Skip to content

Commit 76029cc

Browse files
maksfbspupyrev
authored and
spupyrev
committed
Rebase: [Facebook] Revert "[BOLT] Update dynamic relocations from section relocations"
Summary: This reverts commit 729d29e. Needed as a workaround for T112872562. Manual rebase conflict history: https://phabricator.intern.facebook.com/D35230076 https://phabricator.intern.facebook.com/D35681740 Test Plan: sandcastle Reviewers: #llvm-bolt Subscribers: spupyrev Differential Revision: https://phabricator.intern.facebook.com/D37098481
1 parent 6d05286 commit 76029cc

File tree

8 files changed

+41
-925
lines changed

8 files changed

+41
-925
lines changed

bolt/include/bolt/Core/BinarySection.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,6 @@ class BinarySection {
296296
return make_range(Relocations.begin(), Relocations.end());
297297
}
298298

299-
/// Iterate over all dynamic relocations for this section.
300-
iterator_range<RelocationSetType::iterator> dynamicRelocations() {
301-
return make_range(DynamicRelocations.begin(), DynamicRelocations.end());
302-
}
303-
304-
/// Iterate over all dynamic relocations for this section.
305-
iterator_range<RelocationSetType::const_iterator> dynamicRelocations() const {
306-
return make_range(DynamicRelocations.begin(), DynamicRelocations.end());
307-
}
308-
309299
/// Does this section have any non-pending relocations?
310300
bool hasRelocations() const { return !Relocations.empty(); }
311301

bolt/include/bolt/Core/Relocation.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ struct Relocation {
9595
/// Return true if relocation type is for thread local storage.
9696
static bool isTLS(uint64_t Type);
9797

98-
/// Return code for a NONE relocation
99-
static uint64_t getNone();
100-
10198
/// Return code for a PC-relative 4-byte relocation
10299
static uint64_t getPC32();
103100

@@ -107,10 +104,6 @@ struct Relocation {
107104
/// Return true if this relocation is PC-relative. Return false otherwise.
108105
bool isPCRelative() const { return isPCRelative(Type); }
109106

110-
/// Return true if this relocation is R_*_RELATIVE type. Return false
111-
/// otherwise.
112-
bool isRelative() const { return isRelative(Type); }
113-
114107
/// Emit relocation at a current \p Streamer' position. The caller is
115108
/// responsible for setting the position correctly.
116109
size_t emit(MCStreamer *Streamer) const;

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "llvm/Support/Error.h"
2323
#include <map>
2424
#include <set>
25-
#include <unordered_map>
2625

2726
namespace llvm {
2827

@@ -132,7 +131,7 @@ class RewriteInstance {
132131
void processLKSMPLocks();
133132

134133
/// Read relocations from a given section.
135-
void readDynamicRelocations(const object::SectionRef &Section, bool IsJmpRel);
134+
void readDynamicRelocations(const object::SectionRef &Section);
136135

137136
/// Read relocations from a given section.
138137
void readRelocations(const object::SectionRef &Section);
@@ -209,10 +208,6 @@ class RewriteInstance {
209208
/// \p OldAddress address in the original binary.
210209
uint64_t getNewFunctionAddress(uint64_t OldAddress);
211210

212-
/// Return address of a function or moved data in the new binary
213-
/// corresponding to \p OldAddress address in the original binary.
214-
uint64_t getNewFunctionOrDataAddress(uint64_t OldAddress);
215-
216211
/// Return value for the symbol \p Name in the output.
217212
uint64_t getNewValueForSymbol(const StringRef Name);
218213

@@ -324,14 +319,6 @@ class RewriteInstance {
324319
const std::vector<uint32_t> &NewSectionIndex, WriteFuncTy Write,
325320
StrTabFuncTy AddToStrTab);
326321

327-
/// Get output index in dynamic symbol table.
328-
uint32_t getOutputDynamicSymbolIndex(const MCSymbol *Symbol) {
329-
auto It = SymbolIndex.find(Symbol);
330-
if (It != SymbolIndex.end())
331-
return It->second;
332-
return 0;
333-
}
334-
335322
/// Add a notes section containing the BOLT revision and command line options.
336323
void addBoltInfoSection();
337324

@@ -459,19 +446,11 @@ class RewriteInstance {
459446
/// Location and size of dynamic relocations.
460447
Optional<uint64_t> DynamicRelocationsAddress;
461448
uint64_t DynamicRelocationsSize{0};
462-
uint64_t DynamicRelativeRelocationsCount{0};
463449

464450
/// PLT relocations are special kind of dynamic relocations stored separately.
465451
Optional<uint64_t> PLTRelocationsAddress;
466452
uint64_t PLTRelocationsSize{0};
467453

468-
/// True if relocation of specified type came from .rela.plt
469-
DenseMap<uint64_t, bool> IsJmpRelocation;
470-
471-
/// Index of specified symbol in the dynamic symbol table. NOTE Currently it
472-
/// is filled and used only with the relocations-related symbols.
473-
std::unordered_map<const MCSymbol *, uint32_t> SymbolIndex;
474-
475454
/// Store all non-zero symbols in this map for a quick address lookup.
476455
std::map<uint64_t, llvm::object::SymbolRef> FileSymRefs;
477456

bolt/lib/Core/Relocation.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ bool Relocation::isX86GOTPCRELX(uint64_t Type) {
580580
return Type == ELF::R_X86_64_GOTPCRELX || Type == ELF::R_X86_64_REX_GOTPCRELX;
581581
}
582582

583-
bool Relocation::isNone(uint64_t Type) { return Type == getNone(); }
583+
bool Relocation::isNone(uint64_t Type) {
584+
if (Arch == Triple::aarch64)
585+
return Type == ELF::R_AARCH64_NONE;
586+
return Type == ELF::R_X86_64_NONE;
587+
}
584588

585589
bool Relocation::isRelative(uint64_t Type) {
586590
if (Arch == Triple::aarch64)
@@ -600,10 +604,10 @@ bool Relocation::isTLS(uint64_t Type) {
600604
return isTLSX86(Type);
601605
}
602606

603-
uint64_t Relocation::getNone() {
607+
bool Relocation::isPCRelative(uint64_t Type) {
604608
if (Arch == Triple::aarch64)
605-
return ELF::R_AARCH64_NONE;
606-
return ELF::R_X86_64_NONE;
609+
return isPCRelativeAArch64(Type);
610+
return isPCRelativeX86(Type);
607611
}
608612

609613
uint64_t Relocation::getPC32() {
@@ -618,12 +622,6 @@ uint64_t Relocation::getPC64() {
618622
return ELF::R_X86_64_PC64;
619623
}
620624

621-
bool Relocation::isPCRelative(uint64_t Type) {
622-
if (Arch == Triple::aarch64)
623-
return isPCRelativeAArch64(Type);
624-
return isPCRelativeX86(Type);
625-
}
626-
627625
size_t Relocation::emit(MCStreamer *Streamer) const {
628626
const size_t Size = getSizeForType(Type);
629627
MCContext &Ctx = Streamer->getContext();

0 commit comments

Comments
 (0)