diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile.in | 77 | ||||
-rw-r--r-- | Mkfiles/msvc.mak | 1 | ||||
-rw-r--r-- | Mkfiles/netware.mak | 1 | ||||
-rw-r--r-- | Mkfiles/openwcom.mak | 1 | ||||
-rw-r--r-- | Mkfiles/owlinux.mak | 1 | ||||
-rw-r--r-- | aclocal.m4 | 45 | ||||
-rw-r--r-- | compiler.h | 29 | ||||
-rw-r--r-- | configure.in | 51 | ||||
-rw-r--r-- | eval.c | 28 | ||||
-rw-r--r-- | eval.h | 8 | ||||
-rw-r--r-- | ilog2.c | 7 | ||||
-rw-r--r-- | lib/strlcpy.c | 2 | ||||
-rw-r--r-- | nasm.c | 12 | ||||
-rw-r--r-- | nasm.h | 15 | ||||
-rw-r--r-- | nasmlib.c | 24 | ||||
-rw-r--r-- | nasmlib.h | 8 | ||||
-rw-r--r-- | output/codeview.c | 2 | ||||
-rw-r--r-- | output/nulldbg.c | 4 | ||||
-rw-r--r-- | output/outaout.c | 6 | ||||
-rw-r--r-- | output/outas86.c | 2 | ||||
-rw-r--r-- | output/outbin.c | 8 | ||||
-rw-r--r-- | output/outcoff.c | 12 | ||||
-rw-r--r-- | output/outdbg.c | 10 | ||||
-rw-r--r-- | output/outelf32.c | 141 | ||||
-rw-r--r-- | output/outelf64.c | 102 | ||||
-rw-r--r-- | output/outelfx32.c | 89 | ||||
-rw-r--r-- | output/outform.c | 20 | ||||
-rw-r--r-- | output/outform.h | 50 | ||||
-rw-r--r-- | output/outieee.c | 10 | ||||
-rw-r--r-- | output/outlib.h | 3 | ||||
-rw-r--r-- | output/outmacho.c | 4 | ||||
-rw-r--r-- | output/outobj.c | 10 | ||||
-rw-r--r-- | output/outrdf2.c | 2 | ||||
-rw-r--r-- | parser.c | 12 | ||||
-rw-r--r-- | parser.h | 1 | ||||
-rw-r--r-- | preproc-nop.c | 2 | ||||
-rw-r--r-- | preproc.c | 2 |
38 files changed, 417 insertions, 390 deletions
@@ -46,11 +46,8 @@ TAGS /insnsn.c /macros.c /nasm -/nasm.man -/nasm.1 /ndisasm -/ndisasm.man -/nasm.1 +/*.1 /pptok.c /pptok.h /pptok.ph diff --git a/Makefile.in b/Makefile.in index 4a5b3b08..44ceceb7 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@ @@ -91,7 +95,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) @@ -103,11 +106,11 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \ all: nasm$(X) ndisasm$(X) 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, @@ -116,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 nsis/version.nsh: version version.pl - $(PERL) $(srcdir)/version.pl nsis < $(srcdir)/version > nsis/version.nsh + $(RUNPERL) $(srcdir)/version.pl nsis < $(srcdir)/version > nsis/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). @@ -296,18 +299,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/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index 890ad43d..133087dd 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.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) diff --git a/Mkfiles/netware.mak b/Mkfiles/netware.mak index c3c8bf64..3d40c1c8 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 diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 7fb9ba51..58e11883 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) diff --git a/Mkfiles/owlinux.mak b/Mkfiles/owlinux.mak index b6ddad91..af7577d2 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) @@ -15,25 +15,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]))))]) @@ -72,15 +72,6 @@ #define __STDC_LIMIT_MACROS 1 #define __STDC_FORMAT_MACROS 1 -#ifdef __GNUC__ -# if __GNUC__ >= 4 -# define HAVE_GNUC_4 -# endif -# if __GNUC__ >= 3 -# define HAVE_GNUC_3 -# endif -#endif - /* Some versions of MSVC have these only with underscores in front */ #include <stddef.h> #include <stdarg.h> @@ -102,13 +93,31 @@ int vsnprintf(char *, size_t, const char *, va_list); # endif #endif +/* Missing fseeko/ftello */ +#ifndef HAVE_FSEEKO +# undef off_t /* Just in case it is a macro */ +# ifdef HAVE__FSEEKI64 +# define fseeko _fseeki64 +# define ftello _ftelli64 +# define off_t int64_t +# else +# define fseeko fseek +# define ftello ftell +# define off_t long +# endif +#endif + #if !defined(HAVE_STRLCPY) || !HAVE_DECL_STRLCPY 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 cbaebc4a..317fbe29 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -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.63) AC_INIT(config.h.in) @@ -51,6 +51,7 @@ dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE AC_PROG_CC +AC_PROG_CC_STDC AC_PROG_LN_S AC_PROG_MAKE_SET if test -f nasm.c; then @@ -66,7 +67,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 @@ -75,10 +75,8 @@ 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 Force gcc and gcc-compatible compilers treat signed integers +dnl as 2's complement PA_ADD_CFLAGS([-fwrapv]) dnl Look for programs... @@ -115,7 +113,10 @@ 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 <io.h> +AC_CHECK_HEADERS(io.h) dnl Look for <unistd.h> AC_CHECK_HEADERS(unistd.h) @@ -124,30 +125,15 @@ 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) @@ -157,6 +143,22 @@ AC_CHECK_FUNCS(canonicalize_file_name) AC_CHECK_FUNCS(_fullpath) AC_CHECK_FUNCS(pathconf) +AC_FUNC_FSEEKO +AC_CHECK_FUNCS([_fseeki64]) +AC_CHECK_FUNCS([ftruncate _chsize _chsize_s]) +AC_CHECK_FUNCS([fileno]) + +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]) + 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__) @@ -182,11 +184,16 @@ AC_ARG_ENABLE([ccache], [CC="ccache $CC"], []) +dnl If we have gcc, add appropriate code cleanliness options +PA_ADD_CFLAGS([-W]) +PA_ADD_CFLAGS([-Wall]) +PA_ADD_CFLAGS([-std=c99]) PA_ADD_CFLAGS([-pedantic]) dnl Suppress format warning on Windows targets due to their <inttypes.h> PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format]) PA_ADD_CFLAGS([-Wc90-c99-compat]) PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long]) +dnl PA_ADD_CFLAGS([-Wwrite-strings]) AC_ARG_ENABLE([werror], [AC_HELP_STRING([--enable-werror], [compile with -Werror to error out on any warning])], @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2012 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. * @@ -54,9 +54,6 @@ #define TEMPEXPR_DELTA 8 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; @@ -70,7 +67,6 @@ static struct tokenval *tokval; /* The current token */ static int i; /* The t_type of tokval */ static void *scpriv; -static struct location *location; /* Pointer to current line's segment,offset */ static int *opflags; static struct eval_hints *hint; @@ -241,7 +237,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), @@ -892,11 +888,11 @@ static expr *expr6(int critical) case TOKEN_HERE: case TOKEN_BASE: /* - * If !location->known, this indicates that no + * If !location.known, this indicates that no * symbol, Here or Base references are valid because we * are in preprocess-only mode. */ - if (!location->known) { + if (!location.known) { nasm_error(ERR_NONFATAL, "%s not supported in preprocess-only mode", (i == TOKEN_HERE ? "`$'" : @@ -908,13 +904,13 @@ static expr *expr6(int critical) type = EXPR_SIMPLE; /* might get overridden by UNKNOWN */ if (i == TOKEN_BASE) { - label_seg = in_abs_seg ? abs_seg : location->segment; + label_seg = in_abs_seg ? abs_seg : location.segment; label_ofs = 0; } else if (i == TOKEN_HERE) { - label_seg = in_abs_seg ? abs_seg : location->segment; - label_ofs = in_abs_seg ? abs_offset : location->offset; + label_seg = in_abs_seg ? abs_seg : location.segment; + label_ofs = in_abs_seg ? abs_offset : location.offset; } else { - if (!labelfunc(tokval->t_charptr, &label_seg, &label_ofs)) { + if (!lookup_label(tokval->t_charptr, &label_seg, &label_ofs)) { scope = local_scope(tokval->t_charptr); if (critical == 2) { nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined", @@ -953,14 +949,6 @@ static expr *expr6(int critical) } } -void eval_global_info(struct ofmt *output, lfunc lookup_label, - struct location * locp) -{ - outfmt = output; - labelfunc = lookup_label; - location = locp; -} - expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, int *fwref, int critical, struct eval_hints *hints) { @@ -39,14 +39,6 @@ #define NASM_EVAL_H /* - * Called once to tell the evaluator what output format is - * 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); - -/* * The evaluator itself. */ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, @@ -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 4335359c..22d9ccfb 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" /* @@ -101,8 +101,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 */ @@ -118,7 +118,7 @@ int64_t global_offset_changed; /* referenced in labels.c */ int64_t prev_offset_changed; int32_t stall_count; -static struct location location; +struct location location; int in_abs_seg; /* Flag we are in ABSOLUTE seg */ int32_t abs_seg; /* ABSOLUTE segment basis */ int32_t abs_offset; /* ABSOLUTE offset */ @@ -128,7 +128,7 @@ static struct RAA *offsets; static struct SAA *forwrefs; /* keep track of forward references */ static const struct forwrefinfo *forwref; -static struct preproc_ops *preproc; +static const struct preproc_ops *preproc; #define OP_NORMAL (1u << 0) #define OP_PREPROCESS (1u << 1) @@ -376,8 +376,6 @@ int main(int argc, char **argv) if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); - parser_global_info(&location); - eval_global_info(ofmt, lookup_label, &location); /* define some macros dependent of command-line */ define_macros_late(); @@ -631,7 +629,7 @@ enum text_options { OPT_PREFIX, OPT_POSTFIX }; -struct textargs textopts[] = { +static const struct textargs textopts[] = { {"prefix", OPT_PREFIX}, {"postfix", OPT_POSTFIX}, {NULL, 0} @@ -220,6 +220,7 @@ struct location { int32_t segment; int known; }; +extern struct location location; /* * Expression-evaluator datatype. Expressions, within the @@ -344,8 +345,8 @@ struct preproc_ops { void (*include_path)(char *path); }; -extern struct preproc_ops nasmpp; -extern struct preproc_ops preproc_nop; +extern const struct preproc_ops nasmpp; +extern const struct preproc_ops preproc_nop; /* * Some lexical properties of the NASM source language, included @@ -478,6 +479,10 @@ enum vex_class { * prefixes, we must ensure the enumerations for prefixes and * register names do not overlap. */ +#ifdef P_WAIT +# undef P_WAIT /* Macro defined on some Windows versions */ +#endif + enum prefixes { /* instruction prefixes */ P_none = 0, PREFIX_ENUM_START = REG_ENUM_LIMIT, @@ -682,7 +687,7 @@ struct ofmt { /* * this is a pointer to the first element of the debug information */ - struct dfmt **debug_formats; + const struct dfmt * const *debug_formats; /* * the default debugging format if -F is not specified @@ -848,10 +853,10 @@ struct ofmt { struct ofmt_alias { const char *shortname; const char *fullname; - struct ofmt *ofmt; + const struct ofmt *ofmt; }; -extern struct ofmt *ofmt; +extern const struct ofmt *ofmt; extern FILE *ofile; /* @@ -165,7 +165,7 @@ no_return nasm_assert_failed(const char *file, int line, const char *msg) void nasm_write(const void *ptr, size_t size, FILE *f) { size_t n = fwrite(ptr, 1, size, f); - if (n != size) + if (n != size || ferror(f) || feof(f)) nasm_fatal(0, "unable to write output: %s", strerror(errno)); } @@ -459,10 +459,32 @@ void fwriteaddr(uint64_t data, int size, FILE * fp) #endif +#ifdef HAVE_FILENO /* Useless without fileno() */ +# ifdef HAVE__CHSIZE_S +# define nasm_ftruncate(fd,size) _chsize_s(fd,size) +# elif defined(HAVE__CHSIZE) +# define nasm_ftruncate(fd,size) _chsize(fd,size) +# elif defined(HAVE_FTRUNCATE) +# define nasm_ftruncate(fd,size) ftruncate(fd,size) +# endif +#endif + void fwritezero(size_t bytes, FILE *fp) { size_t blksize; +#ifdef nasm_ftruncate + if (bytes >= BUFSIZ && !ferror(fp) && !feof(fp)) { + off_t pos = ftello(fp); + if (pos >= 0) { + if (!fflush(fp) && + !nasm_ftruncate(fileno(fp), pos + bytes) && + !fseeko(fp, pos+bytes, SEEK_SET)) + return; + } + } +#endif + while (bytes) { blksize = (bytes < ZERO_BUF_SIZE) ? bytes : ZERO_BUF_SIZE; @@ -44,7 +44,13 @@ #include <stdio.h> #include <string.h> #ifdef HAVE_STRINGS_H -#include <strings.h> +# include <strings.h> +#endif +#ifdef HAVE_IO_H +# include <io.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> #endif /* diff --git a/output/codeview.c b/output/codeview.c index f9750bfc..a63fd633 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -58,7 +58,7 @@ static void cv8_typevalue(int32_t type); static void cv8_output(int type, void *param); static void cv8_cleanup(void); -struct dfmt df_cv8 = { +const struct dfmt df_cv8 = { "Codeview 8", /* .fullname */ "cv8", /* .shortname */ cv8_init, /* .init */ diff --git a/output/nulldbg.c b/output/nulldbg.c index 581a1c55..e8f87d75 100644 --- a/output/nulldbg.c +++ b/output/nulldbg.c @@ -77,7 +77,7 @@ void null_debug_cleanup(void) { } -struct dfmt null_debug_form = { +const struct dfmt null_debug_form = { "Null debug format", "null", null_debug_init, @@ -89,4 +89,4 @@ struct dfmt null_debug_form = { null_debug_cleanup }; -struct dfmt *null_debug_arr[2] = { &null_debug_form, NULL }; +const struct dfmt * const null_debug_arr[2] = { &null_debug_form, NULL }; diff --git a/output/outaout.c b/output/outaout.c index b353600e..1ac7d5a1 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) { @@ -906,7 +906,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, @@ -930,7 +930,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 b69c1d34..920748c9 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -627,7 +627,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 ae07de4f..2b70b3b5 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -1403,7 +1403,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); @@ -1653,7 +1653,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, @@ -1673,7 +1673,7 @@ struct ofmt of_bin = { bin_cleanup }; -struct ofmt of_ith = { +const struct ofmt of_ith = { "Intel hex", "ith", OFMT_TEXT, @@ -1693,7 +1693,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 56d76674..13a556dd 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -1167,7 +1167,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, @@ -1189,13 +1189,13 @@ struct ofmt of_coff = { #endif -extern struct dfmt df_cv8; +extern const struct dfmt df_cv8; #ifdef OF_WIN32 -struct dfmt *win32_debug_arr[2] = { &df_cv8, NULL }; +static const struct dfmt * const win32_debug_arr[2] = { &df_cv8, NULL }; -struct ofmt of_win32 = { +const struct ofmt of_win32 = { "Microsoft Win32 (i386) object files", "win32", 0, @@ -1219,9 +1219,9 @@ struct ofmt of_win32 = { #ifdef OF_WIN64 -struct dfmt *win64_debug_arr[2] = { &df_cv8, NULL }; +static const struct dfmt * const 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 c68d1990..ef7f8a93 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; @@ -202,7 +202,7 @@ static int dbg_set_info(enum geninfo type, char **val) return 0; } -char *types[] = { +static const char * const types[] = { "unknown", "label", "byte", "word", "dword", "float", "qword", "tbyte" }; static void dbgdbg_init(void) @@ -241,7 +241,7 @@ static void dbgdbg_typevalue(int32_t type) fprintf(ofile, "new type: %s(%"PRIX32")\n", types[TYM_TYPE(type) >> 3], TYM_ELEMENTS(type)); } -static struct dfmt debug_debug_form = { +static const struct dfmt debug_debug_form = { "Trace of all info passed to debug stage", "debug", dbgdbg_init, @@ -253,13 +253,13 @@ static struct dfmt debug_debug_form = { dbgdbg_cleanup, }; -static struct dfmt *debug_debug_arr[3] = { +static const struct dfmt * const debug_debug_arr[3] = { &debug_debug_form, &null_debug_form, 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 b1596c90..8dbdadd9 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" @@ -83,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; @@ -153,27 +152,27 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; -static struct dfmt df_dwarf; -static struct dfmt df_stabs; +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ -static void debug32_typevalue(int32_t); +static void debug_typevalue(int32_t); /* 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 @@ -1011,7 +1010,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, @@ -1032,7 +1031,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); @@ -1328,32 +1327,33 @@ static int elf_set_info(enum geninfo type, char **val) (void)val; return 0; } -static struct dfmt df_dwarf = { +static const struct dfmt df_dwarf = { "ELF32 (i386) dwarf debug format for Linux/Unix", "dwarf", - dwarf32_init, - dwarf32_linenum, + dwarf_init, + dwarf_linenum, null_debug_deflabel, null_debug_directive, - debug32_typevalue, - dwarf32_output, - dwarf32_cleanup + debug_typevalue, + dwarf_output, + dwarf_cleanup }; -static struct dfmt df_stabs = { +static const struct dfmt df_stabs = { "ELF32 (i386) stabs debug format for Linux/Unix", "stabs", null_debug_init, - stabs32_linenum, + stabs_linenum, null_debug_deflabel, null_debug_directive, - debug32_typevalue, - stabs32_output, - stabs32_cleanup + debug_typevalue, + stabs_output, + stabs_cleanup }; -struct dfmt *elf32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; +static const struct dfmt * const 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, @@ -1375,33 +1375,7 @@ 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_typevalue(int32_t type) +static void debug_typevalue(int32_t type) { int32_t stype, ssize; switch (TYM_TYPE(type)) { @@ -1468,7 +1442,34 @@ static void debug32_typevalue(int32_t type) } } -static void stabs32_output(int type, void *param) +/* stabs debugging routines */ + +static void stabs_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 stabs_output(int type, void *param) { struct symlininfo *s; struct linelist *el; @@ -1499,7 +1500,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; @@ -1635,7 +1636,7 @@ static void stabs32_generate(void) stabstrbuf = ssbuf; } -static void stabs32_cleanup(void) +static void stabs_cleanup(void) { struct linelist *ptr, *del; if (!stabslines) @@ -1655,22 +1656,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; @@ -1686,7 +1687,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) @@ -1726,7 +1727,7 @@ static void dwarf32_output(int type, void *param) } -static void dwarf32_generate(void) +static void dwarf_generate(void) { uint8_t *pbuf; int indx; @@ -1959,7 +1960,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); @@ -1973,7 +1974,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; @@ -2010,7 +2011,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 878c8e49..03e50369 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; @@ -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; @@ -155,27 +154,27 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; -static struct dfmt df_dwarf; -static struct dfmt df_stabs; +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ -static void debug64_typevalue(int32_t); +static void debug_typevalue(int32_t); /* 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 @@ -589,8 +588,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 @@ -1095,7 +1094,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, @@ -1108,7 +1107,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) { @@ -1116,14 +1115,14 @@ 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); 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, @@ -1135,7 +1134,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, @@ -1147,7 +1146,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, @@ -1418,32 +1417,33 @@ static int elf_set_info(enum geninfo type, char **val) (void)val; return 0; } -static struct dfmt df_dwarf = { +static const struct dfmt df_dwarf = { "ELF64 (x86-64) dwarf debug format for Linux/Unix", "dwarf", - dwarf64_init, - dwarf64_linenum, + dwarf_init, + dwarf_linenum, null_debug_deflabel, null_debug_directive, - debug64_typevalue, - dwarf64_output, - dwarf64_cleanup + debug_typevalue, + dwarf_output, + dwarf_cleanup }; -static struct dfmt df_stabs = { +static const struct dfmt df_stabs = { "ELF64 (x86-64) stabs debug format for Linux/Unix", "stabs", null_debug_init, - stabs64_linenum, + stabs_linenum, null_debug_deflabel, null_debug_directive, - debug64_typevalue, - stabs64_output, - stabs64_cleanup + debug_typevalue, + stabs_output, + stabs_cleanup }; -struct dfmt *elf64_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; +static const struct dfmt * const 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, @@ -1464,7 +1464,7 @@ struct ofmt of_elf64 = { }; /* common debugging routines */ -static void debug64_typevalue(int32_t type) +static void debug_typevalue(int32_t type) { int32_t stype, ssize; switch (TYM_TYPE(type)) { @@ -1533,7 +1533,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) { @@ -1556,7 +1556,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; @@ -1587,7 +1587,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; @@ -1725,7 +1725,7 @@ static void stabs64_generate(void) stabstrbuf = ssbuf; } -static void stabs64_cleanup(void) +static void stabs_cleanup(void) { struct linelist *ptr, *del; if (!stabslines) @@ -1745,22 +1745,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; @@ -1776,7 +1776,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) @@ -1816,7 +1816,7 @@ static void dwarf64_output(int type, void *param) } -static void dwarf64_generate(void) +static void dwarf_generate(void) { uint8_t *pbuf; int indx; @@ -2051,7 +2051,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); @@ -2065,7 +2065,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; @@ -2102,7 +2102,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 5af5cfb0..a2a1e2a9 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; @@ -154,27 +154,27 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; -static struct dfmt df_dwarf; -static struct dfmt df_stabs; +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; static struct elf_symbol *lastsym; /* common debugging routines */ -static void debugx32_typevalue(int32_t); +static void debug_typevalue(int32_t); /* 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 @@ -1056,7 +1056,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, @@ -1077,7 +1077,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); @@ -1377,32 +1377,33 @@ static int elf_set_info(enum geninfo type, char **val) (void)val; return 0; } -static struct dfmt df_dwarf = { +static const struct dfmt df_dwarf = { "ELFX32 (x86-64) dwarf debug format for Linux/Unix", "dwarf", - dwarfx32_init, - dwarfx32_linenum, + dwarf_init, + dwarf_linenum, null_debug_deflabel, null_debug_directive, - debugx32_typevalue, - dwarfx32_output, - dwarfx32_cleanup + debug_typevalue, + dwarf_output, + dwarf_cleanup }; -static struct dfmt df_stabs = { +static const struct dfmt df_stabs = { "ELFX32 (x86-64) stabs debug format for Linux/Unix", "stabs", null_debug_init, - stabsx32_linenum, + stabs_linenum, null_debug_deflabel, null_debug_directive, - debugx32_typevalue, - stabsx32_output, - stabsx32_cleanup + debug_typevalue, + stabs_output, + stabs_cleanup }; -struct dfmt *elfx32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL }; +static const struct dfmt * const 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, @@ -1423,7 +1424,7 @@ struct ofmt of_elfx32 = { }; /* common debugging routines */ -static void debugx32_typevalue(int32_t type) +static void debug_typevalue(int32_t type) { int32_t stype, ssize; switch (TYM_TYPE(type)) { @@ -1492,7 +1493,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) { @@ -1515,7 +1516,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; @@ -1546,7 +1547,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; @@ -1681,7 +1682,7 @@ static void stabsx32_generate(void) stabstrbuf = ssbuf; } -static void stabsx32_cleanup(void) +static void stabs_cleanup(void) { struct linelist *ptr, *del; if (!stabslines) @@ -1701,22 +1702,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; @@ -1732,7 +1733,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) @@ -1772,7 +1773,7 @@ static void dwarfx32_output(int type, void *param) } -static void dwarfx32_generate(void) +static void dwarf_generate(void) { uint8_t *pbuf; int indx; @@ -2007,7 +2008,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); @@ -2021,7 +2022,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; @@ -2058,7 +2059,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; diff --git a/output/outform.c b/output/outform.c index 17744bb2..f7c817e7 100644 --- a/output/outform.c +++ b/output/outform.c @@ -47,9 +47,11 @@ #define BUILD_DRIVERS_ARRAY #include "output/outform.h" -struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias) +const struct ofmt *ofmt_find(const char *name, + const struct ofmt_alias **ofmt_alias) { - struct ofmt **ofp, *of; + const struct ofmt * const *ofp; + const struct ofmt *of; unsigned int i; *ofmt_alias = NULL; @@ -72,9 +74,10 @@ struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias) return NULL; } -struct dfmt *dfmt_find(struct ofmt *ofmt, const char *name) +const struct dfmt *dfmt_find(const struct ofmt *ofmt, const char *name) { - struct dfmt **dfp, *df; + const struct dfmt * const *dfp; + const struct dfmt *df; for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) { if (!nasm_stricmp(name, df->shortname)) @@ -83,9 +86,9 @@ struct dfmt *dfmt_find(struct ofmt *ofmt, const 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 * const *ofp, *of; unsigned int i; /* primary targets first */ @@ -105,9 +108,10 @@ 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; + const struct dfmt * const *dfp; + const struct dfmt *df; for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) { fprintf(fp, " %c %-10s%s\n", diff --git a/output/outform.h b/output/outform.h index e34ef752..5d30d645 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 * const 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 *, const char *); -void ofmt_list(struct ofmt *, FILE *); -void dfmt_list(struct ofmt *ofmt, FILE * fp); -extern struct dfmt null_debug_form; +const struct ofmt *ofmt_find(const char *name, const struct ofmt_alias **ofmt_alias); +const struct dfmt *dfmt_find(const struct ofmt *, const char *); +void ofmt_list(const struct ofmt *, FILE *); +void dfmt_list(const struct ofmt *ofmt, FILE * fp); +extern const struct dfmt null_debug_form; #endif /* NASM_OUTFORM_H */ diff --git a/output/outieee.c b/output/outieee.c index eb4bcf41..a7c5aa73 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -184,8 +184,8 @@ struct ieeeFixupp { static int32_t ieee_entry_seg, ieee_entry_ofs; static int checksum; -extern struct ofmt of_ieee; -static struct dfmt ladsoft_debug_form; +extern const struct ofmt of_ieee; +static const struct dfmt ladsoft_debug_form; static void ieee_data_new(struct ieeeSection *); static void ieee_write_fixup(int32_t, int32_t, struct ieeeSection *, @@ -1495,7 +1495,7 @@ static void dbgls_output(int output_type, void *param) (void)output_type; (void)param; } -static struct dfmt ladsoft_debug_form = { +static const struct dfmt ladsoft_debug_form = { "LADsoft Debug Records", "ladsoft", dbgls_init, @@ -1506,12 +1506,12 @@ static struct dfmt ladsoft_debug_form = { dbgls_output, dbgls_cleanup, }; -static struct dfmt *ladsoft_debug_arr[3] = { +static const struct dfmt * const ladsoft_debug_arr[3] = { &ladsoft_debug_form, &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 29c27a09..c66dbf6b 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); @@ -54,7 +53,7 @@ void null_debug_directive(const char *directive, const char *params); void null_debug_typevalue(int32_t type); void null_debug_output(int type, void *param); void null_debug_cleanup(void); -extern struct dfmt *null_debug_arr[2]; +extern const struct dfmt * const null_debug_arr[2]; #endif /* NASM_OUTLIB_H */ diff --git a/output/outmacho.c b/output/outmacho.c index 26a62ea6..5897469a 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -1614,7 +1614,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, @@ -1661,7 +1661,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 c82b5c26..e8fef6e5 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -624,8 +624,8 @@ static struct ExpDef { static int32_t obj_entry_seg, obj_entry_ofs; -struct ofmt of_obj; -static struct dfmt borland_debug_form; +const struct ofmt of_obj; +static const struct dfmt borland_debug_form; /* The current segment */ static struct Segment *current_seg; @@ -2604,7 +2604,7 @@ static void dbgbi_output(int output_type, void *param) (void)output_type; (void)param; } -static struct dfmt borland_debug_form = { +static const struct dfmt borland_debug_form = { "Borland Debug Records", "borland", dbgbi_init, @@ -2616,13 +2616,13 @@ static struct dfmt borland_debug_form = { dbgbi_cleanup, }; -static struct dfmt *borland_debug_arr[3] = { +static const struct dfmt * const borland_debug_arr[3] = { &borland_debug_form, &null_debug_form, 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 960acb45..a427ebb1 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -773,7 +773,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, @@ -61,12 +61,6 @@ static int is_comma_next(void); static int i; static struct tokenval tokval; -static struct location *location; /* Pointer to current line's segment,offset */ - -void parser_global_info(struct location * locp) -{ - location = locp; -} static int prefix_slot(int prefix) { @@ -431,14 +425,14 @@ restart_parse: } if (i != TOKEN_INSN || tokval.t_integer != I_EQU) { /* - * FIXME: location->segment could be NO_SEG, in which case + * FIXME: location.segment could be NO_SEG, in which case * it is possible we should be passing 'abs_seg'. Look into this. * Work out whether that is *really* what we should be doing. * Generally fix things. I think this is right as it is, but * am still not certain. */ - ldef(result->label, in_abs_seg ? abs_seg : location->segment, - location->offset, NULL, true, false); + ldef(result->label, in_abs_seg ? abs_seg : location.segment, + location.offset, NULL, true, false); } } @@ -39,7 +39,6 @@ #ifndef NASM_PARSER_H #define NASM_PARSER_H -void parser_global_info(struct location *locp); insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef); void cleanup_insn(insn *instruction); diff --git a/preproc-nop.c b/preproc-nop.c index 8024cac2..c5835ea9 100644 --- a/preproc-nop.c +++ b/preproc-nop.c @@ -170,7 +170,7 @@ static void nop_include_path(char *path) (void)path; } -struct preproc_ops preproc_nop = { +const struct preproc_ops preproc_nop = { nop_reset, nop_getline, nop_cleanup, @@ -5237,7 +5237,7 @@ static void make_tok_num(Token * tok, int64_t val) tok->type = TOK_NUMBER; } -struct preproc_ops nasmpp = { +const struct preproc_ops nasmpp = { pp_reset, pp_getline, pp_cleanup, |