| 1 |
# RUN: llvm-mc -triple riscv32 %s -filetype=obj -o %t32.o |
| 2 |
# RUN: llvm-mc -triple riscv64 %s -filetype=obj -o %t64.o |
| 3 |
# RUN: llvm-readelf -r %t32.o | FileCheck %s --check-prefix=GNU |
| 4 |
# RUN: llvm-readelf -r %t64.o | FileCheck %s --check-prefix=GNU |
| 5 |
# RUN: llvm-readobj -r %t32.o | FileCheck %s --check-prefix=LLVM |
| 6 |
# RUN: llvm-readobj -r %t64.o | FileCheck %s --check-prefix=LLVM |
| 7 |
|
| 8 |
## Test that llvm-readelf/llvm-readobj correctly resolves RISCV vendor-specific |
| 9 |
## relocation names when preceded by R_RISCV_VENDOR, and falls back to |
| 10 |
## R_RISCV_CUSTOM* when there is no preceding vendor relocation or the vendor |
| 11 |
## is unknown. |
| 12 |
|
| 13 |
.text |
| 14 |
nop |
| 15 |
|
| 16 |
## Test 1: Known vendor (QUALCOMM) - should resolve to vendor-specific name |
| 17 |
.reloc ., R_RISCV_VENDOR, QUALCOMM |
| 18 |
.reloc ., R_RISCV_CUSTOM192, foo |
| 19 |
nop |
| 20 |
|
| 21 |
## Test 2: Vendor symbol is consumed after one use per RISC-V psABI. |
| 22 |
## The second R_RISCV_CUSTOM192 without a preceding R_RISCV_VENDOR should |
| 23 |
## remain as R_RISCV_CUSTOM192. |
| 24 |
.reloc ., R_RISCV_CUSTOM192, bar |
| 25 |
nop |
| 26 |
|
| 27 |
## Test 3: Known vendor (ANDES) - should resolve to vendor-specific name |
| 28 |
.reloc ., R_RISCV_VENDOR, ANDES |
| 29 |
.reloc ., R_RISCV_CUSTOM241, baz |
| 30 |
nop |
| 31 |
|
| 32 |
## Test 4: Unknown vendor - should fall back to R_RISCV_CUSTOM* |
| 33 |
.reloc ., R_RISCV_VENDOR, UNKNOWN_VENDOR |
| 34 |
.reloc ., R_RISCV_CUSTOM200, qux |
| 35 |
nop |
| 36 |
|
| 37 |
## Test 5: Another known vendor after unknown - should work correctly |
| 38 |
.reloc ., R_RISCV_VENDOR, QUALCOMM |
| 39 |
.reloc ., R_RISCV_CUSTOM193, quux |
| 40 |
nop |
| 41 |
|
| 42 |
## Test 6: Unpaired R_RISCV_VENDOR followed by R_RISCV_CUSTOM* at a different |
| 43 |
## offset - should NOT be treated as a valid pair. |
| 44 |
.reloc . - 1, R_RISCV_VENDOR, QUALCOMM |
| 45 |
.reloc ., R_RISCV_CUSTOM193, barney |
| 46 |
nop |
| 47 |
|
| 48 |
## Test 7: A non-R_RISCV_CUSTOM* relocation in between a vendor relocation pair |
| 49 |
## breaks the pairing - R_RISCV_VENDOR must be immediately before the |
| 50 |
## vendor-specific relocation per psABI. |
| 51 |
.reloc ., R_RISCV_VENDOR, QUALCOMM |
| 52 |
.reloc ., R_RISCV_32, snork |
| 53 |
.reloc ., R_RISCV_CUSTOM193, zot |
| 54 |
nop |
| 55 |
|
| 56 |
# GNU: Relocation section '.rela.text' |
| 57 |
# GNU: R_RISCV_VENDOR {{.*}} QUALCOMM + 0 |
| 58 |
# GNU-NEXT: R_RISCV_QC_ABS20_U {{.*}} foo + 0 |
| 59 |
# GNU-NEXT: R_RISCV_CUSTOM192 {{.*}} bar + 0 |
| 60 |
# GNU-NEXT: R_RISCV_VENDOR {{.*}} ANDES + 0 |
| 61 |
# GNU-NEXT: R_RISCV_NDS_BRANCH_10 {{.*}} baz + 0 |
| 62 |
# GNU-NEXT: R_RISCV_VENDOR {{.*}} UNKNOWN_VENDOR + 0 |
| 63 |
# GNU-NEXT: R_RISCV_CUSTOM200 {{.*}} qux + 0 |
| 64 |
# GNU-NEXT: R_RISCV_VENDOR {{.*}} QUALCOMM + 0 |
| 65 |
# GNU-NEXT: R_RISCV_QC_E_BRANCH {{.*}} quux + 0 |
| 66 |
## Test 6: Different offsets - not a valid pair |
| 67 |
# GNU-NEXT: R_RISCV_VENDOR {{.*}} QUALCOMM + 0 |
| 68 |
# GNU-NEXT: R_RISCV_CUSTOM193 {{.*}} barney + 0 |
| 69 |
## Test 7: Intervening relocation - not a valid pair |
| 70 |
# GNU-NEXT: R_RISCV_VENDOR {{.*}} QUALCOMM + 0 |
| 71 |
# GNU-NEXT: R_RISCV_32 {{.*}} snork + 0 |
| 72 |
# GNU-NEXT: R_RISCV_CUSTOM193 {{.*}} zot + 0 |
| 73 |
|
| 74 |
# LLVM: Relocations [ |
| 75 |
# LLVM: R_RISCV_VENDOR QUALCOMM 0x0 |
| 76 |
# LLVM-NEXT: R_RISCV_QC_ABS20_U foo 0x0 |
| 77 |
# LLVM-NEXT: R_RISCV_CUSTOM192 bar 0x0 |
| 78 |
# LLVM-NEXT: R_RISCV_VENDOR ANDES 0x0 |
| 79 |
# LLVM-NEXT: R_RISCV_NDS_BRANCH_10 baz 0x0 |
| 80 |
# LLVM-NEXT: R_RISCV_VENDOR UNKNOWN_VENDOR 0x0 |
| 81 |
# LLVM-NEXT: R_RISCV_CUSTOM200 qux 0x0 |
| 82 |
# LLVM-NEXT: R_RISCV_VENDOR QUALCOMM 0x0 |
| 83 |
# LLVM-NEXT: R_RISCV_QC_E_BRANCH quux 0x0 |
| 84 |
## Test 6: Different offsets - not a valid pair |
| 85 |
# LLVM-NEXT: R_RISCV_VENDOR QUALCOMM 0x0 |
| 86 |
# LLVM-NEXT: R_RISCV_CUSTOM193 barney 0x0 |
| 87 |
## Test 7: Intervening relocation - not a valid pair |
| 88 |
# LLVM-NEXT: R_RISCV_VENDOR QUALCOMM 0x0 |
| 89 |
# LLVM-NEXT: R_RISCV_32 snork 0x0 |
| 90 |
# LLVM-NEXT: R_RISCV_CUSTOM193 zot 0x0 |