mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 04:17:17 +08:00
[BOLT][PR] readDynamicRelocations: Skip NONE relocations
Summary: NONE relocations should not be processed during dynamic relocations read process Vladislav Khmelevsky, Advanced Software Technology Lab, Huawei Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/118 GitHub Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi@huawei.com> (cherry picked from FBD26489881)
This commit is contained in:
committed by
Maksim Panchenko
parent
06959eedcf
commit
ec9751eef5
@@ -349,6 +349,12 @@ bool Relocation::isGOT(uint64_t Type) {
|
||||
return isGOTX86(Type);
|
||||
}
|
||||
|
||||
bool Relocation::isNone(uint64_t Type) {
|
||||
if (Arch == Triple::aarch64)
|
||||
return Type == ELF::R_AARCH64_NONE;
|
||||
return Type == ELF::R_X86_64_NONE;
|
||||
}
|
||||
|
||||
bool Relocation::isTLS(uint64_t Type) {
|
||||
if (Arch == Triple::aarch64)
|
||||
return isTLSAArch64(Type);
|
||||
|
||||
@@ -69,6 +69,9 @@ struct Relocation {
|
||||
/// Return true if relocation type implies the creation of a GOT entry
|
||||
static bool isGOT(uint64_t Type);
|
||||
|
||||
/// Return true if relocation type is NONE
|
||||
static bool isNone(uint64_t Type);
|
||||
|
||||
/// Return true if relocation type is for thread local storage.
|
||||
static bool isTLS(uint64_t Type);
|
||||
|
||||
|
||||
@@ -2158,13 +2158,16 @@ void RewriteInstance::readDynamicRelocations(const SectionRef &Section) {
|
||||
<< SectionName << ":\n");
|
||||
|
||||
for (const auto &Rel : Section.relocations()) {
|
||||
auto SymbolIter = Rel.getSymbol();
|
||||
auto RType = Rel.getType();
|
||||
if (Relocation::isNone(RType))
|
||||
continue;
|
||||
|
||||
StringRef SymbolName = "<none>";
|
||||
MCSymbol *Symbol = nullptr;
|
||||
uint64_t SymbolAddress = 0;
|
||||
const uint64_t Addend = getRelocationAddend(InputFile, Rel);
|
||||
|
||||
auto SymbolIter = Rel.getSymbol();
|
||||
if (SymbolIter != InputFile->symbol_end()) {
|
||||
SymbolName = cantFail(SymbolIter->getName());
|
||||
auto *BD = BC->getBinaryDataByName(SymbolName);
|
||||
|
||||
Reference in New Issue
Block a user