Browse Source

go port: disable mmap segment, extend text segment to the start of data segment. this is a hack for go, which puts in a separate rodata segment, ignored by our parser currently.

Change-Id: I17902704e873e297faf656afe583becffc4c8dfa
Aki Nyrhinen 8 years ago
parent
commit
5a6cd011f3
3 changed files with 28 additions and 14 deletions
  1. 3 3
      sys/src/9/port/sysproc.c
  2. 25 0
      sys/src/regress/hello.go
  3. 0 11
      util/hello.go

+ 3 - 3
sys/src/9/port/sysproc.c

@@ -1178,7 +1178,7 @@ DBG(
 	 * but prepaged if EXAC
 	 */
 	// TODO: Just use the program header instead of these other things.
-	img = attachimage(SG_TEXT|SG_RONLY, chan, m->externup->color, textaddr, (textlim-textaddr)/BIGPGSZ);
+	img = attachimage(SG_TEXT|SG_RONLY, chan, m->externup->color, textaddr, (dataddr-textaddr)/BIGPGSZ);
 	s = img->s;
 	s->ph = d.e.ph[f.it];
 	m->externup->seg[TSEG] = s;
@@ -1208,11 +1208,11 @@ DBG(
 	s = m->externup->seg[ESEG];
 	m->externup->seg[ESEG] = nil;
 
-	/* MMAP region. Put it at 512GiB for now. */
+	/* MMAP region. Put it at 512GiB for now. 
 	m->externup->seg[ESEG] = newseg(SG_MMAP, 512 * GiB, 1);
 	if (0) print("mmap ESEG is %p\n", m->externup->seg);
 	m->externup->seg[ESEG]->color= m->externup->color;
-
+*/
 	m->externup->seg[SSEG] = s;
 	/* the color of the stack was decided when we created it before,
 	 * it may have nothing to do with the color of other segments.

+ 25 - 0
sys/src/regress/hello.go

@@ -0,0 +1,25 @@
+package main
+
+import (
+	"os"
+	"fmt"
+)
+
+func main() {
+	tab := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
+	ch := make(chan bool)
+	for i := 0; i < 10; i++ {
+		go func(i int){
+			fmt.Printf("hello %s fmt.printf %d/%d\n", tab[i], i, len(tab))
+			ch <- true
+		}(i);
+	}
+	for i := 0; i < 10; i++ {
+		<-ch
+	}
+	os.Stdout.Write([]byte("hello os.write all done\n"))
+
+	if _, err := os.Open("/xyz"); err != nil {
+		fmt.Printf("open failed %v\n", err)
+	}
+}

+ 0 - 11
util/hello.go

@@ -1,11 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"os"
-)
-
-func main() {
-	fmt.Print("hello go\n")
-	os.Exit(0)
-}