Skip to content

Commit

Permalink
[lld][LoongArch] Fix handleUleb128
Browse files Browse the repository at this point in the history
(cherry picked from commit a41bcb3)
  • Loading branch information
SixWeining authored and llvmbot committed Mar 17, 2024
1 parent b95ea2e commit edbe7fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lld/ELF/Arch/LoongArch.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit edbe7fa

Please sign in to comment.