-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing DWARF in .o files #564
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.o files are superficially ELF (with
e_type
set toET_REL
), but unlike executables and shared libraries, they are allowed to contain multiple sections with the same name. With that in mind, the normal pyelftools' logic of pulling DWARF by finding the section with a given name breaks down.Also, trying to load them with relocations enabled gives errors aplenty. Also because there can be multiple relocation sections with a given name and an arbitrary order; the first
.rel.debug_info
in a file doesn't have to correspond to the first.debug_info
. In object files,sh_info
of a rel/rela section is expected to contain the index of the section it applies to. In linked binaries, this doesn't hold.I'm looking at
pletoh.o
withinstm32wb_zigbee_wb_lib.a
as downloaded from here. That file contains:Regarding the way they are interlinked:
When it comes to dumping, readelf observes the section boundaries. So, for example, when dumping info, it goes:
for as many sections as there are. The section header doesn't indicate neither the offset nor the index of the section - its order in the binary is the only thing to go by.
This can be theoretically accommodated in the API by concatenating the info sections for parsing, but keeping section index somewhere in the CU data structure.
That all said, I don't know how prominent this file structure is in the grand scheme of things. Does GCC or LLVM emit objects like that? This is all the output of ARM's IAR compiler.
The text was updated successfully, but these errors were encountered: