PR 10893
authorIan Lance Taylor <ian@airs.com>
Thu, 19 Aug 2010 22:50:16 +0000 (22:50 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 19 Aug 2010 22:50:16 +0000 (22:50 +0000)
* i386.cc (class Output_data_plt_i386): Update declarations.
Define Global_ifunc and Local_ifunc types.  Add global_ifuncs_ and
local_ifuncs_ fields.
(Target_i386::do_plt_section_for_global): New function.
(Target_i386::do_plt_section_for_local): New function.
(Output_data_plt_i386::Output_data_plt_i386): Add symtab
parameter; change all callers.  Initialize global_ifuncs_ and
local_ifuncs_.  If doing a static link define __rel_iplt_start and
__rel_iplt_end.
(Output_data_plt_i386::add_entry): Handle IFUNC symbols.
(Output_data_plt_i386::add_local_ifunc_entry): New function.
(Output_data_plt_i386::do_write): Fix GOT entries for IFUNC
symbols.
(Target_i386::make_plt_section): New function, broken out of
make_plt_entry.  Set sh_info field of .rel.plt to point to .plt.
(Target_i386::make_plt_entry): Call make_plt_section.
(Target_i386::make_local_ifunc_plt_entry): New function.
(Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function.
(Target_i386::Scan::local): Handle IFUNC symbols.  Add
R_386_IRELATIVE to switch.
(Target_i386::Scan::global): Likewise.
(Target_i386::Relocate::relocate): Likewise.
(Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to
switch.
* x86_64.cc (class Output_data_plt_x86_64): Update declarations.
(Target_x86_64::do_plt_section_for_global): New function.
(Target_x86_64::do_plt_section_for_local): New function.
(Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab
parameter; change all callers.  If doing a static link define
__rela_iplt_start and __rela_iplt_end.
(Output_data_plt_x86_64::add_entry): Handle IFUNC symbols.
(Output_data_plt_x86_64::add_local_ifunc_entry): New function.
(Target_x86_64::make_plt_section): Set sh_info field of .rel.plt
to point to .plt.
(Target_x86_64::make_local_ifunc_plt_entry): New function.
(Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to
switch.
(Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function.
(Target_x86_64::Scan::local): Handle IFUNC symbols.  Add
R_X86_64_IRELATIVE to switch.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
(Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to
switch.
* target.h (class Target): Add plt_section_for_global and
plt_section_for_local functions.  Add do_plt_section_for_global
and do_plt_section_for_local virtual functions.
* symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol.  Add
clarifying comments.
(Symbol::use_plt_offset): Handle IFUNC symbol.
* object.cc (Sized_relobj::Sized_relobj): Initialize
local_plt_offsets_.
(Sized_relobj::local_has_plt_offset): New function.
(Sized_relobj::local_plt_offset): New function.
(Sized_relobj::set_local_plt_offset): New function.
(Sized_relobj::do_count): Handle IFUNC symbol.
* object.h (class Symbol_value): Add is_ifunc_symbol_ field.  Take
a bit away from input_shndx_ field.  Add set_is_func_symbol and
is_ifunc_symbol functions.
(class Sized_relobj): Update declarations.  Remove Tls_got_entry
and Local_tls_got_offsets.  Define Local_plt_offsets.  Add
local_plt_offsets_ field.
(Sized_relobj::clear_local_symbols): Clear local_plt_offsets_.
* output.h (class Output_section_data): Add non-const
output_section function.
(class Output_data_got): Update declarations.
(class Output_data_got::Got_entry): Add use_plt_offset_ field.
Add use_plt_offset parameter to global and local constructors.
Change all callers.  Change local_sym_index_ field to 31 bits.
Change GSYM_CODE and CONSTANT_CODE accordingly.
* output.cc (Output_data_reloc_base::do_adjust_output_section): If
doing a static link don't set sh_link field.
(Output_data_got::Got_entry::write): Use PLT offset if
appropriate.
(Output_data_got::add_global_plt): New function.
(Output_data_got::add_local_plt): New function.
* target-reloc.h (relocate_section): Handle IFUNC symbol.
* defstd.cc (in_section): Remove entries for __rel_iplt_start,
__rel_iplt_end, __rela_iplt_start, and __rela_iplt_end.
* configure.ac: Set IFUNC automake conditional for glibc >= 2.11.
* testsuite/Makefile.am: Add a bunch of IFUNC tests, all within
IFUNC conditional.
* testsuite/ifunc-sel.h: New file.
* testsuite/ifuncmain1.c: New file.
* testsuite/ifuncmain1vis.c: New file.
* testsuite/ifuncmod1.c: New file.
* testsuite/ifuncdep2.c: New file.
* testsuite/ifuncmain2.c: New file.
* testsuite/ifuncmain3.c: New file.
* testsuite/ifuncmod3.c: New file.
* testsuite/ifuncmain4.c: New file.
* testsuite/ifuncmain5.c: New file.
* testsuite/ifuncmod5.c: New file.
* testsuite/ifuncmain6pie.c: New file.
* testsuite/ifuncmod6.c: New file.
* testsuite/ifuncmain7.c: New file.
* configure, testsuite/Makefile.in: Rebuild.

29 files changed:
gold/ChangeLog
gold/configure
gold/configure.ac
gold/defstd.cc
gold/i386.cc
gold/object.cc
gold/object.h
gold/output.cc
gold/output.h
gold/symtab.h
gold/target-reloc.h
gold/target.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/ifunc-sel.h [new file with mode: 0644]
gold/testsuite/ifuncdep2.c [new file with mode: 0644]
gold/testsuite/ifuncmain1.c [new file with mode: 0644]
gold/testsuite/ifuncmain1vis.c [new file with mode: 0644]
gold/testsuite/ifuncmain2.c [new file with mode: 0644]
gold/testsuite/ifuncmain3.c [new file with mode: 0644]
gold/testsuite/ifuncmain4.c [new file with mode: 0644]
gold/testsuite/ifuncmain5.c [new file with mode: 0644]
gold/testsuite/ifuncmain6pie.c [new file with mode: 0644]
gold/testsuite/ifuncmain7.c [new file with mode: 0644]
gold/testsuite/ifuncmod1.c [new file with mode: 0644]
gold/testsuite/ifuncmod3.c [new file with mode: 0644]
gold/testsuite/ifuncmod5.c [new file with mode: 0644]
gold/testsuite/ifuncmod6.c [new file with mode: 0644]
gold/x86_64.cc

index 8b600b2a2dffdcaa3f1add096527bad11500028e..83eef92a373a05d103b6ea042cea7478663ba891 100644 (file)
@@ -1,3 +1,104 @@
+2010-08-19  Ian Lance Taylor  <iant@google.com>
+
+       PR 10893
+       * i386.cc (class Output_data_plt_i386): Update declarations.
+       Define Global_ifunc and Local_ifunc types.  Add global_ifuncs_ and
+       local_ifuncs_ fields.
+       (Target_i386::do_plt_section_for_global): New function.
+       (Target_i386::do_plt_section_for_local): New function.
+       (Output_data_plt_i386::Output_data_plt_i386): Add symtab
+       parameter; change all callers.  Initialize global_ifuncs_ and
+       local_ifuncs_.  If doing a static link define __rel_iplt_start and
+       __rel_iplt_end.
+       (Output_data_plt_i386::add_entry): Handle IFUNC symbols.
+       (Output_data_plt_i386::add_local_ifunc_entry): New function.
+       (Output_data_plt_i386::do_write): Fix GOT entries for IFUNC
+       symbols.
+       (Target_i386::make_plt_section): New function, broken out of
+       make_plt_entry.  Set sh_info field of .rel.plt to point to .plt.
+       (Target_i386::make_plt_entry): Call make_plt_section.
+       (Target_i386::make_local_ifunc_plt_entry): New function.
+       (Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function.
+       (Target_i386::Scan::local): Handle IFUNC symbols.  Add
+       R_386_IRELATIVE to switch.
+       (Target_i386::Scan::global): Likewise.
+       (Target_i386::Relocate::relocate): Likewise.
+       (Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to
+       switch.
+       * x86_64.cc (class Output_data_plt_x86_64): Update declarations.
+       (Target_x86_64::do_plt_section_for_global): New function.
+       (Target_x86_64::do_plt_section_for_local): New function.
+       (Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab
+       parameter; change all callers.  If doing a static link define
+       __rela_iplt_start and __rela_iplt_end.
+       (Output_data_plt_x86_64::add_entry): Handle IFUNC symbols.
+       (Output_data_plt_x86_64::add_local_ifunc_entry): New function.
+       (Target_x86_64::make_plt_section): Set sh_info field of .rel.plt
+       to point to .plt.
+       (Target_x86_64::make_local_ifunc_plt_entry): New function.
+       (Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to
+       switch.
+       (Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function.
+       (Target_x86_64::Scan::local): Handle IFUNC symbols.  Add
+       R_X86_64_IRELATIVE to switch.
+       (Target_x86_64::Scan::global): Likewise.
+       (Target_x86_64::Relocate::relocate): Likewise.
+       (Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to
+       switch.
+       * target.h (class Target): Add plt_section_for_global and
+       plt_section_for_local functions.  Add do_plt_section_for_global
+       and do_plt_section_for_local virtual functions.
+       * symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol.  Add
+       clarifying comments.
+       (Symbol::use_plt_offset): Handle IFUNC symbol.
+       * object.cc (Sized_relobj::Sized_relobj): Initialize
+       local_plt_offsets_.
+       (Sized_relobj::local_has_plt_offset): New function.
+       (Sized_relobj::local_plt_offset): New function.
+       (Sized_relobj::set_local_plt_offset): New function.
+       (Sized_relobj::do_count): Handle IFUNC symbol.
+       * object.h (class Symbol_value): Add is_ifunc_symbol_ field.  Take
+       a bit away from input_shndx_ field.  Add set_is_func_symbol and
+       is_ifunc_symbol functions.
+       (class Sized_relobj): Update declarations.  Remove Tls_got_entry
+       and Local_tls_got_offsets.  Define Local_plt_offsets.  Add
+       local_plt_offsets_ field.
+       (Sized_relobj::clear_local_symbols): Clear local_plt_offsets_.
+       * output.h (class Output_section_data): Add non-const
+       output_section function.
+       (class Output_data_got): Update declarations.
+       (class Output_data_got::Got_entry): Add use_plt_offset_ field.
+       Add use_plt_offset parameter to global and local constructors.
+       Change all callers.  Change local_sym_index_ field to 31 bits.
+       Change GSYM_CODE and CONSTANT_CODE accordingly.
+       * output.cc (Output_data_reloc_base::do_adjust_output_section): If
+       doing a static link don't set sh_link field.
+       (Output_data_got::Got_entry::write): Use PLT offset if
+       appropriate.
+       (Output_data_got::add_global_plt): New function.
+       (Output_data_got::add_local_plt): New function.
+       * target-reloc.h (relocate_section): Handle IFUNC symbol.
+       * defstd.cc (in_section): Remove entries for __rel_iplt_start,
+       __rel_iplt_end, __rela_iplt_start, and __rela_iplt_end.
+       * configure.ac: Set IFUNC automake conditional for glibc >= 2.11.
+       * testsuite/Makefile.am: Add a bunch of IFUNC tests, all within
+       IFUNC conditional.
+       * testsuite/ifunc-sel.h: New file.
+       * testsuite/ifuncmain1.c: New file.
+       * testsuite/ifuncmain1vis.c: New file.
+       * testsuite/ifuncmod1.c: New file.
+       * testsuite/ifuncdep2.c: New file.
+       * testsuite/ifuncmain2.c: New file.
+       * testsuite/ifuncmain3.c: New file.
+       * testsuite/ifuncmod3.c: New file.
+       * testsuite/ifuncmain4.c: New file.
+       * testsuite/ifuncmain5.c: New file.
+       * testsuite/ifuncmod5.c: New file.
+       * testsuite/ifuncmain6pie.c: New file.
+       * testsuite/ifuncmod6.c: New file.
+       * testsuite/ifuncmain7.c: New file.
+       * configure, testsuite/Makefile.in: Rebuild.
+
 2010-08-18  Ian Lance Taylor  <iant@google.com>
 
        * incremental.cc
index eb8f01ed7b9182b55eff912e234fca30652ae4ac..0259c2fe59df8874e4c02af461d9713cceb10b90 100755 (executable)
@@ -602,6 +602,8 @@ LFS_CFLAGS
 WARN_CXXFLAGS
 NO_WERROR
 WARN_CFLAGS
+IFUNC_FALSE
+IFUNC_TRUE
 RANDOM_SEED_CFLAGS
 CONSTRUCTOR_PRIORITY_FALSE
 CONSTRUCTOR_PRIORITY_TRUE
@@ -1913,8 +1915,10 @@ $as_echo "$ac_res" >&6; }
 ac_fn_c_check_decl ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
-$as_echo_n "checking whether $2 is declared... " >&6; }
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -1924,8 +1928,12 @@ $4
 int
 main ()
 {
-#ifndef $2
-  (void) $2;
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
 #endif
 
   ;
@@ -2189,8 +2197,10 @@ $as_echo "$ac_res" >&6; }
 ac_fn_cxx_check_decl ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
-$as_echo_n "checking whether $2 is declared... " >&6; }
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
@@ -2200,8 +2210,12 @@ $4
 int
 main ()
 {
-#ifndef $2
-  (void) $2;
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
 #endif
 
   ;
@@ -6335,6 +6349,41 @@ if test "$gold_cv_c_random_seed" = "yes"; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for glibc >= 2.11" >&5
+$as_echo_n "checking for glibc >= 2.11... " >&6; }
+if test "${gold_cv_lib_glibc2_11+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#if !defined __GLIBC__
+error
+#elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11)
+error
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gold_cv_lib_glibc2_11=yes
+else
+  gold_cv_lib_glibc2_11=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gold_cv_lib_glibc2_11" >&5
+$as_echo "$gold_cv_lib_glibc2_11" >&6; }
+
+ if test "$gold_cv_lib_glibc2_11" = "yes"; then
+  IFUNC_TRUE=
+  IFUNC_FALSE='#'
+else
+  IFUNC_TRUE='#'
+  IFUNC_FALSE=
+fi
+
+
 
 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7206,6 +7255,10 @@ if test -z "${CONSTRUCTOR_PRIORITY_TRUE}" && test -z "${CONSTRUCTOR_PRIORITY_FAL
   as_fn_error "conditional \"CONSTRUCTOR_PRIORITY\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${IFUNC_TRUE}" && test -z "${IFUNC_FALSE}"; then
+  as_fn_error "conditional \"IFUNC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HAVE_ZLIB_TRUE}" && test -z "${HAVE_ZLIB_FALSE}"; then
   as_fn_error "conditional \"HAVE_ZLIB\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
index f1c4378e229ee0f500d435dc391a73d39d381f4e..ba6bd172353c838b42b3120038c1dccaecdb50d4 100644 (file)
@@ -359,6 +359,20 @@ if test "$gold_cv_c_random_seed" = "yes"; then
 fi
 AC_SUBST(RANDOM_SEED_CFLAGS)
 
+dnl On GNU/Linux ifunc is supported by the dynamic linker in glibc
+dnl 2.11 or later.
+AC_CACHE_CHECK([for glibc >= 2.11], [gold_cv_lib_glibc2_11],
+[AC_COMPILE_IFELSE([
+#include <features.h>
+#if !defined __GLIBC__
+error
+#elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11)
+error
+#endif
+], [gold_cv_lib_glibc2_11=yes], [gold_cv_lib_glibc2_11=no])])
+
+AM_CONDITIONAL(IFUNC, test "$gold_cv_lib_glibc2_11" = "yes")
+
 AM_BINUTILS_WARNINGS
 
 WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//' -e 's/-Wshadow//'`
index e09d8142ba74e9b574b6d3885f12a50b3ae0f73d..a7a57e44f560a505992a5fec99c92cda2443574a 100644 (file)
@@ -1,6 +1,6 @@
 // defstd.cc -- define standard symbols for gold.
 
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -108,54 +108,6 @@ const Define_symbol_in_section in_section[] =
     true,                      // offset_is_from_end
     true                       // only_if_ref
   },
-  {
-    "__rel_iplt_start",                // name
-    ".rel.iplt",               // output_section
-    0,                         // value
-    0,                         // size
-    elfcpp::STT_NOTYPE,                // type
-    elfcpp::STB_GLOBAL,                // binding
-    elfcpp::STV_HIDDEN,                // visibility
-    0,                         // nonvis
-    false,                     // offset_is_from_end
-    true                       // only_if_ref
-  },
-  {
-    "__rel_iplt_end",          // name
-    ".rel.iplt",               // output_section
-    0,                         // value
-    0,                         // size
-    elfcpp::STT_NOTYPE,                // type
-    elfcpp::STB_GLOBAL,                // binding
-    elfcpp::STV_HIDDEN,                // visibility
-    0,                         // nonvis
-    true,                      // offset_is_from_end
-    true                       // only_if_ref
-  },
-  {
-    "__rela_iplt_start",       // name
-    ".rela.iplt",              // output_section
-    0,                         // value
-    0,                         // size
-    elfcpp::STT_NOTYPE,                // type
-    elfcpp::STB_GLOBAL,                // binding
-    elfcpp::STV_HIDDEN,                // visibility
-    0,                         // nonvis
-    false,                     // offset_is_from_end
-    true                       // only_if_ref
-  },
-  {
-    "__rela_iplt_end",         // name
-    ".rela.iplt",              // output_section
-    0,                         // value
-    0,                         // size
-    elfcpp::STT_NOTYPE,                // type
-    elfcpp::STB_GLOBAL,                // binding
-    elfcpp::STV_HIDDEN,                // visibility
-    0,                         // nonvis
-    true,                      // offset_is_from_end
-    true                       // only_if_ref
-  },
   {
     "__stack",                 // name
     ".stack",                  // output_section
index b27296769a7dd825332852f2ca296f8e0035d1d1..56d405bc8a8fecdeb6953b349a4d271940aa8c75 100644 (file)
@@ -45,7 +45,113 @@ namespace
 
 using namespace gold;
 
-class Output_data_plt_i386;
+// A class to handle the PLT data.
+
+class Output_data_plt_i386 : public Output_section_data
+{
+ public:
+  typedef Output_data_reloc<elfcpp::SHT_REL, true, 32, false> Reloc_section;
+
+  Output_data_plt_i386(Symbol_table*, Layout*, Output_data_space*);
+
+  // Add an entry to the PLT.
+  void
+  add_entry(Symbol* gsym);
+
+  // Add an entry to the PLT for a local STT_GNU_IFUNC symbol.
+  unsigned int
+  add_local_ifunc_entry(Sized_relobj<32, false>* relobj,
+                       unsigned int local_sym_index);
+
+  // Return the .rel.plt section data.
+  Reloc_section*
+  rel_plt() const
+  { return this->rel_; }
+
+  // Return where the TLS_DESC relocations should go.
+  Reloc_section*
+  rel_tls_desc(Layout*);
+
+  // Return the number of PLT entries.
+  unsigned int
+  entry_count() const
+  { return this->count_; }
+
+  // Return the offset of the first non-reserved PLT entry.
+  static unsigned int
+  first_plt_entry_offset()
+  { return plt_entry_size; }
+
+  // Return the size of a PLT entry.
+  static unsigned int
+  get_plt_entry_size()
+  { return plt_entry_size; }
+
+ protected:
+  void
+  do_adjust_output_section(Output_section* os);
+
+  // Write to a map file.
+  void
+  do_print_to_mapfile(Mapfile* mapfile) const
+  { mapfile->print_output_data(this, _("** PLT")); }
+
+ private:
+  // The size of an entry in the PLT.
+  static const int plt_entry_size = 16;
+
+  // The first entry in the PLT for an executable.
+  static unsigned char exec_first_plt_entry[plt_entry_size];
+
+  // The first entry in the PLT for a shared object.
+  static unsigned char dyn_first_plt_entry[plt_entry_size];
+
+  // Other entries in the PLT for an executable.
+  static unsigned char exec_plt_entry[plt_entry_size];
+
+  // Other entries in the PLT for a shared object.
+  static unsigned char dyn_plt_entry[plt_entry_size];
+
+  // Set the final size.
+  void
+  set_final_data_size()
+  { this->set_data_size((this->count_ + 1) * plt_entry_size); }
+
+  // Write out the PLT data.
+  void
+  do_write(Output_file*);
+
+  // We keep a list of global STT_GNU_IFUNC symbols, each with its
+  // offset in the GOT.
+  struct Global_ifunc
+  {
+    Symbol* sym;
+    unsigned int got_offset;
+  };
+
+  // We keep a list of local STT_GNU_IFUNC symbols, each with its
+  // offset in the GOT.
+  struct Local_ifunc
+  {
+    Sized_relobj<32, false>* object;
+    unsigned int local_sym_index;
+    unsigned int got_offset;
+  };
+
+  // The reloc section.
+  Reloc_section* rel_;
+  // The TLS_DESC relocations, if necessary.  These must follow the
+  // regular PLT relocs.
+  Reloc_section* tls_desc_rel_;
+  // The .got.plt section.
+  Output_data_space* got_plt_;
+  // The number of PLT entries.
+  unsigned int count_;
+  // Global STT_GNU_IFUNC symbols.
+  std::vector<Global_ifunc> global_ifuncs_;
+  // Local STT_GNU_IFUNC symbols.
+  std::vector<Local_ifunc> local_ifuncs_;
+};
 
 // The i386 target class.
 // TLS info comes from
@@ -172,6 +278,15 @@ class Target_i386 : public Target_freebsd<32, false>
     return Target::do_is_local_label_name(name);
   }
 
+  // Return the PLT section.
+  Output_data*
+  do_plt_section_for_global(const Symbol*) const
+  { return this->plt_section(); }
+
+  Output_data*
+  do_plt_section_for_local(const Relobj*, unsigned int) const
+  { return this->plt_section(); }
+
   // Return whether SYM is call to a non-split function.
   bool
   do_is_call_to_non_split(const Symbol* sym, unsigned int) const;
@@ -255,6 +370,9 @@ class Target_i386 : public Target_freebsd<32, false>
     inline bool
     possible_function_pointer_reloc(unsigned int r_type);
 
+    bool
+    reloc_needs_plt_for_ifunc(Sized_relobj<32, false>*, unsigned int r_type);
+
     static void
     unsupported_reloc_local(Sized_relobj<32, false>*, unsigned int r_type);
 
@@ -415,10 +533,20 @@ class Target_i386 : public Target_freebsd<32, false>
     return this->got_tlsdesc_;
   }
 
+  // Create the PLT section.
+  void
+  make_plt_section(Symbol_table* symtab, Layout* layout);
+
   // Create a PLT entry for a global symbol.
   void
   make_plt_entry(Symbol_table*, Layout*, Symbol*);
 
+  // Create a PLT entry for a local STT_GNU_IFUNC symbol.
+  void
+  make_local_ifunc_plt_entry(Symbol_table*, Layout*,
+                            Sized_relobj<32, false>* relobj,
+                            unsigned int local_sym_index);
+
   // Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
   void
   define_tls_base_symbol(Symbol_table*, Layout*);
@@ -586,100 +714,38 @@ Target_i386::rel_dyn_section(Layout* layout)
   return this->rel_dyn_;
 }
 
-// A class to handle the PLT data.
-
-class Output_data_plt_i386 : public Output_section_data
-{
- public:
-  typedef Output_data_reloc<elfcpp::SHT_REL, true, 32, false> Reloc_section;
-
-  Output_data_plt_i386(Layout*, Output_data_space*);
-
-  // Add an entry to the PLT.
-  void
-  add_entry(Symbol* gsym);
-
-  // Return the .rel.plt section data.
-  const Reloc_section*
-  rel_plt() const
-  { return this->rel_; }
-
-  // Return where the TLS_DESC relocations should go.
-  Reloc_section*
-  rel_tls_desc(Layout*);
-
-  // Return the number of PLT entries.
-  unsigned int
-  entry_count() const
-  { return this->count_; }
-
-  // Return the offset of the first non-reserved PLT entry.
-  static unsigned int
-  first_plt_entry_offset()
-  { return plt_entry_size; }
-
-  // Return the size of a PLT entry.
-  static unsigned int
-  get_plt_entry_size()
-  { return plt_entry_size; }
-
- protected:
-  void
-  do_adjust_output_section(Output_section* os);
-
-  // Write to a map file.
-  void
-  do_print_to_mapfile(Mapfile* mapfile) const
-  { mapfile->print_output_data(this, _("** PLT")); }
-
- private:
-  // The size of an entry in the PLT.
-  static const int plt_entry_size = 16;
-
-  // The first entry in the PLT for an executable.
-  static unsigned char exec_first_plt_entry[plt_entry_size];
-
-  // The first entry in the PLT for a shared object.
-  static unsigned char dyn_first_plt_entry[plt_entry_size];
-
-  // Other entries in the PLT for an executable.
-  static unsigned char exec_plt_entry[plt_entry_size];
-
-  // Other entries in the PLT for a shared object.
-  static unsigned char dyn_plt_entry[plt_entry_size];
-
-  // Set the final size.
-  void
-  set_final_data_size()
-  { this->set_data_size((this->count_ + 1) * plt_entry_size); }
-
-  // Write out the PLT data.
-  void
-  do_write(Output_file*);
-
-  // The reloc section.
-  Reloc_section* rel_;
-  // The TLS_DESC relocations, if necessary.  These must follow the
-  // regular PLT relocs.
-  Reloc_section* tls_desc_rel_;
-  // The .got.plt section.
-  Output_data_space* got_plt_;
-  // The number of PLT entries.
-  unsigned int count_;
-};
-
 // Create the PLT section.  The ordinary .got section is an argument,
 // since we need to refer to the start.  We also create our own .got
 // section just for PLT entries.
 
-Output_data_plt_i386::Output_data_plt_i386(Layout* layout,
+Output_data_plt_i386::Output_data_plt_i386(Symbol_table* symtab,
+                                          Layout* layout,
                                           Output_data_space* got_plt)
-  : Output_section_data(4), tls_desc_rel_(NULL), got_plt_(got_plt), count_(0)
+  : Output_section_data(4), tls_desc_rel_(NULL), got_plt_(got_plt), count_(0),
+    global_ifuncs_(), local_ifuncs_()
 {
   this->rel_ = new Reloc_section(false);
   layout->add_output_section_data(".rel.plt", elfcpp::SHT_REL,
                                  elfcpp::SHF_ALLOC, this->rel_,
                                  ORDER_DYNAMIC_PLT_RELOCS, false);
+
+  if (parameters->doing_static_link())
+    {
+      // A statically linked executable will only have a .rel.plt
+      // section to hold R_386_IRELATIVE relocs for STT_GNU_IFUNC
+      // symbols.  The library will use these symbols to locate the
+      // IRELATIVE relocs at program startup time.
+      symtab->define_in_output_data("__rel_iplt_start", NULL,
+                                   Symbol_table::PREDEFINED,
+                                   this->rel_, 0, 0, elfcpp::STT_NOTYPE,
+                                   elfcpp::STB_GLOBAL, elfcpp::STV_HIDDEN,
+                                   0, false, true);
+      symtab->define_in_output_data("__rel_iplt_end", NULL,
+                                   Symbol_table::PREDEFINED,
+                                   this->rel_, 0, 0, elfcpp::STT_NOTYPE,
+                                   elfcpp::STB_GLOBAL, elfcpp::STV_HIDDEN,
+                                   0, true, true);
+    }
 }
 
 void
@@ -711,15 +777,58 @@ Output_data_plt_i386::add_entry(Symbol* gsym)
   this->got_plt_->set_current_data_size(got_offset + 4);
 
   // Every PLT entry needs a reloc.
-  gsym->set_needs_dynsym_entry();
-  this->rel_->add_global(gsym, elfcpp::R_386_JUMP_SLOT, this->got_plt_,
-                        got_offset);
+  if (gsym->type() == elfcpp::STT_GNU_IFUNC
+      && gsym->can_use_relative_reloc(false))
+    {
+      this->rel_->add_symbolless_global_addend(gsym, elfcpp::R_386_IRELATIVE,
+                                              this->got_plt_, got_offset);
+      struct Global_ifunc gi;
+      gi.sym = gsym;
+      gi.got_offset = got_offset;
+      this->global_ifuncs_.push_back(gi);
+    }
+  else
+    {
+      gsym->set_needs_dynsym_entry();
+      this->rel_->add_global(gsym, elfcpp::R_386_JUMP_SLOT, this->got_plt_,
+                            got_offset);
+    }
 
   // Note that we don't need to save the symbol.  The contents of the
   // PLT are independent of which symbols are used.  The symbols only
   // appear in the relocations.
 }
 
+// Add an entry to the PLT for a local STT_GNU_IFUNC symbol.  Return
+// the PLT offset.
+
+unsigned int
+Output_data_plt_i386::add_local_ifunc_entry(Sized_relobj<32, false>* relobj,
+                                           unsigned int local_sym_index)
+{
+  unsigned int plt_offset = (this->count_ + 1) * plt_entry_size;
+  ++this->count_;
+
+  section_offset_type got_offset = this->got_plt_->current_data_size();
+
+  // Every PLT entry needs a GOT entry which points back to the PLT
+  // entry.
+  this->got_plt_->set_current_data_size(got_offset + 4);
+
+  // Every PLT entry needs a reloc.
+  this->rel_->add_symbolless_local_addend(relobj, local_sym_index,
+                                         elfcpp::R_386_IRELATIVE,
+                                         this->got_plt_, got_offset);
+
+  struct Local_ifunc li;
+  li.object = relobj;
+  li.local_sym_index = local_sym_index;
+  li.got_offset = got_offset;
+  this->local_ifuncs_.push_back(li);
+
+  return plt_offset;
+}
+
 // Return where the TLS_DESC relocations should go, creating it if
 // necessary. These follow the JUMP_SLOT relocations.
 
@@ -858,6 +967,32 @@ Output_data_plt_i386::do_write(Output_file* of)
       elfcpp::Swap<32, false>::writeval(got_pov, plt_address + plt_offset + 6);
     }
 
+  // If any STT_GNU_IFUNC symbols have PLT entries, we need to change
+  // the GOT to point to the actual symbol value, rather than point to
+  // the PLT entry.  That will let the dynamic linker call the right
+  // function when resolving IRELATIVE relocations.
+  for (std::vector<Global_ifunc>::const_iterator p =
+        this->global_ifuncs_.begin();
+       p != this->global_ifuncs_.end();
+       ++p)
+    {
+      const Sized_symbol<32>* ssym =
+       static_cast<const Sized_symbol<32>*>(p->sym);
+      elfcpp::Swap<32, false>::writeval(got_view + p->got_offset,
+                                       ssym->value());
+    }
+
+  for (std::vector<Local_ifunc>::const_iterator p =
+        this->local_ifuncs_.begin();
+       p != this->local_ifuncs_.end();
+       ++p)
+    {
+      const Symbol_value<32>* psymval =
+       p->object->local_symbol(p->local_sym_index);
+      elfcpp::Swap<32, false>::writeval(got_view + p->got_offset,
+                                       psymval->value(p->object, 0));
+    }
+
   gold_assert(static_cast<section_size_type>(pov - oview) == oview_size);
   gold_assert(static_cast<section_size_type>(got_pov - got_view) == got_size);
 
@@ -865,29 +1000,56 @@ Output_data_plt_i386::do_write(Output_file* of)
   of->write_output_view(got_file_offset, got_size, got_view);
 }
 
-// Create a PLT entry for a global symbol.
+// Create the PLT section.
 
 void
-Target_i386::make_plt_entry(Symbol_table* symtab, Layout* layout, Symbol* gsym)
+Target_i386::make_plt_section(Symbol_table* symtab, Layout* layout)
 {
-  if (gsym->has_plt_offset())
-    return;
-
   if (this->plt_ == NULL)
     {
       // Create the GOT sections first.
       this->got_section(symtab, layout);
 
-      this->plt_ = new Output_data_plt_i386(layout, this->got_plt_);
+      this->plt_ = new Output_data_plt_i386(symtab, layout, this->got_plt_);
       layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
                                      (elfcpp::SHF_ALLOC
                                       | elfcpp::SHF_EXECINSTR),
                                      this->plt_, ORDER_PLT, false);
+
+      // Make the sh_info field of .rel.plt point to .plt.
+      Output_section* rel_plt_os = this->plt_->rel_plt()->output_section();
+      rel_plt_os->set_info_section(this->plt_->output_section());
     }
+}
+
+// Create a PLT entry for a global symbol.
 
+void
+Target_i386::make_plt_entry(Symbol_table* symtab, Layout* layout, Symbol* gsym)
+{
+  if (gsym->has_plt_offset())
+    return;
+  if (this->plt_ == NULL)
+    this->make_plt_section(symtab, layout);
   this->plt_->add_entry(gsym);
 }
 
+// Make a PLT entry for a local STT_GNU_IFUNC symbol.
+
+void
+Target_i386::make_local_ifunc_plt_entry(Symbol_table* symtab, Layout* layout,
+                                       Sized_relobj<32, false>* relobj,
+                                       unsigned int local_sym_index)
+{
+  if (relobj->local_has_plt_offset(local_sym_index))
+    return;
+  if (this->plt_ == NULL)
+    this->make_plt_section(symtab, layout);
+  unsigned int plt_offset = this->plt_->add_local_ifunc_entry(relobj,
+                                                             local_sym_index);
+  relobj->set_local_plt_offset(local_sym_index, plt_offset);
+}
+
 // Return the number of entries in the PLT.
 
 unsigned int
@@ -1035,6 +1197,75 @@ Target_i386::Scan::unsupported_reloc_local(Sized_relobj<32, false>* object,
             object->name().c_str(), r_type);
 }
 
+// Return whether we need to make a PLT entry for a relocation of a
+// given type against a STT_GNU_IFUNC symbol.
+
+bool
+Target_i386::Scan::reloc_needs_plt_for_ifunc(Sized_relobj<32, false>* object,
+                                            unsigned int r_type)
+{
+  switch (r_type)
+    {
+    case elfcpp::R_386_NONE:
+    case elfcpp::R_386_GNU_VTINHERIT:
+    case elfcpp::R_386_GNU_VTENTRY:
+      return false;
+
+    case elfcpp::R_386_32:
+    case elfcpp::R_386_16:
+    case elfcpp::R_386_8:
+    case elfcpp::R_386_PC32:
+    case elfcpp::R_386_PC16:
+    case elfcpp::R_386_PC8:
+    case elfcpp::R_386_PLT32:
+    case elfcpp::R_386_GOTOFF:
+    case elfcpp::R_386_GOTPC:
+    case elfcpp::R_386_GOT32:
+      return true;
+
+    case elfcpp::R_386_COPY:
+    case elfcpp::R_386_GLOB_DAT:
+    case elfcpp::R_386_JUMP_SLOT:
+    case elfcpp::R_386_RELATIVE:
+    case elfcpp::R_386_IRELATIVE:
+    case elfcpp::R_386_TLS_TPOFF:
+    case elfcpp::R_386_TLS_DTPMOD32:
+    case elfcpp::R_386_TLS_DTPOFF32:
+    case elfcpp::R_386_TLS_TPOFF32:
+    case elfcpp::R_386_TLS_DESC:
+      // We will give an error later.
+      return false;
+
+    case elfcpp::R_386_TLS_GD:
+    case elfcpp::R_386_TLS_GOTDESC:
+    case elfcpp::R_386_TLS_DESC_CALL:
+    case elfcpp::R_386_TLS_LDM:
+    case elfcpp::R_386_TLS_LDO_32:
+    case elfcpp::R_386_TLS_IE:
+    case elfcpp::R_386_TLS_IE_32:
+    case elfcpp::R_386_TLS_GOTIE:
+    case elfcpp::R_386_TLS_LE:
+    case elfcpp::R_386_TLS_LE_32:
+      gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
+                object->name().c_str(), r_type);
+      return false;
+
+    case elfcpp::R_386_32PLT:
+    case elfcpp::R_386_TLS_GD_32:
+    case elfcpp::R_386_TLS_GD_PUSH:
+    case elfcpp::R_386_TLS_GD_CALL:
+    case elfcpp::R_386_TLS_GD_POP:
+    case elfcpp::R_386_TLS_LDM_32:
+    case elfcpp::R_386_TLS_LDM_PUSH:
+    case elfcpp::R_386_TLS_LDM_CALL:
+    case elfcpp::R_386_TLS_LDM_POP:
+    case elfcpp::R_386_USED_BY_INTEL_200:
+    default:
+      // We will give an error later.
+      return false;
+    }
+}
+
 // Scan a relocation for a local symbol.
 
 inline void
@@ -1048,6 +1279,14 @@ Target_i386::Scan::local(Symbol_table* symtab,
                         unsigned int r_type,
                         const elfcpp::Sym<32, false>& lsym)
 {
+  // A local STT_GNU_IFUNC symbol may require a PLT entry.
+  if (lsym.get_st_type() == elfcpp::STT_GNU_IFUNC
+      && this->reloc_needs_plt_for_ifunc(object, r_type))
+    {
+      unsigned int r_sym = elfcpp::elf_r_sym<32>(reloc.get_r_info());
+      target->make_local_ifunc_plt_entry(symtab, layout, object, r_sym);
+    }
+
   switch (r_type)
     {
     case elfcpp::R_386_NONE:
@@ -1066,9 +1305,9 @@ Target_i386::Scan::local(Symbol_table* symtab,
         {
           Reloc_section* rel_dyn = target->rel_dyn_section(layout);
           unsigned int r_sym = elfcpp::elf_r_sym<32>(reloc.get_r_info());
-          rel_dyn->add_local_relative(object, r_sym, elfcpp::R_386_RELATIVE,
-                                      output_section, data_shndx,
-                                      reloc.get_r_offset());
+         rel_dyn->add_local_relative(object, r_sym, elfcpp::R_386_RELATIVE,
+                                     output_section, data_shndx,
+                                     reloc.get_r_offset());
         }
       break;
 
@@ -1125,17 +1364,27 @@ Target_i386::Scan::local(Symbol_table* symtab,
         // The symbol requires a GOT entry.
         Output_data_got<32, false>* got = target->got_section(symtab, layout);
         unsigned int r_sym = elfcpp::elf_r_sym<32>(reloc.get_r_info());
-        if (got->add_local(object, r_sym, GOT_TYPE_STANDARD))
+
+       // For a STT_GNU_IFUNC symbol we want the PLT offset.  That
+       // lets function pointers compare correctly with shared
+       // libraries.  Otherwise we would need an IRELATIVE reloc.
+       bool is_new;
+       if (lsym.get_st_type() == elfcpp::STT_GNU_IFUNC)
+         is_new = got->add_local_plt(object, r_sym, GOT_TYPE_STANDARD);
+       else
+         is_new = got->add_local(object, r_sym, GOT_TYPE_STANDARD);
+        if (is_new)
           {
             // If we are generating a shared object, we need to add a
             // dynamic RELATIVE relocation for this symbol's GOT entry.
             if (parameters->options().output_is_position_independent())
               {
                 Reloc_section* rel_dyn = target->rel_dyn_section(layout);
-                unsigned int r_sym = elfcpp::elf_r_sym<32>(reloc.get_r_info());
-                rel_dyn->add_local_relative(
-                    object, r_sym, elfcpp::R_386_RELATIVE, got,
-                    object->local_got_offset(r_sym, GOT_TYPE_STANDARD));
+               unsigned int got_offset =
+                 object->local_got_offset(r_sym, GOT_TYPE_STANDARD);
+               rel_dyn->add_local_relative(object, r_sym,
+                                           elfcpp::R_386_RELATIVE,
+                                           got, got_offset);
               }
           }
       }
@@ -1147,6 +1396,7 @@ Target_i386::Scan::local(Symbol_table* symtab,
     case elfcpp::R_386_GLOB_DAT:
     case elfcpp::R_386_JUMP_SLOT:
     case elfcpp::R_386_RELATIVE:
+    case elfcpp::R_386_IRELATIVE:
     case elfcpp::R_386_TLS_TPOFF:
     case elfcpp::R_386_TLS_DTPMOD32:
     case elfcpp::R_386_TLS_DTPOFF32:
@@ -1394,6 +1644,11 @@ Target_i386::Scan::global(Symbol_table* symtab,
                          unsigned int r_type,
                          Symbol* gsym)
 {
+  // A STT_GNU_IFUNC symbol may require a PLT entry.
+  if (gsym->type() == elfcpp::STT_GNU_IFUNC
+      && this->reloc_needs_plt_for_ifunc(object, r_type))
+    target->make_plt_entry(symtab, layout, gsym);
+
   switch (r_type)
     {
     case elfcpp::R_386_NONE:
@@ -1424,13 +1679,31 @@ Target_i386::Scan::global(Symbol_table* symtab,
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym, reloc);
               }
+           else if (r_type == elfcpp::R_386_32
+                    && gsym->type() == elfcpp::STT_GNU_IFUNC
+                    && gsym->can_use_relative_reloc(false)
+                    && !gsym->is_from_dynobj()
+                    && !gsym->is_undefined()
+                    && !gsym->is_preemptible())
+             {
+               // Use an IRELATIVE reloc for a locally defined
+               // STT_GNU_IFUNC symbol.  This makes a function
+               // address in a PIE executable match the address in a
+               // shared library that it links against.
+               Reloc_section* rel_dyn = target->rel_dyn_section(layout);
+               rel_dyn->add_symbolless_global_addend(gsym,
+                                                     elfcpp::R_386_IRELATIVE,
+                                                     output_section,
+                                                     object, data_shndx,
+                                                     reloc.get_r_offset());
+             }
             else if (r_type == elfcpp::R_386_32
                      && gsym->can_use_relative_reloc(false))
               {
                 Reloc_section* rel_dyn = target->rel_dyn_section(layout);
-                rel_dyn->add_global_relative(gsym, elfcpp::R_386_RELATIVE,
-                                             output_section, object,
-                                             data_shndx, reloc.get_r_offset());
+               rel_dyn->add_global_relative(gsym, elfcpp::R_386_RELATIVE,
+                                            output_section, object,
+                                            data_shndx, reloc.get_r_offset());
               }
             else
               {
@@ -1485,7 +1758,13 @@ Target_i386::Scan::global(Symbol_table* symtab,
         // The symbol requires a GOT entry.
         Output_data_got<32, false>* got = target->got_section(symtab, layout);
         if (gsym->final_value_is_known())
-          got->add_global(gsym, GOT_TYPE_STANDARD);
+         {
+           // For a STT_GNU_IFUNC symbol we want the PLT address.
+           if (gsym->type() == elfcpp::STT_GNU_IFUNC)
+             got->add_global_plt(gsym, GOT_TYPE_STANDARD);
+           else
+             got->add_global(gsym, GOT_TYPE_STANDARD);
+         }
         else
           {
             // If this symbol is not fully resolved, we need to add a
@@ -1493,15 +1772,34 @@ Target_i386::Scan::global(Symbol_table* symtab,
             Reloc_section* rel_dyn = target->rel_dyn_section(layout);
             if (gsym->is_from_dynobj()
                 || gsym->is_undefined()
-                || gsym->is_preemptible())
+                || gsym->is_preemptible()
+               || (gsym->type() == elfcpp::STT_GNU_IFUNC
+                   && parameters->options().output_is_position_independent()))
               got->add_global_with_rel(gsym, GOT_TYPE_STANDARD,
                                        rel_dyn, elfcpp::R_386_GLOB_DAT);
             else
               {
-                if (got->add_global(gsym, GOT_TYPE_STANDARD))
-                  rel_dyn->add_global_relative(
-                      gsym, elfcpp::R_386_RELATIVE, got,
-                      gsym->got_offset(GOT_TYPE_STANDARD));
+               // For a STT_GNU_IFUNC symbol we want to write the PLT
+               // offset into the GOT, so that function pointer
+               // comparisons work correctly.
+               bool is_new;
+               if (gsym->type() != elfcpp::STT_GNU_IFUNC)
+                 is_new = got->add_global(gsym, GOT_TYPE_STANDARD);
+               else
+                 {
+                   is_new = got->add_global_plt(gsym, GOT_TYPE_STANDARD);
+                   // Tell the dynamic linker to use the PLT address
+                   // when resolving relocations.
+                   if (gsym->is_from_dynobj()
+                       && !parameters->options().shared())
+                     gsym->set_needs_dynsym_value();
+                 }
+                if (is_new)
+                 {
+                   unsigned int got_off = gsym->got_offset(GOT_TYPE_STANDARD);
+                   rel_dyn->add_global_relative(gsym, elfcpp::R_386_RELATIVE,
+                                                got, got_off);
+                 }
               }
           }
       }
@@ -1534,6 +1832,7 @@ Target_i386::Scan::global(Symbol_table* symtab,
     case elfcpp::R_386_GLOB_DAT:
     case elfcpp::R_386_JUMP_SLOT:
     case elfcpp::R_386_RELATIVE:
+    case elfcpp::R_386_IRELATIVE:
     case elfcpp::R_386_TLS_TPOFF:
     case elfcpp::R_386_TLS_DTPMOD32:
     case elfcpp::R_386_TLS_DTPOFF32:
@@ -1866,19 +2165,41 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
        }
     }
 
+  const Sized_relobj<32, false>* object = relinfo->object;
+
   // Pick the value to use for symbols defined in shared objects.
   Symbol_value<32> symval;
   if (gsym != NULL
-      && gsym->use_plt_offset(r_type == elfcpp::R_386_PC8
-                             || r_type == elfcpp::R_386_PC16
-                             || r_type == elfcpp::R_386_PC32))
+      && gsym->type() == elfcpp::STT_GNU_IFUNC
+      && r_type == elfcpp::R_386_32
+      && gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF)
+      && gsym->can_use_relative_reloc(false)
+      && !gsym->is_from_dynobj()
+      && !gsym->is_undefined()
+      && !gsym->is_preemptible())
+    {
+      // In this case we are generating a R_386_IRELATIVE reloc.  We
+      // want to use the real value of the symbol, not the PLT offset.
+    }
+  else if (gsym != NULL
+          && gsym->use_plt_offset(r_type == elfcpp::R_386_PC8
+                                  || r_type == elfcpp::R_386_PC16
+                                  || r_type == elfcpp::R_386_PC32))
     {
       symval.set_output_value(target->plt_section()->address()
                              + gsym->plt_offset());
       psymval = &symval;
     }
-
-  const Sized_relobj<32, false>* object = relinfo->object;
+  else if (gsym == NULL && psymval->is_ifunc_symbol())
+    {
+      unsigned int r_sym = elfcpp::elf_r_sym<32>(rel.get_r_info());
+      if (object->local_has_plt_offset(r_sym))
+       {
+         symval.set_output_value(target->plt_section()->address()
+                                 + object->local_plt_offset(r_sym));
+         psymval = &symval;
+       }
+    }
 
   // Get the GOT offset if needed.
   // The GOT pointer points to the end of the GOT section.
@@ -2001,6 +2322,7 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
     case elfcpp::R_386_GLOB_DAT:
     case elfcpp::R_386_JUMP_SLOT:
     case elfcpp::R_386_RELATIVE:
+    case elfcpp::R_386_IRELATIVE:
       // These are outstanding tls relocs, which are unexpected when
       // linking.
     case elfcpp::R_386_TLS_TPOFF:
@@ -2713,6 +3035,7 @@ Target_i386::Relocatable_size_for_reloc::get_size_for_reloc(
     case elfcpp::R_386_GLOB_DAT:
     case elfcpp::R_386_JUMP_SLOT:
     case elfcpp::R_386_RELATIVE:
+    case elfcpp::R_386_IRELATIVE:
     case elfcpp::R_386_TLS_TPOFF:
     case elfcpp::R_386_TLS_DTPMOD32:
     case elfcpp::R_386_TLS_DTPOFF32:
index b3d987056c73119633a51498818c489b84520392..5250fa3c2c4e14fd5e84a8ac7a220f72f2f35bdc 100644 (file)
@@ -391,6 +391,7 @@ Sized_relobj<size, big_endian>::Sized_relobj(
     local_dynsym_offset_(0),
     local_values_(),
     local_got_offsets_(),
+    local_plt_offsets_(),
     kept_comdat_sections_(),
     has_eh_frame_(false),
     discarded_eh_frame_shndx_(-1U),
@@ -1690,6 +1691,41 @@ Sized_relobj<size, big_endian>::do_should_include_member(Symbol_table* symtab,
   return Archive::SHOULD_INCLUDE_UNKNOWN;
 }
 
+// Return whether the local symbol SYMNDX has a PLT offset.
+
+template<int size, bool big_endian>
+bool
+Sized_relobj<size, big_endian>::local_has_plt_offset(unsigned int symndx) const
+{
+  typename Local_plt_offsets::const_iterator p =
+    this->local_plt_offsets_.find(symndx);
+  return p != this->local_plt_offsets_.end();
+}
+
+// Get the PLT offset of a local symbol.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj<size, big_endian>::local_plt_offset(unsigned int symndx) const
+{
+  typename Local_plt_offsets::const_iterator p =
+    this->local_plt_offsets_.find(symndx);
+  gold_assert(p != this->local_plt_offsets_.end());
+  return p->second;
+}
+
+// Set the PLT offset of a local symbol.
+
+template<int size, bool big_endian>
+void
+Sized_relobj<size, big_endian>::set_local_plt_offset(unsigned int symndx,
+                                                    unsigned int plt_offset)
+{
+  std::pair<typename Local_plt_offsets::iterator, bool> ins =
+    this->local_plt_offsets_.insert(std::make_pair(symndx, plt_offset));
+  gold_assert(ins.second);
+}
+
 // First pass over the local symbols.  Here we add their names to
 // *POOL and *DYNPOOL, and we store the symbol value in
 // THIS->LOCAL_VALUES_.  This function is always called from a
@@ -1756,6 +1792,8 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
        lv.set_is_section_symbol();
       else if (sym.get_st_type() == elfcpp::STT_TLS)
        lv.set_is_tls_symbol();
+      else if (sym.get_st_type() == elfcpp::STT_GNU_IFUNC)
+       lv.set_is_ifunc_symbol();
 
       // Save the input symbol value for use in do_finalize_local_symbols().
       lv.set_input_value(sym.get_st_value());
@@ -2065,7 +2103,6 @@ Sized_relobj<size, big_endian>::do_section_entsize(unsigned int shndx)
   return shdr.get_sh_entsize(); 
 }
 
-
 // Write out the local symbols.
 
 template<int size, bool big_endian>
index 94ad64312e1a78b27876983bb11d6da8e806af74..3412aec781b9762148ce60f256a9f139186bff3a 100644 (file)
@@ -39,6 +39,7 @@ class General_options;
 class Task;
 class Cref;
 class Layout;
+class Output_data;
 class Output_section;
 class Output_file;
 class Output_symtab_xindex;
@@ -1151,7 +1152,7 @@ class Symbol_value
   Symbol_value()
     : output_symtab_index_(0), output_dynsym_index_(-1U), input_shndx_(0),
       is_ordinary_shndx_(false), is_section_symbol_(false),
-      is_tls_symbol_(false), has_output_value_(true)
+      is_tls_symbol_(false), is_ifunc_symbol_(false), has_output_value_(true)
   { this->u_.value = 0; }
 
   // Get the value of this symbol.  OBJECT is the object in which this
@@ -1364,11 +1365,21 @@ class Symbol_value
   set_is_tls_symbol()
   { this->is_tls_symbol_ = true; }
 
-  // Return TRUE if this is a TLS symbol.
+  // Return true if this is a TLS symbol.
   bool
   is_tls_symbol() const
   { return this->is_tls_symbol_; }
 
+  // Record that this is an IFUNC symbol.
+  void
+  set_is_ifunc_symbol()
+  { this->is_ifunc_symbol_ = true; }
+
+  // Return true if this is an IFUNC symbol.
+  bool
+  is_ifunc_symbol() const
+  { return this->is_ifunc_symbol_; }
+
  private:
   // The index of this local symbol in the output symbol table.  This
   // will be 0 if no value has been assigned yet, and the symbol may
@@ -1381,7 +1392,7 @@ class Symbol_value
   unsigned int output_dynsym_index_;
   // The section index in the input file in which this symbol is
   // defined.
-  unsigned int input_shndx_ : 28;
+  unsigned int input_shndx_ : 27;
   // Whether the section index is an ordinary index, not a special
   // value.
   bool is_ordinary_shndx_ : 1;
@@ -1389,6 +1400,8 @@ class Symbol_value
   bool is_section_symbol_ : 1;
   // Whether this is a STT_TLS symbol.
   bool is_tls_symbol_ : 1;
+  // Whether this is a STT_GNU_IFUNC symbol.
+  bool is_ifunc_symbol_ : 1;
   // Whether this symbol has a value for the output file.  This is
   // normally set to true during Layout::finalize, by
   // finalize_local_symbols.  It will be false for a section symbol in
@@ -1692,6 +1705,19 @@ class Sized_relobj : public Relobj
     return p->second;
   }
 
+  // Return whether the local symbol SYMNDX has a PLT offset.
+  bool
+  local_has_plt_offset(unsigned int symndx) const;
+
+  // Return the PLT offset for a local symbol.  It is an error to call
+  // this if it doesn't have one.
+  unsigned int
+  local_plt_offset(unsigned int symndx) const;
+
+  // Set the PLT offset of the local symbol SYMNDX.
+  void
+  set_local_plt_offset(unsigned int symndx, unsigned int plt_offset);
+
   // Get the offset of input section SHNDX within its output section.
   // This is -1 if the input section requires a special mapping, such
   // as a merge section.  The output section can be found in the
@@ -2108,6 +2134,7 @@ class Sized_relobj : public Relobj
   {
     this->local_values_.clear();
     this->local_got_offsets_.clear();
+    this->local_plt_offsets_.clear();
   }
 
   // Record a mapping from discarded section SHNDX to the corresponding
@@ -2139,20 +2166,8 @@ class Sized_relobj : public Relobj
   // for tp-relative offsets for TLS symbols.
   typedef Unordered_map<unsigned int, Got_offset_list*> Local_got_offsets;
 
-  // The TLS GOT offsets of local symbols. The map stores the offsets
-  // for either a single GOT entry that holds the module index of a TLS
-  // symbol, or a pair of GOT entries containing the module index and
-  // dtv-relative offset.
-  struct Tls_got_entry
-  {
-    Tls_got_entry(int got_offset, bool have_pair)
-      : got_offset_(got_offset),
-        have_pair_(have_pair)
-    { }
-    int got_offset_;
-    bool have_pair_;
-  };
-  typedef Unordered_map<unsigned int, Tls_got_entry> Local_tls_got_offsets;
+  // The PLT offsets of local symbols.
+  typedef Unordered_map<unsigned int, unsigned int> Local_plt_offsets;
 
   // Saved information for sections whose layout was deferred.
   struct Deferred_layout
@@ -2197,6 +2212,8 @@ class Sized_relobj : public Relobj
   // GOT offsets for local non-TLS symbols, and tp-relative offsets
   // for TLS symbols, indexed by symbol number.
   Local_got_offsets local_got_offsets_;
+  // PLT offsets for local symbols.
+  Local_plt_offsets local_plt_offsets_;
   // For each input section, the offset of the input section in its
   // output section.  This is INVALID_ADDRESS if the input section requires a
   // special mapping.
index 55080a1fa0a21134de2d5161a5dc2eec7bf2f8b0..5cb63fb7725640d24709894c47c78b1e0d7eece7 100644 (file)
@@ -1,6 +1,6 @@
 // output.cc -- manage the output file for gold
 
-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -1133,10 +1133,17 @@ Output_data_reloc_base<sh_type, dynamic, size, big_endian>
     os->set_entsize(elfcpp::Elf_sizes<size>::rela_size);
   else
     gold_unreachable();
-  if (dynamic)
-    os->set_should_link_to_dynsym();
-  else
+
+  // A STT_GNU_IFUNC symbol may require a IRELATIVE reloc when doing a
+  // static link.  The backends will generate a dynamic reloc section
+  // to hold this.  In that case we don't want to link to the dynsym
+  // section, because there isn't one.
+  if (!dynamic)
     os->set_should_link_to_symtab();
+  else if (parameters->doing_static_link())
+    ;
+  else
+    os->set_should_link_to_dynsym();
 }
 
 // Write out relocation data.
@@ -1262,12 +1269,18 @@ Output_data_got<size, big_endian>::Got_entry::write(unsigned char* pov) const
        // link-time value, which will be relocated dynamically by a
        // RELATIVE relocation.
        Symbol* gsym = this->u_.gsym;
-       Sized_symbol<size>* sgsym;
-       // This cast is a bit ugly.  We don't want to put a
-       // virtual method in Symbol, because we want Symbol to be
-       // as small as possible.
-       sgsym = static_cast<Sized_symbol<size>*>(gsym);
-       val = sgsym->value();
+       if (this->use_plt_offset_ && gsym->has_plt_offset())
+         val = (parameters->target().plt_section_for_global(gsym)->address()
+                + gsym->plt_offset());
+       else
+         {
+           Sized_symbol<size>* sgsym;
+           // This cast is a bit ugly.  We don't want to put a
+           // virtual method in Symbol, because we want Symbol to be
+           // as small as possible.
+           sgsym = static_cast<Sized_symbol<size>*>(gsym);
+           val = sgsym->value();
+         }
       }
       break;
 
@@ -1277,9 +1290,17 @@ Output_data_got<size, big_endian>::Got_entry::write(unsigned char* pov) const
 
     default:
       {
+       const Sized_relobj<size, big_endian>* object = this->u_.object;
         const unsigned int lsi = this->local_sym_index_;
-        const Symbol_value<size>* symval = this->u_.object->local_symbol(lsi);
-        val = symval->value(this->u_.object, 0);
+        const Symbol_value<size>* symval = object->local_symbol(lsi);
+       if (!this->use_plt_offset_)
+         val = symval->value(this->u_.object, 0);
+       else
+         {
+           const Output_data* plt =
+             parameters->target().plt_section_for_local(object, lsi);
+           val = plt->address() + object->local_plt_offset(lsi);
+         }
       }
       break;
     }
@@ -1302,7 +1323,23 @@ Output_data_got<size, big_endian>::add_global(
   if (gsym->has_got_offset(got_type))
     return false;
 
-  this->entries_.push_back(Got_entry(gsym));
+  this->entries_.push_back(Got_entry(gsym, false));
+  this->set_got_size();
+  gsym->set_got_offset(got_type, this->last_got_offset());
+  return true;
+}
+
+// Like add_global, but use the PLT offset.
+
+template<int size, bool big_endian>
+bool
+Output_data_got<size, big_endian>::add_global_plt(Symbol* gsym,
+                                                 unsigned int got_type)
+{
+  if (gsym->has_got_offset(got_type))
+    return false;
+
+  this->entries_.push_back(Got_entry(gsym, true));
   this->set_got_size();
   gsym->set_got_offset(got_type, this->last_got_offset());
   return true;
@@ -1310,6 +1347,7 @@ Output_data_got<size, big_endian>::add_global(
 
 // Add an entry for a global symbol to the GOT, and add a dynamic
 // relocation of type R_TYPE for the GOT entry.
+
 template<int size, bool big_endian>
 void
 Output_data_got<size, big_endian>::add_global_with_rel(
@@ -1417,7 +1455,25 @@ Output_data_got<size, big_endian>::add_local(
   if (object->local_has_got_offset(symndx, got_type))
     return false;
 
-  this->entries_.push_back(Got_entry(object, symndx));
+  this->entries_.push_back(Got_entry(object, symndx, false));
+  this->set_got_size();
+  object->set_local_got_offset(symndx, got_type, this->last_got_offset());
+  return true;
+}
+
+// Like add_local, but use the PLT offset.
+
+template<int size, bool big_endian>
+bool
+Output_data_got<size, big_endian>::add_local_plt(
+    Sized_relobj<size, big_endian>* object,
+    unsigned int symndx,
+    unsigned int got_type)
+{
+  if (object->local_has_got_offset(symndx, got_type))
+    return false;
+
+  this->entries_.push_back(Got_entry(object, symndx, true));
   this->set_got_size();
   object->set_local_got_offset(symndx, got_type, this->last_got_offset());
   return true;
@@ -1425,6 +1481,7 @@ Output_data_got<size, big_endian>::add_local(
 
 // Add an entry for a local symbol to the GOT, and add a dynamic
 // relocation of type R_TYPE for the GOT entry.
+
 template<int size, bool big_endian>
 void
 Output_data_got<size, big_endian>::add_local_with_rel(
@@ -1486,7 +1543,7 @@ Output_data_got<size, big_endian>::add_local_pair_with_rel(
   Output_section* os = object->output_section(shndx);
   rel_dyn->add_output_section(os, r_type_1, this, got_offset);
 
-  this->entries_.push_back(Got_entry(object, symndx));
+  this->entries_.push_back(Got_entry(object, symndx, false));
   if (r_type_2 != 0)
     {
       got_offset = this->last_got_offset();
@@ -1516,7 +1573,7 @@ Output_data_got<size, big_endian>::add_local_pair_with_rela(
   Output_section* os = object->output_section(shndx);
   rela_dyn->add_output_section(os, r_type_1, this, got_offset, 0);
 
-  this->entries_.push_back(Got_entry(object, symndx));
+  this->entries_.push_back(Got_entry(object, symndx, false));
   if (r_type_2 != 0)
     {
       got_offset = this->last_got_offset();
index 78c51ce7b089d28fc102e0526372f4f484fb9217..1670704474c45a2056be3421ea626c070422e572 100644 (file)
@@ -1,6 +1,6 @@
 // output.h -- manage the output file for gold   -*- C++ -*-
 
-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -605,6 +605,10 @@ class Output_section_data : public Output_data
   { }
 
   // Return the output section.
+  Output_section*
+  output_section()
+  { return this->output_section_; }
+
   const Output_section*
   output_section() const
   { return this->output_section_; }
@@ -1913,6 +1917,11 @@ class Output_data_got : public Output_section_data_build
   bool
   add_global(Symbol* gsym, unsigned int got_type);
 
+  // Like add_global, but use the PLT offset of the global symbol if
+  // it has one.
+  bool
+  add_global_plt(Symbol* gsym, unsigned int got_type);
+
   // Add an entry for a global symbol to the GOT, and add a dynamic
   // relocation of type R_TYPE for the GOT entry.
   void
@@ -1942,6 +1951,12 @@ class Output_data_got : public Output_section_data_build
   add_local(Sized_relobj<size, big_endian>* object, unsigned int sym_index,
             unsigned int got_type);
 
+  // Like add_local, but use the PLT offset of the local symbol if it
+  // has one.
+  bool
+  add_local_plt(Sized_relobj<size, big_endian>* object, unsigned int sym_index,
+               unsigned int got_type);
+
   // Add an entry for a local symbol to the GOT, and add a dynamic
   // relocation of type R_TYPE for the GOT entry.
   void
@@ -1995,28 +2010,29 @@ class Output_data_got : public Output_section_data_build
    public:
     // Create a zero entry.
     Got_entry()
-      : local_sym_index_(CONSTANT_CODE)
+      : local_sym_index_(CONSTANT_CODE), use_plt_offset_(false)
     { this->u_.constant = 0; }
 
     // Create a global symbol entry.
-    explicit Got_entry(Symbol* gsym)
-      : local_sym_index_(GSYM_CODE)
+    Got_entry(Symbol* gsym, bool use_plt_offset)
+      : local_sym_index_(GSYM_CODE), use_plt_offset_(use_plt_offset)
     { this->u_.gsym = gsym; }
 
     // Create a local symbol entry.
     Got_entry(Sized_relobj<size, big_endian>* object,
-              unsigned int local_sym_index)
-      : local_sym_index_(local_sym_index)
+              unsigned int local_sym_index, bool use_plt_offset)
+      : local_sym_index_(local_sym_index), use_plt_offset_(use_plt_offset)
     {
       gold_assert(local_sym_index != GSYM_CODE
-                 && local_sym_index != CONSTANT_CODE);
+                 && local_sym_index != CONSTANT_CODE
+                 && local_sym_index == this->local_sym_index_);
       this->u_.object = object;
     }
 
     // Create a constant entry.  The constant is a host value--it will
     // be swapped, if necessary, when it is written out.
     explicit Got_entry(Valtype constant)
-      : local_sym_index_(CONSTANT_CODE)
+      : local_sym_index_(CONSTANT_CODE), use_plt_offset_(false)
     { this->u_.constant = constant; }
 
     // Write the GOT entry to an output view.
@@ -2026,8 +2042,8 @@ class Output_data_got : public Output_section_data_build
    private:
     enum
     {
-      GSYM_CODE = -1U,
-      CONSTANT_CODE = -2U
+      GSYM_CODE = 0x7fffffff,
+      CONSTANT_CODE = 0x7ffffffe
     };
 
     union
@@ -2041,7 +2057,9 @@ class Output_data_got : public Output_section_data_build
     } u_;
     // For a local symbol, the local symbol index.  This is GSYM_CODE
     // for a global symbol, or CONSTANT_CODE for a constant.
-    unsigned int local_sym_index_;
+    unsigned int local_sym_index_ : 31;
+    // Whether to use the PLT offset of the symbol if it has one.
+    bool use_plt_offset_ : 1;
   };
 
   typedef std::vector<Got_entry> Got_entries;
index 8ccbca9a4107398876bdf3f2e0e4fdacd7daf923..b9e34852e4b76fb4e204a4616d272b58dc0e7202 100644 (file)
@@ -582,9 +582,6 @@ class Symbol
   }
 
   // Return true if this symbol is a function that needs a PLT entry.
-  // If the symbol is defined in a dynamic object or if it is subject
-  // to pre-emption, we need to make a PLT entry. If we're doing a
-  // static link or a -pie link, we don't create PLT entries.
   bool
   needs_plt_entry() const
   {
@@ -592,12 +589,27 @@ class Symbol
     if (this->is_undefined() && !parameters->options().shared())
       return false;
 
-    return (!parameters->doing_static_link()
-           && !parameters->options().pie()
-            && this->is_func()
-            && (this->is_from_dynobj()
-                || this->is_undefined()
-                || this->is_preemptible()));
+    // An STT_GNU_IFUNC symbol always needs a PLT entry, even when
+    // doing a static link.
+    if (this->type() == elfcpp::STT_GNU_IFUNC)
+      return true;
+
+    // We only need a PLT entry for a function.
+    if (!this->is_func())
+      return false;
+
+    // If we're doing a static link or a -pie link, we don't create
+    // PLT entries.
+    if (parameters->doing_static_link()
+       || parameters->options().pie())
+      return false;
+
+    // We need a PLT entry if the function is defined in a dynamic
+    // object, or is undefined when building a shared object, or if it
+    // is subject to pre-emption.
+    return (this->is_from_dynobj()
+           || this->is_undefined()
+           || this->is_preemptible());
   }
 
   // When determining whether a reference to a symbol needs a dynamic
@@ -678,6 +690,10 @@ class Symbol
     if (!this->has_plt_offset())
       return false;
 
+    // For a STT_GNU_IFUNC symbol we always have to use the PLT entry.
+    if (this->type() == elfcpp::STT_GNU_IFUNC)
+      return true;
+
     // If we are going to generate a dynamic relocation, then we will
     // wind up using that, so no need to use the PLT entry.
     if (this->needs_dynamic_reloc(FUNCTION_CALL
index 23866e373d5690f8f77dc08f167f5376a331df67..769d3224f20e2fe34324de671baf7030e737e70c 100644 (file)
@@ -284,6 +284,10 @@ relocate_section(
          else
            symval.set_no_output_symtab_entry();
          symval.set_output_value(sym->value());
+         if (gsym->type() == elfcpp::STT_TLS)
+           symval.set_is_tls_symbol();
+         else if (gsym->type() == elfcpp::STT_GNU_IFUNC)
+           symval.set_is_ifunc_symbol();
          psymval = &symval;
 
          is_defined_in_discarded_section =
index 6ab31d05c599a5453267d021fd7e9bfec33c3083..33f7ee80639389423b7edb047652677a5863d793 100644 (file)
@@ -53,6 +53,7 @@ class Symbol;
 template<int size>
 class Sized_symbol;
 class Symbol_table;
+class Output_data;
 class Output_section;
 class Input_objects;
 
@@ -261,6 +262,18 @@ class Target
   reloc_addend(void* arg, unsigned int type, uint64_t addend) const
   { return this->do_reloc_addend(arg, type, addend); }
 
+  // Return the PLT section to use for a global symbol.  This is used
+  // for STT_GNU_IFUNC symbols.
+  Output_data*
+  plt_section_for_global(const Symbol* sym) const
+  { return this->do_plt_section_for_global(sym); }
+
+  // Return the PLT section to use for a local symbol.  This is used
+  // for STT_GNU_IFUNC symbols.
+  Output_data*
+  plt_section_for_local(const Relobj* object, unsigned int symndx) const
+  { return this->do_plt_section_for_local(object, symndx); }
+
   // Return true if a reference to SYM from a reloc of type R_TYPE
   // means that the current function may call an object compiled
   // without -fsplit-stack.  SYM is known to be defined in an object
@@ -462,6 +475,16 @@ class Target
   do_reloc_addend(void*, unsigned int, uint64_t) const
   { gold_unreachable(); }
 
+  // Virtual functions that must be overridden by a target that uses
+  // STT_GNU_IFUNC symbols.
+  virtual Output_data*
+  do_plt_section_for_global(const Symbol*) const
+  { gold_unreachable(); }
+
+  virtual Output_data*
+  do_plt_section_for_local(const Relobj*, unsigned int) const
+  { gold_unreachable(); }
+
   // Virtual function which may be overridden by the child class.  The
   // default implementation is that any function not defined by the
   // ABI is a call to a non-split function.
index ab3ca5508d3f86a5cdec3a5c14148fe546ddee2a..0aac007f396d08e5a3ef215179b43969109425a4 100644 (file)
@@ -1530,6 +1530,208 @@ no_version_test.o: no_version_test.c
 no_version_test.stdout: libno_version_test.so
        $(TEST_OBJDUMP) -h $< > $@
 
+# Test STT_GNU_IFUNC symbols.
+if IFUNC
+
+ifuncmod1.o: ifuncmod1.c
+       $(COMPILE) -c -fpic -o $@ $<
+ifuncmod1.so: ifuncmod1.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -shared ifuncmod1.o
+
+ifuncdep1.o: ifuncmod1.c
+       $(COMPILE) -c -o $@ $<
+
+ifuncmain1pic.o: ifuncmain1.c
+       $(COMPILE) -c -fpic -o $@ $<
+ifuncmain1pie.o: ifuncmain1.c
+       $(COMPILE) -c -fpie -o $@ $<
+
+check_PROGRAMS += ifuncmain1static
+ifuncmain1static_SOURCES = ifuncmain1.c
+ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
+ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
+ifuncmain1static_LDADD = ifuncdep1.o
+
+check_PROGRAMS += ifuncmain1picstatic
+ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
+
+check_PROGRAMS += ifuncmain1
+ifuncmain1_SOURCES = ifuncmain1.c
+ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
+ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+ifuncmain1_LDADD = ifuncmod1.so
+
+check_PROGRAMS += ifuncmain1pic
+ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
+
+check_PROGRAMS += ifuncmain1vis
+ifuncmain1vis_SOURCES = ifuncmain1vis.c
+ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
+ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+ifuncmain1vis_LDADD = ifuncmod1.so
+
+check_PROGRAMS += ifuncmain1vispic
+ifuncmain1vispic.o: ifuncmain1vis.c
+       $(COMPILE) -c -fpic -o $@ $<
+ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
+
+check_PROGRAMS += ifuncmain1staticpic
+ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
+
+check_PROGRAMS += ifuncmain1pie
+ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
+
+check_PROGRAMS += ifuncmain1vispie
+ifuncmain1vispie.o: ifuncmain1vis.c
+       $(COMPILE) -c -fpie -o $@ $<
+ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
+
+check_PROGRAMS += ifuncmain1staticpie
+ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
+
+ifuncmain2pic.o: ifuncmain2.c
+       $(COMPILE) -c -fpic -o $@ $<
+
+ifuncdep2pic.o: ifuncdep2.c
+       $(COMPILE) -c -fpic -o $@ $<
+
+check_PROGRAMS += ifuncmain2static
+ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
+ifuncmain2static_DEPENDENCIES = gcctestdir/ld
+ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
+
+check_PROGRAMS += ifuncmain2picstatic
+ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
+
+check_PROGRAMS += ifuncmain2
+ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
+ifuncmain2_DEPENDENCIES = gcctestdir/ld
+ifuncmain2_LDFLAGS = -Bgcctestdir/
+
+check_PROGRAMS += ifuncmain2pic
+ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
+
+ifuncmod3.o: ifuncmod3.c
+       $(COMPILE) -c -fpic -o $@ $<
+ifuncmod3.so: ifuncmod3.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -shared ifuncmod3.o
+
+check_PROGRAMS += ifuncmain3
+ifuncmain3_SOURCES = ifuncmain3.c
+ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
+ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
+ifuncmain3_LDADD = -ldl
+
+ifuncmain4pic.o: ifuncmain4.c
+       $(COMPILE) -c -fpic -o $@ $<
+
+check_PROGRAMS += ifuncmain4static
+ifuncmain4static_SOURCES = ifuncmain4.c
+ifuncmain4static_DEPENDENCIES = gcctestdir/ld
+ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
+
+check_PROGRAMS += ifuncmain4picstatic
+ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
+
+check_PROGRAMS += ifuncmain4
+ifuncmain4_SOURCES = ifuncmain4.c
+ifuncmain4_DEPENDENCIES = gcctestdir/ld
+ifuncmain4_LDFLAGS = -Bgcctestdir/
+
+ifuncmain5pic.o: ifuncmain5.c
+       $(COMPILE) -c -fpic -o $@ $<
+
+ifuncmain5pie.o: ifuncmain5.c
+       $(COMPILE) -c -fpie -o $@ $<
+
+ifuncmod5.o: ifuncmod5.c
+       $(COMPILE) -c -fpic -o $@ $<
+ifuncmod5.so: ifuncmod5.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -shared ifuncmod5.o
+
+ifuncdep5.o: ifuncmod5.c
+       $(COMPILE) -c -o $@ $<
+
+check_PROGRAMS += ifuncmain5static
+ifuncmain5static_SOURCES = ifuncmain5.c
+ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
+ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
+ifuncmain5static_LDADD = ifuncdep5.o
+
+check_PROGRAMS += ifuncmain5picstatic
+ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
+
+check_PROGRAMS += ifuncmain5
+ifuncmain5_SOURCES = ifuncmain5.c
+ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
+ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+ifuncmain5_LDADD = ifuncmod5.so
+
+check_PROGRAMS += ifuncmain5pic
+ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
+
+check_PROGRAMS += ifuncmain5staticpic
+ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
+
+check_PROGRAMS += ifuncmain5pie
+ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
+
+ifuncmain6pie.o: ifuncmain6pie.c
+       $(COMPILE) -c -fpie -o $@ $<
+
+ifuncmod6.o: ifuncmod6.c
+       $(COMPILE) -c -fpic -o $@ $<
+ifuncmod6.so: ifuncmod6.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -shared ifuncmod6.o
+
+check_PROGRAMS += ifuncmain6pie
+ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
+
+ifuncmain7pic.o: ifuncmain7.c
+       $(COMPILE) -c -fpic -o $@ $<
+
+ifuncmain7pie.o: ifuncmain7.c
+       $(COMPILE) -c -fpie -o $@ $<
+
+check_PROGRAMS += ifuncmain7static
+ifuncmain7static_SOURCES = ifuncmain7.c
+ifuncmain7static_DEPENDENCIES = gcctestdir/ld
+ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
+
+check_PROGRAMS += ifuncmain7picstatic
+ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
+
+check_PROGRAMS += ifuncmain7
+ifuncmain7_SOURCES = ifuncmain7.c
+ifuncmain7_DEPENDENCIES = gcctestdir/ld
+ifuncmain7_LDFLAGS = -Bgcctestdir/
+
+check_PROGRAMS += ifuncmain7pic
+ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ ifuncmain7pic.o
+
+check_PROGRAMS += ifuncmain7pie
+ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
+       $(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
+
+endif IFUNC
+
 # Test that strong reference to a weak symbol in a DSO remains strong.
 check_SCRIPTS += strong_ref_weak_def.sh
 check_DATA += strong_ref_weak_def.stdout
index afd0430cabf1d232a27f737774ef5d4ca085f2e2..f96942f83035484142bd0b984d04e4164236b4b4 100644 (file)
@@ -47,7 +47,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
        $(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
        $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \
        $(am__EXEEXT_16) $(am__EXEEXT_17) $(am__EXEEXT_18) \
-       $(am__EXEEXT_19)
+       $(am__EXEEXT_19) $(am__EXEEXT_20)
 
 # Test --detect-odr-violations
 
@@ -357,26 +357,129 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ searched_file_test
 @GCC_FALSE@searched_file_test_DEPENDENCIES =
 @NATIVE_LINKER_FALSE@searched_file_test_DEPENDENCIES =
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am__append_32 =  \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1static \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1picstatic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1 \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1pic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1vis \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1vispic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1staticpic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1pie \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1vispie \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1staticpie \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2static \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2picstatic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2 \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2pic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain3 \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain4static \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain4picstatic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain4 \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5static \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5picstatic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5 \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5pic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5staticpic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5pie \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain6pie \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7static \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7picstatic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7 \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7pic \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7pie
+@GCC_FALSE@ifuncmain2static_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@    ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@    $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@IFUNC_FALSE@ifuncmain2static_DEPENDENCIES = libgoldtest.a \
+@IFUNC_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@ifuncmain2static_DEPENDENCIES = libgoldtest.a \
+@NATIVE_LINKER_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1)
+@GCC_FALSE@ifuncmain2_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@    ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@    $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@IFUNC_FALSE@ifuncmain2_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@IFUNC_FALSE@  ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@ifuncmain2_DEPENDENCIES = libgoldtest.a \
+@NATIVE_LINKER_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1)
+@GCC_FALSE@ifuncmain3_DEPENDENCIES =
+@IFUNC_FALSE@ifuncmain3_DEPENDENCIES =
+@NATIVE_LINKER_FALSE@ifuncmain3_DEPENDENCIES =
+@GCC_FALSE@ifuncmain4static_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@    ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@    $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@IFUNC_FALSE@ifuncmain4static_DEPENDENCIES = libgoldtest.a \
+@IFUNC_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@ifuncmain4static_DEPENDENCIES = libgoldtest.a \
+@NATIVE_LINKER_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1)
+@GCC_FALSE@ifuncmain4_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@    ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@    $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@IFUNC_FALSE@ifuncmain4_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@IFUNC_FALSE@  ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@ifuncmain4_DEPENDENCIES = libgoldtest.a \
+@NATIVE_LINKER_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1)
+@GCC_FALSE@ifuncmain7static_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@    ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@    $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@IFUNC_FALSE@ifuncmain7static_DEPENDENCIES = libgoldtest.a \
+@IFUNC_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@ifuncmain7static_DEPENDENCIES = libgoldtest.a \
+@NATIVE_LINKER_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1)
+@GCC_FALSE@ifuncmain7_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@    ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@    $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@IFUNC_FALSE@ifuncmain7_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@IFUNC_FALSE@  ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@IFUNC_FALSE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@ifuncmain7_DEPENDENCIES = libgoldtest.a \
+@NATIVE_LINKER_FALSE@  ../libgold.a ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@  $(am__DEPENDENCIES_1)
 
 # These tests work with cross linkers.
-@DEFAULT_TARGET_I386_TRUE@am__append_32 = split_i386.sh
-@DEFAULT_TARGET_I386_TRUE@am__append_33 = split_i386_1.stdout split_i386_2.stdout \
+@DEFAULT_TARGET_I386_TRUE@am__append_33 = split_i386.sh
+@DEFAULT_TARGET_I386_TRUE@am__append_34 = split_i386_1.stdout split_i386_2.stdout \
 @DEFAULT_TARGET_I386_TRUE@     split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
 
-@DEFAULT_TARGET_I386_TRUE@am__append_34 = split_i386_1 split_i386_2 split_i386_3 \
+@DEFAULT_TARGET_I386_TRUE@am__append_35 = split_i386_1 split_i386_2 split_i386_3 \
 @DEFAULT_TARGET_I386_TRUE@     split_i386_4 split_i386_r
 
-@DEFAULT_TARGET_X86_64_TRUE@am__append_35 = split_x86_64.sh
-@DEFAULT_TARGET_X86_64_TRUE@am__append_36 = split_x86_64_1.stdout split_x86_64_2.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@am__append_36 = split_x86_64.sh
+@DEFAULT_TARGET_X86_64_TRUE@am__append_37 = split_x86_64_1.stdout split_x86_64_2.stdout \
 @DEFAULT_TARGET_X86_64_TRUE@   split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
 
-@DEFAULT_TARGET_X86_64_TRUE@am__append_37 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \
+@DEFAULT_TARGET_X86_64_TRUE@am__append_38 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \
 @DEFAULT_TARGET_X86_64_TRUE@   split_x86_64_4 split_x86_64_r
 
-@DEFAULT_TARGET_ARM_TRUE@am__append_38 = arm_abs_global.sh \
+@DEFAULT_TARGET_ARM_TRUE@am__append_39 = arm_abs_global.sh \
 @DEFAULT_TARGET_ARM_TRUE@      arm_branch_in_range.sh \
 @DEFAULT_TARGET_ARM_TRUE@      arm_fix_v4bx.sh arm_attr_merge.sh
-@DEFAULT_TARGET_ARM_TRUE@am__append_39 = arm_abs_global.stdout \
+@DEFAULT_TARGET_ARM_TRUE@am__append_40 = arm_abs_global.stdout \
 @DEFAULT_TARGET_ARM_TRUE@      arm_bl_in_range.stdout \
 @DEFAULT_TARGET_ARM_TRUE@      arm_bl_out_of_range.stdout \
 @DEFAULT_TARGET_ARM_TRUE@      thumb_bl_in_range.stdout \
@@ -393,7 +496,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @DEFAULT_TARGET_ARM_TRUE@      arm_attr_merge_6.stdout \
 @DEFAULT_TARGET_ARM_TRUE@      arm_attr_merge_6r.stdout \
 @DEFAULT_TARGET_ARM_TRUE@      arm_attr_merge_7.stdout
-@DEFAULT_TARGET_ARM_TRUE@am__append_40 = arm_abs_global \
+@DEFAULT_TARGET_ARM_TRUE@am__append_41 = arm_abs_global \
 @DEFAULT_TARGET_ARM_TRUE@      arm_bl_in_range arm_bl_out_of_range \
 @DEFAULT_TARGET_ARM_TRUE@      thumb_bl_in_range \
 @DEFAULT_TARGET_ARM_TRUE@      thumb_bl_out_of_range \
@@ -531,6 +634,36 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_19 =  \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ permission_test$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ searched_file_test$(EXEEXT)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_20 = ifuncmain1static$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1picstatic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1pic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1vis$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1vispic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1staticpic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1pie$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1vispie$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain1staticpie$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2static$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2picstatic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain2pic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain3$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain4static$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain4picstatic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain4$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5static$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5picstatic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5pic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5staticpic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain5pie$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain6pie$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7static$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7picstatic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7pic$(EXEEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncmain7pie$(EXEEXT)
 basic_pic_test_SOURCES = basic_pic_test.c
 basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
 basic_pic_test_LDADD = $(LDADD)
@@ -696,6 +829,170 @@ icf_virtual_function_folding_test_LDADD = $(LDADD)
 icf_virtual_function_folding_test_DEPENDENCIES = libgoldtest.a \
        ../libgold.a ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain1_OBJECTS = ifuncmain1.$(OBJEXT)
+ifuncmain1_OBJECTS = $(am_ifuncmain1_OBJECTS)
+ifuncmain1_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncmain1_LDFLAGS) \
+       $(LDFLAGS) -o $@
+ifuncmain1pic_SOURCES = ifuncmain1pic.c
+ifuncmain1pic_OBJECTS = ifuncmain1pic.$(OBJEXT)
+ifuncmain1pic_LDADD = $(LDADD)
+ifuncmain1pic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain1picstatic_SOURCES = ifuncmain1picstatic.c
+ifuncmain1picstatic_OBJECTS = ifuncmain1picstatic.$(OBJEXT)
+ifuncmain1picstatic_LDADD = $(LDADD)
+ifuncmain1picstatic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain1pie_SOURCES = ifuncmain1pie.c
+ifuncmain1pie_OBJECTS = ifuncmain1pie.$(OBJEXT)
+ifuncmain1pie_LDADD = $(LDADD)
+ifuncmain1pie_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain1static_OBJECTS = ifuncmain1.$(OBJEXT)
+ifuncmain1static_OBJECTS = $(am_ifuncmain1static_OBJECTS)
+ifuncmain1static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(ifuncmain1static_LDFLAGS) $(LDFLAGS) -o $@
+ifuncmain1staticpic_SOURCES = ifuncmain1staticpic.c
+ifuncmain1staticpic_OBJECTS = ifuncmain1staticpic.$(OBJEXT)
+ifuncmain1staticpic_LDADD = $(LDADD)
+ifuncmain1staticpic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain1staticpie_SOURCES = ifuncmain1staticpie.c
+ifuncmain1staticpie_OBJECTS = ifuncmain1staticpie.$(OBJEXT)
+ifuncmain1staticpie_LDADD = $(LDADD)
+ifuncmain1staticpie_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain1vis_OBJECTS = ifuncmain1vis.$(OBJEXT)
+ifuncmain1vis_OBJECTS = $(am_ifuncmain1vis_OBJECTS)
+ifuncmain1vis_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(ifuncmain1vis_LDFLAGS) $(LDFLAGS) -o $@
+ifuncmain1vispic_SOURCES = ifuncmain1vispic.c
+ifuncmain1vispic_OBJECTS = ifuncmain1vispic.$(OBJEXT)
+ifuncmain1vispic_LDADD = $(LDADD)
+ifuncmain1vispic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain1vispie_SOURCES = ifuncmain1vispie.c
+ifuncmain1vispie_OBJECTS = ifuncmain1vispie.$(OBJEXT)
+ifuncmain1vispie_LDADD = $(LDADD)
+ifuncmain1vispie_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain2_OBJECTS = ifuncmain2.$(OBJEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncdep2.$(OBJEXT)
+ifuncmain2_OBJECTS = $(am_ifuncmain2_OBJECTS)
+ifuncmain2_LDADD = $(LDADD)
+ifuncmain2_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncmain2_LDFLAGS) \
+       $(LDFLAGS) -o $@
+ifuncmain2pic_SOURCES = ifuncmain2pic.c
+ifuncmain2pic_OBJECTS = ifuncmain2pic.$(OBJEXT)
+ifuncmain2pic_LDADD = $(LDADD)
+ifuncmain2pic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain2picstatic_SOURCES = ifuncmain2picstatic.c
+ifuncmain2picstatic_OBJECTS = ifuncmain2picstatic.$(OBJEXT)
+ifuncmain2picstatic_LDADD = $(LDADD)
+ifuncmain2picstatic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain2static_OBJECTS = ifuncmain2.$(OBJEXT) \
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     ifuncdep2.$(OBJEXT)
+ifuncmain2static_OBJECTS = $(am_ifuncmain2static_OBJECTS)
+ifuncmain2static_LDADD = $(LDADD)
+ifuncmain2static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(ifuncmain2static_LDFLAGS) $(LDFLAGS) -o $@
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain3_OBJECTS = ifuncmain3.$(OBJEXT)
+ifuncmain3_OBJECTS = $(am_ifuncmain3_OBJECTS)
+ifuncmain3_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncmain3_LDFLAGS) \
+       $(LDFLAGS) -o $@
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain4_OBJECTS = ifuncmain4.$(OBJEXT)
+ifuncmain4_OBJECTS = $(am_ifuncmain4_OBJECTS)
+ifuncmain4_LDADD = $(LDADD)
+ifuncmain4_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncmain4_LDFLAGS) \
+       $(LDFLAGS) -o $@
+ifuncmain4picstatic_SOURCES = ifuncmain4picstatic.c
+ifuncmain4picstatic_OBJECTS = ifuncmain4picstatic.$(OBJEXT)
+ifuncmain4picstatic_LDADD = $(LDADD)
+ifuncmain4picstatic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain4static_OBJECTS = ifuncmain4.$(OBJEXT)
+ifuncmain4static_OBJECTS = $(am_ifuncmain4static_OBJECTS)
+ifuncmain4static_LDADD = $(LDADD)
+ifuncmain4static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(ifuncmain4static_LDFLAGS) $(LDFLAGS) -o $@
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain5_OBJECTS = ifuncmain5.$(OBJEXT)
+ifuncmain5_OBJECTS = $(am_ifuncmain5_OBJECTS)
+ifuncmain5_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncmain5_LDFLAGS) \
+       $(LDFLAGS) -o $@
+ifuncmain5pic_SOURCES = ifuncmain5pic.c
+ifuncmain5pic_OBJECTS = ifuncmain5pic.$(OBJEXT)
+ifuncmain5pic_LDADD = $(LDADD)
+ifuncmain5pic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain5picstatic_SOURCES = ifuncmain5picstatic.c
+ifuncmain5picstatic_OBJECTS = ifuncmain5picstatic.$(OBJEXT)
+ifuncmain5picstatic_LDADD = $(LDADD)
+ifuncmain5picstatic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain5pie_SOURCES = ifuncmain5pie.c
+ifuncmain5pie_OBJECTS = ifuncmain5pie.$(OBJEXT)
+ifuncmain5pie_LDADD = $(LDADD)
+ifuncmain5pie_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain5static_OBJECTS = ifuncmain5.$(OBJEXT)
+ifuncmain5static_OBJECTS = $(am_ifuncmain5static_OBJECTS)
+ifuncmain5static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(ifuncmain5static_LDFLAGS) $(LDFLAGS) -o $@
+ifuncmain5staticpic_SOURCES = ifuncmain5staticpic.c
+ifuncmain5staticpic_OBJECTS = ifuncmain5staticpic.$(OBJEXT)
+ifuncmain5staticpic_LDADD = $(LDADD)
+ifuncmain5staticpic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain6pie_SOURCES = ifuncmain6pie.c
+ifuncmain6pie_OBJECTS = ifuncmain6pie.$(OBJEXT)
+ifuncmain6pie_LDADD = $(LDADD)
+ifuncmain6pie_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain7_OBJECTS = ifuncmain7.$(OBJEXT)
+ifuncmain7_OBJECTS = $(am_ifuncmain7_OBJECTS)
+ifuncmain7_LDADD = $(LDADD)
+ifuncmain7_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ifuncmain7_LDFLAGS) \
+       $(LDFLAGS) -o $@
+ifuncmain7pic_SOURCES = ifuncmain7pic.c
+ifuncmain7pic_OBJECTS = ifuncmain7pic.$(OBJEXT)
+ifuncmain7pic_LDADD = $(LDADD)
+ifuncmain7pic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain7picstatic_SOURCES = ifuncmain7picstatic.c
+ifuncmain7picstatic_OBJECTS = ifuncmain7picstatic.$(OBJEXT)
+ifuncmain7picstatic_LDADD = $(LDADD)
+ifuncmain7picstatic_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ifuncmain7pie_SOURCES = ifuncmain7pie.c
+ifuncmain7pie_OBJECTS = ifuncmain7pie.$(OBJEXT)
+ifuncmain7pie_LDADD = $(LDADD)
+ifuncmain7pie_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am_ifuncmain7static_OBJECTS = ifuncmain7.$(OBJEXT)
+ifuncmain7static_OBJECTS = $(am_ifuncmain7static_OBJECTS)
+ifuncmain7static_LDADD = $(LDADD)
+ifuncmain7static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(ifuncmain7static_LDFLAGS) $(LDFLAGS) -o $@
 @CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_initpri1_OBJECTS = initpri1.$(OBJEXT)
 initpri1_OBJECTS = $(am_initpri1_OBJECTS)
 initpri1_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(initpri1_LDFLAGS) \
@@ -1148,7 +1445,20 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \
        $(exclude_libs_test_SOURCES) \
        flagstest_compress_debug_sections.c flagstest_o_specialfile.c \
        flagstest_o_specialfile_and_compress_debug_sections.c \
-       icf_virtual_function_folding_test.c $(initpri1_SOURCES) \
+       icf_virtual_function_folding_test.c $(ifuncmain1_SOURCES) \
+       ifuncmain1pic.c ifuncmain1picstatic.c ifuncmain1pie.c \
+       $(ifuncmain1static_SOURCES) ifuncmain1staticpic.c \
+       ifuncmain1staticpie.c $(ifuncmain1vis_SOURCES) \
+       ifuncmain1vispic.c ifuncmain1vispie.c $(ifuncmain2_SOURCES) \
+       ifuncmain2pic.c ifuncmain2picstatic.c \
+       $(ifuncmain2static_SOURCES) $(ifuncmain3_SOURCES) \
+       $(ifuncmain4_SOURCES) ifuncmain4picstatic.c \
+       $(ifuncmain4static_SOURCES) $(ifuncmain5_SOURCES) \
+       ifuncmain5pic.c ifuncmain5picstatic.c ifuncmain5pie.c \
+       $(ifuncmain5static_SOURCES) ifuncmain5staticpic.c \
+       ifuncmain6pie.c $(ifuncmain7_SOURCES) ifuncmain7pic.c \
+       ifuncmain7picstatic.c ifuncmain7pie.c \
+       $(ifuncmain7static_SOURCES) $(initpri1_SOURCES) \
        $(justsyms_SOURCES) $(large_SOURCES) local_labels_test.c \
        many_sections_r_test.c $(many_sections_test_SOURCES) \
        $(object_unittest_SOURCES) permission_test.c plugin_test_1.c \
@@ -1428,16 +1738,16 @@ TEST_AS = $(top_builddir)/../gas/as-new
 # the right choice for files 'make' builds that people rebuild.
 MOSTLYCLEANFILES = *.so *.syms *.stdout $(am__append_3) \
        $(am__append_8) $(am__append_17) $(am__append_25) \
-       $(am__append_29) $(am__append_34) $(am__append_37) \
-       $(am__append_40)
+       $(am__append_29) $(am__append_35) $(am__append_38) \
+       $(am__append_41)
 
 # We will add to these later, for each individual test.  Note
 # that we add each test under check_SCRIPTS or check_PROGRAMS;
 # the TESTS variable is automatically populated from these.
 check_SCRIPTS = $(am__append_1) $(am__append_23) $(am__append_27) \
-       $(am__append_32) $(am__append_35) $(am__append_38)
-check_DATA = $(am__append_2) $(am__append_24) $(am__append_28) \
        $(am__append_33) $(am__append_36) $(am__append_39)
+check_DATA = $(am__append_2) $(am__append_24) $(am__append_28) \
+       $(am__append_34) $(am__append_37) $(am__append_40)
 BUILT_SOURCES = $(am__append_16)
 TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
 
@@ -1816,6 +2126,48 @@ binary_unittest_SOURCES = binary_unittest.cc
 @GCC_TRUE@@NATIVE_LINKER_TRUE@searched_file_test_DEPENDENCIES = alt/searched_file_test_lib.a
 @GCC_TRUE@@NATIVE_LINKER_TRUE@searched_file_test_LDFLAGS = -Bgcctestdir/ -Lalt
 @GCC_TRUE@@NATIVE_LINKER_TRUE@searched_file_test_LDADD = -l:searched_file_test_lib.a
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1static_SOURCES = ifuncmain1.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1static_LDADD = ifuncdep1.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1_SOURCES = ifuncmain1.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1_LDADD = ifuncmod1.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vis_SOURCES = ifuncmain1vis.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vis_LDADD = ifuncmod1.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2static_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2_LDFLAGS = -Bgcctestdir/
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain3_SOURCES = ifuncmain3.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain3_LDADD = -ldl
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4static_SOURCES = ifuncmain4.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4static_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4_SOURCES = ifuncmain4.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4_LDFLAGS = -Bgcctestdir/
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5static_SOURCES = ifuncmain5.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5static_LDADD = ifuncdep5.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5_SOURCES = ifuncmain5.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5_LDADD = ifuncmod5.so
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7static_SOURCES = ifuncmain7.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7static_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7_SOURCES = ifuncmain7.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7_LDFLAGS = -Bgcctestdir/
 @DEFAULT_TARGET_I386_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
 @DEFAULT_TARGET_X86_64_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
 all: $(BUILT_SOURCES)
@@ -1971,6 +2323,204 @@ exclude_libs_test$(EXEEXT): $(exclude_libs_test_OBJECTS) $(exclude_libs_test_DEP
 @NATIVE_LINKER_FALSE@icf_virtual_function_folding_test$(EXEEXT): $(icf_virtual_function_folding_test_OBJECTS) $(icf_virtual_function_folding_test_DEPENDENCIES) 
 @NATIVE_LINKER_FALSE@  @rm -f icf_virtual_function_folding_test$(EXEEXT)
 @NATIVE_LINKER_FALSE@  $(LINK) $(icf_virtual_function_folding_test_OBJECTS) $(icf_virtual_function_folding_test_LDADD) $(LIBS)
+ifuncmain1$(EXEEXT): $(ifuncmain1_OBJECTS) $(ifuncmain1_DEPENDENCIES) 
+       @rm -f ifuncmain1$(EXEEXT)
+       $(ifuncmain1_LINK) $(ifuncmain1_OBJECTS) $(ifuncmain1_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1pic$(EXEEXT): $(ifuncmain1pic_OBJECTS) $(ifuncmain1pic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1pic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1pic_OBJECTS) $(ifuncmain1pic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1pic$(EXEEXT): $(ifuncmain1pic_OBJECTS) $(ifuncmain1pic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1pic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1pic_OBJECTS) $(ifuncmain1pic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1pic$(EXEEXT): $(ifuncmain1pic_OBJECTS) $(ifuncmain1pic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1pic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1pic_OBJECTS) $(ifuncmain1pic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1picstatic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1picstatic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1picstatic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1pie$(EXEEXT): $(ifuncmain1pie_OBJECTS) $(ifuncmain1pie_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1pie$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1pie_OBJECTS) $(ifuncmain1pie_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1pie$(EXEEXT): $(ifuncmain1pie_OBJECTS) $(ifuncmain1pie_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1pie$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1pie_OBJECTS) $(ifuncmain1pie_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1pie$(EXEEXT): $(ifuncmain1pie_OBJECTS) $(ifuncmain1pie_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1pie$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1pie_OBJECTS) $(ifuncmain1pie_LDADD) $(LIBS)
+ifuncmain1static$(EXEEXT): $(ifuncmain1static_OBJECTS) $(ifuncmain1static_DEPENDENCIES) 
+       @rm -f ifuncmain1static$(EXEEXT)
+       $(ifuncmain1static_LINK) $(ifuncmain1static_OBJECTS) $(ifuncmain1static_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1staticpic$(EXEEXT): $(ifuncmain1staticpic_OBJECTS) $(ifuncmain1staticpic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1staticpic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1staticpic_OBJECTS) $(ifuncmain1staticpic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1staticpic$(EXEEXT): $(ifuncmain1staticpic_OBJECTS) $(ifuncmain1staticpic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1staticpic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1staticpic_OBJECTS) $(ifuncmain1staticpic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1staticpic$(EXEEXT): $(ifuncmain1staticpic_OBJECTS) $(ifuncmain1staticpic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1staticpic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1staticpic_OBJECTS) $(ifuncmain1staticpic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1staticpie$(EXEEXT): $(ifuncmain1staticpie_OBJECTS) $(ifuncmain1staticpie_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1staticpie$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1staticpie_OBJECTS) $(ifuncmain1staticpie_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1staticpie$(EXEEXT): $(ifuncmain1staticpie_OBJECTS) $(ifuncmain1staticpie_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1staticpie$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1staticpie_OBJECTS) $(ifuncmain1staticpie_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1staticpie$(EXEEXT): $(ifuncmain1staticpie_OBJECTS) $(ifuncmain1staticpie_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1staticpie$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1staticpie_OBJECTS) $(ifuncmain1staticpie_LDADD) $(LIBS)
+ifuncmain1vis$(EXEEXT): $(ifuncmain1vis_OBJECTS) $(ifuncmain1vis_DEPENDENCIES) 
+       @rm -f ifuncmain1vis$(EXEEXT)
+       $(ifuncmain1vis_LINK) $(ifuncmain1vis_OBJECTS) $(ifuncmain1vis_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1vispic$(EXEEXT): $(ifuncmain1vispic_OBJECTS) $(ifuncmain1vispic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1vispic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1vispic_OBJECTS) $(ifuncmain1vispic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1vispic$(EXEEXT): $(ifuncmain1vispic_OBJECTS) $(ifuncmain1vispic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1vispic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1vispic_OBJECTS) $(ifuncmain1vispic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1vispic$(EXEEXT): $(ifuncmain1vispic_OBJECTS) $(ifuncmain1vispic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1vispic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1vispic_OBJECTS) $(ifuncmain1vispic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain1vispie$(EXEEXT): $(ifuncmain1vispie_OBJECTS) $(ifuncmain1vispie_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain1vispie$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain1vispie_OBJECTS) $(ifuncmain1vispie_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain1vispie$(EXEEXT): $(ifuncmain1vispie_OBJECTS) $(ifuncmain1vispie_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain1vispie$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain1vispie_OBJECTS) $(ifuncmain1vispie_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain1vispie$(EXEEXT): $(ifuncmain1vispie_OBJECTS) $(ifuncmain1vispie_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain1vispie$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain1vispie_OBJECTS) $(ifuncmain1vispie_LDADD) $(LIBS)
+ifuncmain2$(EXEEXT): $(ifuncmain2_OBJECTS) $(ifuncmain2_DEPENDENCIES) 
+       @rm -f ifuncmain2$(EXEEXT)
+       $(ifuncmain2_LINK) $(ifuncmain2_OBJECTS) $(ifuncmain2_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain2pic$(EXEEXT): $(ifuncmain2pic_OBJECTS) $(ifuncmain2pic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain2pic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain2pic_OBJECTS) $(ifuncmain2pic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain2pic$(EXEEXT): $(ifuncmain2pic_OBJECTS) $(ifuncmain2pic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain2pic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain2pic_OBJECTS) $(ifuncmain2pic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain2pic$(EXEEXT): $(ifuncmain2pic_OBJECTS) $(ifuncmain2pic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain2pic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain2pic_OBJECTS) $(ifuncmain2pic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain2picstatic$(EXEEXT): $(ifuncmain2picstatic_OBJECTS) $(ifuncmain2picstatic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain2picstatic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain2picstatic_OBJECTS) $(ifuncmain2picstatic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain2picstatic$(EXEEXT): $(ifuncmain2picstatic_OBJECTS) $(ifuncmain2picstatic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain2picstatic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain2picstatic_OBJECTS) $(ifuncmain2picstatic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain2picstatic$(EXEEXT): $(ifuncmain2picstatic_OBJECTS) $(ifuncmain2picstatic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain2picstatic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain2picstatic_OBJECTS) $(ifuncmain2picstatic_LDADD) $(LIBS)
+ifuncmain2static$(EXEEXT): $(ifuncmain2static_OBJECTS) $(ifuncmain2static_DEPENDENCIES) 
+       @rm -f ifuncmain2static$(EXEEXT)
+       $(ifuncmain2static_LINK) $(ifuncmain2static_OBJECTS) $(ifuncmain2static_LDADD) $(LIBS)
+ifuncmain3$(EXEEXT): $(ifuncmain3_OBJECTS) $(ifuncmain3_DEPENDENCIES) 
+       @rm -f ifuncmain3$(EXEEXT)
+       $(ifuncmain3_LINK) $(ifuncmain3_OBJECTS) $(ifuncmain3_LDADD) $(LIBS)
+ifuncmain4$(EXEEXT): $(ifuncmain4_OBJECTS) $(ifuncmain4_DEPENDENCIES) 
+       @rm -f ifuncmain4$(EXEEXT)
+       $(ifuncmain4_LINK) $(ifuncmain4_OBJECTS) $(ifuncmain4_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain4picstatic$(EXEEXT): $(ifuncmain4picstatic_OBJECTS) $(ifuncmain4picstatic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain4picstatic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain4picstatic_OBJECTS) $(ifuncmain4picstatic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain4picstatic$(EXEEXT): $(ifuncmain4picstatic_OBJECTS) $(ifuncmain4picstatic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain4picstatic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain4picstatic_OBJECTS) $(ifuncmain4picstatic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain4picstatic$(EXEEXT): $(ifuncmain4picstatic_OBJECTS) $(ifuncmain4picstatic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain4picstatic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain4picstatic_OBJECTS) $(ifuncmain4picstatic_LDADD) $(LIBS)
+ifuncmain4static$(EXEEXT): $(ifuncmain4static_OBJECTS) $(ifuncmain4static_DEPENDENCIES) 
+       @rm -f ifuncmain4static$(EXEEXT)
+       $(ifuncmain4static_LINK) $(ifuncmain4static_OBJECTS) $(ifuncmain4static_LDADD) $(LIBS)
+ifuncmain5$(EXEEXT): $(ifuncmain5_OBJECTS) $(ifuncmain5_DEPENDENCIES) 
+       @rm -f ifuncmain5$(EXEEXT)
+       $(ifuncmain5_LINK) $(ifuncmain5_OBJECTS) $(ifuncmain5_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain5pic$(EXEEXT): $(ifuncmain5pic_OBJECTS) $(ifuncmain5pic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain5pic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain5pic_OBJECTS) $(ifuncmain5pic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain5pic$(EXEEXT): $(ifuncmain5pic_OBJECTS) $(ifuncmain5pic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain5pic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain5pic_OBJECTS) $(ifuncmain5pic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain5pic$(EXEEXT): $(ifuncmain5pic_OBJECTS) $(ifuncmain5pic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain5pic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain5pic_OBJECTS) $(ifuncmain5pic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain5picstatic$(EXEEXT): $(ifuncmain5picstatic_OBJECTS) $(ifuncmain5picstatic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain5picstatic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain5picstatic_OBJECTS) $(ifuncmain5picstatic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain5picstatic$(EXEEXT): $(ifuncmain5picstatic_OBJECTS) $(ifuncmain5picstatic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain5picstatic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain5picstatic_OBJECTS) $(ifuncmain5picstatic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain5picstatic$(EXEEXT): $(ifuncmain5picstatic_OBJECTS) $(ifuncmain5picstatic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain5picstatic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain5picstatic_OBJECTS) $(ifuncmain5picstatic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain5pie$(EXEEXT): $(ifuncmain5pie_OBJECTS) $(ifuncmain5pie_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain5pie$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain5pie_OBJECTS) $(ifuncmain5pie_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain5pie$(EXEEXT): $(ifuncmain5pie_OBJECTS) $(ifuncmain5pie_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain5pie$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain5pie_OBJECTS) $(ifuncmain5pie_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain5pie$(EXEEXT): $(ifuncmain5pie_OBJECTS) $(ifuncmain5pie_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain5pie$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain5pie_OBJECTS) $(ifuncmain5pie_LDADD) $(LIBS)
+ifuncmain5static$(EXEEXT): $(ifuncmain5static_OBJECTS) $(ifuncmain5static_DEPENDENCIES) 
+       @rm -f ifuncmain5static$(EXEEXT)
+       $(ifuncmain5static_LINK) $(ifuncmain5static_OBJECTS) $(ifuncmain5static_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain5staticpic$(EXEEXT): $(ifuncmain5staticpic_OBJECTS) $(ifuncmain5staticpic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain5staticpic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain5staticpic_OBJECTS) $(ifuncmain5staticpic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain5staticpic$(EXEEXT): $(ifuncmain5staticpic_OBJECTS) $(ifuncmain5staticpic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain5staticpic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain5staticpic_OBJECTS) $(ifuncmain5staticpic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain5staticpic$(EXEEXT): $(ifuncmain5staticpic_OBJECTS) $(ifuncmain5staticpic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain5staticpic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain5staticpic_OBJECTS) $(ifuncmain5staticpic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain6pie$(EXEEXT): $(ifuncmain6pie_OBJECTS) $(ifuncmain6pie_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain6pie$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain6pie_OBJECTS) $(ifuncmain6pie_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain6pie$(EXEEXT): $(ifuncmain6pie_OBJECTS) $(ifuncmain6pie_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain6pie$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain6pie_OBJECTS) $(ifuncmain6pie_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain6pie$(EXEEXT): $(ifuncmain6pie_OBJECTS) $(ifuncmain6pie_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain6pie$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain6pie_OBJECTS) $(ifuncmain6pie_LDADD) $(LIBS)
+ifuncmain7$(EXEEXT): $(ifuncmain7_OBJECTS) $(ifuncmain7_DEPENDENCIES) 
+       @rm -f ifuncmain7$(EXEEXT)
+       $(ifuncmain7_LINK) $(ifuncmain7_OBJECTS) $(ifuncmain7_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain7pic$(EXEEXT): $(ifuncmain7pic_OBJECTS) $(ifuncmain7pic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain7pic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain7pic_OBJECTS) $(ifuncmain7pic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain7pic$(EXEEXT): $(ifuncmain7pic_OBJECTS) $(ifuncmain7pic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain7pic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain7pic_OBJECTS) $(ifuncmain7pic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain7pic$(EXEEXT): $(ifuncmain7pic_OBJECTS) $(ifuncmain7pic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain7pic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain7pic_OBJECTS) $(ifuncmain7pic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain7picstatic$(EXEEXT): $(ifuncmain7picstatic_OBJECTS) $(ifuncmain7picstatic_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain7picstatic$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain7picstatic_OBJECTS) $(ifuncmain7picstatic_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain7picstatic$(EXEEXT): $(ifuncmain7picstatic_OBJECTS) $(ifuncmain7picstatic_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain7picstatic$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain7picstatic_OBJECTS) $(ifuncmain7picstatic_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain7picstatic$(EXEEXT): $(ifuncmain7picstatic_OBJECTS) $(ifuncmain7picstatic_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain7picstatic$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain7picstatic_OBJECTS) $(ifuncmain7picstatic_LDADD) $(LIBS)
+@GCC_FALSE@ifuncmain7pie$(EXEEXT): $(ifuncmain7pie_OBJECTS) $(ifuncmain7pie_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f ifuncmain7pie$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(ifuncmain7pie_OBJECTS) $(ifuncmain7pie_LDADD) $(LIBS)
+@IFUNC_FALSE@ifuncmain7pie$(EXEEXT): $(ifuncmain7pie_OBJECTS) $(ifuncmain7pie_DEPENDENCIES) 
+@IFUNC_FALSE@  @rm -f ifuncmain7pie$(EXEEXT)
+@IFUNC_FALSE@  $(LINK) $(ifuncmain7pie_OBJECTS) $(ifuncmain7pie_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@ifuncmain7pie$(EXEEXT): $(ifuncmain7pie_OBJECTS) $(ifuncmain7pie_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f ifuncmain7pie$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(ifuncmain7pie_OBJECTS) $(ifuncmain7pie_LDADD) $(LIBS)
+ifuncmain7static$(EXEEXT): $(ifuncmain7static_OBJECTS) $(ifuncmain7static_DEPENDENCIES) 
+       @rm -f ifuncmain7static$(EXEEXT)
+       $(ifuncmain7static_LINK) $(ifuncmain7static_OBJECTS) $(ifuncmain7static_LDADD) $(LIBS)
 initpri1$(EXEEXT): $(initpri1_OBJECTS) $(initpri1_DEPENDENCIES) 
        @rm -f initpri1$(EXEEXT)
        $(initpri1_LINK) $(initpri1_OBJECTS) $(initpri1_LDADD) $(LIBS)
@@ -2297,6 +2847,32 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile_and_compress_debug_sections.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icf_virtual_function_folding_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncdep2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1pic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1picstatic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1pie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1staticpic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1staticpie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1vis.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1vispic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain1vispie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain2pic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain2picstatic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain3.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain4picstatic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain5.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain5pic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain5picstatic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain5pie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain5staticpic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain6pie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain7.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain7pic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain7picstatic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifuncmain7pie.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initpri1.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/justsyms_1.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/large-large.Po@am__quote@
@@ -2886,6 +3462,66 @@ permission_test.log: permission_test$(EXEEXT)
        @p='permission_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 searched_file_test.log: searched_file_test$(EXEEXT)
        @p='searched_file_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1static.log: ifuncmain1static$(EXEEXT)
+       @p='ifuncmain1static$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1picstatic.log: ifuncmain1picstatic$(EXEEXT)
+       @p='ifuncmain1picstatic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1.log: ifuncmain1$(EXEEXT)
+       @p='ifuncmain1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1pic.log: ifuncmain1pic$(EXEEXT)
+       @p='ifuncmain1pic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1vis.log: ifuncmain1vis$(EXEEXT)
+       @p='ifuncmain1vis$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1vispic.log: ifuncmain1vispic$(EXEEXT)
+       @p='ifuncmain1vispic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1staticpic.log: ifuncmain1staticpic$(EXEEXT)
+       @p='ifuncmain1staticpic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1pie.log: ifuncmain1pie$(EXEEXT)
+       @p='ifuncmain1pie$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1vispie.log: ifuncmain1vispie$(EXEEXT)
+       @p='ifuncmain1vispie$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain1staticpie.log: ifuncmain1staticpie$(EXEEXT)
+       @p='ifuncmain1staticpie$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain2static.log: ifuncmain2static$(EXEEXT)
+       @p='ifuncmain2static$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain2picstatic.log: ifuncmain2picstatic$(EXEEXT)
+       @p='ifuncmain2picstatic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain2.log: ifuncmain2$(EXEEXT)
+       @p='ifuncmain2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain2pic.log: ifuncmain2pic$(EXEEXT)
+       @p='ifuncmain2pic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain3.log: ifuncmain3$(EXEEXT)
+       @p='ifuncmain3$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain4static.log: ifuncmain4static$(EXEEXT)
+       @p='ifuncmain4static$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain4picstatic.log: ifuncmain4picstatic$(EXEEXT)
+       @p='ifuncmain4picstatic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain4.log: ifuncmain4$(EXEEXT)
+       @p='ifuncmain4$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain5static.log: ifuncmain5static$(EXEEXT)
+       @p='ifuncmain5static$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain5picstatic.log: ifuncmain5picstatic$(EXEEXT)
+       @p='ifuncmain5picstatic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain5.log: ifuncmain5$(EXEEXT)
+       @p='ifuncmain5$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain5pic.log: ifuncmain5pic$(EXEEXT)
+       @p='ifuncmain5pic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain5staticpic.log: ifuncmain5staticpic$(EXEEXT)
+       @p='ifuncmain5staticpic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain5pie.log: ifuncmain5pie$(EXEEXT)
+       @p='ifuncmain5pie$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain6pie.log: ifuncmain6pie$(EXEEXT)
+       @p='ifuncmain6pie$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain7static.log: ifuncmain7static$(EXEEXT)
+       @p='ifuncmain7static$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain7picstatic.log: ifuncmain7picstatic$(EXEEXT)
+       @p='ifuncmain7picstatic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain7.log: ifuncmain7$(EXEEXT)
+       @p='ifuncmain7$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain7pic.log: ifuncmain7pic$(EXEEXT)
+       @p='ifuncmain7pic$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+ifuncmain7pie.log: ifuncmain7pie$(EXEEXT)
+       @p='ifuncmain7pie$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 .test.log:
        @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
 @am__EXEEXT_TRUE@.test$(EXEEXT).log:
@@ -3683,6 +4319,103 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -o $@ -c -fPIC $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@no_version_test.stdout: libno_version_test.so
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_OBJDUMP) -h $< > $@
+
+# Test STT_GNU_IFUNC symbols.
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod1.o: ifuncmod1.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod1.so: ifuncmod1.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -shared ifuncmod1.o
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncdep1.o: ifuncmod1.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -o $@ $<
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1pic.o: ifuncmain1.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1pie.o: ifuncmain1.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpie -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vispic.o: ifuncmain1vis.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vispie.o: ifuncmain1vis.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpie -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2pic.o: ifuncmain2.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncdep2pic.o: ifuncdep2.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod3.o: ifuncmod3.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod3.so: ifuncmod3.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -shared ifuncmod3.o
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4pic.o: ifuncmain4.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5pic.o: ifuncmain5.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5pie.o: ifuncmain5.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpie -o $@ $<
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod5.o: ifuncmod5.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod5.so: ifuncmod5.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -shared ifuncmod5.o
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncdep5.o: ifuncmod5.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain6pie.o: ifuncmain6pie.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpie -o $@ $<
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod6.o: ifuncmod6.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmod6.so: ifuncmod6.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -shared ifuncmod6.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7pic.o: ifuncmain7.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpic -o $@ $<
+
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7pie.o: ifuncmain7.c
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(COMPILE) -c -fpie -o $@ $<
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ ifuncmain7pic.o
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
+@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@     $(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
 @GCC_TRUE@@NATIVE_LINKER_TRUE@strong_ref_weak_def_2.o: strong_ref_weak_def_2.c
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -o $@ -c -fPIC $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@strong_ref_weak_def_2.so: strong_ref_weak_def_2.o gcctestdir/ld
diff --git a/gold/testsuite/ifunc-sel.h b/gold/testsuite/ifunc-sel.h
new file mode 100644 (file)
index 0000000..6a27b69
--- /dev/null
@@ -0,0 +1,26 @@
+/* Used by the elf ifunc tests.  */
+#ifndef ELF_IFUNC_SEL_H
+#define ELF_IFUNC_SEL_H 1
+
+extern int global;
+
+static inline void *
+ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void))
+{
+ switch (global)
+   {
+   case 1:
+     return f1;
+   case -1:
+     return f2;
+   default:
+     return f3;
+   }
+}
+
+static inline void *
+ifunc_one (int (*f1) (void))
+{
+  return f1;
+}
+#endif
diff --git a/gold/testsuite/ifuncdep2.c b/gold/testsuite/ifuncdep2.c
new file mode 100644 (file)
index 0000000..758bae1
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test 3 STT_GNU_IFUNC symbols.  */
+
+#include "ifunc-sel.h"
+
+int global __attribute__ ((visibility ("protected"))) = -1;
+
+static int
+one (void)
+{
+  return 1;
+}
+
+static int
+minus_one (void)
+{
+  return -1;
+}
+
+static int
+zero (void) 
+{
+  return 0;
+}
+
+void * foo1_ifunc (void) __asm__ ("foo1");
+__asm__(".type foo1, %gnu_indirect_function");
+
+void * 
+foo1_ifunc (void)
+{
+  return ifunc_sel (one, minus_one, zero);
+}
+
+void * foo2_ifunc (void) __asm__ ("foo2");
+__asm__(".type foo2, %gnu_indirect_function");
+
+void * 
+foo2_ifunc (void)
+{
+  return ifunc_sel (minus_one, one, zero);
+}
+
+void * foo3_ifunc (void) __asm__ ("foo3");
+__asm__(".type foo3, %gnu_indirect_function");
+
+void * 
+foo3_ifunc (void)
+{
+  return ifunc_sel (one, zero, minus_one);
+}
diff --git a/gold/testsuite/ifuncmain1.c b/gold/testsuite/ifuncmain1.c
new file mode 100644 (file)
index 0000000..cc1e5ec
--- /dev/null
@@ -0,0 +1,64 @@
+/* Test STT_GNU_IFUNC symbols:
+
+   1. Direct function call.
+   2. Function pointer.
+   3. Visibility without override.
+ */
+
+#include <stdlib.h>
+
+int ret_foo;
+int ret_foo_hidden;
+int ret_foo_protected;
+
+extern int foo (void);
+extern int foo_protected (void);
+
+#ifndef FOO_P
+typedef int (*foo_p) (void);
+#endif
+
+foo_p foo_ptr = foo;
+foo_p foo_procted_ptr = foo_protected;
+
+extern foo_p get_foo_p (void);
+extern foo_p get_foo_hidden_p (void);
+extern foo_p get_foo_protected_p (void);
+
+int
+main (void)
+{
+  foo_p p;
+  
+  if (foo_ptr != foo)
+    abort ();
+  if (foo () != -1)
+    abort ();
+  if ((*foo_ptr) () != -1)
+    abort ();
+
+  if (foo_procted_ptr != foo_protected)
+    abort ();
+  if (foo_protected () != 0)
+    abort ();
+  if ((*foo_procted_ptr) () != 0)
+    abort ();
+
+  p = get_foo_p ();
+  if (p != foo)
+    abort ();
+  if (ret_foo != -1 || (*p) () != ret_foo)
+    abort ();
+
+  p = get_foo_hidden_p ();
+  if (ret_foo_hidden != 1 || (*p) () != ret_foo_hidden)
+    abort ();
+
+  p = get_foo_protected_p ();
+  if (p != foo_protected)
+    abort ();
+  if (ret_foo_protected != 0 || (*p) () != ret_foo_protected)
+    abort ();
+
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmain1vis.c b/gold/testsuite/ifuncmain1vis.c
new file mode 100644 (file)
index 0000000..c16af63
--- /dev/null
@@ -0,0 +1,89 @@
+/* Test STT_GNU_IFUNC symbols:
+
+   1. Direct function call.
+   2. Function pointer.
+   3. Visibility with override.
+ */
+
+#include <stdlib.h>
+
+int __attribute__ ((noinline)) foo_hidden (void);
+
+int ret_foo;
+int ret_foo_hidden;
+int ret_foo_protected;
+
+extern int foo (void);
+extern int foo_protected (void);
+
+#ifndef FOO_P
+typedef int (*foo_p) (void);
+#endif
+
+foo_p foo_ptr = foo;
+foo_p foo_procted_ptr = foo_protected;
+
+extern foo_p get_foo_p (void);
+extern foo_p get_foo_hidden_p (void);
+extern foo_p get_foo_protected_p (void);
+
+int
+__attribute__ ((noinline))
+foo (void)
+{
+  return -30;
+}
+
+int
+__attribute__ ((noinline))
+foo_hidden (void)
+{
+  return -20;
+}
+
+int
+__attribute__ ((noinline))
+foo_protected (void)
+{
+  return -40;
+}
+
+int
+main (void)
+{
+  foo_p p;
+  
+  if (foo_ptr != foo)
+    abort ();
+  if ((*foo_ptr) () != -30)
+    abort ();
+
+  if (foo_procted_ptr != foo_protected)
+    abort ();
+  if ((*foo_procted_ptr) () != -40)
+    abort ();
+
+  p = get_foo_p ();
+  if (p != foo)
+    abort ();
+  if (foo () != -30)
+    abort ();
+  if (ret_foo != -30 || (*p) () != ret_foo)
+    abort ();
+
+  p = get_foo_hidden_p ();
+  if (foo_hidden () != -20)
+    abort ();
+  if (ret_foo_hidden != 1 || (*p) () != ret_foo_hidden)
+    abort ();
+
+  p = get_foo_protected_p ();
+  if (p == foo_protected)
+    abort ();
+  if (foo_protected () != -40)
+    abort ();
+  if (ret_foo_protected != 0 || (*p) () != ret_foo_protected)
+    abort ();
+
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmain2.c b/gold/testsuite/ifuncmain2.c
new file mode 100644 (file)
index 0000000..db3ba56
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test calling one STT_GNU_IFUNC function with 3 different
+   STT_GNU_IFUNC definitions.  */
+
+#include <stdlib.h>
+
+extern int foo1 (void);
+
+int
+main (void)
+{
+  if (foo1 () != -1)
+    abort ();
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmain3.c b/gold/testsuite/ifuncmain3.c
new file mode 100644 (file)
index 0000000..8e543e5
--- /dev/null
@@ -0,0 +1,133 @@
+/* Test STT_GNU_IFUNC symbols with dlopen:
+
+   1. Direct function call.
+   2. Function pointer.
+   3. Visibility with override.
+ */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+extern int __attribute__ ((noinline)) foo (void);
+extern int __attribute__ ((noinline)) foo_hidden (void);
+extern int __attribute__ ((noinline)) foo_protected (void);
+
+typedef int (*foo_p) (void);
+
+int
+__attribute__ ((noinline))
+foo (void)
+{
+  return -30;
+}
+
+int
+__attribute__ ((noinline))
+foo_hidden (void)
+{
+  return -20;
+}
+
+int
+__attribute__ ((noinline))
+foo_protected (void)
+{
+  return -40;
+}
+
+int
+main (void)
+{
+  foo_p p;
+  foo_p (*f) (void);
+  int *ret;
+
+  void *h = dlopen ("ifuncmod3.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("cannot load: %s\n", dlerror ());
+      return 1;
+    }
+
+  p = dlsym (h, "foo");
+  if (p == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+  if ((*p) () != -1)
+    abort ();
+
+  f = dlsym (h, "get_foo_p");
+  if (f == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  ret = dlsym (h, "ret_foo");
+  if (ret == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  p = (*f) ();
+  if (p != foo)
+    abort ();
+  if (foo () != -30)
+    abort ();
+  if (*ret != -30 || (*p) () != *ret)
+    abort ();
+
+  f = dlsym (h, "get_foo_hidden_p");
+  if (f == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  ret = dlsym (h, "ret_foo_hidden");
+  if (ret == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  p = (*f) ();
+  if (foo_hidden () != -20)
+    abort ();
+  if (*ret != 1 || (*p) () != *ret)
+    abort ();
+
+  f = dlsym (h, "get_foo_protected_p");
+  if (f == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  ret = dlsym (h, "ret_foo_protected");
+  if (ret == NULL)
+    {
+      printf ("symbol not found: %s\n", dlerror ());
+      return 1;
+    }
+
+  p = (*f) ();
+  if (p == foo_protected)
+    abort ();
+  if (foo_protected () != -40)
+    abort ();
+  if (*ret != 0 || (*p) () != *ret)
+    abort ();
+
+  if (dlclose (h) != 0)
+    {
+      printf ("cannot close: %s\n", dlerror ());
+      return 1;
+    }
+
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmain4.c b/gold/testsuite/ifuncmain4.c
new file mode 100644 (file)
index 0000000..e55fee2
--- /dev/null
@@ -0,0 +1,4 @@
+/* Test STT_GNU_IFUNC symbols in a single source file.  */
+
+#include "ifuncmod1.c"
+#include "ifuncmain1.c"
diff --git a/gold/testsuite/ifuncmain5.c b/gold/testsuite/ifuncmain5.c
new file mode 100644 (file)
index 0000000..9e6c2c1
--- /dev/null
@@ -0,0 +1,41 @@
+/* Test STT_GNU_IFUNC symbols with dynamic function pointer only.  */
+
+#include <stdlib.h>
+
+extern int foo (void);
+extern int foo_protected (void);
+
+typedef int (*foo_p) (void);
+
+extern foo_p __attribute__ ((noinline)) get_foo (void);
+extern foo_p __attribute__ ((noinline)) get_foo_protected (void);
+
+foo_p
+__attribute__ ((noinline))
+get_foo (void)
+{
+  return foo;
+}
+
+foo_p
+__attribute__ ((noinline))
+get_foo_protected (void)
+{
+  return foo_protected;
+}
+
+int
+main (void)
+{
+  foo_p p;
+
+  p = get_foo ();
+  if ((*p) () != -1)
+    abort ();
+
+  p = get_foo_protected ();
+  if ((*p) () != 0)
+    abort ();
+
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmain6pie.c b/gold/testsuite/ifuncmain6pie.c
new file mode 100644 (file)
index 0000000..8478d4c
--- /dev/null
@@ -0,0 +1,64 @@
+/* Test STT_GNU_IFUNC symbols in PIE:
+
+   1. Direct function call.
+   2. Function pointer.
+   3. Reference from a shared library.
+ */
+
+#include <stdlib.h>
+#include "ifunc-sel.h"
+
+typedef int (*foo_p) (void);
+extern foo_p foo_ptr;
+
+static int
+one (void)
+{
+  return -30;
+}
+
+void * foo_ifunc (void) __asm__ ("foo");
+__asm__(".type foo, %gnu_indirect_function");
+
+void *
+foo_ifunc (void)
+{
+  return ifunc_one (one);
+}
+
+extern int foo (void);
+extern foo_p get_foo (void);
+extern foo_p get_foo_p (void);
+
+foo_p my_foo_ptr = foo;
+
+int
+main (void)
+{
+  foo_p p;
+
+  p = get_foo ();
+  if (p != foo)
+    abort ();
+  if ((*p) () != -30)
+    abort ();
+
+  p = get_foo_p ();
+  if (p != foo)
+    abort ();
+  if ((*p) () != -30)
+    abort ();
+
+  if (foo_ptr != foo)
+    abort ();
+  if (my_foo_ptr != foo)
+    abort ();
+  if ((*foo_ptr) () != -30)
+    abort ();
+  if ((*my_foo_ptr) () != -30)
+    abort ();
+  if (foo () != -30)
+    abort ();
+
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmain7.c b/gold/testsuite/ifuncmain7.c
new file mode 100644 (file)
index 0000000..f6608ea
--- /dev/null
@@ -0,0 +1,74 @@
+/* Test local STT_GNU_IFUNC symbols:
+
+   1. Direct function call.
+   2. Function pointer.
+ */
+
+#include <stdlib.h>
+#include "ifunc-sel.h"
+
+extern int foo (void);
+
+static int
+one (void)
+{
+  return -30;
+}
+
+static void * foo_ifunc (void) __asm__ ("foo");
+__asm__(".type foo, %gnu_indirect_function");
+
+static void *
+__attribute__ ((used))
+foo_ifunc (void)
+{
+  return ifunc_one (one);
+}
+
+typedef int (*foo_p) (void);
+
+extern foo_p __attribute__ ((noinline)) get_foo_p (void);
+extern foo_p __attribute__ ((noinline)) get_foo (void);
+
+foo_p foo_ptr = foo;
+
+foo_p
+__attribute__ ((noinline))
+get_foo_p (void)
+{
+  return foo_ptr;
+}
+
+foo_p
+__attribute__ ((noinline))
+get_foo (void)
+{
+  return foo;
+}
+
+int
+main (void)
+{
+  foo_p p;
+
+  p = get_foo ();
+  if (p != foo)
+    abort ();
+  if ((*p) () != -30)
+    abort ();
+
+  p = get_foo_p ();
+  if (p != foo)
+    abort ();
+  if ((*p) () != -30)
+    abort ();
+
+  if (foo_ptr != foo)
+    abort ();
+  if ((*foo_ptr) () != -30)
+    abort ();
+  if (foo () != -30)
+    abort ();
+
+  return 0;
+}
diff --git a/gold/testsuite/ifuncmod1.c b/gold/testsuite/ifuncmod1.c
new file mode 100644 (file)
index 0000000..e3b37cb
--- /dev/null
@@ -0,0 +1,95 @@
+/* Test STT_GNU_IFUNC symbols:
+
+   1. Direct function call.
+   2. Function pointer.
+   3. Visibility.
+ */
+#include "ifunc-sel.h"
+
+int global __attribute__ ((visibility ("protected"))) = -1;
+
+static int
+one (void)
+{
+  return 1;
+}
+
+static int
+minus_one (void)
+{
+  return -1;
+}
+
+static int
+zero (void)
+{
+  return 0;
+}
+
+void * foo_ifunc (void) __asm__ ("foo");
+__asm__(".type foo, %gnu_indirect_function");
+
+void *
+foo_ifunc (void)
+{
+  return ifunc_sel (one, minus_one, zero);
+}
+
+void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
+__asm__(".type foo_hidden, %gnu_indirect_function");
+
+void *
+foo_hidden_ifunc (void)
+{
+  return ifunc_sel (minus_one, one, zero);
+}
+
+void * foo_protected_ifunc (void) __asm__ ("foo_protected");
+__asm__(".type foo_protected, %gnu_indirect_function");
+
+void *
+foo_protected_ifunc (void)
+{
+  return ifunc_sel (one, zero, minus_one);
+}
+
+/* Test hidden indirect function.  */
+__asm__(".hidden foo_hidden");
+
+/* Test protected indirect function.  */
+__asm__(".protected foo_protected");
+
+extern int foo (void);
+extern int foo_hidden (void);
+extern int foo_protected (void);
+extern int ret_foo;
+extern int ret_foo_hidden;
+extern int ret_foo_protected;
+
+#define FOO_P
+typedef int (*foo_p) (void);
+
+extern foo_p get_foo_p (void);
+extern foo_p get_foo_hidden_p (void);
+extern foo_p get_foo_protected_p (void);
+
+foo_p
+get_foo_p (void)
+{
+  ret_foo = foo ();
+  return foo;
+}
+
+foo_p
+get_foo_hidden_p (void)
+{
+  ret_foo_hidden = foo_hidden ();
+  return foo_hidden;
+}
+
+foo_p
+get_foo_protected_p (void)
+{
+  ret_foo_protected = foo_protected ();
+  return foo_protected;
+}
diff --git a/gold/testsuite/ifuncmod3.c b/gold/testsuite/ifuncmod3.c
new file mode 100644 (file)
index 0000000..ca2d962
--- /dev/null
@@ -0,0 +1,7 @@
+/* Test STT_GNU_IFUNC symbols with dlopen.  */
+
+#include "ifuncmod1.c"
+
+int ret_foo;
+int ret_foo_hidden;
+int ret_foo_protected;
diff --git a/gold/testsuite/ifuncmod5.c b/gold/testsuite/ifuncmod5.c
new file mode 100644 (file)
index 0000000..9a08e8c
--- /dev/null
@@ -0,0 +1,55 @@
+/* Test STT_GNU_IFUNC symbols without direct function call.  */
+#include "ifunc-sel.h"
+
+int global __attribute__ ((visibility ("protected"))) = -1;
+
+static int
+one (void)
+{
+  return 1;
+}
+
+static int
+minus_one (void)
+{
+  return -1;
+}
+
+static int
+zero (void)
+{
+  return 0;
+}
+
+void * foo_ifunc (void) __asm__ ("foo");
+__asm__(".type foo, %gnu_indirect_function");
+
+void *
+foo_ifunc (void)
+{
+  return ifunc_sel (one, minus_one, zero);
+}
+
+void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
+__asm__(".type foo_hidden, %gnu_indirect_function");
+
+void *
+foo_hidden_ifunc (void)
+{
+  return ifunc_sel (minus_one, one, zero);
+}
+
+void * foo_protected_ifunc (void) __asm__ ("foo_protected");
+__asm__(".type foo_protected, %gnu_indirect_function");
+
+void *
+foo_protected_ifunc (void)
+{
+  return ifunc_sel (one, zero, minus_one);
+}
+
+/* Test hidden indirect function.  */
+__asm__(".hidden foo_hidden");
+
+/* Test protected indirect function.  */
+__asm__(".protected foo_protected");
diff --git a/gold/testsuite/ifuncmod6.c b/gold/testsuite/ifuncmod6.c
new file mode 100644 (file)
index 0000000..89a50f9
--- /dev/null
@@ -0,0 +1,22 @@
+/* Test STT_GNU_IFUNC symbol reference in a shared library.  */
+
+extern int foo (void);
+
+typedef int (*foo_p) (void);
+
+extern foo_p get_foo_p (void);
+extern foo_p get_foo (void);
+
+foo_p foo_ptr = foo;
+
+foo_p
+get_foo_p (void)
+{
+  return foo_ptr;
+}
+
+foo_p
+get_foo (void)
+{
+  return foo;
+}
index df46f2b9771b13dfe9368481add688863b2b1ba9..b137db3c2d001e33aaeea34a5b4e732b748fd75c 100644 (file)
@@ -46,7 +46,115 @@ namespace
 
 using namespace gold;
 
-class Output_data_plt_x86_64;
+// A class to handle the PLT data.
+
+class Output_data_plt_x86_64 : public Output_section_data
+{
+ public:
+  typedef Output_data_reloc<elfcpp::SHT_RELA, true, 64, false> Reloc_section;
+
+  Output_data_plt_x86_64(Symbol_table*, Layout*, Output_data_got<64, false>*,
+                         Output_data_space*);
+
+  // Add an entry to the PLT.
+  void
+  add_entry(Symbol* gsym);
+
+  // Add an entry to the PLT for a local STT_GNU_IFUNC symbol.
+  unsigned int
+  add_local_ifunc_entry(Sized_relobj<64, false>* relobj,
+                       unsigned int local_sym_index);
+
+  // Add the reserved TLSDESC_PLT entry to the PLT.
+  void
+  reserve_tlsdesc_entry(unsigned int got_offset)
+  { this->tlsdesc_got_offset_ = got_offset; }
+
+  // Return true if a TLSDESC_PLT entry has been reserved.
+  bool
+  has_tlsdesc_entry() const
+  { return this->tlsdesc_got_offset_ != -1U; }
+
+  // Return the GOT offset for the reserved TLSDESC_PLT entry.
+  unsigned int
+  get_tlsdesc_got_offset() const
+  { return this->tlsdesc_got_offset_; }
+
+  // Return the offset of the reserved TLSDESC_PLT entry.
+  unsigned int
+  get_tlsdesc_plt_offset() const
+  { return (this->count_ + 1) * plt_entry_size; }
+
+  // Return the .rela.plt section data.
+  Reloc_section*
+  rela_plt()
+  { return this->rel_; }
+
+  // Return where the TLSDESC relocations should go.
+  Reloc_section*
+  rela_tlsdesc(Layout*);
+
+  // Return the number of PLT entries.
+  unsigned int
+  entry_count() const
+  { return this->count_; }
+
+  // Return the offset of the first non-reserved PLT entry.
+  static unsigned int
+  first_plt_entry_offset()
+  { return plt_entry_size; }
+
+  // Return the size of a PLT entry.
+  static unsigned int
+  get_plt_entry_size()
+  { return plt_entry_size; }
+
+ protected:
+  void
+  do_adjust_output_section(Output_section* os);
+
+  // Write to a map file.
+  void
+  do_print_to_mapfile(Mapfile* mapfile) const
+  { mapfile->print_output_data(this, _("** PLT")); }
+
+ private:
+  // The size of an entry in the PLT.
+  static const int plt_entry_size = 16;
+
+  // The first entry in the PLT.
+  // From the AMD64 ABI: "Unlike Intel386 ABI, this ABI uses the same
+  // procedure linkage table for both programs and shared objects."
+  static unsigned char first_plt_entry[plt_entry_size];
+
+  // Other entries in the PLT for an executable.
+  static unsigned char plt_entry[plt_entry_size];
+
+  // The reserved TLSDESC entry in the PLT for an executable.
+  static unsigned char tlsdesc_plt_entry[plt_entry_size];
+
+  // Set the final size.
+  void
+  set_final_data_size();
+
+  // Write out the PLT data.
+  void
+  do_write(Output_file*);
+
+  // The reloc section.
+  Reloc_section* rel_;
+  // The TLSDESC relocs, if necessary.  These must follow the regular
+  // PLT relocs.
+  Reloc_section* tlsdesc_rel_;
+  // The .got section.
+  Output_data_got<64, false>* got_;
+  // The .got.plt section.
+  Output_data_space* got_plt_;
+  // The number of PLT entries.
+  unsigned int count_;
+  // Offset of the reserved TLSDESC_GOT entry when needed.
+  unsigned int tlsdesc_got_offset_;
+};
 
 // The x86_64 target class.
 // See the ABI at
@@ -188,6 +296,15 @@ class Target_x86_64 : public Target_freebsd<64, false>
   uint64_t
   do_reloc_addend(void* arg, unsigned int r_type, uint64_t addend) const;
 
+  // Return the PLT section.
+  Output_data*
+  do_plt_section_for_global(const Symbol*) const
+  { return this->plt_section(); }
+
+  Output_data*
+  do_plt_section_for_local(const Relobj*, unsigned int) const
+  { return this->plt_section(); }
+
   // Adjust -fstack-split code which calls non-stack-split code.
   void
   do_calls_non_split(Relobj* object, unsigned int shndx,
@@ -291,6 +408,9 @@ class Target_x86_64 : public Target_freebsd<64, false>
     inline bool
     possible_function_pointer_reloc(unsigned int r_type);
 
+    bool
+    reloc_needs_plt_for_ifunc(Sized_relobj<64, false>*, unsigned int r_type);
+
     // Whether we have issued an error about a non-PIC compilation.
     bool issued_non_pic_error_;
   };
@@ -441,6 +561,12 @@ class Target_x86_64 : public Target_freebsd<64, false>
   void
   make_plt_entry(Symbol_table*, Layout*, Symbol*);
 
+  // Create a PLT entry for a local STT_GNU_IFUNC symbol.
+  void
+  make_local_ifunc_plt_entry(Symbol_table*, Layout*,
+                            Sized_relobj<64, false>* relobj,
+                            unsigned int local_sym_index);
+
   // Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
   void
   define_tls_base_symbol(Symbol_table*, Layout*);
@@ -641,116 +767,12 @@ Target_x86_64::rela_dyn_section(Layout* layout)
   return this->rela_dyn_;
 }
 
-// A class to handle the PLT data.
-
-class Output_data_plt_x86_64 : public Output_section_data
-{
- public:
-  typedef Output_data_reloc<elfcpp::SHT_RELA, true, 64, false> Reloc_section;
-
-  Output_data_plt_x86_64(Layout*, Output_data_got<64, false>*,
-                         Output_data_space*);
-
-  // Add an entry to the PLT.
-  void
-  add_entry(Symbol* gsym);
-
-  // Add the reserved TLSDESC_PLT entry to the PLT.
-  void
-  reserve_tlsdesc_entry(unsigned int got_offset)
-  { this->tlsdesc_got_offset_ = got_offset; }
-
-  // Return true if a TLSDESC_PLT entry has been reserved.
-  bool
-  has_tlsdesc_entry() const
-  { return this->tlsdesc_got_offset_ != -1U; }
-
-  // Return the GOT offset for the reserved TLSDESC_PLT entry.
-  unsigned int
-  get_tlsdesc_got_offset() const
-  { return this->tlsdesc_got_offset_; }
-
-  // Return the offset of the reserved TLSDESC_PLT entry.
-  unsigned int
-  get_tlsdesc_plt_offset() const
-  { return (this->count_ + 1) * plt_entry_size; }
-
-  // Return the .rela.plt section data.
-  const Reloc_section*
-  rela_plt() const
-  { return this->rel_; }
-
-  // Return where the TLSDESC relocations should go.
-  Reloc_section*
-  rela_tlsdesc(Layout*);
-
-  // Return the number of PLT entries.
-  unsigned int
-  entry_count() const
-  { return this->count_; }
-
-  // Return the offset of the first non-reserved PLT entry.
-  static unsigned int
-  first_plt_entry_offset()
-  { return plt_entry_size; }
-
-  // Return the size of a PLT entry.
-  static unsigned int
-  get_plt_entry_size()
-  { return plt_entry_size; }
-
- protected:
-  void
-  do_adjust_output_section(Output_section* os);
-
-  // Write to a map file.
-  void
-  do_print_to_mapfile(Mapfile* mapfile) const
-  { mapfile->print_output_data(this, _("** PLT")); }
-
- private:
-  // The size of an entry in the PLT.
-  static const int plt_entry_size = 16;
-
-  // The first entry in the PLT.
-  // From the AMD64 ABI: "Unlike Intel386 ABI, this ABI uses the same
-  // procedure linkage table for both programs and shared objects."
-  static unsigned char first_plt_entry[plt_entry_size];
-
-  // Other entries in the PLT for an executable.
-  static unsigned char plt_entry[plt_entry_size];
-
-  // The reserved TLSDESC entry in the PLT for an executable.
-  static unsigned char tlsdesc_plt_entry[plt_entry_size];
-
-  // Set the final size.
-  void
-  set_final_data_size();
-
-  // Write out the PLT data.
-  void
-  do_write(Output_file*);
-
-  // The reloc section.
-  Reloc_section* rel_;
-  // The TLSDESC relocs, if necessary.  These must follow the regular
-  // PLT relocs.
-  Reloc_section* tlsdesc_rel_;
-  // The .got section.
-  Output_data_got<64, false>* got_;
-  // The .got.plt section.
-  Output_data_space* got_plt_;
-  // The number of PLT entries.
-  unsigned int count_;
-  // Offset of the reserved TLSDESC_GOT entry when needed.
-  unsigned int tlsdesc_got_offset_;
-};
-
 // Create the PLT section.  The ordinary .got section is an argument,
 // since we need to refer to the start.  We also create our own .got
 // section just for PLT entries.
 
-Output_data_plt_x86_64::Output_data_plt_x86_64(Layout* layout,
+Output_data_plt_x86_64::Output_data_plt_x86_64(Symbol_table* symtab,
+                                              Layout* layout,
                                                Output_data_got<64, false>* got,
                                                Output_data_space* got_plt)
   : Output_section_data(8), tlsdesc_rel_(NULL), got_(got), got_plt_(got_plt),
@@ -760,6 +782,24 @@ Output_data_plt_x86_64::Output_data_plt_x86_64(Layout* layout,
   layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA,
                                  elfcpp::SHF_ALLOC, this->rel_,
                                  ORDER_DYNAMIC_PLT_RELOCS, false);
+
+  if (parameters->doing_static_link())
+    {
+      // A statically linked executable will only have a .rela.plt
+      // section to hold R_X86_64_IRELATIVE relocs for STT_GNU_IFUNC
+      // symbols.  The library will use these symbols to locate the
+      // IRELATIVE relocs at program startup time.
+      symtab->define_in_output_data("__rela_iplt_start", NULL,
+                                   Symbol_table::PREDEFINED,
+                                   this->rel_, 0, 0, elfcpp::STT_NOTYPE,
+                                   elfcpp::STB_GLOBAL, elfcpp::STV_HIDDEN,
+                                   0, false, true);
+      symtab->define_in_output_data("__rela_iplt_end", NULL,
+                                   Symbol_table::PREDEFINED,
+                                   this->rel_, 0, 0, elfcpp::STT_NOTYPE,
+                                   elfcpp::STB_GLOBAL, elfcpp::STV_HIDDEN,
+                                   0, true, true);
+    }
 }
 
 void
@@ -789,15 +829,46 @@ Output_data_plt_x86_64::add_entry(Symbol* gsym)
   this->got_plt_->set_current_data_size(got_offset + 8);
 
   // Every PLT entry needs a reloc.
-  gsym->set_needs_dynsym_entry();
-  this->rel_->add_global(gsym, elfcpp::R_X86_64_JUMP_SLOT, this->got_plt_,
-                        got_offset, 0);
+  if (gsym->type() == elfcpp::STT_GNU_IFUNC
+      && gsym->can_use_relative_reloc(false))
+    this->rel_->add_symbolless_global_addend(gsym, elfcpp::R_X86_64_IRELATIVE,
+                                            this->got_plt_, got_offset, 0);
+  else
+    {
+      gsym->set_needs_dynsym_entry();
+      this->rel_->add_global(gsym, elfcpp::R_X86_64_JUMP_SLOT, this->got_plt_,
+                            got_offset, 0);
+    }
 
   // Note that we don't need to save the symbol.  The contents of the
   // PLT are independent of which symbols are used.  The symbols only
   // appear in the relocations.
 }
 
+// Add an entry to the PLT for a local STT_GNU_IFUNC symbol.  Return
+// the PLT offset.
+
+unsigned int
+Output_data_plt_x86_64::add_local_ifunc_entry(Sized_relobj<64, false>* relobj,
+                                             unsigned int local_sym_index)
+{
+  unsigned int plt_offset = (this->count_ + 1) * plt_entry_size;
+  ++this->count_;
+
+  section_offset_type got_offset = this->got_plt_->current_data_size();
+
+  // Every PLT entry needs a GOT entry which points back to the PLT
+  // entry.
+  this->got_plt_->set_current_data_size(got_offset + 8);
+
+  // Every PLT entry needs a reloc.
+  this->rel_->add_symbolless_local_addend(relobj, local_sym_index,
+                                         elfcpp::R_X86_64_IRELATIVE,
+                                         this->got_plt_, got_offset, 0);
+
+  return plt_offset;
+}
+
 // Return where the TLSDESC relocations should go, creating it if
 // necessary.  These follow the JUMP_SLOT relocations.
 
@@ -968,12 +1039,16 @@ Target_x86_64::make_plt_section(Symbol_table* symtab, Layout* layout)
       // Create the GOT sections first.
       this->got_section(symtab, layout);
 
-      this->plt_ = new Output_data_plt_x86_64(layout, this->got_,
+      this->plt_ = new Output_data_plt_x86_64(symtab, layout, this->got_,
                                               this->got_plt_);
       layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
                                      (elfcpp::SHF_ALLOC
                                       | elfcpp::SHF_EXECINSTR),
                                      this->plt_, ORDER_PLT, false);
+
+      // Make the sh_info field of .rela.plt point to .plt.
+      Output_section* rela_plt_os = this->plt_->rela_plt()->output_section();
+      rela_plt_os->set_info_section(this->plt_->output_section());
     }
 }
 
@@ -1000,6 +1075,22 @@ Target_x86_64::make_plt_entry(Symbol_table* symtab, Layout* layout,
   this->plt_->add_entry(gsym);
 }
 
+// Make a PLT entry for a local STT_GNU_IFUNC symbol.
+
+void
+Target_x86_64::make_local_ifunc_plt_entry(Symbol_table* symtab, Layout* layout,
+                                         Sized_relobj<64, false>* relobj,
+                                         unsigned int local_sym_index)
+{
+  if (relobj->local_has_plt_offset(local_sym_index))
+    return;
+  if (this->plt_ == NULL)
+    this->make_plt_section(symtab, layout);
+  unsigned int plt_offset = this->plt_->add_local_ifunc_entry(relobj,
+                                                             local_sym_index);
+  relobj->set_local_plt_offset(local_sym_index, plt_offset);
+}
+
 // Return the number of entries in the PLT.
 
 unsigned int
@@ -1172,6 +1263,7 @@ Target_x86_64::Scan::check_non_pic(Relobj* object, unsigned int r_type)
     {
       // These are the relocation types supported by glibc for x86_64.
     case elfcpp::R_X86_64_RELATIVE:
+    case elfcpp::R_X86_64_IRELATIVE:
     case elfcpp::R_X86_64_GLOB_DAT:
     case elfcpp::R_X86_64_JUMP_SLOT:
     case elfcpp::R_X86_64_DTPMOD64:
@@ -1200,6 +1292,72 @@ Target_x86_64::Scan::check_non_pic(Relobj* object, unsigned int r_type)
     }
 }
 
+// Return whether we need to make a PLT entry for a relocation of the
+// given type against a STT_GNU_IFUNC symbol.
+
+bool
+Target_x86_64::Scan::reloc_needs_plt_for_ifunc(Sized_relobj<64, false>* object,
+                                              unsigned int r_type)
+{
+  switch (r_type)
+    {
+    case elfcpp::R_X86_64_NONE:
+    case elfcpp::R_X86_64_GNU_VTINHERIT:
+    case elfcpp::R_X86_64_GNU_VTENTRY:
+      return false;
+
+    case elfcpp::R_X86_64_64:
+    case elfcpp::R_X86_64_32:
+    case elfcpp::R_X86_64_32S:
+    case elfcpp::R_X86_64_16:
+    case elfcpp::R_X86_64_8:
+    case elfcpp::R_X86_64_PC64:
+    case elfcpp::R_X86_64_PC32:
+    case elfcpp::R_X86_64_PC16:
+    case elfcpp::R_X86_64_PC8:
+    case elfcpp::R_X86_64_PLT32:
+    case elfcpp::R_X86_64_GOTPC32:
+    case elfcpp::R_X86_64_GOTOFF64:
+    case elfcpp::R_X86_64_GOTPC64:
+    case elfcpp::R_X86_64_PLTOFF64:
+    case elfcpp::R_X86_64_GOT64:
+    case elfcpp::R_X86_64_GOT32:
+    case elfcpp::R_X86_64_GOTPCREL64:
+    case elfcpp::R_X86_64_GOTPCREL:
+    case elfcpp::R_X86_64_GOTPLT64:
+      return true;
+
+    case elfcpp::R_X86_64_COPY:
+    case elfcpp::R_X86_64_GLOB_DAT:
+    case elfcpp::R_X86_64_JUMP_SLOT:
+    case elfcpp::R_X86_64_RELATIVE:
+    case elfcpp::R_X86_64_IRELATIVE:
+    case elfcpp::R_X86_64_TPOFF64:
+    case elfcpp::R_X86_64_DTPMOD64:
+    case elfcpp::R_X86_64_TLSDESC:
+      // We will give an error later.
+      return false;
+
+    case elfcpp::R_X86_64_TLSGD:
+    case elfcpp::R_X86_64_GOTPC32_TLSDESC:
+    case elfcpp::R_X86_64_TLSDESC_CALL:
+    case elfcpp::R_X86_64_TLSLD:
+    case elfcpp::R_X86_64_DTPOFF32:
+    case elfcpp::R_X86_64_DTPOFF64:
+    case elfcpp::R_X86_64_GOTTPOFF:
+    case elfcpp::R_X86_64_TPOFF32:
+      gold_error(_("%s: unsupported TLS reloc %u for IFUNC symbol"),
+                object->name().c_str(), r_type);
+      return false;
+
+    case elfcpp::R_X86_64_SIZE32:
+    case elfcpp::R_X86_64_SIZE64:
+    default:
+      // We will give an error later.
+      return false;
+    }
+}
+
 // Scan a relocation for a local symbol.
 
 inline void
@@ -1213,6 +1371,14 @@ Target_x86_64::Scan::local(Symbol_table* symtab,
                            unsigned int r_type,
                            const elfcpp::Sym<64, false>& lsym)
 {
+  // A local STT_GNU_IFUNC symbol may require a PLT entry.
+  if (lsym.get_st_type() == elfcpp::STT_GNU_IFUNC
+      && this->reloc_needs_plt_for_ifunc(object, r_type))
+    {
+      unsigned int r_sym = elfcpp::elf_r_sym<64>(reloc.get_r_info());
+      target->make_local_ifunc_plt_entry(symtab, layout, object, r_sym);
+    }
+
   switch (r_type)
     {
     case elfcpp::R_X86_64_NONE:
@@ -1231,11 +1397,11 @@ Target_x86_64::Scan::local(Symbol_table* symtab,
         {
           unsigned int r_sym = elfcpp::elf_r_sym<64>(reloc.get_r_info());
           Reloc_section* rela_dyn = target->rela_dyn_section(layout);
-          rela_dyn->add_local_relative(object, r_sym,
-                                       elfcpp::R_X86_64_RELATIVE,
-                                       output_section, data_shndx,
-                                       reloc.get_r_offset(),
-                                       reloc.get_r_addend());
+         rela_dyn->add_local_relative(object, r_sym,
+                                      elfcpp::R_X86_64_RELATIVE,
+                                      output_section, data_shndx,
+                                      reloc.get_r_offset(),
+                                      reloc.get_r_addend());
         }
       break;
 
@@ -1306,7 +1472,16 @@ Target_x86_64::Scan::local(Symbol_table* symtab,
         // The symbol requires a GOT entry.
         Output_data_got<64, false>* got = target->got_section(symtab, layout);
         unsigned int r_sym = elfcpp::elf_r_sym<64>(reloc.get_r_info());
-        if (got->add_local(object, r_sym, GOT_TYPE_STANDARD))
+
+       // For a STT_GNU_IFUNC symbol we want the PLT offset.  That
+       // lets function pointers compare correctly with shared
+       // libraries.  Otherwise we would need an IRELATIVE reloc.
+       bool is_new;
+       if (lsym.get_st_type() == elfcpp::STT_GNU_IFUNC)
+         is_new = got->add_local_plt(object, r_sym, GOT_TYPE_STANDARD);
+       else
+         is_new = got->add_local(object, r_sym, GOT_TYPE_STANDARD);
+        if (is_new)
           {
             // If we are generating a shared object, we need to add a
             // dynamic relocation for this symbol's GOT entry.
@@ -1315,9 +1490,13 @@ Target_x86_64::Scan::local(Symbol_table* symtab,
                 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
                // R_X86_64_RELATIVE assumes a 64-bit relocation.
                if (r_type != elfcpp::R_X86_64_GOT32)
-                  rela_dyn->add_local_relative(
-                      object, r_sym, elfcpp::R_X86_64_RELATIVE, got,
-                      object->local_got_offset(r_sym, GOT_TYPE_STANDARD), 0);
+                 {
+                   unsigned int got_offset =
+                     object->local_got_offset(r_sym, GOT_TYPE_STANDARD);
+                   rela_dyn->add_local_relative(object, r_sym,
+                                                elfcpp::R_X86_64_RELATIVE,
+                                                got, got_offset, 0);
+                 }
                 else
                   {
                     this->check_non_pic(object, r_type);
@@ -1338,6 +1517,7 @@ Target_x86_64::Scan::local(Symbol_table* symtab,
     case elfcpp::R_X86_64_GLOB_DAT:
     case elfcpp::R_X86_64_JUMP_SLOT:
     case elfcpp::R_X86_64_RELATIVE:
+    case elfcpp::R_X86_64_IRELATIVE:
       // These are outstanding tls relocs, which are unexpected when linking
     case elfcpp::R_X86_64_TPOFF64:
     case elfcpp::R_X86_64_DTPMOD64:
@@ -1571,6 +1751,11 @@ Target_x86_64::Scan::global(Symbol_table* symtab,
                             unsigned int r_type,
                             Symbol* gsym)
 {
+  // A STT_GNU_IFUNC symbol may require a PLT entry.
+  if (gsym->type() == elfcpp::STT_GNU_IFUNC
+      && this->reloc_needs_plt_for_ifunc(object, r_type))
+    target->make_plt_entry(symtab, layout, gsym);
+
   switch (r_type)
     {
     case elfcpp::R_X86_64_NONE:
@@ -1603,14 +1788,34 @@ Target_x86_64::Scan::global(Symbol_table* symtab,
                 target->copy_reloc(symtab, layout, object,
                                    data_shndx, output_section, gsym, reloc);
               }
+           else if (r_type == elfcpp::R_X86_64_64
+                    && gsym->type() == elfcpp::STT_GNU_IFUNC
+                    && gsym->can_use_relative_reloc(false)
+                    && !gsym->is_from_dynobj()
+                    && !gsym->is_undefined()
+                    && !gsym->is_preemptible())
+             {
+               // Use an IRELATIVE reloc for a locally defined
+               // STT_GNU_IFUNC symbol.  This makes a function
+               // address in a PIE executable match the address in a
+               // shared library that it links against.
+               Reloc_section* rela_dyn = target->rela_dyn_section(layout);
+               unsigned int r_type = elfcpp::R_X86_64_IRELATIVE;
+               rela_dyn->add_symbolless_global_addend(gsym, r_type,
+                                                      output_section, object,
+                                                      data_shndx,
+                                                      reloc.get_r_offset(),
+                                                      reloc.get_r_addend());
+             }
             else if (r_type == elfcpp::R_X86_64_64
                      && gsym->can_use_relative_reloc(false))
               {
                 Reloc_section* rela_dyn = target->rela_dyn_section(layout);
-                rela_dyn->add_global_relative(gsym, elfcpp::R_X86_64_RELATIVE,
-                                              output_section, object,
-                                              data_shndx, reloc.get_r_offset(),
-                                              reloc.get_r_addend());
+               rela_dyn->add_global_relative(gsym, elfcpp::R_X86_64_RELATIVE,
+                                             output_section, object,
+                                             data_shndx,
+                                             reloc.get_r_offset(),
+                                             reloc.get_r_addend());
               }
             else
               {
@@ -1664,23 +1869,49 @@ Target_x86_64::Scan::global(Symbol_table* symtab,
         // The symbol requires a GOT entry.
         Output_data_got<64, false>* got = target->got_section(symtab, layout);
         if (gsym->final_value_is_known())
-          got->add_global(gsym, GOT_TYPE_STANDARD);
+         {
+           // For a STT_GNU_IFUNC symbol we want the PLT address.
+           if (gsym->type() == elfcpp::STT_GNU_IFUNC)
+             got->add_global_plt(gsym, GOT_TYPE_STANDARD);
+           else
+             got->add_global(gsym, GOT_TYPE_STANDARD);
+         }
         else
           {
             // If this symbol is not fully resolved, we need to add a
             // dynamic relocation for it.
             Reloc_section* rela_dyn = target->rela_dyn_section(layout);
-            if (gsym->is_from_dynobj()
-                || gsym->is_undefined()
-                || gsym->is_preemptible())
+           if (gsym->is_from_dynobj()
+               || gsym->is_undefined()
+               || gsym->is_preemptible()
+               || (gsym->type() == elfcpp::STT_GNU_IFUNC
+                   && parameters->options().output_is_position_independent()))
               got->add_global_with_rela(gsym, GOT_TYPE_STANDARD, rela_dyn,
                                         elfcpp::R_X86_64_GLOB_DAT);
             else
               {
-                if (got->add_global(gsym, GOT_TYPE_STANDARD))
-                  rela_dyn->add_global_relative(
-                      gsym, elfcpp::R_X86_64_RELATIVE, got,
-                      gsym->got_offset(GOT_TYPE_STANDARD), 0);
+               // For a STT_GNU_IFUNC symbol we want to write the PLT
+               // offset into the GOT, so that function pointer
+               // comparisons work correctly.
+               bool is_new;
+               if (gsym->type() != elfcpp::STT_GNU_IFUNC)
+                 is_new = got->add_global(gsym, GOT_TYPE_STANDARD);
+               else
+                 {
+                   is_new = got->add_global_plt(gsym, GOT_TYPE_STANDARD);
+                   // Tell the dynamic linker to use the PLT address
+                   // when resolving relocations.
+                   if (gsym->is_from_dynobj()
+                       && !parameters->options().shared())
+                     gsym->set_needs_dynsym_value();
+                 }
+                if (is_new)
+                 {
+                   unsigned int got_off = gsym->got_offset(GOT_TYPE_STANDARD);
+                   rela_dyn->add_global_relative(gsym,
+                                                 elfcpp::R_X86_64_RELATIVE,
+                                                 got, got_off, 0);
+                 }
               }
           }
         // For GOTPLT64, we also need a PLT entry (but only if the
@@ -1723,6 +1954,7 @@ Target_x86_64::Scan::global(Symbol_table* symtab,
     case elfcpp::R_X86_64_GLOB_DAT:
     case elfcpp::R_X86_64_JUMP_SLOT:
     case elfcpp::R_X86_64_RELATIVE:
+    case elfcpp::R_X86_64_IRELATIVE:
       // These are outstanding tls relocs, which are unexpected when linking
     case elfcpp::R_X86_64_TPOFF64:
     case elfcpp::R_X86_64_DTPMOD64:
@@ -2007,7 +2239,9 @@ Target_x86_64::Relocate::relocate(const Relocate_info<64, false>* relinfo,
        }
     }
 
-  // Pick the value to use for symbols defined in shared objects.
+  const Sized_relobj<64, false>* object = relinfo->object;
+
+  // Pick the value to use for symbols defined in the PLT.
   Symbol_value<64> symval;
   if (gsym != NULL
       && gsym->use_plt_offset(r_type == elfcpp::R_X86_64_PC64
@@ -2019,8 +2253,17 @@ Target_x86_64::Relocate::relocate(const Relocate_info<64, false>* relinfo,
                              + gsym->plt_offset());
       psymval = &symval;
     }
+  else if (gsym == NULL && psymval->is_ifunc_symbol())
+    {
+      unsigned int r_sym = elfcpp::elf_r_sym<64>(rela.get_r_info());
+      if (object->local_has_plt_offset(r_sym))
+       {
+         symval.set_output_value(target->plt_section()->address()
+                                 + object->local_plt_offset(r_sym));
+         psymval = &symval;
+       }
+    }
 
-  const Sized_relobj<64, false>* object = relinfo->object;
   const elfcpp::Elf_Xword addend = rela.get_r_addend();
 
   // Get the GOT offset if needed.
@@ -2196,6 +2439,7 @@ Target_x86_64::Relocate::relocate(const Relocate_info<64, false>* relinfo,
     case elfcpp::R_X86_64_GLOB_DAT:
     case elfcpp::R_X86_64_JUMP_SLOT:
     case elfcpp::R_X86_64_RELATIVE:
+    case elfcpp::R_X86_64_IRELATIVE:
       // These are outstanding tls relocs, which are unexpected when linking
     case elfcpp::R_X86_64_TPOFF64:
     case elfcpp::R_X86_64_DTPMOD64:
@@ -2789,6 +3033,7 @@ Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc(
     case elfcpp::R_X86_64_GLOB_DAT:
     case elfcpp::R_X86_64_JUMP_SLOT:
     case elfcpp::R_X86_64_RELATIVE:
+    case elfcpp::R_X86_64_IRELATIVE:
       // These are outstanding tls relocs, which are unexpected when linking
     case elfcpp::R_X86_64_TPOFF64:
     case elfcpp::R_X86_64_DTPMOD64: