]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld/elf/x86: Don't compare IFUNC address in the shared object
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 16 Jan 2021 15:00:09 +0000 (07:00 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 18 Jan 2021 12:48:04 +0000 (04:48 -0800)
On x86, glibc 2.33 starts to issue a fatal error message when calling
IFUNC function defined in the unrelocated executable from a shared
library.

1. Update x86 ELF linker to always convert IFUNC function defined in
position-dependent executable (PDE) to the normal function.  GOT in PDE
will be updated by R_*_IRELATIVE at run-time.
2. Update PR ld/23169 tests not to compare function address of external
IFUNC function in the shared object to avoid calling the IFUNC function
defined in the unrelocated executable.
3. Remove pr23169e tests which call the IFUNC function defined in the
unrelocated position-independent executable from a shared library.

bfd/

PR ld/23169
* elfxx-x86.c (_bfd_x86_elf_link_fixup_ifunc_symbol): Don't
check pointer_equality_needed.

ld/

PR ld/23169
* testsuite/ld-ifunc/ifunc.exp: Replace pr23169c.rd with
pr23169a.rd for pr23169c and pr23169f.  Remove pr23169e tests.
* testsuite/ld-ifunc/pr23169a.c (foo): Don't compare function
address.

(cherry picked from commit 75a933f39918ce4f4b9481234992895e022787ee)

bfd/ChangeLog
bfd/elfxx-x86.c
ld/ChangeLog
ld/testsuite/ld-ifunc/ifunc.exp
ld/testsuite/ld-ifunc/pr23169a.c

index 0ec715104a1509d9a8b77213cd9a2e6234fb4452..4af18e9bc904bd7aa8b6b165bb047a877f16ef1d 100644 (file)
@@ -1,3 +1,9 @@
+2021-01-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23169
+       * elfxx-x86.c (_bfd_x86_elf_link_fixup_ifunc_symbol): Don't
+       check pointer_equality_needed.
+
 2021-01-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/26688
index 3a0dffc4e6ec4c38e8f52fd83d9e1d9b7341b80f..2688623e7319873939d26d21cb3217ed264a6518 100644 (file)
@@ -1711,8 +1711,7 @@ _bfd_x86_elf_link_fixup_ifunc_symbol (struct bfd_link_info *info,
       && h->def_regular
       && h->dynindx != -1
       && h->plt.offset != (bfd_vma) -1
-      && h->type == STT_GNU_IFUNC
-      && h->pointer_equality_needed)
+      && h->type == STT_GNU_IFUNC)
     {
       asection *plt_s;
       bfd_vma plt_offset;
index 473a065ceb307929e25fc2be555dd9a2bb4dd91d..6bd5477229d6e78e47589fbb17b60f51053fa9b6 100644 (file)
@@ -1,3 +1,11 @@
+2021-01-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23169
+       * testsuite/ld-ifunc/ifunc.exp: Replace pr23169c.rd with
+       pr23169a.rd for pr23169c and pr23169f.  Remove pr23169e tests.
+       * testsuite/ld-ifunc/pr23169a.c (foo): Don't compare function
+       address.
+
 2021-01-14  Nick Clifton  <nickc@redhat.com>
 
        * po/fr.po: Updated French translation.
index 31666d0f29c9986cd1a49b6a0919147b98ce0337..9d3ace6521639383393ad647ad6c63276a806d9e 100644 (file)
@@ -640,7 +640,7 @@ run_cc_link_tests [list \
        "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
        "-fPIE -O2 -g" \
        { pr23169b.c pr23169c.c } \
-       {{readelf {--dyn-syms} pr23169c.rd} \
+       {{readelf {--dyn-syms} pr23169a.rd} \
         {readelf {-r -W} pr23169b.rd}} \
        "pr23169c" \
     ] \
@@ -653,21 +653,12 @@ run_cc_link_tests [list \
         {readelf {-r -W} pr23169b.rd}} \
        "pr23169d" \
     ] \
-    [list \
-       "Build pr23169e" \
-       "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
-       "-fPIE -O2 -g" \
-       { pr23169b.c pr23169c.c } \
-       {{readelf {--dyn-syms} pr23169c.rd} \
-        {readelf {-r -W} pr23169b.rd}} \
-       "pr23169e" \
-    ] \
     [list \
        "Build pr23169f" \
        "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
        "-fPIE -O2 -g" \
        { pr23169b.c pr23169c.c } \
-       {{readelf {--dyn-syms} pr23169c.rd} \
+       {{readelf {--dyn-syms} pr23169a.rd} \
         {readelf {-r -W} pr23169b.rd}} \
        "pr23169f" \
     ] \
@@ -774,15 +765,6 @@ run_ld_link_exec_tests [list \
        "pass.out" \
        "$NOPIE_CFLAGS -O2 -g" \
     ] \
-    [list \
-       "Run pr23169e" \
-       "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
-       "" \
-       { pr23169b.c pr23169c.c } \
-       "pr23169e" \
-       "pass.out" \
-       "-fPIE -O2 -g" \
-    ] \
     [list \
        "Run pr23169f" \
        "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
index 02bf2208904c662549aa6501880501a56fac1408..8beed283bc88d38a19cf6f9ed2ab8f73eb970600 100644 (file)
@@ -4,6 +4,6 @@ extern int func (void);
 void
 foo (void)
 {
-  if (func_p != &func || func_p () != 0xbadbeef)
+  if (func () != 0xbadbeef || func_p () != 0xbadbeef)
     __builtin_abort ();
 }