-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang ias, thumb2: proc-v7.S:85:60: error: branch target out of range #1286
Comments
cc @jcai19 This is the issue observed in |
Smaller test case (requires https://reviews.llvm.org/D95872) .syntax unified
9998:
nop.w @ don't use adr_l inside ALT_SMP()
.pushsection ".alt.smp.init", "a"
.long 9998b - .
b.w . + (1f - 9998b)
.popsection
1: $ clang --target=arm-linux-gnueabi -Wa,-mthumb -Wa,-march=armv7-a foo.s
foo.s:6:5: error: branch target out of range
b.w . + (1f - 9998b)
^ vs $ arm-linux-gnueabi-as -mthumb -march=armv7-a foo.s
$ arm-linux-gnueabi-objdump -Dr a.out
...
Disassembly of section .text:
00000000 <.text>:
0: f3af 8000 nop.w
Disassembly of section .alt.smp.init:
00000000 <.alt.smp.init>:
0: 00000000 andeq r0, r0, r0
0: R_ARM_REL32 .text
4: f000 b800 b.w 8 <.alt.smp.init+0x8>
... |
seems like target specific parsing, since 9998:
jmp . + (1f - 9998b + 2)
1:
nop works for x86, but .syntax unified
9998:
b.w . + (1f - 9998b + 2)
1:
nop fails for Looks like calls to |
Thanks for the reduced test case. I also reproduced the issue with llvm-mc.
|
Further reduced test case:
But if I further reduce operand of the jump instruction then the test case works.
The difference is caused by one particular line (https://llvm.org/doxygen/ARMAsmParser_8cpp_source.html#l01072) of code in ARMOperand::isSignedOffset, which returns opposite boolean values for the two cases. Will do more investigation and see if we can handle the former casse by fixing this line in LLVM. |
So the fundamental issue here is that LLVM ARM backend tries to validate the range of branch targets before symbolic values are resolved (i.e. before the layout of fragments are finalized). LLVM also validates the range after the values are known, so disabling the first check for symbolic expressions (which they already do if the expression is a single symbol) seems to work for me. I have a patch locally but it seems LLVM Phabricator is down for the moment. Will send it for review once it comes back. |
LLVM patch sent: https://reviews.llvm.org/D97501 |
arm32_v6 isn't booting with IAS: ClangBuiltLinux/linux#1313 arm32_v7 is blocked on one last build issue: ClangBuiltLinux/linux#1286 arm32_all{mod|yes}config is blocked on some patches that will probably land in the 5.12 merge window: https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9061/1 https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9062/1 I need to go chase backports back to 4.19.
Currently ARM backend validates the range of branch targets before the layout of fragments is finalized. This causes build failure if symbolic expressions are used, with the exception of a single symbolic value. For example, "b.w ." works but "b.w . + 2" currently fails to assemble. This fixes the issue by delaying this check (in ARMAsmParser::validateInstruction) of b.w instructions until the symbol expressions are resolved (in ARMAsmBackend::adjustFixupValue). Link: ClangBuiltLinux/linux#1286 Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D97568
Currently ARM backend validates the range of branch targets before the layout of fragments is finalized. This causes build failure if symbolic expressions are used, with the exception of a single symbolic value. For example, "b.w ." works but "b.w . + 2" currently fails to assemble. This fixes the issue by delaying this check (in ARMAsmParser::validateInstruction) of b.w instructions until the symbol expressions are resolved (in ARMAsmBackend::adjustFixupValue). Link: ClangBuiltLinux/linux#1286 Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D97568
Currently ARM backend validates the range of branch targets before the layout of fragments is finalized. This causes build failure if symbolic expressions are used, with the exception of a single symbolic value. For example, "b.w ." works but "b.w . + 2" currently fails to assemble. This fixes the issue by delaying this check (in ARMAsmParser::validateInstruction) of b.w instructions until the symbol expressions are resolved (in ARMAsmBackend::adjustFixupValue). Link: ClangBuiltLinux/linux#1286 Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D97568
Building a thumb2-enabled arm32 kernel with clang ias and CONFIG_SMP_ON_UP, I get a couple of errors like
arch/arm/mm/proc-v7.S:85:60: error: branch target out of range
.pushsection ".alt.smp.init", "a" ; .long 9998b - . ; b.w . + (1f - 9998b) ; .popsection
The underlying code looks like
and this was recently changed with commit 450abd3 ("ARM: kernel: use relative
references for UP/SMP alternatives").
The text was updated successfully, but these errors were encountered: