Page 1 of 1

cross compiler and grub

Posted: Wed Sep 05, 2007 3:00 pm
by R2_
I just built the cross compiler on the wiki page but when I try to make a hello world kernel GRUBs tell me its not a valid file format...

at first i was using aout format for NASM but the linker for the cross compiler told me that it didn't recognize that file format... i changed format for the assembly file to elf and the linker worked but GRUB says invalid file format..

any help ?

I know the code is right because I've compiled it in the past using linux and tested it... only change is i used aout file format rather than elf when it worked... but I can't do that as the cross compiler ok the wiki is for elf file format...

(On mac os x now)

ASM file

Code: Select all

[BITS 32]
[global start]
[extern main] ; this is in the c file

start:
  call main

  cli  ; stop interrupts
  hlt ; halt the CPU

c file

Code: Select all

int main(void)
{
	char *str = "Hello, world", *ch;
	unsigned short *vidmem = (unsigned short*) 0xb8000;
	unsigned i;
	
	for (ch = str, i = 0; *ch; ch++, i++)
		vidmem[i] = (unsigned char) *ch | 0x0700;
		
	for (;;);
}
edit:
Nevermind... fixed it =]

yet another silly mistake by the very clumsy OS dever R2

I was missing the grub header :P