From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D1B1D3858D28 for ; Fri, 6 Jan 2023 16:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1B1D3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673023238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m7wDCJldfDdeU8Ysai0FDVlDXC8zQiHVodkFRo0Y6iQ=; b=b+Hrv/qXNFjUU6k8jPndXzuoRwu8fA2hnSxtfvoTB07himIzVC1sJYxGZ6FPkfJQCglzi8 SFCZYx2pfuxDm1Jd3jVR69uKmYStw7IK6bEYl90nYz9SGCo7tCdbN8K0v0t8rBhy43geou zHK9zzbF9BWNl8vRls7JjLNmPkS/3ps= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-358-6xllZnQ3NsGluIWra2ORFA-1; Fri, 06 Jan 2023 11:40:37 -0500 X-MC-Unique: 6xllZnQ3NsGluIWra2ORFA-1 Received: by mail-qv1-f70.google.com with SMTP id o95-20020a0c9068000000b005320eb4e959so981090qvo.16 for ; Fri, 06 Jan 2023 08:40:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m7wDCJldfDdeU8Ysai0FDVlDXC8zQiHVodkFRo0Y6iQ=; b=LUOK5mDV2ubZD4DNfJ21Tcr+F5pT8264t1esNJuotKVBZWfZ4v8os79MaPNf17mzWe /WHLb4pJ+Es6eCP85N9iypkKKaao/rVEQU6XkjwRQ9tzOuP1eSEZLl9eqhoFxPqdSbNd 9F7oQJxAnFQx4w0EBXm1jJLGn/WUOy9gjK4daa28TVz4cZAoiWyWSNzmD09NCn1iFTgz ixn773oDy2rDu0PbWlwiyfZWA9WtDVF7BKkL2g/cv1S0fcPWHrs2IkDTY4pDkK+m8WMp oSCTYOokr+O5eVfLxVfVPmH7kdFVepPLeUeKQhoSeXMuwcAJ19DHUL3JBYuyl7FJn6uZ SukQ== X-Gm-Message-State: AFqh2kpHJV47F1nbfO9nA/GzC1Tz1B8wgS5XZNc4ZDmcVRpfkWnSzBYo jXZNVCYO0ursnFASe3HyRIzRYXdqU6jINDH4FYKnRIJjbbRXrVYTGkIyP9ZZGctjp4eAUtpfAMR mb5KwD6KPXbZlkf4Gwg== X-Received: by 2002:ac8:46d4:0:b0:3a8:1178:5652 with SMTP id h20-20020ac846d4000000b003a811785652mr72214128qto.58.1673023235451; Fri, 06 Jan 2023 08:40:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsrVVRb73ixxU5TPaU7q7amnvo3aPE8PmJgpoZIG11QkexyqGU59WlpD8P0Ygo0H9H073rwMA== X-Received: by 2002:ac8:46d4:0:b0:3a8:1178:5652 with SMTP id h20-20020ac846d4000000b003a811785652mr72214113qto.58.1673023235187; Fri, 06 Jan 2023 08:40:35 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id fx11-20020a05622a4acb00b003a6934255dasm714128qtb.46.2023.01.06.08.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 08:40:34 -0800 (PST) From: Andrew Burgess To: "Maciej W. Rozycki" Cc: binutils@sourceware.org Subject: Re: [PATCH 1/2] opcodes/mips: use .word/.short for undefined instructions In-Reply-To: References: Date: Fri, 06 Jan 2023 16:40:32 +0000 Message-ID: <87fscny5tr.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: "Maciej W. Rozycki" writes: > Hi Andrew, > > In the course of reviewing outstanding upstream mailing list traffic I > came across this change of yours. > > On Thu, 3 Nov 2022, Andrew Burgess via Binutils wrote: > >> diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c >> index faeebccfc3b..1d9875f2bb0 100644 >> --- a/opcodes/mips-dis.c >> +++ b/opcodes/mips-dis.c >> @@ -2515,7 +2515,10 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) >> } >> } >> >> - infprintf (is, "0x%x", insn); >> + if (length == 2) >> + infprintf (is, ".short\t0x%x", insn); >> + else >> + infprintf (is, ".word\t0x%x", insn); > > FYI, I find this questionable as `.word' (at least with the MIPS target) > implies natural alignment while 32-bit microMIPS encodings, valid or not, > are not. Also, given the endianness peculiarity (analogous to the MIPS16 > extended encodings), I think this needs to be ".short\t0x%x, 0x%x" really, > with the instruction word split into halfwords for any reasonable meaning. > This is already reflected in the raw hex dump of instruction streams; the > numbers printed need to match it. > > With the naked number previously used this obviously didn't matter as it > stood out without any attempt to pretend to have a meaning. This is also > the reason why I chose to keep it as it used to be since forever. Hi, Below is an initial patch. When I set the environment variable DISABLE_MATCHING then the disassembler fails to match all instructions, so prints .short for everything. Right now I can't find anything where this doesn't work, but I don't believe that the answer is actually this simple. Given your deeper knowledge of the target, could you take a look at what I have below and point me at some tests/configurations/whatever where this isn't going to be good enough? Alternatively, if this is enough, then I'll write this up into a proper patch. Thanks, Andrew --- diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c index 6a513cd8946..5c6ec9a1147 100644 --- a/opcodes/mips-dis.c +++ b/opcodes/mips-dis.c @@ -2554,6 +2554,9 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) opend = micromips_opcodes + bfd_micromips_num_opcodes; for (op = micromips_opcodes; op < opend; op++) { + if (getenv ("DISABLE_MATCHING") != NULL) + break; + if (op->pinfo != INSN_MACRO && !(no_aliases && (op->pinfo2 & INSN2_ALIAS)) && (insn & op->mask) == op->match @@ -2601,11 +2604,19 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) } if (length == 2) - infprintf (is, dis_style_assembler_directive, ".short"); + { + infprintf (is, dis_style_assembler_directive, ".short"); + infprintf (is, dis_style_text, "\t"); + infprintf (is, dis_style_immediate, "0x%x", insn); + } else - infprintf (is, dis_style_assembler_directive, ".word"); - infprintf (is, dis_style_text, "\t"); - infprintf (is, dis_style_immediate, "0x%x", insn); + { + infprintf (is, dis_style_assembler_directive, ".short"); + infprintf (is, dis_style_text, "\t"); + infprintf (is, dis_style_immediate, "0x%x", (insn >> 16) & 0xffff); + infprintf (is, dis_style_text, ", "); + infprintf (is, dis_style_immediate, "0x%x", (insn & 0xffff)); + } info->insn_type = dis_noninsn; return length;