]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bpf: opcodes: fix regression in BPF disassembler
authorJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 31 Jul 2023 13:44:36 +0000 (15:44 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 31 Jul 2023 13:46:43 +0000 (15:46 +0200)
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=30705.

Tested in bpf-unkonwn-none.

opcodes/ChangeLog:

2023-07-31  Jose E. Marchesi  <jose.marchesi@oracle.com>

PR 30705
* bpf-dis.c (print_insn_bpf): Check that info->section->owner is
actually available before using it.

opcodes/ChangeLog
opcodes/bpf-dis.c

index 9d33da2162746db4b3e323e95485706751c2a2e1..99f95c645682b5769c6043fd89f4f9b2e8ac8b31 100644 (file)
@@ -1,3 +1,9 @@
+2023-07-31  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+       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  <jose.marchesi@oracle.com>
 
        * bpf-dis.c: Initialize asm_bpf_version to -1.
index a8cb9e8e6db2fa33e617a6f59ff2c3a6132b3085..1b1a532df7416c8aa90be5182ff67aa4fed8eeaf 100644 (file)
@@ -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 == -1)
+  if (asm_bpf_version == -1 && info->section && info->section->owner)
     {
       struct bfd *abfd = info->section->owner;
       Elf_Internal_Ehdr *header = elf_elfheader (abfd);