Print this page
switch aw & cw to target ARMv7
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/aw/aw.c
+++ new/usr/src/tools/aw/aw.c
1 1
2 2 /*
3 3 * CDDL HEADER START
4 4 *
5 5 * The contents of this file are subject to the terms of the
6 6 * Common Development and Distribution License (the "License").
7 7 * You may not use this file except in compliance with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 27
28 28 /*
29 29 * Wrapper for the GNU assembler to make it accept the Sun assembler
30 30 * arguments where possible.
31 31 *
32 32 * There are several limitations; the Sun assembler takes multiple
33 33 * source files, we only take one.
34 34 *
35 35 * -b, -s, -xF, -T plain not supported.
36 36 * -S isn't supported either, because while GNU as does generate
37 37 * listings with -a, there's no obvious mapping between sub-options.
38 38 * -K pic, -K PIC not supported either, though it's not clear what
39 39 * these actually do ..
40 40 * -Qy (not supported) adds a string to the .comment section
41 41 * describing the assembler version, while
42 42 * -Qn (supported) suppresses the string (also the default).
43 43 *
44 44 * We also add '-#' support to see invocation lines..
45 45 * We also add '-xarch=amd64' in case we need to feed the assembler
46 46 * something different (or in case we need to invoke a different binary
47 47 * altogether!)
48 48 */
49 49
50 50 #include <sys/types.h>
51 51 #include <sys/wait.h>
52 52 #include <stdio.h>
53 53 #include <unistd.h>
54 54 #include <string.h>
55 55 #include <stdlib.h>
56 56 #include <sys/param.h>
57 57
58 58 static const char *progname;
59 59 static int verbose;
60 60
61 61 struct aelist {
62 62 int ael_argc;
63 63 struct ae {
64 64 struct ae *ae_next;
65 65 char *ae_arg;
66 66 } *ael_head, *ael_tail;
67 67 };
68 68
69 69 static struct aelist *
70 70 newael(void)
71 71 {
72 72 return (calloc(sizeof (struct aelist), 1));
73 73 }
74 74
75 75 static void
76 76 newae(struct aelist *ael, const char *arg)
77 77 {
78 78 struct ae *ae;
79 79
80 80 ae = calloc(sizeof (*ae), 1);
81 81 ae->ae_arg = strdup(arg);
82 82 if (ael->ael_tail == NULL)
83 83 ael->ael_head = ae;
84 84 else
85 85 ael->ael_tail->ae_next = ae;
86 86 ael->ael_tail = ae;
87 87 ael->ael_argc++;
88 88 }
89 89
90 90 static void
91 91 fixae_arg(struct ae *ae, const char *newarg)
92 92 {
93 93 free(ae->ae_arg);
94 94 ae->ae_arg = strdup(newarg);
95 95 }
96 96
97 97 static char **
98 98 aeltoargv(struct aelist *ael)
99 99 {
100 100 struct ae *ae;
101 101 char **argv;
102 102 int argc;
103 103
104 104 argv = calloc(sizeof (*argv), ael->ael_argc + 1);
105 105
106 106 for (argc = 0, ae = ael->ael_head; ae; ae = ae->ae_next, argc++) {
107 107 argv[argc] = ae->ae_arg;
108 108 if (ae == ael->ael_tail)
109 109 break;
110 110 }
111 111
112 112 return (argv);
113 113 }
114 114
115 115 static int
116 116 error(const char *arg)
117 117 {
118 118 (void) fprintf(stderr,
119 119 "%s: as->gas mapping failed at or near arg '%s'\n", progname, arg);
120 120 return (2);
121 121 }
122 122
123 123 static int
124 124 usage(const char *arg)
125 125 {
126 126 if (arg != NULL)
127 127 (void) fprintf(stderr, "error: %s\n", arg);
128 128 (void) fprintf(stderr, "Usage: %s [-V] [-#]\n"
129 129 "\t[-xarch=architecture]\n"
130 130 "\t[-o objfile] [-L]\n"
131 131 "\t[-P [[-Ipath] [-Dname] [-Dname=def] [-Uname]]...]\n"
132 132 "\t[-m] [-n] file.s ...\n", progname);
133 133 return (3);
134 134 }
135 135
136 136 static void
137 137 copyuntil(FILE *in, FILE *out, int termchar)
138 138 {
139 139 int c;
140 140
141 141 while ((c = fgetc(in)) != EOF) {
142 142 if (out && fputc(c, out) == EOF)
143 143 exit(1);
144 144 if (c == termchar)
145 145 break;
146 146 }
147 147 }
148 148
149 149 /*
150 150 * Variant of copyuntil(), used for copying the path used
151 151 * for .file directives. This version removes the workspace
152 152 * from the head of the path, or failing that, attempts to remove
153 153 * /usr/include. This is a workaround for the way gas handles
154 154 * these directives. The objects produced by gas contain STT_FILE
155 155 * symbols for every .file directive. These FILE symbols contain our
156 156 * workspace paths, leading to wsdiff incorrectly flagging them as
157 157 * having changed. By clipping off the workspace from these paths,
158 158 * we eliminate these false positives.
159 159 */
160 160 static void
161 161 copyuntil_path(FILE *in, FILE *out, int termchar,
162 162 const char *wspace, size_t wspace_len)
163 163 {
164 164 #define SYS_INC "/usr/include/"
165 165
166 166 static const size_t proto_inc_len = sizeof (PROTO_INC) - 1;
167 167 static const size_t sys_inc_len = sizeof (SYS_INC) - 1;
168 168
169 169 /*
170 170 * Dynamically sized buffer for reading paths. Retained
171 171 * and reused between calls.
172 172 */
173 173 static char *buf = NULL;
174 174 static size_t bufsize = 0;
175 175
176 176 size_t bufcnt = 0;
177 177 char *bufptr;
178 178 int c;
179 179
180 180 /* Read the path into the buffer */
181 181 while ((c = fgetc(in)) != EOF) {
182 182 /*
183 183 * If we need a buffer, or need a larger buffer,
184 184 * fix that here.
185 185 */
186 186 if (bufcnt >= bufsize) {
187 187 bufsize = (bufsize == 0) ? MAXPATHLEN : (bufsize * 2);
188 188 buf = realloc(buf, bufsize + 1); /* + room for NULL */
189 189 if (buf == NULL) {
190 190 perror("realloc");
191 191 exit(1);
192 192 }
193 193 }
194 194
195 195 buf[bufcnt++] = c;
196 196 if (c == termchar)
197 197 break;
198 198 }
199 199 if (bufcnt == 0)
200 200 return;
201 201
202 202 /*
203 203 * We have a non-empty buffer, and thus the opportunity
204 204 * to do some surgery on it before passing it to the output.
205 205 */
206 206 buf[bufcnt] = '\0';
207 207 bufptr = buf;
208 208
209 209 /*
210 210 * If our workspace is at the start, remove it.
211 211 * If not, then look for the system /usr/include instead.
212 212 */
213 213 if ((wspace_len > 0) && (wspace_len < bufcnt) &&
214 214 (strncmp(bufptr, wspace, wspace_len) == 0)) {
215 215 bufptr += wspace_len;
216 216 bufcnt -= wspace_len;
217 217
218 218 /*
219 219 * Further opportunity: Also clip the prefix
220 220 * that leads to /usr/include in the proto.
221 221 */
222 222 if ((proto_inc_len < bufcnt) &&
223 223 (strncmp(bufptr, PROTO_INC, proto_inc_len) == 0)) {
224 224 bufptr += proto_inc_len;
225 225 bufcnt -= proto_inc_len;
226 226 }
227 227 } else if ((sys_inc_len < bufcnt) &&
228 228 (strncmp(bufptr, SYS_INC, sys_inc_len) == 0)) {
229 229 bufptr += sys_inc_len;
230 230 bufcnt -= sys_inc_len;
231 231 }
232 232
233 233 /* Output whatever is left */
234 234 if (out && (fwrite(bufptr, 1, bufcnt, out) != bufcnt)) {
235 235 perror("fwrite");
236 236 exit(1);
237 237 }
238 238
239 239 #undef PROTO_INC
240 240 #undef SYS_INC
241 241 }
242 242
243 243 /*
244 244 * The idea here is to take directives like this emitted
245 245 * by cpp:
246 246 *
247 247 * # num
248 248 *
249 249 * and convert them to directives like this that are
250 250 * understood by the GNU assembler:
251 251 *
252 252 * .line num
253 253 *
254 254 * and similarly:
255 255 *
256 256 * # num "string" optional stuff
257 257 *
258 258 * is converted to
259 259 *
260 260 * .line num
261 261 * .file "string"
262 262 *
263 263 * While this could be done with a sequence of sed
264 264 * commands, this is simpler and faster..
265 265 */
266 266 static pid_t
267 267 filter(int pipein, int pipeout)
268 268 {
269 269 pid_t pid;
270 270 FILE *in, *out;
271 271 char *wspace;
272 272 size_t wspace_len;
273 273
274 274 if (verbose)
275 275 (void) fprintf(stderr, "{#line filter} ");
276 276
277 277 switch (pid = fork()) {
278 278 case 0:
279 279 if (dup2(pipein, 0) == -1 ||
280 280 dup2(pipeout, 1) == -1) {
281 281 perror("dup2");
282 282 exit(1);
283 283 }
284 284 closefrom(3);
285 285 break;
286 286 case -1:
287 287 perror("fork");
288 288 default:
289 289 return (pid);
290 290 }
291 291
292 292 in = fdopen(0, "r");
293 293 out = fdopen(1, "w");
294 294
295 295 /*
296 296 * Key off the CODEMGR_WS environment variable to detect
297 297 * if we're in an activated workspace, and to get the
298 298 * path to the workspace.
299 299 */
300 300 wspace = getenv("CODEMGR_WS");
301 301 if (wspace != NULL)
302 302 wspace_len = strlen(wspace);
303 303
304 304 while (!feof(in)) {
305 305 int c, num;
306 306
307 307 switch (c = fgetc(in)) {
308 308 case '#':
309 309 switch (fscanf(in, " %d", &num)) {
310 310 case 0:
311 311 /*
312 312 * discard comment lines completely
313 313 * discard ident strings completely too.
314 314 * (GNU as politely ignores them..)
315 315 */
316 316 copyuntil(in, NULL, '\n');
317 317 break;
318 318 default:
319 319 (void) fprintf(stderr, "fscanf botch?");
320 320 /*FALLTHROUGH*/
321 321 case EOF:
322 322 exit(1);
323 323 /*NOTREACHED*/
324 324 case 1:
325 325 /*
326 326 * This line has a number at the beginning;
327 327 * if it has a string after the number, then
328 328 * it's a filename.
329 329 *
330 330 * If this is an activated workspace, use
331 331 * copyuntil_path() to do path rewriting
332 332 * that will prevent workspace paths from
333 333 * being burned into the resulting object.
334 334 * If not in an activated workspace, then
335 335 * copy the existing path straight through
336 336 * without interpretation.
337 337 */
338 338 if (fgetc(in) == ' ' && fgetc(in) == '"') {
339 339 (void) fprintf(out, "\t.file \"");
340 340 if (wspace != NULL)
341 341 copyuntil_path(in, out, '"',
342 342 wspace, wspace_len);
343 343 else
344 344 copyuntil(in, out, '"');
345 345 (void) fputc('\n', out);
346 346 }
347 347 (void) fprintf(out, "\t.line %d\n", num - 1);
348 348 /*
349 349 * discard the rest of the line
350 350 */
351 351 copyuntil(in, NULL, '\n');
352 352 break;
353 353 }
354 354 break;
355 355 case '\n':
356 356 /*
357 357 * preserve newlines
358 358 */
359 359 (void) fputc(c, out);
360 360 break;
361 361 case EOF:
362 362 /*
363 363 * don't write EOF!
364 364 */
365 365 break;
366 366 default:
367 367 /*
368 368 * lines that don't begin with '#' are copied
369 369 */
370 370 (void) fputc(c, out);
371 371 copyuntil(in, out, '\n');
372 372 break;
373 373 }
374 374
375 375 if (ferror(out))
376 376 exit(1);
377 377 }
378 378
379 379 exit(0);
380 380 /*NOTREACHED*/
381 381 }
382 382
383 383 static pid_t
384 384 invoke(char **argv, int pipein, int pipeout)
385 385 {
386 386 pid_t pid;
387 387
388 388 if (verbose) {
389 389 char **dargv = argv;
390 390
391 391 while (*dargv)
392 392 (void) fprintf(stderr, "%s ", *dargv++);
393 393 }
394 394
395 395 switch (pid = fork()) {
396 396 case 0:
397 397 if (pipein >= 0 && dup2(pipein, 0) == -1) {
398 398 perror("dup2");
399 399 exit(1);
400 400 }
401 401 if (pipeout >= 0 && dup2(pipeout, 1) == -1) {
402 402 perror("dup2");
403 403 exit(1);
404 404 }
405 405 closefrom(3);
406 406 (void) execvp(argv[0], argv);
407 407 perror("execvp");
408 408 (void) fprintf(stderr, "%s: couldn't run %s\n",
409 409 progname, argv[0]);
410 410 break;
411 411 case -1:
412 412 perror("fork");
413 413 default:
414 414 return (pid);
415 415 }
416 416 exit(2);
417 417 /*NOTREACHED*/
418 418 }
419 419
420 420 static int
421 421 pipeline(char **ppargv, char **asargv)
422 422 {
423 423 int pipedes[4];
424 424 int active = 0;
425 425 int rval = 0;
426 426 pid_t pid_pp, pid_f, pid_as;
427 427
428 428 if (pipe(pipedes) == -1 || pipe(pipedes + 2) == -1) {
429 429 perror("pipe");
430 430 return (4);
431 431 }
432 432
433 433 if ((pid_pp = invoke(ppargv, -1, pipedes[0])) > 0)
434 434 active++;
435 435
436 436 if (verbose)
437 437 (void) fprintf(stderr, "| ");
438 438
439 439 if ((pid_f = filter(pipedes[1], pipedes[2])) > 0)
440 440 active++;
441 441
442 442 if (verbose)
443 443 (void) fprintf(stderr, "| ");
444 444
445 445 if ((pid_as = invoke(asargv, pipedes[3], -1)) > 0)
446 446 active++;
447 447
448 448 if (verbose) {
449 449 (void) fprintf(stderr, "\n");
450 450 (void) fflush(stderr);
451 451 }
452 452
453 453 closefrom(3);
454 454
455 455 if (active != 3)
456 456 return (5);
457 457
458 458 while (active != 0) {
459 459 pid_t pid;
460 460 int stat;
461 461
462 462 if ((pid = wait(&stat)) == -1) {
463 463 rval++;
464 464 break;
465 465 }
466 466
467 467 if (!WIFEXITED(stat))
468 468 continue;
469 469
470 470 if (pid == pid_pp || pid == pid_f || pid == pid_as) {
471 471 active--;
472 472 if (WEXITSTATUS(stat) != 0)
473 473 rval++;
474 474 }
475 475 }
476 476
477 477 return (rval);
478 478 }
479 479
480 480 int
481 481 main(int argc, char *argv[])
482 482 {
483 483 struct aelist *cpp = NULL;
484 484 struct aelist *m4 = NULL;
485 485 struct aelist *as = newael();
486 486 char **asargv;
487 487 char *outfile = NULL;
488 488 char *srcfile = NULL;
489 489 const char *dir, *cmd;
490 490 static char as_pgm[MAXPATHLEN];
491 491 static char as64_pgm[MAXPATHLEN];
492 492 static char m4_pgm[MAXPATHLEN];
493 493 static char m4_cmdefs[MAXPATHLEN];
494 494 static char cpp_pgm[MAXPATHLEN];
495 495 int as64 = 0;
496 496 int code;
497 497
498 498 if ((progname = strrchr(argv[0], '/')) == NULL)
499 499 progname = argv[0];
500 500 else
501 501 progname++;
502 502
503 503 /*
504 504 * Helpful when debugging, or when changing tool versions..
505 505 */
506 506 cmd = dir = NULL;
507 507 if ((cmd = getenv("AW_" AW_TARGET "_AS")) == NULL)
508 508 cmd = getenv("AW_AS");
509 509 if ((dir = getenv("AW_" AW_TARGET "_AS_DIR")) == NULL)
510 510 dir = getenv("AW_AS_DIR");
511 511
512 512 if (cmd != NULL) {
513 513 (void) strlcpy(as_pgm, cmd, sizeof (as_pgm));
514 514 } else {
515 515 if (dir == NULL)
516 516 dir = DEFAULT_AS_DIR;
517 517 (void) snprintf(as_pgm, sizeof (as_pgm), "%s/gas", dir);
518 518 }
519 519
520 520 cmd = dir = NULL;
521 521 if ((cmd = getenv("AW_" AW_TARGET "_AS64")) == NULL)
522 522 cmd = getenv("AW_AS64");
523 523 if ((dir = getenv("AW_" AW_TARGET "_AS64_DIR")) == NULL)
524 524 dir = getenv("AW_AS64_DIR");
525 525
526 526 if (cmd != NULL) {
527 527 (void) strlcpy(as64_pgm, cmd, sizeof (as64_pgm));
528 528 } else {
529 529 if (dir == NULL)
530 530 dir = DEFAULT_AS64_DIR;
531 531 (void) snprintf(as64_pgm, sizeof (as_pgm), "%s/gas", dir);
532 532 }
533 533
534 534 if ((cmd = getenv("AW_M4")) != NULL)
535 535 strlcpy(m4_pgm, cmd, sizeof (m4_pgm));
536 536 else {
537 537 if ((dir = getenv("AW_M4_DIR")) == NULL)
538 538 dir = DEFAULT_M4_DIR; /* /usr/ccs/bin */
539 539 (void) snprintf(m4_pgm, sizeof (m4_pgm), "%s/m4", dir);
540 540 }
541 541
542 542 if ((cmd = getenv("AW_M4LIB")) != NULL)
543 543 strlcpy(m4_cmdefs, cmd, sizeof (m4_cmdefs));
544 544 else {
545 545 if ((dir = getenv("AW_M4LIB_DIR")) == NULL)
546 546 dir = DEFAULT_M4LIB_DIR; /* /usr/ccs/lib */
547 547 (void) snprintf(m4_cmdefs, sizeof (m4_cmdefs),
548 548 "%s/cm4defs", dir);
549 549 }
550 550
551 551 if ((cmd = getenv("AW_CPP")) != NULL)
552 552 strlcpy(cpp_pgm, cmd, sizeof (cpp_pgm));
553 553 else {
554 554 if ((dir = getenv("AW_CPP_DIR")) == NULL)
555 555 dir = DEFAULT_CPP_DIR; /* /usr/ccs/lib */
556 556 (void) snprintf(cpp_pgm, sizeof (cpp_pgm), "%s/cpp", dir);
557 557 }
558 558
559 559 newae(as, as_pgm);
560 560 newae(as, "--warn");
561 561 newae(as, "--fatal-warnings");
562 562 newae(as, "--traditional-format");
563 563
564 564 /*
565 565 * Walk the argument list, translating as we go ..
566 566 */
567 567 while (--argc > 0) {
568 568 char *arg;
569 569 int arglen;
570 570
571 571 arg = *++argv;
572 572 arglen = strlen(arg);
573 573
574 574 if (*arg != '-') {
575 575 char *filename;
576 576
577 577 /*
578 578 * filenames ending in '.s' are taken to be
579 579 * assembler files, and provide the default
580 580 * basename of the output file.
581 581 *
582 582 * other files are passed through to the
583 583 * preprocessor, if present, or to gas if not.
584 584 */
585 585 filename = arg;
586 586 if ((arglen > 2) &&
587 587 ((strcmp(arg + arglen - 2, ".s") == 0) ||
588 588 (strcmp(arg + arglen - 2, ".S") == 0))) {
589 589 /*
590 590 * Though 'as' allows multiple assembler
591 591 * files to be processed in one invocation
592 592 * of the assembler, ON only processes one
593 593 * file at a time, which makes things a lot
594 594 * simpler!
595 595 */
596 596 if (srcfile == NULL)
597 597 srcfile = arg;
598 598 else
599 599 return (usage(
600 600 "one assembler file at a time"));
601 601
602 602 /*
603 603 * If we haven't seen a -o option yet,
604 604 * default the output to the basename
605 605 * of the input, substituting a .o on the end
606 606 */
607 607 if (outfile == NULL) {
608 608 char *argcopy;
609 609
610 610 argcopy = strdup(arg);
611 611 argcopy[arglen - 1] = 'o';
612 612
613 613 if ((outfile = strrchr(
614 614 argcopy, '/')) == NULL)
615 615 outfile = argcopy;
616 616 else
617 617 outfile++;
618 618 }
619 619 }
620 620 if (cpp)
621 621 newae(cpp, filename);
622 622 else if (m4)
623 623 newae(m4, filename);
624 624 else
625 625 newae(as, filename);
626 626 continue;
627 627 } else
628 628 arglen--;
629 629
630 630 switch (arg[1]) {
631 631 case 'K':
632 632 /*
633 633 * -K pic
634 634 * -K PIC
635 635 */
636 636 if (arglen == 1) {
637 637 if ((arg = *++argv) == NULL || *arg == '\0')
638 638 return (usage("malformed -K"));
639 639 argc--;
640 640 } else {
641 641 arg += 2;
642 642 }
643 643 if (strcmp(arg, "PIC") != 0 && strcmp(arg, "pic") != 0)
644 644 return (usage("malformed -K"));
645 645 break; /* just ignore -Kpic for gcc */
646 646 case 'Q':
647 647 if (strcmp(arg, "-Qn") == 0)
648 648 break;
649 649 /*FALLTHROUGH*/
650 650 case 'b':
651 651 case 's':
652 652 case 'T':
653 653 /*
654 654 * -b Extra symbol table for source browser ..
655 655 * not relevant to gas, thus should error.
656 656 * -s Put stabs in .stabs section not stabs.excl
657 657 * not clear if there's an equivalent
658 658 * -T 4.x migration option
659 659 */
660 660 default:
661 661 return (error(arg));
662 662 case 'x':
663 663 /*
664 664 * Accept -xarch special case to invoke alternate
665 665 * assemblers or assembler flags for different
666 666 * architectures.
667 667 */
668 668 if (strcmp(arg, "-xarch=amd64") == 0 ||
669 669 strcmp(arg, "-xarch=generic64") == 0) {
670 670 as64++;
671 671 fixae_arg(as->ael_head, as64_pgm);
672 672 break;
673 673 }
674 674 /*
675 675 * XX64: Is this useful to gas?
676 676 */
677 677 if (strcmp(arg, "-xmodel=kernel") == 0)
678 678 break;
679 679
680 680 /*
681 681 * -xF Generates performance analysis data
682 682 * no equivalent
683 683 */
684 684 return (error(arg));
685 685 case 'V':
686 686 newae(as, arg);
687 687 break;
688 688 case '#':
689 689 verbose++;
690 690 break;
691 691 case 'L':
692 692 newae(as, "--keep-locals");
693 693 break;
694 694 case 'n':
695 695 newae(as, "--no-warn");
696 696 break;
697 697 case 'o':
698 698 if (arglen != 1)
699 699 return (usage("bad -o flag"));
700 700 if ((arg = *++argv) == NULL || *arg == '\0')
701 701 return (usage("bad -o flag"));
702 702 outfile = arg;
703 703 argc--;
704 704 arglen = strlen(arg + 1);
705 705 break;
706 706 case 'm':
707 707 if (cpp)
708 708 return (usage("-m conflicts with -P"));
709 709 if (m4 == NULL) {
710 710 m4 = newael();
711 711 newae(m4, m4_pgm);
712 712 newae(m4, m4_cmdefs);
713 713 }
714 714 break;
715 715 case 'P':
716 716 if (m4)
717 717 return (usage("-P conflicts with -m"));
718 718 if (cpp == NULL) {
719 719 cpp = newael();
720 720 newae(cpp, cpp_pgm);
721 721 newae(cpp, "-D__GNUC_AS__");
722 722 }
723 723 break;
724 724 case 'D':
725 725 case 'U':
726 726 if (cpp)
727 727 newae(cpp, arg);
728 728 else if (m4)
729 729 newae(m4, arg);
730 730 else
731 731 newae(as, arg);
732 732 break;
733 733 case 'I':
734 734 if (cpp)
735 735 newae(cpp, arg);
736 736 else
737 737 newae(as, arg);
738 738 break;
739 739 case '-': /* a gas-specific option */
740 740 newae(as, arg);
741 741 break;
742 742 }
743 743 }
744 744
745 745 #if defined(AW_TARGET_i386)
746 746 if (as64)
747 747 newae(as, "--64");
748 748 else
749 749 newae(as, "--32");
750 750 #endif
751 751
752 752
↓ open down ↓ |
752 lines elided |
↑ open up ↑ |
753 753 /*
754 754 * gas for 32-bit arm defaults to a much older version of the arm
755 755 * architecture than we can really support. Because of that, we instead
756 756 * opt to make sure that we set the minimum architecture to armv6k, the
757 757 * minimum of what we actually support.
758 758 */
759 759 #if defined(AW_TARGET_arm)
760 760 if (as64) {
761 761 return (error("no 64-bit aw target for arm"));
762 762 } else {
763 - newae(as, "-march=armv6k");
764 - newae(as, "-mfpu=vfpv2");
763 + newae(as, "-march=armv7-a");
764 + newae(as, "-mfpu=vfpv3-d16");
765 765 newae(as, "-mfloat-abi=hard");
766 766 }
767 767 #endif
768 768
769 769 if (srcfile == NULL)
770 770 return (usage("no source file(s) specified"));
771 771 if (outfile == NULL)
772 772 outfile = "a.out";
773 773 newae(as, "-o");
774 774 newae(as, outfile);
775 775
776 776 asargv = aeltoargv(as);
777 777 if (cpp) {
778 778 #if defined(AW_TARGET_sparc)
779 779 newae(cpp, "-Dsparc");
780 780 newae(cpp, "-D__sparc");
781 781 if (as64)
782 782 newae(cpp, "-D__sparcv9");
783 783 else
784 784 newae(cpp, "-D__sparcv8");
785 785 #elif defined(AW_TARGET_i386)
786 786 if (as64) {
787 787 newae(cpp, "-D__x86_64");
788 788 newae(cpp, "-D__amd64");
789 789 } else {
790 790 newae(cpp, "-Di386");
791 791 newae(cpp, "-D__i386");
792 792 }
793 793 #elif defined(AW_TARGET_arm)
794 794 newae(cpp, "-Darm");
795 795 newae(cpp, "-D__arm");
796 796 #else
797 797 #error "need isa-dependent defines"
798 798 #endif
799 799 code = pipeline(aeltoargv(cpp), asargv);
800 800 } else if (m4)
801 801 code = pipeline(aeltoargv(m4), asargv);
802 802 else {
803 803 /*
804 804 * XXX should arrange to fork/exec so that we
805 805 * can unlink the output file if errors are
806 806 * detected..
807 807 */
808 808 (void) execvp(asargv[0], asargv);
809 809 perror("execvp");
810 810 (void) fprintf(stderr, "%s: couldn't run %s\n",
811 811 progname, asargv[0]);
812 812 code = 7;
813 813 }
814 814 if (code != 0)
815 815 (void) unlink(outfile);
816 816 return (code);
817 817 }
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX