Check for duplicates in backtrace used when checking for circular references.
This uses a simple N^2 algorithm (as the number of items in the backtrace is
usually small) but avoids memory runaway due to duplicate item storage.
svn path=/trunk/yasm/; revision=2229
This breaks horribly for things like (sym+511)>>9 in -f bin, as the result is
zero instead of something more useful.
Also don't check RHS for symbols; these will fall out later in the assembly
process if they cannot be simplified.
svn path=/trunk/yasm/; revision=2220
This was because the path returned by yasm__getcwd() did not have a trailing
slash and thus yasm__combpath() stripped off the last path component.
svn path=/trunk/yasm/; revision=2202
In ELF, @ is used to indicate special relocations.
Fixes#164.
Reported by: Gregory McGarry on yasm-devel@
Testcase by: Gregory McGarry
We don't allow identifiers to start with @; doing so conflicts with use of
e.g. "@function" in some directives. Need to look into what GAS does.
svn path=/trunk/yasm/; revision=2166
Contributed by: Samuel Thibault <samuel.thibault@ens-lyon.org>
It is built on top of the NASM parser and preproc, with the following
notable extensions for TASM syntax:
- case insensitive symbols and filenames,
- support for segment and size of labels, which permits to avoid giving
them on each memory dereference,
- support for data reservation (i.e. e.g. "var dd ?"),
- support for multiples (i.e. e.g. "var dd 1 dup 10"),
- little endian string integer constants,
- additional expression operators: shl, shr, and, or, low, high,
- additional offset keyword,
- additional fword and df,
- support for doubled quotes within quotes,
- support for array-like and structure-like notations: t[eax] and
[var].field,
- support for tasm directives: macro, rept, irp, locals, proc, struc,
segment, assume.
Notes:
- Almost all extensions are only effective when tasm_compatible_mode is
set, so we should have very reduced possible breakage.
- Because the "and" keyword can be an expression operator and an
instruction name, the data pseudo-instructions explicitly switch the
lexer state to INSTRUCTION state to fix the ambiguity.
- In gen_x86_insn.py, several instructions (namely lds and lea) now take
relaxed memory sizes. The reason is that in the case of tasm, the size
of the actual pointed data is passed up to there, and thus any type of
data should be accepted.
With all of this, loadlin can be compiled by yasm with quite reduced
modifications.
A new TASM-like frontend is also included.
svn path=/trunk/yasm/; revision=2130
If an expression of the form INT+(a+b)+INT was simplified, constant folding
would combine the ints, but then the level stage (to make INT+a+b) would
start reading from the second (deleted due to folding) INT rather than the
new end of the expression.
Reported by: Samuel Thibault (on yasm-devel@)
svn path=/trunk/yasm/; revision=2123
Formerly, it would not correctly handle absolute paths. Now it uses
yasm__combpath() to do absolute-path aware path combination.
As a benefit, it no longer needs to be OS-specific.
Reported by: Shmuel Baron <shmulik@gmail.com>
svn path=/trunk/yasm/; revision=2116
should not be listed in BUILT_SOURCES but rather have nodist_ prepended.
They still need to be separately listed as CLEANFILES as they're built
at make time.
Reported by: David Harvey <dmharvey@math.harvard.edu>
svn path=/trunk/yasm/; revision=2111
These allow arbitrary prefixes and/or suffixes to be added to
externally-visible (GLOBAL, EXTERN, or COMMON) symbol names.
svn path=/trunk/yasm/; revision=2109
Add proper declspec dllimport/dllexport to all libyasm functions.
Use macros to make these do nothing on non-cmake and Unix builds.
svn path=/trunk/yasm/; revision=2101
Not default nor even distributed in the .tar.gz, the cmake build allows for
loadable yasm plugins by building libyasm as a shared library.
Example plugins are in the plugins/ directory, and may be loaded into a
cmake-built yasm using the -N command line option (non-cmake builds will
not have this option).
Tested only on Linux so far, but should be relatively painless to port to
Windows thanks to the use of cmake rather than libtool to create shared
libraries.
The only modification to the main source tree is some conditional-compiled
additions to yasm.c.
svn path=/trunk/yasm/; revision=2098
Standard macro sets are looked up based on parser and preprocessor keyword
from individual modules.
The "standard" NASM parser macros now reside in the NASM parser, so when
the GAS parser is used with the NASM preprocessor, the NASM-specific macros
are no longer defined.
Object-format specific macros are now individually defined by each object
formatm module. This allows for the object formats to be independent of the
NASM preprocessor module and yields a small optimization benefit as unused
object format macros don't need to be skipped over.
Also add GAS macro equivalents for the Win64 SEH more complex directives [1].
[1] Requested by Brian Gladman <brg@gladman.plus.com>
svn path=/trunk/yasm/; revision=2082
A full testcase for NASM mode based on the AVX programming reference is
included. GAS mode should work, but is untested at present.
V-prefix aliases are present for all supported instructions to allow easy
use of the VEX prefix version without significant code modifications.
All comparison and other pseudo-ops are included.
svn path=/trunk/yasm/; revision=2051
To do this, restructure how special symbols are handled between the parser
and object format. Instead of creating special symbols with the right
names, instead have the parser call the object format to see if a match
is found into the special symbols, which are no longer stored in the
symbol table.
svn path=/trunk/yasm/; revision=2035
avoid warnings. This is primarily useful in bin object format output.
db label ; if label is >255, warns.
db label & 0xff ; okay, no warning.
Masks other than full-sized 1s are still not supported:
db label & 0x7f ; too complex error
svn path=/trunk/yasm/; revision=2034
Formerly:
foo equ 1:2
jmp foo
would result in a far jump. Now, an explicit "far" is required:
jmp far foo
to generate a far jump.
In addition, the direct use of seg:off in immediates and effective
addresses will result in an error; the use of EQU'ed seg:off values
is still legal (and will still result in just the offset). This
behavior is more sane and also matches NASM behavior.
Thus:
foo equ 1:2
mov ax, foo ; okay, just 2
mov ax, [foo] ; okay, just 2
mov ax, 1:2 ; illegal
mov ax, [1:2] ; illegal
svn path=/trunk/yasm/; revision=2028
This allows for arbitrary load (LMA) and execution (VMA) addresses.
The following new section attributes are supported:
- start (LMA start address)
- follows (follow another section's last LMA)
- align (LMA alignment)
- vstart (VMA start address)
- vfollows (follow another section's last VMA)
- valign (VMA alignment)
In addition, sections can be designed progbits or nobits.
The following special symbols are generated for program use:
- section.<sectname>.start (LMA start address)
- section.<sectname>.vstart (VMA start address)
- section.<sectname>.length (section length)
The ORG directive adjusts the file offset relative to LMA, so that if
ORG=0x100, a section with LMA=0x100 will be at file offset 0.
VMA addresses are the same as LMA addresses unless otherwise specified.
Full map file support is supported via the [MAP] directive. The map output
filename can be set either as a parameter to the [MAP] directive or on the
command line with --mapfile=<filename>. MAP options are BRIEF, SECTIONS,
SEGMENTS, SYMBOLS, and ALL (all of the above). If no filename is specified
either on the command line or in the source file, the map is output to
standard output.
Full documentation will be added to the Yasm manual in the near future.
This implementation supports several configurations NASM does not, for
instance http://osdir.com/ml/lang.nasm.devel/2004-12/msg00032.html .
It is also fully 64-bit aware.
Fixes: #71, #99.
svn path=/trunk/yasm/; revision=2010
Note: label values are still not supported, and probably never will be,
as yasm is single-pass parsing, and only reads the source file once.
Someday we may add specific support for relatively common %if-%error
idioms.
svn path=/trunk/yasm/; revision=2008
This will make certain types of parser-preprocessor synchronization
easier for upcoming feature enhancements.
Due to additional complexity in GAS (rept), internally GAS converts
lines back into blocks.
svn path=/trunk/yasm/; revision=2007
Instead write our own yasm__getcwd() which retries getcwd() with
increasing buffer sizes until the path fits (as the initial size is 1024,
in basically all cases it'll succeed on the first try).
Reported by: bird-yasm@anduin.net
svn path=/trunk/yasm/; revision=2004
This adds a "default" directive that takes either "rel" or "abs". This
sets whether the default mode for simple displacements is RIP-relative (rel)
or not (abs). The default without a directive is "abs".
Also added is corresponding "rel" and "abs" effective address modifiers
to override whatever default is set:
[rel label] is RIP-relative
[abs label] is not.
In default rel mode, [label] defaults to the former, in default abs mode,
the latter. Also, segment overrides (note difference from NASM below) are
abs regardless of mode, unless explicitly overridden with rel:
[fs:label] is always abs
[rel fs:label] is always rel
However, we have a number of differences from NASM in this handling due to
what I feel to be yasm's more sane handling of [dword ...] and [qword ...].
In yasm, these set the displacement size, rather than the address size; the
latter is set using a a32/a64 prefix. I feel this is more sane as in 64-bit
mode the two can be different in the MovOffs (A0/A1 mov *ax) case.
Also, yasm disables default-rel mode if any segment register is used, not
just FS or GS as NASM currently does.
See modules/arch/x86/tests/riprel1.asm and
modules/arch/x86/tests/riprel2.asm for examples, as well as my recent
posting to the nasm-devel mailing list on SF.
svn path=/trunk/yasm/; revision=1963
Not doing this could cause us to lose an entry if the tree is deep enough
that we need to rehash the keys as we're moving downward.
Reported by: Stefan Sellmer <stefansel@hotmail.de>
svn path=/trunk/yasm/; revision=1905
- HAMT_search() wasn't doing a full string comparison on the key before
returning success.
- HAMT_insert()'s check for the above was always doing a case-sensitive
check; fixed to use case-insensitive when the HAMT is supposed to be
case-insensitive (and likewise for HAMT_search).
svn path=/trunk/yasm/; revision=1903
intnum to not allocate bitvectors for "most" negative numbers.
We pay a bit more in conversion, but save big in terms of memory and
malloc/free calls
(e.g. ~10,000 allocations and ~250K bytes for elf-x86id.asm test).
svn path=/trunk/yasm/; revision=1900
parser.
Add testcase for both local labels and .org fill.
Noticed by: Jung Lee <moorang@gmail.com>
Testcase from: Xiaoming Mo <xiaoming.mo@skelix.org>
svn path=/trunk/yasm/; revision=1899