* powerpc.cc (Powerpc_relobj::do_scan_relocs): Make STB_LOCAL
authorAlan Modra <amodra@gmail.com>
Fri, 30 Nov 2012 04:47:08 +0000 (04:47 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 30 Nov 2012 04:47:08 +0000 (04:47 +0000)
_GLOBAL_OFFSET_TABLE_ rather than STB_WEAK.
(Output_data_got_powerpc::make_header): Update _GLOBAL_OFFSET_TABLE_
value if it already exists.

gold/ChangeLog
gold/powerpc.cc

index 9a2868e05548446ed87e2c3142878f604e2df59d..8b44555a1b2c03e097465ca84f5daeff3f72bba1 100644 (file)
@@ -1,3 +1,10 @@
+2012-11-30  Alan Modra  <amodra@gmail.com>
+
+       * powerpc.cc (Powerpc_relobj::do_scan_relocs): Make STB_LOCAL
+       _GLOBAL_OFFSET_TABLE_ rather than STB_WEAK.
+       (Output_data_got_powerpc::make_header): Update _GLOBAL_OFFSET_TABLE_
+       value if it already exists.
+
 2012-11-19  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gold/14858
index fd7931227a7be34ee69445e590c6ff9b4df4ebd7..e4aef132f385522848aa4d623b3083ef94f96f97 100644 (file)
@@ -1391,8 +1391,8 @@ Powerpc_relobj<size, big_endian>::do_scan_relocs(Symbol_table* symtab,
 {
   if (size == 32)
     {
-      // Define a weak hidden _GLOBAL_OFFSET_TABLE_ to ensure it isn't
-      // seen as undefined when scanning relocs (and thus requires
+      // Define _GLOBAL_OFFSET_TABLE_ to ensure it isn't seen as
+      // undefined when scanning relocs (and thus requires
       // non-relative dynamic relocs).  The proper value will be
       // updated later.
       Symbol *gotsym = symtab->lookup("_GLOBAL_OFFSET_TABLE_", NULL);
@@ -1407,7 +1407,7 @@ Powerpc_relobj<size, big_endian>::do_scan_relocs(Symbol_table* symtab,
                                        Symbol_table::PREDEFINED,
                                        got, 0, 0,
                                        elfcpp::STT_OBJECT,
-                                       elfcpp::STB_WEAK,
+                                       elfcpp::STB_LOCAL,
                                        elfcpp::STV_HIDDEN, 0,
                                        false, false);
        }
@@ -1574,13 +1574,20 @@ private:
        Output_data_got<size, big_endian>::add_constant(0);
 
        // Define _GLOBAL_OFFSET_TABLE_ at the header
-       this->symtab_->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
-                                            Symbol_table::PREDEFINED,
-                                            this, this->g_o_t(), 0,
-                                            elfcpp::STT_OBJECT,
-                                            elfcpp::STB_LOCAL,
-                                            elfcpp::STV_HIDDEN,
-                                            0, false, false);
+       Symbol *gotsym = this->symtab_->lookup("_GLOBAL_OFFSET_TABLE_", NULL);
+       if (gotsym != NULL)
+         {
+           Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(gotsym);
+           sym->set_value(this->g_o_t());
+         }
+       else
+         this->symtab_->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL,
+                                              Symbol_table::PREDEFINED,
+                                              this, this->g_o_t(), 0,
+                                              elfcpp::STT_OBJECT,
+                                              elfcpp::STB_LOCAL,
+                                              elfcpp::STV_HIDDEN, 0,
+                                              false, false);
       }
     else
       Output_data_got<size, big_endian>::add_constant(0);