linker strange behavior

Asked by Radoslav

Hello,

I am trying to build bare metal project for SAM4s. Calling linker with arm-none-eabi-gcc and arm-none-eabi-ld produces different results when objdump is called.

The command for the linker which i use:
/usr/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -Wl,--gc-sections -Wl,-Map=proba.map
-T../../../ASF_CMSIS_Clean/branch/Release1.1/linker_scripts/flash_sam4s4.ld
-L/usr/lib/gcc/arm-none-eabi/4.9.3/armv7e-m -o proba.elf system_sam4s.o main.o proba.o
-lstdc++ -lsupc++ -lm -lc -lg -lnosys -lstdc++ -lsupc++ -lm -lc -lg -lnosys

/usr/bin/arm-none-eabi-objdump -d proba.elf > proba.lst

objdump generate only:
<deregister_tm_clones>:
<register_tm_clones>:
<__do_global_dtors_aux>:
<frame_dummy>:
<atexit>:
<__libc_fini_array>:
<__register_exitproc>:
<register_fini>:
<_global_impure_ptr>:
<_init>:
<__init_array_start>:
<__frame_dummy_init_array_entry>:
<__fini_array_start>:

I don't see main and other functions that I am using.
When calling linker directly

/usr/bin/arm-none-eabi-ld -T../../../ASF_CMSIS_Clean/branch/Release1.1/linker_scripts/flash_sam4s4.ld
-o proba.elf system_sam4s.o main.o proba.o

objdump generates assembly which contains all used functions.
I have tried different options but still i cannot get to work when calling
arm-none-eabi-gcc. I have tried arm-none-eabi-gcc versions 4.9.3 and 5.4.1. Operating system is Ubuntu 15.10.
What am I doing wrong?
Regards

Question information

Language:
English Edit question
Status:
Expired
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Radoslav,

Do you still have the problem when you remove the -Wl,--gc-sections option from the GCC command line?

Best regards.

Revision history for this message
Radoslav (r-prodanov) said :
#2

Removing the -Wl,--gc-sections option produces the following error:

/usr/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -c -O2 -g2 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -DDEBUG -DTOOLCHAIN_GCC_ARM -DNO_RELOC='0' -std=gnu99 -mlittle-endian -DSAM4S4C -I../../../ASF_CMSIS_Clean/branch/Release1.1/include/ -I. -I/usr/lib/gcc/arm-none-eabi/4.9.3/include/ -o system_sam4s.o system_sam4s.c
/usr/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -c -O2 -g2 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -DDEBUG -DTOOLCHAIN_GCC_ARM -DNO_RELOC='0' -std=gnu99 -mlittle-endian -DSAM4S4C -I../../../ASF_CMSIS_Clean/branch/Release1.1/include/ -I. -I/usr/lib/gcc/arm-none-eabi/4.9.3/include/ -o main.o main.c
/usr/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -c -O2 -g2 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -DDEBUG -DTOOLCHAIN_GCC_ARM -DNO_RELOC='0' -std=gnu99 -mlittle-endian -DSAM4S4C -I../../../ASF_CMSIS_Clean/branch/Release1.1/include/ -I. -I/usr/lib/gcc/arm-none-eabi/4.9.3/include/ -o proba.o proba.c
/usr/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -Wl,-Map=proba.map -Wl,-T../../../ASF_CMSIS_Clean/branch/Release1.1/linker_scripts/flash_sam4s4.ld -L/usr/lib/gcc/arm-none-eabi/4.9.3/armv7e-m -o proba.elf system_sam4s.o main.o proba.o -lstdc++ -lsupc++ -lm -lc -lg -lnosys -lstdc++ -lsupc++ -lm -lc -lg -lnosys
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/lib/armv7e-m/crt0.o: In function `_start':
/build/buildd/newlib-2.1.0+git20141201.db59ff3/build/arm-none-eabi/armv7e-m/libgloss/arm/../../../../../libgloss/arm/crt0.S:422: undefined reference to `__bss_start__'
/build/buildd/newlib-2.1.0+git20141201.db59ff3/build/arm-none-eabi/armv7e-m/libgloss/arm/../../../../../libgloss/arm/crt0.S:422: undefined reference to `__bss_end__'
collect2: error: ld returned 1 exit status
Makefile:209: recipe for target 'proba.elf' failed
make: *** [proba.elf] Error 1

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.