Page 1 of 1

linker script

Posted: Sat Jan 09, 2010 11:01 am
by matematik
I am using gcc cross-compiler built from the tutorial on wiki. I'm using this linker script:

Code: Select all

ENTRY(kmain)
OUTPUT_FORMAT(elf64-x86-64)
PHDRS
{
	header PT_PHDR FILEHDR PHDRS ;
	load PT_LOAD ;
}
SECTIONS
{
	.text :
	{
		code = .;
		*(.text)
		*(.rodata)
		*(.eh_frame)
		. = ALIGN(4096);
	} :load
	.data : 
	{
		data = .;
		*(.data)
		. = ALIGN(4096);
	} :load
	.bss :
	{
		bss = .;
		*(.bss)
		. = ALIGN(4096);
	} :load
	end = .;
}
MEMORY
{
	all(RWXAI) : org = 0x0100000, l = 1M
}
My kernel loads fine and works, but the file is padded to 1MB mark and I don't think it is neccessary. How can i tell the linker not to pad it but put code right after elf header?

Re: linker script

Posted: Sun Jan 10, 2010 10:12 am
by matematik
Ah, never mind. Found that on wiki:
Try linking your kernel with the option "-z max-page-size=0x1000" to force the linker to use 4kb pages.
It works fine now. But I don't understand why should gcc increase file size because of page size?