Skip to content
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

error: expected absolute expression on arm #742

Closed
jcai19 opened this issue Oct 18, 2019 · 6 comments
Closed

error: expected absolute expression on arm #742

jcai19 opened this issue Oct 18, 2019 · 6 comments
Assignees
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 12 This bug was fixed in LLVM 12.0 [TOOL] integrated-as The issue is relevant to LLVM integrated assembler

Comments

@jcai19
Copy link
Member

jcai19 commented Oct 18, 2019

CC=clang AS=clang

arch/arm/mm/proc-v7.S:169:143: error: expected absolute expression
 .pushsection ".alt.smp.init", "a" ; .long 9998b ;9997: orr r1, r1, #((1 << 0) | (1 << 6))|(3 << 3) ; .if . - 9997b == 2 ; nop ; .endif ; .if . - 9997b != 4 ; .error "ALT_UP() content must assemble to exactly 4 bytes"; .endif ; .popsection

gnu as does not have this issue.

@jcai19 jcai19 added [TOOL] integrated-as The issue is relevant to LLVM integrated assembler [ARCH] arm32 This bug impacts ARCH=arm labels Oct 18, 2019
@jcai19 jcai19 self-assigned this Oct 18, 2019
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Oct 19, 2019

I suspect it's the .if . - 9997b == 2 again. #473

@jcai19
Copy link
Member Author

jcai19 commented Oct 20, 2019

.if . - 9997b == 2

Yes you are correct. I'm not sure if it is caused by the same reason of similar issues for other architecture, so I just created this one to track the issues on 32-bit arm.

Strange enough, if I simply copy the instructions and make a test case out of it, clang would not have the issue. So right now to reproduce this issue, I will have to run
$ clang -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__ASSEMBLY__ --target=arm-linux-gnueabihf -D__LINUX_ARM_ARCH__=7 -march=armv7-a -include asm/unified.h -c -o /tmp/proc-v7.o arch/arm/mm/proc-v7.S

The reason seemed to be that this instruction and label 9997 are assigned to two different fragments, and without layout current integrated assembler cannot calculate their difference. While in the test case somehow they are assigned to the same fragment, so the integrated assembler can simply compare their offset and produce a constant value as the result of the substraction.

@jcai19
Copy link
Member Author

jcai19 commented Oct 20, 2019

Some more observation: I only found one macro (ALT_UP) uses dot symbol in .if directive.

linux $ grep -r ".if .\ "
arch/arm/include/asm/assembler.h: .if . - 9997b == 2 ;
arch/arm/include/asm/assembler.h: .if . - 9997b != 4 ;\

Turned out both instances are in used in the same macro.

#ifdef CONFIG_SMP
#define ALT_SMP(instr...)
9998: instr
/*

  • Note: if you get assembler errors from ALT_UP() when building with
  • CONFIG_THUMB2_KERNEL, you almost certainly need to use
  • ALT_SMP( W(instr) ... )
    */
    #define ALT_UP(instr...)
    .pushsection ".alt.smp.init", "a" ;
    .long 9998b ;
    9997: instr ;
    .if . - 9997b == 2 ;
    nop ;
    .endif ;
    .if . - 9997b != 4 ;
    .error "ALT_UP() content must assemble to exactly 4 bytes";
    .endif ;
    .popsection
    #define ALT_UP_B(label)
    .equ up_b_offset, label - 9998b ;
    .pushsection ".alt.smp.init", "a" ;
    .long 9998b ;
    W(b) . + up_b_offset ;
    .popsection
    #else
    #define ALT_SMP(instr...)
    #define ALT_UP(instr...) instr
    #define ALT_UP_B(label) b label
    #endif

@nickdesaulniers
Copy link
Member

@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Oct 29, 2019
@tpimh tpimh added the [BUG] llvm A bug that should be fixed in upstream LLVM label Oct 31, 2019
@jcai19 jcai19 added [PATCH] Exists There is a patch that fixes this issue [PATCH] Submitted A patch has been submitted for review and removed [PATCH] Submitted A patch has been submitted for review [PATCH] Exists There is a patch that fixes this issue labels Nov 9, 2019
@nickdesaulniers
Copy link
Member

Without support for adrl (#430 ) I can't boot test this. I can disable configs for drivers that use adrl, but arch/arm/boot/compressed/head.S:1447 uses adrl.

@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Sep 2, 2020
@nickdesaulniers nickdesaulniers added [FIXED][LLVM] 12 This bug was fixed in LLVM 12.0 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Sep 23, 2020
@nickdesaulniers
Copy link
Member

Big thanks @jcai19 . (adrl patches linked in #430 help to test this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 12 This bug was fixed in LLVM 12.0 [TOOL] integrated-as The issue is relevant to LLVM integrated assembler
Projects
None yet
Development

No branches or pull requests

3 participants