1## Check the section header properties of ".dynsym",
2## ".dynstr", ".symtab", ".strtab", ".shstrtab".
3## These sections sections are usually added implicitly,
4## but here we add them explicitly in YAML and verify.
5## We check their order matches YAML and that file offset is
6## ascending. This is a natural default behavior.
7
8# RUN: yaml2obj --docnum=1 %s -o %t1
9# RUN: llvm-readelf -S %t1 | FileCheck %s
10
11# CHECK:      Section Headers:
12# CHECK-NEXT:  [Nr] Name      Type     Address          Off    Size
13# CHECK-NEXT:  [ 0]           NULL     0000000000000000 000000 000000
14# CHECK-NEXT:  [ 1] .dynstr   STRTAB   0000000000000100 000040 000001
15# CHECK-NEXT:  [ 2] .dynsym   DYNSYM   0000000000000150 000041 000018
16# CHECK-NEXT:  [ 3] .symtab   SYMTAB   0000000000000000 000059 000018
17# CHECK-NEXT:  [ 4] .strtab   STRTAB   0000000000000000 000071 000001
18# CHECK-NEXT:  [ 5] .shstrtab STRTAB   0000000000000000 000072 000035
19# CHECK-NEXT:  [ 6] .text.foo PROGBITS 0000000000000200 0000a7 000000
20
21--- !ELF
22FileHeader:
23  Class: ELFCLASS64
24  Data:  ELFDATA2LSB
25  Type:  ET_DYN
26Sections:
27  - Name:    .dynstr
28    Type:    SHT_STRTAB
29    Address: 0x100
30  - Name:    .dynsym
31    Type:    SHT_DYNSYM
32    Address: 0x150
33  - Name:    .symtab
34    Type:    SHT_SYMTAB
35  - Name:    .strtab
36    Type:    SHT_STRTAB
37  - Name:    .shstrtab
38    Type:    SHT_STRTAB
39  - Name:    .text.foo
40    Type:    SHT_PROGBITS
41    Address: 0x200
42
43## Check that yaml2obj creates empty .dynstr and .dynsym sections for
44## the case when no dynamic symbols were specified and Content wasn't set,
45## but the sections were explicitly listed. Check their VAs are correct.
46
47# RUN: yaml2obj --docnum=2 %s -o %t2
48# RUN: llvm-readelf -S %t2 | FileCheck %s --check-prefix=NODYNSYM
49
50# NODYNSYM:      Section Headers:
51# NODYNSYM-NEXT: [Nr] Name      Type      Address          Off    Size
52# NODYNSYM-NEXT: [ 0]           NULL      0000000000000000 000000 000000
53# NODYNSYM-NEXT: [ 1] .dynstr   STRTAB    0000000000000100 000040 000001
54# NODYNSYM-NEXT: [ 2] .dynsym   DYNSYM    0000000000000150 000041 000018
55# NODYNSYM-NEXT: [ 3] .symtab   SYMTAB    0000000000000000 000059 000018
56# NODYNSYM-NEXT: [ 4] .strtab   STRTAB    0000000000000000 000071 000001
57# NODYNSYM-NEXT: [ 5] .shstrtab STRTAB    0000000000000000 000072 000035
58# NODYNSYM-NEXT: [ 6] .text.foo PROGBITS  0000000000000200 0000a7 000000
59
60--- !ELF
61FileHeader:
62  Class: ELFCLASS64
63  Data:  ELFDATA2LSB
64  Type:  ET_DYN
65Sections:
66  - Name:    .dynstr
67    Type:    SHT_STRTAB
68    Address: 0x100
69  - Name:    .dynsym
70    Type:    SHT_DYNSYM
71    Address: 0x150
72  - Name:    .symtab
73    Type:    SHT_SYMTAB
74  - Name:    .strtab
75    Type:    SHT_STRTAB
76  - Name:    .shstrtab
77    Type:    SHT_STRTAB
78  - Name:    .text.foo
79    Type:    SHT_PROGBITS
80    Address: 0x200
81
82## Check we don't add a symbol table when no "Symbols" key is specified.
83
84# RUN: yaml2obj --docnum=3 %s -o %t3
85# RUN: llvm-readelf -S %t3 | FileCheck /dev/null --implicit-check-not=.symtab
86
87--- !ELF
88FileHeader:
89  Class: ELFCLASS64
90  Data:  ELFDATA2LSB
91  Type:  ET_DYN
92
93## Check we add a symbol table when "Symbols" key is specified.
94
95# RUN: yaml2obj --docnum=4 %s -o %t4
96# RUN: llvm-readelf -S %t4 | FileCheck %s --check-prefix=SYMTAB
97
98# SYMTAB: .symtab
99
100--- !ELF
101FileHeader:
102  Class: ELFCLASS64
103  Data:  ELFDATA2LSB
104  Type:  ET_DYN
105Symbols: []
106