summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/arm/crt1.S
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/arm/crt1.S')
-rw-r--r--libc/sysdeps/linux/arm/crt1.S18
1 files changed, 17 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/arm/crt1.S b/libc/sysdeps/linux/arm/crt1.S
index a1d7f0f23..040ddfd27 100644
--- a/libc/sysdeps/linux/arm/crt1.S
+++ b/libc/sysdeps/linux/arm/crt1.S
@@ -245,7 +245,19 @@ _start:
mov fp, #0
mov lr, #0
-#ifdef __ARCH_USE_MMU__
+#if defined(__ARCH_USE_MMU__) || defined(__UCLIBC_FORMAT_ELF__)
+#ifdef L_rcrt1
+ /* We don't need to save a1 since no dynamic linker should have run */
+ adr a1, .L__ehdr_start_off /* Get address of .L__ehdr_start_off */
+ ldr a2, .L__ehdr_start_off /* Offset from .L__ehdr_start_off to __ehdr_start */
+ add a1, a1, a2 /* Address of __ehdr_start = load addr */
+ bl reloc_static_pie
+ mov a1, #0 /* Clean up a1 so that a random address won't get called at the end of program */
+
+ /* Clear the frame pointer and link register again since it might be modified by previous call */
+ mov fp, #0
+ mov lr, #0
+#endif
/* Pop argc off the stack and save a pointer to argv */
ldr a2, [sp], #4
mov a3, sp
@@ -310,6 +322,10 @@ _start:
.word _init(GOT)
.word main(GOT)
#endif
+#ifdef L_rcrt1
+.L__ehdr_start_off:
+ .word __ehdr_start - .L__ehdr_start_off
+#endif
#endif
/* Define a symbol for the first piece of initialized data. */