]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Re: elf_backend_finish_dynamic_symbol returning false
authorAlan Modra <amodra@gmail.com>
Thu, 15 Feb 2024 08:33:07 +0000 (19:03 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 15 Feb 2024 08:41:42 +0000 (19:11 +1030)
I didn't examine ld testsuite logs properly after cf95b909e2c2.
Replacing one of the "return false" with BFD_ASSERT in
finish_dynamic_symbol was wrong as it causes segmentation faults on
testcases expected to fail.  Revert those changes and instead make
a bfd_final_link failure noisy.

bfd/elf32-s390.c
bfd/elf64-s390.c
bfd/elf64-x86-64.c
bfd/elfnn-aarch64.c
bfd/elfnn-kvx.c
ld/ldwrite.c

index 06d54e6fa2d5c40307e74d694d6496c67da6c4d5..1a2ade0414e0065b8f65cbac7bd45105510411ed 100644 (file)
@@ -3505,7 +3505,8 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
             RELATIVE reloc.  The entry in the global offset table
             will already have been initialized in the
             relocate_section function.  */
-         BFD_ASSERT (h->def_regular || ELF_COMMON_DEF_P (h));
+         if (!(h->def_regular || ELF_COMMON_DEF_P (h)))
+           return false;
          BFD_ASSERT((h->got.offset & 1) != 0);
          rela.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
          rela.r_addend = (h->root.u.def.value
index bef90f6ed847911d78269fa206fe007186c6b528..ab9ec3f5b487630542635bc8c224e1dde971c222 100644 (file)
@@ -3371,7 +3371,8 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
             RELATIVE reloc.  The entry in the global offset table
             will already have been initialized in the
             relocate_section function.  */
-         BFD_ASSERT (h->def_regular || ELF_COMMON_DEF_P (h));
+         if (!(h->def_regular || ELF_COMMON_DEF_P (h)))
+           return false;
          BFD_ASSERT((h->got.offset & 1) != 0);
          rela.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
          rela.r_addend = (h->root.u.def.value
index 6cc70a7d4c37d87f4ac859bce17489b65b13fdf0..3300a2017bd919cd592a111d33ab0901b36c50ea 100644 (file)
@@ -4921,7 +4921,8 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
       else if (bfd_link_pic (info)
               && SYMBOL_REFERENCES_LOCAL_P (info, h))
        {
-         BFD_ASSERT (SYMBOL_DEFINED_NON_SHARED_P (h));
+         if (!SYMBOL_DEFINED_NON_SHARED_P (h))
+           return false;
          BFD_ASSERT((h->got.offset & 1) != 0);
          if (info->enable_dt_relr)
            generate_dynamic_reloc = false;
index cf21f62d73a1df0a4ef0925f157e7962bf5e8c89..560983aaed6230454dda0693c550693a7c080e16 100644 (file)
@@ -9739,7 +9739,8 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
        }
       else if (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h))
        {
-         BFD_ASSERT (h->def_regular || ELF_COMMON_DEF_P (h));
+         if (!(h->def_regular || ELF_COMMON_DEF_P (h)))
+           return false;
          BFD_ASSERT ((h->got.offset & 1) != 0);
          rela.r_info = ELFNN_R_INFO (0, AARCH64_R (RELATIVE));
          rela.r_addend = (h->root.u.def.value
index 00446c9a8d806d1ee7c5ded81ecae5471ea142ff..ae5ed6bf3f75eaa81421ea6c697d0fdb00f0dc8d 100644 (file)
@@ -4479,7 +4479,8 @@ elfNN_kvx_finish_dynamic_symbol (bfd *output_bfd,
 
       if (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h))
        {
-         BFD_ASSERT (h->def_regular);
+         if (!h->def_regular)
+           return false;
 
          /* in case of PLT related GOT entry, it is not clear who is
             supposed to set the LSB of GOT entry...
index 46fb33c825e6379c289f9a96f0a540d13ee6b182..8ce4297853bd2c60fbe47ffefc07742bf0e88e64 100644 (file)
@@ -549,13 +549,9 @@ ldwrite (void)
     split_sections (link_info.output_bfd, &link_info);
   if (!bfd_final_link (link_info.output_bfd, &link_info))
     {
-      /* If there was an error recorded, print it out.  Otherwise assume
-        an appropriate error message like unknown symbol was printed
-        out.  */
-
       if (bfd_get_error () != bfd_error_no_error)
        einfo (_("%F%P: final link failed: %E\n"));
       else
-       xexit (1);
+       einfo (_("%F%P: final link failed\n"));
     }
 }