[Top] [All Lists]

Re: Moving kernel_entry to LOADADDR

To: Gerald Champagne <>
Subject: Re: Moving kernel_entry to LOADADDR
From: Florian Lohoff <>
Date: Wed, 24 Oct 2001 13:16:11 +0200
Cc: "" <>
In-reply-to: <>
Organization: rfc822 - pure communication
References: <>
User-agent: Mutt/1.3.23i
On Thu, Oct 18, 2001 at 07:58:58PM -0500, Gerald Champagne wrote:
> I'm planning to work with a very minimal boot loader, and I'd like
> to hard-code a jump to kernel_entry in my boot loader.  I got tired
> of having kernel_entry moving around, so I just moved it to the top
> of head.S, just afte the ".fill 0x280".  That places kernel_entry at
> the same place every time.  It's always at LOADADDR+0x280.

Dont do this - Its easy to decode the elf stuff:

Basically this is the code needed to relocate the elf chunks
and return the entry point. I might have corrupted it a bit due to stripping
unneeded bits but you will get the point. This code even clears bss
chunk which the kernel will do itself again.

        Elf32_Ehdr      *fhdr = fb;
        Elf32_Shdr      *shdr;  
        int             i;

        if (fhdr->e_machine != EM_MIPS) {
                printf("No Mips ELF\n");

        fhdr=(void *) KSEG1ADDR(fb);

        shdr=fb + fhdr->e_shoff;

        for(i=0;i<fhdr->e_shnum;i++,shdr++) {

                if (shdr->sh_size <= 0) 

                if (shdr->sh_type == SHT_PROGBITS) {
                        memcpy((void *) KSEG1ADDR(shdr->sh_addr),
                                KSEG1ADDR(fb + shdr->sh_offset),
                } else if (shdr->sh_type == SHT_NOBITS) {
                        memset((void *) KSEG1ADDR(shdr->sh_addr), 0x0, 
        return((void *) fhdr->e_entry);

Florian Lohoff                     +49-5201-669912
Nine nineth on september the 9th              Welcome to the new billenium

Attachment: pgpVGUP_yfT5e.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>