mirror of
https://git.musl-libc.org/git/musl
synced 2025-02-10 07:14:15 +03:00
4ce3cb5cdd
this is mainly in hopes of supporting c++ (not yet possible for other reasons) but will also help applications/libraries which use (and more often, abuse) the gcc __attribute__((__constructor__)) feature in "C" code. x86_64 and arm versions of the new startup asm are untested and may have minor problems.
19 lines
690 B
ArmAsm
19 lines
690 B
ArmAsm
/* 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 */
|
|
push %rax /* 8th arg: glibc ABI compatible */
|
|
push %rsp /* 7th arg: glibc ABI compatible */
|
|
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
|