[Dwarf-discuss] Question about differentiate instruction address in different sections
Thu Apr 13 05:09:30 GMT 2006
HaiFeng He wrote:
> I'm a new learner of dwarf. In my current project, I'm trying to use dwarf
> to link the instructions in a relocate binary to the corresponding source
> code line number.
> And I choose to use libdwarf to do that.
> are. The addresses listed there are actually the offset to the
> the code section,
> where the instructions locate. I can not find a way to differentiate whether
> an instruction is in .text or .text.init by looking at the address. Anybody
> can help me out?
I believe Jim Blandy has explained the "problem" correctly. A couple
1) Ask David Anderson to "fix" libdwarf...
2) Get an ELF dump of the same relocatable file. It should not be too
hard to find the relocation that goes with the DWARF info and determine
which text section is involved.
3) Try linking just the relocatable into an executable file--and ignore
whatever unresolved symbols are reported. Then run libdwarf on the
executable. Depending on the target OS, the relocations may have been
incorporated into the DWARF info because the .text and .text.init
sections get combined into a single program section. Then the code
offset in the line info will be relative to that. You may need to look
at a symbol definition or three to figure out the relative order of the
section contributions, but it should be possible.
More information about the Dwarf-discuss