This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Fix crash on function signature mismatch with --relocatable
ClosedPublic

Authored by sbc100 on Apr 23 2020, 6:17 PM.

Details

Summary

These stub new function were not being added to the symbol table
which in turn meant that we were crashing when trying to output
relocations against them.

Fixes: PR45645

Diff Detail

Event Timeline

sbc100 created this revision.Apr 23 2020, 6:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2020, 6:17 PM
sbc100 added a reviewer: ruiu.Apr 23 2020, 6:18 PM
sbc100 added a reviewer: aheejin.
aheejin added inline comments.Apr 24 2020, 2:13 PM
lld/wasm/SymbolTable.cpp
648

I'm not very familiar with this part of code. Does making the symbols local here prevent this from being emitted in the output object file? Why not sym->getName() bug debugName now?

sbc100 marked an inline comment as done.Apr 24 2020, 2:47 PM
sbc100 added inline comments.
lld/wasm/SymbolTable.cpp
648

No, the code is still emitted, its just that its marked a local in the symbol table.

Without this change the symbol doesn't get added the symbol table at all, which will then cause the crash when wriing the relocation data.

See the assumptions being made when deciding which symbol to add to the table:
https://github.com/llvm/llvm-project/blob/10bc12588dac532fad044b2851dde8e7b9121e88/lld/wasm/Writer.cpp#L562

This code (not unreasoably) assumes that symbol are either part of the global shared symbol table, or they are local symbols in a given object. Without this bugfix this new symbol would not be local to an object or in the symbol table.

I change the name here to match the debug name so its value in the symbol table shows up as signature_mismatch:ret32' rather then just ret32. Since its a local symbol its name doesn't actually matter to the future link step.

aheejin accepted this revision.Apr 24 2020, 3:26 PM

Thanks for fixing this so quickly!

This revision is now accepted and ready to land.Apr 24 2020, 3:26 PM
This revision was automatically updated to reflect the committed changes.