10 years, 6 months ago.

Undefined reference to '_start' when compiling

I am trying to use the mbed linker script and startup files with GCC to compile a simple blinky program for the LPC1114. I am able to compile it with a different linker script and startup file but not with the mbed files found here: http://mbed.org/users/mbed_official/code/mbed-src/

Here is how I am compiling: arm-none-eabi-g++ -c -mcpu=cortex-m0 -mthumb -Os -Wall -fwrapv -fomit-frame-pointer -std=gnu++98 -g -ggdb3 -fno-rtti -fno-exceptions -fverbose-asm -DCORE_M0 -MD -MP -MF compile/temp.d -Iinclude/rick/ -Iinclude/hdr/ -Iinclude/inc/ compile/temp.c -o compile/temp.o

arm-none-eabi-g++ -c -mcpu=cortex-m0 -mthumb -Os -Wall -fwrapv -fomit-frame-pointer -std=gnu++98 -g -ggdb3 -fno-rtti -fno-exceptions -fverbose-asm -DCORE_M0 -MD -MP -MF compile/startup1.d -Iinclude/inc/ include/mbed/system_LPC11xx.c -o compile/startup1.o

arm-none-eabi-as -mcpu=cortex-m0 -mthumb include/mbed/startup_LPC11xx.s -o compile/startup2.o

Here is the linking: arm-none-eabi-g++ -mcpu=cortex-m0 -mthumb -fwrapv -fomit-frame-pointer -Tinclude/mbed/LPC1114.ld -g -Wl,-Map=compile/temp.map,- -cref,- -no-warn-mismatch -Wl,- -gc-sections -nostartfiles -Linclude compile/temp.o compile/startup1.o compile/startup2.o -o compile/temp.elf

Everything goes fine until the linking and then it complains about an undefined reference to _start. Shouldn't _start be defined in the linker script? As far as I can tell none of the files in the distribution define _start. It is referenced in LPC11xx.s on line 166.

Here are the files I am using: targets\cmsis\TARGET_NXP\TARGET_LPC11XX_11CXX\TARGET_LPC11XX\system_LPC11xx.c targets\cmsis\TARGET_NXP\TARGET_LPC11XX_11CXX\TOOLCHAIN_GCC_ARM\startup_LPC11xx.s targets\cmsis\TARGET_NXP\TARGET_LPC11XX_11CXX\TOOLCHAIN_GCC_ARM\TARGET_LPC11XX\LPC1114.ld

Can you specify what do you mean: "I am able to compile it with a different linker script and startup file but not with the mbed files found here" ? What different files? What makefile do you use?

Why do you use -nostartfiles flag?

Could you possible try a makefile I wrote : https://github.com/0xc0170/mbed_gcc_makefile. If any problems, pm me here please.

Regards,
0xc0170

posted by Martin Kojtal 21 Oct 2013

1 Answer

10 years, 6 months ago.

0xc0170, thanks for your reply. A friend gave me the linker script and crt0.c he is using. I don't like it because you have to specify the stack size when you compile instead of letting it just grow like the mbed linker script allows. As far as I know those files have nothing to do with the mbed files.

I don't use make and I don't understand make files. Do you think you could tell me what arguments it passes to arm-none-eabi-g++?