gdb - how can I prevent arm-none-eabi compiler generating main symbol -


i'm using arm-none-eabi compile source file. after compiling , generating elf file. got following symbols using nm command

00021da8 t isr_init          u main          u malloc 010008b0 d master_ahb_map 

i'm using gdb debug, have problem main symbol not defined. gdb generate following error :

function "main" not defined. 

when change entry point main, works fine. i'm developing bare metal program, didn't define main anywhere in program.

i linked program following libraries

(gnu_arm_tool)/lib/gcc/arm-none-eabi/4.8.4/armv7-ar/thumb/fpu (gnu_arm_tool)/arm-none-eabi/lib/armv7-ar/thumb/fpu 

for understanding, main symbol generated 1 of above libraries. question how can or how can avoid compiler generating undefined symbol main, or @ least delete undefined main symbol in final elf file avoid gdb error.

to avoid gcc generating references main, link program -nostdlib gcc option:

-nostdlib: not use standard system startup files or libraries when linking. no startup files , libraries specify passed linker, , options specifying linkage of system libraries, such -static-libgcc or -shared-libgcc, ignored. compiler may generate calls memcmp, memset, memcpy , memmove. these entries resolved entries in libc. these entry points should supplied through other mechanism when option specified.

one of standard libraries bypassed -nostdlib , -nodefaultlibs libgcc.a, library of internal subroutines gcc uses overcome shortcomings of particular machines, or special needs languages. (see interfacing gcc output, more discussion of libgcc.a.) in cases, need libgcc.a when want avoid other standard libraries. in other words, when specify -nostdlib or -nodefaultlibs should specify -lgcc well. ensures have no unresolved references internal gcc library subroutines.

to avoid gcc generating calls memcmp, memset, memcpy etc compile gcc's -ffreestanding option. or use "function attributes" syntax, e.g.:

/* defined in linker script gcc.ld */ extern int __etext, __data_start__, __data_end__, __bss_start__, __bss_end__;  /* make gcc not translate data copy loop memcpy() call  *  * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888  * note passing optimize("freestanding", "no-builtin")  * function attribute here doesn't work on  * gcc-arm-embedded 2014 (gcc 4.9.3) */ __attribute__((optimize("freestanding", "no-builtin",                         "no-tree-loop-distribute-patterns"))) void reset_handler() {         int *src, *dst;         (src = &__etext, dst = &__data_start__;                         dst != &__data_end__;                         src++, dst++)                 *dst = *src;         (dst = &__bss_start__; dst < &__bss_end__; dst++)             *dst = 0;          main(); }