This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Fix for weak undefined functions in -pie mode
ClosedPublic

Authored by sbc100 on Feb 2 2021, 7:12 PM.

Details

Summary

This fixes two related related issue. Firstly we were never generting
imports for weak functions (even with the import-functions policy
for undefined symbols). Adding a direct call to foo in the
weak-undefined-pic.s exposed a crash in the linker which this
change fixes.

Secondly we were failing to call handleWeakUndefines for the -pie
case which is PIC but doesn't set the undefined symbol policy to
import-functions. With this change -pie binaries will by default
call handleWeakUndefines which generates the undefined stub handlers
for any weakly undefined symbols.

Fixes: https://github.com/emscripten-core/emscripten/issues/13337

Diff Detail

Event Timeline

sbc100 created this revision.Feb 2 2021, 7:12 PM
sbc100 requested review of this revision.Feb 2 2021, 7:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2021, 7:12 PM
sbc100 edited the summary of this revision. (Show Details)Feb 2 2021, 7:15 PM
sbc100 updated this revision to Diff 320972.Feb 2 2021, 7:15 PM
sbc100 edited the summary of this revision. (Show Details)

typos

Harbormaster completed remote builds in B87622: Diff 320972.
dschuff accepted this revision.Feb 3 2021, 12:54 PM
dschuff added inline comments.
lld/test/wasm/weak-undefined-pic.s
72–74
97
This revision is now accepted and ready to land.Feb 3 2021, 12:54 PM

@sbc100 This revision is responsible for the sanitizer errors on the emscripten autorollers: https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket.appspot.com/8855537012484712752/+/steps/Emscripten_testsuite__upstream__wasm3_/0/stdout

Would you be able to take a look?

I think I will revert for now and followup after the weekend..