From patchwork Tue Jan 3 02:41:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 38247 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4406212wrt; Mon, 2 Jan 2023 18:41:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXt3MjL2tFEtLljxWFWhhblUJq4StsfTHvjkKMiHlzkY5hZYlHoIUnkL7UmiXGFOTH9rDJN6 X-Received: by 2002:a05:6402:2296:b0:467:9046:e2ef with SMTP id cw22-20020a056402229600b004679046e2efmr35387272edb.17.1672713692035; Mon, 02 Jan 2023 18:41:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672713692; cv=none; d=google.com; s=arc-20160816; b=anIh2lLKbU9DaF/qou6HHQPVDTLnoWj/XCxJugLqYm9hyWyHQLnjJ/L9FyfEEmBWGL oyCyKQ2q57PB5BYfSCwHoUjT9u8ygpYYsbxQtSKQGeSD2PC9HXbf160i0moheRZJob2E 4uJBNON5vbIpwWhwTH9vxW0bFB/txrMgqgvuLgJ9mrdXXstJKZrKFm+xryas2CNcw7VV WrPVc6hPoaTwkq1GifR+mbF1MAtzIXgJ7DVzZVW5VK0tX1iUOLqJ7fkVoXiOj8SGGqtK bc9CWZBF0AdD5N5eweKsAp3MIFspA1PgxRpfuWakS3nDM6Key/fTipwxMl5OMvoGmNXz I3Ag== 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:date:message-id :references:content-transfer-encoding:mime-version:subject :in-reply-to:cc:to:delivered-to:dkim-signature:dkim-filter; bh=+u82SaYsIaj63Fed+jo9y6YTEw5tUNIC26qGucGFBVw=; b=UExxnMiDyf3SS3QlQyB6e7KUYlByveLxddFrbc/nY8CgFMCo7Q4blE+6EhbkY/Qv82 GSiKnCAytHtGKEF6VIFbO5dNRA04zjzL2iCxL877oQsFC8LygAtpJYRaCoFh2OcCYnBD z+ghBHySnIk709uW4vxmqOVFYdhiQaOWWSGAA9DIFV88YCoScBf8EZoVdvLsJZGEBWQT Bupn25mcgNI/7ivnjolksjgxYzodaeeUXQZH90uC/X/XNMW7Tjk74F3r9LE8BP73+TN/ 4z5DZq+mDXXa26Zj40Yfst2GJeloqcMkC4vNmGZgLp5PzQAWmy1jRZlVKs6lI2xeHY+z Ue5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=N9pT9BCb; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id co17-20020a0564020c1100b004870d75f7e1si15433304edb.518.2023.01.02.18.41.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 18:41:32 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=N9pT9BCb; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 826F13858D32 for ; Tue, 3 Jan 2023 02:41:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 826F13858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672713690; bh=+u82SaYsIaj63Fed+jo9y6YTEw5tUNIC26qGucGFBVw=; h=To:CC:In-Reply-To:Subject:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=N9pT9BCbj4k1A4/CorCEReNTFOJIFYsPALMwb3icN7Z4mttVK2AEd17BiPVjPaX+O yXc85plYNj2djO8nYqN8jgspiUerdJi0DYznCKV4nvD+K6aYfbZgyH37U50SqVY1x9 qrh5ywPJFTnMOlBTNO4hgb18q4sKAlSg2RtL2w9k= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id 946BE3858D1E for ; Tue, 3 Jan 2023 02:41:20 +0000 (GMT) To: Alan Modra CC: In-Reply-To: (message from Alan Modra on Tue, 3 Jan 2023 02:35:27 +0100) Subject: ARM: Fix ld bloat introduced between binutils-2.38 and 2.39 MIME-Version: 1.0 References: <20230102160857.ABA7F2042C@pchp3.se.axis.com> Message-ID: <20230103024119.12F182042C@pchp3.se.axis.com> Date: Tue, 3 Jan 2023 03:41:19 +0100 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_PASS, 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: Hans-Peter Nilsson via Binutils From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson 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?1753967432448411986?= X-GMAIL-MSGID: =?utf-8?q?1753967432448411986?= > From: Alan Modra > CC: "binutils@sourceware.org" > On Mon, Jan 02, 2023 at 05:08:57PM +0100, Hans-Peter Nilsson via Binutils wrote: > > That may sound like an argument for setting the bfd_arch_arm > > ELF_MAXPAGESIZE to 4 KiB, but then the obscure corner-case > > wouldn't be properly handled. > > Agreed. It's what x86 did when facing the same thing. If anybody > cares about the obscure corner-case you identify then they can just > use -z max-page-size. Or edit elf32-arm.c. I see where this is going, but... > > Instead, I suggest simply making ELF_MAXPAGESIZE generally > > overridable by means of a --with option at linker > > configuration time. > > I dislike configure time options that affect linker behaviour, but I > realise I'm flogging a dead horse since we already have a lot of them. > However, this particular option is worse than most since it affects > all ELF targets. That can't be correct or useful with > --enable-targets=all. I have to say that people using --enable-targets=all to build their linkers definitely shouldn't be using this option, as their definition of "all" then doesn't include obscure corner cases! And how do the "--enable-targets=all"-people link? IIUC they have to specify an emulation when using such a linker, so they can't be using a general invocation. To wit, I don't think the "--enable-targets=all"-breakage is a valid counter-argument. Anyway, here's the obvious alternative. It needs to have the ARM testsuite adjusted (not included, will fix and send for separate consideration on approval). Ok for master, 2.40 and 2.39? --- 8< --- Subject: ARM: Fix ld bloat introduced between binutils-2.38 and 2.39 Since commit 9833b7757d24, "PR28824, relro security issues", ELF_MAXPAGESIZE matters much more, with regards to layout of the linked file. That commit fixed an actual bug, but also exposes a problem for targets were that value is too high. For example, for ARM(32, a.k.a. "Aarch32") specifically bfd_arch_arm, it's set to 64 KiB, making all Linux(/GNU) targets pay an extra amount of up to 60 KiB of bloat in DSO:s and executables. This matters when there are many such files, and where storage is expensive. It's *mostly* bloat when using a Linux kernel, as ARM(32) is a good example of an target where ELF_MAXPAGESIZE is set to an extreme value for an obscure corner-case. The ARM (32-bit) kernel has 4 KiB pages, has had that value forever, and can't be configured to any other value. The use-case is IIUC "Aarch32" emulation on an "Aarch64" (arm64) kernel, but not just that, but a setup where the Linux page-size is configured to something other than the *default* 4 KiB. Not sure there actually any such systems in use, again with both Aarch32 compatibility support and a non-4KiB pagesize, with all the warnings in the kernel config and requiring the "EXPERT" level set on. So, let's do like x86-64 in a2267dbfc9e1 "x86-64: Use only one default max-page-size" and set ELF_MAXPAGESIZE to 4096. bfd: * elf32-arm.c (ELF_COMMONPAGESIZE): Always set to 0x1000. --- bfd/elf32-arm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 0cd3aec14368..b83c43c741c9 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -20261,11 +20261,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym) #define ELF_ARCH bfd_arch_arm #define ELF_TARGET_ID ARM_ELF_DATA #define ELF_MACHINE_CODE EM_ARM -#ifdef __QNXTARGET__ #define ELF_MAXPAGESIZE 0x1000 -#else -#define ELF_MAXPAGESIZE 0x10000 -#endif #define ELF_COMMONPAGESIZE 0x1000 #define bfd_elf32_mkobject elf32_arm_mkobject