Index: llvm/include/llvm/ObjectYAML/ELFYAML.h =================================================================== --- llvm/include/llvm/ObjectYAML/ELFYAML.h +++ llvm/include/llvm/ObjectYAML/ELFYAML.h @@ -100,10 +100,6 @@ Optional NoHeaders; }; -struct SectionName { - StringRef Section; -}; - struct Symbol { StringRef Name; ELF_STT Type; @@ -602,9 +598,10 @@ Optional FileSize; Optional MemSize; Optional Offset; + Optional FirstSec; + Optional LastSec; - std::vector Sections; - // This vector is parallel to Sections and contains corresponding chunks. + // This vector contains all chunks from [FirstSec, LastSec]. std::vector Chunks; }; @@ -653,7 +650,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VerneedEntry) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Relocation) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionOrType) -LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionName) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::ARMIndexTableEntry) namespace llvm { @@ -789,6 +785,7 @@ template <> struct MappingTraits { static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr); + static std::string validate(IO &IO, ELFYAML::ProgramHeader &FileHdr); }; template <> @@ -855,10 +852,6 @@ static void mapping(IO &IO, ELFYAML::SectionOrType §ionOrType); }; -template <> struct MappingTraits { - static void mapping(IO &IO, ELFYAML::SectionName §ionName); -}; - } // end namespace yaml } // end namespace llvm Index: llvm/lib/ObjectYAML/ELFEmitter.cpp =================================================================== --- llvm/lib/ObjectYAML/ELFEmitter.cpp +++ llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -464,12 +464,16 @@ template void ELFState::initProgramHeaders(std::vector &PHeaders) { DenseMap NameToFill; - for (const std::unique_ptr &D : Doc.Chunks) - if (auto S = dyn_cast(D.get())) + DenseMap NameToIndex; + for (size_t I = 0, E = Doc.Chunks.size(); I != E; ++I) { + if (auto S = dyn_cast(Doc.Chunks[I].get())) NameToFill[S->Name] = S; + NameToIndex[Doc.Chunks[I]->Name] = I + 1; + } std::vector Sections = Doc.getSections(); - for (ELFYAML::ProgramHeader &YamlPhdr : Doc.ProgramHeaders) { + for (size_t I = 0, E = Doc.ProgramHeaders.size(); I != E; ++I) { + ELFYAML::ProgramHeader &YamlPhdr = Doc.ProgramHeaders[I]; Elf_Phdr Phdr; zero(Phdr); Phdr.p_type = YamlPhdr.Type; @@ -478,22 +482,30 @@ Phdr.p_paddr = YamlPhdr.PAddr; PHeaders.push_back(Phdr); - // Map Sections list to corresponding chunks. - for (const ELFYAML::SectionName &SecName : YamlPhdr.Sections) { - if (ELFYAML::Fill *Fill = NameToFill.lookup(SecName.Section)) { - YamlPhdr.Chunks.push_back(Fill); - continue; - } + if (!YamlPhdr.FirstSec && !YamlPhdr.LastSec) + continue; - unsigned Index; - if (SN2I.lookup(SecName.Section, Index)) { - YamlPhdr.Chunks.push_back(Sections[Index]); - continue; - } + // Get the index of the section, or 0 in the case when the section doesn't exist. + size_t First = NameToIndex[*YamlPhdr.FirstSec]; + if (!First) + reportError("unknown section or fill referenced: '" + *YamlPhdr.FirstSec + + "' by the 'FirstSec' key of the program header with index " + + Twine(I)); + size_t Last = NameToIndex[*YamlPhdr.LastSec]; + if (!Last) + reportError("unknown section or fill referenced: '" + *YamlPhdr.LastSec + + "' by the 'LastSec' key of the program header with index " + + Twine(I)); + if (!First || !Last) + continue; - reportError("unknown section or fill referenced: '" + SecName.Section + - "' by program header"); - } + if (First > Last) + reportError("program header with index " + Twine(I) + + ": the section index of " + *YamlPhdr.FirstSec + + " is greater than the index of " + *YamlPhdr.LastSec); + + for (size_t I = First; I <= Last; ++I) + YamlPhdr.Chunks.push_back(Doc.Chunks[I - 1].get()); } } Index: llvm/lib/ObjectYAML/ELFYAML.cpp =================================================================== --- llvm/lib/ObjectYAML/ELFYAML.cpp +++ llvm/lib/ObjectYAML/ELFYAML.cpp @@ -903,7 +903,8 @@ IO &IO, ELFYAML::ProgramHeader &Phdr) { IO.mapRequired("Type", Phdr.Type); IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0)); - IO.mapOptional("Sections", Phdr.Sections); + IO.mapOptional("FirstSec", Phdr.FirstSec); + IO.mapOptional("LastSec", Phdr.LastSec); IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0)); IO.mapOptional("PAddr", Phdr.PAddr, Phdr.VAddr); IO.mapOptional("Align", Phdr.Align); @@ -912,6 +913,15 @@ IO.mapOptional("Offset", Phdr.Offset); } +std::string MappingTraits::validate( + IO &IO, ELFYAML::ProgramHeader &FileHdr) { + if (!FileHdr.FirstSec && FileHdr.LastSec) + return "the \"LastSec\" key can't be used without the \"FirstSec\" key"; + if (FileHdr.FirstSec && !FileHdr.LastSec) + return "the \"FirstSec\" key can't be used without the \"LastSec\" key"; + return ""; +} + LLVM_YAML_STRONG_TYPEDEF(StringRef, StOtherPiece) template <> struct ScalarTraits { @@ -1253,11 +1263,6 @@ IO.mapRequired("SectionOrType", sectionOrType.sectionNameOrType); } -void MappingTraits::mapping( - IO &IO, ELFYAML::SectionName §ionName) { - IO.mapRequired("Section", sectionName.Section); -} - static void sectionMapping(IO &IO, ELFYAML::ARMIndexTableSection &Section) { commonSectionMapping(IO, Section); IO.mapOptional("Entries", Section.Entries); Index: llvm/test/DebugInfo/symbolize-build-id-error.test =================================================================== --- llvm/test/DebugInfo/symbolize-build-id-error.test +++ llvm/test/DebugInfo/symbolize-build-id-error.test @@ -17,7 +17,7 @@ Flags: [ SHF_ALLOC ] Content: 0123456789 ProgramHeaders: - - Type: PT_NOTE - Flags: [ PF_R ] - Sections: - - Section: .note.invalid + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.invalid + LastSec: .note.invalid Index: llvm/test/DebugInfo/symbolize-build-id.test =================================================================== --- llvm/test/DebugInfo/symbolize-build-id.test +++ llvm/test/DebugInfo/symbolize-build-id.test @@ -22,7 +22,7 @@ Flags: [ SHF_ALLOC ] Content: 040000000800000003000000474e5500abb50d82b6bdc861 ProgramHeaders: - - Type: PT_NOTE - Flags: [ PF_R ] - Sections: - - Section: .note.gnu.build-id + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id Index: llvm/test/Object/invalid.test =================================================================== --- llvm/test/Object/invalid.test +++ llvm/test/Object/invalid.test @@ -450,10 +450,10 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic ## Check that llvm-readobj reports a warning when a dynamic relocation section ## has sh_entsize field with size != sizeof(Elf_Rela). @@ -525,8 +525,8 @@ ProgramHeaders: - Type: PT_DYNAMIC FileSize: 0xffff0000 - Sections: - - Section: .dynamic + FirstSec: .dynamic + LastSec: .dynamic # RUN: yaml2obj --docnum=24 %s -o %t24 # RUN: not obj2yaml 2>&1 %t24 | FileCheck %s -DFILE=%t24 --check-prefix=INVALID-SHSTRNDX Index: llvm/test/Object/obj2yaml.test =================================================================== --- llvm/test/Object/obj2yaml.test +++ llvm/test/Object/obj2yaml.test @@ -660,17 +660,17 @@ # ELF-AVR-NEXT: Machine: EM_AVR # ELF-AVR-NEXT: Flags: [ EF_AVR_ARCH_AVR2 ] # ELF-AVR-NEXT: ProgramHeaders: -# ELF-AVR-NEXT: - Type: PT_LOAD -# ELF-AVR-NEXT: Flags: [ PF_X, PF_R ] -# ELF-AVR-NEXT: Sections: -# ELF-AVR-NEXT: - Section: .text -# ELF-AVR-NEXT: Align: 0x0000000000000002 -# ELF-AVR-NEXT: - Type: PT_LOAD -# ELF-AVR-NEXT: Flags: [ PF_W, PF_R ] -# ELF-AVR-NEXT: Sections: -# ELF-AVR-NEXT: - Section: .data -# ELF-AVR-NEXT: VAddr: 0x0000000000800060 -# ELF-AVR-NEXT: PAddr: 0x0000000000000004 +# ELF-AVR-NEXT: - Type: PT_LOAD +# ELF-AVR-NEXT: Flags: [ PF_X, PF_R ] +# ELF-AVR-NEXT: FirstSec: .text +# ELF-AVR-NEXT: LastSec: .text +# ELF-AVR-NEXT: Align: 0x0000000000000002 +# ELF-AVR-NEXT: - Type: PT_LOAD +# ELF-AVR-NEXT: Flags: [ PF_W, PF_R ] +# ELF-AVR-NEXT: FirstSec: .data +# ELF-AVR-NEXT: LastSec: .data +# ELF-AVR-NEXT: VAddr: 0x0000000000800060 +# ELF-AVR-NEXT: PAddr: 0x0000000000000004 # ELF-AVR-NEXT: Sections: # ELF-AVR-NEXT: - Name: .text # ELF-AVR-NEXT: Type: SHT_PROGBITS Index: llvm/test/tools/llvm-elfabi/binary-read-add-soname.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-add-soname.test +++ llvm/test/tools/llvm-elfabi/binary-read-add-soname.test @@ -30,18 +30,17 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x0000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - Sections: - - Section: .dynamic + FirstSec: .dynamic + LastSec: .dynamic # CHECK: --- !tapi-tbe # CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} Index: llvm/test/tools/llvm-elfabi/binary-read-arch.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-arch.test +++ llvm/test/tools/llvm-elfabi/binary-read-arch.test @@ -30,18 +30,17 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x0000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x0008 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: --- !tapi-tbe # CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} Index: llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test +++ llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test @@ -32,17 +32,16 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x0000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x0008 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: DT_SONAME string offset (0x000000000000000d) outside of dynamic string table Index: llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test +++ llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test @@ -32,17 +32,16 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x1008 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1008 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: virtual address is not in any segment: 0x260 when locating .dynstr section contents Index: llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test +++ llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test @@ -36,16 +36,14 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1024 - Sections: # CHECK: DT_NEEDED string offset (0x000000000000ffff) outside of dynamic string table Index: llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test +++ llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test @@ -35,17 +35,15 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1024 - Sections: # CHECK: NeededLibs: # CHECK-NEXT: - libfoo.so{{$}} Index: llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test +++ llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test @@ -27,17 +27,16 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x0000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x0008 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: Couldn't determine dynamic string table size (no DT_STRSZ entry) Index: llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test +++ llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test @@ -26,17 +26,16 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x0000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x0008 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: Couldn't locate dynamic string table (no DT_STRTAB entry) Index: llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test +++ llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test @@ -34,18 +34,17 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x1018 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1018 + FirstSec: .dynamic + LastSec: .dynamic # ORIGINAL: SoName: somelib.so{{$}} Index: llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test +++ llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test @@ -33,17 +33,16 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x1018 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1018 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: String overran bounds of string table (no null terminator) when reading DT_SONAME Index: llvm/test/tools/llvm-elfabi/binary-read-soname.test =================================================================== --- llvm/test/tools/llvm-elfabi/binary-read-soname.test +++ llvm/test/tools/llvm-elfabi/binary-read-soname.test @@ -33,18 +33,17 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Align: 8 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x1018 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 8 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1018 + FirstSec: .dynamic + LastSec: .dynamic # CHECK: --- !tapi-tbe # CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} Index: llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml =================================================================== --- llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml +++ llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml @@ -389,26 +389,8 @@ Flags: [ PF_X, PF_R ] VAddr: 0x0000000000400000 Align: 1024 - Sections: - - Section: .interp - - Section: .interp - - Section: .note.ABI-tag - - Section: .note.gnu.build-id - - Section: .gnu.hash - - Section: .gnu.version - - Section: .gnu.version_r - - Section: .rela.dyn - - Section: .rela.plt - - Section: .init - - Section: .plt - - Section: .plt.got - - Section: .text - - Section: .fini - - Section: .rodata - - Section: .eh_frame_hdr - - Section: .eh_frame - - Section: .dynsym - - Section: .dynstr + FirstSec: .interp + LastSec: .dynstr Symbols: - Name: .interp Type: STT_SECTION Index: llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-pt-null.yaml =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-pt-null.yaml +++ llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-pt-null.yaml @@ -12,9 +12,9 @@ AddressAlign: 0x8 Content: "0001020304" ProgramHeaders: - - Type: PT_NULL - Flags: [ PF_X, PF_R ] - VAddr: 0xF00000000 - PAddr: 0x100000 - Sections: - - Section: .text + - Type: PT_NULL + Flags: [ PF_X, PF_R ] + VAddr: 0xF00000000 + PAddr: 0x100000 + FirstSec: .text + LastSec: .text Index: llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-segments.yaml =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-segments.yaml +++ llvm/test/tools/llvm-objcopy/ELF/Inputs/ihex-elf-segments.yaml @@ -48,13 +48,9 @@ Size: 65536 AddressAlign: 0x8 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0xF00000000 - PAddr: 0x100000 - Sections: - - Section: .text - - Section: .data1 - - Section: .data2 - - Section: .data3 - - Section: .bss + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xF00000000 + PAddr: 0x100000 + FirstSec: .text + LastSec: .bss Index: llvm/test/tools/llvm-objcopy/ELF/add-symbol.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/add-symbol.test +++ llvm/test/tools/llvm-objcopy/ELF/add-symbol.test @@ -44,18 +44,18 @@ AddressAlign: 0x0000000000001000 Size: 64 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x1000 - Align: 0x1000 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x2000 - Align: 0x1000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + Align: 0x1000 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x2000 + Align: 0x1000 + FirstSec: .data + LastSec: .data ## TODO (grimar): llvm-objcopy seems produce a broken output without ## the following line, i.e. when there is no symbol table in the input. Symbols: [] Index: llvm/test/tools/llvm-objcopy/ELF/adjacent-segments.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/adjacent-segments.test +++ llvm/test/tools/llvm-objcopy/ELF/adjacent-segments.test @@ -23,14 +23,14 @@ AddressAlign: 0x10 Size: 16 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text2 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text2 + LastSec: .text2 #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/bad-build-id.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/bad-build-id.test +++ llvm/test/tools/llvm-objcopy/ELF/bad-build-id.test @@ -15,7 +15,7 @@ Flags: [ SHF_ALLOC ] Content: 040000000100000003000000474E55004F000000 ProgramHeaders: - - Type: PT_NOTE - Flags: [ PF_R ] - Sections: - - Section: .note.gnu.build-id + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id Index: llvm/test/tools/llvm-objcopy/ELF/basic-binary-copy.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/basic-binary-copy.test +++ llvm/test/tools/llvm-objcopy/ELF/basic-binary-copy.test @@ -16,10 +16,10 @@ AddressAlign: 0x0000000000001000 Content: "c3c3c3c3" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text # CHECK: 0000000 c3c3 c3c3 # SIZE: 4 Index: llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test @@ -23,11 +23,10 @@ Size: 4064 Content: "DEADBEEF" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .note - - Section: .rodata + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .note + LastSec: .rodata # CHECK: 000000 de ad be ef Index: llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test @@ -32,18 +32,18 @@ AddressAlign: 0x0000000000000004 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x1000 - PAddr: [[PADDR]] - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x1004 - PAddr: [[PADDR]] - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + PAddr: [[PADDR]] + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x1004 + PAddr: [[PADDR]] + FirstSec: .data + LastSec: .data # CHECK: 0000000 3232 c3c3 # SIZE: 4 Index: llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test @@ -35,11 +35,10 @@ AddressAlign: 0x1000 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - Sections: - - Section: .text - - Section: .data + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + FirstSec: .text + LastSec: .data ## The computed LMA of a section not in a PT_LOAD equals its sh_addr. @@ -78,13 +77,13 @@ AddressAlign: 0x1000 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x2000 + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x2000 ## p_vaddr is increased from 0x2000 to 0x4000. - PAddr: 0x4000 - Sections: - - Section: .data + PAddr: 0x4000 + FirstSec: .data + LastSec: .data ## Check that we use sh_offset instead of sh_addr to decide where to write section contents. @@ -124,11 +123,11 @@ AddressAlign: 0x1000 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x3000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x3000 + FirstSec: .data + LastSec: .data ## The first section (.text) is empty. Test that we skip its LMA until the first ## non-empty section, otherwise we would leave a large number of leading zeroes. Index: llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test @@ -32,13 +32,11 @@ Content: "32323232" Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text3 # CHECK: 000000 de ad be ef Index: llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test @@ -32,13 +32,11 @@ Content: "32323232" Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text3 # CHECK: 000000 c3 c3 c3 c3 # CHECK: 001000 de ad be ef Index: llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test @@ -32,13 +32,11 @@ Content: "32323232" Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text3 # CHECK: 000000 c3 c3 c3 c3 # CHECK: 001000 00 00 00 00 Index: llvm/test/tools/llvm-objcopy/ELF/binary-segment-layout.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-segment-layout.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-segment-layout.test @@ -23,16 +23,16 @@ Address: 0x08 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x00 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x08 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x00 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x08 + FirstSec: .data + LastSec: .data # CHECK: 0000000 c3c3 c3c3 0000 0000 3232 # SIZE: 10 Index: llvm/test/tools/llvm-objcopy/ELF/build-id-link-dir.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/build-id-link-dir.test +++ llvm/test/tools/llvm-objcopy/ELF/build-id-link-dir.test @@ -50,7 +50,7 @@ Flags: [ SHF_ALLOC ] Content: 040000001000000003000000474E55004FCB712AA6387724A9F465A32CD8C14B ProgramHeaders: - - Type: PT_NOTE - Flags: [ PF_R ] - Sections: - - Section: .note.gnu.build-id + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id Index: llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test +++ llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test @@ -22,17 +22,17 @@ AddressAlign: 0x0000000000000008 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x1000 - Align: 0x1000 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x1008 - Align: 0x1000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + Align: 0x1000 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x1008 + Align: 0x1000 + FirstSec: .data + LastSec: .data # CHECK: 0000000 c3 c3 c3 c3 00 00 00 00 32 32 Index: llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test +++ llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test @@ -22,18 +22,18 @@ AddressAlign: 0x0000000000000008 Content: "3232" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x1000 - Align: 0x1000 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x1008 - Align: 0x1000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + Align: 0x1000 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x1008 + Align: 0x1000 + FirstSec: .data + LastSec: .data #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/copy-after-strip-sections.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/copy-after-strip-sections.test +++ llvm/test/tools/llvm-objcopy/ELF/copy-after-strip-sections.test @@ -21,6 +21,6 @@ Type: SHT_PROGBITS Content: 'facefeed' ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .text + - Type: PT_LOAD + FirstSec: .text + LastSec: .text Index: llvm/test/tools/llvm-objcopy/ELF/dump-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/dump-section.test +++ llvm/test/tools/llvm-objcopy/ELF/dump-section.test @@ -35,10 +35,10 @@ Type: SHT_NOBITS Flags: [ SHF_WRITE ] ProgramHeaders: -- Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text # CHECK: 0000000 de ad be ef Index: llvm/test/tools/llvm-objcopy/ELF/empty-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/empty-section.test +++ llvm/test/tools/llvm-objcopy/ELF/empty-section.test @@ -79,14 +79,13 @@ Address: 0x1000 Size: 0x100 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0 - Align: 0x100 - Sections: - - Section: .foo - - Type: PT_LOAD - VAddr: 0x1000 - Align: 0x1000 - Sections: - - Section: .empty - - Section: .baz + - Type: PT_LOAD + VAddr: 0 + Align: 0x100 + FirstSec: .foo + LastSec: .foo + - Type: PT_LOAD + VAddr: 0x1000 + Align: 0x1000 + FirstSec: .empty + LastSec: .baz Index: llvm/test/tools/llvm-objcopy/ELF/identical-segments.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/identical-segments.test +++ llvm/test/tools/llvm-objcopy/ELF/identical-segments.test @@ -24,20 +24,18 @@ AddressAlign: 0x1000 Size: 4096 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text2 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Section: .text2 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Section: .text2 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text2 + LastSec: .text2 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text2 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text2 #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/invalid-p_filesz-p_offset.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/invalid-p_filesz-p_offset.test +++ llvm/test/tools/llvm-objcopy/ELF/invalid-p_filesz-p_offset.test @@ -16,10 +16,10 @@ - Name: .foo Type: SHT_PROGBITS ProgramHeaders: - - Type: PT_LOAD - FileSize: 0x100000 - Sections: - - Section: .foo + - Type: PT_LOAD + FileSize: 0x100000 + FirstSec: .foo + LastSec: .foo ## A similar case, but now the p_offset property of the program header is too large. Index: llvm/test/tools/llvm-objcopy/ELF/marker-segment.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/marker-segment.test +++ llvm/test/tools/llvm-objcopy/ELF/marker-segment.test @@ -29,28 +29,27 @@ Flags: [ SHF_ALLOC ] Size: 64 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x1000 - Align: 0x1000 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_R, PF_W ] - VAddr: 0x2000 - Align: 0x1000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + Align: 0x1000 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x2000 + Align: 0x1000 + FirstSec: .data + LastSec: .data - Type: PT_GNU_STACK Flags: [ PF_R, PF_W ] VAddr: 0x0000 Align: 0x0000 - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x2010 - Sections: - - Section: .xdata - - Section: .after + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x2010 + FirstSec: .xdata + LastSec: .after #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/no-build-id.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/no-build-id.test +++ llvm/test/tools/llvm-objcopy/ELF/no-build-id.test @@ -15,7 +15,7 @@ Flags: [ SHF_ALLOC ] Content: 000000000000000000000000 ProgramHeaders: - - Type: PT_NOTE - Flags: [ PF_R ] - Sections: - - Section: .note.foo + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.foo + LastSec: .note.foo Index: llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test +++ llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test @@ -97,28 +97,23 @@ Flags: [ PF_R, PF_X ] Offset: 0 Align: 0x1000 - Sections: - - Section: .note1 - - Section: .note2 - - Section: .text + FirstSec: .note1 + LastSec: .text - Type: PT_LOAD Flags: [ PF_R, PF_W ] VAddr: 0x1480 # Ensure Offset=VAddr (mod Align) if Offset changes Align: 0x1000 - Sections: - - Section: .tdata - - Section: .bss + FirstSec: .tdata + LastSec: .bss - Type: PT_TLS Flags: [ PF_R, PF_W ] VAddr: 0x1480 # Ensure Offset=VAddr (mod Align) if Offset changes - Sections: - - Section: .tdata - - Section: .tbss + FirstSec: .tdata + LastSec: .tbss - Type: PT_NOTE VAddr: 0x400 - Sections: - - Section: .note1 - - Section: .note2 + FirstSec: .note1 + LastSec: .note2 ... # RUN: yaml2obj --docnum=2 %s -o %t2 @@ -175,9 +170,8 @@ Flags: [ PF_R, PF_X ] Offset: 0 Align: 4096 - Sections: - - Section: .text - - Section: .note + FirstSec: .text + LastSec: .note - Type: PT_LOAD Flags: [ PF_R, PF_W ] Offset: 0x202 Index: llvm/test/tools/llvm-objcopy/ELF/overlap-chain.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/overlap-chain.test +++ llvm/test/tools/llvm-objcopy/ELF/overlap-chain.test @@ -40,26 +40,22 @@ AddressAlign: 0x1000 Size: 4096 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Section: .text2 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text4 - - Section: .text5 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text3 - - Section: .text4 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text2 - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text2 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text4 + LastSec: .text5 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text3 + LastSec: .text4 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text2 + LastSec: .text3 #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test +++ llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test @@ -33,16 +33,15 @@ Size: 4064 Content: "DEADBEEF" ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .note - - Section: .rodata - - Type: PT_NOTE - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .note + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .note + LastSec: .rodata + - Type: PT_NOTE + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .note + LastSec: .note # CHECK: 000000 de ad be ef Index: llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents-ehdr-phdrs.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents-ehdr-phdrs.test +++ llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents-ehdr-phdrs.test @@ -37,6 +37,6 @@ Offset: 0 FileSize: 176 # sizeof(Elf64_Ehdr) + 2 * sizeof(Elf64_Phdr) - Type: PT_LOAD - Sections: - - Section: .keep_me + FirstSec: .keep_me + LastSec: .keep_me Symbols: [] Index: llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test +++ llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test @@ -311,188 +311,153 @@ Address: 0x5038 ProgramHeaders: # First segment has unlabelled space at start and end. - - Type: 0x6ABCDEF0 # Non-specific segment type. - VAddr: 0x2000 - Align: 0x2000 - Sections: - - Section: blob1 - - Section: section1 - - Section: blob2 - - Section: section2 # nobits - - Section: blob3 - - Section: section3 - - Section: blob4 + - Type: 0x6ABCDEF0 # Non-specific segment type. + VAddr: 0x2000 + Align: 0x2000 + FirstSec: blob1 + LastSec: blob4 # Second segment has sections at start and end. - - Type: 0x6ABCDEF0 - VAddr: 0x2100 - Align: 0x100 - Sections: - - Section: section4 - - Section: blob5 - - Section: section5 + - Type: 0x6ABCDEF0 + VAddr: 0x2100 + Align: 0x100 + FirstSec: section4 + LastSec: section5 # Third segment is all covered by a section. - - Type: 0x6ABCDEF0 - VAddr: 0x2200 - Align: 0x100 - Sections: - - Section: section6 + - Type: 0x6ABCDEF0 + VAddr: 0x2200 + Align: 0x100 + FirstSec: section6 + LastSec: section6 # Fourth segment has no sections (after removing blob headers). - - Type: 0x6ABCDEF0 - VAddr: 0x2300 - Align: 0x100 - Sections: - - Section: blob6 + - Type: 0x6ABCDEF0 + VAddr: 0x2300 + Align: 0x100 + FirstSec: blob6 + LastSec: blob6 # Fifth segment is empty. - Type: 0x6ABCDEF0 VAddr: 0x2308 Offset: 0x2308 - # The next few segments test behaviour of fully nested segments. # Sixth segment is the "parent" segment. - - Type: 0x6ABCDEF0 - VAddr: 0x3000 - Align: 0x1000 - Sections: - - Section: sectionA - - Section: sectionB - - Section: blobA - - Section: sectionC - - Section: blobB - - Section: sectionD - - Section: blobC - - Section: sectionE - - Section: blobD - - Section: sectionF - - Section: blobE - - Section: blobF - - Section: sectionG - - Section: blobG - - Section: sectionH - - Section: blobH - - Section: sectionI + - Type: 0x6ABCDEF0 + VAddr: 0x3000 + Align: 0x1000 + FirstSec: sectionA + LastSec: sectionI # Seventh segment is empty and nested. - Type: 0x6ABCDEF0 VAddr: 0x3002 Offset: 0x3002 # Eighth segment contains only a section and is nested. - - Type: 0x6ABCDEF0 - VAddr: 0x3004 - Sections: - - Section: sectionB + - Type: 0x6ABCDEF0 + VAddr: 0x3004 + FirstSec: sectionB + LastSec: sectionB # Ninth segment contains only unlabelled space and is nested. - - Type: 0x6ABCDEF0 - VAddr: 0x3008 - Sections: - - Section: blobA + - Type: 0x6ABCDEF0 + VAddr: 0x3008 + FirstSec: blobA + LastSec: blobA # Tenth segment contains two sections with space between and is nested. - - Type: 0x6ABCDEF0 - VAddr: 0x300C - Sections: - - Section: sectionC - - Section: blobB - - Section: sectionD + - Type: 0x6ABCDEF0 + VAddr: 0x300C + FirstSec: sectionC + LastSec: sectionD # Eleventh segment contains two sections with space between and at ends and is nested. - - Type: 0x6ABCDEF0 - VAddr: 0x3018 - Sections: - - Section: blobC - - Section: sectionE - - Section: blobD - - Section: sectionF - - Section: blobE + - Type: 0x6ABCDEF0 + VAddr: 0x3018 + FirstSec: blobC + LastSec: blobE # Twelfth segment contains one section with space at ends adjacent to space in parent segment. - Type: 0x6ABCDEF0 VAddr: 0x302E Offset: 0x302E FileSize: 8 - Sections: - - Section: sectionG + FirstSec: sectionG + LastSec: sectionG # Thirteenth segment contains overlaps sections at either end in parent segment. - Type: 0x6ABCDEF0 VAddr: 0x303A Offset: 0x303A FileSize: 0x8 - Sections: - - Section: blobH + FirstSec: blobH + LastSec: blobH # The next batch of segments are segments that only partially overlap other segments. # Segment14: |-unlabelled-|-Sec-| # Segment15: |--|-Sec-|-unlabelled-| - - Type: 0x6ABCDEF0 - VAddr: 0x4000 - Sections: - - Section: blobz - - Section: sectionz - - Type: 0x6ABCDEF0 - VAddr: 0x4002 - Offset: 0x4002 - Sections: - - Section: sectionz - - Section: bloby + - Type: 0x6ABCDEF0 + VAddr: 0x4000 + FirstSec: blobz + LastSec: sectionz + - Type: 0x6ABCDEF0 + VAddr: 0x4002 + Offset: 0x4002 + FirstSec: sectionz + LastSec: bloby # Segment16: |-Sec-|--| # Segment17: |--|----unlabelled---| - - Type: 0x6ABCDEF0 - VAddr: 0x400C + - Type: 0x6ABCDEF0 + VAddr: 0x400C FileSize: 6 - Sections: - - Section: sectiony - - Type: 0x6ABCDEF0 - VAddr: 0x400E - Offset: 0x400E - Sections: - - Section: blobx + FirstSec: sectiony + LastSec: sectiony + - Type: 0x6ABCDEF0 + VAddr: 0x400E + Offset: 0x400E + FirstSec: blobx + LastSec: blobx # Segment18: |-unlabelled-|-Sec-| # Segment19: |-Sec-|-unlabelled-| - - Type: 0x6ABCDEF0 - VAddr: 0x4014 - Sections: - - Section: blobw - - Section: sectionx - - Type: 0x6ABCDEF0 - VAddr: 0x4018 - Sections: - - Section: sectionx - - Section: blobv + - Type: 0x6ABCDEF0 + VAddr: 0x4014 + FirstSec: blobw + LastSec: sectionx + - Type: 0x6ABCDEF0 + VAddr: 0x4018 + FirstSec: sectionx + LastSec: blobv # Segment20: |-Sec-| # Segment21: |--|-unlabelled-|-Sec-| - - Type: 0x6ABCDEF0 - VAddr: 0x4020 - Sections: - - Section: sectionw + - Type: 0x6ABCDEF0 + VAddr: 0x4020 + FirstSec: sectionw + LastSec: sectionw + - Type: 0x6ABCDEF0 VAddr: 0x4022 Offset: 0x4022 - Sections: - - Section: blobu - - Section: sectionv + FirstSec: blobu + LastSec: sectionv # Segment22: |-Sec-| # Segment23: |--|-Sec-| - - Type: 0x6ABCDEF0 - VAddr: 0x402C - Sections: - - Section: sectionu - - Type: 0x6ABCDEF0 - VAddr: 0x402E - Offset: 0x402E - Sections: - - Section: sectiont + - Type: 0x6ABCDEF0 + VAddr: 0x402C + FirstSec: sectionu + LastSec: sectionu + - Type: 0x6ABCDEF0 + VAddr: 0x402E + Offset: 0x402E + FirstSec: sectiont + LastSec: sectiont # Segment24: |-unlabelled-|--| # Segment25: |--Sec--| - - Type: 0x6ABCDEF0 - VAddr: 0x4034 + - Type: 0x6ABCDEF0 + VAddr: 0x4034 FileSize: 6 - Sections: - - Section: blobt - - Type: 0x6ABCDEF0 - VAddr: 0x4038 - Sections: - - Section: sections + FirstSec: blobt + LastSec: blobt + - Type: 0x6ABCDEF0 + VAddr: 0x4038 + FirstSec: sections + LastSec: sections # The next batch of segments represent groups of three nested/overlapping segments, # with one parent segment containing two overlapping segments. @@ -500,100 +465,85 @@ # Segment26: |-unlabelled-|-Sec-|-unlabelled-| # Segment27: |------------|--| # Segment28: |-Sec-|------------| - - Type: 0x6ABCDEF0 - VAddr: 0x5000 - Align: 0x1000 - Sections: - - Section: bloba - - Section: sectiona - - Section: blobb - - Type: 0x6ABCDEF0 - VAddr: 0x5000 + - Type: 0x6ABCDEF0 + VAddr: 0x5000 + Align: 0x1000 + FirstSec: bloba + LastSec: blobb + - Type: 0x6ABCDEF0 + VAddr: 0x5000 FileSize: 6 - Sections: - - Section: bloba - - Type: 0x6ABCDEF0 - VAddr: 0x5004 - Sections: - - Section: sectiona - - Section: blobb + FirstSec: bloba + LastSec: bloba + - Type: 0x6ABCDEF0 + VAddr: 0x5004 + FirstSec: sectiona + LastSec: blobb # Segment29: |-Sec-|-unlabelled-|-Sec-| # Segment30: |-Sec-|--------| # Segment31: |---------|-Sec-| - - Type: 0x6ABCDEF0 - VAddr: 0x500C - Sections: - - Section: sectionb - - Section: blobc - - Section: sectionc - - Type: 0x6ABCDEF0 - VAddr: 0x500C + - Type: 0x6ABCDEF0 + VAddr: 0x500C + FirstSec: sectionb + LastSec: sectionc + - Type: 0x6ABCDEF0 + VAddr: 0x500C FileSize: 7 - Sections: - - Section: sectionb - - Type: 0x6ABCDEF0 - VAddr: 0x5011 - Offset: 0x5011 - Sections: - - Section: sectionc + FirstSec: sectionb + LastSec: sectionb + - Type: 0x6ABCDEF0 + VAddr: 0x5011 + Offset: 0x5011 + FirstSec: sectionc + LastSec: sectionc # Segment32: |-Sec-|-unlabelled-|-Sec-| # Segment33: |-Sec-|------------| # Segment34: |------------|-Sec-| - - Type: 0x6ABCDEF0 - VAddr: 0x5018 - Sections: - - Section: sectiond - - Section: blobd - - Section: sectione - - Type: 0x6ABCDEF0 - VAddr: 0x5018 - Sections: - - Section: sectiond - - Section: blobd - - Type: 0x6ABCDEF0 - VAddr: 0x501C - Sections: - - Section: blobd - - Section: sectione + - Type: 0x6ABCDEF0 + VAddr: 0x5018 + FirstSec: sectiond + LastSec: sectione + - Type: 0x6ABCDEF0 + VAddr: 0x5018 + FirstSec: sectiond + LastSec: blobd + - Type: 0x6ABCDEF0 + VAddr: 0x501C + FirstSec: blobd + LastSec: sectione # Segment35: |-unlabelled-|-Sec-|-unlabelled-| # Segment36: |------------|-Sec-| # Segment37: |-Sec-|------------| - - Type: 0x6ABCDEF0 - VAddr: 0x5024 - Sections: - - Section: blobe - - Section: sectionf - - Section: blobf - - Type: 0x6ABCDEF0 - VAddr: 0x5024 - Sections: - - Section: blobe - - Section: sectionf - - Type: 0x6ABCDEF0 - VAddr: 0x5028 - Sections: - - Section: sectionf - - Section: blobf + - Type: 0x6ABCDEF0 + VAddr: 0x5024 + FirstSec: blobe + LastSec: blobf + - Type: 0x6ABCDEF0 + VAddr: 0x5024 + FirstSec: blobe + LastSec: sectionf + - Type: 0x6ABCDEF0 + VAddr: 0x5028 + FirstSec: sectionf + LastSec: blobf # Segment38: |-unlabelled-|-Sec-|-unlabelled-| # Segment39: |------------|---| # Segment40: |---|------------| - - Type: 0x6ABCDEF0 - VAddr: 0x5030 - Sections: - - Section: blobg - - Section: sectiong - - Section: blobh - - Type: 0x6ABCDEF0 - VAddr: 0x5030 + - Type: 0x6ABCDEF0 + VAddr: 0x5030 + FirstSec: blobg + LastSec: blobh + - Type: 0x6ABCDEF0 + VAddr: 0x5030 FileSize: 7 - Sections: - - Section: blobg - - Type: 0x6ABCDEF0 - VAddr: 0x5035 - Offset: 0x5035 - Sections: - - Section: blobh + FirstSec: blobg + LastSec: blobg + - Type: 0x6ABCDEF0 + VAddr: 0x5035 + Offset: 0x5035 + FirstSec: blobh + LastSec: blobh Index: llvm/test/tools/llvm-objcopy/ELF/program-headers.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/program-headers.test +++ llvm/test/tools/llvm-objcopy/ELF/program-headers.test @@ -28,19 +28,18 @@ Address: 0xAAAA2000 AddressAlign: 0x0000000000001000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0xAAAA1000 - PAddr: 0xFFFF1000 - Sections: - - Section: .text - - Section: .init - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0xAAAA2000 - PAddr: 0xFFFF2000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xAAAA1000 + PAddr: 0xFFFF1000 + FirstSec: .text + LastSec: .init + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0xAAAA2000 + PAddr: 0xFFFF2000 + FirstSec: .data + LastSec: .data #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/remove-section-in-segment.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/remove-section-in-segment.test +++ llvm/test/tools/llvm-objcopy/ELF/remove-section-in-segment.test @@ -42,6 +42,5 @@ ProgramHeaders: # Use an arbitrary segment type to show that the segment type is unimportant. - Type: 0x61234567 - Sections: - - Section: shf_alloc - - Section: non_alloc + FirstSec: shf_alloc + LastSec: non_alloc Index: llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test +++ llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test @@ -28,16 +28,16 @@ AddressAlign: 0x1000 Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x3000 - Sections: - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x3000 + FirstSec: .text3 + LastSec: .text3 ## TODO (grimar): without the following line (i.e. without an empty symbol table), ## llvm-objcopy adds an empty .strtab section. It doesn't look correct. Symbols: [] Index: llvm/test/tools/llvm-objcopy/ELF/segment-shift.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/segment-shift.test +++ llvm/test/tools/llvm-objcopy/ELF/segment-shift.test @@ -28,16 +28,16 @@ AddressAlign: 0x1000 Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x3000 - Sections: - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x3000 + FirstSec: .text3 + LastSec: .text3 # CHECK: ProgramHeaders [ # CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/segment-test-remove-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/segment-test-remove-section.test +++ llvm/test/tools/llvm-objcopy/ELF/segment-test-remove-section.test @@ -36,12 +36,10 @@ AddressAlign: 0x1000 Size: 4096 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Section: .text2 - - Section: .text3 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text3 ## TODO (grimar): without the following line (i.e. without an empty symbol table), ## llvm-objcopy adds an empty .strtab section. It doesn't look correct. Symbols: [] Index: llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test @@ -56,9 +56,9 @@ Info: .text ProgramHeaders: # Use an arbitrary segment type to show that the segment type is unimportant. - - Type: 0x61234567 - Sections: - - Section: .debug_in_segment + - Type: 0x61234567 + FirstSec: .debug_in_segment + LastSec: .debug_in_segment # CHECK: SectionHeaderCount: 8 Index: llvm/test/tools/llvm-objcopy/ELF/strip-all.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-all.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-all.test @@ -70,9 +70,9 @@ Type: SHT_PROGBITS ProgramHeaders: # Use an arbitrary segment type to show that the segment type is unimportant. - - Type: 0x61234567 - Sections: - - Section: non_alloc_in_segment + - Type: 0x61234567 + FirstSec: non_alloc_in_segment + LastSec: non_alloc_in_segment # CHECK: SectionHeaderCount: 6 Index: llvm/test/tools/llvm-objcopy/ELF/strip-non-alloc.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-non-alloc.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-non-alloc.test @@ -27,9 +27,9 @@ Flags: [ SHF_ALLOC, SHF_EXECINSTR ] ProgramHeaders: # Use an arbitrary segment type to show that the segment type is unimportant. - - Type: 0x61234567 - Sections: - - Section: non_alloc_in_segment + - Type: 0x61234567 + FirstSec: non_alloc_in_segment + LastSec: non_alloc_in_segment # RUN: yaml2obj --docnum=2 %s -o %t2 # RUN: llvm-objcopy --strip-non-alloc %t2 %t2.out @@ -57,6 +57,6 @@ Type: SHT_PROGBITS Content: 00 ProgramHeaders: - - Type: 0x61234567 - Sections: - - Section: .text + - Type: 0x61234567 + FirstSec: .text + LastSec: .text Index: llvm/test/tools/llvm-objcopy/ELF/strip-sections.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-sections.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-sections.test @@ -34,11 +34,10 @@ Flags: [ ] Content: "FEEDFACE" ProgramHeaders: -- Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Section: .non_alloc_in_segment +- Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .non_alloc_in_segment # DATA: {{^[^[:blank:]]+}} de ad be ef ca fe ba be # DATA-NOT: fe ed fa ce Index: llvm/test/tools/llvm-objcopy/ELF/triple-overlap.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/triple-overlap.test +++ llvm/test/tools/llvm-objcopy/ELF/triple-overlap.test @@ -40,32 +40,22 @@ AddressAlign: 0x1000 Size: 4096 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text4 - - Section: .text5 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text3 - - Section: .text4 - - Section: .text5 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - - Section: .text2 - - Section: .text3 - - Section: .text4 - - Section: .text5 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text2 - - Section: .text3 - - Section: .text4 - - Section: .text5 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text4 + LastSec: .text5 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text3 + LastSec: .text5 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text5 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text2 + LastSec: .text5 #CHECK: ProgramHeaders [ #CHECK-NEXT: ProgramHeader { Index: llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test +++ llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test @@ -39,18 +39,16 @@ Content: "FFFFFFFF" Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x3000 - Sections: - - Section: .text3 - - Section: .text4 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text2 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x3000 + FirstSec: .text3 + LastSec: .text4 # CHECK: 000000 c3 c3 c3 c3 # CHECK: 001000 de ad be ef Index: llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test +++ llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test @@ -39,18 +39,16 @@ Content: "FFFFFFFF" Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x3000 - Sections: - - Section: .text3 - - Section: .text4 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text2 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x3000 + FirstSec: .text3 + LastSec: .text4 # CHECK: 000000 de ad be ef # CHECK: 001000 32 32 32 32 Index: llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test +++ llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test @@ -39,18 +39,16 @@ Content: "FFFFFFFF" Size: 0x1000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x3000 - Sections: - - Section: .text3 - - Section: .text4 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .text + LastSec: .text2 + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x3000 + FirstSec: .text3 + LastSec: .text4 # CHECK: 000000 c3 c3 c3 c3 # CHECK: 001000 de ad be ef Index: llvm/test/tools/llvm-objdump/ELF/dynamic-section-machine-specific.test =================================================================== --- llvm/test/tools/llvm-objdump/ELF/dynamic-section-machine-specific.test +++ llvm/test/tools/llvm-objdump/ELF/dynamic-section-machine-specific.test @@ -28,12 +28,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 2: Test that MIPS machine-specific tags can be dumped. ## MIPS has a few long tag names. Show that we indent columns properly. @@ -190,12 +190,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 3: Test that PPC machine-specific tags can be dumped. # RUN: yaml2obj --docnum=3 -o %t.ppc %s @@ -222,12 +222,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 4: Test that PPC64 machine-specific tags can be dumped. # RUN: yaml2obj --docnum=4 -o %t.ppc64 %s @@ -251,12 +251,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 5: Test that AARCH64 machine-specific tags can be dumped. # RUN: yaml2obj --docnum=5 -o %t.aarch64 %s @@ -283,9 +283,9 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-objdump/ELF/dynamic-section.test =================================================================== --- llvm/test/tools/llvm-objdump/ELF/dynamic-section.test +++ llvm/test/tools/llvm-objdump/ELF/dynamic-section.test @@ -205,15 +205,14 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1010 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + FirstSec: .dynamic + LastSec: .dynamic # RUN: yaml2obj --docnum=2 %s -o %t2 # RUN: llvm-objdump -p %t2 | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=ELF32 @@ -421,15 +420,14 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1010 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + FirstSec: .dynamic + LastSec: .dynamic ## When printing the value column we want to have the minimal possible indentation. ## Use an arbitrary dynamic tag to demonstrate that. Index: llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test =================================================================== --- llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test +++ llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test @@ -56,10 +56,10 @@ Address: 0x1000 Content: 909090909090909090909090 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .text + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .text + LastSec: .text Symbols: - Name: both_static Value: 0x1001 Index: llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test =================================================================== --- llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test +++ llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test @@ -94,17 +94,13 @@ - Type: PT_LOAD VAddr: 0x100000 Align: 0x100 - Sections: - - Section: .foo - - Section: .rela.dyn - - Section: .rela.plt - - Section: .rel.dyn - - Section: .dynamic + FirstSec: .foo + LastSec: .dynamic - Type: PT_DYNAMIC VAddr: 0x100500 Align: 0x100 - Sections: - - Section: .dynamic + FirstSec: .dynamic + LastSec: .dynamic DynamicSymbols: - Name: foo Section: .foo Index: llvm/test/tools/llvm-objdump/X86/phdrs-lma.test =================================================================== --- llvm/test/tools/llvm-objdump/X86/phdrs-lma.test +++ llvm/test/tools/llvm-objdump/X86/phdrs-lma.test @@ -33,16 +33,15 @@ Content: "00000000" Address: 0x00002000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x00001000 - PAddr: 0x00002000 - Sections: - - Section: .text - - Section: .init - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x00002000 - PAddr: 0x00003000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x00001000 + PAddr: 0x00002000 + FirstSec: .text + LastSec: .init + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x00002000 + PAddr: 0x00003000 + FirstSec: .data + LastSec: .data Index: llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test =================================================================== --- llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test +++ llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test @@ -45,14 +45,13 @@ Content: "00000000" Address: 0x00002000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0x00001000 - Sections: - - Section: .text - - Section: .init - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x00002000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x00001000 + FirstSec: .text + LastSec: .init + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x00002000 + FirstSec: .data + LastSec: .data Index: llvm/test/tools/llvm-objdump/section-filter.test =================================================================== --- llvm/test/tools/llvm-objdump/section-filter.test +++ llvm/test/tools/llvm-objdump/section-filter.test @@ -40,22 +40,21 @@ AddressAlign: 0x10 Size: 1 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x400 - PAddr: 0x1000 - Sections: - - Section: .text - - Section: .text2 - - Type: PT_LOAD - VAddr: 0x410 - PAddr: 0x2000 - Sections: - - Section: .data - - Type: PT_LOAD - VAddr: 0x420 - PAddr: 0x3000 - Sections: - - Section: .bss + - Type: PT_LOAD + VAddr: 0x400 + PAddr: 0x1000 + FirstSec: .text + LastSec: .text2 + - Type: PT_LOAD + VAddr: 0x410 + PAddr: 0x2000 + FirstSec: .data + LastSec: .data + - Type: PT_LOAD + VAddr: 0x420 + PAddr: 0x3000 + FirstSec: .bss + LastSec: .bss ## Test that --section works with --fault-map-section. # RUN: yaml2obj %s --docnum=2 -o %t.o Index: llvm/test/tools/llvm-objdump/warn-on-out-of-range-start-stop-address.test =================================================================== --- llvm/test/tools/llvm-objdump/warn-on-out-of-range-start-stop-address.test +++ llvm/test/tools/llvm-objdump/warn-on-out-of-range-start-stop-address.test @@ -151,9 +151,8 @@ Flags: [ PF_X, PF_R ] VAddr: 0x1000 FileSize: 0x500 - Sections: - - Section: .text - - Section: .text2 + FirstSec: .text + LastSec: .text2 --- !ELF FileHeader: @@ -172,8 +171,8 @@ Flags: [ PF_X, PF_R ] VAddr: 0x1000 FileSize: 0x4 - Sections: - - Section: .text + FirstSec: .text + LastSec: .text --- !ELF FileHeader: Index: llvm/test/tools/llvm-readobj/ELF/all.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/all.test +++ llvm/test/tools/llvm-readobj/ELF/all.test @@ -97,20 +97,19 @@ ## An arbitrary linker-generated valid content. Content: 040000001000000003000000474E55004FCB712AA6387724A9F465A32CD8C14B ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .hash - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic - - Type: PT_GNU_EH_FRAME - Sections: - - Section: .eh_frame_hdr - - Type: PT_NOTE - Sections: - - Section: .note.gnu.build-id + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .hash + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_GNU_EH_FRAME + FirstSec: .eh_frame_hdr + LastSec: .eh_frame_hdr + - Type: PT_NOTE + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id Symbols: [] DynamicSymbols: - Name: foo Index: llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test +++ llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test @@ -44,10 +44,9 @@ DynamicSymbols: - StName: 0x1234 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.dyn - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.dyn + LastSec: .dynamic ## Show we print a warning for an invalid relocation table size stored in a DT_RELASZ entry. # RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG1VAL=0xFF -DTAG2=DT_RELAENT %s -o %t2 @@ -77,10 +76,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .relx.dyn - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .relx.dyn + LastSec: .dynamic ## Show we print a warning for an invalid relocation table entry size stored in a DT_RELAENT entry. # RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG2=DT_RELAENT -DTAG2VAL=0xFF %s -o %t3 @@ -158,10 +156,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.plt - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.plt + LastSec: .dynamic ## Show we print a warning when dumping dynamic relocations if there is no dynamic symbol table. # RUN: yaml2obj --docnum=4 %s -o %t11 @@ -207,10 +204,9 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.dyn - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.dyn + LastSec: .dynamic ## Show we print a warning when the symbol index of a dynamic relocation is too ## large (goes past the end of the dynamic symbol table). @@ -254,10 +250,9 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.dyn - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.dyn + LastSec: .dynamic ## Show that when we have both REL and RELA relocations, we dump both sets. # RUN: yaml2obj --docnum=6 %s -o %t13 @@ -314,11 +309,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.dyn - - Section: .rel.dyn - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.dyn + LastSec: .dynamic ## Check that llvm-readobj/llvm-readelf reports a warning when dumping a relocation ## which refers to a symbol past the end of the file. @@ -402,14 +395,12 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - Offset: 0x0 - Sections: - - Section: .dynamic - - Section: .rela.dyn - - Section: .dynsym - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + Offset: 0x0 + FirstSec: .dynamic + LastSec: .dynsym + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic SectionHeaderTable: NoHeaders: true Index: llvm/test/tools/llvm-readobj/ELF/check-output-order.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/check-output-order.test +++ llvm/test/tools/llvm-readobj/ELF/check-output-order.test @@ -40,6 +40,6 @@ Value: 0 Symbols: [] ProgramHeaders: - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/demangle.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/demangle.test +++ llvm/test/tools/llvm-readobj/ELF/demangle.test @@ -216,17 +216,13 @@ - Name: _Z3fooi Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - VAddr: 0x0 - Sections: - - Section: .dynstr - - Section: .dynsym - - Section: .rela.dyn - - Section: .dynamic - - Section: .text.foo - - Type: PT_DYNAMIC - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + VAddr: 0x0 + FirstSec: .dynstr + LastSec: .text.foo + - Type: PT_DYNAMIC + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/dyn-symbols-size-from-hash-table.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dyn-symbols-size-from-hash-table.test +++ llvm/test/tools/llvm-readobj/ELF/dyn-symbols-size-from-hash-table.test @@ -123,22 +123,18 @@ Section: .data Value: 0x200 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0 - Sections: - - Section: .text - - Section: .data - - Type: PT_LOAD - VAddr: 0x400 - Sections: - - Section: .dynsym - - Section: .hash - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0xA00 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0 + FirstSec: .text + LastSec: .data + - Type: PT_LOAD + VAddr: 0x400 + FirstSec: .dynsym + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0xA00 + FirstSec: .dynamic + LastSec: .dynamic ## Case 2: Table size from DT_HASH does not match size from section header. # RUN: yaml2obj --docnum=2 %s -o %t2-smaller -DCHAIN="[1, 2]" @@ -290,22 +286,18 @@ Section: .data Value: 0x300 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0 - Sections: - - Section: .text - - Section: .data - - Type: PT_LOAD - VAddr: 0x400 - Sections: - - Section: .dynsym - - Section: .hash - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0xA00 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0 + FirstSec: .text + LastSec: .data + - Type: PT_LOAD + VAddr: 0x400 + FirstSec: .dynsym + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0xA00 + FirstSec: .dynamic + LastSec: .dynamic ## Case 3: DT_HASH is missing. ## Show that no warning occurs if there are section headers. @@ -409,9 +401,7 @@ NChain: 0xFFFFFFFF DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.plt - - Section: .dynamic - - Section: .hash + - Type: PT_LOAD + FirstSec: .rela.plt + LastSec: .hash VAddr: 0x1000 Index: llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test +++ llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test @@ -63,10 +63,10 @@ - Name: foo - Name: bar ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x100 - Sections: - - Section: .dynsym + - Type: PT_LOAD + VAddr: 0x100 + FirstSec: .dynsym + LastSec: .dynsym ## Case 2: Check the output for aliases. ## a) Check the two-letter alias --dt is equivalent to the --dyn-symbols @@ -201,10 +201,10 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x0000 - Sections: - - Section: .dynsym + - Type: PT_LOAD + VAddr: 0x0000 + FirstSec: .dynsym + LastSec: .dynsym ## Case 6: Check that if we can get the location of the dynamic symbol table using both the DT_SYMTAB value ## and the section headers table then we prefer the former and report a warning. @@ -238,10 +238,10 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x0000 - Sections: - - Section: .mydynsym + - Type: PT_LOAD + VAddr: 0x0000 + FirstSec: .mydynsym + LastSec: .mydynsym ## Case 7: Check how we dump versioned symbols. Use both -V and --dyn-symbols ## to check that printed version is consistent. @@ -488,10 +488,10 @@ Address: 0x100 Size: 0x1 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x100 - Sections: - - Section: .dynsym + - Type: PT_LOAD + VAddr: 0x100 + FirstSec: .dynsym + LastSec: .dynsym --- !ELF FileHeader: @@ -582,11 +582,10 @@ ## An arbitrary valid symbol to document we report an error before dumping it. - StName: 0x1 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .dynstr - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .dynstr + LastSec: .dynamic ## Case 11: check various warnings we report when fields of the SHT_DYNSYM section are broken. Index: llvm/test/tools/llvm-readobj/ELF/dynamic-empty.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-empty.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-empty.test @@ -18,11 +18,11 @@ Type: SHT_DYNAMIC Address: 0x1000 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test @@ -35,14 +35,14 @@ Content: "01234567" Symbols: [] ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic ## Test handling of a .dynamic section with an invalid entsize (i.e. not 2 * sizeof(Elf_Dyn)). # RUN: yaml2obj %s --docnum=2 -o %t.bad-entsize @@ -77,14 +77,14 @@ Value: 0 Symbols: [] ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic ## Test handling of string references pointing past the end of the dynamic string table. # RUN: yaml2obj %s --docnum=3 -o %t.bad-string @@ -171,15 +171,14 @@ Value: 0 Symbols: [] ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1010 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + FirstSec: .dynamic + LastSec: .dynamic ## Test handling of DT_STRTAB pointing outside the file's address space. # RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab @@ -226,14 +225,14 @@ Value: 0x0 Symbols: [] ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic ## Test handling of other d_ptr tags pointing outside the file's address space. # RUN: yaml2obj %s --docnum=5 -o %t.bad-rela @@ -268,14 +267,14 @@ Value: 0x0 Symbols: [] ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic ## Check how we handle cases when the dynamic string table is not null-terminated. @@ -365,15 +364,14 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1100 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1100 + FirstSec: .dynamic + LastSec: .dynamic ## Check that we emit an appropriate warning when the dynamic string table ends past the end of the file. Index: llvm/test/tools/llvm-readobj/ELF/dynamic-no-pt-dynamic.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-no-pt-dynamic.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-no-pt-dynamic.test @@ -32,7 +32,7 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-not-in-pt-dynamic.test @@ -50,15 +50,14 @@ AddressAlign: 0x100 Content: "00" ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .text + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .text + LastSec: .text ## Case 2: The dynamic table found using the dynamic program header is different from the ## table found using the section header table. @@ -104,15 +103,14 @@ AddressAlign: 0x100 Content: "00000000000000000000000000000000" ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .text + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .text + LastSec: .text ## Case 3: Both dynamic tables found using SHT_DYNAMIC/PT_DYNAMIC are corrupted. @@ -145,12 +143,11 @@ AddressAlign: 0x100 Content: "00" ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .text + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .text + LastSec: .text Index: llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test @@ -53,14 +53,11 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.dyn - - Section: .dynamic - Section: .dynsym - Section: .dynstr - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.dyn + LastSec: .dynstr + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic SectionHeaderTable: NoHeaders: true Index: llvm/test/tools/llvm-readobj/ELF/dynamic-reloc.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-reloc.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-reloc.test @@ -125,10 +125,6 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .rela.dyn - - Section: .rel.dyn - - Section: .relr.dyn - - Section: .plt - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .rela.dyn + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/dynamic-table-dtnull.s =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-table-dtnull.s +++ llvm/test/tools/llvm-readobj/ELF/dynamic-table-dtnull.s @@ -25,12 +25,12 @@ - Tag: DT_DEBUG Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic # Sometimes .dynamic section content length can be greater than the # length of its entries. In this case, we should not try to dump anything @@ -67,9 +67,9 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test @@ -39,12 +39,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 2: Test that MIPS machine-specific tags can be dumped. # RUN: yaml2obj --docnum=2 %s -o %t.mips @@ -259,12 +259,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 3: Test that PPC machine-specific tags can be dumped. # RUN: yaml2obj --docnum=3 %s -o %t.ppc @@ -301,12 +301,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 4: Test that PPC64 machine-specific tags can be dumped. # RUN: yaml2obj --docnum=4 %s -o %t.ppc64 @@ -339,12 +339,12 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic ## Case 5: Test that AARCH64 machine-specific tags can be dumped. # RUN: yaml2obj --docnum=5 %s -o %t.aarch64 @@ -381,9 +381,9 @@ - Tag: DT_NULL Value: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/dynamic-tags.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/dynamic-tags.test +++ llvm/test/tools/llvm-readobj/ELF/dynamic-tags.test @@ -281,15 +281,14 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynstr - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1010 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynstr + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + FirstSec: .dynamic + LastSec: .dynamic # RUN: yaml2obj %s --docnum=1 -DBITS=32 -DSYMBOLIC=0x12345678 -DDEBUG=0xfedcba09 \ # RUN: -DTEXTREL=0x11223344 -DBINDNOW=0x88776655 -DFLAGS=0xffffffff \ Index: llvm/test/tools/llvm-readobj/ELF/gnu-notes.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/gnu-notes.test +++ llvm/test/tools/llvm-readobj/ELF/gnu-notes.test @@ -104,10 +104,10 @@ AddressAlign: 0x0000000000000004 Content: 040000000900000004000000474E5500676F6C6420312E3131000000 ProgramHeaders: - - Type: PT_NOTE + - Type: PT_NOTE FileSize: 0x20 - Sections: - - Section: .note.gnu.build-id + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id ## Test tools report an error if a note section has an invalid offset ## that goes past the end of file. @@ -186,10 +186,10 @@ Type: SHT_NOTE Notes: [] ProgramHeaders: - - Type: PT_NOTE + - Type: PT_NOTE FileSize: 0xffff0000 - Sections: - - Section: .note + FirstSec: .note + LastSec: .note ## Check we report a warning when we are unable to locate the PT_NOTE ## segment because of broken program headers. Index: llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test +++ llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test @@ -39,19 +39,17 @@ Size: 0x4 ProgramHeaders: ## Case 1: an arbitrary segment with sections. - - Type: PT_PHDR - Flags: [ PF_W ] - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_PHDR + Flags: [ PF_W ] + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 2: another segment with different sections. - - Type: PT_PHDR - Flags: [ PF_X ] - VAddr: 0x2000 - Sections: - - Section: .bar.begin - - Section: .bar.end + - Type: PT_PHDR + Flags: [ PF_X ] + VAddr: 0x2000 + FirstSec: .bar.begin + LastSec: .bar.end ## Check that --section-mapping=false --program-headers produces just program headers. # RUN: llvm-readelf --section-mapping=false --program-headers %t64.elf \ Index: llvm/test/tools/llvm-readobj/ELF/gnuhash.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/gnuhash.test +++ llvm/test/tools/llvm-readobj/ELF/gnuhash.test @@ -57,11 +57,10 @@ - Name: ddd Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Check we report a warning if there is no dynamic symbol section in the object. @@ -103,11 +102,10 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Check what we do when the index of the first symbol in the dynamic symbol table ## included in the hash table is larger than the number of dynamic symbols. @@ -156,11 +154,10 @@ - Name: aaa Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Check we emit a warning when the dynamic symbol table is empty. ## A valid dynamic symbol table should have at least one symbol: the symbol with index 0. @@ -209,11 +206,10 @@ Type: SHT_DYNSYM Size: 0 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Linkers might produce an empty no-op SHT_GNU_HASH section when ## there are no dynamic symbols or when all dynamic symbols are undefined. @@ -277,11 +273,10 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Check we report a proper warning when a hash table goes past the end of the file. Index: llvm/test/tools/llvm-readobj/ELF/hash-histogram.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/hash-histogram.test +++ llvm/test/tools/llvm-readobj/ELF/hash-histogram.test @@ -63,11 +63,9 @@ - Name: c - Name: d ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Show that we report a warning for a hash table which contains an entry of ## the bucket array pointing to a cycle. @@ -106,10 +104,9 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Each SHT_HASH section starts with two 32-bit fields: nbucket and nchain. ## Check we report an error when a DT_HASH value points to data that has size less than 8 bytes. @@ -142,9 +139,8 @@ ProgramHeaders: - Type: PT_LOAD FileSize: 0x23a - Sections: - - Section: .hash - - Section: .dynamic + FirstSec: .hash + LastSec: .dynamic ## Check we report a warning when the hash table goes past the end of the file. @@ -201,10 +197,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Check we dump a histogram for the .gnu.hash table even when the .hash table is skipped. @@ -258,11 +253,9 @@ DynamicSymbols: - Name: foo ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Check we report a proper warning when the GNU hash table goes past the end of the file. @@ -308,10 +301,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .gnu.hash + LastSec: .dynamic ## Linkers might produce an empty no-op SHT_GNU_HASH section when ## there are no dynamic symbols or when all dynamic symbols are undefined. @@ -369,10 +361,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .gnu.hash + LastSec: .dynamic ## Check we report warnings when the dynamic symbol table is absent or empty. @@ -416,6 +407,6 @@ Type: [[TYPE]] Size: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .gnu.hash + - Type: PT_LOAD + FirstSec: .gnu.hash + LastSec: .gnu.hash Index: llvm/test/tools/llvm-readobj/ELF/hash-symbols.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/hash-symbols.test +++ llvm/test/tools/llvm-readobj/ELF/hash-symbols.test @@ -104,12 +104,10 @@ Value: 0x0000000000001001 Type: [[TYPE=STT_NOTYPE]] ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .hash - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .hash + LastSec: .dynamic ## Check what we print for unnamed section symbols. # RUN: yaml2obj --docnum=1 -DBITS=64 -DTYPE=STT_SECTION -DNAME="''" %s -o %t1-sec-syms.so @@ -188,11 +186,10 @@ Binding: STB_WEAK Value: 0x0000000000001001 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .hash + LastSec: .dynamic ## Check the output when only .gnu.hash section is present. @@ -252,11 +249,10 @@ Binding: STB_WEAK Value: 0x0000000000001001 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Show that if there are no hash sections, we do not print anything. # RUN: yaml2obj --docnum=4 %s -o %t4.so @@ -317,19 +313,16 @@ - Name: _Z3fooi Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - VAddr: 0x0 - Sections: - - Section: .dynstr - - Section: .dynsym - - Section: .dynamic - - Section: .text.foo - - Type: PT_DYNAMIC - Flags: [ PF_R ] - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + VAddr: 0x0 + FirstSec: .dynstr + LastSec: .text.foo + - Type: PT_DYNAMIC + Flags: [ PF_R ] + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic ## Show that we report a warning for a hash table which contains an entry of ## the bucket array pointing to a cycle. @@ -365,10 +358,9 @@ - Name: aaa - Name: bbb ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Each SHT_HASH section starts with two 32-bit fields: nbucket and nchain. ## Check we report an error when a DT_HASH value points to data that has size less than 8 bytes. @@ -401,9 +393,8 @@ ProgramHeaders: - Type: PT_LOAD FileSize: 0x23a - Sections: - - Section: .hash - - Section: .dynamic + FirstSec: .hash + LastSec: .dynamic ## Check we report a warning when the hash table goes past the end of the file. @@ -465,10 +456,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Check we report a proper warning when a GNU hash table goes past the end of the file. @@ -524,11 +514,10 @@ - Name: ddd Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## Check the behavior when the dynamic symbol table is empty or not found. @@ -576,12 +565,10 @@ Flags: [ SHF_ALLOC ] Size: 0 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .hash - - Section: .dynamic - - Section: .dynstr + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .hash + LastSec: .dynstr ## Case A.2: similar to A.1, but now check that we report a warning when the dynamic symbol table was not found. ## To do that, set the type of the .dynsym to SHT_PROGBITS to hide it. @@ -649,12 +636,10 @@ Flags: [ SHF_ALLOC ] Size: 0 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic - - Section: .dynstr + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynstr ## In this case we have a broken value in the hash buckets array. Normally it contains an ## index into the dynamic symbol table and also is used to get a hash value from the hash values array. @@ -699,11 +684,10 @@ - Name: foo Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R, PF_X ] - Sections: - - Section: .gnu.hash - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R, PF_X ] + FirstSec: .gnu.hash + LastSec: .dynamic ## In this case we are unable to read a hash value for a symbol with ## an index that is less than the index of the first hashed symbol. Index: llvm/test/tools/llvm-readobj/ELF/hash-table.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/hash-table.test +++ llvm/test/tools/llvm-readobj/ELF/hash-table.test @@ -38,10 +38,9 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Document that we ignore the sh_entsize value when dumping the hash section. ## Implementation assumes that the size of entries is 4, matching the ELF specification. @@ -117,14 +116,13 @@ SectionHeaderTable: NoHeaders: [[NOHEADERS=false]] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x10 - Sections: - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x10 + FirstSec: .dynamic + LastSec: .dynamic ## Document we don't report a warning when the value of the sh_entsize field of the SHT_HASH section is not 4. @@ -179,9 +177,8 @@ ProgramHeaders: - Type: PT_LOAD FileSize: 0x23a - Sections: - - Section: .hash - - Section: .dynamic + FirstSec: .hash + LastSec: .dynamic ## Check we report a warning when the hash table goes past the end of the file. @@ -274,10 +271,9 @@ Value: 0x0 DynamicSymbols: [] ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .hash - - Section: .dynamic + - Type: PT_LOAD + FirstSec: .hash + LastSec: .dynamic ## Show we do not duplicate warnings when printing both the hash table and the hash histogram. ## Note that --elf-hash-histogram is only implemented for llvm-readelf currently. Index: llvm/test/tools/llvm-readobj/ELF/loadname.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/loadname.test +++ llvm/test/tools/llvm-readobj/ELF/loadname.test @@ -47,9 +47,8 @@ Flags: [ PF_R ] VAddr: 0x0000 FileSize: [[PHDRFILESIZE]] - Sections: - - Section: .dynstr - - Section: .dynamic + FirstSec: .dynstr + LastSec: .dynamic ## Check we do not crash when an object contains a DT_STRTAB entry whose address ## is past the end of the object. Index: llvm/test/tools/llvm-readobj/ELF/malformed-pt-dynamic.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/malformed-pt-dynamic.test +++ llvm/test/tools/llvm-readobj/ELF/malformed-pt-dynamic.test @@ -140,7 +140,7 @@ ProgramHeaders: - Type: PT_DYNAMIC FileSize: [[FILESIZE=]] - Sections: - - Section: .dynamic + FirstSec: .dynamic + LastSec: .dynamic SectionHeaderTable: NoHeaders: [[NOHEADERS=false]] Index: llvm/test/tools/llvm-readobj/ELF/needed-libs.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/needed-libs.test +++ llvm/test/tools/llvm-readobj/ELF/needed-libs.test @@ -51,9 +51,8 @@ ProgramHeaders: - Type: PT_LOAD VAddr: 0x0 - Sections: - - Section: .dynstr - - Section: .dynamic + FirstSec: .dynstr + LastSec: .dynamic ## Check what we print when the dynamic string table is empty. # RUN: yaml2obj %s --docnum=2 -o %t2 @@ -94,8 +93,7 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x0 - Sections: - - Section: .dynstr - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x0 + FirstSec: .dynstr + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test +++ llvm/test/tools/llvm-readobj/ELF/non-dynamic-in-pt-dynamic.test @@ -48,16 +48,14 @@ - Tag: DT_NULL Value: 0x0 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .dynamic - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .text - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .text + LastSec: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .text + LastSec: .dynamic ## In this case .text goes after .dynamic and we don't display any warnings, ## though the content of the .text is used for dumping the dynamic table. @@ -102,16 +100,14 @@ AddressAlign: 0x100 Content: "00000000000000000000000000000000" ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text ## In this case .text goes after .dynamic, but (PT_DYNAMIC segment size % dynamic entry size != 0) ## and we have to use the information from the section header instead. @@ -157,13 +153,11 @@ AddressAlign: 0x100 Content: "00" ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .text + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .text Index: llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test +++ llvm/test/tools/llvm-readobj/ELF/note-core-ntfile-bad.test @@ -32,9 +32,9 @@ Type: SHT_NOTE Content: 0500000008000000454C4946434F5245000000000000000000000000 ProgramHeaders: - - Type: PT_NOTE - Sections: - - Section: .note.foo + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo # RUN: yaml2obj --docnum=2 %s -o %t2.o # RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM @@ -66,9 +66,9 @@ Type: SHT_NOTE Content: 050000002C000000454C4946434F5245000000000100000000000000001000000000000000100000000000000020000000000000003000000000000078787878 ProgramHeaders: - - Type: PT_NOTE - Sections: - - Section: .note.foo + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo # RUN: yaml2obj --docnum=3 %s -o %t3.o # RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT @@ -100,9 +100,9 @@ Type: SHT_NOTE Content: 050000002C000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000078797A00 ProgramHeaders: - - Type: PT_NOTE - Sections: - - Section: .note.foo + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo # RUN: yaml2obj --docnum=4 %s -o %t4.o # RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY @@ -137,6 +137,6 @@ Type: SHT_NOTE Content: 0500000044000000454C4946434F5245000000000200000000000000001000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000078797A00 ProgramHeaders: - - Type: PT_NOTE - Sections: - - Section: .note.foo + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo Index: llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test +++ llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test @@ -45,9 +45,9 @@ Type: SHT_NOTE Content: 0500000080000000454C4946434F524500000000030000000000000000100000000000000010000000000000002000000000000000300000000000000040000000000000005000000000000000600000000000000070000000000000008000000000000000900000000000002F706174682F746F2F612E6F7574002F706174682F746F2F6C6962632E736F005B737461636B5D00 ProgramHeaders: - - Type: PT_NOTE - Sections: - - Section: .note.foo + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo # GNU: Displaying notes found # GNU-NEXT: Owner Data size Description Index: llvm/test/tools/llvm-readobj/ELF/note-core.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/note-core.test +++ llvm/test/tools/llvm-readobj/ELF/note-core.test @@ -271,6 +271,6 @@ - Name: CORE Type: [[TYPE]] ProgramHeaders: - - Type: PT_NOTE - Sections: - - Section: .note.foo + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo Index: llvm/test/tools/llvm-readobj/ELF/program-headers.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/program-headers.test +++ llvm/test/tools/llvm-readobj/ELF/program-headers.test @@ -445,146 +445,125 @@ Size: 0x1 ProgramHeaders: ## Case 1: an arbitrary segment with sections. - - Type: PT_PHDR - Flags: [ PF_W ] - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_PHDR + Flags: [ PF_W ] + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 2: another segment with different sections. - - Type: PT_PHDR - Flags: [ PF_X ] - VAddr: 0x2000 - Sections: - - Section: .bar.begin - - Section: .bar.end + - Type: PT_PHDR + Flags: [ PF_X ] + VAddr: 0x2000 + FirstSec: .bar.begin + LastSec: .bar.end ## Case 3: the PT_NULL segment. - - Type: PT_NULL - Flags: [ PF_X ] - VAddr: 0x2000 - Sections: - - Section: .bar.begin - - Section: .bar.end + - Type: PT_NULL + Flags: [ PF_X ] + VAddr: 0x2000 + FirstSec: .bar.begin + LastSec: .bar.end ## Case 4: the PT_DYNAMIC segment. - - Type: PT_DYNAMIC - Flags: [ PF_R, PF_W, PF_X ] - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_DYNAMIC + Flags: [ PF_R, PF_W, PF_X ] + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 5: the PT_INTERP segment. - - Type: PT_INTERP - Flags: [ PF_R, PF_W ] - VAddr: 0x3000 - Sections: - - Section: .interp + - Type: PT_INTERP + Flags: [ PF_R, PF_W ] + VAddr: 0x3000 + FirstSec: .interp + LastSec: .interp ## Case 6: the PT_NOTE segment. - - Type: PT_NOTE - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_NOTE + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 7: the PT_SHLIB segment. - - Type: PT_SHLIB - VAddr: 0x1000 - Sections: - - Section: .foo.begin + - Type: PT_SHLIB + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.begin ## Case 8: the PT_TLS segment. - - Type: PT_TLS - VAddr: 0x4000 - Sections: - - Section: .tls + - Type: PT_TLS + VAddr: 0x4000 + FirstSec: .tls + LastSec: .tls ## Case 9: the PT_LOOS segment. - - Type: 0x60000000 ## PT_LOOS - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x60000000 ## PT_LOOS + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 10: the PT_GNU_EH_FRAME segment. - - Type: PT_GNU_EH_FRAME - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_GNU_EH_FRAME + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 11: the PT_SUNW_UNWIND segment. - - Type: 0x6464e550 ## PT_SUNW_UNWIND - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x6464e550 ## PT_SUNW_UNWIND + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 12: the PT_GNU_STACK segment. - - Type: PT_GNU_STACK - Sections: - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_GNU_STACK + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 13: the PT_GNU_RELRO segment. - - Type: PT_GNU_RELRO - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_GNU_RELRO + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 14: the PT_GNU_PROPERTY segment. - - Type: PT_GNU_PROPERTY - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: PT_GNU_PROPERTY + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 15: the PT_OPENBSD_RANDOMIZE segment. - - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 16: the PT_OPENBSD_WXNEEDED segment. - - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 17: the PT_OPENBSD_BOOTDATA segment. - - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 18: the PT_HIOS segment. - - Type: 0x6fffffff ## PT_HIOS - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x6fffffff ## PT_HIOS + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 19: the PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO segment. - - Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 20: the PT_ARM_EXIDX/PT_MIPS_RTPROC segment. - - Type: 0x70000001 ## PT_ARM_EXIDX, PT_MIPS_RTPROC - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x70000001 ## PT_ARM_EXIDX, PT_MIPS_RTPROC + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 20: the PT_MIPS_OPTIONS segment. - - Type: 0x70000002 ## PT_MIPS_OPTIONS - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x70000002 ## PT_MIPS_OPTIONS + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 21: the PT_MIPS_ABIFLAGS segment. - - Type: 0x70000003 ## PT_MIPS_ABIFLAGS - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x70000003 ## PT_MIPS_ABIFLAGS + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Case 22: the PT_HIPROC segment. - - Type: 0x7fffffff ## PT_HIPROC - VAddr: 0x1000 - Sections: - - Section: .foo.begin - - Section: .foo.end + - Type: 0x7fffffff ## PT_HIPROC + VAddr: 0x1000 + FirstSec: .foo.begin + LastSec: .foo.end ## Check how we dump ARM specific program headers. # RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_ARM %s -o %tarm.elf @@ -702,9 +681,9 @@ - Name: .foo Type: SHT_PROGBITS ProgramHeaders: - - Type: PT_PHDR - Sections: - - Section: .foo + - Type: PT_PHDR + FirstSec: .foo + LastSec: .foo ## Case B: the value of the e_phoff field is invalid. Index: llvm/test/tools/llvm-readobj/ELF/reloc-negative-addend-no-sym.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/reloc-negative-addend-no-sym.test +++ llvm/test/tools/llvm-readobj/ELF/reloc-negative-addend-no-sym.test @@ -62,12 +62,11 @@ - Name: force_dynsym Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .rela.dyn - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .rela.dyn + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/reloc-zero-name-or-value.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/reloc-zero-name-or-value.test +++ llvm/test/tools/llvm-readobj/ELF/reloc-zero-name-or-value.test @@ -133,12 +133,11 @@ Section: .text Binding: STB_GLOBAL ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x1000 - Sections: - - Section: .dynamic - - Section: .rela.dyn - - Type: PT_DYNAMIC - VAddr: 0x1000 - Sections: - - Section: .dynamic + - Type: PT_LOAD + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .rela.dyn + - Type: PT_DYNAMIC + VAddr: 0x1000 + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/llvm-readobj/ELF/unwind.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/unwind.test +++ llvm/test/tools/llvm-readobj/ELF/unwind.test @@ -217,16 +217,16 @@ Flags: [ PF_X, PF_R ] VAddr: 0x00400000 PAddr: 0x00400000 - Sections: - - Section: .text - - Type: PT_GNU_EH_FRAME - Flags: [ PF_X, PF_R ] - VAddr: 0x004013C0 - PAddr: 0x004013C0 + FirstSec: .text + LastSec: .text + - Type: PT_GNU_EH_FRAME + Flags: [ PF_X, PF_R ] + VAddr: 0x004013C0 + PAddr: 0x004013C0 MemSize: [[MEMSIZE]] FileSize: [[FILESIZE]] - Sections: - - Section: .eh_frame_hdr + FirstSec: .eh_frame_hdr + LastSec: .eh_frame_hdr ## Document we report a error when the memory size of the PT_GNU_EH_FRAME does not match its file size. ## TODO: we want to report a warning and continue dumping instead. @@ -326,11 +326,10 @@ Data: ELFDATA2LSB Type: ET_EXEC ProgramHeaders: - - Type: PT_GNU_EH_FRAME + - Type: PT_GNU_EH_FRAME MemSize: [[SIZE]] FileSize: [[SIZE]] Offset: [[OFFSET]] - Sections: [] ## Case B: test we report an error when the file size of the PT_GNU_EH_FRAME ## is invalid (goes past the end of the file). Index: llvm/test/tools/llvm-xray/ARM/extract-instrmap.test =================================================================== --- llvm/test/tools/llvm-xray/ARM/extract-instrmap.test +++ llvm/test/tools/llvm-xray/ARM/extract-instrmap.test @@ -17,24 +17,23 @@ Flags: [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ] Entry: 0x00000000000012B0 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .rel.dyn - Align: 0x0000000000001000 - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .text - VAddr: 0x00000000000012B0 - Align: 0x0000000000001000 - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: xray_instr_map - - Section: xray_fn_idx - VAddr: 0x00000000000033CC - Align: 0x0000000000001000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rel.dyn + LastSec: .rel.dyn + Align: 0x0000000000001000 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x00000000000012B0 + Align: 0x0000000000001000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: xray_instr_map + LastSec: xray_fn_idx + VAddr: 0x00000000000033CC + Align: 0x0000000000001000 Sections: - Name: .rel.dyn Type: SHT_REL Index: llvm/test/tools/obj2yaml/ELF/program-headers.yaml =================================================================== --- llvm/test/tools/obj2yaml/ELF/program-headers.yaml +++ llvm/test/tools/obj2yaml/ELF/program-headers.yaml @@ -37,59 +37,53 @@ # RUN: obj2yaml %t1 | FileCheck %s --check-prefix=YAML # YAML: ProgramHeaders: -# YAML-NEXT: - Type: PT_LOAD -# YAML-NEXT: Flags: [ PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .hash -# YAML-NEXT: - Section: .gnu.hash -# YAML-NEXT: - Section: .dynsym -# YAML-NEXT: - Section: .dynstr -# YAML-NEXT: Align: 0x0000000000001000 -# YAML-NEXT: - Type: PT_LOAD -# YAML-NEXT: Flags: [ PF_X, PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .foo -# YAML-NEXT: - Section: .zed -# YAML-NEXT: VAddr: 0x0000000000001000 -# YAML-NEXT: Align: 0x0000000000001000 -# YAML-NEXT: - Type: PT_LOAD -# YAML-NEXT: Flags: [ PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: '.foo (1)' -# YAML-NEXT: - Section: .baz -# YAML-NEXT: VAddr: 0x0000000000002000 -# YAML-NEXT: Align: 0x0000000000001000 -# YAML-NEXT: - Type: PT_LOAD -# YAML-NEXT: Flags: [ PF_W, PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .dynamic -# YAML-NEXT: - Section: .dynamic.tail -# YAML-NEXT: VAddr: 0x0000000000003EF0 -# YAML-NEXT: Align: 0x0000000000001000 -# YAML-NEXT: - Type: PT_DYNAMIC -# YAML-NEXT: Flags: [ PF_W, PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .dynamic -# YAML-NEXT: VAddr: 0x0000000000003EF0 -# YAML-NEXT: Align: 0x0000000000000008 -# YAML-NEXT: - Type: PT_GNU_RELRO -# YAML-NEXT: Flags: [ PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .dynamic -# YAML-NEXT: VAddr: 0x0000000000003EF0 +# YAML-NEXT: - Type: PT_LOAD +# YAML-NEXT: Flags: [ PF_R ] +# YAML-NEXT: FirstSec: .hash +# YAML-NEXT: LastSec: .dynstr +# YAML-NEXT: Align: 0x0000000000001000 +# YAML-NEXT: - Type: PT_LOAD +# YAML-NEXT: Flags: [ PF_X, PF_R ] +# YAML-NEXT: FirstSec: .foo +# YAML-NEXT: LastSec: .zed +# YAML-NEXT: VAddr: 0x0000000000001000 +# YAML-NEXT: Align: 0x0000000000001000 +# YAML-NEXT: - Type: PT_LOAD +# YAML-NEXT: Flags: [ PF_R ] +# YAML-NEXT: FirstSec: '.foo (1)' +# YAML-NEXT: LastSec: .baz +# YAML-NEXT: VAddr: 0x0000000000002000 +# YAML-NEXT: Align: 0x0000000000001000 +# YAML-NEXT: - Type: PT_LOAD +# YAML-NEXT: Flags: [ PF_W, PF_R ] +# YAML-NEXT: FirstSec: .dynamic +# YAML-NEXT: LastSec: .dynamic.tail +# YAML-NEXT: VAddr: 0x0000000000003EF0 +# YAML-NEXT: Align: 0x0000000000001000 +# YAML-NEXT: - Type: PT_DYNAMIC +# YAML-NEXT: Flags: [ PF_W, PF_R ] +# YAML-NEXT: FirstSec: .dynamic +# YAML-NEXT: LastSec: .dynamic +# YAML-NEXT: VAddr: 0x0000000000003EF0 +# YAML-NEXT: Align: 0x0000000000000008 +# YAML-NEXT: - Type: PT_GNU_RELRO +# YAML-NEXT: Flags: [ PF_R ] +# YAML-NEXT: FirstSec: .dynamic +# YAML-NEXT: LastSec: .dynamic +# YAML-NEXT: VAddr: 0x0000000000003EF0 # YAML-NEXT: - Type: PT_LOAD # YAML-NEXT: Flags: [ PF_R ] # YAML-NEXT: VAddr: 0x0000000000004000 -# YAML-NEXT: - Type: PT_LOAD -# YAML-NEXT: Flags: [ PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .gnu.hash -# YAML-NEXT: VAddr: 0x00000000000001A0 -# YAML-NEXT: - Type: PT_LOAD -# YAML-NEXT: Flags: [ PF_R ] -# YAML-NEXT: Sections: -# YAML-NEXT: - Section: .gnu.hash -# YAML-NEXT: VAddr: 0x00000000000001A0 +# YAML-NEXT: - Type: PT_LOAD +# YAML-NEXT: Flags: [ PF_R ] +# YAML-NEXT: FirstSec: .gnu.hash +# YAML-NEXT: LastSec: .gnu.hash +# YAML-NEXT: VAddr: 0x00000000000001A0 +# YAML-NEXT: - Type: PT_LOAD +# YAML-NEXT: Flags: [ PF_R ] +# YAML-NEXT: FirstSec: .gnu.hash +# YAML-NEXT: LastSec: .gnu.hash +# YAML-NEXT: VAddr: 0x00000000000001A0 # YAML-NEXT: Sections: --- !ELF @@ -101,82 +95,75 @@ ## Check we can create a PT_LOAD with arbitrary (we used .hash, .gnu.hash) ## and implicit sections (we use .dynsym, .dynstr). It also checks that the ## SHT_NULL section at index 0 is not included in the segment. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .hash - - Section: .gnu.hash - - Section: .dynsym - - Section: .dynstr + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .hash + LastSec: .dynstr Align: 0x1000 Offset: 0x0 ## Check we can create a PT_LOAD with a different set of properties and sections. - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: - - Section: .foo - - Section: .zed - VAddr: 0x1000 - Align: 0x1000 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .foo + LastSec: .zed + VAddr: 0x1000 + Align: 0x1000 ## Create a PT_LOAD to demonstate we are able to refer to output sections with the same name. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: '.foo (1)' - - Section: .baz - VAddr: 0x2000 - Align: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: '.foo (1)' + LastSec: .baz + VAddr: 0x2000 + Align: 0x1000 ## Show we can create a writeable PT_LOAD segment and put an arbitrary section into it. ## Here we test both regular (SHT_PROGBITS) and a special section (SHT_DYNAMIC). - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .dynamic - - Section: .dynamic.tail - VAddr: 0x3EF0 - Align: 0x1000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .dynamic + LastSec: .dynamic.tail + VAddr: 0x3EF0 + Align: 0x1000 ## Show we can create a nested dynamic segment and put a section into it. - - Type: PT_DYNAMIC - Flags: [ PF_W, PF_R ] - Sections: - - Section: .dynamic - VAddr: 0x3EF0 - Align: 0x8 + - Type: PT_DYNAMIC + Flags: [ PF_W, PF_R ] + FirstSec: .dynamic + LastSec: .dynamic + VAddr: 0x3EF0 + Align: 0x8 ## Show we can create a relro segment and put a section into it. ## We used .dynamic here and in tests above to demonstrate that ## we can place a section in any number of segments. ## Also, we explicitly set the "Align" property to 1 to demonstate ## that we do not dump it, because it is the default alignment ## value set by yaml2obj. - - Type: PT_GNU_RELRO - Flags: [ PF_R ] - Sections: - - Section: .dynamic - VAddr: 0x3EF0 - Align: 0x1 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .dynamic + LastSec: .dynamic + VAddr: 0x3EF0 + Align: 0x1 ## Show we can dump a standalone empty segment. - Type: PT_LOAD Flags: [ PF_R ] - Sections: [ ] VAddr: 0x4000 Align: 0x1 ## ELF specification says that loadable segment entries in the ## program header are sorted by virtual address. ## Show we can dump an out of order segment. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .gnu.hash - VAddr: 0x1A0 - Align: 0x1 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .gnu.hash + LastSec: .gnu.hash + VAddr: 0x1A0 + Align: 0x1 ## Test we are able to dump duplicated segments. ## We use a segment that is the same as the previous one for this. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .gnu.hash - VAddr: 0x1A0 - Align: 0x1 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .gnu.hash + LastSec: .gnu.hash + VAddr: 0x1A0 + Align: 0x1 Sections: - Name: .hash Type: SHT_PROGBITS @@ -240,31 +227,27 @@ # RUN: yaml2obj --docnum=2 %s -o %t2 # RUN: obj2yaml %t2 | FileCheck %s --check-prefix=EMPTY -# EMPTY: - Type: PT_LOAD -# EMPTY-NEXT: Flags: [ PF_W, PF_R ] -# EMPTY-NEXT: Sections: -# EMPTY-NEXT: - Section: .empty.tls.start -# EMPTY-NEXT: - Section: .section.1 -# EMPTY-NEXT: - Section: .empty.tls.middle -# EMPTY-NEXT: - Section: .section.2 -# EMPTY-NEXT: - Section: .empty.tls.end +# EMPTY: - Type: PT_LOAD +# EMPTY-NEXT: Flags: [ PF_W, PF_R ] +# EMPTY-NEXT: FirstSec: .empty.tls.start +# EMPTY-NEXT: LastSec: .empty.tls.end # EMPTY-NEXT: VAddr: 0x0000000000001000 # EMPTY-NEXT: Align: 0x0000000000001000 -# EMPTY-NEXT: - Type: PT_TLS -# EMPTY-NEXT: Flags: [ PF_W, PF_R ] -# EMPTY-NEXT: Sections: -# EMPTY-NEXT: - Section: .empty.tls.start -# EMPTY-NEXT: VAddr: 0x0000000000001000 -# EMPTY-NEXT: - Type: PT_TLS -# EMPTY-NEXT: Flags: [ PF_W, PF_R ] -# EMPTY-NEXT: Sections: -# EMPTY-NEXT: - Section: .empty.tls.middle -# EMPTY-NEXT: VAddr: 0x0000000000001100 -# EMPTY-NEXT: - Type: PT_TLS -# EMPTY-NEXT: Flags: [ PF_W, PF_R ] -# EMPTY-NEXT: Sections: -# EMPTY-NEXT: - Section: .empty.tls.end -# EMPTY-NEXT: VAddr: 0x0000000000001200 +# EMPTY-NEXT: - Type: PT_TLS +# EMPTY-NEXT: Flags: [ PF_W, PF_R ] +# EMPTY-NEXT: FirstSec: .empty.tls.start +# EMPTY-NEXT: LastSec: .empty.tls.start +# EMPTY-NEXT: VAddr: 0x0000000000001000 +# EMPTY-NEXT: - Type: PT_TLS +# EMPTY-NEXT: Flags: [ PF_W, PF_R ] +# EMPTY-NEXT: FirstSec: .empty.tls.middle +# EMPTY-NEXT: LastSec: .empty.tls.middle +# EMPTY-NEXT: VAddr: 0x0000000000001100 +# EMPTY-NEXT: - Type: PT_TLS +# EMPTY-NEXT: Flags: [ PF_W, PF_R ] +# EMPTY-NEXT: FirstSec: .empty.tls.end +# EMPTY-NEXT: LastSec: .empty.tls.end +# EMPTY-NEXT: VAddr: 0x0000000000001200 # EMPTY-NEXT: Sections: --- !ELF @@ -273,34 +256,30 @@ Data: ELFDATA2LSB Type: ET_DYN ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .empty.tls.start - - Section: .section.1 - - Section: .empty.tls.middle - - Section: .section.2 - - Section: .empty.tls.end - VAddr: 0x1000 - Align: 0x1000 - - Type: PT_TLS - Flags: [ PF_W, PF_R ] - Sections: - - Section: .empty.tls.start - VAddr: 0x1000 - Align: 0x1 - - Type: PT_TLS - Flags: [ PF_W, PF_R ] - Sections: - - Section: .empty.tls.middle - VAddr: 0x1100 - Align: 0x1 - - Type: PT_TLS - Flags: [ PF_W, PF_R ] - Sections: - - Section: .empty.tls.end - VAddr: 0x1200 - Align: 0x1 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .empty.tls.start + LastSec: .empty.tls.end + VAddr: 0x1000 + Align: 0x1000 + - Type: PT_TLS + Flags: [ PF_W, PF_R ] + FirstSec: .empty.tls.start + LastSec: .empty.tls.start + VAddr: 0x1000 + Align: 0x1 + - Type: PT_TLS + Flags: [ PF_W, PF_R ] + FirstSec: .empty.tls.middle + LastSec: .empty.tls.middle + VAddr: 0x1100 + Align: 0x1 + - Type: PT_TLS + Flags: [ PF_W, PF_R ] + FirstSec: .empty.tls.end + LastSec: .empty.tls.end + VAddr: 0x1200 + Align: 0x1 Sections: - Name: .empty.tls.start Type: SHT_PROGBITS @@ -337,12 +316,12 @@ # MISALIGNED-READELF-NEXT: LOAD 0x000077 0x0000000000001000 0x0000000000001000 0x000078 0x000078 R 0x1000 # MISALIGNED-YAML: ProgramHeaders: -# MISALIGNED-YAML-NEXT: - Type: PT_LOAD -# MISALIGNED-YAML-NEXT: Flags: [ PF_R ] -# MISALIGNED-YAML-NEXT: Sections: -# MISALIGNED-YAML-NEXT: - Section: .foo -# MISALIGNED-YAML-NEXT: VAddr: 0x0000000000001000 -# MISALIGNED-YAML-NEXT: Align: 0x0000000000001000 +# MISALIGNED-YAML-NEXT: - Type: PT_LOAD +# MISALIGNED-YAML-NEXT: Flags: [ PF_R ] +# MISALIGNED-YAML-NEXT: FirstSec: .foo +# MISALIGNED-YAML-NEXT: LastSec: .foo +# MISALIGNED-YAML-NEXT: VAddr: 0x0000000000001000 +# MISALIGNED-YAML-NEXT: Align: 0x0000000000001000 # MISALIGNED-YAML-NEXT: Sections: --- !ELF @@ -351,13 +330,13 @@ Data: ELFDATA2LSB Type: ET_DYN ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .foo - VAddr: 0x1000 - Align: 0x1000 - Offset: 0x000077 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .foo + LastSec: .foo + VAddr: 0x1000 + Align: 0x1000 + Offset: 0x000077 Sections: - Name: .foo Type: SHT_PROGBITS @@ -371,13 +350,22 @@ # RUN: obj2yaml %t4 | FileCheck %s --check-prefix=NON-ALLOC # NON-ALLOC: ProgramHeaders: -# NON-ALLOC-NEXT: - Type: PT_LOAD -# NON-ALLOC-NEXT: Flags: [ PF_R ] -# NON-ALLOC-NEXT: Sections: -# NON-ALLOC-NEXT: - Section: .alloc.1 -# NON-ALLOC-NEXT: - Section: .non-alloc.1 -# NON-ALLOC-NEXT: - Section: .alloc.2 -# NON-ALLOC-NEXT: VAddr: 0x0000000000001000 +# NON-ALLOC-NEXT: - Type: PT_LOAD +# NON-ALLOC-NEXT: Flags: [ PF_R ] +# NON-ALLOC-NEXT: FirstSec: .alloc.1 +# NON-ALLOC-NEXT: LastSec: .non-alloc.1 +# NON-ALLOC-NEXT: - Type: PT_LOAD +# NON-ALLOC-NEXT: Flags: [ PF_R ] +# NON-ALLOC-NEXT: FirstSec: .alloc.1 +# NON-ALLOC-NEXT: LastSec: .non-alloc.1 +# NON-ALLOC-NEXT: - Type: PT_LOAD +# NON-ALLOC-NEXT: Flags: [ PF_R ] +# NON-ALLOC-NEXT: FirstSec: .alloc.2 +# NON-ALLOC-NEXT: LastSec: .alloc.2 +# NON-ALLOC-NEXT: - Type: PT_LOAD +# NON-ALLOC-NEXT: Flags: [ PF_R ] +# NON-ALLOC-NEXT: FirstSec: .alloc.1 +# NON-ALLOC-NEXT: LastSec: .alloc.2 # NON-ALLOC-NEXT: Sections: --- !ELF @@ -386,12 +374,22 @@ Data: ELFDATA2LSB Type: ET_DYN ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .alloc.1 - - Section: .alloc.2 - VAddr: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .alloc.1 + LastSec: .non-alloc.1 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .alloc.1 + LastSec: .non-alloc.2 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .non-alloc.2 + LastSec: .alloc.2 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .alloc.1 + LastSec: .alloc.2 Sections: - Name: .alloc.1 Type: SHT_PROGBITS @@ -416,31 +414,26 @@ # RUN: obj2yaml %t5 | FileCheck %s --check-prefix=NOBITS # NOBITS: ProgramHeaders: -# NOBITS-NEXT: - Type: PT_LOAD -# NOBITS-NEXT: Flags: [ PF_W, PF_R ] -# NOBITS-NEXT: Sections: -# NOBITS-NEXT: - Section: .bss -# NOBITS-NEXT: - Type: PT_LOAD -# NOBITS-NEXT: Flags: [ PF_W, PF_R ] -# NOBITS-NEXT: Sections: -# NOBITS-NEXT: - Section: .data.1 -# NOBITS-NEXT: - Section: .bss -# NOBITS-NEXT: - Type: PT_LOAD -# NOBITS-NEXT: Flags: [ PF_W, PF_R ] -# NOBITS-NEXT: Sections: -# NOBITS-NEXT: - Section: .data.1 -# NOBITS-NEXT: - Section: .bss -# NOBITS-NEXT: - Section: .data.2 -# NOBITS-NEXT: - Type: PT_LOAD -# NOBITS-NEXT: Flags: [ PF_W, PF_R ] -# NOBITS-NEXT: Sections: -# NOBITS-NEXT: - Section: .bss -# NOBITS-NEXT: - Section: .data.2 -# NOBITS-NEXT: - Type: PT_LOAD -# NOBITS-NEXT: Flags: [ PF_W, PF_R ] -# NOBITS-NEXT: Sections: -# NOBITS-NEXT: - Section: .foo.bss -# NOBITS-NEXT: - Section: .bar.bss +# NOBITS-NEXT: - Type: PT_LOAD +# NOBITS-NEXT: Flags: [ PF_W, PF_R ] +# NOBITS-NEXT: FirstSec: .bss +# NOBITS-NEXT: LastSec: .bss +# NOBITS-NEXT: - Type: PT_LOAD +# NOBITS-NEXT: Flags: [ PF_W, PF_R ] +# NOBITS-NEXT: FirstSec: .data.1 +# NOBITS-NEXT: LastSec: .bss +# NOBITS-NEXT: - Type: PT_LOAD +# NOBITS-NEXT: Flags: [ PF_W, PF_R ] +# NOBITS-NEXT: FirstSec: .data.1 +# NOBITS-NEXT: LastSec: .data.2 +# NOBITS-NEXT: - Type: PT_LOAD +# NOBITS-NEXT: Flags: [ PF_W, PF_R ] +# NOBITS-NEXT: FirstSec: .bss +# NOBITS-NEXT: LastSec: .data.2 +# NOBITS-NEXT: - Type: PT_LOAD +# NOBITS-NEXT: Flags: [ PF_W, PF_R ] +# NOBITS-NEXT: FirstSec: .foo.bss +# NOBITS-NEXT: LastSec: .bar.bss # NOBITS-NEXT: VAddr: 0x0000000200000000 # NOBITS-NEXT: Sections: @@ -451,36 +444,31 @@ Type: ET_EXEC ProgramHeaders: ## Case 1: the segment contains a single SHT_NOBITS section. - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .bss + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .bss + LastSec: .bss ## Case 2: the SHT_NOBITS section is the last section in the segment. - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .data.1 - - Section: .bss + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.1 + LastSec: .bss ## Case 3: the SHT_NOBITS section is in the middle of the segment. - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .data.1 - - Section: .bss - - Section: .data.2 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.1 + LastSec: .data.2 ## Case 4: the SHT_NOBITS section is the first section in the segment. - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .bss - - Section: .data.2 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .bss + LastSec: .data.2 ## Case 5: another two SHT_NOBITS sections in a different segment. - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .foo.bss - - Section: .bar.bss - VAddr: 0x200000000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .foo.bss + LastSec: .bar.bss + VAddr: 0x200000000 Sections: - Name: .data.1 Type: SHT_PROGBITS @@ -518,7 +506,7 @@ # RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | \ # RUN: FileCheck %s --check-prefix=UNSORTED --implicit-check-not="error:" -# UNSORTED: error: sections in the program header with index 1 are not sorted by their file offset +# UNSORTED: error: program header with index 0: the section index of .bar is greater than the index of .foo # UNSORTED-NEXT: error: sections in the program header with index 3 are not sorted by their file offset --- !ELF @@ -529,30 +517,27 @@ ProgramHeaders: ## Case 1: the .bar section is placed after the .foo section in the file. ## Check we report an error about the violation of the order. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .bar - - Section: .foo - VAddr: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .bar + LastSec: .foo + VAddr: 0x1000 ## There is nothing wrong with this segment. We have it to show that ## we report correct program header indices in error messages. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .foo - - Section: .bar - VAddr: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .foo + LastSec: .bar + VAddr: 0x1000 ## Case 2: the .bar section is placed before the .zed section in the file, ## but the sh_offset of .zed is less than the sh_offset of ## the .bar section because of the "ShOffset" property. ## Document we report an error for such a case. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .bar - - Section: .zed - VAddr: 0x1001 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .bar + LastSec: .zed + VAddr: 0x1001 Sections: - Name: .foo Type: SHT_PROGBITS @@ -591,13 +576,11 @@ # RUN: obj2yaml %t7 | FileCheck %s --check-prefix=ZERO-SIZE # ZERO-SIZE: ProgramHeaders: -# ZERO-SIZE-NEXT: - Type: PT_LOAD -# ZERO-SIZE-NEXT: Flags: [ PF_W, PF_R ] -# ZERO-SIZE-NEXT: Sections: -# ZERO-SIZE-NEXT: - Section: .empty.bar1 -# ZERO-SIZE-NEXT: - Section: .bar -# ZERO-SIZE-NEXT: - Section: .empty.bar2 -# ZERO-SIZE-NEXT: VAddr: 0x0000000000002000 +# ZERO-SIZE-NEXT: - Type: PT_LOAD +# ZERO-SIZE-NEXT: Flags: [ PF_W, PF_R ] +# ZERO-SIZE-NEXT: FirstSec: .empty.bar1 +# ZERO-SIZE-NEXT: LastSec: .empty.bar2 +# ZERO-SIZE-NEXT: VAddr: 0x0000000000002000 # ZERO-SIZE-NEXT: Sections: --- !ELF @@ -606,11 +589,11 @@ Data: ELFDATA2LSB Type: ET_EXEC ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - Sections: - - Section: .bar - VAddr: 0x2000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .bar + LastSec: .bar + VAddr: 0x2000 Sections: - Name: .empty.foo Type: SHT_PROGBITS @@ -642,11 +625,11 @@ # RUN: obj2yaml %t8 | FileCheck %s --check-prefix=BROKEN-VA # BROKEN-VA: ProgramHeaders: -# BROKEN-VA-NEXT: - Type: PT_LOAD -# BROKEN-VA-NEXT: Flags: [ PF_W, PF_R ] -# BROKEN-VA-NEXT: Sections: -# BROKEN-VA-NEXT: - Section: .empty_middle -# BROKEN-VA-NEXT: VAddr: 0x0000000000001000 +# BROKEN-VA-NEXT: - Type: PT_LOAD +# BROKEN-VA-NEXT: Flags: [ PF_W, PF_R ] +# BROKEN-VA-NEXT: FirstSec: .empty_middle +# BROKEN-VA-NEXT: LastSec: .empty_middle +# BROKEN-VA-NEXT: VAddr: 0x0000000000001000 --- !ELF FileHeader: @@ -654,13 +637,11 @@ Data: ELFDATA2LSB Type: ET_EXEC ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_W, PF_R ] - VAddr: 0x1000 - Sections: - - Section: .empty_begin - - Section: .empty_middle - - Section: .empty_end + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + VAddr: 0x1000 + FirstSec: .empty_begin + LastSec: .empty_end Sections: - Name: .empty_begin Type: SHT_PROGBITS Index: llvm/test/tools/yaml2obj/ELF/custom-fill.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/custom-fill.yaml +++ llvm/test/tools/yaml2obj/ELF/custom-fill.yaml @@ -119,16 +119,14 @@ Pattern: "" Size: 0x45 ProgramHeaders: - - Type: PT_LOAD - VAddr: 0x100 - Sections: - - Section: fill1 - - Section: .bar - - Section: fill2 - - Type: PT_GNU_RELRO - VAddr: 0x105 - Sections: - - Section: fill2 + - Type: PT_LOAD + VAddr: 0x100 + FirstSec: fill1 + LastSec: fill2 + - Type: PT_GNU_RELRO + VAddr: 0x105 + FirstSec: fill2 + LastSec: fill2 ## Check that the "Pattern" field is not mandatory. # RUN: yaml2obj --docnum=4 2>&1 -o %t4 %s @@ -269,7 +267,8 @@ ## an unknown section or fill and have at least one Fill defined. # RUN: not yaml2obj --docnum=10 2>&1 %s | FileCheck %s --check-prefix=UNKNOWN-ERR -# UNKNOWN-ERR: error: unknown section or fill referenced: 'fill' by program header +# UNKNOWN-ERR: error: unknown section or fill referenced: 'fill' by the 'FirstSec' key of the program header with index 0 +# UNKNOWN-ERR: error: unknown section or fill referenced: 'fill' by the 'LastSec' key of the program header with index 0 --- !ELF FileHeader: @@ -281,9 +280,9 @@ Pattern: "" Size: 0 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: fill + - Type: PT_LOAD + FirstSec: fill + LastSec: fill ## Show that we can use the "Offset" key to set an arbitrary offset for a Fill. Index: llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml +++ llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml @@ -27,14 +27,14 @@ - Tag: DT_NULL Value: 0x0000000000000000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0x0000 - Align: 8 - Sections: - - Section: .dynamic - - Type: PT_DYNAMIC - Flags: [ PF_X, PF_R ] - VAddr: 0x0008 - Sections: - - Section: .dynamic + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + Align: 8 + FirstSec: .dynamic + LastSec: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + FirstSec: .dynamic + LastSec: .dynamic Index: llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml +++ llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml @@ -20,10 +20,8 @@ Data: ELFDATA2LSB Type: ET_REL ProgramHeaders: - - Type: PT_LOAD - Sections: [] - - Type: PT_LOAD - Sections: [] + - Type: PT_LOAD + - Type: PT_LOAD ## Check we can override all default values using the same values ## and that this does not change the output. @@ -43,10 +41,8 @@ EPhEntSize: [[PHENTSIZE=56]] EPhNum: [[PHNUM=2]] ProgramHeaders: - - Type: PT_LOAD - Sections: [] - - Type: PT_LOAD - Sections: [] + - Type: PT_LOAD + - Type: PT_LOAD ## Override different fields to check the output produced. Index: llvm/test/tools/yaml2obj/ELF/program-header-address.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/program-header-address.yaml +++ llvm/test/tools/yaml2obj/ELF/program-header-address.yaml @@ -28,28 +28,27 @@ ProgramHeaders: ## Show what virtual and physical address we set by default for the case where ## a program header has no sections. - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - Sections: [] + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] ## Show what virtual and physical address we set by default for the case ## where a program header includes a section with a virtual address that ## is explicitly set. - Type: PT_LOAD Flags: [ PF_X, PF_R ] - Sections: - - Section: .foo + FirstSec: .foo + LastSec: .foo ## Now we have a program header that has a virtual address different to ## the address of the section included. Show that the default physical address ## is equal to the program header's virtual address. - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0xAAAA1000 - Sections: - - Section: .foo + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xAAAA1000 + FirstSec: .foo + LastSec: .foo ## Show that we are able to set different virtual and physical addresses. - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0xAAAA1000 - PAddr: 0xBBBB2000 - Sections: - - Section: .foo + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xAAAA1000 + PAddr: 0xBBBB2000 + FirstSec: .foo + LastSec: .foo Index: llvm/test/tools/yaml2obj/ELF/program-header-align.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/program-header-align.yaml +++ llvm/test/tools/yaml2obj/ELF/program-header-align.yaml @@ -25,9 +25,8 @@ ProgramHeaders: - Type: PT_TLS Align: 16 - Sections: - - Section: .tdata - - Section: .tbss + FirstSec: .tdata + LastSec: .tbss ## If Align is not specified, p_align is inferred from the maximum alignment ## of contained sections. @@ -48,7 +47,6 @@ Type: SHT_PROGBITS AddressAlign: 16 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .text - - Section: .text.hot + - Type: PT_LOAD + FirstSec: .text + LastSec: .text.hot Index: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml +++ llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml @@ -86,16 +86,14 @@ ## We have 2 segments, the first is predefined and the second can be customized. ## We want to have more than one segment to show we check all of them when ## trying to find a non-nobits section after a nobits one. - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .data.before - - Section: .nobits.1 - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: [[SEC1]] - - Section: [[SEC2]] + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .data.before + LastSec: .nobits.1 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: [[SEC1]] + LastSec: [[SEC2]] ## Case D. We have a segment with SHT_NOBITS sections on its borders and one ## non-nobits in the middle. Check we allocate the file space only for @@ -132,9 +130,7 @@ Flags: [ SHF_ALLOC ] Size: 0x100 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_R ] - Sections: - - Section: .nobits.1 - - Section: .data - - Section: .nobits.2 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .nobits.1 + LastSec: .nobits.2 Index: llvm/test/tools/yaml2obj/ELF/program-header-size-offset.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/program-header-size-offset.yaml +++ llvm/test/tools/yaml2obj/ELF/program-header-size-offset.yaml @@ -73,25 +73,25 @@ # Program header with only file size set. - Type: 0x6abcdef0 FileSize: 6 - Sections: - - Section: .rodata + FirstSec: .rodata + LastSec: .rodata # Program header with only mem size set. - Type: 0x6abcdef0 - MemSize: 6 - Sections: - - Section: .rodata + MemSize: 6 + FirstSec: .rodata + LastSec: .rodata # Program header with only offset set. - Type: 0x6abcdef0 Offset: 0x1fff - Sections: - - Section: .rodata + FirstSec: .rodata + LastSec: .rodata # Program header with sections, valid properties. - Type: 0x6abcdef0 Offset: 0xffe FileSize: 7 MemSize: 9 - Sections: - - Section: .text + FirstSec: .text + LastSec: .text # Program header with invalid properties. - Type: 0x6abcdef0 Offset: 0x3000 @@ -100,10 +100,8 @@ # Program header with 2 SHT_NOBITS sections. - Type: 0x6abcdef0 Offset: 0x2004 - Sections: - - Section: .data - - Section: .nobits1 - - Section: .nobits2 + FirstSec: .data + LastSec: .nobits2 ## Test the "Offset" property. @@ -137,13 +135,12 @@ Flags: [ SHF_ALLOC ] Size: 0x1 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .foo - - Section: .bar - - Type: PT_LOAD - Sections: - - Section: .bar + - Type: PT_LOAD + FirstSec: .foo + LastSec: .bar + - Type: PT_LOAD + FirstSec: .bar + LastSec: .bar ## Check we can set the "Offset" value explicitly to be less than or equal to ## the offset of a section in the segment. @@ -172,10 +169,10 @@ Flags: [ SHF_ALLOC ] Size: 0x1 ProgramHeaders: - - Type: PT_LOAD - Offset: [[OFFSET]] - Sections: - - Section: .foo + - Type: PT_LOAD + Offset: [[OFFSET]] + FirstSec: .foo + LastSec: .foo ## Check we report an error when the "Offset" value is larger than the offset of a section in the segment. # RUN: not yaml2obj --docnum=3 -DOFFSET=0x79 %s -o /dev/null 2>&1 | \ @@ -207,7 +204,7 @@ ## 0xFFFFFF00, but no error is reported. ShOffset: 0xFFFFFFFF ProgramHeaders: - - Type: PT_LOAD - Offset: 0xFFFFFF00 - Sections: - - Section: .foo + - Type: PT_LOAD + Offset: 0xFFFFFF00 + FirstSec: .foo + LastSec: .foo Index: llvm/test/tools/yaml2obj/ELF/program-header.yaml =================================================================== --- llvm/test/tools/yaml2obj/ELF/program-header.yaml +++ llvm/test/tools/yaml2obj/ELF/program-header.yaml @@ -23,19 +23,18 @@ Content: "00000000" AddressAlign: 0x0000000000001000 ProgramHeaders: - - Type: PT_LOAD - Flags: [ PF_X, PF_R ] - VAddr: 0xAAAA1000 - PAddr: 0xFFFF1000 - Sections: - - Section: .text - - Section: .init - - Type: PT_LOAD - Flags: [ PF_R ] - VAddr: 0xAAAA2000 - PAddr: 0xFFFF2000 - Sections: - - Section: .data + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xAAAA1000 + PAddr: 0xFFFF1000 + FirstSec: .text + LastSec: .init + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0xAAAA2000 + PAddr: 0xFFFF2000 + FirstSec: .data + LastSec: .data - Type: PT_GNU_EH_FRAME - Type: PT_GNU_STACK - Type: PT_GNU_RELRO @@ -82,18 +81,92 @@ #CHECK-NEXT:] ## Check we do not allow referencing sections that do not exist. -# RUN: not yaml2obj --docnum=2 %s -o %t 2>&1 | FileCheck %s --check-prefix=ERR +# RUN: not yaml2obj -DFIRST=".unknown1" -DLAST=".unknown2" --docnum=2 %s 2>&1 | \ +# RUN: FileCheck %s --check-prefix=UNKNOWN-ERR -# ERR: error: unknown section or fill referenced: '.foo' by program header -# ERR: error: unknown section or fill referenced: '.bar' by program header +# UNKNOWN-ERR: error: unknown section or fill referenced: '.unknown1' by the 'FirstSec' key of the program header with index 0 +# UNKNOWN-ERR: error: unknown section or fill referenced: '.unknown2' by the 'LastSec' key of the program header with index 0 --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC +Sections: + - Name: .foo + Type: SHT_PROGBITS + Offset: 0x100 + Size: 0x10 + - Name: .bar + Type: SHT_PROGBITS + Offset: 0x200 + Size: 0x20 + - Name: .zed + Type: SHT_PROGBITS + Offset: 0x300 + Size: 0x30 + - Name: .fill1 + Type: Fill + Offset: 0x400 + Size: 0x40 + - Name: .fill2 + Type: Fill + Offset: 0x500 + Size: 0x50 ProgramHeaders: - - Type: PT_LOAD - Sections: - - Section: .foo - - Section: .bar + - Type: PT_LOAD + FirstSec: [[FIRST=]] + LastSec: [[LAST=]] + +## Check we report an error when the index of the section specified by the "FirstSec" key +## is greater than the index of the section specified by the "LastSec" key. + +# RUN: not yaml2obj -DFIRST=".bar" -DLAST=".foo" --docnum=2 %s 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ORDER-ERR + +# ORDER-ERR: error: program header with index 0: the section index of .bar is greater than the index of .foo + +## Check that we can't use the "LastSec" key without the "FirstSec" key. + +# RUN: not yaml2obj -DLAST=".foo" --docnum=2 %s 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ONLY-LAST-ERR + +# ONLY-LAST-ERR: error: the "LastSec" key can't be used without the "FirstSec" key + +## Check that we can't use the "FirstSec" key without the "LastSec" key. + +# RUN: not yaml2obj -DFIRST=".foo" --docnum=2 %s 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ONLY-FIRST-ERR + +# ONLY-FIRST-ERR: error: the "FirstSec" key can't be used without the "LastSec" key + +## Check we create an empty segment when neither "FirstSec" nor "LastSec" are specified. + +# RUN: yaml2obj --docnum=2 %s -o %t3 +# RUN: llvm-readelf --program-headers %t3 | FileCheck %s --check-prefix=EMPTY-SEGMENT + +# EMPTY-SEGMENT: Type Offset VirtAddr PhysAddr FileSiz MemSiz +# EMPTY-SEGMENT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 +# EMPTY-SEGMENT-EMPTY: + +## Check that we include all sections between FirstSec and LastSec in the segment when both keys are used. + +# RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".zed" %s -o %t4 +# RUN: llvm-readelf --program-headers %t4 | FileCheck %s --check-prefix=BOTH + +# BOTH: Type Offset VirtAddr PhysAddr FileSiz MemSiz +# BOTH-NEXT: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000230 0x000230 + +## Check that we include fills that are between FirstSec and LastSec in the segment when both keys are used. + +# RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".fill1" %s -o %t5a +# RUN: llvm-readelf --program-headers %t5a | FileCheck %s --check-prefix=FILL1 + +# FILL1: Type Offset VirtAddr PhysAddr FileSiz MemSiz +# FILL1: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000340 0x000340 + +# RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".fill2" %s -o %t5b +# RUN: llvm-readelf --program-headers %t5b | FileCheck %s --check-prefix=FILL2 + +# FILL2: Type Offset VirtAddr PhysAddr FileSiz MemSiz +# FILL2: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000450 0x000450 Index: llvm/tools/obj2yaml/elf2yaml.cpp =================================================================== --- llvm/tools/obj2yaml/elf2yaml.cpp +++ llvm/tools/obj2yaml/elf2yaml.cpp @@ -391,8 +391,11 @@ // obj2yaml does not create Fill chunks. for (const std::unique_ptr &C : Chunks) { ELFYAML::Section &S = cast(*C.get()); - if (isInSegment(S, Sections[S.OriginalSecNdx], Phdr)) - PH.Sections.push_back({S.Name}); + if (isInSegment(S, Sections[S.OriginalSecNdx], Phdr)) { + if (!PH.FirstSec) + PH.FirstSec = S.Name; + PH.LastSec = S.Name; + } } Ret.push_back(PH);