[lld] [lld][ELF][AVR] Add range check for R_AVR_13_PCREL (PR #67636)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 19 04:55:06 PDT 2024
aykevl wrote:
A correct fix is the following:
```diff
--- a/lld/ELF/Arch/AVR.cpp
+++ b/lld/ELF/Arch/AVR.cpp
@@ -231,7 +231,7 @@ void AVR::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
// Since every jump destination is word aligned we gain an extra bit
case R_AVR_7_PCREL: {
- checkInt(loc, val - 2, 7, rel);
+ checkInt(loc, val - 2, 8, rel);
checkAlignment(loc, val, 2, rel);
const uint16_t target = (val - 2) >> 1;
write16le(loc, (read16le(loc) & 0xfc07) | ((target & 0x7f) << 3));
```
I've verified the behavior against avr-ld.
https://github.com/llvm/llvm-project/pull/67636
More information about the llvm-commits
mailing list