Peter Johnson [Sun, 12 Sep 2004 07:57:47 +0000 (07:57 -0000)]
* ins.h, scanner.h, dfa.h, code.c, re.h, parse.h, token.h, substr.h:
Remove use of "inline". This could cause breakage on non-gcc systems (as
these files do not use config.h because of cross-build reasons).
* yasm.dep, yasm.mak, yasm.dsp, yasm.dsw: Remove support for VC6 builds.
* libyasm.dsp, libyasm.mak, libyasm.dep: Likewise.
* modules.dsp, modules.mak, modules.dep: Likewise.
* yasm.suo: Remove unneeded user options file.
* vc: Update svn:ignore property to reflect removal of VC6 builds and user
options file.
* genmacro.vcproj: Generate genmacro tool.
* genmacro/run.bat: Use genmacro to generate nasm-macros.c.
* modules.vcproj: Point to the new location for nasm-macros.c.
* re2c.vcproj: Generate re2c tool.
* re2c/run.bat: Use re2c to generate re2c-generated .c files.
Peter Johnson [Tue, 7 Sep 2004 07:39:26 +0000 (07:39 -0000)]
* configure.ac: Remove check for groff, add check for xmlto.
* Makefile: Add support for building man pages from DocBook XML refentry's
using xmlto.
* frontends/yasm/yasm.xml: New. Source XML file for yasm(1) man page.
* frontends/yasm/yasm.1: Generated yasm(1) man page. We may want to remove
this at some point, but it would have impact on those keeping up with HEAD.
* frontends/yasm/Makefile.inc: Add new yasm(1) man page to distribution and
install.
* HACKING: Update required tools list. Rename "CVS" to "Subversion".
Remove "Generating ChangeLogs" section, as with Subversion this is not
necessary.
Peter Johnson [Fri, 3 Sep 2004 23:01:51 +0000 (23:01 -0000)]
* x86id.re (yasm_x86__parse_insn): Add checking of effective address size.
* x86arch.h (x86_new_insn_data): Add shortmov_op for shortmov post-action.
* x86bc.c (x86_insn): Likewise.
(yasm_x86__bc_create_insn): Copy shortmov_op to instruction.
(x86_bc_insn_resolve): Handle shortmov_op post-action.
* x86id.re (yasm_x86__parse_insn): Set shortmov_op post-action if desired.
* x86id.re (mov_insn): Through reorder and use of new shortmov_op
post-action, change generated code for mov on AMD64. On AMD64, the short
mov (opcode A0/A1/A2/A3), generated when moving to AL/AX/EAX/RAX from an
absolute address (no registers) has a 64-bit size in 64-bit mode. While an
address override can reduce it to 32-bits, automatically generating such an
override does not fit well with the model of not doing anything behind the
programmer's back. Instead, we now generate the 32-bit address size MOD/RM
form unless the address size is specifically set to 64 bits using [qword 0]
notation (this is the equivalent of the GNU AS movabs pseudo-instruction).
The short mov is still generated in 32-bit mode, whether obtained via BITS
setting or an a32 prefix in BITS 64 mode. (The a32 prefix handling
necessitated the new shortmov post-action.) Examples (pulled from new
mem64.asm):
Peter Johnson [Wed, 1 Sep 2004 07:10:14 +0000 (07:10 -0000)]
* configure.ac, Mkfiles/*/config.h: Stop using date command / CVS string,
switch to constant use of "HEAD" instead. This will be replaced by the SVN
tree revision for automated builds.
Michael Urman [Fri, 28 May 2004 13:19:48 +0000 (13:19 -0000)]
Fixed handling of absolute sections in the elf object format, including
preventing a segfault. The assumptions it had made for all sections
were wrong with absolute sections, so added just as much special casing
as necessary. I hope the output is correct as well - this way we should
at least get bugs if it's wrong.
Peter Johnson [Sun, 11 Apr 2004 23:25:17 +0000 (23:25 -0000)]
Add rudimentary, untested, AMD64 support.
The AMD64 MASM likes to generate REL32 relocations for everything; I've not
yet figured out how this works.
This code should work fine for files without relocation.
Bugzilla bug: 33
Reported by: Jeff Lawson <jlawson-yasm@bovine.net>
Peter Johnson [Sat, 27 Mar 2004 03:14:52 +0000 (03:14 -0000)]
Fix indexreg handling in x86_expr_checkea_getregusage() to correctly handle
a non-multiplier used after a multiplier (e.g. edi*8+eax). Previously,
this resulted in the eax overriding the edi as the indexreg, causing the
effective address not to be recognized.
Update the effaddr testcase to test this case and a few other similar ones.
Peter Johnson [Tue, 16 Mar 2004 08:26:19 +0000 (08:26 -0000)]
Fix push in 64-bit mode to take a 32-bit signed immediate rather than a
64-bit immediate. Actually, whether it's signed or unsigned seems to be
uncertain; AMD64 documentation shows it as signed, but Intel's new IA-32e
says it's unsigned! While we're here, the Imm8 version is signed, not
unsigned.
Bugzilla bug: 30
Reported by: Michael Ryan <michaelryan@mindspring.com>
Peter Johnson [Sat, 7 Feb 2004 22:28:40 +0000 (22:28 -0000)]
Make yasm dynamic module loader able to find modules even when run from a
different location. The new code uses dirname() to add the argv[0] path to
the LTDL module loader search path. Added new replacements for dirname and
basename functions from OpenBSD.
Bugzilla: Bug 24
Reported by: Simon Paulger <simonjpaulger@hotmail.com>
(Hopefully) finish cleanups begun in phase 1 (see phase 1 commit message),
making dbgfmt, objfmt, optimizer, and preproc module interfaces follow the
same thread-safe interface style as the phase 1 changes.
Also put in a large number of doxygen documentation cleanups.
Peter Johnson [Thu, 5 Feb 2004 08:25:20 +0000 (08:25 -0000)]
Correct ordering of legacy prefix and REX prefix for SSE/SSE2 instructions
in 64-bit (AMD64) mode. Intel says these bytes should not be treated as
prefixes, but AMD64 treats them as legacy prefixes, expecting them to come
before the REX byte.
For now, keep the three-byte max instruction length (although it's not truly
correct), as handling the other "3-byte" cases such as R/M spare with no EA
is probably more painful than it's worth to push down to later in the code
generation path.
Reported by: Henryk Richter <henryk.richter@comlab.uni-rostock.de>
Peter Johnson [Tue, 16 Dec 2003 07:45:04 +0000 (07:45 -0000)]
Add a workaround for the lack of per-objfmt macro support to fix the common
use of the ORG macro (several user comments about the lack of this) and the
initial value of the __SECT__ macro (used by ENDSTRUC among other macros).
Fortunately, for all current objfmts, __SECT__ is currently defined as
[section .text], so one common definition can be used for now.
FIXME: remove this workaround when a better solution has been implemented.
Peter Johnson [Tue, 16 Dec 2003 03:54:15 +0000 (03:54 -0000)]
Properly handle fatal errors (like missing include file) from the real
NASM parser by changing the libyasm yasm_fatal() interface to use va_list
instead of ... variable arguments. Add a yasm__fatal() function that takes
... and calls yasm_fatal().
Michael Urman [Tue, 4 Nov 2003 20:05:50 +0000 (20:05 -0000)]
Fix stabs to always use stab size 12, n_value size 4. Truncate 64bit
values into 32bits as necessary. This is the proper fix to "written
length does not match optimized length" in amd64+stabs.
Michael Urman [Tue, 4 Nov 2003 19:52:02 +0000 (19:52 -0000)]
"Fix" stabs to always output the same stab length in stabs_bc_stab_tobytes.
Previously only "symvalue" stabs did this, causing a mismatched output size
with amd64 and stabs. However since it appears the actual stabs spec always
uses 12 byte stabs, this fix is already obsolete and will be superceded
shortly.
Reported By: Jeff Lawson <jlawson-yasm@bovine.net>
Peter Johnson [Tue, 28 Oct 2003 18:58:55 +0000 (18:58 -0000)]
Hide details of yasm_arch_module structure, instead creating wrapper macro
"functions" that call down to the module level. Doesn't really change the
internal complexities, just makes it easier to read and write code that
uses it.
Peter Johnson [Fri, 24 Oct 2003 01:32:22 +0000 (01:32 -0000)]
Fix pshift instructions by fixing meaning of MOD_Gap0 to actually eat the
first parameter (before MOD_Op2Add). Before this change, MOD_Gap0 did not
eat a parameter until AFTER MOD_Op2Add.
Peter Johnson [Tue, 21 Oct 2003 03:04:56 +0000 (03:04 -0000)]
Fix reporting of redefinition errors by adding a set of error/warning
reporting functions that take a parameter for the line to be displayed in
addition to the the line used for sorting. This allows the "previously
defined" message to use the standard errwarn line resolution functions.
The resulting error messages look like gcc output.
Peter Johnson [Tue, 21 Oct 2003 01:36:19 +0000 (01:36 -0000)]
Fix a couple of MMX/SSE/SSE2 instructions: movntps, movntq, movss, and the
pcmp* family. The first three had some operand encoding problems, and pcmp*
was typoed as pacmp*.
Reported by: Edouard Gomez <ed.gomez@free.fr>
Peter Johnson [Sun, 19 Oct 2003 18:38:03 +0000 (18:38 -0000)]
Remove obsolete overflow check in EA displacements (causing error instead of
warning on size overflow).
Bugzilla Bug 18
Reported by Jeff Lawson <jlawson-yasm@bovine.net>
Peter Johnson [Fri, 3 Oct 2003 00:32:40 +0000 (00:32 -0000)]
Merge in NASM CVS changes up to 10/02/2003. Changes NOT merged:
- Removal of backslash() - why was this okay?
- Addition of pp_get_include_path_ptr() - we (will eventually) do this a
different way in yasm.
As yasm has evolved, various minor additions have been made to libyasm to
support the new features. These minor additions have accumulated, and
some contain significant redundancies. In addition, the core focus of
yasm has begun to move away from the front-end commandline program "yasm"
to focusing on libyasm, a collection of reusable routines for use in all
sorts of programs dealing with code at the assembly level, and the modules
that provide specific features for parsing such code.
This libyasm/module update focuses on cleaning up much of the cruft that
has accumulated in libyasm, standardizing function names, eliminating
redundancies, making many of the core objects more reusable for future
extensions, and starting to make libyasm and the modules thread-safe by
eliminating static variables.
Specific changes include:
- Making a symbol table data structure (no longer global). It follows a
factory model for creating symrecs.
- Label symbols now refer only to bytecodes; bytecodes have a pointer to
their containing section.
- Standardizing on *_create() and *_destroy() for allocation/deallocation.
- Adding a standardized callback mechanism for all data structures that
allow associated data. Allowed the removal of objfmt and
dbgfmt-specific data callbacks in their interfaces.
- Unmodularizing linemgr, but allowing multiple linemap instances (linemgr
is now renamed linemap).
- Remove references to lindex; all virtual lines (from linemap) are now
just "line"s.
- Eliminating the bytecode "type" enum, instead adding a standardized
callback mechanism for custom (and standard internal) bytecode types.
This will make it much easier to add new bytecodes, and eliminate the
possibility of type collisions. This also allowed the removal of the
of_data and df_data bytecodes, as objfmts and dbgfmts can now easily
implement their own bytecodes, and the cleanup of arch's bytecode usage.
- Remove the bytecodehead and sectionhead pseudo-containers, instead
making true containers: section now implements all the functions of
bytecodehead, and the new object data structure implements all the
functions of sectionhead.
- Add object data structure: it's a container that contains sections, a
symbol table, and a line mapping for a single object. Every former use
of sectionhead now takes an object.
- Make arch interface and all standard architectures thread-safe:
yasm_arch_module is the module interface; it contains a create()
function that returns a yasm_arch * to store local yasm_arch data; all
yasm_arch_module functions take the yasm_arch *.
- Make nasm parser thread-safe.
To be done in phase 2: making other module interfaces thread-safe. Note
that while the module interface may be thread-safe, not all modules may be
written in such a fashion (hopefully all the "standard" ones will be, but
this is yet to be determined).
Peter Johnson [Fri, 5 Sep 2003 00:39:15 +0000 (00:39 -0000)]
Fix support for o64. AMD64 isn't always 32-bit default operand size, so
add fields to bytecode and parsing insn_info to determine default operand
size in 64-bit mode.
Michael Urman [Fri, 15 Aug 2003 03:43:55 +0000 (03:43 -0000)]
STABS debugging information. This includes, naturally, several draft
changes to the dbgfmt interface, and other assorted updates, including:
* yasm.c now calls df->initialize() and df->generate()
* a dbgfmt bytecode type with associated handling
* yasm_output_reloc_func type for use particularly by dbgfmts
* df: initialize updated; generate, bc_dbgfmt_data_{output|delete|print} added
* null-dbgfmt structure brought in line with these additions
* elf-objfmt made aware of stabs sections, and what to do with them
The bad news:
* just enough stabs output to support line number information in GDB
* GDB identifies function labels off by 3 bytes in my test, but line
numbers remain correct, somehow. Unknown whether stabs-dbgfmt or GDB
at fault.
Peter Johnson [Sun, 3 Aug 2003 21:13:20 +0000 (21:13 -0000)]
Add support for the AMD64 syntax [symbol wrt rip]. This is distinct from
[rip+symbol] in that the latter adds the symbol offset to rip, whereas the
former is the same as [symbol] but uses rip-relative addressing. This is
a minor overload of the WRT operator, but reads well and shouldn't conflict
with the use of WRT against sections.
Doing this currently adds a bit of overhead to all effective addresses in
64-bit mode (a $ symbol reference). This is the cleanest approach I could
figure out; a time/space trade could be made later, such as prescanning for
RIP usage before allocating the symbol.
Michael Urman [Sun, 3 Aug 2003 01:13:14 +0000 (01:13 -0000)]
ELF objfmt size agnosticism:
* Replace ulongs secthead.size, secthead.align, reloc.addr with intnums
* Calculate relocation size with intnums
* Create macros YASM_WRITE_32I_L, YASM_WRITE_64I_L to write 32/64bit
intnums to buffer
This doesn't quite cover everything, particularly due to various calls
to yasm_intnum_get_uint for various bits of processing, but it's close!
Miscellany:
* Fix non-call to elf_reloc_delete()
* Remove unused secthead.addr, secthead_set_addr
* Create macro YASM_WRITE_64Z_L to write zero-extended 32bit value to
64bits of buffer
Michael Urman [Sat, 2 Aug 2003 21:50:42 +0000 (21:50 -0000)]
Move elf relocation valsize handling to the backend.
Add elf x86 test case to verify it works properly.
Unsure about elf x86-64 status (relocations segfault my objdump), but
it's no *worse* than last commit.
Michael Urman [Sat, 2 Aug 2003 20:32:42 +0000 (20:32 -0000)]
Continue adding AMD64 ELF support (without breaking x86!):
Move more machine-specific items to the backend (EHDR_SIZE) and make it
target machine-dependent there.
Theoretically everything except relocations may work, but since builds
of amd64 with bits=32 can segfault objdump, don't trust it.
Work to support relocations is next; perhaps then it can be tested.