Skip to content

Commit

Permalink
[BOLT] Remove allow-section-relocations option
Browse files Browse the repository at this point in the history
Summary: The option is not used. Remove all related code.

(cherry picked from FBD20237859)
  • Loading branch information
maksfb committed Mar 3, 2020
1 parent c7e012e commit cb9c991
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 43 deletions.
11 changes: 4 additions & 7 deletions bolt/src/BinaryContext.cpp
Expand Up @@ -882,22 +882,19 @@ MCSymbol *BinaryContext::registerNameAtAddress(StringRef Name,
}

const BinaryData *
BinaryContext::getBinaryDataContainingAddressImpl(uint64_t Address,
bool IncludeEnd) const {
BinaryContext::getBinaryDataContainingAddressImpl(uint64_t Address) const {
auto NI = BinaryDataMap.lower_bound(Address);
auto End = BinaryDataMap.end();
if ((NI != End && Address == NI->first && !IncludeEnd) ||
if ((NI != End && Address == NI->first) ||
((NI != BinaryDataMap.begin()) && (NI-- != BinaryDataMap.begin()))) {
if (NI->second->containsAddress(Address) ||
(IncludeEnd && NI->second->getEndAddress() == Address)) {
if (NI->second->containsAddress(Address)) {
return NI->second;
}

// If this is a sub-symbol, see if a parent data contains the address.
auto *BD = NI->second->getParent();
while (BD) {
if (BD->containsAddress(Address) ||
(IncludeEnd && NI->second->getEndAddress() == Address))
if (BD->containsAddress(Address))
return BD;
BD = BD->getParent();
}
Expand Down
14 changes: 5 additions & 9 deletions bolt/src/BinaryContext.h
Expand Up @@ -270,8 +270,7 @@ class BinaryContext {
/// Look up the symbol entry that contains the given \p Address (based on
/// the start address and size for each symbol). Returns a pointer to
/// the BinaryData for that symbol. If no data is found, nullptr is returned.
const BinaryData *getBinaryDataContainingAddressImpl(uint64_t Address,
bool IncludeEnd) const;
const BinaryData *getBinaryDataContainingAddressImpl(uint64_t Address) const;

/// Update the Parent fields in BinaryDatas after adding a new entry into
/// \p BinaryDataMap.
Expand Down Expand Up @@ -620,16 +619,13 @@ class BinaryContext {
/// the start address and size for each symbol). Returns a pointer to
/// the BinaryData for that symbol. If no data is found, nullptr is returned.
const BinaryData *
getBinaryDataContainingAddress(uint64_t Address,
bool IncludeEnd = false) const {
return getBinaryDataContainingAddressImpl(Address, IncludeEnd);
getBinaryDataContainingAddress(uint64_t Address) const {
return getBinaryDataContainingAddressImpl(Address);
}

BinaryData *getBinaryDataContainingAddress(uint64_t Address,
bool IncludeEnd = false) {
BinaryData *getBinaryDataContainingAddress(uint64_t Address) {
return
const_cast<BinaryData *>(getBinaryDataContainingAddressImpl(Address,
IncludeEnd));
const_cast<BinaryData *>(getBinaryDataContainingAddressImpl(Address));
}

/// Return BinaryData for the given \p Name or nullptr if no
Expand Down
30 changes: 3 additions & 27 deletions bolt/src/RewriteInstance.cpp
Expand Up @@ -122,16 +122,6 @@ ForceToDataRelocations("force-data-relocations",
cl::ZeroOrMore,
cl::cat(BoltCategory));

// Note: enabling this is liable to make things break.
static cl::opt<bool>
AllowSectionRelocations("allow-section-relocations",
cl::desc("allow reordering of data referenced by section relocations "
"(experimental)"),
cl::init(false),
cl::Hidden,
cl::ZeroOrMore,
cl::cat(BoltOptCategory));

static cl::opt<bool>
PrintCacheMetrics("print-cache-metrics",
cl::desc("calculate and print various metrics for instruction cache"),
Expand Down Expand Up @@ -2235,21 +2225,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
Addend = 0;
}

// If we are allowing section relocations, we assign relocations
// that are pointing to the end of a symbol to that symbol rather
// than the following symbol.
const auto IncludeEnd =
opts::AllowSectionRelocations && IsSectionRelocation;

if (auto *BD = BC->getBinaryDataContainingAddress(SymbolAddress,
IncludeEnd)) {
assert(!IncludeEnd ||
(BD == BC->getBinaryDataContainingAddress(SymbolAddress) ||
!BC->getBinaryDataContainingAddress(SymbolAddress) ||
(IsSectionRelocation && BD->getEndAddress() ==
BC->getBinaryDataContainingAddress(SymbolAddress)->
getAddress())));

if (auto *BD = BC->getBinaryDataContainingAddress(SymbolAddress)) {
// Note: this assertion is trying to check sanity of BinaryData objects
// but AArch64 has inferred and incomplete object locations coming from
// GOT/TLS or any other non-trivial relocation (that requires creation
Expand All @@ -2266,7 +2242,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
"BOLT symbol names of all non-section relocations must match "
"up with symbol names referenced in the relocation");

if (!opts::AllowSectionRelocations && IsSectionRelocation) {
if (IsSectionRelocation) {
BC->markAmbiguousRelocations(*BD, Address);
}

Expand Down Expand Up @@ -2310,7 +2286,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
SymbolFlags);
}

if (!opts::AllowSectionRelocations && IsSectionRelocation) {
if (IsSectionRelocation) {
auto *BD = BC->getBinaryDataByName(ReferencedSymbol->getName());
BC->markAmbiguousRelocations(*BD, Address);
}
Expand Down

0 comments on commit cb9c991

Please sign in to comment.