summaryrefslogtreecommitdiffstats
path: root/lld/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF')
-rw-r--r--lld/ELF/InputSection.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 38654d5a573..97df0331955 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -1223,18 +1223,11 @@ SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) {
// If Offset is not at beginning of a section piece, it is not in the map.
// In that case we need to do a binary search of the original section piece vector.
- size_t Size = Pieces.size();
- size_t Idx = 0;
-
- while (Size != 1) {
- size_t H = Size / 2;
- Size -= H;
- if (Pieces[Idx + H].InputOff <= Offset)
- Idx += H;
- }
- if (Offset < Pieces[Idx].InputOff)
- --Idx;
- return &Pieces[Idx];
+ auto It2 =
+ llvm::upper_bound(Pieces, Offset, [](uint64_t Offset, SectionPiece P) {
+ return Offset < P.InputOff;
+ });
+ return &It2[-1];
}
// Returns the offset in an output section for a given input offset.
OpenPOWER on IntegriCloud