yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * libc/sysdeps/linux/microblaze/crt0.S -- Initial program entry point for linux/microblaze |
| 3 | * |
| 4 | * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> |
| 5 | * Copyright (C) 2001,2002 NEC Corporation |
| 6 | * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org> |
| 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU Lesser |
| 9 | * General Public License. See the file COPYING.LIB in the main |
| 10 | * directory of this archive for more details. |
| 11 | * |
| 12 | * Written by Miles Bader <miles@gnu.org> |
| 13 | */ |
| 14 | |
| 15 | #include <clinkage.h> |
| 16 | |
| 17 | /* Upon entry, the stack contains the following data: |
| 18 | argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0 |
| 19 | */ |
| 20 | |
| 21 | .text |
| 22 | C_ENTRY(_start): |
| 23 | lw r5, r0, r1 /* Arg 0: argc */ |
| 24 | |
| 25 | addi r6, r1, 4 /* Arg 1: argv */ |
| 26 | |
| 27 | /* Arg 2: envp */ |
| 28 | addi r3, r5, 1 /* skip argc elements to get envp start */ |
| 29 | /* ...plus the NULL at the end of argv */ |
| 30 | add r3, r3, r3 /* Make word offset */ |
| 31 | add r3, r3, r3 |
| 32 | add r7, r6, r3 /* add to argv to get offset */ |
| 33 | |
| 34 | /* tail-call uclibc's startup routine */ |
| 35 | brid C_SYMBOL_NAME(__uClibc_main) |
| 36 | nop |
| 37 | |
| 38 | |
| 39 | /* Stick in a dummy reference to `main', so that if an application |
| 40 | is linking when the `main' function is in a static library (.a) |
| 41 | we can be sure that `main' actually gets linked in. */ |
| 42 | L_dummy_main_reference: |
| 43 | .long C_SYMBOL_NAME(main) |
| 44 | |
| 45 | /* Define a symbol for the first piece of initialized data. */ |
| 46 | .data |
| 47 | .globl __data_start |
| 48 | __data_start: |
| 49 | .long 0 |
| 50 | .weak data_start |
| 51 | data_start = __data_start |
| 52 | |