1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 13:06:59 +03:00

Merge pull request #1058 from andreas-schwab/main

This commit is contained in:
Rui Ueyama 2023-07-24 19:09:17 +09:00 committed by GitHub
commit 6e8a9dfec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,6 +127,7 @@ static void overwrite_uleb(u8 *loc, u64 val) {
*loc++ = 0b1000'0000 | (val & 0b0111'1111);
val >>= 7;
}
*loc = val & 0b0111'1111;
}
// Returns the rd register of an R/I/U/J-type instruction.
@ -527,6 +528,15 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
case R_RISCV_32_PCREL:
*(U32<E> *)loc = S + A - P;
break;
case R_RISCV_SET_ULEB128:
overwrite_uleb(loc, S + A);
break;
case R_RISCV_SUB_ULEB128: {
u8 *p = loc;
u64 val = read_uleb(p);
overwrite_uleb(loc, val - (S + A));
break;
}
default:
unreachable();
}
@ -726,6 +736,8 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_RISCV_SET8:
case R_RISCV_SET16:
case R_RISCV_SET32:
case R_RISCV_SET_ULEB128:
case R_RISCV_SUB_ULEB128:
break;
default:
Error(ctx) << *this << ": unknown relocation: " << rel;