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

Error linking kernel

Post by chrisa128 »

Hi all,

I've had a problem with building my kernel where I get the error "not enough space for program headers (allocated 5, needed 6)". Im compiling under linux using the attached Makefile...

I've tried everything I can think of, any help would be appreciated... Thanks,

[attachment deleted by admin]
Therx

Re:Error linking kernel

Post by Therx »

Just a guess. The error suggests that your running out of space of somekind. You're not trying to put the output file on a full disk are you. Have you tried rebooting in case you've run out of RAM (this happens to me sometimes if I've left the computer on all day).

Did make give you a line number or any other info?

Also it looks like you're using GCC to linnk the objects. I know it can do this but it would be easier for the long run if you used ld directly (i think gcc calls it anyway) to give you more control over the linking process.

Pete
chrisa128

Re:Error linking kernel

Post by chrisa128 »

Not out of disk space ??? I even tried rebooting....


I have attached the complete output from the makefile (I stripped the kernel to 2 files to check that it wasn't too many files).....

I'd prefere it if I could link through the makefile using GCC for ease of use...

Any helkp appreciated :)

[attachment deleted by admin]
chrisa128

Re:Error linking kernel

Post by chrisa128 »

Ok, I really need to sort this as I just can't get it to work using LD...

Can anyone tell me if I have any errors in the Makefile????
Chris Giese

Re:Error linking kernel

Post by Chris Giese »

Do you use a linker script? I've seen a similar error that seems to occur when the virtual and physical addresses of the ELF file are different:
http://my.execpc.com/~geezer/osd/gotchas/index.htm#ld_N

Another idea: say "objdump -h *.o" to list the sections present in all .o files that get linked to form the kernel. Look for any peculiar sections; other than .text, .data, .rodata*, and .bss
chrisa128

Re:Error linking kernel

Post by chrisa128 »

Im not using a Linker Script... Do i still need to do this when im using a Makefile to compile it?
Chris Giese

Re:Error linking kernel

Post by Chris Giese »

chrisa128 wrote: Im not using a Linker Script... Do i still need to do this when im using a Makefile to compile it?
Yes. If the virtual and physical addresses of the kernel are different, here's a linker script you can use:

Code: Select all

ENTRY(entry)    /* entry point */
phys = 0x100000; /* 1 meg = load (physical) adr of kernel */
virt = 0xC0000000; /* 3 gig = virtual address of kernel */
SECTIONS {
/* kernel code and (ELF only) read-only data */
    .text virt : AT(phys) {
/* labels to define start of section: */
   g_code = .; _g_code = .;
        *(.text)
/* ELF constant data section(s). Note trailing wildcard. */
        *(.rodata*) 
   . = ALIGN(4096);
    }
/* kernel data */
    .data : AT(phys + (g_data - g_code)) {
   g_data = .; _g_data = .;
        *(.data)
   . = ALIGN(4096);
    }
/* kernel BSS */
    .bss : AT(phys + (g_bss - g_code)) {
   g_bss = .; _g_bss = .;
        *(.bss)
        *(COMMON) /* "common" variables */
   . = ALIGN(4096);
    }
/* end of BSS/kernel */
    g_end = .; _g_end = .;
}
If this script file is named "krnl.ld", link with "ld -T krnl.ld ..."
chrisa128

Re:Error linking kernel

Post by chrisa128 »

I think this may have worked... It links ok when I don't run it with my Makefile... :)

Thanks Chris
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Error linking kernel

Post by Pype.Clicker »

what developping environment do you use ? (Djgpp? Cygwin? linux binutils ?)

Under Wind0ws, make sure your FILES environment variable was large enough to have your tools run ...
Post Reply