+2020-12-16  Howard Chu <hyc@symas.com>
+           H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/27081
+       * libdep_plugin.c (onload): Skip if not all required plugin hooks
+       are available.
+       * testsuite/config/default.exp (dep_plug_opt): New.
+       * testsuite/ld-elf/elf.exp: Pass $dep_plug_opt to nm.
+       * testsuite/ld-elf/pr26391.fd: New file.
+
 2020-12-16  Alan Modra  <amodra@gmail.com>
 
        * ld.h (ld_config_type): Delete maxpagesize and commonpagesize.
 
   while ((tv++)->tv_tag != LDPT_NULL);
 
   /* Register hooks.  */
-  if (!tv_register_claim_file)
+  if (tv_register_claim_file
+      && tv_register_all_symbols_read
+      && tv_register_cleanup)
     {
-      TV_MESSAGE (LDPL_FATAL, "No register_claim_file hook");
-      fflush (NULL);
-      return LDPS_ERR;
-    }
-  (*tv_register_claim_file) (onclaim_file);
-  if (!tv_register_all_symbols_read)
-    {
-      TV_MESSAGE (LDPL_FATAL, "No register_all_symbols_read hook");
-      fflush (NULL);
-      return LDPS_ERR;
-    }
-  (*tv_register_all_symbols_read) (onall_symbols_read);
-  if (!tv_register_cleanup)
-    {
-      TV_MESSAGE (LDPL_FATAL, "No register_cleanup hook");
-      fflush (NULL);
-      return LDPS_ERR;
+      (*tv_register_claim_file) (onclaim_file);
+      (*tv_register_all_symbols_read) (onall_symbols_read);
+      (*tv_register_cleanup) (oncleanup);
     }
-  (*tv_register_cleanup) (oncleanup);
   fflush (NULL);
   return LDPS_OK;
 }
 
        }
     }
 }
+
+if {[file exists .libs/libdep.so]} {
+  set dep_plug_opt "--plugin .libs/libdep.so"
+} elseif {[file exists .libs/libdep.dll]} {
+  set dep_plug_opt "--plugin .libs/libdep.dll"
+} else {
+    set dep_plug_opt ""
+}
 
        "" \
        "" \
        {pr26391a.c pr26391b.c pr26391c.c pr26391d.c} \
-       {{nm "" pr26391.nd}} \
+       [list \
+           [list "nm" "$dep_plug_opt" "pr26391.nd"] \
+           [list "nm" "$dep_plug_opt" "pr26391.fd"] \
+       ] \
        "pr26391-5.o" \
        "-fno-function-sections" \
     ] \