[llvm] [BOLT] Fix LongJmp layout estimation (PR #215416)
Alexey Moksyakov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 16 22:34:14 PDT 2026
yavtuk wrote:
> Thank you for the review, @rafaelauler, but, unfortunately, I have realized that the patch does not fix the original issue I was investigating.
>
> **Original issue**
>
> The original motivation for this PR was processing a Chromium build with llvm-bolt, which resulted in several BOLT errors. All observed failures were caused by misestimating the 128 MiB range of AArch64 branch26/call26 instructions. Depending on when the out-of-range value is resolved, the failure appears either during MC emission:
>
> ```
> <unknown>:0: error: fixup value out of range
> BOLT-ERROR: Emission failed.
> ```
>
> or during JITLink:
>
> ```
> BOLT-ERROR: JITLink failed: In graph in-memory object file, section .text: relocation target 0x8400048 (<anonymous symbol>:0x400040 + 0x8000008) is out of range of Branch26PCRel fixup at address 0x400040 ($x, 0x400000 + 0x4)
@adam-bzowski-arm If you have time to debug this bug, here's how I fixed a similar problem:
Branch26PCRel related to call (bl target) instruction. You can add more log to dump Target and SignedValue, calculate call site for this relocation.
```
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
uint64_t Value, MCContext &Ctx,
const Triple &TheTriple, bool IsResolved) {
.....
case AArch64::fixup_aarch64_pcrel_branch26:
case AArch64::fixup_aarch64_pcrel_call26:
// Signed 28-bit immediate
if (SignedValue > 134217727 || SignedValue < -134217728)
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
// Low two bits are not encoded (4-byte alignment assumed).
if (Value & 0x3)
Ctx.reportError(Fixup.getLoc(), "fixup not sufficiently aligned");
return (Value >> 2) & 0x3ffffff;
.....
}
```
my case the issue was in getSymbolAddress, the target was in the middle of the target function.
I can try to help you with debug if you can share reproducer.
https://github.com/llvm/llvm-project/pull/215416
More information about the llvm-commits
mailing list