|
Packit Service |
82fcde |
/* ELF startup code for HPPA.
|
|
Packit Service |
82fcde |
Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
In addition to the permissions in the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License, the Free Software Foundation gives you unlimited
|
|
Packit Service |
82fcde |
permission to link the compiled version of this file with other
|
|
Packit Service |
82fcde |
programs, and to distribute those programs without any restriction
|
|
Packit Service |
82fcde |
coming from the use of this file. (The GNU Lesser General Public
|
|
Packit Service |
82fcde |
License restrictions do apply in other respects; for example, they
|
|
Packit Service |
82fcde |
cover modification of the file, and distribution when not linked
|
|
Packit Service |
82fcde |
into another program.)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Note that people who make modified versions of this file are not
|
|
Packit Service |
82fcde |
obligated to grant this special exception for their modified
|
|
Packit Service |
82fcde |
versions; it is their choice whether to do so. The GNU Lesser
|
|
Packit Service |
82fcde |
General Public License gives permission to release a modified
|
|
Packit Service |
82fcde |
version without this exception; this exception also makes it
|
|
Packit Service |
82fcde |
possible to release a modified version which carries forward this
|
|
Packit Service |
82fcde |
exception.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.import main, code
|
|
Packit Service |
82fcde |
.import $global$, data
|
|
Packit Service |
82fcde |
.import __libc_start_main, code
|
|
Packit Service |
82fcde |
.import __libc_csu_fini, code
|
|
Packit Service |
82fcde |
.import __libc_csu_init, code
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Have the linker create plabel words so we get PLABEL32
|
|
Packit Service |
82fcde |
relocs and not 21/14. The use of 21/14 relocs is only
|
|
Packit Service |
82fcde |
supported in the latest dynamic linker. */
|
|
Packit Service |
82fcde |
#ifdef PIC
|
|
Packit Service |
82fcde |
.section .data.rel.ro,"aw",@progbits
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
.section .rodata,"a",@progbits
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
.align 4
|
|
Packit Service |
82fcde |
.Lpmain:
|
|
Packit Service |
82fcde |
.word P%main
|
|
Packit Service |
82fcde |
.Lp__libc_start_main:
|
|
Packit Service |
82fcde |
.word P%__libc_start_main
|
|
Packit Service |
82fcde |
.Lp__libc_csu_fini:
|
|
Packit Service |
82fcde |
.word P%__libc_csu_fini
|
|
Packit Service |
82fcde |
.Lp__libc_csu_init:
|
|
Packit Service |
82fcde |
.word P%__libc_csu_init
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.text
|
|
Packit Service |
82fcde |
.align 4
|
|
Packit Service |
82fcde |
.globl _start
|
|
Packit Service |
82fcde |
.export _start, ENTRY
|
|
Packit Service |
82fcde |
.type _start,@function
|
|
Packit Service |
82fcde |
_start:
|
|
Packit Service |
82fcde |
/* At entry to the function we have:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
r26 - Unused
|
|
Packit Service |
82fcde |
r25 - argc
|
|
Packit Service |
82fcde |
r24 - argv
|
|
Packit Service |
82fcde |
r23 - False _dl_fini plabel address
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
This function is called from the lower half of RTLD_START.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The call to __libc_start_main expects:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
1. r26 - Application main
|
|
Packit Service |
82fcde |
2. r25 - argc
|
|
Packit Service |
82fcde |
3. r24 - argv
|
|
Packit Service |
82fcde |
4. r23 - __libc_csu_init
|
|
Packit Service |
82fcde |
5. sp-52 - __libc_csu_fini
|
|
Packit Service |
82fcde |
6. sp-56 - rtld_fini
|
|
Packit Service |
82fcde |
7. sp-60 - stackend */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.proc
|
|
Packit Service |
82fcde |
.callinfo
|
|
Packit Service |
82fcde |
/* Clear previous-sp. */
|
|
Packit Service |
82fcde |
stw %r0, -4(%sp)
|
|
Packit Service |
82fcde |
/* Setup the stack and frame. */
|
|
Packit Service |
82fcde |
stw %rp, -20(%sp)
|
|
Packit Service |
82fcde |
ldo 64(%sp), %sp
|
|
Packit Service |
82fcde |
stw %sp, -4(%sp)
|
|
Packit Service |
82fcde |
stw %r19, -32(%sp)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
|
|
Packit Service |
82fcde |
/* void (*rtld_fini) (void) (6th argument) */
|
|
Packit Service |
82fcde |
stw %r23, -56(%sp)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Need to setup 1, 4, 5, and 7th arguments */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef PIC
|
|
Packit Service |
82fcde |
/* Load $global$ address into %dp */
|
|
Packit Service |
82fcde |
bl .+8, %dp
|
|
Packit Service |
82fcde |
addil L'$global$-$PIC_pcrel$0+1, %dp
|
|
Packit Service |
82fcde |
ldo R'$global$-$PIC_pcrel$0+5(%r1), %dp
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* load main (1st argument) */
|
|
Packit Service |
82fcde |
addil LT'.Lpmain, %r19
|
|
Packit Service |
82fcde |
ldw RT'.Lpmain(%r1), %r26
|
|
Packit Service |
82fcde |
ldw 0(%r26),%r26
|
|
Packit Service |
82fcde |
/* void (*init) (void) (4th argument) */
|
|
Packit Service |
82fcde |
addil LT'.Lp__libc_csu_init, %r19
|
|
Packit Service |
82fcde |
ldw RT'.Lp__libc_csu_init(%r1), %r23
|
|
Packit Service |
82fcde |
ldw 0(%r23), %r23
|
|
Packit Service |
82fcde |
/* void (*fini) (void) (5th argument) */
|
|
Packit Service |
82fcde |
addil LT'.Lp__libc_csu_fini, %r19
|
|
Packit Service |
82fcde |
ldw RT'.Lp__libc_csu_fini(%r1), %r22
|
|
Packit Service |
82fcde |
ldw 0(%r22), %r22
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
/* Load $global$ address into %dp */
|
|
Packit Service |
82fcde |
ldil L%$global$, %dp
|
|
Packit Service |
82fcde |
ldo R%$global$(%dp), %dp
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* load main (1st argument) */
|
|
Packit Service |
82fcde |
ldil LR'.Lpmain, %r26
|
|
Packit Service |
82fcde |
ldw RR'.Lpmain(%r26), %r26
|
|
Packit Service |
82fcde |
/* void (*init) (void) (4th argument) */
|
|
Packit Service |
82fcde |
ldil LR'.Lp__libc_csu_init, %r23
|
|
Packit Service |
82fcde |
ldw RR'.Lp__libc_csu_init(%r23), %r23
|
|
Packit Service |
82fcde |
/* void (*fini) (void) (5th argument) */
|
|
Packit Service |
82fcde |
ldil LR'.Lp__libc_csu_fini, %r22
|
|
Packit Service |
82fcde |
ldw RR'.Lp__libc_csu_fini(%r22), %r22
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
/* Store 5th argument */
|
|
Packit Service |
82fcde |
stw %r22, -52(%sp)
|
|
Packit Service |
82fcde |
/* void *stack_end (7th argument) */
|
|
Packit Service |
82fcde |
stw %sp, -60(%sp)
|
|
Packit Service |
82fcde |
bl __libc_start_main,%r2
|
|
Packit Service |
82fcde |
nop
|
|
Packit Service |
82fcde |
/* die horribly if it returned (it shouldn't) */
|
|
Packit Service |
82fcde |
iitlbp %r0,(%sr0,%r0)
|
|
Packit Service |
82fcde |
nop
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.procend
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Define a symbol for the first piece of initialized data. */
|
|
Packit Service |
82fcde |
.data
|
|
Packit Service |
82fcde |
.globl __data_start
|
|
Packit Service |
82fcde |
__data_start:
|
|
Packit Service |
82fcde |
.long 0
|
|
Packit Service |
82fcde |
.weak data_start
|
|
Packit Service |
82fcde |
data_start = __data_start
|