uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
uint64_t getRelocationType(DataRefImpl Rel) const override;
- std::error_code
- getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const override;
+ void getRelocationTypeName(DataRefImpl Rel,
+ SmallVectorImpl<char> &Result) const override;
+
public:
COFFObjectFile(MemoryBufferRef Object, std::error_code &EC);
basic_symbol_iterator symbol_begin_impl() const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
uint64_t getRelocationType(DataRefImpl Rel) const override;
- std::error_code
- getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const override;
+ void getRelocationTypeName(DataRefImpl Rel,
+ SmallVectorImpl<char> &Result) const override;
uint32_t getSectionType(DataRefImpl Sec) const override;
uint64_t getSectionFlags(DataRefImpl Sec) const override;
}
template <class ELFT>
-std::error_code ELFObjectFile<ELFT>::getRelocationTypeName(
+void ELFObjectFile<ELFT>::getRelocationTypeName(
DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
- const Elf_Shdr *sec = getRelSection(Rel);
- uint32_t type;
- if (sec->sh_type == ELF::SHT_REL)
- type = getRel(Rel)->getType(EF.isMips64EL());
- else
- type = getRela(Rel)->getType(EF.isMips64EL());
-
+ uint32_t type = getRelocationType(Rel);
EF.getRelocationTypeName(type, Result);
- return std::error_code();
}
template <class ELFT>
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
section_iterator getRelocationSection(DataRefImpl Rel) const;
uint64_t getRelocationType(DataRefImpl Rel) const override;
- std::error_code
- getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const override;
+ void getRelocationTypeName(DataRefImpl Rel,
+ SmallVectorImpl<char> &Result) const override;
uint8_t getRelocationLength(DataRefImpl Rel) const;
// MachO specific.
/// @brief Get a string that represents the type of this relocation.
///
/// This is for display purposes only.
- std::error_code getTypeName(SmallVectorImpl<char> &Result) const;
-
+ void getTypeName(SmallVectorImpl<char> &Result) const;
DataRefImpl getRawDataRefImpl() const;
const ObjectFile *getObject() const;
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
- virtual std::error_code
- getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const = 0;
+ virtual void getRelocationTypeName(DataRefImpl Rel,
+ SmallVectorImpl<char> &Result) const = 0;
public:
uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
return OwningObject->getRelocationType(RelocationPimpl);
}
-inline std::error_code
-RelocationRef::getTypeName(SmallVectorImpl<char> &Result) const {
+inline void RelocationRef::getTypeName(SmallVectorImpl<char> &Result) const {
return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
}
object::RelocToApply R(V.visit(Type, Reloc, SymAddr));
if (V.error()) {
SmallString<32> Name;
- std::error_code ec(Reloc.getTypeName(Name));
- if (ec) {
- errs() << "Aaaaaa! Nameless relocation! Aaaaaa!\n";
- }
+ Reloc.getTypeName(Name);
errs() << "error: failed to compute relocation: "
<< Name << "\n";
continue;
Res = #reloc_type; \
break;
-std::error_code
-COFFObjectFile::getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const {
+void COFFObjectFile::getRelocationTypeName(
+ DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
const coff_relocation *Reloc = toRel(Rel);
StringRef Res;
switch (getMachine()) {
Res = "Unknown";
}
Result.append(Res.begin(), Res.end());
- return std::error_code();
}
#undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME
return getAnyRelocationType(RE);
}
-std::error_code
-MachOObjectFile::getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const {
+void MachOObjectFile::getRelocationTypeName(
+ DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
StringRef res;
uint64_t RType = getRelocationType(Rel);
break;
}
Result.append(res.begin(), res.end());
- return std::error_code();
}
uint8_t MachOObjectFile::getRelocationLength(DataRefImpl Rel) const {
// NOTE: Caller takes ownership of returned string.
const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI) {
SmallVector<char, 0> ret;
- if (std::error_code ec = (*unwrap(RI))->getTypeName(ret))
- report_fatal_error(ec.message());
-
+ (*unwrap(RI))->getTypeName(ret);
char *str = static_cast<char*>(malloc(ret.size()));
std::copy(ret.begin(), ret.end(), str);
return str;
// Stop when rel_cur's address is past the current instruction.
if (addr >= Index + Size) break;
- if (error(rel_cur->getTypeName(name))) goto skip_print_rel;
+ rel_cur->getTypeName(name);
if (error(getRelocationValueString(*rel_cur, val)))
goto skip_print_rel;
outs() << format(Fmt.data(), SectionAddr + addr) << name
SmallString<32> valuestr;
if (hidden)
continue;
- if (error(Reloc.getTypeName(relocname)))
- continue;
+ Reloc.getTypeName(relocname);
if (error(getRelocationValueString(Reloc, valuestr)))
continue;
outs() << format(Fmt.data(), address) << " " << relocname << " "
uint64_t RelocType = Reloc.getType();
SmallString<32> RelocName;
StringRef SymbolName;
- if (error(Reloc.getTypeName(RelocName)))
- return;
+ Reloc.getTypeName(RelocName);
symbol_iterator Symbol = Reloc.getSymbol();
if (Symbol != Obj->symbol_end() && error(Symbol->getName(SymbolName)))
return;
const RelocationRef &Reloc) {
uint64_t Offset = Reloc.getOffset();
SmallString<32> RelocName;
- if (error(Reloc.getTypeName(RelocName)))
- return;
+ Reloc.getTypeName(RelocName);
DataRefImpl DR = Reloc.getRawDataRefImpl();
MachO::any_relocation_info RE = Obj->getRelocation(DR);