|
| 1 | +# REQUIRES: riscv |
| 2 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax a.s -o a.o |
| 4 | +# RUN: llvm-readobj -r -x .debug_rnglists -x .debug_loclists a.o | FileCheck %s --check-prefix=REL |
| 5 | +# RUN: ld.lld -shared --gc-sections a.o -o a.so |
| 6 | +# RUN: llvm-readelf -x .debug_rnglists -x .debug_loclists a.so | FileCheck %s |
| 7 | + |
| 8 | +# REL: .rela.debug_rnglists { |
| 9 | +# REL-NEXT: 0x0 R_RISCV_SET_ULEB128 w1 0x83 |
| 10 | +# REL-NEXT: 0x0 R_RISCV_SUB_ULEB128 w2 0x0 |
| 11 | +# REL-NEXT: 0x1 R_RISCV_SET_ULEB128 w2 0x78 |
| 12 | +# REL-NEXT: 0x1 R_RISCV_SUB_ULEB128 w1 0x0 |
| 13 | +# REL-NEXT: 0x3 R_RISCV_SET_ULEB128 w1 0x89 |
| 14 | +# REL-NEXT: 0x3 R_RISCV_SUB_ULEB128 w2 0x0 |
| 15 | +# REL-NEXT: 0x5 R_RISCV_SET_ULEB128 w2 0x3FF8 |
| 16 | +# REL-NEXT: 0x5 R_RISCV_SUB_ULEB128 w1 0x0 |
| 17 | +# REL-NEXT: 0x8 R_RISCV_SET_ULEB128 w1 0x4009 |
| 18 | +# REL-NEXT: 0x8 R_RISCV_SUB_ULEB128 w2 0x0 |
| 19 | +# REL-NEXT: 0xB R_RISCV_SET_ULEB128 w2 0x1FFFF8 |
| 20 | +# REL-NEXT: 0xB R_RISCV_SUB_ULEB128 w1 0x0 |
| 21 | +# REL-NEXT: 0xF R_RISCV_SET_ULEB128 w1 0x200009 |
| 22 | +# REL-NEXT: 0xF R_RISCV_SUB_ULEB128 w2 0x0 |
| 23 | +# REL-NEXT: } |
| 24 | +# REL: .rela.debug_loclists { |
| 25 | +# REL-NEXT: 0x0 R_RISCV_SET_ULEB128 w2 0x3 |
| 26 | +# REL-NEXT: 0x0 R_RISCV_SUB_ULEB128 w1 0x4 |
| 27 | +# REL-NEXT: 0x1 R_RISCV_SET_ULEB128 x2 0x0 |
| 28 | +# REL-NEXT: 0x1 R_RISCV_SUB_ULEB128 x1 0x0 |
| 29 | +# REL-NEXT: } |
| 30 | + |
| 31 | +# REL: Hex dump of section '.debug_rnglists': |
| 32 | +# REL-NEXT: 0x00000000 7b800181 01808001 81800180 80800181 { |
| 33 | +# REL-NEXT: 0x00000010 808001 . |
| 34 | +# REL: Hex dump of section '.debug_loclists': |
| 35 | +# REL-NEXT: 0x00000000 0008 . |
| 36 | + |
| 37 | +# CHECK: Hex dump of section '.debug_rnglists': |
| 38 | +# CHECK-NEXT: 0x00000000 7ffc0085 01fcff00 858001fc ffff0085 . |
| 39 | +# CHECK-NEXT: 0x00000010 808001 . |
| 40 | +# CHECK: Hex dump of section '.debug_loclists': |
| 41 | +# CHECK-NEXT: 0x00000000 0300 . |
| 42 | + |
| 43 | +# RUN: ld.lld -shared --gc-sections -z dead-reloc-in-nonalloc=.debug_loclists=0x7f a.o -o a127.so |
| 44 | +# RUN: llvm-readelf -x .debug_loclists a127.so | FileCheck %s --check-prefix=CHECK127 |
| 45 | +# CHECK127: Hex dump of section '.debug_loclists': |
| 46 | +# CHECK127-NEXT: 0x00000000 037f . |
| 47 | + |
| 48 | +# RUN: not ld.lld -shared --gc-sections -z dead-reloc-in-nonalloc=.debug_loclists=0x80 a.o 2>&1 | FileCheck %s --check-prefix=CHECK128 |
| 49 | +# CHECK128: error: a.o:(.debug_loclists+0x1): ULEB128 value 128 exceeds available space; references 'x2' |
| 50 | + |
| 51 | +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax sub.s -o sub.o |
| 52 | +# RUN: not ld.lld -shared sub.o 2>&1 | FileCheck %s --check-prefix=SUB |
| 53 | +# SUB: error: sub.o:(.debug_rnglists+0x8): unknown relocation (61) against symbol w2 |
| 54 | + |
| 55 | +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired1.s -o unpaired1.o |
| 56 | +# RUN: not ld.lld -shared unpaired1.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED |
| 57 | +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired2.s -o unpaired2.o |
| 58 | +# RUN: not ld.lld -shared unpaired2.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED |
| 59 | +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired3.s -o unpaired3.o |
| 60 | +# RUN: not ld.lld -shared unpaired3.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED |
| 61 | +# UNPAIRED: error: {{.*}}.o:(.debug_rnglists+0x8): R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128 |
| 62 | + |
| 63 | +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax overflow.s -o overflow.o |
| 64 | +# RUN: not ld.lld -shared overflow.o 2>&1 | FileCheck %s --check-prefix=OVERFLOW |
| 65 | +# OVERFLOW: error: overflow.o:(.debug_rnglists+0x8): ULEB128 value 128 exceeds available space; references 'w2' |
| 66 | + |
| 67 | +#--- a.s |
| 68 | +.section .text.w,"axR" |
| 69 | +w1: |
| 70 | + call foo # 4 bytes after relaxation |
| 71 | +w2: |
| 72 | + |
| 73 | +.section .text.x,"ax" |
| 74 | +x1: |
| 75 | + call foo # 4 bytes after relaxation |
| 76 | +x2: |
| 77 | + |
| 78 | +.section .debug_rnglists |
| 79 | +.uleb128 w1-w2+131 # initial value: 0x7b |
| 80 | +.uleb128 w2-w1+120 # initial value: 0x0180 |
| 81 | +.uleb128 w1-w2+137 # initial value: 0x0181 |
| 82 | +.uleb128 w2-w1+16376 # initial value: 0x018080 |
| 83 | +.uleb128 w1-w2+16393 # initial value: 0x018081 |
| 84 | +.uleb128 w2-w1+2097144 # initial value: 0x01808080 |
| 85 | +.uleb128 w1-w2+2097161 # initial value: 0x01808081 |
| 86 | + |
| 87 | +.section .debug_loclists |
| 88 | +.reloc ., R_RISCV_SET_ULEB128, w2+3 |
| 89 | +.reloc ., R_RISCV_SUB_ULEB128, w1+4 # SUB with a non-zero addend |
| 90 | +.byte 0 |
| 91 | +.uleb128 x2-x1 # references discarded symbols |
| 92 | + |
| 93 | +#--- sub.s |
| 94 | +w1: call foo; w2: |
| 95 | +.section .debug_rnglists |
| 96 | +.quad 0; |
| 97 | +.reloc ., R_RISCV_SUB_ULEB128, w2+120 |
| 98 | +.byte 0x7f |
| 99 | + |
| 100 | +#--- unpaired1.s |
| 101 | +w1: call foo; w2: |
| 102 | +.section .debug_rnglists |
| 103 | +.quad 0; |
| 104 | +.reloc ., R_RISCV_SET_ULEB128, w2+120 |
| 105 | +.byte 0x7f |
| 106 | + |
| 107 | +#--- unpaired2.s |
| 108 | +w1: call foo; w2: |
| 109 | +.section .debug_rnglists |
| 110 | +.quad 0 |
| 111 | +.reloc ., R_RISCV_SET_ULEB128, w2+120 |
| 112 | +.reloc .+1, R_RISCV_SUB_ULEB128, w1 |
| 113 | +.byte 0x7f |
| 114 | + |
| 115 | +#--- unpaired3.s |
| 116 | +w1: call foo; w2: |
| 117 | +.section .debug_rnglists |
| 118 | +.quad 0 |
| 119 | +.reloc ., R_RISCV_SET_ULEB128, w2+120 |
| 120 | +.reloc ., R_RISCV_SUB64, w1 |
| 121 | +.byte 0x7f |
| 122 | + |
| 123 | +#--- overflow.s |
| 124 | +w1: call foo; w2: |
| 125 | +.section .debug_rnglists |
| 126 | +.quad 0 |
| 127 | +.reloc ., R_RISCV_SET_ULEB128, w2+124 |
| 128 | +.reloc ., R_RISCV_SUB_ULEB128, w1 |
| 129 | +.byte 0x7f |
0 commit comments