diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/Object/Object.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Object/SymbolSize.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp | 2 |
7 files changed, 25 insertions, 32 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 6d64d683743..22de8c8ba29 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -118,8 +118,8 @@ static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) { if (std::error_code EC = Sym.getAddress(Address)) return EC; - if (Address == UnknownAddressOrSize) { - Result = UnknownAddressOrSize; + if (Address == UnknownAddress) { + Result = UnknownAddress; return std::error_code(); } @@ -129,7 +129,7 @@ static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) { return EC; if (SecI == Obj->section_end()) { - Result = UnknownAddressOrSize; + Result = UnknownAddress; return std::error_code(); } @@ -387,7 +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 = I->getSize(); + uint64_t Size = I->getCommonSize(); CommonSize += Size; } } @@ -494,7 +494,7 @@ void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj, } uint32_t Align = Sym.getAlignment(); - uint64_t Size = Sym.getSize(); + uint64_t Size = Sym.getCommonSize(); CommonSize += Align + Size; SymbolsToAllocate.push_back(Sym); @@ -517,7 +517,7 @@ void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj, for (auto &Sym : SymbolsToAllocate) { uint32_t Align = Sym.getAlignment(); StringRef Name; - uint64_t Size = Sym.getSize(); + uint64_t Size = Sym.getCommonSize(); Check(Sym.getName(Name)); if (Align) { // This symbol has an alignment requirement. diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp index c8d3d22966d..5ec062da07f 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp @@ -64,18 +64,18 @@ RuntimeDyldCOFF::loadObject(const object::ObjectFile &O) { uint64_t RuntimeDyldCOFF::getSymbolOffset(const SymbolRef &Sym) { uint64_t Address; if (Sym.getAddress(Address)) - return UnknownAddressOrSize; + return UnknownAddress; - if (Address == UnknownAddressOrSize) - return UnknownAddressOrSize; + if (Address == UnknownAddress) + return UnknownAddress; const ObjectFile *Obj = Sym.getObject(); section_iterator SecI(Obj->section_end()); if (Sym.getSection(SecI)) - return UnknownAddressOrSize; + return UnknownAddress; if (SecI == Obj->section_end()) - return UnknownAddressOrSize; + return UnknownAddress; uint64_t SectionAddress = SecI->getAddress(); return Address - SectionAddress; diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index e2f559eec72..0595d38f086 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -155,11 +155,11 @@ std::error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref, COFFSymbolRef Symb = getCOFFSymbol(Ref); if (Symb.isAnyUndefined()) { - Result = UnknownAddressOrSize; + Result = UnknownAddress; return std::error_code(); } if (Symb.isCommon()) { - Result = UnknownAddressOrSize; + Result = UnknownAddress; return std::error_code(); } int32_t SectionNumber = Symb.getSectionNumber(); @@ -236,12 +236,9 @@ uint32_t COFFObjectFile::getSymbolFlags(DataRefImpl Ref) const { return Result; } -uint64_t COFFObjectFile::getSymbolSize(DataRefImpl Ref) const { +uint64_t COFFObjectFile::getCommonSymbolSizeImpl(DataRefImpl Ref) const { COFFSymbolRef Symb = getCOFFSymbol(Ref); - - if (Symb.isCommon()) - return Symb.getValue(); - return UnknownAddressOrSize; + return Symb.getValue(); } std::error_code diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index f76dd0d3f7c..ded81099300 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -375,14 +375,14 @@ std::error_code MachOObjectFile::getSymbolAddress(DataRefImpl Symb, MachO::nlist_64 Entry = getSymbol64TableEntry(Symb); if ((Entry.n_type & MachO::N_TYPE) == MachO::N_UNDF && Entry.n_value == 0) - Res = UnknownAddressOrSize; + Res = UnknownAddress; else Res = Entry.n_value; } else { MachO::nlist Entry = getSymbolTableEntry(Symb); if ((Entry.n_type & MachO::N_TYPE) == MachO::N_UNDF && Entry.n_value == 0) - Res = UnknownAddressOrSize; + Res = UnknownAddress; else Res = Entry.n_value; } @@ -398,13 +398,10 @@ uint32_t MachOObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; } -uint64_t MachOObjectFile::getSymbolSize(DataRefImpl DRI) const { +uint64_t MachOObjectFile::getCommonSymbolSizeImpl(DataRefImpl DRI) const { uint64_t Value; getSymbolAddress(DRI, Value); - uint32_t flags = getSymbolFlags(DRI); - if (flags & SymbolRef::SF_Common) - return Value; - return UnknownAddressOrSize; + return Value; } std::error_code MachOObjectFile::getSymbolType(DataRefImpl Symb, @@ -453,7 +450,7 @@ uint32_t MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const { if ((MachOType & MachO::N_TYPE) == MachO::N_UNDF) { uint64_t Value; getSymbolAddress(DRI, Value); - if (Value && Value != UnknownAddressOrSize) + if (Value && Value != UnknownAddress) Result |= SymbolRef::SF_Common; } diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp index 85f243675ef..42da2e4c33e 100644 --- a/llvm/lib/Object/Object.cpp +++ b/llvm/lib/Object/Object.cpp @@ -187,7 +187,7 @@ uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI) { } uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI) { - return (*unwrap(SI))->getSize(); + return (*unwrap(SI))->getCommonSize(); } // RelocationRef accessors diff --git a/llvm/lib/Object/SymbolSize.cpp b/llvm/lib/Object/SymbolSize.cpp index 121bf1baa7a..925a3d4df46 100644 --- a/llvm/lib/Object/SymbolSize.cpp +++ b/llvm/lib/Object/SymbolSize.cpp @@ -41,10 +41,9 @@ ErrorOr<std::vector<std::pair<SymbolRef, uint64_t>>> llvm::object::computeSymbolSizes(const ObjectFile &O) { std::vector<std::pair<SymbolRef, uint64_t>> Ret; - if (isa<ELFObjectFileBase>(&O)) { - for (SymbolRef Sym : O.symbols()) { - Ret.push_back({Sym, Sym.getSize()}); - } + if (const auto *E = dyn_cast<ELFObjectFileBase>(&O)) { + for (SymbolRef Sym : E->symbols()) + Ret.push_back({Sym, E->getSymbolSize(Sym)}); return Ret; } diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp index 7c09e5d5958..a84c4c58494 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp @@ -31,8 +31,8 @@ public: StringRef SymName; SymI->getName(SymName); uint64_t SymAddr; SymI->getAddress(SymAddr); - uint64_t SymSize = SymI->getSize(); auto *Obj = cast<ELFObjectFileBase>(Rel.getObjectFile()); + uint64_t SymSize = Obj->getSymbolSize(*SymI); int64_t Addend = *Obj->getRelocationAddend(Rel.getRawDataRefImpl()); MCSymbol *Sym = Ctx.getOrCreateSymbol(SymName); |

