note-section.yaml
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
## 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