]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elfcode.h
Fix: strip --strip-debug breaks relocations
[thirdparty/binutils-gdb.git] / bfd / elfcode.h
index ab8c3eaaf4c6f152e1134a1a4a32e11742ef46b3..2c2eb368df986bdc02b2187cbb6f145a405804d0 100644 (file)
@@ -1014,7 +1014,13 @@ elf_write_relocs (bfd *abfd, asection *sec, void *data)
       sym = *ptr->sym_ptr_ptr;
       if (sym == last_sym)
        n = last_sym_idx;
-      else if (bfd_is_abs_section (sym->section) && sym->value == 0)
+      /* If the relocation is against an absolute symbol whoes value is
+        zero, then the symbol can be dropped, simplifying the reloc.
+        PR 31106: Except for complex relocations where the symbols
+        itself might be significant.  */
+      else if (bfd_is_abs_section (sym->section)
+              && sym->value == 0
+              && (sym->flags & BSF_RELC) == 0)
        n = STN_UNDEF;
       else
        {