aarch64 as internal error in md_apply_fix at ....../gas/config/tc-aarch64.c:8330

Joel Sherrill joel@rtems.org
Fri Mar 12 14:33:12 GMT 2021


Hi

I filed this as PR27217 in late January but since wanted to post it here in
case people are not looking at tickets regularly.

This arose from an RTEMS test case for how our configuration and
initialization is built. The included C code compiles and assembles cleanly
on the other 17 architectures supported by RTEMS. But when compiled at -O2,
-O1, and -Os on aarch64, gcc produces assembly which gives an internal
error in gas. Examining the generated assembly on arm and aarch64, enabling
optimization results in the .set statement being in the top part of the
generated assembly versus the bottom part. This pattern of .set placement
is consistent across at least arm and aarch64.

  $ /home/joel/rtems-work/tools/6/bin/aarch64-rtems6-gcc -c -O2 set.c
/tmp/ccyseDVm.s: Assembler messages:
/tmp/ccyseDVm.s: Internal error in md_apply_fix at
../../sourceware-mirror-binutils-gdb-8807d31/gas/config/tc-aarch64.c:8330.
Please report this bug.

GCC's behavior related to the start and end of user assembly language
comments also varies based on optimization level. This isn't critical but
odd. This type of comment isn't generated for the arm.

===========================
extern char bar[];
char * foo(void)
{
        return bar;
}
__asm__ (".set bar, 0");
===========================

$ /home/joel/rtems-work/tools/6/bin/aarch64-rtems6-gcc -c -O2 set.c
/tmp/ccyseDVm.s: Assembler messages:
/tmp/ccyseDVm.s: Internal error in md_apply_fix at
../../sourceware-mirror-binutils-gdb-8807d31/gas/config/tc-aarch64.c:8330.
Please report this bug.

This is the generated assembly so you do not need a full aarch64 toolchain.

===================================
.arch armv8-a
.file "set.c"
.text
// Start of user assembly
.set bar, 0
// End of user assembly
.align 2
.p2align 4,,11
.global foo
.type foo, %function
foo:
adrp x0, bar
add x0, x0, :lo12:bar
ret
.size foo, .-foo
.ident "GCC: (GNU) 10.2.1 20201030 (RTEMS 6, RSB
31dd1ab4424e59e48c60dfa587e805e908d13b02, Newlib 9517e5f)"

===================================

This is the assembly language at -O0 and it assembles successfully:

===================================


.arch armv8-a
.file "set.c"
.text
.align 2
.global foo
.type foo, %function
foo:
adrp x0, bar
add x0, x0, :lo12:bar
ret
.size foo, .-foo
// Start of user assembly
.set bar, 0
.ident "GCC: (GNU) 10.2.1 20201030 (RTEMS 6, RSB
31dd1ab4424e59e48c60dfa587e805e908d13b02, Newlib 9517e5f)"

===================================

I've confirmed this in the current master (as of when I filed the ticket)
as well as an older version I had. Based on reports from other RTEMS
developers, this has been broken a while. I personally confirmed it in
these:

GNU assembler (GNU Binutils) 2.36.50.20210120
GNU assembler (GNU Binutils) 2.35.50.20201102

Thanks.

--joel
RTEMS


More information about the Binutils mailing list