linker script

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
matematik
Posts: 4
Joined: Sun Aug 24, 2008 5:49 am
Contact:

linker script

Post 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?
matematik
Posts: 4
Joined: Sun Aug 24, 2008 5:49 am
Contact:

Re: linker script

Post 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?
Post Reply