-
Notifications
You must be signed in to change notification settings - Fork 234
64-bit relocations? (Error: value of -549755813888 too large for field of 4 bytes at 0) #168
Comments
Hmm, I agree you should be able to do that. Obviously, the final address |
In |
Thanks, I'll run it though and see what I find. What is the "complete bootstrap"? |
Use it to build the linux kernel, glibc, and the user-space stuff. |
A size of 2 translates to 4 bytes. A size of 3 translates to 0 bytes. I think you mean a size of 4 which translates to 8 bytes. It might be useful to make this conditional on the target ISA size, as a size of 2 is always OK for rv32, it is only rv64 that can use a size of 4 here. Note that the only relocs that currently have a size of 3 are R_RISCV_NONE and R_RISCV_RELAX both of which are placeholder relocs that don't directly modify the binary. It looks like a value of 3 works by accident, because gas disables the overflow check when a reloc has a size of 0. And in the linker we are handling this reloc directly in perform_relocation without using the reloc size. We shouldn't be using something that only works by accident. A value of 4 fails because now the reloc size is larger than the instruction, and I get a "fixup not contained within frag" error because it thinks we are trying to write past the end of memory. So that can't be right either. I think we need a different solution here. Like setting the fx_no_overflow bit in gas for this fixup, to disable the inappropriate overflow check. This may require doing our own overflow checking in md_apply_fix. Or maybe gas should be a little smarter, and disable the overflow check for pc-relative relocs, as you can't expect to detect overflow in this case in the assembler when we don't know the link time address yet. I see that the z8k port is setting fx_no_overflow for pc-relative relocs. Actually, in the mips gas port, I see |
I can confirm that the patch below worked for my problem, but I gave up trying to claim that this is correct & sufficient:
|
I briefly looked into this, but it looks hairy to me. If you try to assemble (with the riscv64 version
of GAS)
you hit
The message comes from https://github.com/riscv/riscv-binutils-gdb/blob/riscv-binutils-2.31.1/gas/write.c#L1113 which looks like generic GAS.
The text was updated successfully, but these errors were encountered: