ld: Clarify --wrap documentation
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Thu, 10 Jan 2019 14:05:19 +0000 (15:05 +0100)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Mon, 14 Jan 2019 07:24:44 +0000 (08:24 +0100)
ld/

* ld.texi (--wrap): Add example to emphasise that only undefined
references are replaced by the linker.

ld/ChangeLog
ld/ld.texi

index 2c211fe3fef27df1d113db0a9f8992a0fabe3959..274f4af998dd0322a08bed6d7d4ce47636585204 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-14  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * ld.texi (--wrap): Add example to emphasise that only undefined
+       references are replaced by the linker.
+
 2019-01-09  Nick Clifton  <nickc@redhat.com>
 
        * po/es.po: Updated Spanish translation.
index cc0d220fa0030d7185f4a9b062f765387c4d47d1..5179af3e0e1f3c4c1f50399c302b79dc3c059441 100644 (file)
@@ -2392,6 +2392,25 @@ you should not put the definition of @code{__real_malloc} in the same
 file as @code{__wrap_malloc}; if you do, the assembler may resolve the
 call before the linker has a chance to wrap it to @code{malloc}.
 
+Only undefined references are replaced by the linker.  So, translation unit
+internal references to @var{symbol} are not resolved to
+@code{__wrap_@var{symbol}}.  In the next example, the call to @code{f} in
+@code{g} is not resolved to @code{__wrap_f}.
+
+@smallexample
+int
+f (void)
+@{
+  return 123;
+@}
+
+int
+g (void)
+@{
+  return f();
+@}
+@end smallexample
+
 @kindex --eh-frame-hdr
 @kindex --no-eh-frame-hdr
 @item --eh-frame-hdr
This page took 0.028633 seconds and 4 git commands to generate.