mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-27 08:10:07 +08:00
Make limits 64 bits, add globallines limit to configurable limits
Make all limit counters 64 bits, in case someone really has a usage for an insanely large program. The globallines limit was omitted, add it to the list of configurable limits. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
cd133a6f2d
commit
a3d96d02b0
@ -72,7 +72,7 @@ static void *scpriv;
|
||||
static int *opflags;
|
||||
|
||||
static struct eval_hints *hint;
|
||||
static int deadman;
|
||||
static int64_t deadman;
|
||||
|
||||
|
||||
/*
|
||||
|
32
asm/nasm.c
32
asm/nasm.c
@ -94,7 +94,8 @@ static bool abort_on_panic = ABORT_ON_PANIC;
|
||||
static bool keep_all;
|
||||
|
||||
bool tasm_compatible_mode = false;
|
||||
int pass0, passn;
|
||||
int pass0;
|
||||
int64_t passn;
|
||||
static int pass1, pass2; /* XXX: Get rid of these, they are redundant */
|
||||
int globalrel = 0;
|
||||
int globalbnd = 0;
|
||||
@ -106,8 +107,7 @@ const char *outname;
|
||||
static const char *listname;
|
||||
static const char *errname;
|
||||
|
||||
static int globallineno; /* for forward-reference tracking */
|
||||
#define GLOBALLINENO_MAX INT32_MAX
|
||||
static int64_t globallineno; /* for forward-reference tracking */
|
||||
|
||||
/* static int pass = 0; */
|
||||
const struct ofmt *ofmt = &OF_DEFAULT;
|
||||
@ -159,10 +159,10 @@ static char *(*quote_for_make)(const char *) = quote_for_pmake;
|
||||
* Execution limits that can be set via a command-line option or %pragma
|
||||
*/
|
||||
|
||||
#define LIMIT_MAX_VAL (INT_MAX >> 1) /* Effectively unlimited */
|
||||
#define LIMIT_MAX_VAL (INT64_MAX >> 1) /* Effectively unlimited */
|
||||
|
||||
int nasm_limit[LIMIT_MAX+1] =
|
||||
{ LIMIT_MAX_VAL, 1000, 1000000, 1000000, 1000000 };
|
||||
int64_t nasm_limit[LIMIT_MAX+1] =
|
||||
{ LIMIT_MAX_VAL, 1000, 1000000, 1000000, 1000000, 2000000000 };
|
||||
|
||||
struct limit_info {
|
||||
const char *name;
|
||||
@ -173,7 +173,8 @@ static const struct limit_info limit_info[LIMIT_MAX+1] = {
|
||||
{ "stalled-passes", "number of passes without forward progress" },
|
||||
{ "macro-levels", "levels of macro expansion"},
|
||||
{ "rep", "%rep count" },
|
||||
{ "eval", "expression evaluation descent"}
|
||||
{ "eval", "expression evaluation descent"},
|
||||
{ "lines", "total source lines processed"}
|
||||
};
|
||||
|
||||
enum directive_result
|
||||
@ -1378,7 +1379,7 @@ static void assemble_file(const char *fname, StrList **depend_ptr)
|
||||
insn output_ins;
|
||||
int i;
|
||||
uint64_t prev_offset_changed;
|
||||
int stall_count = 0; /* Make sure we make forward progress... */
|
||||
int64_t stall_count = 0; /* Make sure we make forward progress... */
|
||||
|
||||
switch (cmd_sb) {
|
||||
case 16:
|
||||
@ -1432,10 +1433,10 @@ static void assemble_file(const char *fname, StrList **depend_ptr)
|
||||
globallineno = 0;
|
||||
|
||||
while ((line = preproc->getline())) {
|
||||
if (globallineno++ == GLOBALLINENO_MAX)
|
||||
nasm_error(ERR_FATAL,
|
||||
"overall line number reaches the maximum %d\n",
|
||||
GLOBALLINENO_MAX);
|
||||
if (++globallineno > nasm_limit[LIMIT_LINES])
|
||||
nasm_fatal(0,
|
||||
"overall line count exceeds the maximum %"PRId64"\n",
|
||||
nasm_limit[LIMIT_LINES]);
|
||||
|
||||
/*
|
||||
* Here we parse our directives; this is not handled by the
|
||||
@ -1639,7 +1640,7 @@ static void assemble_file(const char *fname, StrList **depend_ptr)
|
||||
*/
|
||||
nasm_error(ERR_NONFATAL,
|
||||
"Can't find valid values for all labels "
|
||||
"after %d passes, giving up.", passn);
|
||||
"after %"PRId64" passes, giving up.", passn);
|
||||
nasm_error(ERR_NONFATAL,
|
||||
"Possible causes: recursive EQUs, macro abuse.");
|
||||
break;
|
||||
@ -1650,7 +1651,8 @@ static void assemble_file(const char *fname, StrList **depend_ptr)
|
||||
lfmt->cleanup();
|
||||
if (!terminate_after_phase && opt_verbose_info) {
|
||||
/* -On and -Ov switches */
|
||||
fprintf(stdout, "info: assembly required 1+%d+1 passes\n", passn-3);
|
||||
fprintf(stdout, "info: assembly required 1+%"PRId64"+1 passes\n",
|
||||
passn-3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1955,7 +1957,7 @@ static void help(const char xopt)
|
||||
printf(" %-15s %s (default ",
|
||||
limit_info[i].name, limit_info[i].help);
|
||||
if (nasm_limit[i] < LIMIT_MAX_VAL) {
|
||||
printf("%d)\n", nasm_limit[i]);
|
||||
printf("%"PRId64")\n", nasm_limit[i]);
|
||||
} else {
|
||||
printf("unlimited)\n");
|
||||
}
|
||||
|
@ -3044,7 +3044,7 @@ issue_error:
|
||||
count = reloc_value(evalresult);
|
||||
if (count > nasm_limit[LIMIT_REP]) {
|
||||
nasm_error(ERR_NONFATAL,
|
||||
"`%%rep' count %"PRId64" exceeds limit (currently %d)",
|
||||
"`%%rep' count %"PRId64" exceeds limit (currently %"PRId64")",
|
||||
count, nasm_limit[LIMIT_REP]);
|
||||
count = 0;
|
||||
} else if (count < 0) {
|
||||
@ -4195,7 +4195,7 @@ static Token *expand_smacro(Token * tline)
|
||||
Token *org_tline = tline;
|
||||
Context *ctx;
|
||||
const char *mname;
|
||||
int deadman = nasm_limit[LIMIT_MACROS];
|
||||
int64_t deadman = nasm_limit[LIMIT_MACROS];
|
||||
bool expanded;
|
||||
|
||||
/*
|
||||
|
@ -760,10 +760,11 @@ enum nasm_limit {
|
||||
LIMIT_STALLED,
|
||||
LIMIT_MACROS,
|
||||
LIMIT_REP,
|
||||
LIMIT_EVAL
|
||||
LIMIT_EVAL,
|
||||
LIMIT_LINES
|
||||
};
|
||||
#define LIMIT_MAX LIMIT_EVAL
|
||||
extern int nasm_limit[LIMIT_MAX+1];
|
||||
#define LIMIT_MAX LIMIT_LINES
|
||||
extern int64_t nasm_limit[LIMIT_MAX+1];
|
||||
extern enum directive_result nasm_set_limit(const char *, const char *);
|
||||
|
||||
/*
|
||||
@ -1242,7 +1243,7 @@ enum decorator_tokens {
|
||||
*/
|
||||
|
||||
extern int pass0;
|
||||
extern int passn; /* Actual pass number */
|
||||
extern int64_t passn; /* Actual pass number */
|
||||
|
||||
extern bool tasm_compatible_mode;
|
||||
extern int optimizing;
|
||||
|
@ -75,7 +75,8 @@ static void dbg_init(void)
|
||||
|
||||
static void dbg_reset(void)
|
||||
{
|
||||
fprintf(ofile, "*** pass reset: pass0 = %d, passn = %d\n", pass0, passn);
|
||||
fprintf(ofile, "*** pass reset: pass0 = %d, passn = %"PRId64"\n",
|
||||
pass0, passn);
|
||||
}
|
||||
|
||||
static void dbg_cleanup(void)
|
||||
|
Loading…
Reference in New Issue
Block a user