[llvm] [AVR] Emit relocation record for local branch (PR #145291)

Patryk Wychowaniec via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 23 11:44:00 PDT 2025


Patryk27 wrote:

We don't emit relocations for jumps deliberately, as a fix for something else:

- https://github.com/llvm/llvm-project/pull/106722
- https://github.com/llvm/llvm-project/pull/121498

I recall we - cc @benshi001 -'ve had some discussion on whether we should emit relocations always (as GCC does) or only when needed (which is the current approach), but I can't find it on GitHub now. Anywhere, the system is what the system does and so the current approach is to avoid emitting relocations, which - in a hindsight, of course - is not compatible with relaxation.

I think the proper fix would be to go back to emitting relocations always, not only conditionally - i.e. change this:

https://github.com/llvm/llvm-project/blob/b215c8e18ff9aec25fa01c802c388d93b391ff91/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L522

... into:

```cpp
  case AVR::fixup_7_pcrel:
  case AVR::fixup_13_pcrel:
  case AVR::fixup_call:
    return true;
```

The only downside I see is that the generated *.elf files will be somewhat bigger (every jump will need to have its own relocation), but this doesn't really affect the final binary (which is linked and thus doesn't contain relocations anyway).

Thoughts?

https://github.com/llvm/llvm-project/pull/145291


More information about the llvm-commits mailing list