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]

R_PPC_REL24 relocation in shared libraries


Hi,

the linker does allow R_PPC_REL24 relocations in shared libraries. These
relocs come from object files compiled without -fPIC. Code compiled
without -fPIC is not supposed to work in shared libraries. I think that
is true for every *-linux* architecture, but I'm mainly concerned about
powerpc-linux.

I cooked this patch:

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.68
diff -p -u -r1.68 elf32-ppc.c
--- bfd/elf32-ppc.c     20 Feb 2003 09:10:18 -0000      1.68
+++ bfd/elf32-ppc.c     23 Feb 2003 12:39:21 -0000
@@ -4943,6 +4943,13 @@ ppc_elf_relocate_section (output_bfd, in
          goto dodyn;
 
        case R_PPC_REL24:
+         if (info->shared) {
+               fprintf(stderr, "The target `%s' has a %s relocation, that means '%s' was compiled without -fPIC.\n",
+                                      sym_name,
+                                      howto->name,
+                                      bfd_archive_filename (input_bfd));
+               ret = FALSE;
+               }
        case R_PPC_REL32:
        case R_PPC_REL14:
        case R_PPC_REL14_BRTAKEN:


However, make check fails now for ld:

grep ^FAIL ./ld/ld.log
FAIL: vers1
FAIL: vers2
FAIL: vers3
FAIL: vers6
FAIL: vers8
FAIL: visibility (hidden) (non PIC)
FAIL: visibility (hidden) (non PIC, load offset)
FAIL: visibility (hidden) (PIC main, non PIC so)
FAIL: visibility (hidden_normal) (non PIC)
FAIL: visibility (hidden_normal) (PIC main, non PIC so)
FAIL: visibility (hidden_undef_def) (non PIC)
FAIL: visibility (hidden_undef_def) (non PIC, load offset)
FAIL: visibility (hidden_undef_def) (PIC main, non PIC so)
FAIL: visibility (protected) (non PIC)
FAIL: visibility (protected) (PIC main, non PIC so)
FAIL: visibility (protected_undef_def) (non PIC)
FAIL: visibility (protected_undef_def) (PIC main, non PIC so)
FAIL: visibility (normal) (non PIC)
FAIL: visibility (normal) (PIC main, non PIC so)
FAIL: ELF weak
FAIL: TLS32 shared
FAIL: shared (non PIC)
FAIL: shared (PIC main, non PIC so)

The surpise, even the shared lib test is compiled without -fPIC. Why?

grep tls32.[so] ld/ld.log 
/home/olaf/binutils/ld/../gas/as-new   -o tmpdir/tls32.o -a32 /tmp/binutils-head/src/ld/testsuite/ld-powerpc/tls32.s
/home/olaf/binutils/ld/ld-new  -o tmpdir/tls32 -L/tmp/binutils-head/src/ld/testsuite/ld-powerpc -melf32ppc tmpdir/tls32.o tmpdir/tlslib32.o
/home/olaf/binutils/ld/ld-new  -o tmpdir/tlsexe32 -L/tmp/binutils-head/src/ld/testsuite/ld-powerpc -melf32ppc tmpdir/tls32.o tmpdir/libtlslib32.so 
/home/olaf/binutils/ld/ld-new  -o tmpdir/tls32.so -L/tmp/binutils-head/src/ld/testsuite/ld-powerpc -shared -melf32ppc tmpdir/tls32.o 
The target `__tls_get_addr' has a R_PPC_REL24 relocation, that means 'tmpdir/tls32.o' was compiled without -fPIC.
The target `__tls_get_addr' has a R_PPC_REL24 relocation, that means 'tmpdir/tls32.o' was compiled without -fPIC.
The target `__tls_get_addr' has a R_PPC_REL24 relocation, that means 'tmpdir/tls32.o' was compiled without -fPIC.
The target `__tls_get_addr' has a R_PPC_REL24 relocation, that means 'tmpdir/tls32.o' was compiled without -fPIC.

Linking to non-PIC objects is supposed to work:

gcc -L/home/olaf/binutils/ld -g -O2  -B/home/olaf/binutils/ld/tmpdir/gas/ -I/tmp/binutils-head/src/ld/testsuite/ld-shared -g -O2  -c /tmp/binutils-head/src/ld/testsuite/ld-shared/sh1.c -o tmpdir/sh1np.o
gcc -L/home/olaf/binutils/ld -g -O2  -B/home/olaf/binutils/ld/tmpdir/gas/ -I/tmp/binutils-head/src/ld/testsuite/ld-shared -g -O2  -c /tmp/binutils-head/src/ld/testsuite/ld-shared/sh2.c -o tmpdir/sh2np.o
/home/olaf/binutils/ld/ld-new  -o tmpdir/shmpnp.so -shared  tmpdir/sh1np.o tmpdir/sh2np.o
The target `shlib_shlibcalled' has a R_PPC_REL24 relocation, that means 'tmpdir/sh1np.o' was compiled without -fPIC.
The target `shlib_overriddencall2' has a R_PPC_REL24 relocation, that means 'tmpdir/sh1np.o' was compiled without -fPIC.
The target `main_called' has a R_PPC_REL24 relocation, that means 'tmpdir/sh1np.o' was compiled without -fPIC.
The target `shlib_shlibvar1' has a R_PPC_REL24 relocation, that means 'tmpdir/sh1np.o' was compiled without -fPIC.
FAIL: shared (PIC main, non PIC so)




Do I expect something wrong, or is the testsuite buggy?


Gruss Olaf

-- 
A: No.
Q: Should I include quotations after my reply?


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