From: Andrew Burgess <andrew.burgess@embecosm.com>
To: binutils@sourceware.org
Cc: Cooper Qu <cooper.qu@linux.alibaba.com>,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH] opcodes/csky: return the default disassembler when there is no bfd
Date: Wed, 16 Sep 2020 10:12:39 +0100 [thread overview]
Message-ID: <20200916091239.3477746-1-andrew.burgess@embecosm.com> (raw)
The disassembler function should return a valid disassembler function
even when there is no BFD present. This is implied (I believe) by the
comment in dis-asm.h which says the BFD may be NULL. Further, it
makes sense when considering that the disassembler is used in GDB, and
GDB may connect to a target and perform debugging even without a BFD
being supplied.
This commit makes the csky_get_disassembler function return the
default disassembler configuration when no bfd is supplied, this is
the same default configuration as is used when a BFD is supplied, but
the BFD has no attributes section.
Before the change configuring GDB with --enable-targets=all and
running the tests gdb.base/all-architectures-2.exp results in many
errors, but after this change there are no failures.
opcodes/ChangeLog:
* csky-dis.c (csky_get_disassembler): Don't return NULL when there
is no BFD.
---
opcodes/ChangeLog | 5 +++++
opcodes/csky-dis.c | 32 +++++++++++++++++---------------
2 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index ba0f4605f54..a28160b984e 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -239,23 +239,25 @@ csky_get_disassembler (bfd *abfd)
obj_attribute *attr;
const char *sec_name = NULL;
if (!abfd)
- return NULL;
-
- mach_flag = elf_elfheader (abfd)->e_flags;
-
- sec_name = get_elf_backend_data (abfd)->obj_attrs_section;
- /* Skip any input that hasn't attribute section.
- This enables to link object files without attribute section with
- any others. */
- if (bfd_get_section_by_name (abfd, sec_name) != NULL)
+ dis_info.isa = CSKY_DEFAULT_ISA;
+ else
{
- attr = elf_known_obj_attributes_proc (abfd);
- dis_info.isa = attr[Tag_CSKY_ISA_EXT_FLAGS].i;
- dis_info.isa <<= 32;
- dis_info.isa |= attr[Tag_CSKY_ISA_FLAGS].i;
+ mach_flag = elf_elfheader (abfd)->e_flags;
+
+ sec_name = get_elf_backend_data (abfd)->obj_attrs_section;
+ /* Skip any input that hasn't attribute section.
+ This enables to link object files without attribute section with
+ any others. */
+ if (bfd_get_section_by_name (abfd, sec_name) != NULL)
+ {
+ attr = elf_known_obj_attributes_proc (abfd);
+ dis_info.isa = attr[Tag_CSKY_ISA_EXT_FLAGS].i;
+ dis_info.isa <<= 32;
+ dis_info.isa |= attr[Tag_CSKY_ISA_FLAGS].i;
+ }
+ else
+ dis_info.isa = CSKY_DEFAULT_ISA;
}
- else
- dis_info.isa = CSKY_DEFAULT_ISA;
return print_insn_csky;
}
--
2.25.4
next reply other threads:[~2020-09-16 9:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 9:12 Andrew Burgess [this message]
2020-09-17 7:41 ` Lifang Xia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200916091239.3477746-1-andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=binutils@sourceware.org \
--cc=cooper.qu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).