mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
Unmodularize errwarn, while making key errwarn functions replaceable.
Also removes dependency of libyasm on libintl (gettext), so it can be linked -no-undefined now! svn path=/trunk/yasm/; revision=842
This commit is contained in:
parent
9d0fa1135c
commit
d9f68d6d4b
93 changed files with 1240 additions and 1392 deletions
|
|
@ -39,6 +39,7 @@ libyasm_la_SOURCES = \
|
|||
src/xmalloc.c \
|
||||
src/xstrdup.c \
|
||||
src/strcasecmp.c
|
||||
libyasm_la_LDFLAGS = -no-undefined
|
||||
|
||||
yasm_SOURCES += \
|
||||
src/main.c \
|
||||
|
|
|
|||
|
|
@ -88,6 +88,16 @@ static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/
|
|||
const char *ext, const char *def);
|
||||
static void print_error(const char *fmt, ...);
|
||||
|
||||
static /*@exits@*/ void handle_yasm_int_error(const char *file,
|
||||
unsigned int line,
|
||||
const char *message);
|
||||
static /*@exits@*/ void handle_yasm_fatal(const char *message);
|
||||
static const char *handle_yasm_gettext(const char *msgid);
|
||||
static void print_yasm_error(const char *filename, unsigned long line,
|
||||
const char *msg);
|
||||
static void print_yasm_warning(const char *filename, unsigned long line,
|
||||
const char *msg);
|
||||
|
||||
/* values for special_options */
|
||||
#define SPECIAL_SHOW_HELP 0x01
|
||||
#define SPECIAL_SHOW_VERSION 0x02
|
||||
|
|
@ -153,11 +163,10 @@ main(int argc, char *argv[])
|
|||
textdomain(PACKAGE);
|
||||
|
||||
/* Initialize errwarn handling */
|
||||
yasm_std_errwarn.initialize();
|
||||
|
||||
/* Initialize memory allocation */
|
||||
xalloc_initialize((void (*) (int))yasm_std_errwarn.fatal,
|
||||
YASM_FATAL_NOMEM);
|
||||
yasm_internal_error_ = handle_yasm_int_error;
|
||||
yasm_fatal = handle_yasm_fatal;
|
||||
yasm_gettext_hook = handle_yasm_gettext;
|
||||
yasm_errwarn_initialize();
|
||||
|
||||
/* Set libltdl malloc/free functions. */
|
||||
#ifdef WITH_DMALLOC
|
||||
|
|
@ -223,15 +232,15 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Initialize line manager */
|
||||
yasm_std_linemgr.initialize(yasm_std_errwarn.internal_error_);
|
||||
yasm_std_linemgr.initialize();
|
||||
yasm_std_linemgr.set(in_filename, 1, 1);
|
||||
|
||||
/* Initialize intnum and floatnum */
|
||||
yasm_intnum_initialize(&yasm_std_errwarn);
|
||||
yasm_floatnum_initialize(&yasm_std_errwarn);
|
||||
yasm_intnum_initialize();
|
||||
yasm_floatnum_initialize();
|
||||
|
||||
/* Initialize symbol table */
|
||||
yasm_symrec_initialize(&yasm_std_errwarn);
|
||||
yasm_symrec_initialize();
|
||||
|
||||
/* handle preproc-only case here */
|
||||
if (preproc_only) {
|
||||
|
|
@ -261,8 +270,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Pre-process until done */
|
||||
cur_preproc->initialize(in, in_filename, &yasm_std_linemgr,
|
||||
&yasm_std_errwarn);
|
||||
cur_preproc->initialize(in, in_filename, &yasm_std_linemgr);
|
||||
while ((got = cur_preproc->input(preproc_buf, PREPROC_BUF_SIZE)) != 0)
|
||||
fwrite(preproc_buf, got, 1, obj);
|
||||
|
||||
|
|
@ -272,8 +280,9 @@ main(int argc, char *argv[])
|
|||
if (obj != stdout)
|
||||
fclose(obj);
|
||||
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
if (obj != stdout)
|
||||
remove(obj_filename);
|
||||
xfree(preproc_buf);
|
||||
|
|
@ -293,7 +302,7 @@ main(int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
cur_arch->initialize(&yasm_std_errwarn);
|
||||
cur_arch->initialize();
|
||||
|
||||
/* Set basic as the optimizer (TODO: user choice) */
|
||||
cur_optimizer = load_optimizer("basic");
|
||||
|
|
@ -304,8 +313,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
yasm_arch_common_initialize(cur_arch);
|
||||
yasm_expr_initialize(cur_arch, &yasm_std_errwarn);
|
||||
yasm_bc_initialize(cur_arch, &yasm_std_errwarn);
|
||||
yasm_expr_initialize(cur_arch);
|
||||
yasm_bc_initialize(cur_arch);
|
||||
|
||||
/* If not already specified, default to bin as the object format. */
|
||||
if (!cur_objfmt)
|
||||
|
|
@ -359,7 +368,7 @@ main(int argc, char *argv[])
|
|||
/* Initialize the object format */
|
||||
if (cur_objfmt->initialize)
|
||||
cur_objfmt->initialize(in_filename, obj_filename, cur_dbgfmt,
|
||||
cur_arch, &yasm_std_errwarn);
|
||||
cur_arch);
|
||||
|
||||
/* Set NASM as the parser */
|
||||
cur_parser = load_parser("nasm");
|
||||
|
|
@ -401,24 +410,25 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Parse! */
|
||||
sections = cur_parser->do_parse(cur_preproc, cur_arch, cur_objfmt,
|
||||
&yasm_std_linemgr, &yasm_std_errwarn, in,
|
||||
in_filename, 0);
|
||||
&yasm_std_linemgr, in, in_filename, 0);
|
||||
|
||||
/* Close input file */
|
||||
if (in != stdin)
|
||||
fclose(in);
|
||||
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
cleanup(sections);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
yasm_symrec_parser_finalize();
|
||||
cur_optimizer->optimize(sections, &yasm_std_errwarn);
|
||||
cur_optimizer->optimize(sections);
|
||||
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
cleanup(sections);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -442,14 +452,16 @@ main(int argc, char *argv[])
|
|||
/* If we had an error at this point, we also need to delete the output
|
||||
* object file (to make sure it's not left newer than the source).
|
||||
*/
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
remove(obj_filename);
|
||||
cleanup(sections);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
|
||||
cleanup(sections);
|
||||
return EXIT_SUCCESS;
|
||||
|
|
@ -496,7 +508,7 @@ cleanup(yasm_sectionhead *sections)
|
|||
yasm_floatnum_cleanup();
|
||||
yasm_intnum_cleanup();
|
||||
|
||||
yasm_std_errwarn.cleanup();
|
||||
yasm_errwarn_cleanup();
|
||||
yasm_std_linemgr.cleanup();
|
||||
|
||||
BitVector_Shutdown();
|
||||
|
|
@ -611,7 +623,7 @@ opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
|
|||
|
||||
if (extra == 1) {
|
||||
/* -w, disable warnings */
|
||||
yasm_std_errwarn.warn_disable_all();
|
||||
yasm_warn_disable_all();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -631,9 +643,9 @@ opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
|
|||
warning_error = enable;
|
||||
} else if (strcmp(cmd, "unrecognized-char") == 0) {
|
||||
if (enable)
|
||||
yasm_std_errwarn.warn_enable(YASM_WARN_UNREC_CHAR);
|
||||
yasm_warn_enable(YASM_WARN_UNREC_CHAR);
|
||||
else
|
||||
yasm_std_errwarn.warn_disable(YASM_WARN_UNREC_CHAR);
|
||||
yasm_warn_disable(YASM_WARN_UNREC_CHAR);
|
||||
} else
|
||||
return 1;
|
||||
|
||||
|
|
@ -713,3 +725,44 @@ print_error(const char *fmt, ...)
|
|||
va_end(va);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
static /*@exits@*/ void
|
||||
handle_yasm_int_error(const char *file, unsigned int line, const char *message)
|
||||
{
|
||||
fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
|
||||
gettext(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static /*@exits@*/ void
|
||||
handle_yasm_fatal(const char *message)
|
||||
{
|
||||
fprintf(stderr, _("FATAL: %s\n"), gettext(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char *
|
||||
handle_yasm_gettext(const char *msgid)
|
||||
{
|
||||
return gettext(msgid);
|
||||
}
|
||||
|
||||
static void
|
||||
print_yasm_error(const char *filename, unsigned long line, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s:%lu: %s\n", filename, line, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
print_yasm_warning(const char *filename, unsigned long line, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"), msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ libyasm_la_SOURCES = \
|
|||
src/xmalloc.c \
|
||||
src/xstrdup.c \
|
||||
src/strcasecmp.c
|
||||
libyasm_la_LDFLAGS = -no-undefined
|
||||
|
||||
yasm_SOURCES += \
|
||||
src/main.c \
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ struct yasm_arch {
|
|||
/* keyword used to select architecture */
|
||||
const char *keyword;
|
||||
|
||||
void (*initialize) (yasm_errwarn *we);
|
||||
void (*initialize) (void);
|
||||
void (*cleanup) (void);
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -101,14 +101,12 @@ typedef struct bytecode_objfmt_data {
|
|||
unsigned char bytes_static[16];
|
||||
|
||||
/*@dependent@*/ static yasm_arch *cur_arch;
|
||||
/*@dependent@*/ static yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we)
|
||||
yasm_bc_initialize(yasm_arch *a)
|
||||
{
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
}
|
||||
|
||||
yasm_immval *
|
||||
|
|
@ -337,14 +335,14 @@ yasm_bc_delete(yasm_bytecode *bc)
|
|||
objfmt_data->of->bc_objfmt_data_delete(objfmt_data->type,
|
||||
objfmt_data->data);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("objfmt can't handle its own objfmt data bytecode"));
|
||||
break;
|
||||
default:
|
||||
if (bc->type < cur_arch->bc.type_max)
|
||||
cur_arch->bc.bc_delete(bc);
|
||||
else
|
||||
cur_we->internal_error(N_("Unknown bytecode type"));
|
||||
yasm_internal_error(N_("Unknown bytecode type"));
|
||||
break;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
|
@ -511,10 +509,10 @@ bc_resolve_reserve(bytecode_reserve *reserve, unsigned long *len,
|
|||
* the circular reference error to filter through.
|
||||
*/
|
||||
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT))
|
||||
cur_we->error(line,
|
||||
yasm__error(line,
|
||||
N_("expression must not contain floating point value"));
|
||||
else
|
||||
cur_we->error(line,
|
||||
yasm__error(line,
|
||||
N_("attempt to reserve non-constant quantity of space"));
|
||||
retval = YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
} else
|
||||
|
|
@ -577,13 +575,13 @@ bc_resolve_incbin(bytecode_incbin *incbin, unsigned long *len, int save,
|
|||
/* Open file and determine its length */
|
||||
f = fopen(incbin->filename, "rb");
|
||||
if (!f) {
|
||||
cur_we->error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
if (fseek(f, 0L, SEEK_END) < 0) {
|
||||
cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
flen = (unsigned long)ftell(f);
|
||||
|
|
@ -591,9 +589,9 @@ bc_resolve_incbin(bytecode_incbin *incbin, unsigned long *len, int save,
|
|||
|
||||
/* Compute length of incbin from start, maxlen, and len */
|
||||
if (start > flen) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, line,
|
||||
N_("`incbin': start past end of file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__warning(YASM_WARN_GENERAL, line,
|
||||
N_("`incbin': start past end of file `%s'"),
|
||||
incbin->filename);
|
||||
start = flen;
|
||||
}
|
||||
flen -= start;
|
||||
|
|
@ -617,7 +615,7 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
|
||||
switch (bc->type) {
|
||||
case YASM_BC__EMPTY:
|
||||
cur_we->internal_error(N_("got empty bytecode in bc_calc_len"));
|
||||
yasm_internal_error(N_("got empty bytecode in bc_calc_len"));
|
||||
/*break;*/
|
||||
case YASM_BC__DATA:
|
||||
retval = bc_resolve_data((bytecode_data *)bc, &bc->len);
|
||||
|
|
@ -632,18 +630,17 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
break;
|
||||
case YASM_BC__ALIGN:
|
||||
/* TODO */
|
||||
cur_we->internal_error(
|
||||
N_("TODO: align bytecode not implemented!"));
|
||||
yasm_internal_error(N_("TODO: align bytecode not implemented!"));
|
||||
/*break;*/
|
||||
case YASM_BC__OBJFMT_DATA:
|
||||
cur_we->internal_error(N_("resolving objfmt data bytecode?"));
|
||||
yasm_internal_error(N_("resolving objfmt data bytecode?"));
|
||||
/*break;*/
|
||||
default:
|
||||
if (bc->type < cur_arch->bc.type_max)
|
||||
retval = cur_arch->bc.bc_resolve(bc, save, sect,
|
||||
calc_bc_dist);
|
||||
else
|
||||
cur_we->internal_error(N_("Unknown bytecode type"));
|
||||
yasm_internal_error(N_("Unknown bytecode type"));
|
||||
}
|
||||
|
||||
/* Multiply len by number of multiples */
|
||||
|
|
@ -660,7 +657,7 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
if (!num) {
|
||||
retval = YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT)) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("expression must not contain floating point value"));
|
||||
retval |= YASM_BC_RESOLVE_ERROR;
|
||||
}
|
||||
|
|
@ -727,7 +724,7 @@ bc_tobytes_incbin(bytecode_incbin *incbin, unsigned char **bufp,
|
|||
if (incbin->start) {
|
||||
num = yasm_expr_get_intnum(&incbin->start, NULL);
|
||||
if (!num)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("could not determine start in bc_tobytes_incbin"));
|
||||
start = yasm_intnum_get_uint(num);
|
||||
}
|
||||
|
|
@ -735,24 +732,24 @@ bc_tobytes_incbin(bytecode_incbin *incbin, unsigned char **bufp,
|
|||
/* Open file */
|
||||
f = fopen(incbin->filename, "rb");
|
||||
if (!f) {
|
||||
cur_we->error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Seek to start of data */
|
||||
if (fseek(f, (long)start, SEEK_SET) < 0) {
|
||||
cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read len bytes */
|
||||
if (fread(*bufp, (size_t)len, 1, f) < (size_t)len) {
|
||||
cur_we->error(line,
|
||||
N_("`incbin': unable to read %lu bytes from file `%s'"),
|
||||
len, incbin->filename);
|
||||
yasm__error(line,
|
||||
N_("`incbin': unable to read %lu bytes from file `%s'"),
|
||||
len, incbin->filename);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -781,7 +778,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
if (bc->multiple) {
|
||||
num = yasm_expr_get_intnum(&bc->multiple, NULL);
|
||||
if (!num)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("could not determine multiple in bc_tobytes"));
|
||||
*multiple = yasm_intnum_get_uint(num);
|
||||
if (*multiple == 0) {
|
||||
|
|
@ -812,7 +809,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
|
||||
switch (bc->type) {
|
||||
case YASM_BC__EMPTY:
|
||||
cur_we->internal_error(N_("got empty bytecode in bc_tobytes"));
|
||||
yasm_internal_error(N_("got empty bytecode in bc_tobytes"));
|
||||
/*break;*/
|
||||
case YASM_BC__DATA:
|
||||
error = bc_tobytes_data((bytecode_data *)bc, &destbuf, sect, bc, d,
|
||||
|
|
@ -824,8 +821,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
break;
|
||||
case YASM_BC__ALIGN:
|
||||
/* TODO */
|
||||
cur_we->internal_error(
|
||||
N_("TODO: align bytecode not implemented!"));
|
||||
yasm_internal_error(N_("TODO: align bytecode not implemented!"));
|
||||
/*break;*/
|
||||
case YASM_BC__OBJFMT_DATA:
|
||||
objfmt_data = (bytecode_objfmt_data *)bc;
|
||||
|
|
@ -833,7 +829,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
error = output_bc_objfmt_data(objfmt_data->type,
|
||||
objfmt_data->data, &destbuf);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Have objfmt data bytecode but no way to output it"));
|
||||
break;
|
||||
default:
|
||||
|
|
@ -841,11 +837,11 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
error = cur_arch->bc.bc_tobytes(bc, &destbuf, sect, d,
|
||||
output_expr);
|
||||
else
|
||||
cur_we->internal_error(N_("Unknown bytecode type"));
|
||||
yasm_internal_error(N_("Unknown bytecode type"));
|
||||
}
|
||||
|
||||
if (!error && ((unsigned long)(destbuf - origbuf) != datasize))
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("written length does not match optimized length"));
|
||||
return mybuf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ typedef enum {
|
|||
} yasm_bytecode_type;
|
||||
#define YASM_BYTECODE_TYPE_BASE YASM_BC__OBJFMT_DATA+1
|
||||
|
||||
void yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we);
|
||||
void yasm_bc_initialize(yasm_arch *a);
|
||||
|
||||
/*@only@*/ yasm_immval *yasm_imm_new_int(unsigned long int_val,
|
||||
unsigned long lindex);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ typedef struct yasm_intnum yasm_intnum;
|
|||
typedef struct yasm_floatnum yasm_floatnum;
|
||||
|
||||
typedef struct yasm_linemgr yasm_linemgr;
|
||||
typedef struct yasm_errwarn yasm_errwarn;
|
||||
|
||||
typedef enum {
|
||||
YASM_EXPR_ADD,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,19 @@
|
|||
|
||||
#define MSG_MAXSIZE 1024
|
||||
|
||||
/* Default handlers for replacable functions */
|
||||
static /*@exits@*/ void def_internal_error_
|
||||
(const char *file, unsigned int line, const char *message);
|
||||
static /*@exits@*/ void def_fatal(const char *message);
|
||||
static const char *def_gettext_hook(const char *msgid);
|
||||
|
||||
/* Storage for errwarn's "extern" functions */
|
||||
/*@exits@*/ void (*yasm_internal_error_)
|
||||
(const char *file, unsigned int line, const char *message)
|
||||
= def_internal_error_;
|
||||
/*@exits@*/ void (*yasm_fatal) (const char *message) = def_fatal;
|
||||
const char * (*yasm_gettext_hook) (const char *msgid) = def_gettext_hook;
|
||||
|
||||
/* Enabled warnings. See errwarn.h for a list. */
|
||||
static unsigned long warn_class_enabled;
|
||||
|
||||
|
|
@ -48,18 +61,6 @@ static unsigned int error_count;
|
|||
/* Total warning count */
|
||||
static unsigned int warning_count;
|
||||
|
||||
/* See errwarn.h for constants that match up to these strings.
|
||||
* When adding a string here, keep errwarn.h in sync!
|
||||
*/
|
||||
|
||||
/* Fatal error messages. Match up with fatal_num enum in errwarn.h. */
|
||||
/*@-observertrans@*/
|
||||
static const char *fatal_msgs[] = {
|
||||
N_("unknown"),
|
||||
N_("out of memory")
|
||||
};
|
||||
/*@=observertrans@*/
|
||||
|
||||
typedef /*@reldef@*/ SLIST_HEAD(errwarndatahead_s, errwarn_data)
|
||||
errwarndatahead;
|
||||
static /*@only@*/ /*@null@*/ errwarndatahead errwarns;
|
||||
|
|
@ -82,8 +83,14 @@ static /*@null@*/ errwarn_data *previous_we;
|
|||
static char unprint[5];
|
||||
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_initialize(void)
|
||||
static const char *
|
||||
def_gettext_hook(const char *msgid)
|
||||
{
|
||||
return msgid;
|
||||
}
|
||||
|
||||
void
|
||||
yasm_errwarn_initialize(void)
|
||||
{
|
||||
/* Default enabled warnings. See errwarn.h for a list. */
|
||||
warn_class_enabled =
|
||||
|
|
@ -96,8 +103,8 @@ yasm_std_errwarn_initialize(void)
|
|||
previous_we = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_cleanup(void)
|
||||
void
|
||||
yasm_errwarn_cleanup(void)
|
||||
{
|
||||
errwarn_data *we;
|
||||
|
||||
|
|
@ -113,8 +120,8 @@ yasm_std_errwarn_cleanup(void)
|
|||
/* Convert a possibly unprintable character into a printable string, using
|
||||
* standard cat(1) convention for unprintable characters.
|
||||
*/
|
||||
static char *
|
||||
yasm_std_errwarn_conv_unprint(char ch)
|
||||
char *
|
||||
yasm__conv_unprint(char ch)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
|
|
@ -137,11 +144,11 @@ yasm_std_errwarn_conv_unprint(char ch)
|
|||
* Exit immediately because it's essentially an assert() trap.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_internal_error_(const char *file, unsigned int line,
|
||||
const char *message)
|
||||
def_internal_error_(const char *file, unsigned int line, const char *message)
|
||||
{
|
||||
fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
|
||||
gettext(message));
|
||||
fprintf(stderr,
|
||||
yasm_gettext_hook(N_("INTERNAL ERROR at %s, line %u: %s\n")),
|
||||
file, line, yasm_gettext_hook(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
|
|
@ -153,9 +160,10 @@ yasm_std_errwarn_internal_error_(const char *file, unsigned int line,
|
|||
* memory), so just exit immediately.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_fatal(yasm_fatal_cause num)
|
||||
def_fatal(const char *message)
|
||||
{
|
||||
fprintf(stderr, _("FATAL: %s\n"), gettext(fatal_msgs[num]));
|
||||
fprintf(stderr, yasm_gettext_hook(N_("FATAL: %s\n")),
|
||||
yasm_gettext_hook(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
|
|
@ -211,8 +219,7 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
|
|||
assert(ins_we != NULL);
|
||||
SLIST_INSERT_AFTER(ins_we, we, link);
|
||||
} else
|
||||
yasm_std_errwarn_internal_error_(__FILE__, __LINE__,
|
||||
N_("Unexpected errwarn insert action"));
|
||||
yasm_internal_error(N_("Unexpected errwarn insert action"));
|
||||
}
|
||||
|
||||
/* Remember previous err/warn */
|
||||
|
|
@ -224,17 +231,17 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
|
|||
/* Register an error at line lindex. Does not print the error, only stores it
|
||||
* for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_error_va(unsigned long lindex, const char *fmt, va_list va)
|
||||
void
|
||||
yasm__error_va(unsigned long lindex, const char *fmt, va_list va)
|
||||
{
|
||||
errwarn_data *we = errwarn_data_new(lindex, 1);
|
||||
|
||||
we->type = WE_ERROR;
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
|
||||
#else
|
||||
vsprintf(we->msg, gettext(fmt), va);
|
||||
vsprintf(we->msg, yasm_gettext_hook(fmt), va);
|
||||
#endif
|
||||
|
||||
error_count++;
|
||||
|
|
@ -243,9 +250,9 @@ yasm_std_errwarn_error_va(unsigned long lindex, const char *fmt, va_list va)
|
|||
/* Register an warning at line lindex. Does not print the warning, only stores
|
||||
* it for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
|
||||
const char *fmt, va_list va)
|
||||
void
|
||||
yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
|
||||
va_list va)
|
||||
{
|
||||
errwarn_data *we;
|
||||
|
||||
|
|
@ -257,9 +264,9 @@ yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
|
|||
we->type = WE_WARNING;
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
|
||||
#else
|
||||
vsprintf(we->msg, gettext(fmt), va);
|
||||
vsprintf(we->msg, yasm_gettext_hook(fmt), va);
|
||||
#endif
|
||||
|
||||
warning_count++;
|
||||
|
|
@ -268,61 +275,57 @@ yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
|
|||
/* Register an error at line lindex. Does not print the error, only stores it
|
||||
* for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_error(unsigned long lindex, const char *fmt, ...)
|
||||
void
|
||||
yasm__error(unsigned long lindex, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
yasm_std_errwarn_error_va(lindex, fmt, va);
|
||||
yasm__error_va(lindex, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/* Register an warning at line lindex. Does not print the warning, only stores
|
||||
* it for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_warning(yasm_warn_class num, unsigned long lindex,
|
||||
const char *fmt, ...)
|
||||
void
|
||||
yasm__warning(yasm_warn_class num, unsigned long lindex, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
yasm_std_errwarn_warning_va(num, lindex, fmt, va);
|
||||
yasm__warning_va(num, lindex, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/* Parser error handler. Moves YACC-style error into our error handling
|
||||
* system.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_parser_error(unsigned long lindex, const char *s)
|
||||
void
|
||||
yasm__parser_error(unsigned long lindex, const char *s)
|
||||
{
|
||||
yasm_std_errwarn_error(lindex, N_("parser error: %s"), s);
|
||||
yasm__error(lindex, N_("parser error: %s"), s);
|
||||
previous_we->type = WE_PARSERERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_warn_enable(yasm_warn_class num)
|
||||
void
|
||||
yasm_warn_enable(yasm_warn_class num)
|
||||
{
|
||||
warn_class_enabled |= (1UL<<num);
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_warn_disable(yasm_warn_class num)
|
||||
void
|
||||
yasm_warn_disable(yasm_warn_class num)
|
||||
{
|
||||
warn_class_enabled &= ~(1UL<<num);
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_warn_disable_all(void)
|
||||
void
|
||||
yasm_warn_disable_all(void)
|
||||
{
|
||||
warn_class_enabled = 0;
|
||||
}
|
||||
|
||||
/* Get the number of errors (including warnings if warnings are being treated
|
||||
* as errors).
|
||||
*/
|
||||
static unsigned int
|
||||
yasm_std_errwarn_get_num_errors(int warning_as_error)
|
||||
unsigned int
|
||||
yasm_get_num_errors(int warning_as_error)
|
||||
{
|
||||
if (warning_as_error)
|
||||
return error_count+warning_count;
|
||||
|
|
@ -330,9 +333,11 @@ yasm_std_errwarn_get_num_errors(int warning_as_error)
|
|||
return error_count;
|
||||
}
|
||||
|
||||
/* Output all previously stored errors and warnings to stderr. */
|
||||
static void
|
||||
yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
|
||||
void
|
||||
yasm_errwarn_output_all(yasm_linemgr *lm, int warning_as_error,
|
||||
void (*print_error) (const char *fn, unsigned long line, const char *msg),
|
||||
void (*print_warning) (const char *fn, unsigned long line,
|
||||
const char *msg))
|
||||
{
|
||||
errwarn_data *we;
|
||||
const char *filename;
|
||||
|
|
@ -340,7 +345,8 @@ yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
|
|||
|
||||
/* If we're treating warnings as errors, tell the user about it. */
|
||||
if (warning_as_error && warning_as_error != 2) {
|
||||
fprintf(stderr, "%s\n", _("warnings being treated as errors"));
|
||||
print_error("", 0,
|
||||
yasm_gettext_hook(N_("warnings being treated as errors")));
|
||||
warning_as_error = 2;
|
||||
}
|
||||
|
||||
|
|
@ -349,27 +355,8 @@ yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
|
|||
/* Output error/warning */
|
||||
lm->lookup(we->line, &filename, &line);
|
||||
if (we->type == WE_ERROR)
|
||||
fprintf(stderr, "%s:%lu: %s\n", filename, line, we->msg);
|
||||
print_error(filename, line, we->msg);
|
||||
else
|
||||
fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"),
|
||||
we->msg);
|
||||
print_warning(filename, line, we->msg);
|
||||
}
|
||||
}
|
||||
|
||||
yasm_errwarn yasm_std_errwarn = {
|
||||
yasm_std_errwarn_initialize,
|
||||
yasm_std_errwarn_cleanup,
|
||||
yasm_std_errwarn_internal_error_,
|
||||
yasm_std_errwarn_fatal,
|
||||
yasm_std_errwarn_error_va,
|
||||
yasm_std_errwarn_warning_va,
|
||||
yasm_std_errwarn_error,
|
||||
yasm_std_errwarn_warning,
|
||||
yasm_std_errwarn_parser_error,
|
||||
yasm_std_errwarn_warn_enable,
|
||||
yasm_std_errwarn_warn_disable,
|
||||
yasm_std_errwarn_warn_disable_all,
|
||||
yasm_std_errwarn_get_num_errors,
|
||||
yasm_std_errwarn_output_all,
|
||||
yasm_std_errwarn_conv_unprint
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,66 +34,61 @@ typedef enum {
|
|||
YASM_WARN_PREPROC /* preprocessor warnings */
|
||||
} yasm_warn_class;
|
||||
|
||||
/* Fatal error constants.
|
||||
* See fatal_msgs in errwarn.c for strings that match up to these constants.
|
||||
* When adding a constant here, keep errwarn.c in sync!
|
||||
/* Initialize any internal data structures. */
|
||||
void yasm_errwarn_initialize(void);
|
||||
|
||||
/* Cleans up any memory allocated by initialize or other functions. */
|
||||
void yasm_errwarn_cleanup(void);
|
||||
|
||||
/* Reporting point of internal errors. These are usually due to sanity
|
||||
* check failures in the code.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
typedef enum {
|
||||
YASM_FATAL_UNKNOWN = 0,
|
||||
YASM_FATAL_NOMEM
|
||||
} yasm_fatal_cause;
|
||||
extern /*@exits@*/ void (*yasm_internal_error_)
|
||||
(const char *file, unsigned int line, const char *message);
|
||||
#define yasm_internal_error(msg) \
|
||||
yasm_internal_error_(__FILE__, __LINE__, msg)
|
||||
|
||||
struct yasm_errwarn {
|
||||
/* Initialize any internal data structures. */
|
||||
void (*initialize) (void);
|
||||
/* Reporting point of fatal errors.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
extern /*@exits@*/ void (*yasm_fatal) (const char *message);
|
||||
|
||||
/* Cleans up any memory allocated by initialize or other functions. */
|
||||
void (*cleanup) (void);
|
||||
/* va_list versions of the below two functions */
|
||||
void yasm__error_va(unsigned long lindex, const char *, va_list va);
|
||||
void yasm__warning_va(yasm_warn_class, unsigned long lindex, const char *,
|
||||
va_list va);
|
||||
|
||||
/* Reporting point of internal errors. These are usually due to sanity
|
||||
* check failures in the code.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
/*@exits@*/ void (*internal_error_) (const char *file, unsigned int line,
|
||||
const char *message);
|
||||
#define internal_error(msg) internal_error_(__FILE__, __LINE__, msg)
|
||||
void yasm__error(unsigned long lindex, const char *, ...) /*@printflike@*/;
|
||||
void yasm__warning(yasm_warn_class, unsigned long lindex, const char *, ...)
|
||||
/*@printflike@*/;
|
||||
|
||||
/* Reporting point of fatal errors.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
/*@exits@*/ void (*fatal) (yasm_fatal_cause);
|
||||
/* Logs a parser error. These can be overwritten by non-parser errors on
|
||||
* the same line.
|
||||
*/
|
||||
void yasm__parser_error(unsigned long lindex, const char *);
|
||||
|
||||
/* va_list versions of the below two functions */
|
||||
void (*error_va) (unsigned long lindex, const char *, va_list va);
|
||||
void (*warning_va) (yasm_warn_class, unsigned long lindex, const char *,
|
||||
va_list va);
|
||||
/* Enables/disables a class of warnings. */
|
||||
void yasm_warn_enable(yasm_warn_class);
|
||||
void yasm_warn_disable(yasm_warn_class);
|
||||
void yasm_warn_disable_all(void);
|
||||
|
||||
void (*error) (unsigned long lindex, const char *, ...) /*@printflike@*/;
|
||||
void (*warning) (yasm_warn_class, unsigned long lindex, const char *, ...)
|
||||
/*@printflike@*/;
|
||||
/* Returns total number of errors logged to this point.
|
||||
* If warning_as_error is nonzero, warnings are treated as errors.
|
||||
*/
|
||||
unsigned int yasm_get_num_errors(int warning_as_error);
|
||||
|
||||
/* Logs a parser error. These can be overwritten by non-parser errors on
|
||||
* the same line.
|
||||
*/
|
||||
void (*parser_error) (unsigned long lindex, const char *);
|
||||
/* Outputs all errors/warnings by calling print_error and print_warning. */
|
||||
void yasm_errwarn_output_all
|
||||
(yasm_linemgr *lm, int warning_as_error,
|
||||
void (*print_error) (const char *fn, unsigned long line, const char *msg),
|
||||
void (*print_warning) (const char *fn, unsigned long line,
|
||||
const char *msg));
|
||||
|
||||
/* Enables/disables a class of warnings. */
|
||||
void (*warn_enable) (yasm_warn_class);
|
||||
void (*warn_disable) (yasm_warn_class);
|
||||
void (*warn_disable_all) (void);
|
||||
/* Convert a possibly unprintable character into a printable string. */
|
||||
char *yasm__conv_unprint(char ch);
|
||||
|
||||
/* Returns total number of errors logged to this point.
|
||||
* If warning_as_error is nonzero, warnings are treated as errors.
|
||||
*/
|
||||
unsigned int (*get_num_errors) (int warning_as_error);
|
||||
|
||||
/* Outputs all errors/warnings (e.g. to stderr or elsewhere). */
|
||||
void (*output_all) (yasm_linemgr *lm, int warning_as_error);
|
||||
|
||||
/* Convert a possibly unprintable character into a printable string. */
|
||||
char * (*conv_unprint) (char ch);
|
||||
};
|
||||
|
||||
extern yasm_errwarn yasm_std_errwarn;
|
||||
/* Map to gettext() if gettext is being used. */
|
||||
extern const char * (*yasm_gettext_hook) (const char *msgid);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -49,14 +49,12 @@ static int expr_traverse_nodes_post(/*@null@*/ yasm_expr *e,
|
|||
/*@null@*/ void *d));
|
||||
|
||||
static /*@dependent@*/ yasm_arch *cur_arch;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we)
|
||||
yasm_expr_initialize(yasm_arch *a)
|
||||
{
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
}
|
||||
|
||||
/* allocate a new expression node, with children as defined.
|
||||
|
|
@ -90,7 +88,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
/*@=usereleased@*/
|
||||
}
|
||||
} else {
|
||||
cur_we->internal_error(N_("Right side of expression must exist"));
|
||||
yasm_internal_error(N_("Right side of expression must exist"));
|
||||
}
|
||||
|
||||
if (right) {
|
||||
|
|
@ -716,8 +714,8 @@ yasm_expr__level_tree(yasm_expr *e, int fold_const, int simplify_ident,
|
|||
/* Check for circular reference */
|
||||
SLIST_FOREACH(np, eh, next) {
|
||||
if (np->e == equ_expr) {
|
||||
cur_we->error(e->line,
|
||||
N_("circular reference detected."));
|
||||
yasm__error(e->line,
|
||||
N_("circular reference detected."));
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
typedef struct yasm_expr__item yasm_expr__item;
|
||||
|
||||
void yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we);
|
||||
void yasm_expr_initialize(yasm_arch *a);
|
||||
|
||||
/*@only@*/ yasm_expr *yasm_expr_new(yasm_expr_op, /*@only@*/ yasm_expr__item *,
|
||||
/*@only@*/ /*@null@*/ yasm_expr__item *,
|
||||
|
|
|
|||
|
|
@ -135,8 +135,6 @@ static POT_Entry_Source POT_TableP_Source[] = {
|
|||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80},0x7fff}, /* 1e+0 */
|
||||
};
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
static void
|
||||
POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp)
|
||||
|
|
@ -160,15 +158,13 @@ POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp)
|
|||
|
||||
/*@-compdef@*/
|
||||
void
|
||||
yasm_floatnum_initialize(yasm_errwarn *we)
|
||||
yasm_floatnum_initialize(void)
|
||||
/*@globals undef POT_TableN, undef POT_TableP, POT_TableP_Source,
|
||||
POT_TableN_Source @*/
|
||||
{
|
||||
int dec_exp = 1;
|
||||
int i;
|
||||
|
||||
cur_we = we;
|
||||
|
||||
/* Allocate space for two POT tables */
|
||||
POT_TableN = xmalloc(14*sizeof(POT_Entry));
|
||||
POT_TableP = xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
|
||||
|
|
@ -516,8 +512,8 @@ yasm_floatnum_calc(yasm_floatnum *acc, yasm_expr_op op,
|
|||
/*@unused@*/ yasm_floatnum *operand, unsigned long lindex)
|
||||
{
|
||||
if (op != YASM_EXPR_NEG)
|
||||
cur_we->error(lindex,
|
||||
N_("Unsupported floating-point arithmetic operation"));
|
||||
yasm__error(lindex,
|
||||
N_("Unsupported floating-point arithmetic operation"));
|
||||
else
|
||||
acc->sign ^= 1;
|
||||
}
|
||||
|
|
@ -592,7 +588,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr,
|
|||
|
||||
/* underflow and overflow both set!? */
|
||||
if (underflow && overflow)
|
||||
cur_we->internal_error(N_("Both underflow and overflow set"));
|
||||
yasm_internal_error(N_("Both underflow and overflow set"));
|
||||
|
||||
/* check for underflow or overflow and set up appropriate output */
|
||||
if (underflow) {
|
||||
|
|
@ -615,7 +611,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr,
|
|||
/* get little-endian bytes */
|
||||
buf = BitVector_Block_Read(output, &len);
|
||||
if (len < byte_size)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Byte length of BitVector does not match bit length"));
|
||||
|
||||
/* copy to output */
|
||||
|
|
@ -671,7 +667,7 @@ yasm_floatnum_get_sized(const yasm_floatnum *flt, unsigned char *ptr,
|
|||
case 10:
|
||||
return floatnum_get_common(flt, ptr, 10, 64, 0, 15);
|
||||
default:
|
||||
cur_we->internal_error(N_("Invalid float conversion size"));
|
||||
yasm_internal_error(N_("Invalid float conversion size"));
|
||||
/*@notreached@*/
|
||||
return 1; /* never reached, but silence GCC warning */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef YASM_FLOATNUM_H
|
||||
#define YASM_FLOATNUM_H
|
||||
|
||||
void yasm_floatnum_initialize(yasm_errwarn *we);
|
||||
void yasm_floatnum_initialize(void);
|
||||
/* Clean up internal allocations */
|
||||
void yasm_floatnum_cleanup(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,14 +49,11 @@ struct yasm_intnum {
|
|||
|
||||
/* static bitvect used for conversions */
|
||||
static /*@only@*/ wordptr conv_bv;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_intnum_initialize(yasm_errwarn *we)
|
||||
yasm_intnum_initialize(void)
|
||||
{
|
||||
cur_we = we;
|
||||
|
||||
conv_bv = BitVector_Create(BITVECT_ALLOC_SIZE, FALSE);
|
||||
BitVector_from_Dec_static_Boot(BITVECT_ALLOC_SIZE);
|
||||
}
|
||||
|
|
@ -77,8 +74,8 @@ yasm_intnum_new_dec(char *str, unsigned long lindex)
|
|||
|
||||
if (BitVector_from_Dec_static(conv_bv,
|
||||
(unsigned char *)str) == ErrCode_Ovfl)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
intn->type = INTNUM_UL;
|
||||
intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0);
|
||||
|
|
@ -98,8 +95,8 @@ yasm_intnum_new_bin(char *str, unsigned long lindex)
|
|||
intn->origsize = (unsigned char)strlen(str);
|
||||
|
||||
if(intn->origsize > BITVECT_ALLOC_SIZE)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
|
||||
BitVector_from_Bin(conv_bv, (unsigned char *)str);
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
|
|
@ -121,8 +118,8 @@ yasm_intnum_new_oct(char *str, unsigned long lindex)
|
|||
intn->origsize = strlen(str)*3;
|
||||
|
||||
if(intn->origsize > BITVECT_ALLOC_SIZE)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
|
||||
BitVector_from_Oct(conv_bv, (unsigned char *)str);
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
|
|
@ -144,8 +141,8 @@ yasm_intnum_new_hex(char *str, unsigned long lindex)
|
|||
intn->origsize = strlen(str)*4;
|
||||
|
||||
if(intn->origsize > BITVECT_ALLOC_SIZE)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
|
||||
BitVector_from_Hex(conv_bv, (unsigned char *)str);
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
|
|
@ -167,7 +164,7 @@ yasm_intnum_new_charconst_nasm(const char *str, unsigned long lindex)
|
|||
size_t len = strlen(str);
|
||||
|
||||
if (len > 4)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("character constant too large, ignoring trailing characters"));
|
||||
|
||||
intn->val.ul = 0;
|
||||
|
|
@ -275,7 +272,7 @@ yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand)
|
|||
|
||||
if (!operand && op != YASM_EXPR_NEG && op != YASM_EXPR_NOT &&
|
||||
op != YASM_EXPR_LNOT)
|
||||
cur_we->internal_error(N_("Operation needs an operand"));
|
||||
yasm_internal_error(N_("Operation needs an operand"));
|
||||
|
||||
/* A operation does a bitvector computation if result is allocated. */
|
||||
switch (op) {
|
||||
|
|
@ -446,8 +443,7 @@ yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand)
|
|||
BitVector_Copy(result, op1);
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
N_("invalid operation in intnum calculation"));
|
||||
yasm_internal_error(N_("invalid operation in intnum calculation"));
|
||||
}
|
||||
|
||||
/* If we were doing a bitvector computation... */
|
||||
|
|
@ -510,7 +506,7 @@ yasm_intnum_get_uint(const yasm_intnum *intn)
|
|||
case INTNUM_BV:
|
||||
return BitVector_Chunk_Read(intn->val.bv, 32, 0);
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown intnum type"));
|
||||
yasm_internal_error(N_("unknown intnum type"));
|
||||
/*@notreached@*/
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -538,7 +534,7 @@ yasm_intnum_get_int(const yasm_intnum *intn)
|
|||
} else
|
||||
return (long)BitVector_Chunk_Read(intn->val.bv, 32, 0);
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown intnum type"));
|
||||
yasm_internal_error(N_("unknown intnum type"));
|
||||
/*@notreached@*/
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -563,8 +559,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, size_t size)
|
|||
case INTNUM_BV:
|
||||
buf = BitVector_Block_Read(intn->val.bv, &len);
|
||||
if (len < (unsigned int)size)
|
||||
cur_we->internal_error(
|
||||
N_("Invalid size specified (too large)"));
|
||||
yasm_internal_error(N_("Invalid size specified (too large)"));
|
||||
memcpy(ptr, buf, size);
|
||||
xfree(buf);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef YASM_INTNUM_H
|
||||
#define YASM_INTNUM_H
|
||||
|
||||
void yasm_intnum_initialize(yasm_errwarn *we);
|
||||
void yasm_intnum_initialize(void);
|
||||
/* Clean up internal allocations */
|
||||
void yasm_intnum_cleanup(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,10 @@
|
|||
|
||||
#include "hamt.h"
|
||||
|
||||
#include "errwarn.h"
|
||||
#include "linemgr.h"
|
||||
|
||||
|
||||
static /*@exits@*/ void (*efunc) (const char *file, unsigned int line,
|
||||
const char *message);
|
||||
|
||||
/* Source lines tracking */
|
||||
typedef struct {
|
||||
struct line_index_mapping *vector;
|
||||
|
|
@ -119,15 +117,11 @@ yasm_std_linemgr_set(const char *filename, unsigned long line,
|
|||
}
|
||||
|
||||
static void
|
||||
yasm_std_linemgr_initialize(/*@exits@*/
|
||||
void (*error_func) (const char *file,
|
||||
unsigned int line,
|
||||
const char *message))
|
||||
yasm_std_linemgr_initialize(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
filename_table = HAMT_new(error_func);
|
||||
efunc = error_func;
|
||||
filename_table = HAMT_new(yasm_internal_error_);
|
||||
|
||||
line_index = 1;
|
||||
|
||||
|
|
@ -216,10 +210,9 @@ yasm_std_linemgr_add_assoc_data(int type, /*@only@*/ void *data,
|
|||
|
||||
adrh->vector[line_index-1] = data;
|
||||
if (adrh->delete_func != delete_func)
|
||||
efunc(__FILE__, __LINE__,
|
||||
N_("multiple deletion functions specified"));
|
||||
yasm_internal_error(N_("multiple deletion functions specified"));
|
||||
} else {
|
||||
efunc(__FILE__, __LINE__, N_("non-common data not supported yet"));
|
||||
yasm_internal_error(N_("non-common data not supported yet"));
|
||||
delete_func(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,7 @@ typedef enum yasm_linemgr_std_type {
|
|||
|
||||
struct yasm_linemgr {
|
||||
/* Initialize cur_lindex and any manager internal data structures. */
|
||||
void (*initialize) (/*@exits@*/
|
||||
void (*error_func) (const char *file,
|
||||
unsigned int line,
|
||||
const char *message));
|
||||
void (*initialize) (void);
|
||||
|
||||
/* Cleans up any memory allocated. */
|
||||
void (*cleanup) (void);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct yasm_objfmt {
|
|||
* provided solely for informational purposes.
|
||||
*/
|
||||
void (*initialize) (const char *in_filename, const char *obj_filename,
|
||||
yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we);
|
||||
yasm_dbgfmt *df, yasm_arch *a);
|
||||
|
||||
/* Write out (post-optimized) sections to the object file.
|
||||
* This function may call symrec functions as necessary (including
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ struct yasm_optimizer {
|
|||
* object file. (A failure is indicated by calling ErrorAt() from within
|
||||
* this function).
|
||||
*/
|
||||
void (*optimize) (yasm_sectionhead *sections, yasm_errwarn *we);
|
||||
void (*optimize) (yasm_sectionhead *sections);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -60,6 +60,6 @@ struct yasm_parser {
|
|||
*/
|
||||
yasm_sectionhead *(*do_parse)
|
||||
(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm,
|
||||
yasm_errwarn *we, FILE *f, const char *in_filename, int save_input);
|
||||
FILE *f, const char *in_filename, int save_input);
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ struct yasm_preproc {
|
|||
* This function also takes the FILE * to the initial starting file and
|
||||
* the filename.
|
||||
*/
|
||||
void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we);
|
||||
void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm);
|
||||
|
||||
/* Cleans up any allocated memory. */
|
||||
void (*cleanup) (void);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,6 @@ struct yasm_section {
|
|||
int res_only; /* allow only resb family of bytecodes? */
|
||||
|
||||
yasm_bytecodehead bc; /* the bytecodes for the section's contents */
|
||||
|
||||
/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message);
|
||||
};
|
||||
|
||||
/*@-compdestroy@*/
|
||||
|
|
@ -90,10 +87,7 @@ yasm_sections_initialize(yasm_sectionhead *headp, yasm_objfmt *of)
|
|||
yasm_section *
|
||||
yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
||||
unsigned long start, int res_only, int *isnew,
|
||||
unsigned long lindex,
|
||||
/*@exits@*/ void (*error_func)
|
||||
(const char *file, unsigned int line,
|
||||
const char *message))
|
||||
unsigned long lindex)
|
||||
{
|
||||
yasm_section *s;
|
||||
|
||||
|
|
@ -125,8 +119,6 @@ yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
|||
s->opt_flags = 0;
|
||||
s->res_only = res_only;
|
||||
|
||||
s->error_func = error_func;
|
||||
|
||||
*isnew = 1;
|
||||
return s;
|
||||
}
|
||||
|
|
@ -134,10 +126,7 @@ yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
|||
|
||||
/*@-onlytrans@*/
|
||||
yasm_section *
|
||||
yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start,
|
||||
/*@exits@*/ void (*error_func)
|
||||
(const char *file, unsigned int line,
|
||||
const char *message))
|
||||
yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start)
|
||||
{
|
||||
yasm_section *s;
|
||||
|
||||
|
|
@ -151,8 +140,6 @@ yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start,
|
|||
s->opt_flags = 0;
|
||||
s->res_only = 1;
|
||||
|
||||
s->error_func = error_func;
|
||||
|
||||
return s;
|
||||
}
|
||||
/*@=onlytrans@*/
|
||||
|
|
@ -183,7 +170,7 @@ yasm_section_set_of_data(yasm_section *sect, yasm_objfmt *of, void *of_data)
|
|||
if (of->section_data_delete)
|
||||
of->section_data_delete(of_data);
|
||||
else
|
||||
sect->error_func(__FILE__, __LINE__,
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific section data"));
|
||||
return;
|
||||
}
|
||||
|
|
@ -194,7 +181,7 @@ yasm_section_set_of_data(yasm_section *sect, yasm_objfmt *of, void *of_data)
|
|||
if (of2->section_data_delete)
|
||||
of2->section_data_delete(sect->data.general.of_data);
|
||||
else
|
||||
sect->error_func(__FILE__, __LINE__,
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific section data"));
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +296,7 @@ yasm_section_delete(yasm_section *sect)
|
|||
if (of->section_data_delete)
|
||||
of->section_data_delete(sect->data.general.of_data);
|
||||
else
|
||||
sect->error_func(__FILE__, __LINE__,
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific section data"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,10 @@
|
|||
|
||||
/*@dependent@*/ yasm_section *yasm_sections_switch_general
|
||||
(yasm_sectionhead *headp, const char *name, unsigned long start,
|
||||
int res_only, /*@out@*/ int *isnew, unsigned long lindex,
|
||||
/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message));
|
||||
int res_only, /*@out@*/ int *isnew, unsigned long lindex);
|
||||
|
||||
/*@dependent@*/ yasm_section *yasm_sections_switch_absolute
|
||||
(yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start,
|
||||
/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message));
|
||||
(yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start);
|
||||
|
||||
int yasm_section_is_absolute(yasm_section *sect);
|
||||
|
||||
|
|
|
|||
|
|
@ -92,15 +92,11 @@ typedef /*@reldef@*/ SLIST_HEAD(nontablesymhead_s, non_table_symrec_s)
|
|||
nontablesymhead;
|
||||
static /*@only@*/ nontablesymhead *non_table_syms;
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_symrec_initialize(yasm_errwarn *we)
|
||||
yasm_symrec_initialize(void)
|
||||
{
|
||||
cur_we = we;
|
||||
|
||||
sym_table = HAMT_new(cur_we->internal_error_);
|
||||
sym_table = HAMT_new(yasm_internal_error_);
|
||||
non_table_syms = xmalloc(sizeof(nontablesymhead));
|
||||
SLIST_INIT(non_table_syms);
|
||||
}
|
||||
|
|
@ -116,7 +112,7 @@ symrec_delete_one(/*@only@*/ void *d)
|
|||
if (sym->of->symrec_data_delete)
|
||||
sym->of->symrec_data_delete(sym->of_data);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific data"));
|
||||
}
|
||||
xfree(sym);
|
||||
|
|
@ -201,7 +197,7 @@ symrec_define(const char *name, sym_type type, int in_table,
|
|||
/* Has it been defined before (either by DEFINED or COMMON/EXTERN)? */
|
||||
if ((rec->status & SYM_DEFINED) ||
|
||||
(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN))) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("duplicate definition of `%s'; first defined on line %lu"),
|
||||
name, rec->line);
|
||||
} else {
|
||||
|
|
@ -255,7 +251,7 @@ yasm_symrec_declare(const char *name, yasm_sym_vis vis, unsigned long lindex)
|
|||
((rec->visibility & YASM_SYM_EXTERN) && (vis == YASM_SYM_EXTERN)))))
|
||||
rec->visibility |= vis;
|
||||
else
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("duplicate definition of `%s'; first defined on line %lu"),
|
||||
name, rec->line);
|
||||
return rec;
|
||||
|
|
@ -321,7 +317,7 @@ yasm_symrec_set_of_data(yasm_symrec *sym, yasm_objfmt *of, void *of_data)
|
|||
if (sym->of->symrec_data_delete)
|
||||
sym->of->symrec_data_delete(sym->of_data);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific data"));
|
||||
}
|
||||
sym->of = of;
|
||||
|
|
@ -336,8 +332,8 @@ symrec_parser_finalize_checksym(yasm_symrec *sym,
|
|||
/* error if a symbol is used but never defined or extern/common declared */
|
||||
if ((sym->status & SYM_USED) && !(sym->status & SYM_DEFINED) &&
|
||||
!(sym->visibility & (YASM_SYM_EXTERN | YASM_SYM_COMMON))) {
|
||||
cur_we->error(sym->line, N_("undefined symbol `%s' (first use)"),
|
||||
sym->name);
|
||||
yasm__error(sym->line, N_("undefined symbol `%s' (first use)"),
|
||||
sym->name);
|
||||
if (sym->line < firstundef_line)
|
||||
firstundef_line = sym->line;
|
||||
}
|
||||
|
|
@ -351,8 +347,8 @@ yasm_symrec_parser_finalize(void)
|
|||
firstundef_line = ULONG_MAX;
|
||||
yasm_symrec_traverse(NULL, symrec_parser_finalize_checksym);
|
||||
if (firstundef_line < ULONG_MAX)
|
||||
cur_we->error(firstundef_line,
|
||||
N_(" (Each undefined symbol is reported only once.)"));
|
||||
yasm__error(firstundef_line,
|
||||
N_(" (Each undefined symbol is reported only once.)"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef YASM_SYMREC_H
|
||||
#define YASM_SYMREC_H
|
||||
|
||||
void yasm_symrec_initialize(yasm_errwarn *we);
|
||||
void yasm_symrec_initialize(void);
|
||||
|
||||
/*@dependent@*/ yasm_symrec *yasm_symrec_use(const char *name,
|
||||
unsigned long lindex);
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ main(void)
|
|||
Suite *s = floatnum_suite();
|
||||
SRunner *sr = srunner_create(s);
|
||||
BitVector_Boot();
|
||||
yasm_floatnum_initialize(NULL);
|
||||
yasm_floatnum_initialize();
|
||||
srunner_run_all(sr, CRNORMAL);
|
||||
nf = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
|
|
|
|||
|
|
@ -130,8 +130,6 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
|
|||
/*@only@*/ char *xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines in xmalloc.c. */
|
||||
void xalloc_initialize(/*@exits@*/ void (*fatal_func) (int type),
|
||||
int nomem_fatal_type);
|
||||
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
|
||||
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
|
||||
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
|
||||
|
|
|
|||
|
|
@ -27,17 +27,8 @@
|
|||
#include "util.h"
|
||||
RCSID("$IdPath$");
|
||||
|
||||
#include "errwarn.h"
|
||||
|
||||
static /*@exits@*/ void (*fatal_func) (int type);
|
||||
static int nomem_fatal_type;
|
||||
|
||||
|
||||
void
|
||||
xalloc_initialize(/*@exits@*/ void (*f) (int type), int t)
|
||||
{
|
||||
fatal_func = f;
|
||||
nomem_fatal_type = t;
|
||||
}
|
||||
|
||||
#ifndef WITH_DMALLOC
|
||||
|
||||
|
|
@ -50,7 +41,7 @@ xmalloc(size_t size)
|
|||
size = 1;
|
||||
newmem = malloc(size);
|
||||
if (!newmem)
|
||||
fatal_func(nomem_fatal_type);
|
||||
yasm_fatal(N_("out of memory"));
|
||||
|
||||
return newmem;
|
||||
}
|
||||
|
|
@ -65,7 +56,7 @@ xcalloc(size_t nelem, size_t elsize)
|
|||
|
||||
newmem = calloc(nelem, elsize);
|
||||
if (!newmem)
|
||||
fatal_func(nomem_fatal_type);
|
||||
yasm_fatal(N_("out of memory"));
|
||||
|
||||
return newmem;
|
||||
}
|
||||
|
|
@ -82,7 +73,7 @@ xrealloc(void *oldmem, size_t size)
|
|||
else
|
||||
newmem = realloc(oldmem, size);
|
||||
if (!newmem)
|
||||
fatal_func(nomem_fatal_type);
|
||||
yasm_fatal(N_("out of memory"));
|
||||
|
||||
return newmem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ libyasm_la_SOURCES = \
|
|||
src/xmalloc.c \
|
||||
src/xstrdup.c \
|
||||
src/strcasecmp.c
|
||||
libyasm_la_LDFLAGS = -no-undefined
|
||||
|
||||
yasm_SOURCES += \
|
||||
src/main.c \
|
||||
|
|
|
|||
|
|
@ -42,13 +42,11 @@
|
|||
|
||||
|
||||
unsigned char yasm_x86_LTX_mode_bits = 0;
|
||||
/*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
|
||||
|
||||
|
||||
static void
|
||||
x86_initialize(yasm_errwarn *we)
|
||||
x86_initialize(void)
|
||||
{
|
||||
yasm_x86__errwarn = we;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -73,7 +71,7 @@ yasm_x86__directive(const char *name, yasm_valparamhead *valparams,
|
|||
(lval == 16 || lval == 32 || lval == 64))
|
||||
yasm_x86_LTX_mode_bits = (unsigned char)lval;
|
||||
else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "BITS");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "BITS");
|
||||
return 0;
|
||||
} else
|
||||
return 1;
|
||||
|
|
@ -101,7 +99,7 @@ yasm_x86__get_reg_size(unsigned long reg)
|
|||
case X86_FPUREG:
|
||||
return 10;
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown register size"));
|
||||
yasm_internal_error(N_("unknown register size"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -162,7 +160,7 @@ yasm_x86__reg_print(FILE *f, unsigned long reg)
|
|||
fprintf(f, "st%d", (int)(reg&0xF));
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown register size"));
|
||||
yasm_internal_error(N_("unknown register size"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ typedef struct x86_new_jmprel_data {
|
|||
yasm_bytecode *yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d);
|
||||
|
||||
extern unsigned char yasm_x86_LTX_mode_bits;
|
||||
extern /*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
|
||||
#define cur_we yasm_x86__errwarn
|
||||
|
||||
void yasm_x86__bc_delete(yasm_bytecode *bc);
|
||||
void yasm_x86__bc_print(FILE *f, int indent_level, const yasm_bytecode *bc);
|
||||
|
|
|
|||
|
|
@ -202,11 +202,11 @@ yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d)
|
|||
jmprel->op_sel = d->op_sel;
|
||||
|
||||
if ((d->op_sel == JR_SHORT_FORCED) && (d->near_op_len == 0))
|
||||
cur_we->error(d->lindex,
|
||||
N_("no SHORT form of that jump instruction exists"));
|
||||
yasm__error(d->lindex,
|
||||
N_("no SHORT form of that jump instruction exists"));
|
||||
if ((d->op_sel == JR_NEAR_FORCED) && (d->short_op_len == 0))
|
||||
cur_we->error(d->lindex,
|
||||
N_("no NEAR form of that jump instruction exists"));
|
||||
yasm__error(d->lindex,
|
||||
N_("no NEAR form of that jump instruction exists"));
|
||||
|
||||
jmprel->shortop.opcode[0] = d->short_op[0];
|
||||
jmprel->shortop.opcode[1] = d->short_op[1];
|
||||
|
|
@ -238,8 +238,8 @@ yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned char segment,
|
|||
return;
|
||||
|
||||
if (segment != 0 && x86_ea->segment != 0)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple segment overrides, using leftmost"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple segment overrides, using leftmost"));
|
||||
|
||||
x86_ea->segment = segment;
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ yasm_x86__bc_insn_get_ea(yasm_bytecode *bc)
|
|||
return NULL;
|
||||
|
||||
if ((x86_bytecode_type)bc->type != X86_BC_INSN)
|
||||
cur_we->internal_error(N_("Trying to get EA of non-instruction"));
|
||||
yasm_internal_error(N_("Trying to get EA of non-instruction"));
|
||||
|
||||
return (yasm_effaddr *)(((x86_insn *)bc)->ea);
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned char opersize)
|
|||
jmprel->opersize = opersize;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("OperSize override applied to non-instruction"));
|
||||
}
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned char addrsize)
|
|||
jmprel->addrsize = addrsize;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("AddrSize override applied to non-instruction"));
|
||||
}
|
||||
}
|
||||
|
|
@ -408,13 +408,13 @@ yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned char prefix,
|
|||
lockrep_pre = &jmprel->lockrep_pre;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("LockRep prefix applied to non-instruction"));
|
||||
}
|
||||
|
||||
if (*lockrep_pre != 0)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple LOCK or REP prefixes, using leftmost"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple LOCK or REP prefixes, using leftmost"));
|
||||
|
||||
*lockrep_pre = prefix;
|
||||
}
|
||||
|
|
@ -701,7 +701,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
temp = yasm_expr_copy(jmprel->target);
|
||||
num = yasm_expr_get_intnum(&temp, calc_bc_dist);
|
||||
if (!num) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("short jump target external or out of segment"));
|
||||
yasm_expr_delete(temp);
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
|
|
@ -711,14 +711,13 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
yasm_expr_delete(temp);
|
||||
/* does a short form exist? */
|
||||
if (jmprel->shortop.opcode_len == 0) {
|
||||
cur_we->error(bc->line,
|
||||
N_("short jump does not exist"));
|
||||
yasm__error(bc->line, N_("short jump does not exist"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
/* short displacement must fit in -128 <= rel <= +127 */
|
||||
if (rel < -128 || rel > 127) {
|
||||
cur_we->error(bc->line, N_("short jump out of range"));
|
||||
yasm__error(bc->line, N_("short jump out of range"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
|
|
@ -730,7 +729,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
jrshort = 0;
|
||||
if (save) {
|
||||
if (jmprel->nearop.opcode_len == 0) {
|
||||
cur_we->error(bc->line, N_("near jump does not exist"));
|
||||
yasm__error(bc->line, N_("near jump does not exist"));
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
}
|
||||
|
|
@ -765,7 +764,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
* it to actually be within short range).
|
||||
*/
|
||||
if (save) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("short jump out of range (near jump does not exist)"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
|
|
@ -783,7 +782,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
jrshort = 0;
|
||||
} else {
|
||||
if (save) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("short jump out of range (near jump does not exist)"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
|
|
@ -834,7 +833,7 @@ yasm_x86__bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
cur_we->internal_error(N_("Didn't handle bytecode type in x86 arch"));
|
||||
yasm_internal_error(N_("Didn't handle bytecode type in x86 arch"));
|
||||
/*@notreached@*/
|
||||
return YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
|
|
@ -863,7 +862,7 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
|
|||
YASM_WRITE_8(*bufp, 0x67);
|
||||
if (insn->rex != 0 && insn->rex != 0xff) {
|
||||
if (insn->mode_bits != 64)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("x86: got a REX prefix in non-64-bit mode"));
|
||||
YASM_WRITE_8(*bufp, insn->rex);
|
||||
}
|
||||
|
|
@ -878,14 +877,13 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
|
|||
if (ea) {
|
||||
if (x86_ea->need_modrm) {
|
||||
if (!x86_ea->valid_modrm)
|
||||
cur_we->internal_error(
|
||||
N_("invalid Mod/RM in x86 tobytes_insn"));
|
||||
yasm_internal_error(N_("invalid Mod/RM in x86 tobytes_insn"));
|
||||
YASM_WRITE_8(*bufp, x86_ea->modrm);
|
||||
}
|
||||
|
||||
if (x86_ea->need_sib) {
|
||||
if (!x86_ea->valid_sib)
|
||||
cur_we->internal_error(N_("invalid SIB in x86 tobytes_insn"));
|
||||
yasm_internal_error(N_("invalid SIB in x86 tobytes_insn"));
|
||||
YASM_WRITE_8(*bufp, x86_ea->sib);
|
||||
}
|
||||
|
||||
|
|
@ -906,7 +904,7 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
|
|||
&eat.sib, &eat.valid_sib,
|
||||
&eat.need_sib, &insn->rex,
|
||||
yasm_common_calc_bc_dist))
|
||||
cur_we->internal_error(N_("checkea failed"));
|
||||
yasm_internal_error(N_("checkea failed"));
|
||||
|
||||
if (ea->disp) {
|
||||
if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
|
||||
|
|
@ -961,7 +959,7 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
|
|||
case JR_SHORT:
|
||||
/* 1 byte relative displacement */
|
||||
if (jmprel->shortop.opcode_len == 0)
|
||||
cur_we->internal_error(N_("short jump does not exist"));
|
||||
yasm_internal_error(N_("short jump does not exist"));
|
||||
|
||||
/* Opcode */
|
||||
for (i=0; i<jmprel->shortop.opcode_len; i++)
|
||||
|
|
@ -976,7 +974,7 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
|
|||
case JR_NEAR:
|
||||
/* 2/4 byte relative displacement (depending on operand size) */
|
||||
if (jmprel->nearop.opcode_len == 0) {
|
||||
cur_we->error(bc->line, N_("near jump does not exist"));
|
||||
yasm__error(bc->line, N_("near jump does not exist"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -991,7 +989,7 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
|
|||
return 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unrecognized relative jump op_sel"));
|
||||
yasm_internal_error(N_("unrecognized relative jump op_sel"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1022,7 +1020,7 @@ yasm_x86__intnum_tobytes(const yasm_intnum *intn, unsigned char **bufp,
|
|||
if (rel) {
|
||||
long val;
|
||||
if (valsize != 1 && valsize != 2 && valsize != 4)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("tried to do PC-relative offset from invalid sized value"));
|
||||
val = yasm_intnum_get_uint(intn);
|
||||
val -= bc->len;
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ x86_expr_checkea_distcheck_reg(yasm_expr **ep)
|
|||
/* The reg expn *must* be EXPR_ADD at this point. Sanity check. */
|
||||
if (e->terms[havereg_expr].type != YASM_EXPR_EXPR ||
|
||||
e->terms[havereg_expr].data.expn->op != YASM_EXPR_ADD)
|
||||
cur_we->internal_error(N_("Register expression not ADD or EXPN"));
|
||||
yasm_internal_error(N_("Register expression not ADD or EXPN"));
|
||||
|
||||
/* Iterate over each term in reg expn */
|
||||
for (i=0; i<e->terms[havereg_expr].data.expn->numterms; i++) {
|
||||
|
|
@ -311,10 +311,10 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg,
|
|||
* Sanity check for EXPR_INT.
|
||||
*/
|
||||
if (e->terms[i].data.expn->terms[0].type != YASM_EXPR_REG)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Register not found in reg expn"));
|
||||
if (e->terms[i].data.expn->terms[1].type != YASM_EXPR_INT)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Non-integer value in reg expn"));
|
||||
reg = get_reg(&e->terms[i].data.expn->terms[0], ®num,
|
||||
data);
|
||||
|
|
@ -411,7 +411,7 @@ x86_checkea_calc_displen(yasm_expr **ep, unsigned int wordsize, int noreg,
|
|||
*/
|
||||
if (!yasm_intnum_check_size(intn, (size_t)wordsize, 0) &&
|
||||
!yasm_intnum_check_size(intn, 1, 1)) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -475,7 +475,7 @@ x86_checkea_calc_displen(yasm_expr **ep, unsigned int wordsize, int noreg,
|
|||
case 2:
|
||||
case 4:
|
||||
if (wordsize != *displen) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (displacement size)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ x86_checkea_calc_displen(yasm_expr **ep, unsigned int wordsize, int noreg,
|
|||
break;
|
||||
default:
|
||||
/* we shouldn't ever get any other size! */
|
||||
cur_we->internal_error(N_("strange EA displacement size"));
|
||||
yasm_internal_error(N_("strange EA displacement size"));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -547,7 +547,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
* otherwise illegal. It's also illegal in non-64-bit mode.
|
||||
*/
|
||||
if (*n_modrm || *n_sib) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (displacement size)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -609,7 +609,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
|
||||
/* We can only do 64-bit addresses in 64-bit mode. */
|
||||
if (*addrsize == 64 && bits != 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (64-bit in non-64-bit mode)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -622,7 +622,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
calc_bc_dist)) {
|
||||
case 0:
|
||||
e = *ep;
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
|
|
@ -644,7 +644,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
*/
|
||||
for (i=0; i<17; i++) {
|
||||
if (reg3264mult[i] < 0) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
if (i != indexreg && reg3264mult[i] == 1 &&
|
||||
|
|
@ -686,7 +686,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
*/
|
||||
for (i=0; i<17; i++)
|
||||
if (i != basereg && i != indexreg && reg3264mult[i] != 0) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -694,7 +694,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
if (indexreg != REG3264_NONE && reg3264mult[indexreg] != 1 &&
|
||||
reg3264mult[indexreg] != 2 && reg3264mult[indexreg] != 4 &&
|
||||
reg3264mult[indexreg] != 8) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -704,7 +704,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
* legal.
|
||||
*/
|
||||
if (reg3264mult[REG3264_ESP] > 1 || basereg == REG3264_ESP) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
/* If mult==1 and basereg is not ESP, swap indexreg w/basereg. */
|
||||
|
|
@ -715,7 +715,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
/* RIP is only legal if it's the ONLY register used. */
|
||||
if (indexreg == REG64_RIP ||
|
||||
(basereg == REG64_RIP && indexreg != REG3264_NONE)) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -752,7 +752,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
*/
|
||||
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
|
||||
bits, X86_REX_B)) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid combination of operands and effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -781,7 +781,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
else {
|
||||
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
|
||||
bits, X86_REX_B)) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid combination of operands and effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
if (yasm_x86__set_rex_from_reg(rex, &low3,
|
||||
X86_REG64 | indexreg, bits,
|
||||
X86_REX_X)) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid combination of operands and effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -842,7 +842,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
|
||||
/* 64-bit mode does not allow 16-bit addresses */
|
||||
if (bits == 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("16-bit addresses not supported in 64-bit mode"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -857,7 +857,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
calc_bc_dist)) {
|
||||
case 0:
|
||||
e = *ep;
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
|
|
@ -869,7 +869,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
/* reg multipliers not 0 or 1 are illegal. */
|
||||
if (reg16mult.bx & ~1 || reg16mult.si & ~1 || reg16mult.di & ~1 ||
|
||||
reg16mult.bp & ~1) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
|
||||
/* Check the modrm value for invalid combinations. */
|
||||
if (modrm16[havereg] & 0070) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -901,7 +901,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
switch (*addrsize) {
|
||||
case 64:
|
||||
if (bits != 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (64-bit in non-64-bit mode)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -913,7 +913,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
case 16:
|
||||
/* 64-bit mode does not allow 16-bit addresses */
|
||||
if (bits == 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("16-bit addresses not supported in 64-bit mode"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -931,17 +931,17 @@ yasm_x86__floatnum_tobytes(const yasm_floatnum *flt, unsigned char **bufp,
|
|||
int fltret;
|
||||
|
||||
if (!yasm_floatnum_check_size(flt, (size_t)valsize)) {
|
||||
cur_we->error(e->line, N_("invalid floating point constant size"));
|
||||
yasm__error(e->line, N_("invalid floating point constant size"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
fltret = yasm_floatnum_get_sized(flt, *bufp, (size_t)valsize);
|
||||
if (fltret < 0) {
|
||||
cur_we->error(e->line, N_("underflow in floating point expression"));
|
||||
yasm__error(e->line, N_("underflow in floating point expression"));
|
||||
return 1;
|
||||
}
|
||||
if (fltret > 0) {
|
||||
cur_we->error(e->line, N_("overflow in floating point expression"));
|
||||
yasm__error(e->line, N_("overflow in floating point expression"));
|
||||
return 1;
|
||||
}
|
||||
*bufp += valsize;
|
||||
|
|
|
|||
|
|
@ -1537,7 +1537,7 @@ x86_new_jmprel(const unsigned long data[4], int num_operands,
|
|||
/* We know the target is in operand 0, but sanity check for Imm. */
|
||||
op = yasm_ops_first(operands);
|
||||
if (op->type != YASM_INSN__OPERAND_IMM)
|
||||
cur_we->internal_error(N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
d.target = yasm_expr_new(YASM_EXPR_SUB, yasm_expr_expr(op->data.val),
|
||||
yasm_expr_sym(yasm_symrec_define_label("$", cur_section, prev_bc,
|
||||
0, lindex)), lindex);
|
||||
|
|
@ -1820,7 +1820,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
mismatch = 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("invalid operand type"));
|
||||
yasm_internal_error(N_("invalid operand type"));
|
||||
}
|
||||
|
||||
if (mismatch)
|
||||
|
|
@ -1870,7 +1870,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
mismatch = 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("invalid target modifier type"));
|
||||
yasm_internal_error(N_("invalid target modifier type"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1882,8 +1882,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
|
||||
if (!found) {
|
||||
/* Didn't find a matching one */
|
||||
cur_we->error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
yasm__error(lindex, N_("invalid combination of opcode and operands"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1895,25 +1894,23 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
case MOD_ExtErr:
|
||||
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
|
||||
case 0:
|
||||
cur_we->error(lindex, N_("mismatch in operand sizes"));
|
||||
yasm__error(lindex, N_("mismatch in operand sizes"));
|
||||
break;
|
||||
case 1:
|
||||
cur_we->error(lindex, N_("operand size not specified"));
|
||||
yasm__error(lindex, N_("operand size not specified"));
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
N_("unrecognized x86 ext mod index"));
|
||||
yasm_internal_error(N_("unrecognized x86 ext mod index"));
|
||||
}
|
||||
return NULL; /* It was an error */
|
||||
case MOD_ExtWarn:
|
||||
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
N_("unrecognized x86 ext mod index"));
|
||||
yasm_internal_error(N_("unrecognized x86 ext mod index"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unrecognized x86 extended modifier"));
|
||||
yasm_internal_error(N_("unrecognized x86 extended modifier"));
|
||||
}
|
||||
|
||||
/* Shortcut to JmpRel */
|
||||
|
|
@ -1996,7 +1993,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
yasm_x86_LTX_mode_bits);
|
||||
break;
|
||||
case YASM_INSN__OPERAND_SEGREG:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
case YASM_INSN__OPERAND_MEMORY:
|
||||
d.ea = op->data.ea;
|
||||
|
|
@ -2017,8 +2014,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
d.im_len = size_lookup[(info->operands[i] &
|
||||
OPS_MASK)>>OPS_SHIFT];
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_SImm:
|
||||
if (op->type == YASM_INSN__OPERAND_IMM) {
|
||||
|
|
@ -2027,8 +2023,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
OPS_MASK)>>OPS_SHIFT];
|
||||
d.im_sign = 1;
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_Spare:
|
||||
if (op->type == YASM_INSN__OPERAND_SEGREG)
|
||||
|
|
@ -2037,13 +2032,12 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
if (yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
|
||||
op->data.reg, yasm_x86_LTX_mode_bits,
|
||||
X86_REX_R)) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_Op0Add:
|
||||
if (op->type == YASM_INSN__OPERAND_REG) {
|
||||
|
|
@ -2051,22 +2045,20 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
if (yasm_x86__set_rex_from_reg(&d.rex, &opadd,
|
||||
op->data.reg, yasm_x86_LTX_mode_bits,
|
||||
X86_REX_B)) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
return NULL;
|
||||
}
|
||||
d.op[0] += opadd;
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_Op1Add:
|
||||
/* Op1Add is only used for FPU, so no need to do REX */
|
||||
if (op->type == YASM_INSN__OPERAND_REG)
|
||||
d.op[1] += (unsigned char)(op->data.reg&7);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_SpareEA:
|
||||
if (op->type == YASM_INSN__OPERAND_REG) {
|
||||
|
|
@ -2076,18 +2068,17 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
|
||||
op->data.reg, yasm_x86_LTX_mode_bits,
|
||||
X86_REX_R)) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
if (d.ea)
|
||||
xfree(d.ea);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown operand action"));
|
||||
yasm_internal_error(N_("unknown operand action"));
|
||||
}
|
||||
|
||||
switch (info->operands[i] & OPAP_MASK) {
|
||||
|
|
@ -2100,7 +2091,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
d.signext_imm8_op = 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("unknown operand postponed action"));
|
||||
}
|
||||
}
|
||||
|
|
@ -2258,13 +2249,13 @@ yasm_x86__switch_cpu(const char *id, unsigned long lindex)
|
|||
|
||||
/* catchalls */
|
||||
[\001-\377]+ {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
return;
|
||||
}
|
||||
[\000] {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
|
@ -2308,8 +2299,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
O "64" {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_OPERSIZE;
|
||||
|
|
@ -2319,7 +2310,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* address size overrides */
|
||||
A "16" {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("Cannot override address size to 16 bits in 64-bit mode"));
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
|
|
@ -2334,8 +2325,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
A "64" {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_ADDRSIZE;
|
||||
|
|
@ -2378,8 +2369,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* control, debug, and test registers */
|
||||
C R [02-48] {
|
||||
if (yasm_x86_LTX_mode_bits != 64 && oid[2] == '8') {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_CRREG | (oid[2]-'0');
|
||||
|
|
@ -2406,8 +2397,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
X M M [0-9] {
|
||||
if (yasm_x86_LTX_mode_bits != 64 &&
|
||||
(oid[3] == '8' || oid[3] == '9')) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_XMMREG | (oid[3]-'0');
|
||||
|
|
@ -2415,8 +2406,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
X M M "1" [0-5] {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | (10+oid[4]-'0');
|
||||
|
|
@ -2426,8 +2417,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* integer registers */
|
||||
R A X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 0;
|
||||
|
|
@ -2435,8 +2426,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R C X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 1;
|
||||
|
|
@ -2444,8 +2435,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R D X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 2;
|
||||
|
|
@ -2453,8 +2444,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R B X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 3;
|
||||
|
|
@ -2462,8 +2453,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R S P {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 4;
|
||||
|
|
@ -2471,8 +2462,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R B P {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 5;
|
||||
|
|
@ -2480,8 +2471,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R S I {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 6;
|
||||
|
|
@ -2489,8 +2480,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R D I {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 7;
|
||||
|
|
@ -2498,8 +2489,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R [8-9] {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | (oid[1]-'0');
|
||||
|
|
@ -2507,8 +2498,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | (10+oid[2]-'0');
|
||||
|
|
@ -2525,8 +2516,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
E D I { data[0] = X86_REG32 | 7; return YASM_ARCH_CHECK_ID_REG; }
|
||||
R [8-9] D {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG32 | (oid[1]-'0');
|
||||
|
|
@ -2534,8 +2525,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] D {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG32 | (10+oid[2]-'0');
|
||||
|
|
@ -2552,8 +2543,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
D I { data[0] = X86_REG16 | 7; return YASM_ARCH_CHECK_ID_REG; }
|
||||
R [8-9] W {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG16 | (oid[1]-'0');
|
||||
|
|
@ -2561,8 +2552,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] W {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG16 | (10+oid[2]-'0');
|
||||
|
|
@ -2579,8 +2570,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
B H { data[0] = X86_REG8 | 7; return YASM_ARCH_CHECK_ID_REG; }
|
||||
S P L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 4;
|
||||
|
|
@ -2588,8 +2579,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
B P L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 5;
|
||||
|
|
@ -2597,8 +2588,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
S I L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 6;
|
||||
|
|
@ -2606,8 +2597,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
D I L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 7;
|
||||
|
|
@ -2615,8 +2606,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R [8-9] B {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8 | (oid[1]-'0');
|
||||
|
|
@ -2624,8 +2615,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] B {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8 | (10+oid[2]-'0');
|
||||
|
|
@ -2635,7 +2626,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* segment registers */
|
||||
E S {
|
||||
if (yasm_x86_LTX_mode_bits == 64)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' segment register ignored in 64-bit mode"), oid);
|
||||
data[0] = 0x2600;
|
||||
return YASM_ARCH_CHECK_ID_SEGREG;
|
||||
|
|
@ -2643,14 +2634,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C S { data[0] = 0x2e01; return YASM_ARCH_CHECK_ID_SEGREG; }
|
||||
S S {
|
||||
if (yasm_x86_LTX_mode_bits == 64)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' segment register ignored in 64-bit mode"), oid);
|
||||
data[0] = 0x3602;
|
||||
return YASM_ARCH_CHECK_ID_SEGREG;
|
||||
}
|
||||
D S {
|
||||
if (yasm_x86_LTX_mode_bits == 64)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' segment register ignored in 64-bit mode"), oid);
|
||||
data[0] = 0x3e03;
|
||||
return YASM_ARCH_CHECK_ID_SEGREG;
|
||||
|
|
@ -2661,8 +2652,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* RIP for 64-bit mode IP-relative offsets */
|
||||
R I P {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_RIP;
|
||||
|
|
@ -2677,9 +2668,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
M O V S X { RET_INSN(movszx, 0xBE, CPU_386); }
|
||||
M O V S X D {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(movsxd, 0, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2689,21 +2680,21 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P U S H { RET_INSN(push, 0, CPU_Any); }
|
||||
P U S H A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0060, CPU_186);
|
||||
}
|
||||
P U S H A D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x2060, CPU_386);
|
||||
}
|
||||
P U S H A W {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x1060, CPU_186);
|
||||
|
|
@ -2712,21 +2703,21 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P O P { RET_INSN(pop, 0, CPU_Any); }
|
||||
P O P A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0061, CPU_186);
|
||||
}
|
||||
P O P A D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x2061, CPU_386);
|
||||
}
|
||||
P O P A W {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x1061, CPU_186);
|
||||
|
|
@ -2741,14 +2732,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* Load segment registers from memory */
|
||||
L D S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(ldes, 0xC5, CPU_Any);
|
||||
}
|
||||
L E S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(ldes, 0xC4, CPU_Any);
|
||||
|
|
@ -2764,14 +2755,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C M C { RET_INSN(onebyte, 0x00F5, CPU_Any); }
|
||||
L A H F {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x009F, CPU_Any);
|
||||
}
|
||||
S A H F {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x009E, CPU_Any);
|
||||
|
|
@ -2781,9 +2772,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P U S H F W { RET_INSN(onebyte, 0x109C, CPU_Any); }
|
||||
P U S H F Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x409C, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2793,9 +2784,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P O P F W { RET_INSN(onebyte, 0x109D, CPU_Any); }
|
||||
P O P F Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x409D, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2819,42 +2810,42 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
N O T { RET_INSN(f6, 0x02, CPU_Any); }
|
||||
A A A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0037, CPU_Any);
|
||||
}
|
||||
A A S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x003F, CPU_Any);
|
||||
}
|
||||
D A A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0027, CPU_Any);
|
||||
}
|
||||
D A S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x002F, CPU_Any);
|
||||
}
|
||||
A A D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(aadm, 0x01, CPU_Any);
|
||||
}
|
||||
A A M {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(aadm, 0x00, CPU_Any);
|
||||
|
|
@ -2864,9 +2855,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C W D E { RET_INSN(onebyte, 0x2098, CPU_386); }
|
||||
C D Q E {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x4098, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2875,9 +2866,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C D Q { RET_INSN(onebyte, 0x2099, CPU_386); }
|
||||
C D O {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x4099, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2941,9 +2932,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
J E C X Z { RET_INSN(jcxz, 32, CPU_386); }
|
||||
J R C X Z {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(jcxz, 64, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2991,9 +2982,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C M P S D { RET_INSN(cmpsd, 0, CPU_Any); }
|
||||
C M P S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40A7, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3009,9 +3000,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
L O D S D { RET_INSN(onebyte, 0x20AD, CPU_386); }
|
||||
L O D S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40AD, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3021,9 +3012,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
M O V S D { RET_INSN(movsd, 0, CPU_Any); }
|
||||
M O V S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40A5, CPU_Any);
|
||||
|
|
@ -3033,9 +3024,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
S C A S D { RET_INSN(onebyte, 0x20AF, CPU_386); }
|
||||
S C A S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40AF, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3045,9 +3036,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
S T O S D { RET_INSN(onebyte, 0x20AB, CPU_386); }
|
||||
S T O S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40AB, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3066,7 +3057,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
I N T "03" { RET_INSN(onebyte, 0x00CC, CPU_Any); }
|
||||
I N T O {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x00CE, CPU_Any);
|
||||
|
|
@ -3076,9 +3067,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
I R E T D { RET_INSN(onebyte, 0x20CF, CPU_386); }
|
||||
I R E T Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40CF, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3086,7 +3077,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
R S M { RET_INSN(twobyte, 0x0FAA, CPU_586|CPU_SMM); }
|
||||
B O U N D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(bound, 0, CPU_186);
|
||||
|
|
@ -3096,7 +3087,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* Protection control */
|
||||
A R P L {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(arpl, 0, CPU_286|CPU_Prot);
|
||||
|
|
@ -3217,14 +3208,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* Pentium II/Pentium Pro extensions */
|
||||
S Y S E N T E R {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(twobyte, 0x0F34, CPU_686);
|
||||
}
|
||||
S Y S E X I T {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(twobyte, 0x0F35, CPU_686|CPU_Priv);
|
||||
|
|
@ -3527,9 +3518,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* AMD x86-64 extensions */
|
||||
S W A P G S {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(threebyte, 0x0F01F8, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3565,7 +3556,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
L O A D A L L "286" { RET_INSN(twobyte, 0x0F05, CPU_286|CPU_Undoc); }
|
||||
S A L C {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x00D6, CPU_Undoc);
|
||||
|
|
|
|||
|
|
@ -49,17 +49,14 @@
|
|||
|
||||
yasm_objfmt yasm_bin_LTX_objfmt;
|
||||
static /*@dependent@*/ yasm_arch *cur_arch;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
static void
|
||||
bin_objfmt_initialize(/*@unused@*/ const char *in_filename,
|
||||
/*@unused@*/ const char *obj_filename,
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
|
||||
yasm_errwarn *we)
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
|
||||
{
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
}
|
||||
|
||||
/* Aligns sect to either its specified alignment (in its objfmt-specific data)
|
||||
|
|
@ -174,13 +171,12 @@ bin_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
|
||||
/* Check for complex float expressions */
|
||||
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
|
||||
cur_we->error((*ep)->line,
|
||||
N_("floating point expression too complex"));
|
||||
yasm__error((*ep)->line, N_("floating point expression too complex"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Couldn't output, assume it contains an external reference. */
|
||||
cur_we->error((*ep)->line,
|
||||
yasm__error((*ep)->line,
|
||||
N_("binary object format does not support external references"));
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -210,7 +206,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Warn that gaps are converted to 0 and write out the 0's. */
|
||||
if (gap) {
|
||||
unsigned long left;
|
||||
cur_we->warning(YASM_WARN_GENERAL, bc->line,
|
||||
yasm__warning(YASM_WARN_GENERAL, bc->line,
|
||||
N_("uninitialized space declared in code/data section: zeroing"));
|
||||
/* Write out in chunks */
|
||||
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
|
||||
|
|
@ -253,7 +249,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
bss = yasm_sections_find_general(sections, ".bss");
|
||||
|
||||
if (!text)
|
||||
cur_we->internal_error(N_("No `.text' section in bin objfmt output"));
|
||||
yasm_internal_error(N_("No `.text' section in bin objfmt output"));
|
||||
|
||||
/* First determine the actual starting offsets for .data and .bss.
|
||||
* As the order in the file is .text -> .data -> .bss (not present),
|
||||
|
|
@ -267,8 +263,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
assert(startexpr != NULL);
|
||||
startnum = yasm_expr_get_intnum(&startexpr, NULL);
|
||||
if (!startnum)
|
||||
cur_we->internal_error(
|
||||
N_("Complex expr for start in bin objfmt output"));
|
||||
yasm_internal_error(N_("Complex expr for start in bin objfmt output"));
|
||||
start = yasm_intnum_get_uint(startnum);
|
||||
yasm_expr_delete(startexpr);
|
||||
textstart = start;
|
||||
|
|
@ -354,8 +349,8 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
resonly = 1;
|
||||
} else {
|
||||
/* other section names not recognized. */
|
||||
cur_we->error(lindex, N_("segment name `%s' not recognized"),
|
||||
sectname);
|
||||
yasm__error(lindex, N_("segment name `%s' not recognized"),
|
||||
sectname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +361,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
unsigned long bitcnt;
|
||||
|
||||
if (strcmp(sectname, ".text") == 0) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("cannot specify an alignment to the `%s' section"),
|
||||
sectname);
|
||||
return NULL;
|
||||
|
|
@ -374,9 +369,9 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
align = yasm_expr_get_intnum(&vp->param, NULL);
|
||||
if (!align) {
|
||||
cur_we->error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
yasm__error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
return NULL;
|
||||
}
|
||||
alignval = yasm_intnum_get_uint(align);
|
||||
|
|
@ -386,9 +381,9 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
*/
|
||||
BitCount(bitcnt, alignval);
|
||||
if (bitcnt > 1) {
|
||||
cur_we->error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
yasm__error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -397,8 +392,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
}
|
||||
|
||||
retval = yasm_sections_switch_general(headp, sectname, start, resonly,
|
||||
&isnew, lindex,
|
||||
cur_we->internal_error_);
|
||||
&isnew, lindex);
|
||||
|
||||
if (isnew) {
|
||||
if (have_alignval) {
|
||||
|
|
@ -410,7 +404,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
yasm_symrec_define_label(sectname, retval, (yasm_bytecode *)NULL,
|
||||
1, lindex);
|
||||
} else if (have_alignval)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("alignment value ignored on section redeclaration"));
|
||||
|
||||
return retval;
|
||||
|
|
@ -431,7 +425,7 @@ bin_objfmt_common_declare(/*@unused@*/ yasm_symrec *sym,
|
|||
unsigned long lindex)
|
||||
{
|
||||
yasm_expr_delete(size);
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("binary object format does not support common variables"));
|
||||
}
|
||||
|
||||
|
|
@ -450,20 +444,20 @@ bin_objfmt_directive(const char *name, yasm_valparamhead *valparams,
|
|||
/* ORG takes just a simple integer as param */
|
||||
vp = yasm_vps_first(valparams);
|
||||
if (vp->val) {
|
||||
cur_we->error(lindex, N_("argument to ORG should be numeric"));
|
||||
yasm__error(lindex, N_("argument to ORG should be numeric"));
|
||||
return 0;
|
||||
} else if (vp->param)
|
||||
start = yasm_expr_get_intnum(&vp->param, NULL);
|
||||
|
||||
if (!start) {
|
||||
cur_we->error(lindex, N_("argument to ORG should be numeric"));
|
||||
yasm__error(lindex, N_("argument to ORG should be numeric"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ORG changes the start of the .text section */
|
||||
sect = yasm_sections_find_general(headp, ".text");
|
||||
if (!sect)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("bin objfmt: .text section does not exist before ORG is called?"));
|
||||
yasm_section_set_start(sect, yasm_intnum_get_uint(start), lindex);
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ static coff_symtab_head coff_symtab; /* symbol table of indexed syms */
|
|||
|
||||
yasm_objfmt yasm_coff_LTX_objfmt;
|
||||
static /*@dependent@*/ yasm_arch *cur_arch;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
static /*@dependent@*/ coff_symtab_entry *
|
||||
|
|
@ -176,7 +175,7 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
|
|||
coff_symtab_entry *entry;
|
||||
|
||||
if (STAILQ_EMPTY(&coff_symtab))
|
||||
cur_we->internal_error(N_("empty COFF symbol table"));
|
||||
yasm_internal_error(N_("empty COFF symbol table"));
|
||||
entry = STAILQ_LAST(&coff_symtab, coff_symtab_entry, link);
|
||||
sym_data_prev = yasm_symrec_get_of_data(entry->sym);
|
||||
assert(sym_data_prev != NULL);
|
||||
|
|
@ -200,15 +199,13 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
|
|||
static void
|
||||
coff_objfmt_initialize(const char *in_filename,
|
||||
/*@unused@*/ const char *obj_filename,
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
|
||||
yasm_errwarn *we)
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
|
||||
{
|
||||
yasm_symrec *filesym;
|
||||
coff_symrec_data *data;
|
||||
coff_symtab_entry *entry;
|
||||
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
|
||||
coff_objfmt_parse_scnum = 1; /* section numbering starts at 1 */
|
||||
STAILQ_INIT(&coff_symtab);
|
||||
|
|
@ -281,7 +278,7 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
yasm_sym_vis vis;
|
||||
|
||||
if (valsize != 4) {
|
||||
cur_we->error((*ep)->line, N_("coff: invalid relocation size"));
|
||||
yasm__error((*ep)->line, N_("coff: invalid relocation size"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -334,12 +331,11 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
|
||||
/* Check for complex float expressions */
|
||||
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
|
||||
cur_we->error((*ep)->line,
|
||||
N_("floating point expression too complex"));
|
||||
yasm__error((*ep)->line, N_("floating point expression too complex"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
cur_we->error((*ep)->line, N_("coff: relocation too complex"));
|
||||
yasm__error((*ep)->line, N_("coff: relocation too complex"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +366,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Warn that gaps are converted to 0 and write out the 0's. */
|
||||
if (gap) {
|
||||
unsigned long left;
|
||||
cur_we->warning(YASM_WARN_GENERAL, bc->line,
|
||||
yasm__warning(YASM_WARN_GENERAL, bc->line,
|
||||
N_("uninitialized space declared in code/data section: zeroing"));
|
||||
/* Write out in chunks */
|
||||
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
|
||||
|
|
@ -424,7 +420,7 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
|
|||
} else {
|
||||
pos = ftell(info->f);
|
||||
if (pos == -1) {
|
||||
cur_we->error(0, N_("could not get file position on output file"));
|
||||
yasm__error(0, N_("could not get file position on output file"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +443,7 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
|
|||
|
||||
pos = ftell(info->f);
|
||||
if (pos == -1) {
|
||||
cur_we->error(0, N_("could not get file position on output file"));
|
||||
yasm__error(0, N_("could not get file position on output file"));
|
||||
return 1;
|
||||
}
|
||||
csd->relptr = (unsigned long)pos;
|
||||
|
|
@ -458,7 +454,7 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
|
|||
|
||||
csymd = yasm_symrec_get_of_data(reloc->sym);
|
||||
if (!csymd)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("coff: no symbol data for relocated symbol"));
|
||||
|
||||
YASM_WRITE_32_L(localbuf, reloc->addr); /* address of relocation */
|
||||
|
|
@ -498,9 +494,9 @@ coff_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d)
|
|||
YASM_WRITE_32_L(localbuf, csd->relptr); /* file ptr to relocs */
|
||||
YASM_WRITE_32_L(localbuf, 0); /* file ptr to line nums */
|
||||
if (csd->nreloc >= 64*1024) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, 0,
|
||||
N_("too many relocations in section `%s'"),
|
||||
yasm_section_get_name(sect));
|
||||
yasm__warning(YASM_WARN_GENERAL, 0,
|
||||
N_("too many relocations in section `%s'"),
|
||||
yasm_section_get_name(sect));
|
||||
YASM_WRITE_16_L(localbuf, 0xFFFF); /* max out */
|
||||
} else
|
||||
YASM_WRITE_16_L(localbuf, csd->nreloc); /* num of relocation entries */
|
||||
|
|
@ -527,7 +523,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
|
||||
/* Allocate space for headers by seeking forward */
|
||||
if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
|
||||
cur_we->error(0, N_("could not seek on output file"));
|
||||
yasm__error(0, N_("could not seek on output file"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -550,7 +546,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
/* Symbol table */
|
||||
pos = ftell(f);
|
||||
if (pos == -1) {
|
||||
cur_we->error(0, N_("could not get file position on output file"));
|
||||
yasm__error(0, N_("could not get file position on output file"));
|
||||
return;
|
||||
}
|
||||
symtab_pos = (unsigned long)pos;
|
||||
|
|
@ -569,8 +565,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
/* Get symrec's of_data (needed for storage class) */
|
||||
csymd = yasm_symrec_get_of_data(entry->sym);
|
||||
if (!csymd)
|
||||
cur_we->internal_error(
|
||||
N_("coff: expected sym data to be present"));
|
||||
yasm_internal_error(N_("coff: expected sym data to be present"));
|
||||
|
||||
/* Look at symrec for value/scnum/etc. */
|
||||
if (yasm_symrec_get_label(entry->sym, §, &precbc)) {
|
||||
|
|
@ -595,7 +590,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
intn = yasm_expr_get_intnum(&csymd->size,
|
||||
yasm_common_calc_bc_dist);
|
||||
if (!intn)
|
||||
cur_we->error(csymd->size->line,
|
||||
yasm__error(csymd->size->line,
|
||||
N_("COMMON data size not an integer expression"));
|
||||
else
|
||||
value = yasm_intnum_get_uint(intn);
|
||||
|
|
@ -642,7 +637,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
strncpy((char *)localbuf, entry->aux[0].fname, 14);
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("coff: unrecognized aux symtab type"));
|
||||
}
|
||||
fwrite(info.buf, 18, 1, f);
|
||||
|
|
@ -675,7 +670,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
|
||||
/* Write headers */
|
||||
if (fseek(f, 0, SEEK_SET) < 0) {
|
||||
cur_we->error(0, N_("could not seek on output file"));
|
||||
yasm__error(0, N_("could not seek on output file"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -730,7 +725,7 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
sectname = vp->val;
|
||||
if (strlen(sectname) > 8) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("COFF section names limited to 8 characters: truncating"));
|
||||
sectname[8] = '\0';
|
||||
}
|
||||
|
|
@ -759,7 +754,7 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
}
|
||||
|
||||
retval = yasm_sections_switch_general(headp, sectname, 0, resonly, &isnew,
|
||||
lindex, cur_we->internal_error_);
|
||||
lindex);
|
||||
|
||||
if (isnew) {
|
||||
coff_section_data *data;
|
||||
|
|
@ -782,8 +777,8 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
COFF_SYMTAB_AUX_SECT);
|
||||
data->sym = sym;
|
||||
} else if (flags_override)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("section flags ignored on section redeclaration"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("section flags ignored on section redeclaration"));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,14 +51,11 @@ yasm_objfmt yasm_dbg_LTX_objfmt;
|
|||
*/
|
||||
static FILE *dbg_objfmt_file;
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
static void
|
||||
dbg_objfmt_initialize(const char *in_filename, const char *obj_filename,
|
||||
yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we)
|
||||
yasm_dbgfmt *df, yasm_arch *a)
|
||||
{
|
||||
cur_we = we;
|
||||
|
||||
dbg_objfmt_file = fopen(obj_filename, "wt");
|
||||
if (!dbg_objfmt_file) {
|
||||
fprintf(stderr, N_("could not open file `%s'"), obj_filename);
|
||||
|
|
@ -104,7 +101,7 @@ dbg_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
if ((vp = yasm_vps_first(valparams)) && !vp->param && vp->val != NULL) {
|
||||
retval = yasm_sections_switch_general(headp, vp->val, 200, 0, &isnew,
|
||||
lindex, cur_we->internal_error_);
|
||||
lindex);
|
||||
if (isnew) {
|
||||
fprintf(dbg_objfmt_file, "(new) ");
|
||||
yasm_symrec_define_label(vp->val, retval, (yasm_bytecode *)NULL, 1,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
#define BCFLAG_INPROGRESS (1UL<<0)
|
||||
#define BCFLAG_DONE (1UL<<1)
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
static int basic_optimize_section_1(yasm_section *sect,
|
||||
/*@unused@*/ /*@null@*/ void *d);
|
||||
|
|
@ -138,7 +137,7 @@ basic_optimize_bytecode_1(/*@observer@*/ yasm_bytecode *bc, void *d)
|
|||
basic_optimize_calc_bc_dist_1);
|
||||
if (bcr_retval & YASM_BC_RESOLVE_UNKNOWN_LEN) {
|
||||
if (!(bcr_retval & YASM_BC_RESOLVE_ERROR))
|
||||
cur_we->error(bc->line, N_("circular reference detected."));
|
||||
yasm__error(bc->line, N_("circular reference detected."));
|
||||
data->saw_unknown = -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -190,7 +189,7 @@ basic_optimize_bytecode_2(/*@observer@*/ yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
assert(data != NULL);
|
||||
|
||||
if (bc->opt_flags != BCFLAG_DONE)
|
||||
cur_we->internal_error(N_("Optimizer pass 1 missed a bytecode!"));
|
||||
yasm_internal_error(N_("Optimizer pass 1 missed a bytecode!"));
|
||||
|
||||
if (!data->precbc)
|
||||
bc->offset = 0;
|
||||
|
|
@ -212,19 +211,17 @@ basic_optimize_section_2(yasm_section *sect, /*@unused@*/ /*@null@*/ void *d)
|
|||
data.sect = sect;
|
||||
|
||||
if (yasm_section_get_opt_flags(sect) != SECTFLAG_DONE)
|
||||
cur_we->internal_error(N_("Optimizer pass 1 missed a section!"));
|
||||
yasm_internal_error(N_("Optimizer pass 1 missed a section!"));
|
||||
|
||||
return yasm_bcs_traverse(yasm_section_get_bytecodes(sect), &data,
|
||||
basic_optimize_bytecode_2);
|
||||
}
|
||||
|
||||
static void
|
||||
basic_optimize(yasm_sectionhead *sections, yasm_errwarn *we)
|
||||
basic_optimize(yasm_sectionhead *sections)
|
||||
{
|
||||
int saw_unknown = 0;
|
||||
|
||||
cur_we = we;
|
||||
|
||||
/* Optimization process: (essentially NASM's pass 1)
|
||||
* Determine the size of all bytecodes.
|
||||
* Forward references are /not/ resolved (only backward references are
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ line: '\n' { $$ = (yasm_bytecode *)NULL; }
|
|||
$$ = (yasm_bytecode *)NULL;
|
||||
}
|
||||
| error '\n' {
|
||||
cur_we->error(cur_lindex,
|
||||
N_("label or instruction expected at start of line"));
|
||||
yasm__error(cur_lindex,
|
||||
N_("label or instruction expected at start of line"));
|
||||
$$ = (yasm_bytecode *)NULL;
|
||||
yyerrok;
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ instr: INSN {
|
|||
yasm_ops_delete(&$2.operands, 0);
|
||||
}
|
||||
| INSN error {
|
||||
cur_we->error(cur_lindex, N_("expression syntax error"));
|
||||
yasm__error(cur_lindex, N_("expression syntax error"));
|
||||
$$ = NULL;
|
||||
}
|
||||
| PREFIX instr {
|
||||
|
|
@ -228,7 +228,7 @@ datavals: dataval {
|
|||
dataval: dvexpr { $$ = yasm_dv_new_expr($1); }
|
||||
| STRING { $$ = yasm_dv_new_string($1); }
|
||||
| error {
|
||||
cur_we->error(cur_lindex, N_("expression syntax error"));
|
||||
yasm__error(cur_lindex, N_("expression syntax error"));
|
||||
$$ = (yasm_dataval *)NULL;
|
||||
}
|
||||
;
|
||||
|
|
@ -268,7 +268,7 @@ directive: DIRECTIVE_NAME directive_val {
|
|||
xfree($1);
|
||||
}
|
||||
| DIRECTIVE_NAME error {
|
||||
cur_we->error(cur_lindex, N_("invalid arguments to [%s]"), $1);
|
||||
yasm__error(cur_lindex, N_("invalid arguments to [%s]"), $1);
|
||||
xfree($1);
|
||||
}
|
||||
;
|
||||
|
|
@ -353,7 +353,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 1)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 1;
|
||||
}
|
||||
|
|
@ -361,7 +361,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 2)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 2;
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 4)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 4;
|
||||
}
|
||||
|
|
@ -377,7 +377,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 8)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 8;
|
||||
}
|
||||
|
|
@ -385,7 +385,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 10)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 10;
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 16)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 16;
|
||||
}
|
||||
|
|
@ -558,7 +558,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_objfmt->extern_declare(sym, objext_valparams,
|
||||
lindex);
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "EXTERN");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "EXTERN");
|
||||
} else if (yasm__strcasecmp(name, "global") == 0) {
|
||||
vp = yasm_vps_first(valparams);
|
||||
if (vp->val) {
|
||||
|
|
@ -567,15 +567,14 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_objfmt->global_declare(sym, objext_valparams,
|
||||
lindex);
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
|
||||
} else if (yasm__strcasecmp(name, "common") == 0) {
|
||||
vp = yasm_vps_first(valparams);
|
||||
if (vp->val) {
|
||||
vp2 = yasm_vps_next(vp);
|
||||
if (!vp2 || (!vp2->val && !vp2->param))
|
||||
cur_we->error(lindex,
|
||||
N_("no size specified in %s declaration"),
|
||||
"COMMON");
|
||||
yasm__error(lindex, N_("no size specified in %s declaration"),
|
||||
"COMMON");
|
||||
else {
|
||||
if (vp2->val) {
|
||||
sym = yasm_symrec_declare(vp->val, YASM_SYM_COMMON,
|
||||
|
|
@ -596,7 +595,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
}
|
||||
}
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "COMMON");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "COMMON");
|
||||
} else if (yasm__strcasecmp(name, "section") == 0 ||
|
||||
yasm__strcasecmp(name, "segment") == 0) {
|
||||
yasm_section *new_section =
|
||||
|
|
@ -608,7 +607,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_prev_bc =
|
||||
yasm_bcs_last(yasm_section_get_bytecodes(new_section));
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "SECTION");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "SECTION");
|
||||
} else if (yasm__strcasecmp(name, "absolute") == 0) {
|
||||
/* it can be just an ID or a complete expression, so handle both. */
|
||||
vp = yasm_vps_first(valparams);
|
||||
|
|
@ -616,12 +615,11 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_cur_section =
|
||||
yasm_sections_switch_absolute(&nasm_parser_sections,
|
||||
p_expr_new_ident(yasm_expr_sym(
|
||||
yasm_symrec_use(vp->val, lindex))),
|
||||
cur_we->internal_error_);
|
||||
yasm_symrec_use(vp->val, lindex))));
|
||||
else if (vp->param) {
|
||||
nasm_parser_cur_section =
|
||||
yasm_sections_switch_absolute(&nasm_parser_sections, vp->param,
|
||||
cur_we->internal_error_);
|
||||
yasm_sections_switch_absolute(&nasm_parser_sections,
|
||||
vp->param);
|
||||
vp->param = NULL;
|
||||
}
|
||||
nasm_parser_prev_bc = (yasm_bytecode *)NULL;
|
||||
|
|
@ -633,8 +631,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
const yasm_intnum *intcpu;
|
||||
intcpu = yasm_expr_get_intnum(&vp->param, NULL);
|
||||
if (!intcpu)
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"),
|
||||
"CPU");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "CPU");
|
||||
else {
|
||||
char strcpu[16];
|
||||
sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu));
|
||||
|
|
@ -649,7 +646,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
;
|
||||
} else if (nasm_parser_objfmt->directive(name, valparams, objext_valparams,
|
||||
&nasm_parser_sections, lindex)) {
|
||||
cur_we->error(lindex, N_("unrecognized directive [%s]"), name);
|
||||
yasm__error(lindex, N_("unrecognized directive [%s]"), name);
|
||||
}
|
||||
|
||||
yasm_vps_delete(valparams);
|
||||
|
|
@ -660,6 +657,6 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
static void
|
||||
nasm_parser_error(const char *s)
|
||||
{
|
||||
cur_we->parser_error(cur_lindex, s);
|
||||
yasm__parser_error(cur_lindex, s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,23 +50,21 @@ size_t nasm_parser_locallabel_base_len = 0;
|
|||
/*@dependent@*/ yasm_arch *nasm_parser_arch;
|
||||
/*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
|
||||
/*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
|
||||
/*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
|
||||
|
||||
int nasm_parser_save_input;
|
||||
|
||||
static /*@dependent@*/ yasm_sectionhead *
|
||||
nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
|
||||
yasm_linemgr *lm, yasm_errwarn *we, FILE *f,
|
||||
const char *in_filename, int save_input)
|
||||
yasm_linemgr *lm, FILE *f, const char *in_filename,
|
||||
int save_input)
|
||||
/*@globals killed nasm_parser_locallabel_base @*/
|
||||
{
|
||||
pp->initialize(f, in_filename, lm, we);
|
||||
pp->initialize(f, in_filename, lm);
|
||||
nasm_parser_in = f;
|
||||
nasm_parser_input = pp->input;
|
||||
nasm_parser_arch = a;
|
||||
nasm_parser_objfmt = of;
|
||||
nasm_parser_linemgr = lm;
|
||||
nasm_parser_errwarn = we;
|
||||
nasm_parser_save_input = save_input;
|
||||
|
||||
/* Initialize section list */
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ extern size_t nasm_parser_locallabel_base_len;
|
|||
extern /*@dependent@*/ yasm_arch *nasm_parser_arch;
|
||||
extern /*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
|
||||
extern /*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
|
||||
extern /*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
|
||||
|
||||
extern int nasm_parser_save_input;
|
||||
|
||||
|
|
@ -55,6 +54,4 @@ extern int nasm_parser_save_input;
|
|||
#define p_expr_new_branch(o,r) yasm_expr_new_branch(o,r,cur_lindex)
|
||||
#define p_expr_new_ident(r) yasm_expr_new_ident(r,cur_lindex)
|
||||
|
||||
#define cur_we nasm_parser_errwarn
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -366,9 +366,8 @@ scan:
|
|||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
} else if (!nasm_parser_locallabel_base) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("no non-local label before `%s'"),
|
||||
s.tok[0]);
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("no non-local label before `%s'"), s.tok[0]);
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
} else {
|
||||
len = TOKLEN + nasm_parser_locallabel_base_len;
|
||||
|
|
@ -410,7 +409,7 @@ scan:
|
|||
case YASM_ARCH_CHECK_ID_TARGETMOD:
|
||||
RETURN(TARGETMOD);
|
||||
default:
|
||||
cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("Arch feature not supported, treating as identifier"));
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
|
|
@ -429,9 +428,9 @@ scan:
|
|||
}
|
||||
|
||||
any {
|
||||
cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(s.tok[0]));
|
||||
yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(s.tok[0]));
|
||||
goto scan;
|
||||
}
|
||||
*/
|
||||
|
|
@ -470,9 +469,9 @@ linechg:
|
|||
}
|
||||
|
||||
any {
|
||||
cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(s.tok[0]));
|
||||
yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(s.tok[0]));
|
||||
goto linechg;
|
||||
}
|
||||
*/
|
||||
|
|
@ -516,9 +515,9 @@ directive:
|
|||
}
|
||||
|
||||
any {
|
||||
cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(s.tok[0]));
|
||||
yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(s.tok[0]));
|
||||
goto directive;
|
||||
}
|
||||
*/
|
||||
|
|
@ -535,10 +534,10 @@ stringconst_scan:
|
|||
/*!re2c
|
||||
"\n" {
|
||||
if (cursor == s.eof)
|
||||
cur_we->error(cur_lindex,
|
||||
N_("unexpected end of file in string"));
|
||||
yasm__error(cur_lindex,
|
||||
N_("unexpected end of file in string"));
|
||||
else
|
||||
cur_we->error(cur_lindex, N_("unterminated string"));
|
||||
yasm__error(cur_lindex, N_("unterminated string"));
|
||||
strbuf[count] = '\0';
|
||||
yylval.str_val = strbuf;
|
||||
if (nasm_parser_save_input && cursor != s.eof)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
static FILE *in;
|
||||
static yasm_linemgr *cur_lm;
|
||||
static yasm_errwarn *cur_we;
|
||||
static char *line, *linepos;
|
||||
static size_t lineleft;
|
||||
static char *file_name;
|
||||
|
|
@ -95,17 +94,17 @@ nasm_efunc(int severity, const char *fmt, ...)
|
|||
va_start(va, fmt);
|
||||
switch (severity & ERR_MASK) {
|
||||
case ERR_WARNING:
|
||||
cur_we->warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
|
||||
va);
|
||||
yasm__warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
|
||||
va);
|
||||
break;
|
||||
case ERR_NONFATAL:
|
||||
cur_we->error_va(cur_lm->get_current(), fmt, va);
|
||||
yasm__error_va(cur_lm->get_current(), fmt, va);
|
||||
break;
|
||||
case ERR_FATAL:
|
||||
cur_we->fatal(YASM_FATAL_UNKNOWN); /* FIXME */
|
||||
yasm_fatal(N_("unknown")); /* FIXME */
|
||||
break;
|
||||
case ERR_PANIC:
|
||||
cur_we->internal_error(fmt); /* FIXME */
|
||||
yasm_internal_error(fmt); /* FIXME */
|
||||
break;
|
||||
case ERR_DEBUG:
|
||||
break;
|
||||
|
|
@ -114,12 +113,10 @@ nasm_efunc(int severity, const char *fmt, ...)
|
|||
}
|
||||
|
||||
static void
|
||||
nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we)
|
||||
nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
||||
{
|
||||
in = f;
|
||||
cur_lm = lm;
|
||||
cur_we = we;
|
||||
line = NULL;
|
||||
file_name = NULL;
|
||||
prior_linnum = 0;
|
||||
|
|
|
|||
|
|
@ -36,17 +36,14 @@
|
|||
static int is_interactive;
|
||||
static FILE *in;
|
||||
static yasm_linemgr *cur_lm;
|
||||
static yasm_errwarn *cur_we;
|
||||
|
||||
int isatty(int);
|
||||
|
||||
static void
|
||||
raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we)
|
||||
raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
||||
{
|
||||
in = f;
|
||||
cur_lm = lm;
|
||||
cur_we = we;
|
||||
/*@-unrecog@*/
|
||||
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
|
||||
/*@=unrecog@*/
|
||||
|
|
@ -69,11 +66,10 @@ raw_preproc_input(char *buf, size_t max_size)
|
|||
if (c == '\n')
|
||||
buf[n++] = (char)c;
|
||||
if (c == EOF && ferror(in))
|
||||
cur_we->error(cur_lm->get_current(),
|
||||
N_("error when reading from file"));
|
||||
yasm__error(cur_lm->get_current(),
|
||||
N_("error when reading from file"));
|
||||
} else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
|
||||
cur_we->error(cur_lm->get_current(),
|
||||
N_("error when reading from file"));
|
||||
yasm__error(cur_lm->get_current(), N_("error when reading from file"));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ static YAPP_Output current_output;
|
|||
YYSTYPE yapp_preproc_lval;
|
||||
|
||||
/*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
|
||||
/*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
|
||||
|
||||
int isatty(int);
|
||||
|
||||
|
|
@ -120,13 +119,13 @@ yapp_macro_insert (char *name, int argc, int fillargs)
|
|||
void
|
||||
yapp_macro_error_exists (YAPP_Macro *v)
|
||||
{
|
||||
if (v) cur_we->error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
|
||||
if (v) yasm__error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
|
||||
}
|
||||
|
||||
void
|
||||
yapp_macro_error_sameargname (YAPP_Macro *v)
|
||||
{
|
||||
if (v) cur_we->error(cur_lindex, N_("Duplicate argument names in macro"));
|
||||
if (v) yasm__error(cur_lindex, N_("Duplicate argument names in macro"));
|
||||
}
|
||||
|
||||
YAPP_Macro *
|
||||
|
|
@ -141,7 +140,7 @@ yapp_define_insert (char *name, int argc, int fillargs)
|
|||
if ((argc >= 0 && ym->args < 0)
|
||||
|| (argc < 0 && ym->args >= 0))
|
||||
{
|
||||
cur_we->warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
|
||||
yasm__warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -237,12 +236,10 @@ void
|
|||
expand_token_list(struct source_head *paramexp, struct source_head *to_head, source **to_tail);
|
||||
|
||||
static void
|
||||
yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we)
|
||||
yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
||||
{
|
||||
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
|
||||
yapp_preproc_linemgr = lm;
|
||||
yapp_preproc_errwarn = we;
|
||||
yapp_preproc_current_file = xstrdup(in_filename);
|
||||
yapp_preproc_line_number = 1;
|
||||
yapp_lex_initialize(f);
|
||||
|
|
@ -254,7 +251,7 @@ yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
|||
out->out = current_output = YAPP_OUTPUT;
|
||||
SLIST_INSERT_HEAD(&output_head, out, next);
|
||||
|
||||
macro_table = HAMT_new(we->internal_error_);
|
||||
macro_table = HAMT_new(yasm_internal_error_);
|
||||
|
||||
source_tail = SLIST_FIRST(&source_head);
|
||||
macro_tail = SLIST_FIRST(¯o_head);
|
||||
|
|
@ -470,7 +467,7 @@ eat_through_return(struct source_head *to_head, source **to_tail)
|
|||
while ((token = yapp_preproc_lex()) != '\n') {
|
||||
if (token == 0)
|
||||
return 0;
|
||||
cur_we->error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
|
||||
yasm__error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
|
||||
}
|
||||
append_token('\n', to_head, to_tail);
|
||||
return '\n';
|
||||
|
|
@ -483,7 +480,7 @@ yapp_get_ident(const char *synlvl)
|
|||
if (token == WHITESPACE)
|
||||
token = yapp_preproc_lex();
|
||||
if (token != IDENT) {
|
||||
cur_we->error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
|
||||
yasm__error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
|
@ -511,7 +508,7 @@ expand_macro(char *name,
|
|||
|
||||
ydebug(("YAPP: +Expand macro %s...\n", name));
|
||||
|
||||
if (ym->expanding) cur_we->internal_error(N_("Recursively expanding a macro!"));
|
||||
if (ym->expanding) yasm_internal_error(N_("Recursively expanding a macro!"));
|
||||
|
||||
if (ym->type == YAPP_DEFINE) {
|
||||
if (ym->args == -1) {
|
||||
|
|
@ -543,7 +540,7 @@ expand_macro(char *name,
|
|||
|
||||
/* find out what we got */
|
||||
if (from_head) {
|
||||
cur_we->internal_error(N_("Expanding macro with non-null from_head ugh\n"));
|
||||
yasm_internal_error(N_("Expanding macro with non-null from_head ugh\n"));
|
||||
}
|
||||
token = yapp_preproc_lex();
|
||||
append_token(token, &replay_head, &replay_tail);
|
||||
|
|
@ -590,9 +587,9 @@ expand_macro(char *name,
|
|||
|
||||
default:
|
||||
if (token < 256)
|
||||
cur_we->internal_error(N_("Unexpected character token in parameter expansion"));
|
||||
yasm_internal_error(N_("Unexpected character token in parameter expansion"));
|
||||
else
|
||||
cur_we->error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
|
||||
yasm__error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -612,7 +609,7 @@ expand_macro(char *name,
|
|||
ym->expanding = 1;
|
||||
|
||||
/* so the macro exists. build a HAMT parameter table */
|
||||
param_table = HAMT_new(cur_we->internal_error_);
|
||||
param_table = HAMT_new(yasm_internal_error_);
|
||||
/* fill the entries by walking the replay buffer and create
|
||||
* "macros". coincidentally, clear the replay buffer. */
|
||||
|
||||
|
|
@ -688,11 +685,11 @@ expand_macro(char *name,
|
|||
xfree(replay);
|
||||
}
|
||||
else if (param) {
|
||||
cur_we->internal_error(N_("Got to end of arglist before end of replay!"));
|
||||
yasm_internal_error(N_("Got to end of arglist before end of replay!"));
|
||||
}
|
||||
replay = SLIST_FIRST(&replay_head);
|
||||
if (replay || param)
|
||||
cur_we->internal_error(N_("Count and distribution of define args mismatched!"));
|
||||
yasm_internal_error(N_("Count and distribution of define args mismatched!"));
|
||||
|
||||
/* the param_table is set up without errors, so expansion is ready
|
||||
* to go */
|
||||
|
|
@ -726,7 +723,7 @@ expand_macro(char *name,
|
|||
}
|
||||
}
|
||||
else
|
||||
cur_we->internal_error(N_("Invoking Macros not yet supported"));
|
||||
yasm_internal_error(N_("Invoking Macros not yet supported"));
|
||||
|
||||
ym->expanding = 0;
|
||||
}
|
||||
|
|
@ -772,7 +769,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
append_token(token, &source_head, &source_tail);
|
||||
/*if (append_to_return()==0) state=YAPP_STATE_EOF;*/
|
||||
ydebug(("YAPP: default: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val));
|
||||
/*cur_we->error(cur_lindex, N_("YAPP got an unhandled token."));*/
|
||||
/*yasm__error(cur_lindex, N_("YAPP got an unhandled token."));*/
|
||||
break;
|
||||
|
||||
case IDENT:
|
||||
|
|
@ -795,7 +792,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
|
||||
case CLEAR:
|
||||
HAMT_delete(macro_table, (void (*)(void *))yapp_macro_delete);
|
||||
macro_table = HAMT_new(cur_we->internal_error_);
|
||||
macro_table = HAMT_new(yasm_internal_error_);
|
||||
break;
|
||||
|
||||
case DEFINE:
|
||||
|
|
@ -841,7 +838,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
break;
|
||||
}
|
||||
else if (last_token == ',' || token != ',')
|
||||
cur_we->error(cur_lindex, N_("Unexpected token in %%define parameters"));
|
||||
yasm__error(cur_lindex, N_("Unexpected token in %%define parameters"));
|
||||
last_token = token;
|
||||
}
|
||||
if (token == ')') {
|
||||
|
|
@ -858,7 +855,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
append_token('\n', &source_head, &source_tail);
|
||||
}
|
||||
else {
|
||||
cur_we->internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
|
||||
yasm_internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -921,7 +918,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
cur_we->error(cur_lindex, N_("YAPP got into a bad state"));
|
||||
yasm__error(cur_lindex, N_("YAPP got into a bad state"));
|
||||
}
|
||||
if (need_line_directive) {
|
||||
append_token(LINE, &source_head, &source_tail);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,5 @@ void yapp_lex_initialize(FILE *f);
|
|||
void set_inhibit(void);
|
||||
|
||||
extern /*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
|
||||
extern /*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
|
||||
#define cur_lindex (yapp_preproc_linemgr->get_current())
|
||||
#define cur_we yapp_preproc_errwarn
|
||||
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ DIR %[ \t]*
|
|||
}
|
||||
|
||||
if(inch == '\n')
|
||||
cur_we->error(cur_lindex, _("unterminated string"));
|
||||
yasm__error(cur_lindex, _("unterminated string"));
|
||||
else if(inch == EOF)
|
||||
cur_we->error(cur_lindex, _("unexpected end of file in string"));
|
||||
yasm__error(cur_lindex, _("unexpected end of file in string"));
|
||||
|
||||
strbuf[count] = '\0';
|
||||
|
||||
|
|
@ -172,8 +172,8 @@ DIR %[ \t]*
|
|||
/* FIXME: handle includes that aren't relative */
|
||||
incfile = fopen (yytext, "r");
|
||||
if(!incfile) {
|
||||
cur_we->error(cur_lindex, _("include file `%s': %s"),
|
||||
yytext, strerror(errno));
|
||||
yasm__error(cur_lindex, _("include file `%s': %s"),
|
||||
yytext, strerror(errno));
|
||||
xfree(inc);
|
||||
}
|
||||
else {
|
||||
|
|
@ -330,12 +330,12 @@ DIR %[ \t]*
|
|||
[][+*/,()-] { return yytext[0]; }
|
||||
|
||||
<inhibit>. {
|
||||
cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), cur_we->conv_unprint(yytext[0]));
|
||||
yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), yasm__conv_unprint(yytext[0]));
|
||||
}
|
||||
|
||||
. {
|
||||
cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(yytext[0]));
|
||||
yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(yytext[0]));
|
||||
}
|
||||
|
||||
%%
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ libyasm_la_SOURCES = \
|
|||
src/xmalloc.c \
|
||||
src/xstrdup.c \
|
||||
src/strcasecmp.c
|
||||
libyasm_la_LDFLAGS = -no-undefined
|
||||
|
||||
yasm_SOURCES += \
|
||||
src/main.c \
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ struct yasm_arch {
|
|||
/* keyword used to select architecture */
|
||||
const char *keyword;
|
||||
|
||||
void (*initialize) (yasm_errwarn *we);
|
||||
void (*initialize) (void);
|
||||
void (*cleanup) (void);
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -42,13 +42,11 @@
|
|||
|
||||
|
||||
unsigned char yasm_x86_LTX_mode_bits = 0;
|
||||
/*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
|
||||
|
||||
|
||||
static void
|
||||
x86_initialize(yasm_errwarn *we)
|
||||
x86_initialize(void)
|
||||
{
|
||||
yasm_x86__errwarn = we;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -73,7 +71,7 @@ yasm_x86__directive(const char *name, yasm_valparamhead *valparams,
|
|||
(lval == 16 || lval == 32 || lval == 64))
|
||||
yasm_x86_LTX_mode_bits = (unsigned char)lval;
|
||||
else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "BITS");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "BITS");
|
||||
return 0;
|
||||
} else
|
||||
return 1;
|
||||
|
|
@ -101,7 +99,7 @@ yasm_x86__get_reg_size(unsigned long reg)
|
|||
case X86_FPUREG:
|
||||
return 10;
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown register size"));
|
||||
yasm_internal_error(N_("unknown register size"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -162,7 +160,7 @@ yasm_x86__reg_print(FILE *f, unsigned long reg)
|
|||
fprintf(f, "st%d", (int)(reg&0xF));
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown register size"));
|
||||
yasm_internal_error(N_("unknown register size"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ typedef struct x86_new_jmprel_data {
|
|||
yasm_bytecode *yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d);
|
||||
|
||||
extern unsigned char yasm_x86_LTX_mode_bits;
|
||||
extern /*@dependent@*/ yasm_errwarn *yasm_x86__errwarn;
|
||||
#define cur_we yasm_x86__errwarn
|
||||
|
||||
void yasm_x86__bc_delete(yasm_bytecode *bc);
|
||||
void yasm_x86__bc_print(FILE *f, int indent_level, const yasm_bytecode *bc);
|
||||
|
|
|
|||
|
|
@ -202,11 +202,11 @@ yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d)
|
|||
jmprel->op_sel = d->op_sel;
|
||||
|
||||
if ((d->op_sel == JR_SHORT_FORCED) && (d->near_op_len == 0))
|
||||
cur_we->error(d->lindex,
|
||||
N_("no SHORT form of that jump instruction exists"));
|
||||
yasm__error(d->lindex,
|
||||
N_("no SHORT form of that jump instruction exists"));
|
||||
if ((d->op_sel == JR_NEAR_FORCED) && (d->short_op_len == 0))
|
||||
cur_we->error(d->lindex,
|
||||
N_("no NEAR form of that jump instruction exists"));
|
||||
yasm__error(d->lindex,
|
||||
N_("no NEAR form of that jump instruction exists"));
|
||||
|
||||
jmprel->shortop.opcode[0] = d->short_op[0];
|
||||
jmprel->shortop.opcode[1] = d->short_op[1];
|
||||
|
|
@ -238,8 +238,8 @@ yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned char segment,
|
|||
return;
|
||||
|
||||
if (segment != 0 && x86_ea->segment != 0)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple segment overrides, using leftmost"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple segment overrides, using leftmost"));
|
||||
|
||||
x86_ea->segment = segment;
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ yasm_x86__bc_insn_get_ea(yasm_bytecode *bc)
|
|||
return NULL;
|
||||
|
||||
if ((x86_bytecode_type)bc->type != X86_BC_INSN)
|
||||
cur_we->internal_error(N_("Trying to get EA of non-instruction"));
|
||||
yasm_internal_error(N_("Trying to get EA of non-instruction"));
|
||||
|
||||
return (yasm_effaddr *)(((x86_insn *)bc)->ea);
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned char opersize)
|
|||
jmprel->opersize = opersize;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("OperSize override applied to non-instruction"));
|
||||
}
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned char addrsize)
|
|||
jmprel->addrsize = addrsize;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("AddrSize override applied to non-instruction"));
|
||||
}
|
||||
}
|
||||
|
|
@ -408,13 +408,13 @@ yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned char prefix,
|
|||
lockrep_pre = &jmprel->lockrep_pre;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("LockRep prefix applied to non-instruction"));
|
||||
}
|
||||
|
||||
if (*lockrep_pre != 0)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple LOCK or REP prefixes, using leftmost"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("multiple LOCK or REP prefixes, using leftmost"));
|
||||
|
||||
*lockrep_pre = prefix;
|
||||
}
|
||||
|
|
@ -701,7 +701,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
temp = yasm_expr_copy(jmprel->target);
|
||||
num = yasm_expr_get_intnum(&temp, calc_bc_dist);
|
||||
if (!num) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("short jump target external or out of segment"));
|
||||
yasm_expr_delete(temp);
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
|
|
@ -711,14 +711,13 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
yasm_expr_delete(temp);
|
||||
/* does a short form exist? */
|
||||
if (jmprel->shortop.opcode_len == 0) {
|
||||
cur_we->error(bc->line,
|
||||
N_("short jump does not exist"));
|
||||
yasm__error(bc->line, N_("short jump does not exist"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
/* short displacement must fit in -128 <= rel <= +127 */
|
||||
if (rel < -128 || rel > 127) {
|
||||
cur_we->error(bc->line, N_("short jump out of range"));
|
||||
yasm__error(bc->line, N_("short jump out of range"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
|
|
@ -730,7 +729,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
jrshort = 0;
|
||||
if (save) {
|
||||
if (jmprel->nearop.opcode_len == 0) {
|
||||
cur_we->error(bc->line, N_("near jump does not exist"));
|
||||
yasm__error(bc->line, N_("near jump does not exist"));
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
}
|
||||
|
|
@ -765,7 +764,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
* it to actually be within short range).
|
||||
*/
|
||||
if (save) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("short jump out of range (near jump does not exist)"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
|
|
@ -783,7 +782,7 @@ x86_bc_resolve_jmprel(x86_jmprel *jmprel, unsigned long *len, int save,
|
|||
jrshort = 0;
|
||||
} else {
|
||||
if (save) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("short jump out of range (near jump does not exist)"));
|
||||
return YASM_BC_RESOLVE_ERROR |
|
||||
YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
|
|
@ -834,7 +833,7 @@ yasm_x86__bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
cur_we->internal_error(N_("Didn't handle bytecode type in x86 arch"));
|
||||
yasm_internal_error(N_("Didn't handle bytecode type in x86 arch"));
|
||||
/*@notreached@*/
|
||||
return YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
|
|
@ -863,7 +862,7 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
|
|||
YASM_WRITE_8(*bufp, 0x67);
|
||||
if (insn->rex != 0 && insn->rex != 0xff) {
|
||||
if (insn->mode_bits != 64)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("x86: got a REX prefix in non-64-bit mode"));
|
||||
YASM_WRITE_8(*bufp, insn->rex);
|
||||
}
|
||||
|
|
@ -878,14 +877,13 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
|
|||
if (ea) {
|
||||
if (x86_ea->need_modrm) {
|
||||
if (!x86_ea->valid_modrm)
|
||||
cur_we->internal_error(
|
||||
N_("invalid Mod/RM in x86 tobytes_insn"));
|
||||
yasm_internal_error(N_("invalid Mod/RM in x86 tobytes_insn"));
|
||||
YASM_WRITE_8(*bufp, x86_ea->modrm);
|
||||
}
|
||||
|
||||
if (x86_ea->need_sib) {
|
||||
if (!x86_ea->valid_sib)
|
||||
cur_we->internal_error(N_("invalid SIB in x86 tobytes_insn"));
|
||||
yasm_internal_error(N_("invalid SIB in x86 tobytes_insn"));
|
||||
YASM_WRITE_8(*bufp, x86_ea->sib);
|
||||
}
|
||||
|
||||
|
|
@ -906,7 +904,7 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
|
|||
&eat.sib, &eat.valid_sib,
|
||||
&eat.need_sib, &insn->rex,
|
||||
yasm_common_calc_bc_dist))
|
||||
cur_we->internal_error(N_("checkea failed"));
|
||||
yasm_internal_error(N_("checkea failed"));
|
||||
|
||||
if (ea->disp) {
|
||||
if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
|
||||
|
|
@ -961,7 +959,7 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
|
|||
case JR_SHORT:
|
||||
/* 1 byte relative displacement */
|
||||
if (jmprel->shortop.opcode_len == 0)
|
||||
cur_we->internal_error(N_("short jump does not exist"));
|
||||
yasm_internal_error(N_("short jump does not exist"));
|
||||
|
||||
/* Opcode */
|
||||
for (i=0; i<jmprel->shortop.opcode_len; i++)
|
||||
|
|
@ -976,7 +974,7 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
|
|||
case JR_NEAR:
|
||||
/* 2/4 byte relative displacement (depending on operand size) */
|
||||
if (jmprel->nearop.opcode_len == 0) {
|
||||
cur_we->error(bc->line, N_("near jump does not exist"));
|
||||
yasm__error(bc->line, N_("near jump does not exist"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -991,7 +989,7 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
|
|||
return 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unrecognized relative jump op_sel"));
|
||||
yasm_internal_error(N_("unrecognized relative jump op_sel"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1022,7 +1020,7 @@ yasm_x86__intnum_tobytes(const yasm_intnum *intn, unsigned char **bufp,
|
|||
if (rel) {
|
||||
long val;
|
||||
if (valsize != 1 && valsize != 2 && valsize != 4)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("tried to do PC-relative offset from invalid sized value"));
|
||||
val = yasm_intnum_get_uint(intn);
|
||||
val -= bc->len;
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ x86_expr_checkea_distcheck_reg(yasm_expr **ep)
|
|||
/* The reg expn *must* be EXPR_ADD at this point. Sanity check. */
|
||||
if (e->terms[havereg_expr].type != YASM_EXPR_EXPR ||
|
||||
e->terms[havereg_expr].data.expn->op != YASM_EXPR_ADD)
|
||||
cur_we->internal_error(N_("Register expression not ADD or EXPN"));
|
||||
yasm_internal_error(N_("Register expression not ADD or EXPN"));
|
||||
|
||||
/* Iterate over each term in reg expn */
|
||||
for (i=0; i<e->terms[havereg_expr].data.expn->numterms; i++) {
|
||||
|
|
@ -311,10 +311,10 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg,
|
|||
* Sanity check for EXPR_INT.
|
||||
*/
|
||||
if (e->terms[i].data.expn->terms[0].type != YASM_EXPR_REG)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Register not found in reg expn"));
|
||||
if (e->terms[i].data.expn->terms[1].type != YASM_EXPR_INT)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Non-integer value in reg expn"));
|
||||
reg = get_reg(&e->terms[i].data.expn->terms[0], ®num,
|
||||
data);
|
||||
|
|
@ -411,7 +411,7 @@ x86_checkea_calc_displen(yasm_expr **ep, unsigned int wordsize, int noreg,
|
|||
*/
|
||||
if (!yasm_intnum_check_size(intn, (size_t)wordsize, 0) &&
|
||||
!yasm_intnum_check_size(intn, 1, 1)) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -475,7 +475,7 @@ x86_checkea_calc_displen(yasm_expr **ep, unsigned int wordsize, int noreg,
|
|||
case 2:
|
||||
case 4:
|
||||
if (wordsize != *displen) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (displacement size)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ x86_checkea_calc_displen(yasm_expr **ep, unsigned int wordsize, int noreg,
|
|||
break;
|
||||
default:
|
||||
/* we shouldn't ever get any other size! */
|
||||
cur_we->internal_error(N_("strange EA displacement size"));
|
||||
yasm_internal_error(N_("strange EA displacement size"));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -547,7 +547,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
* otherwise illegal. It's also illegal in non-64-bit mode.
|
||||
*/
|
||||
if (*n_modrm || *n_sib) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (displacement size)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -609,7 +609,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
|
||||
/* We can only do 64-bit addresses in 64-bit mode. */
|
||||
if (*addrsize == 64 && bits != 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (64-bit in non-64-bit mode)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -622,7 +622,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
calc_bc_dist)) {
|
||||
case 0:
|
||||
e = *ep;
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
|
|
@ -644,7 +644,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
*/
|
||||
for (i=0; i<17; i++) {
|
||||
if (reg3264mult[i] < 0) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
if (i != indexreg && reg3264mult[i] == 1 &&
|
||||
|
|
@ -686,7 +686,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
*/
|
||||
for (i=0; i<17; i++)
|
||||
if (i != basereg && i != indexreg && reg3264mult[i] != 0) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -694,7 +694,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
if (indexreg != REG3264_NONE && reg3264mult[indexreg] != 1 &&
|
||||
reg3264mult[indexreg] != 2 && reg3264mult[indexreg] != 4 &&
|
||||
reg3264mult[indexreg] != 8) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -704,7 +704,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
* legal.
|
||||
*/
|
||||
if (reg3264mult[REG3264_ESP] > 1 || basereg == REG3264_ESP) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
/* If mult==1 and basereg is not ESP, swap indexreg w/basereg. */
|
||||
|
|
@ -715,7 +715,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
/* RIP is only legal if it's the ONLY register used. */
|
||||
if (indexreg == REG64_RIP ||
|
||||
(basereg == REG64_RIP && indexreg != REG3264_NONE)) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -752,7 +752,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
*/
|
||||
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
|
||||
bits, X86_REX_B)) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid combination of operands and effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -781,7 +781,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
else {
|
||||
if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
|
||||
bits, X86_REX_B)) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid combination of operands and effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
if (yasm_x86__set_rex_from_reg(rex, &low3,
|
||||
X86_REG64 | indexreg, bits,
|
||||
X86_REX_X)) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid combination of operands and effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -842,7 +842,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
|
||||
/* 64-bit mode does not allow 16-bit addresses */
|
||||
if (bits == 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("16-bit addresses not supported in 64-bit mode"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -857,7 +857,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
calc_bc_dist)) {
|
||||
case 0:
|
||||
e = *ep;
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
|
|
@ -869,7 +869,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
/* reg multipliers not 0 or 1 are illegal. */
|
||||
if (reg16mult.bx & ~1 || reg16mult.si & ~1 || reg16mult.di & ~1 ||
|
||||
reg16mult.bp & ~1) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
|
||||
/* Check the modrm value for invalid combinations. */
|
||||
if (modrm16[havereg] & 0070) {
|
||||
cur_we->error(e->line, N_("invalid effective address"));
|
||||
yasm__error(e->line, N_("invalid effective address"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -901,7 +901,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
switch (*addrsize) {
|
||||
case 64:
|
||||
if (bits != 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("invalid effective address (64-bit in non-64-bit mode)"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -913,7 +913,7 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
|
|||
case 16:
|
||||
/* 64-bit mode does not allow 16-bit addresses */
|
||||
if (bits == 64) {
|
||||
cur_we->error(e->line,
|
||||
yasm__error(e->line,
|
||||
N_("16-bit addresses not supported in 64-bit mode"));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -931,17 +931,17 @@ yasm_x86__floatnum_tobytes(const yasm_floatnum *flt, unsigned char **bufp,
|
|||
int fltret;
|
||||
|
||||
if (!yasm_floatnum_check_size(flt, (size_t)valsize)) {
|
||||
cur_we->error(e->line, N_("invalid floating point constant size"));
|
||||
yasm__error(e->line, N_("invalid floating point constant size"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
fltret = yasm_floatnum_get_sized(flt, *bufp, (size_t)valsize);
|
||||
if (fltret < 0) {
|
||||
cur_we->error(e->line, N_("underflow in floating point expression"));
|
||||
yasm__error(e->line, N_("underflow in floating point expression"));
|
||||
return 1;
|
||||
}
|
||||
if (fltret > 0) {
|
||||
cur_we->error(e->line, N_("overflow in floating point expression"));
|
||||
yasm__error(e->line, N_("overflow in floating point expression"));
|
||||
return 1;
|
||||
}
|
||||
*bufp += valsize;
|
||||
|
|
|
|||
|
|
@ -1537,7 +1537,7 @@ x86_new_jmprel(const unsigned long data[4], int num_operands,
|
|||
/* We know the target is in operand 0, but sanity check for Imm. */
|
||||
op = yasm_ops_first(operands);
|
||||
if (op->type != YASM_INSN__OPERAND_IMM)
|
||||
cur_we->internal_error(N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
d.target = yasm_expr_new(YASM_EXPR_SUB, yasm_expr_expr(op->data.val),
|
||||
yasm_expr_sym(yasm_symrec_define_label("$", cur_section, prev_bc,
|
||||
0, lindex)), lindex);
|
||||
|
|
@ -1820,7 +1820,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
mismatch = 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("invalid operand type"));
|
||||
yasm_internal_error(N_("invalid operand type"));
|
||||
}
|
||||
|
||||
if (mismatch)
|
||||
|
|
@ -1870,7 +1870,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
mismatch = 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("invalid target modifier type"));
|
||||
yasm_internal_error(N_("invalid target modifier type"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1882,8 +1882,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
|
||||
if (!found) {
|
||||
/* Didn't find a matching one */
|
||||
cur_we->error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
yasm__error(lindex, N_("invalid combination of opcode and operands"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1895,25 +1894,23 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
case MOD_ExtErr:
|
||||
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
|
||||
case 0:
|
||||
cur_we->error(lindex, N_("mismatch in operand sizes"));
|
||||
yasm__error(lindex, N_("mismatch in operand sizes"));
|
||||
break;
|
||||
case 1:
|
||||
cur_we->error(lindex, N_("operand size not specified"));
|
||||
yasm__error(lindex, N_("operand size not specified"));
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
N_("unrecognized x86 ext mod index"));
|
||||
yasm_internal_error(N_("unrecognized x86 ext mod index"));
|
||||
}
|
||||
return NULL; /* It was an error */
|
||||
case MOD_ExtWarn:
|
||||
switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
N_("unrecognized x86 ext mod index"));
|
||||
yasm_internal_error(N_("unrecognized x86 ext mod index"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unrecognized x86 extended modifier"));
|
||||
yasm_internal_error(N_("unrecognized x86 extended modifier"));
|
||||
}
|
||||
|
||||
/* Shortcut to JmpRel */
|
||||
|
|
@ -1996,7 +1993,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
yasm_x86_LTX_mode_bits);
|
||||
break;
|
||||
case YASM_INSN__OPERAND_SEGREG:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
case YASM_INSN__OPERAND_MEMORY:
|
||||
d.ea = op->data.ea;
|
||||
|
|
@ -2017,8 +2014,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
d.im_len = size_lookup[(info->operands[i] &
|
||||
OPS_MASK)>>OPS_SHIFT];
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_SImm:
|
||||
if (op->type == YASM_INSN__OPERAND_IMM) {
|
||||
|
|
@ -2027,8 +2023,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
OPS_MASK)>>OPS_SHIFT];
|
||||
d.im_sign = 1;
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_Spare:
|
||||
if (op->type == YASM_INSN__OPERAND_SEGREG)
|
||||
|
|
@ -2037,13 +2032,12 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
if (yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
|
||||
op->data.reg, yasm_x86_LTX_mode_bits,
|
||||
X86_REX_R)) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_Op0Add:
|
||||
if (op->type == YASM_INSN__OPERAND_REG) {
|
||||
|
|
@ -2051,22 +2045,20 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
if (yasm_x86__set_rex_from_reg(&d.rex, &opadd,
|
||||
op->data.reg, yasm_x86_LTX_mode_bits,
|
||||
X86_REX_B)) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
return NULL;
|
||||
}
|
||||
d.op[0] += opadd;
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_Op1Add:
|
||||
/* Op1Add is only used for FPU, so no need to do REX */
|
||||
if (op->type == YASM_INSN__OPERAND_REG)
|
||||
d.op[1] += (unsigned char)(op->data.reg&7);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
case OPA_SpareEA:
|
||||
if (op->type == YASM_INSN__OPERAND_REG) {
|
||||
|
|
@ -2076,18 +2068,17 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
yasm_x86__set_rex_from_reg(&d.rex, &d.spare,
|
||||
op->data.reg, yasm_x86_LTX_mode_bits,
|
||||
X86_REX_R)) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("invalid combination of opcode and operands"));
|
||||
if (d.ea)
|
||||
xfree(d.ea);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
cur_we->internal_error(
|
||||
N_("invalid operand conversion"));
|
||||
yasm_internal_error(N_("invalid operand conversion"));
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown operand action"));
|
||||
yasm_internal_error(N_("unknown operand action"));
|
||||
}
|
||||
|
||||
switch (info->operands[i] & OPAP_MASK) {
|
||||
|
|
@ -2100,7 +2091,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
|
|||
d.signext_imm8_op = 1;
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("unknown operand postponed action"));
|
||||
}
|
||||
}
|
||||
|
|
@ -2258,13 +2249,13 @@ yasm_x86__switch_cpu(const char *id, unsigned long lindex)
|
|||
|
||||
/* catchalls */
|
||||
[\001-\377]+ {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
return;
|
||||
}
|
||||
[\000] {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("unrecognized CPU identifier `%s'"), id);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
|
@ -2308,8 +2299,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
O "64" {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_OPERSIZE;
|
||||
|
|
@ -2319,7 +2310,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* address size overrides */
|
||||
A "16" {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("Cannot override address size to 16 bits in 64-bit mode"));
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
|
|
@ -2334,8 +2325,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
A "64" {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a prefix in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_ADDRSIZE;
|
||||
|
|
@ -2378,8 +2369,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* control, debug, and test registers */
|
||||
C R [02-48] {
|
||||
if (yasm_x86_LTX_mode_bits != 64 && oid[2] == '8') {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_CRREG | (oid[2]-'0');
|
||||
|
|
@ -2406,8 +2397,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
X M M [0-9] {
|
||||
if (yasm_x86_LTX_mode_bits != 64 &&
|
||||
(oid[3] == '8' || oid[3] == '9')) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_XMMREG | (oid[3]-'0');
|
||||
|
|
@ -2415,8 +2406,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
X M M "1" [0-5] {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | (10+oid[4]-'0');
|
||||
|
|
@ -2426,8 +2417,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* integer registers */
|
||||
R A X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 0;
|
||||
|
|
@ -2435,8 +2426,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R C X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 1;
|
||||
|
|
@ -2444,8 +2435,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R D X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 2;
|
||||
|
|
@ -2453,8 +2444,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R B X {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 3;
|
||||
|
|
@ -2462,8 +2453,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R S P {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 4;
|
||||
|
|
@ -2471,8 +2462,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R B P {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 5;
|
||||
|
|
@ -2480,8 +2471,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R S I {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 6;
|
||||
|
|
@ -2489,8 +2480,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R D I {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | 7;
|
||||
|
|
@ -2498,8 +2489,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R [8-9] {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | (oid[1]-'0');
|
||||
|
|
@ -2507,8 +2498,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG64 | (10+oid[2]-'0');
|
||||
|
|
@ -2525,8 +2516,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
E D I { data[0] = X86_REG32 | 7; return YASM_ARCH_CHECK_ID_REG; }
|
||||
R [8-9] D {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG32 | (oid[1]-'0');
|
||||
|
|
@ -2534,8 +2525,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] D {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG32 | (10+oid[2]-'0');
|
||||
|
|
@ -2552,8 +2543,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
D I { data[0] = X86_REG16 | 7; return YASM_ARCH_CHECK_ID_REG; }
|
||||
R [8-9] W {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG16 | (oid[1]-'0');
|
||||
|
|
@ -2561,8 +2552,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] W {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG16 | (10+oid[2]-'0');
|
||||
|
|
@ -2579,8 +2570,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
B H { data[0] = X86_REG8 | 7; return YASM_ARCH_CHECK_ID_REG; }
|
||||
S P L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 4;
|
||||
|
|
@ -2588,8 +2579,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
B P L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 5;
|
||||
|
|
@ -2597,8 +2588,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
S I L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 6;
|
||||
|
|
@ -2606,8 +2597,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
D I L {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8X | 7;
|
||||
|
|
@ -2615,8 +2606,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R [8-9] B {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8 | (oid[1]-'0');
|
||||
|
|
@ -2624,8 +2615,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
}
|
||||
R "1" [0-5] B {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_REG8 | (10+oid[2]-'0');
|
||||
|
|
@ -2635,7 +2626,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* segment registers */
|
||||
E S {
|
||||
if (yasm_x86_LTX_mode_bits == 64)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' segment register ignored in 64-bit mode"), oid);
|
||||
data[0] = 0x2600;
|
||||
return YASM_ARCH_CHECK_ID_SEGREG;
|
||||
|
|
@ -2643,14 +2634,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C S { data[0] = 0x2e01; return YASM_ARCH_CHECK_ID_SEGREG; }
|
||||
S S {
|
||||
if (yasm_x86_LTX_mode_bits == 64)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' segment register ignored in 64-bit mode"), oid);
|
||||
data[0] = 0x3602;
|
||||
return YASM_ARCH_CHECK_ID_SEGREG;
|
||||
}
|
||||
D S {
|
||||
if (yasm_x86_LTX_mode_bits == 64)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' segment register ignored in 64-bit mode"), oid);
|
||||
data[0] = 0x3e03;
|
||||
return YASM_ARCH_CHECK_ID_SEGREG;
|
||||
|
|
@ -2661,8 +2652,8 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* RIP for 64-bit mode IP-relative offsets */
|
||||
R I P {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is a register in 64-bit mode"), oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
data[0] = X86_RIP;
|
||||
|
|
@ -2677,9 +2668,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
M O V S X { RET_INSN(movszx, 0xBE, CPU_386); }
|
||||
M O V S X D {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(movsxd, 0, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2689,21 +2680,21 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P U S H { RET_INSN(push, 0, CPU_Any); }
|
||||
P U S H A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0060, CPU_186);
|
||||
}
|
||||
P U S H A D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x2060, CPU_386);
|
||||
}
|
||||
P U S H A W {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x1060, CPU_186);
|
||||
|
|
@ -2712,21 +2703,21 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P O P { RET_INSN(pop, 0, CPU_Any); }
|
||||
P O P A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0061, CPU_186);
|
||||
}
|
||||
P O P A D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x2061, CPU_386);
|
||||
}
|
||||
P O P A W {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x1061, CPU_186);
|
||||
|
|
@ -2741,14 +2732,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* Load segment registers from memory */
|
||||
L D S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(ldes, 0xC5, CPU_Any);
|
||||
}
|
||||
L E S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(ldes, 0xC4, CPU_Any);
|
||||
|
|
@ -2764,14 +2755,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C M C { RET_INSN(onebyte, 0x00F5, CPU_Any); }
|
||||
L A H F {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x009F, CPU_Any);
|
||||
}
|
||||
S A H F {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x009E, CPU_Any);
|
||||
|
|
@ -2781,9 +2772,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P U S H F W { RET_INSN(onebyte, 0x109C, CPU_Any); }
|
||||
P U S H F Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x409C, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2793,9 +2784,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
P O P F W { RET_INSN(onebyte, 0x109D, CPU_Any); }
|
||||
P O P F Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x409D, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2819,42 +2810,42 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
N O T { RET_INSN(f6, 0x02, CPU_Any); }
|
||||
A A A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0037, CPU_Any);
|
||||
}
|
||||
A A S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x003F, CPU_Any);
|
||||
}
|
||||
D A A {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x0027, CPU_Any);
|
||||
}
|
||||
D A S {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x002F, CPU_Any);
|
||||
}
|
||||
A A D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(aadm, 0x01, CPU_Any);
|
||||
}
|
||||
A A M {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(aadm, 0x00, CPU_Any);
|
||||
|
|
@ -2864,9 +2855,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C W D E { RET_INSN(onebyte, 0x2098, CPU_386); }
|
||||
C D Q E {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x4098, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2875,9 +2866,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C D Q { RET_INSN(onebyte, 0x2099, CPU_386); }
|
||||
C D O {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x4099, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2941,9 +2932,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
J E C X Z { RET_INSN(jcxz, 32, CPU_386); }
|
||||
J R C X Z {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(jcxz, 64, CPU_Hammer|CPU_64);
|
||||
|
|
@ -2991,9 +2982,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
C M P S D { RET_INSN(cmpsd, 0, CPU_Any); }
|
||||
C M P S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40A7, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3009,9 +3000,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
L O D S D { RET_INSN(onebyte, 0x20AD, CPU_386); }
|
||||
L O D S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40AD, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3021,9 +3012,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
M O V S D { RET_INSN(movsd, 0, CPU_Any); }
|
||||
M O V S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40A5, CPU_Any);
|
||||
|
|
@ -3033,9 +3024,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
S C A S D { RET_INSN(onebyte, 0x20AF, CPU_386); }
|
||||
S C A S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40AF, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3045,9 +3036,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
S T O S D { RET_INSN(onebyte, 0x20AB, CPU_386); }
|
||||
S T O S Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40AB, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3066,7 +3057,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
I N T "03" { RET_INSN(onebyte, 0x00CC, CPU_Any); }
|
||||
I N T O {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x00CE, CPU_Any);
|
||||
|
|
@ -3076,9 +3067,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
I R E T D { RET_INSN(onebyte, 0x20CF, CPU_386); }
|
||||
I R E T Q {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(onebyte, 0x40CF, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3086,7 +3077,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
R S M { RET_INSN(twobyte, 0x0FAA, CPU_586|CPU_SMM); }
|
||||
B O U N D {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(bound, 0, CPU_186);
|
||||
|
|
@ -3096,7 +3087,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* Protection control */
|
||||
A R P L {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(arpl, 0, CPU_286|CPU_Prot);
|
||||
|
|
@ -3217,14 +3208,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* Pentium II/Pentium Pro extensions */
|
||||
S Y S E N T E R {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(twobyte, 0x0F34, CPU_686);
|
||||
}
|
||||
S Y S E X I T {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(twobyte, 0x0F35, CPU_686|CPU_Priv);
|
||||
|
|
@ -3527,9 +3518,9 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
/* AMD x86-64 extensions */
|
||||
S W A P G S {
|
||||
if (yasm_x86_LTX_mode_bits != 64) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("`%s' is an instruction in 64-bit mode"),
|
||||
oid);
|
||||
return YASM_ARCH_CHECK_ID_NONE;
|
||||
}
|
||||
RET_INSN(threebyte, 0x0F01F8, CPU_Hammer|CPU_64);
|
||||
|
|
@ -3565,7 +3556,7 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
|
|||
L O A D A L L "286" { RET_INSN(twobyte, 0x0F05, CPU_286|CPU_Undoc); }
|
||||
S A L C {
|
||||
if (yasm_x86_LTX_mode_bits == 64) {
|
||||
cur_we->error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
yasm__error(lindex, N_("`%s' invalid in 64-bit mode"), oid);
|
||||
RET_INSN(not64, 0, CPU_Not64);
|
||||
}
|
||||
RET_INSN(onebyte, 0x00D6, CPU_Undoc);
|
||||
|
|
|
|||
|
|
@ -101,14 +101,12 @@ typedef struct bytecode_objfmt_data {
|
|||
unsigned char bytes_static[16];
|
||||
|
||||
/*@dependent@*/ static yasm_arch *cur_arch;
|
||||
/*@dependent@*/ static yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we)
|
||||
yasm_bc_initialize(yasm_arch *a)
|
||||
{
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
}
|
||||
|
||||
yasm_immval *
|
||||
|
|
@ -337,14 +335,14 @@ yasm_bc_delete(yasm_bytecode *bc)
|
|||
objfmt_data->of->bc_objfmt_data_delete(objfmt_data->type,
|
||||
objfmt_data->data);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("objfmt can't handle its own objfmt data bytecode"));
|
||||
break;
|
||||
default:
|
||||
if (bc->type < cur_arch->bc.type_max)
|
||||
cur_arch->bc.bc_delete(bc);
|
||||
else
|
||||
cur_we->internal_error(N_("Unknown bytecode type"));
|
||||
yasm_internal_error(N_("Unknown bytecode type"));
|
||||
break;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
|
@ -511,10 +509,10 @@ bc_resolve_reserve(bytecode_reserve *reserve, unsigned long *len,
|
|||
* the circular reference error to filter through.
|
||||
*/
|
||||
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT))
|
||||
cur_we->error(line,
|
||||
yasm__error(line,
|
||||
N_("expression must not contain floating point value"));
|
||||
else
|
||||
cur_we->error(line,
|
||||
yasm__error(line,
|
||||
N_("attempt to reserve non-constant quantity of space"));
|
||||
retval = YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
} else
|
||||
|
|
@ -577,13 +575,13 @@ bc_resolve_incbin(bytecode_incbin *incbin, unsigned long *len, int save,
|
|||
/* Open file and determine its length */
|
||||
f = fopen(incbin->filename, "rb");
|
||||
if (!f) {
|
||||
cur_we->error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
if (fseek(f, 0L, SEEK_END) < 0) {
|
||||
cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
}
|
||||
flen = (unsigned long)ftell(f);
|
||||
|
|
@ -591,9 +589,9 @@ bc_resolve_incbin(bytecode_incbin *incbin, unsigned long *len, int save,
|
|||
|
||||
/* Compute length of incbin from start, maxlen, and len */
|
||||
if (start > flen) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, line,
|
||||
N_("`incbin': start past end of file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__warning(YASM_WARN_GENERAL, line,
|
||||
N_("`incbin': start past end of file `%s'"),
|
||||
incbin->filename);
|
||||
start = flen;
|
||||
}
|
||||
flen -= start;
|
||||
|
|
@ -617,7 +615,7 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
|
||||
switch (bc->type) {
|
||||
case YASM_BC__EMPTY:
|
||||
cur_we->internal_error(N_("got empty bytecode in bc_calc_len"));
|
||||
yasm_internal_error(N_("got empty bytecode in bc_calc_len"));
|
||||
/*break;*/
|
||||
case YASM_BC__DATA:
|
||||
retval = bc_resolve_data((bytecode_data *)bc, &bc->len);
|
||||
|
|
@ -632,18 +630,17 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
break;
|
||||
case YASM_BC__ALIGN:
|
||||
/* TODO */
|
||||
cur_we->internal_error(
|
||||
N_("TODO: align bytecode not implemented!"));
|
||||
yasm_internal_error(N_("TODO: align bytecode not implemented!"));
|
||||
/*break;*/
|
||||
case YASM_BC__OBJFMT_DATA:
|
||||
cur_we->internal_error(N_("resolving objfmt data bytecode?"));
|
||||
yasm_internal_error(N_("resolving objfmt data bytecode?"));
|
||||
/*break;*/
|
||||
default:
|
||||
if (bc->type < cur_arch->bc.type_max)
|
||||
retval = cur_arch->bc.bc_resolve(bc, save, sect,
|
||||
calc_bc_dist);
|
||||
else
|
||||
cur_we->internal_error(N_("Unknown bytecode type"));
|
||||
yasm_internal_error(N_("Unknown bytecode type"));
|
||||
}
|
||||
|
||||
/* Multiply len by number of multiples */
|
||||
|
|
@ -660,7 +657,7 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
|
|||
if (!num) {
|
||||
retval = YASM_BC_RESOLVE_UNKNOWN_LEN;
|
||||
if (temp && yasm_expr__contains(temp, YASM_EXPR_FLOAT)) {
|
||||
cur_we->error(bc->line,
|
||||
yasm__error(bc->line,
|
||||
N_("expression must not contain floating point value"));
|
||||
retval |= YASM_BC_RESOLVE_ERROR;
|
||||
}
|
||||
|
|
@ -727,7 +724,7 @@ bc_tobytes_incbin(bytecode_incbin *incbin, unsigned char **bufp,
|
|||
if (incbin->start) {
|
||||
num = yasm_expr_get_intnum(&incbin->start, NULL);
|
||||
if (!num)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("could not determine start in bc_tobytes_incbin"));
|
||||
start = yasm_intnum_get_uint(num);
|
||||
}
|
||||
|
|
@ -735,24 +732,24 @@ bc_tobytes_incbin(bytecode_incbin *incbin, unsigned char **bufp,
|
|||
/* Open file */
|
||||
f = fopen(incbin->filename, "rb");
|
||||
if (!f) {
|
||||
cur_we->error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to open file `%s'"),
|
||||
incbin->filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Seek to start of data */
|
||||
if (fseek(f, (long)start, SEEK_SET) < 0) {
|
||||
cur_we->error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
yasm__error(line, N_("`incbin': unable to seek on file `%s'"),
|
||||
incbin->filename);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read len bytes */
|
||||
if (fread(*bufp, (size_t)len, 1, f) < (size_t)len) {
|
||||
cur_we->error(line,
|
||||
N_("`incbin': unable to read %lu bytes from file `%s'"),
|
||||
len, incbin->filename);
|
||||
yasm__error(line,
|
||||
N_("`incbin': unable to read %lu bytes from file `%s'"),
|
||||
len, incbin->filename);
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -781,7 +778,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
if (bc->multiple) {
|
||||
num = yasm_expr_get_intnum(&bc->multiple, NULL);
|
||||
if (!num)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("could not determine multiple in bc_tobytes"));
|
||||
*multiple = yasm_intnum_get_uint(num);
|
||||
if (*multiple == 0) {
|
||||
|
|
@ -812,7 +809,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
|
||||
switch (bc->type) {
|
||||
case YASM_BC__EMPTY:
|
||||
cur_we->internal_error(N_("got empty bytecode in bc_tobytes"));
|
||||
yasm_internal_error(N_("got empty bytecode in bc_tobytes"));
|
||||
/*break;*/
|
||||
case YASM_BC__DATA:
|
||||
error = bc_tobytes_data((bytecode_data *)bc, &destbuf, sect, bc, d,
|
||||
|
|
@ -824,8 +821,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
break;
|
||||
case YASM_BC__ALIGN:
|
||||
/* TODO */
|
||||
cur_we->internal_error(
|
||||
N_("TODO: align bytecode not implemented!"));
|
||||
yasm_internal_error(N_("TODO: align bytecode not implemented!"));
|
||||
/*break;*/
|
||||
case YASM_BC__OBJFMT_DATA:
|
||||
objfmt_data = (bytecode_objfmt_data *)bc;
|
||||
|
|
@ -833,7 +829,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
error = output_bc_objfmt_data(objfmt_data->type,
|
||||
objfmt_data->data, &destbuf);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Have objfmt data bytecode but no way to output it"));
|
||||
break;
|
||||
default:
|
||||
|
|
@ -841,11 +837,11 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
|
|||
error = cur_arch->bc.bc_tobytes(bc, &destbuf, sect, d,
|
||||
output_expr);
|
||||
else
|
||||
cur_we->internal_error(N_("Unknown bytecode type"));
|
||||
yasm_internal_error(N_("Unknown bytecode type"));
|
||||
}
|
||||
|
||||
if (!error && ((unsigned long)(destbuf - origbuf) != datasize))
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("written length does not match optimized length"));
|
||||
return mybuf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ typedef enum {
|
|||
} yasm_bytecode_type;
|
||||
#define YASM_BYTECODE_TYPE_BASE YASM_BC__OBJFMT_DATA+1
|
||||
|
||||
void yasm_bc_initialize(yasm_arch *a, yasm_errwarn *we);
|
||||
void yasm_bc_initialize(yasm_arch *a);
|
||||
|
||||
/*@only@*/ yasm_immval *yasm_imm_new_int(unsigned long int_val,
|
||||
unsigned long lindex);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ typedef struct yasm_intnum yasm_intnum;
|
|||
typedef struct yasm_floatnum yasm_floatnum;
|
||||
|
||||
typedef struct yasm_linemgr yasm_linemgr;
|
||||
typedef struct yasm_errwarn yasm_errwarn;
|
||||
|
||||
typedef enum {
|
||||
YASM_EXPR_ADD,
|
||||
|
|
|
|||
149
src/errwarn.c
149
src/errwarn.c
|
|
@ -39,6 +39,19 @@
|
|||
|
||||
#define MSG_MAXSIZE 1024
|
||||
|
||||
/* Default handlers for replacable functions */
|
||||
static /*@exits@*/ void def_internal_error_
|
||||
(const char *file, unsigned int line, const char *message);
|
||||
static /*@exits@*/ void def_fatal(const char *message);
|
||||
static const char *def_gettext_hook(const char *msgid);
|
||||
|
||||
/* Storage for errwarn's "extern" functions */
|
||||
/*@exits@*/ void (*yasm_internal_error_)
|
||||
(const char *file, unsigned int line, const char *message)
|
||||
= def_internal_error_;
|
||||
/*@exits@*/ void (*yasm_fatal) (const char *message) = def_fatal;
|
||||
const char * (*yasm_gettext_hook) (const char *msgid) = def_gettext_hook;
|
||||
|
||||
/* Enabled warnings. See errwarn.h for a list. */
|
||||
static unsigned long warn_class_enabled;
|
||||
|
||||
|
|
@ -48,18 +61,6 @@ static unsigned int error_count;
|
|||
/* Total warning count */
|
||||
static unsigned int warning_count;
|
||||
|
||||
/* See errwarn.h for constants that match up to these strings.
|
||||
* When adding a string here, keep errwarn.h in sync!
|
||||
*/
|
||||
|
||||
/* Fatal error messages. Match up with fatal_num enum in errwarn.h. */
|
||||
/*@-observertrans@*/
|
||||
static const char *fatal_msgs[] = {
|
||||
N_("unknown"),
|
||||
N_("out of memory")
|
||||
};
|
||||
/*@=observertrans@*/
|
||||
|
||||
typedef /*@reldef@*/ SLIST_HEAD(errwarndatahead_s, errwarn_data)
|
||||
errwarndatahead;
|
||||
static /*@only@*/ /*@null@*/ errwarndatahead errwarns;
|
||||
|
|
@ -82,8 +83,14 @@ static /*@null@*/ errwarn_data *previous_we;
|
|||
static char unprint[5];
|
||||
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_initialize(void)
|
||||
static const char *
|
||||
def_gettext_hook(const char *msgid)
|
||||
{
|
||||
return msgid;
|
||||
}
|
||||
|
||||
void
|
||||
yasm_errwarn_initialize(void)
|
||||
{
|
||||
/* Default enabled warnings. See errwarn.h for a list. */
|
||||
warn_class_enabled =
|
||||
|
|
@ -96,8 +103,8 @@ yasm_std_errwarn_initialize(void)
|
|||
previous_we = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_cleanup(void)
|
||||
void
|
||||
yasm_errwarn_cleanup(void)
|
||||
{
|
||||
errwarn_data *we;
|
||||
|
||||
|
|
@ -113,8 +120,8 @@ yasm_std_errwarn_cleanup(void)
|
|||
/* Convert a possibly unprintable character into a printable string, using
|
||||
* standard cat(1) convention for unprintable characters.
|
||||
*/
|
||||
static char *
|
||||
yasm_std_errwarn_conv_unprint(char ch)
|
||||
char *
|
||||
yasm__conv_unprint(char ch)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
|
|
@ -137,11 +144,11 @@ yasm_std_errwarn_conv_unprint(char ch)
|
|||
* Exit immediately because it's essentially an assert() trap.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_internal_error_(const char *file, unsigned int line,
|
||||
const char *message)
|
||||
def_internal_error_(const char *file, unsigned int line, const char *message)
|
||||
{
|
||||
fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
|
||||
gettext(message));
|
||||
fprintf(stderr,
|
||||
yasm_gettext_hook(N_("INTERNAL ERROR at %s, line %u: %s\n")),
|
||||
file, line, yasm_gettext_hook(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
|
|
@ -153,9 +160,10 @@ yasm_std_errwarn_internal_error_(const char *file, unsigned int line,
|
|||
* memory), so just exit immediately.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_fatal(yasm_fatal_cause num)
|
||||
def_fatal(const char *message)
|
||||
{
|
||||
fprintf(stderr, _("FATAL: %s\n"), gettext(fatal_msgs[num]));
|
||||
fprintf(stderr, yasm_gettext_hook(N_("FATAL: %s\n")),
|
||||
yasm_gettext_hook(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
|
|
@ -211,8 +219,7 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
|
|||
assert(ins_we != NULL);
|
||||
SLIST_INSERT_AFTER(ins_we, we, link);
|
||||
} else
|
||||
yasm_std_errwarn_internal_error_(__FILE__, __LINE__,
|
||||
N_("Unexpected errwarn insert action"));
|
||||
yasm_internal_error(N_("Unexpected errwarn insert action"));
|
||||
}
|
||||
|
||||
/* Remember previous err/warn */
|
||||
|
|
@ -224,17 +231,17 @@ errwarn_data_new(unsigned long lindex, int replace_parser_error)
|
|||
/* Register an error at line lindex. Does not print the error, only stores it
|
||||
* for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_error_va(unsigned long lindex, const char *fmt, va_list va)
|
||||
void
|
||||
yasm__error_va(unsigned long lindex, const char *fmt, va_list va)
|
||||
{
|
||||
errwarn_data *we = errwarn_data_new(lindex, 1);
|
||||
|
||||
we->type = WE_ERROR;
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
|
||||
#else
|
||||
vsprintf(we->msg, gettext(fmt), va);
|
||||
vsprintf(we->msg, yasm_gettext_hook(fmt), va);
|
||||
#endif
|
||||
|
||||
error_count++;
|
||||
|
|
@ -243,9 +250,9 @@ yasm_std_errwarn_error_va(unsigned long lindex, const char *fmt, va_list va)
|
|||
/* Register an warning at line lindex. Does not print the warning, only stores
|
||||
* it for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
|
||||
const char *fmt, va_list va)
|
||||
void
|
||||
yasm__warning_va(yasm_warn_class num, unsigned long lindex, const char *fmt,
|
||||
va_list va)
|
||||
{
|
||||
errwarn_data *we;
|
||||
|
||||
|
|
@ -257,9 +264,9 @@ yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
|
|||
we->type = WE_WARNING;
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, gettext(fmt), va);
|
||||
vsnprintf(we->msg, MSG_MAXSIZE, yasm_gettext_hook(fmt), va);
|
||||
#else
|
||||
vsprintf(we->msg, gettext(fmt), va);
|
||||
vsprintf(we->msg, yasm_gettext_hook(fmt), va);
|
||||
#endif
|
||||
|
||||
warning_count++;
|
||||
|
|
@ -268,61 +275,57 @@ yasm_std_errwarn_warning_va(yasm_warn_class num, unsigned long lindex,
|
|||
/* Register an error at line lindex. Does not print the error, only stores it
|
||||
* for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_error(unsigned long lindex, const char *fmt, ...)
|
||||
void
|
||||
yasm__error(unsigned long lindex, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
yasm_std_errwarn_error_va(lindex, fmt, va);
|
||||
yasm__error_va(lindex, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/* Register an warning at line lindex. Does not print the warning, only stores
|
||||
* it for output_all() to print.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_warning(yasm_warn_class num, unsigned long lindex,
|
||||
const char *fmt, ...)
|
||||
void
|
||||
yasm__warning(yasm_warn_class num, unsigned long lindex, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
yasm_std_errwarn_warning_va(num, lindex, fmt, va);
|
||||
yasm__warning_va(num, lindex, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/* Parser error handler. Moves YACC-style error into our error handling
|
||||
* system.
|
||||
*/
|
||||
static void
|
||||
yasm_std_errwarn_parser_error(unsigned long lindex, const char *s)
|
||||
void
|
||||
yasm__parser_error(unsigned long lindex, const char *s)
|
||||
{
|
||||
yasm_std_errwarn_error(lindex, N_("parser error: %s"), s);
|
||||
yasm__error(lindex, N_("parser error: %s"), s);
|
||||
previous_we->type = WE_PARSERERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_warn_enable(yasm_warn_class num)
|
||||
void
|
||||
yasm_warn_enable(yasm_warn_class num)
|
||||
{
|
||||
warn_class_enabled |= (1UL<<num);
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_warn_disable(yasm_warn_class num)
|
||||
void
|
||||
yasm_warn_disable(yasm_warn_class num)
|
||||
{
|
||||
warn_class_enabled &= ~(1UL<<num);
|
||||
}
|
||||
|
||||
static void
|
||||
yasm_std_errwarn_warn_disable_all(void)
|
||||
void
|
||||
yasm_warn_disable_all(void)
|
||||
{
|
||||
warn_class_enabled = 0;
|
||||
}
|
||||
|
||||
/* Get the number of errors (including warnings if warnings are being treated
|
||||
* as errors).
|
||||
*/
|
||||
static unsigned int
|
||||
yasm_std_errwarn_get_num_errors(int warning_as_error)
|
||||
unsigned int
|
||||
yasm_get_num_errors(int warning_as_error)
|
||||
{
|
||||
if (warning_as_error)
|
||||
return error_count+warning_count;
|
||||
|
|
@ -330,9 +333,11 @@ yasm_std_errwarn_get_num_errors(int warning_as_error)
|
|||
return error_count;
|
||||
}
|
||||
|
||||
/* Output all previously stored errors and warnings to stderr. */
|
||||
static void
|
||||
yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
|
||||
void
|
||||
yasm_errwarn_output_all(yasm_linemgr *lm, int warning_as_error,
|
||||
void (*print_error) (const char *fn, unsigned long line, const char *msg),
|
||||
void (*print_warning) (const char *fn, unsigned long line,
|
||||
const char *msg))
|
||||
{
|
||||
errwarn_data *we;
|
||||
const char *filename;
|
||||
|
|
@ -340,7 +345,8 @@ yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
|
|||
|
||||
/* If we're treating warnings as errors, tell the user about it. */
|
||||
if (warning_as_error && warning_as_error != 2) {
|
||||
fprintf(stderr, "%s\n", _("warnings being treated as errors"));
|
||||
print_error("", 0,
|
||||
yasm_gettext_hook(N_("warnings being treated as errors")));
|
||||
warning_as_error = 2;
|
||||
}
|
||||
|
||||
|
|
@ -349,27 +355,8 @@ yasm_std_errwarn_output_all(yasm_linemgr *lm, int warning_as_error)
|
|||
/* Output error/warning */
|
||||
lm->lookup(we->line, &filename, &line);
|
||||
if (we->type == WE_ERROR)
|
||||
fprintf(stderr, "%s:%lu: %s\n", filename, line, we->msg);
|
||||
print_error(filename, line, we->msg);
|
||||
else
|
||||
fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"),
|
||||
we->msg);
|
||||
print_warning(filename, line, we->msg);
|
||||
}
|
||||
}
|
||||
|
||||
yasm_errwarn yasm_std_errwarn = {
|
||||
yasm_std_errwarn_initialize,
|
||||
yasm_std_errwarn_cleanup,
|
||||
yasm_std_errwarn_internal_error_,
|
||||
yasm_std_errwarn_fatal,
|
||||
yasm_std_errwarn_error_va,
|
||||
yasm_std_errwarn_warning_va,
|
||||
yasm_std_errwarn_error,
|
||||
yasm_std_errwarn_warning,
|
||||
yasm_std_errwarn_parser_error,
|
||||
yasm_std_errwarn_warn_enable,
|
||||
yasm_std_errwarn_warn_disable,
|
||||
yasm_std_errwarn_warn_disable_all,
|
||||
yasm_std_errwarn_get_num_errors,
|
||||
yasm_std_errwarn_output_all,
|
||||
yasm_std_errwarn_conv_unprint
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,66 +34,61 @@ typedef enum {
|
|||
YASM_WARN_PREPROC /* preprocessor warnings */
|
||||
} yasm_warn_class;
|
||||
|
||||
/* Fatal error constants.
|
||||
* See fatal_msgs in errwarn.c for strings that match up to these constants.
|
||||
* When adding a constant here, keep errwarn.c in sync!
|
||||
/* Initialize any internal data structures. */
|
||||
void yasm_errwarn_initialize(void);
|
||||
|
||||
/* Cleans up any memory allocated by initialize or other functions. */
|
||||
void yasm_errwarn_cleanup(void);
|
||||
|
||||
/* Reporting point of internal errors. These are usually due to sanity
|
||||
* check failures in the code.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
typedef enum {
|
||||
YASM_FATAL_UNKNOWN = 0,
|
||||
YASM_FATAL_NOMEM
|
||||
} yasm_fatal_cause;
|
||||
extern /*@exits@*/ void (*yasm_internal_error_)
|
||||
(const char *file, unsigned int line, const char *message);
|
||||
#define yasm_internal_error(msg) \
|
||||
yasm_internal_error_(__FILE__, __LINE__, msg)
|
||||
|
||||
struct yasm_errwarn {
|
||||
/* Initialize any internal data structures. */
|
||||
void (*initialize) (void);
|
||||
/* Reporting point of fatal errors.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
extern /*@exits@*/ void (*yasm_fatal) (const char *message);
|
||||
|
||||
/* Cleans up any memory allocated by initialize or other functions. */
|
||||
void (*cleanup) (void);
|
||||
/* va_list versions of the below two functions */
|
||||
void yasm__error_va(unsigned long lindex, const char *, va_list va);
|
||||
void yasm__warning_va(yasm_warn_class, unsigned long lindex, const char *,
|
||||
va_list va);
|
||||
|
||||
/* Reporting point of internal errors. These are usually due to sanity
|
||||
* check failures in the code.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
/*@exits@*/ void (*internal_error_) (const char *file, unsigned int line,
|
||||
const char *message);
|
||||
#define internal_error(msg) internal_error_(__FILE__, __LINE__, msg)
|
||||
void yasm__error(unsigned long lindex, const char *, ...) /*@printflike@*/;
|
||||
void yasm__warning(yasm_warn_class, unsigned long lindex, const char *, ...)
|
||||
/*@printflike@*/;
|
||||
|
||||
/* Reporting point of fatal errors.
|
||||
* This function must NOT return to calling code. Either exit or longjmp.
|
||||
*/
|
||||
/*@exits@*/ void (*fatal) (yasm_fatal_cause);
|
||||
/* Logs a parser error. These can be overwritten by non-parser errors on
|
||||
* the same line.
|
||||
*/
|
||||
void yasm__parser_error(unsigned long lindex, const char *);
|
||||
|
||||
/* va_list versions of the below two functions */
|
||||
void (*error_va) (unsigned long lindex, const char *, va_list va);
|
||||
void (*warning_va) (yasm_warn_class, unsigned long lindex, const char *,
|
||||
va_list va);
|
||||
/* Enables/disables a class of warnings. */
|
||||
void yasm_warn_enable(yasm_warn_class);
|
||||
void yasm_warn_disable(yasm_warn_class);
|
||||
void yasm_warn_disable_all(void);
|
||||
|
||||
void (*error) (unsigned long lindex, const char *, ...) /*@printflike@*/;
|
||||
void (*warning) (yasm_warn_class, unsigned long lindex, const char *, ...)
|
||||
/*@printflike@*/;
|
||||
/* Returns total number of errors logged to this point.
|
||||
* If warning_as_error is nonzero, warnings are treated as errors.
|
||||
*/
|
||||
unsigned int yasm_get_num_errors(int warning_as_error);
|
||||
|
||||
/* Logs a parser error. These can be overwritten by non-parser errors on
|
||||
* the same line.
|
||||
*/
|
||||
void (*parser_error) (unsigned long lindex, const char *);
|
||||
/* Outputs all errors/warnings by calling print_error and print_warning. */
|
||||
void yasm_errwarn_output_all
|
||||
(yasm_linemgr *lm, int warning_as_error,
|
||||
void (*print_error) (const char *fn, unsigned long line, const char *msg),
|
||||
void (*print_warning) (const char *fn, unsigned long line,
|
||||
const char *msg));
|
||||
|
||||
/* Enables/disables a class of warnings. */
|
||||
void (*warn_enable) (yasm_warn_class);
|
||||
void (*warn_disable) (yasm_warn_class);
|
||||
void (*warn_disable_all) (void);
|
||||
/* Convert a possibly unprintable character into a printable string. */
|
||||
char *yasm__conv_unprint(char ch);
|
||||
|
||||
/* Returns total number of errors logged to this point.
|
||||
* If warning_as_error is nonzero, warnings are treated as errors.
|
||||
*/
|
||||
unsigned int (*get_num_errors) (int warning_as_error);
|
||||
|
||||
/* Outputs all errors/warnings (e.g. to stderr or elsewhere). */
|
||||
void (*output_all) (yasm_linemgr *lm, int warning_as_error);
|
||||
|
||||
/* Convert a possibly unprintable character into a printable string. */
|
||||
char * (*conv_unprint) (char ch);
|
||||
};
|
||||
|
||||
extern yasm_errwarn yasm_std_errwarn;
|
||||
/* Map to gettext() if gettext is being used. */
|
||||
extern const char * (*yasm_gettext_hook) (const char *msgid);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
10
src/expr.c
10
src/expr.c
|
|
@ -49,14 +49,12 @@ static int expr_traverse_nodes_post(/*@null@*/ yasm_expr *e,
|
|||
/*@null@*/ void *d));
|
||||
|
||||
static /*@dependent@*/ yasm_arch *cur_arch;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we)
|
||||
yasm_expr_initialize(yasm_arch *a)
|
||||
{
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
}
|
||||
|
||||
/* allocate a new expression node, with children as defined.
|
||||
|
|
@ -90,7 +88,7 @@ yasm_expr_new(yasm_expr_op op, yasm_expr__item *left, yasm_expr__item *right,
|
|||
/*@=usereleased@*/
|
||||
}
|
||||
} else {
|
||||
cur_we->internal_error(N_("Right side of expression must exist"));
|
||||
yasm_internal_error(N_("Right side of expression must exist"));
|
||||
}
|
||||
|
||||
if (right) {
|
||||
|
|
@ -716,8 +714,8 @@ yasm_expr__level_tree(yasm_expr *e, int fold_const, int simplify_ident,
|
|||
/* Check for circular reference */
|
||||
SLIST_FOREACH(np, eh, next) {
|
||||
if (np->e == equ_expr) {
|
||||
cur_we->error(e->line,
|
||||
N_("circular reference detected."));
|
||||
yasm__error(e->line,
|
||||
N_("circular reference detected."));
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
typedef struct yasm_expr__item yasm_expr__item;
|
||||
|
||||
void yasm_expr_initialize(yasm_arch *a, yasm_errwarn *we);
|
||||
void yasm_expr_initialize(yasm_arch *a);
|
||||
|
||||
/*@only@*/ yasm_expr *yasm_expr_new(yasm_expr_op, /*@only@*/ yasm_expr__item *,
|
||||
/*@only@*/ /*@null@*/ yasm_expr__item *,
|
||||
|
|
|
|||
|
|
@ -135,8 +135,6 @@ static POT_Entry_Source POT_TableP_Source[] = {
|
|||
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80},0x7fff}, /* 1e+0 */
|
||||
};
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
static void
|
||||
POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp)
|
||||
|
|
@ -160,15 +158,13 @@ POT_Table_Init_Entry(/*@out@*/ POT_Entry *e, POT_Entry_Source *s, int dec_exp)
|
|||
|
||||
/*@-compdef@*/
|
||||
void
|
||||
yasm_floatnum_initialize(yasm_errwarn *we)
|
||||
yasm_floatnum_initialize(void)
|
||||
/*@globals undef POT_TableN, undef POT_TableP, POT_TableP_Source,
|
||||
POT_TableN_Source @*/
|
||||
{
|
||||
int dec_exp = 1;
|
||||
int i;
|
||||
|
||||
cur_we = we;
|
||||
|
||||
/* Allocate space for two POT tables */
|
||||
POT_TableN = xmalloc(14*sizeof(POT_Entry));
|
||||
POT_TableP = xmalloc(15*sizeof(POT_Entry)); /* note 1 extra for -1 */
|
||||
|
|
@ -516,8 +512,8 @@ yasm_floatnum_calc(yasm_floatnum *acc, yasm_expr_op op,
|
|||
/*@unused@*/ yasm_floatnum *operand, unsigned long lindex)
|
||||
{
|
||||
if (op != YASM_EXPR_NEG)
|
||||
cur_we->error(lindex,
|
||||
N_("Unsupported floating-point arithmetic operation"));
|
||||
yasm__error(lindex,
|
||||
N_("Unsupported floating-point arithmetic operation"));
|
||||
else
|
||||
acc->sign ^= 1;
|
||||
}
|
||||
|
|
@ -592,7 +588,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr,
|
|||
|
||||
/* underflow and overflow both set!? */
|
||||
if (underflow && overflow)
|
||||
cur_we->internal_error(N_("Both underflow and overflow set"));
|
||||
yasm_internal_error(N_("Both underflow and overflow set"));
|
||||
|
||||
/* check for underflow or overflow and set up appropriate output */
|
||||
if (underflow) {
|
||||
|
|
@ -615,7 +611,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr,
|
|||
/* get little-endian bytes */
|
||||
buf = BitVector_Block_Read(output, &len);
|
||||
if (len < byte_size)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("Byte length of BitVector does not match bit length"));
|
||||
|
||||
/* copy to output */
|
||||
|
|
@ -671,7 +667,7 @@ yasm_floatnum_get_sized(const yasm_floatnum *flt, unsigned char *ptr,
|
|||
case 10:
|
||||
return floatnum_get_common(flt, ptr, 10, 64, 0, 15);
|
||||
default:
|
||||
cur_we->internal_error(N_("Invalid float conversion size"));
|
||||
yasm_internal_error(N_("Invalid float conversion size"));
|
||||
/*@notreached@*/
|
||||
return 1; /* never reached, but silence GCC warning */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef YASM_FLOATNUM_H
|
||||
#define YASM_FLOATNUM_H
|
||||
|
||||
void yasm_floatnum_initialize(yasm_errwarn *we);
|
||||
void yasm_floatnum_initialize(void);
|
||||
/* Clean up internal allocations */
|
||||
void yasm_floatnum_cleanup(void);
|
||||
|
||||
|
|
|
|||
35
src/intnum.c
35
src/intnum.c
|
|
@ -49,14 +49,11 @@ struct yasm_intnum {
|
|||
|
||||
/* static bitvect used for conversions */
|
||||
static /*@only@*/ wordptr conv_bv;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_intnum_initialize(yasm_errwarn *we)
|
||||
yasm_intnum_initialize(void)
|
||||
{
|
||||
cur_we = we;
|
||||
|
||||
conv_bv = BitVector_Create(BITVECT_ALLOC_SIZE, FALSE);
|
||||
BitVector_from_Dec_static_Boot(BITVECT_ALLOC_SIZE);
|
||||
}
|
||||
|
|
@ -77,8 +74,8 @@ yasm_intnum_new_dec(char *str, unsigned long lindex)
|
|||
|
||||
if (BitVector_from_Dec_static(conv_bv,
|
||||
(unsigned char *)str) == ErrCode_Ovfl)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
intn->type = INTNUM_UL;
|
||||
intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0);
|
||||
|
|
@ -98,8 +95,8 @@ yasm_intnum_new_bin(char *str, unsigned long lindex)
|
|||
intn->origsize = (unsigned char)strlen(str);
|
||||
|
||||
if(intn->origsize > BITVECT_ALLOC_SIZE)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
|
||||
BitVector_from_Bin(conv_bv, (unsigned char *)str);
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
|
|
@ -121,8 +118,8 @@ yasm_intnum_new_oct(char *str, unsigned long lindex)
|
|||
intn->origsize = strlen(str)*3;
|
||||
|
||||
if(intn->origsize > BITVECT_ALLOC_SIZE)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
|
||||
BitVector_from_Oct(conv_bv, (unsigned char *)str);
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
|
|
@ -144,8 +141,8 @@ yasm_intnum_new_hex(char *str, unsigned long lindex)
|
|||
intn->origsize = strlen(str)*4;
|
||||
|
||||
if(intn->origsize > BITVECT_ALLOC_SIZE)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("Numeric constant too large for internal format"));
|
||||
|
||||
BitVector_from_Hex(conv_bv, (unsigned char *)str);
|
||||
if (Set_Max(conv_bv) < 32) {
|
||||
|
|
@ -167,7 +164,7 @@ yasm_intnum_new_charconst_nasm(const char *str, unsigned long lindex)
|
|||
size_t len = strlen(str);
|
||||
|
||||
if (len > 4)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("character constant too large, ignoring trailing characters"));
|
||||
|
||||
intn->val.ul = 0;
|
||||
|
|
@ -275,7 +272,7 @@ yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand)
|
|||
|
||||
if (!operand && op != YASM_EXPR_NEG && op != YASM_EXPR_NOT &&
|
||||
op != YASM_EXPR_LNOT)
|
||||
cur_we->internal_error(N_("Operation needs an operand"));
|
||||
yasm_internal_error(N_("Operation needs an operand"));
|
||||
|
||||
/* A operation does a bitvector computation if result is allocated. */
|
||||
switch (op) {
|
||||
|
|
@ -446,8 +443,7 @@ yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand)
|
|||
BitVector_Copy(result, op1);
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
N_("invalid operation in intnum calculation"));
|
||||
yasm_internal_error(N_("invalid operation in intnum calculation"));
|
||||
}
|
||||
|
||||
/* If we were doing a bitvector computation... */
|
||||
|
|
@ -510,7 +506,7 @@ yasm_intnum_get_uint(const yasm_intnum *intn)
|
|||
case INTNUM_BV:
|
||||
return BitVector_Chunk_Read(intn->val.bv, 32, 0);
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown intnum type"));
|
||||
yasm_internal_error(N_("unknown intnum type"));
|
||||
/*@notreached@*/
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -538,7 +534,7 @@ yasm_intnum_get_int(const yasm_intnum *intn)
|
|||
} else
|
||||
return (long)BitVector_Chunk_Read(intn->val.bv, 32, 0);
|
||||
default:
|
||||
cur_we->internal_error(N_("unknown intnum type"));
|
||||
yasm_internal_error(N_("unknown intnum type"));
|
||||
/*@notreached@*/
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -563,8 +559,7 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, size_t size)
|
|||
case INTNUM_BV:
|
||||
buf = BitVector_Block_Read(intn->val.bv, &len);
|
||||
if (len < (unsigned int)size)
|
||||
cur_we->internal_error(
|
||||
N_("Invalid size specified (too large)"));
|
||||
yasm_internal_error(N_("Invalid size specified (too large)"));
|
||||
memcpy(ptr, buf, size);
|
||||
xfree(buf);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef YASM_INTNUM_H
|
||||
#define YASM_INTNUM_H
|
||||
|
||||
void yasm_intnum_initialize(yasm_errwarn *we);
|
||||
void yasm_intnum_initialize(void);
|
||||
/* Clean up internal allocations */
|
||||
void yasm_intnum_cleanup(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,10 @@
|
|||
|
||||
#include "hamt.h"
|
||||
|
||||
#include "errwarn.h"
|
||||
#include "linemgr.h"
|
||||
|
||||
|
||||
static /*@exits@*/ void (*efunc) (const char *file, unsigned int line,
|
||||
const char *message);
|
||||
|
||||
/* Source lines tracking */
|
||||
typedef struct {
|
||||
struct line_index_mapping *vector;
|
||||
|
|
@ -119,15 +117,11 @@ yasm_std_linemgr_set(const char *filename, unsigned long line,
|
|||
}
|
||||
|
||||
static void
|
||||
yasm_std_linemgr_initialize(/*@exits@*/
|
||||
void (*error_func) (const char *file,
|
||||
unsigned int line,
|
||||
const char *message))
|
||||
yasm_std_linemgr_initialize(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
filename_table = HAMT_new(error_func);
|
||||
efunc = error_func;
|
||||
filename_table = HAMT_new(yasm_internal_error_);
|
||||
|
||||
line_index = 1;
|
||||
|
||||
|
|
@ -216,10 +210,9 @@ yasm_std_linemgr_add_assoc_data(int type, /*@only@*/ void *data,
|
|||
|
||||
adrh->vector[line_index-1] = data;
|
||||
if (adrh->delete_func != delete_func)
|
||||
efunc(__FILE__, __LINE__,
|
||||
N_("multiple deletion functions specified"));
|
||||
yasm_internal_error(N_("multiple deletion functions specified"));
|
||||
} else {
|
||||
efunc(__FILE__, __LINE__, N_("non-common data not supported yet"));
|
||||
yasm_internal_error(N_("non-common data not supported yet"));
|
||||
delete_func(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,7 @@ typedef enum yasm_linemgr_std_type {
|
|||
|
||||
struct yasm_linemgr {
|
||||
/* Initialize cur_lindex and any manager internal data structures. */
|
||||
void (*initialize) (/*@exits@*/
|
||||
void (*error_func) (const char *file,
|
||||
unsigned int line,
|
||||
const char *message));
|
||||
void (*initialize) (void);
|
||||
|
||||
/* Cleans up any memory allocated. */
|
||||
void (*cleanup) (void);
|
||||
|
|
|
|||
115
src/main.c
115
src/main.c
|
|
@ -88,6 +88,16 @@ static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/
|
|||
const char *ext, const char *def);
|
||||
static void print_error(const char *fmt, ...);
|
||||
|
||||
static /*@exits@*/ void handle_yasm_int_error(const char *file,
|
||||
unsigned int line,
|
||||
const char *message);
|
||||
static /*@exits@*/ void handle_yasm_fatal(const char *message);
|
||||
static const char *handle_yasm_gettext(const char *msgid);
|
||||
static void print_yasm_error(const char *filename, unsigned long line,
|
||||
const char *msg);
|
||||
static void print_yasm_warning(const char *filename, unsigned long line,
|
||||
const char *msg);
|
||||
|
||||
/* values for special_options */
|
||||
#define SPECIAL_SHOW_HELP 0x01
|
||||
#define SPECIAL_SHOW_VERSION 0x02
|
||||
|
|
@ -153,11 +163,10 @@ main(int argc, char *argv[])
|
|||
textdomain(PACKAGE);
|
||||
|
||||
/* Initialize errwarn handling */
|
||||
yasm_std_errwarn.initialize();
|
||||
|
||||
/* Initialize memory allocation */
|
||||
xalloc_initialize((void (*) (int))yasm_std_errwarn.fatal,
|
||||
YASM_FATAL_NOMEM);
|
||||
yasm_internal_error_ = handle_yasm_int_error;
|
||||
yasm_fatal = handle_yasm_fatal;
|
||||
yasm_gettext_hook = handle_yasm_gettext;
|
||||
yasm_errwarn_initialize();
|
||||
|
||||
/* Set libltdl malloc/free functions. */
|
||||
#ifdef WITH_DMALLOC
|
||||
|
|
@ -223,15 +232,15 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Initialize line manager */
|
||||
yasm_std_linemgr.initialize(yasm_std_errwarn.internal_error_);
|
||||
yasm_std_linemgr.initialize();
|
||||
yasm_std_linemgr.set(in_filename, 1, 1);
|
||||
|
||||
/* Initialize intnum and floatnum */
|
||||
yasm_intnum_initialize(&yasm_std_errwarn);
|
||||
yasm_floatnum_initialize(&yasm_std_errwarn);
|
||||
yasm_intnum_initialize();
|
||||
yasm_floatnum_initialize();
|
||||
|
||||
/* Initialize symbol table */
|
||||
yasm_symrec_initialize(&yasm_std_errwarn);
|
||||
yasm_symrec_initialize();
|
||||
|
||||
/* handle preproc-only case here */
|
||||
if (preproc_only) {
|
||||
|
|
@ -261,8 +270,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Pre-process until done */
|
||||
cur_preproc->initialize(in, in_filename, &yasm_std_linemgr,
|
||||
&yasm_std_errwarn);
|
||||
cur_preproc->initialize(in, in_filename, &yasm_std_linemgr);
|
||||
while ((got = cur_preproc->input(preproc_buf, PREPROC_BUF_SIZE)) != 0)
|
||||
fwrite(preproc_buf, got, 1, obj);
|
||||
|
||||
|
|
@ -272,8 +280,9 @@ main(int argc, char *argv[])
|
|||
if (obj != stdout)
|
||||
fclose(obj);
|
||||
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
if (obj != stdout)
|
||||
remove(obj_filename);
|
||||
xfree(preproc_buf);
|
||||
|
|
@ -293,7 +302,7 @@ main(int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
cur_arch->initialize(&yasm_std_errwarn);
|
||||
cur_arch->initialize();
|
||||
|
||||
/* Set basic as the optimizer (TODO: user choice) */
|
||||
cur_optimizer = load_optimizer("basic");
|
||||
|
|
@ -304,8 +313,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
yasm_arch_common_initialize(cur_arch);
|
||||
yasm_expr_initialize(cur_arch, &yasm_std_errwarn);
|
||||
yasm_bc_initialize(cur_arch, &yasm_std_errwarn);
|
||||
yasm_expr_initialize(cur_arch);
|
||||
yasm_bc_initialize(cur_arch);
|
||||
|
||||
/* If not already specified, default to bin as the object format. */
|
||||
if (!cur_objfmt)
|
||||
|
|
@ -359,7 +368,7 @@ main(int argc, char *argv[])
|
|||
/* Initialize the object format */
|
||||
if (cur_objfmt->initialize)
|
||||
cur_objfmt->initialize(in_filename, obj_filename, cur_dbgfmt,
|
||||
cur_arch, &yasm_std_errwarn);
|
||||
cur_arch);
|
||||
|
||||
/* Set NASM as the parser */
|
||||
cur_parser = load_parser("nasm");
|
||||
|
|
@ -401,24 +410,25 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Parse! */
|
||||
sections = cur_parser->do_parse(cur_preproc, cur_arch, cur_objfmt,
|
||||
&yasm_std_linemgr, &yasm_std_errwarn, in,
|
||||
in_filename, 0);
|
||||
&yasm_std_linemgr, in, in_filename, 0);
|
||||
|
||||
/* Close input file */
|
||||
if (in != stdin)
|
||||
fclose(in);
|
||||
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
cleanup(sections);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
yasm_symrec_parser_finalize();
|
||||
cur_optimizer->optimize(sections, &yasm_std_errwarn);
|
||||
cur_optimizer->optimize(sections);
|
||||
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
cleanup(sections);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -442,14 +452,16 @@ main(int argc, char *argv[])
|
|||
/* If we had an error at this point, we also need to delete the output
|
||||
* object file (to make sure it's not left newer than the source).
|
||||
*/
|
||||
if (yasm_std_errwarn.get_num_errors(warning_error) > 0) {
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
if (yasm_get_num_errors(warning_error) > 0) {
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
remove(obj_filename);
|
||||
cleanup(sections);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
yasm_std_errwarn.output_all(&yasm_std_linemgr, warning_error);
|
||||
yasm_errwarn_output_all(&yasm_std_linemgr, warning_error,
|
||||
print_yasm_error, print_yasm_warning);
|
||||
|
||||
cleanup(sections);
|
||||
return EXIT_SUCCESS;
|
||||
|
|
@ -496,7 +508,7 @@ cleanup(yasm_sectionhead *sections)
|
|||
yasm_floatnum_cleanup();
|
||||
yasm_intnum_cleanup();
|
||||
|
||||
yasm_std_errwarn.cleanup();
|
||||
yasm_errwarn_cleanup();
|
||||
yasm_std_linemgr.cleanup();
|
||||
|
||||
BitVector_Shutdown();
|
||||
|
|
@ -611,7 +623,7 @@ opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
|
|||
|
||||
if (extra == 1) {
|
||||
/* -w, disable warnings */
|
||||
yasm_std_errwarn.warn_disable_all();
|
||||
yasm_warn_disable_all();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -631,9 +643,9 @@ opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
|
|||
warning_error = enable;
|
||||
} else if (strcmp(cmd, "unrecognized-char") == 0) {
|
||||
if (enable)
|
||||
yasm_std_errwarn.warn_enable(YASM_WARN_UNREC_CHAR);
|
||||
yasm_warn_enable(YASM_WARN_UNREC_CHAR);
|
||||
else
|
||||
yasm_std_errwarn.warn_disable(YASM_WARN_UNREC_CHAR);
|
||||
yasm_warn_disable(YASM_WARN_UNREC_CHAR);
|
||||
} else
|
||||
return 1;
|
||||
|
||||
|
|
@ -713,3 +725,44 @@ print_error(const char *fmt, ...)
|
|||
va_end(va);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
static /*@exits@*/ void
|
||||
handle_yasm_int_error(const char *file, unsigned int line, const char *message)
|
||||
{
|
||||
fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line,
|
||||
gettext(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static /*@exits@*/ void
|
||||
handle_yasm_fatal(const char *message)
|
||||
{
|
||||
fprintf(stderr, _("FATAL: %s\n"), gettext(message));
|
||||
#ifdef HAVE_ABORT
|
||||
abort();
|
||||
#else
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char *
|
||||
handle_yasm_gettext(const char *msgid)
|
||||
{
|
||||
return gettext(msgid);
|
||||
}
|
||||
|
||||
static void
|
||||
print_yasm_error(const char *filename, unsigned long line, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s:%lu: %s\n", filename, line, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
print_yasm_warning(const char *filename, unsigned long line, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s:%lu: %s %s\n", filename, line, _("warning:"), msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct yasm_objfmt {
|
|||
* provided solely for informational purposes.
|
||||
*/
|
||||
void (*initialize) (const char *in_filename, const char *obj_filename,
|
||||
yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we);
|
||||
yasm_dbgfmt *df, yasm_arch *a);
|
||||
|
||||
/* Write out (post-optimized) sections to the object file.
|
||||
* This function may call symrec functions as necessary (including
|
||||
|
|
|
|||
|
|
@ -49,17 +49,14 @@
|
|||
|
||||
yasm_objfmt yasm_bin_LTX_objfmt;
|
||||
static /*@dependent@*/ yasm_arch *cur_arch;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
static void
|
||||
bin_objfmt_initialize(/*@unused@*/ const char *in_filename,
|
||||
/*@unused@*/ const char *obj_filename,
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
|
||||
yasm_errwarn *we)
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
|
||||
{
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
}
|
||||
|
||||
/* Aligns sect to either its specified alignment (in its objfmt-specific data)
|
||||
|
|
@ -174,13 +171,12 @@ bin_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
|
||||
/* Check for complex float expressions */
|
||||
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
|
||||
cur_we->error((*ep)->line,
|
||||
N_("floating point expression too complex"));
|
||||
yasm__error((*ep)->line, N_("floating point expression too complex"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Couldn't output, assume it contains an external reference. */
|
||||
cur_we->error((*ep)->line,
|
||||
yasm__error((*ep)->line,
|
||||
N_("binary object format does not support external references"));
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -210,7 +206,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Warn that gaps are converted to 0 and write out the 0's. */
|
||||
if (gap) {
|
||||
unsigned long left;
|
||||
cur_we->warning(YASM_WARN_GENERAL, bc->line,
|
||||
yasm__warning(YASM_WARN_GENERAL, bc->line,
|
||||
N_("uninitialized space declared in code/data section: zeroing"));
|
||||
/* Write out in chunks */
|
||||
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
|
||||
|
|
@ -253,7 +249,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
bss = yasm_sections_find_general(sections, ".bss");
|
||||
|
||||
if (!text)
|
||||
cur_we->internal_error(N_("No `.text' section in bin objfmt output"));
|
||||
yasm_internal_error(N_("No `.text' section in bin objfmt output"));
|
||||
|
||||
/* First determine the actual starting offsets for .data and .bss.
|
||||
* As the order in the file is .text -> .data -> .bss (not present),
|
||||
|
|
@ -267,8 +263,7 @@ bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
assert(startexpr != NULL);
|
||||
startnum = yasm_expr_get_intnum(&startexpr, NULL);
|
||||
if (!startnum)
|
||||
cur_we->internal_error(
|
||||
N_("Complex expr for start in bin objfmt output"));
|
||||
yasm_internal_error(N_("Complex expr for start in bin objfmt output"));
|
||||
start = yasm_intnum_get_uint(startnum);
|
||||
yasm_expr_delete(startexpr);
|
||||
textstart = start;
|
||||
|
|
@ -354,8 +349,8 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
resonly = 1;
|
||||
} else {
|
||||
/* other section names not recognized. */
|
||||
cur_we->error(lindex, N_("segment name `%s' not recognized"),
|
||||
sectname);
|
||||
yasm__error(lindex, N_("segment name `%s' not recognized"),
|
||||
sectname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +361,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
unsigned long bitcnt;
|
||||
|
||||
if (strcmp(sectname, ".text") == 0) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("cannot specify an alignment to the `%s' section"),
|
||||
sectname);
|
||||
return NULL;
|
||||
|
|
@ -374,9 +369,9 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
align = yasm_expr_get_intnum(&vp->param, NULL);
|
||||
if (!align) {
|
||||
cur_we->error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
yasm__error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
return NULL;
|
||||
}
|
||||
alignval = yasm_intnum_get_uint(align);
|
||||
|
|
@ -386,9 +381,9 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
*/
|
||||
BitCount(bitcnt, alignval);
|
||||
if (bitcnt > 1) {
|
||||
cur_we->error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
yasm__error(lindex,
|
||||
N_("argument to `%s' is not a power of two"),
|
||||
vp->val);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -397,8 +392,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
}
|
||||
|
||||
retval = yasm_sections_switch_general(headp, sectname, start, resonly,
|
||||
&isnew, lindex,
|
||||
cur_we->internal_error_);
|
||||
&isnew, lindex);
|
||||
|
||||
if (isnew) {
|
||||
if (have_alignval) {
|
||||
|
|
@ -410,7 +404,7 @@ bin_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
yasm_symrec_define_label(sectname, retval, (yasm_bytecode *)NULL,
|
||||
1, lindex);
|
||||
} else if (have_alignval)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("alignment value ignored on section redeclaration"));
|
||||
|
||||
return retval;
|
||||
|
|
@ -431,7 +425,7 @@ bin_objfmt_common_declare(/*@unused@*/ yasm_symrec *sym,
|
|||
unsigned long lindex)
|
||||
{
|
||||
yasm_expr_delete(size);
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("binary object format does not support common variables"));
|
||||
}
|
||||
|
||||
|
|
@ -450,20 +444,20 @@ bin_objfmt_directive(const char *name, yasm_valparamhead *valparams,
|
|||
/* ORG takes just a simple integer as param */
|
||||
vp = yasm_vps_first(valparams);
|
||||
if (vp->val) {
|
||||
cur_we->error(lindex, N_("argument to ORG should be numeric"));
|
||||
yasm__error(lindex, N_("argument to ORG should be numeric"));
|
||||
return 0;
|
||||
} else if (vp->param)
|
||||
start = yasm_expr_get_intnum(&vp->param, NULL);
|
||||
|
||||
if (!start) {
|
||||
cur_we->error(lindex, N_("argument to ORG should be numeric"));
|
||||
yasm__error(lindex, N_("argument to ORG should be numeric"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ORG changes the start of the .text section */
|
||||
sect = yasm_sections_find_general(headp, ".text");
|
||||
if (!sect)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("bin objfmt: .text section does not exist before ORG is called?"));
|
||||
yasm_section_set_start(sect, yasm_intnum_get_uint(start), lindex);
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ static coff_symtab_head coff_symtab; /* symbol table of indexed syms */
|
|||
|
||||
yasm_objfmt yasm_coff_LTX_objfmt;
|
||||
static /*@dependent@*/ yasm_arch *cur_arch;
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
static /*@dependent@*/ coff_symtab_entry *
|
||||
|
|
@ -176,7 +175,7 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
|
|||
coff_symtab_entry *entry;
|
||||
|
||||
if (STAILQ_EMPTY(&coff_symtab))
|
||||
cur_we->internal_error(N_("empty COFF symbol table"));
|
||||
yasm_internal_error(N_("empty COFF symbol table"));
|
||||
entry = STAILQ_LAST(&coff_symtab, coff_symtab_entry, link);
|
||||
sym_data_prev = yasm_symrec_get_of_data(entry->sym);
|
||||
assert(sym_data_prev != NULL);
|
||||
|
|
@ -200,15 +199,13 @@ coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
|
|||
static void
|
||||
coff_objfmt_initialize(const char *in_filename,
|
||||
/*@unused@*/ const char *obj_filename,
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a,
|
||||
yasm_errwarn *we)
|
||||
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
|
||||
{
|
||||
yasm_symrec *filesym;
|
||||
coff_symrec_data *data;
|
||||
coff_symtab_entry *entry;
|
||||
|
||||
cur_arch = a;
|
||||
cur_we = we;
|
||||
|
||||
coff_objfmt_parse_scnum = 1; /* section numbering starts at 1 */
|
||||
STAILQ_INIT(&coff_symtab);
|
||||
|
|
@ -281,7 +278,7 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
yasm_sym_vis vis;
|
||||
|
||||
if (valsize != 4) {
|
||||
cur_we->error((*ep)->line, N_("coff: invalid relocation size"));
|
||||
yasm__error((*ep)->line, N_("coff: invalid relocation size"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -334,12 +331,11 @@ coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
|
|||
|
||||
/* Check for complex float expressions */
|
||||
if (yasm_expr__contains(*ep, YASM_EXPR_FLOAT)) {
|
||||
cur_we->error((*ep)->line,
|
||||
N_("floating point expression too complex"));
|
||||
yasm__error((*ep)->line, N_("floating point expression too complex"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
cur_we->error((*ep)->line, N_("coff: relocation too complex"));
|
||||
yasm__error((*ep)->line, N_("coff: relocation too complex"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +366,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
/* Warn that gaps are converted to 0 and write out the 0's. */
|
||||
if (gap) {
|
||||
unsigned long left;
|
||||
cur_we->warning(YASM_WARN_GENERAL, bc->line,
|
||||
yasm__warning(YASM_WARN_GENERAL, bc->line,
|
||||
N_("uninitialized space declared in code/data section: zeroing"));
|
||||
/* Write out in chunks */
|
||||
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
|
||||
|
|
@ -424,7 +420,7 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
|
|||
} else {
|
||||
pos = ftell(info->f);
|
||||
if (pos == -1) {
|
||||
cur_we->error(0, N_("could not get file position on output file"));
|
||||
yasm__error(0, N_("could not get file position on output file"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +443,7 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
|
|||
|
||||
pos = ftell(info->f);
|
||||
if (pos == -1) {
|
||||
cur_we->error(0, N_("could not get file position on output file"));
|
||||
yasm__error(0, N_("could not get file position on output file"));
|
||||
return 1;
|
||||
}
|
||||
csd->relptr = (unsigned long)pos;
|
||||
|
|
@ -458,7 +454,7 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
|
|||
|
||||
csymd = yasm_symrec_get_of_data(reloc->sym);
|
||||
if (!csymd)
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("coff: no symbol data for relocated symbol"));
|
||||
|
||||
YASM_WRITE_32_L(localbuf, reloc->addr); /* address of relocation */
|
||||
|
|
@ -498,9 +494,9 @@ coff_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d)
|
|||
YASM_WRITE_32_L(localbuf, csd->relptr); /* file ptr to relocs */
|
||||
YASM_WRITE_32_L(localbuf, 0); /* file ptr to line nums */
|
||||
if (csd->nreloc >= 64*1024) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, 0,
|
||||
N_("too many relocations in section `%s'"),
|
||||
yasm_section_get_name(sect));
|
||||
yasm__warning(YASM_WARN_GENERAL, 0,
|
||||
N_("too many relocations in section `%s'"),
|
||||
yasm_section_get_name(sect));
|
||||
YASM_WRITE_16_L(localbuf, 0xFFFF); /* max out */
|
||||
} else
|
||||
YASM_WRITE_16_L(localbuf, csd->nreloc); /* num of relocation entries */
|
||||
|
|
@ -527,7 +523,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
|
||||
/* Allocate space for headers by seeking forward */
|
||||
if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
|
||||
cur_we->error(0, N_("could not seek on output file"));
|
||||
yasm__error(0, N_("could not seek on output file"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -550,7 +546,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
/* Symbol table */
|
||||
pos = ftell(f);
|
||||
if (pos == -1) {
|
||||
cur_we->error(0, N_("could not get file position on output file"));
|
||||
yasm__error(0, N_("could not get file position on output file"));
|
||||
return;
|
||||
}
|
||||
symtab_pos = (unsigned long)pos;
|
||||
|
|
@ -569,8 +565,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
/* Get symrec's of_data (needed for storage class) */
|
||||
csymd = yasm_symrec_get_of_data(entry->sym);
|
||||
if (!csymd)
|
||||
cur_we->internal_error(
|
||||
N_("coff: expected sym data to be present"));
|
||||
yasm_internal_error(N_("coff: expected sym data to be present"));
|
||||
|
||||
/* Look at symrec for value/scnum/etc. */
|
||||
if (yasm_symrec_get_label(entry->sym, §, &precbc)) {
|
||||
|
|
@ -595,7 +590,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
intn = yasm_expr_get_intnum(&csymd->size,
|
||||
yasm_common_calc_bc_dist);
|
||||
if (!intn)
|
||||
cur_we->error(csymd->size->line,
|
||||
yasm__error(csymd->size->line,
|
||||
N_("COMMON data size not an integer expression"));
|
||||
else
|
||||
value = yasm_intnum_get_uint(intn);
|
||||
|
|
@ -642,7 +637,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
strncpy((char *)localbuf, entry->aux[0].fname, 14);
|
||||
break;
|
||||
default:
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("coff: unrecognized aux symtab type"));
|
||||
}
|
||||
fwrite(info.buf, 18, 1, f);
|
||||
|
|
@ -675,7 +670,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
|
|||
|
||||
/* Write headers */
|
||||
if (fseek(f, 0, SEEK_SET) < 0) {
|
||||
cur_we->error(0, N_("could not seek on output file"));
|
||||
yasm__error(0, N_("could not seek on output file"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -730,7 +725,7 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
sectname = vp->val;
|
||||
if (strlen(sectname) > 8) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("COFF section names limited to 8 characters: truncating"));
|
||||
sectname[8] = '\0';
|
||||
}
|
||||
|
|
@ -759,7 +754,7 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
}
|
||||
|
||||
retval = yasm_sections_switch_general(headp, sectname, 0, resonly, &isnew,
|
||||
lindex, cur_we->internal_error_);
|
||||
lindex);
|
||||
|
||||
if (isnew) {
|
||||
coff_section_data *data;
|
||||
|
|
@ -782,8 +777,8 @@ coff_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
COFF_SYMTAB_AUX_SECT);
|
||||
data->sym = sym;
|
||||
} else if (flags_override)
|
||||
cur_we->warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("section flags ignored on section redeclaration"));
|
||||
yasm__warning(YASM_WARN_GENERAL, lindex,
|
||||
N_("section flags ignored on section redeclaration"));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,14 +51,11 @@ yasm_objfmt yasm_dbg_LTX_objfmt;
|
|||
*/
|
||||
static FILE *dbg_objfmt_file;
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
static void
|
||||
dbg_objfmt_initialize(const char *in_filename, const char *obj_filename,
|
||||
yasm_dbgfmt *df, yasm_arch *a, yasm_errwarn *we)
|
||||
yasm_dbgfmt *df, yasm_arch *a)
|
||||
{
|
||||
cur_we = we;
|
||||
|
||||
dbg_objfmt_file = fopen(obj_filename, "wt");
|
||||
if (!dbg_objfmt_file) {
|
||||
fprintf(stderr, N_("could not open file `%s'"), obj_filename);
|
||||
|
|
@ -104,7 +101,7 @@ dbg_objfmt_sections_switch(yasm_sectionhead *headp,
|
|||
|
||||
if ((vp = yasm_vps_first(valparams)) && !vp->param && vp->val != NULL) {
|
||||
retval = yasm_sections_switch_general(headp, vp->val, 200, 0, &isnew,
|
||||
lindex, cur_we->internal_error_);
|
||||
lindex);
|
||||
if (isnew) {
|
||||
fprintf(dbg_objfmt_file, "(new) ");
|
||||
yasm_symrec_define_label(vp->val, retval, (yasm_bytecode *)NULL, 1,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ struct yasm_optimizer {
|
|||
* object file. (A failure is indicated by calling ErrorAt() from within
|
||||
* this function).
|
||||
*/
|
||||
void (*optimize) (yasm_sectionhead *sections, yasm_errwarn *we);
|
||||
void (*optimize) (yasm_sectionhead *sections);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
#define BCFLAG_INPROGRESS (1UL<<0)
|
||||
#define BCFLAG_DONE (1UL<<1)
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
static int basic_optimize_section_1(yasm_section *sect,
|
||||
/*@unused@*/ /*@null@*/ void *d);
|
||||
|
|
@ -138,7 +137,7 @@ basic_optimize_bytecode_1(/*@observer@*/ yasm_bytecode *bc, void *d)
|
|||
basic_optimize_calc_bc_dist_1);
|
||||
if (bcr_retval & YASM_BC_RESOLVE_UNKNOWN_LEN) {
|
||||
if (!(bcr_retval & YASM_BC_RESOLVE_ERROR))
|
||||
cur_we->error(bc->line, N_("circular reference detected."));
|
||||
yasm__error(bc->line, N_("circular reference detected."));
|
||||
data->saw_unknown = -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -190,7 +189,7 @@ basic_optimize_bytecode_2(/*@observer@*/ yasm_bytecode *bc, /*@null@*/ void *d)
|
|||
assert(data != NULL);
|
||||
|
||||
if (bc->opt_flags != BCFLAG_DONE)
|
||||
cur_we->internal_error(N_("Optimizer pass 1 missed a bytecode!"));
|
||||
yasm_internal_error(N_("Optimizer pass 1 missed a bytecode!"));
|
||||
|
||||
if (!data->precbc)
|
||||
bc->offset = 0;
|
||||
|
|
@ -212,19 +211,17 @@ basic_optimize_section_2(yasm_section *sect, /*@unused@*/ /*@null@*/ void *d)
|
|||
data.sect = sect;
|
||||
|
||||
if (yasm_section_get_opt_flags(sect) != SECTFLAG_DONE)
|
||||
cur_we->internal_error(N_("Optimizer pass 1 missed a section!"));
|
||||
yasm_internal_error(N_("Optimizer pass 1 missed a section!"));
|
||||
|
||||
return yasm_bcs_traverse(yasm_section_get_bytecodes(sect), &data,
|
||||
basic_optimize_bytecode_2);
|
||||
}
|
||||
|
||||
static void
|
||||
basic_optimize(yasm_sectionhead *sections, yasm_errwarn *we)
|
||||
basic_optimize(yasm_sectionhead *sections)
|
||||
{
|
||||
int saw_unknown = 0;
|
||||
|
||||
cur_we = we;
|
||||
|
||||
/* Optimization process: (essentially NASM's pass 1)
|
||||
* Determine the size of all bytecodes.
|
||||
* Forward references are /not/ resolved (only backward references are
|
||||
|
|
|
|||
|
|
@ -60,6 +60,6 @@ struct yasm_parser {
|
|||
*/
|
||||
yasm_sectionhead *(*do_parse)
|
||||
(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm,
|
||||
yasm_errwarn *we, FILE *f, const char *in_filename, int save_input);
|
||||
FILE *f, const char *in_filename, int save_input);
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ line: '\n' { $$ = (yasm_bytecode *)NULL; }
|
|||
$$ = (yasm_bytecode *)NULL;
|
||||
}
|
||||
| error '\n' {
|
||||
cur_we->error(cur_lindex,
|
||||
N_("label or instruction expected at start of line"));
|
||||
yasm__error(cur_lindex,
|
||||
N_("label or instruction expected at start of line"));
|
||||
$$ = (yasm_bytecode *)NULL;
|
||||
yyerrok;
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ instr: INSN {
|
|||
yasm_ops_delete(&$2.operands, 0);
|
||||
}
|
||||
| INSN error {
|
||||
cur_we->error(cur_lindex, N_("expression syntax error"));
|
||||
yasm__error(cur_lindex, N_("expression syntax error"));
|
||||
$$ = NULL;
|
||||
}
|
||||
| PREFIX instr {
|
||||
|
|
@ -228,7 +228,7 @@ datavals: dataval {
|
|||
dataval: dvexpr { $$ = yasm_dv_new_expr($1); }
|
||||
| STRING { $$ = yasm_dv_new_string($1); }
|
||||
| error {
|
||||
cur_we->error(cur_lindex, N_("expression syntax error"));
|
||||
yasm__error(cur_lindex, N_("expression syntax error"));
|
||||
$$ = (yasm_dataval *)NULL;
|
||||
}
|
||||
;
|
||||
|
|
@ -268,7 +268,7 @@ directive: DIRECTIVE_NAME directive_val {
|
|||
xfree($1);
|
||||
}
|
||||
| DIRECTIVE_NAME error {
|
||||
cur_we->error(cur_lindex, N_("invalid arguments to [%s]"), $1);
|
||||
yasm__error(cur_lindex, N_("invalid arguments to [%s]"), $1);
|
||||
xfree($1);
|
||||
}
|
||||
;
|
||||
|
|
@ -353,7 +353,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 1)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 1;
|
||||
}
|
||||
|
|
@ -361,7 +361,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 2)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 2;
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 4)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 4;
|
||||
}
|
||||
|
|
@ -377,7 +377,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 8)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 8;
|
||||
}
|
||||
|
|
@ -385,7 +385,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 10)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 10;
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ operand: '[' memaddr ']' { $$ = yasm_operand_new_mem($2); }
|
|||
$$ = $2;
|
||||
if ($$->type == YASM_INSN__OPERAND_REG &&
|
||||
nasm_parser_arch->get_reg_size($$->data.reg) != 16)
|
||||
cur_we->error(cur_lindex, N_("cannot override register size"));
|
||||
yasm__error(cur_lindex, N_("cannot override register size"));
|
||||
else
|
||||
$$->size = 16;
|
||||
}
|
||||
|
|
@ -558,7 +558,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_objfmt->extern_declare(sym, objext_valparams,
|
||||
lindex);
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "EXTERN");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "EXTERN");
|
||||
} else if (yasm__strcasecmp(name, "global") == 0) {
|
||||
vp = yasm_vps_first(valparams);
|
||||
if (vp->val) {
|
||||
|
|
@ -567,15 +567,14 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_objfmt->global_declare(sym, objext_valparams,
|
||||
lindex);
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "GLOBAL");
|
||||
} else if (yasm__strcasecmp(name, "common") == 0) {
|
||||
vp = yasm_vps_first(valparams);
|
||||
if (vp->val) {
|
||||
vp2 = yasm_vps_next(vp);
|
||||
if (!vp2 || (!vp2->val && !vp2->param))
|
||||
cur_we->error(lindex,
|
||||
N_("no size specified in %s declaration"),
|
||||
"COMMON");
|
||||
yasm__error(lindex, N_("no size specified in %s declaration"),
|
||||
"COMMON");
|
||||
else {
|
||||
if (vp2->val) {
|
||||
sym = yasm_symrec_declare(vp->val, YASM_SYM_COMMON,
|
||||
|
|
@ -596,7 +595,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
}
|
||||
}
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "COMMON");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "COMMON");
|
||||
} else if (yasm__strcasecmp(name, "section") == 0 ||
|
||||
yasm__strcasecmp(name, "segment") == 0) {
|
||||
yasm_section *new_section =
|
||||
|
|
@ -608,7 +607,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_prev_bc =
|
||||
yasm_bcs_last(yasm_section_get_bytecodes(new_section));
|
||||
} else
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"), "SECTION");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "SECTION");
|
||||
} else if (yasm__strcasecmp(name, "absolute") == 0) {
|
||||
/* it can be just an ID or a complete expression, so handle both. */
|
||||
vp = yasm_vps_first(valparams);
|
||||
|
|
@ -616,12 +615,11 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
nasm_parser_cur_section =
|
||||
yasm_sections_switch_absolute(&nasm_parser_sections,
|
||||
p_expr_new_ident(yasm_expr_sym(
|
||||
yasm_symrec_use(vp->val, lindex))),
|
||||
cur_we->internal_error_);
|
||||
yasm_symrec_use(vp->val, lindex))));
|
||||
else if (vp->param) {
|
||||
nasm_parser_cur_section =
|
||||
yasm_sections_switch_absolute(&nasm_parser_sections, vp->param,
|
||||
cur_we->internal_error_);
|
||||
yasm_sections_switch_absolute(&nasm_parser_sections,
|
||||
vp->param);
|
||||
vp->param = NULL;
|
||||
}
|
||||
nasm_parser_prev_bc = (yasm_bytecode *)NULL;
|
||||
|
|
@ -633,8 +631,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
const yasm_intnum *intcpu;
|
||||
intcpu = yasm_expr_get_intnum(&vp->param, NULL);
|
||||
if (!intcpu)
|
||||
cur_we->error(lindex, N_("invalid argument to [%s]"),
|
||||
"CPU");
|
||||
yasm__error(lindex, N_("invalid argument to [%s]"), "CPU");
|
||||
else {
|
||||
char strcpu[16];
|
||||
sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu));
|
||||
|
|
@ -649,7 +646,7 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
;
|
||||
} else if (nasm_parser_objfmt->directive(name, valparams, objext_valparams,
|
||||
&nasm_parser_sections, lindex)) {
|
||||
cur_we->error(lindex, N_("unrecognized directive [%s]"), name);
|
||||
yasm__error(lindex, N_("unrecognized directive [%s]"), name);
|
||||
}
|
||||
|
||||
yasm_vps_delete(valparams);
|
||||
|
|
@ -660,6 +657,6 @@ nasm_parser_directive(const char *name, yasm_valparamhead *valparams,
|
|||
static void
|
||||
nasm_parser_error(const char *s)
|
||||
{
|
||||
cur_we->parser_error(cur_lindex, s);
|
||||
yasm__parser_error(cur_lindex, s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,23 +50,21 @@ size_t nasm_parser_locallabel_base_len = 0;
|
|||
/*@dependent@*/ yasm_arch *nasm_parser_arch;
|
||||
/*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
|
||||
/*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
|
||||
/*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
|
||||
|
||||
int nasm_parser_save_input;
|
||||
|
||||
static /*@dependent@*/ yasm_sectionhead *
|
||||
nasm_parser_do_parse(yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of,
|
||||
yasm_linemgr *lm, yasm_errwarn *we, FILE *f,
|
||||
const char *in_filename, int save_input)
|
||||
yasm_linemgr *lm, FILE *f, const char *in_filename,
|
||||
int save_input)
|
||||
/*@globals killed nasm_parser_locallabel_base @*/
|
||||
{
|
||||
pp->initialize(f, in_filename, lm, we);
|
||||
pp->initialize(f, in_filename, lm);
|
||||
nasm_parser_in = f;
|
||||
nasm_parser_input = pp->input;
|
||||
nasm_parser_arch = a;
|
||||
nasm_parser_objfmt = of;
|
||||
nasm_parser_linemgr = lm;
|
||||
nasm_parser_errwarn = we;
|
||||
nasm_parser_save_input = save_input;
|
||||
|
||||
/* Initialize section list */
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ extern size_t nasm_parser_locallabel_base_len;
|
|||
extern /*@dependent@*/ yasm_arch *nasm_parser_arch;
|
||||
extern /*@dependent@*/ yasm_objfmt *nasm_parser_objfmt;
|
||||
extern /*@dependent@*/ yasm_linemgr *nasm_parser_linemgr;
|
||||
extern /*@dependent@*/ yasm_errwarn *nasm_parser_errwarn;
|
||||
|
||||
extern int nasm_parser_save_input;
|
||||
|
||||
|
|
@ -55,6 +54,4 @@ extern int nasm_parser_save_input;
|
|||
#define p_expr_new_branch(o,r) yasm_expr_new_branch(o,r,cur_lindex)
|
||||
#define p_expr_new_ident(r) yasm_expr_new_ident(r,cur_lindex)
|
||||
|
||||
#define cur_we nasm_parser_errwarn
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -366,9 +366,8 @@ scan:
|
|||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
} else if (!nasm_parser_locallabel_base) {
|
||||
cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("no non-local label before `%s'"),
|
||||
s.tok[0]);
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("no non-local label before `%s'"), s.tok[0]);
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
} else {
|
||||
len = TOKLEN + nasm_parser_locallabel_base_len;
|
||||
|
|
@ -410,7 +409,7 @@ scan:
|
|||
case YASM_ARCH_CHECK_ID_TARGETMOD:
|
||||
RETURN(TARGETMOD);
|
||||
default:
|
||||
cur_we->warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
yasm__warning(YASM_WARN_GENERAL, cur_lindex,
|
||||
N_("Arch feature not supported, treating as identifier"));
|
||||
yylval.str_val = xstrndup(s.tok, TOKLEN);
|
||||
RETURN(ID);
|
||||
|
|
@ -429,9 +428,9 @@ scan:
|
|||
}
|
||||
|
||||
any {
|
||||
cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(s.tok[0]));
|
||||
yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(s.tok[0]));
|
||||
goto scan;
|
||||
}
|
||||
*/
|
||||
|
|
@ -470,9 +469,9 @@ linechg:
|
|||
}
|
||||
|
||||
any {
|
||||
cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(s.tok[0]));
|
||||
yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(s.tok[0]));
|
||||
goto linechg;
|
||||
}
|
||||
*/
|
||||
|
|
@ -516,9 +515,9 @@ directive:
|
|||
}
|
||||
|
||||
any {
|
||||
cur_we->warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(s.tok[0]));
|
||||
yasm__warning(YASM_WARN_UNREC_CHAR, cur_lindex,
|
||||
N_("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(s.tok[0]));
|
||||
goto directive;
|
||||
}
|
||||
*/
|
||||
|
|
@ -535,10 +534,10 @@ stringconst_scan:
|
|||
/*!re2c
|
||||
"\n" {
|
||||
if (cursor == s.eof)
|
||||
cur_we->error(cur_lindex,
|
||||
N_("unexpected end of file in string"));
|
||||
yasm__error(cur_lindex,
|
||||
N_("unexpected end of file in string"));
|
||||
else
|
||||
cur_we->error(cur_lindex, N_("unterminated string"));
|
||||
yasm__error(cur_lindex, N_("unterminated string"));
|
||||
strbuf[count] = '\0';
|
||||
yylval.str_val = strbuf;
|
||||
if (nasm_parser_save_input && cursor != s.eof)
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ struct yasm_preproc {
|
|||
* This function also takes the FILE * to the initial starting file and
|
||||
* the filename.
|
||||
*/
|
||||
void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we);
|
||||
void (*initialize) (FILE *f, const char *in_filename, yasm_linemgr *lm);
|
||||
|
||||
/* Cleans up any allocated memory. */
|
||||
void (*cleanup) (void);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
static FILE *in;
|
||||
static yasm_linemgr *cur_lm;
|
||||
static yasm_errwarn *cur_we;
|
||||
static char *line, *linepos;
|
||||
static size_t lineleft;
|
||||
static char *file_name;
|
||||
|
|
@ -95,17 +94,17 @@ nasm_efunc(int severity, const char *fmt, ...)
|
|||
va_start(va, fmt);
|
||||
switch (severity & ERR_MASK) {
|
||||
case ERR_WARNING:
|
||||
cur_we->warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
|
||||
va);
|
||||
yasm__warning_va(YASM_WARN_PREPROC, cur_lm->get_current(), fmt,
|
||||
va);
|
||||
break;
|
||||
case ERR_NONFATAL:
|
||||
cur_we->error_va(cur_lm->get_current(), fmt, va);
|
||||
yasm__error_va(cur_lm->get_current(), fmt, va);
|
||||
break;
|
||||
case ERR_FATAL:
|
||||
cur_we->fatal(YASM_FATAL_UNKNOWN); /* FIXME */
|
||||
yasm_fatal(N_("unknown")); /* FIXME */
|
||||
break;
|
||||
case ERR_PANIC:
|
||||
cur_we->internal_error(fmt); /* FIXME */
|
||||
yasm_internal_error(fmt); /* FIXME */
|
||||
break;
|
||||
case ERR_DEBUG:
|
||||
break;
|
||||
|
|
@ -114,12 +113,10 @@ nasm_efunc(int severity, const char *fmt, ...)
|
|||
}
|
||||
|
||||
static void
|
||||
nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we)
|
||||
nasm_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
||||
{
|
||||
in = f;
|
||||
cur_lm = lm;
|
||||
cur_we = we;
|
||||
line = NULL;
|
||||
file_name = NULL;
|
||||
prior_linnum = 0;
|
||||
|
|
|
|||
|
|
@ -36,17 +36,14 @@
|
|||
static int is_interactive;
|
||||
static FILE *in;
|
||||
static yasm_linemgr *cur_lm;
|
||||
static yasm_errwarn *cur_we;
|
||||
|
||||
int isatty(int);
|
||||
|
||||
static void
|
||||
raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we)
|
||||
raw_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
||||
{
|
||||
in = f;
|
||||
cur_lm = lm;
|
||||
cur_we = we;
|
||||
/*@-unrecog@*/
|
||||
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
|
||||
/*@=unrecog@*/
|
||||
|
|
@ -69,11 +66,10 @@ raw_preproc_input(char *buf, size_t max_size)
|
|||
if (c == '\n')
|
||||
buf[n++] = (char)c;
|
||||
if (c == EOF && ferror(in))
|
||||
cur_we->error(cur_lm->get_current(),
|
||||
N_("error when reading from file"));
|
||||
yasm__error(cur_lm->get_current(),
|
||||
N_("error when reading from file"));
|
||||
} else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
|
||||
cur_we->error(cur_lm->get_current(),
|
||||
N_("error when reading from file"));
|
||||
yasm__error(cur_lm->get_current(), N_("error when reading from file"));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ static YAPP_Output current_output;
|
|||
YYSTYPE yapp_preproc_lval;
|
||||
|
||||
/*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
|
||||
/*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
|
||||
|
||||
int isatty(int);
|
||||
|
||||
|
|
@ -120,13 +119,13 @@ yapp_macro_insert (char *name, int argc, int fillargs)
|
|||
void
|
||||
yapp_macro_error_exists (YAPP_Macro *v)
|
||||
{
|
||||
if (v) cur_we->error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
|
||||
if (v) yasm__error(cur_lindex, N_("Redefining macro of the same name %d:%d"), v->type, v->args);
|
||||
}
|
||||
|
||||
void
|
||||
yapp_macro_error_sameargname (YAPP_Macro *v)
|
||||
{
|
||||
if (v) cur_we->error(cur_lindex, N_("Duplicate argument names in macro"));
|
||||
if (v) yasm__error(cur_lindex, N_("Duplicate argument names in macro"));
|
||||
}
|
||||
|
||||
YAPP_Macro *
|
||||
|
|
@ -141,7 +140,7 @@ yapp_define_insert (char *name, int argc, int fillargs)
|
|||
if ((argc >= 0 && ym->args < 0)
|
||||
|| (argc < 0 && ym->args >= 0))
|
||||
{
|
||||
cur_we->warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
|
||||
yasm__warning(YASM_WARN_PREPROC, cur_lindex, N_("Attempted %%define both with and without parameters"));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -237,12 +236,10 @@ void
|
|||
expand_token_list(struct source_head *paramexp, struct source_head *to_head, source **to_tail);
|
||||
|
||||
static void
|
||||
yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
||||
yasm_errwarn *we)
|
||||
yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm)
|
||||
{
|
||||
is_interactive = f ? (isatty(fileno(f)) > 0) : 0;
|
||||
yapp_preproc_linemgr = lm;
|
||||
yapp_preproc_errwarn = we;
|
||||
yapp_preproc_current_file = xstrdup(in_filename);
|
||||
yapp_preproc_line_number = 1;
|
||||
yapp_lex_initialize(f);
|
||||
|
|
@ -254,7 +251,7 @@ yapp_preproc_initialize(FILE *f, const char *in_filename, yasm_linemgr *lm,
|
|||
out->out = current_output = YAPP_OUTPUT;
|
||||
SLIST_INSERT_HEAD(&output_head, out, next);
|
||||
|
||||
macro_table = HAMT_new(we->internal_error_);
|
||||
macro_table = HAMT_new(yasm_internal_error_);
|
||||
|
||||
source_tail = SLIST_FIRST(&source_head);
|
||||
macro_tail = SLIST_FIRST(¯o_head);
|
||||
|
|
@ -470,7 +467,7 @@ eat_through_return(struct source_head *to_head, source **to_tail)
|
|||
while ((token = yapp_preproc_lex()) != '\n') {
|
||||
if (token == 0)
|
||||
return 0;
|
||||
cur_we->error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
|
||||
yasm__error(cur_lindex, N_("Skipping possibly valid %%define stuff"));
|
||||
}
|
||||
append_token('\n', to_head, to_tail);
|
||||
return '\n';
|
||||
|
|
@ -483,7 +480,7 @@ yapp_get_ident(const char *synlvl)
|
|||
if (token == WHITESPACE)
|
||||
token = yapp_preproc_lex();
|
||||
if (token != IDENT) {
|
||||
cur_we->error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
|
||||
yasm__error(cur_lindex, N_("Identifier expected after %%%s"), synlvl);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
|
@ -511,7 +508,7 @@ expand_macro(char *name,
|
|||
|
||||
ydebug(("YAPP: +Expand macro %s...\n", name));
|
||||
|
||||
if (ym->expanding) cur_we->internal_error(N_("Recursively expanding a macro!"));
|
||||
if (ym->expanding) yasm_internal_error(N_("Recursively expanding a macro!"));
|
||||
|
||||
if (ym->type == YAPP_DEFINE) {
|
||||
if (ym->args == -1) {
|
||||
|
|
@ -543,7 +540,7 @@ expand_macro(char *name,
|
|||
|
||||
/* find out what we got */
|
||||
if (from_head) {
|
||||
cur_we->internal_error(N_("Expanding macro with non-null from_head ugh\n"));
|
||||
yasm_internal_error(N_("Expanding macro with non-null from_head ugh\n"));
|
||||
}
|
||||
token = yapp_preproc_lex();
|
||||
append_token(token, &replay_head, &replay_tail);
|
||||
|
|
@ -590,9 +587,9 @@ expand_macro(char *name,
|
|||
|
||||
default:
|
||||
if (token < 256)
|
||||
cur_we->internal_error(N_("Unexpected character token in parameter expansion"));
|
||||
yasm_internal_error(N_("Unexpected character token in parameter expansion"));
|
||||
else
|
||||
cur_we->error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
|
||||
yasm__error(cur_lindex, N_("Cannot handle preprocessor items inside possible macro invocation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -612,7 +609,7 @@ expand_macro(char *name,
|
|||
ym->expanding = 1;
|
||||
|
||||
/* so the macro exists. build a HAMT parameter table */
|
||||
param_table = HAMT_new(cur_we->internal_error_);
|
||||
param_table = HAMT_new(yasm_internal_error_);
|
||||
/* fill the entries by walking the replay buffer and create
|
||||
* "macros". coincidentally, clear the replay buffer. */
|
||||
|
||||
|
|
@ -688,11 +685,11 @@ expand_macro(char *name,
|
|||
xfree(replay);
|
||||
}
|
||||
else if (param) {
|
||||
cur_we->internal_error(N_("Got to end of arglist before end of replay!"));
|
||||
yasm_internal_error(N_("Got to end of arglist before end of replay!"));
|
||||
}
|
||||
replay = SLIST_FIRST(&replay_head);
|
||||
if (replay || param)
|
||||
cur_we->internal_error(N_("Count and distribution of define args mismatched!"));
|
||||
yasm_internal_error(N_("Count and distribution of define args mismatched!"));
|
||||
|
||||
/* the param_table is set up without errors, so expansion is ready
|
||||
* to go */
|
||||
|
|
@ -726,7 +723,7 @@ expand_macro(char *name,
|
|||
}
|
||||
}
|
||||
else
|
||||
cur_we->internal_error(N_("Invoking Macros not yet supported"));
|
||||
yasm_internal_error(N_("Invoking Macros not yet supported"));
|
||||
|
||||
ym->expanding = 0;
|
||||
}
|
||||
|
|
@ -772,7 +769,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
append_token(token, &source_head, &source_tail);
|
||||
/*if (append_to_return()==0) state=YAPP_STATE_EOF;*/
|
||||
ydebug(("YAPP: default: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val));
|
||||
/*cur_we->error(cur_lindex, N_("YAPP got an unhandled token."));*/
|
||||
/*yasm__error(cur_lindex, N_("YAPP got an unhandled token."));*/
|
||||
break;
|
||||
|
||||
case IDENT:
|
||||
|
|
@ -795,7 +792,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
|
||||
case CLEAR:
|
||||
HAMT_delete(macro_table, (void (*)(void *))yapp_macro_delete);
|
||||
macro_table = HAMT_new(cur_we->internal_error_);
|
||||
macro_table = HAMT_new(yasm_internal_error_);
|
||||
break;
|
||||
|
||||
case DEFINE:
|
||||
|
|
@ -841,7 +838,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
break;
|
||||
}
|
||||
else if (last_token == ',' || token != ',')
|
||||
cur_we->error(cur_lindex, N_("Unexpected token in %%define parameters"));
|
||||
yasm__error(cur_lindex, N_("Unexpected token in %%define parameters"));
|
||||
last_token = token;
|
||||
}
|
||||
if (token == ')') {
|
||||
|
|
@ -858,7 +855,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
append_token('\n', &source_head, &source_tail);
|
||||
}
|
||||
else {
|
||||
cur_we->internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
|
||||
yasm_internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident"));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -921,7 +918,7 @@ yapp_preproc_input(char *buf, size_t max_size)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
cur_we->error(cur_lindex, N_("YAPP got into a bad state"));
|
||||
yasm__error(cur_lindex, N_("YAPP got into a bad state"));
|
||||
}
|
||||
if (need_line_directive) {
|
||||
append_token(LINE, &source_head, &source_tail);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,5 @@ void yapp_lex_initialize(FILE *f);
|
|||
void set_inhibit(void);
|
||||
|
||||
extern /*@dependent@*/ yasm_linemgr *yapp_preproc_linemgr;
|
||||
extern /*@dependent@*/ yasm_errwarn *yapp_preproc_errwarn;
|
||||
#define cur_lindex (yapp_preproc_linemgr->get_current())
|
||||
#define cur_we yapp_preproc_errwarn
|
||||
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ DIR %[ \t]*
|
|||
}
|
||||
|
||||
if(inch == '\n')
|
||||
cur_we->error(cur_lindex, _("unterminated string"));
|
||||
yasm__error(cur_lindex, _("unterminated string"));
|
||||
else if(inch == EOF)
|
||||
cur_we->error(cur_lindex, _("unexpected end of file in string"));
|
||||
yasm__error(cur_lindex, _("unexpected end of file in string"));
|
||||
|
||||
strbuf[count] = '\0';
|
||||
|
||||
|
|
@ -172,8 +172,8 @@ DIR %[ \t]*
|
|||
/* FIXME: handle includes that aren't relative */
|
||||
incfile = fopen (yytext, "r");
|
||||
if(!incfile) {
|
||||
cur_we->error(cur_lindex, _("include file `%s': %s"),
|
||||
yytext, strerror(errno));
|
||||
yasm__error(cur_lindex, _("include file `%s': %s"),
|
||||
yytext, strerror(errno));
|
||||
xfree(inc);
|
||||
}
|
||||
else {
|
||||
|
|
@ -330,12 +330,12 @@ DIR %[ \t]*
|
|||
[][+*/,()-] { return yytext[0]; }
|
||||
|
||||
<inhibit>. {
|
||||
cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), cur_we->conv_unprint(yytext[0]));
|
||||
yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("Unhandled character in <inhibit> `%s'"), yasm__conv_unprint(yytext[0]));
|
||||
}
|
||||
|
||||
. {
|
||||
cur_we->warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
|
||||
cur_we->conv_unprint(yytext[0]));
|
||||
yasm__warning(YASM_WARN_PREPROC, cur_lindex, _("ignoring unrecognized character `%s'"),
|
||||
yasm__conv_unprint(yytext[0]));
|
||||
}
|
||||
|
||||
%%
|
||||
|
|
|
|||
|
|
@ -59,9 +59,6 @@ struct yasm_section {
|
|||
int res_only; /* allow only resb family of bytecodes? */
|
||||
|
||||
yasm_bytecodehead bc; /* the bytecodes for the section's contents */
|
||||
|
||||
/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message);
|
||||
};
|
||||
|
||||
/*@-compdestroy@*/
|
||||
|
|
@ -90,10 +87,7 @@ yasm_sections_initialize(yasm_sectionhead *headp, yasm_objfmt *of)
|
|||
yasm_section *
|
||||
yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
||||
unsigned long start, int res_only, int *isnew,
|
||||
unsigned long lindex,
|
||||
/*@exits@*/ void (*error_func)
|
||||
(const char *file, unsigned int line,
|
||||
const char *message))
|
||||
unsigned long lindex)
|
||||
{
|
||||
yasm_section *s;
|
||||
|
||||
|
|
@ -125,8 +119,6 @@ yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
|||
s->opt_flags = 0;
|
||||
s->res_only = res_only;
|
||||
|
||||
s->error_func = error_func;
|
||||
|
||||
*isnew = 1;
|
||||
return s;
|
||||
}
|
||||
|
|
@ -134,10 +126,7 @@ yasm_sections_switch_general(yasm_sectionhead *headp, const char *name,
|
|||
|
||||
/*@-onlytrans@*/
|
||||
yasm_section *
|
||||
yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start,
|
||||
/*@exits@*/ void (*error_func)
|
||||
(const char *file, unsigned int line,
|
||||
const char *message))
|
||||
yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start)
|
||||
{
|
||||
yasm_section *s;
|
||||
|
||||
|
|
@ -151,8 +140,6 @@ yasm_sections_switch_absolute(yasm_sectionhead *headp, yasm_expr *start,
|
|||
s->opt_flags = 0;
|
||||
s->res_only = 1;
|
||||
|
||||
s->error_func = error_func;
|
||||
|
||||
return s;
|
||||
}
|
||||
/*@=onlytrans@*/
|
||||
|
|
@ -183,7 +170,7 @@ yasm_section_set_of_data(yasm_section *sect, yasm_objfmt *of, void *of_data)
|
|||
if (of->section_data_delete)
|
||||
of->section_data_delete(of_data);
|
||||
else
|
||||
sect->error_func(__FILE__, __LINE__,
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific section data"));
|
||||
return;
|
||||
}
|
||||
|
|
@ -194,7 +181,7 @@ yasm_section_set_of_data(yasm_section *sect, yasm_objfmt *of, void *of_data)
|
|||
if (of2->section_data_delete)
|
||||
of2->section_data_delete(sect->data.general.of_data);
|
||||
else
|
||||
sect->error_func(__FILE__, __LINE__,
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific section data"));
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +296,7 @@ yasm_section_delete(yasm_section *sect)
|
|||
if (of->section_data_delete)
|
||||
of->section_data_delete(sect->data.general.of_data);
|
||||
else
|
||||
sect->error_func(__FILE__, __LINE__,
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific section data"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,10 @@
|
|||
|
||||
/*@dependent@*/ yasm_section *yasm_sections_switch_general
|
||||
(yasm_sectionhead *headp, const char *name, unsigned long start,
|
||||
int res_only, /*@out@*/ int *isnew, unsigned long lindex,
|
||||
/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message));
|
||||
int res_only, /*@out@*/ int *isnew, unsigned long lindex);
|
||||
|
||||
/*@dependent@*/ yasm_section *yasm_sections_switch_absolute
|
||||
(yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start,
|
||||
/*@exits@*/ void (*error_func) (const char *file, unsigned int line,
|
||||
const char *message));
|
||||
(yasm_sectionhead *headp, /*@keep@*/ yasm_expr *start);
|
||||
|
||||
int yasm_section_is_absolute(yasm_section *sect);
|
||||
|
||||
|
|
|
|||
24
src/symrec.c
24
src/symrec.c
|
|
@ -92,15 +92,11 @@ typedef /*@reldef@*/ SLIST_HEAD(nontablesymhead_s, non_table_symrec_s)
|
|||
nontablesymhead;
|
||||
static /*@only@*/ nontablesymhead *non_table_syms;
|
||||
|
||||
static /*@dependent@*/ yasm_errwarn *cur_we;
|
||||
|
||||
|
||||
void
|
||||
yasm_symrec_initialize(yasm_errwarn *we)
|
||||
yasm_symrec_initialize(void)
|
||||
{
|
||||
cur_we = we;
|
||||
|
||||
sym_table = HAMT_new(cur_we->internal_error_);
|
||||
sym_table = HAMT_new(yasm_internal_error_);
|
||||
non_table_syms = xmalloc(sizeof(nontablesymhead));
|
||||
SLIST_INIT(non_table_syms);
|
||||
}
|
||||
|
|
@ -116,7 +112,7 @@ symrec_delete_one(/*@only@*/ void *d)
|
|||
if (sym->of->symrec_data_delete)
|
||||
sym->of->symrec_data_delete(sym->of_data);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific data"));
|
||||
}
|
||||
xfree(sym);
|
||||
|
|
@ -201,7 +197,7 @@ symrec_define(const char *name, sym_type type, int in_table,
|
|||
/* Has it been defined before (either by DEFINED or COMMON/EXTERN)? */
|
||||
if ((rec->status & SYM_DEFINED) ||
|
||||
(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN))) {
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("duplicate definition of `%s'; first defined on line %lu"),
|
||||
name, rec->line);
|
||||
} else {
|
||||
|
|
@ -255,7 +251,7 @@ yasm_symrec_declare(const char *name, yasm_sym_vis vis, unsigned long lindex)
|
|||
((rec->visibility & YASM_SYM_EXTERN) && (vis == YASM_SYM_EXTERN)))))
|
||||
rec->visibility |= vis;
|
||||
else
|
||||
cur_we->error(lindex,
|
||||
yasm__error(lindex,
|
||||
N_("duplicate definition of `%s'; first defined on line %lu"),
|
||||
name, rec->line);
|
||||
return rec;
|
||||
|
|
@ -321,7 +317,7 @@ yasm_symrec_set_of_data(yasm_symrec *sym, yasm_objfmt *of, void *of_data)
|
|||
if (sym->of->symrec_data_delete)
|
||||
sym->of->symrec_data_delete(sym->of_data);
|
||||
else
|
||||
cur_we->internal_error(
|
||||
yasm_internal_error(
|
||||
N_("don't know how to delete objfmt-specific data"));
|
||||
}
|
||||
sym->of = of;
|
||||
|
|
@ -336,8 +332,8 @@ symrec_parser_finalize_checksym(yasm_symrec *sym,
|
|||
/* error if a symbol is used but never defined or extern/common declared */
|
||||
if ((sym->status & SYM_USED) && !(sym->status & SYM_DEFINED) &&
|
||||
!(sym->visibility & (YASM_SYM_EXTERN | YASM_SYM_COMMON))) {
|
||||
cur_we->error(sym->line, N_("undefined symbol `%s' (first use)"),
|
||||
sym->name);
|
||||
yasm__error(sym->line, N_("undefined symbol `%s' (first use)"),
|
||||
sym->name);
|
||||
if (sym->line < firstundef_line)
|
||||
firstundef_line = sym->line;
|
||||
}
|
||||
|
|
@ -351,8 +347,8 @@ yasm_symrec_parser_finalize(void)
|
|||
firstundef_line = ULONG_MAX;
|
||||
yasm_symrec_traverse(NULL, symrec_parser_finalize_checksym);
|
||||
if (firstundef_line < ULONG_MAX)
|
||||
cur_we->error(firstundef_line,
|
||||
N_(" (Each undefined symbol is reported only once.)"));
|
||||
yasm__error(firstundef_line,
|
||||
N_(" (Each undefined symbol is reported only once.)"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef YASM_SYMREC_H
|
||||
#define YASM_SYMREC_H
|
||||
|
||||
void yasm_symrec_initialize(yasm_errwarn *we);
|
||||
void yasm_symrec_initialize(void);
|
||||
|
||||
/*@dependent@*/ yasm_symrec *yasm_symrec_use(const char *name,
|
||||
unsigned long lindex);
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ main(void)
|
|||
Suite *s = floatnum_suite();
|
||||
SRunner *sr = srunner_create(s);
|
||||
BitVector_Boot();
|
||||
yasm_floatnum_initialize(NULL);
|
||||
yasm_floatnum_initialize();
|
||||
srunner_run_all(sr, CRNORMAL);
|
||||
nf = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
|
|
|
|||
|
|
@ -130,8 +130,6 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
|
|||
/*@only@*/ char *xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines in xmalloc.c. */
|
||||
void xalloc_initialize(/*@exits@*/ void (*fatal_func) (int type),
|
||||
int nomem_fatal_type);
|
||||
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
|
||||
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
|
||||
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
|
||||
|
|
|
|||
|
|
@ -27,17 +27,8 @@
|
|||
#include "util.h"
|
||||
RCSID("$IdPath$");
|
||||
|
||||
#include "errwarn.h"
|
||||
|
||||
static /*@exits@*/ void (*fatal_func) (int type);
|
||||
static int nomem_fatal_type;
|
||||
|
||||
|
||||
void
|
||||
xalloc_initialize(/*@exits@*/ void (*f) (int type), int t)
|
||||
{
|
||||
fatal_func = f;
|
||||
nomem_fatal_type = t;
|
||||
}
|
||||
|
||||
#ifndef WITH_DMALLOC
|
||||
|
||||
|
|
@ -50,7 +41,7 @@ xmalloc(size_t size)
|
|||
size = 1;
|
||||
newmem = malloc(size);
|
||||
if (!newmem)
|
||||
fatal_func(nomem_fatal_type);
|
||||
yasm_fatal(N_("out of memory"));
|
||||
|
||||
return newmem;
|
||||
}
|
||||
|
|
@ -65,7 +56,7 @@ xcalloc(size_t nelem, size_t elsize)
|
|||
|
||||
newmem = calloc(nelem, elsize);
|
||||
if (!newmem)
|
||||
fatal_func(nomem_fatal_type);
|
||||
yasm_fatal(N_("out of memory"));
|
||||
|
||||
return newmem;
|
||||
}
|
||||
|
|
@ -82,7 +73,7 @@ xrealloc(void *oldmem, size_t size)
|
|||
else
|
||||
newmem = realloc(oldmem, size);
|
||||
if (!newmem)
|
||||
fatal_func(nomem_fatal_type);
|
||||
yasm_fatal(N_("out of memory"));
|
||||
|
||||
return newmem;
|
||||
}
|
||||
|
|
|
|||
2
util.h
2
util.h
|
|
@ -130,8 +130,6 @@ int yasm__strncasecmp(const char *s1, const char *s2, size_t n);
|
|||
/*@only@*/ char *xstrdup(const char *str);
|
||||
|
||||
/* Error-checking memory allocation routines in xmalloc.c. */
|
||||
void xalloc_initialize(/*@exits@*/ void (*fatal_func) (int type),
|
||||
int nomem_fatal_type);
|
||||
/*@only@*/ /*@out@*/ void *xmalloc(size_t size);
|
||||
/*@only@*/ void *xcalloc(size_t nelem, size_t elsize);
|
||||
/*@only@*/ void *xrealloc(/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue