public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR28902, -T script with INSERT ordering
@ 2023-05-13 11:13 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-05-13 11:13 UTC (permalink / raw)
  To: binutils

The answer to PR28902 may be deduced from the existing INSERT
documentation that says the default script is parsed after the -T
INSERT script, if you assume (correctly) that nothing special is done
when inserting into -T scripts overriding the default script.  In both
cases INSERT handling looks for the specified output section later on
the internal list of parsed script commands.  This isn't obvious
though, so make the ordering explicit, and mention that section
assignments are the same too.

	PR 28902
	* ld.texi (INSERT): Specify ordering when -T is used both to
	override the default script and to augment.

diff --git a/ld/ld.texi b/ld/ld.texi
index 012eec2e809..8038de39106 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1085,7 +1085,8 @@ a linker bug report.
 @item -T @var{scriptfile}
 @itemx --script=@var{scriptfile}
 Use @var{scriptfile} as the linker script.  This script replaces
-@command{ld}'s default linker script (rather than adding to it), so
+@command{ld}'s default linker script (rather than adding to it),
+unless the script contains @code{INSERT}, so
 @var{commandfile} must specify everything necessary to describe the
 output file.  @xref{Scripts}.  If @var{scriptfile} does not exist in
 the current directory, @code{ld} looks for it in the directories
@@ -4442,6 +4443,12 @@ SECTIONS
 INSERT AFTER .text;
 @end smallexample
 
+Note that when @samp{-T} is used twice, once to override the default
+script and once to augment that script using @code{INSERT} the order
+of parsing and section assignments apply as for the default script.
+The script with @code{INSERT} should be specified @emph{first} on the
+command line.
+
 @item NOCROSSREFS(@var{section} @var{section} @dots{})
 @kindex NOCROSSREFS(@var{sections})
 @cindex cross references

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-13 11:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-13 11:13 PR28902, -T script with INSERT ordering Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).