This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PPC relocs in shared libraries
On Fri, Sep 27, 2002 at 02:44:37PM +0930, Alan Modra wrote:
> On Thu, Sep 26, 2002 at 03:39:00PM -0400, Daniel Jacobowitz wrote:
> > So we're looking at RELA sections. RELA does not use the in-section
> > data, does it?
>
> RELA relocs shouldn't, but see eg. current glibc
> sysdeps/ia64/dl-machine.h:elf_machine_rela_relative :-(
Aha. Looks like prelinker stuff, I see...
> > But readelf goes on to do:
> >
> > compunit.cu_abbrev_offset += rp->r_addend;
> >
> > Which then will apply the value twice, or to garbage, depending on what
> > version of binutils you happen to be using. So I fixed that in my
> > local copy.
>
> Needs committing. :)
I'd change the code again in a day or two anyway. I'll post a patch to
properly relocate sections in readelf, which'll avoid that hokey loop.
> > Then there are dozens of other places in readelf which do not apply
> > relocations. GDB doesn't do it either unless you have a patch I
> > haven't finished cleaning up yet (first posted four or five months ago,
> > and I got busy elsewhere). So I get things like this:
> >
> > - DW_AT_stmt_list : 0
> > - DW_AT_high_pc : 0x24 36
> > - DW_AT_low_pc : 0 0
> > + DW_AT_stmt_list : 142
> > + DW_AT_high_pc : 0x1a04 6660
> > + DW_AT_low_pc : 0x19e0 6624
> >
> > - Extended opcode 2: set Address to 0x0
> > + Extended opcode 2: set Address to 0x182c
> >
> > These two have the same relocations; one happens to write the relocated
> > values into the section and the other doesn't.
>
> A consequence of section contents being ignored for RELA relocs.
>
> Note that there is one good reason to apply the reloc to the
> section contents as well as emitting a reloc and that is glibc's
> ELF_MACHINE_REL_RELATIVE optimization. Prior to seeing that one
> I was inclined to say the section contents should be left at zero.
> Not that this is particularly relevant to debug sections.
It's pretty nice for GDB too. But GDB needs to handle either way, so
it doesn't really care.
> > So: Do we require full relocation processing on debug sections? If so,
> > I'm going to need to finish up the patch to provide an easy way for a
> > client like readelf to relocate a section reliably. At present we
> > don't implement this relocation except for the location of the abbrev
> > table.
> >
> > Also, should this code be supporting REL relocations? Or do the
> > DWARF-2 sections always have RELA for some reason?
>
> Well, x86 is REL and current gcc seems to support -gdwarf-2 on x86.
Yes. Figured it out, though:
- x86 disagrees with PPC about emitting relocations for the
.debug_info section in shared libraries - they're resolved
fully and not emitted.
- For object files, the only relocations in .debug_* are against
section symbols, so the only thing that matters is their offset
from 0. We're REL, so this is stored directly in the object file.
Everything works.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer