From patchwork Sat Mar 20 16:26:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 1456148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DcVaRdHB; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F2mQY6W9Fz9sSC for ; Sun, 21 Mar 2021 03:28:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA594386F81A; Sat, 20 Mar 2021 16:27:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id BEA783857023 for ; Sat, 20 Mar 2021 16:27:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BEA783857023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=harmstone.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark.harmstone@gmail.com Received: by mail-wm1-x332.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso6859410wmi.0 for ; Sat, 20 Mar 2021 09:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U3XsS38IpC6dmn894o/7s/EKKbpBhm0wTDDPQJ/c2d8=; b=DcVaRdHBH6TThvPH10B8xzaNDmKRQTvQdG6uxj1jPhkSB+UPSTGemwcGgRtJqIyB4l vDGfWG6KaqvjOPw1aOz/KbWmnuspf94wdltO8RwSCX+wyXDYUlXguKto57rjEosv95Pv pgImZMN8Of9WhqDH2uTUVeAnHQpggvwkh7hqrC871ViAgVq9JJP2PmdJDrOaZHlM6/6S CIzdLROIfiKhEF4g9N0wV6s1jCHsmpSIQ5jK3OPKi+1ptXNdzlMjlG66m68WxqS+j3WA cxUbg09cRFnSG7oPQjDDilub10w+G/RyMnvnRk618YmYShVvxDiLmc8OsT8/fs35cKI1 mjSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=U3XsS38IpC6dmn894o/7s/EKKbpBhm0wTDDPQJ/c2d8=; b=bCoRbrRfBO95yxTsR6umDNJcfDdUDEHpXyiRXqsGwUsovgJaqgT3jPb2oBsXHe4FXu H5N0UkzAzMOzId96BeEGUZxDaRK/W8E8Zp38S3XdtjKi135/SRY8PiNTlSaH7+G1Ws8E I43XvAnbS54PsUhZQrbeS57r94eQnTZePPQFLgGtkHNRgoGeob4fRHFBEC6Pu013dxRC wCyND03V4NzJPGUoIvFaafIkbZyw+3exqAWiCwyttjVoYvO/9rVqdfP+D5Rwm0Xck5aB 7ZID4wEuPx7OfB5gB1nAjYTjX3bjyadZq2EAOsnUqDD314nV/YoGYbvr7Vplf69rCgCa AppA== X-Gm-Message-State: AOAM533yQVq6pow3HEYcpaSfO2TnV2Bmc27AHng+5GqAtEYfGzfjsAIs Gifp68wQLl6LKOeUqyRmTx1sdVS528Q= X-Google-Smtp-Source: ABdhPJxbFaq/HbS0RaObQxiTO7IFWuy1aKnooovb7NxCHOxbcrR73qzeK0XcWqDmmx4JYgV3QJB07w== X-Received: by 2002:a7b:cb99:: with SMTP id m25mr8712346wmi.64.1616257631607; Sat, 20 Mar 2021 09:27:11 -0700 (PDT) Received: from localhost.localdomain ([2a02:8010:64ea:0:fad1:11ff:fead:57db]) by smtp.gmail.com with ESMTPSA id v18sm14200785wrf.41.2021.03.20.09.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 09:27:11 -0700 (PDT) From: Mark Harmstone To: gcc-patches@gcc.gnu.org Subject: [PATCH 15/24] pdbout: Output definitions of unions. Date: Sat, 20 Mar 2021 16:26:43 +0000 Message-Id: <20210320162652.23346-15-mark@harmstone.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210320162652.23346-1-mark@harmstone.com> References: <20210320162652.23346-1-mark@harmstone.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Harmstone Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" --- gcc/pdbout.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++----- gcc/pdbout.h | 1 + 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 3bfec519877..7d493513e06 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -829,6 +829,7 @@ free_type (struct pdb_type *t) case LF_CLASS: case LF_STRUCTURE: + case LF_UNION: { struct pdb_struct *str = (struct pdb_struct *) t->data; @@ -1097,6 +1098,44 @@ write_struct (uint16_t type, struct pdb_struct *str) } } +/* Output a lfUnion structure. */ +static void +write_union (struct pdb_struct *str) +{ + size_t name_len = str->name ? strlen (str->name) : (sizeof (unnamed) - 1); + unsigned int len = 15 + name_len, align; + + if (len % 4 != 0) + len += 4 - (len % 4); + + fprintf (asm_out_file, "\t.short\t0x%x\n", len - 2); + fprintf (asm_out_file, "\t.short\t0x%x\n", LF_UNION); + fprintf (asm_out_file, "\t.short\t0x%x\n", str->count); + fprintf (asm_out_file, "\t.short\t0x%x\n", str->property.value); + fprintf (asm_out_file, "\t.short\t0x%x\n", + str->field_type ? str->field_type->id : 0); + fprintf (asm_out_file, "\t.short\t0\n"); + fprintf (asm_out_file, "\t.short\t0x%x\n", str->size); + + if (str->name) + ASM_OUTPUT_ASCII (asm_out_file, str->name, name_len + 1); + else + ASM_OUTPUT_ASCII (asm_out_file, unnamed, sizeof (unnamed)); + + align = 4 - ((3 + name_len) % 4); + + if (align != 4) + { + if (align == 3) + fprintf (asm_out_file, "\t.byte\t0xf3\n"); + + if (align >= 2) + fprintf (asm_out_file, "\t.byte\t0xf2\n"); + + fprintf (asm_out_file, "\t.byte\t0xf1\n"); + } +} + /* Output a lfEnum structure. */ static void write_enum (struct pdb_enum *en) @@ -1288,6 +1327,10 @@ write_type (struct pdb_type *t) write_struct (t->cv_type, (struct pdb_struct *) t->data); break; + case LF_UNION: + write_union ((struct pdb_struct *) t->data); + break; + case LF_ENUM: write_enum ((struct pdb_enum *) t->data); break; @@ -1679,10 +1722,10 @@ struct_hasher::equal (const value_type type, compare_type name) return !strcmp (str->name, name); } -/* For a given struct or class, allocate a new pdb_type and +/* For a given struct, class, or union, allocate a new pdb_type and * add it to the type list. */ static struct pdb_type * -find_type_struct (tree t) +find_type_struct (tree t, bool is_union) { tree f; struct pdb_type *fltype = NULL, *strtype, *fwddef = NULL, @@ -1729,7 +1772,8 @@ find_type_struct (tree t) if (type && (type->cv_type == LF_CLASS - || type->cv_type == LF_STRUCTURE)) + || type->cv_type == LF_STRUCTURE + || type->cv_type == LF_UNION)) { struct pdb_struct *str2 = (struct pdb_struct *) type->data; @@ -1811,7 +1855,8 @@ find_type_struct (tree t) if (type && (type->cv_type == LF_CLASS - || type->cv_type == LF_STRUCTURE)) + || type->cv_type == LF_STRUCTURE + || type->cv_type == LF_UNION)) { struct pdb_struct *str2 = (struct pdb_struct *) type->data; @@ -1880,7 +1925,9 @@ find_type_struct (tree t) (struct pdb_type *) xmalloc (offsetof (struct pdb_type, data) + sizeof (struct pdb_struct)); - if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t)) + if (is_union) + strtype->cv_type = LF_UNION; + else if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t)) strtype->cv_type = LF_CLASS; else strtype->cv_type = LF_STRUCTURE; @@ -2744,7 +2791,10 @@ find_type (tree t) return find_type_array (t); case RECORD_TYPE: - return find_type_struct (t); + return find_type_struct (t, false); + + case UNION_TYPE: + return find_type_struct (t, true); case ENUMERAL_TYPE: return find_type_enum (t); diff --git a/gcc/pdbout.h b/gcc/pdbout.h index 96288d235ea..09b3914d650 100644 --- a/gcc/pdbout.h +++ b/gcc/pdbout.h @@ -41,6 +41,7 @@ #define LF_ARRAY 0x1503 #define LF_CLASS 0x1504 #define LF_STRUCTURE 0x1505 +#define LF_UNION 0x1506 #define LF_ENUM 0x1507 #define LF_MEMBER 0x150d #define LF_CHAR 0x8000