This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dwfl_module_getsym vs. prelink

On Fri, 2013-11-15 at 10:31 -0800, Josh Stone wrote:
> On 11/15/2013 06:01 AM, Mark Wielaard wrote:
> > On Fri, 2013-11-15 at 14:35 +0100, Mark Wielaard wrote:
> >> OK, that is definitely a bug. But I cannot immediately explain why it
> >> worked fine in the -N case and not in the -r case. Except for the
> >> specific load address there should be no difference.
> > 
> > Except that prelink -r doesn't actually do a prelink. In particular it
> > doesn't add a .gnu.prelink_undo section which we look for to create the
> > synchronization address between the main and debug files. See 
> > find_prelink_address_sync() in libdwfl/dwfl_module_getdwarf.c.
> Wow, that's a healthy chunk of code!  But I wonder about this comment:
>   If the main file might have been prelinked, then we need to
>   discover the correct synchronization address between the main and
>   debug files.  Because of prelink's section juggling, we cannot rely
>   on the address_sync computed from PT_LOAD segments (see open_elf).
> For this case without prelink_undo, I think we'll have to fallback on
> just the difference in PT_LOAD segments.  That makes some assumptions,
> but at least it's better than doing nothing at all...

Yes, this works for separate .debug files, which have phdrs which match
up with the main elf file. They are created with eu-strip which copies
over the original phdrs. So the address_sync even without prelink
matches up. But it doesn't work for the minisymtab .gnu_debugdata xz
compressed elf (section) files. They are created with binutils objcopy
which seems to mangle the phdrs. See this comment in
dwfl_module_getdwarf.c (find_aux_sym):

      /* Don't trust the phdrs in the minisymtab elf file to be
         setup correctly.  The address_sync is equal to the main
         file it is embedded in at first.  The shdrs are setup
         OK to make find_prelink_address_sync () do the right
         thing if necessary though.  */

So you really do need a real prelink to match them up if the main elf
file changes the load address. I am not sure what objcopy precisely does
or why it even keeps the phdrs around. But they really do look



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]