You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(208) |
Jun
(43) |
Jul
|
Aug
(2) |
Sep
(17) |
Oct
|
Nov
(4) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
(11) |
Mar
(3) |
Apr
(2) |
May
|
Jun
(3) |
Jul
(29) |
Aug
(29) |
Sep
(48) |
Oct
|
Nov
|
Dec
(5) |
2004 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2005 |
Jan
(12) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(1) |
Dec
(2) |
2006 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(21) |
Nov
(25) |
Dec
(16) |
2007 |
Jan
(26) |
Feb
(26) |
Mar
(18) |
Apr
(51) |
May
(45) |
Jun
(26) |
Jul
(6) |
Aug
(85) |
Sep
(161) |
Oct
(111) |
Nov
(83) |
Dec
(18) |
2008 |
Jan
(31) |
Feb
(27) |
Mar
|
Apr
(16) |
May
(142) |
Jun
(136) |
Jul
(51) |
Aug
(21) |
Sep
(47) |
Oct
(428) |
Nov
(19) |
Dec
(6) |
2009 |
Jan
(11) |
Feb
(37) |
Mar
(17) |
Apr
(15) |
May
(13) |
Jun
(61) |
Jul
(127) |
Aug
(15) |
Sep
(22) |
Oct
(28) |
Nov
(37) |
Dec
(10) |
2010 |
Jan
(18) |
Feb
(22) |
Mar
(10) |
Apr
(41) |
May
|
Jun
(48) |
Jul
(61) |
Aug
(54) |
Sep
(34) |
Oct
(15) |
Nov
(49) |
Dec
(11) |
2011 |
Jan
|
Feb
(24) |
Mar
(10) |
Apr
(9) |
May
|
Jun
(33) |
Jul
(41) |
Aug
(20) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(86) |
Mar
(12) |
Apr
|
May
(10) |
Jun
|
Jul
(9) |
Aug
(4) |
Sep
(11) |
Oct
(3) |
Nov
(3) |
Dec
(10) |
2013 |
Jan
(1) |
Feb
(23) |
Mar
(15) |
Apr
(7) |
May
(20) |
Jun
(3) |
Jul
(15) |
Aug
|
Sep
(29) |
Oct
(16) |
Nov
(69) |
Dec
(18) |
2014 |
Jan
|
Feb
(8) |
Mar
|
Apr
|
May
(16) |
Jun
(7) |
Jul
|
Aug
(5) |
Sep
(2) |
Oct
(4) |
Nov
(25) |
Dec
(8) |
2015 |
Jan
(6) |
Feb
(6) |
Mar
|
Apr
(1) |
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
|
Sep
(2) |
Oct
(1) |
Nov
(6) |
Dec
|
2016 |
Jan
(12) |
Feb
(97) |
Mar
(57) |
Apr
(52) |
May
(33) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
(3) |
Nov
(3) |
Dec
|
2017 |
Jan
(4) |
Feb
|
Mar
(23) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(3) |
Aug
(2) |
Sep
|
Oct
(6) |
Nov
(3) |
Dec
(3) |
2018 |
Jan
(4) |
Feb
(11) |
Mar
|
Apr
(1) |
May
(3) |
Jun
(6) |
Jul
|
Aug
(5) |
Sep
(5) |
Oct
(36) |
Nov
(128) |
Dec
(18) |
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(24) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 09:21:20
|
Commit-ID: 8ac25aa02000889df94c3ea96bdda6375ddfa661 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=8ac25aa02000889df94c3ea96bdda6375ddfa661 Author: H. Peter Anvin <hp...@li...> AuthorDate: Thu, 18 Feb 2016 01:16:18 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Thu, 18 Feb 2016 01:16:18 -0800 Change nasmlist/ListGen to lfmt/struct lfmt For consistency with ofmt/dfmt, change the listing structure to "struct lfmt" and "lfmt" and move it to listing.h. Signed-off-by: H. Peter Anvin <hp...@li...> --- Makefile.in | 10 ++++---- Mkfiles/msvc.mak | 12 +++++----- Mkfiles/netware.mak | 12 +++++----- Mkfiles/openwcom.mak | 10 ++++---- Mkfiles/owlinux.mak | 12 +++++----- assemble.c | 35 ++++++++++++++-------------- listing.c | 4 ++-- listing.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++- nasm.c | 6 ++--- nasm.h | 66 ---------------------------------------------------- preproc-nop.c | 3 ++- preproc.c | 15 ++++++------ 12 files changed, 126 insertions(+), 125 deletions(-) diff --git a/Makefile.in b/Makefile.in index b151f38..6b5fbb4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -307,8 +307,8 @@ alldeps: perlreq # @path-separator: "/" #-- Everything below is generated by mkdep.pl - do not edit --# assemble.$(O): assemble.c assemble.h compiler.h config.h directiv.h disp8.h \ - iflag.h iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h \ - preproc.h regs.h tables.h tokens.h + iflag.h iflaggen.h insns.h insnsi.h listing.h nasm.h nasmlib.h opflags.h \ + pptok.h preproc.h regs.h tables.h tokens.h crc64.$(O): crc64.c compiler.h config.h hashtbl.h nasmlib.h directiv.$(O): directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h \ nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h @@ -421,10 +421,10 @@ parser.$(O): parser.c compiler.h config.h directiv.h eval.h float.h iflag.h \ pptok.$(O): pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h \ preproc.h preproc-nop.$(O): preproc-nop.c compiler.h config.h directiv.h insnsi.h \ - nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h + listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h preproc.$(O): preproc.c compiler.h config.h directiv.h eval.h hashtbl.h \ - insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h \ - stdscan.h tables.h tokens.h + insnsi.h listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h \ + regs.h stdscan.h tables.h tokens.h quote.$(O): quote.c compiler.h config.h nasmlib.h quote.h raa.$(O): raa.c compiler.h config.h nasmlib.h raa.h rbtree.$(O): rbtree.c compiler.h config.h rbtree.h diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index 9524c7c..ae94ee2 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -225,8 +225,8 @@ everything: all doc rdf # @exclude: "config.h" #-- Everything below is generated by mkdep.pl - do not edit --# assemble.$(O): assemble.c assemble.h compiler.h directiv.h disp8.h iflag.h \ - iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h \ - regs.h tables.h tokens.h + iflaggen.h insns.h insnsi.h listing.h nasm.h nasmlib.h opflags.h pptok.h \ + preproc.h regs.h tables.h tokens.h crc64.$(O): crc64.c compiler.h hashtbl.h nasmlib.h directiv.$(O): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \ nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h @@ -331,11 +331,11 @@ parser.$(O): parser.c compiler.h directiv.h eval.h float.h iflag.h \ iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h parser.h pptok.h \ preproc.h regs.h stdscan.h tables.h tokens.h pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h -preproc-nop.$(O): preproc-nop.c compiler.h directiv.h insnsi.h nasm.h \ - nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h +preproc-nop.$(O): preproc-nop.c compiler.h directiv.h insnsi.h listing.h \ + nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h preproc.$(O): preproc.c compiler.h directiv.h eval.h hashtbl.h insnsi.h \ - nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h \ - tables.h tokens.h + listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h \ + stdscan.h tables.h tokens.h quote.$(O): quote.c compiler.h nasmlib.h quote.h raa.$(O): raa.c compiler.h nasmlib.h raa.h rbtree.$(O): rbtree.c compiler.h rbtree.h diff --git a/Mkfiles/netware.mak b/Mkfiles/netware.mak index c2797f8..5d86b18 100644 --- a/Mkfiles/netware.mak +++ b/Mkfiles/netware.mak @@ -133,8 +133,8 @@ $(OBJDIR)/version.mak: $(PROOT)/version $(PROOT)/version.pl $(OBJDIR) # @continuation: "\" #-- Everything below is generated by mkdep.pl - do not edit --# assemble.o: assemble.c assemble.h compiler.h config.h directiv.h disp8.h \ - iflag.h iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h \ - preproc.h regs.h tables.h tokens.h + iflag.h iflaggen.h insns.h insnsi.h listing.h nasm.h nasmlib.h opflags.h \ + pptok.h preproc.h regs.h tables.h tokens.h crc64.o: crc64.c compiler.h config.h hashtbl.h nasmlib.h directiv.o: directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h \ nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h @@ -235,11 +235,11 @@ parser.o: parser.c compiler.h config.h directiv.h eval.h float.h iflag.h \ iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h parser.h pptok.h \ preproc.h regs.h stdscan.h tables.h tokens.h pptok.o: pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h preproc.h -preproc-nop.o: preproc-nop.c compiler.h config.h directiv.h insnsi.h nasm.h \ - nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h +preproc-nop.o: preproc-nop.c compiler.h config.h directiv.h insnsi.h \ + listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h preproc.o: preproc.c compiler.h config.h directiv.h eval.h hashtbl.h \ - insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h \ - stdscan.h tables.h tokens.h + insnsi.h listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h \ + regs.h stdscan.h tables.h tokens.h quote.o: quote.c compiler.h config.h nasmlib.h quote.h raa.o: raa.c compiler.h config.h nasmlib.h raa.h rbtree.o: rbtree.c compiler.h config.h rbtree.h diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 7da7fe2..e042808 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -270,8 +270,8 @@ alldeps: perlreq .SYMBOLIC # @continuation: "&" #-- Everything below is generated by mkdep.pl - do not edit --# assemble.$(O): assemble.c assemble.h compiler.h config.h directiv.h disp8.h & - iflag.h iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h & - preproc.h regs.h tables.h tokens.h + iflag.h iflaggen.h insns.h insnsi.h listing.h nasm.h nasmlib.h opflags.h & + pptok.h preproc.h regs.h tables.h tokens.h crc64.$(O): crc64.c compiler.h config.h hashtbl.h nasmlib.h directiv.$(O): directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h & nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h @@ -384,10 +384,10 @@ parser.$(O): parser.c compiler.h config.h directiv.h eval.h float.h iflag.h & pptok.$(O): pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h & preproc.h preproc-nop.$(O): preproc-nop.c compiler.h config.h directiv.h insnsi.h & - nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h + listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h preproc.$(O): preproc.c compiler.h config.h directiv.h eval.h hashtbl.h & - insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h & - stdscan.h tables.h tokens.h + insnsi.h listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h & + regs.h stdscan.h tables.h tokens.h quote.$(O): quote.c compiler.h config.h nasmlib.h quote.h raa.$(O): raa.c compiler.h config.h nasmlib.h raa.h rbtree.$(O): rbtree.c compiler.h config.h rbtree.h diff --git a/Mkfiles/owlinux.mak b/Mkfiles/owlinux.mak index 299e2ba..b3c91ff 100644 --- a/Mkfiles/owlinux.mak +++ b/Mkfiles/owlinux.mak @@ -239,8 +239,8 @@ everything: all doc rdf # @continuation: "\" #-- Everything below is generated by mkdep.pl - do not edit --# assemble.$(O): assemble.c assemble.h compiler.h directiv.h disp8.h iflag.h \ - iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h \ - regs.h tables.h tokens.h + iflaggen.h insns.h insnsi.h listing.h nasm.h nasmlib.h opflags.h pptok.h \ + preproc.h regs.h tables.h tokens.h crc64.$(O): crc64.c compiler.h hashtbl.h nasmlib.h directiv.$(O): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \ nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h @@ -345,11 +345,11 @@ parser.$(O): parser.c compiler.h directiv.h eval.h float.h iflag.h \ iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h parser.h pptok.h \ preproc.h regs.h stdscan.h tables.h tokens.h pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h -preproc-nop.$(O): preproc-nop.c compiler.h directiv.h insnsi.h nasm.h \ - nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h +preproc-nop.$(O): preproc-nop.c compiler.h directiv.h insnsi.h listing.h \ + nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h preproc.$(O): preproc.c compiler.h directiv.h eval.h hashtbl.h insnsi.h \ - nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h \ - tables.h tokens.h + listing.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h \ + stdscan.h tables.h tokens.h quote.$(O): quote.c compiler.h nasmlib.h quote.h raa.$(O): raa.c compiler.h nasmlib.h raa.h rbtree.$(O): rbtree.c compiler.h rbtree.h diff --git a/assemble.c b/assemble.c index 84ed4b8..385d357 100644 --- a/assemble.c +++ b/assemble.c @@ -188,6 +188,7 @@ #include "insns.h" #include "tables.h" #include "disp8.h" +#include "listing.h" enum match_result { /* @@ -358,7 +359,7 @@ static void out(int64_t offset, int32_t segto, const void *data, asize = 0; /* No longer an address */ } - nasmlist->output(offset, data, type, size); + lfmt->output(offset, data, type, size); /* * this call to src_get determines when we call the @@ -495,15 +496,15 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, } if (t > 0 && t == instruction->times - 1) { /* - * Dummy call to nasmlist->output to give the offset to the + * Dummy call to lfmt->output to give the offset to the * listing module. */ - nasmlist->output(offset, NULL, OUT_RAWDATA, 0); - nasmlist->uplevel(LIST_TIMES); + lfmt->output(offset, NULL, OUT_RAWDATA, 0); + lfmt->uplevel(LIST_TIMES); } } if (instruction->times > 1) - nasmlist->downlevel(LIST_TIMES); + lfmt->downlevel(LIST_TIMES); return offset - start; } @@ -534,11 +535,11 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, len = (size_t)instruction->eops->next->next->offset; } /* - * Dummy call to nasmlist->output to give the offset to the + * Dummy call to lfmt->output to give the offset to the * listing module. */ - nasmlist->output(offset, NULL, OUT_RAWDATA, 0); - nasmlist->uplevel(LIST_INCBIN); + lfmt->output(offset, NULL, OUT_RAWDATA, 0); + lfmt->uplevel(LIST_INCBIN); while (t--) { size_t l; @@ -564,15 +565,15 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, l -= m; } } - nasmlist->downlevel(LIST_INCBIN); + lfmt->downlevel(LIST_INCBIN); if (instruction->times > 1) { /* - * Dummy call to nasmlist->output to give the offset to the + * Dummy call to lfmt->output to give the offset to the * listing module. */ - nasmlist->output(offset, NULL, OUT_RAWDATA, 0); - nasmlist->uplevel(LIST_TIMES); - nasmlist->downlevel(LIST_TIMES); + lfmt->output(offset, NULL, OUT_RAWDATA, 0); + lfmt->uplevel(LIST_TIMES); + lfmt->downlevel(LIST_TIMES); } fclose(fp); return instruction->times * len; @@ -710,15 +711,15 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, offset += insn_size; if (itimes > 0 && itimes == instruction->times - 1) { /* - * Dummy call to nasmlist->output to give the offset to the + * Dummy call to lfmt->output to give the offset to the * listing module. */ - nasmlist->output(offset, NULL, OUT_RAWDATA, 0); - nasmlist->uplevel(LIST_TIMES); + lfmt->output(offset, NULL, OUT_RAWDATA, 0); + lfmt->uplevel(LIST_TIMES); } } if (instruction->times > 1) - nasmlist->downlevel(LIST_TIMES); + lfmt->downlevel(LIST_TIMES); return offset - start; } else { /* No match */ diff --git a/listing.c b/listing.c index bb16310..f43381f 100644 --- a/listing.c +++ b/listing.c @@ -326,7 +326,7 @@ static void list_error(int severity, const char *pfx, const char *msg) } -static const ListGen nasm_list = { +static const struct lfmt nasm_list = { list_init, list_cleanup, list_output, @@ -336,5 +336,5 @@ static const ListGen nasm_list = { list_error }; -const ListGen *nasmlist = &nasm_list; +const struct lfmt *lfmt = &nasm_list; diff --git a/listing.h b/listing.h index 8e178b0..58b5eb8 100644 --- a/listing.h +++ b/listing.h @@ -38,7 +38,71 @@ #ifndef NASM_LISTING_H #define NASM_LISTING_H -extern const ListGen *nasmlist; +/* + * List-file generators should look like this: + */ +struct lfmt { + /* + * Called to initialize the listing file generator. Before this + * is called, the other routines will silently do nothing when + * called. The `char *' parameter is the file name to write the + * listing to. + */ + void (*init)(const char *fname); + + /* + * Called to clear stuff up and close the listing file. + */ + void (*cleanup)(void); + + /* + * Called to output binary data. Parameters are: the offset; + * the data; the data type. Data types are similar to the + * output-format interface, only OUT_ADDRESS will _always_ be + * displayed as if it's relocatable, so ensure that any non- + * relocatable address has been converted to OUT_RAWDATA by + * then. Note that OUT_RAWDATA,0 is a valid data type, and is a + * dummy call used to give the listing generator an offset to + * work with when doing things like uplevel(LIST_TIMES) or + * uplevel(LIST_INCBIN). + */ + void (*output)(int32_t offset, const void *data, enum out_type type, uint64_t size); + + /* + * Called to send a text line to the listing generator. The + * `int' parameter is LIST_READ or LIST_MACRO depending on + * whether the line came directly from an input file or is the + * result of a multi-line macro expansion. + */ + void (*line)(int type, char *line); + + /* + * Called to change one of the various levelled mechanisms in + * the listing generator. LIST_INCLUDE and LIST_MACRO can be + * used to increase the nesting level of include files and + * macro expansions; LIST_TIMES and LIST_INCBIN switch on the + * two binary-output-suppression mechanisms for large-scale + * pseudo-instructions. + * + * LIST_MACRO_NOLIST is synonymous with LIST_MACRO except that + * it indicates the beginning of the expansion of a `nolist' + * macro, so anything under that level won't be expanded unless + * it includes another file. + */ + void (*uplevel)(int type); + + /* + * Reverse the effects of uplevel. + */ + void (*downlevel)(int type); + + /* + * Called on a warning or error, with the error message. + */ + void (*error)(int severity, const char *pfx, const char *msg); +}; + +extern const struct lfmt *lfmt; extern bool user_nolist; #endif diff --git a/nasm.c b/nasm.c index 3c2fada..4c9c163 100644 --- a/nasm.c +++ b/nasm.c @@ -1223,7 +1223,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) globalbits = sb = cmd_sb; /* set 'bits' to command line default */ cpu = cmd_cpu; if (pass0 == 2) { - nasmlist->init(listname); + lfmt->init(listname); } in_abs_seg = false; global_offset_changed = 0; /* set by redefine_label */ @@ -1803,7 +1803,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) } preproc->cleanup(0); - nasmlist->cleanup(); + lfmt->cleanup(); if (!terminate_after_phase && opt_verbose_info) { /* -On and -Ov switches */ fprintf(stdout, "info: assembly required 1+%d+1 passes\n", passn-3); @@ -2005,7 +2005,7 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) * preprocessor warnings in the list file */ if ((severity & ERR_MASK) >= ERR_WARNING) - nasmlist->error(severity, pfx, msg); + lfmt->error(severity, pfx, msg); if (severity & ERR_USAGE) want_usage = true; diff --git a/nasm.h b/nasm.h index 80917a1..44b356d 100644 --- a/nasm.h +++ b/nasm.h @@ -127,72 +127,6 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special, bool is_norm, bool isextrn); /* - * List-file generators should look like this: - */ -typedef struct { - /* - * Called to initialize the listing file generator. Before this - * is called, the other routines will silently do nothing when - * called. The `char *' parameter is the file name to write the - * listing to. - */ - void (*init)(const char *fname); - - /* - * Called to clear stuff up and close the listing file. - */ - void (*cleanup)(void); - - /* - * Called to output binary data. Parameters are: the offset; - * the data; the data type. Data types are similar to the - * output-format interface, only OUT_ADDRESS will _always_ be - * displayed as if it's relocatable, so ensure that any non- - * relocatable address has been converted to OUT_RAWDATA by - * then. Note that OUT_RAWDATA,0 is a valid data type, and is a - * dummy call used to give the listing generator an offset to - * work with when doing things like uplevel(LIST_TIMES) or - * uplevel(LIST_INCBIN). - */ - void (*output)(int32_t offset, const void *data, enum out_type type, uint64_t size); - - /* - * Called to send a text line to the listing generator. The - * `int' parameter is LIST_READ or LIST_MACRO depending on - * whether the line came directly from an input file or is the - * result of a multi-line macro expansion. - */ - void (*line)(int type, char *line); - - /* - * Called to change one of the various levelled mechanisms in - * the listing generator. LIST_INCLUDE and LIST_MACRO can be - * used to increase the nesting level of include files and - * macro expansions; LIST_TIMES and LIST_INCBIN switch on the - * two binary-output-suppression mechanisms for large-scale - * pseudo-instructions. - * - * LIST_MACRO_NOLIST is synonymous with LIST_MACRO except that - * it indicates the beginning of the expansion of a `nolist' - * macro, so anything under that level won't be expanded unless - * it includes another file. - */ - void (*uplevel)(int type); - - /* - * Reverse the effects of uplevel. - */ - void (*downlevel)(int type); - - /* - * Called on a warning or error, with the error message. - */ - void (*error)(int severity, const char *pfx, const char *msg); -} ListGen; - -extern const ListGen *nasmlist; - -/* * Token types returned by the scanner, in addition to ordinary * ASCII character values, and zero for end-of-string. */ diff --git a/preproc-nop.c b/preproc-nop.c index 353e269..8024cac 100644 --- a/preproc-nop.c +++ b/preproc-nop.c @@ -51,6 +51,7 @@ #include "nasm.h" #include "nasmlib.h" #include "preproc.h" +#include "listing.h" #define BUF_DELTA 512 @@ -130,7 +131,7 @@ static char *nop_getline(void) break; } - nasmlist->line(LIST_READ, buffer); + lfmt->line(LIST_READ, buffer); return buffer; } diff --git a/preproc.c b/preproc.c index 2845f04..d2b9bb7 100644 --- a/preproc.c +++ b/preproc.c @@ -80,6 +80,7 @@ #include "eval.h" #include "tokens.h" #include "tables.h" +#include "listing.h" typedef struct SMacro SMacro; typedef struct MMacro MMacro; @@ -878,7 +879,7 @@ static char *read_line(void) */ buffer[strcspn(buffer, "\032")] = '\0'; - nasmlist->line(LIST_READ, buffer); + lfmt->line(LIST_READ, buffer); return buffer; } @@ -2506,7 +2507,7 @@ static int do_directive(Token * tline) inc->expansion = NULL; inc->mstk = NULL; istk = inc; - nasmlist->uplevel(LIST_INCLUDE); + lfmt->uplevel(LIST_INCLUDE); } free_tlist(origline); return DIRECTIVE_FOUND; @@ -2962,7 +2963,7 @@ issue_error: istk->mstk = defining; - nasmlist->uplevel(defining->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); + lfmt->uplevel(defining->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); tmp_defining = defining; defining = defining->rep_nest; free_tlist(origline); @@ -4769,7 +4770,7 @@ static int expand_mmacro(Token * tline) } } - nasmlist->uplevel(m->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); + lfmt->uplevel(m->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); return 1; } @@ -4971,7 +4972,7 @@ static char *pp_getline(void) } istk->expansion = l->next; nasm_free(l); - nasmlist->downlevel(LIST_MACRO); + lfmt->downlevel(LIST_MACRO); } } while (1) { /* until we get a line we can use */ @@ -4985,7 +4986,7 @@ static char *pp_getline(void) istk->expansion = l->next; nasm_free(l); p = detoken(tline, false); - nasmlist->line(LIST_MACRO, p); + lfmt->line(LIST_MACRO, p); nasm_free(p); break; } @@ -5013,7 +5014,7 @@ static char *pp_getline(void) nasm_free(src_set_fname(nasm_strdup(i->fname))); } istk = i->next; - nasmlist->downlevel(LIST_INCLUDE); + lfmt->downlevel(LIST_INCLUDE); nasm_free(i); if (!istk) { line = NULL; |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 09:21:18
|
Commit-ID: 36034ec65203acfd1419992743a143b33bfc8ab1 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=36034ec65203acfd1419992743a143b33bfc8ab1 Author: H. Peter Anvin <hp...@li...> AuthorDate: Thu, 18 Feb 2016 01:18:50 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Thu, 18 Feb 2016 01:18:50 -0800 eval: complete globalization of output format Complete the globalization of the output format definitions; one more place where a local copy was cached for no good reason. Signed-off-by: H. Peter Anvin <hp...@li...> --- eval.c | 8 ++------ eval.h | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/eval.c b/eval.c index a8e463f..1709933 100644 --- a/eval.c +++ b/eval.c @@ -56,8 +56,6 @@ static scanner scan; /* Address of scanner routine */ static lfunc labelfunc; /* Address of label routine */ -static struct ofmt *outfmt; /* Structure of addresses of output routines */ - static expr **tempexprs = NULL; static int ntempexprs; static int tempexprs_size = 0; @@ -241,7 +239,7 @@ static expr *segment_part(expr * e) " is already a segment base"); return NULL; } else { - int32_t base = outfmt->segbase(seg + 1); + int32_t base = ofmt->segbase(seg + 1); begintemp(); addtotemp((base == NO_SEG ? EXPR_UNKNOWN : EXPR_SEGBASE + base), @@ -953,10 +951,8 @@ static expr *expr6(int critical) } } -void eval_global_info(struct ofmt *output, lfunc lookup_label, - struct location * locp) +void eval_global_info(lfunc lookup_label, struct location * locp) { - outfmt = output; labelfunc = lookup_label; location = locp; } diff --git a/eval.h b/eval.h index 76ea14b..41949d4 100644 --- a/eval.h +++ b/eval.h @@ -43,8 +43,7 @@ * providing segment-base details, and what function can be used to * look labels up. */ -void eval_global_info(struct ofmt *output, lfunc lookup_label, - struct location * locp); +void eval_global_info(lfunc lookup_label, struct location * locp); /* * The evaluator itself. |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 09:12:20
|
Commit-ID: 15a6aa7ade543d7e807a2321d85729078ed0ce40 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=15a6aa7ade543d7e807a2321d85729078ed0ce40 Author: H. Peter Anvin <hp...@li...> AuthorDate: Thu, 18 Feb 2016 01:07:34 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Thu, 18 Feb 2016 01:07:34 -0800 Makefile: remove explicit mention of lib/strlcpy.c Don't inclure lib/strlcpy.c unconditionally, that is what LIBOBJS is for. Signed-off-by: H. Peter Anvin <hp...@li...> --- Makefile.in | 3 +-- Mkfiles/msvc.mak | 3 +-- Mkfiles/netware.mak | 5 ++--- Mkfiles/openwcom.mak | 3 +-- Mkfiles/owlinux.mak | 3 +-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Makefile.in b/Makefile.in index 10c666c..b151f38 100644 --- a/Makefile.in +++ b/Makefile.in @@ -94,7 +94,6 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \ macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \ strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) \ ilog2.$(O) \ - lib/strlcpy.$(O) \ preproc-nop.$(O) \ disp8.$(O) \ iflag.$(O) @@ -409,7 +408,7 @@ output/outlib.$(O): output/outlib.c compiler.h config.h directiv.h insnsi.h \ tables.h output/outmacho.$(O): output/outmacho.c compiler.h config.h directiv.h \ insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \ - pptok.h preproc.h raa.h regs.h saa.h tables.h + pptok.h preproc.h raa.h rbtree.h regs.h saa.h tables.h output/outobj.$(O): output/outobj.c compiler.h config.h directiv.h eval.h \ insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \ pptok.h preproc.h regs.h stdscan.h tables.h diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index a1bfd5e..9524c7c 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -61,7 +61,6 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \ macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \ strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) \ ilog2.$(O) \ - lib/strlcpy.$(O) \ preproc-nop.$(O) \ disp8.$(O) \ iflag.$(O) @@ -321,7 +320,7 @@ output/outlib.$(O): output/outlib.c compiler.h directiv.h insnsi.h nasm.h \ nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h tables.h output/outmacho.$(O): output/outmacho.c compiler.h directiv.h insnsi.h \ nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \ - preproc.h raa.h regs.h saa.h tables.h + preproc.h raa.h rbtree.h regs.h saa.h tables.h output/outobj.$(O): output/outobj.c compiler.h directiv.h eval.h insnsi.h \ nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \ preproc.h regs.h stdscan.h tables.h diff --git a/Mkfiles/netware.mak b/Mkfiles/netware.mak index d897f44..c2797f8 100644 --- a/Mkfiles/netware.mak +++ b/Mkfiles/netware.mak @@ -48,7 +48,6 @@ NASM = nasm.o nasmlib.o ver.o \ macros.o listing.o eval.o exprlib.o stdscan.o \ strfunc.o tokhash.o regvals.o regflags.o \ ilog2.o \ - strlcpy.o \ preproc-nop.o \ disp8.o \ iflag.o @@ -224,8 +223,8 @@ outieee.o: outieee.c compiler.h config.h directiv.h insnsi.h nasm.h \ outlib.o: outlib.c compiler.h config.h directiv.h insnsi.h nasm.h nasmlib.h \ opflags.h outlib.h pptok.h preproc.h regs.h tables.h outmacho.o: outmacho.c compiler.h config.h directiv.h insnsi.h nasm.h \ - nasmlib.h opflags.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h \ - tables.h + nasmlib.h opflags.h outform.h outlib.h pptok.h preproc.h raa.h rbtree.h \ + regs.h saa.h tables.h outobj.o: outobj.c compiler.h config.h directiv.h eval.h insnsi.h nasm.h \ nasmlib.h opflags.h outform.h outlib.h pptok.h preproc.h regs.h stdscan.h \ tables.h diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 351df72..7da7fe2 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -64,7 +64,6 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) & macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) & strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) & ilog2.$(O) & - lib/strlcpy.$(O) & preproc-nop.$(O) & disp8.$(O) & iflag.$(O) @@ -372,7 +371,7 @@ output/outlib.$(O): output/outlib.c compiler.h config.h directiv.h insnsi.h & tables.h output/outmacho.$(O): output/outmacho.c compiler.h config.h directiv.h & insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h & - pptok.h preproc.h raa.h regs.h saa.h tables.h + pptok.h preproc.h raa.h rbtree.h regs.h saa.h tables.h output/outobj.$(O): output/outobj.c compiler.h config.h directiv.h eval.h & insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h & pptok.h preproc.h regs.h stdscan.h tables.h diff --git a/Mkfiles/owlinux.mak b/Mkfiles/owlinux.mak index 256abba..299e2ba 100644 --- a/Mkfiles/owlinux.mak +++ b/Mkfiles/owlinux.mak @@ -75,7 +75,6 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \ macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \ strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) \ ilog2.$(O) \ - lib/strlcpy.$(O) \ preproc-nop.$(O) \ disp8.$(O) \ iflag.$(O) @@ -335,7 +334,7 @@ output/outlib.$(O): output/outlib.c compiler.h directiv.h insnsi.h nasm.h \ nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h tables.h output/outmacho.$(O): output/outmacho.c compiler.h directiv.h insnsi.h \ nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \ - preproc.h raa.h regs.h saa.h tables.h + preproc.h raa.h rbtree.h regs.h saa.h tables.h output/outobj.$(O): output/outobj.c compiler.h directiv.h eval.h insnsi.h \ nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \ preproc.h regs.h stdscan.h tables.h |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 09:06:20
|
Commit-ID: d338b376df915dfa6eb1d9fa651fb02b7d6dbce2 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=d338b376df915dfa6eb1d9fa651fb02b7d6dbce2 Author: H. Peter Anvin <hp...@li...> AuthorDate: Thu, 18 Feb 2016 00:54:30 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Thu, 18 Feb 2016 01:03:51 -0800 Portability improvements and autoconf modernization Improve the portability of the code and modernize our use of autoconf. Signed-off-by: H. Peter Anvin <hp...@li...> --- Makefile.in | 76 +++++++++++++++++++++++++++++++---------------------------- aclocal.m4 | 45 ++++++++++++++++++++--------------- compiler.h | 15 ++++-------- configure.in | 46 ++++++++++++++++-------------------- ilog2.c | 7 +++--- lib/strlcpy.c | 2 -- 6 files changed, 95 insertions(+), 96 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6ee17b4..10c666c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,9 +22,13 @@ INTERNAL_CFLAGS = -I$(srcdir) -I. ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS) LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -PERL = perl -I$(srcdir)/perllib +PERL = perl +PERLFLAGS = -I$(srcdir)/perllib -XOBJS = @XOBJS@ +RUNPERL = $(PERL) $(PERLFLAGS) + +LIBOBJDIR = @LIBOBJDIR@ +LIBOBJS = @LIBOBJS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -102,11 +106,11 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \ all: nasm$(X) ndisasm$(X) manpages rdf -nasm$(X): $(NASM) $(XOBJS) - $(CC) $(LDFLAGS) -o nasm$(X) $(NASM) $(XOBJS) $(LIBS) +nasm$(X): $(NASM) $(LIBOBJS) + $(CC) $(LDFLAGS) -o nasm$(X) $(NASM) $(LIBOBJS) $(LIBS) -ndisasm$(X): $(NDISASM) $(XOBJS) - $(CC) $(LDFLAGS) -o ndisasm$(X) $(NDISASM) $(XOBJS) $(LIBS) +ndisasm$(X): $(NDISASM) $(LIBOBJS) + $(CC) $(LDFLAGS) -o ndisasm$(X) $(NDISASM) $(LIBOBJS) $(LIBS) # These source files are automagically generated from a single # instruction-table file by a Perl script. They're distributed, @@ -115,79 +119,79 @@ ndisasm$(X): $(NDISASM) $(XOBJS) INSDEP = insns.dat insns.pl insns-iflags.pl iflag.c: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -fc $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -fc $(srcdir)/insns.dat iflaggen.h: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -fh $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -fh $(srcdir)/insns.dat insnsb.c: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat insnsa.c: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat insnsd.c: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat insnsi.h: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat insnsn.c: $(INSDEP) - $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat + $(RUNPERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat # These files contains all the standard macros that are derived from # the version number. version.h: version version.pl - $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h + $(RUNPERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h version.mac: version version.pl - $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac + $(RUNPERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac version.sed: version version.pl - $(PERL) $(srcdir)/version.pl sed < $(srcdir)/version > version.sed + $(RUNPERL) $(srcdir)/version.pl sed < $(srcdir)/version > version.sed version.mak: version version.pl - $(PERL) $(srcdir)/version.pl make < $(srcdir)/version > version.mak + $(RUNPERL) $(srcdir)/version.pl make < $(srcdir)/version > version.mak version.nsh: version version.pl - $(PERL) $(srcdir)/version.pl nsis < $(srcdir)/version > version.nsh + $(RUNPERL) $(srcdir)/version.pl nsis < $(srcdir)/version > version.nsh # This source file is generated from the standard macros file # `standard.mac' by another Perl script. Again, it's part of the # standard distribution. macros.c: macros.pl pptok.ph standard.mac version.mac \ $(srcdir)/macros/*.mac $(srcdir)/output/*.mac - $(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac \ + $(RUNPERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac \ $(srcdir)/macros/*.mac $(srcdir)/output/*.mac # These source files are generated from regs.dat by yet another # perl script. regs.c: regs.dat regs.pl - $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c + $(RUNPERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c regflags.c: regs.dat regs.pl - $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c + $(RUNPERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c regdis.c: regs.dat regs.pl - $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c + $(RUNPERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c regdis.h: regs.dat regs.pl - $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h + $(RUNPERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h regvals.c: regs.dat regs.pl - $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c + $(RUNPERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c regs.h: regs.dat regs.pl - $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h + $(RUNPERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h # Assembler token hash tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph - $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \ + $(RUNPERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \ $(srcdir)/tokens.dat > tokhash.c # Assembler token metadata tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph - $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \ + $(RUNPERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \ $(srcdir)/tokens.dat > tokens.h # Preprocessor token hash pptok.h: pptok.dat pptok.pl perllib/phash.ph - $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h + $(RUNPERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h pptok.c: pptok.dat pptok.pl perllib/phash.ph - $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c + $(RUNPERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c pptok.ph: pptok.dat pptok.pl perllib/phash.ph - $(PERL) $(srcdir)/pptok.pl ph $(srcdir)/pptok.dat pptok.ph + $(RUNPERL) $(srcdir)/pptok.pl ph $(srcdir)/pptok.dat pptok.ph # Directives hash directiv.h: directiv.dat directiv.pl perllib/phash.ph - $(PERL) $(srcdir)/directiv.pl h $(srcdir)/directiv.dat directiv.h + $(RUNPERL) $(srcdir)/directiv.pl h $(srcdir)/directiv.dat directiv.h directiv.c: directiv.dat directiv.pl perllib/phash.ph - $(PERL) $(srcdir)/directiv.pl c $(srcdir)/directiv.dat directiv.c + $(RUNPERL) $(srcdir)/directiv.pl c $(srcdir)/directiv.dat directiv.c # This target generates all files that require perl. # This allows easier generation of distribution (see dist target). @@ -284,18 +288,18 @@ splint: splint -weak *.c test: nasm$(X) - cd test && $(PERL) performtest.pl --nasm=../nasm *.asm + cd test && $(RUNPERL) performtest.pl --nasm=../nasm *.asm golden: nasm$(X) - cd test && $(PERL) performtest.pl --golden --nasm=../nasm *.asm + cd test && $(RUNPERL) performtest.pl --golden --nasm=../nasm *.asm # # This build dependencies in *ALL* makefiles. Partially for that reason, # it's expected to be invoked manually. # alldeps: perlreq - $(PERL) syncfiles.pl Makefile.in Mkfiles/*.mak - $(PERL) mkdep.pl -M Makefile.in Mkfiles/*.mak -- \ + $(RUNPERL) syncfiles.pl Makefile.in Mkfiles/*.mak + $(RUNPERL) mkdep.pl -M Makefile.in Mkfiles/*.mak -- \ . output lib ./config.status diff --git a/aclocal.m4 b/aclocal.m4 index 8951278..d8d8ed7 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -14,25 +14,32 @@ AC_DEFUN(PA_ADD_CFLAGS, CFLAGS="$pa_add_cflags__old_cflags")]) dnl -------------------------------------------------------------------------- -dnl PA_WORKING_STDBOOL +dnl PA_HAVE_FUNC dnl -dnl See if we have a working <stdbool.h> and bool support; in particular, -dnl OpenWatcom 1.8 has a broken _Bool type that we don't want to use. +dnl Look for a function with the specified arguments which could be +dnl a builtin/intrinsic function. dnl -------------------------------------------------------------------------- -AC_DEFUN(PA_WORKING_BOOL, -[AC_MSG_CHECKING([if $CC has a working bool type]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -#ifndef __cplusplus -#include <stdbool.h> -#endif -int foo(bool x, int y) -{ - return x+y; -} - ])], - [AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_WORKING_BOOL, 1, - [Define to 1 if your compiler has a correct implementation of bool])], - [AC_MSG_RESULT([no])]) -]) +AC_DEFUN(PA_HAVE_FUNC, +[AC_MSG_CHECKING([for $1]) +AC_TRY_LINK([], [(void)$1$2;], +AC_MSG_RESULT([yes]) +AC_DEFINE(m4_toupper([HAVE_$1]), [1], + [Define to 1 if you have the `$1' intrinsic function.]), +AC_MSG_RESULT([no]))]) +dnl -------------------------------------------------------------------------- +dnl PA_REPLACE_FUNC +dnl +dnl Look for a function and possible alternatives, unlike AC_REPLACE_FUNCS +dnl this will only add *one* replacement to LIBOBJS if no alternative is +dnl found. +dnl -------------------------------------------------------------------------- +AC_DEFUN(PA_REPLACE_FUNC_WITH, +[pa_replace_func__$2_missing=true +AC_CHECK_FUNCS([$1], [pa_replace_func__$2_missing=false], []) +if $pa_replace_func__$2_missing; then + AC_LIBOBJ([$2]) +fi]) + +AC_DEFUN(PA_REPLACE_FUNC, +[PA_REPLACE_FUNC_WITH([$1], m4_car(m4_unquote(m4_split(m4_normalize[$1]))))]) diff --git a/compiler.h b/compiler.h index e9022f8..a52495e 100644 --- a/compiler.h +++ b/compiler.h @@ -70,15 +70,6 @@ #define __STDC_FORMAT_MACROS 1 #ifdef __GNUC__ -# if __GNUC__ >= 4 -# define HAVE_GNUC_4 -# endif -# if __GNUC__ >= 3 -# define HAVE_GNUC_3 -# endif -#endif - -#ifdef __GNUC__ # define _unused __attribute__((unused)) #else # define _unused @@ -110,8 +101,12 @@ size_t strlcpy(char *, const char *, size_t); #endif #ifndef __cplusplus /* C++ has false, true, bool as keywords */ -# if defined(HAVE_STDBOOL_H) && defined(HAVE_WORKING_BOOL) +# ifdef HAVE_STDBOOL_H # include <stdbool.h> +# elif defined(HAVE__BOOL) +# typedef _Bool bool +# define false 0 +# define true 1 # else /* This is sort of dangerous, since casts will behave different than casting to the standard boolean type. Always use !!, not (bool). */ diff --git a/configure.in b/configure.in index 023bd24..42eee15 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ -dnl Process this file with autoconf 2.61 or later to produce +dnl Process this file with autoconf 2.63 or later to produce dnl a configure script. -AC_PREREQ(2.61) +AC_PREREQ(2.63) AC_INIT(config.h.in) AC_CONFIG_HEADERS(config.h) @@ -48,8 +48,9 @@ AC_PREFIX_PROGRAM(nasm) dnl Checks for programs. dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future -AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC +AC_PROG_CC_STDC +AC_USE_SYSTEM_EXTENSIONS AC_PROG_LN_S AC_PROG_MAKE_SET if test -f nasm.c; then @@ -65,7 +66,6 @@ AC_C_CONST AC_C_INLINE AC_C_RESTRICT AC_TYPE_SIZE_T -PA_WORKING_BOOL AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN)) AH_TEMPLATE(WORDS_BIGENDIAN, [Define to 1 if your processor stores words with the most significant @@ -74,11 +74,6 @@ AH_TEMPLATE(WORDS_LITTLEENDIAN, [Define to 1 if your processor stores words with the least significant byte first (like Intel and VAX, unlike Motorola and SPARC).]) -dnl If we have gcc, add appropriate options -PA_ADD_CFLAGS([-W]) -PA_ADD_CFLAGS([-Wall]) -PA_ADD_CFLAGS([-std=c99]) - dnl Look for programs... AC_CHECK_PROGS(NROFF, nroff, false) AC_CHECK_PROGS(ASCIIDOC, asciidoc, false) @@ -113,7 +108,7 @@ dnl The standard header for str*casecmp is <strings.h> AC_CHECK_HEADERS(strings.h) dnl Look for <stdbool.h> -AC_CHECK_HEADERS(stdbool.h) +AC_HEADER_STDBOOL dnl Look for <unistd.h> AC_CHECK_HEADERS(unistd.h) @@ -122,30 +117,14 @@ dnl Look for <sys/param.h> AC_CHECK_HEADERS(sys/param.h) dnl Checks for library functions. -AC_SUBST(XOBJS) - AC_CHECK_FUNCS(strcspn, , AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")])) AC_CHECK_FUNCS(strspn, , AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")])) -missing=true -AC_CHECK_FUNCS([vsnprintf _vsnprintf], missing=false) -if $missing; then - XOBJS="$XOBJS lib/vsnprintf.o" -fi - -missing=true -AC_CHECK_FUNCS([snprintf _snprintf], missing=false) -if $missing; then - XOBJS="$XOBJS lib/snprintf.o" -fi - AC_CHECK_FUNCS(strcasecmp stricmp) AC_CHECK_FUNCS(strncasecmp strnicmp) -AC_CHECK_FUNCS(strsep) -AC_CHECK_FUNCS(strlcpy) AC_CHECK_FUNCS(getuid) AC_CHECK_FUNCS(getgid) @@ -155,6 +134,18 @@ AC_CHECK_FUNCS(canonicalize_file_name) AC_CHECK_FUNCS(_fullpath) AC_CHECK_FUNCS(pathconf) +PA_HAVE_FUNC(__builtin_ctz, (0U)) +PA_HAVE_FUNC(__builtin_ctzl, (0UL)) +PA_HAVE_FUNC(__builtin_ctzll, (0ULL)) + +dnl Functions for which we have replacements available in lib/ +AC_CONFIG_LIBOBJ_DIR([lib]) +AC_SUBST([LIBOBJDIR], [lib/]) +PA_REPLACE_FUNC([vsnprintf _vsnprintf]) +PA_REPLACE_FUNC([snprintf _snprintf]) +PA_REPLACE_FUNC([strlcpy]) +PA_REPLACE_FUNC([strsep]) + dnl Check for functions that might not be declared in the headers for dnl various idiotic reasons (mostly because of library authors dnl abusing the meaning of __STRICT_ANSI__) @@ -181,6 +172,9 @@ AC_ARG_WITH([ccache], [CC="ccache $CC"], []) +dnl If we have gcc, add appropriate options +PA_ADD_CFLAGS([-W]) +PA_ADD_CFLAGS([-Wall]) PA_ADD_CFLAGS([-pedantic]) PA_ADD_CFLAGS([-Werror=implicit]) PA_ADD_CFLAGS([-Werror=missing-braces]) diff --git a/ilog2.c b/ilog2.c index 9c054fd..a606622 100644 --- a/ilog2.c +++ b/ilog2.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2010 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -42,6 +42,7 @@ } \ } while (0) + #if defined(__GNUC__) && defined(__x86_64__) int ilog2_32(uint32_t v) @@ -67,7 +68,7 @@ int ilog2_32(uint32_t v) return n; } -#elif defined(HAVE_GNUC_4) +#elif defined(HAVE___BUILTIN_CTZ) && INT_MAX >= 2147483647 int ilog2_32(uint32_t v) { @@ -106,7 +107,7 @@ int ilog2_64(uint64_t v) return n; } -#elif defined(HAVE_GNUC_4) +#elif defined(HAVE__BUILTIN_CTZLL) && LLONG_MAX >= 9223372036854775807L int ilog2_64(uint64_t v) { diff --git a/lib/strlcpy.c b/lib/strlcpy.c index 4335359..22d9ccf 100644 --- a/lib/strlcpy.c +++ b/lib/strlcpy.c @@ -14,8 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> -#include <string.h> #include "compiler.h" /* |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 06:09:19
|
Commit-ID: f9be8c317909ad5c47d3271c230fe6b967dc0bf0 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=f9be8c317909ad5c47d3271c230fe6b967dc0bf0 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 22:01:33 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 22:01:33 -0800 outelf64: fix comment Fix comment that refer to R_386_* to avoid hiding similarities versus outelfx32. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outelf64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output/outelf64.c b/output/outelf64.c index b5bec7b..dbd0bf0 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -594,8 +594,8 @@ static void elf_add_reloc(struct elf_section *sect, int32_t segment, * _containing_ the symbol. Such relocations call to this routine, * which searches the symbol list for the symbol in question. * - * R_386_GOT32 references require the _exact_ symbol address to be - * used; R_386_32 references can be at an offset from the symbol. + * R_X86_64_GOT32 references require the _exact_ symbol address to be + * used; R_X86_64_32 references can be at an offset from the symbol. * The boolean argument `exact' tells us this. * * Return value is the adjusted value of `addr', having become an |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 06:09:19
|
Commit-ID: 9e1d691e82ea702d79a0e44e8a2cbf2c31dde164 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=9e1d691e82ea702d79a0e44e8a2cbf2c31dde164 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 22:04:45 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 22:06:20 -0800 gitignore: properly ignore generated man pages Fix the .gitignore files so man pages are correctly ignored. Signed-off-by: H. Peter Anvin <hp...@li...> --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1fb29c2..e68956c 100644 --- a/.gitignore +++ b/.gitignore @@ -46,9 +46,8 @@ TAGS /insnsn.c /macros.c /nasm -/nasm.man /ndisasm -/ndisasm.man +/*.1 /pptok.c /pptok.h /pptok.ph |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 05:06:30
|
Commit-ID: 338656c1de8cace12c55c87ce40a7d909f18c2e9 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=338656c1de8cace12c55c87ce40a7d909f18c2e9 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 20:59:22 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 20:59:22 -0800 output: make all instances of struct ofmt readonly With current_dfmt gone, we can make all instances of struct ofmt const (read-only). Signed-off-by: H. Peter Anvin <hp...@li...> --- nasm.c | 4 ++-- nasm.h | 2 +- output/outaout.c | 6 +++--- output/outas86.c | 2 +- output/outbin.c | 8 ++++---- output/outcoff.c | 6 +++--- output/outdbg.c | 4 ++-- output/outelf32.c | 4 ++-- output/outelf64.c | 4 ++-- output/outelfx32.c | 4 ++-- output/outform.c | 12 ++++++------ output/outform.h | 48 ++++++++++++++++++++++++------------------------ output/outieee.c | 4 ++-- output/outlib.h | 1 - output/outmacho.c | 6 +++--- output/outobj.c | 4 ++-- output/outrdf2.c | 2 +- 17 files changed, 60 insertions(+), 61 deletions(-) diff --git a/nasm.c b/nasm.c index bab5c61..3c2fada 100644 --- a/nasm.c +++ b/nasm.c @@ -99,8 +99,8 @@ static char listname[FILENAME_MAX]; static char errname[FILENAME_MAX]; static int globallineno; /* for forward-reference tracking */ /* static int pass = 0; */ -struct ofmt *ofmt = &OF_DEFAULT; -struct ofmt_alias *ofmt_alias = NULL; +const struct ofmt *ofmt = &OF_DEFAULT; +const struct ofmt_alias *ofmt_alias = NULL; const struct dfmt *dfmt; static FILE *error_file; /* Where to write error messages */ diff --git a/nasm.h b/nasm.h index 2e7a453..80917a1 100644 --- a/nasm.h +++ b/nasm.h @@ -917,7 +917,7 @@ struct ofmt_alias { struct ofmt *ofmt; }; -extern struct ofmt *ofmt; +extern const struct ofmt *ofmt; extern FILE *ofile; /* diff --git a/output/outaout.c b/output/outaout.c index 1ff22a5..5a12540 100644 --- a/output/outaout.c +++ b/output/outaout.c @@ -188,7 +188,7 @@ static void aout_init(void) #ifdef OF_AOUTB -extern struct ofmt of_aoutb; +extern const struct ofmt of_aoutb; static void aoutb_init(void) { @@ -908,7 +908,7 @@ extern macros_t aout_stdmac[]; #ifdef OF_AOUT -struct ofmt of_aout = { +const struct ofmt of_aout = { "Linux a.out object files", "aout", 0, @@ -932,7 +932,7 @@ struct ofmt of_aout = { #ifdef OF_AOUTB -struct ofmt of_aoutb = { +const struct ofmt of_aoutb = { "NetBSD/FreeBSD a.out object files", "aoutb", 0, diff --git a/output/outas86.c b/output/outas86.c index 43108c4..ac3628f 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -629,7 +629,7 @@ static void as86_filename(char *inname, char *outname) extern macros_t as86_stdmac[]; -struct ofmt of_as86 = { +const struct ofmt of_as86 = { "Linux as86 (bin86 version 0.3) object files", "as86", 0, diff --git a/output/outbin.c b/output/outbin.c index 4d669af..5f99346 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -1405,7 +1405,7 @@ static int bin_set_info(enum geninfo type, char **val) return 0; } -struct ofmt of_bin, of_ith, of_srec; +const struct ofmt of_bin, of_ith, of_srec; static void binfmt_init(void); static void do_output_bin(void); static void do_output_ith(void); @@ -1655,7 +1655,7 @@ static void do_output_srec(void) } -struct ofmt of_bin = { +const struct ofmt of_bin = { "flat-form binary files (e.g. DOS .COM, .SYS)", "bin", 0, @@ -1675,7 +1675,7 @@ struct ofmt of_bin = { bin_cleanup }; -struct ofmt of_ith = { +const struct ofmt of_ith = { "Intel hex", "ith", OFMT_TEXT, @@ -1695,7 +1695,7 @@ struct ofmt of_ith = { bin_cleanup }; -struct ofmt of_srec = { +const struct ofmt of_srec = { "Motorola S-records", "srec", OFMT_TEXT, diff --git a/output/outcoff.c b/output/outcoff.c index bd971d1..e208c93 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -1168,7 +1168,7 @@ static int coff_set_info(enum geninfo type, char **val) #ifdef OF_COFF -struct ofmt of_coff = { +const struct ofmt of_coff = { "COFF (i386) object files (e.g. DJGPP for DOS)", "coff", 0, @@ -1196,7 +1196,7 @@ extern struct dfmt df_cv8; struct dfmt *win32_debug_arr[2] = { &df_cv8, NULL }; -struct ofmt of_win32 = { +const struct ofmt of_win32 = { "Microsoft Win32 (i386) object files", "win32", 0, @@ -1222,7 +1222,7 @@ struct ofmt of_win32 = { struct dfmt *win64_debug_arr[2] = { &df_cv8, NULL }; -struct ofmt of_win64 = { +const struct ofmt of_win64 = { "Microsoft Win64 (x86-64) object files", "win64", 0, diff --git a/output/outdbg.c b/output/outdbg.c index 83860ab..b954f14 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -56,7 +56,7 @@ struct Section { char *name; } *dbgsect; -struct ofmt of_dbg; +const struct ofmt of_dbg; static void dbg_init(void) { dbgsect = NULL; @@ -260,7 +260,7 @@ static struct dfmt *debug_debug_arr[3] = { NULL }; -struct ofmt of_dbg = { +const struct ofmt of_dbg = { "Trace of all info passed to output stage", "dbg", OFMT_TEXT, diff --git a/output/outelf32.c b/output/outelf32.c index 5a9f847..bc8be22 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -82,7 +82,7 @@ static struct elf_symbol *fwds; static char elf_module[FILENAME_MAX]; -extern struct ofmt of_elf32; +extern const struct ofmt of_elf32; static struct ELF_SECTDATA { void *data; @@ -1360,7 +1360,7 @@ static struct dfmt df_stabs = { struct dfmt *elf32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; -struct ofmt of_elf32 = { +const struct ofmt of_elf32 = { "ELF32 (i386) object files (e.g. Linux)", "elf32", 0, diff --git a/output/outelf64.c b/output/outelf64.c index ec00156..829c6ff 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -82,7 +82,7 @@ static struct elf_symbol *fwds; static char elf_module[FILENAME_MAX]; -extern struct ofmt of_elf64; +extern const struct ofmt of_elf64; static struct ELF_SECTDATA { void *data; @@ -1451,7 +1451,7 @@ static struct dfmt df_stabs = { struct dfmt *elf64_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; -struct ofmt of_elf64 = { +const struct ofmt of_elf64 = { "ELF64 (x86_64) object files (e.g. Linux)", "elf64", 0, diff --git a/output/outelfx32.c b/output/outelfx32.c index fcd97d3..0d5edf2 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -82,7 +82,7 @@ static struct elf_symbol *fwds; static char elf_module[FILENAME_MAX]; -extern struct ofmt of_elfx32; +extern const struct ofmt of_elfx32; static struct ELF_SECTDATA { void *data; @@ -1410,7 +1410,7 @@ static struct dfmt df_stabs = { struct dfmt *elfx32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; -struct ofmt of_elfx32 = { +const struct ofmt of_elfx32 = { "ELFX32 (x86_64) object files (e.g. Linux)", "elfx32", 0, diff --git a/output/outform.c b/output/outform.c index 3d70e2a..77983c0 100644 --- a/output/outform.c +++ b/output/outform.c @@ -47,9 +47,9 @@ #define BUILD_DRIVERS_ARRAY #include "output/outform.h" -struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias) +const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias) { - struct ofmt **ofp, *of; + const struct ofmt **ofp, *of; unsigned int i; *ofmt_alias = NULL; @@ -72,7 +72,7 @@ struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias) return NULL; } -struct dfmt *dfmt_find(struct ofmt *ofmt, char *name) +struct dfmt *dfmt_find(const struct ofmt *ofmt, char *name) { struct dfmt **dfp, *df; @@ -83,9 +83,9 @@ struct dfmt *dfmt_find(struct ofmt *ofmt, char *name) return NULL; } -void ofmt_list(struct ofmt *deffmt, FILE * fp) +void ofmt_list(const struct ofmt *deffmt, FILE * fp) { - struct ofmt **ofp, *of; + const struct ofmt **ofp, *of; unsigned int i; /* primary targets first */ @@ -105,7 +105,7 @@ void ofmt_list(struct ofmt *deffmt, FILE * fp) } } -void dfmt_list(struct ofmt *ofmt, FILE *fp) +void dfmt_list(const struct ofmt *ofmt, FILE *fp) { struct dfmt **dfp, *df; diff --git a/output/outform.h b/output/outform.h index f52a112..f01588d 100644 --- a/output/outform.h +++ b/output/outform.h @@ -262,24 +262,24 @@ #define OF_DEFAULT of_bin #endif -extern struct ofmt of_bin; -extern struct ofmt of_ith; -extern struct ofmt of_srec; -extern struct ofmt of_aout; -extern struct ofmt of_aoutb; -extern struct ofmt of_coff; -extern struct ofmt of_elf32; -extern struct ofmt of_elfx32; -extern struct ofmt of_elf64; -extern struct ofmt of_as86; -extern struct ofmt of_obj; -extern struct ofmt of_win32; -extern struct ofmt of_win64; -extern struct ofmt of_rdf2; -extern struct ofmt of_ieee; -extern struct ofmt of_macho32; -extern struct ofmt of_macho64; -extern struct ofmt of_dbg; +extern const struct ofmt of_bin; +extern const struct ofmt of_ith; +extern const struct ofmt of_srec; +extern const struct ofmt of_aout; +extern const struct ofmt of_aoutb; +extern const struct ofmt of_coff; +extern const struct ofmt of_elf32; +extern const struct ofmt of_elfx32; +extern const struct ofmt of_elf64; +extern const struct ofmt of_as86; +extern const struct ofmt of_obj; +extern const struct ofmt of_win32; +extern const struct ofmt of_win64; +extern const struct ofmt of_rdf2; +extern const struct ofmt of_ieee; +extern const struct ofmt of_macho32; +extern const struct ofmt of_macho64; +extern const struct ofmt of_dbg; #ifdef BUILD_DRIVERS_ARRAY /* only if included from outform.c */ @@ -288,7 +288,7 @@ extern struct ofmt of_dbg; * drivers array based on the above defines */ -static struct ofmt *drivers[] = { +static const struct ofmt *drivers[] = { #ifdef OF_BIN &of_bin, &of_ith, @@ -343,7 +343,7 @@ static struct ofmt *drivers[] = { NULL }; -static struct ofmt_alias ofmt_aliases[] = { +static const struct ofmt_alias ofmt_aliases[] = { #ifdef OF_ELF32 { "elf", @@ -370,10 +370,10 @@ static struct ofmt_alias ofmt_aliases[] = { #endif /* BUILD_DRIVERS_ARRAY */ -struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias); -struct dfmt *dfmt_find(struct ofmt *, char *); -void ofmt_list(struct ofmt *, FILE *); -void dfmt_list(struct ofmt *ofmt, FILE * fp); +const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias); +struct dfmt *dfmt_find(const struct ofmt *, char *); +void ofmt_list(const struct ofmt *, FILE *); +void dfmt_list(const struct ofmt *ofmt, FILE * fp); extern struct dfmt null_debug_form; #endif /* NASM_OUTFORM_H */ diff --git a/output/outieee.c b/output/outieee.c index 2fcbddb..727d04e 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -184,7 +184,7 @@ struct ieeeFixupp { static int32_t ieee_entry_seg, ieee_entry_ofs; static int checksum; -extern struct ofmt of_ieee; +extern const struct ofmt of_ieee; static void ieee_data_new(struct ieeeSection *); static void ieee_write_fixup(int32_t, int32_t, struct ieeeSection *, @@ -1513,7 +1513,7 @@ static struct dfmt *ladsoft_debug_arr[3] = { &null_debug_form, NULL }; -struct ofmt of_ieee = { +const struct ofmt of_ieee = { "IEEE-695 (LADsoft variant) object file format", "ieee", OFMT_TEXT, diff --git a/output/outlib.h b/output/outlib.h index 29c27a0..1acf11d 100644 --- a/output/outlib.h +++ b/output/outlib.h @@ -44,7 +44,6 @@ int null_directive(enum directives directive, char *value, int pass); void null_sectalign(int32_t seg, unsigned int value); /* Do-nothing versions of all the debug routines */ -struct ofmt; void null_debug_init(void); void null_debug_linenum(const char *filename, int32_t linenumber, int32_t segto); diff --git a/output/outmacho.c b/output/outmacho.c index 98a440d..4f8c65a 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -276,7 +276,7 @@ static struct RAA *extsyms; static struct SAA *strs; static uint32_t strslen; -extern struct ofmt of_macho64; +extern const struct ofmt of_macho64; /* Global file information. This should be cleaned up into either a structure or as function arguments. */ @@ -1595,7 +1595,7 @@ static void macho32_init(void) macho_gotpcrel_sect = NO_SEG; } -struct ofmt of_macho32 = { +const struct ofmt of_macho32 = { "NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files", "macho32", 0, @@ -1642,7 +1642,7 @@ static void macho64_init(void) define_label("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false); } -struct ofmt of_macho64 = { +const struct ofmt of_macho64 = { "NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files", "macho64", 0, diff --git a/output/outobj.c b/output/outobj.c index 9a9ff1c..3cb0610 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -624,7 +624,7 @@ static struct ExpDef { static int32_t obj_entry_seg, obj_entry_ofs; -struct ofmt of_obj; +const struct ofmt of_obj; /* The current segment */ static struct Segment *current_seg; @@ -2623,7 +2623,7 @@ static struct dfmt *borland_debug_arr[3] = { NULL }; -struct ofmt of_obj = { +const struct ofmt of_obj = { "MS-DOS 16-bit/32-bit OMF object files", "obj", 0, diff --git a/output/outrdf2.c b/output/outrdf2.c index 4dcae83..235d713 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -775,7 +775,7 @@ static int rdf2_set_info(enum geninfo type, char **val) return 0; } -struct ofmt of_rdf2 = { +const struct ofmt of_rdf2 = { "Relocatable Dynamic Object File Format v2.0", "rdf", 0, |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 05:06:29
|
Commit-ID: a7bc15dd0aa963ab56a98ee04bc08ce6d9e3baea Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=a7bc15dd0aa963ab56a98ee04bc08ce6d9e3baea Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 20:55:08 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 20:55:08 -0800 Remove ofmt->current_dfmt indirection Move ofmt->current_dfmt into a separate global variable. This should allow us to make ofmt readonly and removes some additional gratuitious differences between backends. Signed-off-by: H. Peter Anvin <hp...@li...> --- assemble.c | 2 +- labels.c | 10 +++++----- nasm.c | 10 ++++++---- nasm.h | 8 ++------ output/outcoff.c | 8 ++++---- output/outdbg.c | 2 +- output/outelf32.c | 22 +++++++++++----------- output/outelf64.c | 22 +++++++++++----------- output/outelfx32.c | 22 +++++++++++----------- output/outform.c | 2 +- output/outieee.c | 2 +- output/outobj.c | 2 +- 12 files changed, 55 insertions(+), 57 deletions(-) diff --git a/assemble.c b/assemble.c index a26f2bf..84ed4b8 100644 --- a/assemble.c +++ b/assemble.c @@ -370,7 +370,7 @@ static void out(int64_t offset, int32_t segto, const void *data, */ if (src_get(&lineno, &lnfname)) - ofmt->current_dfmt->linenum(lnfname, lineno, segto); + dfmt->linenum(lnfname, lineno, segto); if (asize && asize > amax) { if (type != OUT_ADDRESS || (int)size < 0) { diff --git a/labels.c b/labels.c index e14fe47..b4433d0 100644 --- a/labels.c +++ b/labels.c @@ -262,14 +262,14 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special, ofmt->symdef(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(xsymbol, segment, offset, exi, + dfmt->debug_deflabel(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); /** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/ } else { if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) { ofmt->symdef(lptr->defn.label, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(label, segment, offset, exi, + dfmt->debug_deflabel(label, segment, offset, exi, special ? special : lptr->defn.special); } } @@ -327,14 +327,14 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special, ofmt->symdef(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(xsymbol, segment, offset, exi, + dfmt->debug_deflabel(xsymbol, segment, offset, exi, special ? special : lptr->defn.special); /** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/ } else { if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) { ofmt->symdef(lptr->defn.label, segment, offset, exi, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(label, segment, offset, exi, + dfmt->debug_deflabel(label, segment, offset, exi, special ? special : lptr->defn.special); } } @@ -371,7 +371,7 @@ void define_common(char *label, int32_t segment, int32_t size, char *special) ofmt->symdef(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); - ofmt->current_dfmt->debug_deflabel(lptr->defn.label, segment, size, 2, + dfmt->debug_deflabel(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); } diff --git a/nasm.c b/nasm.c index 52ac324..bab5c61 100644 --- a/nasm.c +++ b/nasm.c @@ -358,7 +358,9 @@ int main(int argc, char **argv) /* If debugging info is disabled, suppress any debug calls */ if (!using_debug_info) - ofmt->current_dfmt = &null_debug_form; + dfmt = &null_debug_form; + else if (!dfmt) + dfmt = ofmt->default_dfmt; if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); @@ -459,7 +461,6 @@ int main(int argc, char **argv) init_labels(); ofmt->init(); - dfmt = ofmt->current_dfmt; dfmt->init(); assemble_file(inname, depend_ptr); @@ -665,6 +666,7 @@ static bool process_arg(char *p, char *q) "unrecognised output format `%s' - " "use -hf for a list", param); } + dfmt = NULL; break; case 'O': /* Optimization level */ @@ -742,8 +744,8 @@ static bool process_arg(char *p, char *q) break; case 'F': /* specify debug format */ - ofmt->current_dfmt = dfmt_find(ofmt, param); - if (!ofmt->current_dfmt) { + dfmt = dfmt_find(ofmt, param); + if (!dfmt) { nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, "unrecognized debug format `%s' for" " output format `%s'", diff --git a/nasm.h b/nasm.h index d0fb8bd..2e7a453 100644 --- a/nasm.h +++ b/nasm.h @@ -751,13 +751,9 @@ struct ofmt { struct dfmt **debug_formats; /* - * and a pointer to the element that is being used - * note: this is set to the default at compile time and changed if the - * -F option is selected. If developing a set of new debug formats for - * an output format, be sure to set this to whatever default you want - * + * the default debugging format if -F is not specified */ - const struct dfmt *current_dfmt; + const struct dfmt *default_dfmt; /* * This, if non-NULL, is a NULL-terminated list of `char *'s diff --git a/output/outcoff.c b/output/outcoff.c index a712f95..bd971d1 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -228,8 +228,8 @@ static void coff_cleanup(int debuginfo) struct coff_Reloc *r; int i; - if (debuginfo && ofmt->current_dfmt->cleanup) - ofmt->current_dfmt->cleanup(); + if (debuginfo && dfmt->cleanup) + dfmt->cleanup(); coff_write(); for (i = 0; i < coff_nsects; i++) { @@ -603,7 +603,7 @@ static void coff_out(int32_t segto, const void *data, memset(mydata, 0, sizeof(mydata)); - if (ofmt->current_dfmt && ofmt->current_dfmt->debug_output) { + if (dfmt && dfmt->debug_output) { struct coff_DebugInfo dinfo; dinfo.segto = segto; dinfo.seg = segment; @@ -614,7 +614,7 @@ static void coff_out(int32_t segto, const void *data, else dinfo.size = realsize(type, size); - ofmt->current_dfmt->debug_output(type, &dinfo); + dfmt->debug_output(type, &dinfo); } if (type == OUT_RESERVE) { diff --git a/output/outdbg.c b/output/outdbg.c index 034a615..83860ab 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -66,7 +66,7 @@ static void dbg_init(void) static void dbg_cleanup(int debuginfo) { (void)debuginfo; - of_dbg.current_dfmt->cleanup(); + dfmt->cleanup(); while (dbgsect) { struct Section *tmp = dbgsect; dbgsect = dbgsect->next; diff --git a/output/outelf32.c b/output/outelf32.c index 7852e71..5a9f847 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -241,8 +241,8 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (of_elf32.current_dfmt) { - of_elf32.current_dfmt->cleanup(); + if (dfmt) { + dfmt->cleanup(); } } @@ -692,11 +692,11 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (of_elf32.current_dfmt) { + if (dfmt) { sinfo.offset = s->len; sinfo.section = i; sinfo.name = s->name; - of_elf32.current_dfmt->debug_output(TY_STABSSYMLIN, &sinfo); + dfmt->debug_output(TY_STABSSYMLIN, &sinfo); } /* end of debugging stuff */ @@ -895,9 +895,9 @@ static void elf_write(void) * relocation sections for the user sections. */ nsections = sec_numspecial + 1; - if (of_elf32.current_dfmt == &df_stabs) + if (dfmt == &df_stabs) nsections += 3; - else if (of_elf32.current_dfmt == &df_dwarf) + else if (dfmt == &df_dwarf) nsections += 10; add_sectname("", ".shstrtab"); @@ -911,12 +911,12 @@ static void elf_write(void) } } - if (of_elf32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* in case the debug information is wanted, just add these three sections... */ add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); - } else if (of_elf32.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1013,7 +1013,7 @@ static void elf_write(void) p += strlen(p) + 1; } - if (of_elf32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* for debugging information, create the last three sections which are the .stab , .stabstr and .rel.stab sections respectively */ @@ -1034,7 +1034,7 @@ static void elf_write(void) stabrellen, sec_symtab, sec_stab, 4, 8); p += strlen(p) + 1; } - } else if (of_elf32.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ @@ -1161,7 +1161,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * which are relocation targets. */ //*** fix for 32 bit - if (of_elf32.current_dfmt == &df_dwarf) { + if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; WRITELONG(p, 0); /* no symbol name */ diff --git a/output/outelf64.c b/output/outelf64.c index d23c53a..ec00156 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -246,8 +246,8 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (of_elf64.current_dfmt) { - of_elf64.current_dfmt->cleanup(); + if (dfmt) { + dfmt->cleanup(); } } @@ -709,12 +709,12 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (of_elf64.current_dfmt) { + if (dfmt) { sinfo.offset = s->len; sinfo.section = i; sinfo.segto = segto; sinfo.name = s->name; - of_elf64.current_dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); } /* end of debugging stuff */ @@ -977,9 +977,9 @@ static void elf_write(void) * relocation sections for the user sections. */ nsections = sec_numspecial + 1; - if (of_elf64.current_dfmt == &df_stabs) + if (dfmt == &df_stabs) nsections += 3; - else if (of_elf64.current_dfmt == &df_dwarf) + else if (dfmt == &df_dwarf) nsections += 10; add_sectname("", ".shstrtab"); @@ -993,14 +993,14 @@ static void elf_write(void) } } - if (of_elf64.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* in case the debug information is wanted, just add these three sections... */ add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); } - else if (of_elf64.current_dfmt == &df_dwarf) { + else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1098,7 +1098,7 @@ static void elf_write(void) p += strlen(p) + 1; } - if (of_elf64.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* for debugging information, create the last three sections which are the .stab , .stabstr and .rel.stab sections respectively */ @@ -1119,7 +1119,7 @@ static void elf_write(void) stabrellen, symtabsection, sec_stab, 4, 16); p += strlen(p) + 1; } - } else if (of_elf64.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ @@ -1245,7 +1245,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * dwarf needs symbols for debug sections * which are relocation targets. */ - if (of_elf64.current_dfmt == &df_dwarf) { + if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; WRITELONG(p, 0); /* no symbol name */ diff --git a/output/outelfx32.c b/output/outelfx32.c index 8e1b0c6..fcd97d3 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -245,8 +245,8 @@ static void elf_cleanup(int debuginfo) saa_free(syms); raa_free(bsym); saa_free(strs); - if (of_elfx32.current_dfmt) { - of_elfx32.current_dfmt->cleanup(); + if (dfmt) { + dfmt->cleanup(); } } @@ -708,12 +708,12 @@ static void elf_out(int32_t segto, const void *data, } /* again some stabs debugging stuff */ - if (of_elfx32.current_dfmt) { + if (dfmt) { sinfo.offset = s->len; sinfo.section = i; sinfo.segto = segto; sinfo.name = s->name; - of_elfx32.current_dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); } /* end of debugging stuff */ @@ -939,9 +939,9 @@ static void elf_write(void) * relocation sections for the user sections. */ nsections = sec_numspecial + 1; - if (of_elfx32.current_dfmt == &df_stabs) + if (dfmt == &df_stabs) nsections += 3; - else if (of_elfx32.current_dfmt == &df_dwarf) + else if (dfmt == &df_dwarf) nsections += 10; add_sectname("", ".shstrtab"); @@ -955,14 +955,14 @@ static void elf_write(void) } } - if (of_elfx32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* in case the debug information is wanted, just add these three sections... */ add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); } - else if (of_elfx32.current_dfmt == &df_dwarf) { + else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1059,7 +1059,7 @@ static void elf_write(void) p += strlen(p) + 1; } - if (of_elfx32.current_dfmt == &df_stabs) { + if (dfmt == &df_stabs) { /* for debugging information, create the last three sections which are the .stab , .stabstr and .rel.stab sections respectively */ @@ -1080,7 +1080,7 @@ static void elf_write(void) stabrellen, sec_symtab, sec_stab, 4, 8); p += strlen(p) + 1; } - } else if (of_elfx32.current_dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ @@ -1206,7 +1206,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * dwarf needs symbols for debug sections * which are relocation targets. */ - if (of_elfx32.current_dfmt == &df_dwarf) { + if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; WRITELONG(p, 0); /* no symbol name */ diff --git a/output/outform.c b/output/outform.c index 0c8ae53..3d70e2a 100644 --- a/output/outform.c +++ b/output/outform.c @@ -111,7 +111,7 @@ void dfmt_list(struct ofmt *ofmt, FILE *fp) for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) { fprintf(fp, " %c %-10s%s\n", - df == ofmt->current_dfmt ? '*' : ' ', + df == dfmt ? '*' : ' ', df->shortname, df->fullname); } } diff --git a/output/outieee.c b/output/outieee.c index 42f0fb6..2fcbddb 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -235,7 +235,7 @@ static int ieee_set_info(enum geninfo type, char **val) static void ieee_cleanup(int debuginfo) { ieee_write_file(debuginfo); - of_ieee.current_dfmt->cleanup(); + dfmt->cleanup(); while (seghead) { struct ieeeSection *segtmp = seghead; seghead = seghead->next; diff --git a/output/outobj.c b/output/outobj.c index beb95da..9a9ff1c 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -670,7 +670,7 @@ static int obj_set_info(enum geninfo type, char **val) static void obj_cleanup(int debuginfo) { obj_write_file(debuginfo); - of_obj.current_dfmt->cleanup(); + dfmt->cleanup(); while (seghead) { struct Segment *segtmp = seghead; seghead = seghead->next; |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 05:06:28
|
Commit-ID: e3e2f1bbc2c773a72a3230153c3e31f4a3bf1032 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=e3e2f1bbc2c773a72a3230153c3e31f4a3bf1032 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 21:03:13 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 21:03:13 -0800 outelf64: symtabsection is defined but never set, change to sec_symtab The variable symtabsection is defined but it is never actually set and so was always zero. For both the 32-bit output format this is sec_symtab defined in elf.h. If this is not correct for the 64-bit format, then we should define sec_symtab as a variable instead of having a gratuitious format difference. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outelf64.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/output/outelf64.c b/output/outelf64.c index 829c6ff..b5bec7b 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -139,7 +139,6 @@ static int debug_immcall = 0; static struct linelist *stabslines = 0; static int numlinestabs = 0; static char *stabs_filename = 0; -static int symtabsection; static uint8_t *stabbuf = 0, *stabstrbuf = 0, *stabrelbuf = 0; static int stablen, stabstrlen, stabrellen; @@ -1116,7 +1115,7 @@ static void elf_write(void) /* link -> symtable info -> section to refer to */ elf_section_header(p - shstrtab, SHT_REL, 0, stabrelbuf, false, - stabrellen, symtabsection, sec_stab, 4, 16); + stabrellen, sec_symtab, sec_stab, 4, 16); p += strlen(p) + 1; } } else if (dfmt == &df_dwarf) { @@ -1131,7 +1130,7 @@ static void elf_write(void) p += strlen(p) + 1; elf_section_header(p - shstrtab, SHT_RELA, 0, arangesrelbuf, false, - arangesrellen, symtabsection, debug_aranges, 1, 24); + arangesrellen, sec_symtab, debug_aranges, 1, 24); p += strlen(p) + 1; elf_section_header(p - shstrtab, SHT_PROGBITS, 0, pubnamesbuf, false, @@ -1143,7 +1142,7 @@ static void elf_write(void) p += strlen(p) + 1; elf_section_header(p - shstrtab, SHT_RELA, 0, inforelbuf, false, - inforellen, symtabsection, debug_info, 1, 24); + inforellen, sec_symtab, debug_info, 1, 24); p += strlen(p) + 1; elf_section_header(p - shstrtab, SHT_PROGBITS, 0, abbrevbuf, false, @@ -1155,7 +1154,7 @@ static void elf_write(void) p += strlen(p) + 1; elf_section_header(p - shstrtab, SHT_RELA, 0, linerelbuf, false, - linerellen, symtabsection, debug_line, 1, 24); + linerellen, sec_symtab, debug_line, 1, 24); p += strlen(p) + 1; elf_section_header(p - shstrtab, SHT_PROGBITS, 0, framebuf, false, |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 04:51:20
|
Commit-ID: 4a8d10c1a004ace853dd3019814329065dda5050 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=4a8d10c1a004ace853dd3019814329065dda5050 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 20:47:01 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 20:47:01 -0800 Output preprocessor warnings to the listing file Most preprocessor warnings are ERR_PASS1, but we want to see them in the listing file too. If we make it to the code-generation pass, ignore ERR_PASS* for the purpose of emitting warnings to the list file. While we are at it, allow ERR_DEBUG to specify ERR_PASS* too. Signed-off-by: H. Peter Anvin <hp...@li...> --- nasm.c | 58 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/nasm.c b/nasm.c index 140a6e1..52ac324 100644 --- a/nasm.c +++ b/nasm.c @@ -79,6 +79,7 @@ static iflag_t get_cpu(char *cpu_str); static void parse_cmdline(int, char **); static void assemble_file(char *, StrList **); static bool is_suppressed_warning(int severity); +static bool skip_this_pass(int severity); static void nasm_verror_gnu(int severity, const char *fmt, va_list args); static void nasm_verror_vc(int severity, const char *fmt, va_list args); static void nasm_verror_common(int severity, const char *fmt, va_list args); @@ -1872,11 +1873,13 @@ static void nasm_verror_gnu(int severity, const char *fmt, va_list ap) if (!(severity & ERR_NOFILE)) src_get(&lineno, ¤tfile); - if (currentfile) { - fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno); - nasm_free(currentfile); - } else { - fputs("nasm: ", error_file); + if (!skip_this_pass(severity)) { + if (currentfile) { + fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno); + nasm_free(currentfile); + } else { + fputs("nasm: ", error_file); + } } nasm_verror_common(severity, fmt, ap); @@ -1908,11 +1911,13 @@ static void nasm_verror_vc(int severity, const char *fmt, va_list ap) if (!(severity & ERR_NOFILE)) src_get(&lineno, ¤tfile); - if (currentfile) { - fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno); - nasm_free(currentfile); - } else { - fputs("nasm: ", error_file); + if (!skip_this_pass(severity)) { + if (currentfile) { + fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno); + nasm_free(currentfile); + } else { + fputs("nasm: ", error_file); + } } nasm_verror_common(severity, fmt, ap); @@ -1932,11 +1937,6 @@ static bool is_suppressed_warning(int severity) if ((severity & ERR_MASK) != ERR_WARNING) return false; - /* See if it's a pass-one only warning and we're not in pass one. */ - if (((severity & ERR_PASS1) && pass0 != 1) || - ((severity & ERR_PASS2) && pass0 != 2)) - return true; - /* Might be a warning but suppresed explicitly */ if (severity & ERR_WARN_MASK) return !warning_on[WARN_IDX(severity)]; @@ -1944,6 +1944,19 @@ static bool is_suppressed_warning(int severity) return false; } +static bool skip_this_pass(int severity) +{ + /* See if it's a pass-one only warning and we're not in pass one. */ + if ((severity & ERR_MASK) > ERR_WARNING) + return false; + + if (((severity & ERR_PASS1) && pass0 != 1) || + ((severity & ERR_PASS2) && pass0 != 2)) + return true; + + return false; +} + /** * common error reporting * This is the common back end of the error reporting schemes currently @@ -1982,9 +1995,15 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) vsnprintf(msg, sizeof msg, fmt, args); - fprintf(error_file, "%s%s\n", pfx, msg); + if (!skip_this_pass(severity)) + fprintf(error_file, "%s%s\n", pfx, msg); - nasmlist->error(severity, pfx, msg); + /* + * Don't suppress this with skip_this_pass(), or we don't get + * preprocessor warnings in the list file + */ + if ((severity & ERR_MASK) >= ERR_WARNING) + nasmlist->error(severity, pfx, msg); if (severity & ERR_USAGE) want_usage = true; @@ -2014,6 +2033,11 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) case ERR_PANIC: fflush(NULL); /* abort(); */ /* halt, catch fire, and dump core */ + if (ofile) { + fclose(ofile); + remove(outname); + ofile = NULL; + } exit(3); break; } |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 04:36:16
|
Commit-ID: 11b8817e8a481f7f89160c4ac88bf380a8770fcf Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=11b8817e8a481f7f89160c4ac88bf380a8770fcf Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 20:33:02 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 20:33:02 -0800 listing: remove unused variable The previous commit contained an unused variable, remove it. Signed-off-by: H. Peter Anvin <hp...@li...> --- listing.c | 1 - 1 file changed, 1 deletion(-) diff --git a/listing.c b/listing.c index 4fcf91f..8da58eb 100644 --- a/listing.c +++ b/listing.c @@ -73,7 +73,6 @@ static char listdata[2 * LIST_INDENT]; /* we need less than that actually */ static int32_t listoffset; static int32_t listlineno; -static const char *listfn; static int32_t listp; |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 04:33:50
|
Commit-ID: 130736c0cfcad28ee16cec6c14bb22999d982e5a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=130736c0cfcad28ee16cec6c14bb22999d982e5a Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 20:27:41 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 20:27:41 -0800 Get rid of a bunch of unnecessary indirections We pass around a whole bunch of function pointers in arguments, which then just get stashed in static variables. Clean this mess up and in particular handle the error management in the preprocessor using nasm_set_verror() which already exists. Signed-off-by: H. Peter Anvin <hp...@li...> --- assemble.c | 185 ++++++++++++------------ assemble.h | 5 +- eval.c | 78 +++++----- eval.h | 3 +- float.c | 38 +++-- float.h | 3 +- listing.c | 20 ++- listing.h | 4 +- nasm.c | 35 ++--- nasm.h | 8 +- nasmlib.c | 7 +- nasmlib.h | 26 ++-- output/outaout.c | 5 +- output/outbin.c | 4 +- output/outelf32.c | 5 +- output/outelf64.c | 5 +- output/outelfx32.c | 5 +- output/outform.h | 1 - output/outobj.c | 2 +- parser.c | 15 +- preproc-nop.c | 9 +- preproc.c | 409 ++++++++++++++++++++++++++--------------------------- 22 files changed, 421 insertions(+), 451 deletions(-) diff --git a/assemble.c b/assemble.c index ed8b9f8..a26f2bf 100644 --- a/assemble.c +++ b/assemble.c @@ -227,9 +227,6 @@ typedef struct { (((mod) << 6) | (((reg) & 7) << 3) | ((rm) & 7)) static iflag_t cpu; /* cpu level received from nasm.c */ -static efunc errfunc; -static struct ofmt *outfmt; -static ListGen *list; static int64_t calcsize(int32_t, int64_t, int, insn *, const struct itemplate *); @@ -257,8 +254,8 @@ static int has_prefix(insn * ins, enum prefix_pos pos, int prefix) static void assert_no_prefix(insn * ins, enum prefix_pos pos) { if (ins->prefixes[pos]) - errfunc(ERR_NONFATAL, "invalid %s prefix", - prefix_name(ins->prefixes[pos])); + nasm_error(ERR_NONFATAL, "invalid %s prefix", + prefix_name(ins->prefixes[pos])); } static const char *size_name(int size) @@ -287,7 +284,7 @@ static const char *size_name(int size) static void warn_overflow(int pass, int size) { - errfunc(ERR_WARNING | pass | ERR_WARN_NOV, + nasm_error(ERR_WARNING | pass | ERR_WARN_NOV, "%s data exceeds bounds", size_name(size)); } @@ -340,7 +337,7 @@ static void out(int64_t offset, int32_t segto, const void *data, static char *lnfname = NULL; uint8_t p[8]; int asize = addrsize(type, size); /* Address size in bytes */ - const int amax = outfmt->maxbits >> 3; /* Maximum address size in bytes */ + const int amax = ofmt->maxbits >> 3; /* Maximum address size in bytes */ if (type == OUT_ADDRESS && segment == NO_SEG && wrt == NO_SEG) { /* @@ -350,7 +347,7 @@ static void out(int64_t offset, int32_t segto, const void *data, uint8_t *q = p; if (asize > 8) { - errfunc(ERR_PANIC, "OUT_ADDRESS with size > 8"); + nasm_error(ERR_PANIC, "OUT_ADDRESS with size > 8"); return; } @@ -361,7 +358,7 @@ static void out(int64_t offset, int32_t segto, const void *data, asize = 0; /* No longer an address */ } - list->output(offset, data, type, size); + nasmlist->output(offset, data, type, size); /* * this call to src_get determines when we call the @@ -373,19 +370,19 @@ static void out(int64_t offset, int32_t segto, const void *data, */ if (src_get(&lineno, &lnfname)) - outfmt->current_dfmt->linenum(lnfname, lineno, segto); + ofmt->current_dfmt->linenum(lnfname, lineno, segto); if (asize && asize > amax) { if (type != OUT_ADDRESS || (int)size < 0) { - errfunc(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "%d-bit signed relocation unsupported by output format %s\n", - asize << 3, outfmt->shortname); + asize << 3, ofmt->shortname); size = asize; } else { - errfunc(ERR_WARNING | ERR_WARN_ZEXTRELOC, + nasm_error(ERR_WARNING | ERR_WARN_ZEXTRELOC, "%d-bit unsigned relocation zero-extended from %d bits\n", - asize << 3, outfmt->maxbits); - outfmt->output(segto, data, type, amax, segment, wrt); + asize << 3, ofmt->maxbits); + ofmt->output(segto, data, type, amax, segment, wrt); size = asize - amax; } data = zero_buffer; @@ -393,7 +390,7 @@ static void out(int64_t offset, int32_t segto, const void *data, segment = wrt = NO_SEG; } - outfmt->output(segto, data, type, size, segment, wrt); + ofmt->output(segto, data, type, size, segment, wrt); } static void out_imm8(int64_t offset, int32_t segment, @@ -438,7 +435,7 @@ static bool jmp_match(int32_t segment, int64_t offset, int bits, if (is_byte && c == 0371 && ins->prefixes[PPS_REP] == P_BND) { /* jmp short (opcode eb) cannot be used with bnd prefix. */ ins->prefixes[PPS_REP] = P_none; - errfunc(ERR_WARNING | ERR_WARN_BND | ERR_PASS2 , + nasm_error(ERR_WARNING | ERR_WARN_BND | ERR_PASS2 , "jmp short does not init bnd regs - bnd prefix dropped."); } @@ -446,8 +443,7 @@ static bool jmp_match(int32_t segment, int64_t offset, int bits, } int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, - insn * instruction, struct ofmt *output, efunc error, - ListGen * listgen) + insn * instruction) { const struct itemplate *temp; int j; @@ -457,10 +453,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, int64_t start = offset; int64_t wsize; /* size for DB etc. */ - errfunc = error; /* to pass to other functions */ cpu = cp; - outfmt = output; /* likewise */ - list = listgen; /* and again */ wsize = idata_bytes(instruction->opcode); if (wsize == -1) @@ -470,14 +463,13 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, extop *e; int32_t t = instruction->times; if (t < 0) - errfunc(ERR_PANIC, - "instruction->times < 0 (%ld) in assemble()", t); + nasm_panic(0, "instruction->times < 0 (%"PRId32") in assemble()", t); while (t--) { /* repeat TIMES times */ list_for_each(e, instruction->eops) { if (e->type == EOT_DB_NUMBER) { if (wsize > 8) { - errfunc(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "integer supplied to a DT, DO or DY" " instruction"); } else { @@ -503,15 +495,15 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, } if (t > 0 && t == instruction->times - 1) { /* - * Dummy call to list->output to give the offset to the + * Dummy call to nasmlist->output to give the offset to the * listing module. */ - list->output(offset, NULL, OUT_RAWDATA, 0); - list->uplevel(LIST_TIMES); + nasmlist->output(offset, NULL, OUT_RAWDATA, 0); + nasmlist->uplevel(LIST_TIMES); } } if (instruction->times > 1) - list->downlevel(LIST_TIMES); + nasmlist->downlevel(LIST_TIMES); return offset - start; } @@ -521,10 +513,10 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, fp = fopen(fname, "rb"); if (!fp) { - error(ERR_NONFATAL, "`incbin': unable to open file `%s'", + nasm_error(ERR_NONFATAL, "`incbin': unable to open file `%s'", fname); } else if (fseek(fp, 0L, SEEK_END) < 0) { - error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'", + nasm_error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'", fname); fclose(fp); } else { @@ -542,11 +534,11 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, len = (size_t)instruction->eops->next->next->offset; } /* - * Dummy call to list->output to give the offset to the + * Dummy call to nasmlist->output to give the offset to the * listing module. */ - list->output(offset, NULL, OUT_RAWDATA, 0); - list->uplevel(LIST_INCBIN); + nasmlist->output(offset, NULL, OUT_RAWDATA, 0); + nasmlist->uplevel(LIST_INCBIN); while (t--) { size_t l; @@ -561,7 +553,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, * actually changes while we are reading * it. */ - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "`incbin': unexpected EOF while" " reading file `%s'", fname); t = 0; /* Try to exit cleanly */ @@ -572,15 +564,15 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, l -= m; } } - list->downlevel(LIST_INCBIN); + nasmlist->downlevel(LIST_INCBIN); if (instruction->times > 1) { /* - * Dummy call to list->output to give the offset to the + * Dummy call to nasmlist->output to give the offset to the * listing module. */ - list->output(offset, NULL, OUT_RAWDATA, 0); - list->uplevel(LIST_TIMES); - list->downlevel(LIST_TIMES); + nasmlist->output(offset, NULL, OUT_RAWDATA, 0); + nasmlist->uplevel(LIST_TIMES); + nasmlist->downlevel(LIST_TIMES); } fclose(fp); return instruction->times * len; @@ -598,7 +590,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, int64_t insn_size = calcsize(segment, offset, bits, instruction, temp); itimes = instruction->times; if (insn_size < 0) /* shouldn't be, on pass two */ - error(ERR_PANIC, "errors made it through from pass one"); + nasm_error(ERR_PANIC, "errors made it through from pass one"); else while (itimes--) { for (j = 0; j < MAXPREFIX; j++) { @@ -624,21 +616,21 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, break; case R_CS: if (bits == 64) { - error(ERR_WARNING | ERR_PASS2, + nasm_error(ERR_WARNING | ERR_PASS2, "cs segment base generated, but will be ignored in 64-bit mode"); } c = 0x2E; break; case R_DS: if (bits == 64) { - error(ERR_WARNING | ERR_PASS2, + nasm_error(ERR_WARNING | ERR_PASS2, "ds segment base generated, but will be ignored in 64-bit mode"); } c = 0x3E; break; case R_ES: if (bits == 64) { - error(ERR_WARNING | ERR_PASS2, + nasm_error(ERR_WARNING | ERR_PASS2, "es segment base generated, but will be ignored in 64-bit mode"); } c = 0x26; @@ -651,19 +643,19 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, break; case R_SS: if (bits == 64) { - error(ERR_WARNING | ERR_PASS2, + nasm_error(ERR_WARNING | ERR_PASS2, "ss segment base generated, but will be ignored in 64-bit mode"); } c = 0x36; break; case R_SEGR6: case R_SEGR7: - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "segr6 and segr7 cannot be used as prefixes"); break; case P_A16: if (bits == 64) { - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "16-bit addressing is not supported " "in 64-bit mode"); } else if (bits != 16) @@ -675,7 +667,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, break; case P_A64: if (bits != 64) { - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "64-bit addressing is only supported " "in 64-bit mode"); } @@ -704,7 +696,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, case P_none: break; default: - error(ERR_PANIC, "invalid instruction prefix"); + nasm_error(ERR_PANIC, "invalid instruction prefix"); } if (c != 0) { out(offset, segment, &c, OUT_RAWDATA, 1, @@ -718,49 +710,49 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, offset += insn_size; if (itimes > 0 && itimes == instruction->times - 1) { /* - * Dummy call to list->output to give the offset to the + * Dummy call to nasmlist->output to give the offset to the * listing module. */ - list->output(offset, NULL, OUT_RAWDATA, 0); - list->uplevel(LIST_TIMES); + nasmlist->output(offset, NULL, OUT_RAWDATA, 0); + nasmlist->uplevel(LIST_TIMES); } } if (instruction->times > 1) - list->downlevel(LIST_TIMES); + nasmlist->downlevel(LIST_TIMES); return offset - start; } else { /* No match */ switch (m) { case MERR_OPSIZEMISSING: - error(ERR_NONFATAL, "operation size not specified"); + nasm_error(ERR_NONFATAL, "operation size not specified"); break; case MERR_OPSIZEMISMATCH: - error(ERR_NONFATAL, "mismatch in operand sizes"); + nasm_error(ERR_NONFATAL, "mismatch in operand sizes"); break; case MERR_BRNUMMISMATCH: - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "mismatch in the number of broadcasting elements"); break; case MERR_BADCPU: - error(ERR_NONFATAL, "no instruction for this cpu level"); + nasm_error(ERR_NONFATAL, "no instruction for this cpu level"); break; case MERR_BADMODE: - error(ERR_NONFATAL, "instruction not supported in %d-bit mode", + nasm_error(ERR_NONFATAL, "instruction not supported in %d-bit mode", bits); break; case MERR_ENCMISMATCH: - error(ERR_NONFATAL, "specific encoding scheme not available"); + nasm_error(ERR_NONFATAL, "specific encoding scheme not available"); break; case MERR_BADBND: - error(ERR_NONFATAL, "bnd prefix is not allowed"); + nasm_error(ERR_NONFATAL, "bnd prefix is not allowed"); break; case MERR_BADREPNE: - error(ERR_NONFATAL, "%s prefix is not allowed", + nasm_error(ERR_NONFATAL, "%s prefix is not allowed", (has_prefix(instruction, PPS_REP, P_REPNE) ? "repne" : "repnz")); break; default: - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "invalid combination of opcode and operands"); break; } @@ -769,12 +761,11 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, } int64_t insn_size(int32_t segment, int64_t offset, int bits, iflag_t cp, - insn * instruction, efunc error) + insn * instruction) { const struct itemplate *temp; enum match_result m; - errfunc = error; /* to pass to other functions */ cpu = cp; if (instruction->opcode == I_none) @@ -817,10 +808,10 @@ int64_t insn_size(int32_t segment, int64_t offset, int bits, iflag_t cp, fp = fopen(fname, "rb"); if (!fp) - error(ERR_NONFATAL, "`incbin': unable to open file `%s'", + nasm_error(ERR_NONFATAL, "`incbin': unable to open file `%s'", fname); else if (fseek(fp, 0L, SEEK_END) < 0) - error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'", + nasm_error(ERR_NONFATAL, "`incbin': unable to seek on file `%s'", fname); else { len = ftell(fp); @@ -912,14 +903,14 @@ static void bad_hle_warn(const insn * ins, uint8_t hleok) case w_lock: if (ins->prefixes[PPS_LOCK] != P_LOCK) { - errfunc(ERR_WARNING | ERR_WARN_HLE | ERR_PASS2, + nasm_error(ERR_WARNING | ERR_WARN_HLE | ERR_PASS2, "%s with this instruction requires lock", prefix_name(rep_pfx)); } break; case w_inval: - errfunc(ERR_WARNING | ERR_WARN_HLE | ERR_PASS2, + nasm_error(ERR_WARNING | ERR_WARN_HLE | ERR_PASS2, "%s invalid with this instruction", prefix_name(rep_pfx)); break; @@ -1117,7 +1108,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, if (pfx == P_O16) break; if (pfx != P_none) - errfunc(ERR_WARNING | ERR_PASS2, "invalid operand size prefix"); + nasm_error(ERR_WARNING | ERR_PASS2, "invalid operand size prefix"); else ins->prefixes[PPS_OSIZE] = P_O16; break; @@ -1129,7 +1120,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, if (pfx == P_O32) break; if (pfx != P_none) - errfunc(ERR_WARNING | ERR_PASS2, "invalid operand size prefix"); + nasm_error(ERR_WARNING | ERR_PASS2, "invalid operand size prefix"); else ins->prefixes[PPS_OSIZE] = P_O32; break; @@ -1184,7 +1175,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, case 0340: if (ins->oprs[0].segment != NO_SEG) - errfunc(ERR_NONFATAL, "attempt to reserve non-constant" + nasm_error(ERR_NONFATAL, "attempt to reserve non-constant" " quantity of BSS space"); else length += ins->oprs[0].offset; @@ -1299,7 +1290,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, if (process_ea(opy, &ea_data, bits, rfield, rflags, ins) != eat) { - errfunc(ERR_NONFATAL, "invalid effective address"); + nasm_error(ERR_NONFATAL, "invalid effective address"); return -1; } else { ins->rex |= ea_data.rex; @@ -1309,7 +1300,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, break; default: - errfunc(ERR_PANIC, "internal instruction table corrupt" + nasm_error(ERR_PANIC, "internal instruction table corrupt" ": instruction code \\%o (0x%02X) given", c, c); break; } @@ -1319,7 +1310,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, if (ins->rex & REX_NH) { if (ins->rex & REX_H) { - errfunc(ERR_NONFATAL, "instruction cannot use high registers"); + nasm_error(ERR_NONFATAL, "instruction cannot use high registers"); return -1; } ins->rex &= ~REX_P; /* Don't force REX prefix due to high reg */ @@ -1343,7 +1334,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, int bad32 = REX_R|REX_W|REX_X|REX_B; if (ins->rex & REX_H) { - errfunc(ERR_NONFATAL, "cannot use high register in AVX instruction"); + nasm_error(ERR_NONFATAL, "cannot use high register in AVX instruction"); return -1; } switch (ins->vex_wlp & 060) { @@ -1361,11 +1352,11 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, } if (bits != 64 && ((ins->rex & bad32) || ins->vexreg > 7)) { - errfunc(ERR_NONFATAL, "invalid operands in non-64-bit mode"); + nasm_error(ERR_NONFATAL, "invalid operands in non-64-bit mode"); return -1; } else if (!(ins->rex & REX_EV) && ((ins->vexreg > 15) || (ins->evex_p[0] & 0xf0))) { - errfunc(ERR_NONFATAL, "invalid high-16 register in non-AVX-512"); + nasm_error(ERR_NONFATAL, "invalid high-16 register in non-AVX-512"); return -1; } if (ins->rex & REX_EV) @@ -1377,7 +1368,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, length += 2; } else if (ins->rex & REX_MASK) { if (ins->rex & REX_H) { - errfunc(ERR_NONFATAL, "cannot use high register in rex instruction"); + nasm_error(ERR_NONFATAL, "cannot use high register in rex instruction"); return -1; } else if (bits == 64) { length++; @@ -1389,14 +1380,14 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, lockcheck = false; /* Already errored, no need for warning */ length++; } else { - errfunc(ERR_NONFATAL, "invalid operands in non-64-bit mode"); + nasm_error(ERR_NONFATAL, "invalid operands in non-64-bit mode"); return -1; } } if (has_prefix(ins, PPS_LOCK, P_LOCK) && lockcheck && (!itemp_has(temp,IF_LOCK) || !is_class(MEMORY, ins->oprs[0].type))) { - errfunc(ERR_WARNING | ERR_WARN_LOCK | ERR_PASS2 , + nasm_error(ERR_WARNING | ERR_WARN_LOCK | ERR_PASS2 , "instruction is not lockable"); } @@ -1482,7 +1473,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, case4(020): if (opx->offset < -256 || opx->offset > 255) { - errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, + nasm_error(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, "byte value exceeds bounds"); } out_imm8(offset, segment, opx, -1); @@ -1491,7 +1482,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, case4(024): if (opx->offset < 0 || opx->offset > 255) - errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, + nasm_error(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, "unsigned byte value exceeds bounds"); out_imm8(offset, segment, opx, 1); offset += 1; @@ -1543,7 +1534,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, } else { data = opx->offset - insn_end; if (data > 127 || data < -128) - errfunc(ERR_NONFATAL, "short jump is out of range"); + nasm_error(ERR_NONFATAL, "short jump is out of range"); out(offset, segment, &data, OUT_ADDRESS, 1, NO_SEG, NO_SEG); } @@ -1605,11 +1596,11 @@ static void gencode(int32_t segment, int64_t offset, int bits, case4(074): if (opx->segment == NO_SEG) - errfunc(ERR_NONFATAL, "value referenced by FAR is not" + nasm_error(ERR_NONFATAL, "value referenced by FAR is not" " relocatable"); data = 0; out(offset, segment, &data, OUT_ADDRESS, 2, - outfmt->segbase(1 + opx->segment), + ofmt->segbase(1 + opx->segment), opx->wrt); offset += 2; break; @@ -1620,12 +1611,12 @@ static void gencode(int32_t segment, int64_t offset, int bits, bytes[0] = nasm_regvals[opx->basereg] << 4; opx = &ins->oprs[c & 7]; if (opx->segment != NO_SEG || opx->wrt != NO_SEG) { - errfunc(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "non-absolute expression not permitted as argument %d", c & 7); } else { if (opx->offset & ~15) { - errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, + nasm_error(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, "four-bit argument exceeds bounds"); } bytes[0] |= opx->offset & 15; @@ -1653,7 +1644,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, data = opx->offset; if (opx->wrt == NO_SEG && opx->segment == NO_SEG && (int32_t)data != (int64_t)data) { - errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, + nasm_error(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, "signed dword immediate exceeds bounds"); } out(offset, segment, &data, OUT_ADDRESS, -4, @@ -1727,7 +1718,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, /* If this wasn't explicitly byte-sized, warn as though we * had fallen through to the imm16/32/64 case. */ - errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, + nasm_error(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV, "%s value exceeds bounds", (opx->type & BITS8) ? "signed byte" : s == 16 ? "word" : @@ -1830,7 +1821,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, case 0340: if (ins->oprs[0].segment != NO_SEG) - errfunc(ERR_PANIC, "non-constant BSS size in pass two"); + nasm_error(ERR_PANIC, "non-constant BSS size in pass two"); else { int64_t size = ins->oprs[0].offset; if (size > 0) @@ -1916,7 +1907,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, if (process_ea(opy, &ea_data, bits, rfield, rflags, ins) != eat) - errfunc(ERR_NONFATAL, "invalid effective address"); + nasm_error(ERR_NONFATAL, "invalid effective address"); p = bytes; *p++ = ea_data.modrm; @@ -1975,7 +1966,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, break; default: - errfunc(ERR_PANIC, "internal instruction table corrupt" + nasm_error(ERR_PANIC, "internal instruction table corrupt" ": instruction code \\%o (0x%02X) given", c, c); break; } @@ -1985,14 +1976,14 @@ static void gencode(int32_t segment, int64_t offset, int bits, static opflags_t regflag(const operand * o) { if (!is_register(o->basereg)) - errfunc(ERR_PANIC, "invalid operand passed to regflag()"); + nasm_error(ERR_PANIC, "invalid operand passed to regflag()"); return nasm_reg_flags[o->basereg]; } static int32_t regval(const operand * o) { if (!is_register(o->basereg)) - errfunc(ERR_PANIC, "invalid operand passed to regval()"); + nasm_error(ERR_PANIC, "invalid operand passed to regval()"); return nasm_regvals[o->basereg]; } @@ -2002,7 +1993,7 @@ static int op_rexflags(const operand * o, int mask) int val; if (!is_register(o->basereg)) - errfunc(ERR_PANIC, "invalid operand passed to op_rexflags()"); + nasm_error(ERR_PANIC, "invalid operand passed to op_rexflags()"); flags = nasm_reg_flags[o->basereg]; val = nasm_regvals[o->basereg]; @@ -2159,7 +2150,7 @@ static uint8_t get_broadcast_num(opflags_t opflags, opflags_t brsize) * this cannot be a simple arithmetic calculation. */ if (brsize > BITS64) - errfunc(ERR_FATAL, + nasm_error(ERR_FATAL, "size of broadcasting element is greater than 64 bits"); switch (opsize) { @@ -2966,7 +2957,7 @@ static void add_asp(insn *ins, int addrbits) ins->addr_size = (addrbits == 32) ? 16 : 32; } else { /* Impossible... */ - errfunc(ERR_NONFATAL, "impossible combination of address sizes"); + nasm_error(ERR_NONFATAL, "impossible combination of address sizes"); ins->addr_size = addrbits; /* Error recovery */ } diff --git a/assemble.h b/assemble.h index 381e3ab..f85037a 100644 --- a/assemble.h +++ b/assemble.h @@ -41,8 +41,7 @@ #include "iflag.h" int64_t insn_size(int32_t segment, int64_t offset, int bits, iflag_t cp, - insn * instruction, efunc error); + insn * instruction); int64_t assemble(int32_t segment, int64_t offset, int bits, iflag_t cp, - insn * instruction, struct ofmt *output, efunc error, - ListGen * listgen); + insn * instruction); #endif diff --git a/eval.c b/eval.c index 403a793..a8e463f 100644 --- a/eval.c +++ b/eval.c @@ -54,7 +54,6 @@ #define TEMPEXPR_DELTA 8 static scanner scan; /* Address of scanner routine */ -static efunc error; /* Address of error reporting routine */ static lfunc labelfunc; /* Address of label routine */ static struct ofmt *outfmt; /* Structure of addresses of output routines */ @@ -227,18 +226,18 @@ static expr *segment_part(expr * e) return unknown_expr(); if (!is_reloc(e)) { - error(ERR_NONFATAL, "cannot apply SEG to a non-relocatable value"); + nasm_error(ERR_NONFATAL, "cannot apply SEG to a non-relocatable value"); return NULL; } seg = reloc_seg(e); if (seg == NO_SEG) { - error(ERR_NONFATAL, "cannot apply SEG to a non-relocatable value"); + nasm_error(ERR_NONFATAL, "cannot apply SEG to a non-relocatable value"); return NULL; } else if (seg & SEG_ABS) { return scalarvect(seg & ~SEG_ABS); } else if (seg & 1) { - error(ERR_NONFATAL, "SEG applied to something which" + nasm_error(ERR_NONFATAL, "SEG applied to something which" " is already a segment base"); return NULL; } else { @@ -306,7 +305,7 @@ static expr *rexp0(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "`|' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`|' operator may only be applied to" " scalar values"); } @@ -333,7 +332,7 @@ static expr *rexp1(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "`^' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`^' operator may only be applied to" " scalar values"); } @@ -359,7 +358,7 @@ static expr *rexp2(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "`&' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`&' operator may only be applied to" " scalar values"); } if (is_just_unknown(e) || is_just_unknown(f)) @@ -403,7 +402,7 @@ static expr *rexp3(int critical) if (is_unknown(e)) v = -1; /* means unknown */ else if (!is_really_simple(e)) { - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "`%s': operands differ by a non-scalar", (j == TOKEN_LE ? "<=" : j == TOKEN_LT ? "<" : j == TOKEN_GE ? ">=" : ">")); @@ -443,7 +442,7 @@ static expr *expr0(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "`|' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`|' operator may only be applied to" " scalar values"); } if (is_just_unknown(e) || is_just_unknown(f)) @@ -469,7 +468,7 @@ static expr *expr1(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "`^' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`^' operator may only be applied to" " scalar values"); } if (is_just_unknown(e) || is_just_unknown(f)) @@ -495,7 +494,7 @@ static expr *expr2(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "`&' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`&' operator may only be applied to" " scalar values"); } if (is_just_unknown(e) || is_just_unknown(f)) @@ -522,7 +521,7 @@ static expr *expr3(int critical) return NULL; if (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f))) { - error(ERR_NONFATAL, "shift operator may only be applied to" + nasm_error(ERR_NONFATAL, "shift operator may only be applied to" " scalar values"); } else if (is_just_unknown(e) || is_just_unknown(f)) { e = unknown_expr(); @@ -581,12 +580,12 @@ static expr *expr5(int critical) return NULL; if (j != '*' && (!(is_simple(e) || is_just_unknown(e)) || !(is_simple(f) || is_just_unknown(f)))) { - error(ERR_NONFATAL, "division operator may only be applied to" + nasm_error(ERR_NONFATAL, "division operator may only be applied to" " scalar values"); return NULL; } if (j != '*' && !is_unknown(f) && reloc_value(f) == 0) { - error(ERR_NONFATAL, "division by zero"); + nasm_error(ERR_NONFATAL, "division by zero"); return NULL; } switch (j) { @@ -598,7 +597,7 @@ static expr *expr5(int critical) else if (is_just_unknown(e) && is_just_unknown(f)) e = unknown_expr(); else { - error(ERR_NONFATAL, "unable to multiply two " + nasm_error(ERR_NONFATAL, "unable to multiply two " "non-scalar objects"); return NULL; } @@ -657,7 +656,7 @@ static expr *eval_floatize(enum floatize type) i = scan(scpriv, tokval); if (i != '(') { - error(ERR_NONFATAL, "expecting `('"); + nasm_error(ERR_NONFATAL, "expecting `('"); return NULL; } i = scan(scpriv, tokval); @@ -666,15 +665,14 @@ static expr *eval_floatize(enum floatize type) i = scan(scpriv, tokval); } if (i != TOKEN_FLOAT) { - error(ERR_NONFATAL, "expecting floating-point number"); + nasm_error(ERR_NONFATAL, "expecting floating-point number"); return NULL; } - if (!float_const(tokval->t_charptr, sign, result, - formats[type].bytes, error)) + if (!float_const(tokval->t_charptr, sign, result, formats[type].bytes)) return NULL; i = scan(scpriv, tokval); if (i != ')') { - error(ERR_NONFATAL, "expecting `)'"); + nasm_error(ERR_NONFATAL, "expecting `)'"); return NULL; } @@ -706,13 +704,13 @@ static expr *eval_strfunc(enum strfunc type) i = scan(scpriv, tokval); } if (i != TOKEN_STR) { - error(ERR_NONFATAL, "expecting string"); + nasm_error(ERR_NONFATAL, "expecting string"); return NULL; } string_len = string_transform(tokval->t_charptr, tokval->t_inttwo, &string, type); if (string_len == (size_t)-1) { - error(ERR_NONFATAL, "invalid string for transform"); + nasm_error(ERR_NONFATAL, "invalid string for transform"); return NULL; } @@ -720,13 +718,13 @@ static expr *eval_strfunc(enum strfunc type) if (parens) { i = scan(scpriv, tokval); if (i != ')') { - error(ERR_NONFATAL, "expecting `)'"); + nasm_error(ERR_NONFATAL, "expecting `)'"); return NULL; } } if (rn_warn) - error(ERR_WARNING|ERR_PASS1, "character constant too long"); + nasm_error(ERR_WARNING|ERR_PASS1, "character constant too long"); begintemp(); addtotemp(EXPR_SIMPLE, val); @@ -747,7 +745,7 @@ static int64_t eval_ifunc(int64_t val, enum ifunc func) errtype = (func == IFUNC_ILOG2E) ? ERR_NONFATAL : ERR_WARNING; if (!is_power2(uval)) - error(errtype, "ilog2 argument is not a power of two"); + nasm_error(errtype, "ilog2 argument is not a power of two"); /* fall through */ case IFUNC_ILOG2F: rv = ilog2_64(uval); @@ -758,7 +756,7 @@ static int64_t eval_ifunc(int64_t val, enum ifunc func) break; default: - error(ERR_PANIC, "invalid IFUNC token %d", func); + nasm_error(ERR_PANIC, "invalid IFUNC token %d", func); rv = 0; break; } @@ -796,7 +794,7 @@ static expr *expr6(int critical) if (is_just_unknown(e)) return unknown_expr(); else if (!is_simple(e)) { - error(ERR_NONFATAL, "`~' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`~' operator may only be applied to" " scalar values"); return NULL; } @@ -810,7 +808,7 @@ static expr *expr6(int critical) if (is_just_unknown(e)) return unknown_expr(); else if (!is_simple(e)) { - error(ERR_NONFATAL, "`!' operator may only be applied to" + nasm_error(ERR_NONFATAL, "`!' operator may only be applied to" " scalar values"); return NULL; } @@ -826,7 +824,7 @@ static expr *expr6(int critical) if (is_just_unknown(e)) return unknown_expr(); else if (!is_simple(e)) { - error(ERR_NONFATAL, "function may only be applied to" + nasm_error(ERR_NONFATAL, "function may only be applied to" " scalar values"); return NULL; } @@ -842,7 +840,7 @@ static expr *expr6(int critical) if (!e) return NULL; if (is_unknown(e) && critical) { - error(ERR_NONFATAL, "unable to determine segment base"); + nasm_error(ERR_NONFATAL, "unable to determine segment base"); return NULL; } return e; @@ -859,7 +857,7 @@ static expr *expr6(int critical) if (!e) return NULL; if (i != ')') { - error(ERR_NONFATAL, "expecting `)'"); + nasm_error(ERR_NONFATAL, "expecting `)'"); return NULL; } i = scan(scpriv, tokval); @@ -881,7 +879,7 @@ static expr *expr6(int critical) case TOKEN_STR: tmpval = readstrnum(tokval->t_charptr, tokval->t_inttwo, &rn_warn); if (rn_warn) - error(ERR_WARNING|ERR_PASS1, "character constant too long"); + nasm_error(ERR_WARNING|ERR_PASS1, "character constant too long"); addtotemp(EXPR_SIMPLE, tmpval); break; case TOKEN_REG: @@ -899,7 +897,7 @@ static expr *expr6(int critical) * are in preprocess-only mode. */ if (!location->known) { - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "%s not supported in preprocess-only mode", (i == TOKEN_HERE ? "`$'" : i == TOKEN_BASE ? "`$$'" : @@ -919,11 +917,11 @@ static expr *expr6(int critical) if (!labelfunc(tokval->t_charptr, &label_seg, &label_ofs)) { scope = local_scope(tokval->t_charptr); if (critical == 2) { - error(ERR_NONFATAL, "symbol `%s%s' undefined", + nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined", scope,tokval->t_charptr); return NULL; } else if (critical == 1) { - error(ERR_NONFATAL, + nasm_error(ERR_NONFATAL, "symbol `%s%s' not defined before use", scope,tokval->t_charptr); return NULL; @@ -950,7 +948,7 @@ static expr *expr6(int critical) return finishtemp(); default: - error(ERR_NONFATAL, "expression syntax error"); + nasm_error(ERR_NONFATAL, "expression syntax error"); return NULL; } } @@ -964,8 +962,7 @@ void eval_global_info(struct ofmt *output, lfunc lookup_label, } expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, - int *fwref, int critical, efunc report_error, - struct eval_hints *hints) + int *fwref, int critical, struct eval_hints *hints) { expr *e; expr *f = NULL; @@ -983,7 +980,6 @@ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, scan = sc; scpriv = scprivate; tokval = tv; - error = report_error; opflags = fwref; if (tokval->t_type == TOKEN_INVALID) @@ -1013,14 +1009,14 @@ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, int64_t value; begintemp(); if (!is_reloc(f)) { - error(ERR_NONFATAL, "invalid right-hand operand to WRT"); + nasm_error(ERR_NONFATAL, "invalid right-hand operand to WRT"); return NULL; } value = reloc_seg(f); if (value == NO_SEG) value = reloc_value(f) | SEG_ABS; else if (!(value & SEG_ABS) && !(value % 2) && critical) { - error(ERR_NONFATAL, "invalid right-hand operand to WRT"); + nasm_error(ERR_NONFATAL, "invalid right-hand operand to WRT"); return NULL; } addtotemp(EXPR_WRT, value); diff --git a/eval.h b/eval.h index 0ea59d1..76ea14b 100644 --- a/eval.h +++ b/eval.h @@ -50,8 +50,7 @@ void eval_global_info(struct ofmt *output, lfunc lookup_label, * The evaluator itself. */ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, - int *fwref, int critical, efunc report_error, - struct eval_hints *hints); + int *fwref, int critical, struct eval_hints *hints); void eval_cleanup(void); diff --git a/float.c b/float.c index 7a4f8cb..adf18c5 100644 --- a/float.c +++ b/float.c @@ -51,7 +51,6 @@ * local variables * ----------------- */ -static efunc error; static bool daz = false; /* denormals as zero */ static enum float_round rc = FLOAT_RC_NEAR; /* rounding control */ @@ -183,7 +182,7 @@ static int32_t read_exponent(const char *string, int32_t max) } else if (*string == '_') { /* do nothing */ } else { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "invalid character in floating-point constant %s: '%c'", "exponent", *string); return INT32_MAX; @@ -220,7 +219,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant, if (!seendot) { seendot = true; } else { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "too many periods in floating-point constant"); return false; } @@ -235,7 +234,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant, *p++ = *string - '0'; } else { if (!warned) { - error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS1, + nasm_error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS1, "floating-point constant significand contains " "more than %i digits", MANT_DIGITS); warned = true; @@ -248,7 +247,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant, } else if (*string == '_') { /* do nothing */ } else { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "invalid character in floating-point constant %s: '%c'", "significand", *string); return false; @@ -534,7 +533,7 @@ static bool ieee_flconvert_bin(const char *string, int bits, if (!seendot) seendot = true; else { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "too many periods in floating-point constant"); return false; } @@ -576,7 +575,7 @@ static bool ieee_flconvert_bin(const char *string, int bits, } else if (c == '_') { /* ignore */ } else { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "floating-point constant: `%c' is invalid character", c); return false; } @@ -674,7 +673,7 @@ static int to_packed_bcd(const char *str, const char *p, int tv = -1; if (fmt != &ieee_80) { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "packed BCD requires an 80-bit format"); return 0; } @@ -684,7 +683,7 @@ static int to_packed_bcd(const char *str, const char *p, if (c >= '0' && c <= '9') { if (tv < 0) { if (n == 9) { - error(ERR_WARNING|ERR_PASS1, + nasm_error(ERR_WARNING|ERR_PASS1, "packed BCD truncated to 18 digits"); } tv = c-'0'; @@ -697,7 +696,7 @@ static int to_packed_bcd(const char *str, const char *p, } else if (c == '_') { /* do nothing */ } else { - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "invalid character `%c' in packed BCD constant", c); return 0; } @@ -734,7 +733,7 @@ static int to_float(const char *str, int s, uint8_t *result, const char *strend; if (!str[0]) { - error(ERR_PANIC, + nasm_error(ERR_PANIC, "internal errror: empty string passed to float_const"); return 0; } @@ -762,7 +761,7 @@ static int to_float(const char *str, int s, uint8_t *result, type = FL_INFINITY; break; default: - error(ERR_NONFATAL|ERR_PASS1, + nasm_error(ERR_NONFATAL|ERR_PASS1, "internal error: unknown FP constant token `%s'\n", str); type = FL_QNAN; break; @@ -810,7 +809,7 @@ static int to_float(const char *str, int s, uint8_t *result, type = FL_NORMAL; } else if (exponent > 0) { if (pass0 == 1) - error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1, + nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1, "overflow in floating-point constant"); type = FL_INFINITY; } else { @@ -845,11 +844,11 @@ static int to_float(const char *str, int s, uint8_t *result, } else { if (daz || is_zero(mant)) { /* Flush denormals to zero */ - error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS1, + nasm_error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS1, "underflow in floating-point constant"); goto zero; } else { - error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS1, + nasm_error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS1, "denormal floating-point constant"); } } @@ -865,7 +864,7 @@ static int to_float(const char *str, int s, uint8_t *result, ieee_shr(mant, 1); exponent++; if (exponent >= (expmax << 1)-1) { - error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1, + nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1, "overflow in floating-point constant"); type = FL_INFINITY; goto overflow; @@ -901,11 +900,8 @@ static int to_float(const char *str, int s, uint8_t *result, return 1; /* success */ } -int float_const(const char *number, int sign, uint8_t *result, - int bytes, efunc err) +int float_const(const char *number, int sign, uint8_t *result, int bytes) { - error = err; - switch (bytes) { case 1: return to_float(number, sign, result, &ieee_8); @@ -920,7 +916,7 @@ int float_const(const char *number, int sign, uint8_t *result, case 16: return to_float(number, sign, result, &ieee_128); default: - error(ERR_PANIC, "strange value %d passed to float_const", bytes); + nasm_error(ERR_PANIC, "strange value %d passed to float_const", bytes); return 0; } } diff --git a/float.h b/float.h index 6f94cc6..a00a043 100644 --- a/float.h +++ b/float.h @@ -48,8 +48,7 @@ enum float_round { FLOAT_RC_UP, }; -int float_const(const char *string, int sign, uint8_t *result, int bytes, - efunc error); +int float_const(const char *string, int sign, uint8_t *result, int bytes); int float_option(const char *option); #endif diff --git a/listing.c b/listing.c index 49f5e15..3b395bc 100644 --- a/listing.c +++ b/listing.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2009 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -126,12 +126,17 @@ static void list_emit(void) } } -static void list_init(char *fname, efunc error) +static void list_init(const char *fname) { + if (!fname) { + listfp = NULL; + return; + } + listfp = fopen(fname, "w"); if (!listfp) { - error(ERR_NONFATAL, "unable to open listing file `%s'", - fname); + nasm_error(ERR_NONFATAL, "unable to open listing file `%s'", + fname); return; } @@ -197,7 +202,7 @@ static void list_output(int32_t offset, const void *data, { char q[20]; - if (!listp || suppress || user_nolist) /* fbk - 9/2/00 */ + if (!listp || suppress || user_nolist) return; switch (type) { @@ -321,7 +326,7 @@ static void list_error(int severity, const char *pfx, const char *msg) } -ListGen nasmlist = { +static const ListGen nasm_list = { list_init, list_cleanup, list_output, @@ -330,3 +335,6 @@ ListGen nasmlist = { list_downlevel, list_error }; + +const ListGen *nasmlist = &nasm_list; + diff --git a/listing.h b/listing.h index da2e849..8e178b0 100644 --- a/listing.h +++ b/listing.h @@ -38,7 +38,7 @@ #ifndef NASM_LISTING_H #define NASM_LISTING_H -extern ListGen nasmlist; -extern int user_nolist; /* fbk - 9/1/00 */ +extern const ListGen *nasmlist; +extern bool user_nolist; #endif diff --git a/nasm.c b/nasm.c index a176f25..140a6e1 100644 --- a/nasm.c +++ b/nasm.c @@ -78,10 +78,10 @@ static int get_bits(char *value); static iflag_t get_cpu(char *cpu_str); static void parse_cmdline(int, char **); static void assemble_file(char *, StrList **); +static bool is_suppressed_warning(int severity); static void nasm_verror_gnu(int severity, const char *fmt, va_list args); static void nasm_verror_vc(int severity, const char *fmt, va_list args); static void nasm_verror_common(int severity, const char *fmt, va_list args); -static bool is_suppressed_warning(int severity); static void usage(void); static int using_debug_info, opt_verbose_info; @@ -172,7 +172,7 @@ static const struct warning { static bool want_usage; static bool terminate_after_phase; -int user_nolist = 0; /* fbk 9/2/00 */ +bool user_nolist = false; static char *quote_for_make(const char *str); @@ -377,7 +377,7 @@ int main(int argc, char **argv) if (depend_missing_ok) preproc->include_path(NULL); /* "assume generated" */ - preproc->reset(inname, 0, &nasmlist, depend_ptr); + preproc->reset(inname, 0, depend_ptr); if (outname[0] == '\0') ofmt->filename(inname, outname); ofile = NULL; @@ -402,8 +402,9 @@ int main(int argc, char **argv) location.known = false; /* pass = 1; */ - preproc->reset(inname, 3, &nasmlist, depend_ptr); - memcpy(warning_on, warning_on_global, (ERR_WARN_MAX+1) * sizeof(bool)); + preproc->reset(inname, 3, depend_ptr); + memcpy(warning_on, warning_on_global, + (ERR_WARN_MAX+1) * sizeof(bool)); while ((line = preproc->getline())) { /* @@ -1203,8 +1204,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: " - "32-bit segment size requires a higher cpu"); + nasm_fatal(0, "command line: 32-bit segment size requires a higher cpu"); pass_max = prev_offset_changed = (INT_MAX >> 1) + 2; /* Almost unlimited */ for (passn = 1; pass0 <= 2; passn++) { @@ -1220,8 +1220,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) globalbits = sb = cmd_sb; /* set 'bits' to command line default */ cpu = cmd_cpu; if (pass0 == 2) { - if (*listname) - nasmlist.init(listname, nasm_error); + nasmlist->init(listname); } in_abs_seg = false; global_offset_changed = 0; /* set by redefine_label */ @@ -1233,8 +1232,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) raa_free(offsets); offsets = raa_init(); } - preproc->reset(fname, pass1, &nasmlist, - pass1 == 2 ? depend_ptr : NULL); + preproc->reset(fname, pass1, pass1 == 2 ? depend_ptr : NULL); memcpy(warning_on, warning_on_global, (ERR_WARN_MAX+1) * sizeof(bool)); globallineno = 0; @@ -1273,7 +1271,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) stdscan_reset(); stdscan_set(value); tokval.t_type = TOKEN_INVALID; - e = evaluate(stdscan, NULL, &tokval, NULL, pass2, nasm_error, NULL); + e = evaluate(stdscan, NULL, &tokval, NULL, pass2, NULL); if (e) { unsigned int align = (unsigned int)e->value; if ((uint64_t)e->value > 0x7fffffff) { @@ -1431,8 +1429,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) stdscan_reset(); stdscan_set(value); tokval.t_type = TOKEN_INVALID; - e = evaluate(stdscan, NULL, &tokval, NULL, pass2, - nasm_error, NULL); + e = evaluate(stdscan, NULL, &tokval, NULL, pass2, NULL); if (e) { if (!is_reloc(e)) nasm_error(pass0 == @@ -1679,7 +1676,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) if (pass1 == 1) { int64_t l = insn_size(location.segment, offs, sb, cpu, - &output_ins, nasm_error); + &output_ins); /* if (using_debug_info) && output_ins.opcode != -1) */ if (using_debug_info) @@ -1758,8 +1755,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) } else { offs += assemble(location.segment, offs, sb, cpu, - &output_ins, ofmt, nasm_error, - &nasmlist); + &output_ins); set_curr_offs(offs); } @@ -1804,7 +1800,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) } preproc->cleanup(0); - nasmlist.cleanup(); + nasmlist->cleanup(); if (!terminate_after_phase && opt_verbose_info) { /* -On and -Ov switches */ fprintf(stdout, "info: assembly required 1+%d+1 passes\n", passn-3); @@ -1988,8 +1984,7 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) fprintf(error_file, "%s%s\n", pfx, msg); - if (*listname) - nasmlist.error(severity, pfx, msg); + nasmlist->error(severity, pfx, msg); if (severity & ERR_USAGE) want_usage = true; diff --git a/nasm.h b/nasm.h index f0cc346..d0fb8bd 100644 --- a/nasm.h +++ b/nasm.h @@ -136,7 +136,7 @@ typedef struct { * called. The `char *' parameter is the file name to write the * listing to. */ - void (*init)(char *fname, efunc error); + void (*init)(const char *fname); /* * Called to clear stuff up and close the listing file. @@ -190,6 +190,8 @@ typedef struct { void (*error)(int severity, const char *pfx, const char *msg); } ListGen; +extern const ListGen *nasmlist; + /* * Token types returned by the scanner, in addition to ordinary * ASCII character values, and zero for end-of-string. @@ -351,7 +353,7 @@ struct eval_hints { #define CRITICAL 0x100 typedef expr *(*evalfunc)(scanner sc, void *scprivate, struct tokenval *tv, int *fwref, int critical, - ... [truncated message content] |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 04:33:40
|
Commit-ID: 0e8fcf1b6cbe4a9997270dac7e5e2c9c13e82cb9 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=0e8fcf1b6cbe4a9997270dac7e5e2c9c13e82cb9 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 15:51:08 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 15:51:08 -0800 outelf*: remove type prefix from debugging functions The debugging functions currently have unique prefix, which is good for debuggability but hides real code differences. Convert them to have the same name across files. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outelf32.c | 90 +++++++++++++++++++++++++++--------------------------- output/outelf64.c | 90 +++++++++++++++++++++++++++--------------------------- output/outelfx32.c | 90 +++++++++++++++++++++++++++--------------------------- 3 files changed, 135 insertions(+), 135 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 8553604..03325c0 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -157,24 +157,24 @@ static struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ -static void debug32_typevalue(int32_t); -static void debug32_deflabel(char *, int32_t, int64_t, int, char *); -static void debug32_directive(const char *, const char *); +static void debug_typevalue(int32_t); +static void debug_deflabel(char *, int32_t, int64_t, int, char *); +static void debug_directive(const char *, const char *); /* stabs debugging routines */ -static void stabs32_linenum(const char *filename, int32_t linenumber, int32_t); -static void stabs32_output(int, void *); -static void stabs32_generate(void); -static void stabs32_cleanup(void); +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t); +static void stabs_output(int, void *); +static void stabs_generate(void); +static void stabs_cleanup(void); /* dwarf debugging routines */ -static void dwarf32_init(void); -static void dwarf32_linenum(const char *filename, int32_t linenumber, int32_t); -static void dwarf32_output(int, void *); -static void dwarf32_generate(void); -static void dwarf32_cleanup(void); -static void dwarf32_findfile(const char *); -static void dwarf32_findsect(const int); +static void dwarf_init(void); +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t); +static void dwarf_output(int, void *); +static void dwarf_generate(void); +static void dwarf_cleanup(void); +static void dwarf_findfile(const char *); +static void dwarf_findsect(const int); /* * Special NASM section numbers which are used to define ELF special @@ -1019,7 +1019,7 @@ static void elf_write(void) which are the .stab , .stabstr and .rel.stab sections respectively */ /* this function call creates the stab sections in memory */ - stabs32_generate(); + stabs_generate(); if (stabbuf && stabstrbuf && stabrelbuf) { elf_section_header(p - shstrtab, SHT_PROGBITS, 0, stabbuf, false, @@ -1040,7 +1040,7 @@ static void elf_write(void) /* this function call creates the dwarf sections in memory */ if (dwarf_fsect) - dwarf32_generate(); + dwarf_generate(); elf_section_header(p - shstrtab, SHT_PROGBITS, 0, arangesbuf, false, arangeslen, 0, 0, 1, 0); @@ -1339,24 +1339,24 @@ static int elf_set_info(enum geninfo type, char **val) static struct dfmt df_dwarf = { "ELF32 (i386) dwarf debug format for Linux/Unix", "dwarf", - dwarf32_init, - dwarf32_linenum, - debug32_deflabel, - debug32_directive, - debug32_typevalue, - dwarf32_output, - dwarf32_cleanup + dwarf_init, + dwarf_linenum, + debug_deflabel, + debug_directive, + debug_typevalue, + dwarf_output, + dwarf_cleanup }; static struct dfmt df_stabs = { "ELF32 (i386) stabs debug format for Linux/Unix", "stabs", null_debug_init, - stabs32_linenum, - debug32_deflabel, - debug32_directive, - debug32_typevalue, - stabs32_output, - stabs32_cleanup + stabs_linenum, + debug_deflabel, + debug_directive, + debug_typevalue, + stabs_output, + stabs_cleanup }; struct dfmt *elf32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; @@ -1383,7 +1383,7 @@ struct ofmt of_elf32 = { /* again, the stabs debugging stuff (code) */ -static void debug32_deflabel(char *name, int32_t segment, int64_t offset, int is_global, +static void debug_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { (void)name; @@ -1393,13 +1393,13 @@ static void debug32_deflabel(char *name, int32_t segment, int64_t offset, int is (void)special; } -static void debug32_directive(const char *directive, const char *params) +static void debug_directive(const char *directive, const char *params) { (void)directive; (void)params; } -static void debug32_typevalue(int32_t type) +static void debug_typevalue(int32_t type) { int32_t stype, ssize; switch (TYM_TYPE(type)) { @@ -1468,7 +1468,7 @@ static void debug32_typevalue(int32_t type) /* stabs debugging routines */ -static void stabs32_linenum(const char *filename, int32_t linenumber, +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; @@ -1493,7 +1493,7 @@ static void stabs32_linenum(const char *filename, int32_t linenumber, currentline = linenumber; } -static void stabs32_output(int type, void *param) +static void stabs_output(int type, void *param) { struct symlininfo *s; struct linelist *el; @@ -1524,7 +1524,7 @@ static void stabs32_output(int type, void *param) /* for creating the .stab , .stabstr and .rel.stab sections in memory */ -static void stabs32_generate(void) +static void stabs_generate(void) { int i, numfiles, strsize, numstabs = 0, currfile, mainfileindex; uint8_t *sbuf, *ssbuf, *rbuf, *sptr, *rptr; @@ -1660,7 +1660,7 @@ static void stabs32_generate(void) stabstrbuf = ssbuf; } -static void stabs32_cleanup(void) +static void stabs_cleanup(void) { struct linelist *ptr, *del; if (!stabslines) @@ -1680,22 +1680,22 @@ static void stabs32_cleanup(void) /* dwarf routines */ -static void dwarf32_init(void) +static void dwarf_init(void) { ndebugs = 3; /* 3 debug symbols */ } -static void dwarf32_linenum(const char *filename, int32_t linenumber, +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; - dwarf32_findfile(filename); + dwarf_findfile(filename); debug_immcall = 1; currentline = linenumber; } /* called from elf_out with type == TY_DEBUGSYMLIN */ -static void dwarf32_output(int type, void *param) +static void dwarf_output(int type, void *param) { int ln, aa, inx, maxln, soc; struct symlininfo *s; @@ -1711,7 +1711,7 @@ static void dwarf32_output(int type, void *param) /* Check if section index has changed */ if (!(dwarf_csect && (dwarf_csect->section) == (s->section))) - dwarf32_findsect(s->section); + dwarf_findsect(s->section); /* do nothing unless line or file has changed */ if (!debug_immcall) @@ -1751,7 +1751,7 @@ static void dwarf32_output(int type, void *param) } -static void dwarf32_generate(void) +static void dwarf_generate(void) { uint8_t *pbuf; int indx; @@ -1984,7 +1984,7 @@ static void dwarf32_generate(void) WRITELONG(pbuf,0); /* null ending offset */ } -static void dwarf32_cleanup(void) +static void dwarf_cleanup(void) { nasm_free(arangesbuf); nasm_free(arangesrelbuf); @@ -1998,7 +1998,7 @@ static void dwarf32_cleanup(void) nasm_free(locbuf); } -static void dwarf32_findfile(const char * fname) +static void dwarf_findfile(const char * fname) { int finx; struct linelist *match; @@ -2035,7 +2035,7 @@ static void dwarf32_findfile(const char * fname) } } -static void dwarf32_findsect(const int index) +static void dwarf_findsect(const int index) { int sinx; struct sectlist *match; diff --git a/output/outelf64.c b/output/outelf64.c index f2a192a..89e00e7 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -160,24 +160,24 @@ static struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ -static void debug64_typevalue(int32_t); -static void debug64_deflabel(char *, int32_t, int64_t, int, char *); -static void debug64_directive(const char *, const char *); +static void debug_typevalue(int32_t); +static void debug_deflabel(char *, int32_t, int64_t, int, char *); +static void debug_directive(const char *, const char *); /* stabs debugging routines */ -static void stabs64_linenum(const char *filename, int32_t linenumber, int32_t); -static void stabs64_output(int, void *); -static void stabs64_generate(void); -static void stabs64_cleanup(void); +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t); +static void stabs_output(int, void *); +static void stabs_generate(void); +static void stabs_cleanup(void); /* dwarf debugging routines */ -static void dwarf64_init(void); -static void dwarf64_linenum(const char *filename, int32_t linenumber, int32_t); -static void dwarf64_output(int, void *); -static void dwarf64_generate(void); -static void dwarf64_cleanup(void); -static void dwarf64_findfile(const char *); -static void dwarf64_findsect(const int); +static void dwarf_init(void); +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t); +static void dwarf_output(int, void *); +static void dwarf_generate(void); +static void dwarf_cleanup(void); +static void dwarf_findfile(const char *); +static void dwarf_findsect(const int); /* * Special section numbers which are used to define ELF special @@ -1104,7 +1104,7 @@ static void elf_write(void) which are the .stab , .stabstr and .rel.stab sections respectively */ /* this function call creates the stab sections in memory */ - stabs64_generate(); + stabs_generate(); if (stabbuf && stabstrbuf && stabrelbuf) { elf_section_header(p - shstrtab, SHT_PROGBITS, 0, stabbuf, false, @@ -1125,7 +1125,7 @@ static void elf_write(void) /* this function call creates the dwarf sections in memory */ if (dwarf_fsect) - dwarf64_generate(); + dwarf_generate(); elf_section_header(p - shstrtab, SHT_PROGBITS, 0, arangesbuf, false, arangeslen, 0, 0, 1, 0); @@ -1430,24 +1430,24 @@ static int elf_set_info(enum geninfo type, char **val) static struct dfmt df_dwarf = { "ELF64 (x86-64) dwarf debug format for Linux/Unix", "dwarf", - dwarf64_init, - dwarf64_linenum, - debug64_deflabel, - debug64_directive, - debug64_typevalue, - dwarf64_output, - dwarf64_cleanup + dwarf_init, + dwarf_linenum, + debug_deflabel, + debug_directive, + debug_typevalue, + dwarf_output, + dwarf_cleanup }; static struct dfmt df_stabs = { "ELF64 (x86-64) stabs debug format for Linux/Unix", "stabs", null_debug_init, - stabs64_linenum, - debug64_deflabel, - debug64_directive, - debug64_typevalue, - stabs64_output, - stabs64_cleanup + stabs_linenum, + debug_deflabel, + debug_directive, + debug_typevalue, + stabs_output, + stabs_cleanup }; struct dfmt *elf64_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; @@ -1473,7 +1473,7 @@ struct ofmt of_elf64 = { }; /* common debugging routines */ -static void debug64_deflabel(char *name, int32_t segment, int64_t offset, +static void debug_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { (void)name; @@ -1483,13 +1483,13 @@ static void debug64_deflabel(char *name, int32_t segment, int64_t offset, (void)special; } -static void debug64_directive(const char *directive, const char *params) +static void debug_directive(const char *directive, const char *params) { (void)directive; (void)params; } -static void debug64_typevalue(int32_t type) +static void debug_typevalue(int32_t type) { int32_t stype, ssize; switch (TYM_TYPE(type)) { @@ -1558,7 +1558,7 @@ static void debug64_typevalue(int32_t type) /* stabs debugging routines */ -static void stabs64_linenum(const char *filename, int32_t linenumber, int32_t segto) +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; if (!stabs_filename) { @@ -1581,7 +1581,7 @@ static void stabs64_linenum(const char *filename, int32_t linenumber, int32_t se } -static void stabs64_output(int type, void *param) +static void stabs_output(int type, void *param) { struct symlininfo *s; struct linelist *el; @@ -1612,7 +1612,7 @@ static void stabs64_output(int type, void *param) /* for creating the .stab , .stabstr and .rel.stab sections in memory */ -static void stabs64_generate(void) +static void stabs_generate(void) { int i, numfiles, strsize, numstabs = 0, currfile, mainfileindex; uint8_t *sbuf, *ssbuf, *rbuf, *sptr, *rptr; @@ -1750,7 +1750,7 @@ static void stabs64_generate(void) stabstrbuf = ssbuf; } -static void stabs64_cleanup(void) +static void stabs_cleanup(void) { struct linelist *ptr, *del; if (!stabslines) @@ -1770,22 +1770,22 @@ static void stabs64_cleanup(void) /* dwarf routines */ -static void dwarf64_init(void) +static void dwarf_init(void) { ndebugs = 3; /* 3 debug symbols */ } -static void dwarf64_linenum(const char *filename, int32_t linenumber, +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; - dwarf64_findfile(filename); + dwarf_findfile(filename); debug_immcall = 1; currentline = linenumber; } /* called from elf_out with type == TY_DEBUGSYMLIN */ -static void dwarf64_output(int type, void *param) +static void dwarf_output(int type, void *param) { int ln, aa, inx, maxln, soc; struct symlininfo *s; @@ -1801,7 +1801,7 @@ static void dwarf64_output(int type, void *param) /* Check if section index has changed */ if (!(dwarf_csect && (dwarf_csect->section) == (s->section))) - dwarf64_findsect(s->section); + dwarf_findsect(s->section); /* do nothing unless line or file has changed */ if (!debug_immcall) @@ -1841,7 +1841,7 @@ static void dwarf64_output(int type, void *param) } -static void dwarf64_generate(void) +static void dwarf_generate(void) { uint8_t *pbuf; int indx; @@ -2076,7 +2076,7 @@ static void dwarf64_generate(void) WRITEDLONG(pbuf,0); /* null ending offset */ } -static void dwarf64_cleanup(void) +static void dwarf_cleanup(void) { nasm_free(arangesbuf); nasm_free(arangesrelbuf); @@ -2090,7 +2090,7 @@ static void dwarf64_cleanup(void) nasm_free(locbuf); } -static void dwarf64_findfile(const char * fname) +static void dwarf_findfile(const char * fname) { int finx; struct linelist *match; @@ -2127,7 +2127,7 @@ static void dwarf64_findfile(const char * fname) } } -static void dwarf64_findsect(const int index) +static void dwarf_findsect(const int index) { int sinx; struct sectlist *match; diff --git a/output/outelfx32.c b/output/outelfx32.c index c217c7b..a3ecf79 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -159,24 +159,24 @@ static struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ -static void debugx32_typevalue(int32_t); -static void debugx32_deflabel(char *, int32_t, int64_t, int, char *); -static void debugx32_directive(const char *, const char *); +static void debug_typevalue(int32_t); +static void debug_deflabel(char *, int32_t, int64_t, int, char *); +static void debug_directive(const char *, const char *); /* stabs debugging routines */ -static void stabsx32_linenum(const char *filename, int32_t linenumber, int32_t); -static void stabsx32_output(int, void *); -static void stabsx32_generate(void); -static void stabsx32_cleanup(void); +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t); +static void stabs_output(int, void *); +static void stabs_generate(void); +static void stabs_cleanup(void); /* dwarf debugging routines */ -static void dwarfx32_init(void); -static void dwarfx32_linenum(const char *filename, int32_t linenumber, int32_t); -static void dwarfx32_output(int, void *); -static void dwarfx32_generate(void); -static void dwarfx32_cleanup(void); -static void dwarfx32_findfile(const char *); -static void dwarfx32_findsect(const int); +static void dwarf_init(void); +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t); +static void dwarf_output(int, void *); +static void dwarf_generate(void); +static void dwarf_cleanup(void); +static void dwarf_findfile(const char *); +static void dwarf_findsect(const int); /* * Special section numbers which are used to define ELF special @@ -1065,7 +1065,7 @@ static void elf_write(void) which are the .stab , .stabstr and .rel.stab sections respectively */ /* this function call creates the stab sections in memory */ - stabsx32_generate(); + stabs_generate(); if (stabbuf && stabstrbuf && stabrelbuf) { elf_section_header(p - shstrtab, SHT_PROGBITS, 0, stabbuf, false, @@ -1086,7 +1086,7 @@ static void elf_write(void) /* this function call creates the dwarf sections in memory */ if (dwarf_fsect) - dwarfx32_generate(); + dwarf_generate(); elf_section_header(p - shstrtab, SHT_PROGBITS, 0, arangesbuf, false, arangeslen, 0, 0, 1, 0); @@ -1389,24 +1389,24 @@ static int elf_set_info(enum geninfo type, char **val) static struct dfmt df_dwarf = { "ELFX32 (x86-64) dwarf debug format for Linux/Unix", "dwarf", - dwarfx32_init, - dwarfx32_linenum, - debugx32_deflabel, - debugx32_directive, - debugx32_typevalue, - dwarfx32_output, - dwarfx32_cleanup + dwarf_init, + dwarf_linenum, + debug_deflabel, + debug_directive, + debug_typevalue, + dwarf_output, + dwarf_cleanup }; static struct dfmt df_stabs = { "ELFX32 (x86-64) stabs debug format for Linux/Unix", "stabs", null_debug_init, - stabsx32_linenum, - debugx32_deflabel, - debugx32_directive, - debugx32_typevalue, - stabsx32_output, - stabsx32_cleanup + stabs_linenum, + debug_deflabel, + debug_directive, + debug_typevalue, + stabs_output, + stabs_cleanup }; struct dfmt *elfx32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; @@ -1432,7 +1432,7 @@ struct ofmt of_elfx32 = { }; /* common debugging routines */ -static void debugx32_deflabel(char *name, int32_t segment, int64_t offset, +static void debug_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { (void)name; @@ -1442,13 +1442,13 @@ static void debugx32_deflabel(char *name, int32_t segment, int64_t offset, (void)special; } -static void debugx32_directive(const char *directive, const char *params) +static void debug_directive(const char *directive, const char *params) { (void)directive; (void)params; } -static void debugx32_typevalue(int32_t type) +static void debug_typevalue(int32_t type) { int32_t stype, ssize; switch (TYM_TYPE(type)) { @@ -1517,7 +1517,7 @@ static void debugx32_typevalue(int32_t type) /* stabs debugging routines */ -static void stabsx32_linenum(const char *filename, int32_t linenumber, int32_t segto) +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; if (!stabs_filename) { @@ -1540,7 +1540,7 @@ static void stabsx32_linenum(const char *filename, int32_t linenumber, int32_t s } -static void stabsx32_output(int type, void *param) +static void stabs_output(int type, void *param) { struct symlininfo *s; struct linelist *el; @@ -1571,7 +1571,7 @@ static void stabsx32_output(int type, void *param) /* for creating the .stab , .stabstr and .rel.stab sections in memory */ -static void stabsx32_generate(void) +static void stabs_generate(void) { int i, numfiles, strsize, numstabs = 0, currfile, mainfileindex; uint8_t *sbuf, *ssbuf, *rbuf, *sptr, *rptr; @@ -1706,7 +1706,7 @@ static void stabsx32_generate(void) stabstrbuf = ssbuf; } -static void stabsx32_cleanup(void) +static void stabs_cleanup(void) { struct linelist *ptr, *del; if (!stabslines) @@ -1726,22 +1726,22 @@ static void stabsx32_cleanup(void) /* dwarf routines */ -static void dwarfx32_init(void) +static void dwarf_init(void) { ndebugs = 3; /* 3 debug symbols */ } -static void dwarfx32_linenum(const char *filename, int32_t linenumber, +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; - dwarfx32_findfile(filename); + dwarf_findfile(filename); debug_immcall = 1; currentline = linenumber; } /* called from elf_out with type == TY_DEBUGSYMLIN */ -static void dwarfx32_output(int type, void *param) +static void dwarf_output(int type, void *param) { int ln, aa, inx, maxln, soc; struct symlininfo *s; @@ -1757,7 +1757,7 @@ static void dwarfx32_output(int type, void *param) /* Check if section index has changed */ if (!(dwarf_csect && (dwarf_csect->section) == (s->section))) - dwarfx32_findsect(s->section); + dwarf_findsect(s->section); /* do nothing unless line or file has changed */ if (!debug_immcall) @@ -1797,7 +1797,7 @@ static void dwarfx32_output(int type, void *param) } -static void dwarfx32_generate(void) +static void dwarf_generate(void) { uint8_t *pbuf; int indx; @@ -2032,7 +2032,7 @@ static void dwarfx32_generate(void) WRITELONG(pbuf,0); /* null ending offset */ } -static void dwarfx32_cleanup(void) +static void dwarf_cleanup(void) { nasm_free(arangesbuf); nasm_free(arangesrelbuf); @@ -2046,7 +2046,7 @@ static void dwarfx32_cleanup(void) nasm_free(locbuf); } -static void dwarfx32_findfile(const char * fname) +static void dwarf_findfile(const char * fname) { int finx; struct linelist *match; @@ -2083,7 +2083,7 @@ static void dwarfx32_findfile(const char * fname) } } -static void dwarfx32_findsect(const int index) +static void dwarf_findsect(const int index) { int sinx; struct sectlist *match; |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 04:33:24
|
Commit-ID: bbbf50839479a63841169b8995f285fb1c8a3fc5 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=bbbf50839479a63841169b8995f285fb1c8a3fc5 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 16:10:41 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 16:10:41 -0800 nasmlib: add nasm_fatal() like nasm_panic() Just like nasm_panic(), nasm_fatal() tells the compiler that we can never return from this call. Signed-off-by: H. Peter Anvin <hp...@li...> --- nasmlib.c | 19 ++++++++++++++----- nasmlib.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/nasmlib.c b/nasmlib.c index cf39468..d19cbf6 100644 --- a/nasmlib.c +++ b/nasmlib.c @@ -83,6 +83,15 @@ void nasm_error(int severity, const char *fmt, ...) va_end(ap); } +no_return nasm_fatal(int flags, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + nasm_verror(flags | ERR_FATAL, fmt, ap); + abort(); /* We should never get here */ +} + no_return nasm_panic(int flags, const char *fmt, ...) { va_list ap; @@ -101,7 +110,7 @@ void *nasm_malloc(size_t size) { void *p = malloc(size); if (!p) - nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory"); + nasm_fatal(ERR_NOFILE, "out of memory"); return p; } @@ -109,7 +118,7 @@ void *nasm_zalloc(size_t size) { void *p = calloc(size, 1); if (!p) - nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory"); + nasm_fatal(ERR_NOFILE, "out of memory"); return p; } @@ -117,7 +126,7 @@ void *nasm_realloc(void *q, size_t size) { void *p = q ? realloc(q, size) : malloc(size); if (!p) - nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory"); + nasm_fatal(ERR_NOFILE, "out of memory"); return p; } @@ -134,7 +143,7 @@ char *nasm_strdup(const char *s) p = malloc(size); if (!p) - nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory"); + nasm_fatal(ERR_NOFILE, "out of memory"); strcpy(p, s); return p; } @@ -146,7 +155,7 @@ char *nasm_strndup(const char *s, size_t len) p = malloc(size); if (!p) - nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory"); + nasm_fatal(ERR_NOFILE, "out of memory"); strncpy(p, s, len); p[len] = '\0'; return p; diff --git a/nasmlib.h b/nasmlib.h index 86766e3..2e2e807 100644 --- a/nasmlib.h +++ b/nasmlib.h @@ -77,6 +77,7 @@ typedef void (*efunc) (int severity, const char *fmt, ...); typedef void (*vefunc) (int severity, const char *fmt, va_list ap); void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...); void nasm_set_verror(vefunc); +no_return printf_func(2, 3) nasm_fatal(int flags, const char *fmt, ...); no_return printf_func(2, 3) nasm_panic(int flags, const char *fmt, ...); no_return nasm_panic_from_macro(const char *file, int line); #define panic() nasm_panic_from_macro(__FILE__, __LINE__); |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 23:42:20
|
Commit-ID: 86e31129f71a033fc06201d4ef51d6893355ac42 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=86e31129f71a033fc06201d4ef51d6893355ac42 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 14:44:19 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 14:44:19 -0800 outelf32: remove unused header file Remove unused instance of <limits.h>. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outelf32.c | 1 - 1 file changed, 1 deletion(-) diff --git a/output/outelf32.c b/output/outelf32.c index 6737538..8553604 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -43,7 +43,6 @@ #include <string.h> #include <ctype.h> #include <inttypes.h> -#include <limits.h> #include "nasm.h" #include "nasmlib.h" |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 23:42:20
|
Commit-ID: 4b70bc25043af4030e3010b5a5c3e8ca5dbecaf9 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=4b70bc25043af4030e3010b5a5c3e8ca5dbecaf9 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 14:37:26 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 14:37:26 -0800 outelf32: move stabs32_linenum() so that it matches the other files Move the function stabs32_linenum() so that it is in the same location as in the other ELF backends; this eliminates a gratuitous difference. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outelf32.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index e4971ed..6737538 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -1384,32 +1384,6 @@ struct ofmt of_elf32 = { /* again, the stabs debugging stuff (code) */ -static void stabs32_linenum(const char *filename, int32_t linenumber, - int32_t segto) -{ - (void)segto; - - if (!stabs_filename) { - stabs_filename = (char *)nasm_malloc(strlen(filename) + 1); - strcpy(stabs_filename, filename); - } else { - if (strcmp(stabs_filename, filename)) { - /* - * yep, a memory leak...this program is one-shot anyway, so who cares... - * in fact, this leak comes in quite handy to maintain a list of files - * encountered so far in the symbol lines... - */ - - /* why not nasm_free(stabs_filename); we're done with the old one */ - - stabs_filename = (char *)nasm_malloc(strlen(filename) + 1); - strcpy(stabs_filename, filename); - } - } - debug_immcall = 1; - currentline = linenumber; -} - static void debug32_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { @@ -1493,6 +1467,33 @@ static void debug32_typevalue(int32_t type) } } +/* stabs debugging routines */ + +static void stabs32_linenum(const char *filename, int32_t linenumber, + int32_t segto) +{ + (void)segto; + + if (!stabs_filename) { + stabs_filename = (char *)nasm_malloc(strlen(filename) + 1); + strcpy(stabs_filename, filename); + } else { + if (strcmp(stabs_filename, filename)) { + /* yep, a memory leak...this program is one-shot anyway, so who cares... + in fact, this leak comes in quite handy to maintain a list of files + encountered so far in the symbol lines... */ + + + /* why not nasm_free(stabs_filename); we're done with the old one */ + + stabs_filename = (char *)nasm_malloc(strlen(filename) + 1); + strcpy(stabs_filename, filename); + } + } + debug_immcall = 1; + currentline = linenumber; +} + static void stabs32_output(int type, void *param) { struct symlininfo *s; |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 23:39:21
|
Commit-ID: d2ea49b326058cb96400e79691b4a89c6418cb91 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=d2ea49b326058cb96400e79691b4a89c6418cb91 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 15:35:06 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 15:38:51 -0800 listing: change the line numbers to match the source code Instead of completely useless sequential line numbers, emit line numbers corresponding to the line numbers in the source code. Signed-off-by: H. Peter Anvin <hp...@li...> --- doc/changes.src | 3 +++ listing.c | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/changes.src b/doc/changes.src index 67491b7..eab8439 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -32,6 +32,9 @@ since 2007. relocations are zero-extended from 32-bits with a warning (suppressible via \c{}); signed 64-bit relocations are an arror. +\b Line numbers in list files now correspond to the lines in the source + files, instead of simply being sequential. + \S{cl-2.11.09} Version 2.11.09 \b Fix potential stack overwrite in \c{macho32} backend. diff --git a/listing.c b/listing.c index 49f5e15..4fcf91f 100644 --- a/listing.c +++ b/listing.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2009 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -73,6 +73,7 @@ static char listdata[2 * LIST_INDENT]; /* we need less than that actually */ static int32_t listoffset; static int32_t listlineno; +static const char *listfn; static int32_t listp; @@ -89,7 +90,7 @@ static void list_emit(void) if (!listlinep && !listdata[0]) return; - fprintf(listfp, "%6"PRId32" ", ++listlineno); + fprintf(listfp, "%6"PRId32" ", listlineno); if (listdata[0]) fprintf(listfp, "%08"PRIX32" %-*s", listoffset, LIST_HEXBIT + 1, @@ -111,7 +112,7 @@ static void list_emit(void) listdata[0] = '\0'; if (listerror[0]) { - fprintf(listfp, "%6"PRId32" ", ++listlineno); + fprintf(listfp, "%6"PRId32" ", listlineno); for (i = 0; i < LIST_HEXBIT; i++) putc('*', listfp); @@ -243,10 +244,9 @@ static void list_line(int type, char *line) { if (!listp) return; - if (user_nolist) { /* fbk - 9/2/00 */ - listlineno++; - return; - } + + if (user_nolist) + return; if (mistack && mistack->inhibiting) { if (type == LIST_MACRO) @@ -258,6 +258,7 @@ static void list_line(int type, char *line) } } list_emit(); + listlineno = src_get_linnum(); listlinep = true; strncpy(listline, line, LIST_MAX_LEN - 1); listline[LIST_MAX_LEN - 1] = '\0'; |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 22:39:43
|
Commit-ID: 9f7c68a5190a0b6f31174c9f1f64f242ed778a35 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=9f7c68a5190a0b6f31174c9f1f64f242ed778a35 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 13:44:51 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 13:44:51 -0800 changes.src: more updates for 2.12 More updates in preparation for NASM 2.12. Signed-off-by: H. Peter Anvin <hp...@li...> --- doc/changes.src | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/changes.src b/doc/changes.src index 8eab8d6..67491b7 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -9,8 +9,9 @@ since 2007. \S{cl-2.12} Version 2.12 -\b Huge rework of \c{macho} backend, internal unification of 32 and 64 - bit formats and make nasm to handle section alignemts properly. +\b Huge rework of \c{macho} backend (\k{Mach-O}), internal unification + of 32 and 64 bit formats and make NASM to handle section + alignment properly. \b Fix wrong negative size treated as a big positive value passed into backend causing nasm to crash. @@ -22,9 +23,14 @@ since 2007. \b Fix potential write of oversized (with size greater than allowed in output format) relative relocations. -\b Portability fixes for building nasm with LLVM compiler. +\b Portability fixes for building NASM with LLVM compiler. -\b Add support of Codeview debug format for \c{win32} and \c{win64} formats in \c{coff} backend. +\b Add support of Codeview (\c{cv8}) debug format for \c{win32} and \c{win64} + formats in the \c{COFF} backend (\k{coff}). + +\b Allow 64-bit outputs in 16/32-bit only backends. Unsigned 64-bit + relocations are zero-extended from 32-bits with a warning + (suppressible via \c{}); signed 64-bit relocations are an arror. \S{cl-2.11.09} Version 2.11.09 |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 22:39:24
|
Commit-ID: a648b90eab7d25c4b059979e3fc89087fae63ca7 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=a648b90eab7d25c4b059979e3fc89087fae63ca7 Author: H. Peter Anvin <hp...@li...> AuthorDate: Tue, 16 Feb 2016 22:32:58 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Tue, 16 Feb 2016 22:32:58 -0800 NASM 2.12rc4 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index ffda82f..2382492 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.12rc3 +2.12rc4 |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 21:33:22
|
Commit-ID: 43e0c3cf8dcad976b65fc8e8fefc0b0809af4137 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=43e0c3cf8dcad976b65fc8e8fefc0b0809af4137 Author: H. Peter Anvin <hp...@li...> AuthorDate: Wed, 17 Feb 2016 13:28:19 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Wed, 17 Feb 2016 13:28:19 -0800 outmacho: make a copy of "fmt" instead of making it a pointer Make a point of the output format constants instead of making it a pointer. The output format is set only once, but it is accessed all the time. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outmacho.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/output/outmacho.c b/output/outmacho.c index b3df430..98a440d 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -136,11 +136,11 @@ struct macho_fmt { uint32_t reloc_tlv; /* Thread local relocation type */ }; -static const struct macho_fmt *fmt; +static struct macho_fmt fmt; static void fwriteptr(uint64_t data, FILE * fp) { - fwriteaddr(data, fmt->ptrsize, fp); + fwriteaddr(data, fmt.ptrsize, fp); } struct section { @@ -299,7 +299,7 @@ static uint64_t rel_padcnt = 0; ALIGN(x, sizeof(int64_t)) /* align x to int64_t boundary */ #define alignptr(x) \ - ALIGN(x, fmt->ptrsize) /* align x to output format width */ + ALIGN(x, fmt.ptrsize) /* align x to output format width */ static void debug_reloc (struct reloc *); static void debug_section_relocs (struct section *) _unused; @@ -396,7 +396,7 @@ static int64_t add_reloc(struct section *sect, int32_t section, int64_t adjust; /* Double check this is a valid relocation type for this platform */ - nasm_assert(reltype <= fmt->maxreltype); + nasm_assert(reltype <= fmt.maxreltype); /* the current end of the section will be the symbol's address for ** now, might have to be fixed by macho_fixup_relocs() later on. make @@ -411,7 +411,7 @@ static int64_t add_reloc(struct section *sect, int32_t section, r->length = ilog2_32(bytes); /* set default relocation values */ - r->type = fmt->reloc_abs; + r->type = fmt.reloc_abs; r->pcrel = 0; r->snum = R_ABS; @@ -439,7 +439,7 @@ static int64_t add_reloc(struct section *sect, int32_t section, break; case RL_REL: - r->type = fmt->reloc_rel; + r->type = fmt.reloc_rel; r->pcrel = 1; if (section == NO_SEG) { goto bail; /* No relocation needed */ @@ -469,7 +469,7 @@ static int64_t add_reloc(struct section *sect, int32_t section, goto needsym; case RL_TLV: - r->type = fmt->reloc_tlv; + r->type = fmt.reloc_tlv; goto needsym; needsym: @@ -573,7 +573,7 @@ static void macho_output(int32_t secto, const void *data, nasm_error(ERR_NONFATAL, "Mach-O format does not support" " section base references"); } else if (wrt == NO_SEG) { - if (fmt->ptrsize == 8 && asize != 8) { + if (fmt.ptrsize == 8 && asize != 8) { nasm_error(ERR_NONFATAL, "Mach-O 64-bit format does not support" " 32-bit absolute addresses"); @@ -602,7 +602,7 @@ static void macho_output(int32_t secto, const void *data, if (section != NO_SEG && section % 2) { nasm_error(ERR_NONFATAL, "Mach-O format does not support" " section base references"); - } else if (fmt->ptrsize == 8) { + } else if (fmt.ptrsize == 8) { nasm_error(ERR_NONFATAL, "Unsupported non-32-bit" " Macho-O relocation [2]"); } else if (wrt != NO_SEG) { @@ -677,7 +677,7 @@ static int32_t macho_section(char *name, int pass, int *bits) /* Default to the appropriate number of bits. */ if (!name) { - *bits = fmt->ptrsize << 3; + *bits = fmt.ptrsize << 3; name = ".text"; sectionAttributes = NULL; } else { @@ -1087,7 +1087,7 @@ static void macho_calculate_sizes (void) ** get a pointer to the start of all the raw data */ if (seg_nsects > 0) { ++head_ncmds; - head_sizeofcmds += fmt->segcmd_size + seg_nsects * fmt->sectcmd_size; + head_sizeofcmds += fmt.segcmd_size + seg_nsects * fmt.sectcmd_size; } if (nsyms > 0) { @@ -1111,14 +1111,14 @@ static void macho_calculate_sizes (void) static void macho_write_header (void) { - fwriteint32_t(fmt->mh_magic, ofile); /* magic */ - fwriteint32_t(fmt->cpu_type, ofile); /* CPU type */ + fwriteint32_t(fmt.mh_magic, ofile); /* magic */ + fwriteint32_t(fmt.cpu_type, ofile); /* CPU type */ fwriteint32_t(CPU_SUBTYPE_I386_ALL, ofile); /* CPU subtype */ fwriteint32_t(MH_OBJECT, ofile); /* Mach-O file type */ fwriteint32_t(head_ncmds, ofile); /* number of load commands */ fwriteint32_t(head_sizeofcmds, ofile); /* size of load commands */ fwriteint32_t(0, ofile); /* no flags */ - fwritezero(fmt->header_size - 7*4, ofile); /* reserved fields */ + fwritezero(fmt.header_size - 7*4, ofile); /* reserved fields */ } /* Write out the segment load command at offset. */ @@ -1129,10 +1129,10 @@ static uint32_t macho_write_segment (uint64_t offset) uint32_t s_reloff = 0; struct section *s; - fwriteint32_t(fmt->lc_segment, ofile); /* cmd == LC_SEGMENT_64 */ + fwriteint32_t(fmt.lc_segment, ofile); /* cmd == LC_SEGMENT_64 */ /* size of load command including section load commands */ - fwriteint32_t(fmt->segcmd_size + seg_nsects * fmt->sectcmd_size, + fwriteint32_t(fmt.segcmd_size + seg_nsects * fmt.sectcmd_size, ofile); /* in an MH_OBJECT file all sections are in one unnamed (name @@ -1461,7 +1461,7 @@ static void macho_write (void) /* Emit the Mach-O header. */ macho_write_header(); - offset = fmt->header_size + head_sizeofcmds; + offset = fmt.header_size + head_sizeofcmds; /* emit the segment load command */ if (seg_nsects > 0) @@ -1476,7 +1476,7 @@ static void macho_write (void) fwriteint32_t(offset, ofile); /* symbol table offset */ fwriteint32_t(nsyms, ofile); /* number of symbol ** table entries */ - offset += nsyms * fmt->nlist_size; + offset += nsyms * fmt.nlist_size; fwriteint32_t(offset, ofile); /* string table offset */ fwriteint32_t(strslen, ofile); /* string table size */ } @@ -1589,7 +1589,7 @@ static const struct macho_fmt macho32_fmt = { static void macho32_init(void) { - fmt = &macho32_fmt; + fmt = macho32_fmt; macho_init(); macho_gotpcrel_sect = NO_SEG; @@ -1634,7 +1634,7 @@ static const struct macho_fmt macho64_fmt = { static void macho64_init(void) { - fmt = &macho64_fmt; + fmt = macho64_fmt; macho_init(); /* add special symbol for ..gotpcrel */ |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-02-17 14:03:38
|
Commit-ID: 1452990979398343fe9ca41109ec2e4df2cd368a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=1452990979398343fe9ca41109ec2e4df2cd368a Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Wed, 17 Feb 2016 17:02:34 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Wed, 17 Feb 2016 17:02:34 +0300 docs: Fix typo in previous commit Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- doc/changes.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes.src b/doc/changes.src index d3175ff..8eab8d6 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -9,7 +9,7 @@ since 2007. \S{cl-2.12} Version 2.12 -\b Huge rework of \{macho\} backend, internal unification of 32 and 64 +\b Huge rework of \c{macho} backend, internal unification of 32 and 64 bit formats and make nasm to handle section alignemts properly. \b Fix wrong negative size treated as a big positive value passed into |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-02-17 14:03:24
|
Commit-ID: 2338613e6bdad2dba6d68f2a20a8adb4b61bbc15 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=2338613e6bdad2dba6d68f2a20a8adb4b61bbc15 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Wed, 17 Feb 2016 17:00:06 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Wed, 17 Feb 2016 17:00:06 +0300 docs: changes -- Prepare for 2.12 Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- doc/changes.src | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/changes.src b/doc/changes.src index 258b113..d3175ff 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -7,6 +7,25 @@ The NASM 2 series supports x86-64, and is the production version of NASM since 2007. +\S{cl-2.12} Version 2.12 + +\b Huge rework of \{macho\} backend, internal unification of 32 and 64 + bit formats and make nasm to handle section alignemts properly. + +\b Fix wrong negative size treated as a big positive value passed into + backend causing nasm to crash. + +\b Fix handling of zero-extending unsigned relocations, we have been printing + wrong message and forgot to assign segment with predefined value before + passing it into output format. + +\b Fix potential write of oversized (with size greater than allowed in + output format) relative relocations. + +\b Portability fixes for building nasm with LLVM compiler. + +\b Add support of Codeview debug format for \c{win32} and \c{win64} formats in \c{coff} backend. + \S{cl-2.11.09} Version 2.11.09 \b Fix potential stack overwrite in \c{macho32} backend. |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 06:18:21
|
Commit-ID: dde34c51b35733299b3e3d160c873fa81e64827a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=dde34c51b35733299b3e3d160c873fa81e64827a Author: H. Peter Anvin <hp...@li...> AuthorDate: Tue, 16 Feb 2016 22:15:03 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Tue, 16 Feb 2016 22:15:03 -0800 outmacho: correct handling of GOT relocation, add TLVP relocations Correct the handling of GOT relocations, as they need a symbol reference. Add handling of TLVP relocations; it is unclear to me if non-local relocations in TLVP space is permitted. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outmacho.c | 284 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 183 insertions(+), 101 deletions(-) diff --git a/output/outmacho.c b/output/outmacho.c index d2952b2..b3df430 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -51,6 +51,7 @@ #include "nasmlib.h" #include "saa.h" #include "raa.h" +#include "rbtree.h" #include "output/outform.h" #include "output/outlib.h" @@ -77,10 +78,29 @@ #define CPU_SUBTYPE_I386_ALL 3 /* all-x86 compatible */ #define MH_OBJECT 0x1 /* object file */ +/* Mach-O load commands */ #define LC_SEGMENT 0x1 /* 32-bit segment load cmd */ #define LC_SEGMENT_64 0x19 /* 64-bit segment load cmd */ #define LC_SYMTAB 0x2 /* symbol table load command */ +/* Mach-O relocations numbers */ + +/* Generic relocs, used by i386 Mach-O */ +#define GENERIC_RELOC_VANILLA 0 /* Generic relocation */ +#define GENERIC_RELOC_TLV 5 /* Thread local */ + +#define X86_64_RELOC_UNSIGNED 0 /* Absolute address */ +#define X86_64_RELOC_SIGNED 1 /* Signed 32-bit disp */ +#define X86_64_RELOC_BRANCH 2 /* CALL/JMP with 32-bit disp */ +#define X86_64_RELOC_GOT_LOAD 3 /* MOVQ of GOT entry */ +#define X86_64_RELOC_GOT 4 /* Different GOT entry */ +#define X86_64_RELOC_SUBTRACTOR 5 /* Subtracting two symbols */ +#define X86_64_RELOC_SIGNED_1 6 /* SIGNED with -1 addend */ +#define X86_64_RELOC_SIGNED_2 7 /* SIGNED with -2 addend */ +#define X86_64_RELOC_SIGNED_4 8 /* SIGNED with -4 addend */ +#define X86_64_RELOC_TLV 9 /* Thread local */ + +/* Mach-O VM permission constants */ #define VM_PROT_NONE (0x00) #define VM_PROT_READ (0x01) #define VM_PROT_WRITE (0x02) @@ -89,6 +109,18 @@ #define VM_PROT_DEFAULT (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE) #define VM_PROT_ALL (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE) +/* Our internal relocation types */ +enum reltype { + RL_ABS, /* Absolute relocation */ + RL_REL, /* Relative relocation */ + RL_TLV, /* Thread local */ + RL_SUB, /* X86_64_RELOC_SUBTRACT */ + RL_GOT, /* X86_64_RELOC_GOT */ + RL_GOTLOAD, /* X86_64_RELOC_GOT_LOAD */ +}; +#define RL_MAX_32 RL_TLV +#define RL_MAX_64 RL_GOTLOAD + struct macho_fmt { uint32_t ptrsize; /* Pointer size in bytes */ uint32_t mh_magic; /* Which magic number to use */ @@ -98,6 +130,10 @@ struct macho_fmt { uint32_t segcmd_size; /* Segment command size */ uint32_t sectcmd_size; /* Section command size */ uint32_t nlist_size; /* Nlist (symbol) size */ + enum reltype maxreltype; /* Maximum entry in enum reltype permitted */ + uint32_t reloc_abs; /* Absolute relocation type */ + uint32_t reloc_rel; /* Relative relocation type */ + uint32_t reloc_tlv; /* Thread local relocation type */ }; static const struct macho_fmt *fmt; @@ -114,6 +150,7 @@ struct section { int32_t index; int32_t fileindex; struct reloc *relocs; + struct rbtree *gsyms; /* Global symbols in section */ int align; bool by_name; /* This section was specified by full MachO name */ @@ -144,7 +181,7 @@ struct section { #define S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* section uses pure machine instructions */ -static struct sectmap { +static const struct sectmap { const char *nasmsect; const char *segname; const char *sectname; @@ -178,18 +215,18 @@ struct reloc { struct symbol { /* nasm internal data */ + struct rbtree symv; /* Global symbol rbtree; "key" contains the + symbol offset. */ struct symbol *next; /* next symbol in the list */ char *name; /* name of this symbol */ - int32_t initial_snum; /* symbol number used above in - reloc */ - int32_t snum; /* true snum for reloc */ + int32_t initial_snum; /* symbol number used above in reloc */ + int32_t snum; /* true snum for reloc */ /* data that goes into the file */ - uint32_t strx; /* string table index */ - uint8_t type; /* symbol type */ - uint8_t sect; /* NO_SECT or section number */ - uint16_t desc; /* for stab debugging, 0 for us */ - uint64_t value; /* offset of symbol in section */ + uint32_t strx; /* string table index */ + uint8_t type; /* symbol type */ + uint8_t sect; /* NO_SECT or section number */ + uint16_t desc; /* for stab debugging, 0 for us */ }; /* symbol type bits */ @@ -290,18 +327,12 @@ static struct section *get_section_by_index(const int32_t index) return s; } -static uint8_t get_section_fileindex_by_index(const int32_t index) -{ - struct section *s = get_section_by_index(index); - - return s ? s->fileindex : NO_SECT; -} - /* * Special section numbers which are used to define Mach-O special * symbols, which can be used with WRT to provide PIC relocation * types. */ +static int32_t macho_tlvp_sect; static int32_t macho_gotpcrel_sect; static void macho_init(void) @@ -322,6 +353,11 @@ static void macho_init(void) /* string table starts with a zero byte so index 0 is an empty string */ saa_wbytes(strs, zero_buffer, 1); strslen = 1; + + /* add special symbol for TLVP */ + macho_tlvp_sect = seg_alloc() + 1; + define_label("..tlvp", macho_tlvp_sect, 0L, NULL, false, false); + } static void sect_write(struct section *sect, @@ -331,32 +367,42 @@ static void sect_write(struct section *sect, sect->size += len; } -enum reltype { - RL_ABS, /* Absolute relocation */ - RL_REL, /* Relative relocation */ - RL_SUB, /* X86_64_RELOC_SUBTRACT */ - RL_GOT, /* X86_64_RELOC_GOT */ - RL_GOTLOAD, /* X86_64_RELOC_GOT_LOAD */ -}; +/* + * Find a suitable global symbol for a ..gotpcrel or ..tlvp reference + */ +static struct symbol *macho_find_gsym(struct section *s, + uint64_t offset, bool exact) +{ + struct rbtree *srb; + + srb = rb_search(s->gsyms, offset); + + if (!srb || (exact && srb->key != offset)) { + nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol" + " for this reference"); + return NULL; + } + + return container_of(srb, struct symbol, symv); +} static int64_t add_reloc(struct section *sect, int32_t section, + int64_t offset, enum reltype reltype, int bytes) { struct reloc *r; + struct section *s; int32_t fi; int64_t adjust; - /* NeXT as puts relocs in reversed order (address-wise) into the - ** files, so we do the same, doesn't seem to make much of a - ** difference either way */ - r = nasm_malloc(sizeof(struct reloc)); - r->next = sect->relocs; - sect->relocs = r; + /* Double check this is a valid relocation type for this platform */ + nasm_assert(reltype <= fmt->maxreltype); /* the current end of the section will be the symbol's address for ** now, might have to be fixed by macho_fixup_relocs() later on. make ** sure we don't make the symbol scattered by setting the highest ** bit by accident */ + r = nasm_malloc(sizeof(struct reloc)); r->addr = sect->size & ~R_SCATTERED; r->ext = 1; adjust = bytes; @@ -365,10 +411,15 @@ static int64_t add_reloc(struct section *sect, int32_t section, r->length = ilog2_32(bytes); /* set default relocation values */ - r->type = 0; + r->type = fmt->reloc_abs; r->pcrel = 0; r->snum = R_ABS; + s = NULL; + if (section != NO_SEG) + s = get_section_by_index(section); + fi = s ? s->fileindex : NO_SECT; + /* absolute relocation */ switch (reltype) { case RL_ABS: @@ -376,64 +427,82 @@ static int64_t add_reloc(struct section *sect, int32_t section, /* absolute (can this even happen?) */ r->ext = 0; r->snum = R_ABS; + } else if (fi == NO_SECT) { + /* external */ + r->snum = raa_read(extsyms, section); } else { - /* inter-section */ - fi = get_section_fileindex_by_index(section); - if (fi == NO_SECT) { - /* external */ - r->snum = raa_read(extsyms, section); - } else { - /* local */ - r->ext = 0; - r->snum = fi; - adjust = -sect->size; - } + /* local */ + r->ext = 0; + r->snum = fi; + adjust = -sect->size; } break; case RL_REL: + r->type = fmt->reloc_rel; r->pcrel = 1; if (section == NO_SEG) { - /* intra-section */ - r->type = 1; // X86_64_RELOC_SIGNED + goto bail; /* No relocation needed */ + } else if (fi == NO_SECT) { + /* external */ + sect->extreloc = 1; + r->snum = raa_read(extsyms, section); } else { - /* inter-section */ - r->type = 1; // X86_64_RELOC_SIGNED - fi = get_section_fileindex_by_index(section); - - if (fi == NO_SECT) { - /* external */ - sect->extreloc = 1; - r->snum = raa_read(extsyms, section); - } else { - /* local */ - r->ext = 0; - r->snum = fi; - adjust = -sect->size; - } + /* local */ + r->ext = 0; + r->snum = fi; + adjust = -sect->size; } break; case RL_SUB: r->pcrel = 0; - r->type = 5; // X86_64_RELOC_SUBTRACTOR + r->type = X86_64_RELOC_SUBTRACTOR; break; case RL_GOT: - r->pcrel = 1; - r->type = 4; // X86_64_RELOC_GOT - r->snum = macho_gotpcrel_sect; /* WTF? */ - break; + r->type = X86_64_RELOC_GOT; + goto needsym; case RL_GOTLOAD: + r->type = X86_64_RELOC_GOT_LOAD; + goto needsym; + + case RL_TLV: + r->type = fmt->reloc_tlv; + goto needsym; + + needsym: r->pcrel = 1; - r->type = 3; // X86_64_RELOC_GOT_LOAD - r->snum = macho_gotpcrel_sect; /* WTF? */ + if (section == NO_SEG) { + nasm_error(ERR_NONFATAL, "Unsupported use of use of WRT"); + } else if (fi == NO_SECT) { + /* external */ + r->snum = raa_read(extsyms, section); + } else { + /* internal */ + struct symbol *sym = macho_find_gsym(s, offset, reltype != RL_TLV); + if (!sym) + goto bail; + r->snum = sym->initial_snum; + } break; } + /* NeXT as puts relocs in reversed order (address-wise) into the + ** files, so we do the same, doesn't seem to make much of a + ** difference either way */ + r->next = sect->relocs; + sect->relocs = r; + if (r->ext) + sect->extreloc = 1; ++sect->nreloc; + return adjust; + + bail: + nasm_free(r); + return 0; } static void macho_output(int32_t secto, const void *data, @@ -441,7 +510,7 @@ static void macho_output(int32_t secto, const void *data, int32_t section, int32_t wrt) { struct section *s; - int64_t addr; + int64_t addr, offset; uint8_t mydata[16], *p, gotload; bool is_bss; @@ -449,7 +518,6 @@ static void macho_output(int32_t secto, const void *data, if (type != OUT_RESERVE) nasm_error(ERR_NONFATAL, "attempt to assemble code in " "[ABSOLUTE] space"); - return; } @@ -510,7 +578,7 @@ static void macho_output(int32_t secto, const void *data, "Mach-O 64-bit format does not support" " 32-bit absolute addresses"); } else { - add_reloc(s, section, RL_ABS, asize); + add_reloc(s, section, addr, RL_ABS, asize); } } else { nasm_error(ERR_NONFATAL, "Mach-O format does not support" @@ -528,7 +596,8 @@ static void macho_output(int32_t secto, const void *data, nasm_assert(section != secto); p = mydata; - addr = *(int64_t *)data - size; + offset = *(int64_t *)data; + addr = offset - size; if (section != NO_SEG && section % 2) { nasm_error(ERR_NONFATAL, "Mach-O format does not support" @@ -541,7 +610,7 @@ static void macho_output(int32_t secto, const void *data, " this use of WRT"); wrt = NO_SEG; /* we can at least _try_ to continue */ } else { - addr += add_reloc(s, section, RL_REL, 2); + addr += add_reloc(s, section, addr+size, RL_REL, 2); } WRITESHORT(p, addr); @@ -552,14 +621,15 @@ static void macho_output(int32_t secto, const void *data, nasm_assert(section != secto); p = mydata; - addr = *(int64_t *)data - size; + offset = *(int64_t *)data; + addr = offset - size; if (section != NO_SEG && section % 2) { nasm_error(ERR_NONFATAL, "Mach-O format does not support" " section base references"); } else if (wrt == NO_SEG) { /* Plain relative relocation */ - addr += add_reloc(s, section, RL_REL, 4); + addr += add_reloc(s, section, offset, RL_REL, 4); } else if (wrt == macho_gotpcrel_sect) { if (s->data->datalen > 1) { /* Retrieve instruction opcode */ @@ -569,11 +639,13 @@ static void macho_output(int32_t secto, const void *data, } if (gotload == 0x8B) { /* Check for MOVQ Opcode -> X86_64_RELOC_GOT_LOAD */ - addr += add_reloc(s, section, RL_GOTLOAD, 4); + addr += add_reloc(s, section, offset, RL_GOTLOAD, 4); } else { /* X86_64_RELOC_GOT */ - addr += add_reloc(s, section, RL_GOT, 4); + addr += add_reloc(s, section, offset, RL_GOT, 4); } + } else if (wrt == macho_tlvp_sect) { + addr += add_reloc(s, section, offset, RL_TLV, 4); } else { nasm_error(ERR_NONFATAL, "Mach-O format does not support" " this use of WRT"); @@ -593,7 +665,7 @@ static void macho_output(int32_t secto, const void *data, static int32_t macho_section(char *name, int pass, int *bits) { char *sectionAttributes; - struct sectmap *sm; + const struct sectmap *sm; struct section *s; const char *section, *segment; uint32_t flags; @@ -668,14 +740,12 @@ static int32_t macho_section(char *name, int pass, int *bits) if (!s) { new_seg = true; - s = *sectstail = nasm_malloc(sizeof(struct section)); - s->next = NULL; + s = *sectstail = nasm_zalloc(sizeof(struct section)); sectstail = &s->next; s->data = saa_init(1L); s->index = seg_alloc(); s->fileindex = ++seg_nsects; - s->relocs = NULL; s->align = -1; s->pad = -1; s->offset = -1; @@ -771,18 +841,18 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, return; } - if (name[0] == '.' && name[1] == '.' && name[2] != '@') { - /* - * This is a NASM special symbol. We never allow it into - * the Macho-O symbol table, even if it's a valid one. If it - * _isn't_ a valid one, we should barf immediately. - */ - if (strcmp(name, "..gotpcrel")) + if (name[0] == '.' && name[1] == '.' && name[2] != '@') { + /* + * This is a NASM special symbol. We never allow it into + * the Macho-O symbol table, even if it's a valid one. If it + * _isn't_ a valid one, we should barf immediately. + */ + if (strcmp(name, "..gotpcrel") && strcmp(name, "..tlvp")) nasm_error(ERR_NONFATAL, "unrecognized special symbol `%s'", name); - return; + return; } - sym = *symstail = nasm_malloc(sizeof(struct symbol)); + sym = *symstail = nasm_zalloc(sizeof(struct symbol)); sym->next = NULL; symstail = &sym->next; @@ -790,7 +860,7 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, sym->strx = strslen; sym->type = 0; sym->desc = 0; - sym->value = offset; + sym->symv.key = offset; sym->initial_snum = -1; /* external and common symbols get N_EXT */ @@ -803,15 +873,17 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, sym->type |= N_ABS; sym->sect = NO_SECT; } else { + struct section *s = get_section_by_index(section); + sym->type |= N_SECT; /* get the in-file index of the section the symbol was defined in */ - sym->sect = get_section_fileindex_by_index(section); + sym->sect = s ? s->fileindex : NO_SECT; /* track the initially allocated symbol number for use in future fix-ups */ sym->initial_snum = nsyms; - if (sym->sect == NO_SECT) { + if (!s) { /* remember symbol number of references to external ** symbols, this works because every external symbol gets ** its own section number allocated internally by nasm and @@ -823,7 +895,7 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, case 2: /* there isn't actually a difference between global ** and common symbols, both even have their size in - ** sym->value */ + ** sym->symv.key */ sym->type = N_EXT; break; @@ -832,8 +904,11 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, ** external or common symbol (assemble_file() does a ** seg_alloc() on every call for them) */ nasm_panic(0, "in-file index for section %d not found, is_global = %d", section, is_global); + break; } - } + } else if (is_global) { + s->gsyms = rb_insert(s->gsyms, &sym->symv); + } } ++nsyms; } @@ -1242,10 +1317,10 @@ static void macho_write_symtab (void) sizes. */ if (((sym->type & N_TYPE) == N_SECT) && (sym->sect != NO_SECT)) { nasm_assert(sym->sect <= seg_nsects); - sym->value += sectstab[sym->sect]->addr; + sym->symv.key += sectstab[sym->sect]->addr; } - fwriteptr(sym->value, ofile); /* value (i.e. offset) */ + fwriteptr(sym->symv.key, ofile); /* value (i.e. offset) */ } } @@ -1260,10 +1335,10 @@ static void macho_write_symtab (void) sizes. */ if (((sym->type & N_TYPE) == N_SECT) && (sym->sect != NO_SECT)) { nasm_assert(sym->sect <= seg_nsects); - sym->value += sectstab[sym->sect]->addr; + sym->symv.key += sectstab[sym->sect]->addr; } - fwriteptr(sym->value, ofile); /* value (i.e. offset) */ + fwriteptr(sym->symv.key, ofile); /* value (i.e. offset) */ } for (i = 0; i < nundefsym; i++) { @@ -1277,10 +1352,10 @@ static void macho_write_symtab (void) sizes. */ if (((sym->type & N_TYPE) == N_SECT) && (sym->sect != NO_SECT)) { nasm_assert(sym->sect <= seg_nsects); - sym->value += sectstab[sym->sect]->addr; + sym->symv.key += sectstab[sym->sect]->addr; } - fwriteptr(sym->value, ofile); /* value (i.e. offset) */ + fwriteptr(sym->symv.key, ofile); /* value (i.e. offset) */ } } @@ -1505,7 +1580,11 @@ static const struct macho_fmt macho32_fmt = { MACHO_HEADER_SIZE, MACHO_SEGCMD_SIZE, MACHO_SECTCMD_SIZE, - MACHO_NLIST_SIZE + MACHO_NLIST_SIZE, + RL_MAX_32, + GENERIC_RELOC_VANILLA, + GENERIC_RELOC_VANILLA, + GENERIC_RELOC_TLV }; static void macho32_init(void) @@ -1546,7 +1625,11 @@ static const struct macho_fmt macho64_fmt = { MACHO_HEADER64_SIZE, MACHO_SEGCMD64_SIZE, MACHO_SECTCMD64_SIZE, - MACHO_NLIST64_SIZE + MACHO_NLIST64_SIZE, + RL_MAX_64, + X86_64_RELOC_UNSIGNED, + X86_64_RELOC_SIGNED, + X86_64_RELOC_TLV }; static void macho64_init(void) @@ -1555,8 +1638,7 @@ static void macho64_init(void) macho_init(); /* add special symbol for ..gotpcrel */ - macho_gotpcrel_sect = seg_alloc(); - macho_gotpcrel_sect++; + macho_gotpcrel_sect = seg_alloc() + 1; define_label("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false); } |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 02:06:17
|
Commit-ID: 085a4a9f98861ed904b37dee1e4c7906a1bc0929 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=085a4a9f98861ed904b37dee1e4c7906a1bc0929 Author: H. Peter Anvin <hp...@li...> AuthorDate: Tue, 16 Feb 2016 18:04:39 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Tue, 16 Feb 2016 18:04:39 -0800 outmacho: fix the .rodata -> __TEXT,__const mapping For the mapping of .rodata to __TEXT,__const in the absence of relocations, it would help if we changed the segment name *before* we emit that part of the load command. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outmacho.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/output/outmacho.c b/output/outmacho.c index 24b4338..d2952b2 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -1074,6 +1074,24 @@ static uint32_t macho_write_segment (uint64_t offset) /* emit section headers */ for (s = sects; s != NULL; s = s->next) { + if (s->nreloc) { + nasm_assert((s->flags & SECTION_TYPE) != S_ZEROFILL); + s->flags |= S_ATTR_LOC_RELOC; + if (s->extreloc) + s->flags |= S_ATTR_EXT_RELOC; + } else if (!strcmp(s->segname, "__DATA") && + !strcmp(s->sectname, "__const") && + !s->by_name && + !get_section_by_name("__TEXT", "__const")) { + /* + * The MachO equivalent to .rodata can be either + * __DATA,__const or __TEXT,__const; the latter only if + * there are no relocations. However, when mixed it is + * better to specify the segments explicitly. + */ + xstrncpy(s->segname, "__TEXT"); + } + nasm_write(s->sectname, sizeof(s->sectname), ofile); nasm_write(s->segname, sizeof(s->segname), ofile); fwriteptr(s->addr, ofile); @@ -1101,23 +1119,6 @@ static uint32_t macho_write_segment (uint64_t offset) fwriteint32_t(0, ofile); } - if (s->nreloc) { - s->flags |= S_ATTR_LOC_RELOC; - if (s->extreloc) - s->flags |= S_ATTR_EXT_RELOC; - } else if (!strcmp(s->segname, "__DATA") && - !strcmp(s->sectname, "__const") && - !s->by_name && - !get_section_by_name("__TEXT", "__const")) { - /* - * The MachO equivalent to .rodata can be either - * __DATA,__const or __TEXT,__const; the latter only if - * there are no relocations. However, when mixed it is - * better to specify the segments explicitly. - */ - xstrncpy(s->segname, "__TEXT"); - } - fwriteint32_t(s->flags, ofile); /* flags */ fwriteint32_t(0, ofile); /* reserved */ fwriteptr(0, ofile); /* reserved */ |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 01:57:39
|
Commit-ID: 82a3082d643e2bf8da91bb178fa639eb494be4d6 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=82a3082d643e2bf8da91bb178fa639eb494be4d6 Author: H. Peter Anvin <hp...@li...> AuthorDate: Tue, 16 Feb 2016 17:46:18 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Tue, 16 Feb 2016 17:47:25 -0800 raa: move private parts of the implementation into raa.c Move the private aspects of the implementation into raa.c instead of exposing it to raa.h. Signed-off-by: H. Peter Anvin <hp...@li...> --- raa.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ raa.h | 45 +-------------------------------------------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/raa.c b/raa.c index be912a4..a9ed830 100644 --- a/raa.c +++ b/raa.c @@ -34,6 +34,51 @@ #include "nasmlib.h" #include "raa.h" +/* + * Routines to manage a dynamic random access array of int64_ts which + * may grow in size to be more than the largest single malloc'able + * chunk. + */ + +#define RAA_BLKSHIFT 15 /* 2**this many longs allocated at once */ +#define RAA_BLKSIZE (1 << RAA_BLKSHIFT) +#define RAA_LAYERSHIFT 15 /* 2**this many _pointers_ allocated */ +#define RAA_LAYERSIZE (1 << RAA_LAYERSHIFT) + +typedef struct RAA RAA; +typedef union RAA_UNION RAA_UNION; +typedef struct RAA_LEAF RAA_LEAF; +typedef struct RAA_BRANCH RAA_BRANCH; + +struct RAA { + /* + * Number of layers below this one to get to the real data. 0 + * means this structure is a leaf, holding RAA_BLKSIZE real + * data items; 1 and above mean it's a branch, holding + * RAA_LAYERSIZE pointers to the next level branch or leaf + * structures. + */ + int layers; + + /* + * Number of real data items spanned by one position in the + * `data' array at this level. This number is 0 trivially, for + * a leaf (level 0): for a level 1 branch it should be + * RAA_BLKSHIFT, and for a level 2 branch it's + * RAA_LAYERSHIFT+RAA_BLKSHIFT. + */ + int shift; + + union RAA_UNION { + struct RAA_LEAF { + int64_t data[RAA_BLKSIZE]; + } l; + struct RAA_BRANCH { + struct RAA *data[RAA_LAYERSIZE]; + } b; + } u; +}; + #define LEAFSIZ (sizeof(RAA)-sizeof(RAA_UNION)+sizeof(RAA_LEAF)) #define BRANCHSIZ (sizeof(RAA)-sizeof(RAA_UNION)+sizeof(RAA_BRANCH)) diff --git a/raa.h b/raa.h index d47f84c..22c4537 100644 --- a/raa.h +++ b/raa.h @@ -36,50 +36,7 @@ #include "compiler.h" -/* - * Routines to manage a dynamic random access array of int64_ts which - * may grow in size to be more than the largest single malloc'able - * chunk. - */ - -#define RAA_BLKSHIFT 15 /* 2**this many longs allocated at once */ -#define RAA_BLKSIZE (1 << RAA_BLKSHIFT) -#define RAA_LAYERSHIFT 15 /* 2**this many _pointers_ allocated */ -#define RAA_LAYERSIZE (1 << RAA_LAYERSHIFT) - -typedef struct RAA RAA; -typedef union RAA_UNION RAA_UNION; -typedef struct RAA_LEAF RAA_LEAF; -typedef struct RAA_BRANCH RAA_BRANCH; - -struct RAA { - /* - * Number of layers below this one to get to the real data. 0 - * means this structure is a leaf, holding RAA_BLKSIZE real - * data items; 1 and above mean it's a branch, holding - * RAA_LAYERSIZE pointers to the next level branch or leaf - * structures. - */ - int layers; - - /* - * Number of real data items spanned by one position in the - * `data' array at this level. This number is 0 trivially, for - * a leaf (level 0): for a level 1 branch it should be - * RAA_BLKSHIFT, and for a level 2 branch it's - * RAA_LAYERSHIFT+RAA_BLKSHIFT. - */ - int shift; - - union RAA_UNION { - struct RAA_LEAF { - int64_t data[RAA_BLKSIZE]; - } l; - struct RAA_BRANCH { - struct RAA *data[RAA_LAYERSIZE]; - } b; - } u; -}; +struct RAA; struct RAA *raa_init(void); void raa_free(struct RAA *); |