This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] S/390: Fix highgprs check in startup code
- From: "Andreas Krebbel" <krebbel at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Cc: jan dot kratochvil at redhat dot com
- Date: Wed, 29 Sep 2010 12:31:56 +0200
- Subject: [PATCH] S/390: Fix highgprs check in startup code
Hi,
the attached patch fixes a problem when doing the high gprs capability
check in the 31 bit startup code.
http://sourceware.org/bugzilla/show_bug.cgi?id=12067
The relocation offset of a binary now is calculated as AT_PHDR -
PT_PHDR.p_vaddr. This then is added to the vaddr of the PT_LOAD
segment with file offset 0 in order to get the location of the elf
header.
No testsuite regressions.
Bye,
-Andreas-
2010-09-29 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
[BZ #12067]
* sysdeps/s390/s390-32/elf/start.S: Fix address calculation when
trying to locate the ELF header.
Index: glibc/sysdeps/s390/s390-32/elf/start.S
===================================================================
--- glibc.orig/sysdeps/s390/s390-32/elf/start.S
+++ glibc/sysdeps/s390/s390-32/elf/start.S
@@ -108,7 +108,7 @@ _start:
jne .L20
cl %r8,4(%r4) /* p_offset == 0? */
jne .L20
- l %r9,8(%r4) /* r9 = p_vaddr <- ELF header address */
+ l %r9,8(%r4) /* r9 = PT_LOAD.p_vaddr <- ELF header address */
j .L24
.L20: alr %r4,%r0 /* r4 += AT_PHENT value */
brct %r12,.L19
@@ -124,16 +124,12 @@ _start:
.L22: alr %r4,%r0 /* r4 += AT_PHENT value */
brct %r12,.L23
- ltr %r9,%r9 /* Load address == 0? */
- jz .L14 /* No checking for PIE without PT_PHDR. */
- j .L21
-
-.L25: clr %r3,%r11 /* PT_PHDR p_vaddr == AT_PHDR? */
- je .L21
- lr %r9,%r11
- slr %r9,%r3 /* elf_header_addr = AT_PHDR - PT_PHDR.p_vaddr */
+ j .L14 /* No PT_PHDR found - skip checking. */
-.L21: l %r5,36(%r9) /* Load the e_flags field. */
+.L25: slr %r11,%r3 /* AT_PHDR - PT_PHDR.p_vaddr (relocation offset)*/
+ alr %r9,%r11 /* PT_LOAD.p_vaddr += relocation offset */
+
+ l %r5,36(%r9) /* Load the e_flags field. */
tml %r5,1
jz .L14 /* Binary does not require highgprs facility. */