mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 06:09:11 +02:00
* start to fix mips(el) startup code
git-svn-id: trunk@20253 -
This commit is contained in:
parent
0d76eeb55a
commit
2c76472bd5
@ -2,7 +2,7 @@
|
|||||||
This file is part of the Free Pascal run time library.
|
This file is part of the Free Pascal run time library.
|
||||||
Copyright (c) 1999-2009 by Michael Van Canneyt and David Zhang
|
Copyright (c) 1999-2009 by Michael Van Canneyt and David Zhang
|
||||||
|
|
||||||
Startup code for elf32-mipsel
|
Startup code for elf32-mipsel/elf32-mips
|
||||||
|
|
||||||
See the file COPYING.FPC, included in this distribution,
|
See the file COPYING.FPC, included in this distribution,
|
||||||
for details about the copyright.
|
for details about the copyright.
|
||||||
@ -17,38 +17,40 @@
|
|||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
.global _dynamic_start
|
.global _dynamic_start
|
||||||
|
.ent _dynamic_start
|
||||||
.type _dynamic_start,@function
|
.type _dynamic_start,@function
|
||||||
_dynamic_start:
|
_dynamic_start:
|
||||||
/* TODO: check whether this code is correct */
|
/* TODO: check whether this code is correct */
|
||||||
lui $a2,%hi(__dl_fini)
|
lui $a2,%hi(__dl_fini)
|
||||||
sw $v0,%lo(__dl_fini)($a2)
|
sw $v0,%lo(__dl_fini)($a2)
|
||||||
b _start
|
b _start
|
||||||
|
nop
|
||||||
|
|
||||||
|
.end _dynamic_start
|
||||||
|
.size _dynamic_start, .-_start
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
.global _start
|
.global _start
|
||||||
.type _start,@function
|
.set nomips16
|
||||||
|
.ent _start
|
||||||
|
.type _start,@function
|
||||||
/* This is the canonical entry point, usually the first thing in the text
|
/* This is the canonical entry point, usually the first thing in the text
|
||||||
segment. The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
|
segment. The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
|
||||||
point runs, most registers' values are unspecified, except for:
|
point runs, most registers' values are unspecified, except for:
|
||||||
|
|
||||||
v0 ($2) Contains a function pointer to be registered with `atexit'.
|
v0 ($2) Function pointer of a function to be executed at exit
|
||||||
This is how the dynamic linker arranges to have DT_FINI
|
|
||||||
functions called for shared libraries that have been loaded
|
|
||||||
before this code runs.
|
|
||||||
|
|
||||||
sp ($29) The stack contains the arguments and environment:
|
sp ($29) The stack contains the arguments and environment:
|
||||||
0(%esp) argc
|
0(%sp) argc
|
||||||
4(%esp) argv[0]
|
4(%sp) argv[0]
|
||||||
|
|
||||||
...
|
...
|
||||||
(4*argc)(%esp) NULL
|
(4*argc)(%sp) NULL
|
||||||
(4*(argc+1))(%esp) envp[0]
|
(4*(argc+1))(%sp) envp[0]
|
||||||
...
|
...
|
||||||
NULL
|
NULL
|
||||||
ra ($31) The return address register is set to zero so that programs
|
ra ($31) Return address set to zero.
|
||||||
that search backword through stack frames recognize the last
|
*/
|
||||||
stack frame.
|
|
||||||
_start:
|
_start:
|
||||||
/* load fp */
|
/* load fp */
|
||||||
move $s8,$sp
|
move $s8,$sp
|
||||||
@ -79,13 +81,19 @@ _start:
|
|||||||
addiu $a2,$a0,1
|
addiu $a2,$a0,1
|
||||||
sll $a2,$a2,0x2
|
sll $a2,$a2,0x2
|
||||||
addu $a2,$a2,$a1
|
addu $a2,$a2,$a1
|
||||||
lui $a3,$hi(operatingsystem_parameter_envp)
|
lui $a3,%hi(operatingsystem_parameter_envp)
|
||||||
jal PASCALMAIN
|
jal PASCALMAIN
|
||||||
sw $a2,%lo(operatingsystem_parameter_envp)($a3)
|
sw $a2,%lo(operatingsystem_parameter_envp)($a3)
|
||||||
nop
|
nop
|
||||||
|
b _haltproc
|
||||||
|
nop
|
||||||
|
|
||||||
.globl _haltproc
|
.end _start
|
||||||
.type _haltproc,@function
|
.size _start, .-_start
|
||||||
|
|
||||||
|
.globl _haltproc
|
||||||
|
.ent _haltproc
|
||||||
|
.type _haltproc,@function
|
||||||
_haltproc:
|
_haltproc:
|
||||||
/* TODO: need to check whether __dl_fini is non-zero and call the function pointer in case */
|
/* TODO: need to check whether __dl_fini is non-zero and call the function pointer in case */
|
||||||
|
|
||||||
@ -96,7 +104,8 @@ _haltproc:
|
|||||||
b _haltproc
|
b _haltproc
|
||||||
nop
|
nop
|
||||||
|
|
||||||
.size _start, .-_start
|
.end _haltproc
|
||||||
|
.size _haltproc, .-_haltproc
|
||||||
|
|
||||||
.comm __stkptr,4
|
.comm __stkptr,4
|
||||||
.comm __dl_fini,4
|
.comm __dl_fini,4
|
||||||
@ -104,3 +113,4 @@ _haltproc:
|
|||||||
.comm operatingsystem_parameter_envp,4
|
.comm operatingsystem_parameter_envp,4
|
||||||
.comm operatingsystem_parameter_argc,4
|
.comm operatingsystem_parameter_argc,4
|
||||||
.comm operatingsystem_parameter_argv,4
|
.comm operatingsystem_parameter_argv,4
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user