Files
clang-p2996/llvm/test/tools/yaml2obj/ELF/program-header-align.yaml
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

53 lines
1.2 KiB
YAML

## Test the p_align field of a program header can be set explicitly or inferred
## from the maximum alignment of contained sections.
## Explicit Align has priority over section alignments.
# RUN: yaml2obj --docnum=1 %s -o %t
# RUN: llvm-readobj -l %t | FileCheck %s
# CHECK: ProgramHeader {
# CHECK-NOT: ProgramHeader {
# CHECK: Alignment: 16
# CHECK-NEXT: }
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .tdata
Type: SHT_PROGBITS
AddressAlign: 4
- Name: .tbss
Type: SHT_NOBITS
AddressAlign: 64
ProgramHeaders:
- Type: PT_TLS
Align: 16
FirstSec: .tdata
LastSec: .tbss
## If Align is not specified, p_align is inferred from the maximum alignment
## of contained sections.
# RUN: yaml2obj --docnum=2 %s -o %t
# RUN: llvm-readobj -l %t | FileCheck %s
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .text
Type: SHT_PROGBITS
AddressAlign: 4
- Name: .text.hot
Type: SHT_PROGBITS
AddressAlign: 16
ProgramHeaders:
- Type: PT_LOAD
FirstSec: .text
LastSec: .text.hot