Commit graph

402 commits

Author SHA1 Message Date
H. Peter Anvin
1917f45ec2 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	output/codeview.c
	output/outelf32.c
	output/outelf64.c
	output/outelfx32.c
	output/outform.c
	output/outform.h
	output/outieee.c
	output/outobj.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-08 01:08:53 -08:00
H. Peter Anvin
283b3fb15a Defer debug format search until after command line parsing
Avoid funnies with ordering of debug format selection by deferring
debug format search until after command line processing.  Also permit
the -gformat syntax used by many C compilers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 23:20:00 -08:00
H. Peter Anvin
477ae4419c ofmt: get rid of the debuginfo parameter to ofmt->cleanup()
Get rid of the completely pointless "debuginfo" parameter to
ofmt->cleanup().  Most backends completely ignore it, and the two that
care (obj, ieee) can simply test dfmt instead.

Also, dfmt is never NULL, so any test for a NULL dfmt is bogus.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 22:55:43 -08:00
H. Peter Anvin
c941a35e58 outelf*: remove null debug functions
Instead of duplicating empty functions, use the corresponding
null_debug_* functions.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 22:12:19 -08:00
H. Peter Anvin
bc42cbe363 codeview: remove hack for handling local labels
Now when labels are properly concatenated in common code, there is no
reason for the debugging backend to need to be aware of local
symbols.  We don't have to consider ..[^@] special symbols either, as
they are now filtered in labels.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Debugged-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:06:16 -08:00
H. Peter Anvin
3def9fcb59 outieee: no need to filter .. symbols in the debug format anymore
labels.c now filter ..[^@] special symbols from the debug backend,
so we don't have to open-code that everywhere.

In the actual output format, don't treat ..@ symbols as special.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:04:54 -08:00
H. Peter Anvin
5686a65fe9 outobj: no need to filter .. symbols in the debug format anymore
labels.c now filter ..[^@] special symbols from the debug backend, so
we don't have to open-code that everywhere.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:03:50 -08:00
Jim Kukunas
63c42f08f7 codeview: Don't treat labels starting with .. as local labels
For local labels, starting with '.', the label name is concatenated with
the previous non-local label to produce a label that can be accessed from
elsewhere. This is the name we want to generate debug info for.

Labels starting with ".." are special and shouldn't be concatenated.

Fix Bugzilla #3392342

Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 19:36:41 -05:00
H. Peter Anvin
6224033738 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	.gitignore
	Makefile.in
	assemble.c
	configure.in
	eval.c
	float.c
	listing.c
	nasm.c
	nasmlib.c
	output/outform.h
	preproc.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 12:15:40 -08:00
H. Peter Anvin
335c4857ce 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.

From master branch checkin a7bc15dd0a

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-03-07 12:07:50 -08:00
H. Peter Anvin
0b7969e9a9 Merge branch 'nasm-2.12.xx'
Resolved Conflicts:
	compiler.h

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 11:50:38 -08:00
H. Peter Anvin
215186fe82 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>

From master branch checkin 130736c0cf

Resolved Conflicts:
	nasm.c
	preproc-nop.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-03 15:22:03 -08:00
H. Peter Anvin
41087068aa Replace nasm_error(ERR_FATAL/ERR_PANIC) with nasm_fatal/nasm_panic
Replace all instances of ERR_FATAL or ERR_PANIC with nasm_fatal or
nasm_panic so the compiler knows that these functions cannot return,
*and* we trigger abort() if we were to ever violate that constraint.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-03 15:22:02 -08:00
H. Peter Anvin
c5b2de0964 codeview: be a bit more explicit about the nature of a panic
When we have to die due to an assertion violation, then show the
missing symbol.  Also, use nasm_panic() rather than nasm_assert() for
this purpose.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-03 14:15:41 -08:00
H. Peter Anvin
54469e27d0 outmacho: remove unused debugging functions
Remove unused debugging functions, and the _unused macro which turned
out to cause compilation problems on Linux/PowerPC.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-03 12:29:25 -08:00
H. Peter Anvin
53f1559c06 Remove unnecessary C99-isms
In order to make it more likely to compile cleanly with "C90 plus long
long" style compilers, remove existing constructs (mostly commas at
the end of enums) that aren't compliant.

Ironically enough this was most likely an unintentional omission in
C90...

From master branch checkin 7214d18b40

Resolved Conflicts:
	output/outelf32.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-02 10:48:53 -08:00
H. Peter Anvin
7214d18b40 Remove unnecessary C99-isms
In order to make it more likely to compile cleanly with "C90 plus long
long" style compilers, make gcc warn for incompatible constructs.
Remove existing constructs (mostly commas at the end of enums) that
aren't compliant.

Ironically enough this was most likely an unintentional omission in
C90...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-01 22:43:51 -08:00
H. Peter Anvin
b9c1ca7e8d Merge branch 'nasm-2.12.xx'
Resolved Conflicts:
	configure.in
	output/codeview.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-01 21:51:40 -08:00
Knut St. Osmundsen
52ae33a2cb Remove unnecessary C99 features which break Visual C++ 2010
Fixes Visual C++ 2010 breakage in recently added Codeview 8 code;
these are C99 features which were not necessary to introduce.

Signed-off-by: Knut St. Osmundsen <bird-nasm@anduin.net>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-02-26 23:44:10 -08:00
H. Peter Anvin
8aba13b51f Merge branch 'master' into elfmerge
Resolved Conflicts:
	output/outmacho.c

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-26 20:51:46 -08:00
H. Peter Anvin
ed8eb56546 outmacho: correctly handle references between sections
Correctly generate references between sections.  The previous
version would work correctly as long as all relative references
came from the first section, which is usually __TEXT,__text and
so it usually worked.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-23 00:13:49 -08:00
H. Peter Anvin
95b43676c3 Merge branch 'master' into elfmerge 2016-02-21 21:24:38 -08:00
H. Peter Anvin
a222d21138 outmacho: make a best effort at separating SIGNED from BRANCH relocs
For 64 bits, a BRANCH reloc is sometimes needed to fix up PIC
problems.  Make a best effort at generating BRANCH relocs just as
we make a best effort at distinguishing GOTLOAD from GOT.

This needs to be replaced with information from the assembler to
the backend.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-21 20:56:19 -08:00
H. Peter Anvin
28ec7d1ddf Merge branch 'master' into elfmerge
Resolved Conflicts:
	configure.in

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 13:57:03 -08:00
H. Peter Anvin
4afa730c03 outmacho: default section flags should depend on section name only
The __TEXT segment in particular contains both code and data.  The
most consistent thing is to look only at the section name, and have
the same behavior across sections.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 10:55:00 -08:00
H. Peter Anvin
2530a10b56 Make a few more data items static and const
A few more data items that should be static and const.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 02:28:15 -08:00
H. Peter Anvin
a4973cf997 A few more debugging format arrays to mark const
Making more debugging format array const.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 02:25:26 -08:00
H. Peter Anvin
2be1050f93 codeview: make struct dfmt df_cv8 const
This one was not declared const; fix that.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 02:22:50 -08:00
H. Peter Anvin
7e3b12d6da More constification, mostly of struct dfmt
Make struct dfmt and the struct dfmt arrays const across the board,
and make them static whereever possible.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-18 02:16:36 -08:00
H. Peter Anvin
f9be8c3179 outelf64: fix comment
Fix comment that refer to R_386_* to avoid hiding similarities
versus outelfx32.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 22:01:33 -08:00
H. Peter Anvin
e3e2f1bbc2 outelf64: symtabsection is defined but never set, change to sec_symtab
The variable symtabsection is defined but it is never actually set and
so was always zero.  For both the 32-bit output format this is
sec_symtab defined in elf.h.

If this is not correct for the 64-bit format, then we should define
sec_symtab as a variable instead of having a gratuitious format
difference.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-02-17 21:03:13 -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
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
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
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
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
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
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
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
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
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