From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id 0B1C9385801F; Tue, 5 Dec 2023 15:19:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B1C9385801F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Fix: strip --strip-debug breaks relocations X-Act-Checkin: binutils-gdb X-Git-Author: Nick Clifton X-Git-Refname: refs/heads/master X-Git-Oldrev: 3381781151c60cc70a9fb44856e2dd5611465a73 X-Git-Newrev: e60675a228a8ecd2cfdc7e45cb315a1838b91f74 Message-Id: <20231205151916.0B1C9385801F@sourceware.org> Date: Tue, 5 Dec 2023 15:19:16 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Dec 2023 15:19:16 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De60675a228a8= ecd2cfdc7e45cb315a1838b91f74 commit e60675a228a8ecd2cfdc7e45cb315a1838b91f74 Author: Nick Clifton Date: Tue Dec 5 15:18:40 2023 +0000 Fix: strip --strip-debug breaks relocations =20 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 symbo= l 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 + + 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 =20 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 *da= ta) sym =3D *ptr->sym_ptr_ptr; if (sym =3D=3D last_sym) n =3D last_sym_idx; - else if (bfd_is_abs_section (sym->section) && sym->value =3D=3D 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 =3D=3D 0 + && (sym->flags & BSF_RELC) =3D=3D 0) n =3D STN_UNDEF; else {