~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/cmd/dist/buildruntime.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
        char *goos;
128
128
        char *hdr;
129
129
} zasmhdr[] = {
130
 
        {"386", "windows",
131
 
                "#define        get_tls(r)      MOVL 0x14(FS), r\n"
132
 
                "#define        g(r)    0(r)\n"
133
 
                "#define        m(r)    4(r)\n"
134
 
        },
135
 
        {"386", "plan9",
136
 
                "// Plan 9 does not have per-process segment descriptors with\n"
137
 
                "// which to do thread-local storage. Instead, we will use a\n"
138
 
                "// fixed offset from the per-process TOS struct address for\n"
139
 
                "// the local storage. Since the process ID is contained in the\n"
140
 
                "// TOS struct, we specify an offset for that here as well.\n"
141
 
                "#define        get_tls(r)      MOVL _tos(SB), r \n"
142
 
                "#define        g(r)    -8(r)\n"
143
 
                "#define        m(r)    -4(r)\n"
144
 
                "#define        procid(r)       48(r)\n"
145
 
        },
146
 
        {"386", "linux",
147
 
                "// On Linux systems, what we call 0(GS) and 4(GS) for g and m\n"
148
 
                "// turn into %gs:-8 and %gs:-4 (using gcc syntax to denote\n"
149
 
                "// what the machine sees as opposed to 8l input).\n"
150
 
                "// 8l rewrites 0(GS) and 4(GS) into these.\n"
151
 
                "//\n"
152
 
                "// On Linux Xen, it is not allowed to use %gs:-8 and %gs:-4\n"
153
 
                "// directly.  Instead, we have to store %gs:0 into a temporary\n"
154
 
                "// register and then use -8(%reg) and -4(%reg).  This kind\n"
155
 
                "// of addressing is correct even when not running Xen.\n"
156
 
                "//\n"
157
 
                "// 8l can rewrite MOVL 0(GS), CX into the appropriate pair\n"
158
 
                "// of mov instructions, using CX as the intermediate register\n"
159
 
                "// (safe because CX is about to be written to anyway).\n"
160
 
                "// But 8l cannot handle other instructions, like storing into 0(GS),\n"
161
 
                "// which is where these macros come into play.\n"
162
 
                "// get_tls sets up the temporary and then g and r use it.\n"
163
 
                "//\n"
164
 
                "// Another wrinkle is that get_tls needs to read from %gs:0,\n"
165
 
                "// but in 8l input it's called 8(GS), because 8l is going to\n"
166
 
                "// subtract 8 from all the offsets, as described above.\n"
167
 
                "//\n"
168
 
                "// The final wrinkle is that when generating an ELF .o file for\n"
169
 
                "// external linking mode, we need to be able to relocate the\n"
170
 
                "// -8(r) and -4(r) instructions. Tag them with an extra (GS*1)\n"
171
 
                "// that is ignored by the linker except for that identification.\n"
172
 
                "#define        get_tls(r)      MOVL 8(GS), r\n"
173
 
                "#define        g(r)    -8(r)(GS*1)\n"
174
 
                "#define        m(r)    -4(r)(GS*1)\n"
175
 
        },
176
130
        {"386", "",
177
 
                "#define        get_tls(r)\n"
178
 
                "#define        g(r)    0(GS)\n"
179
 
                "#define        m(r)    4(GS)\n"
180
 
        },
181
 
        
182
 
        {"amd64", "windows",
183
 
                "#define        get_tls(r) MOVQ 0x28(GS), r\n"
184
 
                "#define        g(r) 0(r)\n"
185
 
                "#define        m(r) 8(r)\n"
186
 
        },
187
 
        {"amd64", "plan9",
188
 
                "#define        get_tls(r)\n"
189
 
                "#define        g(r) 0(GS)\n"
190
 
                "#define        m(r) 8(GS)\n"
191
 
                "#define        procid(r) 16(GS)\n"
192
 
        },
193
 
        // The TLS accessors here are defined here to use initial exec model.
194
 
        // If the linker is not outputting a shared library, it will reduce
195
 
        // the TLS accessors to the local exec model, effectively removing
196
 
        // get_tls().
197
 
        {"amd64", "linux",
198
 
                "#define        get_tls(r) MOVQ runtime·tlsgm(SB), r\n"
199
 
                "#define        g(r) 0(r)(GS*1)\n"
200
 
                "#define        m(r) 8(r)(GS*1)\n"
 
131
                "#define        get_tls(r)      MOVL TLS, r\n"
 
132
                "#define        g(r)    0(r)(TLS*1)\n"
 
133
                "#define        m(r)    4(r)(TLS*1)\n"
 
134
        },
 
135
        {"amd64p32", "",
 
136
                "#define        get_tls(r)      MOVL TLS, r\n"
 
137
                "#define        g(r)    0(r)(TLS*1)\n"
 
138
                "#define        m(r)    4(r)(TLS*1)\n"
201
139
        },
202
140
        {"amd64", "",
203
 
                "#define get_tls(r)\n"
204
 
                "#define g(r) 0(GS)\n"
205
 
                "#define m(r) 8(GS)\n"
 
141
                "#define        get_tls(r)      MOVQ TLS, r\n"
 
142
                "#define        g(r)    0(r)(TLS*1)\n"
 
143
                "#define        m(r)    8(r)(TLS*1)\n"
206
144
        },      
 
145
 
207
146
        {"arm", "",
208
147
        "#define        LR      R14\n"
209
148
        },
243
182
ok:
244
183
 
245
184
        // Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -a -n -o workdir/proc.acid proc.c
246
 
        // to get acid [sic] output.
 
185
        // to get acid [sic] output. Run once without the -a -o workdir/proc.acid in order to
 
186
        // report compilation failures (the -o redirects all messages, unfortunately).
247
187
        vreset(&argv);
248
188
        vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
249
189
        vadd(&argv, "-D");
252
192
        vadd(&argv, bprintf(&b, "GOARCH_%s", goarch));
253
193
        vadd(&argv, "-I");
254
194
        vadd(&argv, bprintf(&b, "%s", workdir));
 
195
        vadd(&argv, "-n");
255
196
        vadd(&argv, "-a");
256
 
        vadd(&argv, "-n");
257
197
        vadd(&argv, "-o");
258
198
        vadd(&argv, bpathf(&b, "%s/proc.acid", workdir));
259
199
        vadd(&argv, "proc.c");
284
224
                                aggr = "p";
285
225
                        else if(streq(fields.p[1], "Gobuf"))
286
226
                                aggr = "gobuf";
287
 
                        else if(streq(fields.p[1], "WinCall"))
288
 
                                aggr = "wincall";
 
227
                        else if(streq(fields.p[1], "LibCall"))
 
228
                                aggr = "libcall";
289
229
                        else if(streq(fields.p[1], "WinCallbackContext"))
290
230
                                aggr = "cbctxt";
291
231
                        else if(streq(fields.p[1], "SEH"))
329
269
        vfree(&fields);
330
270
}
331
271
 
332
 
// mkzsys writes zsys_$GOOS_$GOARCH.h,
 
272
// mkzsys writes zsys_$GOOS_$GOARCH.s,
333
273
// which contains arch or os specific asm code.
334
274
// 
335
275
void
365
305
}
366
306
 
367
307
static char *runtimedefs[] = {
 
308
        "defs.c",
368
309
        "proc.c",
369
 
        "iface.c",
370
 
        "hashmap.c",
371
 
        "chan.c",
372
310
        "parfor.c",
373
311
};
374
312