1## In this test we test how llvm-readelf prints file headers. 2 3## Case 1: Test EM_386 object. 4# RUN: yaml2obj %s --docnum=1 -o %t1 5# RUN: llvm-readelf -h %t1 | FileCheck %s --check-prefix=I386 6# RUN: llvm-readelf --file-header %t1 \ 7# RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=I386 8# RUN: llvm-readelf --file-headers %t1 \ 9# RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=I386 10 11# I386:ELF Header: 12# I386-NEXT: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 13# I386-NEXT: Class: ELF32 14# I386-NEXT: Data: 2's complement, little endian 15# I386-NEXT: Version: 1 (current) 16# I386-NEXT: OS/ABI: UNIX - System V 17# I386-NEXT: ABI Version: 0 18# I386-NEXT: Type: REL (Relocatable file) 19# I386-NEXT: Machine: Intel 80386 20# I386-NEXT: Version: 0x1 21# I386-NEXT: Entry point address: 0x11223344 22# I386-NEXT: Start of program headers: 52 (bytes into file) 23# I386-NEXT: Start of section headers: 112 (bytes into file) 24# I386-NEXT: Flags: 0x0 25# I386-NEXT: Size of this header: 52 (bytes) 26# I386-NEXT: Size of program headers: 32 (bytes) 27# I386-NEXT: Number of program headers: 1 28# I386-NEXT: Size of section headers: 40 (bytes) 29# I386-NEXT: Number of section headers: 4 30# I386-NEXT: Section header string table index: 3 31 32--- !ELF 33FileHeader: 34 Class: ELFCLASS32 35 Data: ELFDATA2LSB 36 Type: ET_REL 37 Machine: EM_386 38 Entry: 0x11223344 39Sections: 40 - Name: .foo 41 Type: SHT_PROGBITS 42ProgramHeaders: 43 - Type: PT_LOAD 44 Flags: [ PF_R ] 45 46## Case 2: Test EM_X86_64 object. 47# RUN: yaml2obj %s --docnum=2 -o %t2 48# RUN: llvm-readelf -h %t2 | FileCheck %s --check-prefix=X86-64 49# RUN: llvm-readelf --file-header %t2 \ 50# RUN: | FileCheck %s --check-prefix=X86-64 --strict-whitespace --match-full-lines 51# RUN: llvm-readelf --file-headers %t2 \ 52# RUN: | FileCheck %s --check-prefix=X86-64 --strict-whitespace --match-full-lines 53 54# X86-64:ELF Header: 55# X86-64-NEXT: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 56# X86-64-NEXT: Class: ELF64 57# X86-64-NEXT: Data: 2's complement, little endian 58# X86-64-NEXT: Version: 1 (current) 59# X86-64-NEXT: OS/ABI: UNIX - System V 60# X86-64-NEXT: ABI Version: 0 61# X86-64-NEXT: Type: REL (Relocatable file) 62# X86-64-NEXT: Machine: Advanced Micro Devices X86-64 63# X86-64-NEXT: Version: 0x1 64# X86-64-NEXT: Entry point address: 0x1122334455667788 65# X86-64-NEXT: Start of program headers: 64 (bytes into file) 66# X86-64-NEXT: Start of section headers: 152 (bytes into file) 67# X86-64-NEXT: Flags: 0x0 68# X86-64-NEXT: Size of this header: 64 (bytes) 69# X86-64-NEXT: Size of program headers: 56 (bytes) 70# X86-64-NEXT: Number of program headers: 1 71# X86-64-NEXT: Size of section headers: 64 (bytes) 72# X86-64-NEXT: Number of section headers: 4 73# X86-64-NEXT: Section header string table index: 3 74 75--- !ELF 76FileHeader: 77 Class: ELFCLASS64 78 Data: ELFDATA2LSB 79 Type: ET_REL 80 Machine: EM_X86_64 81 Entry: 0x1122334455667788 82Sections: 83 - Name: .foo 84 Type: SHT_PROGBITS 85ProgramHeaders: 86 - Type: PT_LOAD 87 Flags: [ PF_R ] 88 89## Case 3: Use an arbitrary machine type that allows to show how we print Flags. 90## Here we use an EM_MIPS object for that. 91# RUN: yaml2obj %s --docnum=3 -o %t3 92# RUN: llvm-readelf -h %t3 | FileCheck %s --check-prefix=MIPSEL 93# RUN: llvm-readelf --file-header %t3 \ 94# RUN: | FileCheck %s --check-prefix=MIPSEL --strict-whitespace --match-full-lines 95# RUN: llvm-readelf --file-headers %t3 \ 96# RUN: | FileCheck %s --check-prefix=MIPSEL --strict-whitespace --match-full-lines 97 98# MIPSEL:ELF Header: 99# MIPSEL-NEXT: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 100# MIPSEL-NEXT: Class: ELF32 101# MIPSEL-NEXT: Data: 2's complement, little endian 102# MIPSEL-NEXT: Version: 1 (current) 103# MIPSEL-NEXT: OS/ABI: UNIX - System V 104# MIPSEL-NEXT: ABI Version: 0 105# MIPSEL-NEXT: Type: REL (Relocatable file) 106# MIPSEL-NEXT: Machine: MIPS R3000 107# MIPSEL-NEXT: Version: 0x1 108# MIPSEL-NEXT: Entry point address: 0x0 109# MIPSEL-NEXT: Start of program headers: 52 (bytes into file) 110# MIPSEL-NEXT: Start of section headers: 112 (bytes into file) 111# MIPSEL-NEXT: Flags: 0x50001000, o32, mips32 112# MIPSEL-NEXT: Size of this header: 52 (bytes) 113# MIPSEL-NEXT: Size of program headers: 32 (bytes) 114# MIPSEL-NEXT: Number of program headers: 1 115# MIPSEL-NEXT: Size of section headers: 40 (bytes) 116# MIPSEL-NEXT: Number of section headers: 4 117# MIPSEL-NEXT: Section header string table index: 3 118 119--- !ELF 120FileHeader: 121 Class: ELFCLASS32 122 Data: ELFDATA2LSB 123 Type: ET_REL 124 Machine: EM_MIPS 125 Flags: [ EF_MIPS_ARCH_32, EF_MIPS_ABI_O32 ] 126Sections: 127 - Name: .foo 128 Type: SHT_PROGBITS 129ProgramHeaders: 130 - Type: PT_LOAD 131 Flags: [ PF_R ] 132