I have an ELF file with DWARF debug info. Given a DWARF symbol (say function foo()) I want to find out which ELF section it resides in. I cannot do a PC match against each section's range, because the file has overlay sections, so there are multiple sections with the same mapped address range. In other words, if the symbol lies in one of the overlay sections, its address will match in all of the overlay sections' address ranges.
Thanks in advance for any help.
I don't think there is a way to do this. DWARF just does not encode this information.
gdb requires the user to say which overlays are currently active. I believe this is how it gets this information.