Error: registers may not be the same -- `strexb r0,r0,[r1]' #65

timbrom opened this Issue Feb 29, 2012 · 6 comments


None yet
7 participants

timbrom commented Feb 29, 2012

Upon issuing the make command from stlink/example/libs_stm/build, I received the following error:

make[1]: Entering directory /home/thb/projects/stlink/stlink/example/libs_stm/build' arm-none-eabi-gcc -mcpu=cortex-m3 -Wall -O2 -mlittle-endian -mthumb -mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc -I../inc/stm32f10x -I../inc/device_support -I../inc/core_support -I../inc/base -c -o ../inc/core_support/core_cm3.o ../inc/core_support/core_cm3.c /tmp/ccVFQZtE.s: Assembler messages: /tmp/ccVFQZtE.s:318: Error: registers may not be the same --strexb r0,r0,[r1]'
/tmp/ccVFQZtE.s:333: Error: registers may not be the same -- strexh r0,r0,[r1]' make[1]: *** [../inc/core_support/core_cm3.o] Error 1 make[1]: Leaving directory/home/thb/projects/stlink/stlink/example/libs_stm/build'
make: *** [all] Error 2

The behavior of strexb and strexh is apparently undefined when the two registers are the same. I have attached a patch that fixes the issue. The problems are on lines 736 and 753 of inc/core_support/core_cm3.c. The : "=r" (result) should be changed to : "=&r" (result), which will cause GCC to use a different register for the target operand

I am using the following tools in my toolchain:

timbrom commented Feb 29, 2012

Patch available at git://

philpem commented Mar 12, 2012

I hope you don't mind, Tim, but I've pulled this fix into my fork of the STM32 Peripheral Library:

Also, this error is mainly an issue when GCC is run with -O2. I didn't have a problem with the code when optimisation was at the default setting, but as soon as I switched to -O2... :-/


sventunus referenced this issue in esden/summon-arm-toolchain Jan 11, 2013


error unpacking newlib-1.19.0: not in gzip format #45

THank YOU !

ecolell commented Mar 14, 2014

Thank you, this ( work for me too!

Thank you!

11hwu2 commented Dec 22, 2015

Thank you!

xor-gate closed this May 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment