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
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
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
"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
shortening to signed 8-bit immediate from a larger immediate size. This
yields much smaller code for many arithmetic instructions.
Noticed by: Brian Gladman <brg@gladman.plus.com>
svn path=/trunk/yasm/; revision=1227
object formats without creating duplicate lists of symbols. XDF and COFF
were updated; ELF needs to reorder the symbols on its own, so for now it's
not been updated to use the common implementation.
* hamt.c (HAMTEntry, HAMT, HAMT_destroy)
(HAMT_insert): Change SLIST to STAILQ.
* symrec.c (sym_type): Add SYM_SPECIAL.
(yasm_symtab_define_special): New.
(yasm_symrec_declare): New; includes all functionality from symtab_declare.
(yasm_symtab_declare): Call yasm_symrec_declare now.
(yasm_symrec_is_special): New.
* symrec.h: Add prototypes for above.
* xdf-objfmt.c: Use symrec_data instead of declaring xdf_symtab.
* xdflong.hex, xdfprotect.hex, xdfother.hex: Update due to symbol reordering.
* coff-objfmt.c: Use symrec_data instead of declaring coff_symtab.
* elftimes.hex, elfso.hex, elfabssect.hex: Update due to symbol reordering.
* elfglobext.hex, elf-x86id.hex, elftest.hex, elfso64.hex: Likewise.
* stabs-elf.hex: Likewise.
svn path=/trunk/yasm/; revision=1188
dynamically loaded modules into the now-static libyasm. I now anticipate
that there would be very few users of the dynamic loading features, and it
yielded a lot of instability and build headaches for very little benefit.
The new build should now be much more cross-platform and faster (there was
a lot of overhead in finding and loading modules).
* libtool.m4, ltdl.m4: Delete.
* m4/Makefile.am: Rename to m4/Makefile.inc and remove references to above.
Change to use subdirectory (flat) build rather than recursive build.
* Makefile.am: Include m4/Makefile.inc rather than having it in SUBDIRS.
* libltdl: Delete.
* frontends/yasm/yasm-module.c: Delete.
* basename.c, dirname.c: Delete (no longer needed by yasm-module.c).
* genmodule.c, module.in: Generator and template for new module.c included
in libyasm that replaces the old yasm-module.c (module.in is a modified
rename of yasm-module.c).
* module.h: Modified rename of old yasm-module.h.
* libyasm.h: Include libyasm/module.h.
* libyasm/Makefile.inc: Build generator and include module.c in libyasm.
* yasm.c: Use new libyasm module interface.
* (many) Makefile.inc: Remove libtool libraries, build all modules into
libyasm library.
* configure.ac: Remove libtool/libltdl references.
* Mkfiles/vc/yasm-module.c: Remove. Still need to fix some of the other
Mkfiles/ build files for these changes.
svn path=/trunk/yasm/; revision=1183
similar) to ELF. They are used identically to NASM's ELF shared object
support.
Due to limited WRT support throughout libyasm, this caused a lot of rippling
changes. A major cleanup needs to be performed later to clear some of this
hackiness up.
* elf-machine.h (func_accepts_size_t): Rename to func_accepts_reloc().
(func_map_reloc_info_to_type): Add parameter ssyms for array of special syms.
(elf_machine_ssym): New; for defining machine-specific special syms.
(elf_machine_handler): Change accepts_reloc_size to accepts_reloc. Add new
ssyms and num_ssyms members.
* elf-x86-x86.c (ssym_index): New; this allows nice indexing of ssym arrays.
(elf_x86_x86_accepts_reloc): Rename of elf_x86_x86_accepts_reloc_size. Add
support for various WRT ssyms.
(elf_x86_x86_map_reloc_info_to_type): Add support for various WRT ssyms.
(elf_x86_x86_ssyms): New array of supported special symbols.
(elf_machine_handler_x86_x86): Update for above changes/additions.
* elf-x86-amd64.c (ssym_index, elf_x86_amd64_accepts_reloc)
(elf_x86_amd64_map_reloc_info_to_type, elf_x86_amd64_ssyms)
(elf_machine_handler_x86_amd64): Likewise.
* elf.h (elf_reloc_entry): Add wrt member.
(elf_set_arch): Add symtab parameter.
(elf_is_wrt_sym_relative): New.
(elf_reloc_entry_create): Add wrt parameter.
* elf.c (elf_set_arch): Allocate special syms from machine level.
(elf_is_wrt_sym_relative): New; search special syms, and report whether a
WRT ssym should be symbol-relative or section-relative.
(elf_reloc_entry_create): Pass WRT and ssyms info down to machine level.
* elf-objfmt.c (yasm_objfmt_elf): Add dotdotsym (..sym) symrec member.
(elf_objfmt_create): Pass symtab to elf_set_arch(). Allocate ..sym symbol.
(elf_objfmt_output_reloc): Update for elf_reloc_entry_create() change.
(elf_objfmt_output_expr): Handle WRT ssym. Make relocation symbol-relative
rather than section-relative if either WRT ..sym or WRT ssym that machine
level desires to be symbol-relative.
* symrec.c (yasm_symrec_get_label): Check for NULL sym->value.precbc; this
is now possible due to the user-accessible special symbols that ELF et al
create, which all have NULL precbc's.
* expr.c (yasm_expr_extract_symrec): Recurse into IDENT's to make more exprs
acceptable.
* coretype.h (yasm_output_reloc_func): Remove rel parameter as it shouldn't
be needed and complexifies writing of the reloc functions.
* stabs-dbgfmt.c (stabs_bc_stab_tobytes): Update output_reloc() call.
* elf-objfmt.c (elf_objfmt_output_reloc): Update to match.
* arch.h (yasm_arch_module): Add intnum_fixup_rel() function, change
intnum_tobytes() to not take rel parameter. The rel functionality is being
separated because sometimes it's desirable not to put the data into the
written intnum (e.g. ELF RELA relocations).
(YASM_ARCH_VERSION): Bump due to above change.
(yasm_arch_intnum_fixup_rel): New wrapper.
(yasm_arch_intnum_tobytes): Update wrapper (removing rel).
* lc3bbc.c (yasm_lc3b__intnum_fixup_rel): New, with code from:
(yasm_lc3b__intnum_tobytes): Remove rel code.
* lc3barch.h (yasm_lc3b__intnum_fixup_rel): New.
(yasm_lc3b__intnum_tobytes): Update.
* lc3barch.c (yasm_lc3b_LTX_arch): Reference yasm_lc3b__intnum_fixup_rel().
* x86bc.c (yasm_x86__intnum_fixup_rel): New, with code from:
(yasm_x86__intnum_tobytes): Remove rel code.
* x86arch.h (yasm_x86__intnum_fixup_rel): New.
(yasm_x86__intnum_tobytes): Update.
* x86arch.c (yasm_x86_LTX_arch): Reference yasm_x86__intnum_fixup_rel().
* xdf-objfmt.c (xdf_objfmt_output_expr): Update to use intnum_fixup_rel() /
new intnum_tobytes().
* bin-objfmt.c (bin_objfmt_output_expr): Likewise.
* coff-objfmt.c (coff_objfmt_output_expr): Likewise.
* elf-objfmt.c (elf_objfmt_output_expr: Likewise.
* nasm-listfmt.c (nasm_listfmt_output_expr): Likewise.
* nasm-bison.y: Change precedence of WRT and : operators: instead of being
the strongest binders they are now the weakest. This is needed to correctly
parse and be able to split WRT expressions. WRT handling is still somewhat
of a hack throughout yasm; we'll fix this later.
* x86expr.c (x86_expr_checkea_distcheck_reg): Don't check for WRT here.
(x86_expr_checkea_getregusage): Add new wrt parameter. Use it to handle
"WRT rip" separately from other operators. Recurse if there's a WRT below
the WRT rip; this is to handle cases like ELF-AMD64's elfso64.asm.
(yasm_x86__expr_checkea): Split off top-level WRT's and feed through
separately to x86_expr_checkea_getregusage().
* x86bc.c (x86_bc_insn_tobytes): Ensure the SUB operation for PC-relative
displacements goes BELOW any WRT expression.
(x86_bc_jmp_tobytes): Likewise.
* elfso.asm, elfso.hex, elfso.errwarn: New 32-bit ELF shared object tests.
* modules/objfmts/elf/tests/Makefile.inc: Include in distribution.
* elfso64.asm, elfso64.hex, elfso64.errwarn: New 64-bit ELF shared object
tests. This is not a good example, as the assembled code doesn't work, but
it at least tests the special symbols.
* modules/objfmts/elf/tests/amd64/Makefile.inc: Include in distribution.
svn path=/trunk/yasm/; revision=1168
base structure for relocations and using it in all object formats.
* section.h (yasm_reloc): New base relocation type.
* section.c (yasm_section_add_reloc): New function to add a yasm_reloc to a
section.
(yasm_section_relocs_first, yasm_section_reloc_next): New functions to
access yasm_reloc list.
(yasm_reloc_get): New function to get base info from yasm_reloc.
* section.h: New prototypes for above section.c functions.
* section.c (yasm_section): Add relocs and destroy_reloc members.
(yasm_object_get_general): Initialize relocs and destroy_reloc.
(yasm_object_create_absolute): Likewise.
(yasm_section_destroy): Destroy any created relocs.
* xdf-objfmt.c (xdf_reloc): Base off of new yasm_reloc structure.
(xdf_objfmt_output_expr): Update after xdf_reloc changes.
(xdf_objfmt_output_section): Likewise.
(xdf_section_data_destroy): Likewise.
(xdf_section_data_print): Likewise.
* elf.h (elf_secthead): Remove unneeded list of relocs.
(elf_reloc_entry): Base off of new yasm_reloc structure.
* elf.c (elf_reloc_entry_destroy, elf_relocs_create)
(elf_reloc_destroy): Remove.
(elf_reloc_entry_create): Update after elf_reloc_entry changes.
(elf_secthead_append_reloc, elf_secthead_write_relocs_to_file): Take
additional pointer to yasm_section to access new relocations storage and
update for new elf_reloc_entry structure.
(elf_secthead_create): Update after elf_secthead changes.
(elf_secthead_destroy): Likewise.
(elf_secthead_print): Likewise.
* elf-objfmt.c (elf_objfmt_output_reloc, elf_objfmt_output_expr)
(elf_objfmt_output_section, elf_objfmt_output_secthead): Likewise.
* elf.h: Update prototypes for above elf.c changes.
* coff-objfmt.c (coff_reloc): Base off of new yasm_reloc structure.
(coff_objfmt_output_expr): Update after coff_reloc changes.
(coff_objfmt_output_section): Likewise.
(coff_section_data_destroy): Likewise.
(coff_section_data_print): Likewise.
* nasm-listfmt.c (sectreloc, bcreloc): New.
(nasm_listfmt_output_info): Add bcrelocs, next_reloc, next_reloc_addr.
(nasm_listfmt_output_expr): Record relocations in bcrelocs if next_reloc
and next_reloc_addr match the current expr parameters.
(nasm_listfmt_output): Initialize new members of nasm_listfmt_output_info,
and use bcrelocs data generated by nasm_listfmt_output_expr to add reloc
information to list output.
* x86bc.c (x86_bc_jmp_tobytes): Duplicate jmp_target before splitting
SEGOFF (:) pairs. This avoids a memory leak and doesn't destroy the
ability for the bytecode to be converted to bytes again (which is what
happens when listfmt is used).
* yasm.xml, yasm.1: Add documentation for new listfmt-related options
for yasm frontend: -L (--lformat) and -l (--list).
svn path=/trunk/yasm/; revision=1154
control whether the symbol is replaced with the symbol's value (old
behavior), or just replace it with 0 (new optional behavior). The old
behavior is enabled by setting relocate=1.
* expr.h (yasm_expr_extract_symrec): Likewise (and document new behavior).
* elf-objfmt.c (elf_objfmt_output_expr): Use new function (with relocate=1).
* coff-objfmt.c (coff_objfmt_output_expr): Likewise.
* expr.c (yasm_expr_extract_segment): Renamed to yasm_expr_extract_segoff, a
more approprate name given what operator it looks at.
* expr.h (yasm_expr_extract_segment): Likewise.
* x86bc.c (x86_bc_jmp_tobytes): Use new function name.
* expr.c (yasm_expr_extract_seg): New function to remove SEG unary operator.
* expr.h (yasm_expr_extract_seg): Likewise.
* expr.c (yasm_expr_extract_shr): New function to split SHR operator into
left and right halves.
* expr.h (yasm_expr_extract_shr): Likewise.
* xdf.h: New header file describing the newly added Extended Dynamic Object
Format (XDF). Note: GCC-only code.
* xdfdump.c: New utility that uses the format described in xdf.h to
completely dump an XDF file. Note: non-portable code (runs correctly on
little endian machines only).
Neither of these files are currently included in the distribution.
* xdf-objfmt.c: New YASM objfmt module to output XDF format object files.
* modules/objfmts/xdf/Makefile.inc: Add to build.
* modules/objfmts/Makefile.inc: Likewise.
The XDF object format is a blend between COFF and OMF. It is a very simple
object format intended for use by operating system loaders or similar types
of targets. It allows shifted relocations (useful for static interrupt or
page tables), both flat and segment-relative, and the use of the SEG, WRT,
and x86 JMP FAR notations.
Test cases will be committed soon.
svn path=/trunk/yasm/; revision=1149