1 # Tests RISC-V relocations. We provide a .debug_info section with multiple
2 # DW_AT_high_pc entries (that's one of the attributes for which relocations are
3 # resolved by llvm-dwarfdump) and we add a relocation for each of them.
5 # RUN: yaml2obj %s | llvm-dwarfdump - | FileCheck %s
7 # To add more tests you need to modify the Content of the .debug_abbrev and
8 # .debug_info sections. To do that create a test.s which matches the assembly
9 # code below, run the command that follows and copy over the "Content" value of
10 # the respective sections:
14 # .section .debug_abbrev,"",@progbits
15 # .byte 1 # Abbreviation Code
16 # .byte 0x11 # DW_TAG_compile_unit
17 # .byte 0 # DW_CHILDREN_no
19 # # Add a DW_AT_high_pc for each relocation we test.
20 # .rept 14 # (UPDATE HERE)
21 # .byte 0x12 # DW_AT_high_pc
22 # .byte 0x01 # DW_FORM_addr
29 # .section .debug_info,"",@progbits
30 # .4byte 2+4+1+1+8*14 # Length of Unit (UPDATE HERE)
31 # .2byte 4 # DWARF version number
32 # .4byte .debug_abbrev # Offset Into Abbrev. Section
33 # .byte 8 # Address Size (in bytes)
35 # .8byte 0x00000000000042 # Test 1
36 # .8byte 0x00000000000042 # Test 2
37 # .8byte 0x00000000000042 # Test 3
38 # .8byte 0x00000000000042 # Test 4
39 # .8byte 0x00000000000042 # Test 5
40 # .8byte 0x00000000000042 # Test 6
41 # .8byte 0x00000000000042 # Test 7
42 # .8byte 0x00000000000042 # Test 8
43 # .8byte 0x00000000004242 # Test 9
44 # .8byte 0x00000000004242 # Test 10
45 # .8byte 0x00000042424242 # Test 11
46 # .8byte 0x00000042424242 # Test 12
47 # .8byte 0x42424242424242 # Test 13
48 # .8byte 0x42424242424242 # Test 14
49 # $ llvm-mc test.s -filetype obj -triple riscv64 -o - | obj2yaml
61 Content: 01110012011201120112011201120112011201120112011201120112011201000000
64 Content: 78000000040000000000080142000000000000004200000000000000420000000000000042000000000000004200000000000000420000000000000042000000000000004200000000000000424200000000000042420000000000004242424200000000424242420000000042424242424242004242424242424200
65 - Name: .rela.debug_info
67 Flags: [ SHF_INFO_LINK ]
69 EntSize: 0x0000000000000018
74 # 0x42 with R_RISCV_NONE(0x1) = 0x42
75 # CHECK: DW_AT_high_pc (0x0000000000000042)
76 - Offset: 0x000000000000000C # 0xC + 8*0
81 # 0x42 with R_RISCV_32(0xFFFFFFFFFFFFFFFF) = 0x00000000FFFFFFFF
82 # CHECK-NEXT: DW_AT_high_pc (0x00000000ffffffff)
83 - Offset: 0x0000000000000014 # 0xC + 8*1
84 Symbol: vFFFFFFFFFFFFFFFF
88 # 0x42 with R_RISCV_32_PCREL(0x4) = 0x4-0x1C = 0x00000000FFFFFFE8
89 # CHECK-NEXT: DW_AT_high_pc (0x00000000ffffffe8)
90 - Offset: 0x000000000000001C # 0xC + 8*2
92 Type: R_RISCV_32_PCREL
95 # 0x42 with R_RISCV_64(0xFFFFFFFFFFFFFFFF) = 0xFFFFFFFFFFFFFFFF
96 # CHECK-NEXT: DW_AT_high_pc (0xffffffffffffffff)
97 - Offset: 0x0000000000000024 # 0xC + 8*3
98 Symbol: vFFFFFFFFFFFFFFFF
102 # 0x42 with R_RISCV_SET6(1) = 0x41
103 # CHECK-NEXT: DW_AT_high_pc (0x0000000000000041)
104 - Offset: 0x000000000000002C # 0xC + 8*4
109 # 0x42 with R_RISCV_SUB6(0x4) = 0x7E
110 # CHECK-NEXT: DW_AT_high_pc (0x000000000000007e)
111 - Offset: 0x0000000000000034 # 0xC + 8*5
116 # 0x42 with R_RISCV_ADD8(0x04020103) = 0x45
117 # CHECK-NEXT: DW_AT_high_pc (0x0000000000000045)
118 - Offset: 0x000000000000003C # 0xC + 8*6
123 # 0x42 with R_RISCV_SUB8(0x04020103) = 0x3F
124 # CHECK-NEXT: DW_AT_high_pc (0x000000000000003f)
125 - Offset: 0x0000000000000044 # 0xC + 8*7
130 # 0x4242 with R_RISCV_ADD16(0x04020103) = 0x4345
131 # CHECK-NEXT: DW_AT_high_pc (0x0000000000004345)
132 - Offset: 0x000000000000004C # 0xC + 8*8
137 # 0x4242 with R_RISCV_SUB16(0x04020103) = 0x413F
138 # CHECK-NEXT: DW_AT_high_pc (0x000000000000413f)
139 - Offset: 0x0000000000000054 # 0xC + 8*9
144 # 0x42424242 with R_RISCV_ADD32(0x04020103) = 0x46444345
145 # CHECK-NEXT: DW_AT_high_pc (0x0000000046444345)
146 - Offset: 0x000000000000005C # 0xC + 8*10
151 # 0x42424242 with R_RISCV_SUB32(0x04020103) = 0x3E40413F
152 # CHECK-NEXT: DW_AT_high_pc (0x000000003e40413f)
153 - Offset: 0x0000000000000064 # 0xC + 8*11
158 # 0x0042424242424242 with R_RISCV_ADD64(0x0100000000000000) = 0x0142424242424242
159 # CHECK-NEXT: DW_AT_high_pc (0x0142424242424242)
160 - Offset: 0x000000000000006C # 0xC + 8*12
161 Symbol: v0100000000000000
165 # 0x0042424242424242 with R_RISCV_SUB64(0x0100000000000000) = 0xFF42424242424242
166 # CHECK-NEXT: DW_AT_high_pc (0xff42424242424242)
167 - Offset: 0x0000000000000074 # 0xC + 8*13
168 Symbol: v0100000000000000
175 Value: 0x0000000000000001
179 Value: 0x0000000000000004
183 Value: 0x0000000004020103
184 - Name: vFFFFFFFFFFFFFFFF
187 Value: 0xFFFFFFFFFFFFFFFF
188 - Name: v0100000000000000
191 Value: 0x0100000000000000