[SOLVED] G++ linker going crazy ?

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
User avatar
wichtounet
Member
Member
Posts: 90
Joined: Fri Nov 01, 2013 4:05 pm
Location: Fribourg, Switzerland
Contact:

[SOLVED] G++ linker going crazy ?

Post 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
Last edited by wichtounet on Mon Jan 27, 2014 1:11 am, edited 1 time in total.
Thor Operating System: C++ 64 bits OS: https://github.com/wichtounet/thor-os
Good osdeving!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: G++ linker going crazy ?

Post by Combuster »

All documented on the wiki. You should have seen that one.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
wichtounet
Member
Member
Posts: 90
Joined: Fri Nov 01, 2013 4:05 pm
Location: Fribourg, Switzerland
Contact:

Re: G++ linker going crazy ?

Post 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.
Thor Operating System: C++ 64 bits OS: https://github.com/wichtounet/thor-os
Good osdeving!
Post Reply