Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-backend: PIC stack placement #8915

Closed
quantum5 opened this issue Jul 3, 2019 · 2 comments
Closed

wasm-backend: PIC stack placement #8915

quantum5 opened this issue Jul 3, 2019 · 2 comments

Comments

@quantum5
Copy link
Member

quantum5 commented Jul 3, 2019

After WebAssembly/binaryen#2201, if we change shared.Settings.GLOBAL_BASE = 1024 to shared.Settings.GLOBAL_BASE = 1048576, and then we compile the test file tests/core/test_stack_placement.c as PIC, we get:

$ emcc -fPIC -s MAIN_MODULE -s TOTAL_STACK=1024 stack_placement.c
$ node a.out.js 
data: 0x100000 bss: 0x10a00c stack: 0x37190

Without -fPIC, the test works:

$ emcc -s TOTAL_STACK=1024 stack_placement.c
$ node a.out.js 
data: 0x100000 bss: 0x10a18c stack: 0x10ae20
success.

Before WebAssembly/binaryen#2201, the tests fail the same way with or without -fPIC:

$ emcc -fPIC -s MAIN_MODULE -s TOTAL_STACK=1024 stack_placement.c
$ node a.out.js 
data: 0x100000 bss: 0x10a00c stack: 0x100390
Assertion failed: stack_address > bss_address, at: stack_placement.c,25,main
$ emcc -s TOTAL_STACK=1024 stack_placement.c
$ node a.out.js 
data: 0x100000 bss: 0x10a18c stack: 0x100390
Assertion failed: stack_address > bss_address, at: stack_placement.c,25,main
@quantum5
Copy link
Member Author

quantum5 commented Jul 4, 2019

This is currently preventing dlfcn tests from running on ASan (#8884).

@kripken kripken added this to Blocker in LLVM Upstream Backend Jul 8, 2019
sbc100 added a commit to WebAssembly/binaryen that referenced this issue Jul 10, 2019
I'm working on a change to lld that will cause `-pie` binaries to
import __stack_pointer, just like -shared do already.  Because we
don't yet support mutable globals everywhere this change will
internalize the import and create a new immutable import that is used
to initialize the internal one.

This change is part of the fix for:
emscripten-core/emscripten#8915
sbc100 added a commit to WebAssembly/binaryen that referenced this issue Jul 10, 2019
I'm working on a change to lld that will cause `-pie` binaries to
import __stack_pointer, just like -shared do already.  Because we
don't yet support mutable globals everywhere this change will
internalize the import and create a new immutable import that is used
to initialize the internal one.

This change is part of the fix for:
emscripten-core/emscripten#8915
sbc100 added a commit to WebAssembly/binaryen that referenced this issue Jul 10, 2019
…2213)

I'm working on a change to lld that will cause `-pie` binaries to
import __stack_pointer, just like -shared do already.  Because we
don't yet support mutable globals everywhere this change will
internalize the import and create a new immutable import that is used
to initialize the internal one.

This change is part of the fix for:
emscripten-core/emscripten#8915
llvm-git-migration pushed a commit to llvm/llvm-project that referenced this issue Jul 11, 2019
The -pie binary doesn't know that layout ahead of time so needs to
import the stack pointer from the embedder, just like we do already
for shared libraries.

This change is needed in order to address:
emscripten-core/emscripten#8915

Differential Revision: https://reviews.llvm.org/D64516

llvm-svn: 365771
@quantum5
Copy link
Member Author

This appears to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

1 participant