[Dwarf-discuss] Question about differentiate instruction address in different sections

HaiFeng He hehaifeng
Thu Apr 13 05:26:40 GMT 2006

Thanks for all the suggestions. After read dwarf document, here is what I'm
planning to do.

1. Find the declare location (file name and lineon) for each function in the

binary. (I'm doing this by traverse all the die entries in dwarf compilation
and search for die that has DWARF_TAG_subprogram)

2. By looking at the symbol table in the binary, I can figure out which
a function belongs to.

3. When I go through the .debug_lines section, if I meet a source location
is declaration point of a function, I will set the current code section to
the code section where the fuction belongs to. By doing this, I think I will
able to know which code section I'm dealing with right now.



On 4/13/06, Ron Brender <ron.brender at charter.net> wrote:
> HaiFeng He wrote:
> > Hi,
> >
> > I'm a new learner of dwarf. In my current project, I'm trying to use
> dwarf
> > information
> > 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
> beginning of
> > 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
> possible solutions:
> 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.
> Good luck,
> Ron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freestandards.org/pipermail/dwarf-discuss/attachments/20060413/dd993fc7/attachment.html

More information about the Dwarf-discuss mailing list