Page 1 of 1

[SOLVED] G++ linker going crazy ?

Posted: Sun Jan 26, 2014 1:35 pm
by wichtounet
Hi everybody,

I'm encountering a strange problem with g++ linking phase.

When I use this linker script:

Code: Select all

ENTRY(main)

SECTIONS {
	. = 0x8000401000;

	.text BLOCK(4096) : ALIGN(4096)
	{
		*(.text)
	}

	. = 0x8000601000;

	.data BLOCK(4096) : ALIGN(4096)
	{
		*(.data)
	}
}
g++ creates a 2.1M executable. If I change 0x8000601000 to 0x8000602000, the executable size is 12K. When I look at the ELF headers, I see that the second program header is put at an offset of 0x201000. I don't understand this behavior.

I've searched for it and I found https://groups.google.com/forum/#!topic ... 5fzlMbjdy0. However, there are no real solution in this post, neither real explanation. I tried adding rodata and bss section (even with rodata* and bss*) and it does not change anything.

Does someone ever encountered such issues ? Is there an option I can use to prevent that to happen ?

Thank you for any idea

Re: G++ linker going crazy ?

Posted: Sun Jan 26, 2014 3:50 pm
by Combuster
All documented on the wiki. You should have seen that one.

Re: G++ linker going crazy ?

Posted: Mon Jan 27, 2014 1:11 am
by wichtounet
Combuster wrote:All documented on the wiki. You should have seen that one.
Thank you, the -z max-page-size=0x1000 did it.

As the problem was not with my kernel but with my user applications, I did not came across this page since I was looking for linker issues in general.