[llvm] 7e0827e - [ObjectYAML][test] Use a single test file to test the empty 'DWARF' entry.

Xing GUO via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 02:52:35 PDT 2020


Author: Xing GUO
Date: 2020-06-12T17:56:22+08:00
New Revision: 7e0827e86fd0ec0318679ddc3f170ef134ea80e0

URL: https://github.com/llvm/llvm-project/commit/7e0827e86fd0ec0318679ddc3f170ef134ea80e0
DIFF: https://github.com/llvm/llvm-project/commit/7e0827e86fd0ec0318679ddc3f170ef134ea80e0.diff

LOG: [ObjectYAML][test] Use a single test file to test the empty 'DWARF' entry.

This patch addresses comments in [D81450](https://reviews.llvm.org/D81450#inline-748745)

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D81529

Added: 
    llvm/test/tools/yaml2obj/ELF/DWARF/empty-dwarf-entry.yaml

Modified: 
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml
    llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
index 9eccb65ee01d..e0d7cb875bf0 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml
@@ -406,17 +406,3 @@ DWARF:
       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
index a08e7758e933..22d5584351ac 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
@@ -321,17 +321,3 @@ DWARF:
       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
index 583461aa4ae7..db8eb89be7d8 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-ranges.yaml
@@ -295,25 +295,11 @@ DWARF:
         - 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 @@ DWARF:
         - 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
index 630350fed2a9..c9684ff46c23 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml
@@ -175,32 +175,18 @@ DWARF:
     - 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
index 000000000000..0edb7ddf64a4
--- /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:


        


More information about the llvm-commits mailing list