public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM
@ 2023-11-21  9:27 Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2023-11-21  9:27 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c320501655ec8d5077d0a3231652c7d661249bc

commit 1c320501655ec8d5077d0a3231652c7d661249bc
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Nov 21 09:26:19 2023 +0000

    Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM
    
      PR 31067
      * linker.c (_bfd_generic_link_add_one_symbol): When issuing a warning message, also display a message about the warning not being affected by garbage colleciton.
      * ld.texi (Special Sections): New entry in the linker manual. Describes how the .gnu.warning and .gnu.warning.SYM sections behave.

Diff:
---
 bfd/ChangeLog |  7 +++++++
 bfd/linker.c  |  8 ++++++++
 ld/ChangeLog  |  7 +++++++
 ld/ld.texi    | 45 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 143069894c1..e9f571acac2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2023-11-21  Nick Clifton  <nickc@redhat.com>
+
+	PR 31067
+	linker.c (_bfd_generic_link_add_one_symbol): When issuing a
+	warning message, also display a message about the warning not
+	being affected by garbage colleciton.
+
 2023-11-15  Arsen Arsenović  <arsen@aarsen.me>
 
 	* aclocal.m4: Regenerate.
diff --git a/bfd/linker.c b/bfd/linker.c
index 28fffc3ad63..90dc581cfe3 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1784,6 +1784,14 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
 	    {
 	      (*info->callbacks->warning) (info, string, h->root.string,
 					   hash_entry_bfd (h), NULL, 0);
+	      /* PR 31067: If garbage collection is enabled then the
+		 referenced symbol may actually be discarded later on.
+		 This could be very confusing to the user.  So give them
+		 a hint as to what might be happening.  */
+	      if (info->gc_sections)
+		(*info->callbacks->info)
+		  (_("%P: %pB: note: the message above does not take linker garbage collection into account\n"),
+		   hash_entry_bfd (h));
 	      break;
 	    }
 	  /* Fall through.  */
diff --git a/ld/ChangeLog b/ld/ChangeLog
index a30d3ad39b6..1766bd86dc2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2023-11-21  Nick Clifton  <nickc@redhat.com>
+
+	PR 31067
+	* ld.texi (Special Sections): New entry in the linker manual.
+	Describes how the .gnu.warning and .gnu.warning.SYM sections
+	behave.
+
 2023-11-15  Arsen Arsenović  <arsen@aarsen.me>
 
 	* aclocal.m4: Regenerate.
diff --git a/ld/ld.texi b/ld/ld.texi
index 5a143b2b518..0704eece8d6 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -127,6 +127,7 @@ in the section entitled ``GNU Free Documentation License''.
 * Invocation::                  Invocation
 * Scripts::                     Linker Scripts
 * Plugins::                     Linker Plugins
+* Special Sections::            Special Sections
 @ifset GENERIC
 * Machine Dependent::           Machine Dependent Features
 @end ifset
@@ -7525,6 +7526,50 @@ the @samp{__.LIBDEP} member of @file{libssl.a} would contain
 -L/usr/local/lib -lcrypto
 @end smallexample
 
+@node Special Sections
+When linking ELF format object files @command{ld} treats some sections
+in a special, non standard manner.  This part of the manual describes
+these sections.
+
+@table @gcctabopt
+@item .gnu.warning
+The contents of any section with this name are assumed to be an ascii
+format warning message.  The contents will be displayed to the user if
+the sections appears in any input file, but the section will not be
+copied into the output image.  If the @option{--fatal-warnings} option
+is enabled then the warnings - if any are encountered - will also stop
+the link from completing.
+
+Note - the @samp{.gnu.warning} section is not subject to linker
+garbage collection or orphan handling.
+
+@item .gnu.warning.@var{SYM}
+The contents of any section whoes name starts with the prefix
+@samp{.gnu.warning.} and then finishes with the name of a symbol is
+treated in a similar fashion to the @samp{.gnu.warning} section, but
+only if the named symbol is defined.  So for example the contents of a
+section called @samp{.gnu.warning.foo} will be displayed as warning
+message if, and only if, the symbol @samp{foo} is defined by one or
+more of the input files.  This includes object files pulled in from
+static libraries, shared objects needed to complete the link and so
+on.
+
+Note - because these warning messages are generated before the linker
+performs garbage collection (if enabled) it is possible for a warning
+to be displayed for a symbol that is later removed and then never
+appears in the final output.
+
+@item .note.gnu.property
+When the linker combines sections of this name it will merge them
+together according to various rules encoded into the notes
+themselves.  Therefore the contents of the output .note.gnu.property
+section may not correspond to a simple concatenation of the input
+sections.  If the @option{-Map} option has been used to request a
+linker map then details of any property merging will be included in
+the map.
+
+@end table
+
 @ifset GENERIC
 @node Machine Dependent
 @chapter Machine Dependent Features

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [binutils-gdb] Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM
@ 2023-11-21 11:31 Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2023-11-21 11:31 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1367eeec2cbd1bb14b89030e199d06fc676ffc49

commit 1367eeec2cbd1bb14b89030e199d06fc676ffc49
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Nov 21 11:30:03 2023 +0000

    Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM
    
      PR 31067
      Fix typo in previous delta: defined -> referenced.

Diff:
---
 ld/ld.texi | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ld/ld.texi b/ld/ld.texi
index 0704eece8d6..7ee06a71744 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -7547,12 +7547,12 @@ garbage collection or orphan handling.
 The contents of any section whoes name starts with the prefix
 @samp{.gnu.warning.} and then finishes with the name of a symbol is
 treated in a similar fashion to the @samp{.gnu.warning} section, but
-only if the named symbol is defined.  So for example the contents of a
-section called @samp{.gnu.warning.foo} will be displayed as warning
-message if, and only if, the symbol @samp{foo} is defined by one or
-more of the input files.  This includes object files pulled in from
-static libraries, shared objects needed to complete the link and so
-on.
+only if the named symbol is referenced.  So for example the contents
+of a section called @samp{.gnu.warning.foo} will be displayed as
+warning message if, and only if, the symbol @samp{foo} is referenced
+by one or more of the input files.  This includes object files pulled
+in from static libraries, shared objects needed to complete the link
+and so on.
 
 Note - because these warning messages are generated before the linker
 performs garbage collection (if enabled) it is possible for a warning

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-21 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21  9:27 [binutils-gdb] Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM Nick Clifton
2023-11-21 11:31 Nick Clifton

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).