Commit Graph

9 Commits

Author SHA1 Message Date
Cyrill Gorcunov
744100dc14 Merge branch 'nasm-2.14.xx'
* nasm-2.14.xx:
  Fix undefined behavior when shifting left by 32 bits
  BR 3392529: if the default output name is the same as input -> nasm.out
2018-11-23 23:52:11 +03:00
Michael Bradshaw
fd14310469 Fix undefined behavior when shifting left by 32 bits
See https://bugzilla.nasm.us/show_bug.cgi?id=3392368

Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-11-23 23:51:16 +03:00
Cyrill Gorcunov
f7b44f6092 Merge branch 'nasm-2.14.xx'
* nasm-2.14.xx: (83 commits)
  NASM 2.14rc16
  doc: Update changes
  preproc: expand_smacro -- Fix nil dereference on error path
  eval: Eliminate division by zero
  doc: Update changes
  opflags: Convert is_class and is_reg_class to helpers
  preproc: Fix out of range access in expand mmacro
  doc: Update changes
  parser: Fix sigsegv on certain equ instruction parsing
  labels: Make sure nil label is never passed
  labels: Don't nil dereference if no label provided
  macho: Add warning message in macho_output()
  macho/reloc: Fix addr size sensitive conditions
  macho/reloc: Fix macho_output() to get the offset adjustments by add_reloc()
  macho/reloc: Fixed offset adjustment in add_reloc()
  macho/reloc: Allow absolute relocation when forcing a symbol reference
  macho/reloc: Adjust SUB relocation information
  macho/reloc: Fixed in handling GOT/GOTLOAD/TLV relocations
  macho/reloc: Simplified relocation for REL/BRANCH
  macho/sym: Record initial symbol number always
  ...

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-10-15 22:58:13 +03:00
H. Peter Anvin
af59af466a float: fix bogus pass flags for errors and warnings
Formatting errors -- syntax errors -- are errors, no matter which pass
they end up in.  ERR_PASS1 is just plain crazy: if we end up with a
formatting error on the code-generation pass, we are in a world of
hurt.

Defer warnings to the code-generation pass; that's the pass which
matters value-wise, and that way we get the warnings in the list file,
too.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-07-06 03:11:52 -07:00
Adam Majer
c7c28357c8 asm/float.c: fix buffer underflow in float parsing
When we suffer an underflow that cross limb boundaries, it is possible
to end up with a stack underflow.  Put in an explicit check for this
case (the mantissa will be zero in this case.)

   https://bugzilla.nasm.us/show_bug.cgi?id=3392445

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
diff --git a/asm/float.c b/asm/float.c
index dcf69fea..2965d3db 100644
--- a/asm/float.c
+++ b/asm/float.c
@@ -608,6 +608,8 @@ static void ieee_shr(fp_limb *mant, int i)
         if (offs)
             for (j = MANT_LIMBS-1; j >= offs; j--)
                 mant[j] = mant[j-offs];
+    } else if (MANT_LIMBS-1-offs < 0) {
+        j = MANT_LIMBS-1;
     } else {
         n = mant[MANT_LIMBS-1-offs] >> sr;
         for (j = MANT_LIMBS-1; j > offs; j--) {
2018-07-06 03:08:15 -07:00
H. Peter Anvin
c51369067c errors: simplify nasm_fatal() and nasm_panic()
Nearly all instances of nasm_fatal() and nasm_panic() take a flags
argument of zero. Simplify the code by making nasm_fatal and
nasm_panic default to no flags, and add an alternate version if flags
really are desired. This also means that every call site doesn't have
to initialize a zero argument.

Furthermore, ERR_NOFILE is now often not necessary, as the error code
will no longer cause a null reference if there is no current
file. Therefore, we can remove many instances of ERR_NOFILE which only
deprives the user of information.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 18:20:17 -07:00
H. Peter Anvin
3646e7dde0 BR 3392399: float: get rid of bogus exponent calculation
It turns out that the calculation of "twopwr" in ieee_flconvert_bin()
was more complex than necessary, and wrong in the case of a pure
fraction.

Reported-by: Roel <roelsuidgeest@zonnet.nl>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-05 21:47:20 -07:00
H. Peter Anvin
b20bc733c9 asm/*: Move directive processing to its own file, refactor error handling
Move directive processing to its own file, and move nasmlib/error.c to
asm/error.c (it was not used by the disassembler); remove some extern
declarations from .c files, and do some general code cleanups.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:31:04 -08:00
H. Peter Anvin
e1f985c167 Reorganize the source code into subdirectories
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-25 12:06:29 -07:00