From patchwork Fri Jan 14 16:52:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 50041 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D577A383603F for ; Fri, 14 Jan 2022 16:54:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D577A383603F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1642179283; bh=Ttn5BabP6c9ZvlsagDR4wJKbO2xOeyyXsAGOllT8dew=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HK0IW+3TDyzIIavcIcds3dbeeYie/e/8QO6hQMNyuwTs+qv9WQxjWAQ8yktajWFXd A+IO4/ECQ/0MCEqP1mR9vI4S2Ol9wCkCCFPGeXLx1BtMa2MsAmNvvmqsJAZHrQFuZa w1X1qcwUIj+aPghDabnTcap+ghTLcm8IWYgawMug= 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 ESMTPS id 5FC40385DC11 for ; Fri, 14 Jan 2022 16:53:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5FC40385DC11 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-352-tDIryjl1PB6GCsqn5UOimg-1; Fri, 14 Jan 2022 11:53:01 -0500 X-MC-Unique: tDIryjl1PB6GCsqn5UOimg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7E3F81CCB8 for ; Fri, 14 Jan 2022 16:53:00 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DCFDB79A2D for ; Fri, 14 Jan 2022 16:52:59 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v2 3/6] Add --with-rtld-early-cflags configure option In-Reply-To: References: X-From-Line: 715520a1d4e694057ead5b76e58eac4af5ee76f5 Mon Sep 17 00:00:00 2001 Message-Id: <715520a1d4e694057ead5b76e58eac4af5ee76f5.1642179009.git.fweimer@redhat.com> Date: Fri, 14 Jan 2022 17:52:57 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- v2: Rename configure option. Regenerate INSTALL. INSTALL | 8 ++++++++ config.make.in | 1 + configure | 13 +++++++++++++ configure.ac | 6 ++++++ elf/Makefile | 8 ++++++++ manual/install.texi | 7 +++++++ 6 files changed, 43 insertions(+) Reviewed-by: H.J. Lu diff --git a/INSTALL b/INSTALL index 331d405e56..a9dc12fa31 100644 --- a/INSTALL +++ b/INSTALL @@ -106,6 +106,14 @@ if 'CFLAGS' is specified it must enable optimization. For example: particular case and potentially change debugging information and metadata only). +'--with-rtld-early-cflags=CFLAGS' + Use additional compiler flags CFLAGS to build the early startup + code of the dynamic linker. These flags can be used to enable + early dynamic linker diagnostics to run on CPUs which are not + compatible with the rest of the GNU C Library, for example, due to + compiler flags which target a later instruction set architecture + (ISA). + '--with-timeoutfactor=NUM' Specify an integer NUM to scale the timeout of test programs. This factor can be changed at run time using 'TIMEOUTFACTOR' environment diff --git a/config.make.in b/config.make.in index e8630a8d0c..6d43e691f7 100644 --- a/config.make.in +++ b/config.make.in @@ -110,6 +110,7 @@ CFLAGS = @CFLAGS@ CPPFLAGS-config = @CPPFLAGS@ CPPUNDEFS = @CPPUNDEFS@ extra-nonshared-cflags = @extra_nonshared_cflags@ +rtld-early-cflags = @rtld_early_cflags@ ASFLAGS-config = @ASFLAGS_config@ AR = @AR@ NM = @NM@ diff --git a/configure b/configure index 3f956cf777..6a7e5c6164 100755 --- a/configure +++ b/configure @@ -681,6 +681,7 @@ force_install bindnow hardcoded_path_in_tests enable_timezone_tools +rtld_early_cflags extra_nonshared_cflags use_default_link sysheaders @@ -761,6 +762,7 @@ with_selinux with_headers with_default_link with_nonshared_cflags +with_rtld_early_cflags with_timeoutfactor enable_sanity_checks enable_shared @@ -1480,6 +1482,8 @@ Optional Packages: --with-default-link do not use explicit linker scripts --with-nonshared-cflags=CFLAGS build nonshared libraries with additional CFLAGS + --with-rtld-early-cflags=CFLAGS + build early initialization with additional CFLAGS --with-timeoutfactor=NUM specify an integer to scale the timeout --with-cpu=CPU select code for CPU variant @@ -3386,6 +3390,15 @@ fi +# Check whether --with-rtld-early-cflags was given. +if test "${with_rtld_early_cflags+set}" = set; then : + withval=$with_rtld_early_cflags; rtld_early_cflags=$withval +else + rtld_early_cflags= +fi + + + # Check whether --with-timeoutfactor was given. if test "${with_timeoutfactor+set}" = set; then : diff --git a/configure.ac b/configure.ac index 277d3527d2..40f2de1661 100644 --- a/configure.ac +++ b/configure.ac @@ -162,6 +162,12 @@ AC_ARG_WITH([nonshared-cflags], [extra_nonshared_cflags=$withval], [extra_nonshared_cflags=]) AC_SUBST(extra_nonshared_cflags) +AC_ARG_WITH([rtld-early-cflags], + AS_HELP_STRING([--with-rtld-early-cflags=CFLAGS], + [build early initialization with additional CFLAGS]), + [rtld_early_cflags=$withval], + [rtld_early_cflags=]) +AC_SUBST(rtld_early_cflags) AC_ARG_WITH([timeoutfactor], AS_HELP_STRING([--with-timeoutfactor=NUM], diff --git a/elf/Makefile b/elf/Makefile index 3df49742ff..e6a28b243b 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -167,6 +167,14 @@ CFLAGS-.o += $(call elide-stack-protector,.o,$(elide-routines.os)) CFLAGS-.op += $(call elide-stack-protector,.op,$(elide-routines.os)) CFLAGS-.os += $(call elide-stack-protector,.os,$(all-rtld-routines)) +# Add the requested compiler flags to the early startup code. +CFLAGS-dl-printf.os += $(rtld-early-cflags) +CFLAGS-dl-sysdep.os += $(rtld-early-cflags) +CFLAGS-dl-tunables.os += $(rtld-early-cflags) +CFLAGS-dl-write.os += $(rtld-early-cflags) +CFLAGS-dl-writev.os += $(rtld-early-cflags) +CFLAGS-rtld.os += $(rtld-early-cflags) + ifeq ($(unwind-find-fde),yes) routines += unwind-dw2-fde-glibc shared-only-routines += unwind-dw2-fde-glibc diff --git a/manual/install.texi b/manual/install.texi index b1afc56f5a..accaef45fa 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -131,6 +131,13 @@ that the objects in @file{libc_nonshared.a} are compiled with this flag (although this will not affect the generated code in this particular case and potentially change debugging information and metadata only). +@item --with-rtld-early-cflags=@var{cflags} +Use additional compiler flags @var{cflags} to build the early startup +code of the dynamic linker. These flags can be used to enable early +dynamic linker diagnostics to run on CPUs which are not compatible with +the rest of @theglibc{}, for example, due to compiler flags which target +a later instruction set architecture (ISA). + @item --with-timeoutfactor=@var{NUM} Specify an integer @var{NUM} to scale the timeout of test programs. This factor can be changed at run time using @env{TIMEOUTFACTOR}