yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | # |
| 2 | # crt0.S, part of the i960 support for the uClibc library. |
| 3 | # |
| 4 | # Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.com/ |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of the GNU Library General Public License as published by the Free |
| 8 | # Software Foundation; either version 2 of the License, or (at your option) any |
| 9 | # later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 13 | # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more |
| 14 | # details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU Library General Public License |
| 17 | # along with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | # at 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | # |
| 20 | |
| 21 | /* |
| 22 | * |
| 23 | * The behavior in this file is tightly coupled with how the linux kernel sets things up |
| 24 | * on the stack before calling us. |
| 25 | * |
| 26 | * Currently fs/binfmt_flat.c (for STACK_GROWS_UP) and arch/i960/kernel/process.c |
| 27 | * build things so that a pointer to argc is left in g13 by start_thread(). |
| 28 | * |
| 29 | * ^ |
| 30 | * | <- sp somewhere around here, after being aligned. |
| 31 | * | |
| 32 | * |envp -> envp[0] |
| 33 | * |argv -> argv[0] |
| 34 | * |argc <- g13 |
| 35 | * |
| 36 | * A complete picture of how things are set up can be seen in the comments of |
| 37 | * create_flat_tables_stack_grows_up in fs/binfmt_flat.c |
| 38 | * |
| 39 | * I believe having to use this register could probably be avoided. |
| 40 | * |
| 41 | */ |
| 42 | |
| 43 | .globl start |
| 44 | start: |
| 45 | mov g13, r3 |
| 46 | ldt (r3), g0 |
| 47 | callx ___uClibc_main |
| 48 | |
| 49 | /* We might want to add some instruction so that it crashes if main returns */ |
| 50 | |
| 51 | /* Define a symbol for the first piece of initialized data. */ |
| 52 | .data |
| 53 | .globl __data_start |
| 54 | __data_start: |
| 55 | .long 0 |
| 56 | .weak data_start |
| 57 | data_start = __data_start |
| 58 | |