@@ -5,14 +5,14 @@ cat <<'EOF' | $CC -o $t/a.o -c -xassembler -
5
5
.globl foo, bar
6
6
foo:
7
7
move $s0, $ra
8
- .reloc ., R_LARCH_CALL36, foo2
8
+ .reloc ., R_LARCH_CALL36, print
9
9
.reloc ., R_LARCH_RELAX
10
10
pcaddu18i $t0, 0
11
11
jirl $ra, $t0, 0
12
12
move $ra, $s0
13
13
ret
14
14
bar:
15
- .reloc ., R_LARCH_CALL36, bar2
15
+ .reloc ., R_LARCH_CALL36, print
16
16
.reloc ., R_LARCH_RELAX
17
17
pcaddu18i $t0, 0
18
18
jirl $zero, $t0, 0
@@ -22,8 +22,10 @@ cat <<EOF | $CC -o $t/b.o -c -xc -
22
22
#include <stdio.h>
23
23
void foo();
24
24
void bar();
25
- void foo2() { printf("foo"); }
26
- void bar2() { printf("bar"); }
25
+ void print() __attribute__ ((section(".print")));
26
+ void print() {
27
+ printf("beef");
28
+ }
27
29
28
30
int main() {
29
31
foo();
@@ -33,14 +35,14 @@ int main() {
33
35
EOF
34
36
35
37
$CC -B. -o $t /exe1 $t /a.o $t /b.o -Wl,--no-relax
36
- $QEMU $t /exe1 | grep -q foobar
38
+ $QEMU $t /exe1 | grep -q beefbeef
37
39
38
40
$OBJDUMP -d $t /exe1 > $t /exe1.objdump
39
41
grep -A2 ' <foo>:' $t /exe1.objdump | grep -wq pcaddu18i
40
42
grep -A2 ' <bar>:' $t /exe1.objdump | grep -wq pcaddu18i
41
43
42
- $CC -B. -o $t /exe2 $t /a.o $t /b.o -Wl,--relax
43
- $QEMU $t /exe2 | grep -q foobar
44
+ $CC -B. -o $t /exe2 $t /a.o $t /b.o -Wl,--relax -Wl,-Ttext=0x10000 -Wl,--section-start=.print=0x100000
45
+ $QEMU $t /exe2 | grep -q beefbeef
44
46
45
47
$OBJDUMP -d $t /exe2 > $t /exe2.objdump
46
48
grep -A2 ' <foo>:' $t /exe2.objdump | grep -wq bl
0 commit comments