Description
As far as I investigated, it fails to deference absolute pointer.
Absolute Pointer?
In apple/swift, they use relative pointer which has an offset between its own address and pointee. But linker support is necessary to calculate the offset and wasm-ld doesn't have the subtraction relocation type yet.
To avoid relative pointer, @zhuowei changed to replace the offset with absolute pointer instead and it works well.
But there are some issues in this way.
Issues
-
@zhuowei's change doesn't work in latest swiftwasm branch and I don't know when this way was broken.
-
@zhuowei's patch was applied into RelativePointer.h directly. This change makes it difficult to support wasm64 because the relative pointer's offset is designed to be int32.
What we need to do
There are some ways to solve these issues.
- Implement subtraction relocation type in wasm-ld.
If wasm-ld supports the relocation type, we need nothing to do except reverting absolute pointer patch.
I'm contacting llvm people now for this topic. WebAssembly/tool-conventions#132
- Support absolute pointer in correct way
I'm implementing AbsolutePointer type and make it more robust to support 64bit environment.