diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml --- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml +++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml @@ -406,17 +406,3 @@ Descriptors: - Address: 0x0000000000001234 Length: 0x20 - -## h) Test that yaml2obj will not generate the .debug_aranges section when the "DWARF" entry -## exists but the "debug_aranges" entry doesn't exist in the "DWARF" entry or the "Sections" entry. - -# RUN: yaml2obj --docnum=8 %s -o %t8.o -# RUN: llvm-readelf --sections %t8.o | FileCheck /dev/null --implicit-check-not=.debug_aranges - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2MSB - Type: ET_EXEC - Machine: EM_X86_64 -DWARF: diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml --- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml +++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml @@ -321,17 +321,3 @@ IncludeDirs: [] Files: [] Opcodes: [] - -## h) Test that yaml2obj will not generate the .debug_line section when the "DWARF" entry -## exists but the "debug_line" entry doesn't exist in the "DWARF" entry or the "Sections" entry. - -# RUN: yaml2obj --docnum=8 %s -o %t8.o -# RUN: llvm-readelf --sections %t8.o | FileCheck /dev/null --implicit-check-not=.debug_line - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 -DWARF: diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml --- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml +++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml @@ -295,25 +295,11 @@ - LowOffset: 0x0000000000000001 HighOffset: 0x0000000000000002 -## h) Test that yaml2obj will not generate the .debug_ranges section when the "DWARF" entry -## exists but the "debug_ranges" entry doesn't exist in the "DWARF" entry or the "Sections" entry. - -# RUN: yaml2obj --docnum=8 %s -o %t8.o -# RUN: llvm-readelf --sections %t8.o | FileCheck /dev/null --implicit-check-not=.debug_ranges - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 -DWARF: - -## i) Test that yaml2obj automatically pads zeros if we try to assign an offset that +## h) Test that yaml2obj automatically pads zeros if we try to assign an offset that ## is greater than or equal to the number of bytes written already. -# RUN: yaml2obj --docnum=9 %s -o %t9.o -# RUN: llvm-readelf --hex-dump=.debug_ranges %t9.o | FileCheck %s --check-prefix=PADDED +# RUN: yaml2obj --docnum=8 %s -o %t8.o +# RUN: llvm-readelf --hex-dump=.debug_ranges %t8.o | FileCheck %s --check-prefix=PADDED # PADDED: Hex dump of section '.debug_ranges': # PADDED-NEXT: 0x00000000 01000000 00000000 02000000 00000000 @@ -374,10 +360,10 @@ - LowOffset: 0x01 HighOffset: 0x02 -## j) Test that yaml2obj emits an error message if we try to assign an invalid offset to an +## i) Test that yaml2obj emits an error message if we try to assign an invalid offset to an ## entry of the '.debug_ranges' section. -# RUN: not yaml2obj --docnum=10 %s -o %t10.o 2>&1 | FileCheck %s --check-prefix=INVALID-OFFSET +# RUN: not yaml2obj --docnum=9 %s -o %t9.o 2>&1 | FileCheck %s --check-prefix=INVALID-OFFSET # INVALID-OFFSET: yaml2obj: error: 'Offset' for 'debug_ranges' with index 1 must be greater than or equal to the number of bytes written already (0x20) diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml --- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml +++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml @@ -175,32 +175,18 @@ - b - c -## h) Test that yaml2obj will not generate the .debug_str section when the "DWARF" entry exists -## but the "debug_str" entry doesn't exist in the "DWARF" entry or the "Sections" entry. - -# RUN: yaml2obj --docnum=8 %s -o %t8.o -# RUN: llvm-readelf -S %t8.o | FileCheck /dev/null --implicit-check-not=.debug_str - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 -DWARF: - -## i) Test that if we try to initialize the .debug_str section with a "Type" with non-standard +## h) Test that if we try to initialize the .debug_str section with a "Type" with non-standard ## syntax, e.g., SHT_DYNAMIC, yaml2obj will treat it as a dynamic section and discard the ## content in the "DWARF" entry. +# RUN: yaml2obj --docnum=8 %s -o %t8.o +# RUN: llvm-readelf -S %t8.o | FileCheck %s --check-prefix=DYN-SHDR +# RUN: llvm-readelf -d %t8.o | FileCheck %s --check-prefix=DYNAMIC + # RUN: yaml2obj --docnum=9 %s -o %t9.o # RUN: llvm-readelf -S %t9.o | FileCheck %s --check-prefix=DYN-SHDR # RUN: llvm-readelf -d %t9.o | FileCheck %s --check-prefix=DYNAMIC -# RUN: yaml2obj --docnum=10 %s -o %t10.o -# RUN: llvm-readelf -S %t10.o | FileCheck %s --check-prefix=DYN-SHDR -# RUN: llvm-readelf -d %t10.o | FileCheck %s --check-prefix=DYNAMIC - # DYN-SHDR: Name Type Address Off Size ES Flg Lk Inf Al # DYN-SHDR: .debug_str DYNAMIC 0000000000000000 000040 000010 10 0 0 0 diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/empty-dwarf-entry.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/empty-dwarf-entry.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/yaml2obj/ELF/DWARF/empty-dwarf-entry.yaml @@ -0,0 +1,19 @@ +## Test that yaml2obj doesn't emit .debug_* sections when the "DWARF" entry is empty. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-readelf -S %t.o | FileCheck %s + +# CHECK: There are 3 section headers, starting at offset 0x58: +# CHECK: Section Headers: +# CHECK-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al +# CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 +# CHECK-NEXT: [ 1] .strtab STRTAB 0000000000000000 000040 000001 00 0 0 1 +# CHECK-NEXT: [ 2] .shstrtab STRTAB 0000000000000000 000041 000013 00 0 0 1 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +DWARF: