+2015-06-07 Cary Coutant <ccoutant@gmail.com>
+
+ PR gold/18288
+ * resolve.cc (symbol_to_bits): Remove type parameter; adjust all
+ callers. Don't use STT_COMMON to check for common symbols.
+ (Symbol_table::resolve): Warn if relocatable object has STT_COMMON
+ symbol that's not in a common section.
+ * symtab.h (Symbol::is_common): Don't use STT_COMMON to check for
+ common symbols.
+
2015-06-04 Cary Coutant <ccoutant@gmail.com>
PR gold/18200
static unsigned int
symbol_to_bits(elfcpp::STB binding, bool is_dynamic,
- unsigned int shndx, bool is_ordinary, elfcpp::STT type)
+ unsigned int shndx, bool is_ordinary)
{
unsigned int bits;
break;
default:
- if (type == elfcpp::STT_COMMON)
- bits |= common_flag;
- else if (!is_ordinary && Symbol::is_common_shndx(shndx))
+ if (!is_ordinary && Symbol::is_common_shndx(shndx))
bits |= common_flag;
else
bits |= def_flag;
if (!object->is_dynamic())
{
+ if (sym.get_st_type() == elfcpp::STT_COMMON
+ && (is_ordinary || !Symbol::is_common_shndx(st_shndx)))
+ {
+ gold_warning(_("STT_COMMON symbol '%s' in %s "
+ "is not in a common section"),
+ to->demangled_name().c_str(),
+ to->object()->name().c_str());
+ return;
+ }
// Record that we've seen this symbol in a regular object.
to->set_in_reg();
}
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)
+ if (to->is_common()
+ && !is_ordinary && Symbol::is_common_shndx(st_shndx))
{
adjust_common = true;
tosize = to->symsize();
: sym.get_st_type());
unsigned int frombits = symbol_to_bits(sym.get_st_bind(),
object->is_dynamic(),
- st_shndx, is_ordinary,
- fromtype);
+ st_shndx, is_ordinary);
bool adjust_common_sizes;
bool adjust_dyndef;
unsigned int tobits;
if (to->source() == Symbol::IS_UNDEFINED)
- tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_UNDEF, true,
- to->type());
+ tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_UNDEF, true);
else if (to->source() != Symbol::FROM_OBJECT)
- tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_ABS, false,
- to->type());
+ tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_ABS, false);
else
{
bool is_ordinary;
tobits = symbol_to_bits(to->binding(),
to->object()->is_dynamic(),
shndx,
- is_ordinary,
- to->type());
+ is_ordinary);
}
if ((to->type() == elfcpp::STT_TLS) ^ (fromtype == elfcpp::STT_TLS)