Files
clang-p2996/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test
Georgii Rymar a7a447be0f [yaml2obj] - ProgramHeaders: introduce FirstSec/LastSec instead of Sections list.
Imagine we have a YAML declaration of few sections: `foo1`, `<unnamed 2>`, `foo3`, `foo4`.

To put them into segment we can do (1*):

```
Sections:
 - Section: foo1
 - Section: foo4
```

or we can use (2*):

```
Sections:
 - Section: foo1
 - Section: foo3
 - Section: foo4
```

or (3*) :

```
Sections:
 - Section: foo1
## "(index 2)" here is a name that we automatically created for a unnamed section.
 - Section: (index 2)
 - Section: foo3
 - Section: foo4
```

It looks really confusing that we don't have to list all of sections.

At first I've tried to make this rule stricter and report an error when there is a gap
(i.e. when a section is included into segment, but not listed explicitly).
This did not work perfect, because such approach conflicts with unnamed sections/fills (see (3*)).

This patch drops "Sections" key and introduces 2 keys instead: `FirstSec` and `LastSec`.
Both are optional.

Differential revision: https://reviews.llvm.org/D90458
2020-11-09 13:00:50 +03:00

107 lines
2.8 KiB
Plaintext

# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy %t %t2
# RUN: llvm-readobj --program-headers %t2 | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_ARM
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x2000
AddressAlign: 0x0000000000001000
Content: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
- Name: .xdata
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
- Name: .after
Type: SHT_NOBITS
Flags: [ SHF_ALLOC ]
Size: 64
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x1000
Align: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
Align: 0x1000
FirstSec: .data
LastSec: .data
- Type: PT_GNU_STACK
Flags: [ PF_R, PF_W ]
VAddr: 0x0000
Align: 0x0000
- Type: PT_LOAD
Flags: [ PF_R ]
VAddr: 0x2010
FirstSec: .xdata
LastSec: .after
#CHECK: ProgramHeaders [
#CHECK-NEXT: ProgramHeader {
#CHECK-NEXT: Type: PT_LOAD
#CHECK-NEXT: Offset: 0x1000
#CHECK-NEXT: VirtualAddress: 0x1000
#CHECK-NEXT: PhysicalAddress: 0x1000
#CHECK-NEXT: FileSize: 16
#CHECK-NEXT: MemSize: 16
#CHECK-NEXT: Flags [
#CHECK-NEXT: PF_R
#CHECK-NEXT: PF_X
#CHECK-NEXT: ]
#CHECK-NEXT: Alignment: 4096
#CHECK-NEXT: }
#CHECK-NEXT: ProgramHeader {
#CHECK-NEXT: Type: PT_LOAD
#CHECK-NEXT: Offset: 0x2000
#CHECK-NEXT: VirtualAddress: 0x2000
#CHECK-NEXT: PhysicalAddress: 0x2000
#CHECK-NEXT: FileSize: 16
#CHECK-NEXT: MemSize: 16
#CHECK-NEXT: Flags [
#CHECK-NEXT: PF_R
#CHECK-NEXT: PF_W
#CHECK-NEXT: ]
#CHECK-NEXT: Alignment: 4096
#CHECK-NEXT: }
#CHECK-NEXT: ProgramHeader {
#CHECK-NEXT: Type: PT_GNU_STACK
#CHECK-NEXT: Offset: 0x0
#CHECK-NEXT: VirtualAddress: 0x0
#CHECK-NEXT: PhysicalAddress: 0x0
#CHECK-NEXT: FileSize: 0
#CHECK-NEXT: MemSize: 0
#CHECK-NEXT: Flags [
#CHECK-NEXT: PF_R
#CHECK-NEXT: PF_W
#CHECK-NEXT: ]
#CHECK-NEXT: Alignment: 0
#CHECK-NEXT: }
#CHECK-NEXT: ProgramHeader {
#CHECK-NEXT: Type: PT_LOAD
#CHECK-NEXT: Offset: 0x2010
#CHECK-NEXT: VirtualAddress: 0x2010
#CHECK-NEXT: PhysicalAddress: 0x2010
#CHECK-NEXT: FileSize: 0
#CHECK-NEXT: MemSize: 64
#CHECK-NEXT: Flags [
#CHECK-NEXT: PF_R
#CHECK-NEXT: ]
#CHECK-NEXT: Alignment: 1
#CHECK-NEXT: }
#CHECK-NEXT:]