aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-31 20:57:12 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-31 20:57:12 +0000
commit20122a436c31f61a0063f10759589ec0c73bac31 (patch)
treed406560fbb040d1553cbe5139f6a4b58ae2fd936 /llvm/lib/Object/MachOObjectFile.cpp
parent67294e253edd8cc39a6c66100b777a034d46761d (diff)
downloadllvm-20122a436c31f61a0063f10759589ec0c73bac31.zip
llvm-20122a436c31f61a0063f10759589ec0c73bac31.tar.gz
llvm-20122a436c31f61a0063f10759589ec0c73bac31.tar.bz2
Simplify getSymbolFlags.
None of the object formats require extra parsing to compute these flags, so the method cannot fail. llvm-svn: 200574
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index aca12197..385d0b6 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -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