* options.h (General_options::output_is_executable): New.
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 16 Sep 2008 04:23:29 +0000 (04:23 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Tue, 16 Sep 2008 04:23:29 +0000 (04:23 +0000)
(General_options::output_is_pie): New.
* i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
for shared libraries.
* x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.

gold/ChangeLog
gold/i386.cc
gold/options.h
gold/x86_64.cc

index 8829e0a253516c145cc203159dd0ef7db7eb1a79..7235cd9e5931f5d16bb6694d5bb403ed3ff2442d 100644 (file)
@@ -1,3 +1,11 @@
+2008-09-16  Alexandre Oliva  <aoliva@redhat.com>
+
+       * options.h (General_options::output_is_executable): New.
+       (General_options::output_is_pie): New.
+       * i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
+       for shared libraries.
+       * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
+
 2008-09-11  Chris Demetriou  <cgd@google.com>
 
        * options.h (origin): New -z option.
index 54f123333b71ded73a7ac7258874d240d6f83337..8889a6802b701733f8050473e6cbeae999109208 100644 (file)
@@ -747,12 +747,16 @@ Target_i386::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
   Output_segment* tls_segment = layout->tls_segment();
   if (tls_segment != NULL)
     {
+      bool is_exec = parameters->options().output_is_executable();
       symtab->define_in_output_segment("_TLS_MODULE_BASE_", NULL,
                                       tls_segment, 0, 0,
                                       elfcpp::STT_TLS,
                                       elfcpp::STB_LOCAL,
                                       elfcpp::STV_HIDDEN, 0,
-                                      Symbol::SEGMENT_END, true);
+                                      (is_exec
+                                       ? Symbol::SEGMENT_END
+                                       : Symbol::SEGMENT_START),
+                                      true);
     }
   this->tls_base_symbol_defined_ = true;
 }
index 8614ce6523e45e43ed2ed4b7abe10097bdf1d01c..292673018f00ab7b5c5b08bd0c269595d3e6f026 100644 (file)
@@ -865,6 +865,20 @@ class General_options
   output_is_position_independent() const
   { return this->shared(); }
 
+  // Return true if the output is something that can be exec()ed, such
+  // as a static executable, or a position-dependent or
+  // position-independent executable, but not a dynamic library or an
+  // object file.
+  bool
+  output_is_executable() const
+  { return !this->shared() || this->output_is_pie(); }
+
+  // Return true if the output is a position-independent executable.
+  // This is currently not supported.
+  bool
+  output_is_pie() const
+  { return false; }
+
   // This would normally be static(), and defined automatically, but
   // since static is a keyword, we need to come up with our own name.
   bool
index 2daa9bf44c59ea71443842df1230d6ee1f39f936..dda329759f643c83359b96bfc5178473d932b826 100644 (file)
@@ -807,12 +807,16 @@ Target_x86_64::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
   Output_segment* tls_segment = layout->tls_segment();
   if (tls_segment != NULL)
     {
+      bool is_exec = parameters->options().output_is_executable();
       symtab->define_in_output_segment("_TLS_MODULE_BASE_", NULL,
                                       tls_segment, 0, 0,
                                       elfcpp::STT_TLS,
                                       elfcpp::STB_LOCAL,
                                       elfcpp::STV_HIDDEN, 0,
-                                      Symbol::SEGMENT_END, true);
+                                      (is_exec
+                                       ? Symbol::SEGMENT_END
+                                       : Symbol::SEGMENT_START),
+                                      true);
     }
   this->tls_base_symbol_defined_ = true;
 }