Commit Graph

544 Commits

Author SHA1 Message Date
Cyrill Gorcunov
a4f98b3aab Merge branch 'nasm-2.09.xx'
Conflicts:
	nasm.h
	version

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-04-06 19:12:17 +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
Keith Kanios
e3f4780665 output/outbin.c: initialize section align/start attributes upon creation 2011-02-28 09:49:04 +03:00
Cyrill Gorcunov
befc631d04 elf64: Use nasm_zalloc helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 09:45:43 +03:00
Cyrill Gorcunov
efc249d8fc outelf32: Use nasm_zalloc helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 09:40:43 +03:00
Cyrill Gorcunov
b4af1ac765 outcoff: Use nasm_zalloc helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 09:33:08 +03:00
Cyrill Gorcunov
c13deef255 bin: Use nasm_zalloc for default section creation
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 09:28:25 +03:00
Cyrill Gorcunov
3bc3ff2fb6 bin: Use nasm_zalloc helper for section allocation in a sake of simplicity
Instead of opencoded zero assignments better to use nasm_zalloc
and set fields which are supposed to be non-nil. This simplifies
code and makes it more readable.

Also note the field 'ifollows' renamed to 'prev' as it should
be from the very beginning in terms of lists.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 01:26:24 +03:00
Keith Kanios
11db774a15 output/outbin.c: initialize section align/start attributes upon creation 2011-02-27 13:14:32 -06:00
Cyrill Gorcunov
cb9a459560 coff: Handle massive relocations
The backport of

4db724fdd7
359b63f897
01102ee8e6
2672af7379

so coff output target to be able to handle
massive relocations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-20 14:18:23 +03:00
Cyrill Gorcunov
2672af7379 coff: Cover 'else' with cond compilation
It was a nit in first place.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-07 01:09:36 +03:00
Cyrill Gorcunov
01102ee8e6 coff: Handle massive relocations
In case if relocations number exceed 16bit values
we have to hande such case by a special way, as described
in COFF specification.

 "IMAGE_SCN_LNK_NRELOC_OVFL indicates that the count of
relocations for the section exceeds the 16 bits that are
reserved for it in the section header. If the bit is set
and the NumberOfRelocations field in the section header
is 0xffff, the actual relocation count is stored in the
32-bit VirtualAddress field of the first relocation. It
is an error if IMAGE_SCN_LNK_NRELOC_OVFL is set and
there are fewer than 0xffff relocations in the section."

[ BR3092924 ]

Reported-by: Robert Yates
Investigated-by: nasm64developer
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 18:38:00 +03:00
Cyrill Gorcunov
359b63f897 coff: Issue fatal signal on relocations more then 0xffff
Actually it's temporary action. We have to support more
relocations then that but it requires some more code rework.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-06 02:45:45 +03:00
Cyrill Gorcunov
4db724fdd7 coff: Add IMAGE_SCN_MAX_RELOC constant
We will need it to analyze if section relocations
are overflowed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-05 13:50:04 +03:00
Cyrill Gorcunov
2c157002f2 BR3079550: NASM crash on run-time for OMF output format
We could have accessed malloc'ed data on external symbols
in obj and ieee output formats. Fix it by using nasm_zalloc.

Reported-by: Jiri Malak
Patch-by: Jiri Malak
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-27 21:41:11 +04:00
Cyrill Gorcunov
9e8f0ac460 BR3079550: NASM crash on run-time for OMF output format
We could have accessed malloc'ed data on external symbols
in obj and ieee output formats. Fix it by using nasm_zalloc.

Reported-by: Jiri Malak
Patch-by: Jiri Malak
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-10-02 01:21:00 +04:00
Cyrill Gorcunov
d7b654c73d elf: Move stabs symbol table format into outelf.h
Get rid of code duplication

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-07-30 00:51:44 +04:00
Cyrill Gorcunov
4cc1064328 outbin: Cleanup bin_cleanup
No need for 'q' variable.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-07-06 19:40:02 +04:00
Cyrill Gorcunov
faf23d1302 outbin: Simplify reverse address computing
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-07-06 19:08:28 +04:00
Cyrill Gorcunov
2b416c9def BR3025702: outbin -- Fix byte ordering
In commit 55ae12052c we occasionally broke byte ordering. Fix it.
Note that current stable version 2.08.01 is not affected by this bug.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-07-06 18:33:29 +04:00
H. Peter Anvin
5e2e8b9105 Rename filenames to 8.3 format
Apparently some people still care about compiling native on MS-DOS,
and we don't have a significant number of files which need adjustment.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-06-15 10:47:16 -07:00
H. Peter Anvin
b714cb27cb outobj: handle compilers without 64-bit switch() support
OpenWatcom, in particular, doesn't handle switch() statements with
64-bit expressions, sigh.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-06-07 11:34:28 -07:00
H. Peter Anvin
4dff757ba5 outelf32: handle compilers without 64-bit switch() support
OpenWatcom, in particular, doesn't handle switch() statements with
64-bit expressions, sigh.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-06-07 11:26:11 -07:00
Cyrill Gorcunov
a731924978 nasmlib: Rename elements() macro to ARRAY_SIZE
ARRAY_SIZE is a well known name pointing out that
we're dealing with array in macro argument.

Also to be on a safe side prefix_name helper should
check the index been in bounds more precisely.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-06-03 23:17:21 +04:00
H. Peter Anvin
62de275527 outobj: update error message
The possible sizes we can encounter are 1, 2, 4, 8... make sure we get
a proper error message.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-05-06 17:58:46 -07:00
H. Peter Anvin
931ce775cf outobj: properly error on unsupported relocations
Error out on any relocations not supported by the backend.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-05-06 17:52:57 -07:00
H. Peter Anvin
bce369022a outelf64: update copyright date
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-05-06 17:45:39 -07:00
H. Peter Anvin
32575e46ac ELF support for 8-bit relocations
Support 8-bit relocations (OUT_ADDRESS and OUT_REL1ADR) in ELF.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-05-06 16:14:00 -07:00
H. Peter Anvin
55ae12052c Add support for one-byte relocations
Add OUT_REL1ADR (one-byte relative address) and support for
OUT_ADDRESs with size == 1.  Add support for it in
outbin and outdbg.  *It still needs to be added to other backends*,
both the OUT_REL*ADR and OUT_ADDRESS codepaths need to be handled.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-05-06 15:33:24 -07:00
Cyrill Gorcunov
97ec06a16a MachO: Fix misprinted macho_sectalign
macho_sectalign was occasionally misprinted
with macho_setcalign, fix it. No change on functionality.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-28 23:17:13 +04:00
Cyrill Gorcunov
a20b668add obj: Implement sectalign helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-25 22:00:15 +04:00
Cyrill Gorcunov
573d25fe92 macho: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-25 21:35:09 +04:00
Cyrill Gorcunov
9868bfe80f ieee: Fix section index match in sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-25 17:55:52 +04:00
Cyrill Gorcunov
b9fd67b38e outieee: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-25 01:17:11 +04:00
Cyrill Gorcunov
bb196d4fd3 outbin: Drop current_section variable
There is no need for it anymore.

Reported-by: "H. Peter Anvin" <hpa@linux.intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 22:32:17 +04:00
Cyrill Gorcunov
4c45e83aac outbin: Prune ancient format_mode variable
format_mode is always set to 1 so there is no need to
keep this variable. "Old chicken bit" (c) :)

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 22:25:55 +04:00
Cyrill Gorcunov
630f221b01 bin: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:06:29 +04:00
Cyrill Gorcunov
279d8f146a coff: Use IMAGE_SCN_ALIGN_MASK macro
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:06:14 +04:00
Cyrill Gorcunov
3834305507 coff: Allow alignment greater then 64 bytes on win
On win32/64 we have no 64 bytes limit so hit it on
"coff" target only.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:06:03 +04:00
Cyrill Gorcunov
7c8c258cdd coff: Fix section alignment computation
Section alignment is broken due to not being
direct "align -> power of two set" mapping but
rather including second addition operation.

Fix it by introducing coff_sectalign_flags helper.
This also allow us to use this helper for getting
rid of open coded computation as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:05:50 +04:00
Cyrill Gorcunov
42017a6115 coff: Use predefined macros instead of numbers and style fix
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:03:56 +04:00
Cyrill Gorcunov
557a57bd55 pecoff.h: Complete header
Put in all constants pecoff v8 states. Most probably we
will never need most of them but lets have them here for
completeness.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:02:22 +04:00
H. Peter Anvin
35c30da61b Remove open-coded ilog2() implementations
When we need integer log2, use the new library routine.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-21 16:46:57 -07:00
Cyrill Gorcunov
83ffe8ca24 coff: Use predefined macro in common section flags
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 22:40:11 +04:00
Cyrill Gorcunov
d0c6dbe0fe coff: Use predefined macro and eliminate open coded constants
Not all are covered but process initiated.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 22:03:33 +04:00
Cyrill Gorcunov
d71d876f46 pecoff.h: Add more constants
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 21:47:03 +04:00
Cyrill Gorcunov
2ece71588c pecoff: Update machine types
Update up to pecoff v8

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:46:27 +04:00
Cyrill Gorcunov
8906629f4f output: Introduce pecoff.h
Better to have common constants grouped.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:10:04 +04:00
Cyrill Gorcunov
f8dc028c07 coff: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:10:00 +04:00
Cyrill Gorcunov
2ef5c27be7 Rename SEGALIGN to SECTALIGN
"sectalign" is preferred over "segalign"
since it operates over section attributes.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:09:54 +04:00
Cyrill Gorcunov
c56a7a2c82 Elf64: Implement segalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:15:28 +04:00
Cyrill Gorcunov
f68feb08c2 Elf-32: Implement segalign handling
Via elf_segalign helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:09:02 +04:00
Cyrill Gorcunov
2a587ab1c9 ofmt: Implement null_segalign stubs
Set stubs for all targets

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:08:36 +04:00
Cyrill Gorcunov
d807d911fe Elf: Rename SEG_ALIGN to SEC_FILEALIGN
It's Elf specifics. To not mess with segment alignment.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:44 +04:00
Cyrill Gorcunov
8d4d060104 Add "win" alias for "win32" output format
We already have "elf" and "macho" aliases for respective
32 bit output formats. Make the same for "win32" in a
sake of consistency.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:36 +04:00
Cyrill Gorcunov
ba3c0513dd Elf: switch section_attrib to a new nasm_opt_val interface
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11 13:12:20 +04:00
Cyrill Gorcunov
c084467eba Elf: Use SHA_ANY constant instead of open coded number
SHA_ANY is not part of Elf specification but rather our own symbolic
definition for convenience.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11 12:58:05 +04:00
Cyrill Gorcunov
6837749d85 ofmt: Introduce output format aliases
This allow us to keep compatibility layer without
needing the separated struct ofmt for this and
elf_init_hack routine.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:11:00 +04:00
Cyrill Gorcunov
f134cc63da Elf: Some unification snippets for 32/64 bit versions
Nothing serious, comments and style movements.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:38 +04:00
Cyrill Gorcunov
e3c4791300 Elf: Merge WRITE_STAB to outelf.h
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:20 +04:00
Cyrill Gorcunov
6620d1aa6d Elf: Drop never used SOC helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:07 +04:00
Cyrill Gorcunov
572dd0021c Elf: Introduce section_attrib helper
In a sake of removing code duplication.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:02:38 +04:00
Cyrill Gorcunov
6fe313a719 output/outbin.c: Fix misprinted alignment bound
Due to a misprint in commit
9b66d8e4c3

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:49:58 +03:00
Cyrill Gorcunov
3cbd9e7215 Elf: Drop useless SEG_ALIGN_1
No need for SEG_ALIGN_1 since we have switched
to ALIGN helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:28:34 +03:00
Cyrill Gorcunov
9b66d8e4c3 Use ALIGN helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:28:30 +03:00
Cyrill Gorcunov
a135658e83 ELF: Explicitly point out SYM_GLOBAL, SYM_LOCAL binding
Instead of implicit declaration of global symbols obtained
by STB_GLOBAL << 4, and local symbols by STB_LOCAL << 4
use ELF32_ST_MKBIND helpers.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:46 +03:00
Cyrill Gorcunov
de623f2679 elf.h: Add ELFXX_ST_MKBIND and move ELFXX_ST_ helpers
The profit of ELFXX_ST_MKBIND helper is that we
will use it for SYM_GLOBAL explicitly pointing
out from where this magic 0x10 came from.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:41 +03:00
Cyrill Gorcunov
126faf2e3b output/outelfX.c: Use definitions from stabs.h
Also made Makefile.in to handle dependency.
There are some makefiles in Mkfiles\ should
be fixed as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:36 +03:00
Cyrill Gorcunov
d1428b23da Add common STABs definition into output/stabs.h
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:31 +03:00
Cyrill Gorcunov
c9862c009b outelfX.c: Trivial cleanup
Some tab\space convertions together with
trivial style nitfix.

No change on binary level.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:26 +03:00
Cyrill Gorcunov
3b4c769d99 Elf: Allow symbols binding to undefined section
Commit 2ddcd03900
did bind symbols (in case of omitted SECTION directive)
to .text section but break COMMON binding.
Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-02 23:00:43 +03:00
Cyrill Gorcunov
2ddcd03900 Elf: bind labels to text section by default
In case if SECTION directive is omitted but the real
code exist we form .text section by default and put compiled
code here. In turn labels are not handled in a same manner.

So lets bind them to text section by default as well.

[ BR: 2835192 ]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-12-10 00:36:37 +03:00
H. Peter Anvin
3c9d7ea8a6 outrdf.c: remove obsolete file
The old RDF format has been unsupported for long time now.  Remove it
from the tree.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-11-30 13:27:49 -08:00
H. Peter Anvin
3b861a7766 outform.h: fix OF_NO_RDF2
OF_NO_RDF2 should turn off OF_RDF2, not OF_RDF

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-11-30 13:26:34 -08:00
H. Peter Anvin
b512fb56db outmacho32: replace error() -> nasm_error()
Somehow outmacho32.c escaped the global change of error variables to
hard-coded nasm_error().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-11-30 11:27:47 -08:00
Cyrill Gorcunov
bc0113d977 outcoff: BuildExportTable -- tab/space fix
Due to previous commit an indent by tab (occasionally) brought in.
Fix it as well. No change on binary level.

We're not that far from NASM release so it's a bit unpleasant
manner to push in such trivial change. But since it's the previous
commit dependent -- I dare to push it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-17 23:25:15 +03:00
Cyrill Gorcunov
bf8cebd813 outcoff: Do not fail on long export identifiers
If an export identifier is greater then 241 symbols
we do fail due to buffer overflow. Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-17 20:49:58 +03:00
Cyrill Gorcunov
2e7a84b829 outelf32/64 - various cleanups in a sake of unification
Make a small step forward elf32/64 unification procedure.
Mostly style fixes. Nothing serious.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:59 +03:00
Cyrill Gorcunov
b15ed1f836 dwarfX_output: dont check for "ln" twice
And make dwarf64 version to be more familiar to
32bit version (preparation work for merge).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:54 +03:00
Cyrill Gorcunov
24f9398a6f output/outelf64.c: simplify stabs64_cleanup, dwarf64_cleanup
nasm_free is failsafe against NULL passed

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:49 +03:00
Cyrill Gorcunov
a50f829435 Merge elf header files
Merge elfcommon.h, elf32.h, elf64.h into
single elf.h -- we do support both elf32
and elf64 anyway. Let put them into common
place.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:41 +03:00
Cyrill Gorcunov
a353955a8d output/outelf32-64: use string helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31 20:03:29 +03:00
Cyrill Gorcunov
54e94a56e2 Remove outdated comments
From Frank Kotler:
| ...
| > -                stdscan_bufptr = saveme;        /* bugfix? fbk 8/10/00 */
| > +                stdscan_set(saveme);            /* bugfix? fbk 8/10/00 */
|
| While you're at it, you could remove my comment(s - it seems to have
| reproduced). It *is* a bugfix (apparently). "saveme" might have a better
| name, too...

So get rid of the comments.

Reported-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31 20:03:14 +03:00
Cyrill Gorcunov
917117ff69 stdscan: switch to stdscan_get/set routines
Instead of manipulating stdscan buffer pointer directly
we switch to a routine interface.

This allow us to unify stdscan access: ie caller should
"talk" to stdscan via stdscan_get/set routines.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31 20:02:43 +03:00
Keith Kanios
d2a553c072 BR 2840300: fix macho symbol alignment bug 2009-10-16 21:53:59 -05:00
Cyrill Gorcunov
69c4f63c25 elf,stabs: stabs32/64_generate -- append ending token
This represent "end of compilation unit" token.
Since gcc does (almost) the same lets be on the
same side.

Though to be precise gcc puts offset which points
to the first byte right after the last instruction
issued but in fact string index is analyzed only
so we may safely write zero here (without relocation
as well).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-14 22:43:30 +04:00
Cyrill Gorcunov
28032a027c output/elfcommon.h: tab/space cleanup
No change on binary level

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-06 15:25:35 +04:00
Cyrill Gorcunov
7ea1ef1c84 output/outelf32.c: code style simplification
1) nasm_free is safe against NULL passed so call
   it without test

2) dwarf32_output: check for debug_immcall early
   and get out of procedure if success. This allow
   us to move code blocks left removing indents.

3) dwarf32_findfile and dwarf32_findsect: no need
   for 'else' when 'if' target is plain return.
   Move code blocks left removing indents.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 20:16:28 +04:00
Cyrill Gorcunov
6ae5903676 output/outelf32.c: tab-space cleanup
Together with a small style nitpicking.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 20:02:33 +04:00
Cyrill Gorcunov
82a440da6d output/elf64.h: tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:10:55 +04:00
Cyrill Gorcunov
c5e7878943 output/elf32.h: tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:06:04 +04:00
Cyrill Gorcunov
2cff224e4b output/outelf.h - tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:04:23 +04:00
Victor van den Elzen
0dd450c0ef Use fputs instead of fprintf for plain strings
LLVM's Clang warns about this. outieee.c had a real problem.
2009-08-13 15:07:59 +02:00
Victor van den Elzen
15bb233036 Fix some format strings for nasm_error
Added a format attribute to nasm_error (only for GCC) and
used the resulting warnings to fix some format strings.
2009-08-11 02:43:41 +02:00
Cyrill Gorcunov
5a49e7c578 output/dwarf.h: update dwarf constants
There is a hope we'll be supporting dwarf in full form in future. So
I've encoded the standard constants (though binutils uses some
additional codes).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-10 16:00:43 -07:00
H. Peter Anvin
767750b666 output: change null_debug_routine to null_debug_directive
This is the null implementation of the function debug_directive.  For
some reason it ended up getting mangled as "null_debug_routine".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-09 13:04:13 -07:00
Cyrill Gorcunov
6f742649fe output/outbin.c -- use list helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-01 23:52:25 +04:00
Cyrill Gorcunov
a95a76a868 outaout.c -- use list helpers
Note that we use list_for_each(var,var) sometime
which actually brings in at least one redundant
assignment in case of NULL being passed but save
us a few lines of code.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-28 23:26:12 +04:00
H. Peter Anvin
e39dc8c5b2 Merge branch 'nasm-2.07.xx' 2009-07-26 15:31:59 -07:00
H. Peter Anvin
7ad24562dc BR 2827397: fix invalid C in outcoff AddExports()
The construct:

         if (i == nsects)
             directive_sec =
                 sects[coff_make_section
                       (EXPORT_SECTION_NAME, EXPORT_SECTION_FLAGS)];

... where coff_make_section() can change the global variable "sects"
is undefined C, since there is no sequence point involved in the []
operator, and it is therefore fully permitted for the C compiler to
read the sects variable first.  Change this construct into two
statements to enforce defined behavior; this also ends up with the
code slightly simpler.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-26 15:29:09 -07:00
H. Peter Anvin
605f5155ee Drop the ofmt and errfunc arguments to label definition functions
We never set ofmt and errfunc to anything but the global values.
Dropping them from the label definition function command line
simplifies the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:43:58 -07:00
H. Peter Anvin
9bd1506d59 Remove function pointers in output, simplify error handling
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value.  Also make "ofile" a global
variable and let the backend use it directly.

All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.

Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally.  That lets us
use direct calls to it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-18 18:43:12 -07:00
H. Peter Anvin
159178f2aa Merge commit 'nasm-2.07rc7' into new-preproc 2009-07-17 00:55:17 -04:00
H. Peter Anvin
a5fd1ca895 outcoff: fix invalid reference to ofmt
ofmt is a static in nasm.c (why?), not a global...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:46:34 -04:00
H. Peter Anvin
d1904c6cbb outcoff: this is COFF, not binary
Fix error message in outcoff to say COFF, not binary format...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:44:19 -04:00
Keith Kanios
e5b9d2dac0 outform.h: update comments regarding macho32/macho64 2009-07-16 21:13:10 -05:00
H. Peter Anvin
68bec0872f outobj: don't fclose() the output
Missed fclose() in outobj when converting system to global fclose().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:47:04 -04:00
H. Peter Anvin
340ee009d6 Merge branch 'master' into new-preproc
Conflicts:
	.gitignore
2009-07-13 21:41:33 -04:00
H. Peter Anvin
2a3154c4d3 ELF: add debug support for TY_YWORD
Add debug support for TY_YWORD (256 bits/32 bytes).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 21:25:36 -04:00
Cyrill Gorcunov
e3042cb103 elf32: debug32_typevalue - fix TY_OWORD size
TY_OWORD is 8 * TY_WORD = 16 bytes length

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-13 17:19:21 -04:00
H. Peter Anvin
afa06137fa Hash even backend-specific directives, unify null functions
Hash all directives, even the ones that are backend-specific,
and instead pass the backend an already-parsed directive number.

Furthermore, unify null functions across various backends.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-12 12:55:24 -07:00
H. Peter Anvin
d0fbb7f0ab Don't fclose() the output in the backend
We fopen() the output file in common code but fclose() it in the
backend.  This is bad for a variety of reasons:

1. it is generally an awkward interface to change ownership.
2. we should use ferror() to test for write errors, and that is
   better done in common code.
3. it requires more code.
4. we still need to fclose() in common code during error handing.

Thus, move the fclose() of the output out of the backends, and add
fflush() so we can test ferror() on output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-12 12:15:35 -07:00
Keith Kanios
6d0d0d2736 macho64: Manually merge macho64 branch with master branch. 2009-07-08 23:04:52 -05:00
Keith Kanios
745560e65a outmacho.c: fix section/relocation alignment issue 2009-07-07 23:09:22 -05:00
H. Peter Anvin
5bc87609d2 outdbg: be excrutiatingly correct...
outdbg is actually a good starting point to make a new backend, so we
really should endeavor to make it do things "right".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 10:27:51 -07:00
H. Peter Anvin
62c0e8379c outdbg: fix OUT_REL*ADR, add OUT_REL8ADR
The OUT_REL*ADR types pass a pointer which points to an int64_t
which then should be truncated down to size.  This matters on
bigendian platforms.

Add OUT_REL8ADR.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-07 10:24:52 -07:00
H. Peter Anvin
215086ace8 outbin: be consistent in spelling "Intel hex" with those caps
The documentation uses "Intel hex", with that capitalization (Intel
being a proper noun, hex being descriptive) so make the help message
match.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06 23:37:00 -07:00
Keith Kanios
5051c63d7e outmacho: fixed section/relocation alignment issue 2009-07-06 21:07:15 -05:00
H. Peter Anvin
8ee2e244eb NASM: relicense under the 2-clause BSD license
*To the best of my knowledge*, we now have authorization from everyone
who has significantly contributed to NASM in the past.  As such,
change the license to the 2-clause BSD license.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06 11:09:11 -07:00
H. Peter Anvin
0bc3bf61db outbin: minor cleanups
- add assert so we don't try to write 2^64 bytes of zero
- explicitly track the Intel hex "LBA" (64K page) instead of playing
  games with the last byte written.  This way it is more explicit
  what we're doing and why.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06 10:58:37 -07:00
H. Peter Anvin
ffe782a322 outbin: when using saa_rnbytes() we have to saa_rewind()
Using saa_fpwrite() to dump a section to a file automatically does
saa_rewind(), but if we use saa_rnbytes() to do bit by bit then we
manually need to to saa_rewind() before we start.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-05 15:40:45 -07:00
H. Peter Anvin
31f336183c outbin: when writing S-records, write head record
When writing S-record output, we should write the head record (S0),
too.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-05 15:32:14 -07:00
H. Peter Anvin
4660a2b4a0 outbin: add support for Intel hex and Motorola S-records
Add support for directly generating Intel hex or Motorola S-records.
These formats are commonly used with ROM burners.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-05 15:29:55 -07:00
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
d3544ff534 outobj: handle the case of SEG <undefined> in pass 0
SEG <undefined> can happen, validly, for a common symbol during the
optimization passes.  It better not happen during the real passes,
however!

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-01 22:04:11 -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
Cyrill Gorcunov
2118261e1a ELF64: fix incorrect type for the .strtab section header
The .strtab section is SHT_STRTAB, not SHT_SYMTAB.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-30 14:09:39 -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
b45b21b411 Add copyright headers to macro files
These are definitely overly restrictive, need auditing to pare them
down to proper BSD licensing.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 17:16:54 -07:00
H. Peter Anvin
69925e5b78 Move prototypes for null_debug to outform.h and outlib.h
Move the prototypes for the null debugging format to outform.h (for
the top-level structure declaration only) and outlib.h (for the
internal routines.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27 22:15:25 -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
2b1f51f1ca debug: make *all* the null debug routines available as a library
Make all the null debug routines available as a library, so we can use
them whenever appropriate.  We really don't need to have a bunch of
dummy functions scattered all over the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27 21:58:21 -07:00
H. Peter Anvin
2d115448b4 output: call debug init from a central location
We already call current_dfmt->init in the same place (at the very end
of ofmt->init) in all the backends that do it; instead call it
centrally in nasm.c after ofmt->init.

This fixes invalid ELF files with when compiling with -F dwarf, since
the dwarf initialization routine never got called.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27 21:55:31 -07:00
H. Peter Anvin
0638193769 outelf.c: add appropriate #ifdefs
Only build outelf.c if ELF32 or ELF64 is included.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27 21:10:09 -07:00
H. Peter Anvin
28abe7ada5 outdbg: make outdbg.c compile cleanly
Make outdbg.c compile cleanly again.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27 21:05:42 -07:00
H. Peter Anvin
a564a02788 ELF: make debugging functions static
The debugging functions can and should all be static.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 17:43:54 -07:00
H. Peter Anvin
ca2a788edf ELF: remove loop invariant calculation of global offset
The global symbol offset is a loop invariant; no need to compute it
over and over.  The compiler probably will not be able to do this for
us due to global variables and function calls.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 17:30:58 -07:00
H. Peter Anvin
559d936ad7 ELF: clean up the arithmetic for global symbols
Clean up the arithmetic for global symbols; in particular, make it
clear where the dependency on the debug format comes from (DWARF needs
three symbol table entries all by itself.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 17:26:43 -07:00
H. Peter Anvin
3716238058 ELF: bump GLOBAL_TEMP_BASE
Bump GLOBAL_TEMP_BASE so far that it *cannot* conflict for ELF32
(which has 24-bit symbol table indicies) and is *unlikely* to conflict
for ELF64 (which has 32-bit symbol table indicies.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 17:25:35 -07:00
H. Peter Anvin
c4471462dc ELF: eliminate hard-coded section numbers
Eliminiate hard-coded section numbers, at least to the best of our
ability.  There is still a very odd piece of computation in
elf_build_reltab() which I can't really figure out...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 14:54:44 -07:00
H. Peter Anvin
1acf6ba822 Handle the new ELF headers in the dependency generation
The dependency machinery relies on properly rooted includes, so give
it to them... the path syntax munging machinery in the dependency
script handles it from a Makefile syntax perspective, and then we can
hope that C compilers are smart enough to deal with forward-slash
paths even when that is not the native syntax.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 13:06:49 -07:00
H. Peter Anvin
d219a3e46f ELF: add header files, begin merging common code, drop .comment
Add something approaching real ELF header files.

Begin merging the common ELF code, beginning with the section name
detection.

Drop automatic generation of .comment section, and in particular the
treatment of .common as a special section (if we decide generating
.comment is still a good idea, we should just do it as a macro.)

Augment the list of known sections, and make it table-driven.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 12:30:50 -07:00
H. Peter Anvin
34c768fcc5 outbin: replace fprintf(rf, not_defined); with fputs(not_defined, rf);
Some vendors get nervous about parameterized printf patterns;
furthermore, it's completely unnecessary in this case.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-04-30 08:06:25 -07:00
Andy Polyakov
08ced1d5b4 outcoff: BR 2685756: fix SAFESEH with an internal symbol
Fix the SAFESEH directive for the specific case of a symbol internal
to the program.  With the optimizer enabled, it would otherwise fail
unless the symbol is external.
2009-03-18 14:49:23 -07:00
Michael Scherer
92cb18f2a8 outelf32/64: fix uninitialized rbtree
Fix crash caused by uninitialised memory that lead to dangling pointer
in the rbtree. This can be seen by compiling zsnes 1.50, with a file
that define many symbols, such as fxemu2c.asm.
2009-03-18 14:47:33 -07:00
H. Peter Anvin
577f57614a outelf32/64: remove align_str in favor of fwritezero()
Drop the use of yet another local all-zero buffer, align_str, in favor
of calling fwritezero().
2009-02-21 17:27:51 -08:00
H. Peter Anvin
a5c2455f8a outbin: fix typo: "sections" not "section"
Fix silly typo: the variable is "sections" not "section"...
2009-02-21 17:27:13 -08: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
H. Peter Anvin
04616f4e85 BR 2611906: proper error message for start < origin
When a section other than .text has a start < origin, we would
segfault; fix that.

Furthermore, at bin_cleanup() we don't have usable file/line
information, so pass ERR_NOFILE to the error() function.  Perhaps less
than ideal, but better than printing a null pointer.
2009-02-21 17:19:05 -08:00
Charles Crayne
cc88d658ce Generate warning for unknown section atributes
Previously, the ELF backends silently ignored incorrect or unknown
attributes on section declarations, and therefore used default values
in cases where the user had make an error in attempting to specify
custom values.
2009-01-18 15:27:03 -08:00
H. Peter Anvin
f5fb723495 outas86: slight stylistic cleanups
Minor stylistic cleanups to previous patch.
2009-01-03 17:56:41 -08:00
Soronel Haetir
e07949dc3f Add entry point support to as86 backend
I needed entry point support with the as86 format, and after looking through
the archives found a similar desire from someone in 2002.  For some reason
such a patch never made it into the code, even though the required flag
value is present, so I offer the a patch of my own.

I compared against what is done in the .obj format and the approaches are
quite similar which I hope will aid in its acceptability.  While I have
tested it extensively it does do the job asked, and I'm honestly not sure
what extensive testing of the change would look like.
2009-01-03 17:54:48 -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
1fee7d2d23 ELF: use rbtree for symbol searches
Linear searches are evil, so use an llrbtree to search for symbols by
offset.  This doesn't change the preexisting behaviour that we only
look for global symbols.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-11-06 19:55:05 -08:00
Victor van den Elzen
f568613c2a Fix BR #916647
nasm.c should respect the default debug format of the output format,
instead of replacing it with the first format in the list.
This is cleaner and allows the list to be sorted normally.

This commit rewrites commit 116994111b which was very fragile.
2008-11-05 14:19:15 +01:00
Charles Crayne
5fb6a39bc9 ELF32 support for offset to IE GOT entry
Add new WRT type ..tlsie.
Generate R_386_TLS_IE relocation entries
for references to thread local variables.
2008-11-01 16:48:31 -07:00
H. Peter Anvin
4b9358928b Move all version strings to a single compilation unit (ver.c)
Move all the version strings to a single compilation unit, ver.c; this
does not include the version macros, which are fed into macros.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-31 16:53:49 -07:00
Charles Crayne
dcd3a21145 ELF32 bit support of .tdata and .tbss sections
Set default attributes for .tdata and .tbss sections
Implement new attribute 'tls' for arbitrary section names
Flag variables in sections with tls attribute with STT_TLS
2008-10-30 21:59:42 -07: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
Charles Crayne
10a863d87e ELF64 support for PC relative offset to IE GOT entry
Add new WRT type ..gottpoff.
Generate R_X86_64_GOTTPOFF relocation entries
for references to thread local variables.
2008-10-26 17:32:38 -07:00
Charles Crayne
efb515b98e Flag thread local symbols in symbol table
Set STT_TLS in symbol table for symbols declared
in thread local storage sections. Note that,
for now at least, such symbols must also be
declared as GLOBAL.
2008-10-25 19:31:09 -07:00
Charles Crayne
4adf21c08c ELF64 segment definitions for TLS
Add default definitions for .tdata & .tbss sections
Add definition for SHF_TLS section header flag
Add support for "tls" keyword on section statement
2008-10-25 15:23:30 -07:00
H. Peter Anvin
9cd543e5fd BR 2148448: fix relative addresses in bin output
The "bin" format was misinterpreting the overloading of the "size"
argument to out(), which caused another source of 64-bit relative
offset errors.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-22 11:05:43 -07:00
H. Peter Anvin
21da3006b5 ELF64: once again, fix generation of "naked" OUT_REL*ADR
It is unclear if we will ever see any "naked" (absolute bytes)
OUT_REL*ADR coming from the assembler, but if we do, we should
generate them correctly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-18 11:29:11 -07:00
H. Peter Anvin
2a282275fe ELF64: PLT32, GOTPCREL, and GOTPCREL64 really need exactitude
Now when the assembler is properly generating the address that we push
down to the backend, enable requesting an exact value for these
relocations (these are pointing to a specific GOT or PLT slot; the
addend is used to adjust the computed value in the instruction, not
for offset for the symbol.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 23:32:40 -07:00
H. Peter Anvin
7f1315070e ELF64: the "size" argument to OUT_REL*ADR isn't really the size
The "size" argument to the OUT_REL*ADR output types is actually
intra-instruction offset, not the actual size.  Thus, emit the size
properly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 23:30:54 -07:00
H. Peter Anvin
d5e7498556 ELF64: actually generate relative GOT/PLT references correctly
Fix the arithmetic for relative GOT/PLT references.

We still can't enable exactitude, because of the assumption that
"size" is always the proper adjustment for the offset of the
displacement inside the instruction, which is wrong in the case of
displacements that are followed by an immediate.  This also affects
the list file, so it really should be fixed.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 23:06:46 -07:00
H. Peter Anvin
8218572d5e ELF64: GOTOFF64 doesn't need a gsym at all
GOTOFF64 is used for local variables (as a 64-bit offset from the GOT;
only needed in the Medium PIC or Large PIC models.)  It therefore
should *not* be a elf_add_gsym_reloc() invocation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 22:22:17 -07:00
H. Peter Anvin
bdfd3b3b87 ELF64: We apparently don't need exactitude for GOTOFF64
I am having a bit of a hard time understanding the proper operation of
the "exact" flag to elf_add_gsym_reloc().  We apparently won't
generate proper GOTOFF64 relocations with this flag set; it is
possible that there are *no* proper uses of this flag.  This clearly
needs to be figured out.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 22:11:20 -07:00
H. Peter Anvin
70e6c2a6cb ELF64: GOT and PLT references need a symbol (a slot!) to reference
GOT and PLT references need a symbol; after all, they reference a GOT
or PLT slot.  Thus, they need elf_add_gsym_reloc().  Mungify the
interface so that they can communicate the need for the PC-shifted
offset into the relocation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 20:01:16 -07:00
H. Peter Anvin
8140afbaf1 ELF64: unbreak generating no-segment addresses
When generating an address that is *not* tied to a symbol, we just
want to emit the bytes.  I believe the assembler is already supposed
to do that for us, but just in case, do it right here too.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 19:32:10 -07:00
H. Peter Anvin
64fa04f019 ELF64: use the RELA addend field instead of relying on the code stream
The x86-64 ABI wants the symbol addend to reside in the addend field
of the RELA relocation, not in the code stream.  Apparently it's
something one can get away with, but the linker would still botch it
for some cases.  Change it so we pass the proper output and emit zero
into the code stream.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 18:23:29 -07:00
H. Peter Anvin
c3cea48430 ELF64: fix various GOT relocations
Try to make the various GOT relocations do the right thing in ELF64,
including erring out when appropriate.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-15 15:23:18 -07:00
Charles Crayne
154f6f2380 Fix typo in previous outelf64.c commit
Stray line fragment left in when removing debug code.
2008-10-12 14:14:45 -07:00
Charles Crayne
cff8dc6d6b RIP rel relocations for PIC released for testing.
Expressions like
  mov	r15,[rel integer wrt ..got]
  lea   rax,[rel integer wrt ..gotoff]
now assemble correctly.

In addition, a fix has been made to the corresponding
abs relocations.

Both of these areas still need additional testing.
2008-10-12 14:00:11 -07:00
H. Peter Anvin
5618e0063d outaout.mac: aoutb is an alias for aout
aoutb is an alias format for aout (in the sense they use the same
macro set.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-09 09:53:20 -07:00
H. Peter Anvin
c357381da4 macros: win32 and win64 are COFF, not Mach-O
Somehow the win32 and win64 aliases got listed on Mach-O, not on
COFF.  This doesn't have any effect on the current code, but might in
the future.  Correct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-09 09:37:37 -07:00
H. Peter Anvin
fafb6a50e2 outcoff: stylistic cleanups
Don't use explicit L's for things which are really size_t; not only is
it unnecessarily ugly, but it's wrong in a lot of ways.  Do some other
minor stylistic cleanups.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-02 12:56:39 -07:00
H. Peter Anvin
c00c897df7 outcoff: default output symbols to T_NULL
We would leave the output symbol type uninitialized.  Explicitly
initialize it to zero (T_NULL, meaning no symbol type information),
since that's what was effectively done.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-02 12:55:35 -07:00
Slavik Gnatenko
1b67bd25b2 BR 2010180: outobj: Garbage may be written in a last PUBDEF
The testcase illustrates the problem. After "nasm -f obj
alonesym.nasm"
let's look to dump:

======
PUBDEF386(91) recnum:5, offset:0000005bh, len:03f9h, chksum:bbh(bb)
Group: 0, Seg: 1
00020000h - 'sym0000' Type:0
00020004h - 'sym0001' Type:0
....
00020134h - 'sym0077' Type:0

PUBDEF(90) recnum:6, offset:00000457h, len:000ah, chksum:b6h(b6)
Group: 0, Seg: 1
00000138h - 's' Type:2
0000b600h - '' Type:0
======

The problem is while 's' offset is 20138h it is marked as type 90h not
91h.  The root cause is located in obj_x():

static ObjRecord *obj_x(ObjRecord * orp, uint32_t val)
{
    if (orp->type & 1)
    	orp->x_size = 32;
    if (val > 0xFFFF)
        orp = obj_force(orp, 32);
    if (orp->x_size == 32)
        return (obj_dword(orp, val));
    orp->x_size = 16;
    return (obj_word(orp, val));
}

It sets up x_size and than writes data. In the testcase data are the
offset and this offset overflows a record. In this case the record is
emitted and its x_size is cleared. Because this is last PUBDEF the new
record with only 's' symbol is emitted also but its x_size is not 32
(it's still zero) so obj_fwrite doesn't switch to 91h type.

The problem seems to be very generic and expected to be occurred on
many other record types as well.

        ----

And the fix is simple:

if (orp->x_size == 32)
{
  ObjRecord * nxt = obj_dword(orp, val);
  nxt->x_size = 32; /* x_size is cleared when a record overflows */
  return nxt;
}
2008-07-19 19:27:41 -07:00
H. Peter Anvin
bda7a6e371 ctype.h: wrapper ctype functions with a cast to (unsigned char)
ctype functions take an *int*, which the user is expected to have
taken the input character from getc() and friends, or taken a
character and cast it to (unsigned char).

We don't care about EOF (-1), so use macros that cast to (unsigned
char) for us.
2008-06-21 10:23:17 -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
Charles Crayne
842da0ad0b Correct X86_64 reference in dwarf support message 2008-06-11 16:15:01 -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
H. Peter Anvin
c735d1a6b2 Replace the WSAA macros with functions
Change the WSAA macros into functions; reducing the icache footprint.
2008-06-08 21:15:01 -07:00
H. Peter Anvin
cb38f505e4 WSAA: make the WSAA macros contain their own buffer
Make the WSAA macros contain their own buffer definitions.  This
eliminates the need to have a separate "workbuf" declared in the
outelf backends, which isn't even used for anything else, except for a
few completely redundant strcpys.

Note: these macros probably should be replaced with actual
functions.  The overhead of the function call is likely to be more
than offset by lower icache footprint.
2008-06-08 18:39:55 -07:00
Charles Crayne
2d900f5488 Avoid obscure segfault in DWARF generation
If DWARF debugging info is requested, and no section
is marked executable, output empty debug sections,
instead of allowing assembler to segfault.
2008-06-05 16:12:06 -07:00
Andy Polyakov
082dbb471f outcoff.c: remove dead code, add check for imagerel
Remove commented-out (dead) code, add check that the imagerel
references are valid.
2008-05-27 14:01:25 -07:00
Andy Polyakov
94cd4dd113 Win64: IMAGEREL references (SEH support for Win64)
Guess what, SEH again, but in Win64 context, which is completely
different matter from Win32. At lowest level this one boils down to
putting so called imagerel references, or in practical terms
relocations of type ADDR32NB, 0x0003, into .pdata and .xdata
segments. Two possibilities. 1. implement say 'wrt ..imagerel' or 'wrt
..imagebase'. 2. silently enforce ADDR32NB relocations in .pdata and
.xdata segments.
2008-05-23 19:45:39 -07:00
H. Peter Anvin
45b7431a0c Make SAFESEH syntax error ERR_NONFATAL
Incorrect use of SAFESEH is more suited for ERR_NONFATAL than ERR_FATAL
2008-05-23 18:38:51 -07:00
Andy Polyakov
4401cc79a2 Support for Win32 safeseh (BR 195417)
This is basically not a bug report, but a feature request.

It's desired to be able to link .obj modules compiled with 'nasm -f
win32' with Microsoft 'link /safeseh'. As well as to register symbols
(commonly subroutine's entry points or even external symbols) as "safe
handlers." In order to achieve this, several points are required.

First of all, object module has to have absolute symbol named @feat.00
with value of 1. This can actually be achived by adding 'absolute 1'
and '@feat.00:' to source code, but it's desirable that it's
autogenerated for win32 modules.

Handler registration is essentially symbol's *index* in current
module's symbol table in .sxdata, segment with 0x200 segment flags, an
"info" segment. It's also essential that symbol has type 0x20 (see
below). All this is depicted in following framgents of 'objdump -xD'
output:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .sxdata       00000004  00000000  00000000  0000003c  2**2
                  CONTENTS, READONLY, DEBUGGING

SYMBOL TABLE:
...
[  5](sec -1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000001 @feat.00
[  6](sec  0)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000000 _handler
...
<.sxdata>
0: 06 00 00 00

Note [6] and (ty 20) in _handle line in SYMBOL TABLE. "06 00 00 00" in
.sxdata is little-endian 6, _handler's index. This is what makes up
"registration." It's impossible to achieve this with current nasm
facilities and it's probably appropriate to introduce a directive for
it, 'safeseh _handler' is probably most natural choice.
2008-05-23 18:37:52 -07:00
H. Peter Anvin
72ec0e4144 Temporaries in macros need a unique prefix; WSAA*() macros to header
When using temporaries in macros, given them a unique prefix to avoid
namespace collisions when using one macro inside another.

Move the WSAA*() macros from outelf32/outelf64 to a separate header
file.
2008-04-10 14:56:09 -07:00
Charles Crayne
6f15b9884e Correctly identify dwarf support for elf32
Change architecture tag to i386.
2008-04-07 13:15:53 -07:00
Charles Crayne
aed5cfea58 Adjust symbol number for global symbols
Reloc entries were pointing to wrong target section
2008-03-04 14:25:34 -08:00
Charles Crayne
90131d500b Report dwarf as V2 for ELF32
Older versions of gdb reject version 3
2008-02-24 21:05:46 -08:00
Charles Crayne
225f82fa12 Dwarf3 support for ELF32
1. Port dwarf3 support from ELF64 to ELF32
2. Move common SAA extentions to nasmlib
2008-02-24 19:14:17 -08:00
Charles Crayne
986312b17a Dwarf support tweeks and clean-up
1. Add relocation entries for dwarf sections.
2. Combine common dwarf and stabs routines.
2008-02-23 18:35:11 -08:00
H. Peter Anvin
338a3b6882 Clear up WRITE macros causing compile failures with Watcom
The OpenWatcom compiler warns about invalid shifts (correctly, it
appears) due to the non-X86_MEMORY versions of the various WRITE
macros.  Fix.
2008-02-16 15:25:02 -08:00
Charles Crayne
f0b43d212e Upgrade dwarf3 support for elf64
Add support for multiple executable segments
2008-02-13 19:58:54 -08:00
Charles Crayne
978a25d3e9 Test version of dwarf debugging format for elf64
Not ready for prime time, but anyone who is interested
is welcome to help me test.
2008-02-06 22:17:55 -08:00
Charles Crayne
f3d2d41e06 Prevent segfault in stabs64_typevalue
Prevent segfault when type == STT_OBJECT and no symbol
has been defined.
2008-01-27 12:49:20 -08:00
Charles Crayne
730d6f821a Increase GLOBAL_TEMP_BASE
Increase GLOBAL_TEMP_BASE from 4096 to 1048576
2008-01-16 18:38:48 -08:00
Charles Crayne
4acfb4f44e Temporary fix for large number of sections
Increase GLOBAL_TEMP_BASE TO 4096
2008-01-11 17:22:19 -08:00
Beroset
095e6a2973 regularized spelling of license to match name of LICENSE file 2007-12-29 09:44:23 -05:00
Charles Crayne
116994111b Fix elf vs elf32 stabs generation bug
When invoked as -f elf -g, stabs info was not being generated.
2007-11-30 16:23:56 -08:00
H. Peter Anvin
682221438e Clean up remaining build warnings
Clean up remaining build warnings.  None of this should affect code
operations.  The only warnings which were actually relevant might have
been the ones in ldrdf.c, but it's not clear if anyone ever uses that.
2007-11-18 22:18:09 -08:00
H. Peter Anvin
604a3f4e21 outbin.c: fix one missed change from type -> size
Fix one missed change from "type" to "size".  May want to look through
all the other backends as well for similar issues.

This would generate the wrong section lengths, with obviously bad results.
2007-11-15 10:24:55 -08:00
root
dbb1828ad5 Support setting OSABI value in ELF header. 2007-11-13 19:52:54 -08:00
H. Peter Anvin
4095197f6c Cast 64-bit switch expressions to (int) to keep OpenWatcom happy
Our size arguments are 64-bit values, but we don't need that range for
anywhere where we need a switch.  OpenWatcom can't deal with them
(sigh), so cast them to (int) for now.
2007-11-13 09:49:51 -08: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
Charles Crayne
2321d930ec Clean up a few more 32-bit bottlenecks 2007-11-10 17:52:23 -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
Charles Crayne
d1cf2de1c0 Adjust stabs symbol index to match symbol table.
Add data length info to symbol table when stabs is active.
2007-10-28 15:29:54 -07:00
Charles Crayne
b0e1d423dd Clean up elf symbol table section 2007-10-21 14:21:43 -07: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
root
2674b04d88 Avoid unnecessary warning on redefinition of section (bug 801180) 2007-10-18 17:04:10 -07:00
Charles Crayne
f23a5b042c Generate stabs entries for any executable section 2007-10-17 17:55:45 -07:00
H. Peter Anvin
51cbf4a1fa More "bool" fixes
A few more variables passed as pointers which are now defined as bool *.
2007-10-11 10:12:58 -07:00
H. Peter Anvin
70055964fc Additional uses of bool and enum
Proper use of bool and enum makes code easier to debug.  Do more of
it.  In particular, we really should stomp out any residual uses of
magic constants that aren't enums or, in some cases, even #defines.
2007-10-11 00:05:57 -07:00
H. Peter Anvin
6867acc18e Use the compiler-provided booleans if available, otherwise emulate
Both C and C++ have "bool", "true" and "false" in lower case; C
requires <stdbool.h> for this, in C++ it is an inherent type built
into the compiler.  Use those instead of the old macros; emulate with
a simple typedef enum if unavailable.
2007-10-10 14:58:45 -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
10ba8490ce outcoff: set the "virtual size field" to zero (BR 1351586)
Per SF bug report 1351586:

The COFF spec suggests that the "Virtual Size" field (which
immediately follows the name field inside a section header) be set to
0 for an object file.

By contrast (as documented in comment #4 at the beginning of its
outcoff.c file) NASM sets it to a particular non-0 value.

MASM 6.15 matches NASM for both 16- and 32-bit object files,
i.e. emits non-0 values.

MASM 8 (from VS 2005 Beta) matches the COFF spec for 64-bit object
files, i.e. emits 0.

GAS matches the COFF spec for 32-bit object files (MinGW or Cygwin),
i.e. also emits 0.

Older versions of GNU ld seem to honor said "Virtual Size" field
whereas newer versions do not.  As a result those older versions
generate "bloated" image files.

Since the COFF spec and the real world seem to disagree for this case,
it might make sense to add a method for selecting between the two to
NASM.

Date: 2005-11-28 15:39
Sender: nasm64developer
Logged In: YES
user_id=804543

MASM 8 (from VS 2005 Beta) also matches the COFF spec for 16- and
32-bit object files, i.e. emits 0.

That said, NASM should always emit 0 too. Therefore I am turning this
from a support request into a bug.
2007-09-24 17:02:41 -07:00
Frank Kotler
577f5ea592 Merge branch 'master' of git+ssh://fbkotler@repo.or.cz/srv/git/nasm 2007-09-19 01:34:55 -04:00
H. Peter Anvin
9b0d41ddd4 elf64: fix 32-bit truncations
Fix 32-bit truncations, as evidenced by the following test program:

    mov rax, 8080808080808080h
2007-09-18 22:22:49 -07:00
Frank Kotler
24196047b5 add "const" to output/outdbg.c
apparently we missed that when updating "const" in other files
2007-09-18 02:06:09 -04: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
Chuck Crayne
199b96a810 Provide 64-bit support for ORG directive 2007-09-04 01:29:43 +00:00
H. Peter Anvin
74cc5e569c Finishing touches on perfect hash tokenizer; actually turn the thing on
Finish the perfect hash tokenizer, and actually enable it.

Move stdscan() et al to a separate file, since it's not needed in any
of the clients of nasmlib other than nasm itself.

Run make alldeps.
2007-08-30 22:35:34 +00:00
H. Peter Anvin
b838bcfe9f Generate R_X86_64_64 relocations in elf64 output
When appropriate, generate R_X86_64_64 relocations in elf64 output.
2007-08-29 18:20:19 +00: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
Frank Kotler
155eef6a3d finally commit Mike Frysinger's "elf-visibility" patch 2007-08-26 05:10:24 +00:00
H. Peter Anvin
90b9417613 16-bit relocations are standard in ELF64 (at my request, incidentally) 2007-05-04 18:47:16 +00:00
Chuck Crayne
8ab0320f02 Clarify comments about relocation entries. 2007-04-29 20:57:53 +00:00
Chuck Crayne
1c270b7fe2 Allow ELF32 to be invoked either as -f elf or -f elf32 2007-04-29 00:28:24 +00:00
Chuck Crayne
6e61733e38 Eliminate shift count warnings when building on 32-bit systems
Remove define for DEBUG
2007-04-28 22:18:04 +00:00
Chuck Crayne
26d3de3217 Initial support for ELF64 2007-04-28 06:18:48 +00:00
Keith Kanios
7295e9856d Fixed RDF/2 to comply with "maxbits" use. 2007-04-18 02:24:34 +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
8b2a72881c Fixed obj_fwrite() declaration to match "static" definition. 2007-04-13 22:07:53 +00:00
Keith Kanios
68d52b7737 Added appropriate "void" prototypes. 2007-04-13 22:03:24 +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
Keith Kanios
c1c5a2d96f Fixed c99 data-types after removal of typedefs. 2007-04-13 00:52:54 +00:00
H. Peter Anvin
038d861ede Remove obsolete types; add <inttypes.h> where needed; header fixes
- Remove obsolete types like "uint32"; use "uint32_t" consistently.
- Make sure we include <inttypes.h> where needed.
- Header file guards should be FOO_H or SUBDIR_FOO_H; _FOO_H infringes
  on the C implementation's namespace and should only be used when
  writing libc!
- Change a few "int8_t" back to "char" where appropriate.  There are
  a lot more places where that should be done, though.
- Clean up the check for getuid/getgid in rdoff/rdlar.h.
2007-04-12 16:54:50 +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
Frank Kotler
f3071da71e fix outobj.c bug - every 256th extern crashed nasm
-
2005-06-08 16:41:10 +00:00
Frank Kotler
02f05cebba Jindrich Novy's buffer overrun patch to outieee.c
-
2005-05-09 16:34:43 +00:00
H. Peter Anvin
e2c80181b6 Apply Nindent to all .c and .h files 2005-01-15 22:15:51 +00:00
Yuri Zaporogets
e0c059ab4e outrdf2.c now uses the same definitions of RDOFF2 format that RDOFF utils.
Export/import/common label size is increased from 33 to 64. Fixed the bug
that caused wrong behavior of rdfgetheaderrec() if label length was 32.
Changed error codes from numeric values to symbolic constants.
Moved some routines from rdfdump.c to rdoff.c. They will be utilized also
by rdfdisasm, which is being developed.
2004-09-15 06:54:34 +00:00
Frank Kotler
7c4dada951 fix as86 .bss handling per John Coffman's patch 2004-04-25 02:57:00 +00:00
Frank Kotler
b4a1735c47 Update rdoff 2003-12-12 06:18:07 +00:00
Stanislav Karchebny
d52236c00e Revert erroneous macro added and modify __OUTPUT_FORMAT__ to a string const 2003-09-25 11:43:28 +00:00
Stanislav Karchebny
5e8f36611f Consistency fix 2003-09-25 11:28:45 +00:00
Stanislav Karchebny
88a049aca1 Added _NASM_FORMAT_ macro 2003-09-24 10:30:56 +00:00
H. Peter Anvin
97b7e0a23a Fix list iterator 2003-09-12 20:49:25 +00:00
H. Peter Anvin
bb88d011e3 If we don't specify -g, actually suppress debugging output 2003-09-10 23:34:23 +00:00
Frank Kotler
243a37719b nasm_malloc-ize Martin's outelf.c stabs stuff 2003-09-06 05:48:16 +00:00
H. Peter Anvin
61ecdbb3a8 First attempt at fixing the stabs/ELF issue. 2003-09-06 00:50:27 +00:00
H. Peter Anvin
2b320bcab9 Restore the adjusted symbol id start 2003-07-10 00:40:33 +00:00
H. Peter Anvin
73320328c1 Generate stabs format debugging info for ELF 2003-07-09 19:11:10 +00:00
H. Peter Anvin
da4c3983b2 Quiet spurious gcc warning 2003-07-09 19:10:47 +00:00
Michael K. Ter Louw
fbf539dbd9 start/vstart/align/valign can now be >0x80000000 2003-07-09 08:10:22 +00:00
Frank Kotler
d9119b2e52 Fixed outbin.c to allow origin > 80000000h 2003-06-30 20:39:23 +00:00
Frank Kotler
6b8350cdea Mike's multisection outbin.c "align bug fix" 2003-02-04 07:11:20 +00:00
Frank Kotler
f17039406f Yuri's 12/3/2002 rdoff patches- 2002-12-04 00:49:37 +00:00
H. Peter Anvin
c9f57c24d0 Fixes from Bart Oldeman 2002-09-19 04:27:01 +00:00
H. Peter Anvin
bfebdb0a07 "const"-ipation fixes from Trevor Woerner 2002-09-12 02:23:54 +00:00
H. Peter Anvin
059647580c This is Jim's outcoff patch. 2002-06-07 20:42:22 +00:00
H. Peter Anvin
8215a54b21 Fix off-by-one error found when running theowl's test cases. 2002-05-26 23:48:09 +00:00
H. Peter Anvin
77a036e213 Make .rodata a recognized ELF section with default attributes 2002-05-17 04:51:10 +00:00
H. Peter Anvin
0a7a3b459c Change "const static" -> "static const" to keep gcc happy 2002-05-14 23:54:46 +00:00
H. Peter Anvin
310b3e165f Code cleanup fixes from Ed Beroset 2002-05-14 22:38:55 +00:00
H. Peter Anvin
8ff796d817 Fix from John Coffman to 16-bit OBJ format output. 2002-05-09 05:35:23 +00:00
H. Peter Anvin
8ac364139a NASM 0.98.30 2002-04-30 21:09:12 +00:00