mirror of git://git.musl-libc.org/musl
remove hand-written crt1.s and Scrt1.s files for all archs
since commit c5e34dabbb
, crt1.c has
provided a "mostly-C" implementation of the crt1 start file that
avoids the need for arch-specific symbol referencing, PIC/PIE-specific
code variants, etc. but for archs that had existing hand-written
versions, the new code was initially unused, and later only used as
the dynamic linker entry point. this commit switches all archs to
using the new code.
the code being removed was a recurring source of subtle errors, and
was still broken at least on arm, where it failed to properly align
the stack pointer before calling into C code.
This commit is contained in:
parent
4e6b8eee77
commit
6fef8cafbd
|
@ -1,30 +0,0 @@
|
|||
.weak _init
|
||||
.weak _fini
|
||||
.global _start
|
||||
_start:
|
||||
mov fp,#0
|
||||
mov lr,#0
|
||||
|
||||
ldr a2,[sp],#4
|
||||
mov a3,sp
|
||||
str fp,[sp,#-4]!
|
||||
str a1,[sp,#-4]!
|
||||
|
||||
adr ip,2f
|
||||
ldr a4,2f+4
|
||||
add a4,a4,ip
|
||||
str a4,[sp,#-4]!
|
||||
ldr a4,2f+8
|
||||
add a4,a4,ip
|
||||
|
||||
ldr a1,2f
|
||||
add ip,ip,a1
|
||||
ldr a1,2f+12
|
||||
ldr a1,[ip,a1]
|
||||
|
||||
bl __libc_start_main(PLT)
|
||||
1: b 1b
|
||||
2: .word _GLOBAL_OFFSET_TABLE_-2b
|
||||
.word _fini-2b
|
||||
.word _init-2b
|
||||
.word main(GOT)
|
|
@ -1,17 +0,0 @@
|
|||
.weak _init
|
||||
.weak _fini
|
||||
.global _start
|
||||
.type _start,%function
|
||||
_start:
|
||||
mov fp,#0
|
||||
mov lr,#0
|
||||
ldr a2,[sp],#4
|
||||
mov a3,sp
|
||||
ldr a4,=_fini
|
||||
str fp,[sp,#-4]!
|
||||
str a1,[sp,#-4]!
|
||||
str a4,[sp,#-4]!
|
||||
ldr a4,=_init
|
||||
ldr a1,=main
|
||||
bl __libc_start_main
|
||||
1: b 1b
|
|
@ -1,24 +0,0 @@
|
|||
.weak _init
|
||||
.weak _fini
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
xor %ebp,%ebp
|
||||
pop %ecx
|
||||
mov %esp,%eax
|
||||
and $-16,%esp
|
||||
push %esp
|
||||
push %esp
|
||||
push %edx
|
||||
call 1f
|
||||
1: addl $_GLOBAL_OFFSET_TABLE_,(%esp)
|
||||
pop %ebx
|
||||
call 1f
|
||||
1: addl $[_fini-.],(%esp)
|
||||
call 1f
|
||||
1: addl $[_init-.],(%esp)
|
||||
push %eax
|
||||
push %ecx
|
||||
push main@GOT(%ebx)
|
||||
call __libc_start_main@plt
|
||||
1: jmp 1b
|
|
@ -1,19 +0,0 @@
|
|||
.weak _init
|
||||
.weak _fini
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
xor %ebp,%ebp
|
||||
pop %ecx
|
||||
mov %esp,%eax
|
||||
and $-16,%esp
|
||||
push %esp
|
||||
push %esp
|
||||
push %edx
|
||||
push $_fini
|
||||
push $_init
|
||||
push %eax
|
||||
push %ecx
|
||||
push $main
|
||||
call __libc_start_main
|
||||
1: jmp 1b
|
|
@ -1,16 +0,0 @@
|
|||
.weak _init
|
||||
.weak _fini
|
||||
.global _start
|
||||
.align 2
|
||||
_start:
|
||||
add r19, r0, r0 # Zero the frame pointer.
|
||||
ori r5, r0, main # Get main() ...
|
||||
lw r6, r0, r1 # Get argc...
|
||||
addi r7, r1, 4 # ... and argv ...
|
||||
ori r8, r0, _init # and _init() ...
|
||||
ori r9, r0, _fini # and _fini() ...
|
||||
add r10, r0, r0 # ldso_fini == NULL
|
||||
andi r1, r1, -8 # align stack
|
||||
addik r1, r1, -4*6 # Leave space for the args.
|
||||
bri __libc_start_main # Let's go!
|
||||
nop # Never gets here.
|
|
@ -1,28 +0,0 @@
|
|||
.set noreorder
|
||||
|
||||
.weak _init
|
||||
.weak _fini
|
||||
.global __start
|
||||
.global _start
|
||||
.type __start,@function
|
||||
.type _start,@function
|
||||
__start:
|
||||
_start:
|
||||
subu $fp, $fp, $fp # Zero the frame pointer.
|
||||
lui $gp, %hi(_gp)
|
||||
addi $gp, %lo(_gp)
|
||||
#la $gp, _gp
|
||||
lw $4, %call16(main)($gp) # Get main() ...
|
||||
lw $5, ($sp) # Get argc...
|
||||
addu $6, $sp, 4 # and argv ...
|
||||
lw $7, %call16(_init)($gp) # and _init() ...
|
||||
and $sp, $sp, -8 # Align the stack pointer to 8 bytes
|
||||
addi $sp, $sp, -4*6 # Leave space for arguments 0..3, arg4, and arg5.
|
||||
lw $12, %call16(_fini)($gp) # and _fini() ...
|
||||
sw $12, 4*4($sp) # Save arg4.
|
||||
sw $0, 4*5($sp) # ldso_fini == NULL
|
||||
lw $25, %call16(__libc_start_main)($gp)
|
||||
jalr $25 # Let's go!
|
||||
nop
|
||||
b . # Never gets here.
|
||||
nop
|
|
@ -1,26 +0,0 @@
|
|||
.weak _init
|
||||
.weak _fini
|
||||
.global _start
|
||||
.type _start, %function
|
||||
_start:
|
||||
mr 9, 1 # Save the original stack pointer.
|
||||
clrrwi 1, 1, 4 # Align the stack to 16 bytes.
|
||||
lis 13, _SDA_BASE_@ha # r13 points to the small data area.
|
||||
addi 13, 13, _SDA_BASE_@l
|
||||
li 0, 0 # Zero the frame pointer.
|
||||
stwu 1, -16(1) # The initial stack frame.
|
||||
mtlr 0 # Clear the link register.
|
||||
stw 0, 0(1) # And save it.
|
||||
lis 3, main@ha # Get main() ...
|
||||
addi 3, 3, main@l
|
||||
lwz 4, 0(9) # and argc...
|
||||
addi 5, 9, 4 # and argv ...
|
||||
lis 6, _init@ha # and _init() ...
|
||||
addi 6, 6, _init@l
|
||||
lis 7, _fini@ha # and _fini() ...
|
||||
addi 7, 7, _fini@l
|
||||
li 8, 0 # ldso_fini == NULL
|
||||
bl __libc_start_main # Let's go!
|
||||
b . # Never gets here.
|
||||
.end _start
|
||||
.size _start, .-_start
|
|
@ -1,16 +0,0 @@
|
|||
/* Written 2011 Nicholas J. Kain, released as Public Domain */
|
||||
.weak _init
|
||||
.weak _fini
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
xor %rbp,%rbp /* rbp:undefined -> mark as zero 0 (ABI) */
|
||||
mov %rdx,%r9 /* 6th arg: ptr to register with atexit() */
|
||||
pop %rsi /* 2nd arg: argc */
|
||||
mov %rsp,%rdx /* 3rd arg: argv */
|
||||
andq $-16,%rsp /* align stack pointer */
|
||||
lea _fini(%rip),%r8 /* 5th arg: fini/dtors function */
|
||||
lea _init(%rip),%rcx /* 4th arg: init/ctors function */
|
||||
mov main@GOTPCREL(%rip),%rdi /* 1st arg: application entry ip */
|
||||
call __libc_start_main@PLT /* musl init will run the program */
|
||||
1: jmp 1b
|
|
@ -1,16 +0,0 @@
|
|||
/* Written 2011 Nicholas J. Kain, released as Public Domain */
|
||||
.weak _init
|
||||
.weak _fini
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
xor %rbp,%rbp /* rbp:undefined -> mark as zero 0 (ABI) */
|
||||
mov %rdx,%r9 /* 6th arg: ptr to register with atexit() */
|
||||
pop %rsi /* 2nd arg: argc */
|
||||
mov %rsp,%rdx /* 3rd arg: argv */
|
||||
andq $-16,%rsp /* align stack pointer */
|
||||
mov $_fini,%r8 /* 5th arg: fini/dtors function */
|
||||
mov $_init,%rcx /* 4th arg: init/ctors function */
|
||||
mov $main,%rdi /* 1st arg: application entry ip */
|
||||
call __libc_start_main /* musl init will run the program */
|
||||
1: jmp 1b
|
Loading…
Reference in New Issue