Created
October 28, 2018 20:09
-
-
Save zhuyifei1999/d435930c562077c8d55e235c3c72f77b to your computer and use it in GitHub Desktop.
LD_PRELOAD glibc wrapper to make sure stacks pointers given to clone(2) wrapper are 16-aligned.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Make sure stacks pointers given to clone(2) wrapper are 16-byte aligned. | |
* | |
* Public Domain / CC0 | |
* | |
* i386 glibc clone.S has: | |
* andl $0xfffffff0, %ecx | |
* x86-64 has no such sort and you hit | |
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838 | |
* and sadness somtimes happens :(. Compile this with: | |
* $ gcc -shared ensure_clone_stack_slign.S -o ensure_clone_stack_slign.so | |
* and run a program with: | |
* $ LD_PRELOAD=/path/to/ensure_clone_stack_slign.so command args | |
*/ | |
.globl __clone | |
.text | |
.globl clone | |
.align 4 | |
clone: | |
#ifdef __x86_64__ | |
andq $-16, %rsi | |
#endif | |
jmp __clone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment