• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Check how obj2yaml dumps SHT_NOTE sections.
2
3## We can dump the Name, Desc and Type fields when the note section is valid.
4
5# RUN: yaml2obj --docnum=1 %s -o %t1
6# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=VALID
7
8# VALID:      - Name: .note.foo
9# VALID-NEXT:   Type: SHT_NOTE
10# VALID-NEXT:   Notes:
11# VALID-NEXT:    - Name: ''
12# VALID-NEXT:      Desc: ''
13# VALID-NEXT:      Type: 0x0
14# VALID-NEXT: - Name: .note.bar
15# VALID-NEXT:   Type: SHT_NOTE
16# VALID-NEXT:   Notes:
17# VALID-NEXT:     - Name: ABC
18# VALID-NEXT:       Desc: '001122'
19# VALID-NEXT:       Type: 0xAABBCCDD
20
21--- !ELF
22FileHeader:
23  Class: ELFCLASS64
24  Data:  ELFDATA2LSB
25  Type:  ET_DYN
26Sections:
27  - Name: .note.foo
28    Type: SHT_NOTE
29    Size: 12
30  - Name: .note.bar
31    Type: SHT_NOTE
32    Notes:
33      - Name: ABC
34        Desc: '001122'
35        Type: 0xAABBCCDD
36
37## Check we dump hex digit pairs if the note section is invalid.
38
39# RUN: yaml2obj --docnum=2 %s -o %t2
40# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID
41
42# INVALID:      - Name:    .note.tooShortNote
43# INVALID-NEXT:   Type:    SHT_NOTE
44# INVALID-NEXT:   Content: '0000000000000000000000'
45# INVALID-NEXT: - Name:    .note.tooLongNameSize
46# INVALID-NEXT:   Type:    SHT_NOTE
47# INVALID-NEXT:   Content: 0100000000000000FF00000000
48# INVALID-NEXT: - Name:    .note.tooLongDescSize
49# INVALID-NEXT:   Type:    SHT_NOTE
50# INVALID-NEXT:   Content: 0000000001000000FF00000000
51
52--- !ELF
53FileHeader:
54  Class: ELFCLASS64
55  Data:  ELFDATA2LSB
56  Type:  ET_DYN
57Sections:
58## Content is less than 12 bytes in size.
59## (12 is the size of n_namesz, n_descsz and n_type 4-bytes fields that must always present).
60  - Name: .note.tooShortNote
61    Type: SHT_NOTE
62    Size: 11
63## We can't dump the Name, Desc and Type fields when the
64## content is shorter than the computed size.
65##
66## Too long name size.
67  - Name: .note.tooLongNameSize
68    Type: SHT_NOTE
69    Content: "0100000000000000ff00000000"
70## Too long description size.
71  - Name: .note.tooLongDescSize
72    Type: SHT_NOTE
73    Content: "0000000001000000ff00000000"
74
75## Check we do not crash when dumping a description that has bytes
76## on its bounds that do not fit into signed byte.
77## This is a completely normal case, but we had a crash before.
78
79# RUN: yaml2obj --docnum=3 %s -o %t3
80# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=HEX-DESC
81
82# HEX-DESC: Desc: FE0000FE
83
84--- !ELF
85FileHeader:
86  Class: ELFCLASS64
87  Data:  ELFDATA2MSB
88  Type:  ET_DYN
89Sections:
90  - Name:  .note.tag
91    Type:  SHT_NOTE
92    Flags: [ SHF_ALLOC ]
93    Notes:
94      - Desc: 'FE0000FE'
95        Type: 0
96