diff options
-rw-r--r-- | libc/sysdeps/linux/powerpc/Makefile | 10 | ||||
-rw-r--r-- | libc/sysdeps/linux/powerpc/crt0.S | 19 |
2 files changed, 26 insertions, 3 deletions
diff --git a/libc/sysdeps/linux/powerpc/Makefile b/libc/sysdeps/linux/powerpc/Makefile index 93f447137..cf8be499e 100644 --- a/libc/sysdeps/linux/powerpc/Makefile +++ b/libc/sysdeps/linux/powerpc/Makefile @@ -22,6 +22,9 @@ ASFLAGS=$(CFLAGS) CRT0_SRC = crt0.S CRT0_OBJ = crt0.o crt1.o +ifeq ($(strip $(UCLIBC_PIE_SUPPORT)),y) +CRT0_OBJ += Scrt0.o Scrt1.o +endif CRT0_DEPS=gmon-start.S CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o @@ -41,6 +44,13 @@ $(LIBC): ar-target ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS) $(AR) $(ARFLAGS) $(LIBC) $(OBJS) cp $(CRT0_OBJ) $(TOPDIR)lib/ +ifeq ($(strip $(UCLIBC_PIE_SUPPORT)),y) +ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) + $(RM) $(TOPDIR)lib/Scrt0.o +else + mv $(TOPDIR)lib/Scrt0.o $(TOPDIR)lib/Scrt1.o +endif +endif $(CRT0_OBJ): $(CRT0_SRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o diff --git a/libc/sysdeps/linux/powerpc/crt0.S b/libc/sysdeps/linux/powerpc/crt0.S index 114ffa093..4538c431d 100644 --- a/libc/sysdeps/linux/powerpc/crt0.S +++ b/libc/sysdeps/linux/powerpc/crt0.S @@ -35,7 +35,7 @@ .section ".text" .globl _start .type _start,@function -#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__ +#if defined L_crt0 || L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__ .type __uClibc_main,%function #else .weak _init @@ -66,16 +66,29 @@ _start: addi r5,r5,1 rlwinm r5,r5,2,0,29 add r5,r5,r4 - +#if defined L_Scrt0 || defined L_Scrt1 + bl _GLOBAL_OFFSET_TABLE_-4@local + mflr r31 +#endif /* Ok, now run uClibc's main() -- shouldn't return */ -#if (defined L_crt1) && defined __UCLIBC_CTOR_DTOR__ +#if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__ +# ifdef L_Scrt1 + lwz r6,_init@got(r31) + lwz r7,_fini@got(r31) + bl __uClibc_start_main@plt +# else lis r6,_init@ha # load top 16 bits addi r6,r6,_init@l # load bottom 16 bits lis r7,_fini@ha # load top 16 bits of &msg addi r7,r7,_fini@l # load bottom 16 bits bl __uClibc_start_main +# endif #else +# ifdef L_Scrt0 + bl __uClibc_main@plt +# else bl __uClibc_main +# endif #endif .size _start,.-_start |