Index: lib/ObjectYAML/ELFEmitter.cpp =================================================================== --- lib/ObjectYAML/ELFEmitter.cpp +++ lib/ObjectYAML/ELFEmitter.cpp @@ -114,6 +114,14 @@ NameToIdxMap DynSymN2I; ELFYAML::Object &Doc; + bool HasError = false; + + std::vector toELFSymbols(ArrayRef Symbols, + const StringTableBuilder &Strtab); + unsigned toSectionIndex(StringRef S, StringRef LocSec, StringRef LocSym = ""); + unsigned toSymbolIndex(StringRef S, StringRef LocSec, bool IsDynamic); + void reportError(const Twine &Msg); + bool buildSectionIndex(); bool buildSymbolIndexes(); void initELFHeader(Elf_Ehdr &Header); @@ -132,34 +140,33 @@ void setProgramHeaderLayout(std::vector &PHeaders, std::vector &SHeaders); void finalizeStrings(); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::RawContentSection &Section, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::RelocationSection &Section, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Group, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Group, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::SymtabShndxSection &Shndx, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::SymverSection &Section, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::VerneedSection &Section, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::VerdefSection &Section, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::MipsABIFlags &Section, ContiguousBlobAccumulator &CBA); - bool writeSectionContent(Elf_Shdr &SHeader, + void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::DynamicSection &Section, ContiguousBlobAccumulator &CBA); ELFState(ELFYAML::Object &D); - public: static int writeELF(raw_ostream &OS, ELFYAML::Object &Doc); }; @@ -252,14 +259,34 @@ } } -static bool convertSectionIndex(NameToIdxMap &SN2I, StringRef SecName, - StringRef IndexSrc, unsigned &IndexDest) { - if (!SN2I.lookup(IndexSrc, IndexDest) && !to_integer(IndexSrc, IndexDest)) { - WithColor::error() << "Unknown section referenced: '" << IndexSrc - << "' at YAML section '" << SecName << "'.\n"; - return false; +template +unsigned ELFState::toSectionIndex(StringRef S, StringRef LocSec, + StringRef LocSym) { + unsigned Index; + if (SN2I.lookup(S, Index) || to_integer(S, Index)) + return Index; + + assert(LocSec.empty() || LocSym.empty()); + if (!LocSym.empty()) + reportError("unknown section referenced: '" + S + "' by YAML symbol " + + LocSym); + else + reportError("unknown section referenced: '" + S + "' at YAML section '" + + LocSec + "'"); + return 0; +} + +template +unsigned ELFState::toSymbolIndex(StringRef S, StringRef LocSec, + bool IsDynamic) { + const NameToIdxMap &SymMap = IsDynamic ? DynSymN2I : SymN2I; + unsigned Index; + if (!SymMap.lookup(S, Index) && !to_integer(S, Index)) { + reportError("unknown symbol referenced: '" + S + "' at YAML section '" + + LocSec + "'"); + return 0; } - return true; + return Index; } template @@ -310,7 +337,7 @@ // valid SHN_UNDEF entry since SHT_NULL == 0. SHeaders.resize(Doc.Sections.size()); - for (size_t I = 0; I < Doc.Sections.size(); ++I) { + for (size_t I = 0; I < Doc.Sections.size() && !HasError; ++I) { ELFYAML::Section *Sec = Doc.Sections[I].get(); if (I == 0 && Sec->IsImplicit) continue; @@ -334,12 +361,8 @@ SHeader.sh_addr = Sec->Address; SHeader.sh_addralign = Sec->AddressAlign; - if (!Sec->Link.empty()) { - unsigned Index; - if (!convertSectionIndex(SN2I, Sec->Name, Sec->Link, Index)) - return false; - SHeader.sh_link = Index; - } + if (!Sec->Link.empty()) + SHeader.sh_link = toSectionIndex(Sec->Link, Sec->Name); if (I == 0) { if (auto RawSec = dyn_cast(Sec)) { @@ -352,20 +375,15 @@ if (Sec->EntSize) SHeader.sh_entsize = *Sec->EntSize; } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { SHeader.sh_entsize = 0; SHeader.sh_size = S->Size; @@ -373,19 +391,16 @@ // so just to setup the section offset. CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast(Sec)) { - if (!writeSectionContent(SHeader, *S, CBA)) - return false; - } else + writeSectionContent(SHeader, *S, CBA); + } else { llvm_unreachable("Unknown section type"); + } // Override the fields if requested. if (Sec) { @@ -398,7 +413,7 @@ } } - return true; + return !HasError; } static size_t findFirstNonGlobal(ArrayRef Symbols) { @@ -424,11 +439,9 @@ } template -static std::vector -toELFSymbols(NameToIdxMap &SN2I, ArrayRef Symbols, - const StringTableBuilder &Strtab) { - using Elf_Sym = typename ELFT::Sym; - +std::vector +ELFState::toELFSymbols(ArrayRef Symbols, + const StringTableBuilder &Strtab) { std::vector Ret; Ret.resize(Symbols.size() + 1); @@ -445,18 +458,11 @@ Symbol.st_name = Strtab.getOffset(dropUniqueSuffix(Sym.Name)); Symbol.setBindingAndType(Sym.Binding, Sym.Type); - if (!Sym.Section.empty()) { - unsigned Index; - if (!SN2I.lookup(Sym.Section, Index)) { - WithColor::error() << "Unknown section referenced: '" << Sym.Section - << "' by YAML symbol " << Sym.Name << ".\n"; - exit(1); - } - Symbol.st_shndx = Index; - } else if (Sym.Index) { + if (!Sym.Section.empty()) + Symbol.st_shndx = toSectionIndex(Sym.Section, "", Sym.Name); + else if (Sym.Index) Symbol.st_shndx = *Sym.Index; - } - // else Symbol.st_shndex == SHN_UNDEF (== 0), since it was zero'd earlier. + Symbol.st_value = Sym.Value; Symbol.st_other = Sym.Other ? *Sym.Other : 0; Symbol.st_size = Sym.Size; @@ -478,18 +484,14 @@ dyn_cast_or_null(YAMLSec); if (RawSec && !Symbols.empty() && (RawSec->Content || RawSec->Size)) { if (RawSec->Content) - WithColor::error() << "Cannot specify both `Content` and " + - (IsStatic ? Twine("`Symbols`") - : Twine("`DynamicSymbols`")) + - " for symbol table section '" - << RawSec->Name << "'.\n"; + reportError("cannot specify both `Content` and " + + (IsStatic ? Twine("`Symbols`") : Twine("`DynamicSymbols`")) + + " for symbol table section '" + RawSec->Name + "'"); if (RawSec->Size) - WithColor::error() << "Cannot specify both `Size` and " + - (IsStatic ? Twine("`Symbols`") - : Twine("`DynamicSymbols`")) + - " for symbol table section '" - << RawSec->Name << "'.\n"; - exit(1); + reportError("cannot specify both `Size` and " + + (IsStatic ? Twine("`Symbols`") : Twine("`DynamicSymbols`")) + + " for symbol table section '" + RawSec->Name + "'"); + return; } zero(SHeader); @@ -503,10 +505,7 @@ if (RawSec && !RawSec->Link.empty()) { // If the Link field is explicitly defined in the document, // we should use it. - unsigned Index; - if (!convertSectionIndex(SN2I, RawSec->Name, RawSec->Link, Index)) - return; - SHeader.sh_link = Index; + SHeader.sh_link = toSectionIndex(RawSec->Link, RawSec->Name); } else { // When we describe the .dynsym section in the document explicitly, it is // allowed to omit the "DynamicSymbols" tag. In this case .dynstr is not @@ -543,7 +542,7 @@ } std::vector Syms = - toELFSymbols(SN2I, Symbols, IsStatic ? DotStrtab : DotDynstr); + toELFSymbols(Symbols, IsStatic ? DotStrtab : DotDynstr); writeArrayData(OS, makeArrayRef(Syms)); SHeader.sh_size = arrayDataSize(makeArrayRef(Syms)); } @@ -586,6 +585,11 @@ SHeader.sh_addr = YAMLSec->Address; } +template void ELFState::reportError(const Twine &Msg) { + WithColor::error() << Msg << "\n"; + HasError = true; +} + template void ELFState::setProgramHeaderLayout(std::vector &PHeaders, std::vector &SHeaders) { @@ -597,9 +601,9 @@ for (const ELFYAML::SectionName &SecName : YamlPhdr.Sections) { unsigned Index; if (!SN2I.lookup(SecName.Section, Index)) { - WithColor::error() << "Unknown section referenced: '" << SecName.Section - << "' by program header.\n"; - exit(1); + reportError("unknown section referenced: '" + SecName.Section + + "' by program header"); + return; } Sections.push_back(&SHeaders[Index]); } @@ -662,7 +666,7 @@ } template -bool ELFState::writeSectionContent( +void ELFState::writeSectionContent( Elf_Shdr &SHeader, const ELFYAML::RawContentSection &Section, ContiguousBlobAccumulator &CBA) { raw_ostream &OS = @@ -678,8 +682,6 @@ if (Section.Info) SHeader.sh_info = *Section.Info; - - return true; } static bool isMips64EL(const ELFYAML::Object &Doc) { @@ -689,7 +691,7 @@ } template -bool ELFState::writeSectionContent( +void ELFState::writeSectionContent( Elf_Shdr &SHeader, const ELFYAML::RelocationSection &Section, ContiguousBlobAccumulator &CBA) { assert((Section.Type == llvm::ELF::SHT_REL || @@ -704,26 +706,14 @@ if (Section.Link.empty()) SHeader.sh_link = SN2I.get(".symtab"); - unsigned Index = 0; - if (!Section.RelocatableSec.empty() && - !convertSectionIndex(SN2I, Section.Name, Section.RelocatableSec, Index)) - return false; - SHeader.sh_info = Index; + if (!Section.RelocatableSec.empty()) + SHeader.sh_info = toSectionIndex(Section.RelocatableSec, Section.Name); auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); - - const NameToIdxMap &SymMap = Section.Link == ".dynsym" ? DynSymN2I : SymN2I; for (const auto &Rel : Section.Relocations) { - unsigned SymIdx = 0; - // If a relocation references a symbol, try to look one up in the symbol - // table. If it is not there, treat the value as a symbol index. - if (Rel.Symbol && !SymMap.lookup(*Rel.Symbol, SymIdx) && - !to_integer(*Rel.Symbol, SymIdx)) { - WithColor::error() << "Unknown symbol referenced: '" << *Rel.Symbol - << "' at YAML section '" << Section.Name << "'.\n"; - return false; - } - + unsigned SymIdx = Rel.Symbol ? toSymbolIndex(*Rel.Symbol, Section.Name, + Section.Link == ".dynsym") + : 0; if (IsRela) { Elf_Rela REntry; zero(REntry); @@ -739,11 +729,10 @@ OS.write((const char *)&REntry, sizeof(REntry)); } } - return true; } template -bool ELFState::writeSectionContent( +void ELFState::writeSectionContent( Elf_Shdr &SHeader, const ELFYAML::SymtabShndxSection &Shndx, ContiguousBlobAccumulator &CBA) { raw_ostream &OS = @@ -754,11 +743,10 @@ SHeader.sh_entsize = Shndx.EntSize ? (uint64_t)*Shndx.EntSize : 4; SHeader.sh_size = Shndx.Entries.size() * SHeader.sh_entsize; - return true; } template -bool ELFState::writeSectionContent(Elf_Shdr &SHeader, +void ELFState::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Section, ContiguousBlobAccumulator &CBA) { assert(Section.Type == llvm::ELF::SHT_GROUP && @@ -766,15 +754,8 @@ SHeader.sh_entsize = 4; SHeader.sh_size = SHeader.sh_entsize * Section.Members.size(); - - unsigned SymIdx; - if (!SymN2I.lookup(Section.Signature, SymIdx) && - !to_integer(Section.Signature, SymIdx)) { - WithColor::error() << "Unknown symbol referenced: '" << Section.Signature - << "' at YAML section '" << Section.Name << "'.\n"; - return false; - } - SHeader.sh_info = SymIdx; + SHeader.sh_info = + toSymbolIndex(Section.Signature, Section.Name, /*IsDynamic=*/false); raw_ostream &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); @@ -783,16 +764,14 @@ unsigned int SectionIndex = 0; if (Member.sectionNameOrType == "GRP_COMDAT") SectionIndex = llvm::ELF::GRP_COMDAT; - else if (!convertSectionIndex(SN2I, Section.Name, Member.sectionNameOrType, - SectionIndex)) - return false; + else + SectionIndex = toSectionIndex(Member.sectionNameOrType, Section.Name); support::endian::write(OS, SectionIndex, ELFT::TargetEndianness); } - return true; } template -bool ELFState::writeSectionContent(Elf_Shdr &SHeader, +void ELFState::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::SymverSection &Section, ContiguousBlobAccumulator &CBA) { raw_ostream &OS = @@ -802,11 +781,10 @@ SHeader.sh_entsize = Section.EntSize ? (uint64_t)*Section.EntSize : 2; SHeader.sh_size = Section.Entries.size() * SHeader.sh_entsize; - return true; } template -bool ELFState::writeSectionContent(Elf_Shdr &SHeader, +void ELFState::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::VerdefSection &Section, ContiguousBlobAccumulator &CBA) { typedef typename ELFT::Verdef Elf_Verdef; @@ -846,12 +824,10 @@ SHeader.sh_size = Section.Entries.size() * sizeof(Elf_Verdef) + AuxCnt * sizeof(Elf_Verdaux); SHeader.sh_info = Section.Info; - - return true; } template -bool ELFState::writeSectionContent(Elf_Shdr &SHeader, +void ELFState::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::VerneedSection &Section, ContiguousBlobAccumulator &CBA) { typedef typename ELFT::Verneed Elf_Verneed; @@ -894,12 +870,10 @@ SHeader.sh_size = Section.VerneedV.size() * sizeof(Elf_Verneed) + AuxCnt * sizeof(Elf_Vernaux); SHeader.sh_info = Section.Info; - - return true; } template -bool ELFState::writeSectionContent(Elf_Shdr &SHeader, +void ELFState::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::MipsABIFlags &Section, ContiguousBlobAccumulator &CBA) { assert(Section.Type == llvm::ELF::SHT_MIPS_ABIFLAGS && @@ -923,12 +897,10 @@ Flags.flags1 = Section.Flags1; Flags.flags2 = Section.Flags2; OS.write((const char *)&Flags, sizeof(Flags)); - - return true; } template -bool ELFState::writeSectionContent(Elf_Shdr &SHeader, +void ELFState::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::DynamicSection &Section, ContiguousBlobAccumulator &CBA) { typedef typename ELFT::uint uintX_t; @@ -936,13 +908,10 @@ assert(Section.Type == llvm::ELF::SHT_DYNAMIC && "Section type is not SHT_DYNAMIC"); - if (!Section.Entries.empty() && Section.Content) { - WithColor::error() - << "Cannot specify both raw content and explicit entries " - "for dynamic section '" - << Section.Name << "'.\n"; - return false; - } + if (!Section.Entries.empty() && Section.Content) + reportError("cannot specify both raw content and explicit entries " + "for dynamic section '" + + Section.Name + "'"); if (Section.Content) SHeader.sh_size = Section.Content->binary_size(); @@ -961,8 +930,6 @@ } if (Section.Content) Section.Content->writeAsBinary(OS); - - return true; } template bool ELFState::buildSectionIndex() { @@ -973,8 +940,8 @@ DotShStrtab.add(dropUniqueSuffix(Name)); if (!SN2I.addName(Name, I)) { - WithColor::error() << "Repeated section name: '" << Name - << "' at YAML section number " << I << ".\n"; + reportError("repeated section name: '" + Name + + "' at YAML section number " + Twine(I)); return false; } } @@ -983,20 +950,19 @@ return true; } -static bool buildSymbolsMap(ArrayRef V, NameToIdxMap &Map) { - for (size_t I = 0, S = V.size(); I < S; ++I) { - const ELFYAML::Symbol &Sym = V[I]; - if (Sym.Name.empty() || Map.addName(Sym.Name, I + 1)) - continue; - WithColor::error() << "Repeated symbol name: '" << Sym.Name << "'.\n"; - return false; - } - return true; -} - template bool ELFState::buildSymbolIndexes() { - return buildSymbolsMap(Doc.Symbols, SymN2I) && - buildSymbolsMap(Doc.DynamicSymbols, DynSymN2I); + auto Build = [this](ArrayRef V, NameToIdxMap &Map) { + for (size_t I = 0, S = V.size(); I < S; ++I) { + const ELFYAML::Symbol &Sym = V[I]; + if (Sym.Name.empty() || Map.addName(Sym.Name, I + 1)) + continue; + reportError("repeated symbol name: '" + Sym.Name + "'"); + return false; + } + return true; + }; + + return Build(Doc.Symbols, SymN2I) && Build(Doc.DynamicSymbols, DynSymN2I); } template void ELFState::finalizeStrings() { @@ -1061,6 +1027,8 @@ // Now we can decide segment offsets State.setProgramHeaderLayout(PHeaders, SHeaders); + if (State.HasError) + return 1; OS.write((const char *)&Header, sizeof(Header)); writeArrayData(OS, makeArrayRef(PHeaders)); Index: test/tools/yaml2obj/duplicate-section-names.test =================================================================== --- test/tools/yaml2obj/duplicate-section-names.test +++ test/tools/yaml2obj/duplicate-section-names.test @@ -29,7 +29,7 @@ ## sections with equal names and suffixes. # RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=CASE2 -# CASE2: error: Repeated section name: '.foo [1]' at YAML section number 2. +# CASE2: error: repeated section name: '.foo [1]' at YAML section number 2 --- !ELF FileHeader: @@ -48,7 +48,7 @@ ## names are equal. # RUN: not yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=CASE3 -# CASE3: error: Repeated section name: '.foo' at YAML section number 2. +# CASE3: error: repeated section name: '.foo' at YAML section number 2 --- !ELF FileHeader: Index: test/tools/yaml2obj/duplicate-symbol-names.test =================================================================== --- test/tools/yaml2obj/duplicate-symbol-names.test +++ test/tools/yaml2obj/duplicate-symbol-names.test @@ -21,7 +21,7 @@ ## symbols with equal names and suffixes. # RUN: not yaml2obj --docnum=2 %s 2>&1| FileCheck %s --check-prefix=CASE2 -# CASE2: error: Repeated symbol name: 'localfoo [1]'. +# CASE2: error: repeated symbol name: 'localfoo [1]' --- !ELF FileHeader: @@ -38,7 +38,7 @@ ## names are equal. # RUN: not yaml2obj --docnum=3 %s 2>&1| FileCheck %s --check-prefix=CASE3 -# CASE3: error: Repeated symbol name: 'localfoo'. +# CASE3: error: repeated symbol name: 'localfoo' --- !ELF FileHeader: Index: test/tools/yaml2obj/dynamic-section-raw-content.yaml =================================================================== --- test/tools/yaml2obj/dynamic-section-raw-content.yaml +++ test/tools/yaml2obj/dynamic-section-raw-content.yaml @@ -16,7 +16,7 @@ # RAW-NEXT: 0x00000000 01234567 89012345 67890000 00000000 {{.*}} # RUN: not yaml2obj --docnum=2 %s -o %t2 2>&1 | FileCheck %s --check-prefix=ERR -# ERR: Cannot specify both raw content and explicit entries for dynamic section '.dynamic'. +# ERR: cannot specify both raw content and explicit entries for dynamic section '.dynamic' --- !ELF FileHeader: Index: test/tools/yaml2obj/dynamic-symbols.yaml =================================================================== --- test/tools/yaml2obj/dynamic-symbols.yaml +++ test/tools/yaml2obj/dynamic-symbols.yaml @@ -1,9 +1,10 @@ -# Ensures that implicitly added sections can be ordered within Sections. -# RUN: yaml2obj %s -o %t -# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=SECTION +## Ensures that implicitly added sections can be ordered within Sections. + +# RUN: yaml2obj --docnum=1 %s -o %t1 +# RUN: llvm-readobj --sections %t1 | FileCheck %s --check-prefix=SECTION # RUN: llvm-nm --dynamic %t | FileCheck %s --check-prefix=SYMBOL -!ELF +--- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB @@ -39,3 +40,35 @@ # SYMBOL-DAG: d dynlocal # SYMBOL-DAG: D dynglobal # SYMBOL-DAG: V dynweak + +## Check we can use numeric values to refer to sections. + +# RUN: yaml2obj --docnum=2 %s -o %t2 +# RUN: not llvm-readobj --dyn-symbols %t2 2>&1 | FileCheck -DFILE=%t2 %s --check-prefix=NUM + +# NUM: Name: foo +# NUM: Section: +# NUM-SAME: .data (0x1) + +# NUM: Name: bar +# NUM: Section: +# NUM-SAME: .symtab (0x2) + +# NUM: error: '[[FILE]]': invalid section index: 255 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .data + Type: SHT_PROGBITS +DynamicSymbols: + - Name: foo + Section: 1 + - Name: bar + Section: 2 + - Name: zed + Section: 0xff Index: test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml =================================================================== --- test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml +++ test/tools/yaml2obj/dynsymtab-implicit-sections-size-content.yaml @@ -30,7 +30,7 @@ ## Specifying both `Size` and symbols at the same time is not allowed. # RUN: not yaml2obj --docnum=2 %s -o %t2 2>&1 | FileCheck %s --check-prefix=CASE2 -# CASE2: error: Cannot specify both `Size` and `DynamicSymbols` for symbol table section '.dynsym'. +# CASE2: error: cannot specify both `Size` and `DynamicSymbols` for symbol table section '.dynsym' --- !ELF FileHeader: @@ -49,7 +49,7 @@ ## Specifying both `Content` and symbols at the same time is not allowed. # RUN: not yaml2obj --docnum=3 %s -o %t3 2>&1 | FileCheck %s --check-prefix=CASE3 -# CASE3: error: Cannot specify both `Content` and `DynamicSymbols` for symbol table section '.dynsym'. +# CASE3: error: cannot specify both `Content` and `DynamicSymbols` for symbol table section '.dynsym' --- !ELF FileHeader: Index: test/tools/yaml2obj/elf-custom-null-section.yaml =================================================================== --- test/tools/yaml2obj/elf-custom-null-section.yaml +++ test/tools/yaml2obj/elf-custom-null-section.yaml @@ -130,7 +130,7 @@ # RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | FileCheck %s --check-prefix=CASE4 -# CASE4: error: Unknown section referenced: '.foo' at YAML section ''. +# CASE4: error: unknown section referenced: '.foo' at YAML section '' --- !ELF FileHeader: Index: test/tools/yaml2obj/program-header.yaml =================================================================== --- test/tools/yaml2obj/program-header.yaml +++ test/tools/yaml2obj/program-header.yaml @@ -68,7 +68,7 @@ ## 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 -# ERR: error: Unknown section referenced: '.foo' by program header. +# ERR: error: unknown section referenced: '.foo' by program header --- !ELF FileHeader: Index: test/tools/yaml2obj/relocation-missing-symbol.yaml =================================================================== --- test/tools/yaml2obj/relocation-missing-symbol.yaml +++ test/tools/yaml2obj/relocation-missing-symbol.yaml @@ -1,9 +1,12 @@ -# Show that yaml2obj rejects a symbol reference from a relocation if the symbol -# does not exist. +## Show that yaml2obj rejects a symbol reference from a relocation if the symbol +## does not exist. # RUN: not yaml2obj %s -o %t 2>&1 | FileCheck %s -# CHECK: Unknown symbol referenced: 'does_not_exist' at YAML section '.rela.text' +## Check we are able to report multiple errors. + +# CHECK: error: unknown symbol referenced: 'does_not_exist1' at YAML section '.rela.text' +# CHECK: error: unknown symbol referenced: 'does_not_exist2' at YAML section '.rela.text' --- !ELF FileHeader: @@ -21,4 +24,7 @@ Relocations: - Type: R_X86_64_PC32 Offset: 0 - Symbol: does_not_exist + Symbol: does_not_exist1 + - Type: R_X86_64_PC32 + Offset: 0 + Symbol: does_not_exist2 Index: test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml =================================================================== --- test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml +++ test/tools/yaml2obj/symtab-implicit-sections-size-content.yaml @@ -28,7 +28,7 @@ ## Specifying both `Size` and symbols at the same time is not allowed. # RUN: not yaml2obj --docnum=2 %s -o %t2 2>&1 | FileCheck %s --check-prefix=CASE2 -# CASE2: error: Cannot specify both `Size` and `Symbols` for symbol table section '.symtab'. +# CASE2: error: cannot specify both `Size` and `Symbols` for symbol table section '.symtab' --- !ELF FileHeader: @@ -46,7 +46,7 @@ ## Specifying both `Content` and symbols at the same time is not allowed. # RUN: not yaml2obj --docnum=3 %s -o %t3 2>&1 | FileCheck %s --check-prefix=CASE3 -# CASE3: error: Cannot specify both `Content` and `Symbols` for symbol table section '.symtab'. +# CASE3: error: cannot specify both `Content` and `Symbols` for symbol table section '.symtab' --- !ELF FileHeader: