Commit Graph

2926 Commits

Author SHA1 Message Date
Mark Scott
be8a5c8f2d out: elf,stabs -- Fix @n_value attribute for HdrSym entry
Each stabs entry is 12 bytes in size, for some reason we've
been pasing wrong attribute here in @n_value.

Signed-off-by: Mark Scott <nasm@mscott.cx>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-11-03 01:14:14 +03:00
Cyrill Gorcunov
6377180e08 nasmlib: Plcate undefined behaviour in signed_bits
http://bugzilla.nasm.us/show_bug.cgi?id=3392320

Reported-by: Dingbao Xie <xiedingbao@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-10-11 18:06:30 +03:00
Cyrill Gorcunov
b0b969eec4 disasm: Fix segment prefix name
http://bugzilla.nasm.us/show_bug.cgi?id=3392322

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-09-13 17:16:06 +03:00
Cyrill Gorcunov
8ab77b59e2 insns.dat: Add SMSW for 64 bit mode
http://bugzilla.nasm.us/show_bug.cgi?id=3392323

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-09-13 16:30:21 +03:00
Cyrill Gorcunov
94b4a2c819 output: aout -- Use nasm_x_space helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-26 16:42:27 +03:00
Cyrill Gorcunov
373583c6c8 insns.dat: Add PKU instructions
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-26 15:32:59 +03:00
Cyrill Gorcunov
8b4ef2d1d6 doc: Update changes list
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-26 14:42:30 +03:00
Cyrill Gorcunov
abe67eea15 NASM 2.11.09rc1
- Fix symbol alignment for Elf64
 - Fix symbol lookup for Macho64
 - Fix relocation records for Macho64
 - Fix potential stack overwrite in Macho32

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.org>
2015-07-25 00:39:42 +03:00
Martin Storsjö
561242bd43 out: maco64 -- Properly update the full 64 bit value when adding relocations
Previously only the first byte was updated (since @mydata
is a an uint8_t[]).

Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-24 00:45:59 +03:00
Cyrill Gorcunov
6f05b8008c output: outmacho32 -- Fix stack overwrite
The size of address migh be up to 8 bytes here
so allocate enough stack space.

http://bugzilla.nasm.us/show_bug.cgi?id=3392317

Reported-by: Kyle Brodie <kylecbrodie@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-21 22:51:34 +03:00
Cyrill Gorcunov
bd628dedea output: outmach64 -- Use back WRITELONG for OUT_REL4ADR
Because of 74a08cc3f we no longer need to write all
8 bytes here, revert it back as it were before
5b730a197

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-19 14:24:32 +03:00
Cyrill Gorcunov
2e6297ff1b out: Zeroify temp buffer before use
This is a a buffer on stack big enough to hold
bigger object we might need (address, number and
etc) but it's defined as an array of bytes and
we treat it as different types depending on context,
which may lead to situation where data from stack
been treated as meaningful.

In particular in commit 5b730a197 we've fixed such
problem simply using a "big" write to zeroify stack
data before use.

Lets simply zeroify this buffer explicitly to escape
such problems in future.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-07-19 14:24:26 +03:00
Jim Kukunas
ce28db6b68 macros.pl: expand file wildcards in arguments
Whereas Unix shells automatically globs wildcard arguments, Windows leaves it
up to application. This commit fixes the build for perl implementations that
don't handle wildcards.

Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
2015-07-01 11:35:39 -07:00
Delan Azabani
5b730a197a out: maco64 -- Fix erroneously small write for OUT_REL4ADR
Ensure that the int64_t offset value, which ultimately comes from an
int64_t value in gencode() (assemble.c:1906), is completely written to
the temporary buffer, instead of merely its least significant 32 bits.

Prior to this change, WRITELONG was used instead of WRITEDLONG, which
resulted in add_reloc being passed an int64_t "reloff" whose least
significant 32 bits were those from the aforementioned offset value,
and whose most significant 32 bits were stack garbage from "mydata".

This led to get_closest_section_symbol_by_offset() attempting to search
for extremely large values of "offset" among the symbols in "syms",
which meant that the last symbol with a matching section number would
always win the symbol search.

In effect, this clobbered the resultant relocation information, such
that all entries would be resolved with the same symbol.

Test output can be found here

https://www.azabani.com/patch/2/output.txt

This patch fixes

http://bugzilla.nasm.us/show_bug.cgi?id=3392306

Signed-off-by: Delan Azabani <delan@azabani.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-06-02 13:22:32 +03:00
Ciro Santilli
668e58dc69 doc: typo occationally
Signed-off-by: Ciro Santilli <ciro.santilli@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-05-24 12:59:11 +03:00
Cyrill Gorcunov
4920a03243 output: outmac64 -- Fix the case when first hit matches the symbol
In case if we're looking up for a symbol and it's first
one in symbol table we might endup with error because of
using GE here (78f477b35f) ending cycle with @nearest = NULL.

http://bugzilla.nasm.us/show_bug.cgi?id=3392306

Reprted-by: Benjamin Randazzo <benjamin@linuxcrashing.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-05-09 18:07:47 +03:00
Ed Maste
1f0cb0f2c1 output: elf64 -- increase .symtab and .rel* alignment to 8
Discovered while working on ELF Tool Chain elfcopy (strip),
which originally crashed on an assert while processing
a nasm-generated ELF object.

The .symtab and .rela.text sections report 4 byte alignment,
but require 8.

As an aside, see https://sourceforge.net/p/elftoolchain/tickets/485/ for a
discussion of the ELF Tool Chain issue that this bug exposed.

With my WIP elfcopy change and nasm-assembled jccolss2-64.o from libjpeg-turbo:

% strip -o /dev/null --strip-debug jccolss2-64.o
strip: section .symtab alignment 4 increased to 8
strip: section .rela.text alignment 4 increased to 8

http://bugzilla.nasm.us/show_bug.cgi?id=3392307

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-04-16 01:02:55 +03:00
Cyrill Gorcunov
8fa0fe1640 version: Fix the tag
While been preparing release I managed to write
non-number sequence into @version, which might
cause build problems. Lets fix it here and if
a moment happens -- release 2.11.09.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-02-23 12:04:39 +03:00
Cyrill Gorcunov
3db63b96ec NASM 2.11.08
- Fix section length computation in bin backend which
  leaded in incorrect relocation records.

 - Add a warning for numeric preprocessor definitions
   passed via command line which might have unexpected
   results otherwise.

 - Add ability to specify a module name record in rdoff
   linker with -mn option.

 - Increase label length capacity up to 256 bytes in rdoff
   backend for FreePascal sake, which tends to generate very
   long labels for procedures.

 - Fix segmentation failure when rip addressing is used
   in macho64 backend.

 - Fix access on out of memory when handling strings with
   a single grave. We have sixed similar problem in previous
   release but not all cases were covered.

 - Fix NULL dereference in disassembled on BND instruction.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-02-21 22:19:23 +03:00
Cyrill Gorcunov
399d29c0a5 doc: changes -- Prepare for 2.11.08
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-02-21 22:19:19 +03:00
Cyrill Gorcunov
775153b1bf output: dbg,aout,elf32 -- Fix out for signed relocations
@size might be negative for signed relocations but its length
is abs value. This is rather a fix for future use because at
moment we can't hit this problems but better be on a safe side.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-02-21 21:14:28 +03:00
Cyrill Gorcunov
d72bec12bc output: bin -- Fix section length miscalc for OUT_ADDRESS
While we using proper @asize variable for relocation itself
we miss the fact that @size variable (which might be negative
for signed relocations since fd52c277dd) is used to calculate
section size increment.

http://bugzilla.nasm.us/show_bug.cgi?id=3392299

Reported-by: Ben de Waal <ben@dewaals.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-02-15 18:18:57 +03:00
Cyrill Gorcunov
6d42e9ba47 preproc: Warn if someone predefines non ID as definition
Not sure if someone is used this but to not break
backward compatibility lets simply yield error but
don't stop processing.

http://bugzilla.nasm.us/show_bug.cgi?id=3392300

Reported-by: Dave Shields <thedaveshields@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-02-08 11:07:17 +03:00
Yuri Zaporozhets
d9ca54b6d2 rdoff/ldrdf.c: Add option to specify target RDF module name in command line
Rationale: this is useful for projects developed entirely in high-level
language and which use NASM as a backend (compilers able to generate NASM
code are e.g. ncc or Free Pascal). With this option there is no need to have
a single assembly language file for each project with just one "module NNN"
directive — it is enough now to specify the name as an argument to ldrdf.

Signed-off-by: Yuri Zaporozhets <r_tty@yahoo.co.uk>
2015-01-20 23:38:52 +02:00
Yuri Zaporozhets
7a33af2904 Correct name spelling and email address
Signed-off-by: Yuri Zaporozhets <r_tty@yahoo.co.uk>
2015-01-18 20:21:14 +02:00
Yuri Zaporozhets
76ee8e6091 rdoff: increase EXIM_LABEL_MAX to 256 bytes
Rationale: this is required for, e.g., FreePascal, which tends to generate
very long labels for procedures/methods that do not fit into 64 bytes.

This change does not introduce any incompatibilities.

Signed-off-by: Yuri Zaporozhets <r_tty@yahoo.co.uk>
2015-01-11 21:16:34 +02:00
Cyrill Gorcunov
d4923fc6a2 output: maco 64 -- Fix data conversion
Looks like were a typo in first place

http://bugzilla.nasm.us/show_bug.cgi?id=3392298

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-01-11 17:21:46 +03:00
Cyrill Gorcunov
78f477b35f output: maco 64 -- Fix get_closest_section_symbol_by_offset
- fixup comparision it should be GE
 - make sure we never return nil here

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-01-11 17:19:34 +03:00
H. Peter Anvin
12c0702824 rdoff/rdlib.c: Remove unused function rdl_close()
The function rdl_close() is never used, remove it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2015-01-05 15:21:43 -08:00
H. Peter Anvin
724719b1da Change posix_mktime() to make_posix_time()
The posix_ prefix is reserved for POSIX, and even if there never is a
posix_mktime() defined it might be confusing for programmers familiar
with this convention.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2015-01-05 15:17:56 -08:00
Cyrill Gorcunov
7cc90badae quote: Fix returning out of string pointer, take 2
In commit a45febd767 only part of problem has been covered.
Need to be ready for strings like

 | `a

http://bugzilla.nasm.us/show_bug.cgi?id=3392295

Reported-by: Hanno Boeck <hanno@hboeck.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-20 15:07:39 +03:00
Cyrill Gorcunov
85ec505d05 doc: Add missing closing brace
http://bugzilla.nasm.us/show_bug.cgi?id=3392284

Reported-by: Nick Rowan <nnrowan@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-20 14:25:58 +03:00
Cyrill Gorcunov
1006a47fe8 disasm: Add explicit type conversion to placate compiler
Otherwise getting

 | disasm.c:200:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 |         return GET_REGISTER(nasm_rd_bndreg, regval);

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-20 11:40:36 +03:00
Cyrill Gorcunov
7729edf722 configure.in: Move AC_C_INLINE and friends to be checked before PA_ADD_CFLAGS
Looks like -Werror=missing-declarations revealed problem in
configure: the "inline" support has not been detected properly
leading to problem in building procedure.

Lets move AC_C_INLINE and etc to be tested before gcc flags.

Reported-by: NAKAI Yuta <nak5124@live.jp>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-20 11:35:51 +03:00
Cyrill Gorcunov
9b05974022 ndisasm: Prevent nil dereference on registerd decoding
The sequence | 0x0F 0x1B 0x75 | get matched into
one of BNDx instruction which register value 6
which is of course out of possible BND registers
implemented in hardware at the moment leading to
nil dereference.

Instead lets use a macro in whichreg() helper
which would test the registers bounds and force
the caller to try another template if register is
out of range. In the case above it simply means
ndisasm instead of crashing outputs

 | 00000000  0F                db 0x0f
 | 00000001  1B                db 0x1b
 | 00000002  75                db 0x75

http://bugzilla.nasm.us/show_bug.cgi?id=3392289

Reported-by: Hanno Boeck <hanno@hboeck.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-14 22:44:54 +03:00
Cyrill Gorcunov
1cccb1e8d5 disasm: matches -- Use proper return type
matches() declared as int and better return explicit
zero here instead of @false.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-14 10:57:53 +03:00
Cyrill Gorcunov
00590792fe NASM 2.11.07
A few changes here

 - fix in VMOVNTPS 256 bit encoding
 - fix nil dereference in memory parsing code
   and access to uninitialized space when handling
   strings
 - fix processing of -MD option, the commit 599a982
   was fixing one issue but occasionally broke visible
   command line api, leading to (for example) syslinux
   can't be built with previous version.

There are some more bugs which are to be addressed
but due to fix of -MD option we need to release update.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-09 21:52:09 +03:00
Cyrill Gorcunov
e3131143fa doc: Update changes for 2.11.07
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-12-09 21:47:23 +03:00
Henrik Gramner
e7072c4148 insns.dat: Fix 256-bit vmovntps
Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-11-30 00:21:17 +03:00
Cyrill Gorcunov
0dd37af210 nasm: Fix -MD operating mode
Previously -MD option didn't call for depend mode solely but
produced deps during active compilation phase allowing symbol
refereces processing as well.

Occasionally in commit 599a98 I made -MD option to handle deps
in a separate internal phase which caused problems like

 | error: symbol references not supported in preprocess-only mode

leading to problems in building applications with nasm. Fix it
moving old behaviour back.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-11-29 21:49:38 +03:00
Cyrill Gorcunov
b2c3449788 compiler: Fix typo for HAVE__VSNPRINTF
Reported-by: Michael Murashkin <ragnarokkx@inbox.ru>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-11-26 10:44:19 +03:00
H. Peter Anvin
cfe039f69b configure.in: Remove redundant -Werror=trigraphs
As obnoxious as trigraphs are, we don't need to -Werror them twice.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 13:05:32 -08:00
H. Peter Anvin
ad2acd7754 Add missing static declarations in rdoff/segtab.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:35:29 -08:00
H. Peter Anvin
31bcb6f866 Add missing static declarations in rdoff/rdoff.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:35:16 -08:00
H. Peter Anvin
b06da211f4 Add missing static declaration in rdoff/rdlib.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:34:34 -08:00
H. Peter Anvin
48166388d5 Add missing static declarations in rdoff/rdflib.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:34:03 -08:00
H. Peter Anvin
ef18237372 Add missing static declaration in rdoff/rdfdump.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:33:33 -08:00
H. Peter Anvin
236f7949e4 configure.in: promote some C warnings to errors
Promote some C warnings to errors, especially ones relating to missing
prototypes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:14:52 -08:00
H. Peter Anvin
4de7a764d5 Run "make alldeps" to add missing header file dependencies
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:14:52 -08:00
H. Peter Anvin
2bbe917ede Add missing prototype in tokhash.c (from tokhash.pl)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2014-11-25 12:14:52 -08:00