From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 73EB53858D20; Fri, 31 Mar 2023 06:19:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73EB53858D20 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Arm64/ELF: accept relocations against STN_UNDEF X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: 56ce0c730b5dcb1e365e9cb42394f42a9a4154a3 X-Git-Newrev: af9eb2ee1b10caa89e1c603cd484bc025e71f4fd Message-Id: <20230331061908.73EB53858D20@sourceware.org> Date: Fri, 31 Mar 2023 06:19:08 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2023 06:19:08 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Daf9eb2ee1b10= caa89e1c603cd484bc025e71f4fd commit af9eb2ee1b10caa89e1c603cd484bc025e71f4fd Author: Jan Beulich Date: Fri Mar 31 08:15:53 2023 +0200 Arm64/ELF: accept relocations against STN_UNDEF =20 While only a secondary issue there, the testcase of PR gas/27212 exposes an oversight in relocation handling: Just like e.g. Arm32, which has a similar comment and a similar check, relocations against STN_UNDEF have to be permitted to satisfy the ELF spec. Diff: --- bfd/elfnn-aarch64.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index c4db1e6f168..c23cbd3601a 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -6946,8 +6946,12 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, =20 /* An object file might have a reference to a local undefined symbol. This is a daft object file, but we - should at least do something about it. */ + should at least do something about it. NONE and NULL + relocations do not use the symbol and are explicitly + allowed to use an undefined one, so allow those. + Likewise for relocations against STN_UNDEF. */ if (r_type !=3D R_AARCH64_NONE && r_type !=3D R_AARCH64_NULL + && r_symndx !=3D STN_UNDEF && bfd_is_und_section (sec) && ELF_ST_BIND (sym->st_info) !=3D STB_WEAK) (*info->callbacks->undefined_symbol)