mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 14:16:12 +00:00
Return ErrorOr from SymbolRef::getName.
This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. llvm-svn: 241297
This commit is contained in:
parent
8da856ce76
commit
165a342cde
@ -647,8 +647,7 @@ public:
|
||||
}
|
||||
protected:
|
||||
void moveSymbolNext(DataRefImpl &Symb) const override;
|
||||
std::error_code getSymbolName(DataRefImpl Symb,
|
||||
StringRef &Res) const override;
|
||||
ErrorOr<StringRef> getSymbolName(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Res) const override;
|
||||
uint64_t getSymbolValue(DataRefImpl Symb) const override;
|
||||
|
@ -195,8 +195,7 @@ protected:
|
||||
ELFFile<ELFT> EF;
|
||||
|
||||
void moveSymbolNext(DataRefImpl &Symb) const override;
|
||||
std::error_code getSymbolName(DataRefImpl Symb,
|
||||
StringRef &Res) const override;
|
||||
ErrorOr<StringRef> getSymbolName(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Res) const override;
|
||||
uint64_t getSymbolValue(DataRefImpl Symb) const override;
|
||||
@ -349,14 +348,9 @@ void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const {
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym,
|
||||
StringRef &Result) const {
|
||||
ErrorOr<StringRef> ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Sym) const {
|
||||
const Elf_Sym *ESym = toELFSymIter(Sym);
|
||||
ErrorOr<StringRef> Name = EF.getSymbolName(ESym, Sym.p & 1);
|
||||
if (!Name)
|
||||
return Name.getError();
|
||||
Result = *Name;
|
||||
return std::error_code();
|
||||
return EF.getSymbolName(ESym, Sym.p & 1);
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
@ -199,8 +199,7 @@ public:
|
||||
void moveSymbolNext(DataRefImpl &Symb) const override;
|
||||
|
||||
uint64_t getNValue(DataRefImpl Sym) const;
|
||||
std::error_code getSymbolName(DataRefImpl Symb,
|
||||
StringRef &Res) const override;
|
||||
ErrorOr<StringRef> getSymbolName(DataRefImpl Symb) const override;
|
||||
|
||||
// MachO specific.
|
||||
std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const;
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
|
||||
}
|
||||
|
||||
std::error_code getName(StringRef &Result) const;
|
||||
ErrorOr<StringRef> getName() const;
|
||||
/// Returns the symbol virtual address (i.e. address at which it will be
|
||||
/// mapped).
|
||||
std::error_code getAddress(uint64_t &Result) const;
|
||||
@ -195,8 +195,7 @@ protected:
|
||||
// Implementations assume that the DataRefImpl is valid and has not been
|
||||
// modified externally. It's UB otherwise.
|
||||
friend class SymbolRef;
|
||||
virtual std::error_code getSymbolName(DataRefImpl Symb,
|
||||
StringRef &Res) const = 0;
|
||||
virtual ErrorOr<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
|
||||
std::error_code printSymbolName(raw_ostream &OS,
|
||||
DataRefImpl Symb) const override;
|
||||
virtual std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
@ -305,8 +304,8 @@ public:
|
||||
inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
|
||||
: BasicSymbolRef(SymbolP, Owner) {}
|
||||
|
||||
inline std::error_code SymbolRef::getName(StringRef &Result) const {
|
||||
return getObject()->getSymbolName(getRawDataRefImpl(), Result);
|
||||
inline ErrorOr<StringRef> SymbolRef::getName() const {
|
||||
return getObject()->getSymbolName(getRawDataRefImpl());
|
||||
}
|
||||
|
||||
inline std::error_code SymbolRef::getAddress(uint64_t &Result) const {
|
||||
|
@ -181,9 +181,10 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
||||
SymType == object::SymbolRef::ST_Data ||
|
||||
SymType == object::SymbolRef::ST_Unknown) {
|
||||
|
||||
StringRef Name;
|
||||
ErrorOr<StringRef> NameOrErr = I->getName();
|
||||
Check(NameOrErr.getError());
|
||||
StringRef Name = *NameOrErr;
|
||||
uint64_t SectOffset;
|
||||
Check(I->getName(Name));
|
||||
Check(getOffset(*I, SectOffset));
|
||||
section_iterator SI = Obj.section_end();
|
||||
Check(I->getSection(SI));
|
||||
@ -481,8 +482,9 @@ void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
|
||||
DEBUG(dbgs() << "Processing common symbols...\n");
|
||||
|
||||
for (const auto &Sym : CommonSymbols) {
|
||||
StringRef Name;
|
||||
Check(Sym.getName(Name));
|
||||
ErrorOr<StringRef> NameOrErr = Sym.getName();
|
||||
Check(NameOrErr.getError());
|
||||
StringRef Name = *NameOrErr;
|
||||
|
||||
// Skip common symbols already elsewhere.
|
||||
if (GlobalSymbolTable.count(Name) ||
|
||||
@ -515,9 +517,10 @@ void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
|
||||
// Assign the address of each symbol
|
||||
for (auto &Sym : SymbolsToAllocate) {
|
||||
uint32_t Align = Sym.getAlignment();
|
||||
StringRef Name;
|
||||
uint64_t Size = Sym.getCommonSize();
|
||||
Check(Sym.getName(Name));
|
||||
ErrorOr<StringRef> NameOrErr = Sym.getName();
|
||||
Check(NameOrErr.getError());
|
||||
StringRef Name = *NameOrErr;
|
||||
if (Align) {
|
||||
// This symbol has an alignment requirement.
|
||||
uint64_t AlignOffset = OffsetToAlignment((uint64_t)Addr, Align);
|
||||
|
@ -1064,8 +1064,12 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
|
||||
|
||||
// Obtain the symbol name which is referenced in the relocation
|
||||
StringRef TargetName;
|
||||
if (Symbol != Obj.symbol_end())
|
||||
Symbol->getName(TargetName);
|
||||
if (Symbol != Obj.symbol_end()) {
|
||||
ErrorOr<StringRef> TargetNameOrErr = Symbol->getName();
|
||||
if (std::error_code EC = TargetNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
TargetName = *TargetNameOrErr;
|
||||
}
|
||||
DEBUG(dbgs() << "\t\tRelType: " << RelType << " Addend: " << Addend
|
||||
<< " TargetName: " << TargetName << "\n");
|
||||
RelocationValueRef Value;
|
||||
|
@ -63,8 +63,10 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
||||
bool IsExternal = Obj.getPlainRelocationExternal(RelInfo);
|
||||
if (IsExternal) {
|
||||
symbol_iterator Symbol = RI->getSymbol();
|
||||
StringRef TargetName;
|
||||
Symbol->getName(TargetName);
|
||||
ErrorOr<StringRef> TargetNameOrErr = Symbol->getName();
|
||||
if (std::error_code EC = TargetNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef TargetName = *TargetNameOrErr;
|
||||
RTDyldSymbolTable::const_iterator SI =
|
||||
GlobalSymbolTable.find(TargetName.data());
|
||||
if (SI != GlobalSymbolTable.end()) {
|
||||
@ -162,8 +164,10 @@ void RuntimeDyldMachO::populateIndirectSymbolPointersSection(
|
||||
unsigned SymbolIndex =
|
||||
Obj.getIndirectSymbolTableEntry(DySymTabCmd, FirstIndirectSymbol + i);
|
||||
symbol_iterator SI = Obj.getSymbolByIndex(SymbolIndex);
|
||||
StringRef IndirectSymbolName;
|
||||
SI->getName(IndirectSymbolName);
|
||||
ErrorOr<StringRef> IndirectSymbolNameOrErr = SI->getName();
|
||||
if (std::error_code EC = IndirectSymbolNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef IndirectSymbolName = *IndirectSymbolNameOrErr;
|
||||
DEBUG(dbgs() << " " << IndirectSymbolName << ": index " << SymbolIndex
|
||||
<< ", PT offset: " << PTEntryOffset << "\n");
|
||||
RelocationEntry RE(PTSectionID, PTEntryOffset,
|
||||
|
@ -155,8 +155,10 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
StringRef TargetName;
|
||||
Symbol->getName(TargetName);
|
||||
ErrorOr<StringRef> TargetNameOrErr = Symbol->getName();
|
||||
if (std::error_code EC = TargetNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef TargetName = *TargetNameOrErr;
|
||||
|
||||
DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset
|
||||
<< " RelType: " << RelType << " TargetName: " << TargetName
|
||||
|
@ -240,13 +240,14 @@ private:
|
||||
unsigned SymbolIndex =
|
||||
Obj.getIndirectSymbolTableEntry(DySymTabCmd, FirstIndirectSymbol + i);
|
||||
symbol_iterator SI = Obj.getSymbolByIndex(SymbolIndex);
|
||||
StringRef IndirectSymbolName;
|
||||
SI->getName(IndirectSymbolName);
|
||||
ErrorOr<StringRef> IndirectSymbolName = SI->getName();
|
||||
if (std::error_code EC = IndirectSymbolName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
uint8_t *JTEntryAddr = JTSectionAddr + JTEntryOffset;
|
||||
createStubFunction(JTEntryAddr);
|
||||
RelocationEntry RE(JTSectionID, JTEntryOffset + 1,
|
||||
MachO::GENERIC_RELOC_VANILLA, 0, true, 2);
|
||||
addRelocationForSymbol(RE, IndirectSymbolName);
|
||||
addRelocationForSymbol(RE, *IndirectSymbolName);
|
||||
JTEntryOffset += JTEntrySize;
|
||||
}
|
||||
}
|
||||
|
@ -145,10 +145,13 @@ void COFFObjectFile::moveSymbolNext(DataRefImpl &Ref) const {
|
||||
}
|
||||
}
|
||||
|
||||
std::error_code COFFObjectFile::getSymbolName(DataRefImpl Ref,
|
||||
StringRef &Result) const {
|
||||
ErrorOr<StringRef> COFFObjectFile::getSymbolName(DataRefImpl Ref) const {
|
||||
COFFSymbolRef Symb = getCOFFSymbol(Ref);
|
||||
return getSymbolName(Symb, Result);
|
||||
StringRef Result;
|
||||
std::error_code EC = getSymbolName(Symb, Result);
|
||||
if (EC)
|
||||
return EC;
|
||||
return Result;
|
||||
}
|
||||
|
||||
uint64_t COFFObjectFile::getSymbolValue(DataRefImpl Ref) const {
|
||||
|
@ -327,16 +327,14 @@ void MachOObjectFile::moveSymbolNext(DataRefImpl &Symb) const {
|
||||
Symb.p += SymbolTableEntrySize;
|
||||
}
|
||||
|
||||
std::error_code MachOObjectFile::getSymbolName(DataRefImpl Symb,
|
||||
StringRef &Res) const {
|
||||
ErrorOr<StringRef> MachOObjectFile::getSymbolName(DataRefImpl Symb) const {
|
||||
StringRef StringTable = getStringTableData();
|
||||
MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb);
|
||||
const char *Start = &StringTable.data()[Entry.n_strx];
|
||||
if (Start < getData().begin() || Start >= getData().end())
|
||||
report_fatal_error(
|
||||
"Symbol name entry points before beginning or past end of file.");
|
||||
Res = StringRef(Start);
|
||||
return std::error_code();
|
||||
return StringRef(Start);
|
||||
}
|
||||
|
||||
unsigned MachOObjectFile::getSectionType(SectionRef Sec) const {
|
||||
|
@ -173,10 +173,10 @@ void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef SI) {
|
||||
|
||||
// SymbolRef accessors
|
||||
const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI) {
|
||||
StringRef ret;
|
||||
if (std::error_code ec = (*unwrap(SI))->getName(ret))
|
||||
report_fatal_error(ec.message());
|
||||
return ret.data();
|
||||
ErrorOr<StringRef> Ret = (*unwrap(SI))->getName();
|
||||
if (std::error_code EC = Ret.getError())
|
||||
report_fatal_error(EC.message());
|
||||
return Ret->data();
|
||||
}
|
||||
|
||||
uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI) {
|
||||
|
@ -37,10 +37,10 @@ bool SectionRef::containsSymbol(SymbolRef S) const {
|
||||
|
||||
std::error_code ObjectFile::printSymbolName(raw_ostream &OS,
|
||||
DataRefImpl Symb) const {
|
||||
StringRef Name;
|
||||
if (std::error_code EC = getSymbolName(Symb, Name))
|
||||
ErrorOr<StringRef> Name = getSymbolName(Symb);
|
||||
if (std::error_code EC = Name.getError())
|
||||
return EC;
|
||||
OS << Name;
|
||||
OS << *Name;
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,11 @@ public:
|
||||
uint64_t RelType = Rel.getType();
|
||||
elf_symbol_iterator SymI = Rel.getSymbol();
|
||||
|
||||
StringRef SymName; SymI->getName(SymName);
|
||||
ErrorOr<StringRef> SymNameOrErr = SymI->getName();
|
||||
if (std::error_code EC = SymNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
|
||||
uint64_t SymAddr; SymI->getAddress(SymAddr);
|
||||
uint64_t SymSize = SymI->getSize();
|
||||
int64_t Addend = *ELFRelocationRef(Rel).getAddend();
|
||||
|
@ -30,7 +30,10 @@ public:
|
||||
uint64_t RelType = Rel.getType();
|
||||
symbol_iterator SymI = Rel.getSymbol();
|
||||
|
||||
StringRef SymName; SymI->getName(SymName);
|
||||
ErrorOr<StringRef> SymNameOrErr = SymI->getName();
|
||||
if (std::error_code EC = SymNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
uint64_t SymAddr; SymI->getAddress(SymAddr);
|
||||
|
||||
any_relocation_info RE = Obj->getRelocation(Rel.getRawDataRefImpl());
|
||||
@ -89,10 +92,11 @@ public:
|
||||
symbol_iterator RSymI = Rel.getSymbol();
|
||||
uint64_t RSymAddr;
|
||||
RSymI->getAddress(RSymAddr);
|
||||
StringRef RSymName;
|
||||
RSymI->getName(RSymName);
|
||||
ErrorOr<StringRef> RSymName = RSymI->getName();
|
||||
if (std::error_code EC = RSymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
|
||||
MCSymbol *RSym = Ctx.getOrCreateSymbol(RSymName);
|
||||
MCSymbol *RSym = Ctx.getOrCreateSymbol(*RSymName);
|
||||
if (!RSym->isVariable())
|
||||
RSym->setVariableValue(MCConstantExpr::create(RSymAddr, Ctx));
|
||||
|
||||
|
@ -216,11 +216,13 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::denormalize(IO &IO) {
|
||||
// during the test, we can't hardcode the symbols addresses, so
|
||||
// look them up here and rewrite them.
|
||||
for (const auto &Sym : ErrOrObjectFile->symbols()) {
|
||||
StringRef Name;
|
||||
uint64_t Address;
|
||||
if (Sym.getName(Name) || Sym.getAddress(Address))
|
||||
if (Sym.getAddress(Address))
|
||||
continue;
|
||||
SymbolAddresses[Name] = Address;
|
||||
ErrorOr<StringRef> Name = Sym.getName();
|
||||
if (!Name)
|
||||
continue;
|
||||
SymbolAddresses[*Name] = Address;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1462,12 +1462,12 @@ void DwarfLinker::findValidRelocsMachO(const object::SectionRef &Section,
|
||||
|
||||
auto Sym = Reloc.getSymbol();
|
||||
if (Sym != Obj.symbol_end()) {
|
||||
StringRef SymbolName;
|
||||
if (Sym->getName(SymbolName)) {
|
||||
ErrorOr<StringRef> SymbolName = Sym->getName();
|
||||
if (!SymbolName) {
|
||||
reportWarning("error getting relocation symbol name.");
|
||||
continue;
|
||||
}
|
||||
if (const auto *Mapping = DMO.lookupSymbol(SymbolName))
|
||||
if (const auto *Mapping = DMO.lookupSymbol(*SymbolName))
|
||||
ValidRelocs.emplace_back(Offset64, RelocSize, Addend, Mapping);
|
||||
} else if (const auto *Mapping = DMO.lookupObjectAddress(Addend)) {
|
||||
// Do not store the addend. The addend was the address of the
|
||||
|
@ -197,11 +197,14 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols() {
|
||||
CurrentObjectAddresses.clear();
|
||||
|
||||
for (auto Sym : CurrentObjectHolder.Get().symbols()) {
|
||||
StringRef Name;
|
||||
|
||||
uint64_t Addr;
|
||||
if (Sym.getAddress(Addr) || Addr == UnknownAddress || Sym.getName(Name))
|
||||
if (Sym.getAddress(Addr) || Addr == UnknownAddress)
|
||||
continue;
|
||||
CurrentObjectAddresses[Name] = Addr;
|
||||
ErrorOr<StringRef> Name = Sym.getName();
|
||||
if (!Name)
|
||||
continue;
|
||||
CurrentObjectAddresses[*Name] = Addr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +228,6 @@ void MachODebugMapParser::loadMainBinarySymbols() {
|
||||
// Skip undefined and STAB entries.
|
||||
if ((Type & SymbolRef::ST_Debug) || (Type & SymbolRef::ST_Unknown))
|
||||
continue;
|
||||
StringRef Name;
|
||||
uint64_t Addr;
|
||||
// The only symbols of interest are the global variables. These
|
||||
// are the only ones that need to be queried because the address
|
||||
@ -233,8 +235,13 @@ void MachODebugMapParser::loadMainBinarySymbols() {
|
||||
// addresses should be fetched for the debug map.
|
||||
if (Sym.getAddress(Addr) || Addr == UnknownAddress ||
|
||||
!(Sym.getFlags() & SymbolRef::SF_Global) || Sym.getSection(Section) ||
|
||||
Section->isText() || Sym.getName(Name) || Name.size() == 0 ||
|
||||
Name[0] == '\0')
|
||||
Section->isText())
|
||||
continue;
|
||||
ErrorOr<StringRef> NameOrErr = Sym.getName();
|
||||
if (!NameOrErr)
|
||||
continue;
|
||||
StringRef Name = *NameOrErr;
|
||||
if (Name.size() == 0 || Name[0] == '\0')
|
||||
continue;
|
||||
MainBinarySymbolAddresses[Name] = Addr;
|
||||
}
|
||||
|
@ -97,12 +97,12 @@ static bool collectRelocatedSymbols(const ObjectFile *Obj,
|
||||
const object::symbol_iterator RelocSymI = Reloc.getSymbol();
|
||||
if (RelocSymI == Obj->symbol_end())
|
||||
continue;
|
||||
StringRef RelocSymName;
|
||||
if (error(RelocSymI->getName(RelocSymName)))
|
||||
ErrorOr<StringRef> RelocSymName = RelocSymI->getName();
|
||||
if (error(RelocSymName.getError()))
|
||||
return true;
|
||||
uint64_t Offset = Reloc.getOffset();
|
||||
if (Offset >= SymOffset && Offset < SymEnd) {
|
||||
*I = RelocSymName;
|
||||
*I = *RelocSymName;
|
||||
++I;
|
||||
}
|
||||
}
|
||||
@ -121,12 +121,12 @@ static bool collectRelocationOffsets(
|
||||
const object::symbol_iterator RelocSymI = Reloc.getSymbol();
|
||||
if (RelocSymI == Obj->symbol_end())
|
||||
continue;
|
||||
StringRef RelocSymName;
|
||||
if (error(RelocSymI->getName(RelocSymName)))
|
||||
ErrorOr<StringRef> RelocSymName = RelocSymI->getName();
|
||||
if (error(RelocSymName.getError()))
|
||||
return true;
|
||||
uint64_t Offset = Reloc.getOffset();
|
||||
if (Offset >= SymOffset && Offset < SymEnd)
|
||||
Collection[std::make_pair(SymName, Offset - SymOffset)] = RelocSymName;
|
||||
Collection[std::make_pair(SymName, Offset - SymOffset)] = *RelocSymName;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -190,9 +190,10 @@ static void dumpCXXData(const ObjectFile *Obj) {
|
||||
for (auto &P : SymAddr) {
|
||||
object::SymbolRef Sym = P.first;
|
||||
uint64_t SymSize = P.second;
|
||||
StringRef SymName;
|
||||
if (error(Sym.getName(SymName)))
|
||||
ErrorOr<StringRef> SymNameOrErr = Sym.getName();
|
||||
if (error(SymNameOrErr.getError()))
|
||||
return;
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
object::section_iterator SecI(Obj->section_begin());
|
||||
if (error(Sym.getSection(SecI)))
|
||||
return;
|
||||
|
@ -653,10 +653,10 @@ static char getSymbolNMTypeChar(ELFObjectFileBase &Obj,
|
||||
}
|
||||
|
||||
if (SymI->getELFType() == ELF::STT_SECTION) {
|
||||
StringRef Name;
|
||||
if (error(SymI->getName(Name)))
|
||||
ErrorOr<StringRef> Name = SymI->getName();
|
||||
if (error(Name.getError()))
|
||||
return '?';
|
||||
return StringSwitch<char>(Name)
|
||||
return StringSwitch<char>(*Name)
|
||||
.StartsWith(".debug", 'N')
|
||||
.StartsWith(".note", 'n')
|
||||
.Default('?');
|
||||
@ -670,11 +670,11 @@ static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
|
||||
// OK, this is COFF.
|
||||
symbol_iterator SymI(I);
|
||||
|
||||
StringRef Name;
|
||||
if (error(SymI->getName(Name)))
|
||||
ErrorOr<StringRef> Name = SymI->getName();
|
||||
if (error(Name.getError()))
|
||||
return '?';
|
||||
|
||||
char Ret = StringSwitch<char>(Name)
|
||||
char Ret = StringSwitch<char>(*Name)
|
||||
.StartsWith(".debug", 'N')
|
||||
.StartsWith(".sxdata", 'N')
|
||||
.Default('?');
|
||||
|
@ -213,8 +213,10 @@ static std::error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
|
||||
SymbolRef Sym;
|
||||
if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
|
||||
return EC;
|
||||
if (std::error_code EC = Sym.getName(Name))
|
||||
ErrorOr<StringRef> NameOrErr = Sym.getName();
|
||||
if (std::error_code EC = NameOrErr.getError())
|
||||
return EC;
|
||||
Name = *NameOrErr;
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
|
@ -282,9 +282,10 @@ static void getSectionsAndSymbols(MachOObjectFile *MachOObj,
|
||||
SmallVectorImpl<uint64_t> &FoundFns,
|
||||
uint64_t &BaseSegmentAddress) {
|
||||
for (const SymbolRef &Symbol : MachOObj->symbols()) {
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
if (!SymName.startswith("ltmp"))
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
if (!SymName->startswith("ltmp"))
|
||||
Symbols.push_back(Symbol);
|
||||
}
|
||||
|
||||
@ -361,9 +362,10 @@ static void PrintIndirectSymbolTable(MachOObjectFile *O, bool verbose,
|
||||
if (indirect_symbol < Symtab.nsyms) {
|
||||
symbol_iterator Sym = O->getSymbolByIndex(indirect_symbol);
|
||||
SymbolRef Symbol = *Sym;
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
outs() << SymName;
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
outs() << *SymName;
|
||||
} else {
|
||||
outs() << "?";
|
||||
}
|
||||
@ -592,8 +594,10 @@ static void CreateSymbolAddressMap(MachOObjectFile *O,
|
||||
ST == SymbolRef::ST_Other) {
|
||||
uint64_t Address;
|
||||
Symbol.getAddress(Address);
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
ErrorOr<StringRef> SymNameOrErr = Symbol.getName();
|
||||
if (std::error_code EC = SymNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
if (!SymName.startswith(".objc"))
|
||||
(*AddrMap)[Address] = SymName;
|
||||
}
|
||||
@ -830,9 +834,10 @@ static void DumpLiteralPointerSection(MachOObjectFile *O,
|
||||
[&](const std::pair<uint64_t, SymbolRef> &P) { return P.first == i; });
|
||||
if (Reloc != Relocs.end()) {
|
||||
symbol_iterator RelocSym = Reloc->second;
|
||||
StringRef SymName;
|
||||
RelocSym->getName(SymName);
|
||||
outs() << "external relocation entry for symbol:" << SymName << "\n";
|
||||
ErrorOr<StringRef> SymName = RelocSym->getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
outs() << "external relocation entry for symbol:" << *SymName << "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1793,9 +1798,10 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
|
||||
}
|
||||
}
|
||||
if (reloc_found && isExtern) {
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
const char *name = SymName.data();
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
const char *name = SymName->data();
|
||||
op_info->AddSymbol.Present = 1;
|
||||
op_info->AddSymbol.Name = name;
|
||||
// For i386 extern relocation entries the value in the instruction is
|
||||
@ -1859,9 +1865,10 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
|
||||
// is the offset from the external symbol.
|
||||
if (info->O->getAnyRelocationPCRel(RE))
|
||||
op_info->Value -= Pc + Offset + Size;
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
const char *name = SymName.data();
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
const char *name = SymName->data();
|
||||
unsigned Type = info->O->getAnyRelocationType(RE);
|
||||
if (Type == MachO::X86_64_RELOC_SUBTRACTOR) {
|
||||
DataRefImpl RelNext = Rel;
|
||||
@ -1875,9 +1882,10 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
|
||||
op_info->SubtractSymbol.Name = name;
|
||||
symbol_iterator RelocSymNext = info->O->getSymbolByIndex(SymbolNum);
|
||||
Symbol = *RelocSymNext;
|
||||
StringRef SymNameNext;
|
||||
Symbol.getName(SymNameNext);
|
||||
name = SymNameNext.data();
|
||||
ErrorOr<StringRef> SymNameNext = Symbol.getName();
|
||||
if (std::error_code EC = SymNameNext.getError())
|
||||
report_fatal_error(EC.message());
|
||||
name = SymNameNext->data();
|
||||
}
|
||||
}
|
||||
// TODO: add the VariantKinds to op_info->VariantKind for relocation types
|
||||
@ -1944,9 +1952,10 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
|
||||
}
|
||||
|
||||
if (isExtern) {
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
const char *name = SymName.data();
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
const char *name = SymName->data();
|
||||
op_info->AddSymbol.Present = 1;
|
||||
op_info->AddSymbol.Name = name;
|
||||
switch (r_type) {
|
||||
@ -2056,9 +2065,10 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
|
||||
// NOTE: Scattered relocations don't exist on arm64.
|
||||
if (!info->O->getPlainRelocationExternal(RE))
|
||||
return 0;
|
||||
StringRef SymName;
|
||||
Reloc->getSymbol()->getName(SymName);
|
||||
const char *name = SymName.data();
|
||||
ErrorOr<StringRef> SymName = Reloc->getSymbol()->getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
const char *name = SymName->data();
|
||||
op_info->AddSymbol.Present = 1;
|
||||
op_info->AddSymbol.Name = name;
|
||||
|
||||
@ -2185,9 +2195,10 @@ static const char *GuessIndirectSymbol(uint64_t ReferenceValue,
|
||||
if (indirect_symbol < Symtab.nsyms) {
|
||||
symbol_iterator Sym = info->O->getSymbolByIndex(indirect_symbol);
|
||||
SymbolRef Symbol = *Sym;
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
const char *name = SymName.data();
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
const char *name = SymName->data();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@ -2219,9 +2230,10 @@ static const char *GuessIndirectSymbol(uint64_t ReferenceValue,
|
||||
if (indirect_symbol < Symtab.nsyms) {
|
||||
symbol_iterator Sym = info->O->getSymbolByIndex(indirect_symbol);
|
||||
SymbolRef Symbol = *Sym;
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
const char *name = SymName.data();
|
||||
ErrorOr<StringRef> SymName = Symbol.getName();
|
||||
if (std::error_code EC = SymName.getError())
|
||||
report_fatal_error(EC.message());
|
||||
const char *name = SymName->data();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@ -2447,10 +2459,12 @@ static const char *get_symbol_64(uint32_t sect_offset, SectionRef S,
|
||||
Symbol.getAddress(n_value);
|
||||
if (n_value == UnknownAddress)
|
||||
n_value = 0;
|
||||
StringRef name;
|
||||
Symbol.getName(name);
|
||||
if (!name.empty()) {
|
||||
SymbolName = name.data();
|
||||
ErrorOr<StringRef> NameOrError = Symbol.getName();
|
||||
if (std::error_code EC = NameOrError.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef Name = *NameOrError;
|
||||
if (!Name.empty()) {
|
||||
SymbolName = Name.data();
|
||||
return SymbolName;
|
||||
}
|
||||
}
|
||||
@ -6119,8 +6133,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||
ST == SymbolRef::ST_Other) {
|
||||
uint64_t Address;
|
||||
Symbol.getAddress(Address);
|
||||
StringRef SymName;
|
||||
Symbol.getName(SymName);
|
||||
ErrorOr<StringRef> SymNameOrErr = Symbol.getName();
|
||||
if (std::error_code EC = SymNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
AddrMap[Address] = SymName;
|
||||
if (!DisSymName.empty() && DisSymName == SymName)
|
||||
DisSymNameFound = true;
|
||||
@ -6159,8 +6175,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||
|
||||
// Disassemble symbol by symbol.
|
||||
for (unsigned SymIdx = 0; SymIdx != Symbols.size(); SymIdx++) {
|
||||
StringRef SymName;
|
||||
Symbols[SymIdx].getName(SymName);
|
||||
ErrorOr<StringRef> SymNameOrErr = Symbols[SymIdx].getName();
|
||||
if (std::error_code EC = SymNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
|
||||
SymbolRef::Type ST = Symbols[SymIdx].getType();
|
||||
if (ST != SymbolRef::ST_Function)
|
||||
@ -6423,7 +6441,10 @@ static void findUnwindRelocNameAddend(const MachOObjectFile *Obj,
|
||||
const RelocationRef &Reloc, uint64_t Addr,
|
||||
StringRef &Name, uint64_t &Addend) {
|
||||
if (Reloc.getSymbol() != Obj->symbol_end()) {
|
||||
Reloc.getSymbol()->getName(Name);
|
||||
ErrorOr<StringRef> NameOrErr = Reloc.getSymbol()->getName();
|
||||
if (std::error_code EC = NameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
Name = *NameOrErr;
|
||||
Addend = Addr;
|
||||
return;
|
||||
}
|
||||
@ -6449,7 +6470,10 @@ static void findUnwindRelocNameAddend(const MachOObjectFile *Obj,
|
||||
Sym->second.getSection(SymSection);
|
||||
if (RelocSection == *SymSection) {
|
||||
// There's a valid symbol in the same section before this reference.
|
||||
Sym->second.getName(Name);
|
||||
ErrorOr<StringRef> NameOrErr = Sym->second.getName();
|
||||
if (std::error_code EC = NameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
Name = *NameOrErr;
|
||||
Addend = Addr - Sym->first;
|
||||
return;
|
||||
}
|
||||
|
@ -433,9 +433,10 @@ static std::error_code getRelocationValueString(const COFFObjectFile *Obj,
|
||||
const RelocationRef &Rel,
|
||||
SmallVectorImpl<char> &Result) {
|
||||
symbol_iterator SymI = Rel.getSymbol();
|
||||
StringRef SymName;
|
||||
if (std::error_code EC = SymI->getName(SymName))
|
||||
ErrorOr<StringRef> SymNameOrErr = SymI->getName();
|
||||
if (std::error_code EC = SymNameOrErr.getError())
|
||||
return EC;
|
||||
StringRef SymName = *SymNameOrErr;
|
||||
Result.append(SymName.begin(), SymName.end());
|
||||
return std::error_code();
|
||||
}
|
||||
@ -455,15 +456,15 @@ static void printRelocationTargetName(const MachOObjectFile *O,
|
||||
for (const SymbolRef &Symbol : O->symbols()) {
|
||||
std::error_code ec;
|
||||
uint64_t Addr;
|
||||
StringRef Name;
|
||||
ErrorOr<StringRef> Name = Symbol.getName();
|
||||
|
||||
if ((ec = Symbol.getAddress(Addr)))
|
||||
report_fatal_error(ec.message());
|
||||
if (Addr != Val)
|
||||
continue;
|
||||
if ((ec = Symbol.getName(Name)))
|
||||
report_fatal_error(ec.message());
|
||||
fmt << Name;
|
||||
if (std::error_code EC = Name.getError())
|
||||
report_fatal_error(EC.message());
|
||||
fmt << *Name;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -493,7 +494,9 @@ static void printRelocationTargetName(const MachOObjectFile *O,
|
||||
if (isExtern) {
|
||||
symbol_iterator SI = O->symbol_begin();
|
||||
advance(SI, Val);
|
||||
SI->getName(S);
|
||||
ErrorOr<StringRef> SOrErr = SI->getName();
|
||||
if (!error(SOrErr.getError()))
|
||||
S = *SOrErr;
|
||||
} else {
|
||||
section_iterator SI = O->section_begin();
|
||||
// Adjust for the fact that sections are 1-indexed.
|
||||
@ -830,10 +833,10 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
if (Address >= SectSize)
|
||||
continue;
|
||||
|
||||
StringRef Name;
|
||||
if (error(Symbol.getName(Name)))
|
||||
ErrorOr<StringRef> Name = Symbol.getName();
|
||||
if (error(Name.getError()))
|
||||
break;
|
||||
Symbols.push_back(std::make_pair(Address, Name));
|
||||
Symbols.push_back(std::make_pair(Address, *Name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1121,8 +1124,11 @@ void llvm::PrintSymbolTable(const ObjectFile *o) {
|
||||
StringRef Name;
|
||||
if (Type == SymbolRef::ST_Debug && Section != o->section_end()) {
|
||||
Section->getName(Name);
|
||||
} else if (error(Symbol.getName(Name))) {
|
||||
continue;
|
||||
} else {
|
||||
ErrorOr<StringRef> NameOrErr = Symbol.getName();
|
||||
if (error(NameOrErr.getError()))
|
||||
continue;
|
||||
Name = *NameOrErr;
|
||||
}
|
||||
|
||||
bool Global = Flags & SymbolRef::SF_Global;
|
||||
|
@ -567,12 +567,12 @@ bool Decoder::dumpXDataRecord(const COFFObjectFile &COFF,
|
||||
if (!Symbol)
|
||||
Symbol = getSymbol(COFF, Address, /*FunctionOnly=*/true);
|
||||
|
||||
StringRef Name;
|
||||
if (Symbol)
|
||||
Symbol->getName(Name);
|
||||
ErrorOr<StringRef> Name = Symbol->getName();
|
||||
if (std::error_code EC = Name.getError())
|
||||
report_fatal_error(EC.message());
|
||||
|
||||
ListScope EHS(SW, "ExceptionHandler");
|
||||
SW.printString("Routine", formatSymbol(Name, Address));
|
||||
SW.printString("Routine", formatSymbol(*Name, Address));
|
||||
SW.printHex("Parameter", Parameter);
|
||||
}
|
||||
|
||||
@ -601,7 +601,10 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
|
||||
StringRef FunctionName;
|
||||
uint64_t FunctionAddress;
|
||||
if (Function) {
|
||||
Function->getName(FunctionName);
|
||||
ErrorOr<StringRef> FunctionNameOrErr = Function->getName();
|
||||
if (std::error_code EC = FunctionNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
FunctionName = *FunctionNameOrErr;
|
||||
Function->getAddress(FunctionAddress);
|
||||
} else {
|
||||
const pe32_header *PEHeader;
|
||||
@ -613,13 +616,14 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
|
||||
SW.printString("Function", formatSymbol(FunctionName, FunctionAddress));
|
||||
|
||||
if (XDataRecord) {
|
||||
StringRef Name;
|
||||
uint64_t Address;
|
||||
ErrorOr<StringRef> Name = XDataRecord->getName();
|
||||
if (std::error_code EC = Name.getError())
|
||||
report_fatal_error(EC.message());
|
||||
|
||||
XDataRecord->getName(Name);
|
||||
uint64_t Address;
|
||||
XDataRecord->getAddress(Address);
|
||||
|
||||
SW.printString("ExceptionRecord", formatSymbol(Name, Address));
|
||||
SW.printString("ExceptionRecord", formatSymbol(*Name, Address));
|
||||
|
||||
section_iterator SI = COFF.section_end();
|
||||
if (XDataRecord->getSection(SI))
|
||||
@ -658,7 +662,10 @@ bool Decoder::dumpPackedEntry(const object::COFFObjectFile &COFF,
|
||||
StringRef FunctionName;
|
||||
uint64_t FunctionAddress;
|
||||
if (Function) {
|
||||
Function->getName(FunctionName);
|
||||
ErrorOr<StringRef> FunctionNameOrErr = Function->getName();
|
||||
if (std::error_code EC = FunctionNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
FunctionName = *FunctionNameOrErr;
|
||||
Function->getAddress(FunctionAddress);
|
||||
} else {
|
||||
const pe32_header *PEHeader;
|
||||
|
@ -139,8 +139,10 @@ std::error_code COFFDumper::resolveSymbolName(const coff_section *Section,
|
||||
SymbolRef Symbol;
|
||||
if (std::error_code EC = resolveSymbol(Section, Offset, Symbol))
|
||||
return EC;
|
||||
if (std::error_code EC = Symbol.getName(Name))
|
||||
ErrorOr<StringRef> NameOrErr = Symbol.getName();
|
||||
if (std::error_code EC = NameOrErr.getError())
|
||||
return EC;
|
||||
Name = *NameOrErr;
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
@ -809,8 +811,12 @@ void COFFDumper::printRelocation(const SectionRef &Section,
|
||||
StringRef SymbolName;
|
||||
Reloc.getTypeName(RelocName);
|
||||
symbol_iterator Symbol = Reloc.getSymbol();
|
||||
if (Symbol != Obj->symbol_end() && error(Symbol->getName(SymbolName)))
|
||||
return;
|
||||
if (Symbol != Obj->symbol_end()) {
|
||||
ErrorOr<StringRef> SymbolNameOrErr = Symbol->getName();
|
||||
if (error(SymbolNameOrErr.getError()))
|
||||
return;
|
||||
SymbolName = *SymbolNameOrErr;
|
||||
}
|
||||
|
||||
if (opts::ExpandRelocs) {
|
||||
DictScope Group(W, "Relocation");
|
||||
|
@ -474,8 +474,10 @@ void MachODumper::printRelocation(const MachOObjectFile *Obj,
|
||||
if (IsExtern) {
|
||||
symbol_iterator Symbol = Reloc.getSymbol();
|
||||
if (Symbol != Obj->symbol_end()) {
|
||||
if (error(Symbol->getName(TargetName)))
|
||||
ErrorOr<StringRef> TargetNameOrErr = Symbol->getName();
|
||||
if (error(TargetNameOrErr.getError()))
|
||||
return;
|
||||
TargetName = *TargetNameOrErr;
|
||||
}
|
||||
} else if (!IsScattered) {
|
||||
section_iterator SecI = Obj->getRelocationSection(DR);
|
||||
@ -538,8 +540,8 @@ void MachODumper::printDynamicSymbols() {
|
||||
|
||||
void MachODumper::printSymbol(const SymbolRef &Symbol) {
|
||||
StringRef SymbolName;
|
||||
if (Symbol.getName(SymbolName))
|
||||
SymbolName = "";
|
||||
if (ErrorOr<StringRef> SymbolNameOrErr = Symbol.getName())
|
||||
SymbolName = *SymbolNameOrErr;
|
||||
|
||||
MachOSymbol MOSymbol;
|
||||
getSymbol(Obj, Symbol.getRawDataRefImpl(), MOSymbol);
|
||||
|
@ -118,19 +118,19 @@ static std::string formatSymbol(const Dumper::Context &Ctx,
|
||||
std::string Buffer;
|
||||
raw_string_ostream OS(Buffer);
|
||||
|
||||
StringRef Name;
|
||||
SymbolRef Symbol;
|
||||
if (Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData) ||
|
||||
Symbol.getName(Name)) {
|
||||
OS << format(" (0x%" PRIX64 ")", Offset);
|
||||
return OS.str();
|
||||
if (!Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData)) {
|
||||
if (ErrorOr<StringRef> Name = Symbol.getName()) {
|
||||
OS << *Name;
|
||||
if (Displacement > 0)
|
||||
OS << format(" +0x%X (0x%" PRIX64 ")", Displacement, Offset);
|
||||
else
|
||||
OS << format(" (0x%" PRIX64 ")", Offset);
|
||||
return OS.str();
|
||||
}
|
||||
}
|
||||
|
||||
OS << Name;
|
||||
if (Displacement > 0)
|
||||
OS << format(" +0x%X (0x%" PRIX64 ")", Displacement, Offset);
|
||||
else
|
||||
OS << format(" (0x%" PRIX64 ")", Offset);
|
||||
OS << format(" (0x%" PRIX64 ")", Offset);
|
||||
return OS.str();
|
||||
}
|
||||
|
||||
|
@ -266,10 +266,10 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
|
||||
for (const auto &P : SymAddr) {
|
||||
object::SymbolRef Sym = P.first;
|
||||
if (Sym.getType() == object::SymbolRef::ST_Function) {
|
||||
StringRef Name;
|
||||
uint64_t Addr;
|
||||
if (Sym.getName(Name))
|
||||
ErrorOr<StringRef> Name = Sym.getName();
|
||||
if (!Name)
|
||||
continue;
|
||||
uint64_t Addr;
|
||||
if (Sym.getAddress(Addr))
|
||||
continue;
|
||||
|
||||
@ -288,7 +288,8 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
|
||||
Addr += SectionLoadAddress - Sec->getAddress();
|
||||
}
|
||||
|
||||
outs() << "Function: " << Name << ", Size = " << Size << ", Addr = " << Addr << "\n";
|
||||
outs() << "Function: " << *Name << ", Size = " << Size
|
||||
<< ", Addr = " << Addr << "\n";
|
||||
|
||||
DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size);
|
||||
DILineInfoTable::iterator Begin = Lines.begin();
|
||||
|
@ -100,9 +100,10 @@ void ModuleInfo::addSymbol(const SymbolRef &Symbol, uint64_t SymbolSize,
|
||||
OpdExtractor->isValidOffsetForAddress(OpdOffset32))
|
||||
SymbolAddress = OpdExtractor->getAddress(&OpdOffset32);
|
||||
}
|
||||
StringRef SymbolName;
|
||||
if (error(Symbol.getName(SymbolName)))
|
||||
ErrorOr<StringRef> SymbolNameOrErr = Symbol.getName();
|
||||
if (error(SymbolNameOrErr.getError()))
|
||||
return;
|
||||
StringRef SymbolName = *SymbolNameOrErr;
|
||||
// Mach-O symbol table names have leading underscore, skip it.
|
||||
if (Module->isMachO() && SymbolName.size() > 0 && SymbolName[0] == '_')
|
||||
SymbolName = SymbolName.drop_front();
|
||||
|
@ -120,7 +120,10 @@ void COFFDumper::dumpSections(unsigned NumSections) {
|
||||
const object::coff_relocation *reloc = Obj.getCOFFRelocation(Reloc);
|
||||
COFFYAML::Relocation Rel;
|
||||
object::symbol_iterator Sym = Reloc.getSymbol();
|
||||
Sym->getName(Rel.SymbolName);
|
||||
ErrorOr<StringRef> SymbolNameOrErr = Sym->getName();
|
||||
if (std::error_code EC = SymbolNameOrErr.getError())
|
||||
report_fatal_error(EC.message());
|
||||
Rel.SymbolName = *SymbolNameOrErr;
|
||||
Rel.VirtualAddress = reloc->VirtualAddress;
|
||||
Rel.Type = reloc->Type;
|
||||
Relocations.push_back(Rel);
|
||||
|
Loading…
x
Reference in New Issue
Block a user