]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Properly check linker option in LIBC_LINKER_FEATURE [BZ #28738]
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 2 Jan 2022 14:01:21 +0000 (06:01 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 3 Jan 2022 13:12:34 +0000 (05:12 -0800)
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.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
aclocal.m4
configure

index 3a90d4f679a996c22477a7b363c0c2a7b56b8164..3e0bcdd12b77a3f1ae975afe0f7fe8981b753c10 100644 (file)
@@ -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
index 954bae803ede369bd576c2744f237d2e27a2058d..3f956cf777295c6838d17ac01cadd82c71790cdf 100755 (executable)
--- 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