[PATCH] D111388: [WebAssembly] Make EH work with dynamic linking

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 01:08:08 PDT 2021


aheejin created this revision.
aheejin added a reviewer: sbc100.
Herald added subscribers: wingo, ecnelises, sunfish, hiraditya, jgravelle-google, dschuff.
aheejin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This makes Wasm EH work with dynamic linking. So far we were only able
to handle destructors, which do not use any tags or LSDA info.

1. This uses `TargetExternalSymbol` for `GCC_except_tableN` symbols, which points to the address of per-function LSDA info. It is more convenient to use than `MCSymbol` because it can take additional target flags.

2. When lowering `wasm_lsda` intrinsic, if PIC is enabled, make the symbol relative to `__memory_base` and generate the `add` node. If PIC is disabled, continue to use the absolute address.

3. Make tag symbols (`__cpp_exception` and `__c_longjmp`) undefined in the backend, because it is hard to make it work with dynamic linking's loading order. Instead, we make all tag symbols undefined in the LLVM backend and import it from JS.

4. Add support for undefined tags to the linker.

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

Companion patches:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111388

Files:
  lld/test/wasm/Inputs/tag-section1.ll
  lld/test/wasm/Inputs/tag-section2.ll
  lld/test/wasm/tag-section.ll
  lld/wasm/InputFiles.cpp
  lld/wasm/SymbolTable.cpp
  lld/wasm/SymbolTable.h
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/SyntheticSections.cpp
  lld/wasm/SyntheticSections.h
  llvm/lib/CodeGen/AsmPrinter/WasmException.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/test/CodeGen/WebAssembly/eh-lsda.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111388.378122.patch
Type: text/x-patch
Size: 21412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211008/a429336f/attachment.bin>


More information about the llvm-commits mailing list