summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sparc/crt0.S
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-05-04 17:03:47 +0000
committerEric Andersen <andersen@codepoet.org>2001-05-04 17:03:47 +0000
commitae9bb92ccc2b4a9a75b09c59e1351a78e6a6da53 (patch)
tree3b9f55f665059c5fc5c29d88d99be219e2411ecd /libc/sysdeps/linux/sparc/crt0.S
parent84a9d87e2d6b237ff10990338ce76f050e1c3e2a (diff)
Initial sparc port, thanks to Mathew Bosworth <mbosworth@metaflow.com>,
who sent this to me a month ago and I forgot to check it in. Oops. Better late then never. -Erik
Diffstat (limited to 'libc/sysdeps/linux/sparc/crt0.S')
-rw-r--r--libc/sysdeps/linux/sparc/crt0.S90
1 files changed, 90 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/sparc/crt0.S b/libc/sysdeps/linux/sparc/crt0.S
new file mode 100644
index 000000000..7910131db
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/crt0.S
@@ -0,0 +1,90 @@
+/*
+ * xrt0.s for ERC32.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 675
+ * Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/* code taken from leonccs 1.0 leon/src/libio/crt0.S
+ I don't know if this is available anymore, now that LECCS
+ is out. And I'm not sure if this source is in the LECCS distro :(
+*/
+
+ .text
+! Original :
+! .global __start, _main
+! uC-libc version :
+ .global _start
+ .global __uClibc_main
+
+! Start the real-time clock with a tick of 14 clocks
+!
+
+_start:
+
+ save %sp, -64, %sp
+
+ /* clear the bss */
+
+ sethi %hi(edata),%g2
+ or %g2,%lo(edata),%g2 ! g2 = start of bss
+ sethi %hi(_end),%g3
+ or %g3,%lo(_end),%g3 ! g3 = end of bss
+ mov %g0,%g1 ! so std has two zeros
+zerobss:
+ std %g0,[%g2]
+ add %g2,8,%g2
+ cmp %g2,%g3
+ bleu,a zerobss
+ nop
+
+ /* move data segment to proper location */
+
+relocd:
+ set (_endtext),%g2 ! g2 = start of data in aout file
+ set (_environ),%g4 ! g4 = start of where data should go
+ set (_edata),%g3 ! g3 = end of where data should go
+ subcc %g3, %g4, %g5 ! g5 = length of data
+
+ subcc %g4, %g2, %g0 ! need to relocate data ?
+ ble initok
+ ld [%g4], %g6
+! subcc %g6, 1, %g0
+! be initok
+mvdata:
+ subcc %g5, 8, %g5
+ ldd [%g2 + %g5], %g6
+ bg mvdata
+ std %g6, [%g4 + %g5]
+
+initok:
+
+! call _main
+ call __uClibc_main
+ nop
+! Should not return from uClibc main()
+! ret
+! nop
+
+ .seg "data"
+ .global .bdata
+.bdata:
+ .align 8
+ .global _environ ! first symbol in sdata
+_environ:
+ .word 1
+
+
+