platform/upstream/nasm.git
14 years agoCheck in test case from bug report br3005117
H. Peter Anvin [Thu, 8 Jul 2010 15:30:23 +0000 (08:30 -0700)]
Check in test case from bug report br3005117

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agobr3026808: add test case
H. Peter Anvin [Thu, 8 Jul 2010 14:31:45 +0000 (07:31 -0700)]
br3026808: add test case

Add test case for BR 3026808 (%assign %$local).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agoinsns: add FXSAVE64/FXRSTOR64, drop np prefix
H. Peter Anvin [Thu, 8 Jul 2010 00:20:19 +0000 (17:20 -0700)]
insns: add FXSAVE64/FXRSTOR64, drop np prefix

Add FXSAVE64 and FXRSTOR64; drop the np prefix on 0F AE instructions:
none of the rest of the 0F AE instructions have them, and there are no
conflicts.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agoMerge branch 'master' of ssh://repo.or.cz/srv/git/nasm
H. Peter Anvin [Thu, 8 Jul 2010 00:17:30 +0000 (17:17 -0700)]
Merge branch 'master' of ssh://repo.or.cz/srv/git/nasm

14 years agoinsns.dat: add XSAVE/XRSTOR64, XSAVEOPT, VCVTPH2PS/VCVTPS2PH
H. Peter Anvin [Wed, 7 Jul 2010 20:48:14 +0000 (13:48 -0700)]
insns.dat: add XSAVE/XRSTOR64, XSAVEOPT, VCVTPH2PS/VCVTPS2PH

Add XSAVE64/XRSTOR64 (previously missing), XSAVEOPT/XSAVEOPT64 (per
AVX 007 spec), and VCVTPH2PS/VCVTPS2PH (per AVX 007) spec.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoinsns.dat: remove VCVTPH2PS/VCVTPS2PH as AMD instructions
H. Peter Anvin [Wed, 7 Jul 2010 02:38:35 +0000 (19:38 -0700)]
insns.dat: remove VCVTPH2PS/VCVTPS2PH as AMD instructions

Remove VCVTPH2PS/VCVTPS2PH as AMD instructions based on version 3.04
of the AMD spec.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agoNASM 2.09rc2
H. Peter Anvin [Tue, 6 Jul 2010 22:06:51 +0000 (15:06 -0700)]
NASM 2.09rc2

14 years agodoc: Update changes.src
Cyrill Gorcunov [Tue, 6 Jul 2010 21:48:33 +0000 (01:48 +0400)]
doc: Update changes.src

Before soon-coming 2.09rc2.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoinsns.dat: fix CPU flags for new instructions
H. Peter Anvin [Tue, 6 Jul 2010 16:23:24 +0000 (09:23 -0700)]
insns.dat: fix CPU flags for new instructions

FUTURE is a CPU level flag, and cannot be combined with X64 (which is
shorthand for X86_64,LONG).  Also, make sure we add LONG annotations
to everything that is 64-bit mode only.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agoAdd RD*SBASE, WR*SBASE, RDRAND from AVX v7
H. Peter Anvin [Tue, 6 Jul 2010 16:15:48 +0000 (09:15 -0700)]
Add RD*SBASE, WR*SBASE, RDRAND from AVX v7

Add the RD*SBASE, WR*SBASE and RDRAND instructions from version 7 of
the AVX specification, Intel document 319433-007.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agooutbin: Cleanup bin_cleanup
Cyrill Gorcunov [Tue, 6 Jul 2010 15:40:02 +0000 (19:40 +0400)]
outbin: Cleanup bin_cleanup

No need for 'q' variable.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agooutbin: Simplify reverse address computing
Cyrill Gorcunov [Tue, 6 Jul 2010 15:08:28 +0000 (19:08 +0400)]
outbin: Simplify reverse address computing

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoBR3025702: outbin -- Fix byte ordering
Cyrill Gorcunov [Tue, 6 Jul 2010 14:33:29 +0000 (18:33 +0400)]
BR3025702: outbin -- Fix byte ordering

In commit 55ae12052cd1 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>
14 years agodoc: inslist.src is an intermediate file, move to "make clean"
H. Peter Anvin [Fri, 25 Jun 2010 20:38:49 +0000 (13:38 -0700)]
doc: inslist.src is an intermediate file, move to "make clean"

inslist.src is an intermediate file, it should be in "make clean"
rather than "make spotless"; otherwise it ends up in the xdoc tarball.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoBR 3020760: insns.dat -- confirm push imm32 on x86-64 explicitly
Cyrill Gorcunov [Fri, 25 Jun 2010 11:45:19 +0000 (15:45 +0400)]
BR 3020760: insns.dat -- confirm push imm32 on x86-64 explicitly

PUSH imm64 confuses ones who is trying to find this instruction in
processor programming manuals.

Actually it was introduced in a sake of "push `size' imm" consistency.
In other words -- to allow users to state "PUSH qword imm32" in 64bit code,
though on byte level (ie generated) code it still has a correct and valid
sign-extended "PUSH imm32" instruction.

To get rid of this ambiguie bite we make explicit "PUSH imm32"
being valid in 64bit code. This also makes "PUSH dword imm32"
valid in 64bit code as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopreproc.c: Get rid of signed/unsigned comparison warning
Cyrill Gorcunov [Sat, 19 Jun 2010 21:52:19 +0000 (01:52 +0400)]
preproc.c: Get rid of signed/unsigned comparison warning

We need mac->nparam being explicictly int'fied otherwise
compiler issue a warning. Note that we might have been
using unsigned int but it would break an ability to pass
negative indices.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoBR 3018233: handle LFS, LGS and LSS with a 64-bit register
H. Peter Anvin [Fri, 18 Jun 2010 23:24:46 +0000 (16:24 -0700)]
BR 3018233: handle LFS, LGS and LSS with a 64-bit register

LFS, LGS and LSS are valid in 64-bit mode and have 64-bit (REX.W)
forms.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoopenwcom.mak: drop /f from delete commands
H. Peter Anvin [Tue, 15 Jun 2010 17:49:09 +0000 (10:49 -0700)]
openwcom.mak: drop /f from delete commands

Classic DOS doesn't have del /f, and we don't really need it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoRename filenames to 8.3 format
H. Peter Anvin [Tue, 15 Jun 2010 17:47:16 +0000 (10:47 -0700)]
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>
14 years agoexpand_mmac_params: Expand local single macros unconditionally
Cyrill Gorcunov [Tue, 8 Jun 2010 14:45:06 +0000 (18:45 +0400)]
expand_mmac_params: Expand local single macros unconditionally

Peter proposed to expand local single macros unconditionally.
This should not hurt but give us more cleaner code in result.

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoexpand_mmac_params: Expand local single macros unconditionally
Cyrill Gorcunov [Tue, 8 Jun 2010 14:39:56 +0000 (18:39 +0400)]
expand_mmac_params: Expand local single macros unconditionally

Peter proposed to expand local single macros unconditionally.
This should not hurt but give us more cleaner code in result.

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agooutobj: handle compilers without 64-bit switch() support
H. Peter Anvin [Mon, 7 Jun 2010 18:34:28 +0000 (11:34 -0700)]
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>
14 years agooutelf32: handle compilers without 64-bit switch() support
H. Peter Anvin [Mon, 7 Jun 2010 18:26:11 +0000 (11:26 -0700)]
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>
14 years agoNASM 2.09rc1
Cyrill Gorcunov [Sat, 5 Jun 2010 20:13:43 +0000 (00:13 +0400)]
NASM 2.09rc1

14 years agonasmdoc: Document macro parameters range
Cyrill Gorcunov [Sat, 5 Jun 2010 07:24:59 +0000 (11:24 +0400)]
nasmdoc: Document macro parameters range

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoexpand_mmac_params_range: Simplify condition
Cyrill Gorcunov [Sat, 5 Jun 2010 06:47:10 +0000 (10:47 +0400)]
expand_mmac_params_range: Simplify condition

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopreproc.c: Fix argument indices checking in parameters range
Cyrill Gorcunov [Fri, 4 Jun 2010 21:58:10 +0000 (01:58 +0400)]
preproc.c: Fix argument indices checking in parameters range

Otherwise %{-1:-1} fails.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopreproc.c: Introduce macros parameters range expansion
Cyrill Gorcunov [Fri, 4 Jun 2010 21:50:23 +0000 (01:50 +0400)]
preproc.c: Introduce macros parameters range expansion

Introduce an ability to expand multi-line macros parameters in
a range/sequence manner.

For this purpose a special form is introduced %{x:y} which means to
expand %{x:y} to %{x},%{x+1},%{x+2},...,%{y}.

Both arguments could be negative or positive but MUST NOT be zero.

The arguments take into account possible %rotate as well.

Note that unlike the approach implemented in yasm we refer :-1 as
_last_ argument passed to a macro call, this makes possible to refer
the last element from macro via record as %{-1:-1} which could be
a convenient trick.

Also you can refer the argument in reverse order, ie it's legitime
to write %{5:4}, or even to reverse the all arguments %{-1:1}.

An example

 |
 | %macro mpar 1-*
 |     db %{1:-2}
 | %endmacro
 |
 | mpar 1,2,3,4,5,6

in result we'll get the sequence of 1,2,3,4,5

Reported-by: nasm64developer <nasm64developer@users.sf.net>
Inspired-by: Mathieu Monnier <mathieu.monnier@polytechnique.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoexpand_mmac_params: Format condition
Cyrill Gorcunov [Fri, 4 Jun 2010 05:22:12 +0000 (09:22 +0400)]
expand_mmac_params: Format condition

It's much easier to read aligned

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agonasmlib: Rename elements() macro to ARRAY_SIZE
Cyrill Gorcunov [Thu, 3 Jun 2010 18:04:36 +0000 (22:04 +0400)]
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>
14 years agopreproc.c: Use list_ helpers
Cyrill Gorcunov [Wed, 2 Jun 2010 11:57:51 +0000 (15:57 +0400)]
preproc.c: Use list_ helpers

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoexpand_mmac_params: Don't forget to handle TOK_OTHER
Cyrill Gorcunov [Wed, 2 Jun 2010 07:57:05 +0000 (11:57 +0400)]
expand_mmac_params: Don't forget to handle TOK_OTHER

TOK_OTHER is legitime to follow TOK_PREPROC_ID so don't forget to handle it as well.

[ An addition to commit ec88c1beac00 ]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoBR3005117: Expland local single macro before pasting tokens
Cyrill Gorcunov [Tue, 1 Jun 2010 20:59:21 +0000 (00:59 +0400)]
BR3005117: Expland local single macro before pasting tokens

When we have switched to unified token pasting code we loose
backward compatibility. Restore it.

Note that new code MUST not expluatate this facility but rather
use paste macro %+ explicitly.

N.B. this patch is probably the candidate for revert, though
to give it a chance I commit it.

Reported-by: Alexey Dokuchaev
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoNew %use package "fp"
H. Peter Anvin [Fri, 7 May 2010 20:42:09 +0000 (13:42 -0700)]
New %use package "fp"

New standard macro package with utility macros for floating-point
constants.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agonasmdoc: document octal/binary floating-point
H. Peter Anvin [Fri, 7 May 2010 20:21:20 +0000 (13:21 -0700)]
nasmdoc: document octal/binary floating-point

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agonasmdoc: add missing comma
H. Peter Anvin [Fri, 7 May 2010 20:14:45 +0000 (13:14 -0700)]
nasmdoc: add missing comma

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agonasmdoc: update the full set of numeric prefix/suffix characters.
H. Peter Anvin [Fri, 7 May 2010 20:12:12 +0000 (13:12 -0700)]
nasmdoc: update the full set of numeric prefix/suffix characters.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agooutobj: update error message
H. Peter Anvin [Fri, 7 May 2010 00:58:46 +0000 (17:58 -0700)]
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>
14 years agooutobj: properly error on unsupported relocations
H. Peter Anvin [Fri, 7 May 2010 00:52:57 +0000 (17:52 -0700)]
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>
14 years agooutelf64: update copyright date
H. Peter Anvin [Fri, 7 May 2010 00:45:39 +0000 (17:45 -0700)]
outelf64: update copyright date

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoELF support for 8-bit relocations
H. Peter Anvin [Thu, 6 May 2010 23:14:00 +0000 (16:14 -0700)]
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>
14 years agoPermit short intersegment jumps
H. Peter Anvin [Thu, 6 May 2010 22:32:20 +0000 (15:32 -0700)]
Permit short intersegment jumps

Allow an intersegment jump to be short (OUT_REL1ADR) if explicitly
specified so by the user.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoAdd support for one-byte relocations
H. Peter Anvin [Thu, 6 May 2010 22:25:43 +0000 (15:25 -0700)]
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>
14 years agoMachO: Fix misprinted macho_sectalign
Cyrill Gorcunov [Wed, 28 Apr 2010 19:17:13 +0000 (23:17 +0400)]
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>
14 years agoobj: Implement sectalign helper
Cyrill Gorcunov [Sun, 25 Apr 2010 18:00:15 +0000 (22:00 +0400)]
obj: Implement sectalign helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agomacho: Implement sectalign handler
Cyrill Gorcunov [Sun, 25 Apr 2010 17:35:09 +0000 (21:35 +0400)]
macho: Implement sectalign handler

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoieee: Fix section index match in sectalign handler
Cyrill Gorcunov [Sun, 25 Apr 2010 13:55:52 +0000 (17:55 +0400)]
ieee: Fix section index match in sectalign handler

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoheaders: Update year
Cyrill Gorcunov [Sun, 25 Apr 2010 08:02:38 +0000 (12:02 +0400)]
headers: Update year

It's 2010 now

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agooutieee: Implement sectalign handler
Cyrill Gorcunov [Sat, 24 Apr 2010 21:17:11 +0000 (01:17 +0400)]
outieee: Implement sectalign handler

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agooutbin: Drop current_section variable
Cyrill Gorcunov [Thu, 22 Apr 2010 18:32:17 +0000 (22:32 +0400)]
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>
14 years agooutbin: Prune ancient format_mode variable
Cyrill Gorcunov [Thu, 22 Apr 2010 18:24:04 +0000 (22:24 +0400)]
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>
14 years agoilog2: optimize use of bsr for x86-64
H. Peter Anvin [Thu, 22 Apr 2010 18:02:56 +0000 (11:02 -0700)]
ilog2: optimize use of bsr for x86-64

On x86-64 platforms, we can rely on BSR not changing the destination
operand when the input is zero.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agodoc: use bouncer URLs for the ABI docs
H. Peter Anvin [Wed, 7 Apr 2010 05:40:47 +0000 (22:40 -0700)]
doc: use bouncer URLs for the ABI docs

MSDN can't seem to keep their URLs stable, so use bouncer links
that we can change if necessary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
14 years agobin: Implement sectalign handler
Cyrill Gorcunov [Thu, 22 Apr 2010 12:37:56 +0000 (16:37 +0400)]
bin: Implement sectalign handler

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agocoff: Use IMAGE_SCN_ALIGN_MASK macro
Cyrill Gorcunov [Thu, 22 Apr 2010 11:21:37 +0000 (15:21 +0400)]
coff: Use IMAGE_SCN_ALIGN_MASK macro

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agocoff: Allow alignment greater then 64 bytes on win
Cyrill Gorcunov [Thu, 22 Apr 2010 11:17:35 +0000 (15:17 +0400)]
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>
14 years agocoff: Fix section alignment computation
Cyrill Gorcunov [Thu, 22 Apr 2010 11:05:19 +0000 (15:05 +0400)]
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>
14 years agocoff: Use predefined macros instead of numbers and style fix
Cyrill Gorcunov [Thu, 22 Apr 2010 10:25:21 +0000 (14:25 +0400)]
coff: Use predefined macros instead of numbers and style fix

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoilog2: Use ROUND helper
Cyrill Gorcunov [Thu, 22 Apr 2010 06:29:19 +0000 (10:29 +0400)]
ilog2: Use ROUND helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoilog2: Get rid of tabs
Cyrill Gorcunov [Thu, 22 Apr 2010 06:06:13 +0000 (10:06 +0400)]
ilog2: Get rid of tabs

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopecoff.h: Complete header
Cyrill Gorcunov [Thu, 22 Apr 2010 05:32:22 +0000 (09:32 +0400)]
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>
14 years agoRemove open-coded ilog2() implementations
H. Peter Anvin [Wed, 21 Apr 2010 23:46:57 +0000 (16:46 -0700)]
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>
14 years agoAdd generic ilog2 functions
H. Peter Anvin [Wed, 21 Apr 2010 23:43:20 +0000 (16:43 -0700)]
Add generic ilog2 functions

Add ilog2_{32,64}() and alignlog2_{32,64}() ... the latter is intended
for alignment statements and return -1 for non-power-of-2 other than 0
(which returns 0).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agoMakefile: clean up the lib directory on make clean
H. Peter Anvin [Wed, 21 Apr 2010 23:40:38 +0000 (16:40 -0700)]
Makefile: clean up the lib directory on make clean

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agostandard.mac: Update section alignment on align call
Cyrill Gorcunov [Wed, 21 Apr 2010 19:52:57 +0000 (23:52 +0400)]
standard.mac: Update section alignment on align call

Achieved via sectalign call. Note that not all output
targets (ie formats) may handle sectalign yet, most
of them just ignore this entity.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agocoff: Use predefined macro in common section flags
Cyrill Gorcunov [Wed, 21 Apr 2010 18:40:11 +0000 (22:40 +0400)]
coff: Use predefined macro in common section flags

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agocoff: Use predefined macro and eliminate open coded constants
Cyrill Gorcunov [Wed, 21 Apr 2010 18:03:33 +0000 (22:03 +0400)]
coff: Use predefined macro and eliminate open coded constants

Not all are covered but process initiated.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopecoff.h: Add more constants
Cyrill Gorcunov [Wed, 21 Apr 2010 17:47:03 +0000 (21:47 +0400)]
pecoff.h: Add more constants

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agomake: Update pecoff.h related deps
Cyrill Gorcunov [Wed, 21 Apr 2010 14:51:14 +0000 (18:51 +0400)]
make: Update pecoff.h related deps

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopecoff: Update machine types
Cyrill Gorcunov [Wed, 21 Apr 2010 14:46:27 +0000 (18:46 +0400)]
pecoff: Update machine types

Update up to pecoff v8

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agooutput: Introduce pecoff.h
Cyrill Gorcunov [Wed, 21 Apr 2010 12:38:56 +0000 (16:38 +0400)]
output: Introduce pecoff.h

Better to have common constants grouped.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agocoff: Implement sectalign handler
Cyrill Gorcunov [Wed, 21 Apr 2010 11:45:09 +0000 (15:45 +0400)]
coff: Implement sectalign handler

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoRename SEGALIGN to SECTALIGN
Cyrill Gorcunov [Wed, 21 Apr 2010 09:45:32 +0000 (13:45 +0400)]
Rename SEGALIGN to SECTALIGN

"sectalign" is preferred over "segalign"
since it operates over section attributes.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agosmartalign.mac: align macro should align a segment as well
Cyrill Gorcunov [Tue, 20 Apr 2010 21:22:31 +0000 (01:22 +0400)]
smartalign.mac: align macro should align a segment as well

This change may have backward compatibility issue but
most probably the sane program never used sections with
base address less then instruction alignment.

Note that alignment may only increase which means if a
section is aligned on 2^5 the align 2^4 will not affect
the section.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf64: Implement segalign handler
Cyrill Gorcunov [Tue, 20 Apr 2010 21:15:28 +0000 (01:15 +0400)]
Elf64: Implement segalign handler

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf-32: Implement segalign handling
Cyrill Gorcunov [Tue, 20 Apr 2010 21:05:13 +0000 (01:05 +0400)]
Elf-32: Implement segalign handling

Via elf_segalign helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoofmt: Implement null_segalign stubs
Cyrill Gorcunov [Tue, 20 Apr 2010 20:51:22 +0000 (00:51 +0400)]
ofmt: Implement null_segalign stubs

Set stubs for all targets

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoIntroduce SEGALIGN directive
Cyrill Gorcunov [Tue, 20 Apr 2010 11:33:45 +0000 (15:33 +0400)]
Introduce SEGALIGN directive

No real handling yet though. Definition only.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agolabels.c: lookup_label -- should return bool unconditionally
Cyrill Gorcunov [Tue, 20 Apr 2010 11:26:08 +0000 (15:26 +0400)]
labels.c: lookup_label -- should return bool unconditionally

Better to not put return under condition. It was bad.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agosmartalign: Introduce nojmp mode
Cyrill Gorcunov [Tue, 20 Apr 2010 11:06:44 +0000 (15:06 +0400)]
smartalign: Introduce nojmp mode

This allows to force nasm to generate multibyte
NOPs without jmp injected.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf: Rename SEG_ALIGN to SEC_FILEALIGN
Cyrill Gorcunov [Tue, 20 Apr 2010 11:05:02 +0000 (15:05 +0400)]
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>
14 years agoAdd "win" alias for "win32" output format
Cyrill Gorcunov [Tue, 20 Apr 2010 10:55:53 +0000 (14:55 +0400)]
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>
14 years agonasm.c: Delete redundant goto
Cyrill Gorcunov [Tue, 20 Apr 2010 10:53:44 +0000 (14:53 +0400)]
nasm.c: Delete redundant goto

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf: switch section_attrib to a new nasm_opt_val interface
Cyrill Gorcunov [Sun, 11 Apr 2010 09:12:20 +0000 (13:12 +0400)]
Elf: switch section_attrib to a new nasm_opt_val interface

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agonasmlib.c: Make nasm_opt_val robust
Cyrill Gorcunov [Sun, 11 Apr 2010 09:00:58 +0000 (13:00 +0400)]
nasmlib.c: Make nasm_opt_val robust

nasm_opt_val should be able handle various text stream
passed, including tainted ones. Make it so.

Also it fixes the case when Elf section has multiple
attributes such as "progbits align=16" and friends
(introduced by commit bb0745f). The former just ignore
any other options/values except first one.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agonasmlib.c: Introduce nasm_get_word helper
Cyrill Gorcunov [Sat, 10 Apr 2010 21:03:20 +0000 (01:03 +0400)]
nasmlib.c: Introduce nasm_get_word helper

For easier space separated words extraction
from a text stream.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf: Use SHA_ANY constant instead of open coded number
Cyrill Gorcunov [Sat, 10 Apr 2010 10:58:39 +0000 (14:58 +0400)]
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>
14 years agoexpand_mmacro: Use list helpers
Cyrill Gorcunov [Fri, 9 Apr 2010 11:43:03 +0000 (15:43 +0400)]
expand_mmacro: Use list helpers

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agodetoken: Use list_for_each helpers
Cyrill Gorcunov [Fri, 9 Apr 2010 11:41:48 +0000 (15:41 +0400)]
detoken: Use list_for_each helpers

And a few style nits.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoexpand_smacro: stylish nits
Cyrill Gorcunov [Fri, 9 Apr 2010 11:40:35 +0000 (15:40 +0400)]
expand_smacro: stylish nits

- no need to split functions even if it a bit longer
  then 80 characters, it becomes hard to read it

- initialize "thead" before "tail" is more natural

- use more simple while() instead of for() with a
  long initializer

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoofmt: Introduce output format aliases
Cyrill Gorcunov [Fri, 9 Apr 2010 11:12:13 +0000 (15:12 +0400)]
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>
14 years agoElf: Some unification snippets for 32/64 bit versions
Cyrill Gorcunov [Fri, 9 Apr 2010 10:57:28 +0000 (14:57 +0400)]
Elf: Some unification snippets for 32/64 bit versions

Nothing serious, comments and style movements.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf: Merge WRITE_STAB to outelf.h
Cyrill Gorcunov [Fri, 9 Apr 2010 10:23:57 +0000 (14:23 +0400)]
Elf: Merge WRITE_STAB to outelf.h

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf: Drop never used SOC helper
Cyrill Gorcunov [Fri, 9 Apr 2010 10:21:45 +0000 (14:21 +0400)]
Elf: Drop never used SOC helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agonasmdoc.src: Refer to ..imagebase in special symbols area
Cyrill Gorcunov [Fri, 9 Apr 2010 09:57:14 +0000 (13:57 +0400)]
nasmdoc.src: Refer to ..imagebase in special symbols area

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agonasmlib: Do not hang on if log file creation has been failed
Cyrill Gorcunov [Fri, 9 Apr 2010 09:29:38 +0000 (13:29 +0400)]
nasmlib: Do not hang on if log file creation has been failed

In case if we can't open "malloc.log" for writing
we should not hang out but rather switch to stderr
and continue processing.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agoElf: Introduce section_attrib helper
Cyrill Gorcunov [Fri, 9 Apr 2010 09:24:35 +0000 (13:24 +0400)]
Elf: Introduce section_attrib helper

In a sake of removing code duplication.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agonasmlib: Introduce nasm_trim_spaces and nasm_opt_val helpers
Cyrill Gorcunov [Fri, 9 Apr 2010 09:17:23 +0000 (13:17 +0400)]
nasmlib: Introduce nasm_trim_spaces and nasm_opt_val helpers

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agodirectives.pl: trivial formatting fix
H. Peter Anvin [Wed, 7 Apr 2010 23:56:24 +0000 (16:56 -0700)]
directives.pl: trivial formatting fix

Fix whitespace alignment.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14 years agonasm.c: smarter handling of missing directives
H. Peter Anvin [Wed, 7 Apr 2010 23:54:56 +0000 (16:54 -0700)]
nasm.c: smarter handling of missing directives

If we get D_unknown, we definitely don't need to pass it to the
backend for analysis.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>