From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by sourceware.org (Postfix) with ESMTPS id 5AEBC384D153 for ; Thu, 20 Oct 2022 17:35:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5AEBC384D153 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f179.google.com with SMTP id s196so176823pgs.3 for ; Thu, 20 Oct 2022 10:35:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X4PyCRzstVxduCeS1uCjHtGBwwwwbbqdZqKa52Kebjk=; b=cuNCrrS0wtKdxycijAOHHIzgz4Fr+0vJGx2eRtu/FLXk0wtRMnykuotiHh3gP2J0ZY KP7OWAr/poom/6mBuWtjK8Jr1bcoVYVoBdPz0vMB1McBP4rj62uPqmz1BF5FuNdAmT2k oWVGo5hIXquaoslKXXUaepuC44ZSLMPAlpLnf4QIeYtK4/qGRQRI3s03fbOBG2Qj/FjP gwgbysP02XqJ8uqHu8VLI2yPN0R0iszqb79osu2Lgk6rqu1cnDmCXE2StTk80Xdiz3Xa 7XRc/DQpPWlw2j3kvpU+1Aze/Mav+HnVz9xjM1XPkQLC9RTg8sTYJbiomf08twrPDNdY 2CEw== X-Gm-Message-State: ACrzQf2RuHLizAuDv2DzE6w3Z2dV9/9bxGzwfx/e37/omjfenmPBsN/A jn71HqVVFm+MBIDbft4F/+s= X-Google-Smtp-Source: AMsMyM7eFRxWGyp1HeDVYpTvIs3ktU4ti1Aj+nUgcNvXyLfWJJUB45p/XjJYByzLWBwoYJHZQUhOUw== X-Received: by 2002:a63:db14:0:b0:44d:e4f3:b45c with SMTP id e20-20020a63db14000000b0044de4f3b45cmr12320284pgg.267.1666287311112; Thu, 20 Oct 2022 10:35:11 -0700 (PDT) Received: from localhost ([2620:15c:2c1:200:28c1:7ea8:f98f:7e05]) by smtp.gmail.com with ESMTPSA id a11-20020aa7970b000000b00562664d5027sm13553294pfg.61.2022.10.20.10.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 10:35:10 -0700 (PDT) Date: Thu, 20 Oct 2022 10:35:09 -0700 From: Fangrui Song To: Michael Matz Cc: binutils@sourceware.org, "H.J. Lu" Subject: Re: x86-64: Use only one default max-page-size Message-ID: <20221020173509.rmb55tcejzyczdwr@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 List-Id: On 2022-10-20, H.J. Lu via Binutils wrote: >On Thu, Oct 20, 2022 at 7:42 AM Michael Matz wrote: >> >> 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 >> -- >> 2.37.3 > >OK. > >Thanks. Thanks. I like consistent max-page-size=4096 for x86. (I'll update https://maskray.me/blog/2020-11-15-explain-gnu-linker-options "-z separate-code" when this patch lands.)