summaryrefslogtreecommitdiff
path: root/crt
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-05-02 21:14:41 -0400
committerRich Felker <dalias@aerifal.cx>2012-05-02 21:14:41 -0400
commit94167cafd5a8f4f8309c3f82f5bda17f4767cb60 (patch)
tree2e24c9b532d578cd625b6204bf078441ea80add5 /crt
parentfaab12bececc03ae0472db99504b0fefc0b8e059 (diff)
downloadmusl-94167cafd5a8f4f8309c3f82f5bda17f4767cb60.tar.gz
musl-94167cafd5a8f4f8309c3f82f5bda17f4767cb60.tar.bz2
musl-94167cafd5a8f4f8309c3f82f5bda17f4767cb60.tar.xz
musl-94167cafd5a8f4f8309c3f82f5bda17f4767cb60.zip
PIE support for x86_64 (untested)
Diffstat (limited to 'crt')
-rw-r--r--crt/x86_64/Scrt1.s18
1 files changed, 18 insertions, 0 deletions
diff --git a/crt/x86_64/Scrt1.s b/crt/x86_64/Scrt1.s
new file mode 100644
index 00000000..d8b71617
--- /dev/null
+++ b/crt/x86_64/Scrt1.s
@@ -0,0 +1,18 @@
+/* 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 */
+ 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