While experimenting with C++ exception handling support for shared libraries, I discovered that the support for custom page sizes in __macro__PAGESIZE.h (which is only enabled for LLVM v22 and later) is broken for shared libraries, leading to an alignment-related abort() in sbrk when dlmalloc asks for more memory.
I was able to work around this by adding a && !defined __pic__ clause to the preprocessor guard, causing PAGESIZE to be hard-coded to the traditional 0x10000 value when compiling with -fPIC. I'm not sure what the proper way to handle custom page sizes in shared libraries is, but perhaps rather than rely on wasm-ld to define __wasm_first_page_end, it could be imported from env similar to e.g. __heap_end and friends.
While experimenting with C++ exception handling support for shared libraries, I discovered that the support for custom page sizes in
__macro__PAGESIZE.h(which is only enabled for LLVM v22 and later) is broken for shared libraries, leading to an alignment-relatedabort()insbrkwhendlmallocasks for more memory.I was able to work around this by adding a
&& !defined __pic__clause to the preprocessor guard, causingPAGESIZEto be hard-coded to the traditional 0x10000 value when compiling with-fPIC. I'm not sure what the proper way to handle custom page sizes in shared libraries is, but perhaps rather than rely onwasm-ldto define__wasm_first_page_end, it could be imported fromenvsimilar to e.g.__heap_endand friends.