PR ld/10515
[binutils-gdb.git] / gold / resolve.cc
index 7299c5589a27bf15f16842fe25847f2bf75eaad8..45a4a7aabda34571be6bfeff74225ed46a02b720 100644 (file)
@@ -257,8 +257,9 @@ Symbol_table::resolve(Sized_symbol<size>* to,
       // Record that we've seen this symbol in a regular object.
       to->set_in_reg();
     }
-  else if (to->visibility() == elfcpp::STV_HIDDEN
-           || to->visibility() == elfcpp::STV_INTERNAL)
+  else if (st_shndx == elfcpp::SHN_UNDEF
+           && (to->visibility() == elfcpp::STV_HIDDEN
+               || to->visibility() == elfcpp::STV_INTERNAL))
     {
       // A dynamic object cannot reference a hidden or internal symbol
       // defined in another object.