This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Ensure stub symbols always get address 0
ClosedPublic

Authored by sbc100 on Nov 24 2020, 8:21 AM.

Details

Summary

Without this extra flag we can't distingish between stub functions and
functions that happen to have address 0 (relative to __table_base).

Adding this flag bit the base symbol class actually avoids growing the
SymbolUnion struct which would not be true if we added it to the
FunctionSymbol subclass (due to bitbacking).

The previous approach of setting it's table index to zero worked for
normal static relocations but not for -fPIC code.

See https://github.com/emscripten-core/emscripten/issues/12819

Diff Detail

Event Timeline

sbc100 created this revision.Nov 24 2020, 8:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 24 2020, 8:21 AM
sbc100 requested review of this revision.Nov 24 2020, 8:21 AM
sbc100 updated this revision to Diff 307372.Nov 24 2020, 8:32 AM

Update test

Harbormaster completed remote builds in B79967: Diff 307372.
sbc100 updated this revision to Diff 307487.Nov 24 2020, 5:58 PM

Revert part

sbc100 updated this revision to Diff 307488.Nov 24 2020, 6:07 PM
  • add comment
sbc100 retitled this revision from [lld][WebAssebmly] Ensure stub symbols always get address 0 to [lld][WebAssembly] Ensure stub symbols always get address 0.Nov 24 2020, 6:08 PM
kripken accepted this revision.Nov 25 2020, 8:46 AM

I don't know enough to tell if these changes are sufficient, but they make sense to me.

lld/test/wasm/weak-undefined-pic.s
48
lld/wasm/SymbolTable.cpp
676–678
lld/wasm/SyntheticSections.cpp
335
386
This revision is now accepted and ready to land.Nov 25 2020, 8:46 AM
sbc100 updated this revision to Diff 307740.Nov 25 2020, 6:26 PM
sbc100 marked 4 inline comments as done.

feedback

This revision was landed with ongoing or failed builds.Nov 25 2020, 6:31 PM
This revision was automatically updated to reflect the committed changes.
dschuff added inline comments.Nov 30 2020, 11:15 AM
lld/test/wasm/weak-undefined-pic.s
30
71
lld/wasm/Symbols.h
162

If getting slot 0 (and comparing equal to the nullptr) is also a requirement for stub functions then that should maybe be mentioned here too.