|
4 | 4 | # RUN: %riscv32_cheri_purecap_llvm-mc -filetype=obj %t1.s -o %t1.32.o |
5 | 5 | # RUN: ld.lld -shared %t1.32.o -soname=t1.32.so -o %t1.32.so |
6 | 6 | # RUN: %riscv32_cheri_purecap_llvm-mc -filetype=obj %s -o %t.32.o |
7 | | -# RUN: ld.lld %t.32.o %t1.32.so -z separate-code -o %t.32.got |
8 | | -# RUN: llvm-readelf -S -s %t.32.got | FileCheck --check-prefixes=SEC,NM %s |
9 | | -# RUN: llvm-readobj -r --cap-relocs %t.32.got | FileCheck --check-prefix=RELOCGOT32 %s |
10 | | -# RUN: llvm-readelf -x .got %t.32.got | FileCheck --check-prefix=GOT32 %s |
11 | | -# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex=false %t.32.got | FileCheck --check-prefixes=DIS,DISGOT,DISGOT32 %s |
12 | | -# RUN: ld.lld %t.32.o %t1.32.so -z separate-code -z cheri-riscv-jump-slot -o %t.32.got.plt |
13 | | -# RUN: llvm-readelf -S -s %t.32.got.plt | FileCheck --check-prefixes=SEC,NM %s |
14 | | -# RUN: llvm-readobj -r --cap-relocs %t.32.got.plt | FileCheck --check-prefix=RELOCGOTPLT32 %s |
15 | | -# RUN: llvm-readelf -x .got.plt %t.32.got.plt | FileCheck --check-prefix=GOTPLT32 %s |
16 | | -# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex=false %t.32.got.plt | FileCheck --check-prefixes=DIS,DISGOTPLT,DISGOTPLT32 %s |
| 7 | +# RUN: ld.lld %t.32.o %t1.32.so -z separate-code -o %t.32 |
| 8 | +# RUN: llvm-readelf -S -s %t.32 | FileCheck --check-prefixes=SEC,NM %s |
| 9 | +# RUN: llvm-readobj -r --cap-relocs %t.32 | FileCheck --check-prefix=RELOC32 %s |
| 10 | +# RUN: llvm-readelf -x .got.plt %t.32 | FileCheck --check-prefix=GOTPLT32 %s |
| 11 | +# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex=false %t.32 | FileCheck --check-prefixes=DIS,DIS32 %s |
17 | 12 |
|
18 | 13 | # RUN: %riscv64_cheri_purecap_llvm-mc -filetype=obj %t1.s -o %t1.64.o |
19 | 14 | # RUN: ld.lld -shared %t1.64.o -soname=t1.64.so -o %t1.64.so |
20 | 15 | # RUN: %riscv64_cheri_purecap_llvm-mc -filetype=obj %s -o %t.64.o |
21 | | -# RUN: ld.lld %t.64.o %t1.64.so -z separate-code -o %t.64.got |
22 | | -# RUN: llvm-readelf -S -s %t.64.got | FileCheck --check-prefixes=SEC,NM %s |
23 | | -# RUN: llvm-readobj -r --cap-relocs %t.64.got | FileCheck --check-prefix=RELOCGOT64 %s |
24 | | -# RUN: llvm-readelf -x .got %t.64.got | FileCheck --check-prefix=GOT64 %s |
25 | | -# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex=false %t.64.got | FileCheck --check-prefixes=DIS,DISGOT,DISGOT64 %s |
26 | | -# RUN: ld.lld %t.64.o %t1.64.so -z separate-code -z cheri-riscv-jump-slot -o %t.64.got.plt |
27 | | -# RUN: llvm-readelf -S -s %t.64.got.plt | FileCheck --check-prefixes=SEC,NM %s |
28 | | -# RUN: llvm-readobj -r --cap-relocs %t.64.got.plt | FileCheck --check-prefix=RELOCGOTPLT64 %s |
29 | | -# RUN: llvm-readelf -x .got.plt %t.64.got.plt | FileCheck --check-prefix=GOTPLT64 %s |
30 | | -# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex=false %t.64.got.plt | FileCheck --check-prefixes=DIS,DISGOTPLT,DISGOTPLT64 %s |
| 16 | +# RUN: ld.lld %t.64.o %t1.64.so -z separate-code -o %t.64 |
| 17 | +# RUN: llvm-readelf -S -s %t.64 | FileCheck --check-prefixes=SEC,NM %s |
| 18 | +# RUN: llvm-readobj -r --cap-relocs %t.64 | FileCheck --check-prefix=RELOC64 %s |
| 19 | +# RUN: llvm-readelf -x .got.plt %t.64 | FileCheck --check-prefix=GOTPLT64 %s |
| 20 | +# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex=false %t.64 | FileCheck --check-prefixes=DIS,DIS64 %s |
31 | 21 |
|
32 | 22 | # SEC: .plt PROGBITS {{0*}}00011030 |
33 | 23 |
|
|
36 | 26 | # NM: {{0*}}00000000 0 FUNC GLOBAL DEFAULT UND bar |
37 | 27 | # NM: {{0*}}00000000 0 FUNC WEAK DEFAULT UND weak |
38 | 28 |
|
39 | | -# RELOCGOT32: .rela.dyn { |
40 | | -# RELOCGOT32-NEXT: 0x12068 R_RISCV_CHERI_CAPABILITY bar 0x0 |
41 | | -# RELOCGOT32-NEXT: 0x12070 R_RISCV_CHERI_CAPABILITY weak 0x0 |
42 | | -# RELOCGOT32-NEXT: } |
43 | | -# RELOCGOT32: There is no __cap_relocs section in the file. |
44 | | -# GOT32: section '.got' |
45 | | -# GOT32-NEXT: 0x00012060 00200100 00000000 00000000 00000000 |
46 | | -# GOT32-NEXT: 0x00012070 00000000 00000000 |
47 | | - |
48 | | -# RELOCGOTPLT32: .rela.plt { |
49 | | -# RELOCGOTPLT32-NEXT: 0x13088 R_RISCV_JUMP_SLOT bar 0x0 |
50 | | -# RELOCGOTPLT32-NEXT: 0x13090 R_RISCV_JUMP_SLOT weak 0x0 |
51 | | -# RELOCGOTPLT32-NEXT: } |
52 | | -# RELOCGOTPLT32: CHERI __cap_relocs [ |
53 | | -# RELOCGOTPLT32-NEXT: 0x013088 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
54 | | -# RELOCGOTPLT32-NEXT: 0x013090 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
55 | | -# RELOCGOTPLT32-NEXT: ] |
| 29 | +# RELOC32: .rela.plt { |
| 30 | +# RELOC32-NEXT: 0x13088 R_RISCV_JUMP_SLOT bar 0x0 |
| 31 | +# RELOC32-NEXT: 0x13090 R_RISCV_JUMP_SLOT weak 0x0 |
| 32 | +# RELOC32-NEXT: } |
| 33 | +# RELOC32: CHERI __cap_relocs [ |
| 34 | +# RELOC32-NEXT: 0x013088 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
| 35 | +# RELOC32-NEXT: 0x013090 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
| 36 | +# RELOC32-NEXT: ] |
56 | 37 | # GOTPLT32: section '.got.plt' |
57 | 38 | # GOTPLT32-NEXT: 0x00013078 00000000 00000000 00000000 00000000 |
58 | 39 | # GOTPLT32-NEXT: 0x00013088 00000000 00000000 00000000 00000000 |
59 | 40 |
|
60 | | -# RELOCGOT64: .rela.dyn { |
61 | | -# RELOCGOT64-NEXT: 0x120D0 R_RISCV_CHERI_CAPABILITY bar 0x0 |
62 | | -# RELOCGOT64-NEXT: 0x120E0 R_RISCV_CHERI_CAPABILITY weak 0x0 |
63 | | -# RELOCGOT64-NEXT: } |
64 | | -# RELOCGOT64: There is no __cap_relocs section in the file. |
65 | | -# GOT64: section '.got' |
66 | | -# GOT64-NEXT: 0x000120c0 00200100 00000000 00000000 00000000 |
67 | | -# GOT64-NEXT: 0x000120d0 00000000 00000000 00000000 00000000 |
68 | | -# GOT64-NEXT: 0x000120e0 00000000 00000000 00000000 00000000 |
69 | | - |
70 | | -# RELOCGOTPLT64: .rela.plt { |
71 | | -# RELOCGOTPLT64-NEXT: 0x13110 R_RISCV_JUMP_SLOT bar 0x0 |
72 | | -# RELOCGOTPLT64-NEXT: 0x13120 R_RISCV_JUMP_SLOT weak 0x0 |
73 | | -# RELOCGOTPLT64-NEXT: } |
74 | | -# RELOCGOTPLT64: CHERI __cap_relocs [ |
75 | | -# RELOCGOTPLT64-NEXT: 0x013110 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
76 | | -# RELOCGOTPLT64-NEXT: 0x013120 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
77 | | -# RELOCGOTPLT64-NEXT: ] |
| 41 | +# RELOC64: .rela.plt { |
| 42 | +# RELOC64-NEXT: 0x13110 R_RISCV_JUMP_SLOT bar 0x0 |
| 43 | +# RELOC64-NEXT: 0x13120 R_RISCV_JUMP_SLOT weak 0x0 |
| 44 | +# RELOC64-NEXT: } |
| 45 | +# RELOC64: CHERI __cap_relocs [ |
| 46 | +# RELOC64-NEXT: 0x013110 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
| 47 | +# RELOC64-NEXT: 0x013120 Base: 0x11030 (<unknown symbol>+0) Length: 64 Perms: Function |
| 48 | +# RELOC64-NEXT: ] |
78 | 49 | # GOTPLT64: section '.got.plt' |
79 | 50 | # GOTPLT64-NEXT: 0x000130f0 00000000 00000000 00000000 00000000 |
80 | 51 | # GOTPLT64-NEXT: 0x00013100 00000000 00000000 00000000 00000000 |
|
98 | 69 | # DIS: <foo>: |
99 | 70 | # DIS-NEXT: 11020: |
100 | 71 |
|
101 | | -# DIS: Disassembly of section .plt: |
102 | | -# DIS: <.plt>: |
103 | | -# DISGOT-NEXT: ... |
104 | | -# DISGOTPLT-NEXT: auipcc t2, 2 |
105 | | -# DISGOTPLT-NEXT: sub t1, t1, t3 |
| 72 | +# DIS: Disassembly of section .plt: |
| 73 | +# DIS: <.plt>: |
| 74 | +# DIS-NEXT: auipcc t2, 2 |
| 75 | +# DIS-NEXT: sub t1, t1, t3 |
106 | 76 | ## 32-bit: .got.plt - .plt = 0x13078 - 0x11030 = 4096*2+72 |
107 | 77 | ## 64-bit: .got.plt - .plt = 0x130f0 - 0x11030 = 4096*2+192 |
108 | | -# DISGOTPLT32-NEXT: lc t3, 72(t2) |
109 | | -# DISGOTPLT64-NEXT: lc t3, 192(t2) |
110 | | -# DISGOTPLT-NEXT: addi t1, t1, -44 |
111 | | -# DISGOTPLT32-NEXT: cincoffset t0, t2, 72 |
112 | | -# DISGOTPLT64-NEXT: cincoffset t0, t2, 192 |
113 | | -# DISGOTPLT32-NEXT: srli t1, t1, 1 |
114 | | -# DISGOTPLT32-NEXT: lc t0, 8(t0) |
115 | | -# DISGOTPLT64-NEXT: lc t0, 16(t0) |
116 | | -# DISGOTPLT-NEXT: jr t3 |
117 | | -# DISGOTPLT64-NEXT: nop |
| 78 | +# DIS32-NEXT: lc t3, 72(t2) |
| 79 | +# DIS64-NEXT: lc t3, 192(t2) |
| 80 | +# DIS-NEXT: addi t1, t1, -44 |
| 81 | +# DIS32-NEXT: cincoffset t0, t2, 72 |
| 82 | +# DIS64-NEXT: cincoffset t0, t2, 192 |
| 83 | +# DIS32-NEXT: srli t1, t1, 1 |
| 84 | +# DIS32-NEXT: lc t0, 8(t0) |
| 85 | +# DIS64-NEXT: lc t0, 16(t0) |
| 86 | +# DIS-NEXT: jr t3 |
| 87 | +# DIS64-NEXT: nop |
118 | 88 |
|
119 | | -## 32-bit (.got): &.got[bar]-. = 0x12068-0x11050 = 4096*1+24 |
120 | | -## 64-bit (.got): &.got[bar]-. = 0x120d0-0x11050 = 4096*1+128 |
121 | 89 | ## 32-bit (.got.plt): &.got.plt[bar]-. = 0x13088-0x11050 = 4096*2+56 |
122 | 90 | ## 64-bit (.got.plt): &.got.plt[bar]-. = 0x13110-0x11050 = 4096*2+192 |
123 | | -# DISGOT: 11050: auipcc t3, 1 |
124 | | -# DISGOTPLT: 11050: auipcc t3, 2 |
125 | | -# DISGOT32-NEXT: clc t3, 24(t3) |
126 | | -# DISGOT64-NEXT: clc t3, 128(t3) |
127 | | -# DISGOTPLT32-NEXT: lc t3, 56(t3) |
128 | | -# DISGOTPLT64-NEXT: lc t3, 192(t3) |
129 | | -# DIS-NEXT: cjalr t1, t3 |
130 | | -# DIS-NEXT: nop |
| 91 | +# DIS: 11050: auipcc t3, 2 |
| 92 | +# DIS32-NEXT: lc t3, 56(t3) |
| 93 | +# DIS64-NEXT: lc t3, 192(t3) |
| 94 | +# DIS-NEXT: jalr t1, t3 |
| 95 | +# DIS-NEXT: nop |
131 | 96 |
|
132 | | -## 32-bit (.got): &.got[weak]-. = 0x12070-0x11060 = 4096*1+16 |
133 | | -## 64-bit (.got): &.got[weak]-. = 0x120e0-0x11060 = 4096*1+128 |
134 | 97 | ## 32-bit (.got.plt): &.got.plt[weak]-. = 0x13090-0x11060 = 4096*2+48 |
135 | 98 | ## 64-bit (.got.plt): &.got.plt[weak]-. = 0x13120-0x11060 = 4096*2+192 |
136 | | -# DISGOT: 11060: auipcc t3, 1 |
137 | | -# DISGOTPLT: 11060: auipcc t3, 2 |
138 | | -# DISGOT32-NEXT: clc t3, 16(t3) |
139 | | -# DISGOT64-NEXT: clc t3, 128(t3) |
140 | | -# DISGOTPLT32-NEXT: lc t3, 48(t3) |
141 | | -# DISGOTPLT64-NEXT: lc t3, 192(t3) |
142 | | -# DIS-NEXT: cjalr t1, t3 |
143 | | -# DIS-NEXT: nop |
| 99 | +# DIS: 11060: auipcc t3, 2 |
| 100 | +# DIS32-NEXT: lc t3, 48(t3) |
| 101 | +# DIS64-NEXT: lc t3, 192(t3) |
| 102 | +# DIS-NEXT: jalr t1, t3 |
| 103 | +# DIS-NEXT: nop |
144 | 104 |
|
145 | 105 | .global _start, foo, bar |
146 | 106 | .weak weak |
|
0 commit comments