Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
sourceURLPrefixes WebAssembly custom section

sourceURLPrefixes WebAssembly custom section

This custom section is created to provide mapping of the local (or remote) file paths to network resources. Currently we can have DWARF sections inside the binary WebAssembly file, however debugger, in most of the cases, cannot retrive local files -- this file paths needs to be mapped to some networks server location.


The custom section has the following format:

Field Type Description
Custom Section ID varuint32 0
Custom Section Size varuint32 size of the section (including name)
Section Name Len varuint32 len("sourceURLPrefixes")
Section Name bytes "sourceURLPrefixes"
JSON Len varuint32 len(JSON)
JSON bytes utf-8 encoded JSON

The JSON is an array of pairs (array). The first item of the pair is the prefix to be replaced, and the second is the prefix that will be used as the replacement, e.g.

  ["/Users/yury/example_com/", ""],
  ["/usr/lib/libx/", ""],

If the consumer find the file path that starts with "/Users/yury/example_com/", this path needs to the changed to start with "".


This comment has been minimized.

Copy link

commented Sep 1, 2018

however debugger, in most of the cases, cannot retrive local files

Hmmm, is this from the point of view of an online IDE/debugger?

Curious, as I'm following along with this stuff from a Go perspective (cheering you on mostly 😉), and the use case I'm thinking of is for debuggers in desktop IDE's (eg GoLand in my case, but there are several others).

They'd have access to local files wouldn't they?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.