From db4ac5a63e11b90ab585abf9531edb4ed6f69be0 Mon Sep 17 00:00:00 2001 From: Esme-Yi Date: Wed, 9 Jun 2021 03:11:33 +0000 Subject: [PATCH] [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 --- .../XCOFF/Inputs/xcoff-long-sec-names.o | Bin 296 -> 0 bytes .../XCOFF/Inputs/xcoff-section-headers-truncate.o | Bin 200 -> 0 bytes .../tools/llvm-objdump/XCOFF/section-headers.test | 109 ++++++++++++++------- 3 files changed, 71 insertions(+), 38 deletions(-) delete mode 100644 llvm/test/tools/llvm-objdump/XCOFF/Inputs/xcoff-long-sec-names.o delete mode 100644 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 3dfc498babf0e1a1be36472372ab3c25f7c19d6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 296 zcmZR)&%hkBW>+Tz1H%j;<^W;_y_E9AqP+A}5E}|ufOHRx1EyIS1c2%alJatkk;Fmj zCLr+{7?`2zN-7JG#6jw&An_R(SQrG5`Fd%YIWPzO|Hs3e&X|&#RGO}bY#E9>85tM~ VfEZ{F3P5oq6CO1%_c3Ev0|41NAp`&b 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 7667c6f791c990be80dbd697a7a87d90a9cfea46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 200 zcmZR)&%hcJ@zI2VfhC23fx&@6hJk^R8^~f{1Q9Vn%mQLS03(B5Noqw2j0>hg>X?9- zIRQv8FmQlL1-+ESl0+~QBo8x-8OUbd02USklMZ@G#l>J210&Eb5Jt8SA_F8F^h)3c P!UTctVg{-QyPE+3eaa78 diff --git a/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test b/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test index 95d6f5b..b694108 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 ] -- 2.7.4