Commit Graph

3006 Commits

Author SHA1 Message Date
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
b2bfb580df Merge branch 'master' into elfmerge 2016-02-17 20:33:40 -08:00
H. Peter Anvin
11b8817e8a listing: remove unused variable
The previous commit contained an unused variable, remove it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 20:33:02 -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
bbbf508394 nasmlib: add nasm_fatal() like nasm_panic()
Just like nasm_panic(), nasm_fatal() tells the compiler that
we can never return from this call.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 16:10:41 -08:00
H. Peter Anvin
0e8fcf1b6c outelf*: remove type prefix from debugging functions
The debugging functions currently have unique prefix, which is good
for debuggability but hides real code differences.  Convert them to
have the same name across files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 15:51:08 -08:00
H. Peter Anvin
d2ea49b326 listing: change the line numbers to match the source code
Instead of completely useless sequential line numbers, emit line
numbers corresponding to the line numbers in the source code.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 15:38:51 -08:00
H. Peter Anvin
86e31129f7 outelf32: remove unused header file
Remove unused instance of <limits.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 14:44:19 -08:00
H. Peter Anvin
4b70bc2504 outelf32: move stabs32_linenum() so that it matches the other files
Move the function stabs32_linenum() so that it is in the same location
as in the other ELF backends; this eliminates a gratuitous difference.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 14:37:26 -08:00
H. Peter Anvin
777b7b1d25 Merge tag 'nasm-2.12rc4'
NASM 2.12rc4

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 14:35:48 -08:00
H. Peter Anvin
9f7c68a519 changes.src: more updates for 2.12
More updates in preparation for NASM 2.12.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 13:44:51 -08:00
H. Peter Anvin
43e0c3cf8d outmacho: make a copy of "fmt" instead of making it a pointer
Make a point of the output format constants instead of making it
a pointer.  The output format is set only once, but it is accessed
all the time.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 13:28:19 -08:00
Cyrill Gorcunov
1452990979 docs: Fix typo in previous commit
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-02-17 17:02:34 +03:00
Cyrill Gorcunov
2338613e6b docs: changes -- Prepare for 2.12
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-02-17 17:00:06 +03:00
H. Peter Anvin
a648b90eab NASM 2.12rc4 2016-02-16 22:32:58 -08:00
H. Peter Anvin
dde34c51b3 outmacho: correct handling of GOT relocation, add TLVP relocations
Correct the handling of GOT relocations, as they need a symbol
reference.  Add handling of TLVP relocations; it is unclear to me
if non-local relocations in TLVP space is permitted.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 22:15:03 -08:00
H. Peter Anvin
085a4a9f98 outmacho: fix the .rodata -> __TEXT,__const mapping
For the mapping of .rodata to __TEXT,__const in the absence of
relocations, it would help if we changed the segment name *before* we
emit that part of the load command.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 18:04:39 -08:00
H. Peter Anvin
82a3082d64 raa: move private parts of the implementation into raa.c
Move the private aspects of the implementation into raa.c instead
of exposing it to raa.h.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 17:47:25 -08:00
H. Peter Anvin
ec62791d8c outmacho: sanitize the handling of sections
Sanitize the handling of sections in outmacho somewhat.  This should
bring further performance improvements.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 17:38:58 -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
6fc2b123af outmacho: if .rodata contains no relocations, change it to __TEXT,__const
If we specify .rodata as opposed to the explicit __DATA,__const, and
we end up with no relocations, change it to __TEXT,__const per the
Mach-O ABI.  However, it is generally better for the programmer to
explicitly specify the items that should go into __TEXT,__const as
otherwise a single relocatable item will force the whole thing into
__DATA.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 12:56:27 -08:00
H. Peter Anvin
d1da074b83 outmacho: Allow arbitrary MachO sections, avoid bss lookup
Allow specifying sections with arbitary MachO segment and section
names, as opposed to having a fixed list of supported sections
(especially __DATA,__const is wrong in some cases.)  Furthermore,
we do a completely unnecessary lookup of the bss section *for every
call to macho_output()* which is just plain crazy.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 12:39:26 -08:00
H. Peter Anvin
615ef1a6f8 outmacho: Only test for MAX_SECT at the point sections are laid out
Exceeding MAX_SECT is not a warning, it is a fatal error.  However,
there is no point to test for it until we already process all the
sections.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 11:42:13 -08:00
H. Peter Anvin
e1eb7b8880 outmacho: Fix the computation of non-external relocation offsets
When we clear the ext bit, creating section-relative relocations,
the resulting value is computed somewhat differently; we need to
adjust for that.

TODO: Need to make sure we do the right thing for ALL relocations.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-16 11:30:54 -08:00
H. Peter Anvin
4e5fbcb81b outmacho: use section table lookup for local symbol references
When generating local symbol references, don't loop over all the
sections like we used to...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-16 00:29:48 -08:00
H. Peter Anvin
c44bfaa054 Merge branch 'master' of git://repo.or.cz/nasm 2016-02-15 23:44:43 -08:00
Ozkan Sezer
ec3d426e36 configure.in: Add -Werror flags last (BR 2292332)
configure.in: Add the -Werror flags as the last thing. Otherwise, with
development versions of autoconf, all AC_CHECK_FUNCS calls fails with:
conftest.c:49: error: function declaration isn't a prototype
conftest.c:49: warning: conflicting types for built-in function 'strcspn'

Signed-off-by: Ozkan Sezer <sezero@users.sourceforge.net>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 23:49:56 -08:00
H. Peter Anvin
ddf424758c NASM 2.12rc3 2016-02-12 21:24:32 -08:00
H. Peter Anvin
2bc798a968 rdflib: actually get the time
sizeof(t = time(NULL)) doesn't ever actually call time().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-12 21:21:57 -08:00
H. Peter Anvin
99276cc7d9 outmacho: rename outmac.c to outmacho.c
We already have outmacho.mac, so name this file outmacho.c.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-12 21:19:13 -08:00
H. Peter Anvin
941356b2ca outmac: generate section-relative relocations for local symbols
We generate section-relative relocations for local symbols for all
the other output formats, and we should do the same for MachO;
this was done in MachO-32 but not in MachO-64, presumably because
the MachO spec implies that such relocations shouldn't exist in
64-bit code.  They are indeed rare, but that is a programmer's
decision, and the spec is clear that they are legal.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-12 15:06:23 -08:00
H. Peter Anvin
ca351fa175 assemble.c: when converting an address to RAWDATA, need to update size
When converting an address to RAWDATA we have to copy the address size
into the size variable, as the size variable may be negative.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-12 13:49:45 -08:00
H. Peter Anvin
fc1a7ad662 outmac: correct the format name for macho32
The name for the macho32 output format was incorrectly set to
macho64, which means neither macho32 nor macho64 worked correctly.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-12 13:36:37 -08:00
Cyrill Gorcunov
f8d52b655e output: outmac -- Fix few nits during merge
- typo in @if statement
 - unused @originalIndex

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-02-12 21:50:38 +03:00
H. Peter Anvin
b13df02490 outmac: allow section alignment to be declared more than once
Allow section alignment to be declared more than once, with different
values.  The strictest alignment value via either a section or
sectalign directive becomes the controlling parameter.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 03:23:25 -08:00
H. Peter Anvin
7dcd1a1549 outmac: default to bits 32 for macho32 output format
Default to 32 bits for macho32; default to 64 bits for macho64.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 03:16:02 -08:00
H. Peter Anvin
09b56b421a outmac: move the format definitions down to the format-specific code
Move the format definitions down the to where the format-specific
initialization code lives.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 03:13:00 -08:00
H. Peter Anvin
c635497870 Merge the macho32 and macho64 (outmac32/64) backends
Merge the two Mach-O backends for cleanliness and maintainability.
This should also make the recent fixes to MachO-64 available in
MachO-32.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 03:04:41 -08:00
H. Peter Anvin
d7043da281 realpath: prefer the buffer size given by pathconf()
If realpath(..., NULL) doesn't work, we have to allocate a buffer
blindly.  Use the value returned from pathconf() in preference from
compile-time constants.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 01:32:57 -08:00
H. Peter Anvin
67db8184b1 macho64: remove -64 suffix from static variables
When the macho64 backend was forked, instead of fixing variables which
ought to have been static all along, the porter added a -64 suffix to
prevent namespace conflict.  Fix it by making those variables static.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 01:23:53 -08:00
H. Peter Anvin
797dc4f01e macho: make a bunch of global variables static
These variables should never have been anything but static in the
first place.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-12 01:21:15 -08:00
H. Peter Anvin
b03d91e6ab assemble.c: fix the handling of zero-extending unsigned relocations
First of all we printed the wrong error message, and second of all we
need to set the segments to NO_SEG before passing them to the output
format generator.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-11 21:13:54 -08:00
H. Peter Anvin
b64125022d assemble.c: handle oversized relative relocations
Handle the case of oversized (larger than permitted by the output
format) relative relocations.  Relative relocations are always signed,
and quite likely to actually have the sign bits set, so zero-extending
them is not an option.  Fortunately oversized relative relocations
are rare, as no CPU instruction support 64-bit relative addresses.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-11 21:07:40 -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
5507ad585f Merge branch 'machofix'
This fixes the macho64 output.  However, macho32 has the same problems and the
code either needs to be backported or, better yet, unified.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-11 20:24:53 -08:00
H. Peter Anvin
f30d96d1c0 outmac64.c: Fix memory clobber bug, clean up memory free
Fix an array that was way too small resulting in memory overwrite
errors, and free a few more dynamic data structures.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-11 20:20:10 -08:00
H. Peter Anvin
97577e82d7 macho64: remove LC_DATA_IN_CODE, change reloc type to 1
Change the relocation type to SIGNED instead of BRANCH, this is
probably more correct.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-11 19:25:33 -08:00