Skip to content

Commit a41bcb3

Browse files
committed
[lld][LoongArch] Fix handleUleb128
1 parent 2fe81ed commit a41bcb3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lld/ELF/Arch/LoongArch.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ static bool isJirl(uint32_t insn) {
159159
static void handleUleb128(uint8_t *loc, uint64_t val) {
160160
const uint32_t maxcount = 1 + 64 / 7;
161161
uint32_t count;
162-
uint64_t orig = decodeULEB128(loc, &count);
163-
if (count > maxcount)
162+
const char *error = nullptr;
163+
uint64_t orig = decodeULEB128(loc, &count, nullptr, &error);
164+
if (count > maxcount || (count == maxcount && error))
164165
errorOrWarn(getErrorLocation(loc) + "extra space for uleb128");
165166
uint64_t mask = count < maxcount ? (1ULL << 7 * count) - 1 : -1ULL;
166167
encodeULEB128((orig + val) & mask, loc, count);

0 commit comments

Comments
 (0)