On Sun, 2013-02-10 at 21:40 +0100, Christian wrote: > Hi there, > > I want to use a (pre-existing) project for embedded ARM > (Cortex-M3 processor). > > The 2 files will compile and link fine when compiling with -Os: > > --- start --- > arm-softfloat-linux-gnueabi-gcc -fno-strict-aliasing -mcpu=cortex-m3 > -mthumb -Wall -g -Os -msoft-float -Tstm32.ld -nostdlib -nostartfiles -c > ../../../targets/olimex/main_olimex.cpp > > arm-softfloat-linux-gnueabi-gcc -fno-strict-aliasing -mcpu=cortex-m3 > -mthumb -Wall -g -Os -msoft-float -Tstm32.ld -nostdlib -nostartfiles -c > stm32f10x_vector.c > > arm-softfloat-linux-gnueabi-gcc -fno-strict-aliasing -mcpu=cortex-m3 > -mthumb -Wall -g -Os -msoft-float -Tstm32.ld -nostdlib -nostartfiles -o > target.elf -Wl,--gc-sections,-Map=all.map,-cref,-u,Reset_Handler > main_olimex.o stm32f10x_vector.o > --- end --- > > If I use -O0 (for debugging reasons) the files will still compile > but they won't link: > > --- start --- > arm-softfloat-linux-gnueabi-gcc -fno-strict-aliasing -mcpu=cortex-m3 > -mthumb -Wall -g -O0 -msoft-float -Tstm32.ld -nostdlib -nostartfiles -o > target.elf -Wl,--gc-sections,-Map=all.map,-cref,-u,Reset_Handler > main_olimex.o stm32f10x_vector.o > main_olimex.o:(.ARM.exidx+0x28): undefined reference to > `__aeabi_unwind_cpp_pr1' > main_olimex.o:(.ARM.exidx+0xc0): undefined reference to > `__aeabi_unwind_cpp_pr0' > main_olimex.o:(.ARM.exidx.text._ZN14name_citlUsage9name_Citl15name_debugTools10DebugToolsIN7guclLib12uart_stm32fxINS3_3allINS0_4CitlINS0_8name_STD17PlatformCfgPresetEE4MmplEE9cfgPreset4uartESA_E4bodyIN7stm32fx11app_stm32fxI10appAdapterE7guclCfgIN18platformDispatcherISI_E7depBodyEN3ind3appISI_E7guclCfgINSM_7indBodyENS3_11all_stm32fxISC_SA_E9cfgPresetEEEE4uartENSU_4bodyISX_NSB_4bodyISX_EEE12indBody_uartENS3_12gpio_stm32fxINSC_4gpioESA_E4bodyINS16_9cfgPresetENS12_12indBody_gpioENS3_11sys_stm32fxINSC_3sysESA_E4bodyINS1C_9cfgPresetENS12_11indBody_sysEEEEES1G_E4portILi0EEELi100ELb1ENSI_3EnvEE13writeDebugStrEPh[_ZN14name_citlUsage9name_Citl15name_debugTools10DebugToolsIN7guclLib12uart_stm32fxINS3_3allINS0_4CitlINS0_8name_STD17PlatformCfgPresetEE4MmplEE9cfgPreset4uartESA_E4bodyIN7stm32fx11app_stm32fxI10appAdapterE7guclCfgIN18platformDispatcherISI_E7depBodyEN3ind3appISI_E7guclCfgINSM_7indBodyENS3_11all_stm32fxISC_SA_E9cfgPresetEEEE4uartENSU_4bodyISX_NSB_4bodyISX_EEE12indBody_uartENS3_12gpio_stm32fxINSC_4gpioESA_E4bodyINS16_9cfgPresetENS12_12indBody_gpioENS3_11sys_stm32fxINSC_3sysESA_E4bodyINS1C_9cfgPresetENS12_11indBody_sysEEEEES1G_E4portILi0EEELi100ELb1ENSI_3EnvEE13writeDebugStrEPh]+0x0): > undefined reference to `__aeabi_unwind_cpp_pr1' > main_olimex.o: In function `name_citlUsage::name_Citl::na... > > <and so on ...> > > --- end --- > > => -Os links. -O0 doesn't. > > Any idea what's going on here? I'm just guessing here... When compiling for -Os the calls to the unwinding code are optimized away and for -O0 they remain. The unwinder code is usually part of libgcc which seems to be not included in your linking step. Probably because of '-nostdlib'... Cheers, Oleg