1 /* Machine-dependent ELF startup code. OpenRISC version.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 /* Initial entry point code for the dynamic linker.
22 The function _dl_start is the real entry point;
23 it's return value is the user program's entry point. */
25 /* Count arguments in r11 */
36 /* store argument counter to stack. */
39 /* Load the PIC register. */
41 l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
42 l.ori r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
49 /* Save user entry in a call saved reg. */
51 /* Fall through to _dl_start_user. */
54 /* Set up for _dl_init. */
56 /* Load _rtld_local (a.k.a _dl_loaded). */
57 l.lwz r12, got(_rtld_local)(r16)
61 l.lwz r18, got(_dl_argc)(r16)
65 l.lwz r20, got(_dl_argv)(r16)
68 /* Load envp = &argv[argc + 1]. */
76 /* Now set up for user entry.
77 The already defined ABI loads argc and argv from the stack.
83 /* Load SP as argv - 4. */
91 /* Pass _dl_fini function address to _start.
92 Next start.S will then pass this as rtld_fini to __libc_start_main. */
93 l.lwz r3, got(_dl_fini)(r16)