__builtin_return_address
The asm.js backend splits the 32-bit "PC" register into a 20-bit function index and a 12-bit relative PC, with some alleged support for functions spanning several 12-bit "pages".
That's not a very nice approach; for the wasm32 port, function pointers are simply small integers specifying the function offset. That's what the WebAssembly docs are recommending, too, if I'm reading them correctly.
However, that raises the issue of what to report back to GCC's __builtin_return_address function, which is limited, I think, to a Pmode return value. Returning the function index unadjusted would be a problem because exception handling (which seemed to work on the asm.js port at a time) requires more fine-grained information about which call our function was in.
The options I can think of are:
- split the PC à la the asm.js port
- introduce a third PC space to go with the function index space (+PLT) and the linear memory space (+GOT).
- rewrite the code in unwind-dw2.c to allow for return addresses wider than the word size.
None of them is particularly nice, so I'm wondering whether there might be a simpler approach I'm missing.