リビジョン | 9e854172e249a383d858fef70368af63a04a28a8 (tree) |
---|---|
日時 | 2022-10-14 16:47:14 |
作者 | linted <linted@user...> |
コミッター | Waldemar Brodkorb |
Static pie support for ppc
Modified config files and crt1.S to support static pie elf generation.
Signed-off-by: linted <linted@users.noreply.github.com>
@@ -326,7 +326,7 @@ config STATIC_PIE | ||
326 | 326 | default n |
327 | 327 | depends on DOPIC && !UCLIBC_FORMAT_FDPIC_ELF && \ |
328 | 328 | (TARGET_arm || TARGET_i386 || TARGET_x86_64 || TARGET_aarch64 || \ |
329 | - TARGET_mips || TARGET_xtensa) | |
329 | + TARGET_mips || TARGET_xtensa || TARGET_powerpc) | |
330 | 330 | |
331 | 331 | config ARCH_HAS_NO_SHARED |
332 | 332 | bool |
@@ -41,6 +41,9 @@ | ||
41 | 41 | .weak _init |
42 | 42 | .weak _fini |
43 | 43 | #endif |
44 | +#ifdef L_rcrt1 | |
45 | + .type reloc_static_pie,%function | |
46 | +#endif | |
44 | 47 | .type main,%function |
45 | 48 | .type __uClibc_main,%function |
46 | 49 |
@@ -61,6 +64,22 @@ _start: | ||
61 | 64 | # ifdef PPC_HAS_SECUREPLT |
62 | 65 | mr 30,31 |
63 | 66 | # endif |
67 | +#ifdef L_rcrt1 | |
68 | + stwu r3, -4(r1) /* Save r3 */ | |
69 | + stwu r9, -16(r1) /* Save r9 */ | |
70 | + bcl 20,31,2f /* Jump to label 2 */ | |
71 | +2: mflr r3 /* Load lr into r3 */ | |
72 | + addis r3, r3, _DYNAMIC-2b@ha /* Add high half of _DYNAMIC to r3 */ | |
73 | + addi r3,r3,_DYNAMIC-2b@l /* Add low half of _DYNAMIC */ | |
74 | + lwz r4, 0(r31) /* load _DYNAMIC from the GOT */ | |
75 | + subf r3, r4, r3 /* sub _DYNAMIC@got and it's actual address */ | |
76 | + bl reloc_static_pie /* Call reloc_static_pie */ | |
77 | + lwzu r9, 0(r1) /* restore r9 */ | |
78 | + addi r1, r1, 16 /* update stack pointer */ | |
79 | + lwzu r3, 0(r1) /* restore r3 */ | |
80 | + addi r1, r1, 4 /* update stack pointer */ | |
81 | + li r5, 0 /* zero r5 */ | |
82 | +#endif | |
64 | 83 | #endif |
65 | 84 | /* Set up the small data pointer in r13. */ |
66 | 85 | #ifdef __PIC__ |