Hi,
I am trying to port an existing startup code (which compiles fine using arm compiler 6.18) to compile with GNU toolchain for arm (arm-none-eabi).
The startup code includes a jump to __main which doesnt exist in my codebase presumably because its part of some sort of C runtime library.
But when I try and compile it with gcc cross-compiler, it complains about "undefined reference __main".
How do I resolve this pls?
Thanks
Sarah
Thanks so much Ronan. That fixed the immediate problem. However, I am now getting a different linker error:
/usr/src/debug/libv7fphard-libgloss/3.3.0-r0/newlib-3.3.0/libgloss/arm/crt0.S:547: undefined reference to `__bss_start__'
Given that I have my own startup code startup.S which zero-initialises various bss sections in different TCMs, I am wondering where this runtime library startup code fits in??
FYI My startup code is based on the R52 example code which is supplied with Arm DS dowload.
This symbol is defined in the gcc.ld linker script.
Do you just need to undefine this symbol there, else define a dummy region with __bss_start (and __bss_end) therein?
.bss : { . = ALIGN(4); __bss_start__ = .; *(.bss*) *(COMMON) . = ALIGN(4); __bss_end__ = .; }
I could create dummy regions like u suggested but I am not clear how it fits in with my own startup code and bss regions. E.g.:
tcmb : { *(.data)
. = ALIGN(4); __tcmb_bss_start__ = .; *(.bss) . = ALIGN(4); __tcmb_bss_end__ = .;
/* Associate ARM_LIB_HEAP symbol */ __heap = .; . = ALIGN(64); . = . + 0x1000; } >TCMB
tcmc : { . = ALIGN(4); __tcmc_bss_start__ = .; *(.bss) . = ALIGN(4); __tcmc_bss_end__ = .;
. = ALIGN(4); __stack_start__ = .; . = . + 0x8000; . = ALIGN(4); __stack_end__ = .; } >TCMC
As u can see, I have different bss regions defined in my ld file and my startup code zero-initialises those.
U suggested "undefining" __bss_start and __bss_end. How do I do that pls?
I guess the other question is if I should even be using the GCC startup library or just skip it altogether (given that I have my own startup sequence defined)?
Ignore my comment on undefining the symbols. Thinking it through I don't think that would help. I just meant to comment them out, but the startup code would still be looking for them.
Does your ld script define all the .bss regions? This would be the catch-all for anything else remaining. If there is nothing remaining, still defining them as regions in your ld script should allow the init code to proceed.
Yes that works. Thank you