aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-12-07 12:10:41 -0800
committerFangrui Song <i@maskray.me>2023-12-07 12:10:42 -0800
commita4d4b45aef6dbac1cead60dcba5e60939fc1656d (patch)
treef24cdd01a5cc5f7e9f6c4e1302763430930ba51f
parent2b1c76c7c4d62f4470fe1527bf239f380c19760a (diff)
downloadllvm-a4d4b45aef6dbac1cead60dcba5e60939fc1656d.zip
llvm-a4d4b45aef6dbac1cead60dcba5e60939fc1656d.tar.gz
llvm-a4d4b45aef6dbac1cead60dcba5e60939fc1656d.tar.bz2
[ELF] relocateNonAlloc: move likely expr == R_ABS before unlikely R_SIZE. NFC
-rw-r--r--lld/ELF/InputSection.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 145d55d..2c06bb5 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -999,20 +999,20 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef<RelTy> rels) {
if (config->relocatable && (RelTy::IsRela || sym.type != STT_SECTION))
continue;
- if (expr == R_SIZE) {
- target.relocateNoSym(bufLoc, type,
- SignExtend64<bits>(sym.getSize() + addend));
- continue;
- }
-
// R_ABS/R_DTPREL and some other relocations can be used from non-SHF_ALLOC
// sections.
- if (expr == R_ABS || expr == R_DTPREL || expr == R_GOTPLTREL ||
+ if (LLVM_LIKELY(expr == R_ABS) || expr == R_DTPREL || expr == R_GOTPLTREL ||
expr == R_RISCV_ADD) {
target.relocateNoSym(bufLoc, type, SignExtend64<bits>(sym.getVA(addend)));
continue;
}
+ if (expr == R_SIZE) {
+ target.relocateNoSym(bufLoc, type,
+ SignExtend64<bits>(sym.getSize() + addend));
+ continue;
+ }
+
std::string msg = getLocation(offset) + ": has non-ABS relocation " +
toString(type) + " against symbol '" + toString(sym) +
"'";