Is DT_TEXTREL supposed to be supported on s390 31-bit or not?
Martin Schwidefsky
schwidefsky@de.ibm.com
Thu Dec 17 13:56:00 GMT 2009
Hi Jakub,
On Wed, 16 Dec 2009 18:10:23 +0100
Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Dec 16, 2009 at 05:43:54PM +0100, Martin Schwidefsky wrote:
> > On Wed, 16 Dec 2009 16:56:35 +0100
> > Jakub Jelinek <jakub@redhat.com> wrote:
> >
> > > While DT_TEXTREL libraries are clearly unsupported on many architectures and
> > > on some even ld fails to link them, s390 31-bit (unlike 64-bit) DT_TEXTREL
> > > libraries used to work. But apparently only when targetting old CPUs, with
> > > say -march=z900 or newer relocations like R_390_PC32DBL are created and
> > > ld.so (nor prelink) handles them.
> > > So my question is, do we just want to say that DT_TEXTREL on s390 31-bit is
> > > not supported at all, or do we want to handle the relocations that can
> > > appear in -fno-pic 31-bit libraries?
> >
> > DT_TEXTREL on 64-bit is not supported because of weak global symbols and
> > the limitation of the LARL instruction to a 4GB range.
> >
> > DT_TEXTREL on 31-bit used to work fine though and I can't see a reason
> > why it should not work on newer CPUs. With -march=z900 the compiler
> > will use LARL to get the address of global symbols, but the library will
> > be loaded below 4GB. That should work.
>
> If so, can you please figure out what relocations might be needed
> by -m31 -march=z900 (or later) code and add support for those relocs into
> sysdeps/s390/s390-32/dl-machine.h ? R_390_PC32DBL is the only one I've
> noticed during prelink checking, but that doesn't mean it isn't the only
> one.
Ok, I've reproduced the problem. The load of a non-pic library compiled
with -march=z9-109 gives the following error:
error while loading shared libraries: <lib>: unexpected reloc type 0x13
Reloc type 0x13 is indeed R_390_PC32DBL. The 32-bit variant
of dl-machine.h does not handle this relocation which is used to access
global variables for -m31 -march=z9-109. The following patches fixes
the problem for me:
2009-12-17 Martin Schwidefsky <schwidefsky@de.ibm.com>
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela): Handle
R_390_PC32DBL. Remove unneeded R_390_PLT16DBL.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela): Remove
unneeded R_390_PLT16DBL and R_390_PLT32DBL.
--
diff -urpN glibc/sysdeps/s390/s390-32/dl-machine.h glibc-s390/sysdeps/s390/s390-32/dl-machine.h
--- glibc/sysdeps/s390/s390-32/dl-machine.h 2009-12-17 10:48:49.000000000 +0100
+++ glibc-s390/sysdeps/s390/s390-32/dl-machine.h 2009-12-17 10:47:30.000000000 +0100
@@ -389,10 +389,13 @@ elf_machine_rela (struct link_map *map,
*reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
break;
case R_390_PC16DBL:
- case R_390_PLT16DBL:
*(unsigned short *) reloc_addr = (unsigned short)
((short) (value + reloc->r_addend - (Elf32_Addr) reloc_addr) >> 1);
break;
+ case R_390_PC32DBL:
+ *(unsigned int *) reloc_addr = (unsigned int)
+ ((int) (value + reloc->r_addend - (Elf32_Addr) reloc_addr) >> 1);
+ break;
case R_390_PC16:
*(unsigned short *) reloc_addr =
value + reloc->r_addend - (Elf32_Addr) reloc_addr;
diff -urpN glibc/sysdeps/s390/s390-64/dl-machine.h glibc-s390/sysdeps/s390/s390-64/dl-machine.h
--- glibc/sysdeps/s390/s390-64/dl-machine.h 2009-12-17 10:48:49.000000000 +0100
+++ glibc-s390/sysdeps/s390/s390-64/dl-machine.h 2009-12-17 10:47:20.000000000 +0100
@@ -371,7 +371,6 @@ elf_machine_rela (struct link_map *map,
*reloc_addr = value +reloc->r_addend - (Elf64_Addr) reloc_addr;
break;
case R_390_PC32DBL:
- case R_390_PLT32DBL:
*(unsigned int *) reloc_addr = (unsigned int)
((int) (value + reloc->r_addend - (Elf64_Addr) reloc_addr) >> 1);
break;
@@ -380,7 +379,6 @@ elf_machine_rela (struct link_map *map,
value + reloc->r_addend - (Elf64_Addr) reloc_addr;
break;
case R_390_PC16DBL:
- case R_390_PLT16DBL:
*(unsigned short *) reloc_addr = (unsigned short)
((short) (value + reloc->r_addend - (Elf64_Addr) reloc_addr) >> 1);
break;
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
More information about the Libc-alpha
mailing list