* [PATCH] opcodes/csky: return the default disassembler when there is no bfd
@ 2020-09-16 9:12 Andrew Burgess
2020-09-17 7:41 ` Lifang Xia
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Burgess @ 2020-09-16 9:12 UTC (permalink / raw)
To: binutils; +Cc: Cooper Qu, Andrew Burgess
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] opcodes/csky: return the default disassembler when there is no bfd
2020-09-16 9:12 [PATCH] opcodes/csky: return the default disassembler when there is no bfd Andrew Burgess
@ 2020-09-17 7:41 ` Lifang Xia
0 siblings, 0 replies; 2+ messages in thread
From: Lifang Xia @ 2020-09-17 7:41 UTC (permalink / raw)
To: Andrew Burgess, binutils; +Cc: Cooper Qu
Hi Andrew,
Thanks al lot for that.
Best Regards
Lifang Xia
On 2020/9/16 17:12, Andrew Burgess wrote:
> 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;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-17 7:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 9:12 [PATCH] opcodes/csky: return the default disassembler when there is no bfd Andrew Burgess
2020-09-17 7:41 ` Lifang Xia
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).