This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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;
  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)
          got_offset = gsym->got_offset(GOT_TYPE_STANDARD) - target->got_size();
          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;


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]