tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Multiboot header on amd64


The multiboot specification requires a multiboot header at the beginning
of the kernel file (below 32 KB for multiboot 2).

On i386, we insert it at the beginning of the .text section in locore.S
and that is fine. 

On amd64, the kern.ldscript file sets the .text section load address at
0x200000 which is way beyond 32 kB, hence we cannot just insert the
multiboot header like we do on i386.

I worked that around by adding a specific section in locore.S:
.section        multiboot,"0",@note

The secion is of type note, because it must not be loaded in memory: 
ld seems to tightly bind a loadable section load address and its offset
in the ELF file. There are things below 32 kB that must be kept intact, 
especially when booting from EFI, and we do not want them to be overwritten
by the multiboot section. 

But then the placement of the section in the ELF file is troublesome.
In kern.ldscript I can set addresses, but they are not honoured for a
non loadable section. The only way I found to have the multiboot 
section installed at the begining of the file is:

        headers PT_PHDR PHDRS ;
        multiboot PT_NOTE ;
        text PT_LOAD FILEHDR PHDRS ;
        data PT_LOAD ;
        multiboot :
        } :multiboot

That works at the price of warnings for all other sections:
x86_64--netbsd-strip: netbsd: warning: allocated section `xxx' not in segment

If I add :text after the definition of the .text section, the warning 
goes away, but the multiboot section is located after the loadable sections.

Anyone has some insights on this problem?

Emmanuel Dreyfus

Home | Main Index | Thread Index | Old Index