https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83967
Bernd K <prof7bit at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |prof7bit at gmail dot com --- Comment #11 from Bernd K <prof7bit at gmail dot com> --- Created attachment 43221 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43221&action=edit self contained demo I have made a minimal self contained project that demonstrates the bug with arm-none-eabi-gcc compiling for a Cortex M0+ target (Kinetis MKL05), it is self contained and does not require anything but the installed toolchain itself. Extract the attached archive KL05_demo_gcc_weak_strong_bug.tar.gz. You will find a minimal makefile project, versioned in a git repository with only two commits on two branches, one shows the bug and the other doesn't. $ git checkout bad $ make clean $ make all look at the generated .lst file in the build folder and note that the Systick handler looks like this, it is the weak default implementation from the startup assembly: 000004f4 <SysTick_Handler>: 4f4: e7fe b.n 4f4 <SysTick_Handler> now checkout the good version $ git checkout good $ make clean $ make all The systick handler will look like this which is the strong C implementation: 0000044c <SysTick_Handler>: 44c: 4a02 ldr r2, [pc, #8] ; (458 <SysTick_Handler+0xc>) 44e: 6813 ldr r3, [r2, #0] 450: 3301 adds r3, #1 452: 6013 str r3, [r2, #0] 454: 4770 bx lr 456: 46c0 nop ; (mov r8, r8) 458: 1ffffc00 .word 0x1ffffc00 and the only difference between these two sources is one line in the makefile moved to a different position: $ git diff bad good diff --git a/Makefile b/Makefile index 35ff9c6..82e6d47 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,9 @@ NAME = example -SRCS += $(wildcard *.c) SRCS += $(wildcard cmsis/MKL05Z4/*.s) SRCS += $(wildcard cmsis/MKL05Z4/*.c) +SRCS += $(wildcard *.c) INCDIRS = cmsis/ INCDIRS += cmsis/MKL05Z4/