public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Belyashov <sergey.belyashov@gmail.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: "Jose E. Marchesi" <jose.marchesi@oracle.com>,
	 "Frank Ch. Eigler via Cgen" <cgen@sourceware.org>
Subject: Re: BUG: non-fixed-length ISAs are unsupported for now
Date: Thu, 13 Aug 2020 16:34:33 +0300	[thread overview]
Message-ID: <CAOe0RDy0rdTxQjw-6xwE6gj3SeDf8biyonuOW-6OQTJwz1zE5w@mail.gmail.com> (raw)
In-Reply-To: <20200812195701.GD27698@redhat.com>

Hi,

> Simply, make no change other than setting the base-insn large enough
> to contain all the opcode fields.  Amongst all these cases, that seems
> to be 16 or perhaps 24 bits.  I suggest trying 32.

When I increase base-insn-bitsize to 32 of ISA definition objdump
fails with: stack smashing error. Valgrind shows next backtrace:
00000000 <.text>:
*** stack smashing detected ***: terminated
==325050==
==325050== Process terminating with default action of signal 6 (SIGABRT)
==325050==    at 0x48B718B: raise (raise.c:51)
==325050==    by 0x4896858: abort (abort.c:79)
==325050==    by 0x49013ED: __libc_message (libc_fatal.c:155)
==325050==    by 0x49A39B9: __fortify_fail (fortify_fail.c:26)
==325050==    by 0x49A3985: __stack_chk_fail (stack_chk_fail.c:24)
==325050==    by 0x17BE43: default_print_insn (z80-dis.c:448)
==325050==    by 0x17C0AA: print_insn_z80 (z80-dis.c:567)
==325050==    by 0x131CB3: disassemble_bytes (objdump.c:2768)
==325050==    by 0x13360E: disassemble_section (objdump.c:3340)
==325050==    by 0x1A9E99: bfd_map_over_sections (section.c:1377)
==325050==    by 0x133C2E: disassemble_data (objdump.c:3484)
==325050==    by 0x137079: dump_bfd (objdump.c:4866)

But in C file RETI/RETN instructions are implemented as:
/* retn */
  {
    { 0, 0, 0, 0 },
    { { MNEM, 0 } },
    & ifmt_retn, { 0x132 } //why?!?
  },
/* reti */
  {
    { 0, 0, 0, 0 },
    { { MNEM, 0 } },
    & ifmt_retn, { 0x13a } //why?!?
  },

Definition of these instructions:

(dnf f-0 "whole byte 0" ((MACH z80) all-isas) 7 8)
(dnf f-1  "whole byte 1" ((MACH z80) all-isas) 15 8)

(dni retn       "return from NMI handler" (all-isas UNCOND-CTI) "retn"
(+ (f-0 #xED) (f-1 #x45)) () ())
(dni reti       "return from INT handler" (all-isas UNCOND-CTI) "reti"
(+ (f-0 #xED) (f-1 #x4D)) () ())

default-insn-bitsize in ISA definition is kept 8. If I set it 32 too,
then implementation of instructions looks correct, but stack smashing
exists too.

Best regards,
Sergey Belyashov

  reply	other threads:[~2020-08-13 13:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 13:37 Sergey Belyashov
2020-04-27 16:29 ` Frank Ch. Eigler
2020-04-27 17:00   ` Sergey Belyashov
2020-04-27 17:52     ` Sergey Belyashov
2020-04-27 18:03     ` Jose E. Marchesi
2020-04-27 19:34       ` Sergey Belyashov
2020-04-27 20:01         ` Jose E. Marchesi
2020-04-27 20:23           ` Sergey Belyashov
2020-04-29 19:11           ` Sergey Belyashov
2020-07-30  9:11             ` Sergey Belyashov
2020-08-11 15:38               ` Frank Ch. Eigler
2020-08-11 15:57                 ` Sergey Belyashov
2020-08-11 16:08                   ` Frank Ch. Eigler
2020-08-12 13:59                     ` Sergey Belyashov
2020-08-12 18:36                       ` Frank Ch. Eigler
2020-08-12 18:53                         ` Jose E. Marchesi
2020-08-12 19:19                           ` Sergey Belyashov
2020-08-12 19:21                             ` Frank Ch. Eigler
2020-08-12 19:27                               ` Jose E. Marchesi
2020-08-12 19:44                                 ` Sergey Belyashov
2020-08-12 19:57                                   ` Frank Ch. Eigler
2020-08-13 13:34                                     ` Sergey Belyashov [this message]
2020-08-13 14:32                                       ` Frank Ch. Eigler
2020-08-13 14:47                                         ` Sergey Belyashov

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=CAOe0RDy0rdTxQjw-6xwE6gj3SeDf8biyonuOW-6OQTJwz1zE5w@mail.gmail.com \
    --to=sergey.belyashov@gmail.com \
    --cc=cgen@sourceware.org \
    --cc=fche@redhat.com \
    --cc=jose.marchesi@oracle.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).