aboutsummaryrefslogtreecommitdiff
path: root/ld/ld.texi
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2024-05-10 16:59:05 +0100
committerNick Clifton <nickc@redhat.com>2024-05-10 16:59:05 +0100
commit6e8376fa569e62379a42b91b0afd1f4086f1d897 (patch)
treed9bddaa0a8b3b242ba063df4dbbee272220ea385 /ld/ld.texi
parentad658482c1e4feec4ac99c8e7df17ff78d0c2996 (diff)
downloadgdb-6e8376fa569e62379a42b91b0afd1f4086f1d897.zip
gdb-6e8376fa569e62379a42b91b0afd1f4086f1d897.tar.gz
gdb-6e8376fa569e62379a42b91b0afd1f4086f1d897.tar.bz2
Add --section-ordering command line option to the bfd linker.
Diffstat (limited to 'ld/ld.texi')
-rw-r--r--ld/ld.texi72
1 files changed, 66 insertions, 6 deletions
diff --git a/ld/ld.texi b/ld/ld.texi
index ca9574d..b32bb46 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -302,6 +302,7 @@ and the script command language. If @emph{no} binary input files at all
are specified, the linker does not produce any output, and issues the
message @samp{No input files}.
+@anchor{unrecognised-input-files}
If the linker cannot recognize the format of an object file, it will
assume that it is a linker script. A script specified in this way
augments the main linker script used for the link (either the default
@@ -1163,18 +1164,32 @@ a linker bug report.
@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),
-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
-specified by any preceding @samp{-L} options. Multiple @samp{-T}
-options accumulate.
+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 specified by any preceding @samp{-L}
+options.
+
+Command line options that appear before the @option{-T} option can
+affect the script, but command line options that appear after it do
+not.
+
+Multiple @samp{-T} options will accumulate if they are augmenting the
+current script, otherwise the last, non-augmenting, @option{-T} option
+will be used.
+
+There are other ways of specifying linker scripts. See
+@xref{--default-script}, @xref{--section-ordering-file} and
+@xref{unrecognised-input-files}.
@kindex -dT @var{script}
@kindex --default-script=@var{script}
@cindex script files
@item -dT @var{scriptfile}
@itemx --default-script=@var{scriptfile}
+@anchor{--default-script}
Use @var{scriptfile} as the default linker script. @xref{Scripts}.
This option is similar to the @option{--script} option except that
@@ -2521,6 +2536,51 @@ warning and continue with the link.
@end ifset
+@kindex --section-ordering-file
+@item --section-ordering-file=@var{script}
+@anchor{--section-ordering-file}
+This option is used to augment the current linker script with
+additional mapping of input sections to output sections. This file
+must use the same syntax for @code{SECTIONS} as is used in normal
+linker scripts, but it should not do anything other than place input
+sections into output sections. @pxref{SECTIONS}
+
+A second constraint on the section ordering script is that it can only
+reference output sections that are already defined by whichever linker
+script is currently in use. (Ie the default linker script or a script
+specified on the command line). The benefit of the section ordering
+script however is that the input sections are mapped to the start of
+the output sections, so that they can ensure the ordering of sections
+in the output section. For example, imagine that the default linker
+script looks like this:
+
+@smallexample
+SECTIONS @{
+ .text : @{ *(.text.hot) ; *(.text .text.*) @}
+ .data : @{ *(.data.big) ; *(.data .data.*) @}
+ @}
+@end smallexample
+
+Then if a section ordering file like this is used:
+
+@smallexample
+ .text : @{ *(.text.first) ; *(.text.z*) @}
+ .data : @{ foo.o(.data.first) ; *(.data.small) @}
+@end smallexample
+
+This would be equivalent to a linker script like this:
+
+@smallexample
+SECTIONS @{
+ .text : @{ *(.text.first) ; *(.text.z*) ; *(.text.hot) ; *(.text .text.*) @}
+ .data : @{ foo.o(.data.first) ; *(.data.small) ; *(.data.big) ; *(.data .data.*) @}
+ @}
+@end smallexample
+
+The advantage of the section ordering file is that it can be used to
+order those sections that matter to the user without having to worry
+about any other sections, or memory regions, or anything else.
+
@kindex -shared
@kindex -Bshareable
@item -shared