From: "H.J. Lu" <hjl.tools@gmail.com>
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 [thread overview]
Message-ID: <20220102141623.589517-1-hjl.tools@gmail.com> (raw)
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
--
2.33.1
next reply other threads:[~2022-01-02 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-02 14:16 H.J. Lu [this message]
2022-01-03 11:20 ` Florian Weimer
2022-01-04 18:37 ` Joseph Myers
2022-01-04 18:47 ` [PATCH] Set LC_ALL=C for " H.J. Lu
2022-01-04 21:47 ` [PATCH] Properly check linker option in " Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220102141623.589517-1-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).