1 # REQUIRES: bpf-registered-target
3 ## Verify that when llvm-objdump uses .BTF.ext to show CO-RE
4 ## relocations formatting options operate as expected.
6 # RUN: llvm-mc --triple bpfel %s --filetype=obj | \
7 # RUN: llvm-objdump --no-addresses --no-show-raw-insn -dr - | \
8 # RUN: FileCheck --strict-whitespace --check-prefix=NOADDR %s
10 # RUN: llvm-mc --triple bpfel %s --filetype=obj | \
11 # RUN: llvm-objdump --no-addresses --no-show-raw-insn -d - | \
12 # RUN: FileCheck --strict-whitespace --check-prefix=NORELO %s
14 # RUN: llvm-mc --triple bpfel %s --filetype=obj | \
15 # RUN: llvm-objdump --no-show-raw-insn -dr - | \
16 # RUN: FileCheck --strict-whitespace --check-prefix=ADDR %s
18 # RUN: llvm-mc --triple bpfel %s --filetype=obj | \
19 # RUN: llvm-objdump --adjust-vma=0x10 --no-show-raw-insn -dr - | \
20 # RUN: FileCheck --strict-whitespace --check-prefix=VMA %s
22 ## Input generated from the following C code:
24 ## #define __pai __attribute__((preserve_access_index))
29 ## extern void consume(unsigned long);
31 ## asm volatile("r0 = 42;":::);
32 ## struct foo *foo = 0;
33 ## consume(__builtin_preserve_type_info(*foo, 0));
34 ## consume((unsigned long) &foo->a);
35 ## consume(__builtin_preserve_enum_value(*(enum bar *)U, 0));
38 ## Using the following command:
40 ## clang -target bpf -g -O2 -S t.c
43 # NOADDR-NEXT: CO-RE <type_exists> [3] struct foo
44 # NOADDR-NEXT: call -0x1
45 # NOADDR-NEXT: R_BPF_64_32 consume
46 # NOADDR-NEXT: r1 = 0x0
47 # NOADDR-NEXT: CO-RE <byte_off> [3] struct foo::a (0:0)
48 # NOADDR-NEXT: call -0x1
49 # NOADDR-NEXT: R_BPF_64_32 consume
50 # NOADDR-NEXT: r1 = 0x1 ll
51 # NOADDR-NEXT: CO-RE <enumval_exists> [8] enum bar::U = 0
52 # NOADDR-NEXT: call -0x1
53 # NOADDR-NEXT: R_BPF_64_32 consume
57 # NORELO-NEXT: call -0x1
58 # NORELO-NEXT: r1 = 0x0
59 # NORELO-NEXT: call -0x1
60 # NORELO-NEXT: r1 = 0x1 ll
61 # NORELO-NEXT: call -0x1
65 # ADDR-NEXT: 0000000000000008: CO-RE <type_exists> [3] struct foo
66 # ADDR-NEXT: 2: call -0x1
67 # ADDR-NEXT: 0000000000000010: R_BPF_64_32 consume
68 # ADDR-NEXT: 3: r1 = 0x0
69 # ADDR-NEXT: 0000000000000018: CO-RE <byte_off> [3] struct foo::a (0:0)
70 # ADDR-NEXT: 4: call -0x1
71 # ADDR-NEXT: 0000000000000020: R_BPF_64_32 consume
72 # ADDR-NEXT: 5: r1 = 0x1 ll
73 # ADDR-NEXT: 0000000000000028: CO-RE <enumval_exists> [8] enum bar::U = 0
74 # ADDR-NEXT: 7: call -0x1
75 # ADDR-NEXT: 0000000000000038: R_BPF_64_32 consume
79 # VMA-NEXT: 0000000000000018: CO-RE <type_exists> [3] struct foo
80 # VMA-NEXT: 4: call -0x1
81 # VMA-NEXT: 0000000000000010: R_BPF_64_32 consume
82 # VMA-NEXT: 5: r1 = 0x0
83 # VMA-NEXT: 0000000000000028: CO-RE <byte_off> [3] struct foo::a (0:0)
84 # VMA-NEXT: 6: call -0x1
85 # VMA-NEXT: 0000000000000020: R_BPF_64_32 consume
86 # VMA-NEXT: 7: r1 = 0x1 ll
87 # VMA-NEXT: 0000000000000038: CO-RE <enumval_exists> [8] enum bar::U = 0
88 # VMA-NEXT: 9: call -0x1
89 # VMA-NEXT: 0000000000000038: R_BPF_64_32 consume
94 .file 0 "/home/eddy/work/tmp" "t.c" md5 0x7675be79a30f35c69b89cf826ff55a5f
95 .globl root # -- Begin function root
100 .cfi_sections .debug_frame
103 .loc 0 8 3 prologue_end # t.c:8:3
111 #DEBUG_VALUE: root:foo <- 0
112 .loc 0 10 3 # t.c:10:3
118 .loc 0 11 3 # t.c:11:3
124 .loc 0 12 3 # t.c:12:3
130 .loc 0 13 1 # t.c:13:1
136 .size root, .Lfunc_end0-root
139 .section .debug_loclists,"",@progbits
140 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
141 .Ldebug_list_header_start0:
143 .byte 8 # Address size
144 .byte 0 # Segment selector size
145 .long 1 # Offset entry count
146 .Lloclists_table_base0:
147 .long .Ldebug_loc0-.Lloclists_table_base0
149 .byte 4 # DW_LLE_offset_pair
150 .uleb128 .Ltmp1-.Lfunc_begin0 # starting offset
151 .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset
152 .byte 2 # Loc expr size
153 .byte 48 # DW_OP_lit0
154 .byte 159 # DW_OP_stack_value
155 .byte 0 # DW_LLE_end_of_list
156 .Ldebug_list_header_end0:
157 .section .debug_abbrev,"",@progbits
158 .byte 1 # Abbreviation Code
159 .byte 17 # DW_TAG_compile_unit
160 .byte 1 # DW_CHILDREN_yes
161 .byte 37 # DW_AT_producer
162 .byte 37 # DW_FORM_strx1
163 .byte 19 # DW_AT_language
164 .byte 5 # DW_FORM_data2
166 .byte 37 # DW_FORM_strx1
167 .byte 114 # DW_AT_str_offsets_base
168 .byte 23 # DW_FORM_sec_offset
169 .byte 16 # DW_AT_stmt_list
170 .byte 23 # DW_FORM_sec_offset
171 .byte 27 # DW_AT_comp_dir
172 .byte 37 # DW_FORM_strx1
173 .byte 17 # DW_AT_low_pc
174 .byte 27 # DW_FORM_addrx
175 .byte 18 # DW_AT_high_pc
176 .byte 6 # DW_FORM_data4
177 .byte 115 # DW_AT_addr_base
178 .byte 23 # DW_FORM_sec_offset
179 .ascii "\214\001" # DW_AT_loclists_base
180 .byte 23 # DW_FORM_sec_offset
183 .byte 2 # Abbreviation Code
184 .byte 4 # DW_TAG_enumeration_type
185 .byte 1 # DW_CHILDREN_yes
186 .byte 73 # DW_AT_type
187 .byte 19 # DW_FORM_ref4
189 .byte 37 # DW_FORM_strx1
190 .byte 11 # DW_AT_byte_size
191 .byte 11 # DW_FORM_data1
192 .byte 58 # DW_AT_decl_file
193 .byte 11 # DW_FORM_data1
194 .byte 59 # DW_AT_decl_line
195 .byte 11 # DW_FORM_data1
198 .byte 3 # Abbreviation Code
199 .byte 40 # DW_TAG_enumerator
200 .byte 0 # DW_CHILDREN_no
202 .byte 37 # DW_FORM_strx1
203 .byte 28 # DW_AT_const_value
204 .byte 15 # DW_FORM_udata
207 .byte 4 # Abbreviation Code
208 .byte 36 # DW_TAG_base_type
209 .byte 0 # DW_CHILDREN_no
211 .byte 37 # DW_FORM_strx1
212 .byte 62 # DW_AT_encoding
213 .byte 11 # DW_FORM_data1
214 .byte 11 # DW_AT_byte_size
215 .byte 11 # DW_FORM_data1
218 .byte 5 # Abbreviation Code
219 .byte 46 # DW_TAG_subprogram
220 .byte 1 # DW_CHILDREN_yes
221 .byte 17 # DW_AT_low_pc
222 .byte 27 # DW_FORM_addrx
223 .byte 18 # DW_AT_high_pc
224 .byte 6 # DW_FORM_data4
225 .byte 64 # DW_AT_frame_base
226 .byte 24 # DW_FORM_exprloc
227 .byte 122 # DW_AT_call_all_calls
228 .byte 25 # DW_FORM_flag_present
230 .byte 37 # DW_FORM_strx1
231 .byte 58 # DW_AT_decl_file
232 .byte 11 # DW_FORM_data1
233 .byte 59 # DW_AT_decl_line
234 .byte 11 # DW_FORM_data1
235 .byte 63 # DW_AT_external
236 .byte 25 # DW_FORM_flag_present
239 .byte 6 # Abbreviation Code
240 .byte 52 # DW_TAG_variable
241 .byte 0 # DW_CHILDREN_no
242 .byte 2 # DW_AT_location
243 .byte 34 # DW_FORM_loclistx
245 .byte 37 # DW_FORM_strx1
246 .byte 58 # DW_AT_decl_file
247 .byte 11 # DW_FORM_data1
248 .byte 59 # DW_AT_decl_line
249 .byte 11 # DW_FORM_data1
250 .byte 73 # DW_AT_type
251 .byte 19 # DW_FORM_ref4
254 .byte 7 # Abbreviation Code
255 .byte 72 # DW_TAG_call_site
256 .byte 0 # DW_CHILDREN_no
257 .byte 127 # DW_AT_call_origin
258 .byte 19 # DW_FORM_ref4
259 .byte 125 # DW_AT_call_return_pc
260 .byte 27 # DW_FORM_addrx
263 .byte 8 # Abbreviation Code
264 .byte 46 # DW_TAG_subprogram
265 .byte 1 # DW_CHILDREN_yes
267 .byte 37 # DW_FORM_strx1
268 .byte 58 # DW_AT_decl_file
269 .byte 11 # DW_FORM_data1
270 .byte 59 # DW_AT_decl_line
271 .byte 11 # DW_FORM_data1
272 .byte 39 # DW_AT_prototyped
273 .byte 25 # DW_FORM_flag_present
274 .byte 60 # DW_AT_declaration
275 .byte 25 # DW_FORM_flag_present
276 .byte 63 # DW_AT_external
277 .byte 25 # DW_FORM_flag_present
280 .byte 9 # Abbreviation Code
281 .byte 5 # DW_TAG_formal_parameter
282 .byte 0 # DW_CHILDREN_no
283 .byte 73 # DW_AT_type
284 .byte 19 # DW_FORM_ref4
287 .byte 10 # Abbreviation Code
288 .byte 15 # DW_TAG_pointer_type
289 .byte 0 # DW_CHILDREN_no
290 .byte 73 # DW_AT_type
291 .byte 19 # DW_FORM_ref4
294 .byte 11 # Abbreviation Code
295 .byte 19 # DW_TAG_structure_type
296 .byte 1 # DW_CHILDREN_yes
298 .byte 37 # DW_FORM_strx1
299 .byte 11 # DW_AT_byte_size
300 .byte 11 # DW_FORM_data1
301 .byte 58 # DW_AT_decl_file
302 .byte 11 # DW_FORM_data1
303 .byte 59 # DW_AT_decl_line
304 .byte 11 # DW_FORM_data1
307 .byte 12 # Abbreviation Code
308 .byte 13 # DW_TAG_member
309 .byte 0 # DW_CHILDREN_no
311 .byte 37 # DW_FORM_strx1
312 .byte 73 # DW_AT_type
313 .byte 19 # DW_FORM_ref4
314 .byte 58 # DW_AT_decl_file
315 .byte 11 # DW_FORM_data1
316 .byte 59 # DW_AT_decl_line
317 .byte 11 # DW_FORM_data1
318 .byte 56 # DW_AT_data_member_location
319 .byte 11 # DW_FORM_data1
323 .section .debug_info,"",@progbits
325 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
327 .short 5 # DWARF version number
328 .byte 1 # DWARF Unit Type
329 .byte 8 # Address Size (in bytes)
330 .long .debug_abbrev # Offset Into Abbrev. Section
331 .byte 1 # Abbrev [1] 0xc:0x7d DW_TAG_compile_unit
332 .byte 0 # DW_AT_producer
333 .short 29 # DW_AT_language
335 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
336 .long .Lline_table_start0 # DW_AT_stmt_list
337 .byte 2 # DW_AT_comp_dir
338 .byte 0 # DW_AT_low_pc
339 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
340 .long .Laddr_table_base0 # DW_AT_addr_base
341 .long .Lloclists_table_base0 # DW_AT_loclists_base
342 .byte 2 # Abbrev [2] 0x27:0x10 DW_TAG_enumeration_type
343 .long 55 # DW_AT_type
345 .byte 4 # DW_AT_byte_size
346 .byte 0 # DW_AT_decl_file
347 .byte 5 # DW_AT_decl_line
348 .byte 3 # Abbrev [3] 0x30:0x3 DW_TAG_enumerator
350 .byte 0 # DW_AT_const_value
351 .byte 3 # Abbrev [3] 0x33:0x3 DW_TAG_enumerator
353 .byte 1 # DW_AT_const_value
354 .byte 0 # End Of Children Mark
355 .byte 4 # Abbrev [4] 0x37:0x4 DW_TAG_base_type
357 .byte 7 # DW_AT_encoding
358 .byte 4 # DW_AT_byte_size
359 .byte 4 # Abbrev [4] 0x3b:0x4 DW_TAG_base_type
361 .byte 7 # DW_AT_encoding
362 .byte 8 # DW_AT_byte_size
363 .byte 5 # Abbrev [5] 0x3f:0x27 DW_TAG_subprogram
364 .byte 0 # DW_AT_low_pc
365 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
366 .byte 1 # DW_AT_frame_base
368 # DW_AT_call_all_calls
370 .byte 0 # DW_AT_decl_file
371 .byte 7 # DW_AT_decl_line
373 .byte 6 # Abbrev [6] 0x4a:0x9 DW_TAG_variable
374 .byte 0 # DW_AT_location
375 .byte 10 # DW_AT_name
376 .byte 0 # DW_AT_decl_file
377 .byte 9 # DW_AT_decl_line
378 .long 112 # DW_AT_type
379 .byte 7 # Abbrev [7] 0x53:0x6 DW_TAG_call_site
380 .long 102 # DW_AT_call_origin
381 .byte 1 # DW_AT_call_return_pc
382 .byte 7 # Abbrev [7] 0x59:0x6 DW_TAG_call_site
383 .long 102 # DW_AT_call_origin
384 .byte 2 # DW_AT_call_return_pc
385 .byte 7 # Abbrev [7] 0x5f:0x6 DW_TAG_call_site
386 .long 102 # DW_AT_call_origin
387 .byte 3 # DW_AT_call_return_pc
388 .byte 0 # End Of Children Mark
389 .byte 8 # Abbrev [8] 0x66:0xa DW_TAG_subprogram
391 .byte 0 # DW_AT_decl_file
392 .byte 6 # DW_AT_decl_line
396 .byte 9 # Abbrev [9] 0x6a:0x5 DW_TAG_formal_parameter
397 .long 59 # DW_AT_type
398 .byte 0 # End Of Children Mark
399 .byte 10 # Abbrev [10] 0x70:0x5 DW_TAG_pointer_type
400 .long 117 # DW_AT_type
401 .byte 11 # Abbrev [11] 0x75:0xf DW_TAG_structure_type
402 .byte 10 # DW_AT_name
403 .byte 4 # DW_AT_byte_size
404 .byte 0 # DW_AT_decl_file
405 .byte 2 # DW_AT_decl_line
406 .byte 12 # Abbrev [12] 0x7a:0x9 DW_TAG_member
407 .byte 11 # DW_AT_name
408 .long 132 # DW_AT_type
409 .byte 0 # DW_AT_decl_file
410 .byte 3 # DW_AT_decl_line
411 .byte 0 # DW_AT_data_member_location
412 .byte 0 # End Of Children Mark
413 .byte 4 # Abbrev [4] 0x84:0x4 DW_TAG_base_type
414 .byte 12 # DW_AT_name
415 .byte 5 # DW_AT_encoding
416 .byte 4 # DW_AT_byte_size
417 .byte 0 # End Of Children Mark
419 .section .debug_str_offsets,"",@progbits
420 .long 56 # Length of String Offsets Set
424 .section .debug_str,"MS",@progbits,1
426 .asciz "clang version 17.0.0 (/home/eddy/work/llvm-project/clang 76d673bb89f8ec8cf65a4294a98a83c9d6646b11)" # string offset=0
428 .asciz "t.c" # string offset=99
430 .asciz "/home/eddy/work/tmp" # string offset=103
432 .asciz "unsigned int" # string offset=123
434 .asciz "U" # string offset=136
436 .asciz "V" # string offset=138
438 .asciz "bar" # string offset=140
440 .asciz "unsigned long" # string offset=144
442 .asciz "consume" # string offset=158
444 .asciz "root" # string offset=166
446 .asciz "foo" # string offset=171
448 .asciz "a" # string offset=175
450 .asciz "int" # string offset=177
451 .section .debug_str_offsets,"",@progbits
462 .long .Linfo_string10
463 .long .Linfo_string11
464 .long .Linfo_string12
465 .section .debug_addr,"",@progbits
466 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
468 .short 5 # DWARF version number
469 .byte 8 # Address size
470 .byte 0 # Segment selector size
477 .section .BTF,"",@progbits
478 .short 60319 # 0xeb9f
486 .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
487 .long 218103808 # 0xd000000
489 .long 1 # BTF_KIND_FUNC(id = 2)
490 .long 201326593 # 0xc000001
492 .long 67 # BTF_KIND_STRUCT(id = 3)
493 .long 67108865 # 0x4000001
498 .long 73 # BTF_KIND_INT(id = 4)
499 .long 16777216 # 0x1000000
501 .long 16777248 # 0x1000020
502 .long 0 # BTF_KIND_FUNC_PROTO(id = 5)
503 .long 218103809 # 0xd000001
507 .long 129 # BTF_KIND_INT(id = 6)
508 .long 16777216 # 0x1000000
511 .long 143 # BTF_KIND_FUNC(id = 7)
512 .long 201326594 # 0xc000002
514 .long 191 # BTF_KIND_ENUM(id = 8)
515 .long 100663298 # 0x6000002
521 .byte 0 # string offset=0
522 .ascii "root" # string offset=1
524 .ascii ".text" # string offset=6
526 .ascii "/home/eddy/work/tmp/t.c" # string offset=12
528 .ascii " asm volatile(\"r0 = 42;\":::);" # string offset=36
530 .ascii "foo" # string offset=67
532 .byte 97 # string offset=71
534 .ascii "int" # string offset=73
536 .byte 48 # string offset=77
538 .ascii " consume(__builtin_preserve_type_info(*foo, 0));" # string offset=79
540 .ascii "unsigned long" # string offset=129
542 .ascii "consume" # string offset=143
544 .ascii "0:0" # string offset=151
546 .ascii " consume((unsigned long) &foo->a);" # string offset=155
548 .ascii "bar" # string offset=191
550 .byte 85 # string offset=195
552 .byte 86 # string offset=197
554 .ascii " consume(__builtin_preserve_enum_value(*(enum bar *)U, 0));" # string offset=199
556 .byte 125 # string offset=260
558 .section .BTF.ext,"",@progbits
559 .short 60319 # 0xeb9f
570 .long 6 # FuncInfo section string offset=6
575 .long 6 # LineInfo section string offset=6
580 .long 8195 # Line 8 Col 3
584 .long 10243 # Line 10 Col 3
588 .long 11267 # Line 11 Col 3
592 .long 12291 # Line 12 Col 3
596 .long 13313 # Line 13 Col 1
597 .long 16 # FieldReloc
598 .long 6 # Field reloc section string offset=6
613 .section .debug_line,"",@progbits