summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crt.s34
-rw-r--r--crti.s11
-rw-r--r--crtn.s8
3 files changed, 53 insertions, 0 deletions
diff --git a/crt.s b/crt.s
new file mode 100644
index 0000000..66e9575
--- /dev/null
+++ b/crt.s
@@ -0,0 +1,34 @@
+
+ .seg ".text"
+
+ .global _start
+
+_start:
+ clr %fp
+
+ orcc 0,%g1,%o0
+ be no_atexit
+ sub %sp,32,%sp
+
+ call atexit
+ nop
+
+no_atexit:
+ sethi %hi _fini,%o0
+ call _init
+ or %o0,%lo _fini,%o0
+
+ ld [%sp+32+64],%o0
+ add 32+68,%sp,%o1
+ sll %o0,2,%o2
+ inc 4,%o2
+ set _environ,%o3
+ call main
+ add %o1,%o2,%o2
+
+ call exit
+ nop
+
+ call _exit
+ nop
+
diff --git a/crti.s b/crti.s
new file mode 100644
index 0000000..6ea6167
--- /dev/null
+++ b/crti.s
@@ -0,0 +1,11 @@
+ .seg ".init"
+ .globl _init
+ .type _init,#function
+_init:
+ save %sp,-96,%sp
+
+ .seg ".fini"
+ .globl _fini
+ .type _fini,#function
+_fini:
+ save %sp,-96,%sp
diff --git a/crtn.s b/crtn.s
new file mode 100644
index 0000000..3af21ef
--- /dev/null
+++ b/crtn.s
@@ -0,0 +1,8 @@
+ .seg ".init"
+ ret
+ restore
+
+ .seg ".fini"
+ ret
+ restore
+