While NASM doesn't allow this, GAS does.
While we're here, greatly clean up GAS data bytecode creation by no longer
building intermediate valparam list.
* bytecode.h (yasm_dv_create_string): Add length parameter.
(yasm_bc_create_data): Add append_zero parameter for new ability to append
a single ero byte after each data value. This is used by the GAS .asciz
directive.
* bytecode.c (bytecode_data, ...): Implement the above.
* gas-bison.y (gas_define_strings, gas_define_data)
(gas_define_leb128): Remove; replace in usage with direct calls to bytecode
functions. Add str, dataval, and datavalhead to parser union. Add new
dirvals, which has valparams type, and change strvals and datavals to
datavals type.
* gas-token.re: Use new str type where STRING token is generated.
* nasm-bison.y: Add str type to union, and use for STRING token.
* nasm-token.re: Use new str type where STRING token is generated.
* coff-objfmt.c (win32_objfmt_directive): Adjust for updates to
bytecode_data.
* strzero.asm: Simple test for NUL in GAS string.
svn path=/trunk/yasm/; revision=1293
* bytecode.c (yasm_bc_create_empty_insn): New function to create empty
instruction that can have prefixes applied to it, for standalone prefixes.
* bytecode.h (yasm_bc_create_empty_insn): Prototype.
* x86arch.h (x86_parse_insn_prefix): Add prefix types for segment registers
(X86_SEGREG) and REX bytes (X86_REX).
(yasm_x86__bc_apply_prefixes): Adjust prototype to include REX pointer (as
this isn't in the x86_common structure).
* x86bc.c (yasm_x86__bc_apply_prefixes): Support the new prefix types.
* x86id.re (x86_finalize_*): Use const x86_insn_info; all insn_infos are
const so these pointers should be as well.
(yasm_x86__finalize_insn): Handle empty instruction case by pointing to new
empty_insn info.
(empty_insn): New.
(yasm_x86__parse_check_prefix): Support GAS prefix naming, and REX and jump
hint prefixes (only in GAS mode at the moment).
* gas-bison.y: Add rules to handle segreg prefixes as well as standalone
prefixes (both segreg and others).
* gas-prefix.asm: New testcase that also hits the warning cases in
yasm_x86__bc_apply_prefixes X86_REX case.
svn path=/trunk/yasm/; revision=1292
This is generated by GCC in debug sections.
* gas-token.re: Likewise.
* gas-bison.y: Add support for 4th parameter on .section directive, for use
with M (SHF_MERGE) ELF section flag.
* elf-objfmt.c: Add support for M, S (SHF_STRINGS), G (SHF_GROUP), and T
(SHF_TLS) section flags.
* elf.h: Declare additional SHF_* flags.
With these changes, debug information generated by GCC in GAS format is
passed through successfully. Should just need line number generation to
have full debugging for ELF-DWARF2 coming from GCC.
Only remaining thing to handle that I see at the moment for full GCC output
support is multiple instructions on one line (separated by semicolons).
svn path=/trunk/yasm/; revision=1289
invalid relocation is generated, this still gets called but with a NULL
addend.
* expr.c (expr_xform_bc_dist): Check return value of yasm_symrec_get_label()
to avoid crash.
svn path=/trunk/yasm/; revision=1288
is needed for the GAS .uleb128 and .sleb128 directives.
* intnum.c (yasm_intnum_sign): New signedness discovery function.
* intnum.h (yasm_intnum_sign): Prototype.
* intnum.c (yasm_intnum_get_leb128, yasm_intnum_size_leb128): New.
* intnum.h (yasm_intnum_get_leb128, yasm_intnum_size_leb128): Prototype.
* leb128_test.c: New test for intnum-level LEB128 functions.
* bytecode.c (bytecode_leb128): New bytecode and supporting functions.
(yasm_bc_create_leb128): New creation function.
* bytecode.h (yasm_bc_create_leb128): Prototype.
* gas-token.re: Recognize .uleb128 and .sleb128.
* gas-bison.y: Ditto.
(gas_define_leb128): New.
* leb128.asm: New test for GAS .uleb128 and .sleb128 directives.
svn path=/trunk/yasm/; revision=1287
Going ahead and removing the cleanup script; a later commit will get rid
of the remaining unused variable warnings that the cleanup script took care
of as well.
svn path=/trunk/yasm/; revision=1273
address16_op flags into a single postop enum.
* x86id.re (yasm_x86__finalie_insn): Set new enum rather than flags.
* x86bc.c: Use new combined enum.
svn path=/trunk/yasm/; revision=1268
While we're here, add 64-bit register versions of SSE2 instructions movmskps,
pextrw, pinsrw, and pmovmskb that are documented by Intel but not AMD.
Add test for above.
svn path=/trunk/yasm/; revision=1265
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
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
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
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
- 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
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
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
(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
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
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