Problem with linking kernel

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.
Chris Giese

Re:Problem with linking kernel

Post 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
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Problem with linking kernel

Post by df »

I added this info into the FAQ (wiki version)
-- Stu --
beyondsociety

Re:Problem with linking kernel

Post 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?
Tim

Re:Problem with linking kernel

Post 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.
beyondsociety

Re:Problem with linking kernel

Post 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.
Post Reply