This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Fix crash with `-pie` without `--allow-undefined`
ClosedPublic

Authored by sbc100 on May 1 2021, 10:13 PM.

Details

Summary

shouldImport was not returning true in PIC mode even though our
assumption elsewhere (in Relocations.cpp:scanRelocations) is that we
don't report undefined symbols in PIC mode (at least not today.
This was resulting functions that were undefined and but also not
imported which hits an assert later on that all functions have valid
indexes.

Diff Detail

Event Timeline

sbc100 created this revision.May 1 2021, 10:13 PM
sbc100 requested review of this revision.May 1 2021, 10:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2021, 10:13 PM
sbc100 edited the summary of this revision. (Show Details)
sbc100 edited the summary of this revision. (Show Details)

So this change means that unresolved symbols will turn into imports when linking?

sbc100 added a comment.May 3 2021, 3:48 PM

So this change means that unresolved symbols will turn into imports when linking?

Yes, this was already the assumption of code that reported undefined symbols. In emscripten this had gone unnoticed because we have traditionally also always passed --allow-undefined.

Our experimental -pie and -shared modes implicitly include --allow-undefined (at least for now they do).

dschuff accepted this revision.May 3 2021, 5:07 PM
This revision is now accepted and ready to land.May 3 2021, 5:07 PM