This patch makes jitlink to report an out of range error when the fixup value out of range
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This was clearly not done whilst referencing LLD's implementation as it's buggy. Please fix.
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp | ||
---|---|---|
199–201 | You need to check that Value + 0x800 is a 32-bit signed integer, not that Value is a 32-bit unsigned integer. LUI sign-extends, hence checking it as a signed integer, and the + 0x800 needs to be added to account for the slight asymmetry resulting from the ADDI/etc's sign-extension of the LO12. | |
212 | LO12 should never be range checked, it's a waste of time as the HI20 half will also range check. | |
233 | As with HI20, this needs to check Value + 0x800, not Value. But this at least already checks it as a signed integer rather than an unsigned integer. | |
251 | As with LO12, these are a waste of time |
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp | ||
---|---|---|
212 | If LO12/HI20 relocations are always paired then it seems reasonable to elide the range check here, but we'd need a check that both elements of the pair are present in the input object: JITLink's policy is to assume that objects may be malformed / maliciously crafted and always check. That needn't be addressed straight away, but we should at least add a FIXME for it. |
You need to check that Value + 0x800 is a 32-bit signed integer, not that Value is a 32-bit unsigned integer. LUI sign-extends, hence checking it as a signed integer, and the + 0x800 needs to be added to account for the slight asymmetry resulting from the ADDI/etc's sign-extension of the LO12.