]> Cypherpunks repositories - gostls13.git/commitdiff
8l, runtime: fix Plan 9 386 build.
authorYuval Pavel Zholkover <paulzhol@gmail.com>
Mon, 6 Dec 2010 21:38:28 +0000 (16:38 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 6 Dec 2010 21:38:28 +0000 (16:38 -0500)
8l was broken by commit 7ac0d2eed9, it caused .data to be page aligned in the file - which is not how Plan 9 expects things to be.
Also .rodata was layed out in a similar fashion.

Not sure when signame was introduced, but added a stub.
Removed the symo assignment in asm.c as it is not currently used.

Fix runtime breakage after commit 629c065d36 which prefixes all external symbols with runtime·.

R=rsc
CC=golang-dev
https://golang.org/cl/2674041

src/cmd/8l/asm.c
src/cmd/8l/obj.c
src/cmd/ld/data.c
src/pkg/runtime/plan9/386/signal.c
src/pkg/runtime/plan9/mem.c
src/pkg/runtime/plan9/runtime_defs.go [new file with mode: 0644]
src/pkg/runtime/plan9/thread.c

index fd2984955e7cf7b5892920cd014611b4207cc9f9..3900dd2a1fa7259be96661806ffac46c954d405b 100644 (file)
@@ -386,7 +386,6 @@ asmb(void)
                        break;
                case 2:
                        seek(cout, HEADR+segtext.filelen+segdata.filelen, 0);
-                       symo = HEADR+segtext.filelen+segdata.filelen;
                        break;
                case 3:
                case 4:
index 73a01311f5d201827f3e7f2d4bd3dc27e2120c39..1c3407206df323bf6317245b944123efe2e4e8fd 100644 (file)
@@ -192,7 +192,7 @@ main(int argc, char *argv[])
                if(INITDAT == -1)
                        INITDAT = 0;
                if(INITRND == -1)
-                       INITRND = 4096;
+                       INITRND = 1;
                break;
        case 3: /* MS-DOS .COM */
                HEADR = 0;
index ddcbcaa849d59828509be9d1b2f1516357427489..f2081178c072d6cca24870fb78fb1606115b9f24 100644 (file)
@@ -739,6 +739,10 @@ address(void)
        segdata.fileoff = va - segtext.vaddr + segtext.fileoff;
        if(thechar == '8' && HEADTYPE == 10)    // Windows PE
                segdata.fileoff = segtext.fileoff + rnd(segtext.len, PEFILEALIGN);
+       if(thechar == '8' && HEADTYPE == 2) {   // Plan 9               
+               segdata.vaddr = va = rnd(va, 4096);
+               segdata.fileoff = segtext.fileoff + segtext.filelen;
+       }
        for(s=segdata.sect; s != nil; s=s->next) {
                s->vaddr = va;
                va += s->len;
index 95fb2ca225a89f556db3c121e73dbd7cb59a7803..6bde09846639e2263c4922a337aa41f6130e369d 100644 (file)
@@ -8,3 +8,9 @@ void
 runtime·gettime(int64*, int32*) 
 {
 }
+
+String
+runtime·signame(int32)
+{
+       return runtime·emptystring;
+}
index 7e36f9534c5113cbf6d1a7ce959d3e07c0afc7e7..651e6728eddc188fd39b7496706a9e6ab31c6bf9 100644 (file)
@@ -20,7 +20,7 @@ runtime·SysAlloc(uintptr ask)
        
        // Plan 9 sbrk from /sys/src/libc/9sys/sbrk.c
        bl = ((uintptr)bloc + Round) & ~Round;
-       if(brk_((void*)(bl + ask)) < 0)
+       if(runtime·brk_((void*)(bl + ask)) < 0)
                return (void*)-1;
        bloc = (byte*)bl + ask;
        return (void*)bl;
diff --git a/src/pkg/runtime/plan9/runtime_defs.go b/src/pkg/runtime/plan9/runtime_defs.go
new file mode 100644 (file)
index 0000000..cf0b414
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Go definitions of internal structures. Master is runtime.h
+
+package runtime
+
+type lock struct {
+       key  uint32
+       sema uint32
+}
+
+type usema struct {
+       u uint32
+       k uint32
+}
+
+
+type note struct {
+       wakeup int32
+       sema   usema
+}
index 81e3bffbbe21c18df74e8512f7e0b04ee17df203..f1bd1ffbe2d543c4ccbd448cd8b7f8249e577b09 100644 (file)
@@ -36,10 +36,10 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
        m->tls[0] = m->id;      // so 386 asm can find it
        if(0){
                runtime·printf("newosproc stk=%p m=%p g=%p fn=%p rfork=%p id=%d/%d ostk=%p\n",
-                       stk, m, g, fn, rfork, m->id, m->tls[0], &m);
+                       stk, m, g, fn, runtime·rfork, m->id, m->tls[0], &m);
        }        
        
-       if (rfork(RFPROC | RFMEM, stk, m, g, fn) < 0 )
+       if (runtime·rfork(RFPROC | RFMEM, stk, m, g, fn) < 0 )
                runtime·throw("newosproc: rfork failed");
 }
 
@@ -63,10 +63,10 @@ runtime·lock(Lock *l)
                runtime·throw("lock count");
        m->locks++;
        
-       if(xadd(&l->key, 1) == 1)
+       if(runtime·xadd(&l->key, 1) == 1)
                return; // changed from 0 -> 1; we hold lock
        // otherwise wait in kernel
-       while(plan9_semacquire(&l->sema, 1) < 0) {
+       while(runtime·plan9_semacquire(&l->sema, 1) < 0) {
                /* interrupted; try again */
        }
 }
@@ -78,7 +78,7 @@ runtime·unlock(Lock *l)
        if(m->locks < 0)
                runtime·throw("lock count");
 
-       if(xadd(&l->key, -1) == 0)
+       if(runtime·xadd(&l->key, -1) == 0)
                return; // changed from 1 -> 0: no contention
        
        runtime·plan9_semrelease(&l->sema, 1);
@@ -98,8 +98,8 @@ runtime·destroylock(Lock *l)
 void
 runtime·usemacquire(Usema *s)
 {
-       if((int32)xadd(&s->u, -1) < 0)
-               while(plan9_semacquire(&s->k, 1) < 0) {
+       if((int32)runtime·xadd(&s->u, -1) < 0)
+               while(runtime·plan9_semacquire(&s->k, 1) < 0) {
                        /* interrupted; try again */
                }
 }
@@ -107,7 +107,7 @@ runtime·usemacquire(Usema *s)
 void
 runtime·usemrelease(Usema *s)
 {
-       if((int32)xadd(&s->u, 1) <= 0)
+       if((int32)runtime·xadd(&s->u, 1) <= 0)
                runtime·plan9_semrelease(&s->k, 1);
 }