[PATCH] D71788: [llvm-strip] Add WebAssembly support

Paolo Severini via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 20 15:09:15 PST 2019


paolosev created this revision.
paolosev added a reviewer: jakehehrlich.
paolosev added a project: LLVM.
Herald added subscribers: llvm-commits, seiya, sunfish, aheejin, jgravelle-google, sbc100, aprantl, mgorny, dschuff.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.

The DWARF debug info for a WebAssembly module is currently embedded within the module in a sequence custom sections, whose name matches the DWARF section name as defined in the DWARF standard (e.g. //.debug_info// or //.debug_line//).
It should be possible to export the debug info into a separate, external file and in that case a custom section named //"external_debug_info"// should be added to the original module. The "external_debug_info" section should contain an UTF-8 encoded URL to the external debug info file (see https://yurydelendik.github.io/webassembly-dwarf/ for more details).

This patch modifies **llvm-strip** and **llvm-objcopy** to also work with Wasm modules.
Several existing options should work also for Wasm files:

- -g, --strip-debug, -S, --strip-all, --strip-all-gnu -x, --discard-all, --strip-unneeded  (Remove all DWARF custom sections from a Wasm file).
- -R, --remove-section  (Remove the sections listed).
- -j, --only-section  (Remove all sections but the one listed).

Note that Wasm custom sections can be referred by their name, while the standard sections can be referred by their id (1:Type, 2: Import, ... 10: Code, and so on).

Two new options should be introduced, specific for Wasm modules:

**--wasm-split-debug <wasm-sym-file>** should behave like --split-dwo does for ELF files: extract the debug information into a separate file and strip the debug sections from the input file.
(Note: not sure if we could instead reuse the existing --split-dwo here, but we are not really dealing with DWO files, so that would be confusing).

**--wasm-debug-info-url <dwarf-url>** should be used to specify the URL of the DWARF debug info file created with --wasm-split-debug. This URL will be embedded in the "external_debug_info" custom section of the original file. If not specified, use the output file path of --wasm-split-debug as default value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71788

Files:
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/CopyConfig.cpp
  llvm/tools/llvm-objcopy/CopyConfig.h
  llvm/tools/llvm-objcopy/ObjcopyOpts.td
  llvm/tools/llvm-objcopy/Wasm/Object.cpp
  llvm/tools/llvm-objcopy/Wasm/Object.h
  llvm/tools/llvm-objcopy/Wasm/Reader.cpp
  llvm/tools/llvm-objcopy/Wasm/Reader.h
  llvm/tools/llvm-objcopy/Wasm/WasmObjcopy.cpp
  llvm/tools/llvm-objcopy/Wasm/WasmObjcopy.h
  llvm/tools/llvm-objcopy/Wasm/Writer.cpp
  llvm/tools/llvm-objcopy/Wasm/Writer.h
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71788.234984.patch
Type: text/x-patch
Size: 22318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191220/28bc24e4/attachment.bin>


More information about the llvm-commits mailing list