Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
A month or so ago when I was creating a cross-compiler for my OS (glidix) it didn't automatically add crt0.o and such to the executable, so to force it to include them, I modified gcc/config/glidix.h and added a STARTFILE_SPEC and ENDFILE_SPEC at the end, here's what it looks like now:
("libc.a" does NOT contain the crt0.o files; they are seperate files installed under /glidix/lib), it tries to link crt0.o into libc.so, and fails due to undefined reference to 'main'. Is there something I am doing horribly wrong? And if so, what is it?
So I think your command line is okay. I specifically link in a special version of the start-up code in that list of *.o files because my libc.o is also my ld loader but you needn't do that.
The difference is likely in your STARTFILE_SPEC. You need to tell it to leave out the crt1.o file when you're building shared.
Thank you for your help. It also seems that when I create static executable, they are linked so that there is only one program header, which stores all code, data and bss in a single segment, with read-write-execute permission. Does anyone know why it may be creating this one segment instead of 2? There should be, by default, a segment for code (read-and-execute) and for data (read-and-write).
mariuszp wrote:Thank you for your help. It also seems that when I create static executable, they are linked so that there is only one program header, which stores all code, data and bss in a single segment, with read-write-execute permission. Does anyone know why it may be creating this one segment instead of 2? There should be, by default, a segment for code (read-and-execute) and for data (read-and-write).
Did you fix this issue ?
If a trainstation is where trains stop, what is a workstation ?