llvm-project/llvm/test/tools/obj2yaml/ELF/note-section.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

96 lines
2.5 KiB
YAML

## Check how obj2yaml dumps SHT_NOTE sections.
## We can dump the Name, Desc and Type fields when the note section is valid.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=VALID
# VALID: - Name: .note.foo
# VALID-NEXT: Type: SHT_NOTE
# VALID-NEXT: Notes:
# VALID-NEXT: - Name: ''
# VALID-NEXT: Desc: ''
# VALID-NEXT: Type: 0x00
# VALID-NEXT: - Name: .note.bar
# VALID-NEXT: Type: SHT_NOTE
# VALID-NEXT: Notes:
# VALID-NEXT: - Name: ABC
# VALID-NEXT: Desc: '001122'
# VALID-NEXT: Type: 0xAABBCCDD
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .note.foo
Type: SHT_NOTE
Size: 12
- Name: .note.bar
Type: SHT_NOTE
Notes:
- Name: ABC
Desc: '001122'
Type: 0xAABBCCDD
## Check we dump hex digit pairs if the note section is invalid.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID
# INVALID: - Name: .note.tooShortNote
# INVALID-NEXT: Type: SHT_NOTE
# INVALID-NEXT: Content: '0000000000000000000000'
# INVALID-NEXT: - Name: .note.tooLongNameSize
# INVALID-NEXT: Type: SHT_NOTE
# INVALID-NEXT: Content: 0100000000000000FF00000000
# INVALID-NEXT: - Name: .note.tooLongDescSize
# INVALID-NEXT: Type: SHT_NOTE
# INVALID-NEXT: Content: 0000000001000000FF00000000
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
## Content is less than 12 bytes in size.
## (12 is the size of n_namesz, n_descsz and n_type 4-bytes fields that must always present).
- Name: .note.tooShortNote
Type: SHT_NOTE
Size: 11
## We can't dump the Name, Desc and Type fields when the
## content is shorter than the computed size.
##
## Too long name size.
- Name: .note.tooLongNameSize
Type: SHT_NOTE
Content: "0100000000000000ff00000000"
## Too long description size.
- Name: .note.tooLongDescSize
Type: SHT_NOTE
Content: "0000000001000000ff00000000"
## Check we do not crash when dumping a description that has bytes
## on its bounds that do not fit into signed byte.
## This is a completely normal case, but we had a crash before.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=HEX-DESC
# HEX-DESC: Desc: FE0000FE
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2MSB
Type: ET_DYN
Sections:
- Name: .note.tag
Type: SHT_NOTE
Flags: [ SHF_ALLOC ]
Notes:
- Desc: 'FE0000FE'
Type: 0