[lld] [lld][ELF] Implement merged .debug_names section. (PR #86508)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 22:12:13 PDT 2024
================
@@ -0,0 +1,294 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/debug-names-2.s -o %t2.o
+# RUN: ld.lld --debug-names %t1.o %t2.o -o %t
+
+# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DISASM
+# RUN: llvm-dwarfdump -debug-names %t | FileCheck %s --check-prefix=DWARF
+# RUN: llvm-readelf -SW %t | FileCheck %s --check-prefix=READELF
+
+# DISASM: Disassembly of section .text:
+# DISASM-EMPTY:
+# DISASM: <_Z2f12t1>:
+# DISASM-CHECK: 201180: 55 pushq %rbp
+# DISASM-CHECK: 201181: 48 89 e5 movq %rsp, %rbp
+# DISASM-CHECK: 201184: 5d popq %rbp
+# DISASM-CHECK: 201185: c3 retq
+# DISASM-CHECK: 201186: cc int3
+# DISASM-CHECK: 201187: cc int3
+# DISASM-CHECK: 201188: cc int3
+# DISASM-CHECK: 201189: cc int3
+# DISASM-CHECK: 20118a: cc int3
+# DISASM-CHECK: 20118b: cc int3
+# DISASM-CHECK: 20118c: cc int3
+# DISASM-CHECK: 20118d: cc int3
+# DISASM-CHECK: 20118e: cc int3
+# DISASM-CHECK: 20118f: cc int3
+# DISASM: <main>:
+# DISASM-CHECK: 201190: 55 pushq %rbp
+# DISASM-CHECK: 201191: 48 89 e5 movq %rsp, %rbp
+# DISASM-CHECK: 201194: 31 c0 xorl %eax, %eax
+# DISASM-CHECK: 201196: 5d popq %rbp
+# DISASM-CHECK: 201197: c3 retq
+
+# DWARF: .debug_names contents:
+# DWARF: Name Index @ 0x0 {
+# DWARF-NEXT: Header {
+# DWARF-NEXT: Length: 0xCC
+# DWARF-NEXT: Format: DWARF32
+# DWARF-NEXT: Version: 5
+# DWARF-NEXT: CU count: 2
+# DWARF-NEXT: Local TU count: 0
+# DWARF-NEXT: Foreign TU count: 0
+# DWARF-NEXT: Bucket count: 5
+# DWARF-NEXT: Name count: 5
+# DWARF-NEXT: Abbreviations table size: 0x1F
+# DWARF-NEXT: Augmentation: 'LLVM0700'
+# DWARF: Compilation Unit offsets [
+# DWARF-NEXT: CU[0]: 0x00000000
+# DWARF-NEXT: CU[1]: 0x00000041
+# DWARF: Abbreviations [
+# DWARF-NEXT: Abbreviation 0x1 {
+# DWARF: Tag: DW_TAG_structure_type
+# DWARF-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+# DWARF-NEXT: DW_IDX_parent: DW_FORM_flag_present
+# DWARF-NEXT: DW_IDX_compile_unit: DW_FORM_data1
+# DWARF: Abbreviation 0x2 {
+# DWARF-NEXT: Tag: DW_TAG_subprogram
+# DWARF-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+# DWARF-NEXT: DW_IDX_parent: DW_FORM_flag_present
+# DWARF-NEXT: DW_IDX_compile_unit: DW_FORM_data1
+# DWARF: Abbreviation 0x3 {
+# DWARF-NEXT: Tag: DW_TAG_base_type
+# DWARF-NEXT: DW_IDX_die_offset: DW_FORM_ref4
+# DWARF-NEXT: DW_IDX_parent: DW_FORM_flag_present
+# DWARF-NEXT: DW_IDX_compile_unit: DW_FORM_data1
+# DWARF: Bucket 0 [
+# DWARF: Bucket 1 [
+# DWARF: String: 0x00000089 "f1"
+# DWARF-NEXT: Entry @ 0xa3 {
+# DWARF-NEXT: Abbrev: 0x2
+# DWARF-NEXT: Tag: DW_TAG_subprogram
+# DWARF-NEXT: DW_IDX_die_offset: 0x00000023
+# DWARF-NEXT: DW_IDX_parent: <parent not indexed>
+# DWARF-NEXT: DW_IDX_compile_unit: 0x00
+# DWARF: String: 0x00000095 "t1"
+# DWARF-NEXT: Entry @ 0xaa {
+# DWARF-NEXT: Abbrev: 0x1
+# DWARF-NEXT: Tag: DW_TAG_structure_type
+# DWARF-NEXT: DW_IDX_die_offset: 0x0000003a
+# DWARF-NEXT: DW_IDX_parent: <parent not indexed>
+# DWARF-NEXT: DW_IDX_compile_unit: 0x00
+# DWARF-NEXT: }
+# DWARF-NEXT: Entry @ 0xb0 {
+# DWARF-NEXT: Abbrev: 0x1
+# DWARF-NEXT: Tag: DW_TAG_structure_type
+# DWARF-NEXT: DW_IDX_die_offset: 0x00000042
+# DWARF-NEXT: DW_IDX_parent: <parent not indexed>
+# DWARF-NEXT: DW_IDX_compile_unit: 0x01
+# DWARF: String: 0x00000130 "int"
+# DWARF-NEXT: Entry @ 0xb7 {
+# DWARF-NEXT: Abbrev: 0x3
+# DWARF-NEXT: Tag: DW_TAG_base_type
+# DWARF-NEXT: DW_IDX_die_offset: 0x0000003e
+# DWARF-NEXT: DW_IDX_parent: <parent not indexed>
+# DWARF-NEXT: DW_IDX_compile_unit: 0x01
+# DWARF: Bucket 2 [
+# DWARF: Bucket 3 [
+# DWARF: String: 0x0000008c "_Z2f12t1"
+# DWARF-NEXT: Entry @ 0xbe {
+# DWARF-NEXT: Abbrev: 0x2
+# DWARF-NEXT: Tag: DW_TAG_subprogram
+# DWARF-NEXT: DW_IDX_die_offset: 0x00000023
+# DWARF-NEXT: DW_IDX_parent: <parent not indexed>
+# DWARF-NEXT: DW_IDX_compile_unit: 0x00
+# DWARF: Bucket 4 [
+# DWARF: String: 0x0000012b "main"
+# DWARF-NEXT: Entry @ 0xc5 {
+# DWARF-NEXT: Abbrev: 0x2
+# DWARF-NEXT: Tag: DW_TAG_subprogram
+# DWARF-NEXT: DW_IDX_die_offset: 0x00000023
+# DWARF-NEXT: DW_IDX_parent: <parent not indexed>
+# DWARF-NEXT: DW_IDX_compile_unit: 0x01
+
+# READELF: .debug_names PROGBITS 0000000000000000 0003eb 0000d0
----------------
MaskRay wrote:
`s/0003eb/[[#%x,]]/` so that the test is less sensitive to section offset changes.
The size, while sensitive, is useful as a change detector.
I's just one line and displays the section size. It's better to move it before `# DWARF`
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list