libelfin icon indicating copy to clipboard operation
libelfin copied to clipboard

Support for relocation sections

Open paulreimer opened this issue 8 years ago • 4 comments

Hi there,

Awesome library, it worked great and easy to integrate onto my embedded target.

However, I don't see how to read the entries in the relocation sections?

paulreimer avatar Jan 23 '18 18:01 paulreimer

Thanks. I'm glad you like it.

You're right that there's currently no specific support for parsing relocation sections. Patches welcome. :) It should be relatively easy to add generic support for reading the Elf32/64_Rel and Elf32/64_Rela structures. The actual relocation types would be a bit of a chore, since they're spread out across the processor supplements.

aclements avatar Jan 23 '18 20:01 aclements

OK thanks! I was able to get the reloc info by using those structs from Linux elf.h header. I wasn't sure how to select the right struct (rel vs rela) other than by comparing entsize to sizeof(Elf32_Rela) but I suspect there is a better way and/or hoped this library could do that. As to the various reloc types, I can handle that. But it would be nice to have some sort of iterator over reloc sections, with the right type of reloc struct (or other way of having access to the fields).

paulreimer avatar Jan 23 '18 20:01 paulreimer

I wasn't sure how to select the right struct (rel vs rela) other than by comparing entsize to sizeof(Elf32_Rela) but I suspect there is a better way and/or hoped this library could do that.

The Shdr.type field will be either sht::rel or sht::rela depending on which relocation type it contains. Using the entsize should work too, but Shdr.type is probably more reliable. I've never really figured out what entsize is good for, so it wouldn't surprise me if some tools get it wrong. :)

aclements avatar Jan 23 '18 20:01 aclements

Has there been any development on this? I would also like this feature, and can work on it if development has been dropped

deadly-platypus avatar Aug 29 '19 18:08 deadly-platypus