[PATCH 1/2] ld: More documentation for --defsym

Andrew Burgess andrew.burgess@embecosm.com
Mon Oct 12 13:49:14 GMT 2020


The ordering of command line options --defsym and -T is important,
however, the description of --defsym in the manual doesn't mention
this.

This commit adds more text to the description of --defsym to try and
explain this ordering requirement.

ld/ChangeLog:

	* ld.texi (Options): Extend the description of --defsym.
---
 ld/ChangeLog | 4 ++++
 ld/ld.texi   | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/ld/ld.texi b/ld/ld.texi
index 66bede283e8..2f3a2056f40 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1705,6 +1705,15 @@
 @emph{Note:} there should be no white space between @var{symbol}, the
 equals sign (``@key{=}''), and @var{expression}.
 
+The linker processes @samp{--defsym} arguments and @samp{-T} arguments
+in order, placing @samp{--defsym} before @samp{-T} will define the
+symbol before the linker script from @samp{-T} is processed, while
+placing @samp{--defsym} after @samp{-T} will define the symbol after
+the linker script has been processed.  This difference has
+consequences for expressions within the linker script that use the
+@samp{--defsym} symbols, which order is correct will depend on what
+you are trying to achieve.
+
 @cindex demangling, from command line
 @kindex --demangle[=@var{style}]
 @kindex --no-demangle
-- 
2.25.4



More information about the Binutils mailing list