Commit Graph

213 Commits

Author SHA1 Message Date
H. Peter Anvin
8ac25aa020 Change nasmlist/ListGen to lfmt/struct lfmt
For consistency with ofmt/dfmt, change the listing structure
to "struct lfmt" and "lfmt" and move it to listing.h.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 01:16:18 -08:00
H. Peter Anvin
338656c1de output: make all instances of struct ofmt readonly
With current_dfmt gone, we can make all instances of struct ofmt
const (read-only).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 20:59:22 -08:00
H. Peter Anvin
a7bc15dd0a Remove ofmt->current_dfmt indirection
Move ofmt->current_dfmt into a separate global variable.  This
should allow us to make ofmt readonly and removes some additional
gratuitious differences between backends.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 20:55:08 -08:00
H. Peter Anvin
4a8d10c1a0 Output preprocessor warnings to the listing file
Most preprocessor warnings are ERR_PASS1, but we want to see them in
the listing file too.  If we make it to the code-generation pass,
ignore ERR_PASS* for the purpose of emitting warnings to the list
file.

While we are at it, allow ERR_DEBUG to specify ERR_PASS* too.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 20:47:01 -08:00
H. Peter Anvin
130736c0cf Get rid of a bunch of unnecessary indirections
We pass around a whole bunch of function pointers in arguments,
which then just get stashed in static variables.  Clean this mess
up and in particular handle the error management in the preprocessor
using nasm_set_verror() which already exists.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 20:27:41 -08:00
H. Peter Anvin
2c4a4d5810 Simplify handling of segments and segalign
Slightly simplify the handling of segment number allocation.
If we are in absolute space, never push a segalign down to the backend.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 17:37:18 -08:00
H. Peter Anvin
33814133bd Replace global maxbits variable with field in struct ofmt
maxbits is strictly a property of the output format, so get rid of
this ad hoc method of reporting.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-11 20:40:07 -08:00
H. Peter Anvin
ecc9e0ecd7 Set warning name to zext-reloc and fix the warning message
Adjustment to the warning about zero-extended relocations.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-11 20:29:34 -08:00
H. Peter Anvin
d24dd5fecc Remove the --allow-64-bits option and make it a warning
Remove the --allow-64-bits relocation, and instead make it a
suppressible warning in the case of a zero-extended relocation, and an
error in the case of a sign-extended relocation.

Relocations which can be losslessly represented in the output format
do not issue any diagnostic at all, as there is no problem in that
case.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-08 10:32:13 -08:00
Knut St. Osmundsen
3c72a1b3b3 Add option to allow 64-bit code in any output format
Add the option --allow-64-bit to permit the generation of 64-bit code
even for a 16/32-bit output format.

Using NASM to do some boot strapping code and ran into trouble when
trying to emit a few 64-bit instructions in the OMF object file doing
the mode switching.  While I can see how the "error: obj output format
does not support 64-bit code" message can be a useful reality check
for application programmers, it prevents low-level programmers from
doing what they want.  It if was just a harmless warning, it wouldn't
be so bad, but it turns BITS 64 into BITS 16. The main trick to mixing
64-bit code into OMF and other 32-bit output formats is to avoid
64-bit sized fixups, which normally isn't too hard.

[hpa: shortened the option name to --allow-64-bit, minor code cleanups]

Signed-off-by: Knut St. Osmundsen <bird-nasm@anduin.net>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-01-26 12:34:41 -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
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
599a98272e nasm: Handle -MF and -MD options
It's been long time since -MF and -MD options were described
in docs but actually -MF was not implemented completely and -MD
didn't proceed into normal compilation process. Fix it.

Because we use bitmask for operating_mode selection I had to
move compilation condition one shift left.

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

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-06-29 00:52:54 +04:00
Cyrill Gorcunov
e9fc88ca11 nasm: Convert operating_mode to use bitmask
We will need it to handle mode continuations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-06-29 00:52:54 +04:00
Cyrill Gorcunov
3ed32cb288 nasm: Make op_type members being capitals
Otherwise they look like reguar variables.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-06-29 00:52:54 +04:00
Cyrill Gorcunov
e743843d15 options: Add --v option
It's been requested a long ago to handle '--v' option same was as
a regualar '-v'. From initial report

 | NASM and yasm are in many respects compatible but yasm uses --v
 | instead of -v for version.  As often --v is used for version I
 | end up using --v initially in NASM.  This patch allows me to compile
 | Mozilla apps which use yasm with NASM by merely renaming NASM to yasm
 | so that the build environment does not have to be updated (Mozilla
 | would not accept changes to allow use of NASM).

Reported-by: Andy Willis <abwillis1@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-05-09 22:34:37 +04:00
Cyrill Gorcunov
07f0a8dbc9 debug: Drop LOGALLOC usage
There are special tools (like valgrind and etc)
to track memory leaks, no need for own trivial
tracker.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-05-09 22:22:34 +04:00
Jin Kyu Song
b287ff0ddb bnd: Add a new nobnd prefix
bnd and nobnd prifixes can be used for each instruction line to
direct whether bnd registers should be preserved or not.

And those are also added as options for DEFAULT directive.
Once bnd is set with default, DEFAULT BND, all bnd-prefix
available instructions are prefixed with bnd. To override it,
nobnd prefix can be used.

In the other way, DEFAULT NOBND can disable DEFAULT BND and
have nasm encode in the normal way.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-12-04 20:10:08 -08:00
Jin Kyu Song
bb8cf3fa77 bnd: Show warning when bnd prefix is dropped
When bnd prefix is dropped as jmp is encoded as jmp short,
nasm shows a warning message, which can be suppressed with a new
command line option, -w-bnd.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-12-04 20:06:23 -08:00
Cyrill Gorcunov
0835915c1d iflag: Start using new instruction flags engine
Here we start using instruction flags generator.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-11-24 13:20:59 +04:00
Jin Kyu Song
9bb987d8e0 AVX-512: Change the data type for instruction flags
Increased the size of data type for instruction flags from 32bits to 64bits.
And a new type (iflags_t) is defined for better maintainability.

Bigger data type is needed because more instruction set types are coming
but there were not enough space for them. Since they are not bit masks,
only one instruction set is allowed for each instruction.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-28 09:37:21 +04:00
Cyrill Gorcunov
deb082d633 BR3392248: Update nasm -h output
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-04-20 20:37:17 +04:00
Cyrill Gorcunov
190232f013 nasm.c: Convert GET_CURR_OFFS/SET_CURR_OFFS to functions
In future better to not work with global variables but
rather pass arguments.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:35:04 +04:00
Cyrill Gorcunov
f187eb7788 nasm.c: Update year in header
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:25:33 +04:00
Cyrill Gorcunov
52405e3727 nasm.c: Tabs to spaces in emit_dependencies
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:25:04 +04:00
Cyrill Gorcunov
9f56369883 nasm.c: Tabs to spaces in main
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:24:11 +04:00
Cyrill Gorcunov
45aa118fdf nasm.c: Tabs to spaces in copy_filename
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:22:59 +04:00
Cyrill Gorcunov
f831645ed8 nasm.c: Tabs to spaces in copy_filename
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:22:27 +04:00
Cyrill Gorcunov
331fd7c8aa nasm.c: Tabs to spaces in process_arg
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:20:58 +04:00
Cyrill Gorcunov
f196451d66 nasm.c: Tabs to spaces in process_response_file
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:14:06 +04:00
Cyrill Gorcunov
1476319ced nasm.c: Tabs to spaces in assemble_file
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 12:13:09 +04:00
Cyrill Gorcunov
04dba65098 nasm.c: Tabs to spaces in nasm_verror_gnu
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 02:21:07 +04:00
Cyrill Gorcunov
22ad904341 nasm.c: Tabs to spaces in nasm_verror_common
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 02:20:26 +04:00
Cyrill Gorcunov
cdaae1a8e3 nasm.c: Tabs to spaces in define_macros_early
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-15 02:16:58 +04:00
H. Peter Anvin
5534099473 When generate dependency names internally, quote filenames
Quote filenames for Make when generated for filenames internally.
Only skip quoting when using the -MT option (rather than -MQ).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-09-09 17:09:00 -07:00
Cyrill Gorcunov
b5e8fec848 preproc: Move NOP preprocessor into separate file
No need to carry it in nasm.c, let it be more modular.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-07 11:34:27 +04:00
Cyrill Gorcunov
0b78bff510 preproc: Split get rid of global preproc methods
This will allow to hook on updated preprocessor
without breaking existing one.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-07 01:57:55 +04:00
Cyrill Gorcunov
5bc6d8e44d help: Print that -Ox is a default optimization level
Reported-by: Frank Kotler <fbkotler@myfairpoint.net>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-11 14:19:17 +04:00
H. Peter Anvin
5a24fdd547 Make the LOCK and HLE warnings suppressable.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 15:11:11 -08:00
H. Peter Anvin
442a05a897 nasm.c: Fix is_suppressed_warning()
The logic in is_suppressed_warning() was severely wrong, which would
cause a lot of legitimate warnings to be suppressed while some
warnings would be duplicated.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-24 21:50:53 -08:00
Cyrill Gorcunov
b574b074a7 Don't forget to setup warning levels on preprocessor phase
http://bugzilla.nasm.us/show_bug.cgi?id=3143109

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-12-05 01:56:40 +04:00
Cyrill Gorcunov
d64b8098be Drop tab/space mess from parse_cmdline
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-12-05 01:44:43 +04:00
Cyrill Gorcunov
3b8c2974a1 Use proper bracing on setting warnings in comman line parsing
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-12-05 01:39:04 +04:00
Cyrill Gorcunov
0e754dcafe Add WARN_IDX helper and ERR_WARN_TERM named constant
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-12-05 01:01:06 +04:00
Cyrill Gorcunov
ead8772590 Simplify is_suppressed_warning helper
The former is really hard to read.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-12-04 19:24:25 +04:00
Cyrill Gorcunov
f4941892b3 Drop unused 'arg' variable
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 13:55:25 +04:00
Cyrill Gorcunov
86b2ad05f8 preproc: Move Preproc type to preproc_ops structure
There is no need to hide this structure into a type.
The former preproc_ops is a way more descriptive.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-02 00:15:24 +04:00
Cyrill Gorcunov
9fde335005 nassm.c: Use evaluate for section alignment
This allow us to write the whole expressions
on section alignments, such as

	align 0xa+6

or whatever math. Should be a way more convenient
than hardnumbers scheme we had.

Reported-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 12:05:51 +04:00
Cyrill Gorcunov
c1936da942 ofmt: Alias shortname must be used for __OUTPUT_FORMAT__ macro
__OUTPUT_FORMAT__ must consist of shortname of output format
or its alias, otherwise userspace ABI gets broken.

For example source code still can refer to __OUTPUT_FORMAT__=elf,
instead of __OUTPUT_FORMAT__=elf32.

BR3246990

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-04-06 18:32:15 +04:00
Cyrill Gorcunov
91a65ba2b7 BR3200749: Fix "use after close" file pointer
Cleanup routine might be called several times
so be ready for that.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-07 11:18:50 +03:00