This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Initialize Target before it may be referenced by findAux when reporting "duplicate symbol" error
ClosedPublic

Authored by MaskRay on May 8 2019, 6:26 PM.

Details

Summary
for (InputFile *F : Files)
  Symtab->addFile<ELFT>(F); // if there is a duplicate symbol error

...

Target = getTarget();

When parsing .debug_info in the object file (for better diagnostics),
DWARF.cpp findAux may dereference the null pointer Target

auto *DR = dyn_cast<Defined>(&File->getRelocTargetSym(Rel));
if (!DR) { /// Some asan object files contain R_X86_64_NONE
  RelType Type = Rel.getType(Config->IsMips64EL);
  if (Type != Target->NoneRel) /// Target is null

Move the assignment of Target to an earlier place to fix this.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.May 8 2019, 6:26 PM
ruiu accepted this revision.May 8 2019, 6:29 PM

LGTM

This revision is now accepted and ready to land.May 8 2019, 6:29 PM
This revision was automatically updated to reflect the committed changes.
grimar added a subscriber: grimar.May 13 2019, 6:42 AM
grimar added inline comments.
lld/trunk/test/ELF/undef-broken-debug.test
11

nit: I would not refer to the DWARF.cpp:findAux in the test cases comment.
Simply because both the file name and function name might change.