-
-
Save stanaka/2b63a16d484692b3599f to your computer and use it in GitHub Desktop.
Patch for Go1.6 to use set_thread_area instead of modify_ldt
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
ec2-user@ip-10-1-8-251 go]$ diff -u src/runtime/sys_linux_386.s.orig src/runtime/sys_linux_386.s | |
--- src/runtime/sys_linux_386.s.orig 2016-03-26 02:42:51.537721466 +0000 | |
+++ src/runtime/sys_linux_386.s 2016-03-26 02:44:37.973471872 +0000 | |
@@ -407,7 +407,6 @@ | |
// setldt(int entry, int address, int limit) | |
TEXT runtime·setldt(SB),NOSPLIT,$32 | |
- MOVL entry+0(FP), BX // entry | |
MOVL address+4(FP), DX // base address | |
#ifdef GOOS_android | |
@@ -444,16 +443,14 @@ | |
// set up user_desc | |
LEAL 16(SP), AX // struct user_desc | |
- MOVL BX, 0(AX) | |
+ MOVL $-1, 0(AX) | |
MOVL DX, 4(AX) | |
MOVL $0xfffff, 8(AX) | |
MOVL $(SEG_32BIT|LIMIT_IN_PAGES|USEABLE|CONTENTS_DATA), 12(AX) // flag bits | |
- // call modify_ldt | |
- MOVL $1, BX // func = 1 (write) | |
- MOVL AX, CX // user_desc | |
- MOVL $16, DX // sizeof(user_desc) | |
- MOVL $123, AX // syscall - modify_ldt | |
+ // call set_thread_area | |
+ MOVL AX, BX // user_desc | |
+ MOVL $243, AX // syscall - set_thread_area | |
// We can't call this via 0x10(GS) because this is called from setldt0 to set that up. | |
INT $0x80 | |
@@ -463,9 +460,10 @@ | |
INT $3 | |
// compute segment selector - (entry*8+7) | |
- MOVL entry+0(FP), AX | |
+ LEAL 16(SP), AX // get our user_desc back | |
+ MOVL 0(AX), AX | |
SHLL $3, AX | |
- ADDL $7, AX | |
+ ADDL $3, AX | |
MOVW AX, GS | |
RET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment