From patchwork Mon Mar 27 11:33:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 75355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1437649vqo; Mon, 27 Mar 2023 04:33:50 -0700 (PDT) X-Google-Smtp-Source: AK7set8DFjLru4S0Lr2C5QcGZmmTs0ya5mjFLYix0tg/qvNcO+sXexGzVUwYkbsE8S3F0JBRev9G X-Received: by 2002:a17:906:3710:b0:923:812c:a5d3 with SMTP id d16-20020a170906371000b00923812ca5d3mr17332787ejc.25.1679916830420; Mon, 27 Mar 2023 04:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679916830; cv=none; d=google.com; s=arc-20160816; b=gLPad6gJd3zf5HU2uIRs5xN7276oe1jMtIQCiiW1r+zrab++y2Ru0ZjlQJi6Mt2OAg agzqNqDlgMyduE2oG3ffhsvuwUPEE4RLxhPfJyPqCV4Iw7oET0GH79FaRX8Kn7b8XbVJ dvI+IlfPvZ+djcm49rh0h+Wgyy1KAlhEdTdy0C9Dx1y3l3MHY0ULYTBUkukLKl5R8W45 zrjGIvkafYTH/qGuV0zBqwcaKYazcJ5q9mnLH0AsdjGY7FtFQHRKWxAqMa4Qw1H+JSSu CB7hWXYrcpnlcNvAFTSBzCRZ64FbYRJRtTWV46T/eP0dI2y0m/fEqPZ6mkbztLwCJkId EI2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=qmKHSvyOLc0zyO4EA3WWKEAnmAz+29/xGWGxq8wgAL0=; b=QtwhokygJnDdfb/LspYolhz+8bETgoqv0ySwGfU7m4CgR6UB2dEfPn4KvcvJTRVb36 o+O0LKuPc1Gdq8HoEPaMQ+AqqTHVKpLhLm3t45fHrD1gfBJLCkvFjWzP5CU9Y6nAPPhm ro42H913BwhTaxYMdtCBIpU8Mz3I5aWjC6IS/kpHZR79UNsSIqvpwa0dpeqm6Vv8vqut uN8YUjGTiSEvxl/ePEmZYUlPzfMiEBxjQhfJDqFD8M4RE2s/sbGysErQP80tgSA6ZSDe EsiFP6PCLbZ/lUjJruBFtvVRjWChNRobhloGWkiZ/fN2fK2NJ4BQBcYxqsPdC9d8S0mO 1L6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WUxnfqdq; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l12-20020a056402124c00b004ad02c77d40si28655217edw.29.2023.03.27.04.33.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 04:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WUxnfqdq; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3EA63857BB3 for ; Mon, 27 Mar 2023 11:33:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3EA63857BB3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679916822; bh=qmKHSvyOLc0zyO4EA3WWKEAnmAz+29/xGWGxq8wgAL0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WUxnfqdqHnjIzqC1HAtZ/fq+I0k+t7n0NLkl2j8Z4/fRL3baeYVve/jtskfc5yKnZ 0cslmOVpK6CTHFHVOV5FIXkTQaGwJn7Nlkq+QGLWN2tLlRqrRXPStj+LrTf4CXyd+3 BMurOuCL88Kn08LDF0WKQHCpP/84w05U98wfY1d8= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 84F49385B50B for ; Mon, 27 Mar 2023 11:33:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84F49385B50B Received: by mail-pl1-x62e.google.com with SMTP id ix20so8135343plb.3 for ; Mon, 27 Mar 2023 04:33:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679916811; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qmKHSvyOLc0zyO4EA3WWKEAnmAz+29/xGWGxq8wgAL0=; b=tZ72TTnhbQlzxzBeJBEtHxiwDBs2Mscr3jWFYAGBgGrWAtDi7vHBdcTbcoVUW2TiLo mZZS4dU2muT/f03l8n3Hibq3dvtDbIFiY1l2XYwwEQmRxZZSZkgSvnpH+9j3UBzgvwv9 kPxCqeII0OHzx3EaNL+UoB04e4QgTTrY5dpt2L4YpQo5JzTFFHb7cGdN9rQJmJIqbBJz HZE7o4FMGeBHAhPIBrDt6V/zvUdhbyAb8G4MYNZKddnsoHdIht90KmhkrSzSe90TZD2V Ii0Qgq1BWij0ZlxegXsbazsZu34FllnnInNK3hnRU+Y3htxCT6sIFMT8LCg6lsMktwtZ sgEA== X-Gm-Message-State: AAQBX9cuDA56MxQ2j60b860bGQc2HDKM8fdbIYoxU1yBc6Dg7M6WQ34H VRnZfa9sUXRdx3Zk/ffbis5a83cL2Jo= X-Received: by 2002:a17:90b:1811:b0:237:b64c:6bb3 with SMTP id lw17-20020a17090b181100b00237b64c6bb3mr13037230pjb.11.1679916811305; Mon, 27 Mar 2023 04:33:31 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id 13-20020a63134d000000b004fb171df68fsm17667648pgt.7.2023.03.27.04.33.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 04:33:31 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C057B114276F; Mon, 27 Mar 2023 22:03:28 +1030 (ACDT) Date: Mon, 27 Mar 2023 22:03:28 +1030 To: binutils@sourceware.org Subject: Tidy tc-ppc.c XCOFF auxent access Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761520470653916029?= X-GMAIL-MSGID: =?utf-8?q?1761520470653916029?= It's better not to drill down into u.auxent but instead use a pointer to the combined_entry_type. That way the fix_scnlen field is available, and no one looking at the codes needs to wonder whether coffsymbol (symbol_get_bfdsym (sym))->native[i + 1] is the same auxent. * config/tc-ppc.c (ppc_frob_symbol): Tidy XCOFF auxent access. (ppc_adjust_symtab): Likewise. diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index d25c751378d..ae14fae44bd 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -6154,11 +6154,11 @@ ppc_frob_symbol (symbolS *sym) { /* Size of containing csect. */ symbolS* within = symbol_get_tc (sym)->within; - union internal_auxent *csectaux; - csectaux = &coffsymbol (symbol_get_bfdsym (within)) - ->native[S_GET_NUMBER_AUXILIARY(within)].u.auxent; + coff_symbol_type *csect = coffsymbol (symbol_get_bfdsym (within)); + combined_entry_type *csectaux + = &csect->native[S_GET_NUMBER_AUXILIARY(within)]; - SA_SET_SYM_FSIZE (sym, csectaux->x_csect.x_scnlen.u64); + SA_SET_SYM_FSIZE (sym, csectaux->u.auxent.x_csect.x_scnlen.u64); } } else if (S_GET_STORAGE_CLASS (sym) == C_FCN @@ -6194,44 +6194,47 @@ ppc_frob_symbol (symbolS *sym) || S_GET_STORAGE_CLASS (sym) == C_HIDEXT) { int i; - union internal_auxent *a; + combined_entry_type *a; /* Create a csect aux. */ i = S_GET_NUMBER_AUXILIARY (sym); S_SET_NUMBER_AUXILIARY (sym, i + 1); - a = &coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].u.auxent; + a = &coffsymbol (symbol_get_bfdsym (sym))->native[i + 1]; if (symbol_get_tc (sym)->symbol_class == XMC_TC0) { /* This is the TOC table. */ know (strcmp (S_GET_NAME (sym), "TOC") == 0); - a->x_csect.x_scnlen.u64 = 0; - a->x_csect.x_smtyp = (2 << 3) | XTY_SD; + a->u.auxent.x_csect.x_scnlen.u64 = 0; + a->u.auxent.x_csect.x_smtyp = (2 << 3) | XTY_SD; } else if (symbol_get_tc (sym)->subseg != 0) { /* This is a csect symbol. x_scnlen is the size of the csect. */ if (symbol_get_tc (sym)->next == (symbolS *) NULL) - a->x_csect.x_scnlen.u64 + a->u.auxent.x_csect.x_scnlen.u64 = bfd_section_size (S_GET_SEGMENT (sym)) - S_GET_VALUE (sym); else { resolve_symbol_value (symbol_get_tc (sym)->next); - a->x_csect.x_scnlen.u64 + a->u.auxent.x_csect.x_scnlen.u64 = S_GET_VALUE (symbol_get_tc (sym)->next) - S_GET_VALUE (sym); } if (symbol_get_tc (sym)->symbol_class == XMC_BS || symbol_get_tc (sym)->symbol_class == XMC_UL) - a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_CM; + a->u.auxent.x_csect.x_smtyp + = (symbol_get_tc (sym)->align << 3) | XTY_CM; else - a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_SD; + a->u.auxent.x_csect.x_smtyp + = (symbol_get_tc (sym)->align << 3) | XTY_SD; } else if (S_GET_SEGMENT (sym) == bss_section || S_GET_SEGMENT (sym) == ppc_xcoff_tbss_section.segment) { /* This is a common symbol. */ - a->x_csect.x_scnlen.u64 = symbol_get_frag (sym)->fr_offset; - a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_CM; + a->u.auxent.x_csect.x_scnlen.u64 = symbol_get_frag (sym)->fr_offset; + a->u.auxent.x_csect.x_smtyp + = (symbol_get_tc (sym)->align << 3) | XTY_CM; if (S_GET_SEGMENT (sym) == ppc_xcoff_tbss_section.segment) symbol_get_tc (sym)->symbol_class = XMC_UL; else if (S_IS_EXTERNAL (sym)) @@ -6244,15 +6247,15 @@ ppc_frob_symbol (symbolS *sym) /* This is an absolute symbol. The csect will be created by ppc_adjust_symtab. */ ppc_saw_abs = true; - a->x_csect.x_smtyp = XTY_LD; + a->u.auxent.x_csect.x_smtyp = XTY_LD; if (symbol_get_tc (sym)->symbol_class == -1) symbol_get_tc (sym)->symbol_class = XMC_XO; } else if (! S_IS_DEFINED (sym)) { /* This is an external symbol. */ - a->x_csect.x_scnlen.u64 = 0; - a->x_csect.x_smtyp = XTY_ER; + a->u.auxent.x_csect.x_scnlen.u64 = 0; + a->u.auxent.x_csect.x_smtyp = XTY_ER; } else if (ppc_is_toc_sym (sym)) { @@ -6267,19 +6270,19 @@ ppc_frob_symbol (symbolS *sym) || (!ppc_is_toc_sym (next))) { if (ppc_after_toc_frag == (fragS *) NULL) - a->x_csect.x_scnlen.u64 + a->u.auxent.x_csect.x_scnlen.u64 = bfd_section_size (data_section) - S_GET_VALUE (sym); else - a->x_csect.x_scnlen.u64 + a->u.auxent.x_csect.x_scnlen.u64 = ppc_after_toc_frag->fr_address - S_GET_VALUE (sym); } else { resolve_symbol_value (next); - a->x_csect.x_scnlen.u64 + a->u.auxent.x_csect.x_scnlen.u64 = S_GET_VALUE (next) - S_GET_VALUE (sym); } - a->x_csect.x_smtyp = (2 << 3) | XTY_SD; + a->u.auxent.x_csect.x_smtyp = (2 << 3) | XTY_SD; } else { @@ -6302,7 +6305,7 @@ ppc_frob_symbol (symbolS *sym) if (csect == (symbolS *) NULL) { as_warn (_("warning: symbol %s has no csect"), S_GET_NAME (sym)); - a->x_csect.x_scnlen.u64 = 0; + a->u.auxent.x_csect.x_scnlen.u64 = 0; } else { @@ -6315,22 +6318,21 @@ ppc_frob_symbol (symbolS *sym) csect = symbol_get_tc (csect)->next; } - a->x_csect.x_scnlen.p = - coffsymbol (symbol_get_bfdsym (csect))->native; - coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].fix_scnlen = - 1; + a->u.auxent.x_csect.x_scnlen.p + = coffsymbol (symbol_get_bfdsym (csect))->native; + a->fix_scnlen = 1; } - a->x_csect.x_smtyp = XTY_LD; + a->u.auxent.x_csect.x_smtyp = XTY_LD; } - a->x_csect.x_parmhash = 0; - a->x_csect.x_snhash = 0; + a->u.auxent.x_csect.x_parmhash = 0; + a->u.auxent.x_csect.x_snhash = 0; if (symbol_get_tc (sym)->symbol_class == -1) - a->x_csect.x_smclas = XMC_PR; + a->u.auxent.x_csect.x_smclas = XMC_PR; else - a->x_csect.x_smclas = symbol_get_tc (sym)->symbol_class; - a->x_csect.x_stab = 0; - a->x_csect.x_snstab = 0; + a->u.auxent.x_csect.x_smclas = symbol_get_tc (sym)->symbol_class; + a->u.auxent.x_csect.x_stab = 0; + a->u.auxent.x_csect.x_snstab = 0; /* Don't let the COFF backend resort these symbols. */ symbol_get_bfdsym (sym)->flags |= BSF_NOT_AT_END; @@ -6423,7 +6425,7 @@ ppc_adjust_symtab (void) { symbolS *csect; int i; - union internal_auxent *a; + combined_entry_type *a; if (S_GET_SEGMENT (sym) != absolute_section) continue; @@ -6434,21 +6436,22 @@ ppc_adjust_symtab (void) S_SET_STORAGE_CLASS (csect, C_HIDEXT); i = S_GET_NUMBER_AUXILIARY (csect); S_SET_NUMBER_AUXILIARY (csect, i + 1); - a = &coffsymbol (symbol_get_bfdsym (csect))->native[i + 1].u.auxent; - a->x_csect.x_scnlen.u64 = 0; - a->x_csect.x_smtyp = XTY_SD; - a->x_csect.x_parmhash = 0; - a->x_csect.x_snhash = 0; - a->x_csect.x_smclas = XMC_XO; - a->x_csect.x_stab = 0; - a->x_csect.x_snstab = 0; + a = &coffsymbol (symbol_get_bfdsym (csect))->native[i + 1]; + a->u.auxent.x_csect.x_scnlen.u64 = 0; + a->u.auxent.x_csect.x_smtyp = XTY_SD; + a->u.auxent.x_csect.x_parmhash = 0; + a->u.auxent.x_csect.x_snhash = 0; + a->u.auxent.x_csect.x_smclas = XMC_XO; + a->u.auxent.x_csect.x_stab = 0; + a->u.auxent.x_csect.x_snstab = 0; symbol_insert (csect, sym, &symbol_rootP, &symbol_lastP); i = S_GET_NUMBER_AUXILIARY (sym); - a = &coffsymbol (symbol_get_bfdsym (sym))->native[i].u.auxent; - a->x_csect.x_scnlen.p = coffsymbol (symbol_get_bfdsym (csect))->native; - coffsymbol (symbol_get_bfdsym (sym))->native[i].fix_scnlen = 1; + a = &coffsymbol (symbol_get_bfdsym (sym))->native[i]; + a->u.auxent.x_csect.x_scnlen.p + = coffsymbol (symbol_get_bfdsym (csect))->native; + a->fix_scnlen = 1; } ppc_saw_abs = false;