forked from OSchip/llvm-project
Simplify another function that doesn't fail.
llvm-svn: 238703
This commit is contained in:
parent
7666be70e4
commit
5eb02e45e3
|
@ -613,7 +613,7 @@ protected:
|
|||
StringRef &Res) const override;
|
||||
std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Res) const override;
|
||||
std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
|
||||
uint64_t getSymbolSize(DataRefImpl Symb) const override;
|
||||
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolType(DataRefImpl Symb,
|
||||
SymbolRef::Type &Res) const override;
|
||||
|
|
|
@ -80,7 +80,7 @@ protected:
|
|||
std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Res) const override;
|
||||
uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
|
||||
uint64_t getSymbolSize(DataRefImpl Symb) const override;
|
||||
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolOther(DataRefImpl Symb, uint8_t &Res) const override;
|
||||
std::error_code getSymbolType(DataRefImpl Symb,
|
||||
|
@ -333,10 +333,8 @@ uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
|
|||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Symb,
|
||||
uint64_t &Result) const {
|
||||
Result = toELFSymIter(Symb)->st_size;
|
||||
return object_error::success;
|
||||
uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Symb) const {
|
||||
return toELFSymIter(Symb)->st_size;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
|
|
@ -205,7 +205,7 @@ public:
|
|||
std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Res) const override;
|
||||
uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
|
||||
uint64_t getSymbolSize(DataRefImpl Symb) const override;
|
||||
std::error_code getSymbolType(DataRefImpl Symb,
|
||||
SymbolRef::Type &Res) const override;
|
||||
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
|
||||
|
|
|
@ -147,7 +147,7 @@ public:
|
|||
std::error_code getAddress(uint64_t &Result) const;
|
||||
/// @brief Get the alignment of this symbol as the actual value (not log 2).
|
||||
uint32_t getAlignment() const;
|
||||
std::error_code getSize(uint64_t &Result) const;
|
||||
uint64_t getSize() const;
|
||||
std::error_code getType(SymbolRef::Type &Result) const;
|
||||
std::error_code getOther(uint8_t &Result) const;
|
||||
|
||||
|
@ -207,8 +207,7 @@ protected:
|
|||
virtual std::error_code getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Res) const = 0;
|
||||
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
|
||||
virtual std::error_code getSymbolSize(DataRefImpl Symb,
|
||||
uint64_t &Res) const = 0;
|
||||
virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0;
|
||||
virtual std::error_code getSymbolType(DataRefImpl Symb,
|
||||
SymbolRef::Type &Res) const = 0;
|
||||
virtual std::error_code getSymbolSection(DataRefImpl Symb,
|
||||
|
@ -337,8 +336,8 @@ inline uint32_t SymbolRef::getAlignment() const {
|
|||
return getObject()->getSymbolAlignment(getRawDataRefImpl());
|
||||
}
|
||||
|
||||
inline std::error_code SymbolRef::getSize(uint64_t &Result) const {
|
||||
return getObject()->getSymbolSize(getRawDataRefImpl(), Result);
|
||||
inline uint64_t SymbolRef::getSize() const {
|
||||
return getObject()->getSymbolSize(getRawDataRefImpl());
|
||||
}
|
||||
|
||||
inline std::error_code SymbolRef::getSection(section_iterator &Result) const {
|
||||
|
|
|
@ -387,8 +387,7 @@ void RuntimeDyldImpl::computeTotalAllocSize(const ObjectFile &Obj,
|
|||
uint32_t Flags = I->getFlags();
|
||||
if (Flags & SymbolRef::SF_Common) {
|
||||
// Add the common symbols to a list. We'll allocate them all below.
|
||||
uint64_t Size = 0;
|
||||
Check(I->getSize(Size));
|
||||
uint64_t Size = I->getSize();
|
||||
CommonSize += Size;
|
||||
}
|
||||
}
|
||||
|
@ -495,8 +494,7 @@ void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
|
|||
}
|
||||
|
||||
uint32_t Align = Sym.getAlignment();
|
||||
uint64_t Size = 0;
|
||||
Check(Sym.getSize(Size));
|
||||
uint64_t Size = Sym.getSize();
|
||||
|
||||
CommonSize += Align + Size;
|
||||
SymbolsToAllocate.push_back(Sym);
|
||||
|
@ -518,9 +516,8 @@ void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
|
|||
// Assign the address of each symbol
|
||||
for (auto &Sym : SymbolsToAllocate) {
|
||||
uint32_t Align = Sym.getAlignment();
|
||||
uint64_t Size;
|
||||
StringRef Name;
|
||||
Check(Sym.getSize(Size));
|
||||
uint64_t Size = Sym.getSize();
|
||||
Check(Sym.getName(Name));
|
||||
if (Align) {
|
||||
// This symbol has an alignment requirement.
|
||||
|
|
|
@ -236,16 +236,12 @@ uint32_t COFFObjectFile::getSymbolFlags(DataRefImpl Ref) const {
|
|||
return Result;
|
||||
}
|
||||
|
||||
std::error_code COFFObjectFile::getSymbolSize(DataRefImpl Ref,
|
||||
uint64_t &Result) const {
|
||||
uint64_t COFFObjectFile::getSymbolSize(DataRefImpl Ref) const {
|
||||
COFFSymbolRef Symb = getCOFFSymbol(Ref);
|
||||
|
||||
if (Symb.isCommon())
|
||||
Result = Symb.getValue();
|
||||
else
|
||||
Result = UnknownAddressOrSize;
|
||||
|
||||
return object_error::success;
|
||||
return Symb.getValue();
|
||||
return UnknownAddressOrSize;
|
||||
}
|
||||
|
||||
std::error_code
|
||||
|
|
|
@ -410,16 +410,13 @@ uint32_t MachOObjectFile::getSymbolAlignment(DataRefImpl DRI) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
|
||||
uint64_t &Result) const {
|
||||
uint64_t MachOObjectFile::getSymbolSize(DataRefImpl DRI) const {
|
||||
uint64_t Value;
|
||||
getSymbolAddress(DRI, Value);
|
||||
uint32_t flags = getSymbolFlags(DRI);
|
||||
if (flags & SymbolRef::SF_Common)
|
||||
Result = Value;
|
||||
else
|
||||
Result = UnknownAddressOrSize;
|
||||
return object_error::success;
|
||||
return Value;
|
||||
return UnknownAddressOrSize;
|
||||
}
|
||||
|
||||
std::error_code MachOObjectFile::getSymbolType(DataRefImpl Symb,
|
||||
|
|
|
@ -187,10 +187,7 @@ uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI) {
|
|||
}
|
||||
|
||||
uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI) {
|
||||
uint64_t ret;
|
||||
if (std::error_code ec = (*unwrap(SI))->getSize(ret))
|
||||
report_fatal_error(ec.message());
|
||||
return ret;
|
||||
return (*unwrap(SI))->getSize();
|
||||
}
|
||||
|
||||
// RelocationRef accessors
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
StringRef SymName; SymI->getName(SymName);
|
||||
uint64_t SymAddr; SymI->getAddress(SymAddr);
|
||||
uint64_t SymSize; SymI->getSize(SymSize);
|
||||
uint64_t SymSize = SymI->getSize();
|
||||
int64_t Addend; getELFRelocationAddend(Rel, Addend);
|
||||
|
||||
MCSymbol *Sym = Ctx.getOrCreateSymbol(SymName);
|
||||
|
|
|
@ -204,9 +204,10 @@ static void dumpCXXData(const ObjectFile *Obj) {
|
|||
StringRef SecContents;
|
||||
if (error(Sec.getContents(SecContents)))
|
||||
return;
|
||||
uint64_t SymAddress, SymSize;
|
||||
if (error(Sym.getAddress(SymAddress)) || error(Sym.getSize(SymSize)))
|
||||
uint64_t SymAddress;
|
||||
if (error(Sym.getAddress(SymAddress)))
|
||||
return;
|
||||
uint64_t SymSize = Sym.getSize();
|
||||
uint64_t SecAddress = Sec.getAddress();
|
||||
uint64_t SecSize = Sec.getSize();
|
||||
uint64_t SymOffset = SymAddress - SecAddress;
|
||||
|
|
|
@ -934,8 +934,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
|
|||
S.Address = UnknownAddressOrSize;
|
||||
if (PrintSize && isa<ELFObjectFileBase>(Obj)) {
|
||||
symbol_iterator SymI = I;
|
||||
if (error(SymI->getSize(S.Size)))
|
||||
break;
|
||||
S.Size = SymI->getSize();
|
||||
}
|
||||
if (PrintAddress && isa<ObjectFile>(Obj))
|
||||
if (error(symbol_iterator(I)->getAddress(S.Address)))
|
||||
|
|
|
@ -676,7 +676,6 @@ void llvm::PrintSymbolTable(const ObjectFile *o) {
|
|||
StringRef Name;
|
||||
uint64_t Address;
|
||||
SymbolRef::Type Type;
|
||||
uint64_t Size;
|
||||
uint32_t Flags = Symbol.getFlags();
|
||||
section_iterator Section = o->section_end();
|
||||
if (error(Symbol.getName(Name)))
|
||||
|
@ -685,8 +684,7 @@ void llvm::PrintSymbolTable(const ObjectFile *o) {
|
|||
continue;
|
||||
if (error(Symbol.getType(Type)))
|
||||
continue;
|
||||
if (error(Symbol.getSize(Size)))
|
||||
continue;
|
||||
uint64_t Size = Symbol.getSize();
|
||||
if (error(Symbol.getSection(Section)))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -292,8 +292,7 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
|
|||
|
||||
uint64_t Size;
|
||||
if (isa<ELFObjectFileBase>(SymbolObj)) {
|
||||
if (Sym.getSize(Size))
|
||||
continue;
|
||||
Size = Sym.getSize();
|
||||
} else {
|
||||
object::section_iterator Sec = SymbolObj->section_end();
|
||||
if (Sym.getSection(Sec))
|
||||
|
|
|
@ -113,9 +113,11 @@ void ModuleInfo::addSymbol(const SymbolRef &Symbol, DataExtractor *OpdExtractor,
|
|||
// occupies the memory range up to the following symbol.
|
||||
if (isa<MachOObjectFile>(Module))
|
||||
SymbolSize = 0;
|
||||
else if (error(Symbol.getSize(SymbolSize)) ||
|
||||
SymbolSize == UnknownAddressOrSize)
|
||||
return;
|
||||
else {
|
||||
SymbolSize = Symbol.getSize();
|
||||
if (SymbolSize == UnknownAddressOrSize)
|
||||
return;
|
||||
}
|
||||
StringRef SymbolName;
|
||||
if (error(Symbol.getName(SymbolName)))
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue