public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Fix: strip --strip-debug breaks relocations
@ 2023-12-05 15:19 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2023-12-05 15:19 UTC (permalink / raw)
  To: bfd-cvs

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

commit e60675a228a8ecd2cfdc7e45cb315a1838b91f74
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Dec 5 15:18:40 2023 +0000

    Fix: strip --strip-debug breaks relocations
    
      PR 31106
      * elfcode.h (elf_write_relocs): Do not convert a relocation against a zero-value absolute symbol into a relocation without a symbol if the symbol is being used for a complex relocation.

Diff:
---
 bfd/ChangeLog | 7 +++++++
 bfd/elfcode.h | 8 +++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e9f571acac2..1cc8d3ae9f0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2023-12-05  Nick Clifton  <nickc@redhat.com>
+
+	PR 31106
+	* elfcode.h (elf_write_relocs): Do not convert a relocation
+	against a zero-value absolute symbol into a relocation without a
+	symbol if the symbol is being used for a complex relocation.
+
 2023-11-21  Nick Clifton  <nickc@redhat.com>
 
 	PR 31067
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index ab8c3eaaf4c..2c2eb368df9 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -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
 	{

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-05 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-05 15:19 [binutils-gdb] Fix: strip --strip-debug breaks relocations 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).