From patchwork Fri Apr 28 05:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 13225974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D898C77B61 for ; Fri, 28 Apr 2023 05:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=9/fMSL1JbDiJUufjkl30GQ9nlzT59oL7lgua79f18KE=; b=Z/A yVbRYR2n46qf0i8B7LEkt6oYNRem6q9qCFFuwynyqdw6luIiEXnLDsTriXUpU3ydxW+WGExkAkqbt HxS2iKjVj+EhiqO991bIF714K8/kw0e1L4FoM/kiRpg4rNmr2sT+vyC/nRR03x+2vGxwRxS2+VSJw IyqyRMB6nEB2JOmSLnJMrl5sb6lZhxfoawk6x8LRL0Dy9b6uKiOi8X1RRWicUu0F0ZkVSrEK6mShA 6/FOstmIv3qGoYsQEuziVWr+64gBp/zjcnT153xQU1SHPoqYOuczpYh2596FdXlWH38y6Ggv1L7U1 XRmvCTIe9vUo0nPFZaHE+tI/E2iDKpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1psGI9-008BPH-2h; Fri, 28 Apr 2023 05:05:09 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1psGI6-008BON-31 for linux-arm-kernel@lists.infradead.org; Fri, 28 Apr 2023 05:05:08 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1a677ddd14fso98557755ad.2 for ; Thu, 27 Apr 2023 22:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682658304; x=1685250304; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=WMs1qPhxL/BS9MMmSEsgwTMurDosjtHWEBwSfQK3U8A=; b=4GQDh6mFwGATF9SJtXccUcdoequAkNrAXmgbZCy+DaIB7+el/ymFviB3yK7LVIm2M8 VN1vsubPIJ5SyXXQJikcLodRrSIaBMpdQoNvRG24JP8if5fs6/cCJk0IoWw1VSYayg1N dqv9ueQiWwz1aqAY0YDTe1S3GhZM/GxyI1XFUAPFugFoes/8x94MvQoAIu/ApUWoE+YL TVIxlsnTrtWoWKUoM9DpCVRY3hHcWcvAhhBeRlY3LSZc3xhWrw4dtG7rWkuT/0raTxC6 DmVzRMLCqEgog5SNtBSA6WzBAxs/aFSqF6wKihf34mXXXiPkJk/AOj3XqBWnEXg1Rgr/ ZqXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682658304; x=1685250304; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WMs1qPhxL/BS9MMmSEsgwTMurDosjtHWEBwSfQK3U8A=; b=Fm8GmCnKy3DM2qOGQ2LxDZJVmT5M4gFmOFEZf0tqXbUqfwlPFCV6iv97v1Is2NPLnu 3IeFNqD+n136IVCXcMqzXg0aaH6LDJDy39bCYiy/tdhyUyF6EoaSIpmgFRRHMS/IR3vZ kPwHXunc7e2Cl4Qd9cxJmoUhmb4bDDw/obEIDkxIPpI2agZjYMCxqW9WcyV5Gy3vt3Gu JI/aKWGM2uDf2lvz7jh2RBFFSuT4Hio7NUV9IkGaQggEYQfedYGt8ZnwTf8oZc/yRUvU hWUk+pmDHN3P5EO2PWpoBEjVtrGM8HbdD5mXXTAEmD+CgMfpsfyroKkeYOVfD41UtxRF SwsA== X-Gm-Message-State: AC+VfDwQvYCvXBia9B6XIkkXoaPDVazu+fl5Ax3DnADIDpbcubuIUDpJ rEp7fwxBzovCiYAl+VpvYmJfrNCbhaZJ X-Google-Smtp-Source: ACHHUZ6ZzBcN/mv/MeJEVTey2sDWypLXT1OQBkVfztH0jlUTTZf6QjJzrkb1J7kPJ1stM2edHFOvR6PdI0XK X-Received: from meowing-l.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:3eba]) (user=maskray job=sendgmr) by 2002:a17:902:e541:b0:1a2:1fd0:226b with SMTP id n1-20020a170902e54100b001a21fd0226bmr1419587plf.5.1682658304294; Thu, 27 Apr 2023 22:05:04 -0700 (PDT) Date: Fri, 28 Apr 2023 05:04:42 +0000 Mime-Version: 1.0 Message-ID: <20230428050442.180913-1-maskray@google.com> Subject: [PATCH] arm64: lds: move .got section out of .text From: Fangrui Song To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Bill Wendling , Nick Desaulniers , Ard Biesheuvel , Fangrui Song X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230427_220506_991373_2719FBDB X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, the .got section is placed within the output section .text. However, when .got is non-empty, the SHF_WRITE flag is set when linked by lld. GNU ld recognizes .text as a special section and ignores the SHF_WRITE flag. By renaming .text, we can also get the SHF_WRITE flag. Conventionally, the .got section is placed just before .got.plt (which should be empty and omitted in the kernel). Therefore, we move the .got section to a conventional location (between .text and .data) and remove the unneeded `. = ALIGN(16)`. Signed-off-by: Fangrui Song --- arch/arm64/kernel/vmlinux.lds.S | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index b9202c2ee18e..2bcb3b30db41 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -181,18 +181,8 @@ SECTIONS KPROBES_TEXT HYPERVISOR_TEXT *(.gnu.warning) - . = ALIGN(16); - *(.got) /* Global offset table */ } - /* - * Make sure that the .got.plt is either completely empty or it - * contains only the lazy dispatch entries. - */ - .got.plt : { *(.got.plt) } - ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, - "Unexpected GOT/PLT entries detected!") - . = ALIGN(SEGMENT_ALIGN); _etext = .; /* End of text section */ @@ -247,6 +237,16 @@ SECTIONS . = ALIGN(SEGMENT_ALIGN); __inittext_end = .; + + .got : { *(.got) } + /* + * Make sure that the .got.plt is either completely empty or it + * contains only the lazy dispatch entries. + */ + .got.plt : { *(.got.plt) } + ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, + "Unexpected GOT/PLT entries detected!") + __initdata_begin = .; init_idmap_pg_dir = .;