summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* outmac64.c: Fix memory clobber bug, clean up memory freemachofixH. Peter Anvin2016-02-111-5/+6
| | | | | | | Fix an array that was way too small resulting in memory overwrite errors, and free a few more dynamic data structures. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* macho64: remove LC_DATA_IN_CODE, change reloc type to 1H. Peter Anvin2016-02-111-10/+1
| | | | | | | Change the relocation type to SIGNED instead of BRANCH, this is probably more correct. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* macho64: fix alignment problems, add LC_DATA_IN_CODEH. Peter Anvin2016-02-111-20/+33
| | | | | | | | | | | | Hopefully actually fix the issues with alignment this time. Avoid a linear search of segments for each symbol emitted. Issue an empty LC_DATA_IN_CODE command since that seems to be expected. With this, ffmpeg builds but still crashes on startup, which seems very strange. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* LLVM portability fix for abs(size)H. Peter Anvin2016-02-0513-14/+14
| | | | | | | | | size is actually an uint64_t, and LLVM drops the abs() on the principle that the uint64_t should always be positive. Make it explicit that we are converting to a signed integer first, by using abs((int)size) instead. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* codeview.c: remove superfluous pointer testH. Peter Anvin2016-02-051-2/+2
| | | | | | | | A pointer to a field in a structure can never be NULL so remove the test. There is no reason to test the field for an empty string either, since we immediately thereafter do a strcmp(). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* nasmlib.h: remove system definitions of ALIGN and ALIGN_MASKH. Peter Anvin2016-02-051-0/+2
| | | | | | | | Apparently some BSD flavors define these macros in a system header file; this includes MacOS X. Assume we can just #undef them without causing any additional issues; otherwise we may need to rename them. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* outmac64: Fix the handling of section data alignmentH. Peter Anvin2016-02-051-20/+30
| | | | | | | | | | | | | | | Fix a number of places which failed to account for padding to alignment of section data. Also, fix confusion between aligning section data in the linkable object code and final address alignment; LLVM/Xcode always align section data to 4 bytes (with a comment saying that it probably should be 8 bytes for 64-bit output) independent of the section alignment. This will need to be ported to the macho32 backend, as well; ideally the two should be merged as they are really very similar and we don't want to have these kinds of cross-porting problems. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* nasmlib: Add generic panic() macro, and no-return nasm_panic()H. Peter Anvin2016-02-023-7/+23
| | | | | | | | | Add a generic panic() macro which we can simply insert where an internal error happens. Also, create a nasm_panic() function the only purpose of which is to let the compiler know that we will never return after a panic. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Use a more optimal value for the UNUSED slotH. Peter Anvin2016-01-294-4/+4
| | | | | | | | Instead of ~1/4 the range we can use ~1/3 the range for better distance. It is possible that using ~1/2 - 1 might be even better, but this is a trivial tweak. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* NASM 2.12rc2nasm-2.12rc2H. Peter Anvin2016-01-271-1/+1
|
* compiler.h: disable __STRICT_ANSI__ for djgppH. Peter Anvin2016-01-271-1/+6
| | | | | | | | Undefine __STRICT_ANSI__ for djgpp; it removes the prototypes for non-ANSI functions which is not at all what this symbol is intended for. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* realpath.c: remove testing #ifdef unintentionally left inH. Peter Anvin2016-01-271-1/+1
| | | | | | | Remove the #if 0 for canonicalize_file_name(). This was added to test the realpath() code, and inadvertently left in. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Add option to allow 64-bit code in any output formatKnut St. Osmundsen2016-01-262-15/+38
| | | | | | | | | | | | | | | | | | | | Add the option --allow-64-bit to permit the generation of 64-bit code even for a 16/32-bit output format. Using NASM to do some boot strapping code and ran into trouble when trying to emit a few 64-bit instructions in the OMF object file doing the mode switching. While I can see how the "error: obj output format does not support 64-bit code" message can be a useful reality check for application programmers, it prevents low-level programmers from doing what they want. It if was just a harmless warning, it wouldn't be so bad, but it turns BITS 64 into BITS 16. The main trick to mixing 64-bit code into OMF and other 32-bit output formats is to avoid 64-bit sized fixups, which normally isn't too hard. [hpa: shortened the option name to --allow-64-bit, minor code cleanups] Signed-off-by: Knut St. Osmundsen <bird-nasm@anduin.net> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* make alldeps to remove unnecessary dependencies for realpath.cH. Peter Anvin2016-01-265-15/+5
| | | | | | | The previous commit contained unnecessary dependencies for realpath.c so run make alldeps to remove those. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* NASM 2.12rc1nasm-2.12rc1H. Peter Anvin2016-01-261-1/+1
|
* Portability improvements to nasm_realpath()H. Peter Anvin2016-01-268-22/+201
| | | | | | | | Try harder to nasm_realpath() to be as portable as possible. Move it to a separate file since it has gotten complex enough that it is cleaner that way. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* coff: Add support for the Codeview 8 debug formatJim Kukunas2016-01-245-162/+927
| | | | | | | | | | | Codeview is a debug format for win32/win64 PE/COFF files. It adds two sections, .debug$S (symbols) and .debug$T (types), to the generated object file. These sections are then used by the linker to generate a PDB file which can be used by various debuggers (WinDbg, Visual Studio, etc). Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Add a MD5 implementationJim Kukunas2016-01-244-2/+274
| | | | | | | | | | | | This implementation was written by Colin Plumb and is in the public domain. I've updated it to use stdint.h and the standard C types rather than sys/types.h for portability. Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* nasmlib: Add nasm_realpath()Jim Kukunas2016-01-242-0/+19
| | | | | | | | Converts a relative pathname to an absolute pathname. Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* NASM 2.11.09rc2nasm-2.11.09rc2H. Peter Anvin2016-01-151-1/+1
|
* smartalign.mac: Ignore smartalign in preprocess-only modeH. Peter Anvin2016-01-151-1/+3
| | | | | | | | | | | | | | When running in preprocess-only mode generate the equivalent of standard alignment using nops. This at the very least allows some kind of reasonable output and allows for dependency generation to proceed; the only way to *really* address this problem is to move alignment generation into the assembler proper; this would also allow the align/alignb distinction to be removed and handle padding with instructions which are more than one byte. This should resolve bug 3392319. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* disasm: Drop unused variableCyrill Gorcunov2015-11-051-2/+0
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* disasm: Fix disassembling of evex prefixCyrill Gorcunov2015-11-051-3/+3
| | | | | | | | | | | | | | | | | As been pointed by @hpa evex is pretty fine in ia-32. Quoting Peter | This is wrong, though; EVEX is permitted in 32-bit mode just as VEX is. | The key thing is that bits [7:5] have to be 1 in 32-bit mode. It is | unclear what happens if these bits are 110 as that depends on if it is | decoded using the modr/m decoder or not. For VEX prefixes we accept | them as VEX in that case, which may not match the CPU. This is a fix for commit db6ecf9b76a2 Reported-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: macho64 -- Fix OUT_REL4ADR on bigendiansCyrill Gorcunov2015-11-051-4/+5
| | | | | | | | | | | | We're converting address value into bigendian (on BE machine) and then continue doing arithmetics on top, which is of course incorrect. Instead do all operations first then convert to BE and write it into image. Reported-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Restore AC_C_INLINEH. Peter Anvin2015-11-041-0/+1
| | | | | | | Checkin 7729edf7224e39628bd342c3a3bb44c1753bdfb0 removed AC_C_INLINE, presumably inadvertently. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* disasm: Fix for disassembly of BOUNDMark Scott2015-11-031-1/+1
| | | | | | | | | | | | | The opcode for BOUND, 62h, has a different meaning in long mode - it is the prefix for EVEX instructions. ndisasm did not take this into account and always tried to disassemble 62h back to an EVEX instruction. Attached patch only permits EVEX disassembly if bitness is 64. In 16/32 bit mode 62h will be not be a prefix and so disassemble to BOUND. Signed-off-by: Mark Scott <nasm@mscott.cx> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* out: elf,stabs -- Fix @n_value attribute for HdrSym entryMark Scott2015-11-033-3/+3
| | | | | | | | Each stabs entry is 12 bytes in size, for some reason we've been pasing wrong attribute here in @n_value. Signed-off-by: Mark Scott <nasm@mscott.cx> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* nasmlib: Plcate undefined behaviour in signed_bitsCyrill Gorcunov2015-10-111-1/+1
| | | | | | | http://bugzilla.nasm.us/show_bug.cgi?id=3392320 Reported-by: Dingbao Xie <xiedingbao@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* disasm: Fix segment prefix nameCyrill Gorcunov2015-09-131-1/+1
| | | | | | http://bugzilla.nasm.us/show_bug.cgi?id=3392322 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* insns.dat: Add SMSW for 64 bit modeCyrill Gorcunov2015-09-131-0/+1
| | | | | | http://bugzilla.nasm.us/show_bug.cgi?id=3392323 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: aout -- Use nasm_x_space helpersCyrill Gorcunov2015-07-261-4/+1
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* insns.dat: Add PKU instructionsCyrill Gorcunov2015-07-261-0/+3
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: Update changes listCyrill Gorcunov2015-07-261-0/+14
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* NASM 2.11.09rc1nasm-2.11.09rc1Cyrill Gorcunov2015-07-251-1/+1
| | | | | | | | | - Fix symbol alignment for Elf64 - Fix symbol lookup for Macho64 - Fix relocation records for Macho64 - Fix potential stack overwrite in Macho32 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.org>
* out: maco64 -- Properly update the full 64 bit value when adding relocationsMartin Storsjö2015-07-241-3/+3
| | | | | | | | Previously only the first byte was updated (since @mydata is a an uint8_t[]). Signed-off-by: Martin Storsjö <martin@martin.st> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: outmacho32 -- Fix stack overwriteCyrill Gorcunov2015-07-211-1/+1
| | | | | | | | | | The size of address migh be up to 8 bytes here so allocate enough stack space. http://bugzilla.nasm.us/show_bug.cgi?id=3392317 Reported-by: Kyle Brodie <kylecbrodie@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: outmach64 -- Use back WRITELONG for OUT_REL4ADRCyrill Gorcunov2015-07-191-1/+1
| | | | | | | | Because of 74a08cc3f we no longer need to write all 8 bytes here, revert it back as it were before 5b730a197 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* out: Zeroify temp buffer before useCyrill Gorcunov2015-07-197-0/+14
| | | | | | | | | | | | | | | | | | This is a a buffer on stack big enough to hold bigger object we might need (address, number and etc) but it's defined as an array of bytes and we treat it as different types depending on context, which may lead to situation where data from stack been treated as meaningful. In particular in commit 5b730a197 we've fixed such problem simply using a "big" write to zeroify stack data before use. Lets simply zeroify this buffer explicitly to escape such problems in future. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* macros.pl: expand file wildcards in argumentsJim Kukunas2015-07-011-73/+76
| | | | | | | | Whereas Unix shells automatically globs wildcard arguments, Windows leaves it up to application. This commit fixes the build for perl implementations that don't handle wildcards. Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
* out: maco64 -- Fix erroneously small write for OUT_REL4ADRDelan Azabani2015-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure that the int64_t offset value, which ultimately comes from an int64_t value in gencode() (assemble.c:1906), is completely written to the temporary buffer, instead of merely its least significant 32 bits. Prior to this change, WRITELONG was used instead of WRITEDLONG, which resulted in add_reloc being passed an int64_t "reloff" whose least significant 32 bits were those from the aforementioned offset value, and whose most significant 32 bits were stack garbage from "mydata". This led to get_closest_section_symbol_by_offset() attempting to search for extremely large values of "offset" among the symbols in "syms", which meant that the last symbol with a matching section number would always win the symbol search. In effect, this clobbered the resultant relocation information, such that all entries would be resolved with the same symbol. Test output can be found here https://www.azabani.com/patch/2/output.txt This patch fixes http://bugzilla.nasm.us/show_bug.cgi?id=3392306 Signed-off-by: Delan Azabani <delan@azabani.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: typo occationallyCiro Santilli2015-05-241-1/+1
| | | | | Signed-off-by: Ciro Santilli <ciro.santilli@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: outmac64 -- Fix the case when first hit matches the symbolCyrill Gorcunov2015-05-091-1/+1
| | | | | | | | | | | In case if we're looking up for a symbol and it's first one in symbol table we might endup with error because of using GE here (78f477b35f) ending cycle with @nearest = NULL. http://bugzilla.nasm.us/show_bug.cgi?id=3392306 Reprted-by: Benjamin Randazzo <benjamin@linuxcrashing.org> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: elf64 -- increase .symtab and .rel* alignment to 8Ed Maste2015-04-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Discovered while working on ELF Tool Chain elfcopy (strip), which originally crashed on an assert while processing a nasm-generated ELF object. The .symtab and .rela.text sections report 4 byte alignment, but require 8. As an aside, see https://sourceforge.net/p/elftoolchain/tickets/485/ for a discussion of the ELF Tool Chain issue that this bug exposed. With my WIP elfcopy change and nasm-assembled jccolss2-64.o from libjpeg-turbo: % strip -o /dev/null --strip-debug jccolss2-64.o strip: section .symtab alignment 4 increased to 8 strip: section .rela.text alignment 4 increased to 8 http://bugzilla.nasm.us/show_bug.cgi?id=3392307 Signed-off-by: Ed Maste <emaste@freebsd.org> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* version: Fix the tagCyrill Gorcunov2015-02-231-1/+1
| | | | | | | | | While been preparing release I managed to write non-number sequence into @version, which might cause build problems. Lets fix it here and if a moment happens -- release 2.11.09. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* NASM 2.11.08nasm-2.11.08nasm-2.11.xxCyrill Gorcunov2015-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Fix section length computation in bin backend which leaded in incorrect relocation records. - Add a warning for numeric preprocessor definitions passed via command line which might have unexpected results otherwise. - Add ability to specify a module name record in rdoff linker with -mn option. - Increase label length capacity up to 256 bytes in rdoff backend for FreePascal sake, which tends to generate very long labels for procedures. - Fix segmentation failure when rip addressing is used in macho64 backend. - Fix access on out of memory when handling strings with a single grave. We have sixed similar problem in previous release but not all cases were covered. - Fix NULL dereference in disassembled on BND instruction. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* doc: changes -- Prepare for 2.11.08Cyrill Gorcunov2015-02-211-0/+22
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: dbg,aout,elf32 -- Fix out for signed relocationsCyrill Gorcunov2015-02-213-5/+5
| | | | | | | | @size might be negative for signed relocations but its length is abs value. This is rather a fix for future use because at moment we can't hit this problems but better be on a safe side. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* output: bin -- Fix section length miscalc for OUT_ADDRESSCyrill Gorcunov2015-02-151-0/+6
| | | | | | | | | | | | While we using proper @asize variable for relocation itself we miss the fact that @size variable (which might be negative for signed relocations since fd52c277dd6) is used to calculate section size increment. http://bugzilla.nasm.us/show_bug.cgi?id=3392299 Reported-by: Ben de Waal <ben@dewaals.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* preproc: Warn if someone predefines non ID as definitionCyrill Gorcunov2015-02-081-0/+4
| | | | | | | | | | | Not sure if someone is used this but to not break backward compatibility lets simply yield error but don't stop processing. http://bugzilla.nasm.us/show_bug.cgi?id=3392300 Reported-by: Dave Shields <thedaveshields@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* rdoff/ldrdf.c: Add option to specify target RDF module name in command lineYuri Zaporozhets2015-01-201-9/+51
| | | | | | | | | | Rationale: this is useful for projects developed entirely in high-level language and which use NASM as a backend (compilers able to generate NASM code are e.g. ncc or Free Pascal). With this option there is no need to have a single assembly language file for each project with just one "module NNN" directive — it is enough now to specify the name as an argument to ldrdf. Signed-off-by: Yuri Zaporozhets <r_tty@yahoo.co.uk>