+++ /dev/null
-# $IdPath$
-#
-# Ultra-flat Makefile for DJGPP.
-# Does NOT depend on or use configure.
-#
-# Works for simple build but *not* for development (no clean, dist, etc).
-# Also, WARNING, no header dependencies are included!
-#
-# How to compile:
-# make -fMkfiles/Makefile.dj
-
-CFLAGS=-DHAVE_CONFIG_H -IMkfiles/dj -I. -Isrc -Isrc/arch/x86
-CC=gcc
-
-all: yasm
-
-YASM_BASE_OBJS= \
- src/bytecode.o \
- src/expr.o \
- src/symrec.o \
- src/globals.o \
- src/file.o \
- src/section.o \
- src/arch.o \
- src/objfmt.o \
- src/preproc.o \
- src/parser.o \
- src/intnum.o \
- src/floatnum.o \
- src/hamt.o \
- src/bitvect.o \
- src/valparam.o \
- src/xmalloc.o \
- src/xstrdup.o \
- src/strcasecmp.o
-
-YASM_ARCH_OBJS= \
- src/arch/x86/x86arch.o \
- src/arch/x86/x86bc.o \
- src/arch/x86/x86expr.o
-
-YASM_PARSER_OBJS= \
- src/parsers/nasm/nasm-parser.o \
- nasm-bison.o \
- nasm-token.o
-
-YASM_PREPROC_OBJS= \
- src/preprocs/raw/raw-preproc.o \
- src/preprocs/yapp/yapp-preproc.o \
- yapp-token.o
-
-YASM_OPTIMIZER_OBJS= \
- src/optimizers/basic/basic-optimizer.o
-
-YASM_OBJFMT_OBJS= \
- src/objfmts/dbg/dbg-objfmt.o \
- src/objfmts/bin/bin-objfmt.o
-
-YASM_OBJS= \
- src/main.o \
- src/errwarn.o \
- src/options.o \
- $(YASM_BASE_OBJS) \
- $(YASM_ARCH_OBJS) \
- $(YASM_PARSER_OBJS) \
- $(YASM_PREPROC_OBJS) \
- $(YASM_OPTIMIZER_OBJS) \
- $(YASM_OBJFMT_OBJS) \
- mergesort.o
-
-yasm: $(YASM_OBJS)
- $(CC) -o yasm $(YASM_OBJS)
-
-.c.o:
- $(CC) -c $(CFLAGS) -o $@ $<
-
+++ /dev/null
-# $IdPath$
-#
-# Ultra-flat Makefile "prototype" for non-Unix platforms.
-# Does NOT depend on or use configure.
-#
-# Works for simple build but *not* for development (no clean, dist, etc).
-# Also, WARNING, no header dependencies are included!
-#
-# Problem to fix: to simplify this file, we probably want subdir Makefiles
-# included into this one? But include directives vary between Make versions.
-# Should bison/flex/perl rules even be included in this if it's not for
-# development use?
-#
-# NOTE: Needs a valid config.h for the platform being compiled on.
-#
-# This file should be customized to particular platforms by changing CC and
-# CFLAGS appropriately, along with writing a config.h for the platform.
-
-CFLAGS=-DHAVE_CONFIG_H -IMkfiles -I. -Isrc -Isrc/arch/x86
-CC=gcc
-BISON=bison
-FLEX=flex
-PERL=perl
-
-all: src/yasm
-
-YASM_BASE_OBJS= \
- src/bytecode.o \
- src/expr.o \
- src/symrec.o \
- src/globals.o \
- src/file.o \
- src/section.o \
- src/arch.o \
- src/objfmt.o \
- src/preproc.o \
- src/parser.o \
- src/intnum.o \
- src/floatnum.o \
- src/hamt.o \
- src/bitvect.o \
- src/valparam.o \
- src/xmalloc.o \
- src/xstrdup.o \
- src/strcasecmp.o
-
-YASM_ARCH_OBJS= \
- src/arch/x86/x86arch.o \
- src/arch/x86/x86bc.o \
- src/arch/x86/x86expr.o
-
-YASM_PARSER_OBJS= \
- src/parsers/nasm/nasm-parser.o \
- nasm-bison.o \
- nasm-token.o
-
-YASM_PREPROC_OBJS= \
- src/preprocs/raw/raw-preproc.o \
- src/preprocs/yapp/yapp-preproc.o \
- yapp-token.o
-
-YASM_OPTIMIZER_OBJS= \
- src/optimizers/basic/basic-optimizer.o
-
-YASM_OBJFMT_OBJS= \
- src/objfmts/dbg/dbg-objfmt.o \
- src/objfmts/bin/bin-objfmt.o
-
-YASM_OBJS= \
- src/main.o \
- src/errwarn.o \
- src/options.o \
- $(YASM_BASE_OBJS) \
- $(YASM_ARCH_OBJS) \
- $(YASM_PARSER_OBJS) \
- $(YASM_PREPROC_OBJS) \
- $(YASM_OPTIMIZER_OBJS) \
- $(YASM_OBJFMT_OBJS) \
- mergesort.o
-
-src/yasm: $(YASM_OBJS)
- $(CC) -o src/yasm $(YASM_OBJS)
-
-# This is broken: it produces an invalid bison.h
-nasm-bison.c: nasm-bison.y
- $(BISON) -d --name-prefix=nasm_parser_ -o $@ $<
-
-nasm-token.c: nasm-token.l
- $(FLEX) -Pnasm_parser_ -o$@ $<
-
-nasm-bison.y nasm-token.l: src/arch/x86/instrs.dat src/parsers/nasm/bison.y.in src/parsers/nasm/token.l.in src/parsers/nasm/gen_instr.pl
- $(PERL) src/parsers/nasm/gen_instr.pl -i src/arch/x86/instrs.dat -t nasm-token.l -g nasm-bison.y
-
-yapp-token.c: src/preprocs/yapp/yapp-token.l
- $(FLEX) -Pyapp_parser_ -o$@ $<
-
-.c.o:
- $(CC) -c $(CFLAGS) -o $@ $<
-
+++ /dev/null
-# $IdPath$\r
-#\r
-# Ultra-flat Makefile for Visual C++.\r
-# Does NOT depend on or use configure.\r
-#\r
-# Works for simple build but *not* for development (no clean, dist, etc).\r
-# Also, WARNING, no header dependencies are included!\r
-#\r
-# How to compile:\r
-# nmake -fMkfiles/Makefile.vc\r
-\r
-CFLAGS=/DHAVE_CONFIG_H /IMkfiles/vc /I. /Isrc /Isrc/arch/x86\r
-CC=cl\r
-\r
-all: yasm.exe\r
-\r
-YASM_BASE_OBJS= \\r
- src/bytecode.obj \\r
- src/expr.obj \\r
- src/symrec.obj \\r
- src/globals.obj \\r
- src/file.obj \\r
- src/section.obj \\r
- src/arch.obj \\r
- src/objfmt.obj \\r
- src/preproc.obj \\r
- src/parser.obj \\r
- src/intnum.obj \\r
- src/floatnum.obj \\r
- src/hamt.obj \\r
- src/bitvect.obj \\r
- src/valparam.obj \\r
- src/xmalloc.obj \\r
- src/xstrdup.obj \\r
- src/strcasecmp.obj\r
-\r
-YASM_ARCH_OBJS= \\r
- src/arch/x86/x86arch.obj \\r
- src/arch/x86/x86bc.obj \\r
- src/arch/x86/x86expr.obj\r
-\r
-YASM_PARSER_OBJS= \\r
- src/parsers/nasm/nasm-parser.obj \\r
- nasm-bison.obj \\r
- nasm-token.obj\r
-\r
-YASM_PREPROC_OBJS= \\r
- src/preprocs/raw/raw-preproc.obj \\r
- src/preprocs/yapp/yapp-preproc.obj \\r
- yapp-token.obj\r
-\r
-YASM_OPTIMIZER_OBJS= \\r
- src/optimizers/basic/basic-optimizer.obj\r
-\r
-YASM_OBJFMT_OBJS= \\r
- src/objfmts/dbg/dbg-objfmt.obj \\r
- src/objfmts/bin/bin-objfmt.obj\r
-\r
-YASM_OBJS= \\r
- src/main.obj \\r
- src/errwarn.obj \\r
- src/options.obj \\r
- $(YASM_BASE_OBJS) \\r
- $(YASM_ARCH_OBJS) \\r
- $(YASM_PARSER_OBJS) \\r
- $(YASM_PREPROC_OBJS) \\r
- $(YASM_OPTIMIZER_OBJS) \\r
- $(YASM_OBJFMT_OBJS) \\r
- mergesort.obj\r
-\r
-yasm.exe: $(YASM_OBJS)\r
- $(CC) /Feyasm.exe $(YASM_OBJS)\r
-\r
-.c.obj:\r
- $(CC) /c $(CFLAGS) /Fo$@ $<\r
-\r
+++ /dev/null
-#!/usr/bin/perl
-my @sourcelines = <>;
-my %usedlabel;
-for (@sourcelines) {
- $usedlabel{"$1:"} = "$1:" if m/goto\s+(yy[0-9]*)\s*;/
-}
-for (@sourcelines) {
- s/^(yy[0-9]*:)/$usedlabel{$1}/;
- print;
-}
COPYING.LIB-2.0 \
splint.sh \
Mkfiles/Makefile.flat \
- Mkfiles/Makefile.dj Mkfiles/dj/config.h \
- Mkfiles/Makefile.vc Mkfiles/vc/config.h
+ Mkfiles/Makefile.dj Mkfiles/dj/libyasm/config.h \
+ Mkfiles/vc/yasm-module.c \
+ Mkfiles/vc/yasm.dep \
+ Mkfiles/vc/yasm.dsp \
+ Mkfiles/vc/yasm.dsw \
+ Mkfiles/vc/yasm.mak \
+ Mkfiles/vc/libyasm/config.h \
+ Mkfiles/vc/libyasm/libyasm.dep \
+ Mkfiles/vc/libyasm/libyasm.dsp \
+ Mkfiles/vc/libyasm/libyasm.mak \
+ Mkfiles/vc/modules/modules.dep \
+ Mkfiles/vc/modules/modules.dsp \
+ Mkfiles/vc/modules/modules.mak
# Until this gets fixed in automake
DISTCLEANFILES = libyasm/stamp-h libyasm/stamp-h[0-9]*
--- /dev/null
+# $IdPath$
+#
+# Ultra-flat Makefile for DJGPP (also works for Cygwin).
+# Does NOT depend on or use configure.
+#
+# Works for simple build but *not* for development (no clean, dist, etc).
+# Also, WARNING, no header dependencies are included!
+#
+# How to compile:
+# make -fMkfiles/Makefile.dj
+
+CFLAGS=-DHAVE_CONFIG_H -DWIN32 -IMkfiles/dj -I. -Ifrontends/yasm
+CC=gcc
+
+all: yasm
+
+LIBYASM_OBJS= \
+ libyasm/arch.o \
+ libyasm/bitvect.o \
+ libyasm/bytecode.o \
+ libyasm/errwarn.o \
+ libyasm/expr.o \
+ libyasm/file.o \
+ libyasm/floatnum.o \
+ libyasm/hamt.o \
+ libyasm/intnum.o \
+ libyasm/linemgr.o \
+ libyasm/mergesort.o \
+ libyasm/section.o \
+ libyasm/strcasecmp.o \
+ libyasm/strsep.o \
+ libyasm/symrec.o \
+ libyasm/valparam.o \
+ libyasm/xmalloc.o \
+ libyasm/xstrdup.o
+
+MODULES_ARCH_OBJS= \
+ modules/arch/x86/x86arch.o \
+ modules/arch/x86/x86bc.o \
+ modules/arch/x86/x86expr.o \
+ x86id.o
+
+MODULES_DBGFMTS_OBJS= \
+ modules/dbgfmts/null/null-dbgfmt.o
+
+MODULES_OBJFMTS_OBJS= \
+ modules/objfmts/dbg/dbg-objfmt.o \
+ modules/objfmts/bin/bin-objfmt.o \
+ modules/objfmts/coff/coff-objfmt.o
+
+MODULES_OPTIMIZERS_OBJS= \
+ modules/optimizers/basic/basic-optimizer.o
+
+MODULES_PARSERS_OBJS= \
+ modules/parsers/nasm/nasm-parser.o \
+ nasm-bison.o \
+ nasm-token.o
+
+MODULES_PREPROCS_NASM_OBJS= \
+ modules/preprocs/nasm/nasm-eval.o \
+ modules/preprocs/nasm/nasm-pp.o \
+ modules/preprocs/nasm/nasm-preproc.o \
+ modules/preprocs/nasm/nasmlib.o \
+ nasm-macros.o
+
+MODULES_PREPROCS_YAPP_OBJS = \
+ modules/preprocs/yapp/yapp-preproc.o \
+ yapp-token.o
+
+MODULES_PREPROCS_RAW_OBJS = \
+ modules/preprocs/raw/raw-preproc.o \
+
+MODULES_PREPROCS_OBJS = \
+ $(MODULES_PREPROCS_NASM_OBJS) \
+ $(MODULES_PREPROCS_YAPP_OBJS) \
+ $(MODULES_PREPROCS_RAW_OBJS)
+
+MODULES_OBJS = \
+ $(MODULES_ARCH_OBJS) \
+ $(MODULES_DBGFMTS_OBJS) \
+ $(MODULES_OBJFMTS_OBJS) \
+ $(MODULES_OPTIMIZERS_OBJS) \
+ $(MODULES_PARSERS_OBJS) \
+ $(MODULES_PREPROCS_OBJS)
+
+YASM_OBJS= \
+ frontends/yasm/yasm.o \
+ Mkfiles/vc/yasm-module.o \
+ frontends/yasm/yasm-options.o \
+ $(LIBYASM_OBJS) \
+ $(MODULES_OBJS)
+
+yasm: $(YASM_OBJS)
+ $(CC) -o yasm $(YASM_OBJS)
+
+.c.o:
+ $(CC) -c $(CFLAGS) -o $@ $<
+
--- /dev/null
+# $IdPath$
+#
+# Ultra-flat Makefile "prototype" for non-Unix platforms.
+# Does NOT depend on or use configure.
+#
+# Works for simple build but *not* for development (no clean, dist, etc).
+# Also, WARNING, no header dependencies are included!
+#
+# NOTE: Needs a valid config.h for the platform being compiled on.
+#
+# This file should be customized to particular platforms by changing CC and
+# CFLAGS appropriately, along with writing a config.h for the platform and
+# placing it in a libyasm subdirectory.
+
+CFLAGS=-DHAVE_CONFIG_H -DWIN32 -IMkfiles -I. -Ifrontends/yasm
+CC=gcc
+
+all: yasm
+
+LIBYASM_OBJS= \
+ libyasm/arch.o \
+ libyasm/bitvect.o \
+ libyasm/bytecode.o \
+ libyasm/errwarn.o \
+ libyasm/expr.o \
+ libyasm/file.o \
+ libyasm/floatnum.o \
+ libyasm/hamt.o \
+ libyasm/intnum.o \
+ libyasm/linemgr.o \
+ libyasm/mergesort.o \
+ libyasm/section.o \
+ libyasm/strcasecmp.o \
+ libyasm/strsep.o \
+ libyasm/symrec.o \
+ libyasm/valparam.o \
+ libyasm/xmalloc.o \
+ libyasm/xstrdup.o
+
+MODULES_ARCH_OBJS= \
+ modules/arch/x86/x86arch.o \
+ modules/arch/x86/x86bc.o \
+ modules/arch/x86/x86expr.o \
+ x86id.o
+
+MODULES_DBGFMTS_OBJS= \
+ modules/dbgfmts/null/null-dbgfmt.o
+
+MODULES_OBJFMTS_OBJS= \
+ modules/objfmts/dbg/dbg-objfmt.o \
+ modules/objfmts/bin/bin-objfmt.o \
+ modules/objfmts/coff/coff-objfmt.o
+
+MODULES_OPTIMIZERS_OBJS= \
+ modules/optimizers/basic/basic-optimizer.o
+
+MODULES_PARSERS_OBJS= \
+ modules/parsers/nasm/nasm-parser.o \
+ nasm-bison.o \
+ nasm-token.o
+
+MODULES_PREPROCS_NASM_OBJS= \
+ modules/preprocs/nasm/nasm-eval.o \
+ modules/preprocs/nasm/nasm-pp.o \
+ modules/preprocs/nasm/nasm-preproc.o \
+ modules/preprocs/nasm/nasmlib.o \
+ nasm-macros.o
+
+MODULES_PREPROCS_YAPP_OBJS = \
+ modules/preprocs/yapp/yapp-preproc.o \
+ yapp-token.o
+
+MODULES_PREPROCS_RAW_OBJS = \
+ modules/preprocs/raw/raw-preproc.o \
+
+MODULES_PREPROCS_OBJS = \
+ $(MODULES_PREPROCS_NASM_OBJS) \
+ $(MODULES_PREPROCS_YAPP_OBJS) \
+ $(MODULES_PREPROCS_RAW_OBJS)
+
+MODULES_OBJS = \
+ $(MODULES_ARCH_OBJS) \
+ $(MODULES_DBGFMTS_OBJS) \
+ $(MODULES_OBJFMTS_OBJS) \
+ $(MODULES_OPTIMIZERS_OBJS) \
+ $(MODULES_PARSERS_OBJS) \
+ $(MODULES_PREPROCS_OBJS)
+
+YASM_OBJS= \
+ frontends/yasm/yasm.o \
+ Mkfiles/vc/yasm-module.o \
+ frontends/yasm/yasm-options.o \
+ $(LIBYASM_OBJS) \
+ $(MODULES_OBJS)
+
+yasm: $(YASM_OBJS)
+ $(CC) -o yasm $(YASM_OBJS)
+
+.c.o:
+ $(CC) -c $(CFLAGS) -o $@ $<
+
/* Define to 1 if you have the <assert.h> header file. */\r
/* #undef HAVE_ASSERT_H */\r
\r
-/* Define to 1 if you have the `basename' function. */\r
-#define HAVE_BASENAME 1\r
-\r
/* Define to 1 if you have the `bcopy' function. */\r
/* #undef HAVE_BCOPY */\r
\r
/* */\r
/* #undef HAVE_CATGETS */\r
\r
-/* Define to 1 if you have the `closedir' function. */\r
-/* #undef HAVE_CLOSEDIR */\r
-\r
/* Define to 1 if you have the <ctype.h> header file. */\r
#define HAVE_CTYPE_H 1\r
\r
/* Define if you have the <limits.h> header file. */\r
#define HAVE_LIMITS_H 1\r
\r
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and\r
- to 0 otherwise. */\r
+/* Define if your system has a working `malloc' function. */\r
#define HAVE_MALLOC 1\r
\r
/* Define if you have the <malloc.h> header file. */\r
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */\r
/* #undef HAVE_NDIR_H */\r
\r
-/* Define to 1 if you have the `opendir' function. */\r
-/* #undef HAVE_OPENDIR */\r
-\r
/* Define if libtool can extract symbol lists from object files. */\r
/* #undef HAVE_PRELOADED_SYMBOLS */\r
\r
-/* Define to 1 if you have the `readdir' function. */\r
-/* #undefine HAVE_READDIR */\r
-\r
/* Define to 1 if you have the `rindex' function. */\r
/* #undef HAVE_RINDEX */\r
\r
#define PACKAGE_NAME "yasm"\r
\r
/* Define to the full name and version of this package. */\r
-#define PACKAGE_STRING "yasm CVS"\r
+#define PACKAGE_STRING "yasm `date "+%Y%m%d"`"\r
\r
/* Define to the one symbol short name of this package. */\r
#define PACKAGE_TARNAME "yasm"\r
\r
/* Define to the version of this package. */\r
-#define PACKAGE_VERSION "CVS"\r
+#define PACKAGE_VERSION "`date "+%Y%m%d"`"\r
\r
/* Define if the C compiler supports function prototypes. */\r
#define PROTOTYPES 1\r
/* #undef USE_FORKWAITMSG */\r
\r
/* Version number of package */\r
-#define VERSION "CVS"\r
+#define VERSION "0.1.0"\r
\r
/* Define if using the dmalloc debugging malloc package */\r
/* #undef WITH_DMALLOC */\r
\r
+/* Define if `lex' declares `yytext' as a `char *' by default, not a `char[]'.\r
+ */\r
+#define YYTEXT_POINTER 1\r
+\r
/* Make sure we see all GNU extensions. */\r
/* #undef _GNU_SOURCE */\r
\r
if it is not supported. */\r
/* #undef inline */\r
\r
-/* Define to rpl_malloc if the replacement function should be used. */\r
-/* #undef malloc */\r
-\r
/* Define to `int' if <sys/types.h> doesn't define. */\r
/* #undef pid_t */\r
\r
--- /dev/null
+/* $IdPath$ */\r
+\r
+/* */\r
+/* #undef ENABLE_NLS */\r
+\r
+/* Define if you have the `abort' function. */\r
+#define HAVE_ABORT 1\r
+\r
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */\r
+/* #undef HAVE_ALLOCA_H */\r
+\r
+/* Define to 1 if you have the `argz_append' function. */\r
+/* #undef HAVE_ARGZ_APPEND */\r
+\r
+/* Define to 1 if you have the `argz_create_sep' function. */\r
+/* #undef HAVE_ARGZ_CREATE_SEP */\r
+\r
+/* Define if you have the <argz.h> header file. */\r
+/* #undef HAVE_ARGZ_H */\r
+\r
+/* Define to 1 if you have the `argz_insert' function. */\r
+/* #undef HAVE_ARGZ_INSERT */\r
+\r
+/* Define to 1 if you have the `argz_next' function. */\r
+/* #undef HAVE_ARGZ_NEXT */\r
+\r
+/* Define to 1 if you have the `argz_stringify' function. */\r
+/* #undef HAVE_ARGZ_STRINGIFY */\r
+\r
+/* Define to 1 if you have the <assert.h> header file. */\r
+/* #undef HAVE_ASSERT_H */\r
+\r
+/* Define to 1 if you have the `bcopy' function. */\r
+/* #undef HAVE_BCOPY */\r
+\r
+/* */\r
+/* #undef HAVE_CATGETS */\r
+\r
+/* Define to 1 if you have the <ctype.h> header file. */\r
+#define HAVE_CTYPE_H 1\r
+\r
+/* Define if the GNU dcgettext() function is already present or preinstalled.\r
+ */\r
+/* #undef HAVE_DCGETTEXT */\r
+\r
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.\r
+ */\r
+/* #undef HAVE_DIRENT_H */\r
+\r
+/* Define if you have the GNU dld library. */\r
+/* #undef HAVE_DLD */\r
+\r
+/* Define to 1 if you have the <dld.h> header file. */\r
+/* #undef HAVE_DLD_H */\r
+\r
+/* Define to 1 if you have the `dlerror' function. */\r
+/* #undef HAVE_DLERROR */\r
+\r
+/* Define to 1 if you have the <dlfcn.h> header file. */\r
+/* #undef HAVE_DLFCN_H */\r
+\r
+/* Define to 1 if you have the <dl.h> header file. */\r
+/* #undef HAVE_DL_H */\r
+\r
+/* Define if you don't have `vprintf' but do have `_doprnt'. */\r
+/* #undef HAVE_DOPRNT */\r
+\r
+/* Define to 1 if you have the <errno.h> header file. */\r
+#define HAVE_ERRNO_H 1\r
+\r
+/* Define to 1 if the system has the type `error_t'. */\r
+/* #undef HAVE_ERROR_T */\r
+\r
+/* Define if you have the `fork' function. */\r
+/* #undef HAVE_FORK */\r
+\r
+/* */\r
+/* #undef HAVE_GETTEXT */\r
+\r
+/* Define if you have the GNU C Library */\r
+/* #undef HAVE_GNU_C_LIBRARY */\r
+\r
+/* Define if you have the iconv() function. */\r
+/* #undef HAVE_ICONV */\r
+\r
+/* Define to 1 if you have the `index' function. */\r
+/* #undef HAVE_INDEX */\r
+\r
+/* Define if you have the <inttypes.h> header file. */\r
+/* #undef HAVE_INTTYPES_H */\r
+\r
+/* */\r
+/* #undef HAVE_LC_MESSAGES */\r
+\r
+/* Define if you have the libdl library or equivalent. */\r
+/* #undef HAVE_LIBDL */\r
+\r
+/* Define if you have the <limits.h> header file. */\r
+#define HAVE_LIMITS_H 1\r
+\r
+/* Define if your system has a working `malloc' function. */\r
+#define HAVE_MALLOC 1\r
+\r
+/* Define if you have the <malloc.h> header file. */\r
+#define HAVE_MALLOC_H 1\r
+\r
+/* Define if you have the `memcpy' function. */\r
+#define HAVE_MEMCPY 1\r
+\r
+/* Define if you have the `memmove' function. */\r
+#define HAVE_MEMMOVE 1\r
+\r
+/* Define if you have the <memory.h> header file. */\r
+#define HAVE_MEMORY_H 1\r
+\r
+/* Define if you have the `mergesort function. */\r
+/* #undef HAVE_MERGESORT */\r
+\r
+/* Define if you have the `msgctl' function. */\r
+/* #undef HAVE_MSGCTL */\r
+\r
+/* Define if you have the `msgget' function. */\r
+/* #undef HAVE_MSGGET */\r
+\r
+/* Define if you have the `msgrcv' function. */\r
+/* #undef HAVE_MSGRCV */\r
+\r
+/* Define if you have the `msgsnd' function. */\r
+/* #undef HAVE_MSGSND */\r
+\r
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */\r
+/* #undef HAVE_NDIR_H */\r
+\r
+/* Define if libtool can extract symbol lists from object files. */\r
+/* #undef HAVE_PRELOADED_SYMBOLS */\r
+\r
+/* Define to 1 if you have the `rindex' function. */\r
+/* #undef HAVE_RINDEX */\r
+\r
+/* Define if you have the shl_load function. */\r
+/* #undef HAVE_SHL_LOAD */\r
+\r
+/* Define if you have the `snprintf' function. */\r
+/* #undef HAVE_SNPRINTF */\r
+\r
+/* Define if you have the <stdint.h> header file. */\r
+#define HAVE_STDINT_H 1\r
+\r
+/* Define to 1 if you have the <stdio.h> header file. */\r
+#define HAVE_STDIO_H 1\r
+\r
+/* Define if you have the <stdlib.h> header file. */\r
+#define HAVE_STDLIB_H 1\r
+\r
+/* */\r
+#define HAVE_STPCPY 1\r
+\r
+/* Define if you have the `strcasecmp' function. */\r
+#define HAVE_STRCASECMP 1\r
+\r
+/* Define if you have the `strchr' function. */\r
+#define HAVE_STRCHR 1\r
+\r
+/* Define to 1 if you have the `strcmp' function. */\r
+#define HAVE_STRCMP 1\r
+\r
+/* Define if you have the `strcmpi' function. */\r
+/* #undef HAVE_STRCMPI */\r
+\r
+/* Define if you have the `strerror' function. */\r
+#define HAVE_STRERROR 1\r
+\r
+/* Define if you have the `stricmp' function. */\r
+/* #undef HAVE_STRICMP */\r
+\r
+/* Define if you have the <strings.h> header file. */\r
+#define HAVE_STRINGS_H 1\r
+\r
+/* Define if you have the <string.h> header file. */\r
+#define HAVE_STRING_H 1\r
+\r
+/* Define if you have the `strncasecmp' function. */\r
+#define HAVE_STRNCASECMP 1\r
+\r
+/* Define if you have the `strrchr' function. */\r
+#define HAVE_STRRCHR 1\r
+\r
+/* Define if you have the `strsep' function. */\r
+#define HAVE_STRSEP 1\r
+\r
+/* Define if you have the <sys/cdefs.h> header file. */\r
+#define HAVE_SYS_CDEFS_H 1\r
+\r
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.\r
+ */\r
+/* #undef HAVE_SYS_DIR_H */\r
+\r
+/* Define to 1 if you have the <sys/dl.h> header file. */\r
+/* #undef HAVE_SYS_DL_H */\r
+\r
+/* Define if you have the <sys/ipc.h> header file. */\r
+/* #undef HAVE_SYS_IPC_H */\r
+\r
+/* Define if you have the <sys/msg.h> header file. */\r
+/* #undef HAVE_SYS_MSG_H */\r
+\r
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.\r
+ */\r
+/* #undef HAVE_SYS_NDIR_H */\r
+\r
+/* Define if you have the <sys/param.h> header file. */\r
+#define HAVE_SYS_PARAM_H 1\r
+\r
+/* Define if you have the <sys/queue.h> header file. */\r
+/* #undef HAVE_SYS_QUEUE_H */\r
+\r
+/* Define if you have the <sys/stat.h> header file. */\r
+#define HAVE_SYS_STAT_H 1\r
+\r
+/* Define if you have the <sys/types.h> header file. */\r
+#define HAVE_SYS_TYPES_H 1\r
+\r
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */\r
+#define HAVE_SYS_WAIT_H 1\r
+\r
+/* Define if you have the `toascii' function. */\r
+#define HAVE_TOASCII 1\r
+\r
+/* Define if you have the <unistd.h> header file. */\r
+#define HAVE_UNISTD_H 1\r
+\r
+/* Define if you have the `vfork' function. */\r
+/* #undef HAVE_VFORK */\r
+\r
+/* Define if you have the <vfork.h> header file. */\r
+/* #undef HAVE_VFORK_H */\r
+\r
+/* Define if you have the vprintf function. */\r
+#define HAVE_VPRINTF 1\r
+\r
+/* Define to 1 if you have the `vsnprintf' function. */\r
+/* #undef HAVE_VSNPRINTF */\r
+\r
+/* Define if you have the `wait' function. */\r
+#define HAVE_WAIT 1\r
+\r
+/* Define if `fork' works. */\r
+/* #undef HAVE_WORKING_FORK */\r
+\r
+/* Define if `vfork' works. */\r
+/* #undef HAVE_WORKING_VFORK */\r
+\r
+/* Define if the OS needs help to load dependent libraries for dlopen(). */\r
+#define LTDL_DLOPEN_DEPLIBS 1\r
+\r
+/* Define to the sub-directory in which libtool stores uninstalled libraries.\r
+ */\r
+#define LTDL_OBJDIR ".libs/"\r
+\r
+/* Define to the name of the environment variable that determines the dynamic\r
+ library search path. */\r
+#define LTDL_SHLIBPATH_VAR "PATH"\r
+\r
+/* Define to the extension used for shared libraries, say, ".so". */\r
+#define LTDL_SHLIB_EXT ".dll"\r
+\r
+/* Define to the system default library search path. */\r
+#define LTDL_SYSSEARCHPATH "/lib:/usr/lib"\r
+\r
+/* Define if dlsym() requires a leading underscode in symbol names. */\r
+/* #undef NEED_USCORE */\r
+\r
+/* Name of package */\r
+#define PACKAGE "yasm"\r
+\r
+/* Define to the address where bug reports for this package should be sent. */\r
+#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"\r
+\r
+/* Define to the full name of this package. */\r
+#define PACKAGE_NAME "yasm"\r
+\r
+/* Define to the full name and version of this package. */\r
+#define PACKAGE_STRING "yasm `date "+%Y%m%d"`"\r
+\r
+/* Define to the one symbol short name of this package. */\r
+#define PACKAGE_TARNAME "yasm"\r
+\r
+/* Define to the version of this package. */\r
+#define PACKAGE_VERSION "`date "+%Y%m%d"`"\r
+\r
+/* Define if the C compiler supports function prototypes. */\r
+#define PROTOTYPES 1\r
+\r
+/* Define if you have the ANSI C header files. */\r
+#define STDC_HEADERS 1\r
+\r
+/* Combined test for fork/wait/msg* */\r
+/* #undef USE_FORKWAITMSG */\r
+\r
+/* Version number of package */\r
+#define VERSION "0.1.0"\r
+\r
+/* Define if using the dmalloc debugging malloc package */\r
+/* #undef WITH_DMALLOC */\r
+\r
+/* Define if `lex' declares `yytext' as a `char *' by default, not a `char[]'.\r
+ */\r
+#define YYTEXT_POINTER 1\r
+\r
+/* Make sure we see all GNU extensions. */\r
+/* #undef _GNU_SOURCE */\r
+\r
+/* Make sure we see all SVID extensions. */\r
+/* #undef _SVID_SOURCE */\r
+\r
+/* Define like PROTOTYPES; this can be used by system headers. */\r
+#define __PROTOTYPES 1\r
+\r
+/* Define to empty if `const' does not conform to ANSI C. */\r
+/* #undef const */\r
+\r
+/* Define to a type to use for `error_t' if it is not otherwise available. */\r
+#define error_t int\r
+\r
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing\r
+ if it is not supported. */\r
+/* #undef inline */\r
+\r
+/* Define to `int' if <sys/types.h> doesn't define. */\r
+/* #undef pid_t */\r
+\r
+/* Define to `unsigned' if <sys/types.h> doesn't define. */\r
+/* #undef size_t */\r
+\r
+/* Define as `fork' if `vfork' does not work. */\r
+/* #undef vfork */\r
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "yasm-module.h"
extern yasm_dbgfmt yasm_null_LTX_dbgfmt;
extern yasm_objfmt yasm_bin_LTX_objfmt;
extern yasm_objfmt yasm_coff_LTX_objfmt;
+extern yasm_objfmt yasm_win32_LTX_objfmt;
extern yasm_objfmt yasm_dbg_LTX_objfmt;
extern yasm_optimizer yasm_basic_LTX_optimizer;
extern yasm_parser yasm_nasm_LTX_parser;
{"null", "dbgfmt", &yasm_null_LTX_dbgfmt},
{"bin", "objfmt", &yasm_bin_LTX_objfmt},
{"coff", "objfmt", &yasm_coff_LTX_objfmt},
+ {"win32", "objfmt", &yasm_win32_LTX_objfmt},
{"dbg", "objfmt", &yasm_dbg_LTX_objfmt},
{"basic", "optimizer", &yasm_basic_LTX_optimizer},
{"nasm", "parser", &yasm_nasm_LTX_parser},
# Enable more warnings
if test "$GCC" = "yes"; then
- MORE_CFLAGS="$MORE_CFLAGS -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings"
+ MORE_CFLAGS="$MORE_CFLAGS -Waggregate-return -Wbad-function-cast -Wcast-align -Wcast-qual -Wconversion -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wsign-compare -Wstrict-prototypes -Wwrite-strings"
fi
# Require Perl
# Turn warnings into errors
if test "$warnerror" = "yes"; then
if test "$GCC" = "yes"; then
- MORE_CFLAGS="$MORE_CFLAGS -Werror"
+ MORE_CFLAGS="$MORE_CFLAGS -Wno-conversion -Werror"
fi
fi
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "ltdl.h"
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "yasm-options.h"
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#ifndef WIN32
# define YASM_MODULE_PATH_ENV "YASM_MODULE_PATH"
#endif
+#ifndef WIN32
+extern const lt_dlsymlist lt_preloaded_symbols[];
+#endif
+
/* Preprocess-only buffer size */
#define PREPROC_BUF_SIZE 16384
#endif
/* Initialize preloaded symbol lookup table. */
- LTDL_SET_PRELOADED_SYMBOLS();
+ lt_dlpreload_default(lt_preloaded_symbols);
/* Initialize libltdl. */
errors = lt_dlinit();
}
/* Write the object file */
- cur_objfmt->output(obj?obj:stderr, sections);
+ cur_objfmt->output(obj?obj:stderr, sections,
+ strcmp(cur_dbgfmt->keyword, "null"));
/* Close object file */
if (obj)
* (used when compiling the library itself)
*/
-#include "libyasm/util.h"
-#include "libyasm/linemgr.h"
+#include <libyasm/util.h>
+#include <libyasm/linemgr.h>
-#include "libyasm/errwarn.h"
-#include "libyasm/intnum.h"
-#include "libyasm/floatnum.h"
-#include "libyasm/expr.h"
-#include "libyasm/symrec.h"
+#include <libyasm/errwarn.h>
+#include <libyasm/intnum.h>
+#include <libyasm/floatnum.h>
+#include <libyasm/expr.h>
+#include <libyasm/symrec.h>
-#include "libyasm/bytecode.h"
-#include "libyasm/section.h"
+#include <libyasm/bytecode.h>
+#include <libyasm/section.h>
-#include "libyasm/arch.h"
-#include "libyasm/dbgfmt.h"
-#include "libyasm/objfmt.h"
-#include "libyasm/optimizer.h"
-#include "libyasm/parser.h"
-#include "libyasm/preproc.h"
+#include <libyasm/arch.h>
+#include <libyasm/dbgfmt.h>
+#include <libyasm/objfmt.h>
+#include <libyasm/optimizer.h>
+#include <libyasm/parser.h>
+#include <libyasm/preproc.h>
#ifdef YASM_INTERNAL
#ifdef YASM_BC_INTERNAL
-#include "libyasm/bc-int.h"
+#include <libyasm/bc-int.h>
#endif
#ifdef YASM_EXPR_INTERNAL
-#include "libyasm/expr-int.h"
+#include <libyasm/expr-int.h>
#endif
-#include "libyasm/file.h"
-#include "libyasm/hamt.h"
-#include "libyasm/bitvect.h"
+#include <libyasm/file.h>
+#include <libyasm/hamt.h>
+#include <libyasm/bitvect.h>
#endif
#endif
}
void
-yasm_ea_set_len(yasm_effaddr *ptr, unsigned char len)
+yasm_ea_set_len(yasm_effaddr *ptr, unsigned int len)
{
if (!ptr)
return;
* an explicit override, where we expect the user knows what they're doing.
*/
- ptr->len = len;
+ ptr->len = (unsigned char)len;
}
void
-yasm_ea_set_nosplit(yasm_effaddr *ptr, unsigned char nosplit)
+yasm_ea_set_nosplit(yasm_effaddr *ptr, unsigned int nosplit)
{
if (!ptr)
return;
- ptr->nosplit = nosplit;
+ ptr->nosplit = (unsigned char)nosplit;
}
/*@-nullstate@*/
}
yasm_bytecode *
-yasm_bc_new_data(yasm_datavalhead *datahead, unsigned char size,
+yasm_bc_new_data(yasm_datavalhead *datahead, unsigned int size,
unsigned long lindex)
{
bytecode_data *data;
yasm_bc_new_common(YASM_BC__DATA, sizeof(bytecode_data), lindex);
data->datahead = *datahead;
- data->size = size;
+ data->size = (unsigned char)size;
return (yasm_bytecode *)data;
}
yasm_bytecode *
-yasm_bc_new_reserve(yasm_expr *numitems, unsigned char itemsize,
+yasm_bc_new_reserve(yasm_expr *numitems, unsigned int itemsize,
unsigned long lindex)
{
bytecode_reserve *reserve;
/*@-mustfree@*/
reserve->numitems = numitems;
/*@=mustfree@*/
- reserve->itemsize = itemsize;
+ reserve->itemsize = (unsigned char)itemsize;
return (yasm_bytecode *)reserve;
}
N_("objfmt can't handle its own objfmt data bytecode"));
break;
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
cur_arch->bc.bc_delete(bc);
else
yasm_internal_error(N_("Unknown bytecode type"));
fprintf(f, "%*sUNKNOWN\n", indent_level, "");
break;
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
cur_arch->bc.bc_print(f, indent_level, bc);
else
fprintf(f, "%*s_Unknown_\n", indent_level, "");
yasm_internal_error(N_("resolving objfmt data bytecode?"));
/*break;*/
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
retval = cur_arch->bc.bc_resolve(bc, save, sect,
calc_bc_dist);
else
static int
bc_tobytes_data(bytecode_data *bc_data, unsigned char **bufp,
- const yasm_section *sect, const yasm_bytecode *bc, void *d,
+ const yasm_section *sect, yasm_bytecode *bc, void *d,
yasm_output_expr_func output_expr)
/*@sets **bufp@*/
{
break;
case DV_EXPR:
if (output_expr(&dv->data.expn, bufp, bc_data->size,
- *bufp-bufp_orig, sect, bc, 0, d))
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 0,
+ d))
return 1;
break;
case DV_STRING:
N_("Have objfmt data bytecode but no way to output it"));
break;
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
error = cur_arch->bc.bc_tobytes(bc, &destbuf, sect, d,
output_expr);
else
/*@only@*/ yasm_immval *yasm_imm_new_expr(/*@keep@*/ yasm_expr *e);
/*@observer@*/ const yasm_expr *yasm_ea_get_disp(const yasm_effaddr *ea);
-void yasm_ea_set_len(yasm_effaddr *ea, unsigned char len);
-void yasm_ea_set_nosplit(yasm_effaddr *ea, unsigned char nosplit);
+void yasm_ea_set_len(yasm_effaddr *ea, unsigned int len);
+void yasm_ea_set_nosplit(yasm_effaddr *ea, unsigned int nosplit);
void yasm_ea_delete(/*@only@*/ yasm_effaddr *ea);
void yasm_ea_print(FILE *f, int indent_level, const yasm_effaddr *ea);
size_t datasize,
unsigned long lindex);
/*@only@*/ yasm_bytecode *yasm_bc_new_data(yasm_datavalhead *datahead,
- unsigned char size,
+ unsigned int size,
unsigned long lindex);
/*@only@*/ yasm_bytecode *yasm_bc_new_reserve(/*@only@*/ yasm_expr *numitems,
- unsigned char itemsize,
+ unsigned int itemsize,
unsigned long lindex);
/*@only@*/ yasm_bytecode *yasm_bc_new_incbin
(/*@only@*/ char *filename, /*@only@*/ /*@null@*/ yasm_expr *start,
typedef int (*yasm_output_expr_func)
(yasm_expr **ep, unsigned char **bufp, unsigned long valsize,
unsigned long offset, /*@observer@*/ const yasm_section *sect,
- /*@observer@*/ const yasm_bytecode *bc, int rel, /*@null@*/ void *d)
+ yasm_bytecode *bc, int rel, /*@null@*/ void *d)
/*@uses *ep@*/ /*@sets **bufp@*/;
/* Converts a objfmt data bytecode into its byte representation. Usually
* format functions. The filenames are provided solely for informational
* purposes. May be NULL if not needed by the debug format.
*/
- void (*initialize) (const char *in_filename, const char *obj_filename);
+ void (*initialize) (const char *in_filename, const char *obj_filename,
+ yasm_objfmt *of);
/* Cleans up anything allocated by initialize.
* May be NULL if not needed by the debug format.
*/
void (*cleanup) (void);
+
+ /* DEBUG directive support. */
+ void (*directive) (yasm_valparamhead *valparams, unsigned long lindex);
};
#endif
* standard cat(1) convention for unprintable characters.
*/
char *
-yasm__conv_unprint(char ch)
+yasm__conv_unprint(int ch)
{
int pos = 0;
#ifdef YASM_INTERNAL
/* Convert a possibly unprintable character into a printable string. */
-char *yasm__conv_unprint(char ch);
+char *yasm__conv_unprint(int ch);
#endif
/* Map to gettext() if gettext is being used. */
int retval;
BitVector_Negate(abs_bv, intn->val.bv);
- retval = Set_Max(abs_bv) < size*8;
+ retval = Set_Max(abs_bv) < (long)(size*8);
BitVector_Destroy(abs_bv);
return retval;
} else
- return (Set_Max(intn->val.bv) < size*8);
+ return (Set_Max(intn->val.bv) < (long)(size*8));
}
} else {
switch (intn->type) {
if (size >= 10)
return 1;
else
- return (Set_Max(intn->val.bv) < size*8);
+ return (Set_Max(intn->val.bv) < (long)(size*8));
}
}
return 0;
line_index_assoc_data_raw_head *adrh =
&line_index_assoc_data_array[i];
if (adrh->delete_func && adrh->vector) {
- int j;
+ unsigned int j;
for (j=0; j<adrh->size; j++) {
if (adrh->vector[j])
adrh->delete_func(adrh->vector[j]);
&line_index_assoc_data_array[type>>1];
if (adrh->size == 0) {
- int i;
+ unsigned int i;
adrh->size = 4;
adrh->vector = yasm_xmalloc(adrh->size*sizeof(void *));
}
while (line_index > adrh->size) {
- int i;
+ unsigned int i;
/* allocate another size bins when full for 2x space */
adrh->vector = yasm_xrealloc(adrh->vector,
* This function may call symrec functions as necessary (including
* symrec_traverse) to retrieve symbolic information.
*/
- void (*output) (FILE *f, yasm_sectionhead *sections);
+ void (*output) (FILE *f, yasm_sectionhead *sections, int all_syms);
/* Cleans up anything allocated by initialize.
* May be NULL if not needed by the object format.
# include <stdarg.h>
#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H)
-# include "libyasm/config.h"
+# include <libyasm/config.h>
#endif
#if !defined(lint) && !defined(NDEBUG)
#endif /*YASM_AUTOCONF_INTERNAL*/
-#include "libyasm/compat-queue.h"
+#include <libyasm/compat-queue.h>
#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_SYS_CDEFS_H)
# include <sys/cdefs.h>
#endif /*YASM_INTERNAL*/
-#include "libyasm/coretype.h"
+#include <libyasm/coretype.h>
-#include "libyasm/valparam.h"
+#include <libyasm/valparam.h>
#endif
yasm_valparam *
-yasm_vp_new(/*@keep@*/ const char *v, /*@keep@*/ yasm_expr *p)
+yasm_vp_new(/*@keep@*/ char *v, /*@keep@*/ yasm_expr *p)
{
yasm_valparam *r = yasm_xmalloc(sizeof(yasm_valparam));
r->val = v;
/*@reldef@*/ STAILQ_HEAD(yasm_valparamhead, yasm_valparam);
#endif
-yasm_valparam *yasm_vp_new(/*@keep@*/ const char *v, /*@keep@*/ yasm_expr *p);
+yasm_valparam *yasm_vp_new(/*@keep@*/ char *v, /*@keep@*/ yasm_expr *p);
void yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp);
#ifdef YASM_INTERNAL
# AC_PROG_LIBTOOL
# ---------------
AC_DEFUN([AC_PROG_LIBTOOL],
-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
- AC_PROVIDE_IFELSE([AC_PROG_CXX],
- [AC_LIBTOOL_CXX],
- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
- ])])
-dnl And a similar setup for Fortran 77 support
- AC_PROVIDE_IFELSE([AC_PROG_F77],
- [AC_LIBTOOL_F77],
- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-])])
-
-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [ifdef([AC_PROG_GCJ],
- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([A][M_PROG_GCJ],
- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([LT_AC_PROG_GCJ],
- [define([LT_AC_PROG_GCJ],
- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-])])# AC_PROG_LIBTOOL
+[AC_REQUIRE([_AC_PROG_LIBTOOL])])
# _AC_PROG_LIBTOOL
YASM_MODULES += -dlopen yasm-x86.la
x86id.c: $(srcdir)/modules/arch/x86/x86id.re re2c$(EXEEXT) $(srcdir)/tools/re2c/cleanup.pl
- $(top_builddir)/re2c$(EXEEXT) -b $(srcdir)/modules/arch/x86/x86id.re | $(PERL) $(srcdir)/tools/re2c/cleanup.pl | sed "/^#l/ s,re2c-out\.c,$@," > $@
+ $(top_builddir)/re2c$(EXEEXT) -s $(srcdir)/modules/arch/x86/x86id.re | $(PERL) $(srcdir)/tools/re2c/cleanup.pl | sed "/^#l/ s,re2c-out\.c,$@," > $@
BUILT_SOURCES += \
x86id.c
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "x86arch.h"
unsigned int
yasm_x86__get_reg_size(unsigned long reg)
{
- switch ((x86_expritem_reg_size)(reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(reg & ~0xFUL)) {
case X86_REG8:
case X86_REG8X:
return 1;
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};
- switch ((x86_expritem_reg_size)(reg&~0xF)) {
+ switch ((x86_expritem_reg_size)(reg & ~0xFUL)) {
case X86_REG8:
fprintf(f, "%s", name8[reg&0xF]);
break;
{
switch((x86_parse_insn_prefix)data[0]) {
case X86_LOCKREP:
- yasm_x86__bc_insn_set_lockrep_prefix(bc, (unsigned char)data[1],
+ yasm_x86__bc_insn_set_lockrep_prefix(bc, data[1] & 0xff,
lindex);
break;
case X86_ADDRSIZE:
- yasm_x86__bc_insn_addrsize_override(bc, (unsigned char)data[1]);
+ yasm_x86__bc_insn_addrsize_override(bc, data[1]);
break;
case X86_OPERSIZE:
- yasm_x86__bc_insn_opersize_override(bc, (unsigned char)data[1]);
+ yasm_x86__bc_insn_opersize_override(bc, data[1]);
break;
}
}
* in 64-bit mode or if it wasn't needed to express reg.
*/
int yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3,
- unsigned long reg, unsigned char bits,
+ unsigned long reg, unsigned int bits,
x86_rex_bit_pos rexbit);
void yasm_x86__ea_set_segment(/*@null@*/ yasm_effaddr *ea,
- unsigned char segment, unsigned long lindex);
+ unsigned int segment, unsigned long lindex);
void yasm_x86__ea_set_disponly(yasm_effaddr *ea);
yasm_effaddr *yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex,
- unsigned char bits);
+ unsigned int bits);
yasm_effaddr *yasm_x86__ea_new_imm(/*@keep@*/ yasm_expr *imm,
- unsigned char im_len);
+ unsigned int im_len);
yasm_effaddr *yasm_x86__ea_new_expr(/*@keep@*/ yasm_expr *e);
/*@observer@*/ /*@null@*/ yasm_effaddr *yasm_x86__bc_insn_get_ea
(/*@null@*/ yasm_bytecode *bc);
void yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc,
- unsigned char opersize);
+ unsigned int opersize);
void yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc,
- unsigned char addrsize);
+ unsigned int addrsize);
void yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc,
- unsigned char prefix,
+ unsigned int prefix,
unsigned long lindex);
/* Structure with *all* inputs passed to x86_bytecode_new_insn().
yasm_output_expr_func output_expr);
int yasm_x86__expr_checkea
- (yasm_expr **ep, unsigned char *addrsize, unsigned char bits,
- unsigned char nosplit, unsigned char *displen, unsigned char *modrm,
+ (yasm_expr **ep, unsigned char *addrsize, unsigned int bits,
+ unsigned int nosplit, unsigned char *displen, unsigned char *modrm,
unsigned char *v_modrm, unsigned char *n_modrm, unsigned char *sib,
unsigned char *v_sib, unsigned char *n_sib, unsigned char *rex,
yasm_calc_bc_dist_func calc_bc_dist);
*/
#define YASM_LIB_INTERNAL
#define YASM_BC_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "x86arch.h"
int
yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3,
- unsigned long reg, unsigned char bits,
+ unsigned long reg, unsigned int bits,
x86_rex_bit_pos rexbit)
{
*low3 = (unsigned char)(reg&7);
if (bits == 64) {
- x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xF);
+ x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xFUL);
if (size == X86_REG8X || (reg & 0xF) >= 8) {
if (*rex == 0xff)
/*@=compmempass =mustfree@*/
void
-yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned char segment,
+yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned int segment,
unsigned long lindex)
{
x86_effaddr *x86_ea = (x86_effaddr *)ea;
yasm__warning(YASM_WARN_GENERAL, lindex,
N_("multiple segment overrides, using leftmost"));
- x86_ea->segment = segment;
+ x86_ea->segment = (unsigned char)segment;
}
void
}
yasm_effaddr *
-yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex, unsigned char bits)
+yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex, unsigned int bits)
{
x86_effaddr *x86_ea;
unsigned char rm;
/*@-compmempass@*/
yasm_effaddr *
-yasm_x86__ea_new_imm(yasm_expr *imm, unsigned char im_len)
+yasm_x86__ea_new_imm(yasm_expr *imm, unsigned int im_len)
{
x86_effaddr *x86_ea;
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
x86_ea->ea.disp = imm;
- x86_ea->ea.len = im_len;
+ x86_ea->ea.len = (unsigned char)im_len;
x86_ea->ea.nosplit = 0;
x86_ea->segment = 0;
x86_ea->modrm = 0;
}
void
-yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned char opersize)
+yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned int opersize)
{
x86_insn *insn;
x86_jmprel *jmprel;
switch ((x86_bytecode_type)bc->type) {
case X86_BC_INSN:
insn = (x86_insn *)bc;
- insn->opersize = opersize;
+ insn->opersize = (unsigned char)opersize;
break;
case X86_BC_JMPREL:
jmprel = (x86_jmprel *)bc;
- jmprel->opersize = opersize;
+ jmprel->opersize = (unsigned char)opersize;
break;
default:
yasm_internal_error(
}
void
-yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned char addrsize)
+yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned int addrsize)
{
x86_insn *insn;
x86_jmprel *jmprel;
switch ((x86_bytecode_type)bc->type) {
case X86_BC_INSN:
insn = (x86_insn *)bc;
- insn->addrsize = addrsize;
+ insn->addrsize = (unsigned char)addrsize;
break;
case X86_BC_JMPREL:
jmprel = (x86_jmprel *)bc;
- jmprel->addrsize = addrsize;
+ jmprel->addrsize = (unsigned char)addrsize;
break;
default:
yasm_internal_error(
}
void
-yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned char prefix,
+yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned int prefix,
unsigned long lindex)
{
x86_insn *insn;
yasm__warning(YASM_WARN_GENERAL, lindex,
N_("multiple LOCK or REP prefixes, using leftmost"));
- *lockrep_pre = prefix;
+ *lockrep_pre = (unsigned char)prefix;
}
void
static int
x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
- const yasm_section *sect, const yasm_bytecode *bc, void *d,
+ const yasm_section *sect, yasm_bytecode *bc, void *d,
yasm_output_expr_func output_expr)
{
/*@null@*/ x86_effaddr *x86_ea = insn->ea;
yasm_internal_error(N_("checkea failed"));
if (ea->disp) {
- if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
- sect, bc, 0, d))
+ if (output_expr(&ea->disp, bufp, ea->len,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 0,
+ d))
return 1;
} else {
/* 0 displacement, but we didn't know it before, so we have to
/* Immediate (if required) */
if (imm && imm->val) {
/* TODO: check imm->len vs. sized len from expr? */
- if (output_expr(&imm->val, bufp, imm->len, *bufp-bufp_orig, sect, bc,
- 0, d))
+ if (output_expr(&imm->val, bufp, imm->len,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 0, d))
return 1;
}
static int
x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
- const yasm_section *sect, const yasm_bytecode *bc,
+ const yasm_section *sect, yasm_bytecode *bc,
void *d, yasm_output_expr_func output_expr)
{
unsigned char opersize;
YASM_WRITE_8(*bufp, jmprel->shortop.opcode[i]);
/* Relative displacement */
- if (output_expr(&jmprel->target, bufp, 1, *bufp-bufp_orig, sect,
- bc, 1, d))
+ if (output_expr(&jmprel->target, bufp, 1,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 1, d))
return 1;
break;
case JR_NEAR_FORCED:
/* Relative displacement */
if (output_expr(&jmprel->target, bufp,
- (opersize == 32) ? 4UL : 2UL, *bufp-bufp_orig,
- sect, bc, 1, d))
+ (opersize == 32) ? 4UL : 2UL,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 1, d))
return 1;
break;
default:
N_("tried to do PC-relative offset from invalid sized value"));
val = yasm_intnum_get_uint(intn);
val -= bc->len;
- switch (valsize) {
+ switch ((unsigned int)valsize) {
case 1:
YASM_WRITE_8(*bufp, val);
break;
*/
#define YASM_LIB_INTERNAL
#define YASM_EXPR_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "x86arch.h"
{
x86_checkea_reg3264_data *data = d;
- switch ((x86_expritem_reg_size)(ei->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) {
case X86_REG32:
if (data->addrsize != 32)
return 0;
reg16[7] = &data->di;
/* don't allow 32-bit registers */
- if ((ei->data.reg & ~0xF) != X86_REG16)
+ if ((ei->data.reg & ~0xFUL) != X86_REG16)
return 0;
/* & 7 for sanity check */
unsigned char *addrsize = (unsigned char *)d;
if (ei->type == YASM_EXPR_REG) {
- switch ((x86_expritem_reg_size)(ei->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) {
case X86_REG16:
*addrsize = 16;
break;
int
yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
- unsigned char bits, unsigned char nosplit,
+ unsigned int bits, unsigned int nosplit,
unsigned char *displen, unsigned char *modrm,
unsigned char *v_modrm, unsigned char *n_modrm,
unsigned char *sib, unsigned char *v_sib,
* of register basereg is, as x86_set_rex_from_reg doesn't pay
* much attention.
*/
- if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
+ if (yasm_x86__set_rex_from_reg(rex, &low3,
+ (unsigned int)(X86_REG64 | basereg),
bits, X86_REX_B)) {
yasm__error(e->line,
N_("invalid combination of operands and effective address"));
if (basereg == REG3264_NONE)
*sib |= 5;
else {
- if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
- bits, X86_REX_B)) {
+ if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int)
+ (X86_REG64 | basereg), bits,
+ X86_REX_B)) {
yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
*sib |= 040;
/* Any scale field is valid, just leave at 0. */
else {
- if (yasm_x86__set_rex_from_reg(rex, &low3,
- X86_REG64 | indexreg, bits,
+ if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int)
+ (X86_REG64 | indexreg), bits,
X86_REX_X)) {
yasm__error(e->line,
N_("invalid combination of operands and effective address"));
#define YASM_LIB_INTERNAL
#define YASM_BC_INTERNAL
#define YASM_EXPR_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
RCSID("$IdPath$");
#include "modules/arch/x86/x86arch.h"
0, lindex)), lindex);
/* See if the user explicitly specified short/near. */
- switch (jrinfo->operands[0] & OPTM_MASK) {
+ switch ((int)(jrinfo->operands[0] & OPTM_MASK)) {
case OPTM_Short:
d.op_sel = JR_SHORT_FORCED;
break;
if (info->opersize != d.opersize)
continue;
- switch (info->operands[0] & OPTM_MASK) {
+ switch ((int)(info->operands[0] & OPTM_MASK)) {
case OPTM_Short:
d.short_op_len = info->opcode_len;
d.short_op[0] = info->opcode[0];
for(i = 0, op = yasm_ops_first(operands); op && i<info->num_operands &&
!mismatch; op = yasm_ops_next(op), i++) {
/* Check operand type */
- switch (info->operands[i] & OPT_MASK) {
+ switch ((int)(info->operands[i] & OPT_MASK)) {
case OPT_Imm:
if (op->type != YASM_INSN__OPERAND_IMM)
mismatch = 1;
if (op->type != YASM_INSN__OPERAND_REG)
mismatch = 1;
else {
- switch ((x86_expritem_reg_size)(op->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) {
case X86_REG8:
case X86_REG8X:
case X86_REG16:
if (op->type != YASM_INSN__OPERAND_REG)
mismatch = 1;
else {
- switch ((x86_expritem_reg_size)(op->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) {
case X86_MMXREG:
case X86_XMMREG:
break;
break;
case OPT_CRReg:
if (op->type != YASM_INSN__OPERAND_REG ||
- (op->data.reg & ~0xF) != X86_CRREG)
+ (op->data.reg & ~0xFUL) != X86_CRREG)
mismatch = 1;
break;
case OPT_DRReg:
if (op->type != YASM_INSN__OPERAND_REG ||
- (op->data.reg & ~0xF) != X86_DRREG)
+ (op->data.reg & ~0xFUL) != X86_DRREG)
mismatch = 1;
break;
case OPT_TRReg:
if (op->type != YASM_INSN__OPERAND_REG ||
- (op->data.reg & ~0xF) != X86_TRREG)
+ (op->data.reg & ~0xFUL) != X86_TRREG)
mismatch = 1;
break;
case OPT_ST0:
break;
/* Check target modifier */
- switch (info->operands[i] & OPTM_MASK) {
+ switch ((int)(info->operands[i] & OPTM_MASK)) {
case OPTM_None:
if (op->targetmod != 0)
mismatch = 1;
}
/* Extended error/warning handling */
- switch (info->modifiers & MOD_Ext_MASK) {
+ switch ((int)(info->modifiers & MOD_Ext_MASK)) {
case MOD_ExtNone:
/* No extended modifier, so just continue */
break;
case MOD_ExtErr:
- switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
+ switch ((int)((info->modifiers & MOD_ExtIndex_MASK)
+ >> MOD_ExtIndex_SHIFT)) {
case 0:
yasm__error(lindex, N_("mismatch in operand sizes"));
break;
}
return NULL; /* It was an error */
case MOD_ExtWarn:
- switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
+ switch ((int)((info->modifiers & MOD_ExtIndex_MASK)
+ >> MOD_ExtIndex_SHIFT)) {
default:
yasm_internal_error(N_("unrecognized x86 ext mod index"));
}
}
if (info->modifiers & MOD_Imm8) {
d.imm = yasm_expr_new_ident(yasm_expr_int(
- yasm_intnum_new_int(mod_data & 0xFF)), lindex);
+ yasm_intnum_new_uint(mod_data & 0xFF)), lindex);
d.im_len = 1;
/*mod_data >>= 8;*/
}
if (operands) {
for(i = 0, op = yasm_ops_first(operands); op && i<info->num_operands;
op = yasm_ops_next(op), i++) {
- switch (info->operands[i] & OPA_MASK) {
+ switch ((int)(info->operands[i] & OPA_MASK)) {
case OPA_None:
/* Throw away the operand contents */
switch (op->type) {
yasm_internal_error(N_("unknown operand action"));
}
- switch (info->operands[i] & OPAP_MASK) {
+ switch ((int)(info->operands[i] & OPAP_MASK)) {
case OPAP_None:
break;
case OPAP_ShiftOp:
F C H S { RET_INSN(twobyte, 0xD9E0, CPU_FPU); }
F A B S { RET_INSN(twobyte, 0xD9E1, CPU_FPU); }
F N I N I T { RET_INSN(twobyte, 0xDBE3, CPU_FPU); }
- F I N I T { RET_INSN(threebyte, 0x98DBE3, CPU_FPU); }
+ F I N I T { RET_INSN(threebyte, 0x98DBE3UL, CPU_FPU); }
F L D C W { RET_INSN(fldnstcw, 0x05, CPU_FPU); }
F N S T C W { RET_INSN(fldnstcw, 0x07, CPU_FPU); }
F S T C W { RET_INSN(fstcw, 0, CPU_FPU); }
F N S T S W { RET_INSN(fnstsw, 0, CPU_FPU); }
F S T S W { RET_INSN(fstsw, 0, CPU_FPU); }
F N C L E X { RET_INSN(twobyte, 0xDBE2, CPU_FPU); }
- F C L E X { RET_INSN(threebyte, 0x98DBE2, CPU_FPU); }
+ F C L E X { RET_INSN(threebyte, 0x98DBE2UL, CPU_FPU); }
F N S T E N V { RET_INSN(onebytemem, 0x06D9, CPU_FPU); }
F S T E N V { RET_INSN(twobytemem, 0x069BD9, CPU_FPU); }
F L D E N V { RET_INSN(onebytemem, 0x04D9, CPU_FPU); }
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
-/* Define preproc structure -- see preproc.h for details */
+/* Define dbgfmt structure -- see dbgfmt.h for details */
yasm_dbgfmt yasm_null_LTX_dbgfmt = {
"No debugging info",
"null",
NULL, /*null_dbgfmt_initialize*/
- NULL /*null_dbgfmt_cleanup*/
+ NULL, /*null_dbgfmt_cleanup*/
+ NULL /*null_dbgfmt_directive*/
};
EXTRA_DIST += \
modules/objfmts/dbg/Makefile.inc \
modules/objfmts/bin/Makefile.inc \
- modules/objfmts/coff/Makefile.inc
+ modules/objfmts/coff/Makefile.inc \
+ modules/objfmts/win32/Makefile.inc
include modules/objfmts/dbg/Makefile.inc
include modules/objfmts/bin/Makefile.inc
include modules/objfmts/coff/Makefile.inc
+include modules/objfmts/win32/Makefile.inc
#define YASM_LIB_INTERNAL
#define YASM_BC_INTERNAL
#define YASM_EXPR_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
unsigned long valsize,
/*@unused@*/ unsigned long offset,
/*@observer@*/ const yasm_section *sect,
- /*@observer@*/ const yasm_bytecode *bc, int rel,
+ yasm_bytecode *bc, int rel,
/*@unused@*/ /*@null@*/ void *d)
{
/*@dependent@*/ /*@null@*/ const yasm_intnum *intn;
}
static void
-bin_objfmt_output(FILE *f, yasm_sectionhead *sections)
+bin_objfmt_output(FILE *f, yasm_sectionhead *sections,
+ /*@unused@*/ int all_syms)
{
/*@observer@*/ /*@null@*/ yasm_section *text, *data, *bss, *prevsect;
/*@null@*/ yasm_expr *startexpr;
#define YASM_LIB_INTERNAL
#define YASM_BC_INTERNAL
#define YASM_EXPR_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
* with VMA=0. Who's right? This is #defined as changing this setting affects
* several places in the code.
*/
-#define COFF_SET_VMA 1
+#define COFF_SET_VMA (!win32)
#define COFF_I386MAGIC 0x14C
} type; /* type of relocation */
} coff_reloc;
-typedef enum coff_section_data_flags {
- COFF_STYP_TEXT = 0x0020,
- COFF_STYP_DATA = 0x0040,
- COFF_STYP_BSS = 0x0080
-} coff_section_data_flags;
+#define COFF_STYP_TEXT 0x00000020UL
+#define COFF_STYP_DATA 0x00000040UL
+#define COFF_STYP_BSS 0x00000080UL
+#define COFF_STYP_INFO 0x00000200UL
+#define COFF_STYP_STD_MASK 0x000003FFUL
+#define COFF_STYP_ALIGN_MASK 0x00F00000UL
+#define COFF_STYP_ALIGN_SHIFT 20
+#define COFF_STYP_DISCARD 0x02000000UL
+#define COFF_STYP_NOCACHE 0x04000000UL
+#define COFF_STYP_NOPAGE 0x08000000UL
+#define COFF_STYP_SHARED 0x10000000UL
+#define COFF_STYP_EXECUTE 0x20000000UL
+#define COFF_STYP_READ 0x40000000UL
+#define COFF_STYP_WRITE 0x80000000UL
+#define COFF_STYP_WIN32_MASK 0xFE000000UL
typedef struct coff_section_data {
/*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */
unsigned int scnum; /* section number (1=first section) */
- coff_section_data_flags flags;
+ unsigned long flags; /* section flags (see COFF_STYP_* above) */
unsigned long addr; /* starting memory address (first section -> 0) */
unsigned long scnptr; /* file ptr to raw data */
unsigned long size; /* size of raw data (section data) in bytes */
yasm_objfmt yasm_coff_LTX_objfmt;
static /*@dependent@*/ yasm_arch *cur_arch;
+/* Set nonzero for win32 output. */
+static int win32;
+
static /*@dependent@*/ coff_symtab_entry *
coff_objfmt_symtab_append(yasm_symrec *sym, coff_symrec_sclass sclass,
return entry;
}
+static int
+coff_objfmt_append_local_sym(yasm_symrec *sym, /*@unused@*/ /*@null@*/ void *d)
+{
+ if (!yasm_symrec_get_of_data(sym))
+ coff_objfmt_symtab_append(sym, COFF_SCL_STAT, NULL, 0,
+ COFF_SYMTAB_AUX_NONE);
+ return 1;
+}
+
static void
-coff_objfmt_initialize(const char *in_filename,
+coff_common_initialize(const char *in_filename,
/*@unused@*/ const char *obj_filename,
/*@unused@*/ yasm_dbgfmt *df, yasm_arch *a)
{
STAILQ_INSERT_TAIL(&coff_symtab, entry, link);
}
+static void
+coff_objfmt_initialize(const char *in_filename, const char *obj_filename,
+ yasm_dbgfmt *df, yasm_arch *a)
+{
+ win32 = 0;
+ coff_common_initialize(in_filename, obj_filename, df, a);
+}
+
+static void
+win32_objfmt_initialize(const char *in_filename, const char *obj_filename,
+ yasm_dbgfmt *df, yasm_arch *a)
+{
+ win32 = 1;
+ coff_common_initialize(in_filename, obj_filename, df, a);
+}
+
static int
coff_objfmt_set_section_addr(yasm_section *sect, /*@null@*/ void *d)
{
coff_objfmt_output_expr(yasm_expr **ep, unsigned char **bufp,
unsigned long valsize, unsigned long offset,
/*@observer@*/ const yasm_section *sect,
- /*@observer@*/ const yasm_bytecode *bc, int rel,
- /*@unused@*/ /*@null@*/ void *d)
+ yasm_bytecode *bc, int rel, /*@null@*/ void *d)
{
/*@null@*/ coff_objfmt_output_info *info = (coff_objfmt_output_info *)d;
/*@dependent@*/ /*@null@*/ const yasm_intnum *intn;
reloc->sym = sym;
vis = yasm_symrec_get_visibility(sym);
if (vis & YASM_SYM_COMMON) {
- /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd;
-
- /* COMMON symbols have their length added in */
- csymd = yasm_symrec_get_of_data(sym);
- assert(csymd != NULL);
- *ep = yasm_expr_new(YASM_EXPR_ADD, yasm_expr_expr(*ep),
- yasm_expr_expr(yasm_expr_copy(csymd->size)),
- csymd->size->line);
- *ep = yasm_expr_simplify(*ep, yasm_common_calc_bc_dist);
+ /* In standard COFF, COMMON symbols have their length added in */
+ if (!win32) {
+ /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd;
+
+ csymd = yasm_symrec_get_of_data(sym);
+ assert(csymd != NULL);
+ *ep = yasm_expr_new(YASM_EXPR_ADD, yasm_expr_expr(*ep),
+ yasm_expr_expr(yasm_expr_copy(csymd->size)),
+ csymd->size->line);
+ *ep = yasm_expr_simplify(*ep, yasm_common_calc_bc_dist);
+ }
} else if (!(vis & YASM_SYM_EXTERN)) {
/* Local symbols need relocation to their section's start */
if (yasm_symrec_get_label(sym, &label_sect, &label_precbc)) {
if (rel) {
reloc->type = COFF_RELOC_REL32;
- /* Need to reference to start of section, so add $$ in. */
- *ep = yasm_expr_new(YASM_EXPR_ADD, yasm_expr_expr(*ep),
- yasm_expr_sym(yasm_symrec_define_label("$$", info->sect, NULL,
- 0, (*ep)->line)),
- (*ep)->line);
+ /* For standard COFF, need to reference to start of section, so add
+ * $$ in.
+ * For Win32 COFF, need to reference to next bytecode, so add '$'
+ * (really $+$.len) in.
+ */
+ if (win32)
+ *ep = yasm_expr_new(YASM_EXPR_ADD, yasm_expr_expr(*ep),
+ yasm_expr_sym(yasm_symrec_define_label("$", info->sect, bc,
+ 0, (*ep)->line)),
+ (*ep)->line);
+ else
+ *ep = yasm_expr_new(YASM_EXPR_ADD, yasm_expr_expr(*ep),
+ yasm_expr_sym(yasm_symrec_define_label("$$", info->sect,
+ NULL, 0,
+ (*ep)->line)),
+ (*ep)->line);
*ep = yasm_expr_simplify(*ep, yasm_common_calc_bc_dist);
} else
reloc->type = COFF_RELOC_ADDR32;
long pos;
coff_reloc *reloc;
- /* Don't output absolute sections */
+ /* Don't output absolute sections into the section table */
if (yasm_section_is_absolute(sect))
return 0;
csd->addr = info->addr;
- if (csd->flags == COFF_STYP_BSS) {
+ if ((csd->flags & COFF_STYP_STD_MASK) == COFF_STYP_BSS) {
/*@null@*/ yasm_bytecode *last =
yasm_bcs_last(yasm_section_get_bytecodes(sect));
/*@dependent@*/ /*@null@*/ coff_section_data *csd;
unsigned char *localbuf;
- /* Don't output absolute sections */
+ /* Don't output absolute sections into the section table */
if (yasm_section_is_absolute(sect))
return 0;
}
static void
-coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
+coff_objfmt_output(FILE *f, yasm_sectionhead *sections, int all_syms)
{
coff_objfmt_output_info info;
unsigned char *localbuf;
info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE);
/* Allocate space for headers by seeking forward */
- if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
+ if (fseek(f, (long)(20+40*(coff_objfmt_parse_scnum-1)), SEEK_SET) < 0) {
yasm__error(0, N_("could not seek on output file"));
return;
}
return;
/* Symbol table */
+ if (all_syms) {
+ /* Need to put all local syms into COFF symbol table */
+ yasm_symrec_traverse(NULL, coff_objfmt_append_local_sym);
+ }
pos = ftell(f);
if (pos == -1) {
yasm__error(0, N_("could not get file position on output file"));
symtab_pos = (unsigned long)pos;
STAILQ_FOREACH(entry, &coff_symtab, link) {
const char *name = yasm_symrec_get_name(entry->sym);
+ const yasm_expr *equ_val;
+ const yasm_intnum *intn;
size_t len = strlen(name);
int aux;
/*@dependent@*/ /*@null@*/ coff_symrec_data *csymd;
if (sect) {
/*@dependent@*/ /*@null@*/ coff_section_data *csectd;
csectd = yasm_section_get_of_data(sect);
- scnum = csectd->scnum;
- scnlen = csectd->size;
- nreloc = csectd->nreloc;
+ if (csectd) {
+ scnum = csectd->scnum;
+ scnlen = csectd->size;
+ nreloc = csectd->nreloc;
+ if (COFF_SET_VMA)
+ value = csectd->addr;
+ } else if (yasm_section_is_absolute(sect)) {
+ yasm_expr *abs_start;
+
+ abs_start = yasm_expr_copy(yasm_section_get_start(sect));
+ intn = yasm_expr_get_intnum(&abs_start,
+ yasm_common_calc_bc_dist);
+ if (!intn)
+ yasm__error(abs_start->line,
+ N_("absolute section start not an integer expression"));
+ else
+ value = yasm_intnum_get_uint(intn);
+ yasm_expr_delete(abs_start);
+
+ scnum = 0xffff; /* -1 = absolute symbol */
+ } else
+ yasm_internal_error(N_("didn't understand section"));
if (precbc)
- value = precbc->offset + precbc->len;
- if (COFF_SET_VMA)
- value += csectd->addr;
+ value += precbc->offset + precbc->len;
}
+ } else if ((equ_val = yasm_symrec_get_equ(entry->sym))) {
+ yasm_expr *equ_val_copy = yasm_expr_copy(equ_val);
+ intn = yasm_expr_get_intnum(&equ_val_copy,
+ yasm_common_calc_bc_dist);
+ if (!intn) {
+ yasm_sym_vis vis = yasm_symrec_get_visibility(entry->sym);
+ if (vis & YASM_SYM_GLOBAL)
+ yasm__error(equ_val->line,
+ N_("global EQU value not an integer expression"));
+ } else
+ value = yasm_intnum_get_uint(intn);
+ yasm_expr_delete(equ_val_copy);
+
+ scnum = 0xffff; /* -1 = absolute symbol */
} else {
yasm_sym_vis vis = yasm_symrec_get_visibility(entry->sym);
if (vis & YASM_SYM_COMMON) {
- const yasm_intnum *intn;
intn = yasm_expr_get_intnum(&csymd->size,
yasm_common_calc_bc_dist);
if (!intn)
YASM_WRITE_32_L(localbuf, symtab_pos); /* file ptr to symtab */
YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */
YASM_WRITE_16_L(localbuf, 0); /* size of optional header (none) */
- YASM_WRITE_16_L(localbuf, COFF_F_AR32WR|COFF_F_LNNO|COFF_F_LSYMS); /* flags */
+ /* flags */
+ YASM_WRITE_16_L(localbuf, COFF_F_AR32WR|COFF_F_LNNO
+ |(all_syms?0:COFF_F_LSYMS));
fwrite(info.buf, 20, 1, f);
yasm_sections_traverse(sections, &info, coff_objfmt_output_secthead);
yasm_valparam *vp = yasm_vps_first(valparams);
yasm_section *retval;
int isnew;
- coff_section_data_flags flags;
+ unsigned long flags;
int flags_override = 0;
char *sectname;
int resonly = 0;
+ static const struct {
+ const char *name;
+ unsigned long stdflags; /* if 0, win32 only qualifier */
+ unsigned long win32flags;
+ /* Mode: 0 => clear specified bits
+ * 1 => set specified bits
+ * 2 => clear all bits, then set specified bits
+ */
+ int mode;
+ } flagquals[] = {
+ { "code", COFF_STYP_TEXT, COFF_STYP_EXECUTE | COFF_STYP_READ, 2 },
+ { "text", COFF_STYP_TEXT, COFF_STYP_EXECUTE | COFF_STYP_READ, 2 },
+ { "data", COFF_STYP_DATA, COFF_STYP_READ | COFF_STYP_WRITE, 2 },
+ { "bss", COFF_STYP_BSS, COFF_STYP_READ | COFF_STYP_WRITE, 2 },
+ { "info", COFF_STYP_INFO, COFF_STYP_DISCARD | COFF_STYP_READ, 2 },
+ { "discard", 0, COFF_STYP_DISCARD, 1 },
+ { "nodiscard", 0, COFF_STYP_DISCARD, 0 },
+ { "cache", 0, COFF_STYP_NOCACHE, 0 },
+ { "nocache", 0, COFF_STYP_NOCACHE, 1 },
+ { "page", 0, COFF_STYP_NOPAGE, 0 },
+ { "nopage", 0, COFF_STYP_NOPAGE, 1 },
+ { "share", 0, COFF_STYP_SHARED, 1 },
+ { "noshare", 0, COFF_STYP_SHARED, 0 },
+ { "execute", 0, COFF_STYP_EXECUTE, 1 },
+ { "noexecute", 0, COFF_STYP_EXECUTE, 0 },
+ { "read", 0, COFF_STYP_READ, 1 },
+ { "noread", 0, COFF_STYP_READ, 0 },
+ { "write", 0, COFF_STYP_WRITE, 1 },
+ { "nowrite", 0, COFF_STYP_WRITE, 0 },
+ };
if (!vp || vp->param || !vp->val)
return NULL;
sectname = vp->val;
if (strlen(sectname) > 8) {
+ /* TODO: win32 format supports >8 character section names in object
+ * files via "/nnnn" (where nnnn is decimal offset into string table).
+ */
yasm__warning(YASM_WARN_GENERAL, lindex,
N_("COFF section names limited to 8 characters: truncating"));
sectname[8] = '\0';
}
- if (strcmp(sectname, ".data") == 0)
+ if (strcmp(sectname, ".data") == 0) {
flags = COFF_STYP_DATA;
- else if (strcmp(sectname, ".bss") == 0) {
+ if (win32)
+ flags |= COFF_STYP_READ | COFF_STYP_WRITE |
+ (3<<COFF_STYP_ALIGN_SHIFT); /* align=4 */
+ } else if (strcmp(sectname, ".bss") == 0) {
flags = COFF_STYP_BSS;
+ if (win32)
+ flags |= COFF_STYP_READ | COFF_STYP_WRITE |
+ (3<<COFF_STYP_ALIGN_SHIFT); /* align=4 */
resonly = 1;
- } else
+ } else if (strcmp(sectname, ".text") == 0) {
+ flags = COFF_STYP_TEXT;
+ if (win32)
+ flags |= COFF_STYP_EXECUTE | COFF_STYP_READ |
+ (5<<COFF_STYP_ALIGN_SHIFT); /* align=16 */
+ } else if (strcmp(sectname, ".rdata") == 0) {
+ flags = COFF_STYP_DATA;
+ if (win32)
+ flags |= COFF_STYP_READ | (4<<COFF_STYP_ALIGN_SHIFT); /* align=8 */
+ else
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Standard COFF does not support read-only data sections"));
+ } else {
+ /* Default to code */
flags = COFF_STYP_TEXT;
+ if (win32)
+ flags |= COFF_STYP_EXECUTE | COFF_STYP_READ;
+ }
while ((vp = yasm_vps_next(vp))) {
- if (yasm__strcasecmp(vp->val, "code") == 0 ||
- yasm__strcasecmp(vp->val, "text") == 0) {
- flags = COFF_STYP_TEXT;
- flags_override = 1;
- } else if (yasm__strcasecmp(vp->val, "data") == 0) {
- flags = COFF_STYP_DATA;
- flags_override = 1;
- } else if (yasm__strcasecmp(vp->val, "bss") == 0) {
- flags = COFF_STYP_BSS;
- flags_override = 1;
- resonly = 1;
+ size_t i;
+ int match, win32warn;
+
+ win32warn = 0;
+
+ match = 0;
+ for (i=0; i<NELEMS(flagquals) && !match; i++) {
+ if (yasm__strcasecmp(vp->val, flagquals[i].name) == 0) {
+ if (!win32 && flagquals[i].stdflags == 0)
+ win32warn = 1;
+ else switch (flagquals[i].mode) {
+ case 0:
+ flags &= ~flagquals[i].stdflags;
+ if (win32)
+ flags &= ~flagquals[i].win32flags;
+ break;
+ case 1:
+ flags |= flagquals[i].stdflags;
+ if (win32)
+ flags |= flagquals[i].win32flags;
+ break;
+ case 2:
+ flags &= ~COFF_STYP_STD_MASK;
+ flags |= flagquals[i].stdflags;
+ if (win32) {
+ flags &= ~COFF_STYP_WIN32_MASK;
+ flags |= flagquals[i].win32flags;
+ }
+ break;
+ }
+ flags_override = 1;
+ match = 1;
+ }
}
+
+ if (match)
+ ;
+ else if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) {
+ if (win32) {
+ /*@dependent@*/ /*@null@*/ const yasm_intnum *align;
+ unsigned long bitcnt;
+ unsigned long addralign;
+
+ align = yasm_expr_get_intnum(&vp->param, NULL);
+ if (!align) {
+ yasm__error(lindex,
+ N_("argument to `%s' is not a power of two"),
+ vp->val);
+ return NULL;
+ }
+ addralign = yasm_intnum_get_uint(align);
+
+ /* Check to see if alignment is a power of two.
+ * This can be checked by seeing if only one bit is set.
+ */
+ BitCount(bitcnt, addralign);
+ if (bitcnt > 1) {
+ yasm__error(lindex,
+ N_("argument to `%s' is not a power of two"),
+ vp->val);
+ return NULL;
+ }
+
+ /* Check to see if alignment is supported size */
+ if (addralign > 8192) {
+ yasm__error(lindex,
+ N_("Win32 does not support alignments > 8192"));
+ return NULL;
+ }
+
+ /* Convert alignment into flags setting */
+ flags &= ~COFF_STYP_ALIGN_MASK;
+ while (addralign != 0) {
+ flags += 1<<COFF_STYP_ALIGN_SHIFT;
+ addralign >>= 1;
+ }
+ } else
+ win32warn = 1;
+ } else
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Unrecognized qualifier `%s'"), vp->val);
+
+ if (win32warn)
+ yasm__warning(YASM_WARN_GENERAL, lindex,
+ N_("Standard COFF does not support qualifier `%s'"), vp->val);
}
retval = yasm_sections_switch_general(headp, sectname, 0, resonly, &isnew,
yasm_symrec_print(f, indent_level+1, csd->sym);
fprintf(f, "%*sscnum=%d\n", indent_level, "", csd->scnum);
fprintf(f, "%*sflags=", indent_level, "");
- switch (csd->flags) {
+ switch (csd->flags & COFF_STYP_STD_MASK) {
case COFF_STYP_TEXT:
fprintf(f, "TEXT");
break;
NULL /*coff_objfmt_bc_objfmt_data_delete*/,
NULL /*coff_objfmt_bc_objfmt_data_print*/
};
+
+/* Define objfmt structure -- see objfmt.h for details */
+yasm_objfmt yasm_win32_LTX_objfmt = {
+ "Win32",
+ "win32",
+ "obj",
+ ".text",
+ 32,
+ coff_objfmt_dbgfmt_keywords,
+ "null",
+ win32_objfmt_initialize,
+ coff_objfmt_output,
+ coff_objfmt_cleanup,
+ coff_objfmt_sections_switch,
+ coff_objfmt_section_data_delete,
+ coff_objfmt_section_data_print,
+ coff_objfmt_extglob_declare,
+ coff_objfmt_extglob_declare,
+ coff_objfmt_common_declare,
+ coff_objfmt_symrec_data_delete,
+ coff_objfmt_symrec_data_print,
+ coff_objfmt_directive,
+ NULL /*coff_objfmt_bc_objfmt_data_delete*/,
+ NULL /*coff_objfmt_bc_objfmt_data_print*/
+};
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
}
static void
-dbg_objfmt_output(/*@unused@*/ FILE *f, yasm_sectionhead *sections)
+dbg_objfmt_output(/*@unused@*/ FILE *f, yasm_sectionhead *sections,
+ int all_syms)
{
fprintf(dbg_objfmt_file, "output(f, sections->\n");
yasm_sections_print(dbg_objfmt_file, 1, sections);
- fprintf(dbg_objfmt_file, ")\n");
+ fprintf(dbg_objfmt_file, "%d)\n", all_syms);
fprintf(dbg_objfmt_file, " Symbol Table:\n");
yasm_symrec_print_all(dbg_objfmt_file, 1);
}
--- /dev/null
+/*
+ * ELF-32 utility functions
+ *
+ * Copyright (C) 2003 Peter Johnson
+ *
+ * This file is part of YASM.
+ *
+ * YASM is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * YASM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#define YASM_LIB_INTERNAL
+#include "libyasm.h"
+/*@unused@*/ RCSID("$IdPath$");
+
+#include "elf32.h"
+
+/* Converts an ELF-32 header into little endian bytes */
+void
+elf32_write_elf_header(unsigned char **bufp, Elf32_Ehdr *ehdr)
+{
+ int i;
+
+ for (i=0; i<EI_NIDENT; i++)
+ YASM_WRITE_8(*bufp, ehdr->e_ident[i]);
+ YASM_WRITE_16_L(*bufp, ehdr->e_type);
+ YASM_WRITE_16_L(*bufp, ehdr->e_machine);
+ YASM_WRITE_32_L(*bufp, ehdr->e_version);
+ YASM_WRITE_32_L(*bufp, ehdr->e_entry);
+ YASM_WRITE_32_L(*bufp, ehdr->e_phoff);
+ YASM_WRITE_32_L(*bufp, ehdr->e_shoff);
+ YASM_WRITE_32_L(*bufp, ehdr->e_flags);
+ YASM_WRITE_16_L(*bufp, ehdr->e_ehsize);
+ YASM_WRITE_16_L(*bufp, ehdr->e_phentsize);
+ YASM_WRITE_16_L(*bufp, ehdr->e_phnum);
+ YASM_WRITE_16_L(*bufp, ehdr->e_shentsize);
+ YASM_WRITE_16_L(*bufp, ehdr->e_shnum);
+ YASM_WRITE_16_L(*bufp, ehdr->e_shstrndx);
+}
+
+/* Converts an ELF-32 section header into little endian bytes */
+void
+elf32_write_sect_header(unsigned char **bufp, Elf32_Shdr *shdr)
+{
+ YASM_WRITE_32_L(*bufp, shdr->sh_name);
+ YASM_WRITE_32_L(*bufp, shdr->sh_type);
+ YASM_WRITE_32_L(*bufp, shdr->sh_flags);
+ YASM_WRITE_32_L(*bufp, shdr->sh_addr);
+ YASM_WRITE_32_L(*bufp, shdr->sh_offset);
+ YASM_WRITE_32_L(*bufp, shdr->sh_size);
+ YASM_WRITE_32_L(*bufp, shdr->sh_link);
+ YASM_WRITE_32_L(*bufp, shdr->sh_info);
+ YASM_WRITE_32_L(*bufp, shdr->sh_addralign);
+ YASM_WRITE_32_L(*bufp, shdr->sh_entsize);
+}
+
+void
+elf32_print_sect_header(FILE *f, int indent_level, Elf32_Shdr *shdr)
+{
+ static const char *sh_type_names[] = {
+ "null", "progbits", "symtab", "strtab", "rela", "hash", "dynamic",
+ "note", "nobits", "rel", "shlib", "dynsym"
+ };
+
+ fprintf(f, "%*ssh_name=%lu\n", indent_level, "", shdr->sh_name);
+ fprintf(f, "%*ssh_type=", indent_level, "");
+ if (shdr->sh_type < NELEMS(sh_type_names))
+ fprintf(f, "%s", sh_type_names[shdr->sh_type]);
+ else
+ fprintf(f, "%lu", shdr->sh_type);
+ fprintf(f, "\n%*ssh_flags=%lx\n", indent_level, "", shdr->sh_flags);
+ fprintf(f, "%*ssh_addr=0x%lx\n", indent_level, "", shdr->sh_addr);
+ fprintf(f, "%*ssh_offset=0x%lx\n", indent_level, "", shdr->sh_offset);
+ fprintf(f, "%*ssh_size=0x%lx\n", indent_level, "", shdr->sh_size);
+ fprintf(f, "%*ssh_link=%lu\n", indent_level, "", shdr->sh_link);
+ fprintf(f, "%*ssh_info=%lu\n", indent_level, "", shdr->sh_info);
+ fprintf(f, "%*ssh_addralign=%lu\n", indent_level, "", shdr->sh_addralign);
+ fprintf(f, "%*ssh_entsize=%lu\n", indent_level, "", shdr->sh_entsize);
+}
+
+/* Converts an ELF-32 relocation (non-addend) entry into little endian bytes */
+void
+elf32_write_rel(unsigned char **bufp, Elf32_Rel *rel)
+{
+ YASM_WRITE_32_L(*bufp, rel->r_offset);
+ YASM_WRITE_32_L(*bufp, rel->r_info);
+}
+
+/* Converts an ELF-32 symbol table entry into little endian bytes */
+void
+elf32_write_sym(unsigned char **bufp, Elf32_Sym *sym)
+{
+ YASM_WRITE_32_L(*bufp, sym->st_name);
+ YASM_WRITE_32_L(*bufp, sym->st_value);
+ YASM_WRITE_32_L(*bufp, sym->st_size);
+ YASM_WRITE_8(*bufp, sym->st_info);
+ YASM_WRITE_8(*bufp, sym->st_other);
+ YASM_WRITE_16_L(*bufp, sym->st_shndx);
+}
/* Macro for constructing st_info from field values. */
#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
+void elf32_write_elf_header(unsigned char **bufp, Elf32_Ehdr *ehdr);
+void elf32_write_sect_header(unsigned char **bufp, Elf32_Shdr *shdr);
+void elf32_print_sect_header(FILE *f, int indent_level, Elf32_Shdr *shdr);
+void elf32_write_rel(unsigned char **bufp, Elf32_Rel *rel);
+void elf32_write_sym(unsigned char **bufp, Elf32_Sym *sym);
+
#endif /* !YASM_ELF32_H */
--- /dev/null
+# $IdPath$
+
+lib_LTLIBRARIES += yasm-win32.la
+
+yasm_win32_la_SOURCES = \
+ modules/objfmts/coff/coff-objfmt.c
+yasm_win32_la_LDFLAGS = -module -avoid-version -no-undefined
+yasm_win32_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen yasm-win32.la
+
+EXTRA_DIST += \
+ modules/objfmts/win32/tests/Makefile.inc
+
+include modules/objfmts/win32/tests/Makefile.inc
--- /dev/null
+# $IdPath$
+
+TESTS += \
+ modules/objfmts/win32/tests/win32_test.sh
+
+EXTRA_DIST += \
+ modules/objfmts/win32/tests/win32_test.sh \
+ modules/objfmts/win32/tests/win32test.c \
+ modules/objfmts/win32/tests/win32test.asm \
+ modules/objfmts/win32/tests/win32test.hex \
+ modules/objfmts/win32/tests/win32test.errwarn
--- /dev/null
+#! /bin/sh
+# $IdPath$
+${srcdir}/out_test.sh win32_test modules/objfmts/win32/tests "win32 objfmt" "-f win32" ".obj"
+exit $?
--- /dev/null
+; test source file for assembling to COFF
+; build with (under DJGPP, for example):
+; yasm -f coff cofftest.asm
+; gcc -o cofftest cofftest.c cofftest.o
+
+; This file should test the following:
+; [1] Define and export a global text-section symbol
+; [2] Define and export a global data-section symbol
+; [3] Define and export a global BSS-section symbol
+; [4] Define a non-global text-section symbol
+; [5] Define a non-global data-section symbol
+; [6] Define a non-global BSS-section symbol
+; [7] Define a COMMON symbol
+; [8] Define a NASM local label
+; [9] Reference a NASM local label
+; [10] Import an external symbol
+; [11] Make a PC-relative call to an external symbol
+; [12] Reference a text-section symbol in the text section
+; [13] Reference a data-section symbol in the text section
+; [14] Reference a BSS-section symbol in the text section
+; [15] Reference a text-section symbol in the data section
+; [16] Reference a data-section symbol in the data section
+; [17] Reference a BSS-section symbol in the data section
+
+[BITS 32]
+[GLOBAL _lrotate] ; [1]
+[GLOBAL _greet] ; [1]
+[GLOBAL _asmstr] ; [2]
+[GLOBAL _textptr] ; [2]
+[GLOBAL _selfptr] ; [2]
+[GLOBAL _integer] ; [3]
+[EXTERN _printf] ; [10]
+[COMMON _commvar 4] ; [7]
+
+[SECTION .text]
+
+; prototype: long lrotate(long x, int num);
+_lrotate: ; [1]
+ push ebp
+ mov ebp,esp
+ mov eax,[ebp+8]
+ mov ecx,[ebp+12]
+.label rol eax,1 ; [4] [8]
+ loop .label ; [9] [12]
+ mov esp,ebp
+ pop ebp
+ ret
+
+; prototype: void greet(void);
+_greet mov eax,[_integer] ; [14]
+ inc eax
+ mov [localint],eax ; [14]
+ push dword [_commvar]
+ mov eax,[localptr] ; [13]
+ push dword [eax]
+ push dword [_integer] ; [1] [14]
+ push dword _printfstr ; [13]
+ call _printf ; [11]
+ add esp,16
+ ret
+
+[SECTION .data]
+
+; a string
+_asmstr db 'hello, world', 0 ; [2]
+
+; a string for Printf
+_printfstr db "integer==%d, localint==%d, commvar=%d"
+ db 10, 0
+
+; some pointers
+localptr dd localint ; [5] [17]
+_textptr dd _greet ; [15]
+_selfptr dd _selfptr ; [16]
+
+[SECTION .bss]
+
+; an integer
+_integer resd 1 ; [3]
+
+; a local integer
+localint resd 1 ; [6]
--- /dev/null
+/*
+ * test source file for assembling to COFF
+ * build with (under DJGPP, for example):
+ * yasm -f coff cofftest.asm
+ * gcc -o cofftest cofftest.c cofftest.o
+ */
+
+#include <stdio.h>
+
+extern int lrotate(long, int);
+extern void greet(void);
+extern char asmstr[];
+extern void *selfptr;
+extern void *textptr;
+extern int integer, commvar;
+
+int main(void) {
+
+ printf("Testing lrotate: should get 0x00400000, 0x00000001\n");
+ printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000,4));
+ printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000,14));
+
+ printf("This string should read `hello, world': `%s'\n", asmstr);
+
+ printf("The integers here should be 1234, 1235 and 4321:\n");
+ integer = 1234;
+ commvar = 4321;
+ greet();
+
+ printf("These pointers should be equal: %p and %p\n",
+ &greet, textptr);
+
+ printf("So should these: %p and %p\n", selfptr, &selfptr);
+}
--- /dev/null
+4c
+01
+03
+00
+00
+00
+00
+00
+70
+01
+00
+00
+10
+00
+00
+00
+00
+00
+0c
+01
+2e
+74
+65
+78
+74
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+8c
+00
+00
+00
+cc
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+20
+00
+50
+60
+2e
+64
+61
+74
+61
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+12
+01
+00
+00
+52
+01
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+40
+00
+30
+c0
+2e
+62
+73
+73
+00
+00
+00
+00
+80
+00
+00
+00
+00
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+80
+00
+30
+c0
+55
+89
+e5
+8b
+45
+08
+8b
+4d
+0c
+d1
+c0
+e2
+fc
+89
+ec
+5d
+c3
+a1
+00
+00
+00
+00
+40
+a3
+04
+00
+00
+00
+ff
+35
+00
+00
+00
+00
+a1
+34
+00
+00
+00
+ff
+30
+ff
+35
+00
+00
+00
+00
+68
+0d
+00
+00
+00
+e8
+00
+00
+00
+00
+81
+c4
+10
+00
+00
+00
+c3
+12
+00
+00
+00
+0e
+00
+00
+00
+06
+00
+18
+00
+00
+00
+0e
+00
+00
+00
+06
+00
+1e
+00
+00
+00
+0b
+00
+00
+00
+06
+00
+23
+00
+00
+00
+0c
+00
+00
+00
+06
+00
+2b
+00
+00
+00
+0e
+00
+00
+00
+06
+00
+30
+00
+00
+00
+0c
+00
+00
+00
+06
+00
+35
+00
+00
+00
+0a
+00
+00
+00
+14
+00
+68
+65
+6c
+6c
+6f
+2c
+20
+77
+6f
+72
+6c
+64
+00
+69
+6e
+74
+65
+67
+65
+72
+3d
+3d
+25
+64
+2c
+20
+6c
+6f
+63
+61
+6c
+69
+6e
+74
+3d
+3d
+25
+64
+2c
+20
+63
+6f
+6d
+6d
+76
+61
+72
+3d
+25
+64
+0a
+00
+04
+00
+00
+00
+11
+00
+00
+00
+3c
+00
+00
+00
+34
+00
+00
+00
+0e
+00
+00
+00
+06
+00
+38
+00
+00
+00
+02
+00
+00
+00
+06
+00
+3c
+00
+00
+00
+0c
+00
+00
+00
+06
+00
+2e
+66
+69
+6c
+65
+00
+00
+00
+00
+00
+00
+00
+fe
+ff
+00
+00
+67
+01
+2d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+2e
+74
+65
+78
+74
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+03
+01
+40
+00
+00
+00
+07
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+5f
+6c
+72
+6f
+74
+61
+74
+65
+00
+00
+00
+00
+01
+00
+00
+00
+02
+00
+5f
+67
+72
+65
+65
+74
+00
+00
+11
+00
+00
+00
+01
+00
+00
+00
+02
+00
+5f
+61
+73
+6d
+73
+74
+72
+00
+00
+00
+00
+00
+02
+00
+00
+00
+02
+00
+5f
+74
+65
+78
+74
+70
+74
+72
+38
+00
+00
+00
+02
+00
+00
+00
+02
+00
+5f
+73
+65
+6c
+66
+70
+74
+72
+3c
+00
+00
+00
+02
+00
+00
+00
+02
+00
+5f
+69
+6e
+74
+65
+67
+65
+72
+00
+00
+00
+00
+03
+00
+00
+00
+02
+00
+5f
+70
+72
+69
+6e
+74
+66
+00
+00
+00
+00
+00
+00
+00
+00
+00
+02
+00
+5f
+63
+6f
+6d
+6d
+76
+61
+72
+04
+00
+00
+00
+00
+00
+00
+00
+02
+00
+2e
+64
+61
+74
+61
+00
+00
+00
+00
+00
+00
+00
+02
+00
+00
+00
+03
+01
+40
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+2e
+62
+73
+73
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+00
+00
+03
+01
+08
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+00
+00
*/
#define YASM_LIB_INTERNAL
#define YASM_BC_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
%{
#define YASM_LIB_INTERNAL
#define YASM_EXPR_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
RCSID("$IdPath$");
#ifdef STDC_HEADERS
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
/*@unused@*/ RCSID("$IdPath$");
#include "nasm-parser.h"
/* Define valid preprocessors to use with this parser */
static const char *nasm_parser_preproc_keywords[] = {
"raw",
+ "nasm",
+ "yapp",
NULL
};
* POSSIBILITY OF SUCH DAMAGE.
*/
#define YASM_LIB_INTERNAL
-#include "libyasm.h"
+#include <libyasm.h>
RCSID("$IdPath$");
#include "modules/parsers/nasm/nasm-parser.h"
s.tok = cursor; \
}
-#define TOKLEN (cursor-s.tok)
+#define TOKLEN (size_t)(cursor-s.tok)
typedef struct Scanner {
YYCTYPE *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
if(!s.eof){
size_t cnt = s.tok - s.bot;
if(cnt){
- memcpy(s.bot, s.tok, s.lim - s.tok);
+ memcpy(s.bot, s.tok, (size_t)(s.lim - s.tok));
s.tok = s.bot;
s.ptr -= cnt;
cursor -= cnt;
if (!s.bot)
first = 1;
if((s.top - s.lim) < BSIZE){
- char *buf = yasm_xmalloc((s.lim - s.bot) + BSIZE);
- memcpy(buf, s.tok, s.lim - s.tok);
+ char *buf = yasm_xmalloc((size_t)(s.lim - s.bot) + BSIZE);
+ memcpy(buf, s.tok, (size_t)(s.lim - s.tok));
s.tok = buf;
s.ptr = &buf[s.ptr - s.bot];
cursor = &buf[cursor - s.bot];
e = scalarvect (nasm_reloc_value(e) << nasm_reloc_value(f));
break;
case TOKEN_SHR:
- e = scalarvect (((unsigned long)nasm_reloc_value(e)) >>
- nasm_reloc_value(f));
+ e = scalarvect ((long)(((unsigned long)nasm_reloc_value(e)) >>
+ nasm_reloc_value(f)));
break;
}
}
if (nasm_is_just_unknown(e) || nasm_is_just_unknown(f))
e = unknown_expr();
else
- e = scalarvect (((unsigned long)nasm_reloc_value(e)) /
- ((unsigned long)nasm_reloc_value(f)));
+ e = scalarvect ((long)(((unsigned long)nasm_reloc_value(e)) /
+ ((unsigned long)nasm_reloc_value(f))));
break;
case '%':
if (nasm_is_just_unknown(e) || nasm_is_just_unknown(f))
e = unknown_expr();
else
- e = scalarvect (((unsigned long)nasm_reloc_value(e)) %
- ((unsigned long)nasm_reloc_value(f)));
+ e = scalarvect ((long)(((unsigned long)nasm_reloc_value(e)) %
+ ((unsigned long)nasm_reloc_value(f))));
break;
case TOKEN_SDIV:
if (nasm_is_just_unknown(e) || nasm_is_just_unknown(f))
static char *
check_tasm_directive(char *line)
{
- int i, j, k, m, len;
+ int i, j, k, m;
+ size_t len;
char *p = line, *oldline, oldchar;
/* Skip whitespace */
static char *
prepreproc(char *line)
{
- int lineno, fnlen;
+ int lineno;
+ size_t fnlen;
char *fname, *oldline;
if (line[0] == '#' && line[1] == ' ')
fname++;
fnlen = strcspn(fname, "\"");
line = nasm_malloc(20 + fnlen);
- sprintf(line, "%%line %d %.*s", lineno, fnlen, fname);
+ sprintf(line, "%%line %d %.*s", lineno, (int)fnlen, fname);
nasm_free(oldline);
}
if (tasm_compatible_mode)
hash(char *s)
{
unsigned int h = 0;
- int i = 0;
+ unsigned int i = 0;
/*
* Powers of three, mod 31.
*/
{
long offset = p - buffer;
bufsize += BUF_DELTA;
- buffer = nasm_realloc(buffer, bufsize);
+ buffer = nasm_realloc(buffer, (size_t)bufsize);
p = buffer + offset; /* prevent stale-pointer problems */
}
}
{
if (txtlen == 0)
txtlen = strlen(text);
- t->text = nasm_malloc(1 + txtlen);
- strncpy(t->text, text, txtlen);
+ t->text = nasm_malloc(1 + (size_t)txtlen);
+ strncpy(t->text, text, (size_t)txtlen);
t->text[txtlen] = '\0';
}
return t;
len += strlen(t->text);
}
}
- p = line = nasm_malloc(len + 1);
+ p = line = nasm_malloc((size_t)len + 1);
for (t = tlist; t; t = t->next)
{
if (t->type == TOK_WHITESPACE)
macro_start = nasm_malloc(sizeof(*macro_start));
macro_start->next = NULL;
- make_tok_num(macro_start, strlen(t->text) - 2);
+ make_tok_num(macro_start, (int)strlen(t->text) - 2);
macro_start->mac = NULL;
/*
macro_start->next = NULL;
macro_start->text = nasm_strdup("'''");
if (evalresult->value > 0
- && evalresult->value < strlen(t->text) - 1)
+ && evalresult->value < (int)strlen(t->text) - 1)
{
macro_start->text[1] = t->text[evalresult->value];
}
void nasm_quote(char **str)
{
- int ln=strlen(*str);
+ size_t ln=strlen(*str);
char q=(*str)[0];
char *p;
if (ln>1 && (*str)[ln-1]==q && (q=='"' || q=='\''))
}
}
-void
+static void
replay_saved_tokens(char *ident,
struct source_head *from_head,
struct source_head *to_head,
yapp_preproc_input(char *buf, size_t max_size)
{
static YAPP_State state = YAPP_STATE_INITIAL;
- int n = 0;
+ size_t n = 0;
int token;
int need_line_directive = 0;
- while (saved_length < max_size && state != YAPP_STATE_EOF)
+ while ((size_t)saved_length < max_size && state != YAPP_STATE_EOF)
{
token = yapp_preproc_lex();
/* string/character constant values */
["'] {
- int inch, count;
+ int inch;
+ size_t count;
char endch = yytext[0];
strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
--- /dev/null
+#!/usr/bin/perl
+my @sourcelines = <>;
+my %usedlabel;
+my %usedvar;
+my $lastusedvarline = 0;
+my $level = 0;
+my $line = 1;
+for (@sourcelines) {
+ $usedlabel{"$1:"} = "$1:" if m/goto\s+(yy[0-9]*)\s*;/;
+ $level = $level + 1 if m/\{/;
+ $level = $level - 1 if m/\}/;
+ if ($level < $usedvar{$lastusedvarline}) {
+ $lastusedvarline = 0;
+ }
+ if (m/int\s+yyaccept/) {
+ $usedvar{$line} = $level;
+ $lastusedvarline = $line;
+ } elsif (m/yyaccept/) {
+ $usedvar{$lastusedvarline} = 1000;
+ }
+ $line = $line + 1;
+}
+$line = 1;
+for (@sourcelines) {
+ s/^(yy[0-9]*:)/$usedlabel{$1}/;
+ if ($usedvar{$line} != 0 && $usedvar{$line} != 1000) {
+ print "\n";
+ } else {
+ print;
+ }
+ $line = $line + 1;
+}
# include <stdarg.h>
#if defined(YASM_LIB_AC_INTERNAL) && defined(HAVE_CONFIG_H)
-# include "libyasm/config.h"
+# include <libyasm/config.h>
#endif
#if !defined(lint) && !defined(NDEBUG)
#endif /*YASM_AUTOCONF_INTERNAL*/
-#include "libyasm/compat-queue.h"
+#include <libyasm/compat-queue.h>
#if defined(YASM_AUTOCONF_INTERNAL) && defined(HAVE_SYS_CDEFS_H)
# include <sys/cdefs.h>
#endif /*YASM_INTERNAL*/
-#include "libyasm/coretype.h"
+#include <libyasm/coretype.h>
-#include "libyasm/valparam.h"
+#include <libyasm/valparam.h>
#endif