98 lines · yaml
1## Test that yaml2obj automatically assigns sh_addr to allocatable sections for ET_EXEC/ET_DYN files.2 3# RUN: yaml2obj %s -o %t.so -D TYPE=ET_DYN4# RUN: llvm-readelf --sections %t.so | FileCheck %s --check-prefix=EXE-DSO5 6# RUN: yaml2obj %s -o %t -D TYPE=ET_EXEC7# RUN: llvm-readelf --sections %t | FileCheck %s --check-prefix=EXE-DSO8 9# RUN: yaml2obj %s -o %t.o -D TYPE=ET_REL10# RUN: llvm-readelf --sections %t.o | FileCheck %s --check-prefix=REL11 12## We assign virtual addresses to allocatable sections automatically for executables and shared libraries.13 14# EXE-DSO: Section Headers:15# EXE-DSO-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al16# EXE-DSO-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 017# EXE-DSO-NEXT: [ 1] .text.any.addr PROGBITS 0000000000001000 000040 000003 00 A 0 0 018# EXE-DSO-NEXT: [ 2] .text.shsize PROGBITS 0000000000001003 000043 001234 00 A 0 0 019# EXE-DSO-NEXT: [ 3] .text.align PROGBITS 0000000000001100 000100 000004 00 A 0 0 25620# EXE-DSO-NEXT: [ 4] .data.any.addr PROGBITS 0000000000002000 000104 000001 00 A 0 0 021# EXE-DSO-NEXT: [ 5] .data.after.fill PROGBITS 0000000000002101 000205 000001 00 A 0 0 022# EXE-DSO-NEXT: [ 6] .data.go.back PROGBITS 0000000000001500 000206 000001 00 A 0 0 023# EXE-DSO-NEXT: [ 7] .data.go.back.foo PROGBITS 0000000000001501 000207 000000 00 A 0 0 024# EXE-DSO-NEXT: [ 8] .dynsym DYNSYM 0000000000001508 000208 000018 18 A 9 1 825# EXE-DSO-NEXT: [ 9] .dynstr STRTAB 0000000000001520 000220 000001 00 A 0 0 126# EXE-DSO-NEXT: [10] .strtab STRTAB 0000000000000000 000221 000001 00 0 0 127# EXE-DSO-NEXT: [11] .shstrtab STRTAB 0000000000000000 000222 00008b 00 0 0 128 29## We do not assign virtual addresses to allocatable sections in a relocatable object30## unless YAML document has an explicit request.31 32# REL: Section Headers:33# REL-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al34# REL-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 035# REL-NEXT: [ 1] .text.any.addr PROGBITS 0000000000001000 000040 000003 00 A 0 0 036# REL-NEXT: [ 2] .text.shsize PROGBITS 0000000000000000 000043 001234 00 A 0 0 037# REL-NEXT: [ 3] .text.align PROGBITS 0000000000000000 000100 000004 00 A 0 0 25638# REL-NEXT: [ 4] .data.any.addr PROGBITS 0000000000002000 000104 000001 00 A 0 0 039# REL-NEXT: [ 5] .data.after.fill PROGBITS 0000000000000000 000205 000001 00 A 0 0 040# REL-NEXT: [ 6] .data.go.back PROGBITS 0000000000001500 000206 000001 00 A 0 0 041# REL-NEXT: [ 7] .data.go.back.foo PROGBITS 0000000000000000 000207 000000 00 A 0 0 042# REL-NEXT: [ 8] .dynsym DYNSYM 0000000000000000 000208 000018 18 A 9 1 843# REL-NEXT: [ 9] .dynstr STRTAB 0000000000000000 000220 000001 00 A 0 0 144# REL-NEXT: [10] .strtab STRTAB 0000000000000000 000221 000001 00 0 0 145# REL-NEXT: [11] .shstrtab STRTAB 0000000000000000 000222 00008b 00 0 0 146 47--- !ELF48FileHeader:49 Class: ELFCLASS6450 Data: ELFDATA2LSB51 Type: [[TYPE]]52Sections:53## Show we can place a section at any address.54 - Name: .text.any.addr55 Type: SHT_PROGBITS56 Flags: [ SHF_ALLOC ]57 Address: 0x100058 Size: 0x359## Test that ShSize does not affect virtual addresses.60 - Name: .text.shsize61 Type: SHT_PROGBITS62 Flags: [ SHF_ALLOC ]63 ShSize: 0x123464## Show we respect an address align when automatically65## assign virtual addresses.66 - Name: .text.align67 Type: SHT_PROGBITS68 Flags: [ SHF_ALLOC ]69 AddressAlign: 0x10070 Size: 0x471## We can set another address for a subsequent section.72 - Name: .data.any.addr73 Type: SHT_PROGBITS74 Flags: [ SHF_ALLOC ]75 Address: 0x200076 Size: 0x177## Show that Fill occupies VA space.78 - Type: Fill79 Pattern: "AABB"80 Size: 0x10081 - Name: .data.after.fill82 Type: SHT_PROGBITS83 Flags: [ SHF_ALLOC ]84 Size: 0x185## Show we can go back in the address space and86## continue placing sections. The order of sections in the87## section header table will match the order in the YAML description.88 - Name: .data.go.back89 Address: 0x150090 Type: SHT_PROGBITS91 Flags: [ SHF_ALLOC ]92 Size: 0x193 - Name: .data.go.back.foo94 Type: SHT_PROGBITS95 Flags: [ SHF_ALLOC ]96## Used to trigger creation of .dynsym and .dynstr.97DynamicSymbols: []98