1 # Assembler initialization code for actual execution test.
3 # This code becomes the start of the execution test program. It is
4 # responsible for initializing the static data, invoking the C code,
5 # and returning the result. It is called as though it were a C
6 # function with an argument of the address of the data segment.
8 # We need to know the value of _ftext and _fdata at link time, but we
9 # have no way to actually get that at runtime. This is because when
10 # this code is compiled with -membedded-pic, the la instruction will
11 # be turned into an addiu $gp instruction. We work around this by
12 # storing the information in words in the .data section. We then load
13 # the values of these words *before* doing the runtime relocation.
23 # Grab some space on the stack, just as though we were a real
28 # Save the $gp register, and set it up for our data section.
31 addu $gp
,$
4,0x8000 # macro
33 # The start of the data segment is in $4.
35 # Get the address of start into $5 in a position independent
40 la $
5,start-$LF1
# macro
44 # Now get the address of _ftext into $6.
45 la $
6,_ftext-start
# macro
48 # Get the value of _ftext used to link into $7.
49 lw $
7,text_start
# macro
51 # Get the value of _fdata used to link into $8.
52 lw $
8,data_start
# macro
54 # Get the address of __runtime_reloc_start into $9.
55 la $
9,__runtime_reloc_start-start
# macro
58 # Get the address of __runtime_reloc_stop into $10.
59 la $
10,__runtime_reloc_stop-start
# macro
62 # The words between $9 and $10 are the runtime initialization
63 # instructions. Step through and relocate them. First set
64 # $11 and $12 to the values to add to text and data sections,
72 and $
14,$
13,0xfffffffe # macro
85 # Now the statically initialized data has been relocated
86 # correctly, and we can call the C code which does the actual
90 # We return the value returned by the C code.