E.2. Function pointers
WebAssembly modules have an optional Table known section, which is a typed array of references, like functions, that can’t be stored in memory as raw bytes for security reasons. If the addresses were stored in the module’s memory, there would be a chance that a malicious module would try to modify an address to access data that it shouldn’t have access to.
When a module’s code wants to access the data referenced in the Table section, it asks for the WebAssembly framework to operate on the item at a specific index in the table. The WebAssembly framework then reads the address stored at that index and performs the action.
The Table section is defined with an s-expression that starts with a label using the word table, followed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access