Files
clang-p2996/llvm/test/tools/yaml2obj/ELF/implicit-sections.yaml
Georgii Rymar a6436b0b3a [yaml2obj] - Make the 'Machine' key optional.
Currently we have to set 'Machine' to something in our
YAML descriptions. Usually we use 'EM_X86_64' for 64-bit targets
and 'EM_386' for 32-bit targets. At the same time, in fact, in most
cases our tests do not need a machine type and we can use
'EM_NONE'.

This is cleaner, because avoids the need of using a particular machine.

In this patch I've made the 'Machine' key optional (the default value,
when it is not specified is `EM_NONE`) and removed it (where possible)
from yaml2obj, obj2yaml and llvm-readobj tests.

There are few tests left where I decided not to remove it, because
I didn't want to touch CHECK lines or doing anything more complex
than a removing a "Machine: *" line and formatting lines around.

Differential revision: https://reviews.llvm.org/D86202
2020-08-20 11:40:51 +03:00

106 lines
3.2 KiB
YAML

## Check the section header properties of ".dynsym",
## ".dynstr", ".symtab", ".strtab", ".shstrtab".
## These sections sections are usually added implicitly,
## but here we add them explicitly in YAML and verify.
## We check their order matches YAML and that file offset is
## ascending. This is a natural default behavior.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf -S %t1 | FileCheck %s
# CHECK: Section Headers:
# CHECK-NEXT: [Nr] Name Type Address Off Size
# CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000
# CHECK-NEXT: [ 1] .dynstr STRTAB 0000000000000100 000040 000001
# CHECK-NEXT: [ 2] .dynsym DYNSYM 0000000000000150 000041 000018
# CHECK-NEXT: [ 3] .symtab SYMTAB 0000000000000000 000059 000018
# CHECK-NEXT: [ 4] .strtab STRTAB 0000000000000000 000071 000001
# CHECK-NEXT: [ 5] .shstrtab STRTAB 0000000000000000 000072 000035
# CHECK-NEXT: [ 6] .text.foo PROGBITS 0000000000000200 0000a7 000000
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .dynstr
Type: SHT_STRTAB
Address: 0x100
- Name: .dynsym
Type: SHT_DYNSYM
Address: 0x150
- Name: .symtab
Type: SHT_SYMTAB
- Name: .strtab
Type: SHT_STRTAB
- Name: .shstrtab
Type: SHT_STRTAB
- Name: .text.foo
Type: SHT_PROGBITS
Address: 0x200
## Check that yaml2obj creates empty .dynstr and .dynsym sections for
## the case when no dynamic symbols were specified and Content wasn't set,
## but the sections were explicitly listed. Check their VAs are correct.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-readelf -S %t2 | FileCheck %s --check-prefix=NODYNSYM
# NODYNSYM: Section Headers:
# NODYNSYM-NEXT: [Nr] Name Type Address Off Size
# NODYNSYM-NEXT: [ 0] NULL 0000000000000000 000000 000000
# NODYNSYM-NEXT: [ 1] .dynstr STRTAB 0000000000000100 000040 000001
# NODYNSYM-NEXT: [ 2] .dynsym DYNSYM 0000000000000150 000041 000018
# NODYNSYM-NEXT: [ 3] .symtab SYMTAB 0000000000000000 000059 000018
# NODYNSYM-NEXT: [ 4] .strtab STRTAB 0000000000000000 000071 000001
# NODYNSYM-NEXT: [ 5] .shstrtab STRTAB 0000000000000000 000072 000035
# NODYNSYM-NEXT: [ 6] .text.foo PROGBITS 0000000000000200 0000a7 000000
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .dynstr
Type: SHT_STRTAB
Address: 0x100
- Name: .dynsym
Type: SHT_DYNSYM
Address: 0x150
- Name: .symtab
Type: SHT_SYMTAB
- Name: .strtab
Type: SHT_STRTAB
- Name: .shstrtab
Type: SHT_STRTAB
- Name: .text.foo
Type: SHT_PROGBITS
Address: 0x200
## Check we don't add a symbol table when no "Symbols" key is specified.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-readelf -S %t3 | FileCheck /dev/null --implicit-check-not=.symtab
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
## Check we add a symbol table when "Symbols" key is specified.
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-readelf -S %t4 | FileCheck %s --check-prefix=SYMTAB
# SYMTAB: .symtab
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Symbols: []