This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: multiple SECTIONS and/or MEMORY commands
On Tue, Oct 30, 2001 at 01:54:32PM +1030, Alan Modra wrote:
>> Is this appearing-only-once thing simply convention, or is there (or might
>> there be in the future) something in the linker that depends on it?
>
> There may have been some such restriction in the past, but looking at
> ldgram.y, I see no reason why you can't have multiple MEMORY or SECTIONS
> commands.
Great, I was hoping any restriction was purely historical.
> If there is a contradiction between ld.texinfo and ldgram.y,
> ldgram.y is the definitive source. ;-)
If there's a contradiction here and if it needs to be fixed, here's a
patch that might be acceptable.
Cheers,
John
2001-10-30 John Marshall <jmarshall@acm.org>
* ld.texinfo: A historical requirement that MEMORY and SECTIONS
appear only once across all the linker scripts involved in a link
invocation no longer applies. Make the documentation reflect that.
--- ld.texinfo.orig Tue Oct 30 22:46:57 2001
+++ ld.texinfo Tue Oct 30 22:50:54 2001
@@ -277,10 +277,8 @@
permits the linker to link against a file which appears to be an object
or an archive, but actually merely defines some symbol values, or uses
@code{INPUT} or @code{GROUP} to load other objects. Note that
-specifying a script in this way should only be used to augment the main
-linker script; if you want to use some command that logically can only
-appear once, such as the @code{SECTIONS} or @code{MEMORY} command, you
-must replace the default linker script using the @samp{-T} option.
+specifying a script in this way merely augments the main linker script;
+use the @samp{-T} option to replace the default linker script entirely.
@xref{Scripts}.
For options whose names are a single letter,
@@ -754,9 +752,7 @@
Use @var{scriptfile} as the linker script. This script replaces
@code{ld}'s default linker script (rather than adding to it), so
@var{commandfile} must specify everything necessary to describe the
-output file. You must use this option if you want to use a command
-which can only appear once in a linker script, such as the
-@code{SECTIONS} or @code{MEMORY} command. @xref{Scripts}. If
+output file. @xref{Scripts}. If
@var{scriptfile} does not exist in the current directory, @code{ld}
looks for it in the directories specified by any preceding @samp{-L}
options. Multiple @samp{-T} options accumulate.
@@ -3362,7 +3358,7 @@
regions that become too full. The linker will not shuffle sections
around to fit into the available regions.
-A linker script may contain at most one use of the @code{MEMORY}
+A linker script typically contains at most one use of the @code{MEMORY}
command. However, you can define as many blocks of memory within it as
you wish. The syntax is:
@smallexample