mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Simplify getSymbolFlags.
None of the object formats require extra parsing to compute these flags, so the method cannot fail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200574 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c2c98e7884
commit
d8324e6983
@ -279,8 +279,7 @@ protected:
|
||||
error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const LLVM_OVERRIDE;
|
||||
error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
uint32_t getSymbolFlags(DataRefImpl Symb) const LLVM_OVERRIDE;
|
||||
error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const
|
||||
|
@ -65,7 +65,7 @@ protected:
|
||||
error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const LLVM_OVERRIDE;
|
||||
error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const;
|
||||
uint32_t getSymbolFlags(DataRefImpl Symb) const LLVM_OVERRIDE;
|
||||
error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const
|
||||
@ -378,11 +378,10 @@ error_code ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb,
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
error_code ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Symb,
|
||||
uint32_t &Result) const {
|
||||
uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Symb) const {
|
||||
const Elf_Sym *ESym = getSymbol(Symb);
|
||||
|
||||
Result = SymbolRef::SF_None;
|
||||
uint32_t Result = SymbolRef::SF_None;
|
||||
|
||||
if (ESym->getBinding() != ELF::STB_LOCAL)
|
||||
Result |= SymbolRef::SF_Global;
|
||||
@ -407,7 +406,7 @@ error_code ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Symb,
|
||||
if (ESym->getType() == ELF::STT_TLS)
|
||||
Result |= SymbolRef::SF_ThreadLocal;
|
||||
|
||||
return object_error::success;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
@ -71,8 +71,7 @@ public:
|
||||
error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const LLVM_OVERRIDE;
|
||||
error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
uint32_t getSymbolFlags(DataRefImpl Symb) const LLVM_OVERRIDE;
|
||||
error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const
|
||||
LLVM_OVERRIDE;
|
||||
error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const
|
||||
|
@ -219,7 +219,7 @@ public:
|
||||
error_code getType(SymbolRef::Type &Result) const;
|
||||
|
||||
/// Get symbol flags (bitwise OR of SymbolRef::Flags)
|
||||
error_code getFlags(uint32_t &Result) const;
|
||||
uint32_t getFlags() const;
|
||||
|
||||
/// @brief Get section this symbol is defined in reference to. Result is
|
||||
/// end_sections() if it is undefined or is an absolute symbol.
|
||||
@ -289,8 +289,7 @@ protected:
|
||||
virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const = 0;
|
||||
virtual error_code getSymbolType(DataRefImpl Symb,
|
||||
SymbolRef::Type &Res) const = 0;
|
||||
virtual error_code getSymbolFlags(DataRefImpl Symb,
|
||||
uint32_t &Res) const = 0;
|
||||
virtual uint32_t getSymbolFlags(DataRefImpl Symb) const = 0;
|
||||
virtual error_code getSymbolSection(DataRefImpl Symb,
|
||||
section_iterator &Res) const = 0;
|
||||
virtual error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const = 0;
|
||||
@ -428,8 +427,8 @@ inline error_code SymbolRef::getSize(uint64_t &Result) const {
|
||||
return OwningObject->getSymbolSize(SymbolPimpl, Result);
|
||||
}
|
||||
|
||||
inline error_code SymbolRef::getFlags(uint32_t &Result) const {
|
||||
return OwningObject->getSymbolFlags(SymbolPimpl, Result);
|
||||
inline uint32_t SymbolRef::getFlags() const {
|
||||
return OwningObject->getSymbolFlags(SymbolPimpl);
|
||||
}
|
||||
|
||||
inline error_code SymbolRef::getSection(section_iterator &Result) const {
|
||||
|
@ -124,8 +124,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
|
||||
Check(i->getType(SymType));
|
||||
Check(i->getName(Name));
|
||||
|
||||
uint32_t flags;
|
||||
Check(i->getFlags(flags));
|
||||
uint32_t flags = i->getFlags();
|
||||
|
||||
bool isCommon = flags & SymbolRef::SF_Common;
|
||||
if (isCommon) {
|
||||
|
@ -155,10 +155,9 @@ error_code COFFObjectFile::getSymbolType(DataRefImpl Ref,
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::getSymbolFlags(DataRefImpl Ref,
|
||||
uint32_t &Result) const {
|
||||
uint32_t COFFObjectFile::getSymbolFlags(DataRefImpl Ref) const {
|
||||
const coff_symbol *Symb = toSymb(Ref);
|
||||
Result = SymbolRef::SF_None;
|
||||
uint32_t Result = SymbolRef::SF_None;
|
||||
|
||||
// TODO: Correctly set SF_FormatSpecific, SF_ThreadLocal, SF_Common
|
||||
|
||||
@ -176,7 +175,7 @@ error_code COFFObjectFile::getSymbolFlags(DataRefImpl Ref,
|
||||
if (Symb->SectionNumber == COFF::IMAGE_SYM_ABSOLUTE)
|
||||
Result |= SymbolRef::SF_Absolute;
|
||||
|
||||
return object_error::success;
|
||||
return Result;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::getSymbolSize(DataRefImpl Ref,
|
||||
|
@ -495,8 +495,7 @@ MachOObjectFile::getSymbolFileOffset(DataRefImpl Symb,
|
||||
|
||||
error_code MachOObjectFile::getSymbolAlignment(DataRefImpl DRI,
|
||||
uint32_t &Result) const {
|
||||
uint32_t flags;
|
||||
this->getSymbolFlags(DRI, flags);
|
||||
uint32_t flags = getSymbolFlags(DRI);
|
||||
if (flags & SymbolRef::SF_Common) {
|
||||
nlist_base Entry = getSymbolTableEntryBase(this, DRI);
|
||||
Result = 1 << MachO::GET_COMM_ALIGN(Entry.n_desc);
|
||||
@ -520,8 +519,7 @@ error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
|
||||
|
||||
SectionIndex = Entry.n_sect;
|
||||
if (!SectionIndex) {
|
||||
uint32_t flags = SymbolRef::SF_None;
|
||||
this->getSymbolFlags(DRI, flags);
|
||||
uint32_t flags = getSymbolFlags(DRI);
|
||||
if (flags & SymbolRef::SF_Common)
|
||||
Result = Value;
|
||||
else
|
||||
@ -574,15 +572,14 @@ error_code MachOObjectFile::getSymbolType(DataRefImpl Symb,
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI,
|
||||
uint32_t &Result) const {
|
||||
uint32_t MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const {
|
||||
nlist_base Entry = getSymbolTableEntryBase(this, DRI);
|
||||
|
||||
uint8_t MachOType = Entry.n_type;
|
||||
uint16_t MachOFlags = Entry.n_desc;
|
||||
|
||||
// TODO: Correctly set SF_ThreadLocal
|
||||
Result = SymbolRef::SF_None;
|
||||
uint32_t Result = SymbolRef::SF_None;
|
||||
|
||||
if ((MachOType & MachO::N_TYPE) == MachO::N_UNDF)
|
||||
Result |= SymbolRef::SF_Undefined;
|
||||
@ -606,7 +603,7 @@ error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI,
|
||||
if ((MachOType & MachO::N_TYPE) == MachO::N_ABS)
|
||||
Result |= SymbolRef::SF_Absolute;
|
||||
|
||||
return object_error::success;
|
||||
return Result;
|
||||
}
|
||||
|
||||
error_code
|
||||
|
@ -719,8 +719,7 @@ static void writeSymbolTable(
|
||||
for (object::symbol_iterator I = Obj->begin_symbols(),
|
||||
E = Obj->end_symbols();
|
||||
I != E; ++I) {
|
||||
uint32_t Symflags;
|
||||
failIfError(I->getFlags(Symflags));
|
||||
uint32_t Symflags = I->getFlags();;
|
||||
if (Symflags & object::SymbolRef::SF_FormatSpecific)
|
||||
continue;
|
||||
if (!(Symflags & object::SymbolRef::SF_Global))
|
||||
|
@ -561,9 +561,7 @@ static void dumpSymbolNamesFromObject(ObjectFile *Obj) {
|
||||
getDynamicSymbolIterators(Obj, IBegin, IEnd);
|
||||
}
|
||||
for (symbol_iterator I = IBegin; I != IEnd; ++I) {
|
||||
uint32_t SymFlags;
|
||||
if (error(I->getFlags(SymFlags)))
|
||||
break;
|
||||
uint32_t SymFlags = I->getFlags();
|
||||
if (!DebugSyms && (SymFlags & SymbolRef::SF_FormatSpecific))
|
||||
continue;
|
||||
NMSymbol S;
|
||||
|
@ -702,11 +702,10 @@ static void PrintSymbolTable(const ObjectFile *o) {
|
||||
uint64_t Address;
|
||||
SymbolRef::Type Type;
|
||||
uint64_t Size;
|
||||
uint32_t Flags;
|
||||
uint32_t Flags = si->getFlags();
|
||||
section_iterator Section = o->end_sections();
|
||||
if (error(si->getName(Name))) continue;
|
||||
if (error(si->getAddress(Address))) continue;
|
||||
if (error(si->getFlags(Flags))) continue;
|
||||
if (error(si->getType(Type))) continue;
|
||||
if (error(si->getSize(Size))) continue;
|
||||
if (error(si->getSection(Section))) continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user