set .text section baseaddress

Programming, for all ages and all languages.
Post Reply
mordak
Posts: 6
Joined: Fri Aug 17, 2012 2:15 am

set .text section baseaddress

Post by mordak »

hi 8)
i want create new section in c++ and set differnet base Address
for it section is there any way to do it in vc++.
like this

Code: Select all

SECTIONS
{
	. = 0x100000;

	.setup :
	{
		*(.setup)
	}

	. += 0xC0000000;

	.text : AT(ADDR(.text) - 0xC0000000)
	{
		*(.text)
	}

	.data ALIGN (4096) : AT(ADDR(.data) - 0xC0000000)
	{
		*(.data)
		*(.rodata*)
	}

	.bss ALIGN (4096) : AT(ADDR(.bss) - 0xC0000000)
	{
		*(COMMON*)
		*(.bss*)
	}
}

User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: set .text section baseaddress

Post by neon »

Hello,

What I see here is two questions: one asking to set the base of .text, the other is asking how to create new sections. Creating new sections is possible (please see next paragraph) but setting a specific location for .text is not... there really isn't any need for it.

The closest thing provided is a pragma extension that can be used for creating sections and section alignment; the actual placement of the sections cannot be set to specific linear addresses as with LD. Also note that it is limited to C linkage of functions. This directive can also be used to define and set section properties that the OS can use when allocating pages for the section.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
mordak
Posts: 6
Joined: Fri Aug 17, 2012 2:15 am

Re: set .text section baseaddress

Post by mordak »

Thank you mike so i must use linker script.
Post Reply