]> granicus.if.org Git - yasm/log
yasm
19 years agoImplement align and org bytecodes. While we're here, implement .zero
Peter Johnson [Mon, 3 Oct 2005 05:52:04 +0000 (05:52 -0000)]
Implement align and org bytecodes.  While we're here, implement .zero
directive for GAS (it's generated by GCC).

* bytecode.c (bytecode_align): Update for full align implementation.
(yasm_bc_create_align): Likewise.
(bc_align_finalize): New.
(bc_align_resolve, bc_align_tobytes): Real implementation.
* bytecode.h (yasm_bc_create_align): Update to match.
* arch.h (get_fill, yasm_arch_get_fill): New, to get NOP fill patterns.
* x86arch.c (x86_get_fill): Implement.
* lc3barch.c (lc3b_get_fill): Likewise (probably buggy, there's no real NOP).

* bytecode.c (bytecode_org): New org bytecode.
(bc_org_callback, bc_org_destroy, bc_org_print, bc_org_resolve)
(bc_org_tobytes, yasm_bc_create_org): Implement.

* gas-parser.h (yasm_parser_gas): Add code_section flag to indicate when to
use code fill vs. data fill.
* gas-parser.c: Initialize flag.
* gas-bison.y: Update flag in various places.  Generate org bytecode.
Call gas_parser_align to generate align bytecode.
(gas_parser_align): Generate align bytecode.

* gas-bison.y: Implement .zero directive.
* gas-token.re: Likewise.

* align32, align64: New tests to test align directive NOP generation.

svn path=/trunk/yasm/; revision=1263

19 years ago* x86id.re (push_insn): Turn on signed 8-bit optimization for GAS mode.
Peter Johnson [Mon, 3 Oct 2005 00:12:08 +0000 (00:12 -0000)]
* x86id.re (push_insn): Turn on signed 8-bit optimization for GAS mode.
Don't do this yet for NASM mode; this could be done e.g. through use of
the strict modifier.

svn path=/trunk/yasm/; revision=1262

19 years ago* x86id.re (push_insn, incdec_insn): Fix for GAS parser.
Peter Johnson [Sun, 2 Oct 2005 20:38:29 +0000 (20:38 -0000)]
* x86id.re (push_insn, incdec_insn): Fix for GAS parser.

svn path=/trunk/yasm/; revision=1261

19 years ago* x86id.re (test_insn): Add GAS suffix flags.
Peter Johnson [Sun, 2 Oct 2005 02:31:26 +0000 (02:31 -0000)]
* x86id.re (test_insn): Add GAS suffix flags.

svn path=/trunk/yasm/; revision=1260

19 years ago* x86bc.c (yasm_x86__ea_create_expr, yasm_x86__ea_create_imm): Initialize
Peter Johnson [Sun, 2 Oct 2005 02:30:08 +0000 (02:30 -0000)]
* x86bc.c (yasm_x86__ea_create_expr, yasm_x86__ea_create_imm): Initialize
ea.strong to 0.

svn path=/trunk/yasm/; revision=1259

19 years agoTurn on export macro for win64 in addition to win32.
Peter Johnson [Sat, 1 Oct 2005 16:35:27 +0000 (16:35 -0000)]
Turn on export macro for win64 in addition to win32.

svn path=/trunk/yasm/; revision=1258

19 years agoRevert [1251]. From further investigation, ML64's generation of REL32 in
Peter Johnson [Sat, 1 Oct 2005 05:47:54 +0000 (05:47 -0000)]
Revert [1251].  From further investigation, ML64's generation of REL32 in
these cases seems to be a bug.  If you get a linker error about ADDR32, it
means you aren't using RIP-relative instructions.  Note this means to access
an array you need to do:
  lea rax, [var wrt rip] ; generates RIP-relative insn and REL32 reloc
  mov rcx, [rax+rbx]     ; rbx is index
and not:
  mov rcx, [var+rbx]     ; generates ADDR32 reloc
At least when trying to build a DLL (the ADDR32 reloc fails the DLL link).
When building statically, ADDR32 should work okay and thus the latter form
can be used.

svn path=/trunk/yasm/; revision=1257

19 years ago* coff-objfmt.c (coff_objfmt_output_expr): Try to match the new ML64's
Peter Johnson [Fri, 30 Sep 2005 04:03:59 +0000 (04:03 -0000)]
* coff-objfmt.c (coff_objfmt_output_expr): Try to match the new ML64's
output better by generating relocs directly to the symbol being relocated
rather than to the section.  Use a new coff_objfmt->win64 flag to
conditionalize this rather than just COFF_MACHINE_AMD64.
(coff_objfmt): New win64 flag.
(coff_objfmt_create, win32_objfmt_create, win64_objfmt_create): Initialize
flag.
(coff_objfmt_output): Turn on outputting all symbols in win64 mode so they
can be referenced by relocs.  This isn't quite correct: we should only turn
on the symbols that are actually used by relocs, but having them there
doesn't hurt linking; it only exposes all of the internal symbol names.

With these changes, yasm output matches the new ML64 output except for a
very few cases:
 - ML64 generates REL32 relocs when referencing objects in the same .text
section.  I cannot see how this is necessary because call instructions
don't generate REL32 relocs!  I currently do not plan on fixing this unless
it causes a problem.
 - ML64 generates ADDR32 relocs instead of REL32 relocs when loading a
32-bit register with the address of an object.  I will probably try to fix
this.

Extended test case for this a bit.

svn path=/trunk/yasm/; revision=1256

19 years ago* x86id.re: Unbreak movq for NASM parser. I accidentally overrode it when
Peter Johnson [Thu, 29 Sep 2005 05:13:26 +0000 (05:13 -0000)]
* x86id.re: Unbreak movq for NASM parser.  I accidentally overrode it when
defining the mov forms for GAS.  While I'm here, fix movq so it also
supports the 64-bit move registers (per Intel's spec, AMD has it under movd)
and copy the MMX/SSE2 versions of movq into mov so they're visible to the
GAS parser (and only the GAS parser).

Add a whole bunch of testcases to test movd and movq in both 32 bit and 64
bit modes for both GAS and NASM parsers.

svn path=/trunk/yasm/; revision=1255

19 years ago* Fix win64/tests/Makefile.inc that was causing distcheck breakage.
Peter Johnson [Thu, 29 Sep 2005 05:10:29 +0000 (05:10 -0000)]
* Fix win64/tests/Makefile.inc that was causing distcheck breakage.

svn path=/trunk/yasm/; revision=1254

19 years agoUpdate VC build files for GAS parser.
Peter Johnson [Wed, 28 Sep 2005 06:07:24 +0000 (06:07 -0000)]
Update VC build files for GAS parser.

svn path=/trunk/yasm/; revision=1253

19 years ago- Add win64 as an alias for -f win32 -m amd64.
Peter Johnson [Wed, 28 Sep 2005 05:50:51 +0000 (05:50 -0000)]
- Add win64 as an alias for -f win32 -m amd64.
- Add elf32 as an alias for -f elf.
- Add elf64 as an alias for -f elf -m amd64.
Note the old command lines still work.

Add a testcase for win64 (includes masm -> yasm mapping, look at
win64-dataref.masm and win64-dataref.asm files respectively).

svn path=/trunk/yasm/; revision=1252

19 years ago* coff-objfmt.c (coff_objfmt_output_expr): Change relocations output for
Peter Johnson [Wed, 28 Sep 2005 03:23:24 +0000 (03:23 -0000)]
* coff-objfmt.c (coff_objfmt_output_expr): Change relocations output for
instructions in Win64 to always be REL32 regardless of whether they're
RIP relative or not.  I don't understand this behavior, but it matches how
ML64 generates relocs and unbreaks linking.  The handling of this case must
be handled at a higher level somehow (either at the linker or the compiler).
Note that this REL32 generation behavior of ML64 happens only with the
latest version (VC8); the 2003 SP1 SDK ML64 doesn't do this.

* bytecode.c (yasm_bc_is_data): New supporting function.
* bytecode.h (yasm_bc_is_data): Prototype.

Testcase pending.

Reported by and much debugging support contributed by:
  Brian Gladman <brg@gladman.plus.com>. Thanks!

svn path=/trunk/yasm/; revision=1251

19 years ago* gas-bison.y: Change instructions and prefixes back into identifiers if
Peter Johnson [Tue, 27 Sep 2005 07:16:17 +0000 (07:16 -0000)]
* gas-bison.y: Change instructions and prefixes back into identifiers if
used as an identifier.
* varinsn.*: Test for this.

svn path=/trunk/yasm/; revision=1250

19 years agoSplit arch module parse_check_id into parse_check_reg, parse_check_reggroup,
Peter Johnson [Tue, 27 Sep 2005 07:07:07 +0000 (07:07 -0000)]
Split arch module parse_check_id into parse_check_reg, parse_check_reggroup,
parse_check_segreg, parse_check_insn, parse_check_prefix, and
parse_check_targetmod.  This will allow for future improvements to
identifier handling in the various parsers.

svn path=/trunk/yasm/; revision=1249

19 years ago* gas-bison.y: Allow .data, .text, and .bss to be used in expressions (they
Peter Johnson [Tue, 27 Sep 2005 03:46:34 +0000 (03:46 -0000)]
* gas-bison.y: Allow .data, .text, and .bss to be used in expressions (they
come through as unique directive tokens, not as DIR_ID).
* dataref-imm.*: Test for this.

svn path=/trunk/yasm/; revision=1248

19 years ago* x86id.re (DEF_INSN_DATA): OR in data[3] rather than setting it directly.
Peter Johnson [Mon, 26 Sep 2005 07:52:25 +0000 (07:52 -0000)]
* x86id.re (DEF_INSN_DATA): OR in data[3] rather than setting it directly.
(yasm_x86__finalize_insn): Ignore special suffix value 0x80 when matching
in info, but use strict matching.  This unbreaks jmp/call broken in previous
commit.
(yasm_x86__parse_check_insn): Initialize data[3] and for FLDT and FSTPT, set
special suffix value 0x80.

svn path=/trunk/yasm/; revision=1247

19 years ago* x86id.re: Implement GAS handling for floating point, some extensions,
Peter Johnson [Mon, 26 Sep 2005 07:06:27 +0000 (07:06 -0000)]
* x86id.re: Implement GAS handling for floating point, some extensions,
interrupts, conditional movs/sets, and a few other minor things.  What's
left: string insns, loop insns, other jmp/call forms, protection control,
SSE/SSE2, and odds and ends (like prefixes-as-instructions).

Add an incomplete FP testcase.

svn path=/trunk/yasm/; revision=1246

19 years ago* x86expr.c (yasm_x86__expr_checkea): Add address16_op parameter to avoid
Peter Johnson [Mon, 26 Sep 2005 04:17:09 +0000 (04:17 -0000)]
* x86expr.c (yasm_x86__expr_checkea): Add address16_op parameter to avoid
errors when using enter in 64-bit mode.
* x86arch.h (yasm_x86__expr_checkea): Update prototype.
* x86bc.c (x86_bc_insn_resolve, x86_bc_insn_tobytes): Pass flag to above.

* x86id.re: Implement mul, imul, div, idiv, enter, leave for GAS mode.
Add tests for above.

svn path=/trunk/yasm/; revision=1245

19 years ago* x86id.re (yasm_x86__parse_check_insn): Implement GAS versions of pushf,
Peter Johnson [Mon, 26 Sep 2005 00:43:28 +0000 (00:43 -0000)]
* x86id.re (yasm_x86__parse_check_insn): Implement GAS versions of pushf,
popf, and conversion instructions (cbw, etc).

Add test case for conversion instructions.

svn path=/trunk/yasm/; revision=1244

19 years ago* x86id.re (yasm_x86__parse_check_insn): Enable lahf/sahf for 64-bit mode,
Peter Johnson [Mon, 26 Sep 2005 00:07:33 +0000 (00:07 -0000)]
* x86id.re (yasm_x86__parse_check_insn): Enable lahf/sahf for 64-bit mode,
as these are supported on newer processor steppings.

Add testcase for lahf/sahf in all BITS modes.

svn path=/trunk/yasm/; revision=1243

19 years ago* x86id.re: For GAS, implement movsx/movzx, pushal, popal, xchg, in, out,
Peter Johnson [Mon, 26 Sep 2005 00:03:02 +0000 (00:03 -0000)]
* x86id.re: For GAS, implement movsx/movzx, pushal, popal, xchg, in, out,
and l*s.

Add tests for in/out and movsx/movzx in GAS mode.

svn path=/trunk/yasm/; revision=1242

19 years agoMove gas_amd64_test.sh to x86_gas64_test.sh to match path.
Peter Johnson [Sun, 25 Sep 2005 20:23:40 +0000 (20:23 -0000)]
Move gas_amd64_test.sh to x86_gas64_test.sh to match path.

svn path=/trunk/yasm/; revision=1241

19 years agoMove parsers/gas/tests/amd64 to arch/x86/tests/gas64, as the tests going
Peter Johnson [Sun, 25 Sep 2005 20:19:05 +0000 (20:19 -0000)]
Move parsers/gas/tests/amd64 to arch/x86/tests/gas64, as the tests going
here are really entirely implemented in the x86 arch.

After this commit, gas_amd64_test.sh needs to be renamed.

svn path=/trunk/yasm/; revision=1240

19 years agoPreliminary GAS parser. Only a few instructions are supported at present.
Peter Johnson [Sun, 25 Sep 2005 04:25:26 +0000 (04:25 -0000)]
Preliminary GAS parser.  Only a few instructions are supported at present.
This work is being done under contract with a company that has requested
to remain unnamed at the present time.

* bc-int.h (yasm_effaddr): Add strong flag to indicate if the effective
address is definitely an effective address; GAS does not use [] to designate
effective addresses so it's otherwise impossible to tell the difference
between "expr(,1)" and just "expr" (important for the relative jump
instructions).
* bytecode.h (yasm_ea_set_strong): New function to set the strong flag.
* bytecode.c (yasm_ea_set_strong): Implementation.
* x86bc.c (yasm_x86__ea_create_reg): Initialize strong flag.

* arch.h (yasm_insn_operand): Add deref flag to indicate use of "*foo" in
GAS syntax.
* arch.c (yasm_operand_create_reg, yasm_operand_create_segreg)
(yasm_operand_create_mem, yasm_operand_create_imm): Set deref flag to 0.

* gas: GAS syntax lexer and parser.  Not all directives are implemented yet
(some will require additional core bytecodes).

* elf-objfmt.c (elf_objfmt_section_switch): Add support for GAS-style
section flags.

* x86arch.h (yasm_arch_x86): Add parser setting.
* x86arch.c (x86_create): Check for gas parser and initialize setting.

* x86bc.c (yasm_x86__ea_create_expr): Transform val+RIP to val wrt RIP when
using the GAS parser (this is how GAS interprets "expr(%rip)").

* x86id.re: Too many changes to enumerate in detail.  Add new modifiers for
GAS suffixes.  Start using them in a couple instructions.  Split check_id
into subfunctions (still one entry point at present).
(yasm_x86__finalize_insn): Support new modifiers, reverse operands, derefs.

* yasm.c (main): Change all undef to extern when using GAS parser (this is
default GAS behavior).

svn path=/trunk/yasm/; revision=1239

19 years ago* arch.h (yasm_arch_reggroup_get_reg): Add macro implementation.
Peter Johnson [Sun, 25 Sep 2005 03:47:13 +0000 (03:47 -0000)]
* arch.h (yasm_arch_reggroup_get_reg): Add macro implementation.

svn path=/trunk/yasm/; revision=1238

19 years ago* genmodule.c (main): Make sure len is initialized to 0.
Peter Johnson [Sun, 25 Sep 2005 03:35:49 +0000 (03:35 -0000)]
* genmodule.c (main): Make sure len is initialized to 0.

* genmodule.vcproj: Ensure FILTERMODE is defined for Debug configuration.

Patch by: Masaru Tsuchiyama <tsuchiyama@asahi-net.email.ne.jp>

svn path=/trunk/yasm/; revision=1237

19 years ago* basic-optimizer.c (basic_optimize_bytecode_2): Fix check of
Peter Johnson [Sun, 25 Sep 2005 03:27:05 +0000 (03:27 -0000)]
* basic-optimizer.c (basic_optimize_bytecode_2): Fix check of
yasm_bc_resolve() return value (it's a flag, not a signed integer).

svn path=/trunk/yasm/; revision=1236

19 years ago* bytecode.h (yasm_dv_create_float): Remove (no implementation exists or is
Peter Johnson [Sun, 25 Sep 2005 03:23:54 +0000 (03:23 -0000)]
* bytecode.h (yasm_dv_create_float): Remove (no implementation exists or is
planned).

svn path=/trunk/yasm/; revision=1235

19 years ago* arch.h (yasm_arch_check_id_retval): Add YASM_ARCH_CHECK_ID_REGGROUP to
Peter Johnson [Sun, 25 Sep 2005 03:20:54 +0000 (03:20 -0000)]
* arch.h (yasm_arch_check_id_retval): Add YASM_ARCH_CHECK_ID_REGGROUP to
represent a register group (e.g. indexed registers).
(yasm_arch_reggroup_get_reg): New function to get a specific register from
a register group and index.
(yasm_arch_module): Add module version of yasm_arch_reggroup_get_reg().

* lc3barch.c (lc3b_reggroup_get_reg): Implement.
(yasm_lc3b_LTX_arch): Point to implementation.
* x86arch.c (x86_reggroup_get_reg, yasm_x86_LTX_arch): Likewise.

svn path=/trunk/yasm/; revision=1234

19 years ago* symrec.c (symtab_parser_finalize_checksym): Remove cruft that snuck into
Peter Johnson [Sun, 25 Sep 2005 01:06:00 +0000 (01:06 -0000)]
* symrec.c (symtab_parser_finalize_checksym): Remove cruft that snuck into
previous commit.

svn path=/trunk/yasm/; revision=1233

19 years ago* symrec.h (yasm_symtab_parser_finalize): Add function to declare all
Peter Johnson [Sun, 25 Sep 2005 01:01:02 +0000 (01:01 -0000)]
* symrec.h (yasm_symtab_parser_finalize): Add function to declare all
undefined symbols extern if unused rather than causing undef errors.
* symrec.c (yasm_symtab_parser_finalize): Implement.
(symtab_finalize_info): New (more data to pass to
(symtab_parser_finalize_checksym): Update finalize helper.

* yasm.c (main): Update call to yasm_symtab_parser_finalize().

svn path=/trunk/yasm/; revision=1232

19 years ago* coretype.h (yasm_expr_op): Add YASM_EXPR_NOR for NOR operator.
Peter Johnson [Sun, 25 Sep 2005 00:47:35 +0000 (00:47 -0000)]
* coretype.h (yasm_expr_op): Add YASM_EXPR_NOR for NOR operator.

* intnum.c (yasm_intnum_calc): Handle YASM_EXPR_NOR.
* expr.c (yasm_expr_print): Likewise.

svn path=/trunk/yasm/; revision=1231

19 years ago* arch.h (yasm_arch_syntax_flavor): Remove.
Peter Johnson [Sun, 25 Sep 2005 00:41:04 +0000 (00:41 -0000)]
* arch.h (yasm_arch_syntax_flavor): Remove.
(yasm_arch_create): Add parser and error parameters; now the arch is given
the keyword of the parser in use.  The error parameter allows the caller to
find out whether it was the machine name or the parser name that was in
error.
(yasm_arch_module): Change create definition to match yasm_arch_create().
(yasm_arch_create_error): New error typedef for yasm_arch_create() errors.

* lc3barch.c (lc3b_create): Update to match new yasm_arch_create().
* x86arch.c (x86_create): Likewise.

* yasm.c (main): Use new yasm_arch_create() and handle the two kinds of
errors it can now generate.  Move parser creation up in the sequence so it
happens before the arch is created.

svn path=/trunk/yasm/; revision=1230

19 years ago* x86bc.c (x86_bc_insn_resolve): When handling shift_op, change immlen
Peter Johnson [Sun, 25 Sep 2005 00:15:17 +0000 (00:15 -0000)]
* x86bc.c (x86_bc_insn_resolve): When handling shift_op, change immlen
rather than munging bc->len directly.

svn path=/trunk/yasm/; revision=1229

19 years ago* yasm.c (main): Add workaround for when -m amd64 is specified to override
Peter Johnson [Sun, 25 Sep 2005 00:09:30 +0000 (00:09 -0000)]
* yasm.c (main): Add workaround for when -m amd64 is specified to override
the object format default BITS setting.  This makes it so [bits 64] is not
necessary to explicitly specify in the source file.

svn path=/trunk/yasm/; revision=1228

19 years ago* x86bc.c (x86_bc_insn_resolve): Actually support the flag to allow
Peter Johnson [Sat, 24 Sep 2005 23:50:09 +0000 (23:50 -0000)]
* x86bc.c (x86_bc_insn_resolve): Actually support the flag to allow
shortening to signed 8-bit immediate from a larger immediate size.  This
yields much smaller code for many arithmetic instructions.

Noticed by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1227

19 years ago* elf-objfmt.c (elf_objfmt_output_section): Don't try to skip empty
Peter Johnson [Thu, 8 Sep 2005 05:01:32 +0000 (05:01 -0000)]
* elf-objfmt.c (elf_objfmt_output_section): Don't try to skip empty
sections.  This breaks section numbering between the file section headers
and the section numbering used by symbols to reference sections.

While we're here, don't even try to number sections during parse... this
numbering is getting overwritten anyway.

Fixes #59 (reported by hkmaly@gmail.com).

svn path=/trunk/yasm/; revision=1226

19 years agoFix VC build files.
Peter Johnson [Thu, 8 Sep 2005 02:00:08 +0000 (02:00 -0000)]
Fix VC build files.
 - _stdint.h for VC build (both 64-bit and 32-bit)
 - Handle spaces in genmodule/genmacro/re2c paths.

Patches by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1225

19 years ago* expr.c (expr_level_op): Fix corruption with certain types of complex
Peter Johnson [Wed, 7 Sep 2005 03:53:38 +0000 (03:53 -0000)]
* expr.c (expr_level_op): Fix corruption with certain types of complex
expressions by adjusting level_numterms if expr_simplify_identity changes
fold_numterms.

Reported by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1224

19 years ago* hamt.c: Use uintptr_t to correctly cast to integer from pointer. On some
Peter Johnson [Mon, 5 Sep 2005 20:53:07 +0000 (20:53 -0000)]
* hamt.c: Use uintptr_t to correctly cast to integer from pointer.  On some
platforms (notably Win64), unsigned long is not big enough to hold a
pointer.
* Makefile.am, configure.ac: Use ax_create_stdint_h to get us uintptr_t.
* ax_create_stdint_h.m4: Implementation of ax_create_stdint_h autoconf
macro from http://ac-archive.sourceforge.net/guidod/ax_create_stdint_h.html

svn path=/trunk/yasm/; revision=1223

19 years agoFix distcheck build breakage by including stamp-h1 instead of trying to
Peter Johnson [Tue, 30 Aug 2005 06:56:12 +0000 (06:56 -0000)]
Fix distcheck build breakage by including stamp-h1 instead of trying to
include source (which breaks when different build/source paths are used).

svn path=/trunk/yasm/; revision=1221

19 years ago* nasm-token.re (nasm_parser_lex): Fix #57 by recognizing "long" as an alias
Peter Johnson [Sat, 27 Aug 2005 17:13:32 +0000 (17:13 -0000)]
* nasm-token.re (nasm_parser_lex): Fix #57 by recognizing "long" as an alias
for "dword".

svn path=/trunk/yasm/; revision=1220

19 years ago* bytecode.c (bc_incbin_tobytes): Fix fread call so that return value check
Peter Johnson [Sat, 27 Aug 2005 02:05:36 +0000 (02:05 -0000)]
* bytecode.c (bc_incbin_tobytes): Fix fread call so that return value check
works (was broken for >1 byte files).
(yasm_bc_tobytes): Fix handling of bytecodes that are larger than provided
buffer.

Patch by: Stephen Polkowski <stephen@centtech.com>

svn path=/trunk/yasm/; revision=1219

19 years ago* x86id.re: Add support for AMD64 64-bit registers in SSE-2 cvt instructions.
Peter Johnson [Fri, 19 Aug 2005 03:25:48 +0000 (03:25 -0000)]
* x86id.re: Add support for AMD64 64-bit registers in SSE-2 cvt instructions.

Patch submitted by: Denis Godinho <asmcode@gmail.com>

svn path=/trunk/yasm/; revision=1216

19 years agocoff_objfmt.c: Add support for ADDR32NB relocations, and enable by default for
Peter Johnson [Thu, 4 Aug 2005 07:53:10 +0000 (07:53 -0000)]
coff_objfmt.c: Add support for ADDR32NB relocations, and enable by default for
the .pdata section.  This is needed for structured exception handling on AMD64.
Yasm in the long run should generate this info itself via the use of objfmt
specific directives.

Noticed By: Andrew Dunstan <a_dunstan@hotmail.com>

svn path=/trunk/yasm/; revision=1215

19 years agocoff_objfmt.c (coff_objfmt_section_switch): Default alignment to 16 bytes
Peter Johnson [Wed, 3 Aug 2005 07:05:09 +0000 (07:05 -0000)]
coff_objfmt.c (coff_objfmt_section_switch): Default alignment to 16 bytes
when in 64-bit mode.

svn path=/trunk/yasm/; revision=1214

19 years agoAdd support for ADDR64 relocations in 64-bit mode.
Peter Johnson [Wed, 3 Aug 2005 06:06:28 +0000 (06:06 -0000)]
Add support for ADDR64 relocations in 64-bit mode.
Change flags handling a bit and turn off the AR32WR flag in 64-bit mode.

svn path=/trunk/yasm/; revision=1213

19 years agoFix #53. This makes things like "es stosb" work.
Peter Johnson [Thu, 30 Jun 2005 03:57:56 +0000 (03:57 -0000)]
Fix #53.  This makes things like "es stosb" work.

Reported by: Dmitry Gokun <jedi@online.kharkov.ua>

svn path=/trunk/yasm/; revision=1212

19 years agoAdd -M option for Makefile dependency generation.
Peter Johnson [Wed, 29 Jun 2005 06:16:10 +0000 (06:16 -0000)]
Add -M option for Makefile dependency generation.

Initial patch by: Thomas Weidenmueller <thomas@reactsoft.com>

The NASM preprocessor implementation of this is ugly; the preprocessor
really needs a rewrite to clean it up, but there's other higher-priority
items on the TODO list.

svn path=/trunk/yasm/; revision=1211

19 years agoFix ENTER in BITS 32 mode: it was generating a bogus A16 override.
Peter Johnson [Tue, 28 Jun 2005 09:26:15 +0000 (09:26 -0000)]
Fix ENTER in BITS 32 mode: it was generating a bogus A16 override.
Also add warning if user tries to override address size on ENTER.

Noticed by: Dmitry <jedi@online.kharkov.ua>

svn path=/trunk/yasm/; revision=1210

19 years agoAdd Intel's P4 VMX instructions.
Peter Johnson [Tue, 28 Jun 2005 08:22:04 +0000 (08:22 -0000)]
Add Intel's P4 VMX instructions.

Initial patch: Stephen Polkowski <stephen@centtech.com>

Added test case and tightened up so that vmread/vmwrite to/from 32-bit reg
is illegal in 64-bit mode.

svn path=/trunk/yasm/; revision=1209

19 years agoFix a couple nits in the VC build.
Peter Johnson [Tue, 28 Jun 2005 04:16:22 +0000 (04:16 -0000)]
Fix a couple nits in the VC build.

Contributed by: Masaru Tsuchiyama <tsuchiyama@asahi-net.email.ne.jp>

svn path=/trunk/yasm/; revision=1208

19 years agoFix opcodes FINIT, FCLEX, UCOMISS, and UCOMISD.
Peter Johnson [Thu, 9 Jun 2005 02:38:42 +0000 (02:38 -0000)]
Fix opcodes FINIT, FCLEX, UCOMISS, and UCOMISD.

svn path=/trunk/yasm/; revision=1207

19 years ago* genmacro.c (main): Incorporate slightly modified version of David
Peter Johnson [Sat, 7 May 2005 04:37:48 +0000 (04:37 -0000)]
* genmacro.c (main): Incorporate slightly modified version of David
Woodhouse's fix of a memory corruption bug when the string is empty.

Source: https://www.redhat.com/archives/fedora-extras-commits/2005-February/msg00305.html

svn path=/trunk/yasm/; revision=1206

19 years agoFix #52 by updating flat and DJGPP Makefiles to match changes to how
Peter Johnson [Fri, 6 May 2005 03:25:34 +0000 (03:25 -0000)]
Fix #52 by updating flat and DJGPP Makefiles to match changes to how
nasm-macros.c is built.  Now they build genmacro and generate nasm-macros.c
at build time, as it's no longer contained in the distribution.

svn path=/trunk/yasm/; revision=1205

19 years agoAdd SSE3 (PNI) instruction support.
Peter Johnson [Mon, 2 May 2005 00:49:55 +0000 (00:49 -0000)]
Add SSE3 (PNI) instruction support.

* x86id.re (yasm_x86__parse_cpu): Add cases for "PRESCOTT", "SSE3", and "PNI".
(yasm_x86__parse_check_id): Add cases for all 13 new instructions.
Update FILD and FISTP so that common fildstp_insn can be used.
(lddqu_insn): New instruction format.
* x86arch.h (CPU_SSE3): New.  Renumber others.

* sse3.asm, sse3.hex, sse3.errwarn: New test case for SSE3 instructions.
* x86/tests/Makefile.inc: Include test in build.

svn path=/trunk/yasm/; revision=1204

19 years agoModify the output for 'make check' to be much less verbose, and thus
Michael Urman [Wed, 16 Mar 2005 05:26:35 +0000 (05:26 -0000)]
Modify the output for 'make check' to be much less verbose, and thus
much easier to see the bad news when necessary. Thanks go to Peter for
updates to the C tests. Kudos to him having us send most of our tests
through a single shell script!

svn path=/trunk/yasm/; revision=1203

19 years agoAdd `hidden' `internal' and `protected' symbol visibility types to
Michael Urman [Sat, 12 Mar 2005 05:06:50 +0000 (05:06 -0000)]
Add `hidden' `internal' and `protected' symbol visibility types to
global symbols in ELF. Search for STV_HIDDEN for explanations; these
don't seem to appear in the base ELF documentation.

Sample syntax:
    global foo:hidden

Inspiration and base patch provided by Oskari Saarenmaa under our BSD
license. This checkin tweaks and extends Oskari's patch and adds tests.

svn path=/trunk/yasm/; revision=1202

19 years ago* xdf-objfmt.c (XDF_MAGIC): Change to XDF version 2.0. No backwards
Peter Johnson [Sat, 5 Feb 2005 07:12:14 +0000 (07:12 -0000)]
* xdf-objfmt.c (XDF_MAGIC): Change to XDF version 2.0.  No backwards
compatibility with previous versions maintained.
(xdf_section_data): Add virtual address field.
(xdf_objfmt_output_section): Output in section header.
(xdf_objfmt_output): Adjust section header size to 40 bytes.
(xdf_objfmt_section_switch): Add "virtual=" valparam handling.
(xdf_section_data_destroy): Delete vaddr.
(xdf_section_data_print): Print vaddr.

* xdflong.hex, xdfprotect.hex, xdfother.hex: Update to XDF2 files.

* xdfversion.asm, xdfversion.errwarn, xdfvirtual.hex: Add testcase for
"virtual=" functionality.

* xdf.h (XDF_MAGIC): Update to XDF version 2.0
(SECTION_HEADER): Add s_vaddr field.
* xdfdump.c (print_section): Print virtual address.

svn path=/trunk/yasm/; revision=1201

19 years ago* configure.ac: Turn on -Wno-unused; this covers more warnings than the old
Peter Johnson [Sat, 29 Jan 2005 23:48:05 +0000 (23:48 -0000)]
* configure.ac: Turn on -Wno-unused; this covers more warnings than the old
-Wno-unused-parameter, but works on mingw gcc.

svn path=/trunk/yasm/; revision=1200

19 years ago* coff-objfmt.c (win32_objfmt_directive): New function that implements the
Peter Johnson [Sat, 29 Jan 2005 10:24:23 +0000 (10:24 -0000)]
* coff-objfmt.c (win32_objfmt_directive): New function that implements the
undocumented (in NASM) win32 object format "export" directive.
(yasm_win32_LTX_objfmt): Reference above instead of coff_objfmt_directive.
(coff_objfmt_section_switch): Add support for ".drectve" section.
(coff_objfmt_init_new_section): Refactored from coff_objfmt_section_switch.

* preproc.h (yasm_preproc_module): Add define_builtin for defining macros
before standard.mac macros are processed.
(yasm_preproc_builtin_define): Add prototype and macro to call above.
* raw-preproc.c (raw_preproc_define_builtin): Add (empty).
(yasm_raw_LTX_preproc): Use.
* nasm-preproc.c (nasm_preproc_define_builtin): Add wrapper around new
pp_builtin_define.
(yasm_nasm_LTX_preproc): Use.
* nasm-pp.h (pp_builtin_define): Add prototype.
* nasm-pp.c (builtindef): New list of builtin definitions.
(read_line): Iterate through builtindef.
(pp_builtin_define): Add to builtindef.

* standard.mac: Add wrapper around definition of ORG (only for bin objfmt),
add wrappered EXPORT definition.
* yasm.c (apply_preproc_builtins): Define __YASM_OBJFMT__ to selected objfmt.
(main): Call above in correct places.

* export.asm, export.hex, export.errwarn: New test for use of "export" macro
and directive.

svn path=/trunk/yasm/; revision=1199

19 years agoRemove 3 warnings that caused mingw build to break.
Peter Johnson [Tue, 25 Jan 2005 06:44:42 +0000 (06:44 -0000)]
Remove 3 warnings that caused mingw build to break.

svn path=/trunk/yasm/; revision=1198

19 years ago* yasm.c (options): Allow -i as a synonym for -I.
Peter Johnson [Mon, 24 Jan 2005 06:44:25 +0000 (06:44 -0000)]
* yasm.c (options): Allow -i as a synonym for -I.
* yasm-options.c (parse_cmdline): Make unrecognized options warnings instead
of errors.

These two changes make yasm more closely match the nasm command line.  The
long-term fix for this will be making a nasm-like frontend.

Requested by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1197

19 years ago* nasm-listfmt.c (nasm_listfmt_output_expr): Fix garbage due to non-simple
Peter Johnson [Mon, 24 Jan 2005 06:21:16 +0000 (06:21 -0000)]
* nasm-listfmt.c (nasm_listfmt_output_expr): Fix garbage due to non-simple
expressions by outputting a 0 if the expr does not have an intnum equivalent.
This is not a fix: the real fix will need to be changing how listfmts get the
final data bytes for a bytecode.  This "fix" only replaces the garbage with
0's, not the correct value (e.g. for relative jumps).

Found by: Albrecht Kleine <kleine@ak.sax.de>

svn path=/trunk/yasm/; revision=1196

19 years ago* configure.ac: Reorganize and add a few more extra GCC warnings.
Peter Johnson [Sat, 22 Jan 2005 01:18:08 +0000 (01:18 -0000)]
* configure.ac: Reorganize and add a few more extra GCC warnings.

* x86id.re (YYFILL): Silence "empty if" warnings.
* lc3bid.re (YYFILL): Likewise.

* elf.c (elf_null_machine): Fully specify initializer.

svn path=/trunk/yasm/; revision=1195

19 years ago* yasm.c (main): Make sure we check for undefined symbols before doing any
Peter Johnson [Fri, 21 Jan 2005 23:46:27 +0000 (23:46 -0000)]
* yasm.c (main): Make sure we check for undefined symbols before doing any
expression processing.  A crash is possible if we don't do this.

* nomem64-err.asm, nomem64-err.errwarn: New order forces split of this into:
* nomem64-err2.asm, nomem64-err2.errwarn: move two cases here.

Found by: Ewout Prangsma <ewout@prangsma.net>

svn path=/trunk/yasm/; revision=1194

19 years ago* nasm-token.re (nasm_parser_lex): b/q/h suffixes should be case-insensitive.
Peter Johnson [Wed, 19 Jan 2005 02:51:38 +0000 (02:51 -0000)]
* nasm-token.re (nasm_parser_lex): b/q/h suffixes should be case-insensitive.
* numcase.asm, numcase.errwarn, numcase.hex: Add testcases.

Noticed by: Albrecht Kleine <kleine@ak.sax.de>

svn path=/trunk/yasm/; revision=1193

19 years ago* symrec.c (yasm_symrec_print): Add SYM_SPECIAL to type switch.
Peter Johnson [Fri, 14 Jan 2005 05:27:33 +0000 (05:27 -0000)]
* symrec.c (yasm_symrec_print): Add SYM_SPECIAL to type switch.

svn path=/trunk/yasm/; revision=1192

19 years agoMove pregenerated man pages to root.
Peter Johnson [Fri, 14 Jan 2005 05:25:30 +0000 (05:25 -0000)]
Move pregenerated man pages to root.

svn path=/trunk/yasm/; revision=1191

19 years ago* symrec.h (yasm_symrec_declare): Rename rec parameter to symrec to match
Peter Johnson [Thu, 13 Jan 2005 07:17:06 +0000 (07:17 -0000)]
* symrec.h (yasm_symrec_declare): Rename rec parameter to symrec to match
documentation.

svn path=/trunk/yasm/; revision=1190

19 years agoChange how man pages are built (and where they are built to). Building man
Peter Johnson [Thu, 13 Jan 2005 07:14:48 +0000 (07:14 -0000)]
Change how man pages are built (and where they are built to).  Building man
pages should now be more consistent across systems.

* arch/Makefile.inc: Build yasm_arch.7 at top level, and in dist_man_MANS
instead of man_MANS.  Include build rule for building using XMLTO if XMLTO
is available.
* yasm/Makefile.inc: Likewise (for yasm.1).
* Makefile.am: Change man_MANS to dist_man_MANS.  Remove general rules for
.xml.1 and .xml.7.  Add dist_man_MANS to MAINTAINERCLEANFILES.  Remove
man_MANS from BUILT_SOURCES, DISTCLEANFILES, and EXTRA_DIST.

svn path=/trunk/yasm/; revision=1189

19 years agoAdd some abilities to base symrec so that it can be more effectively used by
Peter Johnson [Wed, 12 Jan 2005 07:53:04 +0000 (07:53 -0000)]
Add some abilities to base symrec so that it can be more effectively used by
object formats without creating duplicate lists of symbols.  XDF and COFF
were updated; ELF needs to reorder the symbols on its own, so for now it's
not been updated to use the common implementation.

* hamt.c (HAMTEntry, HAMT, HAMT_destroy)
(HAMT_insert): Change SLIST to STAILQ.

* symrec.c (sym_type): Add SYM_SPECIAL.
(yasm_symtab_define_special): New.
(yasm_symrec_declare): New; includes all functionality from symtab_declare.
(yasm_symtab_declare): Call yasm_symrec_declare now.
(yasm_symrec_is_special): New.
* symrec.h: Add prototypes for above.

* xdf-objfmt.c: Use symrec_data instead of declaring xdf_symtab.
* xdflong.hex, xdfprotect.hex, xdfother.hex: Update due to symbol reordering.

* coff-objfmt.c: Use symrec_data instead of declaring coff_symtab.

* elftimes.hex, elfso.hex, elfabssect.hex: Update due to symbol reordering.
* elfglobext.hex, elf-x86id.hex, elftest.hex, elfso64.hex: Likewise.
* stabs-elf.hex: Likewise.

svn path=/trunk/yasm/; revision=1188

20 years agoFix up VC, flat, DJ build files to match build changes made in [1183].
Peter Johnson [Tue, 7 Dec 2004 08:05:51 +0000 (08:05 -0000)]
Fix up VC, flat, DJ build files to match build changes made in [1183].

svn path=/trunk/yasm/; revision=1187

20 years agoFix free-before-use case in x86 finalize code. Bytecode transformation
Peter Johnson [Fri, 3 Dec 2004 06:09:30 +0000 (06:09 -0000)]
Fix free-before-use case in x86 finalize code.  Bytecode transformation
deletes the old bytecode, so it's not safe to use anything from the old
bytecode after this point (such as the prefixes array passed to arch
finalize).

 * x86bc.c (yasm_x86__bc_apply_prefixes): Take x86_common as parameter
rather than bytecode; add line parameter instead of referencing bc->line.
 * x86arch.h (yasm_x86__bc_apply_prefixes): Likewise.
 * x86id.re (x86_finalize_jmpfar, x86_finalize_jmp)
(yasm_x86__finalize_insn): Apply prefixes before bytecode transform.

svn path=/trunk/yasm/; revision=1186

20 years ago * Makefile.inc: Remove nasm-macros.c from SOURCES; having it there was
Peter Johnson [Thu, 2 Dec 2004 04:05:20 +0000 (04:05 -0000)]
 * Makefile.inc: Remove nasm-macros.c from SOURCES; having it there was
causing it to be built as a standalone file (it's not; it's #included into
one of the other source files).

svn path=/trunk/yasm/; revision=1185

20 years agoSince modules are now built into libyasm, it's no longer necessary to
Peter Johnson [Wed, 1 Dec 2004 08:09:43 +0000 (08:09 -0000)]
Since modules are now built into libyasm, it's no longer necessary to
version them.

 * parser.h, dbgfmt.h, objfmt.h, listfmt.h, optimizer.h, preproc.h, arch.h:
Remove YASM_xxx_VERSION and version module structure member.
 * (many) .c: Don't initialize version module structure member.

svn path=/trunk/yasm/; revision=1184

20 years agoGreatly simplify build system by removing libtool and integrating formerly
Peter Johnson [Wed, 1 Dec 2004 07:49:18 +0000 (07:49 -0000)]
Greatly simplify build system by removing libtool and integrating formerly
dynamically loaded modules into the now-static libyasm.  I now anticipate
that there would be very few users of the dynamic loading features, and it
yielded a lot of instability and build headaches for very little benefit.
The new build should now be much more cross-platform and faster (there was
a lot of overhead in finding and loading modules).

 * libtool.m4, ltdl.m4: Delete.
 * m4/Makefile.am: Rename to m4/Makefile.inc and remove references to above.
   Change to use subdirectory (flat) build rather than recursive build.
 * Makefile.am: Include m4/Makefile.inc rather than having it in SUBDIRS.
 * libltdl: Delete.

 * frontends/yasm/yasm-module.c: Delete.
 * basename.c, dirname.c: Delete (no longer needed by yasm-module.c).
 * genmodule.c, module.in: Generator and template for new module.c included
   in libyasm that replaces the old yasm-module.c (module.in is a modified
   rename of yasm-module.c).
 * module.h: Modified rename of old yasm-module.h.
 * libyasm.h: Include libyasm/module.h.
 * libyasm/Makefile.inc: Build generator and include module.c in libyasm.
 * yasm.c: Use new libyasm module interface.

 * (many) Makefile.inc: Remove libtool libraries, build all modules into
   libyasm library.

 * configure.ac: Remove libtool/libltdl references.

 * Mkfiles/vc/yasm-module.c: Remove.  Still need to fix some of the other
   Mkfiles/ build files for these changes.

svn path=/trunk/yasm/; revision=1183

20 years agoRefactor some the x86 bytecode handling now that we parse the entire file
Peter Johnson [Thu, 18 Nov 2004 06:17:35 +0000 (06:17 -0000)]
Refactor some the x86 bytecode handling now that we parse the entire file
before finalizing instructions.

* x86arch.h (yasm_x86__bc_apply_prefixes): Don't take num_segregs and
prefixes parameters.
* x86bc.c (yasm_x86__bc_apply_prefixes): Move segreg code to...
* x86id.re (yasm_x86__finalize_insn): Here (only user of this code).
(x86_finalize_jmp): Don't pass num_segregs and prefixes.

* x86arch.h (x86_common): New; refactored common bytecode parameters.
(x86_opcode): New; refactored opcode parameters.
(x86_insn): Refactor with x86_common and x86_opcode.
(x86_jmp): Likewise.
* x86id.re (x86_finalize_common, x86_finalize_opcode): New.
(yasm_x86__finalize_insn, x86_finalize_jmp): Use and update substruct refs.
* x86bc.c (x86_common_print, x86_opcode_print): New.
(x86_bc_insn_print, x86_bc_jmp_print): Use and update substruct refs.
(x86_common_resolve): New.
(x86_bc_insn_resolve, x86_bc_jmp_resolve): Use and update substruct refs.
(x86_common_tobytes, x86_opcode_tobytes): New.
(x86_bc_insn_tobytes, x86_bc_jmp_tobytes): Use and update substruct refs.
(yasm_x86__bc_apply_prefixes): Utilize refactor to simplify.

* bytecode.c (bc_insn_finalize): Simplify (or at least level) immediates
and memory operands before passing them off to yasm_arch_finalize_insn().
This may result in some minor performance improvement on complex static
expressions.

* x86arch.h (x86_parse_targetmod): Add X86_FAR_SEGOFF; this is only
generated due to a SEG:OFF immediate being detected during finalize.
(x86_jmp_opcode_sel): Remove JMP_FAR; this is now a separate bytecode.
(x86_jmp): Remove far opcode.
(x86_jmpfar): New bytecode for far jumps.
(yasm_x86__bc_transform_jmpfar): New.
* x86bc.c (x86_bc_callback_jmpfar): New.
(yasm_x86__bc_transform_jmpfar, x86_bc_jmpfar_destroy): New.
(x86_bc_jmp_print): Move far jump code to..
(x86_bc_jmpfar_print): Here (new).
(x86_bc_jmp_resolve, x86_bc_jmpfar_resolve): Likewise (latter new).
(x86_bc_jmp_tobytes, x86_bc_jmpfar_tobytes): Likewise (latter new).
* x86id.re (OPAP_JmpFar): Remove (detected immediately now).
(jmp_insn, call_insn): Update.
(x86_finalize_jmpfar): New.
(x86_finalize_jmp): Remove far jump-related code.
(yasm_x86__finalize_insn): Add check for SEG:OFF immediate operand, and
apply X86_FAR_SEGOFF if necessary.  Match OPTM_Far against both X86_FAR
and X86_FAR_SEGOFF.  Add shortcut to x86_finalize_jmpfar().

svn path=/trunk/yasm/; revision=1182

20 years ago* bytecode.h: Doxygen cleanups.
Peter Johnson [Tue, 16 Nov 2004 06:41:12 +0000 (06:41 -0000)]
* bytecode.h: Doxygen cleanups.

svn path=/trunk/yasm/; revision=1180

20 years ago* libyasm/tests/Makefile.inc: Build bitvect_test and floatnum_test with
Peter Johnson [Mon, 15 Nov 2004 04:02:24 +0000 (04:02 -0000)]
* libyasm/tests/Makefile.inc: Build bitvect_test and floatnum_test with
standard CFLAGS and LDFLAGS, and as check_PROGRAMS, not noinst_PROGRAMS.

* bitvect_test.c: Update with prototypes to avoid compiler warnings.
* floatnum_test.c: Likewise.

svn path=/trunk/yasm/; revision=1179

20 years agoRemove Check suite; hand-write the two tests that use it. While we're
Peter Johnson [Mon, 15 Nov 2004 00:19:04 +0000 (00:19 -0000)]
Remove Check suite; hand-write the two tests that use it.  While we're
here, remove the bitrotted tests memexpr_test and bytecode_test.

* check: Deleted.
* Makefile.am: Unhook Check suite from build.
* configure.ac: Remove tests for things needed only for Check suite.

* memexpr_test.c: Delete.
* bytecode_test.c: Delete.
* libyasm/tests/Makefile.inc: Delete commented-out references to above.

* bitvect_test.c: Rewrite to not use Check suite.
* floatnum_test.c: Likewise.
* libyasm/tests/Makefile.inc: Don't reference Check suite.

svn path=/trunk/yasm/; revision=1178

20 years agoMove generation of arch instruction bytecodes from on-the-fly during the
Peter Johnson [Sun, 14 Nov 2004 23:17:17 +0000 (23:17 -0000)]
Move generation of arch instruction bytecodes from on-the-fly during the
initial parse stage to a new pass between parse and optimization.  This
should allow for more accurate generation of arch bytecodes and other future
code simplifications in arch.

This change necessitated changing how bytecodes are extended from the base
yasm_bytecode structure; the original method did not allow for bytecodes to
be reliably changed from one type to another, as reallocation of the base
structure to fit the new type could result in the entire structure being
relocated on the heap, and thus all the pointer references to the original
bytecode being lost.  After this commit, the yasm_bytecode base structure
has a void pointer to any extension data.  This change rippled across all
bytecode-creating source files, and comprises the majority of this commit.

* bc-int.h (yasm_bytecode): Add contents pointer.
(yasm_bytecode_callback): Make destroy() and print() take void *contents
instead of bytecode pointer.
(yasm_bc_create_common): Take a pointer to contents instead of datasize.
(yasm_bc_transform): New; transforms a bytecode of any type into a
different type.
* bytecode.c (bytecode_data, bytecode_reserve, bytecode_incbin)
(bytecode_align): Remove bc base structure.
(bc_data_destroy, bc_data_print): Update to match yasm_bytecode_callback.
(bc_reserve_destroy, bc_reserve_print): Likewise.
(bc_incbin_destroy, bc_incbin_print): Likewise.
(bc_align_destroy, bc_align_print): Likewise.
(yasm_bc_create_common): Take a pointer to contents instead of datasize.
(bc_data_resolve, bc_data_tobytes, yasm_bc_create_data): Update to use
contents pointer.
(bc_reserve_resolve, bc_reserve_tobytes, yasm_bc_create_reserve): Likewise.
(bc_incbin_resolve, bc_incbin_tobytes, yasm_bc_create_incbin): Likewise.
(yasm_bc_create_align): Likewise.
(yasm_bc_destroy, yasm_bc_print): Update to match yasm_bytecode_callback.

* section.c (yasm_object_get_general, yasm_object_create_absolute): Pass
a NULL pointer instead of yasm_bytecode size to yasm_bc_create_common().

* stabs-dbgfmt.c (stabs_bc_str, stabs_bc_stab): Remove.
(stabs_bc_str_destroy, stabs_bc_str_print): Update.
(stabs_bc_stab_destroy, stabs_bc_stab_print): Likewise.
(stabs_bc_str_callback, stabs_bc_stab_callback): Add common finalize().
(stabs_dbgfmt_append_bcstr): Update to use contents pointer.
(stabs_dbgfmt_append_stab, stabs_dbgfmt_generate): Likewise.
(stabs_bc_stab_tobytes, stabs_bc_str_tobytes): Likewise.

* lc3barch.h (lc3b_insn): Move here from lc3bbc.c.
(lc3b_new_insn_data, yasm_lc3b__bc_create_insn): Remove.
(yasm_lc3b__bc_transform_insn): New.
* lc3bbc.c (lc3b_insn): Remove (moved).
(lc3b_bc_insn_destroy, lc3b_bc_insn_print): Update.
(lc3b_bc_callback_insn): Add common finalize().
(lc3b_bc_insn_resolve, lc3b_insn_tobytes): Use contents pointer.
(yasm_lc3b__bc_create_insn): Remove.
(yasm_lc3b__bc_transform_insn): New.
* lc3bid.re (yasm_lc3b__parse_insn): Directly create lc3b_insn.

* x86arch.h (x86_insn, x86_jmp): Move here from x86bc.c
(x86_new_insn_data, x86_new_jmp_data): Remove.
(yasm_x86__bc_create_insn, yasm_x86__bc_create_jmp): Remove.
(yasm_x86__bc_transform_insn, yasm_x86__bc_transform_jmp): New.
* x86bc.c (x86_insn, x86_jmp): Remove (moved).
(x86_bc_insn_destroy, x86_bc_insn_print): Update.
(x86_bc_jmp_destroy, x86_bc_jmp_print): Likewise.
(x86_bc_callback_insn, x86_bc_callback_jmp): Add common finalize().
(x86_bc_insn_resolve, x86_insn_tobytes): Use contents pointer.
(x86_bc_jmp_resolve, x86_jmp_tobytes): Likewise.
(yasm_x86__bc_create_insn, yasm_x86__bc_create_jmp): Remove.
(yasm_x86__bc_transform_insn, yasm_x86__bc_transform_jmp): New.
* x86id.re (yasm_x86__parse_insn, x86_parse_jmp): Directly create bytecode
contents.

* bc-int.h (yasm_bytecode_callback): Add new finalize() that will finalize
a bytecode after the parse stage.
(yasm_bc_finalize_common): New; common version of bytecode callback
finalize function.
* bytecode.h (yasm_bc_finalize): New wrapper around callback finalize().
* bytecode.c (yasm_bc_finalize): Implementation.
(yasm_bc_finalize_common): Likewise.
(bc_data_callback, bc_data_reserve_callback, bc_incbin_callback)
(bc_align_callback): Add yasm_bc_finalize_common() as finalize() function.

* section.h (yasm_object_finalize): New; finalizes an entire object.
* section.c (yasm_object_finalize): Implementation.

* yasm.c (main): Call yasm_object_finalize() after parse.

* bc-int.h (yasm_effaddr): Add segreg.
* bytecode.h (yasm_ea_set_segreg): New function to set segreg.
* bytecode.c (yasm_ea_set_segreg): Implement.

* x86bc.c (yasm_x86__ea_create_reg, x86_ea_print, x86_bc_insn_resolve)
(x86_bc_insn_tobytes): Use new EA segreg location.

* coretype.h: Move yasm_insn_operands definition from arch.h to here, as it
is now used in prototypes in bytecode.h.

* bytecode.c (bytecode_insn): New instruction bytecode.
(bc_insn_destroy, bc_insn_print, bc_insn_finalize, bc_insn_resolve)
(bc_insn_tobytes): New callback support functions.
(bc_insn_callback): New.
(yasm_bc_create_insn, yasm_bc_insn_add_prefix, yasm_bc_insn_add_seg_prefix):
New parser-callable functions.
* bytecode.h (yasm_bc_create_insn, yasm_bc_insn_add_prefix)
(yasm_bc_insn_add_seg_prefix): Likewise.

* nasm-bison.y: Call new insn bytecode functions rather than arch functions.

* arch.h (YASM_ARCH_VERSION): Bump version.
(yasm_arch): Rename and extend parse_insn to finalize_insn.  Remove
parse_prefix, parse_seg_prefix, and parse_seg_override.
(yasm_arch_parse_insn): Rename to yasm_arch_finalize_insn.
(yasm_arch_parse_prefix, yasm_arch_parse_seg_prefix)
(yasm_arch_parse_seg_override): Remove.

* lc3barch.c (yasm_lc3b_LTX_arch): Update to match new yasm_arch.
* lc3barch.h (yasm_lc3b__parse_insn): Rename to yasm_lc3b__finalize_insn.
* lc3bid.re (yasm_lc3b__parse_insn): Likewise.

* x86arch.c (x86_parse_prefix, x86_parse_seg_prefix)
(x86_parse_seg_override): Remove.
(yasm_x86_LTX_arch): Update to match new yasm_arch.
* x86arch.h (yasm_x86__parse_insn): Rename to yasm_x86__finalize_insn.
* x86id.re (yasm_x86__parse_insn): Likewise.
(x86_new_jmp): Rename to x86_finalize_jmp.

* x86arch.h (yasm_x86__bc_apply_prefixes, yasm_x86__ea_init): New.
* x86bc.c (yasm_x86__bc_apply_prefixes, yasm_x86__ea_init): Likewise.

svn path=/trunk/yasm/; revision=1177

20 years agoMerged [1173] from 0.4.x branch.
Peter Johnson [Mon, 1 Nov 2004 00:33:46 +0000 (00:33 -0000)]
Merged [1173] from 0.4.x branch.

svn path=/trunk/yasm/; revision=1176

20 years agoRemove mingw build.
Peter Johnson [Mon, 1 Nov 2004 00:30:38 +0000 (00:30 -0000)]
Remove mingw build.

svn path=/trunk/yasm/; revision=1175

20 years ago* linemgr.c (yasm_linemap_create): Initialize pointers in initial
Peter Johnson [Sun, 31 Oct 2004 04:18:37 +0000 (04:18 -0000)]
* linemgr.c (yasm_linemap_create): Initialize pointers in initial
source_info array.  Unless these are initialized to 0,
yasm_linemap_destroy() attempts to free these (invalid) pointers.

svn path=/trunk/yasm/; revision=1170

20 years agoFix #44 by adding support for WRT special symbols (e.g. [sym WRT ..plt] and
Peter Johnson [Sun, 31 Oct 2004 01:07:52 +0000 (01:07 -0000)]
Fix #44 by adding support for WRT special symbols (e.g. [sym WRT ..plt] and
similar) to ELF.  They are used identically to NASM's ELF shared object
support.

Due to limited WRT support throughout libyasm, this caused a lot of rippling
changes.  A major cleanup needs to be performed later to clear some of this
hackiness up.

* elf-machine.h (func_accepts_size_t): Rename to func_accepts_reloc().
(func_map_reloc_info_to_type): Add parameter ssyms for array of special syms.
(elf_machine_ssym): New; for defining machine-specific special syms.
(elf_machine_handler): Change accepts_reloc_size to accepts_reloc.  Add new
ssyms and num_ssyms members.

* elf-x86-x86.c (ssym_index): New; this allows nice indexing of ssym arrays.
(elf_x86_x86_accepts_reloc): Rename of elf_x86_x86_accepts_reloc_size.  Add
support for various WRT ssyms.
(elf_x86_x86_map_reloc_info_to_type): Add support for various WRT ssyms.
(elf_x86_x86_ssyms): New array of supported special symbols.
(elf_machine_handler_x86_x86): Update for above changes/additions.
* elf-x86-amd64.c (ssym_index, elf_x86_amd64_accepts_reloc)
(elf_x86_amd64_map_reloc_info_to_type, elf_x86_amd64_ssyms)
(elf_machine_handler_x86_amd64): Likewise.

* elf.h (elf_reloc_entry): Add wrt member.
(elf_set_arch): Add symtab parameter.
(elf_is_wrt_sym_relative): New.
(elf_reloc_entry_create): Add wrt parameter.
* elf.c (elf_set_arch): Allocate special syms from machine level.
(elf_is_wrt_sym_relative): New; search special syms, and report whether a
WRT ssym should be symbol-relative or section-relative.
(elf_reloc_entry_create): Pass WRT and ssyms info down to machine level.

* elf-objfmt.c (yasm_objfmt_elf): Add dotdotsym (..sym) symrec member.
(elf_objfmt_create): Pass symtab to elf_set_arch().  Allocate ..sym symbol.
(elf_objfmt_output_reloc): Update for elf_reloc_entry_create() change.
(elf_objfmt_output_expr): Handle WRT ssym.  Make relocation symbol-relative
rather than section-relative if either WRT ..sym or WRT ssym that machine
level desires to be symbol-relative.

* symrec.c (yasm_symrec_get_label): Check for NULL sym->value.precbc; this
is now possible due to the user-accessible special symbols that ELF et al
create, which all have NULL precbc's.

* expr.c (yasm_expr_extract_symrec): Recurse into IDENT's to make more exprs
acceptable.

* coretype.h (yasm_output_reloc_func): Remove rel parameter as it shouldn't
be needed and complexifies writing of the reloc functions.
* stabs-dbgfmt.c (stabs_bc_stab_tobytes): Update output_reloc() call.
* elf-objfmt.c (elf_objfmt_output_reloc): Update to match.

* arch.h (yasm_arch_module): Add intnum_fixup_rel() function, change
intnum_tobytes() to not take rel parameter.  The rel functionality is being
separated because sometimes it's desirable not to put the data into the
written intnum (e.g. ELF RELA relocations).
(YASM_ARCH_VERSION): Bump due to above change.
(yasm_arch_intnum_fixup_rel): New wrapper.
(yasm_arch_intnum_tobytes): Update wrapper (removing rel).

* lc3bbc.c (yasm_lc3b__intnum_fixup_rel): New, with code from:
(yasm_lc3b__intnum_tobytes): Remove rel code.
* lc3barch.h (yasm_lc3b__intnum_fixup_rel): New.
(yasm_lc3b__intnum_tobytes): Update.
* lc3barch.c (yasm_lc3b_LTX_arch): Reference yasm_lc3b__intnum_fixup_rel().

* x86bc.c (yasm_x86__intnum_fixup_rel): New, with code from:
(yasm_x86__intnum_tobytes): Remove rel code.
* x86arch.h (yasm_x86__intnum_fixup_rel): New.
(yasm_x86__intnum_tobytes): Update.
* x86arch.c (yasm_x86_LTX_arch): Reference yasm_x86__intnum_fixup_rel().

* xdf-objfmt.c (xdf_objfmt_output_expr): Update to use intnum_fixup_rel() /
new intnum_tobytes().
* bin-objfmt.c (bin_objfmt_output_expr): Likewise.
* coff-objfmt.c (coff_objfmt_output_expr): Likewise.
* elf-objfmt.c (elf_objfmt_output_expr: Likewise.
* nasm-listfmt.c (nasm_listfmt_output_expr): Likewise.

* nasm-bison.y: Change precedence of WRT and : operators: instead of being
the strongest binders they are now the weakest.  This is needed to correctly
parse and be able to split WRT expressions.  WRT handling is still somewhat
of a hack throughout yasm; we'll fix this later.

* x86expr.c (x86_expr_checkea_distcheck_reg): Don't check for WRT here.
(x86_expr_checkea_getregusage): Add new wrt parameter.  Use it to handle
"WRT rip" separately from other operators.  Recurse if there's a WRT below
the WRT rip; this is to handle cases like ELF-AMD64's elfso64.asm.
(yasm_x86__expr_checkea): Split off top-level WRT's and feed through
separately to x86_expr_checkea_getregusage().

* x86bc.c (x86_bc_insn_tobytes): Ensure the SUB operation for PC-relative
displacements goes BELOW any WRT expression.
(x86_bc_jmp_tobytes): Likewise.

* elfso.asm, elfso.hex, elfso.errwarn: New 32-bit ELF shared object tests.
* modules/objfmts/elf/tests/Makefile.inc: Include in distribution.

* elfso64.asm, elfso64.hex, elfso64.errwarn: New 64-bit ELF shared object
tests.  This is not a good example, as the assembled code doesn't work, but
it at least tests the special symbols.
* modules/objfmts/elf/tests/amd64/Makefile.inc: Include in distribution.

svn path=/trunk/yasm/; revision=1168

20 years agoAdd better handling of functions for stabs debugging. It now looks for a
Michael Urman [Sat, 23 Oct 2004 14:56:50 +0000 (14:56 -0000)]
Add better handling of functions for stabs debugging. It now looks for a
potential function as of every bytecode, using the information provided
in revision [1147], and filtering out lables with "." or "$".
  * symrec.c: don't add symrec to bytecode unless added to table.
  * stabs-dbgfmt.c: remove old inefficient code to use new sym lookup.
  * tests/*: create first test, using a copy of elftest.asm.

svn path=/trunk/yasm/; revision=1167

20 years ago* modules.vcproj: Update to include new ELF files.
Peter Johnson [Fri, 15 Oct 2004 17:06:20 +0000 (17:06 -0000)]
* modules.vcproj: Update to include new ELF files.

svn path=/trunk/yasm/; revision=1166

20 years agoMake manual size overrides on effective addresses only work if legal;
Peter Johnson [Thu, 14 Oct 2004 07:46:44 +0000 (07:46 -0000)]
Make manual size overrides on effective addresses only work if legal;
otherwise the override is ignored and a warning is output, so correct
code is always generated.

Reported by: vclaudepierre@tiscali.fr
Bugzilla Bug: 40

* x86expr.c (x86_checkea_calc_displen): Output warnings for noreg case;
reorder such that displacement length calculation is done if the warning
is output.
* x86bc.c (x86_bc_insn_resolve): If length was forced but checkea had to
override it, save it always (to avoid multiple warnings).

* addrop.hex: Match corrected code generation.
* addrop.errwarn: Include new warning message.

* ea-warn.asm, ea-warn.errwarn, ea-warn.hex: Test new functionality more
in depth (code thanks to bug reporter).

svn path=/trunk/yasm/; revision=1165

20 years ago* configure.ac: Add detection for libgen.h.
Peter Johnson [Thu, 14 Oct 2004 05:55:21 +0000 (05:55 -0000)]
* configure.ac: Add detection for libgen.h.
* yasm.c: Conditionally include libgen.h for dirname() definition.
* yasm-module.c: Conditionally include libgen.h for basename() definition.

svn path=/trunk/yasm/; revision=1164

20 years ago* x86id.re (x86_new_jmp): Fix evaluation order dependent call when creating
Peter Johnson [Wed, 13 Oct 2004 03:55:04 +0000 (03:55 -0000)]
* x86id.re (x86_new_jmp): Fix evaluation order dependent call when creating
a FAR target expression.  The create_branch() call could be called before
the expr_copy() call; the former can (and does) delete op->data.val.  Move
the expr_copy() call to an earlier statement to force the correct
evaluation order.

Thanks to: HP TestDrive for providing the Itanium system that discovered
this bug.

svn path=/trunk/yasm/; revision=1163

20 years ago* elf-x86-amd64.c: Set svn:keywords "Id".
Peter Johnson [Mon, 11 Oct 2004 04:34:09 +0000 (04:34 -0000)]
* elf-x86-amd64.c: Set svn:keywords "Id".
* elf-x86-x86.c: Likewise.

svn path=/trunk/yasm/; revision=1162

20 years ago* elf.h: Update x86 and amd64 relocation types and associated comments.
Peter Johnson [Mon, 11 Oct 2004 04:30:08 +0000 (04:30 -0000)]
* elf.h: Update x86 and amd64 relocation types and associated comments.
* elf-x86-x86.c: Add 8-bit and 16-bit relocations (GNU extensions).

* tests/Makefile.inc: Rename elfreloc-err to elfreloc-ext, because relocs
tested in elfreloc-err are now legal due to above changes.
* elfreloc-ext.asm: Likewise.
* elfreloc-ext.errwarn: Likewise.
* elfreloc-ext.hex: New output file.

svn path=/trunk/yasm/; revision=1161

20 years agoEnable machine specific handling of relocation section type, since amd64
Michael Urman [Mon, 11 Oct 2004 03:47:28 +0000 (03:47 -0000)]
Enable machine specific handling of relocation section type, since amd64
should use .rela.* instead of .rel.* sections, of type SHT_RELA instead
of SHT_REL.

* elf.h, elf.c: update calls to backend, passing relocations further in.
* elf-machine.h, elf-x86-amd64.c, elf-x86-x86.c: add support for setting
  relocation section name, type, and update amd64 to write RELA records.
  Also when creating a relocation and writing a value to the file, have
  it handled here to keep REL vs RELA distinctions hidden from elf.c.
* elf-rip.hex: update output to match new section type and data output.

svn path=/trunk/yasm/; revision=1160

20 years agoDeconst yasm_expr_get_intnum's return, allowing inplace modifications to
Michael Urman [Mon, 11 Oct 2004 03:42:08 +0000 (03:42 -0000)]
Deconst yasm_expr_get_intnum's return, allowing inplace modifications to
be made. The specific instigator for this is the ability to modify the
value in a relocation stored in a .rela.section so that listings are
"correct".

svn path=/trunk/yasm/; revision=1159

20 years ago* intnum.c (yasm_intnum_zero): New function to zero an existing intnum.
Peter Johnson [Mon, 11 Oct 2004 02:14:34 +0000 (02:14 -0000)]
* intnum.c (yasm_intnum_zero): New function to zero an existing intnum.
* intnum.h (yasm_intnum_zero): Add prototype for above.

svn path=/trunk/yasm/; revision=1158

20 years agoAdd work around for static-build libtool binaries to find preloaded modules
Peter Johnson [Mon, 11 Oct 2004 00:23:10 +0000 (00:23 -0000)]
Add work around for static-build libtool binaries to find preloaded modules
without the presence of the associated ".la" file.  This caused the Win32
nightly snapshots to be unusable (as they're static-built libtool).

At present, a search for a preloaded module occurs first, before the ".la"
is even looked for.

Noticed by: Oliver <mybox@ollysoft.de>

* libtool.m4: Define new config.h variable LIBTOOL_LIBEXT that is the
extension used for static libraries (e.g. ".a").  This is the extension used
for preloaded symbols.

* ltdl.c (lt_dlopenext): Add first search function to find filename.a prior
to other searches (.la and .so), so preloaded symbols are hit first.

svn path=/trunk/yasm/; revision=1157

20 years agoPhase 2 of 2 cleanup to elf's internal structure.
Michael Urman [Sun, 10 Oct 2004 19:25:23 +0000 (19:25 -0000)]
Phase 2 of 2 cleanup to elf's internal structure.

Move and rename functions for cleanliness.

New files:
elf-machine.h - machine-specific interface, and helper macros
elf-x86-x86   - support specific standard ia32
elf-x86-amd64 - support specific to amd64

Modified files:
elf.c         - update the machine structure traversal for external structures
Makefile.inc  - support the new files

svn path=/trunk/yasm/; revision=1156

20 years agoPhase 1 of a 2 phase cleanup to elf's internal structure.
Michael Urman [Sun, 10 Oct 2004 18:40:31 +0000 (18:40 -0000)]
Phase 1 of a 2 phase cleanup to elf's internal structure.

Historically elf.c had a lot of switches for which machines it supports.
This replaces it with a structure of information and function pointers
which is selected in much the same way the switch value was before. Then
all such switches are replaced with calls through the current machine
handler structure.

Phase 2 will relocate each machine's support to its own file.

svn path=/trunk/yasm/; revision=1155