]> Cypherpunks repositories - gostls13.git/commitdiff
convert 386 to use %gs instead of %fs for extern register.
authorRuss Cox <rsc@golang.org>
Mon, 21 Sep 2009 22:46:50 +0000 (15:46 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 21 Sep 2009 22:46:50 +0000 (15:46 -0700)
required for nacl and may be nicer for ffi,
because %gs is the standard register for thread-local storage.

R=ken
OCL=34861
CL=34866

src/cmd/8c/txt.c
src/cmd/8l/pass.c
src/pkg/runtime/386/asm.s
src/pkg/runtime/darwin/386/sys.s
src/pkg/runtime/linux/386/sys.s
src/pkg/runtime/mkasmh.sh

index 8abaa667d45a56a095e50835e68bf6fed9e28aa1..194599c3a98ab8d8d1c3baada97d43c6e5dacee6 100644 (file)
@@ -450,7 +450,7 @@ naddr(Node *n, Adr *a)
                break;
 
        case OEXREG:
-               a->type = D_INDIR + D_FS;
+               a->type = D_INDIR + D_GS;
                a->offset = n->reg - 1;
                break;
 
index 8b714fdbad4339e81f58bb75ad626f6e5cd54c5a..bc3e1649fbe437dc102eec9d8cfae0ee67cabc6e 100644 (file)
@@ -464,6 +464,7 @@ dostkoff(void)
        int a, f, curframe, curbecome, maxbecome;
        Prog *pmorestack;
        Sym *symmorestack;
+       static int fsreg;
 
        pmorestack = P;
        symmorestack = lookup("sys·morestack", 0);
@@ -565,7 +566,7 @@ dostkoff(void)
                        if(!(p->from.scale & NOSPLIT)) {
                                p = appendp(p); // load g into CX
                                p->as = AMOVL;
-                               p->from.type = D_INDIR+D_FS;
+                               p->from.type = D_INDIR+D_GS;
                                p->from.offset = 0;
                                p->to.type = D_CX;
 
index 3574deed88b0502f16a0191c3268cd51357a5ebb..a7265b2b2da2b40acc4a95a06dc9c306560a4237 100644 (file)
@@ -15,12 +15,12 @@ TEXT _rt0_386(SB),7,$0
 
        CALL    ldt0setup(SB)
 
-       // set up %fs to refer to that ldt entry
+       // set up %gs to refer to that ldt entry
        MOVL    $(7*8+7), AX
-       MOVW    AX, FS
+       MOVW    AX, GS
 
        // store through it, to make sure it works
-       MOVL    $0x123, 0(FS)
+       MOVL    $0x123, 0(GS)
        MOVL    tls0(SB), AX
        CMPL    AX, $0x123
        JEQ     ok
index fc2d8ede9c4dcd30e396685ce210ed6c4b10dc2b..49743359fddf4e866a9cf3a48762e993cd3eb351 100644 (file)
@@ -139,7 +139,7 @@ TEXT bsdthread_start(SB),7,$0
        POPAL
        SHLL    $3, DI  // segment# is ldt*8 + 7.
        ADDL    $7, DI
-       MOVW    DI, FS
+       MOVW    DI, GS
 
        // Now segment is established.  Initialize m, g.
        MOVL    AX, g
index fa056c075dabc296db3e1d42bf85e289314359fa..7f4787700b183e0ca0e343b49e2430f01d8bba21 100755 (executable)
@@ -8,20 +8,6 @@
 
 #include "386/asm.h"
 
-TEXT syscall(SB),7,$0
-       MOVL 4(SP), AX  // syscall number
-       MOVL 8(SP), BX  // arg1
-       MOVL 12(SP), CX // arg2
-       MOVL 16(SP), DX // arg3
-       MOVL 20(SP), SI // arg4
-       MOVL 24(SP), DI // arg5
-       MOVL 28(SP), BP // arg6
-       INT $0x80
-       CMPL AX, $0xfffff001
-       JLS 2(PC)
-       INT $3  // not reached
-       RET
-
 TEXT exit(SB),7,$0
        MOVL    $252, AX        // syscall number
        MOVL    4(SP), BX
@@ -159,7 +145,7 @@ TEXT clone(SB),7,$0
        POPAL
        SHLL    $3, DI  // segment# is ldt*8 + 7 (different 7 than above)
        ADDL    $7, DI
-       MOVW    DI, FS
+       MOVW    DI, GS
 
        // Now segment is established.  Initialize m, g.
        MOVL    DX, g
@@ -190,15 +176,15 @@ TEXT sigaltstack(SB),7,$-8
 
 // <asm-i386/ldt.h>
 // struct user_desc {
-//     unsigned int  entry_number;
-//     unsigned long base_addr;
-//     unsigned int  limit;
-//     unsigned int  seg_32bit:1;
-//     unsigned int  contents:2;
-//     unsigned int  read_exec_only:1;
-//     unsigned int  limit_in_pages:1;
-//     unsigned int  seg_not_present:1;
-//     unsigned int  useable:1;
+//     unsigned int  entry_number;
+//     unsigned long base_addr;
+//     unsigned int  limit;
+//     unsigned int  seg_32bit:1;
+//     unsigned int  contents:2;
+//     unsigned int  read_exec_only:1;
+//     unsigned int  limit_in_pages:1;
+//     unsigned int  seg_not_present:1;
+//     unsigned int  useable:1;
 // };
 #define SEG_32BIT 0x01
 // contents are the 2 bits 0x02 and 0x04.
@@ -223,10 +209,15 @@ TEXT setldt(SB),7,$32
        MOVL    $(SEG_32BIT|USEABLE|CONTENTS_DATA), 12(AX)      // flag bits
 
        // call modify_ldt
-       MOVL    $123, 0(SP)     // syscall - modify_ldt
-       MOVL    $1, 4(SP)       // func = 1 (write)
-       MOVL    AX, 8(SP)       // user_desc
-       MOVL    $16, 12(SP)     // sizeof(user_desc)
-       CALL    syscall(SB)
+       MOVL    $1, BX  // func = 1 (write)
+       MOVL    AX, CX  // user_desc
+       MOVL    $16, DX // sizeof(user_desc)
+       MOVL    $123, AX        // syscall - modify_ldt
+       INT     $0x80
+
+       // breakpoint on error
+       CMPL AX, $0xfffff001
+       JLS 2(PC)
+       INT $3
        RET
 
index 6e6ebfca98d6fc1002be32458e490bc59065c6e0..bc99a26255313c201b121805b9f699190d8ead60 100755 (executable)
@@ -13,8 +13,8 @@ EOF
 
 case "$GOARCH" in
 386)
-       echo '#define   g       0(FS)'
-       echo '#define   m       4(FS)'
+       echo '#define   g       0(GS)'
+       echo '#define   m       4(GS)'
        ;;
 amd64)
        echo '#define   g       R15'