From patchwork Wed Apr 20 07:21:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 53065 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 005403857418 for ; Wed, 20 Apr 2022 07:21:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 005403857418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650439320; bh=Bke95TW4rFEIbWDJAzTtAZUZzF04Zbv5/7WoO2l1Aaw=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gqbqGu+RYOL9/NeHEGXxjm+VGwxhoHWzaH+JYZcU7VJThRuflN0gIcx+dRIgi2AgA Qjp6xGynYUyDy78enxDC/81lhFfLG/m/llNif8QoIJbPpEcz0JGGX27niwDT7GykZJ hWS2CAfsPrOihd6OXaPT6ORj8C8v+S5zBJXLGNGQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 7C2683858D3C for ; Wed, 20 Apr 2022 07:21:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C2683858D3C Received: by mail-pj1-x1035.google.com with SMTP id md20-20020a17090b23d400b001cb70ef790dso4189498pjb.5 for ; Wed, 20 Apr 2022 00:21:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bke95TW4rFEIbWDJAzTtAZUZzF04Zbv5/7WoO2l1Aaw=; b=Yf7Mi+XWB7Bdu8T7LcmgwI3lzd6bx1OYLuYLlWpTNV/NzjtDYy2vFlK+OcxOFLLxeC IsR5NaPuGeWtuhgJbE2nhPA8vuPvFt14V6+31h4besUET8BJ9VOC4vDVUX4YZCbZC3Vg MewkQonx7jCg+uLaVSzIc9vhtMTv6g/GSxxRomx6kEd4zb+tHnK3wtKD/fS4LL2y9tZU klqB6FHfCsyxM8jgDINnVUQkmxdmiXe20DwcCu7w4prxBkX8WuBcifCSdvLrzE7lfG/b /e70wbUdxRHJiBjpiqEMMU3zxsdwnP7xPIxzxdkN64MKorkZouvDasFQLoIpM+TEmcpe O5sw== X-Gm-Message-State: AOAM5317yL0Tw0I6pUtyP83bb0GdlZFRogebCo7mWjQcIx4G8krEa54D ZLZyK0NXdFXpAy29uOtVs7aTZwQfKP0= X-Google-Smtp-Source: ABdhPJxMnIaj4kOyjfkPNk1PTI9NbQ6XSkiYlSwRe4nfOUnl1bC51s5VgI1ZYgaT4UsKueSlB7LNhg== X-Received: by 2002:a17:902:aa06:b0:158:f13b:4859 with SMTP id be6-20020a170902aa0600b00158f13b4859mr17160775plb.141.1650439294547; Wed, 20 Apr 2022 00:21:34 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:58c9:bdee:9ae5:d611]) by smtp.gmail.com with ESMTPSA id p64-20020a622943000000b004fdd5c07d0bsm18790609pfp.63.2022.04.20.00.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 00:21:33 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id AC2AE1140617; Wed, 20 Apr 2022 16:51:30 +0930 (ACST) Date: Wed, 20 Apr 2022 16:51:30 +0930 To: Tulio Magno Quites Machado Filho Subject: [PATCH v3] powerpc64: Enable static-pie Message-ID: References: <20220228064052.3413334-1-amodra@gmail.com> <20220228064052.3413334-5-amodra@gmail.com> <87wnfz199a.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3036.7 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, T_SCC_BODY_TEXT_LINE 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: Alan Modra via Libc-alpha From: Alan Modra Reply-To: Alan Modra Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" On Thu, Apr 14, 2022 at 10:46:14AM +0930, Alan Modra wrote: > I'll note that static-pie is enabled in glibc without any user > --enable-static-pie, ie. it is the default if SUPPORT_STATIC_PIE is > set. SUPPORT_STATIC_PIE is enabled unconditionally for x86 and > aarch64 without any toolchain checks, and I foolishly followed that > precedent. Conditionally define SUPPORT_STATIC_PIE if binutils-2.33 or later. The test ifunc results in .iplt relocations, and with a weak reference to __rela_iplt_start will cause older linkers to generate that symbol. PI_STATIC_AND_HIDDEN should be OK with the base binutils-2.25. * sysdeps/powerpc/powerpc64/configure.ac (SUPPORT_STATIC_PIE): Define. (PI_STATIC_AND_HIDDEN): Define. * sysdeps/powerpc/powerpc64/configure: Regenerate. Regression tested powerpc64le-linux. diff --git a/sysdeps/powerpc/powerpc64/configure b/sysdeps/powerpc/powerpc64/configure index fddea0355a..0db93080d3 100644 --- a/sysdeps/powerpc/powerpc64/configure +++ b/sysdeps/powerpc/powerpc64/configure @@ -1,6 +1,44 @@ # This file is generated from configure.ac by Autoconf. DO NOT EDIT! # Local configure fragment for sysdeps/powerpc/powerpc64. +$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the toolchain supports static-pie" >&5 +$as_echo_n "checking if the toolchain supports static-pie... " >&6; } +if ${libc_cv_ppc64_static_pie+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + if ! nm conftest | grep -q __rela_iplt; then + libc_cv_ppc64_static_pie=yes + fi + fi + rm -rf conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ppc64_static_pie" >&5 +$as_echo "$libc_cv_ppc64_static_pie" >&6; } +if test x$libc_cv_ppc64_static_pie = xyes; then + $as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for support for overlapping .opd entries" >&5 $as_echo_n "checking for support for overlapping .opd entries... " >&6; } if ${libc_cv_overlapping_opd+:} false; then : diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac index 1f3d54414c..7de4de871c 100644 --- a/sysdeps/powerpc/powerpc64/configure.ac +++ b/sysdeps/powerpc/powerpc64/configure.ac @@ -1,6 +1,37 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. # Local configure fragment for sysdeps/powerpc/powerpc64. +dnl It is possible to access static and hidden symbols in a position +dnl independent way requiring no relocation on powerpc64. The linker +dnl edits medium and large model code that uses GOT/TOC entries (which +dnl would require relocation) to r2 relative accesses. +AC_DEFINE(PI_STATIC_AND_HIDDEN) + +AC_CACHE_CHECK(if the toolchain supports static-pie, +libc_cv_ppc64_static_pie, [dnl + cat > conftest.c <