From patchwork Thu Oct 20 14:42:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Matz X-Patchwork-Id: 6228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp149421wrr; Thu, 20 Oct 2022 07:42:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CgE9MWlxsueelocWOVCzGF0gWpTteKxpq5vURiFEHEk9YwLlAZi7dkPOpyMeEQjFtRfVN X-Received: by 2002:a05:6402:278c:b0:45c:da8e:837d with SMTP id b12-20020a056402278c00b0045cda8e837dmr12666992ede.18.1666276957317; Thu, 20 Oct 2022 07:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666276957; cv=none; d=google.com; s=arc-20160816; b=r3S/8f3MXYNs2kzzYK6K2dCie3ximy56epG/upl7cFVnIwSX5UjQV/7QZEkMvrQq3N UnlaevGhMc5lGOOfcSAG0hkJuqubsPnD+J//cMP4GkupAA9LNDuqjr7DMCfx3YZo0RyG be95YvUjKgUK/8r5rsIkL8O3Gef/00ODEYM3MNCCrOCr7ifd1pbDZ/GEtbUjt12QdfF9 hrZy3kcn4uwkD7Sc8/OkVc2pewW/3g1WQkUi8D5aeoaj9WnFOO/nuMAkutAdCGlgl80L QU9rU/8fqoGcXsFo7Q5HnhjkZjG73290TnENYYnHLSLSIk1H9kkAvrLzUe1KmwJlWynL OtHg== 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:mime-version :user-agent:message-id:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=bEfabtJVSSmFTlVByEhZUpKTpCqxixCpNsn2VO3dWvo=; b=FRFLoO+1snjAG4H13NRmqt9L0bM93Rr/J8j3GglcgD9PQTMflUQgYLP+Ta2J7B8IYv lb3tdkVXNfJBlkaYplR38EE8VvIiAjPgVajp704mxxMbL+m9gyxOQ0nv9ouFchEQIUmn uwP1eEFWvAHiibApFJ0CjD84AxIrXDote0NQePOQcnQ0em6yMxbnPhiDoNTXA1cDUa0E kBB3cIqwDTT3pPGN2/f2U0yEOB413NWK38UsfZpFcx/Ni23JeP03W4wZvlo+Cb7SLye6 amIGwcKOegOC96yPmdCXTWdiShW0R5+9seHZsbMlapNC1cK1wNcWk+QhSdYeKDqC4D2b laAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CAP8GxTw; 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 b4-20020a0564021f0400b0045d8bff7afesi9278681edb.376.2022.10.20.07.42.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 07:42:37 -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=CAP8GxTw; 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 62F393850871 for ; Thu, 20 Oct 2022 14:42:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62F393850871 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666276956; bh=bEfabtJVSSmFTlVByEhZUpKTpCqxixCpNsn2VO3dWvo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CAP8GxTwVick3K00ZejW9LWJZNyISEIodh014E4a9lnwxeMspv3R2rwIw9Riiwu0K uKKo3w3rPYFRh5dHEjEEQB+tDh1EIrDlAfNSEPnUelEhgzPpBr47N0FOxK/25hgD51 iI2/yniA/C49RN4AMiPI0Z6JaLFscp5b/6wQKug8= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id E9CCE385084F for ; Thu, 20 Oct 2022 14:42:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E9CCE385084F Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 315861FB3B; Thu, 20 Oct 2022 14:42:25 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2BB1C2C141; Thu, 20 Oct 2022 14:42:25 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 10510) id 21A826457; Thu, 20 Oct 2022 14:42:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by wotan.suse.de (Postfix) with ESMTP id 20739644C; Thu, 20 Oct 2022 14:42:25 +0000 (UTC) Date: Thu, 20 Oct 2022 14:42:25 +0000 (UTC) To: binutils@sourceware.org Subject: x86-64: Use only one default max-page-size Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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: Michael Matz via Binutils From: Michael Matz Reply-To: Michael Matz 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?1747218026960060650?= X-GMAIL-MSGID: =?utf-8?q?1747218026960060650?= On x86-64 the default ELF_MAXPAGESIZE depends on a configure option (--disable-separate-code). Since 9833b775 ("PR28824, relro security issues") we use max-page-size for relro alignment (with a short interval, from 31b4d3a ("PR28824, relro security issues, x86 keep COMMONPAGESIZE relro") to its revert a1faa5ea, where x86-64 used COMMONPAGESIZE as relro alignment target). But that means that a linker configured with --disable-separate-code behaves different from one configured with --enable-separate-code (the default), _even if using "-z {no,}separate-code" option to use the non-configured behaviour_ . In particular it means that when configuring with --disable-separate-code the linker will produce binaries aligned to 2MB pages on disk, and hence generate 2MB executables for a hello world (and even 6MB when linked with "-z separate-code"). Generally we can't have constants that ultimately land in static variables be depending on configure options if those only influence behaviour that is overridable by command line options. So, do away with that, make the default MAXPAGESIZE be 4k (as is default for most x86-64 configs anyway, as most people won't configure with --disable-separate-code). If people need more they can use the "-z max-page-size" (with would have been required right now for a default configure binutils). bfd/ * elf64-x86-64.c (ELF_MAXPAGESIZE): Don't depend on DEFAULT_LD_Z_SEPARATE_CODE. --- I was worried about this case already earlier the year (https://sourceware.org/pipermail/binutils/2022-February/119766.html), but at that time I didn't realize that not only an explicit request via -z max-page-size generates large binaries, but also just configuring binutils different would do so. For compatibility with old code streams I do have to configure binutils in such way and obviously we can't have that produce 2MB or 6MB binaries. --- bfd/elf64-x86-64.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index f3b54400013..2ae8dffba0f 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -5259,11 +5259,7 @@ elf_x86_64_special_sections[]= #define ELF_ARCH bfd_arch_i386 #define ELF_TARGET_ID X86_64_ELF_DATA #define ELF_MACHINE_CODE EM_X86_64 -#if DEFAULT_LD_Z_SEPARATE_CODE -# define ELF_MAXPAGESIZE 0x1000 -#else -# define ELF_MAXPAGESIZE 0x200000 -#endif +#define ELF_MAXPAGESIZE 0x1000 #define ELF_COMMONPAGESIZE 0x1000 #define elf_backend_can_gc_sections 1