mirror of https://github.com/yasm/yasm.git
Tag:
Branch:
Tree:
b1d27878fd
0.2
0.3
0.4
0.5
0.5.0
0.5.0rc2
0.6
0.6.0
0.6.1
0.6.2
0.7
0.7.0
0.7.1
0.7.2
0.8
0.8.0
1.0
1.0.0
1.0.1
1.1
1.1.0
master
multiarch
v0.1.0
v0.2.0
v0.2.1
v0.2.2
v0.3.0
v0.4.0
v0.5.0
v0.5.0rc1
v0.5.0rc2
v0.6.0
v0.6.1
v0.6.2
v0.7.0
v0.7.1
v0.7.2
v0.8.0
v1.0.0
v1.0.1
v1.1.0
v1.2.0
v1.3.0
${ noResults }
12 Commits (b1d27878fdbff4e7e2a7fa6ebf0c0726bf12cf16)
Author | SHA1 | Message | Date |
---|---|---|---|
Peter Johnson | 6ab452816c |
Fix #85: Multiple may be 0. In this case, force size to zero instead of
dividing (and thus crashing). svn path=/trunk/yasm/; revision=1658 |
18 years ago |
Peter Johnson | a7b6526ea4 |
Get rid of calc_bc_dist_func, the only times this was used was when
yasm_common_calc_bc_dist was used. Rename yasm_common_calc_bc_dist to yasm_calc_bc_dist, call it directly from the expr functions, and change higher-level callers to boolean flags of whether to calculate bc distance or not. svn path=/branches/new-optimizer/; revision=1550 |
19 years ago |
Peter Johnson | fe09480565 |
Fix major bug related to multiple handling. Unfortunately this slows down
bytecode multiple output significantly, but this way handles generating relocations correctly (otherwise extern foo; times 5 dd foo doesn't work!). * bytecode.h (yasm_bc_tobytes): Remove multiple output parameter. (yasm_bc_get_multiple): New. * bytecode.c (yasm_bc_tobytes): Update to iterate through multiple here. (yasm_bc_get_multiple): New. * xdf-objfmt.c, elf-objfmt.c, bin-objfmt.c, coff-objfmt.c: Don't iterate through multiple here. * nasm-listfmt.c: Use yasm_bc_get_multiple() to get multiple instead of yasm_bc_tobytes(). * bytecode.pxi: Update. * tests/win32-relocovfl.asm: Tests both this and [1534] but generates too huge of a file (3MB) to be put into the automated tests. svn path=/trunk/yasm/; revision=1536 |
19 years ago |
Peter Johnson | 83c0ecaaec |
* coretype.h (yasm_value): Add size field (specified in bits).
(yasm_value_output_func): Remove valsize and shift parameters. * bytecode.h (yasm_effaddr): Remove disp_len, replacing with need_nonzero_len. (yasm_immval): Remove len. * value.h (yasm_value_initialize): Add size parameter. (yasm_value_finalize_expr): Likewise. (yasm_value_output_basic): Remove valsize and shift parameters. Update all implementations and users for the above. * intnum.c (yasm_intnum_calc): Fix bug in shift right (was doing a logical instead of arithmetic shift). * lc3b-basic.asm, lc3b-basic.errwarn, lc3b-basic.hex: Update based on fixed warnings. svn path=/trunk/yasm/; revision=1534 |
19 years ago |
Peter Johnson | 4c33af41ec |
Revamp error/warning handling, using a model similar to Python's internal
exception handling. There are now two layers an error or warning goes through before it hits the user: first an error is logged via yasm_error_set() (or yasm_warn_set() for a warning). Only one error may be set, whereas multiple warnings can be set (yasm_warn_set maintains a linked list). Then, calling yasm_errwarn_propagate() propagates any error and/or warning(s) to an errwarns structure and associates the errors/warnings with a line number at that time; this call also clears the pending errors/warnings and allows new ones to be set. The propagate function can safely be called when there are no pending error/warnings. In addition, there are some helper errwarn functions that allow clearing of an error/warning without propagating, getting it separately, etc. Still yet to be done: changing most/all uses of yasm_internal_error() into yasm_error_set(YASM_ERROR_ASSERTION). The main advantage this change has is making libyasm functions feel much more library like, and separating the user code line numbers from the inner function error handling (e.g. intnum create functions only needed the line number to trigger errors; this is no longer required). The set/propagate/etc functions use global data structures to avoid passing around a pointer to every function. This would need to be made thread-local data in a threaded app. Errwarns containers (that keep associated line numbers) are no longer global, so multiple source streams can be processed separately with no conflict (at least if there's only a single thread of execution). svn path=/trunk/yasm/; revision=1521 |
19 years ago |
Peter Johnson | 9fa87cdae1 |
Massive cleanup of relocation and WRT handling. Closes #49 and lays the
groundwork for further features and possible cleanups. Note: this commit changes the way in which relocations in the COFF/Win32/Win64 target can be forced to reference a different symbol than is being pointed to; instead of the ambiguous "trap+(trap.end-trap)" to get the reloc to point at trap.end but reference the trap symbol, after this commit "trap.end wrt trap" is the way to say this. This also reads a lot more clearly and is not ambiguous. This should really only affect people who write .pdata sections for Win64. See the objfmts/win64/tests/win64-dataref.asm testcase for an example of usage. This cleanup adds a new data structure, yasm_value, which is used for all expressions that can be potentially relocatable. This data structure splits the absolute portion of the expression away from the relative portion and any modifications to the relative portion (SEG, WRT, PC-relative, etc). A large amount of code in the new value module breaks a general expression into its absolute and relative parts (yasm_value_finalize_expr) and provides a common set of code for writing out non-relocated values (yasm_value_output_basic). All bytecode handling in both libyasm and the architecture modules was rewritten to use yasm_values when appropriate (e.g. data values, immediates, and effective addresses). The yasm_output_expr_func is now yasm_output_value_func and all users and implementors (mainly in object formats) have been updated to handle yasm_values. Simultaneously with this change, yasm_effaddr and yasm_immval full structure definitions have been moved from bc-int.h to bytecode.h. The data hiding provided by bc-int.h was relatively minimal and probably overkill. Also, great simplifications have been made to x86 effective address expression handling. svn path=/trunk/yasm/; revision=1419 |
19 years ago |
Peter Johnson | c75a0a41bd |
* nasm-listfmt.c (nasm_listfmt_output_expr): Fix garbage due to non-simple
expressions by outputting a 0 if the expr does not have an intnum equivalent. This is not a fix: the real fix will need to be changing how listfmts get the final data bytes for a bytecode. This "fix" only replaces the garbage with 0's, not the correct value (e.g. for relative jumps). Found by: Albrecht Kleine <kleine@ak.sax.de> svn path=/trunk/yasm/; revision=1196 |
20 years ago |
Peter Johnson | e2fa2c1c11 |
Since modules are now built into libyasm, it's no longer necessary to
version them. * parser.h, dbgfmt.h, objfmt.h, listfmt.h, optimizer.h, preproc.h, arch.h: Remove YASM_xxx_VERSION and version module structure member. * (many) .c: Don't initialize version module structure member. svn path=/trunk/yasm/; revision=1184 |
20 years ago |
Peter Johnson | 882738b234 |
Greatly simplify build system by removing libtool and integrating formerly
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 |
20 years ago |
Peter Johnson | 23e53d41ce |
Fix #44 by adding support for WRT special symbols (e.g. [sym WRT ..plt] and
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 |
20 years ago |
Peter Johnson | cf8c4b16d5 |
Add relocation information to nasm list format by establishing a common
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 |
20 years ago |
Peter Johnson | 2d0119c5b7 |
First part of list file support. This should accurately output all file
bytes and offsets, but relocations are not yet indicated. Also, this outputs post-preprocessed source, so no comments, etc, are visible in the list file. * listfmt.h: New header file describing listfmt module interface. * coretype.h: Declare new yasm_listfmt typedef. * libyasm.h: Include listfmt.h. * libyasm/Makefile.inc (modinclude_HEADERS): Add listfmt.h. * yasm-module.h (module_type): Add MODULE_LISTFMT for listfmts. (load_listfmt_module, list_listfmts): New macros for listfmts. * yasm-module.c (module_type_str): Add listfmt string for MODULE_LISTFMT. (list_module_load): Add support for MODULE_LISTFMT. * bytecode.h (yasm_bc_tobytes): Comment clarification on effect of calling yasm_bc_tobytes twice on the same bytecode. * linemgr.h: Replace support for associated data with support for bytecode and source line information. (yasm_linemap_get_data): Remove. (yasm_linemap_get_source): Add. (yasm_linemap_add_data): Remove. (yasm_linemap_add_source): Add. * linemgr.c (yasm_linemap, yasm_linemap_create, yasm_linemap_destroy) (yasm_linemap_add_data, yasm_linemap_add_source, yasm_linemap_get_data) (yasm_linemap_get_source): Likewise. * nasm-token.re (fill): Save previous 2 lines instead of previous 1 line. (destroy_line, print_line, line_assoc_data): Remove. (save_line): Save line in structure instead of calling yasm_linemap_add_data. * nasm-bison.y (input rule): Call yasm_linemap_add_source here. * nasm-parser.h (yasm_parser_nasm): Add second line of storage and save_last variable to toggle between the two lines. * nasm-parser.c (nasm_parser_do_parse): Initialize save_last. * modules/Makefile.inc: Include new modules/listfmts/Makefile.inc. * modules/listfmts/Makefile.inc: New; includes modules/listfmts/nasm/Makefile.inc. * modules/listfmts/nasm/Makefile.inc: New build file for NASM-like listfmt. * nasm-listfmt.c: New NASM-like listfmt. * yasm.c: Enable use of listfmts, and default to NASM listfmt. (list_filename, cur_listfmt, cur_listfmt_module): New listfmt variables. (opt_listfmt_handler, opt_listfile_handler): New listfmt functions. (options): Add --lformat (-L) and --list (-l) options. (main): Load "nasm" listfmt as default if none selected. Enable saving of input lines if list output file enabled. Open and write to the list file. (open_obj): Rename to open_file and make more generic. (cleanup): Destroy listfmt and list filename if created. svn path=/trunk/yasm/; revision=1152 |
20 years ago |