[v2,2/2] opcodes/nfp: skip those non-code sections

Message ID 1629939678-17826-3-git-send-email-yinjun.zhang@corigine.com
State New
Headers show
Series
  • opcodes/nfp: bug fix for nfp disassembler
Related show

Commit Message

Yinjun Zhang Aug. 26, 2021, 1:01 a.m.
Currently nfp disassemblers can only support code section,
and we don't require to disassmeble other sections for now.
So skip the non-code sections.

Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com>

Signed-off-by: Simon Horman <simon.horman@corigine.com>

---
 opcodes/nfp-dis.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.27.0

Patch

diff --git a/opcodes/nfp-dis.c b/opcodes/nfp-dis.c
index ff69410d967..05f7a27bc46 100644
--- a/opcodes/nfp-dis.c
+++ b/opcodes/nfp-dis.c
@@ -2959,6 +2959,14 @@  print_insn_nfp (bfd_vma addr, struct disassemble_info *dinfo)
   nfp_opts opts;
   int err;
 
+  /* Currently only disassemble the text section.  */
+  if (!(dinfo->section->flags & SEC_CODE))
+    {
+      dinfo->fprintf_func (dinfo->stream,
+			   "Disassembly of this section is not supported\t # SKIP");
+      return -1;
+    }
+
   opts.show_pc = 1;
   opts.ctx_mode = 0;
   err = parse_disassembler_options (&opts, dinfo);