|
@@ -19,6 +19,7 @@
|
|
|
#include "llvm/Object/ELFObjectFile.h"
|
|
|
#include "llvm/ObjectYAML/ELFYAML.h"
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
+#include "llvm/Support/WithColor.h"
|
|
|
#include "llvm/Support/YAMLTraits.h"
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
@@ -243,8 +244,8 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
|
|
|
if (!Sec->Link.empty()) {
|
|
|
unsigned Index;
|
|
|
if (SN2I.lookup(Sec->Link, Index)) {
|
|
|
- errs() << "error: Unknown section referenced: '" << Sec->Link
|
|
|
- << "' at YAML section '" << Sec->Name << "'.\n";
|
|
|
+ WithColor::error() << "Unknown section referenced: '" << Sec->Link
|
|
|
+ << "' at YAML section '" << Sec->Name << "'.\n";
|
|
|
return false;
|
|
|
}
|
|
|
SHeader.sh_link = Index;
|
|
@@ -260,8 +261,8 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
|
|
|
unsigned Index;
|
|
|
if (SN2I.lookup(S->Info, Index)) {
|
|
|
if (S->Info.getAsInteger(0, Index)) {
|
|
|
- errs() << "error: Unknown section referenced: '" << S->Info
|
|
|
- << "' at YAML section '" << S->Name << "'.\n";
|
|
|
+ WithColor::error() << "Unknown section referenced: '" << S->Info
|
|
|
+ << "' at YAML section '" << S->Name << "'.\n";
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -272,8 +273,8 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
|
|
|
} else if (auto S = dyn_cast<ELFYAML::Group>(Sec.get())) {
|
|
|
unsigned SymIdx;
|
|
|
if (SymN2I.lookup(S->Info, SymIdx)) {
|
|
|
- errs() << "error: Unknown symbol referenced: '" << S->Info
|
|
|
- << "' at YAML section '" << S->Name << "'.\n";
|
|
|
+ WithColor::error() << "Unknown symbol referenced: '" << S->Info
|
|
|
+ << "' at YAML section '" << S->Name << "'.\n";
|
|
|
return false;
|
|
|
}
|
|
|
SHeader.sh_info = SymIdx;
|
|
@@ -430,8 +431,8 @@ void ELFState<ELFT>::addSymbols(const std::vector<ELFYAML::Symbol> &Symbols,
|
|
|
if (!Sym.Section.empty()) {
|
|
|
unsigned Index;
|
|
|
if (SN2I.lookup(Sym.Section, Index)) {
|
|
|
- errs() << "error: Unknown section referenced: '" << Sym.Section
|
|
|
- << "' by YAML symbol " << Sym.Name << ".\n";
|
|
|
+ WithColor::error() << "Unknown section referenced: '" << Sym.Section
|
|
|
+ << "' by YAML symbol " << Sym.Name << ".\n";
|
|
|
exit(1);
|
|
|
}
|
|
|
Symbol.st_shndx = Index;
|
|
@@ -528,9 +529,9 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
|
|
|
if (member.sectionNameOrType == "GRP_COMDAT")
|
|
|
sectionIndex = llvm::ELF::GRP_COMDAT;
|
|
|
else if (SN2I.lookup(member.sectionNameOrType, sectionIndex)) {
|
|
|
- errs() << "error: Unknown section referenced: '"
|
|
|
- << member.sectionNameOrType << "' at YAML section' "
|
|
|
- << Section.Name << "\n";
|
|
|
+ WithColor::error() << "Unknown section referenced: '"
|
|
|
+ << member.sectionNameOrType << "' at YAML section' "
|
|
|
+ << Section.Name << "\n";
|
|
|
return false;
|
|
|
}
|
|
|
SIdx = sectionIndex;
|
|
@@ -574,8 +575,8 @@ template <class ELFT> bool ELFState<ELFT>::buildSectionIndex() {
|
|
|
DotShStrtab.add(Name);
|
|
|
// "+ 1" to take into account the SHT_NULL entry.
|
|
|
if (SN2I.addName(Name, i + 1)) {
|
|
|
- errs() << "error: Repeated section name: '" << Name
|
|
|
- << "' at YAML section number " << i << ".\n";
|
|
|
+ WithColor::error() << "Repeated section name: '" << Name
|
|
|
+ << "' at YAML section number " << i << ".\n";
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -602,7 +603,7 @@ ELFState<ELFT>::buildSymbolIndex(std::size_t &StartIndex,
|
|
|
if (Sym.Name.empty())
|
|
|
continue;
|
|
|
if (SymN2I.addName(Sym.Name, StartIndex)) {
|
|
|
- errs() << "error: Repeated symbol name: '" << Sym.Name << "'.\n";
|
|
|
+ WithColor::error() << "Repeated symbol name: '" << Sym.Name << "'.\n";
|
|
|
return false;
|
|
|
}
|
|
|
}
|