|
Packit |
6c4009 |
/* Startup code for programs linked with GNU libc.
|
|
Packit |
6c4009 |
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
In addition to the permissions in the GNU Lesser General Public
|
|
Packit |
6c4009 |
License, the Free Software Foundation gives you unlimited
|
|
Packit |
6c4009 |
permission to link the compiled version of this file with other
|
|
Packit |
6c4009 |
programs, and to distribute those programs without any restriction
|
|
Packit |
6c4009 |
coming from the use of this file. (The GNU Lesser General Public
|
|
Packit |
6c4009 |
License restrictions do apply in other respects; for example, they
|
|
Packit |
6c4009 |
cover modification of the file, and distribution when not linked
|
|
Packit |
6c4009 |
into another program.)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Note that people who make modified versions of this file are not
|
|
Packit |
6c4009 |
obligated to grant this special exception for their modified
|
|
Packit |
6c4009 |
versions; it is their choice whether to do so. The GNU Lesser
|
|
Packit |
6c4009 |
General Public License gives permission to release a modified
|
|
Packit |
6c4009 |
version without this exception; this exception also makes it
|
|
Packit |
6c4009 |
possible to release a modified version which carries forward this
|
|
Packit |
6c4009 |
exception.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* We do not want .eh_frame info for crt1.o since crt1.o is linked
|
|
Packit |
6c4009 |
before crtbegin.o, the file defining __EH_FRAME_BEGIN__. */
|
|
Packit |
6c4009 |
#undef cfi_startproc
|
|
Packit |
6c4009 |
#define cfi_startproc
|
|
Packit |
6c4009 |
#undef cfi_endproc
|
|
Packit |
6c4009 |
#define cfi_endproc
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* These are the various addresses we require. */
|
|
Packit |
6c4009 |
#ifdef PIC
|
|
Packit |
6c4009 |
.section ".data"
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
.section ".rodata"
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
.align 2
|
|
Packit |
6c4009 |
L(start_addresses):
|
|
Packit |
6c4009 |
.long _SDA_BASE_
|
|
Packit |
6c4009 |
.long main
|
|
Packit |
6c4009 |
.long __libc_csu_init
|
|
Packit |
6c4009 |
.long __libc_csu_fini
|
|
Packit |
6c4009 |
ASM_SIZE_DIRECTIVE(L(start_addresses))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.section ".text"
|
|
Packit |
6c4009 |
ENTRY(_start)
|
|
Packit |
6c4009 |
/* Save the stack pointer, in case we're statically linked under Linux. */
|
|
Packit |
6c4009 |
mr r9,r1
|
|
Packit |
6c4009 |
/* Set up an initial stack frame, and clear the LR. */
|
|
Packit |
6c4009 |
clrrwi r1,r1,4
|
|
Packit |
6c4009 |
#ifdef PIC
|
|
Packit |
6c4009 |
SETUP_GOT_ACCESS(r13,got_label)
|
|
Packit |
6c4009 |
li r0,0
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
li r0,0
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
stwu r1,-16(r1)
|
|
Packit |
6c4009 |
mtlr r0
|
|
Packit |
6c4009 |
stw r0,0(r1)
|
|
Packit |
6c4009 |
/* Set r13 to point at the 'small data area', and put the address of
|
|
Packit |
6c4009 |
start_addresses in r8. Also load the GOT pointer so that new PLT
|
|
Packit |
6c4009 |
calls work, like the one to __libc_start_main. */
|
|
Packit |
6c4009 |
#ifdef PIC
|
|
Packit |
6c4009 |
addis r30,r13,_GLOBAL_OFFSET_TABLE_-got_label@ha
|
|
Packit |
6c4009 |
addis r8,r13,L(start_addresses)-got_label@ha
|
|
Packit |
6c4009 |
addi r30,r30,_GLOBAL_OFFSET_TABLE_-got_label@l
|
|
Packit |
6c4009 |
lwzu r13, L(start_addresses)-got_label@l(r8)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
lis r8,L(start_addresses)@ha
|
|
Packit |
6c4009 |
lwzu r13,L(start_addresses)@l(r8)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
/* and continue in libc-start, in glibc. */
|
|
Packit |
6c4009 |
b JUMPTARGET(__libc_start_main)
|
|
Packit |
6c4009 |
END(_start)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Define a symbol for the first piece of initialized data. */
|
|
Packit |
6c4009 |
.section ".data"
|
|
Packit |
6c4009 |
.globl __data_start
|
|
Packit |
6c4009 |
__data_start:
|
|
Packit |
6c4009 |
.long 0
|
|
Packit |
6c4009 |
weak_alias (__data_start, data_start)
|