C->Name = StringRef(NewName).copy(StringAlloc);
assert(ELFYAML::dropUniqueSuffix(C->Name).empty());
}
- DocSections.insert(C->Name);
+
+ if (!DocSections.insert(C->Name).second)
+ reportError("repeated section/fill name: '" + C->Name +
+ "' at YAML section/fill number " + Twine(I));
}
std::vector<StringRef> ImplicitSections;
template <class ELFT> void ELFState<ELFT>::buildSectionIndex() {
size_t SecNdx = -1;
- StringSet<> Seen;
- for (size_t I = 0; I < Doc.Chunks.size(); ++I) {
- const std::unique_ptr<ELFYAML::Chunk> &C = Doc.Chunks[I];
- bool IsSection = isa<ELFYAML::Section>(C.get());
- if (IsSection)
- ++SecNdx;
-
- if (!Seen.insert(C->Name).second)
- reportError("repeated section/fill name: '" + C->Name +
- "' at YAML section/fill number " + Twine(I));
- if (!IsSection || HasError)
+ for (const std::unique_ptr<ELFYAML::Chunk> &C : Doc.Chunks) {
+ if (!isa<ELFYAML::Section>(C.get()))
continue;
+ ++SecNdx;
if (!SN2I.addName(C->Name, SecNdx))
llvm_unreachable("buildSectionIndex() failed");
bool ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc,
yaml::ErrorHandler EH) {
ELFState<ELFT> State(Doc, EH);
+ if (State.HasError)
+ return false;
// Finalize .strtab and .dynstr sections. We do that early because want to
// finalize the string table builders before writing the content of the
State.finalizeStrings();
State.buildSectionIndex();
- if (State.HasError)
- return false;
-
State.buildSymbolIndexes();
std::vector<Elf_Phdr> PHeaders;