flag, not just sections named ".text".
* section.h (yasm_object_get_general): Add code flag parameter to indicate
if section is intended to contain code.
(yasm_section_is_code): New, to get value of code flag.
* section.c (yasm_section): Add flag to section structure.
(yasm_object_get_general, yasm_section_is_code): Implement flag.
* *-objfmt.c, stabs-dbgfmt.c: Update call to yasm_object_get_general,
setting code flag appropriately (only elf *really* handles this correctly,
coff still needs to handle GAS flags to work fully from GAS mode).
* gas-parser.h (yasm_parser_gas): Remove code_section flag.
* gas-bison.y (gas_switch_section): Don't set.
(gas_parser_align): Use yasm_section_is_code() instead of code_section flag.
* gas-parser.c: Don't initialize code_section flag.
svn path=/trunk/yasm/; revision=1318
if the first thing in the section is a .align, that specifies the section
alignment.
* objfmt.h (yasm_objfmt_module): Add section_align() function.
(yasm_objfmt_section_align): Add wrapper for module section_align().
* xdf-objfmt.c, elf-objfmt.c, bin-objfmt.c, dbg-objfmt.c, coff-objfmt.c:
Implement.
* gas-bison.y (gas_parser_align): Call new yasm_objfmt_section_align() rather
than creating an align bytecode if .align is the first bytecode in the
section.
* gassectalign.asm: New test for this.
svn path=/trunk/yasm/; revision=1315
places in GAS input. Do this by adding a tokenizer state that turns off
insn and prefix generation when inside an instruction or directive, AND
adding a special case for labels.
* gas-parser.h (state): Add INSTDIR.
* gas-token.re: Switch state back to INITIAL on ';' or newline; set state
when entering instruction or directive, add special case for labels.
* gas-bison.y: Remove non-working attempt at translating INSN and PREFIX
into string token; add special case for LABEL identifiers (generated from
special case for labels in tokenizer).
svn path=/trunk/yasm/; revision=1309
allowed at the moment. The implementation works mostly like a preproc; it
copies source lines and replays them to the lexer. A new .line directive
was added to fix up line numbers for errors and warnings.
* gas-parser.h (yasm_parser_gas): Add rept structure storage.
(gas_rept): New data structure for .rept state.
(gas_rept_line): Data structure to store source lines within .rept block.
* gas-parser.c: Initialize rept to NULL and check for unclosed rept.
* gas-bison.y: Add support for .line, .rept, and .endr directives. The
DIR_REPT handler just creates the rept structure, and the DIR_ENDR handler
just errors (.endr without .rept). All the real work is done in the lexer.
* gas-token.re (rept_input): Replays captured .rept block source lines back
to fill().
(fill): Call rept_input() instead of yasm_preproc_input() if expanding a
rept block.
(gas_parser_lex): Capture source lines and store into rept data structures.
Also added a whole bunch of testcases.
svn path=/trunk/yasm/; revision=1306
* gas-bison.y (gas_get_section, gas_switch_section): Add parameter builtin
to indicate gas flags should not be generated.
svn path=/trunk/yasm/; revision=1299
* gas-bison.y (gas_get_section): Don't create empty gas flags unless type
is also specified. This fixes .data/.text/etc section flags.
* elf-objfmt.c (elf_objfmt_section_switch): Add default flags for .comment
section; this is needed so the above change doesn't break .ident.
svn path=/trunk/yasm/; revision=1298
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
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
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
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
This work is being done under contract with a company that has requested
to remain unnamed at the present time.
* bc-int.h (yasm_effaddr): Add strong flag to indicate if the effective
address is definitely an effective address; GAS does not use [] to designate
effective addresses so it's otherwise impossible to tell the difference
between "expr(,1)" and just "expr" (important for the relative jump
instructions).
* bytecode.h (yasm_ea_set_strong): New function to set the strong flag.
* bytecode.c (yasm_ea_set_strong): Implementation.
* x86bc.c (yasm_x86__ea_create_reg): Initialize strong flag.
* arch.h (yasm_insn_operand): Add deref flag to indicate use of "*foo" in
GAS syntax.
* arch.c (yasm_operand_create_reg, yasm_operand_create_segreg)
(yasm_operand_create_mem, yasm_operand_create_imm): Set deref flag to 0.
* gas: GAS syntax lexer and parser. Not all directives are implemented yet
(some will require additional core bytecodes).
* elf-objfmt.c (elf_objfmt_section_switch): Add support for GAS-style
section flags.
* x86arch.h (yasm_arch_x86): Add parser setting.
* x86arch.c (x86_create): Check for gas parser and initialize setting.
* x86bc.c (yasm_x86__ea_create_expr): Transform val+RIP to val wrt RIP when
using the GAS parser (this is how GAS interprets "expr(%rip)").
* x86id.re: Too many changes to enumerate in detail. Add new modifiers for
GAS suffixes. Start using them in a couple instructions. Split check_id
into subfunctions (still one entry point at present).
(yasm_x86__finalize_insn): Support new modifiers, reverse operands, derefs.
* yasm.c (main): Change all undef to extern when using GAS parser (this is
default GAS behavior).
svn path=/trunk/yasm/; revision=1239