summaryrefslogtreecommitdiff
path: root/nasmlib.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-20MPX: Add BND prefix for branch instructionsJin Kyu Song1-1/+1
BND prefix is used for adding bounds checking protection across flow control changes such as call, ret, jmp and jcc calls. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-10-02Add support for DZ and RESZ, document the ZWORD keywordH. Peter Anvin1-1/+3
Add the DZ and RESZ pseudoinstructions and add ZWORD to the documentation. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2012-05-02nasmlib: Shrink idata_bytesCyrill Gorcunov1-20/+9
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-02-24HLE: Implement the basic mechanism for XACQUIRE/XRELEASEH. Peter Anvin1-2/+3
This implements the mechanism for XACQUIRE/XRELEASE. It does not include the necessary annotations in insns.dat. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2011-07-17Drop unused 'opt' from nasm_opt_valCyrill Gorcunov1-2/+2
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25Move numvalue herleper into nasmlib.hCyrill Gorcunov1-2/+1
No need to duplicate implementation. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-04-09Revert "nasmlib: added string replace (strrep) utility function"Keith Kanios1-80/+0
This reverts commit dd9c9752ead3a39fec6f050bfe3ac8768defc02f.
2011-04-09Revert "nasmlib.c: fix issues with strrep utility function"Keith Kanios1-9/+7
This reverts commit f16401f9aabb550a556d3a462f428a3b52f6f9c3.
2011-04-08nasmlib.c: fix issues with strrep utility functionKeith Kanios1-7/+9
2011-04-08nasmlib: added string replace (strrep) utility functionKeith Kanios1-0/+80
2010-07-29nasmlib.c: fix typo in nasm_init_malloc_errorCyrill Gorcunov1-1/+1
Typo happened in 9b603082 so -DLOGALLOC gets broken. Not that important since this is a developer oriented feature but should be fixed anyway. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-06-03nasmlib: Rename elements() macro to ARRAY_SIZECyrill Gorcunov1-1/+1
ARRAY_SIZE is a well known name pointing out that we're dealing with array in macro argument. Also to be on a safe side prefix_name helper should check the index been in bounds more precisely. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11nasmlib.c: Make nasm_opt_val robustCyrill Gorcunov1-15/+34
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>
2010-04-11nasmlib.c: Introduce nasm_get_word helperCyrill Gorcunov1-0/+21
For easier space separated words extraction from a text stream. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10nasmlib: Do not hang on if log file creation has been failedCyrill Gorcunov1-2/+7
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>
2010-04-10nasmlib: Introduce nasm_trim_spaces and nasm_opt_val helpersCyrill Gorcunov1-0/+35
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-24nasmlib.c: Use UINT64_C for 64bit constantsCyrill Gorcunov1-2/+2
In a sake of portability we should better use UINT64_C instead of open-coded ULL postfix. [ BR2938449 ] Reported-by: Alexander Ilyin <dragity@mail.ru> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31nasmlib: Introduce idata_bytes helperCyrill Gorcunov1-0/+38
This allow us to eliminate code duplication Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-13nasm: rename nasm_zap_spaces() to nasm_zap_spaces_fwd()H. Peter Anvin1-1/+1
By analogy with nasm_zap_spaces_rev() have nasm_zap_spaces_fwd(). The forward version isn't a super-common operation, and it might be possible to think the reverse one is the "normal" version... therefore we might as well be explicit. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-10-13nasmlib: introduce string helpersCyrill Gorcunov1-0/+36
To make code more compact we introduce the following string helpers: 1) nasm_scip_spaces - skip leading spaces 2) nasm_skip_word - skip leading non-spaces 3) nasm_zap_spaces - zap leading spaces with zero 4) nasm_zap_spaces_rev - zap spaces in reverse order Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-07-18Remove function pointers in output, simplify error handlingH. Peter Anvin1-21/+32
Remove a bunch of function pointers in the output stage; they are never changed and don't add any value. Also make "ofile" a global variable and let the backend use it directly. All we ever did with these variables were stashing it in locals and using them as-is anyway for no benefit. Also change the global error function, nasm_error() into a true function which invokes a function pointer internally. That lets us use direct calls to it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06NASM: relicense under the 2-clause BSD licenseH. Peter Anvin1-12/+0
*To the best of my knowledge*, we now have authorization from everyone who has significantly contributed to NASM in the past. As such, change the license to the 2-clause BSD license. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-05Change noreturn macro to no_return to avoid header file problemsH. Peter Anvin1-1/+1
Change the "noreturn" macro to "no_return", to avoid problems with system header files which use __attribute__((noreturn)) rather than __attribute__((__noreturn__)) as is appropriate for system headers. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-01nasmlib: add nasm_assert(); use const char * for filenamesH. Peter Anvin1-7/+14
Add new nasm_assert() function, and add "const" to the declarations which take filenames, as well as to the nasm_strdup/strndup functions. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28Add copyright headers to the *.c/*.h files in the main directoryH. Peter Anvin1-5/+46
Add copyright headers to the *.c/*.h files in the main directory. For files where I'm sure enough that we have all the approvals, I have given them the 2-BSD license, the others have been given the "LGPL for now" license header. Most of them can probably be changed after auditing. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27Move backend-specific code to output/; break out null debug stuffH. Peter Anvin1-54/+0
Move backend-specific code into the output/ directory, and make the null debugging backend a separate file (it certainly isn't needed for ndisasm...) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-02-21BR 2592476: Treat WAIT as a prefix even though it's really an instructionH. Peter Anvin1-2/+2
WAIT is technically an instruction, but from an assembler standpoint it behaves as if it had been a prefix. In particular, it has to be ordered *before* any real hardware prefixes.
2009-02-21nasmlib: make nasm_strcat() take const argumentsH. Peter Anvin1-1/+1
None of the strings passed to nasm_strcat() are modified, to make them const.
2009-02-21Unify all-zero buffers; add fwritezero()H. Peter Anvin1-0/+23
We have a number of all-zero buffers in the code. Put a single all-zero buffer in nasmlib.c. Additionally, add fwritezero() which can be used to write an arbitrary number of all-zero bytes; this prevents the situation where the all-zero buffer is simply too small.
2008-06-28nasmlib: fix nasm_str[n]icmp()H. Peter Anvin1-4/+4
Fix nasm_str[n]icmp() on platforms which don't have this function natively. XXX: Given the new nasm_tolower() implementation, we should consider if this might actually be a faster function than the platform-native one.
2008-06-21ctype.h: wrapper ctype functions with a cast to (unsigned char)H. Peter Anvin1-2/+2
ctype functions take an *int*, which the user is expected to have taken the input character from getc() and friends, or taken a character and cast it to (unsigned char). We don't care about EOF (-1), so use macros that cast to (unsigned char) for us.
2008-06-11Use an explicit table for tolower() to avoid a function callH. Peter Anvin1-2/+17
On some platforms, tolower() is implemented as a function call, in order to handle locale support. We never change locales, so can the result of tolower() into a table, so we don't have to sit through the function call every time. ~1.3% overall performance improvement on a macro-heavy benchmark under Linux x86-64.
2008-06-10nasmlib.c: fwriteint*() only need WORDS_LITTLEENDIANH. Peter Anvin1-2/+2
fwriteint*() don't require unaligned references, so they can be optimized for WORDS_LITTLEENDIAN rather than X86_MEMORY...
2008-06-09Move all the RAA code out of nasmlibH. Peter Anvin1-93/+0
The RAA code doesn't have to be in nasmlib; it is only used by nasm itself, and is better handled in a separate module.
2008-06-09Move all the SAA code out of nasmlibH. Peter Anvin1-305/+0
Move all the SAA code out of nasmlib; it's not used by anything than nasm itself. Cleaning out the kitchen sink known as nasmlib is a good thing, too.
2008-06-01qstring: backquoted strings seem to work now...H. Peter Anvin1-18/+45
Hopefully backquoted strings should work correctly now.
2008-06-01qstring: first cut at full quoted string support in the preprocessorH. Peter Anvin1-225/+0
First attempt at properly handle quoted strings in the preprocessor. This also adds range support in %substr. No support in the assembler yet.
2008-06-01qstring: add nasm_unquote() supporting `...`H. Peter Anvin1-0/+205
Add a nasm_unquote() function supporting the intended `...` syntax.
2008-05-30Introduce %depend and %pathsearch, and make incbin a macroH. Peter Anvin1-0/+2
Introduce new preprocessor directives %depend and %pathsearch, and make incbin a standard macro using these filenames. This lets us remove the code that makes incbin search the path.
2008-05-04First cut at AVX machinery.H. Peter Anvin1-3/+3
First cut at AVX machinery support. The only instruction implemented is VPERMIL2PS, and it's probably buggy. I'm checking this in with the hope that other people can start helping out with (a) testing this, and (b) adding instructions. NDISASM support is not there yet.
2008-02-24Dwarf3 support for ELF32Charles Crayne1-0/+55
1. Port dwarf3 support from ELF64 to ELF32 2. Move common SAA extentions to nasmlib
2008-01-21RAA subsystem: use shift instead of divideH. Peter Anvin1-16/+12
Make the RAA size always a power of two, so we can use shifts instead of multiple, expensive divides.
2008-01-21nasmlib.c: log nasm_free() before calling free()H. Peter Anvin1-1/+1
If we're logging nasm_free(), then log it before we actually call free(); that way we can find out what the last thing was if free() crashes.
2008-01-08BR 1864243: better warnings for out-of-range constantsH. Peter Anvin1-1/+1
In particular, we'd miss issuing warnings for out-of-range dword values, and the message for constants too large (we can't deal with > 64 bits) said 32 bits, not 64.
2007-12-29regularized spelling of license to match name of LICENSE fileBeroset1-1/+1
2007-11-19BR 877583: Fix RAA memory leakH. Peter Anvin1-3/+2
raa_free() didn't actually do the proper job; it would only free leaf nodes, not internal nodes.
2007-11-17Check in Keith's FixesCharles Crayne1-8/+5
1. Don't warn on 32-bit overflow 2. Change EM64T to Intel 64 in Defining CPU Dependencies section of documentation.
2007-11-13Clean up the fwrite*() function definitions somewhatH. Peter Anvin1-16/+12
Slight cleanup of the fwrite*() functions. This actually helps gcc generate better code on i386, for no apparent reason.
2007-11-13x86-host-specific performance improvementH. Peter Anvin1-0/+30
If we're on an x86 host, we can do unaligned littleendian memory references directly. Just do'em.
2007-11-13Address data is int64_t; simplify writing an address objectH. Peter Anvin1-14/+16
Address data is always int64_t even if the size itself is smaller; this was broken on bigendian hosts (still need testing!) Create simple "write sized object" macros.