diff options
author | linted <linted@users.noreply.github.com> | 2022-07-16 16:23:45 -0400 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2022-08-08 14:51:00 +0200 |
commit | 3e14288eaaf62124d090b5225665632e1fe5d47c (patch) | |
tree | ff7061c4a5ef94b3db1de9728f36c7e0ae4877f1 /libc | |
parent | 52b67ddcf6086f2d385e1e8c1784645807a8d9b6 (diff) |
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>
Diffstat (limited to 'libc')
-rw-r--r-- | libc/misc/internals/Makefile.in | 2 | ||||
-rw-r--r-- | libc/sysdeps/linux/aarch64/crt1.S | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in index 4a6e73d2d..69af8b76e 100644 --- a/libc/misc/internals/Makefile.in +++ b/libc/misc/internals/Makefile.in @@ -17,7 +17,7 @@ MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC-y)) MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC-y)) CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS) - +CFLAGS-reloc_static_pie.c := $(SSP_DISABLE_FLAGS) libc-y += $(MISC_INTERNALS_OBJ) ifneq ($(UCLIBC_FORMAT_SHARED_FLAT),y) diff --git a/libc/sysdeps/linux/aarch64/crt1.S b/libc/sysdeps/linux/aarch64/crt1.S index 09d0327ac..e9f946894 100644 --- a/libc/sysdeps/linux/aarch64/crt1.S +++ b/libc/sysdeps/linux/aarch64/crt1.S @@ -48,6 +48,20 @@ _start: mov x29, #0 mov x30, #0 +#ifdef L_rcrt1 + /* Save off the atexit pointer */ + mov x19, x0 + + /* Calculate load address... idk how this works, but it does */ + adrp x0, _start + + /* Do relocations */ + bl reloc_static_pie + + /* restore atexit pointer */ + mov x0, x19 +#endif + /* Setup _fini in argument register */ mov x5, x0 |