mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 09:38:57 +00:00
Fix problem where TLS common symbols are not allocated properly during LTO.
The plugin API doesn't provide a way for the claimed file handler to identify a TLS symbol, so when adding a common TLS symbol, gold mistakenly places the symbol in the non-TLS commons list, and does not override it when we see the replacement symbol that is marked as TLS. Consequently, we allocate the TLS common symbol as a regular common, and, if it's the only TLS in the program, we'll give an internal error because we haven't allocated a TLS segment. This patch fixes the problem by removing an exclusion where common symbols would not override the placeholder symbols, but checking to see if the size needs adjusting (the original reason for the exclusion). Furthermore, we need to avoid putting placeholder symbols in the common list, and wait until we see a real common symbol with a type we can trust. gold/ PR gold/17432 * resolve.cc (Symbol_table::resolve): Override common placeholder symbols, but adjust sizes. * symtab.cc (Symbol_table::add_from_object): Don't add placeholder symbols to common lists.
This commit is contained in:
@@ -309,11 +309,26 @@ Symbol_table::resolve(Sized_symbol<size>* to,
|
||||
{
|
||||
Pluginobj* obj = to->object()->pluginobj();
|
||||
if (obj != NULL
|
||||
&& parameters->options().plugins()->in_replacement_phase()
|
||||
&& !to->is_common())
|
||||
&& parameters->options().plugins()->in_replacement_phase())
|
||||
{
|
||||
this->override(to, sym, st_shndx, is_ordinary, object, version);
|
||||
return;
|
||||
bool adjust_common = false;
|
||||
typename Sized_symbol<size>::Size_type tosize = 0;
|
||||
typename Sized_symbol<size>::Value_type tovalue = 0;
|
||||
if (to->is_common() && !is_ordinary && st_shndx == elfcpp::SHN_COMMON)
|
||||
{
|
||||
adjust_common = true;
|
||||
typename Sized_symbol<size>::Size_type tosize = to->symsize();
|
||||
typename Sized_symbol<size>::Value_type tovalue = to->value();
|
||||
}
|
||||
this->override(to, sym, st_shndx, is_ordinary, object, version);
|
||||
if (adjust_common)
|
||||
{
|
||||
if (tosize > to->symsize())
|
||||
to->set_symsize(tosize);
|
||||
if (tovalue > to->value())
|
||||
to->set_value(tovalue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user