From 41087068aa3d5ddac8b28cb2bdcacd606f475c08 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 3 Mar 2016 14:27:34 -0800 Subject: Replace nasm_error(ERR_FATAL/ERR_PANIC) with nasm_fatal/nasm_panic Replace all instances of ERR_FATAL or ERR_PANIC with nasm_fatal or nasm_panic so the compiler knows that these functions cannot return, *and* we trigger abort() if we were to ever violate that constraint. Signed-off-by: H. Peter Anvin --- labels.c | 2 +- lib/vsnprintf.c | 4 ++-- nasm.c | 26 +++++++++++++------------- nasmlib.c | 4 ++-- output/outaout.c | 6 +++--- output/outas86.c | 8 ++++---- output/outbin.c | 20 ++++++++++---------- output/outcoff.c | 8 ++++---- output/outelf32.c | 8 ++++---- output/outelf64.c | 16 ++++++++-------- output/outelfx32.c | 14 +++++++------- output/outieee.c | 18 +++++++++--------- output/outmacho.c | 2 +- output/outobj.c | 18 +++++++++--------- output/outrdf2.c | 18 +++++++++--------- parser.c | 2 +- preproc-nop.c | 2 +- preproc.c | 2 +- 18 files changed, 89 insertions(+), 89 deletions(-) diff --git a/labels.c b/labels.c index e14fe474..9f2b76e6 100644 --- a/labels.c +++ b/labels.c @@ -234,7 +234,7 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special, lptr = find_label(label, 1); if (!lptr) - nasm_error(ERR_PANIC, "can't find label `%s' on pass two", label); + nasm_panic(0, "can't find label `%s' on pass two", label); if (!islocal(label)) { if (!islocalchar(*label) && lptr->defn.is_norm) diff --git a/lib/vsnprintf.c b/lib/vsnprintf.c index bc54f949..ecca3e66 100644 --- a/lib/vsnprintf.c +++ b/lib/vsnprintf.c @@ -23,7 +23,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap) int rv, bytes; if (size > BUFFER_SIZE) { - nasm_error(ERR_PANIC|ERR_NOFILE, + nasm_panic(ERR_NOFILE, "vsnprintf: size (%d) > BUFFER_SIZE (%d)", size, BUFFER_SIZE); size = BUFFER_SIZE; @@ -31,7 +31,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap) rv = vsprintf(snprintf_buffer, format, ap); if (rv >= BUFFER_SIZE) - nasm_error(ERR_PANIC|ERR_NOFILE, "vsnprintf buffer overflow"); + nasm_panic(ERR_NOFILE, "vsnprintf buffer overflow"); if (size > 0) { if ((size_t)rv < size-1) diff --git a/nasm.c b/nasm.c index 5556e061..ba42aa88 100644 --- a/nasm.c +++ b/nasm.c @@ -393,7 +393,7 @@ int main(int argc, char **argv) if (*outname) { ofile = fopen(outname, "w"); if (!ofile) - nasm_error(ERR_FATAL | ERR_NOFILE, + nasm_fatal(ERR_NOFILE, "unable to open output file `%s'", outname); } else @@ -446,7 +446,7 @@ int main(int argc, char **argv) ofile = fopen(outname, (ofmt->flags & OFMT_TEXT) ? "w" : "wb"); if (!ofile) - nasm_error(ERR_FATAL | ERR_NOFILE, + nasm_fatal(ERR_NOFILE, "unable to open output file `%s'", outname); /* @@ -519,7 +519,7 @@ static void copy_filename(char *dst, const char *src) size_t len = strlen(src); if (len >= (size_t)FILENAME_MAX) { - nasm_error(ERR_FATAL | ERR_NOFILE, "file name too long"); + nasm_fatal(ERR_NOFILE, "file name too long"); return; } strncpy(dst, src, FILENAME_MAX); @@ -659,7 +659,7 @@ static bool process_arg(char *p, char *q) case 'f': /* output format */ ofmt = ofmt_find(param, &ofmt_alias); if (!ofmt) { - nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + nasm_fatal(ERR_NOFILE | ERR_USAGE, "unrecognised output format `%s' - " "use -hf for a list", param); } @@ -699,7 +699,7 @@ static bool process_arg(char *p, char *q) break; default: - nasm_error(ERR_FATAL, + nasm_fatal(0, "unknown optimization option -O%c\n", *param); break; @@ -742,7 +742,7 @@ static bool process_arg(char *p, char *q) case 'F': /* specify debug format */ ofmt->current_dfmt = dfmt_find(ofmt, param); if (!ofmt->current_dfmt) { - nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + nasm_fatal(ERR_NOFILE | ERR_USAGE, "unrecognized debug format `%s' for" " output format `%s'", param, ofmt->shortname); @@ -756,7 +756,7 @@ static bool process_arg(char *p, char *q) else if (nasm_stricmp("gnu", param) == 0) nasm_set_verror(nasm_verror_gnu); else - nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + nasm_fatal(ERR_NOFILE | ERR_USAGE, "unrecognized error reporting format `%s'", param); break; @@ -967,7 +967,7 @@ set_warning: strlcpy(lpostfix, param, POSTFIX_MAX); break; default: - nasm_error(ERR_PANIC | ERR_NOFILE, + nasm_panic(ERR_NOFILE, "internal error"); break; } @@ -1170,7 +1170,7 @@ static void parse_cmdline(int argc, char **argv) !strcmp(inname, outname) || !strcmp(inname, listname) || (depend_file && !strcmp(inname, depend_file))) - nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + nasm_fatal(ERR_NOFILE | ERR_USAGE, "file `%s' is both input and output file", inname); @@ -1178,7 +1178,7 @@ static void parse_cmdline(int argc, char **argv) error_file = fopen(errname, "w"); if (!error_file) { error_file = stderr; /* Revert to default! */ - nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + nasm_fatal(ERR_NOFILE | ERR_USAGE, "cannot open file `%s' for error messages", errname); } @@ -1200,7 +1200,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) int pass_max; if (cmd_sb == 32 && iflag_ffs(&cmd_cpu) < IF_386) - nasm_error(ERR_FATAL, "command line: " + nasm_fatal(0, "command line: " "32-bit segment size requires a higher cpu"); pass_max = prev_offset_changed = (INT_MAX >> 1) + 2; /* Almost unlimited */ @@ -1279,7 +1279,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) * ofmt should have some 'check' method which * would report segment alignment bounds. */ - nasm_error(ERR_FATAL, + nasm_fatal(0, "incorrect segment alignment `%s'", value); } else if (!is_power2(align)) { nasm_error(ERR_NONFATAL, @@ -1443,7 +1443,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) } else if (passn == 1) abs_offset = 0x100; /* don't go near zero in case of / */ else - nasm_error(ERR_PANIC, "invalid ABSOLUTE address " + nasm_panic(0, "invalid ABSOLUTE address " "in pass two"); in_abs_seg = true; location.segment = NO_SEG; diff --git a/nasmlib.c b/nasmlib.c index d19cbf6d..265091c7 100644 --- a/nasmlib.c +++ b/nasmlib.c @@ -163,7 +163,7 @@ char *nasm_strndup(const char *s, size_t len) no_return nasm_assert_failed(const char *file, int line, const char *msg) { - nasm_error(ERR_FATAL, "assertion %s failed at %s:%d", msg, file, line); + nasm_fatal(0, "assertion %s failed at %s:%d", msg, file, line); exit(1); } @@ -171,7 +171,7 @@ void nasm_write(const void *ptr, size_t size, FILE *f) { size_t n = fwrite(ptr, 1, size, f); if (n != size) - nasm_error(ERR_FATAL, "unable to write output: %s", strerror(errno)); + nasm_fatal(0, "unable to write output: %s", strerror(errno)); } #ifndef nasm_stricmp diff --git a/output/outaout.c b/output/outaout.c index 360f549d..fe49feb4 100644 --- a/output/outaout.c +++ b/output/outaout.c @@ -631,7 +631,7 @@ static void aout_out(int32_t segto, const void *data, sbss.len += size; } else if (type == OUT_RAWDATA) { if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); aout_sect_write(s, data, size); } else if (type == OUT_ADDRESS) { int asize = abs((int)size); @@ -683,7 +683,7 @@ static void aout_out(int32_t segto, const void *data, aout_sect_write(s, mydata, asize); } else if (type == OUT_REL2ADR) { if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR"); + nasm_panic(0, "intra-segment OUT_REL2ADR"); if (segment != NO_SEG && segment % 2) { nasm_error(ERR_NONFATAL, "a.out format does not support" " segment base references"); @@ -713,7 +713,7 @@ static void aout_out(int32_t segto, const void *data, aout_sect_write(s, mydata, 2L); } else if (type == OUT_REL4ADR) { if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment != NO_SEG && segment % 2) { nasm_error(ERR_NONFATAL, "a.out format does not support" " segment base references"); diff --git a/output/outas86.c b/output/outas86.c index 43108c4e..84e3035c 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -343,7 +343,7 @@ static void as86_out(int32_t segto, const void *data, bsslen += size; } else if (type == OUT_RAWDATA) { if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); as86_sect_write(s, data, size); as86_add_piece(s, 0, 0L, 0L, size, 0); } else if (type == OUT_ADDRESS) { @@ -364,7 +364,7 @@ static void as86_out(int32_t segto, const void *data, } } else if (type == OUT_REL2ADR) { if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR"); + nasm_panic(0, "intra-segment OUT_REL2ADR"); if (segment != NO_SEG) { if (segment % 2) { nasm_error(ERR_NONFATAL, "as86 format does not support" @@ -377,7 +377,7 @@ static void as86_out(int32_t segto, const void *data, } } else if (type == OUT_REL4ADR) { if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment != NO_SEG) { if (segment % 2) { nasm_error(ERR_NONFATAL, "as86 format does not support" @@ -518,7 +518,7 @@ static void as86_set_rsize(int size) fputc(0x03, ofile); break; default: - nasm_error(ERR_PANIC, "bizarre relocation size %d", size); + nasm_panic(0, "bizarre relocation size %d", size); break; } } diff --git a/output/outbin.c b/output/outbin.c index 71c7bcd4..47fbb471 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -270,7 +270,7 @@ static void bin_cleanup(int debuginfo) if (s->flags & (START_DEFINED | ALIGN_DEFINED | FOLLOWS_DEFINED)) { /* Check for a mixture of real and virtual section attributes. */ if (s->flags & (VSTART_DEFINED | VALIGN_DEFINED | VFOLLOWS_DEFINED)) - nasm_error(ERR_FATAL|ERR_NOFILE, + nasm_fatal(ERR_NOFILE, "cannot mix real and virtual attributes" " in nobits section (%s)", s->name); /* Real and virtual attributes mean the same thing for nobits sections. */ @@ -341,11 +341,11 @@ static void bin_cleanup(int debuginfo) s && strcmp(s->name, g->follows); sp = &s->next, s = s->next) ; if (!s) - nasm_error(ERR_FATAL|ERR_NOFILE, "section %s follows an invalid or" + nasm_fatal(ERR_NOFILE, "section %s follows an invalid or" " unknown section (%s)", g->name, g->follows); if (s->next && (s->next->flags & FOLLOWS_DEFINED) && !strcmp(s->name, s->next->follows)) - nasm_error(ERR_FATAL|ERR_NOFILE, "sections %s and %s can't both follow" + nasm_fatal(ERR_NOFILE, "sections %s and %s can't both follow" " section %s", g->name, s->next->name, s->name); /* Find the end of the current follows group (gs). */ for (gsp = &g->next, gs = g->next; @@ -389,7 +389,7 @@ static void bin_cleanup(int debuginfo) if (sections->flags & START_DEFINED) { /* Make sure this section doesn't begin before the origin. */ if (sections->start < origin) - nasm_error(ERR_FATAL|ERR_NOFILE, "section %s begins" + nasm_fatal(ERR_NOFILE, "section %s begins" " before program origin", sections->name); } else if (sections->flags & ALIGN_DEFINED) { sections->start = ALIGN(origin, sections->align); @@ -445,13 +445,13 @@ static void bin_cleanup(int debuginfo) /* Check for section overlap. */ if (s) { if (s->start < origin) - nasm_error(ERR_FATAL|ERR_NOFILE, "section %s beings before program origin", + nasm_fatal(ERR_NOFILE, "section %s beings before program origin", s->name); if (g->start > s->start) - nasm_error(ERR_FATAL|ERR_NOFILE, "sections %s ~ %s and %s overlap!", + nasm_fatal(ERR_NOFILE, "sections %s ~ %s and %s overlap!", gs->name, g->name, s->name); if (pend > s->start) - nasm_error(ERR_FATAL|ERR_NOFILE, "sections %s and %s overlap!", + nasm_fatal(ERR_NOFILE, "sections %s and %s overlap!", g->name, s->name); } /* Remember this section as the latest >0 length section. */ @@ -480,7 +480,7 @@ static void bin_cleanup(int debuginfo) for (s = sections; s && strcmp(g->vfollows, s->name); s = s->next) ; if (!s) - nasm_error(ERR_FATAL|ERR_NOFILE, + nasm_fatal(ERR_NOFILE, "section %s vfollows unknown section (%s)", g->name, g->vfollows); } else if (g->prev != NULL) @@ -519,7 +519,7 @@ static void bin_cleanup(int debuginfo) } } if (h) - nasm_error(ERR_FATAL|ERR_NOFILE, "circular vfollows path detected"); + nasm_fatal(ERR_NOFILE, "circular vfollows path detected"); #ifdef DEBUG nasm_error(ERR_DEBUG, @@ -748,7 +748,7 @@ static void bin_out(int32_t segto, const void *data, /* Find the segment we are targeting. */ s = find_section_by_index(segto); if (!s) - nasm_error(ERR_PANIC, "code directed to nonexistent segment?"); + nasm_panic(0, "code directed to nonexistent segment?"); /* "Smart" section-type adaptation code. */ if (!(s->flags & TYPE_DEFINED)) { diff --git a/output/outcoff.c b/output/outcoff.c index a712f953..9587f352 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -583,7 +583,7 @@ static void coff_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != coff_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in COFF driver"); + nasm_panic(0, "strange segment conditions in COFF driver"); else s = coff_sects[coff_nsects - 1]; } @@ -626,7 +626,7 @@ static void coff_out(int32_t segto, const void *data, s->len += size; } else if (type == OUT_RAWDATA) { if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); coff_sect_write(s, data, size); } else if (type == OUT_ADDRESS) { int asize = abs((int)size); @@ -674,7 +674,7 @@ static void coff_out(int32_t segto, const void *data, " relocations"); } else if (type == OUT_REL4ADR) { if (segment == segto && !(win64)) /* Acceptable for RIP-relative */ - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); else if (segment == NO_SEG && win32) nasm_error(ERR_NONFATAL, "Win32 COFF does not correctly support" " relative references to absolute addresses"); @@ -875,7 +875,7 @@ static inline void coff_adjust_relocs(struct coff_Section *s) else { if (ofmt == &of_coff) - nasm_error(ERR_FATAL, + nasm_fatal(0, "Too many relocations (%d) for section `%s'", s->nrelocs, s->name); } diff --git a/output/outelf32.c b/output/outelf32.c index a8b181a2..9c83a579 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -422,7 +422,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, /* we have to be sure at least text section is there */ int tempint; if (segment != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in ELF driver"); + nasm_panic(0, "strange segment conditions in ELF driver"); } for (i = 0; i < nsects; i++) { if (segment == sects[i]->index) { @@ -686,7 +686,7 @@ static void elf_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in ELF driver"); + nasm_panic(0, "strange segment conditions in ELF driver"); else { s = sects[nsects - 1]; i = nsects - 1; @@ -723,7 +723,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_RAWDATA: if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); elf_sect_write(s, data, size); break; @@ -846,7 +846,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_REL4ADR: if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment != NO_SEG && segment % 2) { nasm_error(ERR_NONFATAL, "ELF format does not support" " segment base references"); diff --git a/output/outelf64.c b/output/outelf64.c index f2a192a3..ef0b9377 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -427,7 +427,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, /* we have to be sure at least text section is there */ int tempint; if (segment != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in ELF driver"); + nasm_panic(0, "strange segment conditions in ELF driver"); } for (i = 0; i < nsects; i++) { if (segment == sects[i]->index) { @@ -702,7 +702,7 @@ static void elf_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in ELF driver"); + nasm_panic(0, "strange segment conditions in ELF driver"); else { s = sects[nsects - 1]; i = nsects - 1; @@ -738,7 +738,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_RAWDATA: if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); elf_sect_write(s, data, size); break; @@ -775,7 +775,7 @@ static void elf_out(int32_t segto, const void *data, elf_add_reloc(s, segment, addr, R_X86_64_64); break; default: - nasm_error(ERR_PANIC, "internal error elf64-hpa-871"); + nasm_panic(0, "internal error elf64-hpa-871"); break; } addr = 0; @@ -843,7 +843,7 @@ static void elf_out(int32_t segto, const void *data, addr = 0; break; default: - nasm_error(ERR_PANIC, "internal error elf64-hpa-903"); + nasm_panic(0, "internal error elf64-hpa-903"); break; } } else if (wrt == elf_plt_sect + 1) { @@ -871,7 +871,7 @@ static void elf_out(int32_t segto, const void *data, rel12adr: addr = *(int64_t *)data - size; if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL1ADR"); + nasm_panic(0, "intra-segment OUT_REL1ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -892,7 +892,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_REL4ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -930,7 +930,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_REL8ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL8ADR"); + nasm_panic(0, "intra-segment OUT_REL8ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { diff --git a/output/outelfx32.c b/output/outelfx32.c index c217c7be..18f3724c 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -426,7 +426,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, /* we have to be sure at least text section is there */ int tempint; if (segment != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in ELF driver"); + nasm_panic(0, "strange segment conditions in ELF driver"); } for (i = 0; i < nsects; i++) { if (segment == sects[i]->index) { @@ -701,7 +701,7 @@ static void elf_out(int32_t segto, const void *data, if (!s) { int tempint; /* ignored */ if (segto != elf_section_names(".text", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in ELF driver"); + nasm_panic(0, "strange segment conditions in ELF driver"); else { s = sects[nsects - 1]; i = nsects - 1; @@ -737,7 +737,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_RAWDATA: if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); elf_sect_write(s, data, size); break; @@ -774,7 +774,7 @@ static void elf_out(int32_t segto, const void *data, elf_add_reloc(s, segment, addr, R_X86_64_64); break; default: - nasm_error(ERR_PANIC, "internal error elfx32-hpa-871"); + nasm_panic(0, "internal error elfx32-hpa-871"); break; } addr = 0; @@ -832,7 +832,7 @@ static void elf_out(int32_t segto, const void *data, addr = 0; break; default: - nasm_error(ERR_PANIC, "internal error elfx32-hpa-903"); + nasm_panic(0, "internal error elfx32-hpa-903"); break; } } else if (wrt == elf_plt_sect + 1) { @@ -860,7 +860,7 @@ static void elf_out(int32_t segto, const void *data, rel12adr: addr = *(int64_t *)data - size; if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL1ADR"); + nasm_panic(0, "intra-segment OUT_REL1ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { @@ -881,7 +881,7 @@ static void elf_out(int32_t segto, const void *data, case OUT_REL4ADR: addr = *(int64_t *)data - size; if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment == NO_SEG) { /* Do nothing */ } else if (segment % 2) { diff --git a/output/outieee.c b/output/outieee.c index 42f0fb66..2415bc74 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -419,7 +419,7 @@ static void ieee_out(int32_t segto, const void *data, if (!any_segs) { int tempint; /* ignored */ if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in IEEE driver"); + nasm_panic(0, "strange segment conditions in IEEE driver"); } /* @@ -429,7 +429,7 @@ static void ieee_out(int32_t segto, const void *data, if (seg->index == segto) break; if (!seg) - nasm_error(ERR_PANIC, "code directed to nonexistent segment?"); + nasm_panic(0, "code directed to nonexistent segment?"); if (type == OUT_RAWDATA) { ucdata = data; @@ -535,7 +535,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, } } else - nasm_error(ERR_PANIC, + nasm_panic(0, "unrecognised WRT value in ieee_write_fixup"); } else nasm_error(ERR_NONFATAL, "target of WRT must be a section "); @@ -577,7 +577,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, */ if (eb) { if (realtype == OUT_REL2ADR || realtype == OUT_REL4ADR) { - nasm_error(ERR_PANIC, + nasm_panic(0, "Segment of a rel not supported in ieee_write_fixup"); } else { /* If we want the segment */ @@ -588,7 +588,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, } else /* If we get here the seg value doesn't make sense */ - nasm_error(ERR_PANIC, + nasm_panic(0, "unrecognised segment value in ieee_write_fixup"); } @@ -643,7 +643,7 @@ static void ieee_write_fixup(int32_t segment, int32_t wrt, } else /* If we get here the seg value doesn't make sense */ - nasm_error(ERR_PANIC, + nasm_panic(0, "unrecognised segment value in ieee_write_fixup"); } } @@ -994,7 +994,7 @@ static void ieee_write_file(int debuginfo) if (seg->index == ieee_entry_seg) break; if (!seg) - nasm_error(ERR_PANIC, "Start address records are incorrect"); + nasm_panic(0, "Start address records are incorrect"); else ieee_putascii("ASG,R%X,%lX,+.\n", seg->ieee_index, ieee_entry_ofs); @@ -1357,7 +1357,7 @@ static void dbgls_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (!any_segs) { int tempint; /* ignored */ if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver"); + nasm_panic(0, "strange segment conditions in OBJ driver"); } /* @@ -1367,7 +1367,7 @@ static void dbgls_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (seg->index == segto) break; if (!seg) - nasm_error(ERR_PANIC, "lineno directed to nonexistent segment?"); + nasm_panic(0, "lineno directed to nonexistent segment?"); for (fn = fnhead; fn; fn = fn->next) { if (!nasm_stricmp(lnfname, fn->name)) diff --git a/output/outmacho.c b/output/outmacho.c index 9a431147..b67561c6 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -1139,7 +1139,7 @@ static void macho_calculate_sizes (void) } if (seg_nsects > MAX_SECT) { - nasm_error(ERR_FATAL, "MachO output is limited to %d sections\n", + nasm_fatal(0, "MachO output is limited to %d sections\n", MAX_SECT); } diff --git a/output/outobj.c b/output/outobj.c index ff03664c..a39610be 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -840,7 +840,7 @@ static void obj_deflabel(char *name, int32_t segment, if (!any_segs && segment == first_seg) { int tempint; /* ignored */ if (segment != obj_segment("__NASMDEFSEG", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver"); + nasm_panic(0, "strange segment conditions in OBJ driver"); } for (seg = seghead; seg && is_global; seg = seg->next) @@ -1046,7 +1046,7 @@ static void obj_out(int32_t segto, const void *data, if (!any_segs) { int tempint; /* ignored */ if (segto != obj_segment("__NASMDEFSEG", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver"); + nasm_panic(0, "strange segment conditions in OBJ driver"); } /* @@ -1056,7 +1056,7 @@ static void obj_out(int32_t segto, const void *data, if (seg->index == segto) break; if (!seg) - nasm_error(ERR_PANIC, "code directed to nonexistent segment?"); + nasm_panic(0, "code directed to nonexistent segment?"); orp = seg->orp; orp->parm[0] = seg->currentpos; @@ -1193,7 +1193,7 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, locat = FIX_16_SELECTOR; seg--; if (bytes != 2) - nasm_error(ERR_PANIC, "OBJ: 4-byte segment base fixup got" + nasm_panic(0, "OBJ: 4-byte segment base fixup got" " through sanity check"); } else { base = false; @@ -1239,7 +1239,7 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, if (eb) method = 6, e = eb->exts[i], tidx = e->index; else - nasm_error(ERR_PANIC, + nasm_panic(0, "unrecognised segment value in obj_write_fixup"); } } @@ -1298,7 +1298,7 @@ static void obj_write_fixup(ObjRecord * orp, int bytes, if (eb) method |= 0x20, fidx = eb->exts[i]->index; else - nasm_error(ERR_PANIC, + nasm_panic(0, "unrecognised WRT value in obj_write_fixup"); } } @@ -1447,7 +1447,7 @@ static int32_t obj_segment(char *name, int pass, int *bits) if (!strcmp(grp->name, "FLAT")) break; if (!grp) - nasm_error(ERR_PANIC, "failure to define FLAT?!"); + nasm_panic(0, "failure to define FLAT?!"); } seg->grp = grp; } else if (!nasm_strnicmp(p, "class=", 6)) @@ -2457,7 +2457,7 @@ static void dbgbi_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (!any_segs) { int tempint; /* ignored */ if (segto != obj_segment("__NASMDEFSEG", 2, &tempint)) - nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver"); + nasm_panic(0, "strange segment conditions in OBJ driver"); } /* @@ -2467,7 +2467,7 @@ static void dbgbi_linnum(const char *lnfname, int32_t lineno, int32_t segto) if (seg->index == segto) break; if (!seg) - nasm_error(ERR_PANIC, "lineno directed to nonexistent segment?"); + nasm_panic(0, "lineno directed to nonexistent segment?"); /* for (fn = fnhead; fn; fn = fnhead->next) */ for (fn = fnhead; fn; fn = fn->next) /* fbk - Austin Lunnen - John Fine */ diff --git a/output/outrdf2.c b/output/outrdf2.c index 4dcae83c..e6dcda98 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -145,7 +145,7 @@ static void rdf2_init(void) segdata = seg_alloc(); segbss = seg_alloc(); if (segtext != 0 || segdata != 2 || segbss != 4) - nasm_error(ERR_PANIC, + nasm_panic(0, "rdf segment numbers not allocated as expected (%d,%d,%d)", segtext, segdata, segbss); bsslength = 0; @@ -227,7 +227,7 @@ static int32_t rdf2_section_names(char *name, int pass, int *bits) code = 3; } if (nsegments == RDF_MAXSEGS) { - nasm_error(ERR_FATAL, "reached compiled-in maximum segment limit (%d)", + nasm_fatal(0, "reached compiled-in maximum segment limit (%d)", RDF_MAXSEGS); return NO_SEG; } @@ -235,7 +235,7 @@ static int32_t rdf2_section_names(char *name, int pass, int *bits) segments[nsegments].segname = nasm_strdup(name); i = seg_alloc(); if (i % 2 != 0) - nasm_error(ERR_PANIC, "seg_alloc() returned odd number"); + nasm_panic(0, "seg_alloc() returned odd number"); segments[nsegments].segnumber = i >> 1; segments[nsegments].segtype = code; segments[nsegments].segreserved = reserved; @@ -497,7 +497,7 @@ static void membufwrite(int segment, const void *data, int bytes) break; } if (i == nsegments) - nasm_error(ERR_PANIC, "can't find segment %d", segment); + nasm_panic(0, "can't find segment %d", segment); if (bytes < 0) { b = buf; @@ -520,7 +520,7 @@ static int getsegmentlength(int segment) break; } if (i == nsegments) - nasm_error(ERR_PANIC, "can't find segment %d", segment); + nasm_panic(0, "can't find segment %d", segment); return segments[i].seglength; } @@ -577,7 +577,7 @@ static void rdf2_out(int32_t segto, const void *data, membufwrite(segto, databuf, 1); } else if (type == OUT_RAWDATA) { if (segment != NO_SEG) - nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG"); + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); membufwrite(segto, data, size); } else if (type == OUT_ADDRESS) { @@ -606,7 +606,7 @@ static void rdf2_out(int32_t segto, const void *data, membufwrite(segto, databuf, asize); } else if (type == OUT_REL2ADR) { if (segment == segto) - nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR"); + nasm_panic(0, "intra-segment OUT_REL2ADR"); rr.reclen = 8; rr.offset = getsegmentlength(segto); /* current offset */ @@ -638,9 +638,9 @@ static void rdf2_out(int32_t segto, const void *data, membufwrite(segto, &rr.offset, -2); } else if (type == OUT_REL4ADR) { if ((segment == segto) && (globalbits != 64)) - nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR"); + nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment != NO_SEG && segment % 2) { - nasm_error(ERR_PANIC, "erm... 4 byte segment base ref?"); + nasm_panic(0, "erm... 4 byte segment base ref?"); } rr.type = RDFREC_RELOC; /* type signature */ diff --git a/parser.c b/parser.c index 423d7855..50bfdf64 100644 --- a/parser.c +++ b/parser.c @@ -107,7 +107,7 @@ static int prefix_slot(int prefix) case P_VEX2: return PPS_VEX; default: - nasm_error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix); + nasm_panic(0, "Invalid value %d passed to prefix_slot()", prefix); return -1; } } diff --git a/preproc-nop.c b/preproc-nop.c index b43bd809..4d04af5d 100644 --- a/preproc-nop.c +++ b/preproc-nop.c @@ -66,7 +66,7 @@ static void nop_reset(char *file, int pass, ListGen *listgen, StrList **deplist) nop_fp = fopen(file, "r"); if (!nop_fp) - nasm_error(ERR_FATAL | ERR_NOFILE, + nasm_fatal(ERR_NOFILE, "unable to open input file `%s'", file); nop_list = listgen; (void)pass; /* placate compilers */ diff --git a/preproc.c b/preproc.c index 4e052989..054cc209 100644 --- a/preproc.c +++ b/preproc.c @@ -5024,7 +5024,7 @@ static char *pp_getline(void) fclose(i->fp); if (i->conds) { /* nasm_error can't be conditionally suppressed */ - nasm_error(ERR_FATAL, + nasm_fatal(0, "expected `%%endif' before end of file"); } /* only set line and file name if there's a next node */ -- cgit v1.2.1