修訂 | 3e14288eaaf62124d090b5225665632e1fe5d47c (tree) |
---|---|
時間 | 2022-08-08 21:51:00 |
作者 | linted <linted@user...> |
Commiter | Waldemar Brodkorb |
Added support for creation of Static Position-Independent Executables (PIE) on aarch64
Updated config to allow compilation of rcrt1.o for aarch64 and modified it's crt1.S to relocate dynamic section prior to uClibc_main.
Disabled stack protector when compiling reloc_static_pie.c to avoid TLS access prior to it being setup.
Signed-off-by: linted <linted@users.noreply.github.com>
@@ -304,7 +304,7 @@ config DOPIC | ||
304 | 304 | config STATIC_PIE |
305 | 305 | bool "Add support for Static Position Independent Executables (PIE)" |
306 | 306 | default n |
307 | - depends on DOPIC && !UCLIBC_FORMAT_FDPIC_ELF && (TARGET_arm || TARGET_i386 || TARGET_x86_64) | |
307 | + depends on DOPIC && !UCLIBC_FORMAT_FDPIC_ELF && (TARGET_arm || TARGET_i386 || TARGET_x86_64 || TARGET_aarch64) | |
308 | 308 | |
309 | 309 | config ARCH_HAS_NO_SHARED |
310 | 310 | bool |
@@ -17,7 +17,7 @@ MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC-y)) | ||
17 | 17 | MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC-y)) |
18 | 18 | |
19 | 19 | CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS) |
20 | - | |
20 | +CFLAGS-reloc_static_pie.c := $(SSP_DISABLE_FLAGS) | |
21 | 21 | |
22 | 22 | libc-y += $(MISC_INTERNALS_OBJ) |
23 | 23 | ifneq ($(UCLIBC_FORMAT_SHARED_FLAT),y) |
@@ -48,6 +48,20 @@ _start: | ||
48 | 48 | mov x29, #0 |
49 | 49 | mov x30, #0 |
50 | 50 | |
51 | +#ifdef L_rcrt1 | |
52 | + /* Save off the atexit pointer */ | |
53 | + mov x19, x0 | |
54 | + | |
55 | + /* Calculate load address... idk how this works, but it does */ | |
56 | + adrp x0, _start | |
57 | + | |
58 | + /* Do relocations */ | |
59 | + bl reloc_static_pie | |
60 | + | |
61 | + /* restore atexit pointer */ | |
62 | + mov x0, x19 | |
63 | +#endif | |
64 | + | |
51 | 65 | /* Setup _fini in argument register */ |
52 | 66 | mov x5, x0 |
53 | 67 |