[llvm] db4ac5a - [NFC][XCOFF] Use yaml2obj in llvm-objdump/XCOFF/section-headers.test instead of binary files.
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 8 20:12:08 PDT 2021
Author: Esme-Yi
Date: 2021-06-09T03:11:33Z
New Revision: db4ac5a63e11b90ab585abf9531edb4ed6f69be0
URL: https://github.com/llvm/llvm-project/commit/db4ac5a63e11b90ab585abf9531edb4ed6f69be0
DIFF: https://github.com/llvm/llvm-project/commit/db4ac5a63e11b90ab585abf9531edb4ed6f69be0.diff
LOG: [NFC][XCOFF] Use yaml2obj in llvm-objdump/XCOFF/section-headers.test instead of binary files.
Summary: This a minor patch to refactor the test file,
llvm-objdump/XCOFF/section-headers.test, to use yaml2obj
for this testing rather than a canned binary.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D103146
Added:
Modified:
llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
Removed:
llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-long-sec-names.o
llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-section-headers-truncate.o
################################################################################
diff --git a/llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-long-sec-names.o b/llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-long-sec-names.o
deleted file mode 100644
index 3dfc498babf0e..0000000000000
Binary files a/llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-long-sec-names.o and /dev/null
diff er
diff --git a/llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-section-headers-truncate.o b/llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-section-headers-truncate.o
deleted file mode 100644
index 7667c6f791c99..0000000000000
Binary files a/llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-section-headers-truncate.o and /dev/null
diff er
diff --git a/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test b/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
index 95d6f5baa3da4..b69410873144a 100644
--- a/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
+++ b/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
@@ -1,43 +1,76 @@
-# RUN: llvm-objdump --section-headers %p/Inputs/xcoff-section-headers.o | \
-# RUN: FileCheck %s
+## Test various details of llvm-objdump -h/--section-headers for XCOFF.
-# RUN: llvm-objdump --section-headers %p/Inputs/xcoff-long-sec-names.o | \
-# RUN: FileCheck --check-prefix=LONG %s
+## Check the -h/--section-headers option prints section headers correctly.
+# RUN: yaml2obj %s --docnum=1 -o %t-basic.o
+# RUN: llvm-objdump --section-headers %t-basic.o | FileCheck %s
-# RUN: not llvm-objdump --section-headers 2>&1 \
-# RUN: %p/Inputs/xcoff-section-headers-truncate.o | FileCheck \
-# RUN: --check-prefix=ERROR %s
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size VMA Type
+# CHECK-NEXT: 0 .text 00000008 00000008 TEXT
+# CHECK-NEXT: 1 .data 00000004 00000000 DATA
+# CHECK-NEXT: 2 .bss 00000000 00000010 BSS
+# CHECK-NEXT: 3 .tdata 00000004 00000000 DATA
+# CHECK-NEXT: 4 .tbss 00000000 00000000 BSS
+
+--- !XCOFF
+FileHeader:
+ MagicNumber: 0x1DF
+Sections:
+ - Name: .text
+ Address: 0x8
+ Size: 0x8
+ Flags: [ STYP_TEXT ]
+ - Name: .data
+ Size: 0x4
+ Flags: [ STYP_DATA ]
+ - Name: .bss
+ Size: 0x0
+ Address: 0x10
+ Flags: [ STYP_BSS ]
+ - Name: .tdata
+ Size: 0x4
+ Flags: [ STYP_TDATA ]
+ - Name: .tbss
+ Size: 0x0
+ Flags: [ STYP_TBSS ]
+
+## Check the -h/--section-headers option prints long section names.
+# RUN: yaml2obj %s --docnum=2 -o %t-longname.o
+# RUN: llvm-objdump --section-headers %t-longname.o \
+# RUN: | FileCheck %s --check-prefix=LONG
+
+# LONG: Sections:
+# LONG-NEXT: Idx Name Size VMA Type
+# LONG-NEXT: 0 .dwarnge 00000004 00000000
+# LONG-NEXT: 1 .dwpbnms 00000004 00000000
+# LONG-NEXT: 2 .dwpbtyp 00000004 00000000
+
+--- !XCOFF
+FileHeader:
+ MagicNumber: 0x1DF
+Sections:
+ - Name: .dwarnge
+ Size: 0x4
+ Flags: [ STYP_PAD ]
+ - Name: .dwpbnms
+ Size: 0x4
+ Flags: [ STYP_PAD ]
+ - Name: .dwpbtyp
+ Size: 0x4
+ Flags: [ STYP_PAD ]
+
+## Truncate the file to end before the section header table ends.
+# RUN: yaml2obj %s --docnum=3 -o %t-truncate.o
+# RUN: %python -c "with open('%t-truncate.o', 'r+b') as input: input.truncate(20)"
+# RUN: not llvm-objdump --section-headers %t-truncate.o 2>&1 \
+# RUN: | FileCheck --check-prefix=ERROR %s
# ERROR: The end of the file was unexpectedly encountered
-# CHECK: xcoff-section-headers.o: file format aixcoff-rs6000
-# CHECK: Sections:
-# CHECK: Idx Name Size VMA Type
-# CHECK: 0 .text 00000080 00000000 TEXT
-# CHECK: 1 .data 00000024 00000080 DATA
-# CHECK: 2 .bss 00000004 000000a4 BSS
-# CHECK: 3 .tdata 00000008 00000000 DATA
-# CHECK: 4 .tbss 00000004 00000008 BSS
-
-# xcoff-section-headers.o Compiled with IBM XL C/C++ for AIX, V16.1.0
-# test.c:
-# int a;
-# int b = 12345;
-# __thread int c;
-# __thread double d = 3.14159;
-#
-# int func(void) {
-# return a;
-# }
-
-# LONG: xcoff-long-sec-names.o: file format aixcoff-rs6000
-# LONG: Sections:
-# LONG: Idx Name Size VMA Type
-# LONG: 0 .dwarnge 00000004 00000000
-# LONG: 1 .dwpbnms 00000004 00000000
-# LONG: 2 .dwpbtyp 00000004 00000000
-
-# xcoff-long-sec-names.o was generated by assembling the following .s file:
-# .dwsect 0x30000 # .dwpbnms section
-# .dwsect 0x40000 # .dwpbtyp section
-# .dwsect 0x50000 # .dwarnge section
+--- !XCOFF
+FileHeader:
+ MagicNumber: 0x1DF
+Sections:
+ - Name: .text
+ Size: 0x8
+ Flags: [ STYP_TEXT ]
More information about the llvm-commits
mailing list