const uint64_t ObjSize = Obj->getMemoryBufferRef().getBufferSize();
if (Size > ObjSize - Offset) {
- Dumper->reportUniqueWarning(createError(
+ Dumper->reportUniqueWarning(
"unable to read data at 0x" + Twine::utohexstr(Offset) +
" of size 0x" + Twine::utohexstr(Size) + " (" + SizePrintName +
"): it goes past the end of the file of size 0x" +
- Twine::utohexstr(ObjSize)));
+ Twine::utohexstr(ObjSize));
return {Start, Start};
}
(" or " + EntSizePrintName + " (0x" + Twine::utohexstr(EntSize) + ")")
.str();
- Dumper->reportUniqueWarning(createError(Msg.c_str()));
+ Dumper->reportUniqueWarning(Msg);
return {Start, Start};
}
};
}
if (SymTabOrErr->first.size() != VersionsOrErr->size())
- reportUniqueWarning(
- createError(describe(Sec) + ": the number of entries (" +
- Twine(VersionsOrErr->size()) +
- ") does not match the number of symbols (" +
- Twine(SymTabOrErr->first.size()) +
- ") in the symbol table with index " + Twine(Sec.sh_link)));
+ reportUniqueWarning(describe(Sec) + ": the number of entries (" +
+ Twine(VersionsOrErr->size()) +
+ ") does not match the number of symbols (" +
+ Twine(SymTabOrErr->first.size()) +
+ ") in the symbol table with index " +
+ Twine(Sec.sh_link));
if (SymTab)
std::tie(*SymTab, *StrTab) = *SymTabOrErr;
Obj.getStringTableForSymtab(*DotSymtabSec))
StrTable = *StrTableOrErr;
else
- reportUniqueWarning(createError(
+ reportUniqueWarning(
"unable to get the string table for the SHT_SYMTAB section: " +
- toString(StrTableOrErr.takeError())));
+ toString(StrTableOrErr.takeError()));
if (Expected<Elf_Sym_Range> SymsOrErr = Obj.symbols(DotSymtabSec))
Syms = *SymsOrErr;
else
reportUniqueWarning(
- createError("unable to read symbols from the SHT_SYMTAB section: " +
- toString(SymsOrErr.takeError())));
+ "unable to read symbols from the SHT_SYMTAB section: " +
+ toString(SymsOrErr.takeError()));
Entries = DotSymtabSec->getEntityCount();
}
if (Syms.begin() == Syms.end())
virtual void printMipsABIFlags() = 0;
const ELFDumper<ELFT> &dumper() const { return Dumper; }
void reportUniqueWarning(Error Err) const;
+ void reportUniqueWarning(const Twine &Msg) const;
protected:
std::vector<GroupSection> getGroups();
this->dumper().reportUniqueWarning(std::move(Err));
}
+template <class ELFT>
+void DumpStyle<ELFT>::reportUniqueWarning(const Twine &Msg) const {
+ this->dumper().reportUniqueWarning(Msg);
+}
+
template <typename ELFT> class LLVMStyle : public DumpStyle<ELFT> {
public:
TYPEDEF_ELF_TYPES(ELFT)
template <typename ELFT>
std::string ELFDumper<ELFT>::getStaticSymbolName(uint32_t Index) const {
auto Warn = [&](Error E) -> std::string {
- this->reportUniqueWarning(
- createError("unable to read the name of symbol with index " +
- Twine(Index) + ": " + toString(std::move(E))));
+ this->reportUniqueWarning("unable to read the name of symbol with index " +
+ Twine(Index) + ": " + toString(std::move(E)));
return "<?>";
};
break;
}
} else {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
"unable to read program headers to locate the PT_DYNAMIC segment: " +
- toString(PhdrsOrErr.takeError())));
+ toString(PhdrsOrErr.takeError()));
}
// Try to locate the .dynamic section in the sections header table.
ObjF.getMemoryBufferRef().getBufferSize()) ||
(DynamicPhdr->p_offset + DynamicPhdr->p_filesz <
DynamicPhdr->p_offset))) {
- reportUniqueWarning(createError(
+ reportUniqueWarning(
"PT_DYNAMIC segment offset (0x" +
Twine::utohexstr(DynamicPhdr->p_offset) + ") + file size (0x" +
Twine::utohexstr(DynamicPhdr->p_filesz) +
") exceeds the size of the file (0x" +
- Twine::utohexstr(ObjF.getMemoryBufferRef().getBufferSize()) + ")"));
+ Twine::utohexstr(ObjF.getMemoryBufferRef().getBufferSize()) + ")");
// Don't use the broken dynamic header.
DynamicPhdr = nullptr;
}
if (DynamicSec->sh_addr + DynamicSec->sh_size >
DynamicPhdr->p_vaddr + DynamicPhdr->p_memsz ||
DynamicSec->sh_addr < DynamicPhdr->p_vaddr)
- reportUniqueWarning(createError(describe(*DynamicSec) +
- " is not contained within the "
- "PT_DYNAMIC segment"));
+ reportUniqueWarning(describe(*DynamicSec) +
+ " is not contained within the "
+ "PT_DYNAMIC segment");
if (DynamicSec->sh_addr != DynamicPhdr->p_vaddr)
- reportUniqueWarning(createError(describe(*DynamicSec) +
- " is not at the start of "
- "PT_DYNAMIC segment"));
+ reportUniqueWarning(describe(*DynamicSec) + " is not at the start of "
+ "PT_DYNAMIC segment");
}
return std::make_pair(DynamicPhdr, DynamicSec);
FromSec.EntSizePrintName = "";
IsSecTableValid = !FromSec.getAsArrayRef<Elf_Dyn>().empty();
} else {
- reportUniqueWarning(createError("unable to read the dynamic table from " +
- describe(*DynamicSec) + ": " +
- toString(RegOrErr.takeError())));
+ reportUniqueWarning("unable to read the dynamic table from " +
+ describe(*DynamicSec) + ": " +
+ toString(RegOrErr.takeError()));
}
}
DynamicTable = DynamicPhdr ? FromPhdr : FromSec;
parseDynamicTable();
} else {
- reportUniqueWarning(createError("no valid dynamic table was found"));
+ reportUniqueWarning("no valid dynamic table was found");
}
return;
}
// verify that.
if (FromPhdr.Addr != FromSec.Addr)
- reportUniqueWarning(createError("SHT_DYNAMIC section header and PT_DYNAMIC "
- "program header disagree about "
- "the location of the dynamic table"));
+ reportUniqueWarning("SHT_DYNAMIC section header and PT_DYNAMIC "
+ "program header disagree about "
+ "the location of the dynamic table");
if (!IsPhdrTableValid && !IsSecTableValid) {
- reportUniqueWarning(createError("no valid dynamic table was found"));
+ reportUniqueWarning("no valid dynamic table was found");
return;
}
- // Information in the PT_DYNAMIC program header has priority over the information
- // in a section header.
+ // Information in the PT_DYNAMIC program header has priority over the
+ // information in a section header.
if (IsPhdrTableValid) {
if (!IsSecTableValid)
- reportUniqueWarning(createError(
- "SHT_DYNAMIC dynamic table is invalid: PT_DYNAMIC will be used"));
+ reportUniqueWarning(
+ "SHT_DYNAMIC dynamic table is invalid: PT_DYNAMIC will be used");
DynamicTable = FromPhdr;
} else {
- reportUniqueWarning(createError(
- "PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used"));
+ reportUniqueWarning(
+ "PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used");
DynamicTable = FromSec;
}
else
reportWarning(E.takeError(), ObjF.getFileName());
} else {
- reportUniqueWarning(createError(
- "unable to read dynamic symbols from " + describe(Sec) + ": " +
- toString(RegOrErr.takeError())));
+ reportUniqueWarning("unable to read dynamic symbols from " +
+ describe(Sec) + ": " +
+ toString(RegOrErr.takeError()));
}
}
break;
else if (Dyn.getVal() == DT_RELA)
DynPLTRelRegion.EntSize = sizeof(Elf_Rela);
else
- reportUniqueWarning(createError(Twine("unknown DT_PLTREL value of ") +
- Twine((uint64_t)Dyn.getVal())));
+ reportUniqueWarning(Twine("unknown DT_PLTREL value of ") +
+ Twine((uint64_t)Dyn.getVal()));
DynPLTRelRegion.EntSizePrintName = "PLTREL entry size";
break;
case ELF::DT_JMPREL:
const uint64_t FileSize = Obj.getBufSize();
const uint64_t Offset = (const uint8_t *)StringTableBegin - Obj.base();
if (StringTableSize > FileSize - Offset)
- reportUniqueWarning(createError(
+ reportUniqueWarning(
"the dynamic string table at 0x" + Twine::utohexstr(Offset) +
" goes past the end of the file (0x" + Twine::utohexstr(FileSize) +
- ") with DT_STRSZ = 0x" + Twine::utohexstr(StringTableSize)));
+ ") with DT_STRSZ = 0x" + Twine::utohexstr(StringTableSize));
else
DynamicStringTable = StringRef(StringTableBegin, StringTableSize);
}
// according to the section header.
if (HashTable && IsHashTableSupported) {
if (DynSymRegion->EntSize == 0)
- reportUniqueWarning(
- createError("SHT_DYNSYM section has sh_entsize == 0"));
+ reportUniqueWarning("SHT_DYNSYM section has sh_entsize == 0");
else if (HashTable->nchain != DynSymRegion->Size / DynSymRegion->EntSize)
- reportUniqueWarning(createError(
+ reportUniqueWarning(
"hash table nchain (" + Twine(HashTable->nchain) +
") differs from symbol count derived from SHT_DYNSYM section "
"header (" +
- Twine(DynSymRegion->Size / DynSymRegion->EntSize) + ")"));
+ Twine(DynSymRegion->Size / DynSymRegion->EntSize) + ")");
}
}
(uint64_t)HashTable->nchain * DynSymRegion->EntSize;
const uint64_t Offset = (const uint8_t *)DynSymRegion->Addr - Obj.base();
if (DerivedSize > FileSize - Offset)
- reportUniqueWarning(createError(
+ reportUniqueWarning(
"the size (0x" + Twine::utohexstr(DerivedSize) +
") of the dynamic symbol table at 0x" + Twine::utohexstr(Offset) +
", derived from the hash table, goes past the end of the file (0x" +
- Twine::utohexstr(FileSize) + ") and will be ignored"));
+ Twine::utohexstr(FileSize) + ") and will be ignored");
else
DynSymRegion->Size = HashTable->nchain * DynSymRegion->EntSize;
}
if (*NameOrErr == Name)
return &Shdr;
} else {
- reportUniqueWarning(createError("unable to read the name of " +
- describe(Shdr) + ": " +
- toString(NameOrErr.takeError())));
+ reportUniqueWarning("unable to read the name of " + describe(Shdr) +
+ ": " + toString(NameOrErr.takeError()));
}
}
return nullptr;
template <class ELFT>
StringRef ELFDumper<ELFT>::getDynamicString(uint64_t Value) const {
if (DynamicStringTable.empty() && !DynamicStringTable.data()) {
- reportUniqueWarning(createError("string table was not found"));
+ reportUniqueWarning("string table was not found");
return "<?>";
}
auto WarnAndReturn = [this](const Twine &Msg, uint64_t Offset) {
- reportUniqueWarning(createError("string table at offset 0x" +
- Twine::utohexstr(Offset) + Msg));
+ reportUniqueWarning("string table at offset 0x" + Twine::utohexstr(Offset) +
+ Msg);
return "<?>";
};
Expected<ArrayRef<Elf_Word>> Chains =
getGnuHashTableChains<ELFT>(DynSymRegion, GnuHashTable);
if (!Chains) {
- reportUniqueWarning(
- createError("unable to dump 'Values' for the SHT_GNU_HASH "
- "section: " +
- toString(Chains.takeError())));
+ reportUniqueWarning("unable to dump 'Values' for the SHT_GNU_HASH "
+ "section: " +
+ toString(Chains.takeError()));
return;
}
Expected<ArrayRef<uint8_t>> ContentsOrErr =
Obj.getSectionContents(*RegInfoSec);
if (!ContentsOrErr) {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
"unable to read the content of the .reginfo section (" +
- describe(*RegInfoSec) + "): " + toString(ContentsOrErr.takeError())));
+ describe(*RegInfoSec) + "): " + toString(ContentsOrErr.takeError()));
return;
}
if (ContentsOrErr->size() < sizeof(Elf_Mips_RegInfo<ELFT>)) {
- this->reportUniqueWarning(
- createError("the .reginfo section has an invalid size (0x" +
- Twine::utohexstr(ContentsOrErr->size()) + ")"));
+ this->reportUniqueWarning("the .reginfo section has an invalid size (0x" +
+ Twine::utohexstr(ContentsOrErr->size()) + ")");
return;
}
return;
auto Warn = [&](Error &&E) {
- this->reportUniqueWarning(createError("unable to read the stack map from " +
- describe(*StackMapSection) + ": " +
- toString(std::move(E))));
+ this->reportUniqueWarning("unable to read the stack map from " +
+ describe(*StackMapSection) + ": " +
+ toString(std::move(E)));
};
Expected<ArrayRef<uint8_t>> ContentOrErr =
const Elf_Shdr &Symtab) -> StringRef {
Expected<StringRef> StrTableOrErr = Obj.getStringTableForSymtab(Symtab);
if (!StrTableOrErr) {
- reportUniqueWarning(createError("unable to get the string table for " +
- describe(Obj, Symtab) + ": " +
- toString(StrTableOrErr.takeError())));
+ reportUniqueWarning("unable to get the string table for " +
+ describe(Obj, Symtab) + ": " +
+ toString(StrTableOrErr.takeError()));
return "<?>";
}
StringRef Strings = *StrTableOrErr;
if (Sym.st_name >= Strings.size()) {
- reportUniqueWarning(createError(
- "unable to get the name of the symbol with index " + Twine(SymNdx) +
- ": st_name (0x" + Twine::utohexstr(Sym.st_name) +
- ") is past the end of the string table of size 0x" +
- Twine::utohexstr(Strings.size())));
+ reportUniqueWarning("unable to get the name of the symbol with index " +
+ Twine(SymNdx) + ": st_name (0x" +
+ Twine::utohexstr(Sym.st_name) +
+ ") is past the end of the string table of size 0x" +
+ Twine::utohexstr(Strings.size()));
return "<?>";
}
Obj.template getEntry<Elf_Sym>(**SymtabOrErr, Sec.sh_info))
Signature = GetSignature(**SymOrErr, Sec.sh_info, **SymtabOrErr);
else
- reportUniqueWarning(createError(
- "unable to get the signature symbol for " + describe(Obj, Sec) +
- ": " + toString(SymOrErr.takeError())));
+ reportUniqueWarning("unable to get the signature symbol for " +
+ describe(Obj, Sec) + ": " +
+ toString(SymOrErr.takeError()));
} else {
- reportUniqueWarning(createError("unable to get the symbol table for " +
- describe(Obj, Sec) + ": " +
- toString(SymtabOrErr.takeError())));
+ reportUniqueWarning("unable to get the symbol table for " +
+ describe(Obj, Sec) + ": " +
+ toString(SymtabOrErr.takeError()));
}
ArrayRef<Elf_Word> Data;
if (Expected<ArrayRef<Elf_Word>> ContentsOrErr =
Obj.template getSectionContentsAsArray<Elf_Word>(Sec)) {
if (ContentsOrErr->empty())
- reportUniqueWarning(
- createError("unable to read the section group flag from the " +
- describe(Obj, Sec) + ": the section is empty"));
+ reportUniqueWarning("unable to read the section group flag from the " +
+ describe(Obj, Sec) + ": the section is empty");
else
Data = *ContentsOrErr;
} else {
- reportUniqueWarning(createError("unable to get the content of the " +
- describe(Obj, Sec) + ": " +
- toString(ContentsOrErr.takeError())));
+ reportUniqueWarning("unable to get the content of the " +
+ describe(Obj, Sec) + ": " +
+ toString(ContentsOrErr.takeError()));
}
Ret.push_back({getPrintableSectionName(Sec),
if (Expected<const Elf_Shdr *> SecOrErr = Obj.getSection(Ndx)) {
GM.push_back({getPrintableSectionName(**SecOrErr), Ndx});
} else {
- reportUniqueWarning(
- createError("unable to get the section with index " + Twine(Ndx) +
- " when dumping the " + describe(Obj, Sec) + ": " +
- toString(SecOrErr.takeError())));
+ reportUniqueWarning("unable to get the section with index " +
+ Twine(Ndx) + " when dumping the " +
+ describe(Obj, Sec) + ": " +
+ toString(SecOrErr.takeError()));
GM.push_back({"<?>", Ndx});
}
}
const GroupSection *MainGroup = Map[GM.Index];
if (MainGroup != &G)
this->reportUniqueWarning(
- createError("section with index " + Twine(GM.Index) +
- ", included in the group section with index " +
- Twine(MainGroup->Index) +
- ", was also found in the group section with index " +
- Twine(G.Index)));
+ "section with index " + Twine(GM.Index) +
+ ", included in the group section with index " +
+ Twine(MainGroup->Index) +
+ ", was also found in the group section with index " +
+ Twine(G.Index));
OS << " [" << format_decimal(GM.Index, 5) << "] " << GM.Name << "\n";
}
}
Expected<RelSymbol<ELFT>> Target =
this->dumper().getRelocationTarget(R, SymTab);
if (!Target)
- this->reportUniqueWarning(createError(
- "unable to print relocation " + Twine(RelIndex) + " in " +
- describe(this->Obj, Sec) + ": " + toString(Target.takeError())));
+ this->reportUniqueWarning("unable to print relocation " + Twine(RelIndex) +
+ " in " + describe(this->Obj, Sec) + ": " +
+ toString(Target.takeError()));
else
printRelRelaReloc(R, *Target);
}
if (Expected<size_t> NumOrErr = GetEntriesNum(Sec))
EntriesNum = std::to_string(*NumOrErr);
else
- this->reportUniqueWarning(createError(
- "unable to get the number of relocations in " +
- describe(this->Obj, Sec) + ": " + toString(NumOrErr.takeError())));
+ this->reportUniqueWarning("unable to get the number of relocations in " +
+ describe(this->Obj, Sec) + ": " +
+ toString(NumOrErr.takeError()));
uintX_t Offset = Sec.sh_offset;
StringRef Name = this->getPrintableSectionName(Sec);
if (!FirstSym) {
Optional<DynRegionInfo> DynSymRegion = this->dumper().getDynSymRegion();
this->reportUniqueWarning(
- createError(Twine("unable to print symbols for the .hash table: the "
- "dynamic symbol table ") +
- (DynSymRegion ? "is empty" : "was not found")));
+ Twine("unable to print symbols for the .hash table: the "
+ "dynamic symbol table ") +
+ (DynSymRegion ? "is empty" : "was not found"));
return;
}
const Elf_Sym *FirstSym = DynSyms.empty() ? nullptr : &DynSyms[0];
Optional<DynRegionInfo> DynSymRegion = this->dumper().getDynSymRegion();
if (!FirstSym) {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
Twine("unable to print symbols for the .gnu.hash table: the "
"dynamic symbol table ") +
- (DynSymRegion ? "is empty" : "was not found")));
+ (DynSymRegion ? "is empty" : "was not found"));
return;
}
auto GetSymbol = [&](uint64_t SymIndex,
uint64_t SymsTotal) -> const Elf_Sym * {
if (SymIndex >= SymsTotal) {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
"unable to print hashed symbol with index " + Twine(SymIndex) +
", which is greater than or equal to the number of dynamic symbols "
"(" +
- Twine::utohexstr(SymsTotal) + ")"));
+ Twine::utohexstr(SymsTotal) + ")");
return nullptr;
}
return FirstSym + SymIndex;
getGnuHashTableChains<ELFT>(DynSymRegion, &GnuHash);
ArrayRef<Elf_Word> Values;
if (!ValuesOrErr)
- this->reportUniqueWarning(
- createError("unable to get hash values for the SHT_GNU_HASH "
- "section: " +
- toString(ValuesOrErr.takeError())));
+ this->reportUniqueWarning("unable to get hash values for the SHT_GNU_HASH "
+ "section: " +
+ toString(ValuesOrErr.takeError()));
else
Values = *ValuesOrErr;
break;
if (SymIndex < GnuHash.symndx) {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
"unable to read the hash value for symbol with index " +
Twine(SymIndex) +
", which is less than the index of the first hashed symbol (" +
- Twine(GnuHash.symndx) + ")"));
+ Twine(GnuHash.symndx) + ")");
break;
}
Expected<ArrayRef<Elf_Phdr>> PhdrsOrErr = this->Obj.program_headers();
if (!PhdrsOrErr) {
- this->reportUniqueWarning(createError("unable to dump program headers: " +
- toString(PhdrsOrErr.takeError())));
+ this->reportUniqueWarning("unable to dump program headers: " +
+ toString(PhdrsOrErr.takeError()));
return;
}
Expected<ArrayRef<Elf_Phdr>> PhdrsOrErr = this->Obj.program_headers();
if (!PhdrsOrErr) {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
"can't read program headers to build section to segment mapping: " +
- toString(PhdrsOrErr.takeError())));
+ toString(PhdrsOrErr.takeError()));
return;
}
this->Obj.getSection(Sec.sh_link))
LinkedSecName = this->getPrintableSectionName(**LinkedSecOrErr);
else
- this->reportUniqueWarning(
- createError("invalid section linked to " + describe(this->Obj, Sec) +
- ": " + toString(LinkedSecOrErr.takeError())));
+ this->reportUniqueWarning("invalid section linked to " +
+ describe(this->Obj, Sec) + ": " +
+ toString(LinkedSecOrErr.takeError()));
OS << " Addr: " << format_hex_no_prefix(Sec.sh_addr, 16)
<< " Offset: " << format_hex(Sec.sh_offset, 8)
Expected<StringRef> NameOrErr =
this->dumper().getSymbolVersionByIndex(Ndx, IsDefault);
if (!NameOrErr) {
- this->reportUniqueWarning(createError(
- "unable to get a version for entry " + Twine(I) + " of " +
- describe(this->Obj, *Sec) + ": " + toString(NameOrErr.takeError())));
+ this->reportUniqueWarning("unable to get a version for entry " +
+ Twine(I) + " of " + describe(this->Obj, *Sec) +
+ ": " + toString(NameOrErr.takeError()));
Versions.emplace_back("<corrupt>");
continue;
}
Expected<ArrayRef<Elf_Word>> ChainsOrErr = getGnuHashTableChains<ELFT>(
this->dumper().getDynSymRegion(), &GnuHashTable);
if (!ChainsOrErr) {
- this->reportUniqueWarning(
- createError("unable to print the GNU hash table histogram: " +
- toString(ChainsOrErr.takeError())));
+ this->reportUniqueWarning("unable to print the GNU hash table histogram: " +
+ toString(ChainsOrErr.takeError()));
return;
}
for (const typename ELFT::Note Note : Obj.notes(S, Err))
ProcessNoteFn(Note);
if (Err)
- Dumper.reportUniqueWarning(
- createError("unable to read notes from the " + describe(Obj, S) +
- ": " + toString(std::move(Err))));
+ Dumper.reportUniqueWarning("unable to read notes from the " +
+ describe(Obj, S) + ": " +
+ toString(std::move(Err)));
FinishNotesFn();
}
return;
Expected<ArrayRef<typename ELFT::Phdr>> PhdrsOrErr = Obj.program_headers();
if (!PhdrsOrErr) {
- Dumper.reportUniqueWarning(createError(
+ Dumper.reportUniqueWarning(
"unable to read program headers to locate the PT_NOTE segment: " +
- toString(PhdrsOrErr.takeError())));
+ toString(PhdrsOrErr.takeError()));
return;
}
for (const typename ELFT::Note Note : Obj.notes(P, Err))
ProcessNoteFn(Note);
if (Err)
- Dumper.reportUniqueWarning(createError(
+ Dumper.reportUniqueWarning(
"unable to read notes from the PT_NOTE segment with index " +
- Twine(I) + ": " + toString(std::move(Err))));
+ Twine(I) + ": " + toString(std::move(Err)));
FinishNotesFn();
}
}
function_ref<void(const Elf_Shdr &)> OnSectionStart,
function_ref<void(StringRef, uint64_t)> OnLibEntry) {
auto Warn = [this](unsigned SecNdx, StringRef Msg) {
- this->reportUniqueWarning(
- createError("SHT_LLVM_DEPENDENT_LIBRARIES section at index " +
- Twine(SecNdx) + " is broken: " + Msg));
+ this->reportUniqueWarning("SHT_LLVM_DEPENDENT_LIBRARIES section at index " +
+ Twine(SecNdx) + " is broken: " + Msg);
};
unsigned I = -1;
llvm::function_ref<void(const Elf_Relr &)> RelrFn) {
auto Warn = [&](Error &&E,
const Twine &Prefix = "unable to read relocations from") {
- this->reportUniqueWarning(createError(Prefix + " " + describe(Obj, Sec) +
- ": " + toString(std::move(E))));
+ this->reportUniqueWarning(Prefix + " " + describe(Obj, Sec) + ": " +
+ toString(std::move(E)));
};
// SHT_RELR/SHT_ANDROID_RELR sections do not have an associated symbol table.
Obj.getSectionName(Sec, this->dumper().WarningHandler))
Name = *SecNameOrErr;
else
- this->reportUniqueWarning(createError("unable to get the name of " +
- describe(Obj, Sec) + ": " +
- toString(SecNameOrErr.takeError())));
+ this->reportUniqueWarning("unable to get the name of " +
+ describe(Obj, Sec) + ": " +
+ toString(SecNameOrErr.takeError()));
return Name;
}
Expected<RelSymbol<ELFT>> TargetOrErr =
this->dumper().getRelocationTarget(R, SymTab);
if (!TargetOrErr)
- reportUniqueWarning(
- createError("unable to get the target of relocation with index " +
- Twine(Ndx) + " in " + describe(Obj, RelocSec) + ": " +
- toString(TargetOrErr.takeError())));
+ reportUniqueWarning("unable to get the target of relocation with index " +
+ Twine(Ndx) + " in " + describe(Obj, RelocSec) + ": " +
+ toString(TargetOrErr.takeError()));
else
Sym = TargetOrErr->Sym;
Expected<const Elf_Shdr *> SectionOrErr =
this->Obj.getSection(*Sym, SymTab, this->dumper().getShndxTable());
if (!SectionOrErr) {
- reportUniqueWarning(createError(
+ reportUniqueWarning(
"cannot identify the section for relocation symbol '" +
- (*TargetOrErr).Name + "': " + toString(SectionOrErr.takeError())));
+ (*TargetOrErr).Name + "': " + toString(SectionOrErr.takeError()));
} else if (*SectionOrErr != FunctionSec) {
- reportUniqueWarning(createError("relocation symbol '" +
- (*TargetOrErr).Name +
- "' is not in the expected section"));
+ reportUniqueWarning("relocation symbol '" + (*TargetOrErr).Name +
+ "' is not in the expected section");
// Pretend that the symbol is in the correct section and report its
// stack size anyway.
FunctionSec = *SectionOrErr;
uint64_t Offset = R.Offset;
if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1)) {
- reportUniqueWarning(createStringError(
- object_error::parse_failed,
- "found invalid relocation offset (0x" + Twine::utohexstr(Offset) +
- ") into " + describe(Obj, StackSizeSec) +
- " while trying to extract a stack size entry"));
+ reportUniqueWarning("found invalid relocation offset (0x" +
+ Twine::utohexstr(Offset) + ") into " +
+ describe(Obj, StackSizeSec) +
+ " while trying to extract a stack size entry");
return;
}
// The function address is followed by a ULEB representing the stack
// size. Check for an extra byte before we try to process the entry.
if (!Data.isValidOffsetForDataOfSize(Offset, sizeof(Elf_Addr) + 1)) {
- reportUniqueWarning(createStringError(
- object_error::parse_failed,
+ reportUniqueWarning(
describe(Obj, Sec) +
- " ended while trying to extract a stack size entry"));
+ " ended while trying to extract a stack size entry");
break;
}
uint64_t SymValue = Data.getAddress(&Offset);
Expected<const Elf_Shdr *> RelSecOrErr = Obj.getSection(Sec.sh_info);
if (!RelSecOrErr) {
- reportUniqueWarning(createStringError(
- object_error::parse_failed,
- describe(Obj, Sec) + ": failed to get a relocated section: " +
- toString(RelSecOrErr.takeError())));
+ reportUniqueWarning(describe(Obj, Sec) +
+ ": failed to get a relocated section: " +
+ toString(RelSecOrErr.takeError()));
continue;
}
[&](const Relocation<ELFT> &R, unsigned Ndx, const Elf_Shdr &Sec,
const Elf_Shdr *SymTab) {
if (!IsSupportedFn || !IsSupportedFn(R.Type)) {
- reportUniqueWarning(createStringError(
- object_error::parse_failed,
+ reportUniqueWarning(
describe(Obj, *RelocSec) +
- " contains an unsupported relocation with index " +
- Twine(Ndx) + ": " + Obj.getRelocationTypeName(R.Type)));
+ " contains an unsupported relocation with index " + Twine(Ndx) +
+ ": " + Obj.getRelocationTypeName(R.Type));
return;
}
const GroupSection *MainGroup = Map[GM.Index];
if (MainGroup != &G)
this->reportUniqueWarning(
- createError("section with index " + Twine(GM.Index) +
- ", included in the group section with index " +
- Twine(MainGroup->Index) +
- ", was also found in the group section with index " +
- Twine(G.Index)));
+ "section with index " + Twine(GM.Index) +
+ ", included in the group section with index " +
+ Twine(MainGroup->Index) +
+ ", was also found in the group section with index " +
+ Twine(G.Index));
W.startLine() << GM.Name << " (" << GM.Index << ")\n";
}
}
Expected<RelSymbol<ELFT>> Target =
this->dumper().getRelocationTarget(R, SymTab);
if (!Target) {
- this->reportUniqueWarning(createError(
- "unable to print relocation " + Twine(RelIndex) + " in " +
- describe(this->Obj, Sec) + ": " + toString(Target.takeError())));
+ this->reportUniqueWarning("unable to print relocation " + Twine(RelIndex) +
+ " in " + describe(this->Obj, Sec) + ": " +
+ toString(Target.takeError()));
return;
}
Expected<ArrayRef<Elf_Phdr>> PhdrsOrErr = this->Obj.program_headers();
if (!PhdrsOrErr) {
- this->reportUniqueWarning(createError("unable to dump program headers: " +
- toString(PhdrsOrErr.takeError())));
+ this->reportUniqueWarning("unable to dump program headers: " +
+ toString(PhdrsOrErr.takeError()));
return;
}
*this->dumper().getDotCGProfileSec());
if (!CGProfileOrErr) {
this->reportUniqueWarning(
- createError("unable to dump the SHT_LLVM_CALL_GRAPH_PROFILE section: " +
- toString(CGProfileOrErr.takeError())));
+ "unable to dump the SHT_LLVM_CALL_GRAPH_PROFILE section: " +
+ toString(CGProfileOrErr.takeError()));
return;
}
Expected<ArrayRef<uint8_t>> ContentsOrErr =
this->Obj.getSectionContents(Shdr);
if (!ContentsOrErr) {
- this->reportUniqueWarning(
- createError("unable to read the content of the "
- "SHT_LLVM_LINKER_OPTIONS section: " +
- toString(ContentsOrErr.takeError())));
+ this->reportUniqueWarning("unable to read the content of the "
+ "SHT_LLVM_LINKER_OPTIONS section: " +
+ toString(ContentsOrErr.takeError()));
continue;
}
if (ContentsOrErr->empty())
continue;
if (ContentsOrErr->back() != 0) {
- this->reportUniqueWarning(
- createError("SHT_LLVM_LINKER_OPTIONS section at index " + Twine(I) +
- " is broken: the "
- "content is not null-terminated"));
+ this->reportUniqueWarning("SHT_LLVM_LINKER_OPTIONS section at index " +
+ Twine(I) +
+ " is broken: the "
+ "content is not null-terminated");
continue;
}
SmallVector<StringRef, 16> Strings;
toStringRef(ContentsOrErr->drop_back()).split(Strings, '\0');
if (Strings.size() % 2 != 0) {
- this->reportUniqueWarning(createError(
+ this->reportUniqueWarning(
"SHT_LLVM_LINKER_OPTIONS section at index " + Twine(I) +
" is broken: an incomplete "
"key-value pair was found. The last possible key was: \"" +
- Strings.back() + "\""));
+ Strings.back() + "\"");
continue;
}