platform/upstream/nasm.git
15 years agoFix BR #916647
Victor van den Elzen [Wed, 5 Nov 2008 13:11:46 +0000 (14:11 +0100)]
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.

15 years agochanges.src: document if for %ifmacro.
H. Peter Anvin [Tue, 4 Nov 2008 22:26:32 +0000 (14:26 -0800)]
changes.src: document if for %ifmacro.

Document fixed %ifmacro.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest: add test for BR 2222615
H. Peter Anvin [Tue, 4 Nov 2008 22:25:12 +0000 (14:25 -0800)]
test: add test for BR 2222615

Add a test for %ifmacro, per BR 2222615.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: BR 2222615: fix segfault on bogus %ifmacro
H. Peter Anvin [Tue, 4 Nov 2008 22:24:34 +0000 (14:24 -0800)]
preproc: BR 2222615: fix segfault on bogus %ifmacro

BR 2222615: Fix segmentation fault on %ifmacro without an argument.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoPrevent erroneous extra "final" pass
Charles Crayne [Tue, 4 Nov 2008 02:21:24 +0000 (18:21 -0800)]
Prevent erroneous extra "final" pass

Specifically check for end of final pass.

15 years agodoc/changes.src: document ELF TLS
H. Peter Anvin [Mon, 3 Nov 2008 04:41:29 +0000 (20:41 -0800)]
doc/changes.src: document ELF TLS

Add ELF TLS to the release notes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: minor edit to the TLS documentation examples.
H. Peter Anvin [Mon, 3 Nov 2008 04:40:16 +0000 (20:40 -0800)]
doc: minor edit to the TLS documentation examples.

Minimize the TLS documentation examples (we don't need "dword" in a
mov from ebx, for example.)  This is just to avoid user confusion.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoDocument differences between TLS coding in ELF32 and ELF64
Charles Crayne [Sun, 2 Nov 2008 00:09:36 +0000 (17:09 -0700)]
Document differences between TLS coding in ELF32 and ELF64

Absolute relocation wrt ..tlsie for ELF32
Relative relocation wrt ..gottpoff for ELF64

15 years agoELF32 support for offset to IE GOT entry
Charles Crayne [Sat, 1 Nov 2008 23:48:31 +0000 (16:48 -0700)]
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.

15 years agoversion.pl: snapshot releases *only* have digits in the tail
H. Peter Anvin [Sat, 1 Nov 2008 19:57:05 +0000 (12:57 -0700)]
version.pl: snapshot releases *only* have digits in the tail

Snapshot releases have *only* digits in the tail.  "git describe"
produces tails that have digits in them, but aren't numeric.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMove all version strings to a single compilation unit (ver.c)
H. Peter Anvin [Fri, 31 Oct 2008 23:53:49 +0000 (16:53 -0700)]
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>
15 years agoELF32 bit support of .tdata and .tbss sections
Charles Crayne [Fri, 31 Oct 2008 04:59:42 +0000 (21:59 -0700)]
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

15 years agorbtree: drop the data pointer; instead rely on being embedded
H. Peter Anvin [Thu, 30 Oct 2008 17:58:28 +0000 (10:58 -0700)]
rbtree: drop the data pointer; instead rely on being embedded

Drop the data pointer, and instead assume the struct rbtree will be
embedded in a bigger data structure (to be extracted via
container_of()).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agocompiler.h: add offsetof() and container_of()
H. Peter Anvin [Thu, 30 Oct 2008 17:52:08 +0000 (10:52 -0700)]
compiler.h: add offsetof() and container_of()

offsetof() is a C99 construct; provided here as an ersatz for older
systems.

container_of() is a nonstandard but highly useful construct, which
allows data structure control items like tree structures to be
embedded in larger data structures without the penalty of extra
pointers and allocations.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoLeft-leaning red-black tree data structure
H. Peter Anvin [Thu, 30 Oct 2008 06:29:23 +0000 (23:29 -0700)]
Left-leaning red-black tree data structure

Implement library functions for "left-leaning red-black trees" with
uint64_t keys.  This is meant for looking up symbols by address in the
backends that need to do so, e.g. ELF.

A good question is if there is a better way to do this, that recovers
the original symbol, but that's a future issue.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoFix header guards for outlib.h
H. Peter Anvin [Tue, 28 Oct 2008 06:01:57 +0000 (23:01 -0700)]
Fix header guards for outlib.h

Fix typo in header guards for outlib.h

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agomake alldeps
H. Peter Anvin [Thu, 30 Oct 2008 04:03:17 +0000 (21:03 -0700)]
make alldeps

Run "make alldeps"

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: cross-reference macro parameter concatenation with %[...]
H. Peter Anvin [Thu, 30 Oct 2008 04:02:30 +0000 (21:02 -0700)]
doc: cross-reference macro parameter concatenation with %[...]

Explicitly document that %[...] and macro parameters concatenate the
same way, and cross-reference the two.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMerge branch 'nasm-2.05.xx'
H. Peter Anvin [Thu, 30 Oct 2008 03:47:58 +0000 (20:47 -0700)]
Merge branch 'nasm-2.05.xx'

15 years agodoc: fix typo in the description of %unmacro
H. Peter Anvin [Thu, 30 Oct 2008 03:46:30 +0000 (20:46 -0700)]
doc: fix typo in the description of %unmacro

The description of %unmacro used %unmacro in a place which should
obviously have been %macro.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: fix capitalization
H. Peter Anvin [Thu, 30 Oct 2008 01:17:59 +0000 (18:17 -0700)]
doc: fix capitalization

Make the capitalization of "The -t Option" consistent with the other
options.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: remove duplicate entry for the "error" warning class
H. Peter Anvin [Thu, 30 Oct 2008 01:16:31 +0000 (18:16 -0700)]
doc: remove duplicate entry for the "error" warning class

Remove duplicate entry for the "error" warning class; leave at the end
with "all", as being another meta-warning class.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: retroactively document updates to the warning options
H. Peter Anvin [Thu, 30 Oct 2008 01:14:03 +0000 (18:14 -0700)]
doc: retroactively document updates to the warning options

Retroactively document the following changes to the warning options:

  - gcc-like syntax (-Wfoo, -Wno-foo)
  - "all" alias
  - "error" metawarning

Added in 2.00rc1 but never documented.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: fix typo in the description of %unmacro
H. Peter Anvin [Thu, 30 Oct 2008 03:46:30 +0000 (20:46 -0700)]
doc: fix typo in the description of %unmacro

The description of %unmacro used %unmacro in a place which should
obviously have been %macro.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: fix capitalization
H. Peter Anvin [Thu, 30 Oct 2008 01:17:59 +0000 (18:17 -0700)]
doc: fix capitalization

Make the capitalization of "The -t Option" consistent with the other
options.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: remove duplicate entry for the "error" warning class
H. Peter Anvin [Thu, 30 Oct 2008 01:16:31 +0000 (18:16 -0700)]
doc: remove duplicate entry for the "error" warning class

Remove duplicate entry for the "error" warning class; leave at the end
with "all", as being another meta-warning class.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: retroactively document updates to the warning options
H. Peter Anvin [Thu, 30 Oct 2008 01:14:03 +0000 (18:14 -0700)]
doc: retroactively document updates to the warning options

Retroactively document the following changes to the warning options:

  - gcc-like syntax (-Wfoo, -Wno-foo)
  - "all" alias
  - "error" metawarning

Added in 2.00rc1 but never documented.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMerge commit 'nasm-2.05.01'
H. Peter Anvin [Wed, 29 Oct 2008 17:53:37 +0000 (10:53 -0700)]
Merge commit 'nasm-2.05.01'

Conflicts:
doc/changes.src

15 years agoNASM 2.05.01
H. Peter Anvin [Wed, 29 Oct 2008 17:52:53 +0000 (10:52 -0700)]
NASM 2.05.01

15 years agodoc/changes.src: document -W/-w fix as a NASM 2.05.01 feature.
H. Peter Anvin [Wed, 29 Oct 2008 17:51:51 +0000 (10:51 -0700)]
doc/changes.src: document -W/-w fix as a NASM 2.05.01 feature.

Make -W/-w fix a release note for NASM 2.05.01.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMerge branch 'master' of git+ssh://ccrayne@repo.or.cz/srv/git/nasm
Charles Crayne [Tue, 28 Oct 2008 05:54:38 +0000 (22:54 -0700)]
Merge branch 'master' of git+ssh://ccrayne@repo.or.cz/srv/git/nasm

15 years agoInitial documentation for ELF64 TLS
Charles Crayne [Tue, 28 Oct 2008 05:53:40 +0000 (22:53 -0700)]
Initial documentation for ELF64 TLS

More to come.

15 years agooutput: add common file outlib.c for common functions; realsize()
H. Peter Anvin [Tue, 28 Oct 2008 05:19:59 +0000 (22:19 -0700)]
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>
15 years agopreproc: merge expand_mmac_params() and expand_indirect()
H. Peter Anvin [Mon, 27 Oct 2008 06:49:00 +0000 (23:49 -0700)]
preproc: merge expand_mmac_params() and expand_indirect()

These two really need to be done together, in order for constructs
such as %[%1] to work properly.  Furthermore, fix a token-pasting bug
in expand_mmac_params().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMerge branch 'master' of git+ssh://ccrayne@repo.or.cz/srv/git/nasm
Charles Crayne [Mon, 27 Oct 2008 00:33:43 +0000 (17:33 -0700)]
Merge branch 'master' of git+ssh://ccrayne@repo.or.cz/srv/git/nasm

15 years agoELF64 support for PC relative offset to IE GOT entry
Charles Crayne [Mon, 27 Oct 2008 00:32:38 +0000 (17:32 -0700)]
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.

15 years agoMerge branch 'nasm-2.05.xx'
H. Peter Anvin [Sun, 26 Oct 2008 16:00:45 +0000 (09:00 -0700)]
Merge branch 'nasm-2.05.xx'

15 years agoBetter description of the number-overflow warning
H. Peter Anvin [Sun, 26 Oct 2008 15:59:04 +0000 (08:59 -0700)]
Better description of the number-overflow warning

Better grammar and fix incorrect description of the number-overflow
warning (it is not just limited to 64-bit arithmetic overflow, it also
triggers when trying to squeeze in a value which is too large into an
immediate.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoBR: 2196966: make the -w/-W options work again
H. Peter Anvin [Sun, 26 Oct 2008 15:57:13 +0000 (08:57 -0700)]
BR: 2196966: make the -w/-W options work again

The code to parse the -w/-W options was updating warning_on[], not
warning_on_global[], but warning_on[] is reset at the beginning of
each pass (to let the warning directive work); as a result the -w/-W
options don't actually do anything at all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMerge branch 'master' of git+ssh://ccrayne@repo.or.cz/srv/git/nasm
Charles Crayne [Sun, 26 Oct 2008 02:32:48 +0000 (19:32 -0700)]
Merge branch 'master' of git+ssh://ccrayne@repo.or.cz/srv/git/nasm

15 years agoFlag thread local symbols in symbol table
Charles Crayne [Sun, 26 Oct 2008 02:31:09 +0000 (19:31 -0700)]
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.

15 years agosmartalign: clean up unnecessary duplication; tweak dependencies
H. Peter Anvin [Sun, 26 Oct 2008 00:48:33 +0000 (17:48 -0700)]
smartalign: clean up unnecessary duplication; tweak dependencies

Remove unnecessary duplicated patterns; with indirection we can handle
lists of any length.

For 16-bit generic padding, alternate between SI and DI dependencies.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoELF64 segment definitions for TLS
Charles Crayne [Sat, 25 Oct 2008 22:23:30 +0000 (15:23 -0700)]
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

15 years agoFor snapshot releases, expand out the mangled version numbers.
H. Peter Anvin [Sat, 25 Oct 2008 19:41:29 +0000 (12:41 -0700)]
For snapshot releases, expand out the mangled version numbers.

For snapshot releases, expand out the mangled version number,
e.g. 2.05.00.0.20081025.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodisasm: introduce opy
H. Peter Anvin [Sat, 25 Oct 2008 07:42:51 +0000 (00:42 -0700)]
disasm: introduce opy

Introduce the opy pointer into the disassembler, and use it where
appropriate.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoassemble: use opx and opy in a few more places
H. Peter Anvin [Sat, 25 Oct 2008 07:41:00 +0000 (00:41 -0700)]
assemble: use opx and opy in a few more places

Use opx and opy in a few more places where we can do so.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc/changes.src: retroactively document anonymous %push
H. Peter Anvin [Fri, 24 Oct 2008 23:53:53 +0000 (16:53 -0700)]
doc/changes.src: retroactively document anonymous %push

Retroactively document the anonymous %push, which was added in version
2.04 but not documented.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: don't macro-expand the argument to %use
H. Peter Anvin [Fri, 24 Oct 2008 23:38:17 +0000 (16:38 -0700)]
preproc: don't macro-expand the argument to %use

Use expand_id() for the argument to %use, instead of expand_smacro().
This really makes more sense for a "naked" argument.  This is a
semantic change, but is unlikely to break any real code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: document %pop with argument
H. Peter Anvin [Fri, 24 Oct 2008 23:27:11 +0000 (16:27 -0700)]
doc: document %pop with argument

Document that %pop can now take an argument, and what it does.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: allow %pop to take an identifier, unify %push/%repl/%pop
H. Peter Anvin [Fri, 24 Oct 2008 23:24:21 +0000 (16:24 -0700)]
preproc: allow %pop to take an identifier, unify %push/%repl/%pop

Allow the %pop directive to take an identifier (an assert on the
context name); unify the parsing parts of %push, %repl,  and %pop.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: document anonymous %push
H. Peter Anvin [Fri, 24 Oct 2008 23:19:03 +0000 (16:19 -0700)]
doc: document anonymous %push

The anonymous %push was never documented, document it now.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc/changes.src: begin the release notes for 2.06
H. Peter Anvin [Fri, 24 Oct 2008 23:05:19 +0000 (16:05 -0700)]
doc/changes.src: begin the release notes for 2.06

The next version will presumably be called 2.06; begin collecting
release notes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: fix awkward word order
H. Peter Anvin [Fri, 24 Oct 2008 17:15:46 +0000 (10:15 -0700)]
doc: fix awkward word order

"the exactly same" -> "exactly the same"

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoversion.pl: don't add an extra .00 for subminor if we don't need it
H. Peter Anvin [Fri, 24 Oct 2008 17:10:32 +0000 (10:10 -0700)]
version.pl: don't add an extra .00 for subminor if we don't need it

When producing the mangled version number, don't add a subminor if
there isn't a patch level or release candidate number.  Thus, 2.05p1
is 2.05.00.01, but 2.05 can just be 2.05.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoMerge branch 'indirect'
H. Peter Anvin [Fri, 24 Oct 2008 06:13:44 +0000 (23:13 -0700)]
Merge branch 'indirect'

15 years agoFix op2 references that had not yet been converted; introduce opy
H. Peter Anvin [Fri, 24 Oct 2008 06:07:53 +0000 (23:07 -0700)]
Fix op2 references that had not yet been converted; introduce opy

Fix op2 references not yet converted to accessing op2; add an opy
pointer similar to the opx pointer instead of multiple references.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodisasm: extension byte support in the disassembler
H. Peter Anvin [Wed, 15 Oct 2008 18:51:24 +0000 (11:51 -0700)]
disasm: extension byte support in the disassembler

Add support to the disassembler for the extension bytes (for operand
4+).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoAdd extension bytecodes to support operands 4+
H. Peter Anvin [Sat, 11 Oct 2008 05:10:31 +0000 (22:10 -0700)]
Add extension bytecodes to support operands 4+

The bytecode format assumes max 4 operands pretty strictly, but we
already have one instruction with 5 operands, and it's likely to get
more.  Support them via extension prefixes (similar to REX prefixes).
For bytecodes which use argument bytes we encode the number directly,
however.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoWhen issuing warnings for EA displacements, use the *EA* operand
H. Peter Anvin [Fri, 24 Oct 2008 03:49:09 +0000 (20:49 -0700)]
When issuing warnings for EA displacements, use the *EA* operand

When issuing warnings for EA displacements during address generation,
actually look a the proper operand!

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoNASM 2.05
H. Peter Anvin [Fri, 24 Oct 2008 02:42:17 +0000 (19:42 -0700)]
NASM 2.05

15 years agodoc/changes.src: update release notes
H. Peter Anvin [Fri, 24 Oct 2008 02:29:28 +0000 (19:29 -0700)]
doc/changes.src: update release notes

Update the release notes in preparation for NASM 2.05.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoThe CRC32 instructions can take 66 prefixes as well as F2
H. Peter Anvin [Thu, 23 Oct 2008 23:39:25 +0000 (16:39 -0700)]
The CRC32 instructions can take 66 prefixes as well as F2

The CRC32 instructions require F2, but can also take a 66 prefix to
set the operand size.  This is not the SSE model of prefix extension.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest/crc32.asm: test the CRC32 instruction
H. Peter Anvin [Thu, 23 Oct 2008 23:24:02 +0000 (16:24 -0700)]
test/crc32.asm: test the CRC32 instruction

Test for the CRC32 instruction.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoBR 2190521: fix the CRC32 opcodes
H. Peter Anvin [Thu, 23 Oct 2008 23:23:19 +0000 (16:23 -0700)]
BR 2190521: fix the CRC32 opcodes

A stray \1 bytecode was hiding in the CRC32 opcodes, causing complete
havoc.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoNASM 2.05rc8
H. Peter Anvin [Wed, 22 Oct 2008 18:23:18 +0000 (11:23 -0700)]
NASM 2.05rc8

15 years agoBR 2187210: Fix PFRCPV and PFRSQRTV
H. Peter Anvin [Wed, 22 Oct 2008 18:18:27 +0000 (11:18 -0700)]
BR 2187210: Fix PFRCPV and PFRSQRTV

Fix the Geode instructions PFRCPV and PFRSQRTV per bug report 2187210.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoassemble: not all backends handle intra-segment OUT_REL*ADR
H. Peter Anvin [Wed, 22 Oct 2008 18:15:00 +0000 (11:15 -0700)]
assemble: not all backends handle intra-segment OUT_REL*ADR

Not all backends can handle being handled an intrasegment OUT_REL*ADR,
and we don't fix them up in common code either (which would be the
logical thing to do -- right now we fix them up in a bunch of
individual places.)

For now, just fix up the one in address generation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoBR 2148448: fix relative addresses in bin output
H. Peter Anvin [Wed, 22 Oct 2008 18:03:09 +0000 (11:03 -0700)]
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>
15 years agoUpdate .gitignore to include additional generated files
H. Peter Anvin [Mon, 20 Oct 2008 05:25:11 +0000 (22:25 -0700)]
Update .gitignore to include additional generated files

pptok.ph and doc/inslist.src are generated files; list them in
.gitignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest/ppindirect.asm: test token pasting inside %[...]
H. Peter Anvin [Mon, 20 Oct 2008 05:23:12 +0000 (22:23 -0700)]
test/ppindirect.asm: test token pasting inside %[...]

Test for token pasting inside %[...].

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: fix terminal token pasting in indirect sequences
H. Peter Anvin [Mon, 20 Oct 2008 05:22:05 +0000 (22:22 -0700)]
preproc: fix terminal token pasting in indirect sequences

Fix the case where the terminal token pastes with the first token of
the unmodified sequence.  This is a really ugly version; we need to
merge the two instances plus the one in expand_mmac_params().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: error on unterminated %[...]
H. Peter Anvin [Mon, 20 Oct 2008 05:14:30 +0000 (22:14 -0700)]
preproc: error on unterminated %[...]

Make unterminated %[...] constructs an error.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: fix exit conditions for indirection loop
H. Peter Anvin [Mon, 20 Oct 2008 05:12:06 +0000 (22:12 -0700)]
preproc: fix exit conditions for indirection loop

When locating the end of a %[...] construct, we need to end up with
the pointer pointing to the terminating character.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: correctly handle quoted strings inside %[...] constructs
H. Peter Anvin [Mon, 20 Oct 2008 02:30:11 +0000 (19:30 -0700)]
preproc: correctly handle quoted strings inside %[...] constructs

We need to skip quoted strings when determining the ending point of
%[...] constructs.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agodoc: document the %[...] construct.
H. Peter Anvin [Mon, 20 Oct 2008 00:00:52 +0000 (17:00 -0700)]
doc: document the %[...] construct.

Add documentation for the %[...] construct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest: better smartalign tests
H. Peter Anvin [Sun, 19 Oct 2008 23:47:53 +0000 (16:47 -0700)]
test: better smartalign tests

Smartalign tests for 16, 32 and 64-bit mode.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agosmartalign: use a "times" construct rather than %rep
H. Peter Anvin [Sun, 19 Oct 2008 23:45:27 +0000 (16:45 -0700)]
smartalign: use a "times" construct rather than %rep

Use a "times" construct rather than "%rep" for higher performance.
No need to preprocess the same line over and over for no good reason.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agomacros.pl: handle \-continuation lines in macros.pl
H. Peter Anvin [Sun, 19 Oct 2008 23:44:02 +0000 (16:44 -0700)]
macros.pl: handle \-continuation lines in macros.pl

Correctly handle \-continuation lines in macros.pl.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agosmartalign: rewrite to use the indirect construct, %[...]
H. Peter Anvin [Sun, 19 Oct 2008 23:38:28 +0000 (16:38 -0700)]
smartalign: rewrite to use the indirect construct, %[...]

This code can be made so much smaller with clever use of the
indirection construct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest: add test for preprocessor indirection construct
H. Peter Anvin [Sun, 19 Oct 2008 23:25:57 +0000 (16:25 -0700)]
test: add test for preprocessor indirection construct

Add a test for the preprocessor indirection construct, %[...].

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: fix list iteration in the case of expand_indirect()
H. Peter Anvin [Sun, 19 Oct 2008 23:24:53 +0000 (16:24 -0700)]
preproc: fix list iteration in the case of expand_indirect()

Linked lists where an element may be deleted or substituted during
processing can be subtle to deal with.  Fix the iteration conditions
in this particular case.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agopreproc: Add new %[...] indirection construct
H. Peter Anvin [Sun, 19 Oct 2008 22:45:05 +0000 (15:45 -0700)]
preproc: Add new %[...] indirection construct

Add a new %[...] construct to support indirect macro expansion.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoNASM 2.05rc7
H. Peter Anvin [Sun, 19 Oct 2008 21:53:48 +0000 (14:53 -0700)]
NASM 2.05rc7

15 years agoELF64: once again, fix generation of "naked" OUT_REL*ADR
H. Peter Anvin [Sat, 18 Oct 2008 18:29:11 +0000 (11:29 -0700)]
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>
15 years agoNASM 2.05rc6
H. Peter Anvin [Sat, 18 Oct 2008 06:37:43 +0000 (23:37 -0700)]
NASM 2.05rc6

15 years agodoc/changes.src: document massive changes to ELF64 backend
H. Peter Anvin [Sat, 18 Oct 2008 06:36:45 +0000 (23:36 -0700)]
doc/changes.src: document massive changes to ELF64 backend

We didn't just fix the GOT stuff, but also now properly use RELA and
so forth.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoELF64: PLT32, GOTPCREL, and GOTPCREL64 really need exactitude
H. Peter Anvin [Sat, 18 Oct 2008 06:32:40 +0000 (23:32 -0700)]
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>
15 years agoELF64: the "size" argument to OUT_REL*ADR isn't really the size
H. Peter Anvin [Sat, 18 Oct 2008 06:30:54 +0000 (23:30 -0700)]
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>
15 years agoassemble: for OUT_REL*ADR, the "size" argument is not really size...
H. Peter Anvin [Sat, 18 Oct 2008 06:29:11 +0000 (23:29 -0700)]
assemble: for OUT_REL*ADR, the "size" argument is not really size...

For OUT_REL*ADR, the "size" argument is actually the offset inside the
instruction; that is in fact why we encode the real size in the
instruction itself.  Thus, emit the offsets properly using this
mechanism when generating relative EAs.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest/elf64so.asm: demonstrate a case where we bind to the wrong symbol
H. Peter Anvin [Sat, 18 Oct 2008 06:14:53 +0000 (23:14 -0700)]
test/elf64so.asm: demonstrate a case where we bind to the wrong symbol

Show an artificial case where we bind to the wrong symbol, due to the
confusion in the output system between the size of relative symbols
and their position.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoELF64: actually generate relative GOT/PLT references correctly
H. Peter Anvin [Sat, 18 Oct 2008 06:06:46 +0000 (23:06 -0700)]
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>
15 years agotest/Makefile: enable debugging info for elftest/elftest64
H. Peter Anvin [Sat, 18 Oct 2008 06:03:04 +0000 (23:03 -0700)]
test/Makefile: enable debugging info for elftest/elftest64

Enable debugging information for the ELF tests.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoELF64: GOTOFF64 doesn't need a gsym at all
H. Peter Anvin [Sat, 18 Oct 2008 05:22:17 +0000 (22:22 -0700)]
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>
15 years agoELF64: We apparently don't need exactitude for GOTOFF64
H. Peter Anvin [Sat, 18 Oct 2008 05:11:20 +0000 (22:11 -0700)]
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>
15 years agoelftest64: both Small PIC and Medium PIC model tests
H. Peter Anvin [Sat, 18 Oct 2008 05:10:33 +0000 (22:10 -0700)]
elftest64: both Small PIC and Medium PIC model tests

Try both Small PIC and Medium PIC model references.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoELF64: GOT and PLT references need a symbol (a slot!) to reference
H. Peter Anvin [Sat, 18 Oct 2008 03:01:16 +0000 (20:01 -0700)]
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>
15 years agoELF64: unbreak generating no-segment addresses
H. Peter Anvin [Sat, 18 Oct 2008 02:32:10 +0000 (19:32 -0700)]
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>
15 years agoSAA: add saa_writeaddr() similar to other locations
H. Peter Anvin [Sat, 18 Oct 2008 02:30:34 +0000 (19:30 -0700)]
SAA: add saa_writeaddr() similar to other locations

Provide saa_writeaddr() to write an integer in x86 format.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agotest/Makefile: the elftest objects depend on $(NASM)
H. Peter Anvin [Sat, 18 Oct 2008 02:29:15 +0000 (19:29 -0700)]
test/Makefile: the elftest objects depend on $(NASM)

If NASM has changed, we logically want to re-run the ELF tests...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
15 years agoELF64: use the RELA addend field instead of relying on the code stream
H. Peter Anvin [Sat, 18 Oct 2008 01:23:29 +0000 (18:23 -0700)]
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>