From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 2606C385841C for ; Sun, 12 Dec 2021 16:04:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2606C385841C Received: by mail-pl1-x62f.google.com with SMTP id y7so9583903plp.0 for ; Sun, 12 Dec 2021 08:04:44 -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=ImRX7P5EDXqyeGuazY7/HUyOsbcG1PKGHqPdrmJdO28=; b=B/+ksD0EyJtC/4Iv3/clmF/uRWsXIzBiM9hta2SmK/TCT3UZUHH9mUk6DIijYqPQyr Nt4WGtdnMcbZcyUl9iUrq1ZnfiTQ4H0xtYT6mncpXGudE7mw6Kzmb9+gSn//eYNVFu2x l6s/ko/j3rQkx0KRL6EWaBNyqBZ64fQOuXlOBmmNJI5gvn8ODambFH40Q8TFg+sJGO/4 CKNqmHofZcmBdY7d8YbdQ4jq0PL8uDz45FDz3Mja8s1tebztYQYkjiJBcSdQ+bgzDHHD LvFacinD1K07MczYZhtoQN1VhIZwrzFr2GcF7q/0/nq8Ob/xT8qaPlhgz2Vvz1JAl2k0 dtvw== X-Gm-Message-State: AOAM533150o5DK4EDFu8cqW3TLtrbkhNXKszvdjuW/1DRmpI/wi2Gcs8 oWC+f1mwXWB+rTj3wPuCGSo+ff4e3qIrTCxaxwT4I4TreAs= X-Google-Smtp-Source: ABdhPJy1jjfkUX2v1fqc3QhTROO6Tm8QO8Irhq8bE/Rr/w8A57E+jBbUxxb/WVIGpIBqlWKXBwMkngqZX7PCGnwecuI= X-Received: by 2002:a17:902:ced1:b0:141:e15d:49e0 with SMTP id d17-20020a170902ced100b00141e15d49e0mr89750344plg.27.1639325083082; Sun, 12 Dec 2021 08:04:43 -0800 (PST) MIME-Version: 1.0 References: <20211210220213.3285838-1-hjl.tools@gmail.com> <15c12c84-4f44-63e2-5a39-26bff6788848@linux.alibaba.com> In-Reply-To: <15c12c84-4f44-63e2-5a39-26bff6788848@linux.alibaba.com> From: "H.J. Lu" Date: Sun, 12 Dec 2021 08:04:07 -0800 Message-ID: Subject: Re: [PATCH v2] Check alignment of PT_LOAD segment only if possible To: Rongwei Wang Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3029.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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: 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-List-Received-Date: Sun, 12 Dec 2021 16:04:48 -0000 On Sat, Dec 11, 2021 at 7:54 PM Rongwei Wang wrote: > > > > On 12/11/21 6:02 AM, H.J. Lu via Libc-alpha wrote: > > Add a configure check for 2MB variable alignment and check alignment of > > PT_LOAD segment only if 2MB variable alignment is supported. > > > > Tested with cross build to glibcs-alpha-linux-gnu. > > --- > > configure | 26 ++++++++++++++++++++++++++ > > configure.ac | 11 +++++++++++ > > elf/Makefile | 15 ++++++++++----- > > 3 files changed, 47 insertions(+), 5 deletions(-) > > > > diff --git a/configure b/configure > > index e4d013907c..37259efce7 100755 > > --- a/configure > > +++ b/configure > > @@ -6817,6 +6817,32 @@ if test $libc_cv_builtin_trap = yes; then > > > > fi > > > > +# Check target support for 2MB variable alignment. > > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for 2MB variable alignment" >&5 > > +$as_echo_n "checking for 2MB variable alignment... " >&6; } > > +if ${libc_cv_have_2MB_alignment+:} false; then : > > + $as_echo_n "(cached) " >&6 > > +else > > + > > +cat confdefs.h - <<_ACEOF >conftest.$ac_ext > > +/* end confdefs.h. */ > > + > > +int foo __attribute__((aligned(0x200000))) = 1; > > + > > +_ACEOF > > +if ac_fn_c_try_compile "$LINENO"; then : > > + libc_cv_have_2MB_alignment=yes > > +else > > + libc_cv_have_2MB_alignment=no > > +fi > > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > > + > > +fi > > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_have_2MB_alignment" >&5 > > +$as_echo "$libc_cv_have_2MB_alignment" >&6; } > > +config_vars="$config_vars > > +have-2MB-alignment = $libc_cv_have_2MB_alignment" > > + > > ac_ext=cpp > > ac_cpp='$CXXCPP $CPPFLAGS' > > ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > > diff --git a/configure.ac b/configure.ac > > index a91a7f399c..57d4572c26 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -1726,6 +1726,17 @@ if test $libc_cv_builtin_trap = yes; then > > AC_DEFINE([HAVE_BUILTIN_TRAP]) > > fi > > > > +# Check target support for 2MB variable alignment. > > +AC_CACHE_CHECK([for 2MB variable alignment], > > + libc_cv_have_2MB_alignment, [ > > +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ > > +int foo __attribute__((aligned(0x200000))) = 1; > > +])], > > + [libc_cv_have_2MB_alignment=yes], > > + [libc_cv_have_2MB_alignment=no]) > > +]) > > +LIBC_CONFIG_VAR([have-2MB-alignment], [$libc_cv_have_2MB_alignment]) > > + > > dnl C++ feature tests. > > AC_LANG_PUSH([C++]) > > > > diff --git a/elf/Makefile b/elf/Makefile > > index fe42caeb0e..1bf77bc5ac 100644 > > --- a/elf/Makefile > > +++ b/elf/Makefile > > @@ -207,7 +207,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ > > tst-tls4 tst-tls5 \ > > tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \ > > tst-tls16 tst-tls17 tst-tls18 tst-tls19 tst-tls-dlinfo \ > > - tst-align tst-align2 tst-align3 \ > > + tst-align tst-align2 \ > > tst-dlmodcount tst-dlopenrpath tst-deep1 \ > > tst-dlmopen1 tst-dlmopen3 tst-dlmopen4 \ > > unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \ > > @@ -241,9 +241,6 @@ tests-internal += loadtest unload unload2 circleload1 \ > > tests-container += tst-pldd tst-dlopen-tlsmodid-container \ > > tst-dlopen-self-container tst-preload-pthread-libc > > test-srcs = tst-pathopt > > -ifeq (yes,$(have-fpie)) > > -tests-pie += tst-align3 > > -endif > > selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null) > > ifneq ($(selinux-enabled),1) > > tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog > > @@ -305,7 +302,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ > > circlemod3 circlemod3a \ > > reldep8mod1 reldep8mod2 reldep8mod3 \ > > reldep9mod1 reldep9mod2 reldep9mod3 \ > > - tst-alignmod tst-alignmod2 tst-alignmod3 \ > > + tst-alignmod tst-alignmod2 \ > > $(modules-execstack-$(have-z-execstack)) \ > > tst-dlopenrpathmod tst-deep1mod1 tst-deep1mod2 tst-deep1mod3 \ > > tst-dlmopen1mod tst-auditmod1 \ > > @@ -418,6 +415,14 @@ endif > > modules-execstack-yes = tst-execstack-mod > > extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) > > > > +ifeq (yes,$(have-2MB-alignment)) > > +tests += tst-align3 > > +modules-names += tst-alignmod3 > > +ifeq (yes,$(have-fpie)) > > +tests-pie += tst-align3 > > +endif > > +endif > > + > > # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special > > # rules. > > modules-names-nobuild := filtmod1 tst-big-note-lib tst-ro-dynamic-mod > > > Hello > > It seems that I need to wait for this patch to merge before I can send > out the following patch again: > "Add a testcase to check alignment of PT_LOAD segment" > > I am not sure if I got it right. If I missing something, please let me know. > It has been checked in. A followup patch was posted at https://sourceware.org/pipermail/libc-alpha/2021-December/134038.html -- H.J.