diff options
-rw-r--r-- | gold/i386.cc | 4 | ||||
-rw-r--r-- | gold/layout.cc | 5 | ||||
-rw-r--r-- | gold/layout.h | 12 | ||||
-rw-r--r-- | gold/x86_64.cc | 4 |
4 files changed, 24 insertions, 1 deletions
diff --git a/gold/i386.cc b/gold/i386.cc index 38ea0cc..7671910 100644 --- a/gold/i386.cc +++ b/gold/i386.cc @@ -973,6 +973,7 @@ Target_i386::Scan::local(const General_options&, case elfcpp::R_386_TLS_IE: // Initial-exec case elfcpp::R_386_TLS_IE_32: case elfcpp::R_386_TLS_GOTIE: + layout->set_has_static_tls(); if (optimized_type == tls::TLSOPT_NONE) { // For the R_386_TLS_IE relocation, we need to create a @@ -1005,6 +1006,7 @@ Target_i386::Scan::local(const General_options&, case elfcpp::R_386_TLS_LE: // Local-exec case elfcpp::R_386_TLS_LE_32: + layout->set_has_static_tls(); if (output_is_shared) { // We need to create a dynamic relocation. @@ -1275,6 +1277,7 @@ Target_i386::Scan::global(const General_options& options, case elfcpp::R_386_TLS_IE: // Initial-exec case elfcpp::R_386_TLS_IE_32: case elfcpp::R_386_TLS_GOTIE: + layout->set_has_static_tls(); if (optimized_type == tls::TLSOPT_NONE) { // For the R_386_TLS_IE relocation, we need to create a @@ -1304,6 +1307,7 @@ Target_i386::Scan::global(const General_options& options, case elfcpp::R_386_TLS_LE: // Local-exec case elfcpp::R_386_TLS_LE_32: + layout->set_has_static_tls(); if (parameters->output_is_shared()) { // We need to create a dynamic relocation. diff --git a/gold/layout.cc b/gold/layout.cc index 0a08f71..26585fa 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -71,7 +71,8 @@ Layout::Layout(const General_options& options) eh_frame_section_(NULL), output_file_size_(-1), input_requires_executable_stack_(false), input_with_gnu_stack_note_(false), - input_without_gnu_stack_note_(false) + input_without_gnu_stack_note_(false), + has_static_tls_(false) { // Make space for more than enough segments for a typical file. // This is just for efficiency--it's OK if we wind up needing more. @@ -1733,6 +1734,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects, odyn->add_constant(elfcpp::DT_TEXTREL, 0); flags |= elfcpp::DF_TEXTREL; } + if (parameters->output_is_shared() && this->has_static_tls()) + flags |= elfcpp::DF_STATIC_TLS; odyn->add_constant(elfcpp::DT_FLAGS, flags); } diff --git a/gold/layout.h b/gold/layout.h index 12f703f..37a70db 100644 --- a/gold/layout.h +++ b/gold/layout.h @@ -226,6 +226,16 @@ class Layout find_output_segment(elfcpp::PT type, elfcpp::Elf_Word set, elfcpp::Elf_Word clear) const; + // Set a flag to indicate that an object file uses the static TLS model. + void + set_has_static_tls() + { this->has_static_tls_ = true; } + + // Return true if any object file uses the static TLS model. + bool + has_static_tls() const + { return this->has_static_tls_; } + // Dump statistical information to stderr. void print_stats() const; @@ -460,6 +470,8 @@ class Layout // Whether we have seen at least one object file without an // executable stack marker. bool input_without_gnu_stack_note_; + // Whether we have seen an object file that uses the static TLS model. + bool has_static_tls_; }; // This task handles writing out data in output sections which is not diff --git a/gold/x86_64.cc b/gold/x86_64.cc index f25a107..6df501d 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -942,6 +942,7 @@ Target_x86_64::Scan::local(const General_options&, break; case elfcpp::R_X86_64_GOTTPOFF: // Initial-exec + layout->set_has_static_tls(); if (optimized_type == tls::TLSOPT_NONE) { // Create a GOT entry for the tp-relative offset. @@ -957,6 +958,7 @@ Target_x86_64::Scan::local(const General_options&, break; case elfcpp::R_X86_64_TPOFF32: // Local-exec + layout->set_has_static_tls(); if (output_is_shared) unsupported_reloc_local(object, r_type); break; @@ -1219,6 +1221,7 @@ Target_x86_64::Scan::global(const General_options& options, break; case elfcpp::R_X86_64_GOTTPOFF: // Initial-exec + layout->set_has_static_tls(); if (optimized_type == tls::TLSOPT_NONE) { // Create a GOT entry for the tp-relative offset. @@ -1233,6 +1236,7 @@ Target_x86_64::Scan::global(const General_options& options, break; case elfcpp::R_X86_64_TPOFF32: // Local-exec + layout->set_has_static_tls(); if (parameters->output_is_shared()) unsupported_reloc_local(object, r_type); break; |