Created attachment 13418 [details] Fix for missing null-check objdump crashes when disassembling a non-ELF RISC-V binary due to a missing null-pointer check. I've attached a patch.
Patches for the GNU toolchain require an FSF copyright assignment, except for some trivial patches. Do you have a copyright assignment? mtvec is a RISC-V CSR so it seems unlikely to be your name. I would need a name to check the records at the FSF. Are you interested in getting an assignment? If you don't or can't get an assignment, then it would be useful to give a description of the problem so someone else with an assignment can write the patch.
I don't have a copyright assignment yet but I would be interested in getting one. What is the procedure for this? This patch is quite trivial by the way so we might be able to skip it in this case?
The master branch has been updated by Nelson Chu <nelsonc1225@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=113bb7618a4b52c5fc8fdc0e82b2cd9f72471f72 commit 113bb7618a4b52c5fc8fdc0e82b2cd9f72471f72 Author: Job Noorman <mtvec@pm.me> Date: Tue May 18 08:41:11 2021 +0800 RISC-V: PR27814, Objdump crashes when disassembling a non-ELF RISC-V binary. 2021-05-18 Job Noorman <mtvec@pm.me> opcodes/ PR 27814 * riscv-dis.c (riscv_get_disassembler): Get elf attributes only for the elf objects.
Hi Job Noorman, Thanks for reporting this. I have committed this fix, with the name and email from your account. So marked as resolved and fixed.
FYI, the original fix for this bug was not correct in all cases since it would try to access any non-NULL backend_data for any BFD as if it were for an ELF. My patch at https://sourceware.org/pipermail/binutils/2022-April/120619.html, which just got committed, fixes the issue properly (as far as I can tell) and also fixes a similar issue in several other architectures.