Skip to content

PAGESIZE macro set to garbage value in shared libraries #778

@dicej

Description

@dicej

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions