aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeining Lu <luweining@loongson.cn>2024-03-05 23:19:16 +0800
committerllvmbot <60944935+llvmbot@users.noreply.github.com>2024-03-16 18:28:00 -0700
commitedbe7fa5fef93bb747cb58a589dc25901793774b (patch)
tree431fbf7375d360b642852a22e409aa78ac6469e8
parentb95ea2e51bdfe20c9db6a0675ab068fa59a0b9fe (diff)
downloadllvm-edbe7fa5fef93bb747cb58a589dc25901793774b.zip
llvm-edbe7fa5fef93bb747cb58a589dc25901793774b.tar.gz
llvm-edbe7fa5fef93bb747cb58a589dc25901793774b.tar.bz2
[lld][LoongArch] Fix handleUleb128
(cherry picked from commit a41bcb3930534ef1525b4fc30e53e818b39e2b60)
-rw-r--r--lld/ELF/Arch/LoongArch.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp
index 8a6f6db..464f5df 100644
--- a/lld/ELF/Arch/LoongArch.cpp
+++ b/lld/ELF/Arch/LoongArch.cpp
@@ -159,8 +159,9 @@ static bool isJirl(uint32_t insn) {
static void handleUleb128(uint8_t *loc, uint64_t val) {
const uint32_t maxcount = 1 + 64 / 7;
uint32_t count;
- uint64_t orig = decodeULEB128(loc, &count);
- if (count > maxcount)
+ const char *error = nullptr;
+ uint64_t orig = decodeULEB128(loc, &count, nullptr, &error);
+ if (count > maxcount || (count == maxcount && error))
errorOrWarn(getErrorLocation(loc) + "extra space for uleb128");
uint64_t mask = count < maxcount ? (1ULL << 7 * count) - 1 : -1ULL;
encodeULEB128((orig + val) & mask, loc, count);