Linux: "error: expected string in directive" on ARM

Created on 22 Oct 2019  Â·  17Comments  Â·  Source: ClangBuiltLinux/linux

$ cat foo.s
.section ".foo", #alloc
$ arm-linux-gnueabihf-gcc -c foo.s
$ echo $?
0
$ ~/storage/llvm-project/build/release/bin/clang -target arm-linux-gnueabihf -c foo.s
foo.s:1:18: error: expected string in directive
.section ".foo", #alloc

[ARCH] arm32 [BUG] linux [BUG] llvm [FIXED][LINUX] 5.5 [TOOL] integrated-as

Most helpful comment

All 17 comments

interesting, which source file does this occur in, @jcai19 ?

interesting, which source file does this occur in, @jcai19 ?

It's in arch/arm/mm/proc-v7.S.

$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j32 CC=clang AS=clang arch/arm/mm/proc-v7.o

AS arch/arm/mm/proc-v7.o
clang-10: warning: argument unused during compilation: '-march=armv7-a' [-Wunused-command-line-argument]
clang-10: warning: argument unused during compilation: '-Wa,-march=armv7-a' [-Wunused-command-line-argument]
arch/arm/mm/proc-v7.S:169:107: 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
^
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
^
arch/arm/mm/proc-v7.S:169:160: error: ALT_UP() content must assemble to exactly 4 bytes
.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
^
arch/arm/mm/proc-v7.S:647:30: error: expected string in directive
.section ".proc.info.init", #alloc
^
make[1]: * [scripts/Makefile.build:357: arch/arm/mm/proc-v7.o] Error 1

I have a local patch that seems to fixes the "expected absolute expression" errors at #742 (still trying to figure out the right unit test before sending it for review), but to be able to build this file with integrated assembler, we also need to fix the this error (the last one).

Based on smithp35's comment, if the Linux kernel is currently the only instance the Solaris style comment markers are used, I suggest that we postpone D69296 until there are more instances and we get to the point that not implementing it can cause more trouble.

Based on smithp35's comment, if the Linux kernel is currently the only instance the Solaris style comment markers are used, I suggest that we postpone D69296 until there are more instances and we get to the point that not implementing it can cause more trouble.

There are more updates to the code review so hopefully this will not be a concern.

It sounds like we should patch the kernel in this case. Is there a syntax that is not "solaris style" that we should use?

It sounds like we should patch the kernel in this case. Is there a syntax that is not "solaris style" that we should use?

That would be great. We can use "a" to replace #alloc (https://sourceware.org/binutils/docs/as/Section.html). FYI it was mentioned in D69296 there are more usage of such syntax besides Linux.

sounds like this was reverted.

We could send a kernel patch. Looks like there's 28 instances of it throughout arch/arm/.

ag \\.section | grep \#
mm/proc-arm1020.S:494:  .section ".proc.info.init", #alloc
mm/proc-v7m.S:96:   .section ".init.text", #alloc, #execinstr
mm/proc-v7m.S:180:  .section ".proc.info.init", #alloc
mm/proc-arm740.S:131:   .section ".proc.info.init", #alloc
mm/proc-arm1022.S:446:  .section ".proc.info.init", #alloc
mm/proc-arm946.S:398:   .section ".proc.info.init", #alloc
mm/proc-arm926.S:463:   .section ".proc.info.init", #alloc
mm/proc-arm920.S:437:   .section ".proc.info.init", #alloc
mm/proc-sa1100.S:242:   .section ".proc.info.init", #alloc
mm/proc-mohawk.S:419:   .section ".proc.info.init", #alloc
mm/proc-arm7tdmi.S:75:      .section ".proc.info.init", #alloc
mm/proc-arm1026.S:440:  .section ".proc.info.init", #alloc
mm/proc-feroceon.S:574: .section ".proc.info.init", #alloc
mm/proc-xscale.S:613:   .section ".proc.info.init", #alloc
mm/proc-sa110.S:199:    .section ".proc.info.init", #alloc
mm/proc-xsc3.S:499: .section ".proc.info.init", #alloc
mm/proc-arm940.S:343:   .section ".proc.info.init", #alloc
mm/proc-arm925.S:480:   .section ".proc.info.init", #alloc
mm/proc-arm720.S:175:       .section ".proc.info.init", #alloc
mm/proc-arm1020e.S:452: .section ".proc.info.init", #alloc
mm/proc-v6.S:264:   .section ".proc.info.init", #alloc
mm/proc-fa526.S:188:    .section ".proc.info.init", #alloc
mm/proc-arm922.S:415:   .section ".proc.info.init", #alloc
mm/proc-arm9tdmi.S:69:      .section ".proc.info.init", #alloc
boot/bootp/init.S:16:       .section .start,#alloc,#execinstr
boot/compressed/piggy.S:2:  .section .piggydata,#alloc
boot/compressed/head.S:143:     .section ".start", #alloc, #execinstr
boot/compressed/big-endian.S:9: .section ".start", #alloc, #execinstr
➜  arm git:(alloc) ✗ ag \\.section | grep \# | wc -l

(That's after I've patched arch/arm/mm/proc-v7.S).

I suggest we try uploading a #alloc -> "a" patch and see whether it is welcomed by the Linux community. #alloc is a Solaris assembler syntax while we are...... Linux!

I just have an impression that this is some legacy syntax and we are now adding more cruft to the MC layer.

Thanks for the patch!

Was this page helpful?
0 / 5 - 0 ratings