Page 2 of 2

Re:Problem with linking kernel

Posted: Sat Dec 13, 2003 9:48 pm
by Chris Giese
I think you can safely use a dummy __main(), like this:

Code: Select all

int __main(void) { return 0; }
For _alloca(), either
  • link with libgcc.a,
  • extract _alloca() from libgcc.a and use it alone,
  • write your own _alloca(), or
  • compile with -mno-stack-arg-probe
This was also discussed in a thread in alt.os.development: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=5a1a16f6e245a2ab&seekm=1061906780.216942%40news.liwest.at#link1

Re:Problem with linking kernel

Posted: Sun Dec 14, 2003 4:34 am
by df
I added this info into the FAQ (wiki version)

Re:Problem with linking kernel

Posted: Sun Dec 14, 2003 1:39 pm
by beyondsociety

Code: Select all

I think you can safely use a dummy __main(), like this:
Code:int __main(void) { return 0; }
When I add this code to my kernel.c, ld:segmentation fault (core dumped). What is going wrong?

Re:Problem with linking kernel

Posted: Sun Dec 14, 2003 1:47 pm
by Tim
What executable format are you using? The main reason for Cygwin ld crashing is when you try to use the binary format, which is apparently broken in Cygwin.

Re:Problem with linking kernel

Posted: Sun Dec 14, 2003 1:59 pm
by beyondsociety
Fixed it. I changed the OUTPUT_FORMAT in the linker script from pe-i386 to pei-i386 and that fixed the segmentation fault. I was having problems with objcopy not converting my kernel.exe file, which I noticed that it was not working because of not correctly typing in the correct option for the format.

Everything is working now. Thanks for all the help.