[PATCH] D44622: [ELF] - Fix for "LLD crashes with --emit-relocs when trying to proccess .eh_frame"

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 19 15:14:38 PDT 2018


espindola added a comment.

The crash is from

  // This is for --emit-relocs. If .text.foo is emitted as .text.bar, we want
  // to emit .rela.text.foo as .rela.text.bar for consistency (this is not
  // technically required, but not doing it is odd). This code guarantees that.
  if ((S->Type == SHT_REL || S->Type == SHT_RELA) &&
      !isa<SyntheticSection>(S)) {
    OutputSection *Out =
        cast<InputSection>(S)->getRelocatedSection()->getOutputSection();

Where Out is null because we call this for the relocation section before .eh_frame. The caller is

  std::vector<OutputSection *> V;
  for (InputSectionBase *S : InputSections) {
    if (!S->Live || S->Parent)
      continue;
  
    StringRef Name = getOutputSectionName(S);

So this suggests two options that might be simpler.

- Just handle Out being null. We are just trying to get a better looking output section name. It is not critical.
- Do two passes over the input section in LinkerScript::addOrphanSections.


https://reviews.llvm.org/D44622





More information about the llvm-commits mailing list