Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1622052rwr; Thu, 27 Apr 2023 22:27:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49FBUfKkoO4n9okx8Ce4l9Mp3BfxHzpkyVPxTakp36qEpk848nI0jZW2GmWm3LWLGK0SWl X-Received: by 2002:a17:903:11c4:b0:1a9:5e50:f20b with SMTP id q4-20020a17090311c400b001a95e50f20bmr4689485plh.21.1682659624614; Thu, 27 Apr 2023 22:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682659624; cv=none; d=google.com; s=arc-20160816; b=fBl79ZA1ZM4B/1M80uSyHSf6Poj7kLBjrSQKrUwQyHOFhSG0xiUx5QYS+04ZxNrjmP 5cbLhrJ3GSoLHhgQ9rpkuQESUH6kzE7hHeAQVa6rQA6chjrJlZ7C67B4uvDgv4+Ji1xq yLY3/rpz4IC96i9M8WeLepQ+KuU1EZ5NE+rYe7E6cEzHsVbJ8X1v5KXCtenRuYgtP421 QaA/L0K/6QH05mBnqdvVnncWUx4QySYm3bLzoxsk0DJ1MBkaJtPbcGS9k31zUjWbTNiC vOcgrx40Y6AXPZdCSxl7/aljFjONRDApBdXlGvnMM1UD0tBiVbYF9l+F82VNGPMOsUSi +P4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=WMs1qPhxL/BS9MMmSEsgwTMurDosjtHWEBwSfQK3U8A=; b=VQ/O0O4Tq01ygtBIl13sLVjhKL/ryg5Ymtfw5FoPFpshOwkSUNukJ9vb23tm0PoBRJ X6Dl9j8Qu1hrjvxIG5GT7EHkUd3X9Xc/bC5ZChAcdm0b8tcdcLAY2EiZdsa521qDFxPz 4qZafNnwYSuVAxMfG+zySW44HEtkYPU1ugd3ubEKqa4Zwh4cpvjmcJxzrIzthydUyU+R q1pcrvcg1gqCjQwRcWOaYDwd97mNsmLnzUrPkx8x8S1k19qeA/L0Kf23DoEqleYwwah9 VyzyNHJ8AXOcmsczRv2HyIIuyjninjVRL+6SmGg0W3Y8ICJWS6O0Mi08/dq+zfT677mY GgMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=4GQDh6mF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a170903028600b00194967b7badsi21387975plr.591.2023.04.27.22.26.47; Thu, 27 Apr 2023 22:27:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=4GQDh6mF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345225AbjD1FFI (ORCPT + 99 others); Fri, 28 Apr 2023 01:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjD1FFG (ORCPT ); Fri, 28 Apr 2023 01:05:06 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C49BC26B3 for ; Thu, 27 Apr 2023 22:05:04 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1a950b97dafso78025495ad.3 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=De6QzGEkSLa7TAayvx1QeN4IOnjYw2Mi5KsNco9UqlX1tP18V2U3xpuo+VxhfLsb0o zBQuHXbdDMe2tw2aMcy4RYVjHJvV+gGefZ3PEfxQYB9pWCCJXwPV+dqBJ8rZwdpFMflX zHo8yCGWKp47muVDAe0Vun+jSyh8lUAfdBHWEVtLEbh5HoZwX1eaAMFDJWDSPOpR2s6y VekZRr3E+o2R0vmrsYIQ6RttTakvSwGWPRlmf90MVSqnjwuDoOoSlaDagkhekX208sYo T1hFL8QbpGwdoeXPxY6lUe75wba9nxCqxZV4796cUuPCr+5qLGadvEQ0JDP8Isum8VGN hirg== X-Gm-Message-State: AC+VfDwIxPEtgzS2H1WsE+PprbmqGW1FNdHAdL/9B7/bDnxE5UZBnbR3 65wgtalThRK34NCuHtv6htv4oMckmsCb 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 = .; -- 2.40.1.495.gc816e09b53d-goog