This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold assert after "relocation refers to discarded section" warnings
- From: Cary Coutant <ccoutant at google dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 4 Oct 2011 14:24:44 -0700
- Subject: gold assert after "relocation refers to discarded section" warnings
Ian,
When we see a reference to a local symbol in a discarded COMDAT
section, we print a warning "relocation refers to discarded section",
and continue. Unfortunately, if the relocation happens to be one of
the GOT relocations, we fail an assert later in Relocate::relocate()
because no GOT offset has been assigned:
// Get the GOT offset if needed.
// The GOT pointer points to the end of the GOT section.
// We need to subtract the size of the GOT section to get
// the actual offset to use in the relocation.
bool have_got_offset = false;
unsigned int got_offset = 0;
switch (r_type)
{
case elfcpp::R_X86_64_GOT32:
case elfcpp::R_X86_64_GOT64:
case elfcpp::R_X86_64_GOTPLT64:
case elfcpp::R_X86_64_GOTPCREL:
case elfcpp::R_X86_64_GOTPCREL64:
if (gsym != NULL)
{
gold_assert(gsym->has_got_offset(GOT_TYPE_STANDARD));
got_offset = gsym->got_offset(GOT_TYPE_STANDARD) - target->got_size();
}
else
{
unsigned int r_sym = elfcpp::elf_r_sym<64>(rela.get_r_info());
gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_STANDARD));
got_offset = (object->local_got_offset(r_sym, GOT_TYPE_STANDARD)
- target->got_size());
}
have_got_offset = true;
break;
default:
break;
}
We could soften the assert to accept this case, but should we continue
with a got_offset of 0? Alternatively, we could print a fatal error
message at this point, or we could just turn the earlier warning into
an error. What do you think?
-cary