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

Jim Blandy jimb
Thu Apr 13 08:39:57 GMT 2006

On 4/13/06, HaiFeng He <hehaifeng at gmail.com> wrote:
> 3. When I go through the .debug_lines section, if I meet a source location
> which
> is declaration point of a function, I will set the current code section to
> be
> the code section where the fuction belongs to. By doing this, I think I will
> be
> able to know which code section I'm dealing with right now.

This seems fragile, and more work than actually checking the relocs. 
All you need to do is read the .rel.debug_info section, and build a
table sorted by the address the reloc is meant to modify.  Then, when
an address appears in the line number info, check the table to see if
there is a reloc that applies to it.  If there is, that reloc refers
to a symbol, and that symbol refers to a section.

More information about the Dwarf-discuss mailing list