-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathcrt0.S
More file actions
71 lines (49 loc) · 1.62 KB
/
crt0.S
File metadata and controls
71 lines (49 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#**************************************************************************/
# */
# external declarations */
# */
#**************************************************************************/
.globl _start
.extern shellcode # Defined in shellcode.c
.extern _got_start # Defined in raw.ld
.extern _got_entry_count # Defined in raw.ld
#**************************************************************************/
# */
# section declaration */
# */
#**************************************************************************/
.section ".load"
_start:
mflr r4
bl getpc
getpc:
mflr r3
mtlr r4
mr r5, r3
subi r5, r5, (getpc - _start)
lis r3, _got_start@ha
addi r3, r3, _got_start@l
lis r4, _got_entry_count@ha
addi r4, r4, _got_entry_count@l
add r10, r5, r3
cmpwi r4, 0
beq main
li r11, 0
li r9, 0
subf r4, r11, r4
mtctr r4
next_off:
slwi r9, r9, 2
lwzx r0, r10, r9
add r0, r0, r5
stwx r0, r10, r9
addi r11, r11, 1
mr r9, r11
bdnz next_off
main:
#**************************************
# branch to main program
#***
bl shellcode
twge r2, r2
# End of __start