+2018-10-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23818
+       * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols
+       defined in discarded input sections.
+
 2018-10-24  Alan Modra  <amodra@gmail.com>
 
        * elf32-arm.c (elf32_arm_size_stubs): Ignore as-needed libs that
 
       return FALSE;
     }
 
+  bed = get_elf_backend_data (info->output_bfd);
+
   /* We only need version numbers for symbols defined in regular
      objects.  */
   if (!h->def_regular)
-    return TRUE;
+    {
+      /* Hide symbols defined in discarded input sections.  */
+      if ((h->root.type == bfd_link_hash_defined
+          || h->root.type == bfd_link_hash_defweak)
+         && discarded_section (h->root.u.def.section))
+       (*bed->elf_backend_hide_symbol) (info, h, TRUE);
+      return TRUE;
+    }
 
   hide = FALSE;
-  bed = get_elf_backend_data (info->output_bfd);
   p = strchr (h->root.root.string, ELF_VER_CHR);
   if (p != NULL && h->verinfo.vertree == NULL)
     {
 
+2018-10-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23818
+       * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test.
+       * testsuite/ld-plugin/pr23818.d: New file.
+       * testsuite/ld-plugin/pr23818.t: Likewise.
+       * testsuite/ld-plugin/pr23818a.c: Likewise.
+       * testsuite/ld-plugin/pr23818b.c: Likewise.
+
 2018-10-23  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-elf/shared.exp: Don't build pr19073 test on alpha.
 
   [list "Build pr22751.a" \
    "$plug_opt" "-flto $lto_no_fat $INT128_CFLAGS" \
    {pr22751.c} {} "pr22751.a"] \
+  [list "Build libpr23818.so" \
+   "-shared -flto -g -Wl,-version-script,pr23818.t" \
+   "-g -flto $lto_fat" \
+   {pr23818a.c pr23818b.c} \
+   {{"readelf" {-s --wide} "pr23818.d"}} \
+   "libpr23818.so"] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
 
--- /dev/null
+#failif
+#...
+.*0+ +[A-Z]+ +GLOBAL +DEFAULT +ABS foo
+#...
 
--- /dev/null
+{
+  global: bar;
+  local: *;
+};
 
--- /dev/null
+void
+foo ()
+{
+}
 
--- /dev/null
+void foo (void);
+
+void
+bar (void)
+{
+  foo ();
+}