Commit | Line | Data |
---|---|---|
92a9c616 RS |
1 | .macro start, sym |
2 | .type \sym, @function | |
3 | .pushsection .opd, "aw" | |
4 | \sym: .quad .L.\sym, .TOC.@tocbase, 0 | |
5 | .popsection | |
6 | .L.\sym: | |
7 | mflr 0 | |
8 | std 31, -8(1) | |
9 | std 0, 16(1) | |
10 | stdu 1, -128(1) | |
11 | mr 31, 1 | |
12 | .endm | |
13 | ||
14 | ||
15 | .macro end, sym | |
16 | addi 1,31,128 | |
17 | ld 0, 16(1) | |
18 | mtlr 0 | |
19 | ld 31, -8(1) | |
20 | blr | |
21 | .size \sym, . - .L.\sym | |
22 | .endm | |
23 | ||
24 | ||
25 | .macro forward, from, to | |
26 | start \from | |
27 | bl \to | |
28 | nop | |
29 | end \from | |
30 | .endm | |
31 | ||
32 | ||
33 | .macro usegot, sym | |
34 | .pushsection .data | |
35 | \sym\@: .quad \@ | |
36 | .popsection | |
37 | .pushsection .toc, "aw" | |
38 | .LT\@: .tc \sym\@[TC], \sym\@ | |
39 | .popsection | |
40 | ld 3,.LT\@@toc(2) | |
41 | .endm | |
42 | ||
43 | ||
44 | .macro in123 | |
45 | .pushsection .toc, "aw" | |
46 | .LThello: | |
47 | .tc hello[TC],hello | |
48 | .popsection | |
49 | ||
50 | .pushsection .rodata | |
51 | hello: .asciz "Hello, world!\n" | |
52 | .popsection | |
53 | ||
54 | .pushsection .text.in123, "axG", @progbits, in123, comdat | |
55 | .weak in123 | |
56 | start in123 | |
57 | ld 3, .LThello@toc(2) | |
58 | #bl printf | |
59 | nop | |
60 | end in123 | |
61 | .popsection | |
62 | .endm | |
63 | ||
64 | ||
65 | .macro in23 | |
66 | .pushsection .text | |
67 | forward local, in123 | |
68 | .popsection | |
69 | ||
70 | .pushsection .text.in23, "axG", @progbits, in23, comdat | |
71 | .weak in23 | |
72 | forward in23, local | |
73 | .popsection | |
74 | .endm | |
75 | ||
76 | ||
77 | .macro gobblegot, sym | |
78 | .pushsection .text | |
79 | .globl \sym | |
80 | start \sym | |
81 | .rept 5000 | |
82 | usegot a | |
83 | .endr | |
84 | end \sym | |
85 | .popsection | |
86 | .endm |