c/6916: Wrong assembler code for ARM/Thumb

omakarenko@cyberplat.ru omakarenko@cyberplat.ru
Mon Jun 3 04:56:00 GMT 2002

>Number:         6916
>Category:       c
>Synopsis:       Wrong assembler code for ARM/Thumb
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 03 04:56:00 PDT 2002
>Originator:     omakarenko@cyberplat.ru
>Release:        unknown-1.0
GNU C version 3.1 (arm-elf)
compiled by GNU C version 2.96 20000731 (RedHat Linux 7.3 2.96-110)
Configured with: /home/oleg/arm/tools/gcc/configure --target=arm-elf --enable-languages=c,c++ --disable-shared --disable-nls --with-gnu-as --with-gnu-ld --disable-checking -
-with-multilibs --with-newlib --disable-newlib-io-float
Thread model:single
The following simple file when compiled with

arm-elf-gcc -o test.Os.s -S -Os -mthumb test.c

produces code like:
ldr  r3, [r3, sp]

which is wrong for Thumb mode (sp can not be used in thumb mode)

gas then complains with "Error: lo register required"

-O2 and -O3 give the same result.

arm-elf-gcc -o test.Os.s -S -Os test.c
arm-elf-gcc -o test.Os.o -c -Os test.c


More information about the Gcc-bugs mailing list