mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-25 13:20:57 +00:00

This fixes a bug as well. When "FileSize:" (p_filesz) is specified and different from the actual value, the following code probably should not use PHeader.p_filesz: if (SHeader->sh_offset == PHeader.p_offset + PHeader.p_filesz) PHeader.p_memsz += SHeader->sh_size; Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D67256 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371420 91177308-0d34-0410-b5e6-96231b3b80d8
109 lines
2.4 KiB
YAML
109 lines
2.4 KiB
YAML
# Show that yaml2obj properly emits program headers with explicit file size,
|
|
# memory size and offset parameters.
|
|
|
|
# RUN: yaml2obj %s -o %t
|
|
# RUN: llvm-readobj %t --program-headers | FileCheck %s
|
|
|
|
# CHECK: ProgramHeaders [
|
|
# CHECK: Offset: 0x1234
|
|
# CHECK: FileSize: 1111
|
|
# CHECK: MemSize: 9999
|
|
|
|
# CHECK: Offset: 0x2000
|
|
# CHECK: FileSize: 6
|
|
# CHECK: MemSize: 4
|
|
|
|
# CHECK: Offset: 0x2000
|
|
# CHECK: FileSize: 4
|
|
# CHECK: MemSize: 6
|
|
|
|
# CHECK: Offset: 0x1FFF
|
|
# CHECK: FileSize: 5
|
|
# CHECK: MemSize: 5
|
|
|
|
# CHECK: Offset: 0xFFE
|
|
# CHECK: FileSize: 7
|
|
# CHECK: MemSize: 9
|
|
|
|
# CHECK: Offset: 0x3000
|
|
# CHECK: FileSize: 3
|
|
# CHECK: MemSize: 2
|
|
|
|
# CHECK: Offset: 0x2004
|
|
# CHECK: FileSize: 4
|
|
# CHECK: MemSize: 6
|
|
# CHECK: ]
|
|
|
|
!ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_EXEC
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .text
|
|
Type: SHT_PROGBITS
|
|
Size: 4
|
|
ShOffset: 0x1000
|
|
AddressAlign: 0x1000
|
|
- Name: .rodata
|
|
Type: SHT_PROGBITS
|
|
Size: 4
|
|
ShOffset: 0x2000
|
|
AddressAlign: 0x1000
|
|
- Name: .data
|
|
Type: SHT_PROGBITS
|
|
ShOffset: 0x2004
|
|
Size: 4
|
|
- Name: .nobits1
|
|
Type: SHT_NOBITS
|
|
ShOffset: 0x2008
|
|
Size: 1
|
|
- Name: .nobits2
|
|
Type: SHT_NOBITS
|
|
# Intentionally set to 0x2009 though the previous section is SHT_NOBITS.
|
|
ShOffset: 0x2009
|
|
Size: 1
|
|
ProgramHeaders:
|
|
# Program header with no sections.
|
|
- Type: 0x6abcdef0 # arbitrary type
|
|
Offset: 0x1234
|
|
FileSize: 1111
|
|
MemSize: 9999
|
|
# Program header with only file size set.
|
|
- Type: 0x6abcdef0
|
|
FileSize: 6
|
|
Sections:
|
|
- Section: .rodata
|
|
# Program header with only mem size set.
|
|
- Type: 0x6abcdef0
|
|
MemSize: 6
|
|
Sections:
|
|
- Section: .rodata
|
|
# Program header with only offset set.
|
|
- Type: 0x6abcdef0
|
|
Offset: 0x1fff
|
|
Sections:
|
|
- Section: .rodata
|
|
# Program header with sections, valid properties.
|
|
- Type: 0x6abcdef0
|
|
Offset: 0xffe
|
|
FileSize: 7
|
|
MemSize: 9
|
|
Sections:
|
|
- Section: .text
|
|
# Program header with sections, invalid properties.
|
|
- Type: 0x6abcdef0
|
|
Offset: 0x3000
|
|
FileSize: 3
|
|
MemSize: 2
|
|
Sections:
|
|
- Section: .data
|
|
# Program header with 2 SHT_NOBITS sections.
|
|
- Type: 0x6abcdef0
|
|
Offset: 0x2004
|
|
Sections:
|
|
- Section: .data
|
|
- Section: .nobits1
|
|
- Section: .nobits2
|