Fix internal error when linking an archive library with no preceding objects.
authorCary Coutant <ccoutant@gmail.com>
Tue, 21 Jul 2015 19:42:07 +0000 (12:42 -0700)
committerCary Coutant <ccoutant@gmail.com>
Tue, 21 Jul 2015 19:42:07 +0000 (12:42 -0700)
gold/
PR gold/18696
* archive.cc (Library_base::should_include_member): Don't use entry
point for relocatable links, or if target is not yet valid.
* parameters.cc (Parameters::entry): Check target_valid().

gold/ChangeLog
gold/archive.cc
gold/parameters.cc

index becff516c756977b28364b5ecbbc96b0704fbcb2..b7f0a33500b9a06642dc57d89d46b753a3619bf2 100644 (file)
@@ -1,3 +1,10 @@
+2015-07-21  Cary Coutant  <ccoutant@gmail.com>
+
+       PR gold/18696
+       * archive.cc (Library_base::should_include_member): Don't use entry
+       point for relocatable links, or if target is not yet valid.
+       * parameters.cc (Parameters::entry): Check target_valid().
+
 2015-07-20  Han Shen  <shenhan@google.com>
 
        Optimize erratum 843419 fix.
index 6d259803185368ccbe3b71cda4040d90105b66d3..cc69c40fb9887adea97a35dda4857c4a3783a959 100644 (file)
@@ -138,11 +138,15 @@ Library_base::should_include_member(Symbol_table* symtab, Layout* layout,
       return Library_base::SHOULD_INCLUDE_YES;
     }
 
-  if (strcmp(sym_name, parameters->entry()) == 0)
+  if (!parameters->options().relocatable())
     {
-      *why = "entry symbol ";
-      *why += sym_name;
-      return Library_base::SHOULD_INCLUDE_YES;
+      const char* entry_sym = parameters->entry();
+      if (entry_sym != NULL && strcmp(sym_name, entry_sym) == 0)
+       {
+         *why = "entry symbol ";
+         *why += sym_name;
+         return Library_base::SHOULD_INCLUDE_YES;
+       }
     }
 
   return Library_base::SHOULD_INCLUDE_UNKNOWN;
index 8eab000cf52ed8160fcaeafd9fe457235e18b11f..5ed191225122a40608921c30be431c2920b1877a 100644 (file)
@@ -237,7 +237,7 @@ const char*
 Parameters::entry() const
 {
   const char* ret = this->options().entry();
-  if (ret == NULL)
+  if (ret == NULL && parameters->target_valid())
     ret = parameters->target().entry_symbol_name();
   return ret;
 }