This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Reserving a large address region using the MEMORY directive
- From: Nick Clifton <nickc at redhat dot com>
- To: Mike Hearn <mike at theoretic dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 27 Jan 2004 17:53:05 +0000
- Subject: Re: Reserving a large address region using the MEMORY directive
- References: <pan.2004.01.21.22.28.07.379780@theoretic.com>
Hi Mike,
> 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
> with:
>
> MEMORY {
> 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?
That script does look basically correct, but I think that you have
attributes slightly mixed up.
before (rwxai)
This says that the "before" region is read-only ("r") and read/write
("w"). Presumably you just want "r".
Also specifying an attribute for a region means that only sections
whose attributes exactly match the attributes of the region will be
allocated to it. Any other sections will be assigned to the nearest
region with no attributes - ie the "loadarea" in the case of your map.
I think that you probably want a map like this:
MEMORY {
before (rxai) : ORIGIN = 0x000000, LENGTH = 0x400000
loadarea (wx) : ORIGIN = 0x400000, LENGTH = 256M
after : ORIGIN = 0x10400000, LENGTH = 0xe0c00000
}
Assuming that you do not have any writable/executable input
sections...
Cheers
Nick