LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "go.h" | 7 #include "go.h" |
8 | 8 |
9 /* | 9 /* |
10 * architecture-independent object file output | 10 * architecture-independent object file output |
11 */ | 11 */ |
12 | 12 |
13 static void outhist(Biobuf *b); | 13 static void outhist(Biobuf *b); |
14 static void dumpglobls(void); | 14 static void dumpglobls(void); |
15 | 15 |
16 void | 16 void |
17 dumpobj(void) | 17 dumpobj(void) |
18 { | 18 { |
| 19 NodeList *externs, *tmp; |
| 20 |
19 bout = Bopen(outfile, OWRITE); | 21 bout = Bopen(outfile, OWRITE); |
20 if(bout == nil) { | 22 if(bout == nil) { |
21 flusherrors(); | 23 flusherrors(); |
22 print("can't create %s: %r\n", outfile); | 24 print("can't create %s: %r\n", outfile); |
23 errorexit(); | 25 errorexit(); |
24 } | 26 } |
25 | 27 |
26 Bprint(bout, "go object %s %s %s %s\n", getgoos(), thestring, getgoversi
on(), expstring()); | 28 Bprint(bout, "go object %s %s %s %s\n", getgoos(), thestring, getgoversi
on(), expstring()); |
27 Bprint(bout, " exports automatically generated from\n"); | 29 Bprint(bout, " exports automatically generated from\n"); |
28 Bprint(bout, " %s in package \"%s\"\n", curio.infile, localpkg->name); | 30 Bprint(bout, " %s in package \"%s\"\n", curio.infile, localpkg->name); |
29 dumpexport(); | 31 dumpexport(); |
30 Bprint(bout, "\n!\n"); | 32 Bprint(bout, "\n!\n"); |
31 | 33 |
32 outhist(bout); | 34 outhist(bout); |
33 | 35 |
| 36 externs = nil; |
| 37 if(externdcl != nil) |
| 38 externs = externdcl->end; |
| 39 |
34 dumpglobls(); | 40 dumpglobls(); |
35 dumptypestructs(); | 41 dumptypestructs(); |
| 42 |
| 43 // Dump extra globals. |
| 44 tmp = externdcl; |
| 45 if(externs != nil) |
| 46 externdcl = externs->next; |
| 47 dumpglobls(); |
| 48 externdcl = tmp; |
| 49 |
36 dumpdata(); | 50 dumpdata(); |
37 dumpfuncs(); | 51 dumpfuncs(); |
38 | 52 |
39 Bterm(bout); | 53 Bterm(bout); |
40 } | 54 } |
41 | 55 |
42 static void | 56 static void |
43 dumpglobls(void) | 57 dumpglobls(void) |
44 { | 58 { |
45 Node *n; | 59 Node *n; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if(m > len-n) | 331 if(m > len-n) |
318 m = len-n; | 332 m = len-n; |
319 off = dsname(sym, off, s+n, m); | 333 off = dsname(sym, off, s+n, m); |
320 } | 334 } |
321 off = duint8(sym, off, 0); // terminating NUL for runtime | 335 off = duint8(sym, off, 0); // terminating NUL for runtime |
322 off = (off+widthptr-1)&~(widthptr-1); // round to pointer alignment | 336 off = (off+widthptr-1)&~(widthptr-1); // round to pointer alignment |
323 ggloblsym(sym, off, 1, 1); | 337 ggloblsym(sym, off, 1, 1); |
324 | 338 |
325 return sym;····· | 339 return sym;····· |
326 } | 340 } |
LEFT | RIGHT |