File: implicit-sections-order.yaml

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (163 lines) | stat: -rw-r--r-- 6,165 bytes parent folder | download | duplicates (2)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
## Check that obj2yaml dumps SHT_STRTAB/SHT_SYMTAB/SHT_DYNSYM sections
## when they are allocatable.

## In the following test we check the normal case: when .dynsym (SHT_DYNSYM)
## and .dynstr (SHT_STRTAB) are allocatable sections and .symtab (SHT_SYMTAB),
## .strtab (SHT_STRTAB) and .shstrtab (SHT_STRTAB) are not.
## Check we explicitly declare allocatable sections.

# RUN: yaml2obj %s -o %t1.so -D FLAG1=SHF_ALLOC -D FLAG2=""
# RUN: llvm-readelf -S %t1.so | FileCheck %s --check-prefixes=RE,RE-1
# RUN: obj2yaml %t1.so | FileCheck %s --check-prefix=OUTPUT

## Check the information about sections using an independent tool.

# RE:        Section Headers:
# RE-NEXT:   [Nr] Name      Type     Address          Off    Size   ES Flg Lk Inf Al
# RE-NEXT:   [ 0]           NULL     0000000000000000 000000 000000 00     0   0  0
# RE-NEXT:   [ 1] .foo.1    PROGBITS 0000000000000000 000040 000000 00     0   0  0
# RE-1-NEXT: [ 2] .dynsym   DYNSYM   0000000000001000 000040 000030 18   A 4   2  0
# RE-2-NEXT: [ 2] .dynsym   DYNSYM   0000000000001000 000040 000030 18     4   2  0
# RE-NEXT:   [ 3] .foo.2    PROGBITS 0000000000000000 000070 000000 00     0   0  0
# RE-1-NEXT: [ 4] .dynstr   STRTAB   0000000000002000 000070 000005 00   A 0   0  0
# RE-2-NEXT: [ 4] .dynstr   STRTAB   0000000000002000 000070 000005 00     0   0  0
# RE-NEXT:   [ 5] .foo.3    PROGBITS 0000000000000000 000075 000000 00     0   0  0
# RE-1-NEXT: [ 6] .symtab   SYMTAB   0000000000003000 000075 000030 18     8   2  0
# RE-2-NEXT: [ 6] .symtab   SYMTAB   0000000000003000 000075 000030 18   A 8   2  0
# RE-NEXT:   [ 7] .foo.4    PROGBITS 0000000000000000 0000a5 000000 00     0   0  0
# RE-1-NEXT: [ 8] .strtab   STRTAB   0000000000004000 0000a5 000005 00     0   0  0
# RE-2-NEXT: [ 8] .strtab   STRTAB   0000000000004000 0000a5 000005 00   A 0   0  0
# RE-NEXT:   [ 9] .foo.5    PROGBITS 0000000000000000 0000aa 000000 00     0   0  0
# RE-1-NEXT: [10] .shstrtab STRTAB   0000000000005000 0000aa 000055 00     0   0  0
# RE-2-NEXT: [10] .shstrtab STRTAB   0000000000005000 0000aa 000055 00   A 0   0  0
# RE-NEXT:   [11] .foo.6    PROGBITS 0000000000000000 0000ff 000000 00     0   0  0

# OUTPUT:      --- !ELF
# OUTPUT-NEXT: FileHeader:
# OUTPUT-NEXT:   Class:   ELFCLASS64
# OUTPUT-NEXT:   Data:    ELFDATA2LSB
# OUTPUT-NEXT:   Type:    ET_DYN
# OUTPUT-NEXT:   Machine: EM_X86_64
# OUTPUT-NEXT: Sections:
# OUTPUT-NEXT:   - Name: .foo.1
# OUTPUT-NEXT:     Type: SHT_PROGBITS
# OUTPUT-NEXT:   - Name:    .dynsym
# OUTPUT-NEXT:     Type:    SHT_DYNSYM
# OUTPUT-NEXT:     Flags:   [ SHF_ALLOC ]
# OUTPUT-NEXT:     Address: 0x0000000000001000
# OUTPUT-NEXT:     Link:    .dynstr
# OUTPUT-NEXT:     EntSize: 0x0000000000000018
# OUTPUT-NEXT:   - Name: .foo.2
# OUTPUT-NEXT:     Type: SHT_PROGBITS
# OUTPUT-NEXT:   - Name:    .dynstr
# OUTPUT-NEXT:     Type:    SHT_STRTAB
# OUTPUT-NEXT:     Flags:   [ SHF_ALLOC ]
# OUTPUT-NEXT:     Address: 0x0000000000002000
# OUTPUT-NEXT:   - Name: .foo.3
# OUTPUT-NEXT:     Type: SHT_PROGBITS
# OUTPUT-NEXT:   - Name: .foo.4
# OUTPUT-NEXT:     Type: SHT_PROGBITS
# OUTPUT-NEXT:   - Name: .foo.5
# OUTPUT-NEXT:     Type: SHT_PROGBITS
# OUTPUT-NEXT:   - Name: .foo.6
# OUTPUT-NEXT:     Type: SHT_PROGBITS
# OUTPUT-NEXT: Symbols:
# OUTPUT-NEXT:   - Name: foo
# OUTPUT-NEXT: DynamicSymbols:
# OUTPUT-NEXT:   - Name: bar
# OUTPUT-NEXT: ...

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .foo.1
    Type: SHT_PROGBITS
  - Name:    .dynsym
    Type:    SHT_DYNSYM
    Address: 0x1000
    Flags: [ [[FLAG1]] ]
  - Name: .foo.2
    Type: SHT_PROGBITS
  - Name:    .dynstr
    Type:    SHT_STRTAB
    Address: 0x2000
    Flags: [ [[FLAG1]] ]
  - Name: .foo.3
    Type: SHT_PROGBITS
  - Name:    .symtab
    Type:    SHT_SYMTAB
    Address: 0x3000
    Flags: [ [[FLAG2]] ]
  - Name: .foo.4
    Type: SHT_PROGBITS
  - Name:    .strtab
    Type:    SHT_STRTAB
    Address: 0x4000
    Flags: [ [[FLAG2]] ]
  - Name: .foo.5
    Type: SHT_PROGBITS
  - Name:    .shstrtab
    Type:    SHT_STRTAB
    Address: 0x5000
    Flags: [ [[FLAG2]] ]
  - Name: .foo.6
    Type: SHT_PROGBITS
Symbols:
  - Name: foo
DynamicSymbols:
  - Name: bar

## Now test the abnormal case: when .symtab (SHT_SYMTAB),
## .strtab (SHT_STRTAB) and .shstrtab (SHT_STRTAB) are
## allocatable sections, but .dynsym (SHT_DYNSYM) and
## .dynstr (SHT_STRTAB) are not.
## Check that only allocatable versions are explicitly declared.

# RUN: yaml2obj %s -o %t2.so -D FLAG1="" -D FLAG2=SHF_ALLOC
# RUN: llvm-readelf -S %t2.so | FileCheck %s --check-prefixes=RE,RE-2
# RUN: obj2yaml %t2.so | FileCheck %s --check-prefix=OUTPUT2

## Check we explicitly declare only allocatable
## SHT_STRTAB/SHT_SYMTAB/SHT_DYNSYM sections.
# OUTPUT2:      --- !ELF
# OUTPUT2-NEXT: FileHeader:
# OUTPUT2-NEXT:   Class:   ELFCLASS64
# OUTPUT2-NEXT:   Data:    ELFDATA2LSB
# OUTPUT2-NEXT:   Type:    ET_DYN
# OUTPUT2-NEXT:   Machine: EM_X86_64
# OUTPUT2-NEXT: Sections:
# OUTPUT2-NEXT:   - Name: .foo.1
# OUTPUT2-NEXT:     Type: SHT_PROGBITS
# OUTPUT2-NEXT:   - Name: .foo.2
# OUTPUT2-NEXT:     Type: SHT_PROGBITS
# OUTPUT2-NEXT:   - Name: .foo.3
# OUTPUT2-NEXT:     Type: SHT_PROGBITS
# OUTPUT2-NEXT:   - Name:    .symtab
# OUTPUT2-NEXT:     Type:    SHT_SYMTAB
# OUTPUT2-NEXT:     Flags:   [ SHF_ALLOC ]
# OUTPUT2-NEXT:     Address: 0x0000000000003000
# OUTPUT2-NEXT:     Link:    .strtab
# OUTPUT2-NEXT:     EntSize: 0x0000000000000018
# OUTPUT2-NEXT:   - Name: .foo.4
# OUTPUT2-NEXT:     Type: SHT_PROGBITS
# OUTPUT2-NEXT:   - Name:    .strtab
# OUTPUT2-NEXT:     Type:    SHT_STRTAB
# OUTPUT2-NEXT:     Flags:   [ SHF_ALLOC ]
# OUTPUT2-NEXT:     Address: 0x0000000000004000
# OUTPUT2-NEXT:   - Name: .foo.5
# OUTPUT2-NEXT:     Type: SHT_PROGBITS
# OUTPUT2-NEXT:   - Name:    .shstrtab
# OUTPUT2-NEXT:     Type:    SHT_STRTAB
# OUTPUT2-NEXT:     Flags:   [ SHF_ALLOC ]
# OUTPUT2-NEXT:     Address: 0x0000000000005000
# OUTPUT2-NEXT:   - Name:    .foo.6
# OUTPUT2-NEXT:     Type:    SHT_PROGBITS
# OUTPUT2-NEXT: Symbols:
# OUTPUT2-NEXT:   - Name: foo
# OUTPUT2-NEXT: DynamicSymbols:
# OUTPUT2-NEXT:   - Name: bar
# OUTPUT2-NEXT: ...