From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by sourceware.org (Postfix) with ESMTPS id 5637439A5C11 for ; Sat, 6 Mar 2021 00:40:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5637439A5C11 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1260ZBuo164299 for ; Sat, 6 Mar 2021 00:40:49 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 3726v7hmxu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 06 Mar 2021 00:40:49 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1260Z9dF117206 for ; Sat, 6 Mar 2021 00:40:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by userp3030.oracle.com with ESMTP id 373xutgtaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 06 Mar 2021 00:40:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=COf17algfbrCz9pq1JX4gTSYUP13COf2qvcQaUEEP7NI0TPwc+NPe7jouB5AOYN15nZEHf9ct35wEkEv7o50Zf59uUTzx/m4sReRUmf34LpgcmuB61WO7LnGjR5+h6RI/uYfuiHyBw5bBMqPFOt6ZX7+1oAyYSukzgQlQ/x/lEzivFwY8fbzFvhQylMuH3fY0lZ4O+yyyg+RP6Suu6vUr03Wl1gER3IONQ+zCrfq5EDKAz8jPXTHC+Vb71OOK04IdZYN2lJjE8ExtCyiTqaKycGCwZ0Y5XN/4gat3WflskPaSIFEDffA/qzEWp50SNK+ngvkkU5kHqAgA064GMiiXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CjHC5xun2aXcdffXxBam3NY8KkBjQA29Nd9wHxaj1uM=; b=J6TZektMtRtfKw4W6CLYDKtKYzgkDziQ0FovtG3lLIrDs1jTCJaf76Mxipd5IHLPOoMSnGV/EgA3bGW9epQ+Fm5z3uXEjpzVsnanbDYYm9suITpN1PscF2XVfoi5dwsCFA89p+GapaCvNlGCXTHaHN4AqOTUh24NwOBs1FtMrsf6LQvrv5z5zqfqn8O/pzxvQY62H/aYXu+9ccLxuylMCuTUtX1HHyxjWtNWHycmZr66CUGtwvh6Gnk9PtmzSz6pxS13WoWxvDflG24JlEND5193GN9jHIfmpCqV5CRylDOkP0IHYsaKfKG0qP9oro66idbntC9+5Wzsc3kn/9kg3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from SA2PR10MB4715.namprd10.prod.outlook.com (2603:10b6:806:fb::10) by SN6PR10MB3053.namprd10.prod.outlook.com (2603:10b6:805:d2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Sat, 6 Mar 2021 00:40:47 +0000 Received: from SA2PR10MB4715.namprd10.prod.outlook.com ([fe80::bdcf:f0:1350:5fa2]) by SA2PR10MB4715.namprd10.prod.outlook.com ([fe80::bdcf:f0:1350:5fa2%6]) with mapi id 15.20.3890.035; Sat, 6 Mar 2021 00:40:47 +0000 From: Nick Alcock To: binutils@sourceware.org Subject: [PATCH 16/16] libctf: support encodings for enums Date: Sat, 6 Mar 2021 00:40:23 +0000 Message-Id: <20210306004023.164154-17-nick.alcock@oracle.com> X-Mailer: git-send-email 2.30.0.252.gc27e85e57d In-Reply-To: <20210306004023.164154-1-nick.alcock@oracle.com> References: <20210306004023.164154-1-nick.alcock@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [2001:8b0:1101:10::2] X-ClientProxiedBy: LO2P265CA0470.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::26) To SA2PR10MB4715.namprd10.prod.outlook.com (2603:10b6:806:fb::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from loom.srvr.nix (2001:8b0:1101:10::2) by LO2P265CA0470.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25 via Frontend Transport; Sat, 6 Mar 2021 00:40:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7dcd8d15-77b3-4b5a-f5c2-08d8e0387b84 X-MS-TrafficTypeDiagnostic: SN6PR10MB3053: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sQtiI/55tyZCaXXhc4w5iWmDn0Mg9ule0v+WbYGhABKijyHZJXFaBxylepshlY9VLnXsDs96+Zjk9c1y/uQxfBz3Aa6pqhN8kdshNdI1HsLjP8D/XlqdEJqnRfENA7EmXDn8b0BbqDrTC5Wv989ql8de1uQp8oxeJAgbwcIC3m1FW5i+HuKjQ7Cq96EvF4YfDJS22DXbPvNrwH7oQUsh0zZkCITT21C6TudGYDLs5E1rxTnc2InSeXDHKJz2r5ULlK0K2aLKVNTONb7x55pUzheTSx/ajoeyZSGQzhBd5hDIu1d3mHnlvimSrt8eXZziySPH4OaMozqV8Oyu95ShDEnrrcVRINLsrouJfQojxb0yBEVu0mjzL0JX1NJMGLvcP2PWGJBkDJSwHnoGoN+fsPB8P7543EwZZpHsVkoVGXxk4UkaOLS1P/YGv7GOxYUjAzTJByboZMjWr5zS/8q1qvrSANQPIJb0m1XdLymJdk/4Mc1TdcOy9Jdzrx6tPQZI1O0CP4y9l7tWBkGaZTQtxA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4715.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(346002)(39860400002)(2616005)(16526019)(44832011)(6666004)(6506007)(52116002)(186003)(1076003)(5660300002)(478600001)(316002)(8676002)(66476007)(2906002)(6512007)(66556008)(83380400001)(86362001)(66946007)(6486002)(36756003)(8936002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?c8uSdhwtbzbKj2vujrKC13PONzBBO1AVt7FQYzrDT5F71pKgirHqX8jjfDL1?= =?us-ascii?Q?Ec2rt+OiSQnRHzZI6aR3hoMoX92995aH1lm5XHE0pOlEQBe+A6jWJWUzw0eE?= =?us-ascii?Q?cm25yYdbkk9A81FvdvT4hNytbcWuwCHZLZ+QlQHGRPWDWAMqhxeRBT1aEhWP?= =?us-ascii?Q?tzCQSooqG+JJvTWNFdmMOw2VuoT0Fhp4ykzffdQPvyKu4tPCycxtZj/BJcGY?= =?us-ascii?Q?xbYqJF3a0+ZBDU29k6KL8hO+0EJcfobtsLtjSlTQN3tjpFhK4o9j2WfaNSg4?= =?us-ascii?Q?Zie4Ivs5XQEgk77hRpr/WtgtxaKdVMxJw8oK+1kw898fUdpe4ph1wDw1Slgx?= =?us-ascii?Q?HG/U/UjolLBB3HPSZC/e1hiIjtuPCrt0IUeR95T/Dte2THAAIvPVx2xWwG56?= =?us-ascii?Q?3FeofLzyhK4jQuzGL98UOuOytiQoRaIrxqO4kMBPz0QV+zNHBZJVHV1dRWgm?= =?us-ascii?Q?WSAKS2oNr2/BlxV3SiFobXFYgg50kuuk3ciDSv3MlJAdFlWk9eqKXRE9JByz?= =?us-ascii?Q?b/ncA0/2JvDUqtmO6zz2akW68EcNsajtqj6kan978pw9NEiW1lX7KS3DXyLb?= =?us-ascii?Q?yaZT3mdQuOF6VowpIn4J+7sWshDJoDeIVNK9OtTpJWZdeqfiDAVXzQ9xFOxC?= =?us-ascii?Q?81GaMu7+L23Mhgj70am6XOXZRnw141FMqzTlZydV4eTdkJjtBjmDgqJcHeN5?= =?us-ascii?Q?otNWCkNmpN9AoQjiUBAeOsfI0iTbtEybjIe3BqpHHkaYyDLgIfj6PK5Fdgnt?= =?us-ascii?Q?/4lxLPYUVGR6X0nAweBCGggU36e03MP0az+U18/UKNdVft2yS6ReJjNfs94Q?= =?us-ascii?Q?wMkCm2K3DdsRlzBUydIwXKWV9+1yzyzOBIOCh6ygNnn2XcDgnvM/71l6MAyV?= =?us-ascii?Q?8g7wSsVtnDrqW2NPsVaCjvva3IOhIaP+Qp33yofpSTYq+cazeF0CfD0kQVJC?= =?us-ascii?Q?oLAIUi9/NjEga4uSefNU9EE8NJGw86jkfciCq/W8rpkoX/aLrqpOHxaf/kXt?= =?us-ascii?Q?VMVkTNi7OQVzoCOIqZGUVzyCRL48HZwGT+WqOnpUhozrB2jOtteJDdZ0YRTp?= =?us-ascii?Q?lu9bbOI9yxXE6dIj0XBTyje719FBI0AEyBwOA94YU54S/H1dBKtxX7XswbDh?= =?us-ascii?Q?kmCESXcG3OZRJ/qH1vSz+vGpDTLeSh2MKzHAg2OwiDYP5+IJt+dKaOOSpKlZ?= =?us-ascii?Q?cEg14enyr5LcdfTRqJQBUVTUnpUD7zPNI/U0ogai3q7yUYpeQ0yWeacakMRo?= =?us-ascii?Q?cpqips/Chzz7wSohGsW223JKnuJf4cDDZJrgYkO1dbqNfuR+79dtsi8rfpTB?= =?us-ascii?Q?VusDYWJNo8e3jfbzKNV1vqWY7O60c8VISpFHIZl0crhp5g=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7dcd8d15-77b3-4b5a-f5c2-08d8e0387b84 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4715.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2021 00:40:47.0396 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WXPxscYT+w1ZFipLa3LRnPVa/WapvciZJdFEdaZkv0w+fqg2rFpzXf40xquegFMAPWLRyJAyDIORmWk5vxI43Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB3053 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9914 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103060002 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9914 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 phishscore=0 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103060002 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2021 00:40:52 -0000 The previous commit started to error-check the lookup of ctf_type_encoding for the underlying type that is internally done when carrying out a ctf_type_encoding on a slice. Unfortunately, enums have no encoding, so this has historically been returning an error (which is ignored) and then populating the cte_format with uninitialized data. Now the error is not ignored, this is returning an error, which breaks linking of CTF containing bitfields of enumerated type. CTF format v3 does not record the actual underlying type of a enum, but we can mock up something that is not *too* wrong, and that is at any rate better than uninitialized data. ld/ChangeLog 2021-03-05 Nick Alcock * testsuite/ld-ctf/slice.c: Check slices of enums too. * testsuite/ld-ctf/slice.d: Results adjusted. libctf/ChangeLog 2021-03-05 Nick Alcock * ctf-types.c (ctf_type_encoding): Support, after a fashion, for enums. * ctf-dump.c (ctf_dump_format_type): Do not report enums' degenerate encoding. --- ld/testsuite/ld-ctf/slice.c | 3 +++ ld/testsuite/ld-ctf/slice.d | 4 ++-- libctf/ctf-dump.c | 5 ++++- libctf/ctf-types.c | 8 +++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ld/testsuite/ld-ctf/slice.c b/ld/testsuite/ld-ctf/slice.c index 7937bcf796e..fb38852142e 100644 --- a/ld/testsuite/ld-ctf/slice.c +++ b/ld/testsuite/ld-ctf/slice.c @@ -1,6 +1,9 @@ +enum foo { FOO_BAR }; + struct slices { int one : 1; int two : 2; int six : 6; int ten :10; + enum foo bar:1; } slices; diff --git a/ld/testsuite/ld-ctf/slice.d b/ld/testsuite/ld-ctf/slice.d index d1167828f47..72a7074f9ef 100644 --- a/ld/testsuite/ld-ctf/slice.d +++ b/ld/testsuite/ld-ctf/slice.d @@ -15,7 +15,7 @@ Contents of CTF section .ctf: Compilation unit name: .*slice.c #... Data object section: .* \(0x4 bytes\) - Type section: .* \(0x9c bytes\) + Type section: .* \(0xd0 bytes\) String section: .* #... Data objects: @@ -28,5 +28,5 @@ Contents of CTF section .ctf: *\[0x1\] two: ID 0x[0-9a-f]*: \(kind 1\) int:2 \[slice 0x1:0x2\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\) *\[0x3\] six: ID 0x[0-9a-f]*: \(kind 1\) int:6 \[slice 0x3:0x6\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\) *\[0x9\] ten: ID 0x[0-9a-f]*: \(kind 1\) int:10 \[slice 0x9:0xa\] \(format 0x1\) \(size 0x2\) \(aligned at 0x2\) - + *\[0x13\] bar: ID 0x[0-9a-f]*: \(kind 8\) enum foo:1 \[slice 0x13:0x1\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\) #... diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index 409626a224b..8540212eadd 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -142,7 +142,10 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag) unsliced_kind = ctf_type_kind_unsliced (fp, id); kind = ctf_type_kind (fp, id); - if (ctf_type_encoding (fp, id, &ep) == 0) + /* Report encodings of everything with an encoding other than enums: + base-type enums cannot have a nonzero cte_offset or cte_bits value. + (Slices of them can, but they are of kind CTF_K_SLICE.) */ + if (unsliced_kind != CTF_K_ENUM && ctf_type_encoding (fp, id, &ep) == 0) { if ((ssize_t) ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT && flag & CTF_FT_BITFIELD) diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index ed76eca8463..9afe06ba112 100644 --- a/libctf/ctf-types.c +++ b/libctf/ctf-types.c @@ -1157,7 +1157,7 @@ ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type) return (ctf_set_errno (ofp, ECTF_NOTYPE)); } -/* Return the encoding for the specified INTEGER or FLOAT. */ +/* Return the encoding for the specified INTEGER, FLOAT, or ENUM. */ int ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep) @@ -1194,6 +1194,12 @@ ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep) ep->cte_offset = CTF_FP_OFFSET (data); ep->cte_bits = CTF_FP_BITS (data); break; + case CTF_K_ENUM: + /* v3 only: we must guess at the underlying integral format. */ + ep->cte_format = CTF_INT_SIGNED; + ep->cte_offset = 0; + ep->cte_bits = 0; + break; case CTF_K_SLICE: { const ctf_slice_t *slice; -- 2.30.0.252.gc27e85e57d