From patchwork Wed Jul 12 01:38: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: 118766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp848994vqm; Tue, 11 Jul 2023 18:38:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlE14zCD2MOeeqwVrMoz2kvARfFPmUA8dvxy+FBLr/elJKGrJo7dkOGe332OS/5DpWQ1ydky X-Received: by 2002:a17:906:410e:b0:991:cfce:7a09 with SMTP id j14-20020a170906410e00b00991cfce7a09mr18033334ejk.67.1689125925013; Tue, 11 Jul 2023 18:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689125924; cv=none; d=google.com; s=arc-20160816; b=eyZbjClbKwCqoaZEfQ68fSq4KMaG86wEomWOkPPCW6og2g4D8nMoNVf9cV5Pd/lOwH MNbnOm3ubsuRofzOERLdD1CUkeRRVpB8YWZJiII4Puaxt1IdJFMUQ9TlxbfbrkaO0ugq wfKuZvvIOYypVhxDzNmgaSL2esjQZ3asLY6lNkOMJuqNdP4ZNGPwoNyFL8u3wZXxmQN7 dgUATEqJM3aL2roEqw2N8sBIJ/8kXKHfKvSLOfJ+J85lpMq1Bl5F/k0nHLPbQgareToD pJwHMDi/WqurEQ77SG0lz7P0LuCC1VLP8huyoGjfUSIToaE4mXPGArNkWjL3HjSaLV+8 ik3g== 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=YmG3JGmx4bGz5CC17jzDVEmC9UWp5Yk7fYMqQBIwMR8=; fh=HNIqzTA9Dp00ovCAyCdXfuEvWDT00OlFxFRPLybXRis=; b=xyxitzddXZAtB7W/c9TPg7GL4B2/hA5KukQ7nVlEiXWdM8v+5F+mQTBUOKGOqbkPNH cRMPLkztSSj1PebQdsUo73aXgB4iYZKLrDwtUbhqw3+0iaGJud14pNm20nqzinq+4kLL k0Cr6lJ38gLr/nFnIX5uxota8fRy0tAfYpcBq9nfuvfnbE0hJw+QzzG2RJOCMsQ2nNH9 ZR/+ROrbWAAonw1+ONEaJvCEslksHXr8O/ZGko3H8XVzA3Eba+iZ5fK1yTPHmjfPvRWb 22ckmXtZs3pHopCRyXYJ1AHaWbTgz7zlR4DyVZOrFLIkvW5yoEfh5EFusUi6iAjYq84Q H9Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lPln5zhu; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w10-20020a1709060a0a00b0099364d9f0e0si3397692ejf.540.2023.07.11.18.38.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 18:38:44 -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=lPln5zhu; 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 71B923857722 for ; Wed, 12 Jul 2023 01:38:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71B923857722 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689125922; bh=YmG3JGmx4bGz5CC17jzDVEmC9UWp5Yk7fYMqQBIwMR8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lPln5zhu+HFV+93T7eJHq/uHKtGF5IEAPLPpHfxhfIjPdboUgWUmooYh3a2iCCEkv EFLTjy+edAk4jYXbehZREuLo3ZzQDMXdyrHYGls2wefSBkyl3I+v+L3yPQiBtnmq3J hr/qysT447Rk3sJqUZ5Bk3ind8HHdwV0kS+aJ+h4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 251B83858C62 for ; Wed, 12 Jul 2023 01:38:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 251B83858C62 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-51b4ef5378bso4685691a12.1 for ; Tue, 11 Jul 2023 18:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689125912; x=1691717912; 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=YmG3JGmx4bGz5CC17jzDVEmC9UWp5Yk7fYMqQBIwMR8=; b=GwTJXTTjT1GvqiUR0G0aHT1qXoQe+bNY2kxLdQtsCt9Kk8uxRBd4KiMviPMNEd5Bzz xDgbmo1KDwpNL8NjEBalmFaLIrhUseaNpuJNBk0RcLtnr0lCb/E93BTaQH0UeQyW3oTx J3u1QnJ7srFPAuv6OPaig41uUenBCO3X7aY3r632WuU/Ii1dblMhwOTTKHRYsmxURWu8 B4+UiMZfBFPvJz2wTIdY+My4QyGld5E5XNBxVBJvcj1kvtxttAeDxsleQzTdcRQ2kd/Y E46ZqdgFgzH+cl+P03VuSdfxsLM/5PP+OzowTO9TLHQ8fr7JMTvHPdTaroDw61GCzZJu dDqA== X-Gm-Message-State: ABy/qLZOonLR6TjFykin3ba5rGFDiG+2d2n/8EULxyRah2x7F9IR/4dq d8D9dXfTPyQXqS3d3JZEsqGJ/Cs8994= X-Received: by 2002:a17:902:e74b:b0:1b8:ac67:c2b with SMTP id p11-20020a170902e74b00b001b8ac670c2bmr20981851plf.21.1689125912379; Tue, 11 Jul 2023 18:38:32 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:80d7:5d82:afc0:aec1]) by smtp.gmail.com with ESMTPSA id h6-20020a170902f7c600b001b9d7c8f44dsm2598182plw.182.2023.07.11.18.38.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 18:38:31 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 6E8A31142A71; Wed, 12 Jul 2023 11:08:28 +0930 (ACST) Date: Wed, 12 Jul 2023 11:08:28 +0930 To: binutils@sourceware.org Subject: .noinit and .persistent alignment Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1771176906016808109 X-GMAIL-MSGID: 1771176906016808109 It's more elegant to make the section match up with its "_start" symbol. We could align by setting the address of the section (by using ALIGN before the colon), but this way we also set sh_addralign to at least $ALIGNMENT. * scripttempl/elf.sc (.noinit, .persistent): Align the output section rather than using ". = ALIGN();" at the beginning. Set address to zero when not a final link. diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index bfd8b5ed4b3..82de4ed9f88 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -342,9 +342,8 @@ STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : test "${HAVE_NOINIT}" = "yes" && NOINIT=" /* This section contains data that is not initialized during load, or during the application's initialization sequence. */ - .noinit (NOLOAD) : + .noinit ${RELOCATING-0} (NOLOAD) : ${RELOCATING+ALIGN(${ALIGNMENT})} { - ${RELOCATING+. = ALIGN(${ALIGNMENT});} ${RELOCATING+PROVIDE (__noinit_start = .);} *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*}) ${RELOCATING+. = ALIGN(${ALIGNMENT});} @@ -353,9 +352,8 @@ test "${HAVE_NOINIT}" = "yes" && NOINIT=" test "${HAVE_PERSISTENT}" = "yes" && PERSISTENT=" /* This section contains data that is initialized during load, but not during the application's initialization sequence. */ - .persistent : + .persistent ${RELOCATING-0} : ${RELOCATING+ALIGN(${ALIGNMENT})} { - ${RELOCATING+. = ALIGN(${ALIGNMENT});} ${RELOCATING+PROVIDE (__persistent_start = .);} *(.persistent${RELOCATING+ .persistent.* .gnu.linkonce.p.*}) ${RELOCATING+. = ALIGN(${ALIGNMENT});}