|
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 |
8 | | -# RUN: llvm-readelf -S -s %t.32 | FileCheck --check-prefixes=SEC,NM %s |
9 | | -# RUN: llvm-readobj -r %t.32 | FileCheck --check-prefix=RELOC32 %s |
10 | | -# RUN: llvm-readelf -x .got %t.32 | FileCheck --check-prefix=GOT32 %s |
11 | | -# RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=DIS,DIS32 %s |
| 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 %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 %t.32.got.plt | FileCheck --check-prefixes=DIS,DISGOTPLT,DISGOTPLT32 %s |
12 | 17 |
|
13 | 18 | # RUN: %riscv64_cheri_purecap_llvm-mc -filetype=obj %t1.s -o %t1.64.o |
14 | 19 | # RUN: ld.lld -shared %t1.64.o -soname=t1.64.so -o %t1.64.so |
15 | 20 | # RUN: %riscv64_cheri_purecap_llvm-mc -filetype=obj %s -o %t.64.o |
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 %t.64 | FileCheck --check-prefix=RELOC64 %s |
19 | | -# RUN: llvm-readelf -x .got %t.64 | FileCheck --check-prefix=GOT64 %s |
20 | | -# RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=DIS,DIS64 %s |
| 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 %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 %t.64.got.plt | FileCheck --check-prefixes=DIS,DISGOTPLT,DISGOTPLT64 %s |
21 | 31 |
|
22 | 32 | # SEC: .plt PROGBITS {{0*}}00011030 |
23 | 33 |
|
|
26 | 36 | # NM: {{0*}}00000000 0 FUNC GLOBAL DEFAULT UND bar |
27 | 37 | # NM: {{0*}}00000000 0 FUNC WEAK DEFAULT UND weak |
28 | 38 |
|
29 | | -# RELOC32: .rela.dyn { |
30 | | -# RELOC32-NEXT: 0x12068 R_RISCV_CHERI_CAPABILITY bar 0x0 |
31 | | -# RELOC32-NEXT: 0x12070 R_RISCV_CHERI_CAPABILITY weak 0x0 |
32 | | -# RELOC32-NEXT: } |
| 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. |
33 | 44 | # GOT32: section '.got' |
34 | 45 | # GOT32-NEXT: 0x00012060 00200100 00000000 00000000 00000000 |
35 | 46 | # GOT32-NEXT: 0x00012070 00000000 00000000 |
36 | 47 |
|
37 | | -# RELOC64: .rela.dyn { |
38 | | -# RELOC64-NEXT: 0x120D0 R_RISCV_CHERI_CAPABILITY bar 0x0 |
39 | | -# RELOC64-NEXT: 0x120E0 R_RISCV_CHERI_CAPABILITY weak 0x0 |
40 | | -# RELOC64-NEXT: } |
| 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: ] |
| 56 | +# GOTPLT32: section '.got.plt' |
| 57 | +# GOTPLT32-NEXT: 0x00013078 00000000 00000000 00000000 00000000 |
| 58 | +# GOTPLT32-NEXT: 0x00013088 00000000 00000000 00000000 00000000 |
| 59 | + |
| 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. |
41 | 65 | # GOT64: section '.got' |
42 | 66 | # GOT64-NEXT: 0x000120c0 00200100 00000000 00000000 00000000 |
43 | 67 | # GOT64-NEXT: 0x000120d0 00000000 00000000 00000000 00000000 |
44 | 68 | # GOT64-NEXT: 0x000120e0 00000000 00000000 00000000 00000000 |
45 | 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: ] |
| 78 | +# GOTPLT64: section '.got.plt' |
| 79 | +# GOTPLT64-NEXT: 0x000130f0 00000000 00000000 00000000 00000000 |
| 80 | +# GOTPLT64-NEXT: 0x00013100 00000000 00000000 00000000 00000000 |
| 81 | +# GOTPLT64-NEXT: 0x00013110 00000000 00000000 00000000 00000000 |
| 82 | +# GOTPLT64-NEXT: 0x00013120 00000000 00000000 00000000 00000000 |
| 83 | + |
46 | 84 | # DIS: <_start>: |
47 | 85 | ## Direct call |
48 | 86 | ## foo - . = 0x11020-0x11000 = 32 |
|
60 | 98 | # DIS: <foo>: |
61 | 99 | # DIS-NEXT: 11020: |
62 | 100 |
|
63 | | -# DIS: Disassembly of section .plt: |
64 | | -# DIS: <.plt>: |
65 | | -# DIS-NEXT: ... |
| 101 | +# DIS: Disassembly of section .plt: |
| 102 | +# DIS: <.plt>: |
| 103 | +# DISGOT-NEXT: ... |
| 104 | +# DISGOTPLT-NEXT: auipcc ct2, 2 |
| 105 | +# DISGOTPLT-NEXT: sub t1, t1, t3 |
| 106 | +## 32-bit: .got.plt - .plt = 0x13078 - 0x11030 = 4096*2+72 |
| 107 | +## 64-bit: .got.plt - .plt = 0x130f0 - 0x11030 = 4096*2+192 |
| 108 | +# DISGOTPLT32-NEXT: lc ct3, 72(ct2) |
| 109 | +# DISGOTPLT64-NEXT: lc ct3, 192(ct2) |
| 110 | +# DISGOTPLT-NEXT: addi t1, t1, -44 |
| 111 | +# DISGOTPLT32-NEXT: cincoffset ct0, ct2, 72 |
| 112 | +# DISGOTPLT64-NEXT: cincoffset ct0, ct2, 192 |
| 113 | +# DISGOTPLT32-NEXT: srli t1, t1, 1 |
| 114 | +# DISGOTPLT32-NEXT: lc ct0, 8(ct0) |
| 115 | +# DISGOTPLT64-NEXT: lc ct0, 16(ct0) |
| 116 | +# DISGOTPLT-NEXT: jr ct3 |
| 117 | +# DISGOTPLT64-NEXT: nop |
66 | 118 |
|
67 | | -## 32-bit: &.got[bar]-. = 0x12068-0x11050 = 4096*1+24 |
68 | | -## 64-bit: &.got[bar]-. = 0x120d0-0x11050 = 4096*1+128 |
69 | | -# DIS: 11050: auipcc ct3, 1 |
70 | | -# DIS32-NEXT: lc ct3, 24(ct3) |
71 | | -# DIS64-NEXT: lc ct3, 128(ct3) |
72 | | -# DIS-NEXT: jalr ct1, ct3 |
73 | | -# DIS-NEXT: nop |
| 119 | +## 32-bit (.got): &.got[bar]-. = 0x12068-0x11050 = 4096*1+24 |
| 120 | +## 64-bit (.got): &.got[bar]-. = 0x120d0-0x11050 = 4096*1+128 |
| 121 | +## 32-bit (.got.plt): &.got.plt[bar]-. = 0x13088-0x11050 = 4096*2+56 |
| 122 | +## 64-bit (.got.plt): &.got.plt[bar]-. = 0x13110-0x11050 = 4096*2+192 |
| 123 | +# DISGOT: 11050: auipcc ct3, 1 |
| 124 | +# DISGOTPLT: 11050: auipcc ct3, 2 |
| 125 | +# DISGOT32-NEXT: lc ct3, 24(ct3) |
| 126 | +# DISGOT64-NEXT: lc ct3, 128(ct3) |
| 127 | +# DISGOTPLT32-NEXT: lc ct3, 56(ct3) |
| 128 | +# DISGOTPLT64-NEXT: lc ct3, 192(ct3) |
| 129 | +# DIS-NEXT: jalr ct1, ct3 |
| 130 | +# DIS-NEXT: nop |
74 | 131 |
|
75 | | -## 32-bit: &.got[weak]-. = 0x12070-0x11060 = 4096*1+16 |
76 | | -## 64-bit: &.got[weak]-. = 0x120e0-0x11060 = 4096*1+128 |
77 | | -# DIS: 11060: auipcc ct3, 1 |
78 | | -# DIS32-NEXT: lc ct3, 16(ct3) |
79 | | -# DIS64-NEXT: lc ct3, 128(ct3) |
80 | | -# DIS-NEXT: jalr ct1, ct3 |
81 | | -# DIS-NEXT: nop |
| 132 | +## 32-bit (.got): &.got[weak]-. = 0x12070-0x11060 = 4096*1+16 |
| 133 | +## 64-bit (.got): &.got[weak]-. = 0x120e0-0x11060 = 4096*1+128 |
| 134 | +## 32-bit (.got.plt): &.got.plt[weak]-. = 0x13090-0x11060 = 4096*2+48 |
| 135 | +## 64-bit (.got.plt): &.got.plt[weak]-. = 0x13120-0x11060 = 4096*2+192 |
| 136 | +# DISGOT: 11060: auipcc ct3, 1 |
| 137 | +# DISGOTPLT: 11060: auipcc ct3, 2 |
| 138 | +# DISGOT32-NEXT: lc ct3, 16(ct3) |
| 139 | +# DISGOT64-NEXT: lc ct3, 128(ct3) |
| 140 | +# DISGOTPLT32-NEXT: lc ct3, 48(ct3) |
| 141 | +# DISGOTPLT64-NEXT: lc ct3, 192(ct3) |
| 142 | +# DIS-NEXT: jalr ct1, ct3 |
| 143 | +# DIS-NEXT: nop |
82 | 144 |
|
83 | 145 | .global _start, foo, bar |
84 | 146 | .weak weak |
|
0 commit comments