Reserving a large address region using the MEMORY directive

Mike Hearn
Wed Jan 21 22:30:00 GMT 2004


As part of experiments into making Wine work correctly with exec-shield
and prelink, I'm trying to reserve a 256mb region of address space so the
dynamic linker will not load any DSOs into that area. We need to be able
to mmap files into this area (starting at 0x00400000).

The first attempt at a workaround was to use a 256mb static array in the
BSS and then unmap it, however this caused people with <= 256mb virtual
memory to segfault.

Reading the ld manual, it seems the best way to do this is to use the
MEMORY directive, however I simply get segfaults when a minimal test app
int main() { return 0; } is run. This is the linker script I'm starting

	before (rwxai) : ORIGIN = 0x000000, LENGTH = 0x400000 
	loadarea       : ORIGIN = 0x400000, LENGTH = 256M

I'm sure this doesn't look right, but am I vaguely on the right track?
Does anybody know what the script I need would look like?

thanks -mike

More information about the Binutils mailing list