Skip to content

[lld][WebAssembly] __wasm_first_page_end is wrongly relocated #153759

@yamt

Description

@yamt

test code:

__attribute__((__visibility__("default")))
int
foo(void)
{
        extern char __wasm_first_page_end;
        return (int)&__wasm_first_page_end;
}

build:

clang -fPIC -shared -o a.so a.c

result:

  (func $foo (;3;) (type 1) (result i32)
    global.get $GOT.data.internal.__wasm_first_page_end
    return
  )
  (global $GOT.data.internal.__wasm_first_page_end (;2;) i32 global.get $__memory_base i32.const 65536 i32.add)

note that __memory_base is added.

w/o extended-const has the same issue:

  (func $__wasm_apply_global_relocs (;2;) (type 0)
    global.get $__memory_base
    i32.const 65536
    i32.add
    global.set $GOT.data.internal.__wasm_first_page_end
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions