summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/yaml2obj/elf-override-shsize.yaml
blob: 4470ae22002ff08828cc00eae090cf51be42bfdf (plain)
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
## Check we are able to set custom sh_size field
## for different sections.

# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1

# CASE1:      Section Headers:
# CASE1-NEXT:  [Nr] Name           Type     Address          Off    Size  
# CASE1-NEXT:  [ 0]                NULL     0000000000000000 000000 000000
# CASE1-NEXT:  [ 1] .dynsym        DYNSYM   0000000000000000 000040 000001
# CASE1-NEXT:  [ 2] .symtab        SYMTAB   0000000000000000 000058 000002
# CASE1-NEXT:  [ 3] .dynamic       DYNAMIC  0000000000000000 000070 000003
# CASE1-NEXT:  [ 4] .rela          RELA     0000000000000000 000070 000004
# CASE1-NEXT:  [ 5] .nobits        NOBITS   0000000000000000 000070 000005
# CASE1-NEXT:  [ 6] .group         GROUP    0000000000000000 000070 000006
# CASE1-NEXT:  [ 7] .gnu.version   VERSYM   0000000000000000 000070 000007
# CASE1-NEXT:  [ 8] .gnu.version_r VERNEED  0000000000000000 000070 000008
# CASE1-NEXT:  [ 9] .gnu.version_d VERDEF   0000000000000000 000070 000009
# CASE1-NEXT:  [10] .regular       PROGBITS 0000000000000000 000070 00000a
# CASE1-NEXT:  [11] .strtab        STRTAB   0000000000000000 000070 00000b

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .dynsym
    Type: SHT_DYNSYM
    ShSize: 0x000000001
  - Name: .symtab
    Type: SHT_SYMTAB
    ShSize: 0x000000002
  - Name: .dynamic
    Type: SHT_DYNAMIC
    ShSize: 0x000000003
  - Name: .rela
    Type: SHT_RELA
    ShSize: 0x000000004
  - Name: .nobits
    Type: SHT_NOBITS
    ShSize: 0x000000005
  - Name: .group
    Type: SHT_GROUP
    ShSize: 0x000000006
    Members:
  - Name: .gnu.version
    Type: SHT_GNU_versym
    Entries: [ ]
    ShSize: 0x000000007
  - Name: .gnu.version_r
    Type: SHT_GNU_verneed
    Info: 0x0000000000000001
    ShSize: 0x000000008
    Dependencies:
  - Name: .gnu.version_d
    Type: SHT_GNU_verdef
    Info: 0x0000000000000001
    ShSize: 0x000000009
    Entries:
  - Name: .regular
    Type: SHT_PROGBITS
    ShSize: 0x00000000A
  - Name: .strtab
    Type: SHT_STRTAB
    ShSize: 0x00000000B

## Here we check that defining ShSize does not actually change
## the content and also does not affect file size.

# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: od -t x1 -v %t2 > %t.txt
# RUN: od -t x1 -v %t3 >> %t.txt
# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2

# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE:.*]]{{$}}
# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
# CASE2: [[FILESIZE]]{{$}}

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
    Content: "fefefefefefefefe"

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
    ShSize: 1
    Content: "fefefefefefefefe"

## Check we can define sh_size larger than section content size
## and thus create overlaping sections.

# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4

# CASE4:      Name: .foo
# CASE4:      SectionData (
# CASE4-NEXT: 0000: AAAABBBB |....|
# CASE4:      Name: .bar
# CASE4:      SectionData (
# CASE4-NEXT: 0000: BBBB |..|

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
    Content: "aaaa"
    ShSize: 4
  - Name: .bar
    Type: SHT_PROGBITS
    Content: "bbbb"

## Check we can set both Size and ShSize and the number of the actual
## bytes written is equal to Size in this case.

# RUN: yaml2obj --docnum=5 %s -o %t5
# RUN: od -t x1 -v %t5 | FileCheck %s --ignore-case --check-prefix=CASE5

# CASE5: aa aa 00 00 bb bb

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
    Content: "aaaa"
  - Name: .bar
    Type: SHT_PROGBITS
    Size: 2
    ShSize: 4
  - Name: .zed
    Type: SHT_PROGBITS
    Content: "bbbb"
OpenPOWER on IntegriCloud