[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:
Vladislav Khmelevsky
2021-02-17 15:36:58 -08:00
committed by Maksim Panchenko
parent 06959eedcf
commit ec9751eef5
3 changed files with 13 additions and 1 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);