mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
From Cary Coutant: Set DF_STATIC_TLS as appropriate.
This commit is contained in:
parent
c32d85ca53
commit
535890bb64
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user