Merge tag 'nasm-2.14.01rc5'

NASM 2.14.01rc5

Resolved Conflicts:
	asm/labels.c
	asm/nasm.c
	version
This commit is contained in:
H. Peter Anvin (Intel) 2018-12-14 13:23:17 -08:00
commit 727c85263f
7 changed files with 55 additions and 26 deletions

View File

@ -441,7 +441,7 @@ void define_label(const char *label, int32_t segment,
* The backend may invoke this before pass 1, so treat that as
* a special "pass".
*/
const int64_t lpass = pass0 + 1;
const int64_t lpass = passn + 1;
/*
* Phase errors here can be one of two types: a new label appears,
@ -530,6 +530,11 @@ void define_label(const char *label, int32_t segment,
*! may end up being an unconditional error in a future
*! version of NASM.
*
* WARN_LABEL_LATE defaults to an error, as this should never
* actually happen. Just in case this is a backwards
* compatibility problem, still make it a warning so that the
* user can suppress or demote it.
*
* Note: As a special case, LBL_SPECIAL symbols are allowed
* to be changed even during the last pass.
*/

View File

@ -143,6 +143,7 @@ static const struct forwrefinfo *forwref;
static const struct preproc_ops *preproc;
static struct strlist *include_path;
bool pp_noline; /* Ignore %line directives */
#define OP_NORMAL (1U << 0)
#define OP_PREPROCESS (1U << 1)
@ -830,7 +831,8 @@ enum text_options {
OPT_PRAGMA,
OPT_BEFORE,
OPT_LIMIT,
OPT_KEEP_ALL
OPT_KEEP_ALL,
OPT_NO_LINE
};
struct textargs {
const char *label;
@ -854,6 +856,7 @@ static const struct textargs textopts[] = {
{"before", OPT_BEFORE, true, 0},
{"limit-", OPT_LIMIT, true, 0},
{"keep-all", OPT_KEEP_ALL, false, 0},
{"no-line", OPT_NO_LINE, false, 0},
{NULL, OPT_BOGUS, false, 0}
};
@ -1118,7 +1121,7 @@ static bool process_arg(char *p, char *q, int pass)
break;
}
olen = 0; /* Placates gcc at lower optimization levels */
olen = 0; /* Placate gcc at lower optimization levels */
plen = strlen(p);
for (tx = textopts; tx->label; tx++) {
olen = strlen(tx->label);
@ -1191,6 +1194,9 @@ static bool process_arg(char *p, char *q, int pass)
case OPT_KEEP_ALL:
keep_all = true;
break;
case OPT_NO_LINE:
pp_noline = true;
break;
case OPT_HELP:
help(0);
exit(0);
@ -1993,10 +1999,11 @@ static void help(const char xopt)
" -l listfile write listing to a listfile\n\n"
" -Ipath add a pathname to the include file path\n");
printf
(" -Olevel optimize opcodes, immediates and branch offsets\n"
(" -Oflags... optimize opcodes, immediates and branch offsets\n"
" -O0 no optimization\n"
" -O1 minimal optimization\n"
" -Ox multipass optimization (default)\n"
" -Ov display the number of passes executed at the end\n"
" -Pfile pre-include a file (also --include)\n"
" -Dmacro[=str] pre-define a macro\n"
" -Umacro undefine a macro\n"
@ -2015,6 +2022,7 @@ static void help(const char xopt)
" --lprefix str prepend the given string to all other symbols\n"
" --lpostfix str append the given string to all other symbols\n"
" --keep-all output files will not be removed even if an error happens\n"
" --no-line ignore %%line directives in input\n"
" --limit-X val set execution limit X\n");
for (i = 0; i <= LIMIT_MAX; i++) {

View File

@ -86,7 +86,6 @@ static char *nop_getline(void)
src_set_linnum(src_get_linnum() + nop_lineinc);
while (1) { /* Loop to handle %line */
p = buffer;
while (1) { /* Loop to handle long lines */
q = fgets(p, bufsize - (p - buffer), nop_fp);
@ -119,13 +118,15 @@ static char *nop_getline(void)
int32_t ln;
int li;
char *nm = nasm_malloc(strlen(buffer));
if (sscanf(buffer + 5, "%"PRId32"+%d %s", &ln, &li, nm) == 3) {
src_set(ln, nm);
int conv = sscanf(buffer + 5, "%"PRId32"+%d %s", &ln, &li, nm);
if (conv >= 2) {
if (!pp_noline)
src_set(ln, conv >= 3 ? nm : NULL);
nop_lineinc = li;
nasm_free(nm);
continue;
}
nasm_free(nm);
if (conv >= 2)
continue;
}
break;
}

View File

@ -3581,6 +3581,10 @@ issue_error:
/*
* Syntax is `%line nnn[+mmm] [filename]'
*/
if (unlikely(pp_noline)) {
free_tlist(origline);
return DIRECTIVE_FOUND;
}
tline = tline->next;
skip_white_(tline);
if (!tok_type_(tline, TOK_NUMBER)) {

View File

@ -43,6 +43,7 @@
extern const char * const pp_directives[];
extern const uint8_t pp_directives_len[];
extern bool pp_noline;
/* Pointer to a macro chain */
typedef const unsigned char macros_t;

View File

@ -37,6 +37,9 @@ failure instead which is very slow and not easy to debug.
\b Duplicate definitions of the same label \e{with the same value} is now
explicitly permitted (2.14 would allow it in some circumstances.)
\b Add the option \c{--no-line} to ignore \c{%line} directives in the
source. See \k{opt-no-line} and \k{line}.
\S{cl-2.14} Version 2.14
\b Changed \c{-I} option semantics by adding a trailing path separator

View File

@ -368,10 +368,10 @@ To get further usage instructions from NASM, try typing
\c nasm -h
\c{--help} option is also the same.
The option \c{--help} is an alias for the \c{-h} option.
As \c{-hf}, this will also list the available output file formats, and what they
are.
The option \c{-hf} will also list the available output file formats,
and what they are.
If you use Linux but aren't sure whether your system is \c{a.out}
or \c{ELF}, type
@ -746,7 +746,9 @@ with a \i{stub preprocessor} which does nothing.
\S{opt-O} The \i\c{-O} Option: Specifying \i{Multipass Optimization}
Using the \c{-O} option, you can tell NASM to carry out different
levels of optimization. The syntax is:
levels of optimization. Multiple flags can be specified after the
\c{-O} options, some of which can be combined in a single option,
e.g. \c{-Oxv}.
\b \c{-O0}: No optimization. All operands take their long forms,
if a short form is not specified, except conditional jumps.
@ -764,6 +766,9 @@ levels of optimization. The syntax is:
releases, the letter \c{x} may also be any number greater than
one. This number has no effect on the actual number of passes.
\b \c{-Ov}: At the end of assembly, print the number of passes
actually executed.
The \c{-Ox} mode is recommended for most uses, and is the default
since NASM 2.09.
@ -917,7 +922,14 @@ In example, running this limits the maximum line count to be 1000.
\S{opt-keep-all} The \i\c{--keep-all} Option
This option doesn't delete any output files even if an error happens.
This option prevents NASM from deleting any output files even if an
error happens.
\S{opt-no-line} The \i\c{--no-line} Option
If this option is given, all \i\c{%line} directives in the source code
are ignored. This can be useful for debugging already preprocessed
code. See \k{line}.
\S{nasmenv} The \i\c{NASMENV} \i{Environment} Variable
@ -3672,15 +3684,6 @@ the user. For example:
\H{otherpreproc} \i{Other Preprocessor Directives}
NASM also has preprocessor directives which allow access to
information from external sources. Currently they include:
\b\c{%line} enables NASM to correctly handle the output of another
preprocessor (see \k{line}).
\b\c{%!} enables NASM to read in the value of an environment variable,
which can then be used in your program (see \k{getenv}).
\S{line} \i\c{%line} Directive
The \c{%line} directive is used to notify NASM that the input line
@ -3691,9 +3694,9 @@ directive allows NASM to output messages which indicate the line
number of the original source file, instead of the file that is being
read by NASM.
This preprocessor directive is not generally of use to programmers,
by may be of interest to preprocessor authors. The usage of the
\c{%line} preprocessor directive is as follows:
This preprocessor directive is not generally used directly by
programmers, but may be of interest to preprocessor authors. The
usage of the \c{%line} preprocessor directive is as follows:
\c %line nnn[+mmm] [filename]
@ -3708,6 +3711,10 @@ After reading a \c{%line} preprocessor directive, NASM will report
all file name and line numbers relative to the values specified
therein.
If the command line option \i\c{--no-line} is given, all \c{%line}
directives are ignored. This may be useful for debugging preprocessed
code. See \k{opt-no-line}.
\S{getenv} \i\c{%!}\e{variable}: Read an Environment Variable.