mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
808d7bc7a0
Now the only method to configure ELF section's content and size is to assign a hexadecimal string to the `Content` field. Unfortunately this way is completely useless when you need to declare a really large section. To solve this problem this patch adds one more optional field `Size` to the `RawContentSection` structure. When yaml2obj generates an ELF file it uses the following algorithm: 1. If both `Content` and `Size` fields are missed create an empty section. 2. If only `Content` field is missed take section length from the `Size` field and fill the section by zero. 3. If only `Size` field is missed create a section using data from the `Content` field. 4. If both `Content` and `Size` fields are provided validate that the `Size` value is not less than size of `Content` data. Than take section length from the `Size`, fill beginning of the section by `Content` and the rest by zero. Examples -------- * Create a section 0x10000 bytes long filled by zero Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Size: 0x10000 * Create a section 0x10000 bytes long starting from 'CA' 'FE' 'BA' 'BE' Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Content: CAFEBABE Size: 0x10000 The patch reviewed by Michael Spencer. llvm-svn: 208995
77 lines
2.1 KiB
YAML
77 lines
2.1 KiB
YAML
# RUN: yaml2obj -format=elf %s | llvm-readobj -sections -section-data - | FileCheck %s
|
|
# RUN: yaml2obj -format=elf -o %t %s
|
|
# RUN: llvm-readobj -sections -section-data %t | FileCheck %s
|
|
|
|
!ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .text
|
|
Type: SHT_PROGBITS
|
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
|
Address: 0xCAFEBABE
|
|
Link: .text # Doesn't make sense for SHT_PROGBITS, but good enough for test.
|
|
Content: EBFE
|
|
AddressAlign: 2
|
|
|
|
- Name: .data
|
|
Type: SHT_PROGBITS
|
|
Flags: [ SHF_ALLOC ]
|
|
Address: 0xCAFECAFE
|
|
Content: FEBF
|
|
Size: 8
|
|
AddressAlign: 2
|
|
|
|
# CHECK: Section {
|
|
# CHECK: Index: 0
|
|
# CHECK: Type: SHT_NULL (0x0)
|
|
#
|
|
# CHECK: Section {
|
|
# CHECK: Name: .text
|
|
# CHECK: Type: SHT_PROGBITS (0x1)
|
|
# CHECK-NEXT: Flags [ (0x6)
|
|
# CHECK-NEXT: SHF_ALLOC (0x2)
|
|
# CHECK-NEXT: SHF_EXECINSTR (0x4)
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: Address: 0xCAFEBABE
|
|
# CHECK: Size: 2
|
|
# Check that Link != 0.
|
|
# CHECK: Link: {{[1-9][0-9]*}}
|
|
# CHECK: AddressAlignment: 2
|
|
# CHECK: SectionData (
|
|
# CHECK-NEXT: 0000: EBFE
|
|
# CHECK-NEXT: )
|
|
#
|
|
# CHECK: Section {
|
|
# CHECK: Name: .data
|
|
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
|
|
# CHECK-NEXT: Flags [ (0x2)
|
|
# CHECK-NEXT: SHF_ALLOC (0x2)
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: Address: 0xCAFECAFE
|
|
# CHECK-NEXT: Offset: 0x1D0
|
|
# CHECK-NEXT: Size: 8
|
|
# CHECK-NEXT: Link: 0
|
|
# CHECK-NEXT: Info: 0
|
|
# CHECK-NEXT: AddressAlignment: 2
|
|
# CHECK-NEXT: EntrySize: 0
|
|
# CHECK-NEXT: SectionData (
|
|
# CHECK-NEXT: 0000: FEBF0000 00000000 |........|
|
|
# CHECK-NEXT: )
|
|
#
|
|
# CHECK: Section {
|
|
# CHECK: Name: .symtab (25)
|
|
# CHECK: Type: SHT_SYMTAB (0x2)
|
|
# CHECK: }
|
|
# CHECK: Section {
|
|
# CHECK: Name: .strtab (17)
|
|
# CHECK: Type: SHT_STRTAB (0x3)
|
|
# CHECK: }
|
|
# CHECK: Section {
|
|
# CHECK: Name: .shstrtab (7)
|
|
# CHECK: Type: SHT_STRTAB (0x3)
|
|
# CHECK: }
|