1/* 2 * Copyright (c) 2011 Aeroflex Gaisler 3 * 4 * BSD license: 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 26 .text 27 .global _start, main, _end 28 29_start: 30 31#ifndef _FLAT 32 save %sp, -64, %sp 33#else 34 add %sp, -72, %sp 35 st %o7, [%sp+64] 36#endif 37 /* clear the bss */ 38 39 sethi %hi(__bss_start),%g2 40 or %g2,%lo(__bss_start),%g2 ! g2 = start of bss 41 sethi %hi(_end),%g3 42 or %g3,%lo(_end),%g3 ! g3 = end of bss 43 mov %g0,%g1 ! so std has two zeros 44 sub %g3, %g2, %g3 45zerobss: 46 subcc %g3, 8, %g3 47 bge,a zerobss 48 std %g0,[%g2+%g3] 49 50 set _end, %o0 51 st %g0,[%o0] 52 53 call bdinit2 54 nop 55 56 call prelibchook 57 nop 58 59 call _call_initcalls /* atexit uses __atexit lock */ 60 nop 61 62 set _fini, %o0 63 call atexit, 1 64 nop 65 66 call _init 67 nop 68 69 call main 70 nop 71 call _exit 72 nop 73#ifndef _FLAT 74 ret 75 restore 76#else 77 ld [%sp+64], %o7 78 retl 79 add %sp, 72, %sp 80#endif 81 82 .seg "data" 83 .global .bdata 84.bdata: 85 .align 8 86 .global _environ 87_environ: 88 .word 1 89 90 91 92