Peter Johnson [Sat, 20 Jan 2007 05:52:32 +0000 (05:52 -0000)]
Fix bug in [1737]. Using a valid environment variable after a non-existent
one would result in the part of the string prior to the non-existent one
getting dropped.
Peter Johnson [Sat, 13 Jan 2007 19:34:04 +0000 (19:34 -0000)]
Initial commit of Mach-O object format.
Contributed by: Henryk Richter <henryk.richter@comlab.uni-rostock.de>
This adds 3 object format keywords: macho, macho32, macho64. These work in
the same way as elf, elf32, and elf64. The object format is still a work
in progress; amongst other things it does not yet support full cross-section
references (othersym1-othersym2), dynamic linking, or GAS input syntax. We
will continue to improve and work on these features in the near future.
Peter Johnson [Sat, 30 Dec 2006 02:48:17 +0000 (02:48 -0000)]
NASM parser bugfixes, and add support for section names that include "-"
(such as the common .note.GNU-stack section). While Yasm allows such section
names by enclosing with double-quotes, NASM allows this, so for compatibility
it makes sense for Yasm to as well.
Peter Johnson [Sat, 23 Dec 2006 10:20:51 +0000 (10:20 -0000)]
NASM parser: change from Bison parser to hand-written recursive descent
parser with one token of lookahead. This allows for better error handling
and proper handling of things like "xxxx"/5. There may be a minor speedup
but it's probably a wash.
Still TODO:
- Unify the expression parser with the NASM preproc one.
- Change the GAS parser to recursive descent.
Only had to change one test result; this is due to re-ordering of symrec
creation versus symrec use in data expressions such as x db y. With the
Bison parser, the symrec use (y) would come first, now the symrec creation
(x) comes first.
Peter Johnson [Sat, 23 Dec 2006 06:45:14 +0000 (06:45 -0000)]
Rename yasm_dvs_destroy() to yasm_dvs_delete() to match the fact it's an
initialized not allocated, so the function doesn't actually free the
provided pointer.
Peter Johnson [Thu, 14 Dec 2006 07:39:01 +0000 (07:39 -0000)]
Push down GAS .ident directive handling into objfmts. Note this makes it
such that only ELF and COFF actually handle .ident; all other object
formats silently ignore it.
In Win32/Win64, the .ident contents are dumped into the .rdata$zzz section
rather than the .comment section as in COFF and ELF; this is due to the
fact the GNU linker for Win32 is broken and puts .comment in the output
executable as a separate section, breaking the executable. The .rdata$zzz
name matches that used by GAS to work around this same linker bug.
Reported and tracked down by: Peter Tanski <p.tanski@gmail.com>
Peter Johnson [Tue, 12 Dec 2006 07:16:45 +0000 (07:16 -0000)]
Pyxelator: Rip out code wrapper generation. Reindent. Add yasm wrapper
generator script. Still needs additional tweaks before it can be tied
into the build.
Peter Johnson [Sun, 10 Dec 2006 07:05:06 +0000 (07:05 -0000)]
Take [1423] to the next logical step by supporting the general case of
(sym in other section)-(sym in this section) rather than just
(sym in other section)-(curpos) (e.g. sym-$). Unfortunately supporting
this required precbc to be flowed down to the value_finalize functions,
but it's relatively reasonable to do so, as all of the _finalize() routines
have access to precbc.
Peter Johnson [Sun, 26 Nov 2006 20:50:23 +0000 (20:50 -0000)]
GAS parser: match .file and .line handling to that of GAS. In GAS, both
.file (sans file number) and .line need to be given before error messages
start having the file/line numbers specified.
This temporarily breaks .rept error reporting somewhat (as the current code
outputs just .line for .rept expansion), but this will be fixed soon.
Peter Johnson [Tue, 7 Nov 2006 06:40:05 +0000 (06:40 -0000)]
Allow overriding of strict-ness requirement with command line option
"--force-strict", which switches Yasm back to the old behavior of treating
any sized operand as "strict" (forcing the actual size).
Peter Johnson [Mon, 6 Nov 2006 08:59:35 +0000 (08:59 -0000)]
Support strict for immediate values, and optimize non-strict (thus some
other testcase changes).
While I'm here, fix handling of arith [], dword X in 64-bit mode by making
this an error; it's impossible to tell if add dword [], X or add qword [], X
is meant as the immediate part is always a dword. This is only important for
arith rather than other memory instructions due to dword also being needed
for optimization.
Next step: support strict for jump sizing and optimize non-strict sized
jumps.
Peter Johnson [Sat, 28 Oct 2006 20:34:03 +0000 (20:34 -0000)]
Make common scanner fill function, as we're using it in two places already.
Actually, GAS parser doesn't use this yet, as it still contains the rept
functionality that will move to GAS preproc at some point. When GAS
preproc implements rept, we can switch to the common implementation.
Peter Johnson [Sat, 28 Oct 2006 18:19:39 +0000 (18:19 -0000)]
Fix prefix order for "3-byte" instructions like the SIMD instructions.
While the F2/F3/66 prefix used by these instructions should precede the
REX prefix in 64-bit mode, they should probably not precede the segment
override. The processor specifications seem to be unclear on this point,
so play it safe.
This change has a minor side-effect of reversing the segreg/size override
ordering on things like "fs cmpsd" in 16-bit mode; this is okay as those
prefixes can be in any order. This is due to the way Yasm implements
segreg overrides for instructions with no EA.
Reported by: Danny Reeves <danny_reeves@hotmail.com>
Peter Johnson [Fri, 27 Oct 2006 07:29:28 +0000 (07:29 -0000)]
expr.c (expr_expand_equ): Work around what I believe to be a GCC aliasing
bug (probably http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28778) by not
accepting NULL for eh, and giving it the static eh at the sole caller of
this function (yasm_expr__level_tree). While I'm here, clean up the logic
a bit to avoid relying on ee.e NULL value. This fix prevents crashes in
GCC 4.1.1 with -fstrict-aliasing (enabled by -O2).
Noticed by: Danny Reeves <danny_reeves@hotmail.com>
Peter Johnson [Sat, 21 Oct 2006 04:49:19 +0000 (04:49 -0000)]
Fix #86 by requiring '-' (e.g. "yasm -") to read from stdin, and reporting
an error if no files are specified (instead of defaulting to stdin).
While the old behavior mimiced GNU AS, the new behavior is far more common
amongst typical compilers (e.g. GCC), including NASM.
While I'm here, add support for '--' (e.g. "yasm -- -f").
Peter Johnson [Thu, 19 Oct 2006 03:21:18 +0000 (03:21 -0000)]
Fix #84: I broke the idiom of concating a decimal number to a register
in the preproc (e.g mm%$x -> mm0) when I implemented a minor optimization
(outputing values in hex to avoid the 2x decimal conversion overhead) in
[1488]. Revert that optimization.
I believe the right way to do this is to add the GAS (and MASM) syntax
sugar of mm(0) etc. to NASM syntax, then any number (not just decimal)
can be used as the new idiom for doing this. But that wouldn't unbreak
programs that already exist, so we're left with this state of affairs.
Sigh.
Peter Johnson [Wed, 18 Oct 2006 04:21:21 +0000 (04:21 -0000)]
Fix handling of CPU flags; the old code would simply take the last CPU
setting in the file and use it against the entire file (oops).
(first half of #83)
Also make the error message a lot nicer, at least for ones we detect early
(shl ax, 2 in 8086 mode still gives the old message).
Peter Johnson [Sat, 7 Oct 2006 17:27:56 +0000 (17:27 -0000)]
Fix error/warnings in the NASM preprocessor to reference the correct line
number, rather than the last parsed line number. Also improve
"cannot reference symbol" error a bit, to include the symbol name.
Peter Johnson [Thu, 5 Oct 2006 06:22:25 +0000 (06:22 -0000)]
Change genmodule to parse through the Makefile (or Makefile.am) looking for YASM_MODULES,
rather than simply taking a list of modules on the command line. This allows significant
improvement of the behavior when used with Visual Studio, as the "old" way of doing this
with Visual Studio build files was to scan through the .c files; this brought up things
that were actually disabled in the build.
Also incorporate a patch by Charles Bailey to make the VC8 build less noisy, and allow use
of Win32 Bison if it's installed. Instructions updated as well.
Peter Johnson [Wed, 4 Oct 2006 04:38:43 +0000 (04:38 -0000)]
Follow-up to #80 and #81: "xchg ax, ax" can use the short 0x90 form as
16-bit operations don't clear the high bits of the 64-bit register, so
this is effectively a NOP as well.
While I'm still looking at this, make "xchg rax, rax" not output a REX
prefix.
I thought about being extra-clever and have "xchg ax, ax" not output an
operand-size prefix, but thought better of it: if the user says "ax"
they're probably going to expect the prefix to be there. Left in as
a comment for future readers of the code.
Peter Johnson [Sat, 30 Sep 2006 05:13:41 +0000 (05:13 -0000)]
Fix #77 by performing symrec-symrec -> subst placeholder transformation
recursively in yasm_expr__bc_dist_subst(); before this we would only do
one level, which fails on simple structures like the old NASM align approach
of "($$-$) & value" (as the $$-$ is one level down in the expression).
Peter Johnson [Fri, 29 Sep 2006 07:18:45 +0000 (07:18 -0000)]
- Fix much brokenness in absolute value handling, particularly in regards to
PC-relative relocations (jumps and calls).
- Allow SEG:OFF to be used as just an offset portion (like NASM does).
- Labels in absolute sections that are declared global are given the correct
absolute value in the symbol table.
One difference from NASM:
label equ 0040h:001eh
jmp label
in NASM means the same as:
jmp 001eh (a near jump)
but yasm will treat this the same as:
jmp 0040h:001eh (a far jump)
I'm still not completely happy with this implementation, but it's workable
and fixes all the bugs I've found so far in absolute handling.