[PATCH] D68751: [lld][WebAssembly] Where possible handle signature mismatches via an adaptor function

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 20:22:10 PDT 2019


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

The primary documentation we have is at : https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md



================
Comment at: lld/wasm/SymbolTable.cpp:592
+// types don't match the adaptor creation will tail.
+bool SymbolTable::replaceWithAdaptorFunction(FunctionSymbol *sym,
+                                             FunctionSymbol *target) {
----------------
ruiu wrote:
> This function seems to enables to call an external function with a less number of arguments. I wonder what is the use case of this -- as long as you have a correct header file for functions, compilers can tell users that the number of parameters doesn't match.
Yes, normally this shouldn't happen, but sadly there are some cases in C when it does.

The motivating case here is crt1.c calling the main function from _start.   We want to be able support both 3 argument and 2 arguments forms.   With native linking you can simply link these two together it will kind of "just work".   With wasm, before this change we end up generating a linker warning and _start ends up calling stub function, so the program doesn't work.

This change fixes that use case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68751





More information about the llvm-commits mailing list