Commit Graph

1461 Commits

Author SHA1 Message Date
H. Peter Anvin
019a98dab1 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>
2008-10-23 16:23:19 -07:00
H. Peter Anvin
6c13a09e75 NASM 2.05rc8 2008-10-22 11:23:18 -07:00
H. Peter Anvin
49b3a3c2af 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>
2008-10-22 11:18:27 -07:00
H. Peter Anvin
e286c7e79c 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>
2008-10-22 11:15:00 -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
d3fcbf051d 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>
2008-10-19 22:25:11 -07:00
H. Peter Anvin
8b5e68079a NASM 2.05rc7 2008-10-19 14:53:48 -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
a368644138 NASM 2.05rc6 2008-10-17 23:37:43 -07:00
H. Peter Anvin
3ffd0fc157 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>
2008-10-17 23:36:45 -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
0a20bcfaf1 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>
2008-10-17 23:29:11 -07:00
H. Peter Anvin
93c7aa2302 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>
2008-10-17 23:14:53 -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
9d8b57d081 test/Makefile: enable debugging info for elftest/elftest64
Enable debugging information for the ELF tests.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-17 23:03:54 -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
15ed768673 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>
2008-10-17 22:10:33 -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
edb58f7813 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>
2008-10-17 19:30:34 -07:00
H. Peter Anvin
9a1f9f5ab6 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>
2008-10-17 19:29:15 -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
e41b69beaf Test and Makefile rules for 32- and 64-bit ELF shared libraries
Add Makefile rules for the 32-bit ELF shared library test, and add a
64-bit ELF shared library test (still work in progress.)
2008-10-17 17:13:26 -07:00
H. Peter Anvin
d83fb7e338 NASM 2.05rc5 2008-10-16 13:05:09 -07:00
H. Peter Anvin
d41e07bd2e Test for BR 2172659
Test for the bug fix for BR 2172659 (invalid byte-sized immediates.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-16 13:03:40 -07:00
H. Peter Anvin
779ed8bcfd BR 2172659: Fix incorrect output value for byte operands
A typo in checkin c1377e9a98 caused a
bunch of signed-byte immediates to incorrectly be issued as zero.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-16 13:01:43 -07:00
H. Peter Anvin
44d3552ab9 Add reference to %+ from macro parameter concatenation
Add a reference to the %+ operator from the section on macro parameter
concatenation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-15 16:18:17 -07:00
H. Peter Anvin
850ba56f1d doc: minor editorial change
Use the terms "defined" and "expanded" for single-line macros more
consistently.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-15 16:14:39 -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
H. Peter Anvin
b048324b9e Test for various ELF64 GOT references
Try to test for various GOT references in ELF64.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-15 15:22:03 -07:00
H. Peter Anvin
a3e57106fa doc: add link to the macro packages when talking about them
When discussing the standard macro packages in the context of
__USE_*__ macros, link to them as well as to the %use directive.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-15 11:15:48 -07:00
H. Peter Anvin
d5118f2009 BR 2164053: --prefix _ not --prefix_
The --prefix option takes a separate argument, not an attached
argument.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-13 10:17:27 -07:00
H. Peter Anvin
d3671e061d NASM 2.05rc4 2008-10-12 21:17:34 -07:00
H. Peter Anvin
8cd1df87e5 Document RIP-relative GOT fixes in ELF64 2008-10-12 21:17:04 -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
507ae03bd1 assemble.c: use case4() macros like in disasm.c
Use the case4() macros as we already do in disasm.c.  It helps reduce
visual clutter, and more clearly demonstrates that groups of four
belong together.  Furthermore, it makes the text compact enough that
we can now use case statements to mask down the EA patterns correctly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-09 15:37:10 -07:00
H. Peter Anvin
fa3833db81 disasm: collapse all the segment register push/pop bytecodes
As far as the disassembler is concerned, the segment register push/pop
bytecodes can be collapsed to a simple expression; the remaining
differences are handled by the filter expressions in insns.pl.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-09 14:15:36 -07:00
H. Peter Anvin
aac7c0c174 test/pushseg.asm: add "pop cs"
"pop cs" is an 8086-only opcode; we support it for assembly but not
for disassembly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 23:32:33 -07:00
H. Peter Anvin
c3ba3acf70 test/pushseg.asm: test for push/pop of segment registers
Simple test for push/pop of segment registers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 23:30:41 -07:00
H. Peter Anvin
ff6e12da50 Reshuffle and move the bytecodes for segment register push/pop
Reshuffle the bytecodes for segment register push/pop to make more
sense, and move them from \4 to \344, thus freeing up the single-digit
bytecodes \4..\7 for future use.  It doesn't really make sense to use
single-digit bytecodes for this very oddball use.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 21:17:32 -07:00
H. Peter Anvin
a5c31197f5 Collect statistics on bytecode use in insnsb.c
We are starting to have to worry about running short on available
bytecodes, especially where we encode the operand number in the byte
code.  Thus, compile a table of bytecode usage and include as a
comment in insnsb.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 16:56:35 -07:00
H. Peter Anvin
e67484e3cb NASM 2.05rc3 2008-10-08 16:25:26 -07:00
H. Peter Anvin
22098d3618 test/imul.asm: remove obsolete ERROR marker
Error already fixed...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 16:53:49 -07:00
H. Peter Anvin
e831d67cec Test for various IMUL patterns
Test for IMUL patterns.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 11:28:29 -07:00
H. Peter Anvin
65feb5ae33 Add missing IMUL pattern: reg64,imm8
Make "imul rax,byte 5" work as expected.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 11:26:41 -07:00
H. Peter Anvin
37c6d166d2 Add a few missing \15 -> \275 conversions
Add a few \15 -> \275 conversions that had been missed earlier.
Still haven't done the work on IMUL.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 10:56:32 -07:00
H. Peter Anvin
55f58acdae Change \40 class opcodes to \254, except IMUL
Change \40 class opcodes which need to be changed to \254.  IMUL will
need a separate audit; I'm not convinced we are really sure what all
the IMUL conditions should be.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 10:53:08 -07:00