aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-01-25 22:50:03 -0800
committerFangrui Song <i@maskray.me>2022-01-25 22:50:03 -0800
commit9fac78d0e1820b132964f6c1cfe22049d890d1d8 (patch)
tree27cb290b81778f63ed81c6cf775505fc7129dd73 /lld/ELF/SyntheticSections.cpp
parent4fb8e0b8621a641b38cf2218cc20301da346cedf (diff)
downloadllvm-9fac78d0e1820b132964f6c1cfe22049d890d1d8.zip
llvm-9fac78d0e1820b132964f6c1cfe22049d890d1d8.tar.gz
llvm-9fac78d0e1820b132964f6c1cfe22049d890d1d8.tar.bz2
[ELF] Simplify and optimize .relr.dyn NFC
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r--lld/ELF/SyntheticSections.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 87f4269..9f0cbf9 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2038,28 +2038,16 @@ template <class ELFT> bool RelrSection<ELFT>::updateAllocSize() {
++i;
// Find foldable relocations to construct bitmaps.
- while (i < e) {
+ for (;;) {
uint64_t bitmap = 0;
-
- while (i < e) {
- uint64_t delta = offsets[i] - base;
-
- // If it is too far, it cannot be folded.
- if (delta >= nBits * wordsize)
- break;
-
- // If it is not a multiple of wordsize away, it cannot be folded.
- if (delta % wordsize)
+ for (; i != e; ++i) {
+ uint64_t d = offsets[i] - base;
+ if (d >= nBits * wordsize || d % wordsize)
break;
-
- // Fold it.
- bitmap |= 1ULL << (delta / wordsize);
- ++i;
+ bitmap |= uint64_t(1) << (d / wordsize);
}
-
if (!bitmap)
break;
-
relrRelocs.push_back(Elf_Relr((bitmap << 1) | 1));
base += nBits * wordsize;
}