From patchwork Sun Sep 29 15:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1990591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NGifAGXi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XGpW313Gwz1xt8 for ; Mon, 30 Sep 2024 01:47:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B127A385E839 for ; Sun, 29 Sep 2024 15:47:40 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 0B62E385841E for ; Sun, 29 Sep 2024 15:47:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B62E385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B62E385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727624846; cv=none; b=QZVfHtJE9+LG3Cql5i9EM6SyHOtanOqUDIpktE+1Evd8ZKB6pBxF9OA2HDkK/8GKrS2YJ9ikJfYD7reyW7dsvCwUn2CNNTdlNqPVp8yrGqMb5KVz4JpgwOk9z1KBtK9UyDnfrLf89DHqbMIxAhwbgm0cUpXv6Pk+f0gYpMRoIhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727624846; c=relaxed/simple; bh=7Dr26lSA4esaXHS+SdPpi3aUpQYMkBJopwLbESYvU9s=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=sMQfaErzUpR87llZ8ZqkbjTSQkl7aG5sphD6rpQBnbX2SpUNRa70lpp7RQZvVDIobkmo1LgleSBoGIwBLe29ofeJS4Cv2q6+BaaLwYecZhZJaoOOOFWRKzWBBeeoFLMoZMqUec/RsRqfwAOFTeUJg9iWFGmJFVEJJAfFDA6IO2k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727624844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=cPrp3Yk/0uOROQVbnd36COQ72sw8IHeZlRvK128Sbrs=; b=NGifAGXiTBPnqHQraHBYI3y+dBHmimoY/3j4vE4w3dgSGQvygjTRVwNHqXbBkI75mG/e1/ Uk229HOcYRxr4tmbhQ9ayxbQgeDMBhjTOwkIWmdwFxDYVqIxjxhyUfoM2vbRfsWU6r2nKQ fiebbuScqDXdz2N0RNb75qhKWkTsaKg= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-7Io4bECEOcy_Ut-QTOZErw-1; Sun, 29 Sep 2024 11:47:23 -0400 X-MC-Unique: 7Io4bECEOcy_Ut-QTOZErw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4CDCD190ECC2 for ; Sun, 29 Sep 2024 15:47:22 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.45.224.151]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3DB7719373D7 for ; Sun, 29 Sep 2024 15:47:20 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v3 00/29] Teach glibc about possible page sizes and handle gaps in ld.so Message-ID: X-From-Line: 52aa57f9ba1971262b8aaa5c705b2a260e6c09eb Mon Sep 17 00:00:00 2001 Date: Sun, 29 Sep 2024 17:47:18 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org This series is another attempt to fix bug 31943. If the binutils RELRO bug is fixed, we still run into a conceptual issue with LOAD segment gaps if the system supports multiple page sizes (or at least, if ld uses a larger page size than required on Linux, as it happens on some targets). To avoid the overhead and loss of test coverage by accepting gaps everywhere, this series teaches glibc the possible range of page sizes for each supported architecture. Information regarding possible page sizes is useful to application programmers, so this is exposed in a new installed header. It is just too tempting to use this to optimize getpagesize etc., so the series contains some commits for that as well. No ABI changes necessary. There is a new build failure on loongarch, apparently unrelated, and reported as GCC PR116887. Thanks, Florian Florian Weimer (29): elf: Add tests to verify that l_contiguous reflects reality Prepare for the addition of the header aarch64: Add alpha: Add arc: Add arm: Add csky: Add hppa: Add loongarch: Add m68k: Add microblaze: Add mips: Add nios2: Add or1k: Add powerpc: Add riscv: Add s390: Add sh: Add sparc: Add x86: Add misc: Add tst-getpagesize elf: Extract rtld_setup_phdr function from dl_main configure: Add --with-ld-relro-load-gaps configure option and test elf: Handle ld.so with LOAD segment gaps in _dl_find_object (bug 31943) Install the header file Linux: Optimize getpagesize using malloc: Use volatile as compiler barrier in tst-memalign, tst-valloc posix: Use in tst-fnmatch3 Optimize various ways to obtain the page size using INSTALL | 12 +++ NEWS | 5 + bits/pagesize.h | 10 ++ bits/shm.h | 9 ++ config.h.in | 3 + configure | 39 ++++++++ configure.ac | 20 ++++ elf/Makefile | 31 ++++++ elf/dl-find_object.c | 78 +++++++++------ elf/rtld.c | 84 +++++++++++----- elf/tst-link-map-contiguous-ldso.c | 43 ++++++++ elf/tst-link-map-contiguous-libc.c | 57 +++++++++++ elf/tst-link-map-contiguous-main.c | 45 +++++++++ elf/tst-program-headers.py | 137 ++++++++++++++++++++++++++ include/sys/pagesize.h | 1 + malloc/tst-memalign.c | 17 ++-- malloc/tst-valloc.c | 17 ++-- manual/install.texi | 12 +++ manual/resource.texi | 31 ++++++ misc/Makefile | 3 + misc/sys/pagesize.h | 32 ++++++ misc/tst-getpagesize.c | 65 ++++++++++++ posix/tst-fnmatch3.c | 23 ++--- posix/unistd.h | 21 ++++ sysdeps/aarch64/bits/pagesize.h | 2 + sysdeps/alpha/bits/pagesize.h | 2 + sysdeps/arc/bits/pagesize.h | 2 + sysdeps/arm/bits/pagesize.h | 2 + sysdeps/csky/bits/pagesize.h | 2 + sysdeps/hppa/bits/pagesize.h | 2 + sysdeps/loongarch/bits/pagesize.h | 2 + sysdeps/m68k/bits/pagesize.h | 2 + sysdeps/m68k/coldfire/bits/pagesize.h | 2 + sysdeps/microblaze/bits/pagesize.h | 2 + sysdeps/mips/bits/pagesize.h | 2 + sysdeps/nios2/bits/pagesize.h | 2 + sysdeps/or1k/bits/pagesize.h | 2 + sysdeps/powerpc/bits/pagesize.h | 2 + sysdeps/riscv/bits/pagesize.h | 2 + sysdeps/s390/bits/pagesize.h | 2 + sysdeps/sh/bits/pagesize.h | 2 + sysdeps/sparc/sparc32/bits/pagesize.h | 2 + sysdeps/sparc/sparc64/bits/pagesize.h | 2 + sysdeps/unix/sysv/linux/arc/Makefile | 5 + sysdeps/unix/sysv/linux/arm/Makefile | 3 + sysdeps/unix/sysv/linux/getpagesize.c | 5 + sysdeps/x86/bits/pagesize.h | 2 + 47 files changed, 758 insertions(+), 90 deletions(-) create mode 100644 bits/pagesize.h create mode 100644 elf/tst-link-map-contiguous-ldso.c create mode 100644 elf/tst-link-map-contiguous-libc.c create mode 100644 elf/tst-link-map-contiguous-main.c create mode 100644 elf/tst-program-headers.py create mode 100644 include/sys/pagesize.h create mode 100644 misc/sys/pagesize.h create mode 100644 misc/tst-getpagesize.c create mode 100644 sysdeps/aarch64/bits/pagesize.h create mode 100644 sysdeps/alpha/bits/pagesize.h create mode 100644 sysdeps/arc/bits/pagesize.h create mode 100644 sysdeps/arm/bits/pagesize.h create mode 100644 sysdeps/csky/bits/pagesize.h create mode 100644 sysdeps/hppa/bits/pagesize.h create mode 100644 sysdeps/loongarch/bits/pagesize.h create mode 100644 sysdeps/m68k/bits/pagesize.h create mode 100644 sysdeps/m68k/coldfire/bits/pagesize.h create mode 100644 sysdeps/microblaze/bits/pagesize.h create mode 100644 sysdeps/mips/bits/pagesize.h create mode 100644 sysdeps/nios2/bits/pagesize.h create mode 100644 sysdeps/or1k/bits/pagesize.h create mode 100644 sysdeps/powerpc/bits/pagesize.h create mode 100644 sysdeps/riscv/bits/pagesize.h create mode 100644 sysdeps/s390/bits/pagesize.h create mode 100644 sysdeps/sh/bits/pagesize.h create mode 100644 sysdeps/sparc/sparc32/bits/pagesize.h create mode 100644 sysdeps/sparc/sparc64/bits/pagesize.h create mode 100644 sysdeps/x86/bits/pagesize.h base-commit: 6948ee4edf0c57c556f8d5f394d9191216d05780