Commit Graph

40 Commits

Author SHA1 Message Date
H. Peter Anvin
0cba107579 Make it possible for outputs to be either text or binary
Allow the backend to specify that an output format is either text or
binary.  For future uses, define this as a flag word so we can define
other flags in the future if it would make sense.

Currently, the ieee and dbg formats are text; all the others are
binary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-05 14:45:12 -07:00
H. Peter Anvin
8beadd4da8 outmacho: change license to 2-BSD
Received authorization from Apple to change the license of outmacho.c
to the 2-clause BSD license.  Thanks!

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-30 21:17:07 -07:00
H. Peter Anvin
d7392ad814 Add new copyright headers to the output modules
Add new copyright headers to the new output modules.  As far as I
know, the only module which we still don't have a green light to
release under 2-BSD is outmacho.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 17:25:15 -07:00
H. Peter Anvin
31b707bef0 Move backend-specific code to output/; break out null debug stuff
Move backend-specific code into the output/ directory, and make the
null debugging backend a separate file (it certainly isn't needed for
ndisasm...)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27 22:07:33 -07:00
H. Peter Anvin
999868f06f Unify all-zero buffers; add fwritezero()
We have a number of all-zero buffers in the code.  Put a single
all-zero buffer in nasmlib.c.  Additionally, add fwritezero()
which can be used to write an arbitrary number of all-zero bytes;
this prevents the situation where the all-zero buffer is simply
too small.
2009-02-21 17:24:08 -08:00
David DeHaven
74a8755fe3 Mach-O alignment fix
Several projects have taken to using .text to store read-only data
when building on Mac OS X due to crashes in SSE code from the .rodata
section being mis-aligned. It seems there was a misunderstanding about
how ld/ld64 handles section alignment in outmacho.c so I wrote a patch
to fix it. I tested it against x264 git, modified it to use ".rodata
align=16" for the data section and use movdqa instructions (guaranteed
to crash when built with unpatched nasm) and it passed all tests in
its checkasm tool.

If you want more data I can provide, but it's late and I've had a
couple glasses of mulled wine :)

-DrD-
2008-12-18 14:58:24 -08:00
H. Peter Anvin
03c4f90afa output: add common file outlib.c for common functions; realsize()
Add a common file, outlib.c, for output formats.  Add the function
realsize() instead of open-coded variants in almost every backend.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-27 22:19:59 -07:00
H. Peter Anvin
cfb7176ca2 Move the output format macros into the macros.pl mechanism
Move the handling of "extra" macros (i.e. output format macros) into
the macros.pl mechanism.  This allows us to change the format of the
internal macro store in the future - e.g. to a single byte store
without redundant pointers.

Also, stop using indicies into a long array when there is no good
reason to not just use different arrays.
2008-06-20 15:20:16 -07:00
H. Peter Anvin
fcb8909749 Move all the RAA code out of nasmlib
The RAA code doesn't have to be in nasmlib; it is only used by nasm
itself, and is better handled in a separate module.
2008-06-09 17:40:16 -07:00
H. Peter Anvin
1803dedae8 Move all the SAA code out of nasmlib
Move all the SAA code out of nasmlib; it's not used by anything than
nasm itself.  Cleaning out the kitchen sink known as nasmlib is a good
thing, too.
2008-06-09 17:32:43 -07:00
Beroset
095e6a2973 regularized spelling of license to match name of LICENSE file 2007-12-29 09:44:23 -05:00
H. Peter Anvin
d1fb15c154 Address data is int64_t; simplify writing an address object
Address data is always int64_t even if the size itself is smaller;
this was broken on bigendian hosts (still need testing!)

Create simple "write sized object" macros.
2007-11-13 09:37:59 -08:00
H. Peter Anvin
fb0c90cdbe BR 1709392: Fix alignment handling in Mach-O format
Fix alignment handling in the Mach-O format.  The patch is from the
bug report, mangled to apply to the current source base.  I have no
way to test this, so I'm going to have to assume it's correct.
2007-11-12 22:11:46 -08:00
H. Peter Anvin
34f6fb0a65 Don't combine type and size into a single argument
Don't combine type and size into a single argument; *every* backend
immediately breaks them apart, so it's really just a huge waste of
effort.  Additionally, it avoids using short immediates in the
resulting code, which is a bad thing.
2007-11-09 14:44:02 -08:00
H. Peter Anvin
44d7dcf87b Fix building under OpenWatcom
OpenWatcom doesn't like 64-bit switch arguments; the change to 64-bit
type arguments caused that to happen in outmacho.c.  Hack around it
for now; however, realistically speaking the whole bit stealing thing
is probably a bad idea, especially since virtually all CPUs handle
short immediates better than long ones.
2007-11-08 20:43:22 -08:00
Charles Crayne
8c7eca4936 Pass 64-bit instruction lengths to back-ends. 2007-11-06 21:48:12 -08:00
Charles Crayne
4e8563d5c4 Upgrade label functions to 64-bit 2007-11-05 17:19:32 -08:00
H. Peter Anvin
7065309739 Formatting: kill off "stealth whitespace"
"Stealth whitespace" makes it harder to read diffs, and just generally
cause unwanted weirdness.  Do a source-wide pass to get rid of it.
2007-10-19 14:42:29 -07:00
H. Peter Anvin
fe501957c0 Portability fixes
Concentrate compiler dependencies to compiler.h; make sure compiler.h
is included first in every .c file (since some prototypes may depend
on the presence of feature request macros.)

Actually use the conditional inclusion of various functions (totally
broken in previous releases.)
2007-10-02 21:53:51 -07:00
H. Peter Anvin
21d6be423f Minor fixes needed to compile with MSVC++ 2005
Minor fixes to make it possible to compile with MS Visual C++ 2005.
Unfortunately, MSVC++ is not fully C99 compliant; in particular, it
doesn't handle interspersed declarations and other code.  Furthermore,
it chokes on some expressions in outelf64.c, which fortunately can be
easily substituted with simpler expressions.
2007-09-16 22:15:34 -07:00
Frank Kotler
7fcda399cd add nasm_strsep to nasmlib, for output/outmacho.c - strtok doesn't work 2007-08-26 05:48:54 +00:00
H. Peter Anvin
f4ba92577e outmacho.c: stylistic cleanups
- No need to cast (int32_t)NULL for a sentinel; just write 0.
- Fix weird formatting of a structure.
- Remove redundant parantheses.
2007-04-14 08:03:02 +00:00
Keith Kanios
c8ef68bba9 Hopefully it is actually fixed this time :P 2007-04-14 03:44:31 +00:00
Keith Kanios
3e7bb1e046 Fixed structure initialization issue. 2007-04-14 01:49:07 +00:00
Keith Kanios
a2e9b953f8 Refixed uninitialized data. 2007-04-14 01:44:35 +00:00
Keith Kanios
df12db1f13 Fixed uninitialized structure data. 2007-04-14 01:40:24 +00:00
Keith Kanios
c7ae18dba1 Placated unreferenced types. 2007-04-14 00:46:25 +00:00
Keith Kanios
93f2e9a5a1 c99 printf/fprintf compliance. 2007-04-14 00:10:59 +00:00
Keith Kanios
2a3311b546 Replaced str(n)casecmp with more standard str(n)icmp. 2007-04-13 22:00:42 +00:00
H. Peter Anvin
c1494ac5ab Macroize any compiler-specific code; macros defined in "compiler.h"
Move anything compiler-specific to "compiler.h".

There was an unguarded use of __attribute__(()) in outmacho.c; also
require gcc 4+ for __builtin_ctlz().  Speed up the open-coded version, too.
2007-04-13 19:58:42 +00:00
Keith Kanios
a6dfa78b78 Fixed distinction between char and int8_t data types. 2007-04-13 16:47:53 +00:00
H. Peter Anvin
58421f9697 outmacho.c: Don't assume __builtin_ctzl exists for gcc < 4
__builtin_ctzl exists for all architectures on gcc 4, but not for all
versions of gcc 3 and lower.  For simplicity, make the cutoff gcc 4.
2007-04-12 16:12:09 +00:00
Keith Kanios
b7a89544d0 General push for x86-64 support, dubbed 0.99.00. 2007-04-12 02:40:54 +00:00
Eric Christopher
a5f0000db0 2006-02-02 Eric Christopher <echristo@apple.com>
Wade Tregaskis  <wtregaskis@apple.com>

	* output/outmacho.c (macho_cleanup): Depend on symbols
	existing.
2006-02-02 21:50:47 +00:00
Eric Christopher
5eb2d2b094 2005-12-08 Wade Tregaskis <wtregaskis@apple.com>
* nasm/nasm/output/outmacho.c (struct section): Added "align" field.
	(sectmap): Added ".rodata" section.
	(exact_log2): New.
	(macho_section): Added support for section attributes.
        "align=" and "data" specifically.
	(macho_write_segment): Write out section alignment to Mach-O file.
2005-12-09 00:27:26 +00:00
Eric Christopher
5547e191fe 2005-12-05 Eric Christopher <echristo@apple.com>
* nasm/nasm/output/outmacho.c (macho_write_section): Don't add
        section offset to the symbol to be relocated.
        (add_reloc): Update comment.
2005-12-05 23:17:17 +00:00
Eric Christopher
a485fbdd37 Added section attributes, in particular S_ATTR_SOME_INSTRUCTIONS and update .text.
Change symbols from saa to explicitly allocated.
macho_layout_symbols: new function to sort symbols and renumber.
adjust symtab output accordingly
fixup relocs after renumbering
add relocation debugging routines.
2005-10-07 22:30:56 +00:00
Eric Christopher
d3179b6ce0 Break macho_cleanup into separate functions. 2005-09-26 22:13:42 +00:00
Eric Christopher
5508a4c7fc Run misc/Nindent on outmacho.c 2005-09-22 21:41:17 +00:00
Eric Christopher
1b8a72ae7c Add basic support for Mach-O file format. 2005-09-22 21:22:33 +00:00