From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id C654B3858406 for ; Sat, 25 Dec 2021 02:51:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C654B3858406 Received: by mail-pj1-x102a.google.com with SMTP id k6-20020a17090a7f0600b001ad9d73b20bso9606511pjl.3 for ; Fri, 24 Dec 2021 18:51:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PR+w/ZNyMv6V4k8fiPbHFyI9FsIp7aORbNMtOO5INZc=; b=SDapRV3O66ocNhjzjcUnfIMwQr3cR5+rIZqhksgLra6mbqQDXuPT3aZezm5JU74fGU HmEAuvOacS0KIAA2K8UnEoZX6ypvNfvHZUlwD5rC0IYeajujjaa9lWANmvNjvZS5YQC+ UtzaJYPgPtVvd06UxLPvw5EHoBcHOSnZu2aYftKWYt6+dbSg39TJ7261kqStPzzMHfUk ESEOFSfwstpqeNZoKPUnwmvgu+NY9eqKMDYpIpvMTZuQKY9bHURpsTK1aVEUFumwBC9+ Zgz9kqoNPCPpfEhEN/fqJwhdGBBminc+uvkmKWqO1XOWbncDJcedw5+pE9jclwpOwQQa lNZA== X-Gm-Message-State: AOAM532+C6TlvlJcJ1n/c/hqJV44OBLVLOAYmeQ2Ubv96NoIwP6gkCxa TXlkWwv1g7cGQaiYtZArVxElL7PSZ0+YLEl02Vg= X-Google-Smtp-Source: ABdhPJyH+/T/IIWQ8j+eAs5rrXX0RGvIiWyaG3Rvb6c01be+wwhxVUGW4CHJebWrdNC87K94izxx20KSZpvf7znEX1w= X-Received: by 2002:a17:90b:4f86:: with SMTP id qe6mr10818058pjb.120.1640400665837; Fri, 24 Dec 2021 18:51:05 -0800 (PST) MIME-Version: 1.0 References: <20211215163232.1787673-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Fri, 24 Dec 2021 18:50:30 -0800 Message-ID: Subject: Re: [PATCH v2] elf: Set p_align to the minimum page size if possible To: Alan Modra Cc: Binutils , Nick Clifton , Florian Weimer Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3022.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Sat, 25 Dec 2021 02:51:09 -0000 On Fri, Dec 24, 2021 at 5:03 PM Alan Modra wrote: > > On Wed, Dec 22, 2021 at 06:38:54AM -0800, H.J. Lu wrote: > > I choose commonpagesize due to this glibc bug: > > > > https://sourceware.org/bugzilla/show_bug.cgi?id=28688 > > This means we are stuck. Choosing commonpagesize or minpagesize will > generate binaries that won't run with older glibc if the actual page > size is maxpagesize (assuming maxpagesize != commonpagesize). We can make this new behavior as opt-in since this is an optimization for ld.so. > I don't see a way to change DT_LOAD p_align that is backwards > compatible, except perhaps using a p_align of zero if the required > segment alignment (as calculated from section alignment) is less than > maxpagesize. That horrible hack just happens to work for older glibc, > but may break other loaders. Neither 0 nor 1 work for older glibc: if (__glibc_unlikely ((ph->p_align & (GLRO(dl_pagesize) - 1)) != 0)) { errstring = N_("ELF load command alignment not page-aligned"); goto lose; } if (__glibc_unlikely (((ph->p_vaddr - ph->p_offset) & (ph->p_align - 1)) != 0)) { errstring = N_("ELF load command address/offset not properly aligned"); goto lose; } -- H.J.