aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/hppa
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@systemhalted.org>2006-09-07 16:34:43 +0000
committerCarlos O'Donell <carlos@systemhalted.org>2006-09-07 16:34:43 +0000
commit0daa050021a9dcc212d47e9ecc584f0610c1b388 (patch)
tree4a351d0a58a39924b7288993e0bf9819b40f1c80 /sysdeps/hppa
parent34cb4e8082506c176b5d8e2d1c7e7175ff3eaffd (diff)
downloadglibc-0daa050021a9dcc212d47e9ecc584f0610c1b388.tar
glibc-0daa050021a9dcc212d47e9ecc584f0610c1b388.tar.gz
glibc-0daa050021a9dcc212d47e9ecc584f0610c1b388.tar.bz2
glibc-0daa050021a9dcc212d47e9ecc584f0610c1b388.zip
2006-09-07 Carlos O'Donell <carlos@systemhalted.org>
* sysdeps/hppa/dl-machine.h (elf_machine_fixup_plt): Remove lvalue cast. * sysdeps/hppa/dl-trampoline.S (_dl_fixup): Correct stack usage. (_dl_runtime_profile): LA fixups. * sysdeps/unix/sysv/linux/hppa/clone.S: Correct stack usage. Return -1 on error. Use branch and link for error handler funciton. * sysdeps/unix/sysv/linux/hppa/sysdep.h: Correct stack usage. Avoid register shuffling. * sysdeps/unix/sysv/linux/hppa/bits/atomic.h (ASM_EAGAIN): Define as -EAGAIN. * sysdeps/unix/sysv/linux/hppa/bits/mman.h: Adjust definitions to match required standards. * sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h (lll_futex_wait): Return __ret. (lll_futex_timed_wait): Likewise. (lll_futex_wake): Likewise. (lll_futex_requeue): Likewise. * sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S: Correct stack usage and adjust error return. * sysdeps/unix/sysv/linux/hppa/nptl/sysdep-cancel.h: Adjust stack usage for gdb, and avoid extra register loads. * sysdeps/unix/sysv/linux/hppa/nptl/unwind-forcedunwind.c: Copy nptl/sysdeps/pthread/unwind-forcedunwind.c. (LIBGCC_SO): Define and use. * sysdeps/unix/sysv/linux/hppa/nptl/unwind-resume.c: Copy nptl/sysdeps/pthread/unwind-resume.c. (LIBGCC_SO): Define and use.
Diffstat (limited to 'sysdeps/hppa')
-rw-r--r--sysdeps/hppa/dl-machine.h5
-rw-r--r--sysdeps/hppa/dl-trampoline.S243
2 files changed, 170 insertions, 78 deletions
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index dd5a28190b..67536c37d7 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -123,12 +123,13 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t,
const Elf32_Rela *reloc,
Elf32_Addr *reloc_addr, struct fdesc value)
{
+ volatile Elf32_Addr *rfdesc = reloc_addr;
/* map is the link_map for the caller, t is the link_map for the object
being called */
- reloc_addr[1] = value.gp;
+ rfdesc[1] = value.gp;
/* Need to ensure that the gp is visible before the code
entry point is updated */
- ((volatile Elf32_Addr *) reloc_addr)[0] = value.ip;
+ rfdesc[0] = value.ip;
return value;
}
diff --git a/sysdeps/hppa/dl-trampoline.S b/sysdeps/hppa/dl-trampoline.S
index c476138ebe..e0d3b9b108 100644
--- a/sysdeps/hppa/dl-trampoline.S
+++ b/sysdeps/hppa/dl-trampoline.S
@@ -1,5 +1,5 @@
/* PLT trampolines. hppa version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,9 +21,9 @@
/* This code gets called via the .plt stub, and is used in
dl-runtime.c to call the `_dl_fixup' function and then redirect
- to the address it returns. `_dl_fixup' takes two
- arguments, however `_dl_profile_fixup' takes a number of
- parameters for use with library auditing (LA).
+ to the address it returns. `_dl_fixup' takes two arguments, however
+ `_dl_profile_fixup' takes a number of parameters for use with
+ library auditing (LA).
WARNING: This template is also used by gcc's __cffc, and expects
that the "bl" for _dl_runtime_resolve exist at a particular offset.
@@ -34,43 +34,46 @@
Enter with r19 = reloc offset, r20 = got-8, r21 = fixup ltp. */
- /* FAKE bl to provide gcc's __cffc with fixup loc. */
+ /* RELOCATION MARKER: bl to provide gcc's __cffc with fixup loc. */
.text
+ /* THIS CODE DOES NOT EXECUTE */
bl _dl_fixup, %r2
.text
- .align 4
.global _dl_runtime_resolve
.type _dl_runtime_resolve,@function
+ cfi_startproc
+ .align 4
_dl_runtime_resolve:
.PROC
.CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=3
.ENTRY
/* SAVE_RP says we do */
- stw %rp, -20(%sp)
+ stw %rp, -20(%sp)
/* Save static link register */
stw %r29,-16(%sp)
- /* Save argument registers in the call stack frame. */
+ /* Save argument registers */
stw %r26,-36(%sp)
stw %r25,-40(%sp)
stw %r24,-44(%sp)
stw %r23,-48(%sp)
/* Build a call frame, and save structure pointer. */
- copy %sp, %r26 /* Copy previous sp */
+ copy %sp, %r1 /* Copy previous sp */
/* Save function result address (on entry) */
stwm %r28,128(%sp)
-
- /* Save floating point argument registers */
- ldo -56(%sp),%r26
- fstd,ma %fr4,-8(%r26)
- fstd,ma %fr5,-8(%r26)
- fstd,ma %fr6,-8(%r26)
- fstd %fr7,0(%r26)
-
/* Fillin some frame info to follow ABI */
+ stw %r1,-4(%sp) /* Previous sp */
stw %r21,-32(%sp) /* PIC register value */
- stw %r26,-4(%sp) /* Previous sp */
+
+ /* Save input floating point registers. This must be done
+ in the new frame since the previous frame doesn't have
+ enough space */
+ ldo -56(%sp),%r1
+ fstd,ma %fr4,-8(%r1)
+ fstd,ma %fr5,-8(%r1)
+ fstd,ma %fr6,-8(%r1)
+ fstd,ma %fr7,-8(%r1)
/* Set up args to fixup func, needs only two arguments */
ldw 8+4(%r20),%r26 /* (1) got[1] == struct link_map */
@@ -81,15 +84,15 @@ _dl_runtime_resolve:
copy %r21,%r19 /* set fixup func ltp */
/* Load up the returned func descriptor */
- copy %ret0, %r22
- copy %ret1, %r19
+ copy %r28, %r22
+ copy %r29, %r19
/* Reload arguments fp args */
- ldo -80(%sp),%r26
- fldd,ma 8(%r26),%fr7
- fldd,ma 8(%r26),%fr6
- fldd,ma 8(%r26),%fr5
- fldd 0(%r26),%fr4
+ ldo -56(%sp),%r1
+ fldd,ma -8(%r1),%fr4
+ fldd,ma -8(%r1),%fr5
+ fldd,ma -8(%r1),%fr6
+ fldd,ma -8(%r1),%fr7
/* Adjust sp, and restore function result address*/
ldwm -128(%sp),%r28
@@ -107,91 +110,179 @@ _dl_runtime_resolve:
ldw -20(%sp),%rp
.EXIT
.PROCEND
+ cfi_endproc
.size _dl_runtime_resolve, . - _dl_runtime_resolve
-
- /* FIXME:
- Need to largely rewrite the bottom half of
- this code in order to save and restore the
- LA struct from the stack along with
- interpreted parameters.
- */
.text
- .align 4
.global _dl_runtime_profile
.type _dl_runtime_profile,@function
+ cfi_startproc
+ .align 4
_dl_runtime_profile:
.PROC
- .CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=3
+ .CALLINFO FRAME=192,CALLS,SAVE_RP,ENTRY_GR=3
.ENTRY
/* SAVE_RP says we do */
- stw %rp, -20(%sp)
-
+ stw %rp, -20(%sp)
/* Save static link register */
stw %r29,-16(%sp)
- /* Save argument registers in the call stack frame. */
- stw %r26,-36(%sp)
- stw %r25,-40(%sp)
- stw %r24,-44(%sp)
- stw %r23,-48(%sp)
/* Build a call frame, and save structure pointer. */
- copy %sp, %r26 /* Copy previous sp */
+ copy %sp, %r1 /* Copy previous sp */
/* Save function result address (on entry) */
- stwm %r28,128(%sp)
-
- /* Save floating point argument registers */
- ldo -56(%sp),%r26
- fstd,ma %fr4,-8(%r26)
- fstd,ma %fr5,-8(%r26)
- fstd,ma %fr6,-8(%r26)
- fstd %fr7,0(%r26)
-
+ stwm %r28,192(%sp)
/* Fillin some frame info to follow ABI */
+ stw %r1,-4(%sp) /* Previous sp */
stw %r21,-32(%sp) /* PIC register value */
- stw %r26,-4(%sp) /* Previous sp */
+
+ /* Create La_hppa_retval */
+ /* -140, lrv_r28
+ -136, lrv_r29
+ -132, 4 byte pad
+ -128, lr_fr4 (8 bytes) */
+
+ /* Create save space for _dl_profile_fixup arguments
+ -120, Saved reloc offset
+ -116, Saved struct link_map
+ -112, *framesizep */
+
+ /* Create La_hppa_regs */
+ /* 32-bit registers */
+ stw %r26,-108(%sp)
+ stw %r25,-104(%sp)
+ stw %r24,-100(%sp)
+ stw %r23,-96(%sp)
+ /* -92, 4 byte pad */
+ /* 64-bit floating point registers */
+ ldo -88(%sp),%r1
+ fstd,ma %fr4,8(%r1)
+ fstd,ma %fr5,8(%r1)
+ fstd,ma %fr6,8(%r1)
+ fstd,ma %fr7,8(%r1)
+ /* 32-bit stack pointer and return register */
+ stw %sp,-56(%sp)
+ stw %r2,-52(%sp)
+
/* Set up args to fixup func, needs five arguments */
ldw 8+4(%r20),%r26 /* (1) got[1] == struct link_map */
+ stw %r26,-116(%sp) /* Save struct link_map */
copy %r19,%r25 /* (2) reloc offset */
+ stw %r25,-120(%sp) /* Save reloc offset */
copy %rp,%r24 /* (3) profile_fixup needs rp */
- copy %r0,%r23 /* (4) regs */
- ldo -56(%sp), %r1
+ ldo -56(%sp),%r23 /* (4) La_hppa_regs */
+ ldo -112(%sp), %r1
stw %r1, -52(%sp) /* (5) long int *framesizep */
/* Call the real address resolver. */
bl _dl_profile_fixup,%rp
copy %r21,%r19 /* set fixup func ltp */
- /* Load up the returned func descriptor */
- copy %ret0, %r22
- copy %ret1, %r19
-
- /* Reload arguments fp args */
- ldo -80(%sp),%r26
- fldd,ma 8(%r26),%fr7
- fldd,ma 8(%r26),%fr6
- fldd,ma 8(%r26),%fr5
- fldd 0(%r26),%fr4
+ /* Load up the returned function descriptor */
+ copy %r28, %r22
+ copy %r29, %r19
+
+ /* Restore gr/fr/sp/rp */
+ ldw -108(%sp),%r26
+ ldw -104(%sp),%r25
+ ldw -100(%sp),%r24
+ ldw -96(%sp),%r23
+ /* -92, 4 byte pad, skip */
+ ldo -88(%sp),%r1
+ fldd,ma 8(%r1),%fr4
+ fldd,ma 8(%r1),%fr5
+ fldd,ma 8(%r1),%fr6
+ fldd,ma 8(%r1),%fr7
+ ldw -52(%sp),%rp
+
+ /* Reload static link register -(192+16) without adjusting stack */
+ ldw -208(%sp),%r29
+
+ /* *framesizep is >= 0 if we have to run pltexit */
+ ldw -112(%sp),%r28
+ cmpb,>>=,N %r0,%r28,L(cpe)
/* Adjust sp, and restore function result address*/
- ldwm -128(%sp),%r28
-
- /* Reload static link register */
- ldw -16(%sp),%r29
- /* Reload general args */
- ldw -36(%sp),%r26
- ldw -40(%sp),%r25
- ldw -44(%sp),%r24
- ldw -48(%sp),%r23
-
+ ldwm -192(%sp),%r28
/* Jump to new function, but return to previous function */
bv %r0(%r22)
ldw -20(%sp),%rp
+ /* NO RETURN */
+
+L(nf):
+ /* Call the returned function descriptor */
+ bv %r0(%r22)
+ nop
+ b,n L(cont)
+
+L(cpe):
+ /* We are going to call the resolved function, but we have a
+ stack frame in the middle. We use the value of framesize to
+ guess how much extra frame we need, and how much frame to
+ copy forward. */
+
+ /* Round to nearest multiple of 64 */
+ addi 63, %r28, %r28
+ depi 0, 27, 6, %r28
+
+ /* Calcualte start of stack copy */
+ ldo -192(%sp),%r2
+
+ /* Increate the stack by *framesizep */
+ copy %sp, %r1
+ add %sp, %r28, %sp
+ /* Save stack pointer */
+ stw %r1, -4(%sp)
+
+ /* Single byte copy of prevous stack onto newly allocated stack */
+1: ldb %r28(%r2), %r1
+ add %r28, %sp, %r26
+ stb %r1, 0(%r26)
+ addi,< -1,%r28,%r28
+ b,n 1b
+
+ /* Retore r28 and r27 and r2 already points at -192(%sp) */
+ ldw 0(%r2),%r28
+ ldw 84(%r2),%r26
+
+ /* Calculate address of L(cont) */
+ b,l L(nf),%r2
+ depwi 0,31,2,%r2
+L(cont):
+ /* Undo fake stack */
+ ldw -4(%sp),%r1
+ copy %r1, %sp
+
+ /* Arguments to _dl_call_pltexit */
+ ldw -116(%sp), %r26 /* (1) got[1] == struct link_map */
+ ldw -120(%sp), %r25 /* (2) reloc offsets */
+ ldo -56(%sp), %r24 /* (3) *La_hppa_regs */
+ ldo -124(%sp), %r23 /* (4) *La_hppa_retval */
+
+ /* Fill *La_hppa_retval */
+ stw %r28,-140(%sp)
+ stw %r29,-136(%sp)
+ ldo -128(%sp), %r1
+ fstd %fr4,0(%r1)
+
+ /* Call _dl_call_pltexit */
+ bl _dl_call_pltexit,%rp
+ nop
+
+ /* Restore *La_hppa_retval */
+ ldw -140(%sp), %r28
+ ldw -136(%sp), %r29
+ ldo -128(%sp), %r1
+ fldd 0(%r1), %fr4
+
+ /* Unwind the stack */
+ ldo 192(%sp),%sp
+ /* Retore callers rp */
+ ldw -20(%sp),%rp
+ /* Return */
+ bv,n 0(%r2)
.EXIT
.PROCEND
.size _dl_runtime_profile, . - _dl_runtime_profile
-
-