From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id DE5543861893 for ; Thu, 13 Aug 2020 13:34:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DE5543861893 Received: by mail-qt1-x832.google.com with SMTP id s23so4283260qtq.12 for ; Thu, 13 Aug 2020 06:34:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=afzwZAh9ARThVjZImXrczeHGbz1ItELG0TtuY8xajbM=; b=JVAw/o8ARqWvxFKrFJN+jyn+DXzF1U/dOl7jh6M3ye0UW9R0SFZfCrBkfe56K86j+B /NLKBlkcHwYdWmrm6UAMi7wLGydZroZt5neZ/AVAU3YHRtxoZC7wR0jqIqYbidSRPS1/ yT6GLcklRY+5fBMVYdT9+FnciBk4dCjCZbtHsNXbR8H+hYKDYWJDXpscQmQOtS2zPwMK oxkM4OYOdiWBMHYVQQdfFyP3s9TcjXchuvfKB7AdIq02luyVZSgGHiA8RNS1P0IpFZRS QiBkWR9ADoH8QOFujTS4HN+3RN6by/Ta+e9nujfo8RZCn9/sJ1iQ+9KbAZyBf+MGzjK5 ytdw== X-Gm-Message-State: AOAM532lnvinJCZaCMNgCNUfekCalU+GHiNVNfqQz5iCzDgh9Zt/34Bi GJPtZN9s3sO10PEoglwZR1vfwskDg0aKyiYG9gfQQgVV2J4QwQ== X-Google-Smtp-Source: ABdhPJxwbjQ3hMk1DxtCDG/sZLmw0WZNAF35sRsuAD14YSIRtulUrb6Uk0VaIvqSceQBLfL+IE5+NauE6vVBYKX2Y00= X-Received: by 2002:aed:3587:: with SMTP id c7mr5447740qte.136.1597325685497; Thu, 13 Aug 2020 06:34:45 -0700 (PDT) MIME-Version: 1.0 References: <20200811153823.GA20457@redhat.com> <20200811160847.GB20457@redhat.com> <20200812183611.GA27698@redhat.com> <87pn7v1yrt.fsf@oracle.com> <20200812192115.GB27698@redhat.com> <87eeob1x7n.fsf@oracle.com> <20200812195701.GD27698@redhat.com> In-Reply-To: <20200812195701.GD27698@redhat.com> From: Sergey Belyashov Date: Thu, 13 Aug 2020 16:34:33 +0300 Message-ID: Subject: Re: BUG: non-fixed-length ISAs are unsupported for now To: "Frank Ch. Eigler" Cc: "Jose E. Marchesi" , "Frank Ch. Eigler via Cgen" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cgen@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cgen mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2020 13:34:47 -0000 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