[Tests] Output of od can be lower or upper case (llvm-objcopy/yaml2obj).

The command `od -t x` is used to dump data in hex format.
The LIT tests assumes that the hex characters are in lowercase.
However, there are also platforms which use uppercase letter.

To solve this issue the tests are updated to use the new
`--ignore-case` option of FileCheck.

Reviewers: Bigcheese, jakehehrlich, rupprecht, espindola, alexshap, jhenderson

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

llvm-svn: 374343
This commit is contained in:
Kai Nacke 2019-10-10 13:24:00 +00:00
parent 5070322332
commit 819f01d917
11 changed files with 1300 additions and 1300 deletions

View File

@ -1,25 +1,25 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 -v %t2 | FileCheck %s
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
# CHECK: 0000000 c3c3 c3c3
# SIZE: 4
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 -v %t2 | FileCheck %s --ignore-case
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
# CHECK: 0000000 c3c3 c3c3
# SIZE: 4

View File

@ -1,42 +1,42 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 -v %t2 | FileCheck %s
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1004
AddressAlign: 0x0000000000000004
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: 0x0000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1004
PAddr: 0x0000
Align: 0x1000
Sections:
- Section: .data
# CHECK: 0000000 c3c3 c3c3 3232
# SIZE: 6
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 -v %t2 | FileCheck %s --ignore-case
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1004
AddressAlign: 0x0000000000000004
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: 0x0000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1004
PAddr: 0x0000
Align: 0x1000
Sections:
- Section: .data
# CHECK: 0000000 c3c3 c3c3 3232
# SIZE: 6

View File

@ -1,45 +1,45 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 %t2 | FileCheck %s
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x2000
AddressAlign: 0x0000000000001000
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
PAddr: 0x4000
Align: 0x1000
Sections:
- Section: .data
# CHECK: 0000000 c3c3 c3c3 0000 0000 0000 0000 0000 0000
# CHECK-NEXT: 0000020 0000 0000 0000 0000 0000 0000 0000 0000
# CHECK-NEXT: *
# CHECK-NEXT: 0030000 3232
# SIZE: 12290
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 %t2 | FileCheck %s --ignore-case
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x2000
AddressAlign: 0x0000000000001000
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
PAddr: 0x4000
Align: 0x1000
Sections:
- Section: .data
# CHECK: 0000000 c3c3 c3c3 0000 0000 0000 0000 0000 0000
# CHECK-NEXT: 0000020 0000 0000 0000 0000 0000 0000 0000 0000
# CHECK-NEXT: *
# CHECK-NEXT: 0030000 3232
# SIZE: 12290

View File

@ -1,38 +1,38 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 %t2 | FileCheck %s
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Address: 0x00
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000000008
Address: 0x08
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x08
Sections:
- Section: .data
# CHECK: 0000000 c3c3 c3c3 0000 0000 3232
# SIZE: 10
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x2 %t2 | FileCheck %s --ignore-case
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Address: 0x00
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000000008
Address: 0x08
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x08
Sections:
- Section: .data
# CHECK: 0000000 c3c3 c3c3 0000 0000 3232
# SIZE: 10

View File

@ -1,40 +1,40 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x1 %t2 | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1008
AddressAlign: 0x0000000000000008
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1008
PAddr: 0x1008
Align: 0x1000
Sections:
- Section: .data
# CHECK: 0000000 c3 c3 c3 c3 00 00 00 00 32 32
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O binary %t %t2
# RUN: od -t x1 %t2 | FileCheck %s --ignore-case
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1008
AddressAlign: 0x0000000000000008
Content: "3232"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
PAddr: 0x1000
Align: 0x1000
Sections:
- Section: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x1008
PAddr: 0x1008
Align: 0x1000
Sections:
- Section: .data
# CHECK: 0000000 c3 c3 c3 c3 00 00 00 00 32 32

View File

@ -1,44 +1,44 @@
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy -O binary -j .text %t %t2
# RUN: llvm-objcopy -O binary --only-section .text %t %t3
# RUN: llvm-objcopy --dump-section .text=%t4 %t %t5
# RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7
# RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t
# RUN: od -t x1 %t2 | FileCheck %s
# RUN: od -t x1 %t6 | FileCheck %s --check-prefix=NON-ALLOC
# RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE
# RUN: diff %t2 %t3
# RUN: diff %t4 %t3
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Content: "DEADBEEF"
- Name: .foo
Type: SHT_PROGBITS
Flags: [ SHF_WRITE ]
Content: "CAFE"
- Name: .bar
Type: SHT_NOBITS
Flags: [ SHF_WRITE ]
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
#CHECK: 0000000 de ad be ef
#NON-ALLOC: 0000000 ca fe
#SIZE: 4
#NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy -O binary -j .text %t %t2
# RUN: llvm-objcopy -O binary --only-section .text %t %t3
# RUN: llvm-objcopy --dump-section .text=%t4 %t %t5
# RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7
# RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t
# RUN: od -t x1 %t2 | FileCheck %s --ignore-case
# RUN: od -t x1 %t6 | FileCheck %s --ignore-case --check-prefix=NON-ALLOC
# RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE
# RUN: diff %t2 %t3
# RUN: diff %t4 %t3
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Content: "DEADBEEF"
- Name: .foo
Type: SHT_PROGBITS
Flags: [ SHF_WRITE ]
Content: "CAFE"
- Name: .bar
Type: SHT_NOBITS
Flags: [ SHF_WRITE ]
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
#CHECK: 0000000 de ad be ef
#NON-ALLOC: 0000000 ca fe
#SIZE: 4
#NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,74 @@
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy --strip-all-gnu %t %t2
# RUN: llvm-strip --strip-all-gnu %t -o %t3
# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s
# RUN: cmp %t2 %t3
# Show that the debug section in a segment was removed, to match GNU.
# First validate that the offset in use is correct.
# RUN: llvm-objcopy %t %t4
# RUN: od -t x1 -N 4 -j 120 %t4 | FileCheck %s --check-prefix=COPY-BYTES
# RUN: od -t x1 -N 4 -j 120 %t2 | FileCheck %s --check-prefix=STRIP-BYTES
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .debug_in_segment
Type: SHT_PROGBITS
Flags: [ ]
Content: "deadbeef"
- Name: .dynstr
Type: SHT_STRTAB
Flags: [ SHF_ALLOC ]
- Name: .symtab.dyn
Type: SHT_SYMTAB
Flags: [ SHF_ALLOC ]
Type: SHT_NOBITS
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Size: 4
- Name: .debug_info
Type: SHT_PROGBITS
Flags: [ ]
AddressAlign: 0x1
Size: 4
- Name: .debug_loc
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x1
Size: 4
- Name: .comment
Type: SHT_PROGBITS
- Name: .random_section_name
Type: SHT_PROGBITS
- Name: .debug_not_a_real_debug_section
Type: SHT_PROGBITS
- Name: .rel.text
Type: SHT_REL
Info: .text
- Name: .rela.text
Type: SHT_RELA
Info: .text
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
Sections:
- Section: .debug_in_segment
# CHECK: SectionHeaderCount: 8
# CHECK: Name: .dynstr
# CHECK: Name: .symtab.dyn
# CHECK: Name: .text
# CHECK: Name: .debug_loc
# CHECK: Name: .comment
# CHECK: Name: .random_section_name
# CHECK: Name: .shstrtab
# COPY-BYTES: de ad be ef
# STRIP-BYTES: 00 00 00 00
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy --strip-all-gnu %t %t2
# RUN: llvm-strip --strip-all-gnu %t -o %t3
# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s
# RUN: cmp %t2 %t3
# Show that the debug section in a segment was removed, to match GNU.
# First validate that the offset in use is correct.
# RUN: llvm-objcopy %t %t4
# RUN: od -t x1 -N 4 -j 120 %t4 | FileCheck %s --ignore-case --check-prefix=COPY-BYTES
# RUN: od -t x1 -N 4 -j 120 %t2 | FileCheck %s --ignore-case --check-prefix=STRIP-BYTES
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .debug_in_segment
Type: SHT_PROGBITS
Flags: [ ]
Content: "deadbeef"
- Name: .dynstr
Type: SHT_STRTAB
Flags: [ SHF_ALLOC ]
- Name: .symtab.dyn
Type: SHT_SYMTAB
Flags: [ SHF_ALLOC ]
Type: SHT_NOBITS
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Size: 4
- Name: .debug_info
Type: SHT_PROGBITS
Flags: [ ]
AddressAlign: 0x1
Size: 4
- Name: .debug_loc
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x1
Size: 4
- Name: .comment
Type: SHT_PROGBITS
- Name: .random_section_name
Type: SHT_PROGBITS
- Name: .debug_not_a_real_debug_section
Type: SHT_PROGBITS
- Name: .rel.text
Type: SHT_REL
Info: .text
- Name: .rela.text
Type: SHT_RELA
Info: .text
ProgramHeaders:
# Use an arbitrary segment type to show that the segment type is unimportant.
- Type: 0x61234567
Sections:
- Section: .debug_in_segment
# CHECK: SectionHeaderCount: 8
# CHECK: Name: .dynstr
# CHECK: Name: .symtab.dyn
# CHECK: Name: .text
# CHECK: Name: .debug_loc
# CHECK: Name: .comment
# CHECK: Name: .random_section_name
# CHECK: Name: .shstrtab
# COPY-BYTES: de ad be ef
# STRIP-BYTES: 00 00 00 00

View File

@ -1,88 +1,88 @@
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy --strip-sections %t %t2
# RUN: llvm-readobj --file-headers --program-headers %t2 | FileCheck %s
# RUN: od -t x1 -j 4096 -N 12 %t2 | FileCheck %s --check-prefix=DATA
## Sanity check the DATA-NOT line by showing that "fe ed fa ce" appears
## if --strip-sections is not specified.
# RUN: llvm-objcopy %t %t3
# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --check-prefix=VALIDATE
## Check that llvm-strip --strip-sections is equivalent to
## llvm-objcopy --strip-sections.
# RUN: llvm-strip --strip-sections %t -o %t4
# RUN: cmp %t2 %t4
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Content: "DEADBEEF"
- Name: .non_alloc_in_segment
Type: SHT_PROGBITS
Flags: [ ]
Content: "CAFEBABE"
- Name: .non_alloc_not_in_segment
Type: SHT_PROGBITS
Flags: [ ]
Content: "FEEDFACE"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .non_alloc_in_segment
# DATA: {{^[^[:blank:]]+}} de ad be ef ca fe ba be
# DATA-NOT: fe ed fa ce
# VALIDATE: {{^[^[:blank:]]+}} de ad be ef ca fe ba be fe ed fa ce
# CHECK: ElfHeader {
# CHECK-NEXT: Ident {
# CHECK-NEXT: Magic: (7F 45 4C 46)
# CHECK-NEXT: Class: 64-bit (0x2)
# CHECK-NEXT: DataEncoding: LittleEndian (0x1)
# CHECK-NEXT: FileVersion: 1
# CHECK-NEXT: OS/ABI: SystemV (0x0)
# CHECK-NEXT: ABIVersion: 0
# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
# CHECK-NEXT: }
# CHECK-NEXT: Type: Executable (0x2)
# CHECK-NEXT: Machine: EM_X86_64 (0x3E)
# CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x0
# CHECK-NEXT: ProgramHeaderOffset: 0x40
# CHECK-NEXT: SectionHeaderOffset: 0x0
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
# CHECK-NEXT: ProgramHeaderEntrySize: 56
# CHECK-NEXT: ProgramHeaderCount: 1
# CHECK-NEXT: SectionHeaderEntrySize: 0
# CHECK-NEXT: SectionHeaderCount: 0
# CHECK-NEXT: StringTableSectionIndex: 0
# CHECK-NEXT: }
# CHECK: ProgramHeaders [
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x1000
# CHECK-NEXT: VirtualAddress: 0x0
# CHECK-NEXT: PhysicalAddress: 0x0
# CHECK-NEXT: FileSize: 8
# CHECK-NEXT: MemSize: 8
# CHECK-NEXT: Flags [ (0x5)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: PF_X (0x1)
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 4096
# CHECK-NEXT: }
# CHECK-NEXT: ]
# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy --strip-sections %t %t2
# RUN: llvm-readobj --file-headers --program-headers %t2 | FileCheck %s
# RUN: od -t x1 -j 4096 -N 12 %t2 | FileCheck %s --ignore-case --check-prefix=DATA
## Sanity check the DATA-NOT line by showing that "fe ed fa ce" appears
## if --strip-sections is not specified.
# RUN: llvm-objcopy %t %t3
# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --ignore-case --check-prefix=VALIDATE
## Check that llvm-strip --strip-sections is equivalent to
## llvm-objcopy --strip-sections.
# RUN: llvm-strip --strip-sections %t -o %t4
# RUN: cmp %t2 %t4
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x0000000000001000
Content: "DEADBEEF"
- Name: .non_alloc_in_segment
Type: SHT_PROGBITS
Flags: [ ]
Content: "CAFEBABE"
- Name: .non_alloc_not_in_segment
Type: SHT_PROGBITS
Flags: [ ]
Content: "FEEDFACE"
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
- Section: .non_alloc_in_segment
# DATA: {{^[^[:blank:]]+}} de ad be ef ca fe ba be
# DATA-NOT: fe ed fa ce
# VALIDATE: {{^[^[:blank:]]+}} de ad be ef ca fe ba be fe ed fa ce
# CHECK: ElfHeader {
# CHECK-NEXT: Ident {
# CHECK-NEXT: Magic: (7F 45 4C 46)
# CHECK-NEXT: Class: 64-bit (0x2)
# CHECK-NEXT: DataEncoding: LittleEndian (0x1)
# CHECK-NEXT: FileVersion: 1
# CHECK-NEXT: OS/ABI: SystemV (0x0)
# CHECK-NEXT: ABIVersion: 0
# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
# CHECK-NEXT: }
# CHECK-NEXT: Type: Executable (0x2)
# CHECK-NEXT: Machine: EM_X86_64 (0x3E)
# CHECK-NEXT: Version: 1
# CHECK-NEXT: Entry: 0x0
# CHECK-NEXT: ProgramHeaderOffset: 0x40
# CHECK-NEXT: SectionHeaderOffset: 0x0
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 64
# CHECK-NEXT: ProgramHeaderEntrySize: 56
# CHECK-NEXT: ProgramHeaderCount: 1
# CHECK-NEXT: SectionHeaderEntrySize: 0
# CHECK-NEXT: SectionHeaderCount: 0
# CHECK-NEXT: StringTableSectionIndex: 0
# CHECK-NEXT: }
# CHECK: ProgramHeaders [
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)
# CHECK-NEXT: Offset: 0x1000
# CHECK-NEXT: VirtualAddress: 0x0
# CHECK-NEXT: PhysicalAddress: 0x0
# CHECK-NEXT: FileSize: 8
# CHECK-NEXT: MemSize: 8
# CHECK-NEXT: Flags [ (0x5)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: PF_X (0x1)
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 4096
# CHECK-NEXT: }
# CHECK-NEXT: ]

View File

@ -1,106 +1,106 @@
## Check we are able to set custom sh_offset field
## for different sections.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: Section Headers:
# CASE1-NEXT: [Nr] Name Type Address Off
# CASE1-NEXT: [ 0] NULL {{.*}} 000000
# CASE1-NEXT: [ 1] .dynsym DYNSYM {{.*}} 000001
# CASE1-NEXT: [ 2] .symtab SYMTAB {{.*}} 000002
# CASE1-NEXT: [ 3] .dynamic DYNAMIC {{.*}} 000003
# CASE1-NEXT: [ 4] .rela RELA {{.*}} 000004
# CASE1-NEXT: [ 5] .nobits NOBITS {{.*}} 000005
# CASE1-NEXT: [ 6] .group GROUP {{.*}} 000006
# CASE1-NEXT: [ 7] .gnu.version VERSYM {{.*}} 000007
# CASE1-NEXT: [ 8] .gnu.version_r VERNEED {{.*}} 000008
# CASE1-NEXT: [ 9] .gnu.version_d VERDEF {{.*}} 000009
# CASE1-NEXT: [10] .regular PROGBITS {{.*}} 00000a
# CASE1-NEXT: [11] .strtab STRTAB {{.*}} 00000b
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .dynsym
Type: SHT_DYNSYM
ShOffset: 0x000000001
- Name: .symtab
Type: SHT_SYMTAB
ShOffset: 0x000000002
- Name: .dynamic
Type: SHT_DYNAMIC
ShOffset: 0x000000003
- Name: .rela
Type: SHT_RELA
ShOffset: 0x000000004
- Name: .nobits
Type: SHT_NOBITS
ShOffset: 0x000000005
- Name: .group
Type: SHT_GROUP
Info: 0
ShOffset: 0x000000006
Members:
- Name: .gnu.version
Type: SHT_GNU_versym
Entries: [ ]
ShOffset: 0x000000007
- Name: .gnu.version_r
Type: SHT_GNU_verneed
Info: 0x0000000000000001
ShOffset: 0x000000008
Dependencies:
- Name: .gnu.version_d
Type: SHT_GNU_verdef
Info: 0x0000000000000001
ShOffset: 0x000000009
Entries:
- Name: .regular
Type: SHT_PROGBITS
ShOffset: 0x00000000A
- Name: .strtab
Type: SHT_STRTAB
ShOffset: 0x00000000B
## Here we check that defining ShOffset does not actually change
## the offset at which section data is placed and also does
## not affect file size.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: od -t x1 -v %t2 > %t.txt
# RUN: od -t x1 -v %t3 >> %t.txt
# RUN: FileCheck %s --input-file=%t.txt --check-prefix=CASE2
# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE:.*]]{{$}}
# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE]]{{$}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "fefefefefefefefe"
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
ShOffset: 0xFFFF0000
Content: "fefefefefefefefe"
## Check we are able to set custom sh_offset field
## for different sections.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: Section Headers:
# CASE1-NEXT: [Nr] Name Type Address Off
# CASE1-NEXT: [ 0] NULL {{.*}} 000000
# CASE1-NEXT: [ 1] .dynsym DYNSYM {{.*}} 000001
# CASE1-NEXT: [ 2] .symtab SYMTAB {{.*}} 000002
# CASE1-NEXT: [ 3] .dynamic DYNAMIC {{.*}} 000003
# CASE1-NEXT: [ 4] .rela RELA {{.*}} 000004
# CASE1-NEXT: [ 5] .nobits NOBITS {{.*}} 000005
# CASE1-NEXT: [ 6] .group GROUP {{.*}} 000006
# CASE1-NEXT: [ 7] .gnu.version VERSYM {{.*}} 000007
# CASE1-NEXT: [ 8] .gnu.version_r VERNEED {{.*}} 000008
# CASE1-NEXT: [ 9] .gnu.version_d VERDEF {{.*}} 000009
# CASE1-NEXT: [10] .regular PROGBITS {{.*}} 00000a
# CASE1-NEXT: [11] .strtab STRTAB {{.*}} 00000b
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .dynsym
Type: SHT_DYNSYM
ShOffset: 0x000000001
- Name: .symtab
Type: SHT_SYMTAB
ShOffset: 0x000000002
- Name: .dynamic
Type: SHT_DYNAMIC
ShOffset: 0x000000003
- Name: .rela
Type: SHT_RELA
ShOffset: 0x000000004
- Name: .nobits
Type: SHT_NOBITS
ShOffset: 0x000000005
- Name: .group
Type: SHT_GROUP
Info: 0
ShOffset: 0x000000006
Members:
- Name: .gnu.version
Type: SHT_GNU_versym
Entries: [ ]
ShOffset: 0x000000007
- Name: .gnu.version_r
Type: SHT_GNU_verneed
Info: 0x0000000000000001
ShOffset: 0x000000008
Dependencies:
- Name: .gnu.version_d
Type: SHT_GNU_verdef
Info: 0x0000000000000001
ShOffset: 0x000000009
Entries:
- Name: .regular
Type: SHT_PROGBITS
ShOffset: 0x00000000A
- Name: .strtab
Type: SHT_STRTAB
ShOffset: 0x00000000B
## Here we check that defining ShOffset does not actually change
## the offset at which section data is placed and also does
## not affect file size.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: od -t x1 -v %t2 > %t.txt
# RUN: od -t x1 -v %t3 >> %t.txt
# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2
# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE:.*]]{{$}}
# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE]]{{$}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "fefefefefefefefe"
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
ShOffset: 0xFFFF0000
Content: "fefefefefefefefe"

View File

@ -1,159 +1,159 @@
## Check we are able to set custom sh_size field
## for different sections.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: Section Headers:
# CASE1-NEXT: [Nr] Name Type Address Off Size
# CASE1-NEXT: [ 0] NULL 0000000000000000 000000 000000
# CASE1-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000001
# CASE1-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000058 000002
# CASE1-NEXT: [ 3] .dynamic DYNAMIC 0000000000000000 000070 000003
# CASE1-NEXT: [ 4] .rela RELA 0000000000000000 000070 000004
# CASE1-NEXT: [ 5] .nobits NOBITS 0000000000000000 000070 000005
# CASE1-NEXT: [ 6] .group GROUP 0000000000000000 000070 000006
# CASE1-NEXT: [ 7] .gnu.version VERSYM 0000000000000000 000070 000007
# CASE1-NEXT: [ 8] .gnu.version_r VERNEED 0000000000000000 000070 000008
# CASE1-NEXT: [ 9] .gnu.version_d VERDEF 0000000000000000 000070 000009
# CASE1-NEXT: [10] .regular PROGBITS 0000000000000000 000070 00000a
# CASE1-NEXT: [11] .strtab STRTAB 0000000000000000 000070 00000b
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .dynsym
Type: SHT_DYNSYM
ShSize: 0x000000001
- Name: .symtab
Type: SHT_SYMTAB
ShSize: 0x000000002
- Name: .dynamic
Type: SHT_DYNAMIC
ShSize: 0x000000003
- Name: .rela
Type: SHT_RELA
ShSize: 0x000000004
- Name: .nobits
Type: SHT_NOBITS
ShSize: 0x000000005
- Name: .group
Type: SHT_GROUP
Info: 0
ShSize: 0x000000006
Members:
- Name: .gnu.version
Type: SHT_GNU_versym
Entries: [ ]
ShSize: 0x000000007
- Name: .gnu.version_r
Type: SHT_GNU_verneed
Info: 0x0000000000000001
ShSize: 0x000000008
Dependencies:
- Name: .gnu.version_d
Type: SHT_GNU_verdef
Info: 0x0000000000000001
ShSize: 0x000000009
Entries:
- Name: .regular
Type: SHT_PROGBITS
ShSize: 0x00000000A
- Name: .strtab
Type: SHT_STRTAB
ShSize: 0x00000000B
## Here we check that defining ShSize does not actually change
## the content and also does not affect file size.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: od -t x1 -v %t2 > %t.txt
# RUN: od -t x1 -v %t3 >> %t.txt
# RUN: FileCheck %s --input-file=%t.txt --check-prefix=CASE2
# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE:.*]]{{$}}
# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE]]{{$}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "fefefefefefefefe"
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
ShSize: 1
Content: "fefefefefefefefe"
## Check we can define sh_size larger than section content size
## and thus create overlaping sections.
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4
# CASE4: Name: .foo
# CASE4: SectionData (
# CASE4-NEXT: 0000: AAAABBBB |....|
# CASE4: Name: .bar
# CASE4: SectionData (
# CASE4-NEXT: 0000: BBBB |..|
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "aaaa"
ShSize: 4
- Name: .bar
Type: SHT_PROGBITS
Content: "bbbb"
## Check we can set both Size and ShSize and the number of the actual
## bytes written is equal to Size in this case.
# RUN: yaml2obj --docnum=5 %s -o %t5
# RUN: od -t x1 -v %t5 | FileCheck %s --check-prefix=CASE5
# CASE5: aa aa 00 00 bb bb
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "aaaa"
- Name: .bar
Type: SHT_PROGBITS
Size: 2
ShSize: 4
- Name: .zed
Type: SHT_PROGBITS
Content: "bbbb"
## Check we are able to set custom sh_size field
## for different sections.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: Section Headers:
# CASE1-NEXT: [Nr] Name Type Address Off Size
# CASE1-NEXT: [ 0] NULL 0000000000000000 000000 000000
# CASE1-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000001
# CASE1-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000058 000002
# CASE1-NEXT: [ 3] .dynamic DYNAMIC 0000000000000000 000070 000003
# CASE1-NEXT: [ 4] .rela RELA 0000000000000000 000070 000004
# CASE1-NEXT: [ 5] .nobits NOBITS 0000000000000000 000070 000005
# CASE1-NEXT: [ 6] .group GROUP 0000000000000000 000070 000006
# CASE1-NEXT: [ 7] .gnu.version VERSYM 0000000000000000 000070 000007
# CASE1-NEXT: [ 8] .gnu.version_r VERNEED 0000000000000000 000070 000008
# CASE1-NEXT: [ 9] .gnu.version_d VERDEF 0000000000000000 000070 000009
# CASE1-NEXT: [10] .regular PROGBITS 0000000000000000 000070 00000a
# CASE1-NEXT: [11] .strtab STRTAB 0000000000000000 000070 00000b
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .dynsym
Type: SHT_DYNSYM
ShSize: 0x000000001
- Name: .symtab
Type: SHT_SYMTAB
ShSize: 0x000000002
- Name: .dynamic
Type: SHT_DYNAMIC
ShSize: 0x000000003
- Name: .rela
Type: SHT_RELA
ShSize: 0x000000004
- Name: .nobits
Type: SHT_NOBITS
ShSize: 0x000000005
- Name: .group
Type: SHT_GROUP
Info: 0
ShSize: 0x000000006
Members:
- Name: .gnu.version
Type: SHT_GNU_versym
Entries: [ ]
ShSize: 0x000000007
- Name: .gnu.version_r
Type: SHT_GNU_verneed
Info: 0x0000000000000001
ShSize: 0x000000008
Dependencies:
- Name: .gnu.version_d
Type: SHT_GNU_verdef
Info: 0x0000000000000001
ShSize: 0x000000009
Entries:
- Name: .regular
Type: SHT_PROGBITS
ShSize: 0x00000000A
- Name: .strtab
Type: SHT_STRTAB
ShSize: 0x00000000B
## Here we check that defining ShSize does not actually change
## the content and also does not affect file size.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: od -t x1 -v %t2 > %t.txt
# RUN: od -t x1 -v %t3 >> %t.txt
# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2
# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE:.*]]{{$}}
# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE]]{{$}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "fefefefefefefefe"
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
ShSize: 1
Content: "fefefefefefefefe"
## Check we can define sh_size larger than section content size
## and thus create overlaping sections.
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4
# CASE4: Name: .foo
# CASE4: SectionData (
# CASE4-NEXT: 0000: AAAABBBB |....|
# CASE4: Name: .bar
# CASE4: SectionData (
# CASE4-NEXT: 0000: BBBB |..|
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "aaaa"
ShSize: 4
- Name: .bar
Type: SHT_PROGBITS
Content: "bbbb"
## Check we can set both Size and ShSize and the number of the actual
## bytes written is equal to Size in this case.
# RUN: yaml2obj --docnum=5 %s -o %t5
# RUN: od -t x1 -v %t5 | FileCheck %s --ignore-case --check-prefix=CASE5
# CASE5: aa aa 00 00 bb bb
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
Content: "aaaa"
- Name: .bar
Type: SHT_PROGBITS
Size: 2
ShSize: 4
- Name: .zed
Type: SHT_PROGBITS
Content: "bbbb"