Previously a line such as "times 4 mov rax, [rel foobar]" would result
in incorrect relocations being generated.
Patch by: bird-yasm@anduin.net
[#211 state:resolved]
Don't generate an additional offset for _GLOBAL_OFFSET_TABLE_ if a WRT was
specified (the NASM usage). In GAS, _GLOBAL_OFFSET_TABLE_ doesn't have a WRT
but instead has special handling.
This isn't quite *exactly* the right fix; a better fix would be to recognize
the _GLOBAL_OFFSET_TABLE_ case in the GAS parser and adjust the value
appropriately there. However, this fix seems to do the right thing in the
meantime for both GAS and NASM cases.
svn path=/trunk/yasm/; revision=2321
add new objfmt interface function init_new_section() to initialize as we
go.
This fixes several issues, primarily with debug formats that create sections.
Reported by: Brian Gladman
svn path=/trunk/yasm/; revision=2310
This was particularly noticable in GAS, but there was also a bug in NASM
output (lack of fixup within instruction in elf32).
Also:
- changed ssym lookup from a linear search to using assocdata
- added more relocation types (most not implemented)
Reported by: Mark Charney
svn path=/trunk/yasm/; revision=2206
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
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
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
- symbol is defined in a TLS section
- symbol is used in a TLS relocation
This is required by the GNU linker, and matches GNU as behavior.
The implementation is not as clean as it perhaps should be, but it does
the job.
Reported by: Nils Weller <nils@gnulinux.nl>
svn path=/trunk/yasm/; revision=2040
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
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
Reported by: Loren Merritt
Fix by: mu@
We already had a testcase for this, but it had an incorrect "golden" result.
svn path=/trunk/yasm/; revision=1952
makes value/parameters more well-defined and flexible enough to handle
string parameters. Value/parameters would now be better called name/values,
but avoid changing the name for now.
svn path=/trunk/yasm/; revision=1851
from libyasm core. Now absolute sections are tracked locally to the parser
and the parser generates EQUs directly for labels in absolute sections.
Fixes#106 and #103.
svn path=/trunk/yasm/; revision=1842
been using a mix of tabs and 4 spaces to indent; this looks horrible if
tab size is ever not 8. While I debated converting to tab-only indentation
that would have been a far higher impact to the source.
svn path=/trunk/yasm/; revision=1825
and common declare. The latter no longer passes through objfmt at parse time;
instead the objfmt must handle them at output time (objfmt-specific
extensions are parsed & stored by the parser). Directives are now handled
using a list (with function pointers) rather than a single function entry
point.
svn path=/trunk/yasm/; revision=1819
yasm_dbgfmt, and yasm_arch. This eliminates a lot of redundant keeping
track of this information in the individual object and debug formats and
also simplifies a fair amount of code.
I'm still not happy with how arch gets passed around in output code, but
there may not be much of an alternative there.
While I'm here, clean up some unused variables and functions and re-enable
the warning for unused variables in configure.ac.
svn path=/trunk/yasm/; revision=1812
a lower level.
To reduce code duplication, refactor several of the large if/else structures
into multiple functions with a lookup table.
Add support for registers to be used in directive expressions.
Allow directives to have underscores and numbers (still cannot start with
numbers).
svn path=/trunk/yasm/; revision=1757
NASM behavior with regards to e.g. extern $foo.
Unfortunately this makes yasm start not matching NASM behavior with regards
to the RDF module directive. In NASM, module $foo results in a literal $foo
reference; yasm now requires either a double $ (e.g. $$foo) or quotes (e.g.
"$foo"). The special case for section (section $foo --> literal $foo) is
still present, but keeping this for other directives is extremely difficult.
svn path=/trunk/yasm/; revision=1754
(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.
svn path=/trunk/yasm/; revision=1723
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>
svn path=/trunk/yasm/; revision=1712
(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.
Reported by: Peter Tanski <peter_tanski@cox.net>
svn path=/trunk/yasm/; revision=1705
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.
svn path=/trunk/yasm/; revision=1680
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.
svn path=/trunk/yasm/; revision=1634