mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 09:29:26 +02:00
Correct code for shared library start
git-svn-id: trunk@23559 -
This commit is contained in:
parent
6e5be15087
commit
f74954dd32
@ -17,17 +17,19 @@
|
|||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
.global _dynamic_start
|
.global _dynamic_start
|
||||||
.ent _dynamic_start
|
.global FPC_SHARED_LIB_START
|
||||||
.type _dynamic_start,@function
|
.type _dynamic_start,@function
|
||||||
|
.type FPC_SHARED_LIB_START,@function
|
||||||
|
FPC_SHARED_LIB_START:
|
||||||
_dynamic_start:
|
_dynamic_start:
|
||||||
|
.ent _dynamic_start
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload $25
|
.cpload $25
|
||||||
/* TODO: check whether this code is correct */
|
/* TODO: check whether this code is correct */
|
||||||
la $v0,__dl_fini
|
la $v0,__dl_fini
|
||||||
lw $v0,($v0)
|
lw $v0,($v0)
|
||||||
lw $v1,%call16(_start)($gp)
|
la $t9,_start
|
||||||
move $t9,$v1
|
jr $t9
|
||||||
jalr $t9
|
|
||||||
nop
|
nop
|
||||||
|
|
||||||
.end _dynamic_start
|
.end _dynamic_start
|
||||||
@ -36,7 +38,6 @@ _dynamic_start:
|
|||||||
.align 4
|
.align 4
|
||||||
.global _start
|
.global _start
|
||||||
.set nomips16
|
.set nomips16
|
||||||
.ent _start
|
|
||||||
.type _start,@function
|
.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
|
||||||
@ -56,55 +57,75 @@ _dynamic_start:
|
|||||||
ra ($31) Return address set to zero.
|
ra ($31) Return address set to zero.
|
||||||
*/
|
*/
|
||||||
_start:
|
_start:
|
||||||
|
.ent _start
|
||||||
/* load fp */
|
/* load fp */
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload $25
|
.cpload $25
|
||||||
addiu $sp,$sp,-32
|
|
||||||
|
/* Record $sp into $s8 */
|
||||||
move $s8,$sp
|
move $s8,$sp
|
||||||
.cprestore 16
|
|
||||||
la $t1,__stkptr
|
|
||||||
sw $s8,($t1)
|
|
||||||
|
|
||||||
/* align stack */
|
/* align stack */
|
||||||
li $at,-8
|
li $at,-8
|
||||||
and $sp,$sp,$at
|
and $sp,$sp,$at
|
||||||
|
|
||||||
addiu $sp,$sp,-32
|
addiu $sp,$sp,-32
|
||||||
|
|
||||||
lui $s7,0x3d
|
/* Compute and save sp offset */
|
||||||
addiu $s7,$s7,2304
|
subu $t1,$s8,$sp
|
||||||
li $at,-8
|
sw $t1,24($sp)
|
||||||
and $s7,$s7,$at
|
|
||||||
addiu $s7,$s7,-32
|
|
||||||
|
|
||||||
/* store argc */
|
/* Save $ra register */
|
||||||
|
sw $ra,28($sp)
|
||||||
|
/* Save $gp register */
|
||||||
|
.cprestore 20
|
||||||
|
|
||||||
|
/* Set __stkptr variable */
|
||||||
|
move $s8,$sp
|
||||||
|
la $t1,__stkptr
|
||||||
|
sw $s8,($t1)
|
||||||
|
|
||||||
|
/* store argc, which is in $a0 */
|
||||||
lw $a0,0($s8)
|
lw $a0,0($s8)
|
||||||
la $a1,operatingsystem_parameter_argc
|
la $t1,operatingsystem_parameter_argc
|
||||||
sw $a0,($a1)
|
sw $a0,($t1)
|
||||||
|
|
||||||
/* store argv */
|
/* store argv which is in $a1 */
|
||||||
addiu $a1,$s8,4
|
addiu $a1,$s8,4
|
||||||
la $a2,operatingsystem_parameter_argv
|
la $t1,operatingsystem_parameter_argv
|
||||||
sw $a1,($a2)
|
sw $a1,($t1)
|
||||||
|
|
||||||
/* store envp */
|
/* store envp which is in $a2 */
|
||||||
addiu $a2,$a0,1
|
la $t1,operatingsystem_parameter_envp
|
||||||
sll $a2,$a2,0x2
|
sw $a2,($t1)
|
||||||
addu $a2,$a2,$a1
|
|
||||||
la $a3,operatingsystem_parameter_envp
|
/* Set IsLibrary to one */
|
||||||
sw $a2,($a3)
|
la $t1,operatingsystem_islibrary
|
||||||
|
li $t2,1
|
||||||
|
sb $t2,($t1)
|
||||||
|
/* Jump to PASCALMAIN */
|
||||||
la $t9,PASCALMAIN
|
la $t9,PASCALMAIN
|
||||||
jalr $t9
|
jalr $t9
|
||||||
nop
|
nop
|
||||||
b _haltproc
|
|
||||||
|
/* Restore $ra */
|
||||||
|
lw $ra,28($sp)
|
||||||
|
|
||||||
|
/* Restore old $sp */
|
||||||
|
lw $t1,24($sp)
|
||||||
|
addu $sp,$sp,$t1
|
||||||
|
/* Return to caller */
|
||||||
|
jr $ra
|
||||||
nop
|
nop
|
||||||
|
|
||||||
.end _start
|
.end _start
|
||||||
.size _start, .-_start
|
.size _start, .-_start
|
||||||
|
|
||||||
.globl _haltproc
|
.globl _haltproc
|
||||||
|
.globl FPC_SHARED_LIB_EXIT
|
||||||
.ent _haltproc
|
.ent _haltproc
|
||||||
.type _haltproc,@function
|
.type _haltproc,@function
|
||||||
|
.type FPC_SHARED_LIB_EXIT,@function
|
||||||
|
FPC_SHARED_LIB_EXIT:
|
||||||
_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 */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user