llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.24k stars 12.07k forks source link

lld incorrectly calculates the maximum range of R_HEX_B22_PCREL relocation #116798

Open androm3da opened 3 days ago

androm3da commented 3 days ago

When building the linux kernel, we see the following link error:

ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160):
relocation R_HEX_B22_PCREL out of range: 2098032 is not in [-2097152, 2097151]; references 'memset'

This issue was triggered by changes in layout but it uncovered an error in the way lld calculates the range of this relocation.

See also https://lore.kernel.org/linux-hexagon/20241114171834.GA1956005@thelio-3990X

llvmbot commented 3 days ago

@llvm/issue-subscribers-lld-elf

Author: Brian Cain (androm3da)

When building the linux kernel, we see the following link error: ``` ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160): relocation R_HEX_B22_PCREL out of range: 2098032 is not in [-2097152, 2097151]; references 'memset' ``` This issue was triggered by changes in layout but it uncovered an error in the way lld calculates the range of this relocation. See also https://lore.kernel.org/linux-hexagon/20241114171834.GA1956005@thelio-3990X
llvmbot commented 3 days ago

@llvm/issue-subscribers-backend-hexagon

Author: Brian Cain (androm3da)

When building the linux kernel, we see the following link error: ``` ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160): relocation R_HEX_B22_PCREL out of range: 2098032 is not in [-2097152, 2097151]; references 'memset' ``` This issue was triggered by changes in layout but it uncovered an error in the way lld calculates the range of this relocation. See also https://lore.kernel.org/linux-hexagon/20241114171834.GA1956005@thelio-3990X
androm3da commented 3 days ago

This is fixed by #115925 - so we can cherry-pick it once it lands.

androm3da commented 3 days ago

/cherry-pick 64e3466fd09ec0b02f27ec15a176611fe65ed961

llvmbot commented 3 days ago

Failed to cherry-pick: 64e3466fd09ec0b02f27ec15a176611fe65ed961

https://github.com/llvm/llvm-project/actions/runs/11916300231

Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request