https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85606

            Bug ID: 85606
           Summary: Assembly file generated for ARM Cortex-M0 should not
                    specify `.arch armv6-m` at all or use `.arch armv6s-m`
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: freddie_chopin at op dot pl
  Target Milestone: ---
            Target: arm-none-eabi

This issue is inspired by following bug report for GAS -
https://sourceware.org/bugzilla/show_bug.cgi?id=23126

Following test case works perfectly fine for GCC 5, 6 and 7, however it fails
with GCC 8.0.1 20180427:

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

$ cat svc.cpp 
__attribute__ ((naked))
int supervisorCall(int (& function)(int, int, int, int), const int argument1,
const int argument2, const int argument3,
                const int argument4)
{
        asm volatile
        (
                        "       mov             r12, r0         \n"
                        "       ldr             r0, [sp]        \n"
                        "       svc             0                       \n"
                        "                                               \n"
                        "       bx              lr                      \n"
        );

        __builtin_unreachable();

        // suppress warnings
        (void)function;
        (void)argument1;
        (void)argument2;
        (void)argument3;
        (void)argument4;
}
$ arm-none-eabi-g++ -c svc.cpp -mcpu=cortex-m0 -save-temps
svc.s: Assembler messages:
svc.s:31: Error: SVC is not permitted on this architecture
$ diff -u svc-7.s svc.s 
--- svc-7.s     2018-05-01 20:14:09.031910734 +0200
+++ svc.s       2018-05-01 20:16:36.751143427 +0200
@@ -12,6 +12,7 @@
        .text
        .align  1
        .global _Z14supervisorCallRFiiiiiEiiii
+       .arch armv6-m
        .syntax unified
        .code   16
        .thumb_func
@@ -37,4 +38,4 @@
        .cantunwind
        .fnend
        .size   _Z14supervisorCallRFiiiiiEiiii,
.-_Z14supervisorCallRFiiiiiEiiii
-       .ident  "GCC: (bleeding-edge-toolchain) 7.3.0"
+       .ident  "GCC: (bleeding-edge-toolchain) 8.0.1 20180427 (prerelease)"
$ cat svc.s 
        .cpu cortex-m0
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 1
        .eabi_attribute 30, 6
        .eabi_attribute 34, 0
        .eabi_attribute 18, 4
        .file   "svc.cpp"
        .text
        .align  1
        .global _Z14supervisorCallRFiiiiiEiiii
        .arch armv6-m
        .syntax unified
        .code   16
        .thumb_func
        .fpu softvfp
        .type   _Z14supervisorCallRFiiiiiEiiii, %function
_Z14supervisorCallRFiiiiiEiiii:
        .fnstart
.LFB0:
        @ Naked Function: prologue and epilogue provided by programmer.
        @ args = 4, pretend = 0, frame = 0
        @ frame_needed = 1, uses_anonymous_args = 0
        .syntax divided
@ 12 "svc.cpp" 1
                mov             r12, r0         
        ldr             r0, [sp]        
        svc             0                       

        bx              lr                      

@ 0 "" 2
        .thumb
        .syntax unified
        .cantunwind
        .fnend
        .size   _Z14supervisorCallRFiiiiiEiiii,
.-_Z14supervisorCallRFiiiiiEiiii
        .ident  "GCC: (bleeding-edge-toolchain) 8.0.1 20180427 (prerelease)"

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

(svc-7.s is a temp file generated with GCC 7.3.0)

Nick Clifton in his comment
(https://sourceware.org/bugzilla/show_bug.cgi?id=23126#c4) to the mentioned GAS
bug report suggested that GCC 8 should either specify just `.cpu` (behaviour as
in previous versions) or specify `.arch armv6s-m` instead of `.arch armv6-m`.
Personally I think the first option should be more reliable in that case,
however this is just a guess.

Reply via email to