[lld] [lld][LoongArch] Support the R_LARCH_{ADD,SUB}_ULEB128 relocation types (PR #81133)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 21:10:43 PST 2024
================
@@ -153,6 +154,20 @@ static bool isJirl(uint32_t insn) {
return (insn & 0xfc000000) == JIRL;
}
+static void handleUleb128(uint8_t *loc, uint64_t val) {
+ const uint32_t maxcount = 1 + (config->is64 ? 64 : 32) / 7;
+ uint32_t count;
+ uint64_t orig = decodeULEB128(loc, &count);
+ if (count > maxcount)
+ errorOrWarn(getErrorLocation(loc) + "extra space for uleb128");
+ uint64_t mask = config->is64 ? -1 : -1u;
+ if (count < maxcount)
+ mask = (1ULL << 7 * count) - 1;
+
+ val = (orig + val) & mask;
+ encodeULEB128(val, loc, count);
----------------
MaskRay wrote:
`encodeULEB128((orig + val) & mask, loc, count);` to avoid changing `val`
https://github.com/llvm/llvm-project/pull/81133
More information about the llvm-commits
mailing list