@hovav @pervognsen
Firefox on Linux x86-64 uses the gsbase for rlbox library sandboxing [1] because we got a pretty nice perf boost --- eliminates roughly 75% of wasm's overhead on some workloads [2] (but to be clear, it is not used by Firefox's Wasm JIT to run Wasm in websites)
Re your question about possible negative displacements --- given that Wasm's memory op supports an linear memory offset specified as the sum of 32-bit variable `offset` and 32-bit `constant`, the straightforward encoding `gs: constant(%reg_offset)` is possible only when the constant is <= INT32_MAX (which is true most of the time).
If we run into a larger constant than that, I expect that we just fall back to using two instructions
```
reg_tmp = offset + constant
val = gs:reg_tmp
```
The nice bit is that the wasm2c implementation doesn't really need to think about any of this, and can just defer to clang due to the `__seg_gs` syntax [3] i.e., named address space support :)
[1] https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/
[2] https://shravanrn.com/pubs/seguecg.pdf
[3] https://github.com/WebAssembly/wabt/blob/main/src/template/wasm2c.declarations.c#L55C48-L55C56