This is the mail archive of the
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
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;
if (gsym != NULL)
got_offset = gsym->got_offset(GOT_TYPE_STANDARD) - target->got_size();
unsigned int r_sym = elfcpp::elf_r_sym<64>(rela.get_r_info());
got_offset = (object->local_got_offset(r_sym, GOT_TYPE_STANDARD)
have_got_offset = true;
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?