From fcce07f171c69d499feebf355f9700ee4f6024ee Mon Sep 17 00:00:00 2001 From: Charles Crayne Date: Sun, 30 Sep 2007 22:15:36 -0700 Subject: [PATCH] modified: nasm.1 to add newer command line options modified: nasm.c to fully parse command line before redirecting stderr. --- nasm.1 | 172 ++++++++++++++++++++++++++++++++++++----------------------------- nasm.c | 22 ++++++--- 2 files changed, 109 insertions(+), 85 deletions(-) diff --git a/nasm.1 b/nasm.1 index 7b5d292..d662df8 100644 --- a/nasm.1 +++ b/nasm.1 @@ -4,23 +4,29 @@ nasm \- the Netwide Assembler, a portable 80x86 assembler .SH SYNOPSIS .B nasm [ +.B \-@ +response file +] [ .B \-f format ] [ .B \-o outfile ] [ +.B \-l +listfile +] [ .IR options ... -] infile +] filename .br .B nasm \-h .br -.B nasm \-r +.B nasm \-v .SH DESCRIPTION The .B nasm command assembles the file -.I infile +.I filename and directs output to the file .I outfile if specified. If @@ -33,11 +39,12 @@ extensions for a raw binary file. Failing that, the output file name will be `nasm.out'. .SS OPTIONS .TP -.B \-h +.BI \-@ " filename" Causes .B nasm -to exit immediately, after giving a summary of its invocation -options, and listing all its supported output file formats. +to process options from +.I filename +as if they were included on the command line. .TP .B \-a Causes @@ -45,6 +52,14 @@ Causes to assemble the given input file without first applying the macro preprocessor. .TP +.BI \-D " macro[=value]" +Pre-defines a single-line macro. +.TP +.BI \-d " macro[=value]" +Same as the +.B \-D +option. +.TP .B \-e Causes .B nasm @@ -53,44 +68,37 @@ to preprocess the given input file, and write the output to (or the specified output file name), and not actually assemble anything. .TP -.B \-M -Causes -.B nasm -to output Makefile-style dependencies to stdout; normal output is -suppressed. +.BI \-f " format" +Specifies the output file format. To see a list of valid output +formats, use the +.B -hf +option. .TP -.BI \-E " filename" +.B \-g Causes .B nasm -to redirect error messages to -.IR filename . -This option exists to support operating systems on which stderr is not -easily redirected. +to generate debug information in selected format .TP -.BI \-r +.B \-h Causes .B nasm -to exit immediately, after displaying its version number. -.I (obsolete) +to exit immediately, after giving a summary of its invocation +options. .TP -.BI \-v -Causes -.B nasm -to exit immediately, after displaying its version number. +.B \-hf +Same as +.B -h +, but also lists all valid output formats. .TP -.BI \-f " format" -Specifies the output file format. Formats include -.IR bin , -to produce flat-form binary files, and -.I aout -and -.I elf -to produce Linux a.out and ELF object files, respectively. +.BI \-I " directory" +Adds a directory to the search path for include files. The directory +specification must include the trailing slash, as it will be +directly prepended to the name of the include file. .TP -.BI \-o " outfile" -Specifies a precise name for the output file, overriding -.BR nasm 's -default means of determining it. +.BI \-i " directory" +Same as the +.B \-I +option. .TP .BI \-l " listfile" Causes an assembly listing to be directed to the given file, in @@ -98,35 +106,19 @@ which the original source is displayed on the right hand side (plus the source for included files and the expansions of multi-line macros) and the generated code is shown in hex on the left. .TP -.B \-s -Causes -.B nasm -to send its error messages and/or help text to -.I stdout -instead of -.IR stderr . -.TP -.BI \-w [+-]foo +.B \-M Causes .B nasm -to enable or disable certain classes of warning messages, for -example -.B \-w+orphan-labels -or -.B \-w-macro-params -to, respectively, enable warnings about labels alone on lines or -disable warnings about incorrect numbers of parameters in macro -calls. +to output Makefile-style dependencies to stdout; normal output is +suppressed. .TP -.BI \-I " directory" -Adds a directory to the search path for include files. The directory -specification must include the trailing slash, as it will be -directly prepended to the name of the include file. +.BI \-O " number" +optimize branch offsets (-O0 disables, default). .TP -.BI \-i " directory" -Same as the -.B \-I -option. +.BI \-o " outfile" +Specifies a precise name for the output file, overriding +.BR nasm 's +default means of determining it. .TP .BI \-P " file" Specifies a file to be pre-included, before the main source file @@ -137,13 +129,24 @@ Same as the .B \-P option. .TP -.BI \-D " macro[=value]" -Pre-defines a single-line macro. +.BI \-r +Causes +.B nasm +to exit immediately, after displaying its version number. +.I (obsolete) .TP -.BI \-d " macro[=value]" -Same as the -.B \-D -option. +.B \-s +Causes +.B nasm +to send its error messages and/or help text to +.I stdout +instead of +.IR stderr . +.TP +.B \-t +Causes +.B nasm +to assemble in SciTech TASM compatible mode .TP .BI \-U " macro" Undefines a single-line macro. @@ -152,6 +155,31 @@ Undefines a single-line macro. Same as the .B \-U option. +.TP +.BI \-v +Causes +.B nasm +to exit immediately, after displaying its version number. +.TP +.BI \-w [+-]foo +Causes +.B nasm +to enable or disable certain classes of warning messages, for +example +.B \-w+orphan-labels +or +.B \-w-macro-params +.TP +.BI \-X " format" +specifies error reporting format (gnu or vc). +.TP +.BI \-Z " filename" +Causes +.B nasm +to redirect error messages to +.IR filename . +This option exists to support operating systems on which stderr is not +easily redirected. .PP .RE .SS SYNTAX @@ -452,17 +480,7 @@ and .IR %elifnctx are also supported. .SH BUGS -There is a reported seg-fault on some (Linux) systems with some -large source files. This appears to be very hard to reproduce. All -other -.I known -bugs have been fixed... -.SH RESTRICTIONS -There is no support for listing files, symbol maps, or debugging -object-file records. The advanced features of the ELF and Win32 -object file formats are not supported, and there is no means for -warning the programmer against using an instruction beyond the -capability of the target processor. +Please report bugs through the bug tracker function at http://nasm.sourceforge.org. .SH SEE ALSO .BR as "(" 1 ")," .BR ld "(" 1 ")." diff --git a/nasm.c b/nasm.c index ed9c6cb..32fa078 100644 --- a/nasm.c +++ b/nasm.c @@ -53,6 +53,7 @@ int globalrel = 0; static char inname[FILENAME_MAX]; static char outname[FILENAME_MAX]; static char listname[FILENAME_MAX]; +static char errname[FILENAME_MAX]; static int globallineno; /* for forward-reference tracking */ /* static int pass = 0; */ static struct ofmt *ofmt = NULL; @@ -442,13 +443,7 @@ static int process_arg(char *p, char *q) } else if (p[1] == 'l') { /* listing file */ strcpy(listname, param); } else if (p[1] == 'Z') { /* error messages file */ - error_file = fopen(param, "w"); - if (!error_file) { - error_file = stderr; /* Revert to default! */ - report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, - "cannot open file `%s' for error messages", - param); - } + strcpy(errname, param); } else if (p[1] == 'F') { /* specify debug format */ ofmt->current_dfmt = dfmt_find(ofmt, param); if (!ofmt->current_dfmt) { @@ -724,7 +719,7 @@ static void parse_cmdline(int argc, char **argv) FILE *rfile; char *envreal, *envcopy = NULL, *p, *arg; - *inname = *outname = *listname = '\0'; + *inname = *outname = *listname = *errname = '\0'; /* * First, process the NASMENV environment variable. @@ -785,6 +780,17 @@ static void parse_cmdline(int argc, char **argv) if (!*inname) report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, "no input file specified"); + else { + if (*errname) { + error_file = fopen(errname, "w"); + if (!error_file) { + error_file = stderr; /* Revert to default! */ + report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + "cannot open file `%s' for error messages", + errname); + } + } + } } /* List of directives */ -- 2.7.4