From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1861) id AF3763858CD1; Mon, 31 Jul 2023 13:46:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF3763858CD1 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jose E. Marchesi To: bfd-cvs@sourceware.org Subject: [binutils-gdb] bpf: opcodes: fix regression in BPF disassembler X-Act-Checkin: binutils-gdb X-Git-Author: Jose E. Marchesi X-Git-Refname: refs/heads/master X-Git-Oldrev: 6a6e82dc75afc3d6d72e925ad562fba8f297251c X-Git-Newrev: 5b512234c874d5f82734dc6115765bc691c2c982 Message-Id: <20230731134656.AF3763858CD1@sourceware.org> Date: Mon, 31 Jul 2023 13:46:56 +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: Mon, 31 Jul 2023 13:46:56 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5b512234c874= d5f82734dc6115765bc691c2c982 commit 5b512234c874d5f82734dc6115765bc691c2c982 Author: Jose E. Marchesi Date: Mon Jul 31 15:44:36 2023 +0200 bpf: opcodes: fix regression in BPF disassembler =20 This patch fixes a regression recently introduced in the BPF disassembler, that was assuming an abfd was always available in info->section->owner. Apparently this is not so in GDB, and therefore https://sourceware.org/bugzilla/show_bug.cgi?id=3D30705. =20 Tested in bpf-unkonwn-none. =20 opcodes/ChangeLog: =20 2023-07-31 Jose E. Marchesi =20 PR 30705 * bpf-dis.c (print_insn_bpf): Check that info->section->owner is actually available before using it. Diff: --- opcodes/ChangeLog | 6 ++++++ opcodes/bpf-dis.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 9d33da21627..99f95c64568 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,9 @@ +2023-07-31 Jose E. Marchesi + + PR 30705 + * bpf-dis.c (print_insn_bpf): Check that info->section->owner is + actually available before using it. + 2023-07-30 Jose E. Marchesi =20 * bpf-dis.c: Initialize asm_bpf_version to -1. diff --git a/opcodes/bpf-dis.c b/opcodes/bpf-dis.c index a8cb9e8e6db..1b1a532df74 100644 --- a/opcodes/bpf-dis.c +++ b/opcodes/bpf-dis.c @@ -147,7 +147,7 @@ print_insn_bpf (bfd_vma pc, disassemble_info *info) If the user didn't explicitly specify an ISA version, then derive it from the CPU Version flag in the ELF header. A CPU version of 0 in the header means "latest version". */ - if (asm_bpf_version =3D=3D -1) + if (asm_bpf_version =3D=3D -1 && info->section && info->section->owner) { struct bfd *abfd =3D info->section->owner; Elf_Internal_Ehdr *header =3D elf_elfheader (abfd);