June 24, 2007

Damn mcmodel=medium....

I have wasted my whole weekend on hunting for a not existing bug. A x86-64 kernel was not going to boot, hanging somewhere around the initialization of few classes. After a long and stressful investigation I have found out, that the code compiled with -mcmodel=medium flag was totally wrong (I have to use this memory model, since the kernel is located at address 0x0f8000000000). The gcc documentation said:

`-mcmodel=medium'
Generate code for the medium model: The program is linked in the

lower 2 GB of the address space but symbols can be located
anywhere in the address space.

According to this information, my code has to work! But it didn't. And then, suddenly, after considering two other possibilities (kernel placed either in lowest 2GB or the highest 2GB of address space) I have found the solution:

`-mmlarge-data-threshold=NUMBER'
When `-mcmodel=medium' is specified, the data greater than

THRESHOLD are placed in large data section. This value must be the
same across all object linked into the binary and defaults to
65535.


Adding the "-mmlarge-data-threshold=1" solved all my issues caused by change from gcc 4.0 to 4.1... Oh well... ;)

Labels:

6 Comments:

Anonymous Anonymous said...

Man! I'm sorry about your weekend.
What a drag! Sometimes another developer is a good sounding board or reality checker - it's hard to spot stuff, sometimes, when you're on you're own.
Maybe you will fly through progress now!
Thanks for sticking with it!

10:54 PM  
Anonymous Anonymous said...

:-) I can feel your frustration.
Keep up the good work Michal.

8:04 PM  
Blogger Cheggus Maximus said...

Pain..Pain..Pain. But the glory will go to you in the end !

Hang in there dude.

12:47 AM  
Blogger Matt said...

I'm really excited Michal!!! Keep it up!

2:23 PM  
Blogger Matt said...

This is really exciting Michal!!! Keep it up!

2:23 PM  
Anonymous Anonymous said...

How about an update on your kernel work so far? I can’t wait to see the finished result!

Do you have any plans to port it to x86-32 your selves, or are you mostly interested in 64bit?

And finally, can you please write some about what the kernel will be like. I mean compare it to AROS/linux/windows and what strengths and weaknesses it will have.

Keep up the good work, its people like you that make a difference!


Zevs

12:30 AM  

Post a Comment

<< Home