Commit graph

713 commits

Author SHA1 Message Date
haruki3hhh
121ab150b3
Fix null pointer dereference in yasm_section_bcs_append (#263) 2024-06-24 16:08:27 -07:00
dataisland
9defefae9f
Fix null-pointer-dereference in yasm_expr_get_intnum (#244) 2023-09-21 22:21:20 -07:00
dataisland
84be2ee6c3
Fix use-after-free in yasm_intnum_destroy (#242) 2023-09-21 22:20:58 -07:00
dataisland
0dfac4d4da
Fix nullptr deref in yasm_expr__copy_except (#241) 2023-09-21 22:04:21 -07:00
Biswapriyo Nath
e69fba2db0
Fix missing yasm_xfree function declaration (#224)
This fixes the following compiler error in macOS in CI.

libyasm/tests/bitvect_test.c:112:5: error: implicit declaration of
function 'yasm_xfree' [-Werror,-Wimplicit-function-declaration]
2023-05-14 11:03:04 -07:00
mackyle
563a03be81
libyasm/section.c: support gas .private_extern directive (#138)
Support for "private_extern" was previously added for nasm mode via
a declaration like so:

    global foo:private_extern
    foo:
             ; codes

However, that same code in gas format looks like this:

    .private_extern foo
    foo:
             # codes

Add support for the gas version of "private_extern" syntax by
supporting a new gas `.private_extern` directive that actually
has exactly the same semantics as the nasm `global ...:private_extern`
directive.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2023-05-12 21:20:12 -07:00
Duncan Ogilvie
8b6c7b237c
Fix allocator mismatch (#107) 2023-05-12 21:19:37 -07:00
Matthieu Darbois
ce56a6f924
Fix test failure introduced in 51af4082cc (#145)
modules/arch/x86/tests/x86_test.sh failed after 51af4082cc commit.
This fixes this test.
2023-05-12 21:14:32 -07:00
Denis Denisov
bd283fe523
Revert optimizations added in #68 (#146) 2020-05-03 23:36:45 -07:00
Simon Brenner
85dad85f7c Only print 'warnings treated as errors' if there were warnings (#75)
This prints it as an additional error for the line that generated the
first warning.
2017-09-23 15:09:47 -07:00
Peter Johnson
51af4082cc Added -Wno-segreg-in-64bit.
This allows suppressing the annoying 'segment register ignored in 64-bit mode'
warning.
2015-11-06 20:15:04 -08:00
Peter Johnson
bf8411efa8 Merge pull request #68 from jix/master
Optimization and improved @jix
2015-01-01 21:51:00 -08:00
Peter Johnson
6818957d07 Make cmake module search case-insensitive.
This is needed to make things like "-f Win32" work, and matches the non-cmake
behavior.

[#276 state:resolved]
2014-10-05 09:48:51 -07:00
Peter Johnson
636dc92558 Allow building of static executables with cmake. 2014-08-10 23:18:46 -07:00
Peter Johnson
24e01c833f Add missing YASM_LIB_DECL declarations. 2014-08-10 12:33:52 -07:00
Peter Johnson
00c85278d1 Warnings cleanup. 2014-08-10 11:39:20 -07:00
Peter Johnson
964fd9a016 Optimize matching loops.
Reported by: Po-Chun Chang

[#264 state:resolved]
[#265 state:resolved]
[#266 state:resolved]
2013-08-07 22:15:20 -07:00
Jannis Harder
0341b79311 Better optimization of expr with segoffs
Lift all segoffs to the root of the tree. Combine identical segment
values while doing this.
2012-08-03 17:30:15 +02:00
Jannis Harder
8da658af79 Overrides and dummy value finalization for bin
- Added support for overriding certain functions
- Override value_finalize with dummy function for the bin objfmt
2012-07-31 13:01:22 +02:00
Jannis Harder
662fa69efc New wrt optimization and improved seg optimization
- Improve seg optimization to handle deep segoffs
- Add wrt optimization that handles deep segoffs
2012-07-31 13:01:22 +02:00
Pawel Worach
a2cbb10ee1 Fix clang warning:
libyasm/md5.c:166:31: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
        memset(ctx, 0, sizeof(ctx));    /* In case it's sensitive */
               ~~~            ^~~
2011-09-24 16:41:08 +03:00
Peter Johnson
94ab1135a3 Remove $Id$ and RCSID() usage.
These are useless now that we're using git.
2011-08-19 10:43:16 -07:00
Peter Johnson
a9b943e5db file.h: Separate conditional inclusion of direct.h.
This fixes builds on mingw64.

Reported by: Pierre Muller

[#235 state:resolved]
2011-08-19 10:14:14 -07:00
Peter Johnson
bd8401d538 expr_simplify_identity: Pass int_term via pointer.
This allows signaling to the caller (expr_level_op) that the int_term
was destroyed.  Without this, the new expr-simplify-identity testcase
has a use-after-free.

[#232 state:resolved]
2011-07-10 23:44:18 -07:00
Peter Johnson
de38127f1c Fix "times" relocation handling.
Previously a line such as "times 4 mov rax, [rel foobar]" would result
in incorrect relocations being generated.

Patch by: bird-yasm@anduin.net

[#211 state:resolved]
2011-06-25 23:32:22 -07:00
Peter Johnson
1143fb7520 Fix test failure due to build environment.
When YASM_TEST_SUITE environment is defined, force version to "yasm
HEAD" and all yasm__getcwd() calls to return "./".
2011-03-20 21:18:01 -07:00
Peter Johnson
7263e1d241 Implement yasm_value_finalize_expr() using yasm_value_finalize().
Previously this was implemented the opposite way, contrary to its
documentation.  This resulted in clearing any already set yasm_value
relative fields.

svn path=/trunk/yasm/; revision=2364
2010-08-18 06:23:06 +00:00
Peter Johnson
50017b49af Add prototype for yasm_dv_get_value().
svn path=/trunk/yasm/; revision=2363
2010-08-18 06:21:34 +00:00
Peter Johnson
72df1b52a2 Add yasm_dv_get_value() to get yasm_value from yasm_dataval.
svn path=/trunk/yasm/; revision=2362
2010-08-18 06:21:08 +00:00
Peter Johnson
323153d55a Instead of initializing unknown sections en-masse during objfmt_output(),
add new objfmt interface function init_new_section() to initialize as we
go.

This fixes several issues, primarily with debug formats that create sections.

Reported by: Brian Gladman

svn path=/trunk/yasm/; revision=2310
2010-03-28 19:28:54 +00:00
Peter Johnson
c699637602 vsyasm: create intermediate output directories if necessary.
This feature is apparently assumed by MSBUILD.

Contributed (with minor modifications) by: Brian Gladman

svn path=/trunk/yasm/; revision=2287
2010-02-13 08:42:27 +00:00
Peter Johnson
e8ff41cac1 Fix two more instances of queue.h HEAD macros for portability.
svn path=/trunk/yasm/; revision=2262
2010-01-03 02:46:11 +00:00
Peter Johnson
b3d84a8148 Implement some linemap changes required for the GAS preprocessor.
Contributed by: Alexei Svitkine <alexei.svitkine@gmail.com>

- yasm_linemap_set() now takes virtual_line as a parameter, instead of
always using linemap->current. If 0 is passed for the virtual_line,
then linemap->current is used, as before.

This is because linemap->current was only incremented by the parser
(and never decremented), so the preprocessor was not able to set
mappings during the preprocessing phase (whereas with these changes,
it now does).

Additionally, setting a mapping for a line number will now delete any
existing mappings for line numbers equal or greater to that line
number. This allows the code to correctly handle the case when the
preprocessor first sets mappings from pre-pp lines to post-pp lines,
and later those mappings getting superseded by .line directives in the
original source.

This change also required making a change to yasm_linemap_lookup() to
set *file_line to 0 when line is 0 (i.e. preventing line 0 - which
means "don't display line number in output" - from getting mapped).

svn path=/trunk/yasm/; revision=2259
2010-01-03 01:58:23 +00:00
Peter Johnson
5501768adb Use queue.h HEAD macros more portably (also avoiding compiler warning).
svn path=/trunk/yasm/; revision=2258
2010-01-03 01:04:18 +00:00
Peter Johnson
b70e2373f7 yasm_intnum_create_sized(): Fix off-by-one error in sign extension check.
svn path=/trunk/yasm/; revision=2253
2010-01-01 20:47:58 +00:00
Peter Johnson
e15ad1b94b Fix #188: Times forward references would result in bad code generation.
svn path=/trunk/yasm/; revision=2233
2009-10-31 21:45:55 +00:00
Peter Johnson
7a0082c94d Fix #186: Avoid memory runaway in optimizer TIMES circular reference checking.
Check for duplicates in backtrace used when checking for circular references.
This uses a simple N^2 algorithm (as the number of items in the backtrace is
usually small) but avoids memory runaway due to duplicate item storage.

svn path=/trunk/yasm/; revision=2229
2009-08-06 07:13:11 +00:00
Peter Johnson
dd7c64f68a Fix #178: Don't "distribute" shift right op.
This breaks horribly for things like (sym+511)>>9 in -f bin, as the result is
zero instead of something more useful.

Also don't check RHS for symbols; these will fall out later in the assembly
process if they cannot be simplified.

svn path=/trunk/yasm/; revision=2220
2009-07-24 19:01:35 +00:00
Peter Johnson
a498736454 Fix #173: Debug full paths were being generated incorrectly.
This was because the path returned by yasm__getcwd() did not have a trailing
slash and thus yasm__combpath() stripped off the last path component.

svn path=/trunk/yasm/; revision=2202
2009-06-03 05:49:18 +00:00
Peter Johnson
b7a38ed4fd Allow @ signs in identifiers in win32/win64 only.
In ELF, @ is used to indicate special relocations.

Fixes #164.

Reported by: Gregory McGarry on yasm-devel@
Testcase by: Gregory McGarry

We don't allow identifiers to start with @; doing so conflicts with use of
e.g. "@function" in some directives.  Need to look into what GAS does.

svn path=/trunk/yasm/; revision=2166
2009-01-02 08:33:21 +00:00
Peter Johnson
7b901e3596 Fix #157: Use UNIX (not Windows) path functions on cygwin platform.
svn path=/trunk/yasm/; revision=2157
2008-10-19 07:29:15 +00:00
Peter Johnson
536542a69e Fix a number of warnings.
svn path=/trunk/yasm/; revision=2133
2008-10-07 05:59:29 +00:00
Peter Johnson
1e77ce6c40 Add core TASM syntax support.
Contributed by: Samuel Thibault <samuel.thibault@ens-lyon.org>

It is built on top of the NASM parser and preproc, with the following
notable extensions for TASM syntax:
 - case insensitive symbols and filenames,
 - support for segment and size of labels, which permits to avoid giving
   them on each memory dereference,
 - support for data reservation (i.e. e.g. "var dd ?"),
 - support for multiples (i.e. e.g. "var dd 1 dup 10"),
 - little endian string integer constants,
 - additional expression operators: shl, shr, and, or, low, high,
 - additional offset keyword,
 - additional fword and df,
 - support for doubled quotes within quotes,
 - support for array-like and structure-like notations: t[eax] and
   [var].field,
 - support for tasm directives: macro, rept, irp, locals, proc, struc,
   segment, assume.

Notes:

 - Almost all extensions are only effective when tasm_compatible_mode is
   set, so we should have very reduced possible breakage.

 - Because the "and" keyword can be an expression operator and an
   instruction name, the data pseudo-instructions explicitly switch the
   lexer state to INSTRUCTION state to fix the ambiguity.

 - In gen_x86_insn.py, several instructions (namely lds and lea) now take
   relaxed memory sizes.  The reason is that in the case of tasm, the size
   of the actual pointed data is passed up to there, and thus any type of
   data should be accepted.

With all of this, loadlin can be compiled by yasm with quite reduced
modifications.

A new TASM-like frontend is also included.

svn path=/trunk/yasm/; revision=2130
2008-10-07 05:38:11 +00:00
Peter Johnson
457170f54e Fix expr simplification bug.
If an expression of the form INT+(a+b)+INT was simplified, constant folding
would combine the ints, but then the level stage (to make INT+a+b) would
start reading from the second (deleted due to folding) INT rather than the
new end of the expression.

Reported by: Samuel Thibault (on yasm-devel@)

svn path=/trunk/yasm/; revision=2123
2008-09-30 03:56:37 +00:00
Peter Johnson
33aa2d621b Fix bug in expr_level_op(). Discovered when adding on-the-fly expr leveling.
svn path=/trunk/yasm/; revision=2117
2008-07-18 05:52:01 +00:00
Peter Johnson
c6a2b083c1 Actually implement yasm__abspath() according to its documentation.
Formerly, it would not correctly handle absolute paths.  Now it uses
yasm__combpath() to do absolute-path aware path combination.
As a benefit, it no longer needs to be OS-specific.

Reported by: Shmuel Baron <shmulik@gmail.com>

svn path=/trunk/yasm/; revision=2116
2008-07-15 05:49:29 +00:00
Peter Johnson
901b28cab4 yasm_symrec_get_global_name(): Document object parameter.
svn path=/trunk/yasm/; revision=2112
2008-07-06 22:30:07 +00:00
Peter Johnson
a78a908bab Generated files listed in SOURCES (rather than included by other files)
should not be listed in BUILT_SOURCES but rather have nodist_ prepended.
They still need to be separately listed as CLEANFILES as they're built
at make time.

Reported by: David Harvey <dmharvey@math.harvard.edu>

svn path=/trunk/yasm/; revision=2111
2008-07-06 22:26:49 +00:00
Peter Johnson
53b2d01a77 Fix #132: Add --prefix and --suffix (aka --postfix) options.
These allow arbitrary prefixes and/or suffixes to be added to
externally-visible (GLOBAL, EXTERN, or COMMON) symbol names.

svn path=/trunk/yasm/; revision=2109
2008-06-08 09:06:05 +00:00
Peter Johnson
0a3f7ea1b9 (cmake build) Install DLL files to correct locations on Windows.
svn path=/trunk/yasm/; revision=2102
2008-05-24 18:30:29 +00:00