This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix ____longjmp_chk for ppc(64)
- From: Andreas Schwab <aschwab at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 24 Jun 2009 14:27:13 +0200
- Subject: Fix ____longjmp_chk for ppc(64)
The ppc32 libc.so contains text relocations due to the non-pic load of
the string in ____longjmp_chk. Also, backtrace from within
__fortify_fail didn't work.
Andreas.
2009-06-24 Andreas Schwab <aschwab@redhat.com>
* sysdeps/powerpc/powerpc32/____longjmp_chk.S (LOAD_ARG): Define.
(CHECK_SP): Use it. Save lr before call.
* sysdeps/powerpc/powerpc64/____longjmp_chk.S (CHECK_SP): Save lr
before call.
diff --git i/sysdeps/powerpc/powerpc32/____longjmp_chk.S w/sysdeps/powerpc/powerpc32/____longjmp_chk.S
index 5c1f648..b358058 100644
--- i/sysdeps/powerpc/powerpc32/____longjmp_chk.S
+++ w/sysdeps/powerpc/powerpc32/____longjmp_chk.S
@@ -26,12 +26,39 @@
#define __longjmp ____longjmp_chk
+#ifdef PIC
+# ifdef HAVE_ASM_PPC_REL16
+# define LOAD_ARG \
+ bcl 20,31,1f; \
+1: mflr r3; \
+ addis r3,r3,_GLOBAL_OFFSET_TABLE_-1b@ha; \
+ addi r3,r3,_GLOBAL_OFFSET_TABLE_-1b@l; \
+ lwz r3,.LC0@got(r3)
+# else
+# define LOAD_ARG \
+ bl _GLOBAL_OFFSET_TABLE_-4@local; \
+ mflr r3; \
+ lwz r3,.LC0@got(r3)
+# endif
+#else
+# define LOAD_ARG \
+ lis r3,.LC0@ha; \
+ la r3,.LC0@l(r3)
+#endif
+
#define CHECK_SP(reg) \
cmplw reg, r1; \
bge+ .Lok; \
- lis r3,.LC0@ha; \
- la r3,.LC0@l(r3); \
+ mflr r0; \
+ stwu r1,-16(r1); \
+ cfi_adjust_cfa_offset (16); \
+ stw r0,20(r1); \
+ cfi_offset (lr, 4); \
+ LOAD_ARG; \
bl HIDDEN_JUMPTARGET (__fortify_fail); \
+ addi r1,r1,16; \
+ cfi_adjust_cfa_offset (-16); \
+ cfi_same_value (lr); \
.Lok:
#include <__longjmp-common.S>
diff --git i/sysdeps/powerpc/powerpc64/____longjmp_chk.S w/sysdeps/powerpc/powerpc64/____longjmp_chk.S
index 5654902..746717c 100644
--- i/sysdeps/powerpc/powerpc64/____longjmp_chk.S
+++ w/sysdeps/powerpc/powerpc64/____longjmp_chk.S
@@ -32,8 +32,16 @@
#define CHECK_SP(reg) \
cmpld reg, r1; \
bge+ .Lok; \
+ mflr r0; \
+ std r0,16(r1); \
+ stdu r1,-112(r1); \
+ cfi_adjust_cfa_offset (112); \
+ cfi_offset (lr, 16); \
ld r3,.LC1@toc(2); \
bl HIDDEN_JUMPTARGET (__fortify_fail); \
+ addi r1,r1,112; \
+ cfi_adjust_cfa_offset (-112); \
+ cfi_same_value (lr); \
.Lok:
#include <__longjmp-common.S>
--
Andreas Schwab, aschwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."