1

I compile my code for sparc embedded platform using gcc with the -nostartfiles and -nostdlib The command as follows:

 gcc -Tlinkram  usr.o bspstart.o -o output.elf

The output elf file is wrong , because the code on the address 0x2000000 is from usr.o, but i expect this bspstart.o.

In bspstart.s, the entry symbol is start

I try to solve the problem in several ways:

  1. reorder the bspstart.o and usr.o in gcc command argments, it works
  2. I specify entry symbol by using ld args, -e start, it dosen't work

I wonder except manually specify the order of object file in gcc command, is there anyway to specify the startup code?

chen rui
  • 37
  • 1
  • This is a duplicate question. Please take a look at: http://stackoverflow.com/questions/7494244/how-to-change-the-entry-point-in-gcc – Joao Oct 20 '14 at 05:18
  • @Joao The OP wrote that the `-e` solution you refer doesn't work. I don't know the reasion and what "doesn't work" means. But I suggest a GCC linker script. (http://www.scoberlin.de/content/media/http/informatik/gcc_docs/ld_3.html) – harper Oct 20 '14 at 06:40
  • How did you verify that `-e start` doesn't work? – harper Oct 20 '14 at 06:41
  • I specify -Wl, -estart, the compiled code is also wrong, it seems the option doesn't work for me. I use objdump to dump the list file, the code at 0x2000000 is from usr.o instead of bspstart.o. BTW, I also tried to modify my linkscript, ENTRY(start), It also doesn't work – chen rui Oct 20 '14 at 06:50
  • How can I specify the first object file to be linked in linkscript or ld arguments – chen rui Oct 20 '14 at 06:56

0 Answers0