[PATCH] D78779: [lld][WebAssembly] Fix crash on function signature mismatch with --relocatable

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 15:12:09 PDT 2020


sbc100 marked an inline comment as done.
sbc100 added inline comments.


================
Comment at: lld/wasm/SymbolTable.cpp:648
+  replaceSymbol<DefinedFunction>(sym, debugName, WASM_SYMBOL_BINDING_LOCAL,
+                                 nullptr, func);
   return func;
----------------
aheejin wrote:
> 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?
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78779/new/

https://reviews.llvm.org/D78779





More information about the llvm-commits mailing list