1## Test various details of llvm-objdump -h/--section-headers for XCOFF. 2 3## Check the -h/--section-headers option prints section headers correctly. 4# RUN: yaml2obj %s --docnum=1 -o %t-basic.o 5# RUN: llvm-objdump --section-headers %t-basic.o | FileCheck %s 6 7# CHECK: Sections: 8# CHECK-NEXT: Idx Name Size VMA Type 9# CHECK-NEXT: 0 .text 00000008 00000008 TEXT 10# CHECK-NEXT: 1 .data 00000004 00000000 DATA 11# CHECK-NEXT: 2 .bss 00000000 00000010 BSS 12# CHECK-NEXT: 3 .tdata 00000004 00000000 DATA 13# CHECK-NEXT: 4 .tbss 00000000 00000004 BSS 14# CHECK-NEXT: 5 .dwline 00000046 00000000 DEBUG 15# CHECK-NEXT: 6 .debug 00000046 00000000 DEBUG 16 17--- !XCOFF 18FileHeader: 19 MagicNumber: 0x1DF 20Sections: 21 - Name: .text 22 Address: 0x8 23 Size: 0x8 24 Flags: [ STYP_TEXT ] 25 - Name: .data 26 Size: 0x4 27 Flags: [ STYP_DATA ] 28 - Name: .bss 29 Size: 0x0 30 Address: 0x10 31 Flags: [ STYP_BSS ] 32 - Name: .tdata 33 Size: 0x4 34 Flags: [ STYP_TDATA ] 35 - Name: .tbss 36 Size: 0x0 37 Flags: [ STYP_TBSS ] 38 - Name: .dwline 39 Size: 0x46 40 Flags: [ STYP_DWARF ] 41 - Name: .debug 42 Size: 0x46 43 Flags: [ STYP_DEBUG ] 44 45## Check the -h/--section-headers option prints long section names. 46# RUN: yaml2obj %s --docnum=2 -o %t-longname.o 47# RUN: llvm-objdump --section-headers %t-longname.o \ 48# RUN: | FileCheck %s --check-prefix=LONG 49 50# LONG: Sections: 51# LONG-NEXT: Idx Name Size VMA Type 52# LONG-NEXT: 0 .dwarnge 00000004 00000000 53# LONG-NEXT: 1 .dwpbnms 00000004 00000000 54# LONG-NEXT: 2 .dwpbtyp 00000004 00000000 55 56--- !XCOFF 57FileHeader: 58 MagicNumber: 0x1DF 59Sections: 60 - Name: .dwarnge 61 Size: 0x4 62 Flags: [ STYP_PAD ] 63 - Name: .dwpbnms 64 Size: 0x4 65 Flags: [ STYP_PAD ] 66 - Name: .dwpbtyp 67 Size: 0x4 68 Flags: [ STYP_PAD ] 69 70## Truncate the file to end before the section header table ends. 71# RUN: yaml2obj %s --docnum=3 -o %t-truncate.o 72# RUN: %python -c "with open('%/t-truncate.o', 'r+b') as input: input.truncate(20)" 73# RUN: not llvm-objdump --section-headers %t-truncate.o 2>&1 \ 74# RUN: | FileCheck --check-prefix=ERROR %s 75 76# ERROR: The end of the file was unexpectedly encountered: section headers with offset 0x14 and size 0x28 go past the end of the file 77 78--- !XCOFF 79FileHeader: 80 MagicNumber: 0x1DF 81Sections: 82 - Name: .text 83 Size: 0x8 84 Flags: [ STYP_TEXT ] 85