diff options
author | David MacKenzie <djm@cygnus> | 1994-06-02 21:00:19 +0000 |
---|---|---|
committer | David MacKenzie <djm@cygnus> | 1994-06-02 21:00:19 +0000 |
commit | ebd6f11797d7beb545cd48111210b07fdec806ce (patch) | |
tree | 373f442b88a298c39528666ef5c4eab380c6bd5e | |
parent | b166d614748f3fe2cb0e047c93a8eafe799a6da0 (diff) | |
download | gdb-ebd6f11797d7beb545cd48111210b07fdec806ce.zip gdb-ebd6f11797d7beb545cd48111210b07fdec806ce.tar.gz gdb-ebd6f11797d7beb545cd48111210b07fdec806ce.tar.bz2 |
* as.c (show_usage): New function.
(parse_args): Code moved from main.
Recognize --help and --version.
* config/tc-ns32k.h: Define TC_NS32K.
* doc/as.texinfo: Document all of the target-independent command
line options.
-rw-r--r-- | gas/ChangeLog | 9 | ||||
-rw-r--r-- | gas/as.c | 360 |
2 files changed, 304 insertions, 65 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 4aac56e..d9f6088 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +Thu Jun 2 13:54:46 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * as.c (show_usage): New function. + (parse_args): Code moved from main. + Recognize --help and --version. + * config/tc-ns32k.h: Define TC_NS32K. + * doc/as.texinfo: Document all of the target-independent command + line options. + Thu Jun 2 12:07:25 1994 Ken Raeburn (raeburn@cujo.cygnus.com) * gasp.c (hash_new_table): Clear newly allocated table. @@ -32,6 +32,9 @@ * */ +#include "ansidecl.h" +#include "libiberty.h" + #include <stdio.h> #include <string.h> @@ -73,9 +76,9 @@ segT reg_section, expr_section; segT text_section, data_section, bss_section; #endif -/* This is true if the assembler should not produce any timing info. */ +/* This is true if the assembler should output time and space usage. */ -static int quiet_flag = 1; +static int statistics_flag = 0; void @@ -93,70 +96,248 @@ print_version_id () fprintf (stderr, "\n"); } -int -main (argc, argv) - int argc; - char **argv; +void +show_usage (stream) + FILE *stream; { - int work_argc; /* variable copy of argc */ - char **work_argv; /* variable copy of argv */ - char *arg; /* an arg to program */ - char a; /* an arg flag (after -) */ - int keep_it; - long start_time = get_run_time (); + fprintf (stream, "Usage: %s [option...] [asmfile...]\n", myname); + + fprintf (stream, "\ +Options:\n\ +-a[sub-option...] turn on listings\n\ + Sub-options [default hls]:\n\ + d omit debugging directives\n\ + h include high-level source\n\ + l include assembly\n\ + n omit forms processing\n\ + s include symbols\n\ +-D ignored\n\ +-f skip whitespace and comment preprocessing\n\ +--help show this message and exit\n\ +-I DIR add DIR to search list for .include directives\n\ +-J don't warn about signed overflow\n\ +-K warn when differences altered for long displacements\n\ +-L keep local symbols (starting with `L')\n"); + fprintf (stream, "\ +-o OBJFILE name the object-file output OBJFILE [default a.out]\n\ +-R fold data section into text section\n\ +--statistics print maximum bytes and total seconds used\n\ +-v, -version print assembler version number\n\ +--version print assembler version number and exit\n\ +-W suppress warnings\n\ +-w ignored\n\ +-x ignored\n\ +-Z generate object file even after errors\n"); + +#ifdef TC_ALPHA + fprintf(stream, "\ +ALPHA options:\n\ +-32addr treat addresses as 32-bit values\n\ +-F lack floating point instructions support\n\ +-nocpp ignored\n"); +#endif -#if 0 /* do we need any of this?? */ - { - static const int sig[] = {SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0}; +#ifdef TC_I960 + fprintf(stream, "\ +I960 options:\n\ +-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC\n\ + specify variant of 960 architecture\n\ +-b add code to collect statistics about branches taken\n\ +-linkrelax make relocatable instructions undefined (?)\n\ +-norelax don't alter compare-and-branch instructions for\n\ + long displacements\n"); +#endif - for (a = 0; sig[a] != 0; a++) - if (signal (sig[a], SIG_IGN) != SIG_IGN) - signal (sig[a], got_sig); - } +#ifdef TC_M68K + fprintf(stream, "\ +680X0 options:\n\ +-l use 1 word for refs to undefined symbols [default 2]\n\ +-m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040\n\ + | -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -mcpu32\n\ + specify variant of 680X0 architecture [default 68020]\n\ +-m68881 | -m68882 | -mno-68881 | -mno-68882\n\ + target has/lacks floating-point coprocessor\n\ + [default yes for 68020, 68030, and cpu32]\n\ +-m68851 | -mno-68851\n\ + target has/lacks memory-management unit coprocessor\n\ + [default yes for 68020 and up]\n\ +-pic, -k (sun3) generate position independent code\n\ +-S turn jbsr into jsr\n\ +--register-prefix-optional\n\ + recognize register names without prefix character\n"); #endif - myname = argv[0]; - memset (flagseen, '\0', sizeof (flagseen)); /* aint seen nothing yet */ -#ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME -#define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out" +#ifdef TC_MIPS + fprintf(stream, "\ +MIPS options:\n\ +-membedded-pic generate embedded position independent code\n\ +-nocpp ignored\n\ +-EB generate big endian output\n\ +-EL generate little endian output\n\ +-g, -g2 do not remove uneeded NOPs or swap branches\n\ +-G NUM allow referencing objects up to NUM bytes\n\ + implicitly with the gp register [default 8]\n\ +-mips1, -mcpu=r{2,3}000 generate code for r2000 and r3000\n\ +-mips2, -mcpu=r6000 generate code for r6000\n\ +-mips3, -mcpu=r4000 generate code for r4000\n\ +-O0 remove unneeded NOPs, do not swap branches\n\ +-O remove unneeded NOPs and swap branches\n\ +--trap, --no-break trap exception on div by 0 and mult overflow\n\ +--break, --no-trap break exception on div by 0 and mult overflow\n"); +#ifdef OBJ_ELF + fprintf(stream, "\ +MIPS ELF options:\n\ +-KPIC, -call_shared generate SVR4 position independent code\n\ +-non_shared do not generate position independent code\n"); +#endif #endif - out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; -#ifdef BFD_ASSEMBLER - bfd_init (); +#ifdef TC_NS32K + fprintf(stream, "\ +NS32K options:\n\ +-m32032 | -m32532 select variant of NS32K architecture\n"); #endif - symbol_begin (); - subsegs_begin (); - read_begin (); - input_scrub_begin (); - frag_init (); - /* - * Parse arguments, but we are only interested in flags. - * When we find a flag, we process it then make it's argv[] NULL. - * This helps any future argv[] scanners avoid what we processed. - * Since it is easy to do here we interpret the special arg "-" - * to mean "use stdin" and we set that argv[] pointing to "". - * After we have munged argv[], the only things left are source file - * name(s) and ""(s) denoting stdin. These file names are used - * (perhaps more than once) later. - */ - /* FIXME-SOMEDAY this should use getopt. */ - work_argc = argc - 1; /* don't count argv[0] */ - work_argv = argv + 1; /* skip argv[0] */ - for (; work_argc--; work_argv++) +#ifdef TC_PPC + fprintf(stream, "\ +PowerPC options:\n\ +-u ignored\n\ +-mpwrx generate code for IBM POWER/2 (RIOS2)\n\ +-mpwr generate code for IBM POWER (RIOS1)\n\ +-m601 generate code for Motorola PowerPC 601\n\ +-mppc generate code for Motorola PowerPC 603/604\n\ +-many generate code for any architecture (PWR/PWRX/PPC)\n"); +#ifdef OBJ_ELF + fprintf(stream, "\ +PowerPC ELF options:\n\ +-V print assembler version number\n\ +-Qy, -Qn ignored\n"); +#endif +#endif + +#ifdef TC_SH + fprintf(stream, "\ +SH options:\n\ +-relax alter jump instructions for long displacements\n"); +#endif + +#ifdef TC_SPARC + fprintf(stream, "\ +SPARC options:\n\ +-Av6 | -Av7 | -Av8 | -Asparclite\n\ + specify variant of SPARC architecture\n\ +-bump warn when assembler switches architectures\n\ +-sparc ignored\n"); +#ifdef OBJ_ELF + fprintf(stream, "\ +SPARC ELF options:\n\ +-V print assembler version number\n\ +-q ignored\n\ +-Qy, -Qn ignored\n\ +-s ignored\n"); +#endif +#endif + +#ifdef TC_TAHOE + fprintf(stream, "\ +Tahoe options:\n\ +-a ignored\n\ +-d LENGTH ignored\n\ +-J ignored\n\ +-S ignored\n\ +-t FILE ignored\n\ +-T ignored\n\ +-V ignored\n"); +#endif + +#ifdef TC_VAX + fprintf(stream, "\ +VAX options:\n\ +-d LENGTH ignored\n\ +-J ignored\n\ +-S ignored\n\ +-t FILE ignored\n\ +-T ignored\n\ +-V ignored\n"); +#endif + +#ifdef TC_Z8K + fprintf(stream, "\ +Z8K options:\n\ +-z8001 generate segmented code\n\ +-z8002 generate unsegmented code\n"); +#endif +} + +/* + * Parse arguments, but we are only interested in flags. + * When we find a flag, we process it then make it's argv[] NULL. + * This helps any future argv[] scanners avoid what we processed. + * Since it is easy to do here we interpret the special arg "-" + * to mean "use stdin" and we set that argv[] pointing to "". + * After we have munged argv[], the only things left are source file + * name(s) and ""(s) denoting stdin. These file names are used + * (perhaps more than once) later. + */ +/* FIXME-SOMEDAY this should use getopt. */ +/* + * check for new machine-dep cmdline options in + * md_parse_option definitions in config/tc-*.c + */ + +void +parse_args (argc, argv) + int argc; + char **argv; +{ + char *arg; /* an arg to program */ + char a; /* an arg flag (after -) */ + + argc--; /* don't count argv[0] */ + argv++; /* skip argv[0] */ + + for (; argc--; argv++) { - arg = *work_argv; /* work_argv points to this argument */ + arg = *argv; /* argv points to this argument */ if (*arg != '-') /* Filename. We need it later. */ continue; /* Keep scanning args looking for flags. */ - if (arg[1] == '-' && arg[2] == 0) + /* Handle double-dash options. */ + if (arg[1] == '-') { - /* "--" as an argument means read STDIN */ - /* on this scan, we don't want to think about filenames */ - *work_argv = ""; /* Code that means 'use stdin'. */ + if (arg[2] == 0) + { + /* "--" as an argument means read stdin. */ + /* On this scan, we don't want to think about filenames. */ + *argv = ""; /* A code that means 'use stdin'. */ + } + else if (strcmp (arg, "--statistics") == 0) + { + statistics_flag = 1; + *argv = NULL; + } + else if (strcmp (arg, "--help") == 0) + { + show_usage (stdout); + exit (0); + } + else if (strcmp (arg, "--version") == 0) + { + print_version_id (); + exit (0); + } +#ifdef md_parse_long_option + else if (md_parse_long_option (arg)) + *argv = NULL; +#endif + else + { + as_warn ("Unknown option `%s' ignored", arg); + *argv = NULL; + } continue; } + /* This better be a switch. */ arg++; /*->letter. */ @@ -226,11 +407,11 @@ main (argc, argv) if (!temp) as_fatal ("virtual memory exhausted"); } - else if (work_argc) + else if (argc) { - *work_argv = NULL; - work_argc--; - temp = *++work_argv; + *argv = NULL; + argc--; + temp = *++argv; } else as_warn ("%s: I expected a filename after -I", myname); @@ -260,11 +441,11 @@ main (argc, argv) if (!out_file_name) as_fatal ("virtual memory exhausted"); } - else if (work_argc) + else if (argc) { /* Want next arg for a file-name. */ - *work_argv = NULL; /* This is not a file-name. */ - work_argc--; - out_file_name = *++work_argv; + *argv = NULL; /* This is not a file-name. */ + argc--; + out_file_name = *++argv; } else as_warn ("%s: I expected a filename after -o. \"%s\" assumed.", @@ -273,9 +454,7 @@ main (argc, argv) break; case 'n': - if (*arg && strcmp(arg, "oquiet") == 0) - quiet_flag = 0; - else if (*arg && strcmp(arg, "ocpp") == 0) + if (*arg && strcmp(arg, "ocpp") == 0) ; else { @@ -325,7 +504,7 @@ main (argc, argv) default: --arg; - if (md_parse_option (&arg, &work_argc, &work_argv) == 0) + if (md_parse_option (&arg, &argc, &argv) == 0) as_warn ("%s: I don't understand '%c' flag.", myname, a); if (arg && *arg) arg++; @@ -337,17 +516,59 @@ main (argc, argv) * file-name. Smash it so the * things that look for filenames won't ever see it. * - * Whatever work_argv points to, it has already been used + * Whatever argv points to, it has already been used * as part of a flag, so DON'T re-use it as a filename. */ - *work_argv = NULL; /* NULL means 'not a file-name' */ + *argv = NULL; /* NULL means 'not a file-name' */ } +} + +int +main (argc, argv) + int argc; + char **argv; +{ + char a; + int keep_it; + long start_time = get_run_time (); + +#if 0 /* do we need any of this?? */ + { + static const int sig[] = {SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0}; + + for (a = 0; sig[a] != 0; a++) + if (signal (sig[a], SIG_IGN) != SIG_IGN) + signal (sig[a], got_sig); + } +#endif + + myname = argv[0]; + memset (flagseen, '\0', sizeof (flagseen)); /* aint seen nothing yet */ +#ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME +#define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out" +#endif + out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; + +#ifdef BFD_ASSEMBLER + bfd_init (); +#endif + + symbol_begin (); + subsegs_begin (); + read_begin (); + input_scrub_begin (); + frag_init (); + parse_args (argc, argv); #ifdef BFD_ASSEMBLER output_file_create (out_file_name); assert (stdoutput != 0); #endif +#ifdef tc_init_after_args + tc_init_after_args (); +#endif + /* Here with flags set up in flagseen[]. */ perform_an_assembly_pass (argc, argv); /* Assemble it. */ #ifdef TC_I960 @@ -368,10 +589,12 @@ main (argc, argv) listing_print (""); #endif +#ifndef OBJ_VMS /* does its own file handling */ #ifndef BFD_ASSEMBLER if (keep_it) #endif output_file_close (out_file_name); +#endif if (!keep_it) unlink (out_file_name); @@ -381,7 +604,7 @@ main (argc, argv) md_end (); #endif - if (!quiet_flag) + if (statistics_flag) { extern char **environ; char *lim = (char *) sbrk (0); @@ -434,12 +657,19 @@ perform_an_assembly_pass (argc, argv) { segT seg; +#ifdef TE_APOLLO + seg = subseg_new (".wtext", 0); +#else seg = subseg_new (".text", 0); +#endif assert (seg == SEG_E0); seg = subseg_new (".data", 0); assert (seg == SEG_E1); seg = subseg_new (".bss", 0); assert (seg == SEG_E2); +#ifdef TE_APOLLO + create_target_segments (); +#endif } #else /* not MANY_SEGMENTS */ |