From patchwork Sun Jan 2 14:16:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 49447 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 CFD78385841A for ; Sun, 2 Jan 2022 14:16:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFD78385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1641133007; bh=di4ombLYHQiTgE6G2IVD/ENunRASoBLWuV3+7Ftz0fE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pCyR+vlqEnVE7HxZZ7jHQOQKTGeJH9YQc6XGQ5rwRNtiR/7DKqKAxK6i9HayEn67Q FrF5gucBmP1nLymREeOTBN3BJVv2R+AiwHxlfj6FADa2Nd/ycJ/l/I4jujzn8K/oZl IA2hCL9VitFz0fSJ/HYbOn1A9k/f0ir8XkeZOEXo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 64AD03858C27 for ; Sun, 2 Jan 2022 14:16:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64AD03858C27 Received: by mail-pg1-x52f.google.com with SMTP id m15so28156436pgu.11 for ; Sun, 02 Jan 2022 06:16:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=di4ombLYHQiTgE6G2IVD/ENunRASoBLWuV3+7Ftz0fE=; b=guFYhxYzsUaXlDGRunxXy75MIlYFM/Zjmt9MsP7gZUVsJKp7NGJd3C5bWuzGRTEYaO SJ/UHA9hHILsD5sAX8aHCEax1NKw2D+ml0QeYXZKt+0Y3FSktmVWisaecYXHE6Qa0nkd R3DuxDmzdIHVjbgERka6C4zPELkooX++PeekJIDc8BTYbBeAJOSDuyIjH29ZpBEuTpYZ a/XjCs4iaCL3xDjSkQpjHBMWGt5oMMNccYjoGFoEwRAV/bA2yw2SfyuQGmcAPDaDmh5k vf3rMelVh967CR3ZIB5hlehzJmC9KZpYhQOE4n9c9nYkIhVK4eJeKWguQVYLVnyy/0s6 gTLw== X-Gm-Message-State: AOAM532Ny4DRJDxmAhoGzx2IPLxxg4iiD6KM391D9Tc7GRb+zx19EMO6 D0u7vijdke4dEQ8g2Fk+WmMe/fbt0jk= X-Google-Smtp-Source: ABdhPJzKlRF53RG86m7wmCttb4ypfIMhXsuSXBpFdy3g/OzMyxyOUEA3gVxEKpSD9nJWQCHPRkROxQ== X-Received: by 2002:a05:6a00:a8e:b0:4a4:ec38:b66a with SMTP id b14-20020a056a000a8e00b004a4ec38b66amr41987667pfl.7.1641132986155; Sun, 02 Jan 2022 06:16:26 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id ds24sm35473744pjb.36.2022.01.02.06.16.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 06:16:25 -0800 (PST) Received: from gnu-tgl-2.localdomain (gnu-tgl-2 [192.168.1.42]) by gnu-tgl-3.localdomain (Postfix) with ESMTPS id B0723C073B for ; Sun, 2 Jan 2022 06:16:24 -0800 (PST) Received: from gnu-tgl-2.. (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id 95B58300433 for ; Sun, 2 Jan 2022 06:16:23 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH] Properly check linker option in LIBC_LINKER_FEATURE [BZ #28738] Date: Sun, 2 Jan 2022 06:16:23 -0800 Message-Id: <20220102141623.589517-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 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_BARRACUDACENTRAL, 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-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Update LIBC_LINKER_FEATURE to also check linker warning message since unknown linker -z option may be ignored by linker: $ touch x.c $ gcc -shared -Wl,-z,foobar x.c /usr/bin/ld: warning: -z foobar ignored $ echo $? 0 $ This fixes BZ #28738. --- aclocal.m4 | 8 +++++++- configure | 32 ++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 3a90d4f679..3e0bcdd12b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -236,7 +236,13 @@ EOF -fPIC -shared -o conftest.so conftest.c 1>&AS_MESSAGE_LOG_FD]) then - libc_linker_feature=yes + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp $2 -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: $1 ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi fi rm -f conftest* fi diff --git a/configure b/configure index 954bae803e..3f956cf777 100755 --- a/configure +++ b/configure @@ -6009,7 +6009,13 @@ EOF $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then - libc_linker_feature=yes + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,-z,execstack -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: -z execstack ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi fi rm -f conftest* fi @@ -6039,7 +6045,13 @@ EOF $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then - libc_linker_feature=yes + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,-z,start-stop-gc -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: -z start-stop-gc ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi fi rm -f conftest* fi @@ -6070,7 +6082,13 @@ EOF $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then - libc_linker_feature=yes + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,--depaudit,x -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: --depaudit ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi fi rm -f conftest* fi @@ -6101,7 +6119,13 @@ EOF $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then - libc_linker_feature=yes + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,--no-dynamic-linker -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: --no-dynamic-linker ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi fi rm -f conftest* fi