public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Add extra linker warning message about discrepancies between normal and common symbols.
Date: Wed,  7 Jun 2023 13:31:24 +0000 (GMT)	[thread overview]
Message-ID: <20230607133124.17A163858C54@sourceware.org> (raw)

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

commit 064ad3ea5ecbc30de1eb52a22ac73fea1b5dcc5b
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Jun 7 14:30:13 2023 +0100

    Add extra linker warning message about discrepancies between normal and common symbols.
    
      PR 30499
      bfd * elflink.c (elf_link_add_object_symbols): Add a message indicating that alignment and size discrepancies between the definition of common symbols and normal symbols are serious and should be investigated.
      ld  * testsuite/ld-elfcomm/elfcomm.exp: Update regexps to match new output from the linker.

Diff:
---
 bfd/ChangeLog                       |  8 ++++++++
 bfd/elflink.c                       | 26 ++++++++++++++++++--------
 ld/ChangeLog                        |  6 ++++++
 ld/testsuite/ld-elfcomm/elfcomm.exp |  6 +++---
 4 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2b466f794a8..1f9b7ec14ba 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2023-06-07  Nick Clifton  <nickc@redhat.com>
+
+	PR 30499
+	* elflink.c (elf_link_add_object_symbols): Add a message
+	indicating that alignment and size discrepancies between the
+	definition of common symbols and normal symbols are serious and
+	should be investigated.
+
 2023-05-31  Tristan Gingold  <tgingold@free.fr>
 
 	PR 30444
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f10faa5f8bd..4f879005c22 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5302,10 +5302,14 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 		  else
 		    _bfd_error_handler
 		      /* xgettext:c-format */
-		      (_("warning: alignment %u of symbol `%s' in %pB"
-			 " is smaller than %u in %pB"),
+		      (_("warning: alignment %u of normal symbol `%s' in %pB"
+			 " is smaller than %u used by the common definition in %pB"),
 		       1 << normal_align, name, normal_bfd,
 		       1 << common_align, common_bfd);
+
+		  /* PR 30499: make sure that users understand that this warning is serious.  */
+		  _bfd_error_handler
+		    (_("warning: NOTE: alignment discrepancies can cause real problems.  Investigation is advised."));
 		}
 	    }
 
@@ -5317,12 +5321,18 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 	      if (h->size != 0
 		  && h->size != isym->st_size
 		  && ! size_change_ok)
-		_bfd_error_handler
-		  /* xgettext:c-format */
-		  (_("warning: size of symbol `%s' changed"
-		     " from %" PRIu64 " in %pB to %" PRIu64 " in %pB"),
-		   name, (uint64_t) h->size, old_bfd,
-		   (uint64_t) isym->st_size, abfd);
+		{
+		  _bfd_error_handler
+		    /* xgettext:c-format */
+		    (_("warning: size of symbol `%s' changed"
+		       " from %" PRIu64 " in %pB to %" PRIu64 " in %pB"),
+		     name, (uint64_t) h->size, old_bfd,
+		     (uint64_t) isym->st_size, abfd);
+
+		  /* PR 30499: make sure that users understand that this warning is serious.  */
+		  _bfd_error_handler
+		    (_("warning: NOTE: size discrepancies can cause real problems.  Investigation is advised."));
+		}
 
 	      h->size = isym->st_size;
 	    }
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1acef2afc97..d722d0ba482 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2023-06-07  Nick Clifton  <nickc@redhat.com>
+
+	PR 30499
+	* testsuite/ld-elfcomm/elfcomm.exp: Update regexps to match new
+	output from the linker.
+
 2023-05-17  Luca Bacci  <luca.bacci@outlook.com>
 
 	PR 30421
diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
index 4a9ffa9ce6d..80df9fe9269 100644
--- a/ld/testsuite/ld-elfcomm/elfcomm.exp
+++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
@@ -186,13 +186,13 @@ if { [ld_link $ld tmpdir/common1.o $options] } {
 # This test fails on MIPS because the backend sets type_change_ok.
 # The size change warning is suppressed.  Same on hppa64.
 if {[istarget mips*-*-*] || [istarget hppa*64*-*-*]} {
-    if { ![regexp "warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] } {
+    if { ![regexp "warning: alignment (\[0-9\]+) of normal symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 used by the common definition in tmpdir/common1a.o" $link_output] } {
         fail $test1w1
     } else {
         pass $test1w1
     }
 } else {
-    if { ![regexp "warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output]
+    if { ![regexp "warning: alignment (\[0-9\]+) of normal symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 used by the common definition in tmpdir/common1a.o" $link_output]
          || ![regexp "warning: size of symbol \`_?foo1\' changed from 2 in tmpdir/common1a.o to 21 in tmpdir/common1b.o" $link_output] } {
         fail $test1w1
     } else {
@@ -211,7 +211,7 @@ if { [ld_link $ld tmpdir/common1.o $options] } {
     return
 }
 
-if { ![regexp "warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] } {
+if { ![regexp "warning: alignment (\[0-9\]+) of normal symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 used by the common definition in tmpdir/common1a.o" $link_output] } {
     fail $test1w2
 } else {
     pass $test1w2

                 reply	other threads:[~2023-06-07 13:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230607133124.17A163858C54@sourceware.org \
    --to=nickc@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).