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: [patch] PPC small data symbols in shared libraries.


On Wednesday 29 June 2005 20:55, Alan Modra wrote:
> On Wed, Jun 29, 2005 at 05:53:53PM +0100, Paul Brook wrote:
> > We have already created external relocations against _SDA_BASE_. I
> > couldn't
>
> Details?  I'd like to know exactly what is going on.  Some solution
> other than more code in add_symbol_hook might spring to mind.

ppc_elf_adjust_dynamic_symbol allocates space for a copy reloc.
Around line 4130, below the comment
  /* We must generate a R_PPC_COPY reloc to tell the dynamic linker to
     copy the initial value out of the dynamic object and into the

To reproduce the problem (on ppc-linux):

$ cat > foo.c << EOF
int _SDA_BASE_ = 22;
EOF
$ gcc -shared -o foo.so foo.c -nostdlib
$ cat > test.c << EOF
int i=4;
extern char _SDA_BASE_[];
int _start()
{
  i = 42;
  return (int)_SDA_BASE_;
}
EOF
$ gcc -O2 -c test.c
$ ld/ld-new test.o foo.so
$ readelf -r a.out
Relocation section '.rela.dyn' at offset 0x1c8 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00000000  00000000 R_PPC_NONE                                   00000000

Without this patch this is an R_PPC_COPY reloc against _SDA_BASE_, which is 
equally wrong. With add_symbol_hook change we get no relocations in the 
output file (the desired behavior).

Paul


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