This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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: Relocation bug


On Mon, Feb 24, 2003 at 02:34:25PM +1030, Alan Modra wrote:

> On Sun, Feb 23, 2003 at 04:53:11PM +0100, Ralf Baechle wrote:
> > Correct linker:
> > 
> > [ralf at dea b0rked]$ mips-linux-objdump --full-contents --section=.data s.so 
> > 
> > s.so:     file format elf32-tradbigmips
> > 
> > Contents of section .data:
> >  40410 00041644 00000000 00000000 00000000  ...D............
> >        ^^^^^^^^
> > 
> > Which is the address of .data plus 0x1234.
> 
> Hmm, if you do this then I think you should be using symbol index zero
> in the relocation too.

I believe you're right, this is a little bug, too.

(Something else to do for my MIPS ELF fixup program I wrote last night ...)

But in case of a properly working linker I believe it's just of cosmetic
effect due to the way that local symbols are supposed to be processed per
ABI:

  R_MIPS_32      2 T word32 local    S + A

... which are then converted to R_MIPS_REL32 relocs in the DSO:

  R_MIPS_REL32   3 T word32 local    A - EA + S

Where the S operand in both cases is defined as:

  S Represents the value of the symbol whose index resides in the relocation
    entry, unless the the symbol is STB_LOCAL and is of type STT_SECTION in
    which case S represents the final sh_addr minus the original sh_addr.

So for local relocations which is STB_LOCAL and STT_SECTION such as above
the processing effectively comes down to the same as having symbol index
zero that when loading the DSO just the load displacement needs to be added.

Anyway I think you poked my nose at something interesting.  All flavours
of the GNU libc dynamic linker I know of are properly treating R_MIPS_REL32
with a symbol index of zero.  I've not checked the BSDs but I bet it's the
same there.  That opens an elegant way out of how to fix the relocation
thing with as little breaking of binaries as possible.  Fix binutils to emit
the relocs with symbol index zero and the difference between old binaries
and current binaries will eventually fade away - without touching dynamic
linkers.

  Ralf


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