]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Check linker support for INSERT in linker script
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 4 Aug 2017 19:17:15 +0000 (12:17 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 4 Aug 2017 19:17:30 +0000 (12:17 -0700)
Since gold doesn't support INSERT in linker script:

https://sourceware.org/bugzilla/show_bug.cgi?id=21676

tst-split-dynreloc fails to link with gold.  Check if linker supports
INSERT in linker script before using it.

* config.make.in (have-insert): New.
* configure.ac (libc_cv_insert): New.  Set to yes if linker
supports INSERT in linker script.
(AC_SUBST(libc_cv_insert): New.
* configure: Regenerated.
* sysdeps/x86_64/Makefile (tests): Add tst-split-dynreloc only
if $(have-insert) == yes.

ChangeLog
config.make.in
configure
configure.ac
sysdeps/x86_64/Makefile

index 33caac763ccd727a0e74b4e01d144c82f33f24d8..cc540a148e8a93cc9d4d7cca6d2a228ac379234c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-08-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config.make.in (have-insert): New.
+       * configure.ac (libc_cv_insert): New.  Set to yes if linker
+       supports INSERT in linker script.
+       (AC_SUBST(libc_cv_insert): New.
+       * configure: Regenerated.
+       * sysdeps/x86_64/Makefile (tests): Add tst-split-dynreloc only
+       if $(have-insert) == yes.
+
 2017-08-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf/Makefile (tests): Add vismain only if
index 5a4a054612acd2272bfdb34309345855b3a15a09..7eff1daf6a86451c13f93a86db6c000c438c2e84 100644 (file)
@@ -54,6 +54,7 @@ enable-werror = @enable_werror@
 have-z-combreloc = @libc_cv_z_combreloc@
 have-z-execstack = @libc_cv_z_execstack@
 have-protected-data = @libc_cv_protected_data@
+have-insert = @libc_cv_insert@
 have-glob-dat-reloc = @libc_cv_has_glob_dat@
 with-fp = @with_fp@
 enable-timezone-tools = @enable_timezone_tools@
index d8e1c50e11183975d123ac5a9ac28ddd2659b934..e6a54d784154b405479e09297b0b8dfbba90d2d4 100755 (executable)
--- a/configure
+++ b/configure
@@ -629,6 +629,7 @@ libc_cv_z_execstack
 libc_cv_z_combreloc
 ASFLAGS_config
 libc_cv_cc_with_libunwind
+libc_cv_insert
 libc_cv_protected_data
 BISON
 INSTALL_INFO
@@ -5716,6 +5717,38 @@ fi
 $as_echo "$libc_cv_protected_data" >&6; }
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker support for INSERT in linker script" >&5
+$as_echo_n "checking linker support for INSERT in linker script... " >&6; }
+if ${libc_cv_insert+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+               const int __attribute__ ((section(".bar"))) bar = 0x12345678;
+               int test (void) { return bar; }
+EOF
+               cat > conftest.t <<EOF
+               SECTIONS
+               {
+                 .bar : { *(.bar) }
+               }
+               INSERT AFTER .rela.dyn;
+EOF
+               libc_cv_insert=no
+               if { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+                 libc_cv_insert=yes
+               fi
+               rm -f conftest.*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_insert" >&5
+$as_echo "$libc_cv_insert" >&6; }
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken __attribute__((alias()))" >&5
 $as_echo_n "checking for broken __attribute__((alias()))... " >&6; }
 if ${libc_cv_broken_alias_attribute+:} false; then :
index 77456aa8d9d35ae557f7cfc4aa98ffd1349e0066..2c6308883c58746fa4923d24a9b39eb43a237fc5 100644 (file)
@@ -1298,6 +1298,27 @@ EOF
               ])
 AC_SUBST(libc_cv_protected_data)
 
+AC_CACHE_CHECK(linker support for INSERT in linker script,
+              libc_cv_insert,
+              [cat > conftest.c <<EOF
+               const int __attribute__ ((section(".bar"))) bar = 0x12345678;
+               int test (void) { return bar; }
+EOF
+               cat > conftest.t <<EOF
+               SECTIONS
+               {
+                 .bar : { *(.bar) }
+               }
+               INSERT AFTER .rela.dyn;
+EOF
+               libc_cv_insert=no
+               if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
+                 libc_cv_insert=yes
+               fi
+               rm -f conftest.*
+              ])
+AC_SUBST(libc_cv_insert)
+
 AC_CACHE_CHECK(for broken __attribute__((alias())),
               libc_cv_broken_alias_attribute,
               [cat > conftest.c <<EOF
index 132470d9cb83c2a56050d4916e6490e85df2e000..7f3ffe34badd42ce909bd2ef5a4d164ba95615c5 100644 (file)
@@ -59,9 +59,11 @@ test-extras += tst-audit4-aux tst-audit10-aux \
 extra-test-objs += tst-audit4-aux.o tst-audit10-aux.o \
                   tst-avx-aux.o tst-avx512-aux.o
 
+ifeq ($(have-insert),yes)
 tests += tst-split-dynreloc
 LDFLAGS-tst-split-dynreloc = -Wl,-T,$(..)sysdeps/x86_64/tst-split-dynreloc.lds
 tst-split-dynreloc-ENV = LD_BIND_NOW=1
+endif
 
 modules-names += tst-auditmod3a tst-auditmod3b \
                tst-auditmod4a tst-auditmod4b \