]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add extra linker warning message about discrepancies between normal and common symbols.
authorNick Clifton <nickc@redhat.com>
Wed, 7 Jun 2023 13:30:13 +0000 (14:30 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 7 Jun 2023 13:30:13 +0000 (14:30 +0100)
  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.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-elfcomm/elfcomm.exp

index 2b466f794a87d1c49b62824b85ea6942824f4337..1f9b7ec14ba0a39e268d184f2a11d0efd78c0496 100644 (file)
@@ -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
index f10faa5f8bde8028248b6c07fb2327d1276df15f..4f879005c226ba07028ee4191ef9a91c90d14607 100644 (file)
@@ -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;
            }
index 1acef2afc97ea44af67284f3fad5c8bbcea96263..d722d0ba4827714543f75682605ee3e9e05e3edb 100644 (file)
@@ -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
index 4a9ffa9ce6d67854733d3a3ec6cf40c47c623630..80df9fe926929e2d2cd3d369691b99df35e43c2b 100644 (file)
@@ -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