1 ## Test that yaml2obj automatically assigns sh_addr to allocatable sections for ET_EXEC/ET_DYN files.
3 # RUN: yaml2obj %s -o %t.so -D TYPE=ET_DYN
4 # RUN: llvm-readelf --sections %t.so | FileCheck %s --check-prefix=EXE-DSO
6 # RUN: yaml2obj %s -o %t -D TYPE=ET_EXEC
7 # RUN: llvm-readelf --sections %t | FileCheck %s --check-prefix=EXE-DSO
9 # RUN: yaml2obj %s -o %t.o -D TYPE=ET_REL
10 # RUN: llvm-readelf --sections %t.o | FileCheck %s --check-prefix=REL
12 ## We assign virtual addresses to allocatable sections automatically for executables and shared libraries.
14 # EXE-DSO: Section Headers:
15 # EXE-DSO-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
16 # EXE-DSO-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
17 # EXE-DSO-NEXT: [ 1] .text.any.addr PROGBITS 0000000000001000 000040 000003 00 A 0 0 0
18 # EXE-DSO-NEXT: [ 2] .text.shsize PROGBITS 0000000000001003 000043 001234 00 A 0 0 0
19 # EXE-DSO-NEXT: [ 3] .text.align PROGBITS 0000000000001100 000100 000004 00 A 0 0 256
20 # EXE-DSO-NEXT: [ 4] .data.any.addr PROGBITS 0000000000002000 000104 000001 00 A 0 0 0
21 # EXE-DSO-NEXT: [ 5] .data.after.fill PROGBITS 0000000000002101 000205 000001 00 A 0 0 0
22 # EXE-DSO-NEXT: [ 6] .data.go.back PROGBITS 0000000000001500 000206 000001 00 A 0 0 0
23 # EXE-DSO-NEXT: [ 7] .data.go.back.foo PROGBITS 0000000000001501 000207 000000 00 A 0 0 0
24 # EXE-DSO-NEXT: [ 8] .dynsym DYNSYM 0000000000001508 000208 000018 18 A 9 1 8
25 # EXE-DSO-NEXT: [ 9] .dynstr STRTAB 0000000000001520 000220 000001 00 A 0 0 1
26 # EXE-DSO-NEXT: [10] .strtab STRTAB 0000000000000000 000221 000001 00 0 0 1
27 # EXE-DSO-NEXT: [11] .shstrtab STRTAB 0000000000000000 000222 00008b 00 0 0 1
29 ## We do not assign virtual addresses to allocatable sections in a relocatable object
30 ## unless YAML document has an explicit request.
32 # REL: Section Headers:
33 # REL-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
34 # REL-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
35 # REL-NEXT: [ 1] .text.any.addr PROGBITS 0000000000001000 000040 000003 00 A 0 0 0
36 # REL-NEXT: [ 2] .text.shsize PROGBITS 0000000000000000 000043 001234 00 A 0 0 0
37 # REL-NEXT: [ 3] .text.align PROGBITS 0000000000000000 000100 000004 00 A 0 0 256
38 # REL-NEXT: [ 4] .data.any.addr PROGBITS 0000000000002000 000104 000001 00 A 0 0 0
39 # REL-NEXT: [ 5] .data.after.fill PROGBITS 0000000000000000 000205 000001 00 A 0 0 0
40 # REL-NEXT: [ 6] .data.go.back PROGBITS 0000000000001500 000206 000001 00 A 0 0 0
41 # REL-NEXT: [ 7] .data.go.back.foo PROGBITS 0000000000000000 000207 000000 00 A 0 0 0
42 # REL-NEXT: [ 8] .dynsym DYNSYM 0000000000000000 000208 000018 18 A 9 1 8
43 # REL-NEXT: [ 9] .dynstr STRTAB 0000000000000000 000220 000001 00 A 0 0 1
44 # REL-NEXT: [10] .strtab STRTAB 0000000000000000 000221 000001 00 0 0 1
45 # REL-NEXT: [11] .shstrtab STRTAB 0000000000000000 000222 00008b 00 0 0 1
53 ## Show we can place a section at any address.
54 - Name: .text.any.addr
59 ## Test that ShSize does not affect virtual addresses.
64 ## Show we respect an address align when automatically
65 ## assign virtual addresses.
71 ## We can set another address for a subsequent section.
72 - Name: .data.any.addr
77 ## Show that Fill occupies VA space.
81 - Name: .data.after.fill
85 ## Show we can go back in the address space and
86 ## continue placing sections. The order of sections in the
87 ## section header table will match the order in the YAML description.
93 - Name: .data.go.back.foo
96 ## Used to trigger creation of .dynsym and .dynstr.