From c470f2ebaff232f9227d38462b9e224a97f4f5a0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 27 Oct 1998 00:07:50 +0000 Subject: [PATCH] Describe -O option. --- ld/ld.1 | 13 +++++++++++++ ld/ld.texinfo | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/ld/ld.1 b/ld/ld.1 index 79c9f102c04..9b4b0319295 100644 --- a/ld/ld.1 +++ b/ld/ld.1 @@ -92,6 +92,9 @@ ld \- the GNU linker .RB "[\|" \-noinhibit-exec "\|]" .RB "[\|" \-no\-keep\-memory "\|]" .RB "[\|" \-no\-warn\-mismatch "\|]" +.RB "[\|" \-O\c +.I level\c +\&\|] .RB "[\|" "\-oformat\ "\c .I output-format\c \&\|] @@ -689,6 +692,16 @@ script command \c .B OUTPUT\c \& can also specify the output file name. +.TP +.BI "\-O" "level" +Generate optimized output files. This might use significantly more +time and therefore probably should be enabled only for generating the +final binary. +\c +.I level\c +\& is supposed to be a numeric value. Any value greater than zero enables +the optimizations. + .TP .BI "\-oformat " "output\-format" Specify the binary format for the output object file. diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 75335b467e5..19427d2b846 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -554,6 +554,13 @@ Use @var{output} as the name for the program produced by @code{ld}; if this option is not specified, the name @file{a.out} is used by default. The script command @code{OUTPUT} can also specify the output file name. +@kindex -O @var{level} +@cindex generating optimized output +@item -O @var{level} +If @var{level} is a numeric values greater than zero @code{ld} optimizes +the output. This might take significantly longer and therefore probably +should only be enabled for the final binary. + @cindex partial link @cindex relocatable output @kindex -r @@ -1663,6 +1670,12 @@ command is also used to set the format for the output file. @xref{BFD}. There are a few other linker scripts commands. @table @code +@item ASSERT(@var{exp}, @var{message}) +@kindex ASSERT +@cindex assertion in linker script +Ensure that @var{exp} is non-zero. If it is zero, then exit the linker +with an error code, and print @var{message}. + @item EXTERN(@var{symbol} @var{symbol} @dots{}) @kindex EXTERN @cindex undefined symbol in linker script @@ -2324,10 +2337,20 @@ runtime code expects to see. __DTOR_END__ = .; @end smallexample +If you are using the @sc{gnu} C++ support for initialization priority, +which provides some control over the order in which global constructors +are run, you must sort the constructors at link time to ensure that they +are executed in the correct order. When using the @code{CONSTRUCTORS} +command, use @samp{SORT(CONSTRUCTORS)} instead. When using the +@code{.ctors} and @code{.dtors} sections, use @samp{*(SORT(.ctors))} and +@samp{*(SORT(.dtors))} instead of just @samp{*(.ctors)} and +@samp{*(.dtors)}. + Normally the compiler and linker will handle these issues automatically, and you will not need to concern yourself with them. However, you may need to consider this if you are using C++ and writing your own linker scripts. + @end table @node Output Section Discarding -- 2.30.2