]> granicus.if.org Git - yasm/log
yasm
18 years ago* gas-bison.y: Close a couple of memory leaks.
Peter Johnson [Sun, 5 Mar 2006 23:33:34 +0000 (23:33 -0000)]
* gas-bison.y: Close a couple of memory leaks.

svn path=/trunk/yasm/; revision=1408

18 years ago* hamt.c (HAMT_delete_trie): Close memory leak (max'ing of size would make
Peter Johnson [Sun, 5 Mar 2006 22:40:44 +0000 (22:40 -0000)]
* hamt.c (HAMT_delete_trie): Close memory leak (max'ing of size would make
size=0 instead of 32 when the actual size was 32).

svn path=/trunk/yasm/; revision=1407

18 years agoMkfiles: Take hamt out of GAP builds here as well.
Peter Johnson [Sun, 5 Mar 2006 22:17:31 +0000 (22:17 -0000)]
Mkfiles: Take hamt out of GAP builds here as well.

svn path=/trunk/yasm/; revision=1406

18 years ago* gap.c: Don't use HAMT.
Peter Johnson [Sun, 5 Mar 2006 22:05:26 +0000 (22:05 -0000)]
* gap.c: Don't use HAMT.
* Makefile.inc: Remove hamt.c from GAP build and turn off -g when building.
* hamt.c: Revert [1404] (no longer required).

svn path=/trunk/yasm/; revision=1405

18 years ago* hamt.c: Add stopgap fix for GAP in cross-build situations by typedefing
Peter Johnson [Sun, 5 Mar 2006 21:15:59 +0000 (21:15 -0000)]
* hamt.c: Add stopgap fix for GAP in cross-build situations by typedefing
uintptr_t to unsigned long for the build platform (instead of trying to
pull in the host platform's _stdint.h).

svn path=/trunk/yasm/; revision=1404

18 years ago* bytecode.c (yasm_bc_destroy): Only xfree symrecs if non-NULL.
Peter Johnson [Sun, 5 Mar 2006 09:29:52 +0000 (09:29 -0000)]
* bytecode.c (yasm_bc_destroy): Only xfree symrecs if non-NULL.
(bc_align_destroy): Free boundary and maxskip (closing memory leaks).
* gas-bison.y (gas_get_section): Don't strdup name, it's always passed
in already strdup'ed/allocated (closes memory leak).

svn path=/trunk/yasm/; revision=1403

18 years ago* dwarf2-info.c: Include config.h before looking for HAVE_UNISTD_H define.
Peter Johnson [Sun, 5 Mar 2006 09:19:25 +0000 (09:19 -0000)]
* dwarf2-info.c: Include config.h before looking for HAVE_UNISTD_H define.

svn path=/trunk/yasm/; revision=1402

18 years ago* dwarf2-info.c: Reorder includes so that compiling against dmalloc works.
Peter Johnson [Sun, 5 Mar 2006 09:06:59 +0000 (09:06 -0000)]
* dwarf2-info.c: Reorder includes so that compiling against dmalloc works.

* dwarf2-info.c, dwarf2-aranges.c: Enable Id keyword.

svn path=/trunk/yasm/; revision=1401

18 years ago* bytecode.c (yasm_bc_create_insn): Use yasm_ops_initialize() instead of
Peter Johnson [Sun, 5 Mar 2006 08:02:35 +0000 (08:02 -0000)]
* bytecode.c (yasm_bc_create_insn): Use yasm_ops_initialize() instead of
STAILQ_INIT().
(yasm_bc_create_empty_insn): Initialize operands member.

svn path=/trunk/yasm/; revision=1400

18 years agoFix a few things found by valgrind. There will be more of these.
Peter Johnson [Sun, 5 Mar 2006 07:50:16 +0000 (07:50 -0000)]
Fix a few things found by valgrind.  There will be more of these.

* bytecode.c (yasm_bc_create_insn): Initialize operands list if none were
given.
* section.c (yasm_object_destroy): Free filenames.
* gas-token.c (fill): Use memmove instead of memcpy on overlapping memory
copy.
* nasm-token.c (fill): Likewise.
* elf.c (elf_secthead_destroy): Free size member.

svn path=/trunk/yasm/; revision=1399

18 years ago* phash.c (phash_lookup), perfect.c (initnorm): Mask upper bits in hash
Peter Johnson [Sun, 5 Mar 2006 01:07:38 +0000 (01:07 -0000)]
* phash.c (phash_lookup), perfect.c (initnorm): Mask upper bits in hash
calculations so that these functions behave identically on 32-bit and >32-bit
architectures.

* gap.c: Fix warnings.
* perfect.c: Change K&R to prototypes to avoid warnings.

svn path=/trunk/yasm/; revision=1398

18 years ago* tools/gap: Clean up unused variables, bad size usage, return success on
Peter Johnson [Sun, 5 Mar 2006 00:11:20 +0000 (00:11 -0000)]
* tools/gap: Clean up unused variables, bad size usage, return success on
failure cases, and other nits.

svn path=/trunk/yasm/; revision=1397

18 years ago* Mkfiles/vc, Mkfiles/vc8: Fix a couple problems with the VC build changes in [1395].
Peter Johnson [Sat, 4 Mar 2006 22:33:43 +0000 (22:33 -0000)]
* Mkfiles/vc, Mkfiles/vc8: Fix a couple problems with the VC build changes in [1395].

svn path=/trunk/yasm/; revision=1396

18 years agoRewrite x86 identifier recognition to use a minimal perfect hash table
Peter Johnson [Sat, 4 Mar 2006 22:09:26 +0000 (22:09 -0000)]
Rewrite x86 identifier recognition to use a minimal perfect hash table
instead of re2c-generated code.  This gives identifier recognition a
significant speedup and also drastically shortens compilation time of yasm
itself.  This rewrite encouraged combining instruction and prefix
recognition into one function and register and target modifier
recognition into a second function (rather than having 5 or so separate
functions).

Also created a state in the NASM parser (as was done in the GAS parser),
so instructions/prefixes are only looked for until an instruction is
recognized.  This avoids search time in the instructions hash for operands.

The tool used to generate the new identifier recognition is called GAP.
Someday we might extend this to generate more code than just the perfect
hash lookup.

* tools/gap: New tool to Generate Architecture Parser (aka perfect hashes).
* phash.c, phash.h: Helper functions used by GAP-generated code.

* x86id.re: Delete.  Split into..
* x86parse.gap: Contains all identifier recognition portions.
* x86id.c: Contains instruction operand tables and code and higher-level
entry points into x86parse.gap perfect hash recognizers.  Chose to flow
history of x86id.re into this file.

* arch.h: Combine instruction/prefix entry points and register/target
modifier entry points.
* lc3barch.c, lc3bid.re, lc3barch.h: Update to match.
* x86arch.c, x86arch.h: Update to match.

* Makefile.am, various Makefile.inc: Update.
* POTFILES.in: Update due to numerous file changes (not just this commit).
* Mkfiles: Update.  VC build files untested at the moment.

svn path=/trunk/yasm/; revision=1395

18 years ago* genmodule.c: Enable svn:keywords Id.
Peter Johnson [Sat, 4 Mar 2006 21:04:25 +0000 (21:04 -0000)]
* genmodule.c: Enable svn:keywords Id.

svn path=/trunk/yasm/; revision=1394

18 years ago* x86id.re (retnf_insn, yasm_x86__parse_check_insn): Fix handling of retf
Peter Johnson [Thu, 2 Mar 2006 02:53:11 +0000 (02:53 -0000)]
* x86id.re (retnf_insn, yasm_x86__parse_check_insn): Fix handling of retf
(NASM syntax) in 64-bit mode.  While I'm here, make all ret forms in GAS mode
match GAS output.

Noticed by: Stefan <SMarF@gmx.de>

svn path=/trunk/yasm/; revision=1393

18 years ago* objfmt.h (yasm_objfmt_add_default_section): Update doxygen documentation.
Peter Johnson [Wed, 1 Mar 2006 01:45:36 +0000 (01:45 -0000)]
* objfmt.h (yasm_objfmt_add_default_section): Update doxygen documentation.

svn path=/trunk/yasm/; revision=1392

18 years ago* coff-objfmt.c: Fix crash when sections are generated inside of the
Peter Johnson [Tue, 28 Feb 2006 07:59:29 +0000 (07:59 -0000)]
* coff-objfmt.c: Fix crash when sections are generated inside of the
assembler that don't call section_switch(), e.g. for dwarf2 internally
generated debug sections.

svn path=/trunk/yasm/; revision=1391

18 years agoFix #70 by allowing overrides on the default (usually ".text") section.
Peter Johnson [Sat, 25 Feb 2006 19:39:57 +0000 (19:39 -0000)]
Fix #70 by allowing overrides on the default (usually ".text") section.
The fix for this rippled into a lot of places, and I'm starting to see some
opportunities for cleaning up some of the object and objfmt structures.

* objfmt.h (yasm_objfmt_add_default_section): Move from standalone function
into objfmt-specific function.
(yasm_objfmt_module): Remove default_section_name string, and add objfmt
specific add_default_section function.
* yasm.c (main): Use slightly updated parameters when calling.

* section.h (yasm_section_is_default, yasm_section_set_default): New.
* section.c (yasm_section): Add def member (for default section flag).
(yasm_section_is_default, yasm_section_set_default): Implement.

* xdf-objfmt.c, bin-objfmt.c, dbg-objfmt.c, coff-objfmt.c: Implement.
Usually this required refactoring the objfmt-specific section data creation
into a separate function that could be used by both section_switch() and
the new add_default_section() functions, and changing section_switch() to
update changes to the section data if section was new or previously just a
default section, instead of the previous behavior of warning if the section
was not new.

* objfmt.c: Delete (no longer needed).
* Makefile.inc, Makefile.flat, libyasm.vcproj
Makefile.dj: Update to reflect removal.

* xdf-overdef.asm, win32-overdef.asm, elf-overdef.asm: Test.

svn path=/trunk/yasm/; revision=1390

18 years agoFix #69 by making the NASM preproc and parser use the yasm built-in
Peter Johnson [Fri, 24 Feb 2006 04:29:39 +0000 (04:29 -0000)]
Fix #69 by making the NASM preproc and parser use the yasm built-in
alignment bytecode rather than just times'ing a NOP.  This generates better
NOP code.

The new align only triggers when the NASM align directive is used unadorned
or with nop as the parameter (e.g. "align 16" or "align 16, nop").  Other
uses, including all uses of balign, maintain their old NASM behavior.  This
is somewhat useful if you still want a string of NOPs rather than more
optimized instruction patterns: just use "balign X, nop" rather than
"align X".  The new align also follows the GAS behavior of increasing the
section's alignment to be the specified alignment (if not already larger).

While I was in here, I found and fixed a bug in 16-bit alignment generation
(typo).  I also changed the x86 32-bit code alignment fill pattern per
suggestions in the AMD x86 code optimization manual.

* nasm-bison.y: Implement a new [align] directive that can take a single
parameter (the alignment) and generate a nop-generating align bytecode.
* standard.mac: Change align macro to generate [align] if the second
macro parameter is nonexistent or "nop".
* x86arch.c (x86_get_fill): Update 32-bit fill pattern and fix bug in 16-bit
fill pattern.

svn path=/trunk/yasm/; revision=1389

18 years ago* dwarf2-info.c (yasm_dwarf2__generate_info): Set section alignment to 0 for
Peter Johnson [Tue, 14 Feb 2006 07:16:24 +0000 (07:16 -0000)]
* dwarf2-info.c (yasm_dwarf2__generate_info): Set section alignment to 0 for
.debug_info and .debug_abbrev; this fixes DWARF2 for gdb on Linux.

svn path=/trunk/yasm/; revision=1388

18 years agoRemove some unused variables/functions.
Peter Johnson [Tue, 14 Feb 2006 03:32:52 +0000 (03:32 -0000)]
Remove some unused variables/functions.

* dwarf2-info.c (dwarf2_info_head_*): Remove.

* dwarf2-line.c (dwarf2_spp_bc_tobytes): Remove unused variable.
* dwarf2-dbgfmt.c (dwarf2_dbgfmt_generate, dwarf2_head_bc_tobytes): Likewise.
* leb128_test.c (run_input_test): Likewise.

svn path=/trunk/yasm/; revision=1387

18 years ago* intnum.c (yasm_intnum_create_leb128): Create an intnum from a LEB128
Peter Johnson [Sun, 12 Feb 2006 23:12:10 +0000 (23:12 -0000)]
* intnum.c (yasm_intnum_create_leb128): Create an intnum from a LEB128
encoded value.
* intnum.h (yasm_intnum_create_leb128): Prototype.
* leb128_test.c: Test above.

svn path=/trunk/yasm/; revision=1386

18 years ago* dwarf2-info.c (yasm_dwarf2__generate_info): Fully initialize second debug_abbrev...
Peter Johnson [Sun, 12 Feb 2006 04:00:10 +0000 (04:00 -0000)]
* dwarf2-info.c (yasm_dwarf2__generate_info): Fully initialize second debug_abbrev to avoid crash
on free.

svn path=/trunk/yasm/; revision=1383

18 years ago* Mkfiles: Update to sync with [1376].
Peter Johnson [Sun, 12 Feb 2006 01:46:15 +0000 (01:46 -0000)]
* Mkfiles: Update to sync with [1376].

svn path=/trunk/yasm/; revision=1380

18 years ago* dwarf2/Makefile.inc: Include dbgfmt-dwarf2.h.
Peter Johnson [Sun, 12 Feb 2006 01:27:39 +0000 (01:27 -0000)]
* dwarf2/Makefile.inc: Include dbgfmt-dwarf2.h.

svn path=/trunk/yasm/; revision=1378

18 years agoGenerate DWARF2 information from asm source, closing #43. Asm-level source
Peter Johnson [Sat, 11 Feb 2006 21:58:35 +0000 (21:58 -0000)]
Generate DWARF2 information from asm source, closing #43.  Asm-level source
debug information is generated if no file/loc directives are used.  Also will
generate basic DWARF2 info/abbrev/aranges if not specified in source.  What's
not handled is multiple code sections; I need to figure out how DWARF2 expects
these to be generated.

The implementation of this refactors all the line generation into
dwarf2-line.c and makes dwarf2-dbgfmt.c contain only the core DWARF2
functions.

One challenge yet to be taken care of is how to test the automatic generation,
as the current working directory is saved into the output object file.

* dwarf64_2loc: Update so built-in info generation doesn't happen.

svn path=/trunk/yasm/; revision=1376

18 years ago* stabs-elf.hex: Update to match previous commit.
Peter Johnson [Sat, 11 Feb 2006 21:52:52 +0000 (21:52 -0000)]
* stabs-elf.hex: Update to match previous commit.

svn path=/trunk/yasm/; revision=1375

18 years ago* elf-objfmt.c (elf_objfmt_output): Create all missing section headers using
Peter Johnson [Sat, 11 Feb 2006 21:52:20 +0000 (21:52 -0000)]
* elf-objfmt.c (elf_objfmt_output): Create all missing section headers using
initial traversal of object sections.  This ensures any symbols generated by
elf_objfmt_create_dbg_secthead() are properly accounted for.
(elf_objfmt_create_dbg_secthead): Update to be properly called from traversal.

svn path=/trunk/yasm/; revision=1374

18 years ago* linemgr.h (yasm_linemap_traverse_filenames): New function to go through all
Peter Johnson [Sat, 11 Feb 2006 21:33:51 +0000 (21:33 -0000)]
* linemgr.h (yasm_linemap_traverse_filenames): New function to go through all
filenames used by linemgr.
* linemgr.c (yasm_linemap_traverse_filenames): Implement.

svn path=/trunk/yasm/; revision=1373

18 years ago* configure.ac: Add checks for unistd.h and getcwd(). These will be needed
Peter Johnson [Fri, 10 Feb 2006 05:34:31 +0000 (05:34 -0000)]
* configure.ac: Add checks for unistd.h and getcwd().  These will be needed
for DWARF2.

svn path=/trunk/yasm/; revision=1372

18 years agoFix #67 by autosizing push immediate with no specified size to either 8 bit
Peter Johnson [Fri, 10 Feb 2006 04:24:12 +0000 (04:24 -0000)]
Fix #67 by autosizing push immediate with no specified size to either 8 bit
or the current BITS-derived operation size.

* x86id.re (OPS_BITS): New match rule for size == BITS setting.
(push_insn): Use OPS_BITS for 16-bit/32-bit mode, and reuse GAS rule for
64-bit mode.
(yasm_x86__finalize_insn): Set size_lookup[7] to BITS setting.  Set opersize
based on this value if OPS_BITS is used.

* pushnosize.asm: New test for push imm, both sized and unsized, in all BITS
modes.

svn path=/trunk/yasm/; revision=1371

18 years ago* x86bc.c (x86_bc_insn_tobytes, x86_bc_jmp_tobytes): Enable signed warnings
Peter Johnson [Fri, 10 Feb 2006 04:15:56 +0000 (04:15 -0000)]
* x86bc.c (x86_bc_insn_tobytes, x86_bc_jmp_tobytes): Enable signed warnings
for signed immediates, jump values.

Note: [1369] actually matches this commit, not [1368].

svn path=/trunk/yasm/; revision=1370

18 years ago* push64.errwarn, addbyte.errwarn, arithsmall.errwarn: Update to match [1368].
Peter Johnson [Fri, 10 Feb 2006 04:13:15 +0000 (04:13 -0000)]
* push64.errwarn, addbyte.errwarn, arithsmall.errwarn: Update to match [1368].

svn path=/trunk/yasm/; revision=1369

18 years ago* intnum.c (yasm_intnum_get_sized): Honor negative warn setting (signed).
Peter Johnson [Fri, 10 Feb 2006 04:09:38 +0000 (04:09 -0000)]
* intnum.c (yasm_intnum_get_sized): Honor negative warn setting (signed).
* intnum.h (yasm_intnum_check_size): Remove reference to nonexistent param
"is_signed" (this was replaced a long time ago with the rangetype param).

svn path=/trunk/yasm/; revision=1368

18 years ago* x86id.re (str_insn): Fix #68. Based on the patch submitted but with some
Peter Johnson [Fri, 10 Feb 2006 02:43:15 +0000 (02:43 -0000)]
* x86id.re (str_insn): Fix #68.  Based on the patch submitted but with some
other cleanups as well.
* str.asm: New test for above.

Reported by: bird-yasm@anduin.net

svn path=/trunk/yasm/; revision=1367

18 years ago* intnum.h (yasm_get_sleb128, yasm_size_sleb128): New functions to handle
Peter Johnson [Thu, 9 Feb 2006 05:00:09 +0000 (05:00 -0000)]
* intnum.h (yasm_get_sleb128, yasm_size_sleb128): New functions to handle
signed LEB128-encoded numbers straight from long values (rather than going
through intnum).
(yasm_get_uleb128, yasm_size_uleb128): Likewise, for unsigned LEB128.
* intnum.c (get_leb128, size_leb128): Move most of functionality here from:
(yasm_intnum_get_leb128, yasm_intnum_size_leb128): Here (refactor).
(yasm_get_sleb128, yasm_size_sleb128, yasm_get_uleb128, yasm_size_uleb128):
Implement using refactored functionality.

svn path=/trunk/yasm/; revision=1366

18 years agoMatch yasm_symtab_traverse() implementation to doxygen documentation by
Peter Johnson [Sun, 5 Feb 2006 22:49:10 +0000 (22:49 -0000)]
Match yasm_symtab_traverse() implementation to doxygen documentation by
fixing underlying HAMT implementation to match.  Change is to reflect that
traversal stops when subfunction return is nonzero.

* hamt.h (HAMT_traverse): Update doxygen comment for stop on nonzero instead
of stop on zero.
* hamt.c (HAMT_traverse): Implement.
* symrec.c, xdf-objfmt.c, elf-objfmt.c, coff-objfmt.c: Update return values
for subfunctions.

svn path=/trunk/yasm/; revision=1365

18 years ago* bitvect.c (BitVector_from_Enum): Silence compiler warning.
Peter Johnson [Sun, 5 Feb 2006 18:53:11 +0000 (18:53 -0000)]
* bitvect.c (BitVector_from_Enum): Silence compiler warning.

svn path=/trunk/yasm/; revision=1364

18 years ago* expr.c (yasm_expr_print): Increase size of opstr so it's large enough to
Peter Johnson [Sun, 5 Feb 2006 18:20:11 +0000 (18:20 -0000)]
* expr.c (yasm_expr_print): Increase size of opstr so it's large enough to
handle the error case string.

svn path=/trunk/yasm/; revision=1363

18 years ago* bytecode.c (yasm_bc_tobytes): *really* fix handling of bytecodes larger than provid...
Peter Johnson [Sun, 5 Feb 2006 02:47:56 +0000 (02:47 -0000)]
* bytecode.c (yasm_bc_tobytes): *really* fix handling of bytecodes larger than provided buffer.
The only way to cause this to happen is with incbin, and while we do have a test intended for this,
it doesn't actually check this functionality due to a change made to unbreak distcheck; next up is
figuring out a good test that will work for different source/build directories.

svn path=/trunk/yasm/; revision=1362

18 years ago* objfmt.h (yasm_objfmt_output): Fix macro.
Peter Johnson [Sun, 5 Feb 2006 02:17:46 +0000 (02:17 -0000)]
* objfmt.h (yasm_objfmt_output): Fix macro.
* yasm.c (main): Fix call to yasm_objfmt_output.

svn path=/trunk/yasm/; revision=1361

18 years ago* re2c/main.c: Include string.h so strlen and memcpy are prototyped.
Peter Johnson [Sat, 4 Feb 2006 06:17:26 +0000 (06:17 -0000)]
* re2c/main.c: Include string.h so strlen and memcpy are prototyped.

svn path=/trunk/yasm/; revision=1360

18 years ago* elf-objfmt.c (elf_objfmt_section_switch): Remove unused variable.
Peter Johnson [Sat, 4 Feb 2006 04:38:09 +0000 (04:38 -0000)]
* elf-objfmt.c (elf_objfmt_section_switch): Remove unused variable.
* dwarf2-dbgfmt.c (dwarf2_dbgfmt_gen_line_op): Likewise.
* lc3bid.re (yasm_lc3b__parse_check_insn): Likewise.

* dbg-objfmt.c (dbg_objfmt_section_align): Remove; no longer used.

svn path=/trunk/yasm/; revision=1359

18 years agoUpdate FSF address in GPL and LGPL licenses.
Peter Johnson [Sat, 4 Feb 2006 04:33:27 +0000 (04:33 -0000)]
Update FSF address in GPL and LGPL licenses.

Noticed by: Rugxulo <rugxulo@gmail.com>

svn path=/trunk/yasm/; revision=1358

18 years ago* dwarf2-dbgfmt.c (generate_section): Split off large chunks into gen_line_op
Peter Johnson [Fri, 3 Feb 2006 06:38:30 +0000 (06:38 -0000)]
* dwarf2-dbgfmt.c (generate_section): Split off large chunks into gen_line_op
and finalize_locs functions, preparing for later asm-source dbg generation.

svn path=/trunk/yasm/; revision=1357

18 years agoImplement DWARF2 .file "foo.c" (sans file number) so that it actually sets
Peter Johnson [Wed, 1 Feb 2006 07:01:47 +0000 (07:01 -0000)]
Implement DWARF2 .file "foo.c" (sans file number) so that it actually sets
the source filename stored in the object file (as GAS does).  The internals
of this move the source and object filename data into the yasm_object
structure and simplify the dbgfmt and objfmt interfaces to remove this
information from function parameters.

* section.c (yasm_object_create): Add src_filename and obj_filename params.
(yasm_object_set_source_fn, yasm_object_get_source_fn)
(yasm_object_get_object_fn): New.
* section.h: Prototype.

* objfmt.h (yasm_objfmt_create): Remove in_filename param.
(yasm_objfmt_output): Remove obj_filename param.
* bin-objfmt.c, dbg-objfmt.c, coff-objfmt.c, xdf-objfmt.c: Update.
* elf-objfmt.c: Update.
* elf.c (elf_strtab_entry_set_str): New ELF support function.
* elf.h (elf_strtab_entry_set_str): Prototype.

* dbgfmt.h (yasm_dbgfmt_create): Remove in_filename and obj_filename params.
* null-dbgfmt.c, stabs-dbgfmt.c, dwarf2-dbgfmt.c: Update.

* dwarf2-dbgfmt.c (dwarf2_dbgfmt_directive): Implement .file "foo.c".

* yasm.c (main): Update to match yasm_object, objfmt and dbgfmt changes.

svn path=/trunk/yasm/; revision=1356

18 years ago* coretype.h (yasm__splitpath): Fix doxygen comment.
Peter Johnson [Tue, 31 Jan 2006 07:26:06 +0000 (07:26 -0000)]
* coretype.h (yasm__splitpath): Fix doxygen comment.

svn path=/trunk/yasm/; revision=1355

18 years ago* dwarf2-dbgfmt.c (dwarf2_dbgfmt_generate_section): Propogate last-label refs
Peter Johnson [Tue, 31 Jan 2006 03:12:59 +0000 (03:12 -0000)]
* dwarf2-dbgfmt.c (dwarf2_dbgfmt_generate_section): Propogate last-label refs
to following locations in case there is no intermediate label.
* dwarf64_2loc.asm: Test for this.

svn path=/trunk/yasm/; revision=1354

18 years ago* coretype.h (yasm__splitpath): Add some detection logic to try to detect
Peter Johnson [Mon, 30 Jan 2006 06:58:19 +0000 (06:58 -0000)]
* coretype.h (yasm__splitpath): Add some detection logic to try to detect
DOS-style path handling.

svn path=/trunk/yasm/; revision=1353

18 years ago* vc8/modules.vcproj: Unbreak.
Peter Johnson [Mon, 30 Jan 2006 00:02:07 +0000 (00:02 -0000)]
* vc8/modules.vcproj: Unbreak.

Report and patch by: Masaru Tsuchiyama <tsuchiyama@asahi-net.email.ne.jp>

svn path=/trunk/yasm/; revision=1352

18 years agoUpdate Mkfiles for DWARF2.
Peter Johnson [Sun, 29 Jan 2006 22:24:25 +0000 (22:24 -0000)]
Update Mkfiles for DWARF2.

* libyasm.vcproj: Add splitpath.c.
* modules.vcproj: Add dwarf2-dbgfmt.c.
* config.h: Define yasm__splitpath to yasm__splitpath_win.
* Makefile.flat, Makefile.dj: Add splitpath.c and dwarf2-dbgfmt.c.

svn path=/trunk/yasm/; revision=1351

18 years agoAdd DWARF2 debugging format. Note: at the moment, this ONLY implements
Peter Johnson [Sun, 29 Jan 2006 21:11:03 +0000 (21:11 -0000)]
Add DWARF2 debugging format.  Note: at the moment, this ONLY implements
passthrough information for line numbers through the use of the .loc and
.file directives in the GAS parser and does NOT generate line numbers for
raw assembly files.  This will be added next, after the other Mkfiles are
updated.

* dwarf2-dbgfmt.c: New.
* elf-objfmt.c (elf_objfmt_dbgfmt_keywords): Add to list of supported dbgfmts.
* coff-objfmt.c (elf_objfmt_dbgfmt_keywords): Likewise.
* elf-objfmt.c (elf_objfmt_create_dbg_secthead): Support all DWARF2 debug_*
sections.
* dwarf2/tests: Tests for passthrough cases for ELF32, ELF64, and Win64.

svn path=/trunk/yasm/; revision=1350

18 years ago* arch.h (yasm_arch_min_insn_len): Get the minimum instruction length in
Peter Johnson [Sun, 29 Jan 2006 21:06:31 +0000 (21:06 -0000)]
* arch.h (yasm_arch_min_insn_len): Get the minimum instruction length in
bytes.
(yasm_arch_get_address_size): Get the active address size in bits.
* lc3barch.c, x86arch.c: Implement.

These are needed for the DWARF2 dbgfmt, but may be useful for other things
in the future.

svn path=/trunk/yasm/; revision=1349

18 years ago* dbgfmt.h (yasm_dbgfmt_directive): Add section parameter to specify currently
Peter Johnson [Sun, 29 Jan 2006 21:04:00 +0000 (21:04 -0000)]
* dbgfmt.h (yasm_dbgfmt_directive): Add section parameter to specify currently
active section at the time of the directive.
* null-dbgfmt.c, stabs-dbgfmt.c: Implement.
* gas-bison.y: Pass.

svn path=/trunk/yasm/; revision=1348

18 years ago* splitpath_test.c: Add no-filename cases.
Peter Johnson [Sun, 29 Jan 2006 01:24:19 +0000 (01:24 -0000)]
* splitpath_test.c: Add no-filename cases.

svn path=/trunk/yasm/; revision=1347

18 years agoSet svn:keywords to include Id.
Peter Johnson [Sun, 29 Jan 2006 01:19:08 +0000 (01:19 -0000)]
Set svn:keywords to include Id.

svn path=/trunk/yasm/; revision=1346

18 years agoAdd functions to split a path into a directory and base filename.
Peter Johnson [Sun, 29 Jan 2006 01:17:49 +0000 (01:17 -0000)]
Add functions to split a path into a directory and base filename.
* splitpath.c (yasm__splitpath_unix, yasm__splitpath_win): New.
* coretype.h: Prototype above and alias yasm__splitpath.
* splitpath_test.c: New test for above.

svn path=/trunk/yasm/; revision=1345

18 years ago* symrec.h (yasm_symtab_get): Fix doxygen documentation.
Peter Johnson [Tue, 24 Jan 2006 07:10:04 +0000 (07:10 -0000)]
* symrec.h (yasm_symtab_get): Fix doxygen documentation.

svn path=/trunk/yasm/; revision=1344

18 years ago* gas-bison.y: Pass .loc and .file directives onto dbgfmt. Note: no dbgfmt
Peter Johnson [Mon, 23 Jan 2006 07:32:18 +0000 (07:32 -0000)]
* gas-bison.y: Pass .loc and .file directives onto dbgfmt.  Note: no dbgfmt
yet supports these (DWARF2 will).

svn path=/trunk/yasm/; revision=1343

18 years ago* parser.h (do_parse): Add dbgfmt parameter.
Peter Johnson [Mon, 23 Jan 2006 06:24:35 +0000 (06:24 -0000)]
* parser.h (do_parse): Add dbgfmt parameter.
* gas-parser.c, nasm-parser.c: Likewise.
* yasm.c (main): Pass current dbgfmt to do_parse.

svn path=/trunk/yasm/; revision=1342

18 years ago* linemgr.h (yasm_linemap_goto_next): Fix typo in text description.
Peter Johnson [Mon, 23 Jan 2006 01:29:44 +0000 (01:29 -0000)]
* linemgr.h (yasm_linemap_goto_next): Fix typo in text description.

svn path=/trunk/yasm/; revision=1341

18 years agoImplement GAS syntax ".local" directive. This is used by GCC to generate
Peter Johnson [Mon, 23 Jan 2006 00:16:38 +0000 (00:16 -0000)]
Implement GAS syntax ".local" directive.  This is used by GCC to generate
.local sym; .comm sym; rather than directly using .lcomm sym.  Handle this
usage as well.  While we're here, also implement alignment for .lcomm and
refactor .lcomm handling and alignment handling.

* gas-token.re: Recognize .local.
* gas-bison.y (DIR_LOCAL): Implement .local.
(DIR_COMM): Recognize .local ; .comm case and call define_lcomm().
(DIR_LCOMM): Move functionality into..
(define_lcomm): Here, and implement alignment with..
(gas_parser_align): That now takes raw exprs.  The valparam part of that is
now implemented in..
(gas_parser_dir_align): Formerly gas_parser_align.
(DIR_ALIGN): Use gas_parser_dir_align() instead.

* symrec.c (yasm_symtab_get): New function to just get a symbol based on name
without actually "referencing" it.
* symrec.h (yasm_symtab_get): Prototype.

* coretype.h (yasm_sym_vis): Add YASM_SYM_DLOCAL for flagging that a symbol
is explicitly flagged as a local symbol (rather than just default that way).

svn path=/trunk/yasm/; revision=1340

18 years ago* intnum.c (yasm_intnum_set_uint): New function to set intnum to any
Peter Johnson [Mon, 23 Jan 2006 00:07:00 +0000 (00:07 -0000)]
* intnum.c (yasm_intnum_set_uint): New function to set intnum to any
arbitrary integer.
(yasm_intnum_zero): Reimplement using yasm_intnum_set_uint.
* intnum.h (yasm_intnum_set_uint): Prototype.

svn path=/trunk/yasm/; revision=1339

18 years agox86id.re: Fix #66 (fstp generated invalid opcode). Cleaned up fldstpt_insn
Peter Johnson [Wed, 18 Jan 2006 02:20:06 +0000 (02:20 -0000)]
x86id.re: Fix #66 (fstp generated invalid opcode).  Cleaned up fldstpt_insn
a bit as well.  We were testing this but for some reason didn't check the
"golden" outputs for correctness.

svn path=/trunk/yasm/; revision=1338

18 years ago* yasm.c (opt_objfmt_handler): Lowercase the objfmt keyword. This forces
Peter Johnson [Wed, 18 Jan 2006 01:51:08 +0000 (01:51 -0000)]
* yasm.c (opt_objfmt_handler): Lowercase the objfmt keyword.  This forces
the __YASM_OBJFMT__ value to always be lowercase, e.g. for "-f Win32" on
the command line, __YASM_OBJFMT__ becomes "win32".

Requested by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1337

18 years ago* Makefile.am: Unbreak distcheck due to yasm32.rules/yasm64.rules ->
Peter Johnson [Wed, 18 Jan 2006 01:40:33 +0000 (01:40 -0000)]
* Makefile.am: Unbreak distcheck due to yasm32.rules/yasm64.rules ->
yasm.rules combination in Mkfiles/vc8.

svn path=/trunk/yasm/; revision=1336

18 years agoVC8 build files cleanup. Also combines yasm32.rules and yasm64.rules into single...
Peter Johnson [Tue, 17 Jan 2006 04:47:49 +0000 (04:47 -0000)]
VC8 build files cleanup.  Also combines yasm32.rules and yasm64.rules into single yasm.rules.
Works for native Win32 builds, Win32->x64 cross builds, and native x64 builds.

Submitted by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1334

18 years ago* standard.mac: Handle new x64 objfmt alias.
Peter Johnson [Tue, 17 Jan 2006 04:29:29 +0000 (04:29 -0000)]
* standard.mac: Handle new x64 objfmt alias.

Noticed by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1333

18 years ago* coff-objfmt.c: Add "x64" as an alias for "win64" (when selecting object
Peter Johnson [Sun, 15 Jan 2006 22:48:55 +0000 (22:48 -0000)]
* coff-objfmt.c: Add "x64" as an alias for "win64" (when selecting object
formats).  This makes integration with the VC8 build tools much nicer, as
VC8 uses "x64" as the PlatformName environment setting.

* win64/Makefile.inc, Mkfiles/Makefile.flat, Mkfiles/Makefile.dj: Update
build files to look for objfmt_x64 module.

Suggested by: Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=1331

18 years ago* elf-x86-x86.c (elf_x86_x86_write_reloc): Don't cast symbol index to
Peter Johnson [Fri, 13 Jan 2006 06:41:50 +0000 (06:41 -0000)]
* elf-x86-x86.c (elf_x86_x86_write_reloc): Don't cast symbol index to
unsigned char.  This was causing relocation corruption after 255 symbols,
in ELF32 only.
* elfmanysym.asm: Additional test that has exactly 257 symbols.

We actually should have caught this with the very large 32-bit elf-x86id.asm
test, but that object file (unlike the 64-bit GAS version of it) has only
been manually reviewed.  This bug was only in ELF32, and wasn't in ELF64.

Fixes bug #62 submitted by: Jens von der Heydt <mailme@vdh-webservice.de>

svn path=/trunk/yasm/; revision=1330

18 years ago* bin-objfmt.c: Remove unused variable bitcnt.
Peter Johnson [Wed, 11 Jan 2006 06:10:57 +0000 (06:10 -0000)]
* bin-objfmt.c: Remove unused variable bitcnt.
* coff-objfmt.c: Likewise.

svn path=/trunk/yasm/; revision=1329

18 years agoBuild cleanups (mostly for warnings) for VC8.
Peter Johnson [Wed, 11 Jan 2006 05:51:32 +0000 (05:51 -0000)]
Build cleanups (mostly for warnings) for VC8.

* Mkfiles/vc8/config.h: Define _CRT_SECURE_NO_DEPRECATE to avoid most warnings about *_s functions.
Also use _stricmp directly instead of stricmp to avoid warnings.
* libyasm/strcasecmp.c: Support _stricmp usage.
* util.h: Likewise.

* tools/re2c/actions.c: Include ctype.h to define toupper/tolower.

* Mkfiles/vc8/modules/modules.vcproj: Don't include nasm-macros.c directly; this file is included
into another file and has no public variables.

* Mkfiles/vc8/yasm.sln: Allow x64 cross-builds from Win32 by building genmacro, genmodule, and
re2c for Win32 target.

svn path=/trunk/yasm/; revision=1328

18 years agoFix VC8 build path problem.
Peter Johnson [Mon, 9 Jan 2006 07:33:34 +0000 (07:33 -0000)]
Fix VC8 build path problem.
Contributed by: Masaru Tsuchiyama <tsuchiyama@asahi-net.email.ne.jp>

svn path=/trunk/yasm/; revision=1327

18 years agoAdd VC8 build files.
Peter Johnson [Sun, 8 Jan 2006 22:56:06 +0000 (22:56 -0000)]
Add VC8 build files.
Contributed by: Brian Gladman <brg@gladman.plus.com>

Also added a couple VC7 build files that were in the tree but missing from
EXTRA_DIST (and thus not included in the distribution).

svn path=/trunk/yasm/; revision=1326

19 years agoRather than pulling the objfmt keyword back from the objfmt when setting
Peter Johnson [Fri, 16 Dec 2005 06:06:25 +0000 (06:06 -0000)]
Rather than pulling the objfmt keyword back from the objfmt when setting
__YASM_OBJFMT__, use whatever name was specified on the command line.  This
also matches the behavior of yasm preprocess-only mode (-e).  Both the
mismatch between preproc/non-preproc and the internal name change (e.g. from
elf to elf32) were quite confusing.

Reported by: Mike Frysinger <vapier@gentoo.org>

svn path=/trunk/yasm/; revision=1325

19 years agore2c.vcproj: Fix win32 build of re2c by including mbo_getopt.
Peter Johnson [Tue, 13 Dec 2005 07:10:57 +0000 (07:10 -0000)]
re2c.vcproj: Fix win32 build of re2c by including mbo_getopt.

svn path=/trunk/yasm/; revision=1324

19 years agoAvoid crash in section_switch for a number of object formats.
Peter Johnson [Sat, 3 Dec 2005 18:04:59 +0000 (18:04 -0000)]
Avoid crash in section_switch for a number of object formats.

Noticed by: Catalin Ionescu <catalin.ionescu@radioconsult.ro>

svn path=/trunk/yasm/; revision=1323

19 years ago* coff-objfmt.c (coff_objfmt_output_secthead): Use sprintf instead of
Peter Johnson [Wed, 30 Nov 2005 06:53:06 +0000 (06:53 -0000)]
* coff-objfmt.c (coff_objfmt_output_secthead): Use sprintf instead of
snprintf when outputting /nnn section names; snprintf doesn't port well
to mingw at least.  This also generates more correct output (fills with 0s).

svn path=/trunk/yasm/; revision=1322

19 years ago* coff-objfmt.c: Support section names >8 characters when outputting Win32
Peter Johnson [Wed, 23 Nov 2005 07:27:41 +0000 (07:27 -0000)]
* coff-objfmt.c: Support section names >8 characters when outputting Win32
or Win64 object files, which support a string table extensison of section
names.

svn path=/trunk/yasm/; revision=1321

19 years ago* coff-objfmt.c (coff_objfmt_section_switch): First cut at mimicing GAS coff
Peter Johnson [Wed, 16 Nov 2005 05:10:44 +0000 (05:10 -0000)]
* coff-objfmt.c (coff_objfmt_section_switch): First cut at mimicing GAS coff
flags.

svn path=/trunk/yasm/; revision=1320

19 years agoMove section alignment to libyasm, refactoring it from individual object
Peter Johnson [Sun, 13 Nov 2005 20:44:21 +0000 (20:44 -0000)]
Move section alignment to libyasm, refactoring it from individual object
formats.

* section.h (yasm_object_get_general): Add align parameter.
(yasm_section_set_align, yasm_section_get_align): New.
* section.c (yasm_section): Add align member and implementations.

* objfmt.h (yasm_objfmt_section_align): Remove.

* gas-bison.y (gas_parser_align): Change to use yasm_section_get/set_align().

* xdf, elf, bin, dbg, coff, stabs: Refactor as necessary.

svn path=/trunk/yasm/; revision=1319

19 years agoIn GAS mode, detect sections that are marked as contain code thanks to "x"
Peter Johnson [Fri, 11 Nov 2005 04:31:20 +0000 (04:31 -0000)]
In GAS mode, detect sections that are marked as contain code thanks to "x"
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

19 years agoFix GAS section alignment, at least for ELF output. In GAS mode, the
Peter Johnson [Wed, 9 Nov 2005 06:05:58 +0000 (06:05 -0000)]
Fix GAS section alignment, at least for ELF output.  In GAS mode, the
section alignment is set to the maximum alignment used anywhere in the
section.

svn path=/trunk/yasm/; revision=1317

19 years agoUnbreak distcheck.
Peter Johnson [Tue, 8 Nov 2005 03:44:38 +0000 (03:44 -0000)]
Unbreak distcheck.

svn path=/trunk/yasm/; revision=1316

19 years agoAdd ability for GAS input to set section alignment in the same way GAS does:
Peter Johnson [Mon, 7 Nov 2005 06:53:52 +0000 (06:53 -0000)]
Add ability for GAS input to set section alignment in the same way GAS does:
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

19 years agoChange some optimization settings so that imm8 optimizations actually get
Peter Johnson [Mon, 7 Nov 2005 05:12:22 +0000 (05:12 -0000)]
Change some optimization settings so that imm8 optimizations actually get
triggered for more cases and optimize from 64-bit down to 32-bit for 64-bit
mov instructions.  This change means that mov reg64, constant will be
auto-sized up to 64 bits, but mov reg64, expr/symbol will default to 32 bits.
You must use mov reg64, qword expr/symbol if you need 64 bits, or in GAS
mode use movabsq expr/symbol, reg64.

This makes the generated code smaller and default most usages into 32-bit
relocations appropriate for ELF64 and Win64.  Right now, 32-bit unsigned
relocs are generated instead of 32-bit signed; this will need to be fixed.

* x86arch.h (x86_insn.postop): Add X86_POSTOP_SIGNEXT_IMM32.
* x86bc.c (x86_bc_insn_resolve): Implement.
* x86id.re (OPAP_SImm32Avail): New flag.
(MOD_Op2AddSp): New modifier to encode spare directly into 2nd opcode byte.
(arith_insn): Use MOD_Op2AddSp and add forced-size override forms.
(mov_insn): Use OPAP_SImm32Avail and add forced-size override form.
(yasm_x86__finalize_insn): Implement new flag and modifier.

Fix up testcases for changes.

svn path=/trunk/yasm/; revision=1314

19 years agoFix common and 0-offset local definition of symbol. The symbol would end
Peter Johnson [Sun, 6 Nov 2005 20:27:49 +0000 (20:27 -0000)]
Fix common and 0-offset local definition of symbol.  The symbol would end
up with the alignment as the offset rather than 0.  The cause of this was
that elf_sym_set_nonzero was getting a 0 offset which it then did not set.

* elf.c (elf_symtab_set_nonzero): Make value a pointer so that 0 values
can actually get set if necessary.
* elf.h (elf_symtab_set_nonzero): Update prototype.
* elf-objfmt.c (elf_objfmt_symtab_append): Likewise, and ripple changes.

* elf_gas64_reloc.hex: Update (now is correct).

svn path=/trunk/yasm/; revision=1313

19 years agoAdd test output file missed in previous commit. Note this output currently
Peter Johnson [Sun, 6 Nov 2005 20:08:48 +0000 (20:08 -0000)]
Add test output file missed in previous commit.  Note this output currently
contains an error due to another bug (will be fixed shortly).

svn path=/trunk/yasm/; revision=1312

19 years agoFix ELF64 relocations for common, global, and common+global symbols to match
Peter Johnson [Sun, 6 Nov 2005 20:07:15 +0000 (20:07 -0000)]
Fix ELF64 relocations for common, global, and common+global symbols to match
GAS output.  The way we were generating relocations before would make
common+global symbol usage generate a relocation against the symbol but
figure in the symbol's value into the relocation addend.

* expr.h (yasm_symrec_relocate_action): New enum, so that:
(yasm_expr_extract_symrec): can conditionalize replacing the symbol with its
value based on whether the symbol is only local (e.g. not declared global,
etc).
* expr.c (yasm_expr_extract_symrec): Update implementation.

* xdf-objfmt.c, coff-objfmt.c: Update to use new enum constants.

* elf-objfmt.c (elf_objfmt_output_expr): Only relocate against section if
symbol is only local, and change call to yasm_expr_extract_symrec to only
add in symbol value if symbol is only local.

* stabs-elf.hex, elftest.hex: Update for changes.

* elf_gas64_reloc.asm: New test.

svn path=/trunk/yasm/; revision=1311

19 years ago* gas-bison.y: Fix a couple use-after-free's.
Peter Johnson [Sat, 5 Nov 2005 20:44:40 +0000 (20:44 -0000)]
* gas-bison.y: Fix a couple use-after-free's.

svn path=/trunk/yasm/; revision=1310

19 years agoHandle instruction and prefix identifiers properly when used in other
Peter Johnson [Thu, 3 Nov 2005 05:29:42 +0000 (05:29 -0000)]
Handle instruction and prefix identifiers properly when used in other
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

19 years ago* symrec.c (symrec_define): Don't error if a symbol is declared common and
Peter Johnson [Thu, 3 Nov 2005 04:38:21 +0000 (04:38 -0000)]
* symrec.c (symrec_define): Don't error if a symbol is declared common and
then defined, and warn instead of error if a symbol is declared global and
then defined.

* externdef.asm: Test for the warning.

svn path=/trunk/yasm/; revision=1308

19 years agoAdd warning class (YASM_WARN_UNINIT_CONTENTS) to turn off the
Peter Johnson [Thu, 3 Nov 2005 03:49:10 +0000 (03:49 -0000)]
Add warning class (YASM_WARN_UNINIT_CONTENTS) to turn off the
"uninitialized data in code/data section: zeroing" warning.  This can now
be turned off using -Wno-uninit-contents on the command line.

* errwarn.h (yasm_warn_class): Add warning class.
* errwarn.c (yasm_errwarn_initialize): Default it to enabled.

* yasm.c (opt_warning_handler): Add as option.

* xdf-objfmt.c, elf-objfmt.c, bin-objfmt.c, coff-objfmt.c: Change warning
class for this warning.

svn path=/trunk/yasm/; revision=1307

19 years agoAdd support for single-level GAS .rept directive. Nested .rept's are not
Peter Johnson [Wed, 2 Nov 2005 08:24:19 +0000 (08:24 -0000)]
Add support for single-level GAS .rept directive.  Nested .rept's are not
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

19 years ago* libyasm.h (yasm_linemap_set): Allow NULL filename to indicate unchanged.
Peter Johnson [Wed, 2 Nov 2005 08:14:01 +0000 (08:14 -0000)]
* libyasm.h (yasm_linemap_set): Allow NULL filename to indicate unchanged.
* libyasm.c (yasm_linemap_set): Implement.

svn path=/trunk/yasm/; revision=1305

19 years agoFix the use of ELF type/size directives with local variables.
Peter Johnson [Tue, 1 Nov 2005 08:26:19 +0000 (08:26 -0000)]
Fix the use of ELF type/size directives with local variables.

* elf.h (elf_symtab_entry): Add in_table flag.
(elf_sym_in_table): New.
* elf.c (elf_symtab_entry_create): Initialize in_table to 0.
(elf_symtab_append_entry, elf_symtab_insert_local_sym): Set flag to 1.

* elf.c (elf_symtab_insert_local_sym): Don't create the entry here, instead
take it as a parameter.

* elf-objfmt.c (elf_objfmt_symtab_append): Only add if not in table by
checking new in_table flag.
(elf_objfmt_append_local_sym): Likewise, and pull some of the logic from
the old elf_symtab_insert_local_sym function to do it.
(elf_objfmt_directive): Don't append to ELF symbol table here, as we don't
know yet if the variable is global or local.

svn path=/trunk/yasm/; revision=1304

19 years ago* assocdat.c (yasm__assoc_data_add): Add safety valve: don't delete existing
Peter Johnson [Tue, 1 Nov 2005 05:29:34 +0000 (05:29 -0000)]
* assocdat.c (yasm__assoc_data_add): Add safety valve: don't delete existing
data if we're getting passed in the same data pointer.

svn path=/trunk/yasm/; revision=1303

19 years ago* elf.c (elf_symtab_create): Default type to STT_NOTYPE.
Peter Johnson [Tue, 1 Nov 2005 04:48:15 +0000 (04:48 -0000)]
* elf.c (elf_symtab_create): Default type to STT_NOTYPE.
* elf-objfmt.c (elf_objfmt_append_local_sym, elf_objfmt_extern_declare)
(elf_objfmt_global_declare, elf_objfmt_common_declare)
(elf_objfmt_directive): Only override if actually required.

svn path=/trunk/yasm/; revision=1302

19 years agoAdd macros for ELF's type, size, and weak directives.
Peter Johnson [Tue, 1 Nov 2005 04:36:44 +0000 (04:36 -0000)]
Add macros for ELF's type, size, and weak directives.

svn path=/trunk/yasm/; revision=1301