opcodes/nfp: skip those non-code sections

Message ID 1629810843-20448-1-git-send-email-yinjun.zhang@corigine.com
State Superseded
Headers show
Series
  • opcodes/nfp: skip those non-code sections
Related show

Commit Message

Yinjun Zhang Aug. 24, 2021, 1:14 p.m.
AddressSanitizer detects heap-buffer-overflow when running
"objdump -D" for nfp .nffw files.

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

Comments

Cooper Qu via Binutils Aug. 25, 2021, 12:39 a.m. | #1
On Tue, Aug 24, 2021 at 09:14:03AM -0400, Yinjun Zhang wrote:
> AddressSanitizer detects heap-buffer-overflow when running

> "objdump -D" for nfp .nffw files.

> 

> 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.


This patch does not fix the real problem in pr27854.  A small binary
edit to the testcase in that PR (change byte 0x150 from 0x03 to 0x07)
will result in objdump -d giving the same out of bounds access to
mecfgs[].

Not OK.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/opcodes/nfp-dis.c b/opcodes/nfp-dis.c
index b74ccb3fce5..6202b12e8fd 100644
--- a/opcodes/nfp-dis.c
+++ b/opcodes/nfp-dis.c
@@ -2950,6 +2950,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);