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.