|
|
ce426f |
# commit d31beafa8e4ca69faa4cf362784796ef17299341
|
|
|
ce426f |
# Author: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
|
|
|
ce426f |
# Date: Wed Dec 4 06:49:15 2013 -0600
|
|
|
ce426f |
#
|
|
|
ce426f |
# PowerPC64 ELFv2 ABI 1/6: Code refactoring
|
|
|
ce426f |
#
|
|
|
ce426f |
# This is the first patch to support the new ELFv2 ABI in glibc.
|
|
|
ce426f |
#
|
|
|
ce426f |
# As preparation, this patch simply refactors some of the powerpc64 assembler
|
|
|
ce426f |
# code to move all code related to creating function descriptors (.opd section)
|
|
|
ce426f |
# or using function descriptors (function pointer call) into a central place
|
|
|
ce426f |
# in sysdep.h.
|
|
|
ce426f |
#
|
|
|
ce426f |
# Note that most locations creating .opd entries were already using macros
|
|
|
ce426f |
# in sysdep.h, this patch simply extends this to the remaining places.
|
|
|
ce426f |
#
|
|
|
ce426f |
# No relevant change in generated code expected.
|
|
|
ce426f |
#
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S 2014-05-29 13:56:35.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S 2014-05-29 13:56:37.000000000 -0500
|
|
|
ce426f |
@@ -60,18 +60,8 @@
|
|
|
ce426f |
.LC0:
|
|
|
ce426f |
.tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION
|
|
|
ce426f |
#endif
|
|
|
ce426f |
- .type BODY_LABEL (_init), @function
|
|
|
ce426f |
- .globl _init
|
|
|
ce426f |
- .section ".opd", "aw"
|
|
|
ce426f |
- .align 3
|
|
|
ce426f |
-_init: OPD_ENT (_init)
|
|
|
ce426f |
-#ifdef HAVE_ASM_GLOBAL_DOT_NAME
|
|
|
ce426f |
- .globl BODY_LABEL (_init)
|
|
|
ce426f |
- .size _init, 24
|
|
|
ce426f |
-#else
|
|
|
ce426f |
- .type _init, @function
|
|
|
ce426f |
-#endif
|
|
|
ce426f |
.section ".init", "ax", @progbits
|
|
|
ce426f |
+ ENTRY_2(_init)
|
|
|
ce426f |
.align ALIGNARG (2)
|
|
|
ce426f |
BODY_LABEL (_init):
|
|
|
ce426f |
mflr 0
|
|
|
ce426f |
@@ -87,18 +77,8 @@
|
|
|
ce426f |
nop
|
|
|
ce426f |
1:
|
|
|
ce426f |
|
|
|
ce426f |
- .type BODY_LABEL (_fini), @function
|
|
|
ce426f |
- .globl _fini
|
|
|
ce426f |
- .section ".opd", "aw"
|
|
|
ce426f |
- .align 3
|
|
|
ce426f |
-_fini: OPD_ENT (_fini)
|
|
|
ce426f |
-#ifdef HAVE_ASM_GLOBAL_DOT_NAME
|
|
|
ce426f |
- .globl BODY_LABEL (_fini)
|
|
|
ce426f |
- .size _fini, 24
|
|
|
ce426f |
-#else
|
|
|
ce426f |
- .type _fini, @function
|
|
|
ce426f |
-#endif
|
|
|
ce426f |
.section ".fini", "ax", @progbits
|
|
|
ce426f |
+ ENTRY_2(_fini)
|
|
|
ce426f |
.align ALIGNARG (2)
|
|
|
ce426f |
BODY_LABEL (_fini):
|
|
|
ce426f |
mflr 0
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h 2014-05-29 13:56:35.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-machine.h 2014-05-29 13:56:37.000000000 -0500
|
|
|
ce426f |
@@ -122,14 +122,7 @@
|
|
|
ce426f |
#define RTLD_START \
|
|
|
ce426f |
asm (".pushsection \".text\"\n" \
|
|
|
ce426f |
" .align 2\n" \
|
|
|
ce426f |
-" .type " BODY_PREFIX "_start,@function\n" \
|
|
|
ce426f |
-" .pushsection \".opd\",\"aw\"\n" \
|
|
|
ce426f |
-" .align 3\n" \
|
|
|
ce426f |
-" .globl _start\n" \
|
|
|
ce426f |
" " ENTRY_2(_start) "\n" \
|
|
|
ce426f |
-"_start:\n" \
|
|
|
ce426f |
-" " OPD_ENT(_start) "\n" \
|
|
|
ce426f |
-" .popsection\n" \
|
|
|
ce426f |
BODY_PREFIX "_start:\n" \
|
|
|
ce426f |
/* We start with the following on the stack, from top: \
|
|
|
ce426f |
argc (4 bytes); \
|
|
|
ce426f |
@@ -154,11 +147,6 @@
|
|
|
ce426f |
".LT__start_name_end:\n" \
|
|
|
ce426f |
" .align 2\n" \
|
|
|
ce426f |
" " END_2(_start) "\n" \
|
|
|
ce426f |
-" .globl _dl_start_user\n" \
|
|
|
ce426f |
-" .pushsection \".opd\",\"aw\"\n" \
|
|
|
ce426f |
-"_dl_start_user:\n" \
|
|
|
ce426f |
-" " OPD_ENT(_dl_start_user) "\n" \
|
|
|
ce426f |
-" .popsection\n" \
|
|
|
ce426f |
" .pushsection \".toc\",\"aw\"\n" \
|
|
|
ce426f |
DL_STARTING_UP_DEF \
|
|
|
ce426f |
".LC__rtld_local:\n" \
|
|
|
ce426f |
@@ -170,7 +158,6 @@
|
|
|
ce426f |
".LC__dl_fini:\n" \
|
|
|
ce426f |
" .tc _dl_fini[TC],_dl_fini\n" \
|
|
|
ce426f |
" .popsection\n" \
|
|
|
ce426f |
-" .type " BODY_PREFIX "_dl_start_user,@function\n" \
|
|
|
ce426f |
" " ENTRY_2(_dl_start_user) "\n" \
|
|
|
ce426f |
/* Now, we do our main work of calling initialisation procedures. \
|
|
|
ce426f |
The ELF ABI doesn't say anything about parameters for these, \
|
|
|
ce426f |
@@ -228,10 +215,7 @@
|
|
|
ce426f |
/* Now, call the start function descriptor at r30... */ \
|
|
|
ce426f |
" .globl ._dl_main_dispatch\n" \
|
|
|
ce426f |
"._dl_main_dispatch:\n" \
|
|
|
ce426f |
-" ld 0,0(30)\n" \
|
|
|
ce426f |
-" ld 2,8(30)\n" \
|
|
|
ce426f |
-" mtctr 0\n" \
|
|
|
ce426f |
-" ld 11,16(30)\n" \
|
|
|
ce426f |
+" " PPC64_LOAD_FUNCPTR(30) "\n" \
|
|
|
ce426f |
" bctr\n" \
|
|
|
ce426f |
".LT__dl_start_user:\n" \
|
|
|
ce426f |
" .long 0\n" \
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S 2014-05-29 13:56:35.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S 2014-05-29 13:56:37.000000000 -0500
|
|
|
ce426f |
@@ -71,12 +71,8 @@
|
|
|
ce426f |
ld r5,INT_PARMS+16(r1)
|
|
|
ce426f |
ld r4,INT_PARMS+8(r1)
|
|
|
ce426f |
mtcrf 0xFF,r0
|
|
|
ce426f |
-/* Load the target address, toc and static chain reg from the function
|
|
|
ce426f |
- descriptor returned by fixup. */
|
|
|
ce426f |
- ld r0,0(r3)
|
|
|
ce426f |
- ld r2,8(r3)
|
|
|
ce426f |
- mtctr r0
|
|
|
ce426f |
- ld r11,16(r3)
|
|
|
ce426f |
+/* Prepare for calling the function returned by fixup. */
|
|
|
ce426f |
+ PPC64_LOAD_FUNCPTR r3
|
|
|
ce426f |
ld r3,INT_PARMS+0(r1)
|
|
|
ce426f |
/* Unwind the stack frame, and jump. */
|
|
|
ce426f |
addi r1,r1,FRAME_SIZE
|
|
|
ce426f |
@@ -322,13 +318,9 @@
|
|
|
ce426f |
ld r5,INT_PARMS+16(r1)
|
|
|
ce426f |
ld r4,INT_PARMS+8(r1)
|
|
|
ce426f |
mtcrf 0xFF,r0
|
|
|
ce426f |
-/* Load the target address, toc and static chain reg from the function
|
|
|
ce426f |
- descriptor returned by fixup. */
|
|
|
ce426f |
- ld r0,0(r3)
|
|
|
ce426f |
- ld r2,8(r3)
|
|
|
ce426f |
- ld r11,16(r3)
|
|
|
ce426f |
+/* Prepare for calling the function returned by fixup. */
|
|
|
ce426f |
+ PPC64_LOAD_FUNCPTR r3
|
|
|
ce426f |
ld r3,INT_PARMS+0(r1)
|
|
|
ce426f |
- mtctr r0
|
|
|
ce426f |
/* Load the floating point registers. */
|
|
|
ce426f |
lfd fp1,FPR_PARMS+0(r1)
|
|
|
ce426f |
lfd fp2,FPR_PARMS+8(r1)
|
|
|
ce426f |
@@ -386,14 +378,10 @@
|
|
|
ce426f |
ld r5,INT_PARMS+16(r1)
|
|
|
ce426f |
ld r4,INT_PARMS+8(r1)
|
|
|
ce426f |
mtcrf 0xFF,r0
|
|
|
ce426f |
-/* Load the target address, toc and static chain reg from the function
|
|
|
ce426f |
- descriptor returned by fixup. */
|
|
|
ce426f |
- ld r0,0(r3)
|
|
|
ce426f |
+/* Prepare for calling the function returned by fixup. */
|
|
|
ce426f |
std r2,40(r1)
|
|
|
ce426f |
- ld r2,8(r3)
|
|
|
ce426f |
- ld r11,16(r3)
|
|
|
ce426f |
+ PPC64_LOAD_FUNCPTR r3
|
|
|
ce426f |
ld r3,INT_PARMS+0(r1)
|
|
|
ce426f |
- mtctr r0
|
|
|
ce426f |
/* Load the floating point registers. */
|
|
|
ce426f |
lfd fp1,FPR_PARMS+0(r1)
|
|
|
ce426f |
lfd fp2,FPR_PARMS+8(r1)
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h 2014-05-29 13:56:35.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h 2014-05-29 13:56:37.000000000 -0500
|
|
|
ce426f |
@@ -74,6 +74,14 @@
|
|
|
ce426f |
#endif
|
|
|
ce426f |
.endm
|
|
|
ce426f |
|
|
|
ce426f |
+/* Macro to prepare for calling via a function pointer. */
|
|
|
ce426f |
+ .macro PPC64_LOAD_FUNCPTR PTR
|
|
|
ce426f |
+ ld r12,0(\PTR)
|
|
|
ce426f |
+ ld r2,8(\PTR)
|
|
|
ce426f |
+ mtctr r12
|
|
|
ce426f |
+ ld r11,16(\PTR)
|
|
|
ce426f |
+ .endm
|
|
|
ce426f |
+
|
|
|
ce426f |
#ifdef USE_PPC64_OVERLAPPING_OPD
|
|
|
ce426f |
# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase
|
|
|
ce426f |
#else
|
|
|
ce426f |
@@ -81,7 +89,6 @@
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
#define ENTRY_1(name) \
|
|
|
ce426f |
- .section ".text"; \
|
|
|
ce426f |
.type BODY_LABEL(name),@function; \
|
|
|
ce426f |
.globl name; \
|
|
|
ce426f |
.section ".opd","aw"; \
|
|
|
ce426f |
@@ -110,6 +117,7 @@
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
#define ENTRY(name) \
|
|
|
ce426f |
+ .section ".text"; \
|
|
|
ce426f |
ENTRY_2(name) \
|
|
|
ce426f |
.align ALIGNARG(2); \
|
|
|
ce426f |
BODY_LABEL(name): \
|
|
|
ce426f |
@@ -127,6 +135,7 @@
|
|
|
ce426f |
/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
|
|
|
ce426f |
past a 2^alignt boundary. */
|
|
|
ce426f |
#define EALIGN(name, alignt, words) \
|
|
|
ce426f |
+ .section ".text"; \
|
|
|
ce426f |
ENTRY_2(name) \
|
|
|
ce426f |
.align ALIGNARG(alignt); \
|
|
|
ce426f |
EALIGN_W_##words; \
|
|
|
ce426f |
@@ -286,24 +295,42 @@
|
|
|
ce426f |
|
|
|
ce426f |
#else /* !__ASSEMBLER__ */
|
|
|
ce426f |
|
|
|
ce426f |
+#define PPC64_LOAD_FUNCPTR(ptr) \
|
|
|
ce426f |
+ "ld 12,0(" #ptr ");\n" \
|
|
|
ce426f |
+ "ld 2,8(" #ptr ");\n" \
|
|
|
ce426f |
+ "mtctr 12;\n" \
|
|
|
ce426f |
+ "ld 11,16(" #ptr ");"
|
|
|
ce426f |
+
|
|
|
ce426f |
#ifdef USE_PPC64_OVERLAPPING_OPD
|
|
|
ce426f |
# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase;"
|
|
|
ce426f |
#else
|
|
|
ce426f |
# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0;"
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
+#define ENTRY_1(name) \
|
|
|
ce426f |
+ ".type " BODY_PREFIX #name ",@function;\n" \
|
|
|
ce426f |
+ ".globl " #name ";\n" \
|
|
|
ce426f |
+ ".pushsection \".opd\",\"aw\";\n" \
|
|
|
ce426f |
+ ".align 3;\n" \
|
|
|
ce426f |
+#name ":\n" \
|
|
|
ce426f |
+ OPD_ENT (name) "\n" \
|
|
|
ce426f |
+ ".popsection;"
|
|
|
ce426f |
+
|
|
|
ce426f |
#ifdef HAVE_ASM_GLOBAL_DOT_NAME
|
|
|
ce426f |
# define DOT_PREFIX "."
|
|
|
ce426f |
# define BODY_PREFIX "."
|
|
|
ce426f |
# define ENTRY_2(name) \
|
|
|
ce426f |
".globl " BODY_PREFIX #name ";\n" \
|
|
|
ce426f |
+ ENTRY_1(name) "\n" \
|
|
|
ce426f |
".size " #name ", 24;"
|
|
|
ce426f |
# define END_2(name) \
|
|
|
ce426f |
".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
|
|
|
ce426f |
#else
|
|
|
ce426f |
# define DOT_PREFIX ""
|
|
|
ce426f |
# define BODY_PREFIX ".LY"
|
|
|
ce426f |
-# define ENTRY_2(name) ".type " #name ",@function;"
|
|
|
ce426f |
+# define ENTRY_2(name) \
|
|
|
ce426f |
+ ".type " #name ",@function;\n" \
|
|
|
ce426f |
+ ENTRY_1(name)
|
|
|
ce426f |
# define END_2(name) \
|
|
|
ce426f |
".size " #name ",.-" BODY_PREFIX #name ";\n" \
|
|
|
ce426f |
".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S 2014-05-29 13:56:35.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S 2014-05-29 13:56:37.000000000 -0500
|
|
|
ce426f |
@@ -104,9 +104,7 @@
|
|
|
ce426f |
|
|
|
ce426f |
std r2,40(r1)
|
|
|
ce426f |
/* Call procedure. */
|
|
|
ce426f |
- ld r0,0(r30)
|
|
|
ce426f |
- ld r2,8(r30)
|
|
|
ce426f |
- mtctr r0
|
|
|
ce426f |
+ PPC64_LOAD_FUNCPTR r30
|
|
|
ce426f |
mr r3,r31
|
|
|
ce426f |
bctrl
|
|
|
ce426f |
ld r2,40(r1)
|