diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index cd3a0faa03df..362a9432568f 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -116,7 +116,6 @@ template class ELFState { bool buildSectionIndex(); bool buildSymbolIndexes(); - void initELFHeader(Elf_Ehdr &Header); void initProgramHeaders(std::vector &PHeaders); bool initImplicitHeader(ContiguousBlobAccumulator &CBA, Elf_Shdr &Header, StringRef SecName, ELFYAML::Section *YAMLSec); @@ -132,6 +131,7 @@ template class ELFState { void setProgramHeaderLayout(std::vector &PHeaders, std::vector &SHeaders); void finalizeStrings(); + void writeELFHeader(ContiguousBlobAccumulator &CBA, raw_ostream &OS); bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::RawContentSection &Section, ContiguousBlobAccumulator &CBA); @@ -205,8 +205,11 @@ template ELFState::ELFState(ELFYAML::Object &D) : Doc(D) { } } -template void ELFState::initELFHeader(Elf_Ehdr &Header) { +template +void ELFState::writeELFHeader(ContiguousBlobAccumulator &CBA, raw_ostream &OS) { using namespace llvm::ELF; + + Elf_Ehdr Header; zero(Header); Header.e_ident[EI_MAG0] = 0x7f; Header.e_ident[EI_MAG1] = 'E'; @@ -230,14 +233,18 @@ template void ELFState::initELFHeader(Elf_Ehdr &Header) { Header.e_shentsize = Doc.Header.SHEntSize ? (uint16_t)*Doc.Header.SHEntSize : sizeof(Elf_Shdr); // Immediately following the ELF header and program headers. - Header.e_shoff = - Doc.Header.SHOffset - ? (typename ELFT::uint)(*Doc.Header.SHOffset) - : sizeof(Header) + sizeof(Elf_Phdr) * Doc.ProgramHeaders.size(); + // Align the start of the section header and write the ELF header. + uint64_t ShOffset; + CBA.getOSAndAlignedOffset(ShOffset, sizeof(typename ELFT::uint)); + Header.e_shoff = Doc.Header.SHOffset + ? typename ELFT::uint(*Doc.Header.SHOffset) + : ShOffset; Header.e_shnum = Doc.Header.SHNum ? (uint16_t)*Doc.Header.SHNum : Doc.Sections.size(); Header.e_shstrndx = Doc.Header.SHStrNdx ? (uint16_t)*Doc.Header.SHStrNdx : SN2I.get(".shstrtab"); + + OS.write((const char *)&Header, sizeof(Header)); } template @@ -1040,19 +1047,13 @@ int ELFState::writeELF(raw_ostream &OS, ELFYAML::Object &Doc) { if (!State.buildSectionIndex() || !State.buildSymbolIndexes()) return 1; - Elf_Ehdr Header; - State.initELFHeader(Header); - - // TODO: Flesh out section header support. - std::vector PHeaders; State.initProgramHeaders(PHeaders); // XXX: This offset is tightly coupled with the order that we write // things to `OS`. - const size_t SectionContentBeginOffset = Header.e_ehsize + - Header.e_phentsize * Header.e_phnum + - Header.e_shentsize * Header.e_shnum; + const size_t SectionContentBeginOffset = + sizeof(Elf_Ehdr) + sizeof(Elf_Phdr) * Doc.ProgramHeaders.size(); ContiguousBlobAccumulator CBA(SectionContentBeginOffset); std::vector SHeaders; @@ -1062,10 +1063,10 @@ int ELFState::writeELF(raw_ostream &OS, ELFYAML::Object &Doc) { // Now we can decide segment offsets State.setProgramHeaderLayout(PHeaders, SHeaders); - OS.write((const char *)&Header, sizeof(Header)); + State.writeELFHeader(CBA, OS); writeArrayData(OS, makeArrayRef(PHeaders)); - writeArrayData(OS, makeArrayRef(SHeaders)); CBA.writeBlobToStream(OS); + writeArrayData(OS, makeArrayRef(SHeaders)); return 0; } diff --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test index 8a75ecd3b779..397c948001e3 100644 --- a/llvm/test/Object/invalid.test +++ b/llvm/test/Object/invalid.test @@ -315,7 +315,7 @@ FileHeader: # RUN: yaml2obj %s --docnum=16 -o %t16 # RUN: not llvm-readobj -r %t16 2>&1 | FileCheck -DFILE=%t16 --check-prefix=INVALID-REL-SYM %s -# INVALID-REL-SYM: error: '[[FILE]]': unable to access section [index 2] data at 0x18000180: offset goes past the end of file +# INVALID-REL-SYM: error: '[[FILE]]': unable to access section [index 2] data at 0x18000040: offset goes past the end of file --- !ELF FileHeader: @@ -565,7 +565,7 @@ Sections: # RUN: yaml2obj --docnum=26 %s -o %t26 # RUN: not llvm-readobj -h %t26 2>&1 | FileCheck -DFILE=%t26 --check-prefix=INVALID-SEC-NUM1 %s -# INVALID-SEC-NUM1: error: '[[FILE]]': invalid section header table offset (e_shoff = 0x40) or invalid number of sections specified in the first section header's sh_size field (0x3ffffffffffffff) +# INVALID-SEC-NUM1: error: '[[FILE]]': invalid section header table offset (e_shoff = 0x78) or invalid number of sections specified in the first section header's sh_size field (0x3ffffffffffffff) --- !ELF FileHeader: diff --git a/llvm/test/tools/llvm-objcopy/ELF/group-reorder.test b/llvm/test/tools/llvm-objcopy/ELF/group-reorder.test index 25d0cd521313..25c57bea220f 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/group-reorder.test +++ b/llvm/test/tools/llvm-objcopy/ELF/group-reorder.test @@ -8,12 +8,12 @@ # aren't purely sorting based on offsets (it gets moved to the beginning # despite having a larger offset). -# IN: There are 7 section headers, starting at offset 0x40: +# IN: There are 7 section headers, starting at offset 0x160: # IN: [Nr] Name Type Address Off Size # IN-NEXT: [ 0] NULL 0000000000000000 000000 000000 -# IN-NEXT: [ 1] .foo PROGBITS 0000000000000000 000200 000040 -# IN-NEXT: [ 2] .group GROUP 0000000000000000 000240 000008 -# IN-NEXT: [ 3] .bar PROGBITS 0000000000000000 000248 000040 +# IN-NEXT: [ 1] .foo PROGBITS 0000000000000000 000040 000040 +# IN-NEXT: [ 2] .group GROUP 0000000000000000 000080 000008 +# IN-NEXT: [ 3] .bar PROGBITS 0000000000000000 000088 000040 # IN: COMDAT group section [ 2] `.group' [bar] contains 1 sections: # IN-NEXT: [Index] Name diff --git a/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test b/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test index 9ebfc11e3c73..fc2e08484b29 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test +++ b/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test @@ -7,13 +7,13 @@ ## Sanity check that the section header table is at offset 64: # RUN: llvm-readobj --file-headers %t.o | FileCheck %s --check-prefix=VALIDATE -# VALIDATE: SectionHeaderOffset: 0x40{{$}} +# VALIDATE: SectionHeaderOffset: 0x80{{$}} ## Truncate the file to end before the section header table ends. -# RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)" +# RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(0x7f)" # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s -DINPUT=%t.o --check-prefix=CASE1 -# CASE1: error: '[[INPUT]]': section header table goes past the end of the file: e_shoff = 0x40 +# CASE1: error: '[[INPUT]]': section header table goes past the end of the file: e_shoff = 0x80 ## Set the e_shoff field to a value much larger than the object file size. # RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('&1 | FileCheck %s --check-prefix=ERR1 -# ERR1: error: program header with offset 0x1b8 and file size 0x100000 goes past the end of the file +# ERR1: error: program header with offset 0x78 and file size 0x100000 goes past the end of the file --- !ELF FileHeader: diff --git a/llvm/test/tools/llvm-objcopy/ELF/overlapping-sections-in-segments.test b/llvm/test/tools/llvm-objcopy/ELF/overlapping-sections-in-segments.test index 2998d5c78333..cd92a7eb643e 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/overlapping-sections-in-segments.test +++ b/llvm/test/tools/llvm-objcopy/ELF/overlapping-sections-in-segments.test @@ -4,14 +4,13 @@ ## inputs somehow. # RUN: yaml2obj %s -o %t.o -## First, check that the section header table appears immediately after the program -## header table. +## First, check the address of the section header table. # RUN: llvm-readobj --file-headers %t.o | FileCheck %s --check-prefix=SHDRS-OFFSET -# SHDRS-OFFSET: SectionHeaderOffset: 0x78{{$}} +# SHDRS-OFFSET: SectionHeaderOffset: 0x1050{{$}} ## Binary edit the section header sh_offset field of the second section to -## overlap the first one. -# RUN: %python -c "with open('%/t.o', 'r+b') as input: import struct; bytes = struct.pack('&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2 # RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2 -# ERR2: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset (0x180) or size (0xffff0000) +# ERR2: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset (0x40) or size (0xffff0000) --- !ELF FileHeader: @@ -172,7 +172,7 @@ ProgramHeaders: # RUN: not llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4 # RUN: not llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4 -# ERR4: error: '[[FILE]]': PT_NOTE header has invalid offset (0x1b8) or size (0xffff0000) +# ERR4: error: '[[FILE]]': PT_NOTE header has invalid offset (0x78) or size (0xffff0000) --- !ELF FileHeader: diff --git a/llvm/test/tools/llvm-readobj/gnu-sections.test b/llvm/test/tools/llvm-readobj/gnu-sections.test index 17a0c4cb8eb2..c5c67330ef3c 100644 --- a/llvm/test/tools/llvm-readobj/gnu-sections.test +++ b/llvm/test/tools/llvm-readobj/gnu-sections.test @@ -1,18 +1,18 @@ # RUN: yaml2obj --docnum=1 %s -o %t-i386.o # RUN: llvm-readelf -S %t-i386.o | FileCheck %s -check-prefix ELF32 -# ELF32: There are 8 section headers, starting at offset 0x34: +# ELF32: There are 8 section headers, starting at offset 0x90: # ELF32-EMPTY: # ELF32-NEXT: Section Headers: # ELF32-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # ELF32-NEXT: [ 0] NULL 00000000 000000 000000 00 0 0 0 -# ELF32-NEXT: [ 1] .text PROGBITS 00000000 000174 000001 00 AX 0 0 4 -# ELF32-NEXT: [ 2] .rel.text REL 00000000 000178 000000 08 5 1 4 -# ELF32-NEXT: [ 3] .data PROGBITS 00000000 000178 000000 00 WA 0 0 4 -# ELF32-NEXT: [ 4] .bss NOBITS 00000000 000178 000000 00 WA 0 0 4 -# ELF32-NEXT: [ 5] .symtab SYMTAB 00000000 000178 000020 10 6 2 8 -# ELF32-NEXT: [ 6] .strtab STRTAB 00000000 000198 000007 00 0 0 1 -# ELF32-NEXT: [ 7] .shstrtab STRTAB 00000000 00019f 000030 00 0 0 1 +# ELF32-NEXT: [ 1] .text PROGBITS 00000000 000034 000001 00 AX 0 0 4 +# ELF32-NEXT: [ 2] .rel.text REL 00000000 000038 000000 08 5 1 4 +# ELF32-NEXT: [ 3] .data PROGBITS 00000000 000038 000000 00 WA 0 0 4 +# ELF32-NEXT: [ 4] .bss NOBITS 00000000 000038 000000 00 WA 0 0 4 +# ELF32-NEXT: [ 5] .symtab SYMTAB 00000000 000038 000020 10 6 2 8 +# ELF32-NEXT: [ 6] .strtab STRTAB 00000000 000058 000007 00 0 0 1 +# ELF32-NEXT: [ 7] .shstrtab STRTAB 00000000 00005f 000030 00 0 0 1 # ELF32-NEXT: Key to Flags: # ELF32-NEXT: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) # ELF32-NEXT: I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) @@ -63,18 +63,18 @@ Symbols: # RUN: | FileCheck %s -check-prefix ELF64 # RUN: llvm-readelf -W -S %t-x64.o | FileCheck %s -check-prefix ELF64 -# ELF64: There are 8 section headers, starting at offset 0x40: +# ELF64: There are 8 section headers, starting at offset 0xb0: # ELF64-EMPTY: # ELF64-NEXT: Section Headers: # ELF64-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # ELF64-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 -# ELF64-NEXT: [ 1] .text PROGBITS 0000000000000000 000240 000001 00 AX 0 0 4 -# ELF64-NEXT: [ 2] .rela.text RELA 0000000000000000 000248 000000 18 5 1 8 -# ELF64-NEXT: [ 3] .data PROGBITS 0000000000000000 000248 000000 00 WA 0 0 4 -# ELF64-NEXT: [ 4] .bss NOBITS 0000000000000000 000248 000000 00 WA 0 0 4 -# ELF64-NEXT: [ 5] .symtab SYMTAB 0000000000000000 000248 000030 18 6 2 8 -# ELF64-NEXT: [ 6] .strtab STRTAB 0000000000000000 000278 000007 00 0 0 1 -# ELF64-NEXT: [ 7] .shstrtab STRTAB 0000000000000000 00027f 000031 00 0 0 1 +# ELF64-NEXT: [ 1] .text PROGBITS 0000000000000000 000040 000001 00 AX 0 0 4 +# ELF64-NEXT: [ 2] .rela.text RELA 0000000000000000 000048 000000 18 5 1 8 +# ELF64-NEXT: [ 3] .data PROGBITS 0000000000000000 000048 000000 00 WA 0 0 4 +# ELF64-NEXT: [ 4] .bss NOBITS 0000000000000000 000048 000000 00 WA 0 0 4 +# ELF64-NEXT: [ 5] .symtab SYMTAB 0000000000000000 000048 000030 18 6 2 8 +# ELF64-NEXT: [ 6] .strtab STRTAB 0000000000000000 000078 000007 00 0 0 1 +# ELF64-NEXT: [ 7] .shstrtab STRTAB 0000000000000000 00007f 000031 00 0 0 1 # ELF64-NEXT: Key to Flags: # ELF64-NEXT: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) # ELF64-NEXT: I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) diff --git a/llvm/test/tools/llvm-readobj/reloc-types-elf-i386.test b/llvm/test/tools/llvm-readobj/reloc-types-elf-i386.test index 1f661e40318a..8606f3fa8cba 100644 --- a/llvm/test/tools/llvm-readobj/reloc-types-elf-i386.test +++ b/llvm/test/tools/llvm-readobj/reloc-types-elf-i386.test @@ -47,7 +47,7 @@ # LLVM: Type: R_386_IRELATIVE (42) # LLVM: Type: R_386_GOT32X (43) -# GNU: Relocation section '.rel.text' at offset 0x128 contains 41 entries: +# GNU: Relocation section '.rel.text' at offset 0x38 contains 41 entries: # GNU-NEXT: Offset Info Type Sym. Value Symbol's Name # GNU-NEXT: 00000002 00000100 R_386_NONE 00000000 foo # GNU-NEXT: 00000008 00000101 R_386_32 00000000 foo diff --git a/llvm/test/tools/llvm-readobj/reloc-types-elf-x64.test b/llvm/test/tools/llvm-readobj/reloc-types-elf-x64.test index 021fbb5d3d78..ad4e06fc955a 100644 --- a/llvm/test/tools/llvm-readobj/reloc-types-elf-x64.test +++ b/llvm/test/tools/llvm-readobj/reloc-types-elf-x64.test @@ -46,7 +46,7 @@ # LLVM: Type: R_X86_64_GOTPCRELX (41) # LLVM: Type: R_X86_64_REX_GOTPCRELX (42) -# GNU: Relocation section '.rela.text' at offset 0x1c8 contains 40 entries: +# GNU: Relocation section '.rela.text' at offset 0x48 contains 40 entries: # GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend # GNU-NEXT: 0000000000000003 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0 # GNU-NEXT: 000000000000000a 0000000100000001 R_X86_64_64 0000000000000000 foo + 0 diff --git a/llvm/test/tools/llvm-readobj/unwind.test b/llvm/test/tools/llvm-readobj/unwind.test index fa7aa5c4220a..7463b2713e68 100644 --- a/llvm/test/tools/llvm-readobj/unwind.test +++ b/llvm/test/tools/llvm-readobj/unwind.test @@ -3,7 +3,7 @@ # CHECK: EH_FRAME Header [ # CHECK-NEXT: Address: 0x4013c0 -# CHECK-NEXT: Offset: 0x27c +# CHECK-NEXT: Offset: 0xbc # CHECK-NEXT: Size: 0x3c # CHECK-NEXT: Corresponding Section: .eh_frame_hdr # CHECK-NEXT: Header { @@ -40,7 +40,7 @@ # CHECK-NEXT: } # CHECK-NEXT:] -# CHECK: .eh_frame section at offset 0x2b8 address 0x401400: +# CHECK: .eh_frame section at offset 0xf8 address 0x401400: # CHECK-NEXT: [0x401400] CIE length=20 # CHECK-NEXT: version: 1 # CHECK-NEXT: augmentation: zR diff --git a/llvm/test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml b/llvm/test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml index c8e583f5033c..47f138043aa4 100644 --- a/llvm/test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml +++ b/llvm/test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml @@ -75,7 +75,7 @@ DynamicSymbols: # CASE4-NEXT: SHF_ALLOC # CASE4-NEXT: ] # CASE4-NEXT: Address: 0x0 -# CASE4-NEXT: Offset: 0x180 +# CASE4-NEXT: Offset: 0x40 # CASE4-NEXT: Size: 2 # CASE4-NEXT: Link: 0 # CASE4-NEXT: Info: 1 @@ -107,7 +107,7 @@ Sections: # CASE5-NEXT: SHF_ALLOC # CASE5-NEXT: ] # CASE5-NEXT: Address: 0x0 -# CASE5-NEXT: Offset: 0x180 +# CASE5-NEXT: Offset: 0x40 # CASE5-NEXT: Size: 5 # CASE5-NEXT: Link: 0 # CASE5-NEXT: Info: 1 @@ -141,7 +141,7 @@ Sections: # CASE6-NEXT: SHF_ALLOC # CASE6-NEXT: ] # CASE6-NEXT: Address: 0x0 -# CASE6-NEXT: Offset: 0x180 +# CASE6-NEXT: Offset: 0x40 # CASE6-NEXT: Size: 4 # CASE6-NEXT: Link: 0 # CASE6-NEXT: Info: 1 @@ -175,7 +175,7 @@ Sections: # CASE7-NEXT: SHF_ALLOC # CASE7-NEXT: ] # CASE7-NEXT: Address: 0x0 -# CASE7-NEXT: Offset: 0x180 +# CASE7-NEXT: Offset: 0x40 # CASE7-NEXT: Size: 2 # CASE7-NEXT: Link: 0 # CASE7-NEXT: Info: 1 diff --git a/llvm/test/tools/yaml2obj/elf-custom-null-section.yaml b/llvm/test/tools/yaml2obj/elf-custom-null-section.yaml index dc74a7bfa95e..ea5f45605028 100644 --- a/llvm/test/tools/yaml2obj/elf-custom-null-section.yaml +++ b/llvm/test/tools/yaml2obj/elf-custom-null-section.yaml @@ -8,9 +8,9 @@ # DEFAULT: Section Headers: # DEFAULT-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # DEFAULT-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 -# DEFAULT-NEXT: [ 1] .symtab SYMTAB 0000000000000000 000140 000018 18 2 1 8 -# DEFAULT-NEXT: [ 2] .strtab STRTAB 0000000000000000 000158 000001 00 0 0 1 -# DEFAULT-NEXT: [ 3] .shstrtab STRTAB 0000000000000000 000159 00001b 00 0 0 1 +# DEFAULT-NEXT: [ 1] .symtab SYMTAB 0000000000000000 000040 000018 18 2 1 8 +# DEFAULT-NEXT: [ 2] .strtab STRTAB 0000000000000000 000058 000001 00 0 0 1 +# DEFAULT-NEXT: [ 3] .shstrtab STRTAB 0000000000000000 000059 00001b 00 0 0 1 --- !ELF FileHeader: @@ -104,10 +104,10 @@ Sections: # OTHER-SECTION: Section Headers: # OTHER-SECTION-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # OTHER-SECTION-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 -# OTHER-SECTION-NEXT: [ 1] foo PROGBITS 0000000000000000 000180 000000 00 0 0 0 -# OTHER-SECTION-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000180 000018 18 3 1 8 -# OTHER-SECTION-NEXT: [ 3] .strtab STRTAB 0000000000000000 000198 000001 00 0 0 1 -# OTHER-SECTION-NEXT: [ 4] .shstrtab STRTAB 0000000000000000 000199 00001f 00 0 0 1 +# OTHER-SECTION-NEXT: [ 1] foo PROGBITS 0000000000000000 000040 000000 00 0 0 0 +# OTHER-SECTION-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000040 000018 18 3 1 8 +# OTHER-SECTION-NEXT: [ 3] .strtab STRTAB 0000000000000000 000058 000001 00 0 0 1 +# OTHER-SECTION-NEXT: [ 4] .shstrtab STRTAB 0000000000000000 000059 00001f 00 0 0 1 --- !ELF FileHeader: @@ -164,7 +164,7 @@ Sections: # MULTIPLE: Section Headers: # MULTIPLE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # MULTIPLE-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 -# MULTIPLE-NEXT: [ 1] .foo NULL 0000000000000123 000180 000020 10 A 1 2 0 +# MULTIPLE-NEXT: [ 1] .foo NULL 0000000000000123 000040 000020 10 A 1 2 0 --- !ELF FileHeader: diff --git a/llvm/test/tools/yaml2obj/elf-header-sh-fields.yaml b/llvm/test/tools/yaml2obj/elf-header-sh-fields.yaml index 9bf64cddf1a1..b887c0a90ea3 100644 --- a/llvm/test/tools/yaml2obj/elf-header-sh-fields.yaml +++ b/llvm/test/tools/yaml2obj/elf-header-sh-fields.yaml @@ -6,7 +6,7 @@ # RUN: yaml2obj --docnum=1 %s -o %t1 # RUN: llvm-readelf --file-headers %t1 | FileCheck %s --check-prefix=DEFAULT -# DEFAULT: Start of section headers: 64 (bytes into file) +# DEFAULT: Start of section headers: 120 (bytes into file) # DEFAULT: Size of section headers: 64 (bytes) # DEFAULT: Number of section headers: 4 # DEFAULT: Section header string table index: 3 diff --git a/llvm/test/tools/yaml2obj/elf-override-shsize.yaml b/llvm/test/tools/yaml2obj/elf-override-shsize.yaml index 987369892bb9..de2bb774f7d1 100644 --- a/llvm/test/tools/yaml2obj/elf-override-shsize.yaml +++ b/llvm/test/tools/yaml2obj/elf-override-shsize.yaml @@ -7,17 +7,17 @@ # CASE1: Section Headers: # CASE1-NEXT: [Nr] Name Type Address Off Size # CASE1-NEXT: [ 0] NULL 0000000000000000 000000 000000 -# CASE1-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000380 000001 -# CASE1-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000398 000002 -# CASE1-NEXT: [ 3] .dynamic DYNAMIC 0000000000000000 0003b0 000003 -# CASE1-NEXT: [ 4] .rela RELA 0000000000000000 0003b0 000004 -# CASE1-NEXT: [ 5] .nobits NOBITS 0000000000000000 0003b0 000005 -# CASE1-NEXT: [ 6] .group GROUP 0000000000000000 0003b0 000006 -# CASE1-NEXT: [ 7] .gnu.version VERSYM 0000000000000000 0003b0 000007 -# CASE1-NEXT: [ 8] .gnu.version_r VERNEED 0000000000000000 0003b0 000008 -# CASE1-NEXT: [ 9] .gnu.version_d VERDEF 0000000000000000 0003b0 000009 -# CASE1-NEXT: [10] .regular PROGBITS 0000000000000000 0003b0 00000a -# CASE1-NEXT: [11] .strtab STRTAB 0000000000000000 0003b0 00000b +# 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: diff --git a/llvm/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml b/llvm/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml index 88b2a4da63b4..9624dd7ff5b0 100644 --- a/llvm/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml +++ b/llvm/test/tools/yaml2obj/explicit-dynsym-no-dynstr.yaml @@ -9,7 +9,7 @@ # CHECK: Section Headers: # CHECK-NEXT: [Nr] Name Type Address Off Size ES Flg Lk # CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 -# CHECK-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000180 000018 18 A 0 +# CHECK-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000018 18 A 0 --- !ELF FileHeader: diff --git a/llvm/test/tools/yaml2obj/implicit-sections.test b/llvm/test/tools/yaml2obj/implicit-sections.test index fef2f1ea4243..77e9e1c2f630 100644 --- a/llvm/test/tools/yaml2obj/implicit-sections.test +++ b/llvm/test/tools/yaml2obj/implicit-sections.test @@ -11,12 +11,12 @@ # CHECK: Section Headers: # CHECK-NEXT: [Nr] Name Type Address Off Size # CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 -# CHECK-NEXT: [ 1] .dynstr STRTAB 0000000000000100 000200 000009 -# CHECK-NEXT: [ 2] .dynsym DYNSYM 0000000000000150 000209 000030 -# CHECK-NEXT: [ 3] .symtab SYMTAB 0000000000000000 000239 000018 -# CHECK-NEXT: [ 4] .strtab STRTAB 0000000000000000 000251 000001 -# CHECK-NEXT: [ 5] .shstrtab STRTAB 0000000000000000 000252 000035 -# CHECK-NEXT: [ 6] .text.foo PROGBITS 0000000000000200 000287 000000 +# CHECK-NEXT: [ 1] .dynstr STRTAB 0000000000000100 000040 000009 +# CHECK-NEXT: [ 2] .dynsym DYNSYM 0000000000000150 000049 000030 +# CHECK-NEXT: [ 3] .symtab SYMTAB 0000000000000000 000079 000018 +# CHECK-NEXT: [ 4] .strtab STRTAB 0000000000000000 000091 000001 +# CHECK-NEXT: [ 5] .shstrtab STRTAB 0000000000000000 000092 000035 +# CHECK-NEXT: [ 6] .text.foo PROGBITS 0000000000000200 0000c7 000000 --- !ELF FileHeader: @@ -55,12 +55,12 @@ DynamicSymbols: # NODYNSYM: Section Headers: # NODYNSYM-NEXT: [Nr] Name Type Address Off Size # NODYNSYM-NEXT: [ 0] NULL 0000000000000000 000000 000000 -# NODYNSYM-NEXT: [ 1] .dynstr STRTAB 0000000000000100 000200 000001 -# NODYNSYM-NEXT: [ 2] .dynsym DYNSYM 0000000000000150 000201 000018 -# NODYNSYM-NEXT: [ 3] .symtab SYMTAB 0000000000000000 000219 000018 -# NODYNSYM-NEXT: [ 4] .strtab STRTAB 0000000000000000 000231 000001 -# NODYNSYM-NEXT: [ 5] .shstrtab STRTAB 0000000000000000 000232 000035 -# NODYNSYM-NEXT: [ 6] .text.foo PROGBITS 0000000000000200 000267 000000 +# NODYNSYM-NEXT: [ 1] .dynstr STRTAB 0000000000000100 000040 000001 +# NODYNSYM-NEXT: [ 2] .dynsym DYNSYM 0000000000000150 000041 000018 +# NODYNSYM-NEXT: [ 3] .symtab SYMTAB 0000000000000000 000059 000018 +# NODYNSYM-NEXT: [ 4] .strtab STRTAB 0000000000000000 000071 000001 +# NODYNSYM-NEXT: [ 5] .shstrtab STRTAB 0000000000000000 000072 000035 +# NODYNSYM-NEXT: [ 6] .text.foo PROGBITS 0000000000000200 0000a7 000000 --- !ELF FileHeader: diff --git a/llvm/test/tools/yaml2obj/program-header-align.yaml b/llvm/test/tools/yaml2obj/program-header-align.yaml index 88b5d2722e0f..7c307712e4c2 100644 --- a/llvm/test/tools/yaml2obj/program-header-align.yaml +++ b/llvm/test/tools/yaml2obj/program-header-align.yaml @@ -37,7 +37,7 @@ ProgramHeaders: #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { #CHECK-NEXT: Type: PT_LOAD -#CHECK-NEXT: Offset: 0x230 +#CHECK-NEXT: Offset: 0xB0 #CHECK-NEXT: VirtualAddress: 0xAAAA1030 #CHECK-NEXT: PhysicalAddress: 0xFFFF1030 #CHECK-NEXT: FileSize: 4 @@ -50,7 +50,7 @@ ProgramHeaders: #CHECK-NEXT: } #CHECK-NEXT: ProgramHeader { #CHECK-NEXT: Type: PT_LOAD -#CHECK-NEXT: Offset: 0x240 +#CHECK-NEXT: Offset: 0xC0 #CHECK-NEXT: VirtualAddress: 0xAAAA2040 #CHECK-NEXT: PhysicalAddress: 0xFFFF2040 #CHECK-NEXT: FileSize: 4 diff --git a/llvm/test/tools/yaml2obj/section-size-content.yaml b/llvm/test/tools/yaml2obj/section-size-content.yaml index 5b231a8362ab..bc7a1a05c59b 100644 --- a/llvm/test/tools/yaml2obj/section-size-content.yaml +++ b/llvm/test/tools/yaml2obj/section-size-content.yaml @@ -31,7 +31,7 @@ Sections: # CASE2-NEXT: Flags [ # CASE2-NEXT: ] # CASE2-NEXT: Address: 0x0 -# CASE2-NEXT: Offset: 0x180 +# CASE2-NEXT: Offset: 0x40 # CASE2-NEXT: Size: 1 # CASE2-NEXT: Link: 0 # CASE2-NEXT: Info: 0 @@ -79,7 +79,7 @@ Sections: # CASE3-NEXT: Flags [ # CASE3-NEXT: ] # CASE3-NEXT: Address: 0x0 -# CASE3-NEXT: Offset: 0x180 +# CASE3-NEXT: Offset: 0x40 # CASE3-NEXT: Size: 1 # CASE3-NEXT: Link: 0 # CASE3-NEXT: Info: 0 @@ -112,7 +112,7 @@ Sections: # CASE4-NEXT: Flags [ # CASE4-NEXT: ] # CASE4-NEXT: Address: 0x0 -# CASE4-NEXT: Offset: 0x180 +# CASE4-NEXT: Offset: 0x40 # CASE4-NEXT: Size: 3 # CASE4-NEXT: Link: 0 # CASE4-NEXT: Info: 0 @@ -144,7 +144,7 @@ Sections: # CASE5-NEXT: Flags [ # CASE5-NEXT: ] # CASE5-NEXT: Address: 0x0 -# CASE5-NEXT: Offset: 0x180 +# CASE5-NEXT: Offset: 0x40 # CASE5-NEXT: Size: 0 --- !ELF diff --git a/llvm/test/tools/yaml2obj/strtab-implicit-sections-size-content.yaml b/llvm/test/tools/yaml2obj/strtab-implicit-sections-size-content.yaml index a634997b42d8..a2be271d728e 100644 --- a/llvm/test/tools/yaml2obj/strtab-implicit-sections-size-content.yaml +++ b/llvm/test/tools/yaml2obj/strtab-implicit-sections-size-content.yaml @@ -34,7 +34,7 @@ Symbols: # CASE2-NEXT: Flags [ # CASE2-NEXT: ] # CASE2-NEXT: Address: 0x0 -# CASE2-NEXT: Offset: 0x140 +# CASE2-NEXT: Offset: 0x40 # CASE2-NEXT: Size: 2 # CASE2-NEXT: Link: 0 # CASE2-NEXT: Info: 0 @@ -69,7 +69,7 @@ Symbols: # CASE3-NEXT: Flags [ # CASE3-NEXT: ] # CASE3-NEXT: Address: 0x0 -# CASE3-NEXT: Offset: 0x140 +# CASE3-NEXT: Offset: 0x40 # CASE3-NEXT: Size: 2 # CASE3-NEXT: Link: 0 # CASE3-NEXT: Info: 0 @@ -105,7 +105,7 @@ Symbols: # CASE4-NEXT: Flags [ # CASE4-NEXT: ] # CASE4-NEXT: Address: 0x0 -# CASE4-NEXT: Offset: 0x140 +# CASE4-NEXT: Offset: 0x40 # CASE4-NEXT: Size: 3 # CASE4-NEXT: Link: 0 # CASE4-NEXT: Info: 0 @@ -141,7 +141,7 @@ Symbols: # CASE5-NEXT: Flags [ (0x0) # CASE5-NEXT: ] # CASE5-NEXT: Address: 0x0 -# CASE5-NEXT: Offset: 0x140 +# CASE5-NEXT: Offset: 0x40 # CASE5-NEXT: Size: 2 # CASE5-NEXT: Link: 0 # CASE5-NEXT: Info: 0 diff --git a/llvm/test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml b/llvm/test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml index 4981dbd61eff..c0c9b4ae8129 100644 --- a/llvm/test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml +++ b/llvm/test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml @@ -70,7 +70,7 @@ Symbols: # CASE4-NEXT: Flags [ (0x0) # CASE4-NEXT: ] # CASE4-NEXT: Address: 0x0 -# CASE4-NEXT: Offset: 0x140 +# CASE4-NEXT: Offset: 0x40 # CASE4-NEXT: Size: 2 # CASE4-NEXT: Link: 2 # CASE4-NEXT: Info: 1 @@ -101,7 +101,7 @@ Sections: # CASE5-NEXT: Flags [ (0x0) # CASE5-NEXT: ] # CASE5-NEXT: Address: 0x0 -# CASE5-NEXT: Offset: 0x140 +# CASE5-NEXT: Offset: 0x40 # CASE5-NEXT: Size: 5 # CASE5-NEXT: Link: 2 # CASE5-NEXT: Info: 1 @@ -134,7 +134,7 @@ Sections: # CASE6-NEXT: Flags [ # CASE6-NEXT: ] # CASE6-NEXT: Address: 0x0 -# CASE6-NEXT: Offset: 0x140 +# CASE6-NEXT: Offset: 0x40 # CASE6-NEXT: Size: 4 # CASE6-NEXT: Link: 2 # CASE6-NEXT: Info: 1 @@ -167,7 +167,7 @@ Sections: # CASE7-NEXT: Flags [ # CASE7-NEXT: ] # CASE7-NEXT: Address: 0x0 -# CASE7-NEXT: Offset: 0x140 +# CASE7-NEXT: Offset: 0x40 # CASE7-NEXT: Size: 2 # CASE7-NEXT: Link: 2 # CASE7-NEXT: Info: 1 diff --git a/llvm/test/tools/yaml2obj/versym-section.yaml b/llvm/test/tools/yaml2obj/versym-section.yaml index 6e0cecba19e2..bd4f61093e91 100644 --- a/llvm/test/tools/yaml2obj/versym-section.yaml +++ b/llvm/test/tools/yaml2obj/versym-section.yaml @@ -7,7 +7,7 @@ # CHECK: Version symbols { # CHECK-NEXT: Section Name: .gnu.version # CHECK-NEXT: Address: 0x200210 -# CHECK-NEXT: Offset: 0x240 +# CHECK-NEXT: Offset: 0x40 # CHECK-NEXT: Link: 6 # CHECK-NEXT: Symbols [ # CHECK-NEXT: Symbol { @@ -97,7 +97,7 @@ DynamicSymbols: # ENTSIZE: Section Headers: # ENTSIZE: [Nr] Name Type Address Off Size ES -# ENTSIZE: [ 1] .gnu.version VERSYM 0000000000000000 000180 000000 03 +# ENTSIZE: [ 1] .gnu.version VERSYM 0000000000000000 000040 000000 03 --- !ELF FileHeader: