summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-02-14 19:21:10 +0000
committerRui Ueyama <ruiu@google.com>2019-02-14 19:21:10 +0000
commit980fb790c1791cbf7589053b15fccb6f9c14db5d (patch)
treeb4bd56875bcfef9c758a118cf4c5e3ba3a59c596
parent4d0934c48f361367edf249f8982e59a90105fb40 (diff)
downloadbcm5719-llvm-980fb790c1791cbf7589053b15fccb6f9c14db5d.tar.gz
bcm5719-llvm-980fb790c1791cbf7589053b15fccb6f9c14db5d.zip
Remove a comparator from header and instead use lambdas for simplicity. NFC.
llvm-svn: 354052
-rw-r--r--lld/ELF/InputSection.cpp14
-rw-r--r--lld/ELF/Relocations.cpp4
-rw-r--r--lld/ELF/Relocations.h15
3 files changed, 13 insertions, 20 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 03326ff3689..6f05fde46d3 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -557,10 +557,16 @@ static Relocation *getRISCVPCRelHi20(const Symbol *Sym, uint64_t Addend) {
// Relocations are sorted by offset, so we can use std::equal_range to do
// binary search.
- auto Range = std::equal_range(IS->Relocations.begin(), IS->Relocations.end(),
- D->Value, RelocationOffsetComparator{});
- for (auto It = std::get<0>(Range); It != std::get<1>(Range); ++It)
- if (isRelExprOneOf<R_PC>(It->Expr))
+ Relocation R;
+ R.Offset = D->Value;
+ auto Range =
+ std::equal_range(IS->Relocations.begin(), IS->Relocations.end(), R,
+ [](const Relocation &LHS, const Relocation &RHS) {
+ return LHS.Offset < RHS.Offset;
+ });
+
+ for (auto It = Range.first; It != Range.second; ++It)
+ if (It->Expr == R_PC)
return &*It;
error("R_RISCV_PCREL_LO12 relocation points to " + IS->getObjMsg(D->Value) +
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 668db477e8b..ab2113b1b84 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1196,7 +1196,9 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) {
// Sort relocations by offset to binary search for R_RISCV_PCREL_HI20
if (Config->EMachine == EM_RISCV)
std::stable_sort(Sec.Relocations.begin(), Sec.Relocations.end(),
- RelocationOffsetComparator{});
+ [](const Relocation &LHS, const Relocation &RHS) {
+ return LHS.Offset < RHS.Offset;
+ });
}
template <class ELFT> void elf::scanRelocations(InputSectionBase &S) {
diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h
index 954885e021f..3298bfcfdb0 100644
--- a/lld/ELF/Relocations.h
+++ b/lld/ELF/Relocations.h
@@ -134,21 +134,6 @@ struct Relocation {
Symbol *Sym;
};
-struct RelocationOffsetComparator {
- bool operator()(const Relocation &Lhs, const Relocation &Rhs) {
- return Lhs.Offset < Rhs.Offset;
- }
-
- // For std::lower_bound, std::upper_bound, std::equal_range.
- bool operator()(const Relocation &Rel, uint64_t Val) {
- return Rel.Offset < Val;
- }
-
- bool operator()(uint64_t Val, const Relocation &Rel) {
- return Val < Rel.Offset;
- }
-};
-
template <class ELFT> void scanRelocations(InputSectionBase &);
void addIRelativeRelocs();
OpenPOWER on IntegriCloud