This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Error if --strip-all and --emit-relocs are used together
ClosedPublic

Authored by MaskRay on Aug 24 2019, 6:30 AM.

Details

Summary

--strip-all suppresses the creation of in.symtab
This can cause a null pointer dereference in OutputSection::finalize

// --emit-relocs => copyRelocs is true
if (!config->copyRelocs || (type != SHT_RELA && type != SHT_REL))
  return;
...
link = in.symTab->getParent()->sectionIndex; // in.symTab is null

Let's just disallow the combination.

In some cases:

  • ld.bfd: final link failed: invalid operation
  • gold: internal error in set_no_output_symtab_entry, at ../../gold/object.h:1814

Event Timeline

MaskRay created this revision.Aug 24 2019, 6:30 AM
ruiu accepted this revision.Aug 25 2019, 10:52 PM

LGTM

This revision is now accepted and ready to land.Aug 25 2019, 10:52 PM
This revision was automatically updated to reflect the committed changes.