* Makefile.am (spu_ovl.o_c): Add missing line continuations.
[binutils-gdb.git] / gold / x86_64.cc
index cbbd5ccf368d972eb017e0d8aa834dffd335364f..69f76a0265f2e51d48c02a214bb870daccad9829 100644 (file)
@@ -139,7 +139,7 @@ class Target_x86_64 : public Sized_target<64, false>
 
   // Return whether SYM is defined by the ABI.
   bool
-  do_is_defined_by_abi(Symbol* sym) const
+  do_is_defined_by_abi(const Symbol* sym) const
   { return strcmp(sym->name(), "__tls_get_addr") == 0; }
 
   // Return the size of the GOT section.
@@ -330,7 +330,7 @@ class Target_x86_64 : public Sized_target<64, false>
   void
   make_plt_entry(Symbol_table*, Layout*, Symbol*);
 
-  // Define the _TLS_MODULE_BASE_ symbol at the end of the TLS segment.
+  // Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
   void
   define_tls_base_symbol(Symbol_table*, Layout*);
 
@@ -796,7 +796,7 @@ Target_x86_64::make_plt_entry(Symbol_table* symtab, Layout* layout,
   this->plt_->add_entry(gsym);
 }
 
-// Define the _TLS_MODULE_BASE_ symbol at the end of the TLS segment.
+// Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
 
 void
 Target_x86_64::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
@@ -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;
 }
@@ -2054,7 +2058,7 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
           if (this->saw_tls_block_reloc_)
             value -= tls_segment->memsz();
         }
-      Relocate_functions<64, false>::rela32(view, value, 0);
+      Relocate_functions<64, false>::rela32(view, value, addend);
       break;
 
     case elfcpp::R_X86_64_DTPOFF64:
@@ -2065,7 +2069,7 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
           if (this->saw_tls_block_reloc_)
             value -= tls_segment->memsz();
         }
-      Relocate_functions<64, false>::rela64(view, value, 0);
+      Relocate_functions<64, false>::rela64(view, value, addend);
       break;
 
     case elfcpp::R_X86_64_GOTTPOFF:         // Initial-exec
@@ -2107,7 +2111,7 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
 
     case elfcpp::R_X86_64_TPOFF32:          // Local-exec
       value -= tls_segment->memsz();
-      Relocate_functions<64, false>::rela32(view, value, 0);
+      Relocate_functions<64, false>::rela32(view, value, addend);
       break;
     }
 }