This is an archive of the discontinued LLVM Phabricator instance.

[GC] Don't crash when printing gc'd sections with no name and no associated file
ClosedPublic

Authored by davide on Sep 19 2016, 9:25 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 71841.Sep 19 2016, 9:25 AM
davide retitled this revision from to [GC] Don't crash when printing gc'd sections with no name and no associated file.
davide updated this object.
davide added reviewers: ruiu, rafael.
davide added a subscriber: llvm-commits.

To be more precise, before this code was crashing because getFile() returned a nullptr on which lld was trying to call getName().

C->getFile() == nullptr
true
F->getName()
"LLD-INTERNAL-combined-lto-object"
    [Raw View]: {Data=0x0000000144483f18 "LLD-INTERNAL-combined-lto-object" Length=32 }

It comes from the combined LTO object.
The input section name is empty anyway so I'm not entirely sure what buys us in this particular circumstance.
In general, anyway, yes, I think <internal> is a better diagnostic if we don't have the filename available. Do you agree?

ruiu edited edge metadata.Sep 19 2016, 3:02 PM

How can a section from combined LTO object have no backing file? I guessed its getFile() should return a combined LTO object file.

davide updated this revision to Diff 71886.Sep 19 2016, 3:57 PM
davide edited edge metadata.

I analyzed this a little bit further.
I think this happen only when we try to print the "special" section &InputSection<ELFT>::Discarded (the debugger confirms).
This has no name associated, and I don't think it's backed by a file. I think it's not entirely unreasonable to skip it while reporting sections which have been gc'ed. What do you think?

ruiu accepted this revision.Sep 19 2016, 4:07 PM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 19 2016, 4:07 PM
This revision was automatically updated to reflect the committed changes.