PR gold/11317
* target-reloc.h (issue_undefined_symbol_error): New inline function, broken out of relocate_section. (relocate_section): Call issue_undefined_symbol_error. * i386.cc (Target_i386::Relocate::relocate_tls): Don't crash if there is no TLS segment if we are about to issue an undefined symbol error. * x86_64.cc (Target_x86_64::relocate_tls): Likewise.
This commit is contained in:
parent
2fbb75826a
commit
191f1a2dcc
4 changed files with 65 additions and 26 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2011-07-08 Ian Lance Taylor <iant@google.com>
|
||||||
|
|
||||||
|
PR gold/11317
|
||||||
|
* target-reloc.h (issue_undefined_symbol_error): New inline
|
||||||
|
function, broken out of relocate_section.
|
||||||
|
(relocate_section): Call issue_undefined_symbol_error.
|
||||||
|
* i386.cc (Target_i386::Relocate::relocate_tls): Don't crash if
|
||||||
|
there is no TLS segment if we are about to issue an undefined
|
||||||
|
symbol error.
|
||||||
|
* x86_64.cc (Target_x86_64::relocate_tls): Likewise.
|
||||||
|
|
||||||
2011-07-08 Ian Lance Taylor <iant@google.com>
|
2011-07-08 Ian Lance Taylor <iant@google.com>
|
||||||
|
|
||||||
PR gold/12279
|
PR gold/12279
|
||||||
|
|
27
gold/i386.cc
27
gold/i386.cc
|
@ -2640,7 +2640,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_gd_to_le(relinfo, relnum, tls_segment,
|
this->tls_gd_to_le(relinfo, relnum, tls_segment,
|
||||||
|
@ -2670,7 +2671,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_gd_to_ie(relinfo, relnum, tls_segment, rel, r_type,
|
this->tls_gd_to_ie(relinfo, relnum, tls_segment, rel, r_type,
|
||||||
|
@ -2697,7 +2699,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_desc_gd_to_le(relinfo, relnum, tls_segment,
|
this->tls_desc_gd_to_le(relinfo, relnum, tls_segment,
|
||||||
|
@ -2736,7 +2739,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_desc_gd_to_ie(relinfo, relnum, tls_segment, rel, r_type,
|
this->tls_desc_gd_to_ie(relinfo, relnum, tls_segment, rel, r_type,
|
||||||
|
@ -2772,7 +2776,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_ld_to_le(relinfo, relnum, tls_segment, rel, r_type,
|
this->tls_ld_to_le(relinfo, relnum, tls_segment, rel, r_type,
|
||||||
|
@ -2807,7 +2812,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value -= tls_segment->memsz();
|
value -= tls_segment->memsz();
|
||||||
|
@ -2823,7 +2829,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Target_i386::Relocate::tls_ie_to_le(relinfo, relnum, tls_segment,
|
Target_i386::Relocate::tls_ie_to_le(relinfo, relnum, tls_segment,
|
||||||
|
@ -2871,7 +2878,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value -= tls_segment->memsz();
|
value -= tls_segment->memsz();
|
||||||
|
@ -2886,7 +2894,8 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value = tls_segment->memsz() - value;
|
value = tls_segment->memsz() - value;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// target-reloc.h -- target specific relocation support -*- C++ -*-
|
// target-reloc.h -- target specific relocation support -*- C++ -*-
|
||||||
|
|
||||||
// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
// Written by Ian Lance Taylor <iant@google.com>.
|
// Written by Ian Lance Taylor <iant@google.com>.
|
||||||
|
|
||||||
// This file is part of gold.
|
// This file is part of gold.
|
||||||
|
@ -169,6 +169,22 @@ visibility_error(const Symbol* sym)
|
||||||
v, sym->name());
|
v, sym->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return true if we are should issue an error saying that SYM is an
|
||||||
|
// undefined symbol. This is called if there is a relocation against
|
||||||
|
// SYM.
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
issue_undefined_symbol_error(const Symbol* sym)
|
||||||
|
{
|
||||||
|
return (sym != NULL
|
||||||
|
&& (sym->is_undefined() || sym->is_placeholder())
|
||||||
|
&& sym->binding() != elfcpp::STB_WEAK
|
||||||
|
&& !sym->is_defined_in_discarded_section()
|
||||||
|
&& !parameters->target().is_defined_by_abi(sym)
|
||||||
|
&& (!parameters->options().shared()
|
||||||
|
|| parameters->options().defs()));
|
||||||
|
}
|
||||||
|
|
||||||
// This function implements the generic part of relocation processing.
|
// This function implements the generic part of relocation processing.
|
||||||
// The template parameter Relocate must be a class type which provides
|
// The template parameter Relocate must be a class type which provides
|
||||||
// a single function, relocate(), which implements the machine
|
// a single function, relocate(), which implements the machine
|
||||||
|
@ -344,13 +360,7 @@ relocate_section(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym != NULL
|
if (issue_undefined_symbol_error(sym))
|
||||||
&& (sym->is_undefined() || sym->is_placeholder())
|
|
||||||
&& sym->binding() != elfcpp::STB_WEAK
|
|
||||||
&& !is_defined_in_discarded_section
|
|
||||||
&& !target->is_defined_by_abi(sym)
|
|
||||||
&& (!parameters->options().shared() // -shared
|
|
||||||
|| parameters->options().defs())) // -z defs
|
|
||||||
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
|
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
|
||||||
else if (sym != NULL
|
else if (sym != NULL
|
||||||
&& sym->visibility() != elfcpp::STV_DEFAULT
|
&& sym->visibility() != elfcpp::STV_DEFAULT
|
||||||
|
|
|
@ -3112,7 +3112,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_gd_to_le(relinfo, relnum, tls_segment,
|
this->tls_gd_to_le(relinfo, relnum, tls_segment,
|
||||||
|
@ -3142,7 +3143,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value = target->got_plt_section()->address() + got_offset;
|
value = target->got_plt_section()->address() + got_offset;
|
||||||
|
@ -3175,7 +3177,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_desc_gd_to_le(relinfo, relnum, tls_segment,
|
this->tls_desc_gd_to_le(relinfo, relnum, tls_segment,
|
||||||
|
@ -3214,7 +3217,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value = target->got_plt_section()->address() + got_offset;
|
value = target->got_plt_section()->address() + got_offset;
|
||||||
|
@ -3250,7 +3254,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->tls_ld_to_le(relinfo, relnum, tls_segment, rela, r_type,
|
this->tls_ld_to_le(relinfo, relnum, tls_segment, rela, r_type,
|
||||||
|
@ -3284,7 +3289,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value -= tls_segment->memsz();
|
value -= tls_segment->memsz();
|
||||||
|
@ -3298,7 +3304,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value -= tls_segment->memsz();
|
value -= tls_segment->memsz();
|
||||||
|
@ -3311,7 +3318,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
{
|
{
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Target_x86_64::Relocate::tls_ie_to_le(relinfo, relnum, tls_segment,
|
Target_x86_64::Relocate::tls_ie_to_le(relinfo, relnum, tls_segment,
|
||||||
|
@ -3350,7 +3358,8 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
|
||||||
case elfcpp::R_X86_64_TPOFF32: // Local-exec
|
case elfcpp::R_X86_64_TPOFF32: // Local-exec
|
||||||
if (tls_segment == NULL)
|
if (tls_segment == NULL)
|
||||||
{
|
{
|
||||||
gold_assert(parameters->errors()->error_count() > 0);
|
gold_assert(parameters->errors()->error_count() > 0
|
||||||
|
|| issue_undefined_symbol_error(gsym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value -= tls_segment->memsz();
|
value -= tls_segment->memsz();
|
||||||
|
|
Loading…
Reference in a new issue