summaryrefslogtreecommitdiff
path: root/disasm
Commit message (Collapse)AuthorAgeFilesLines
* disam: explicitly change stdin to binary modeChang S. Bae2020-04-221-1/+3
| | | | | | | | | | | | | | | | | | | The binary mode has no difference from text mode in POSIX-compliant operating systems. The two modes are distinguishable from each other on Windows, and perhaps on other systems as well. The binary stream has scalability and other advantages. Windows treats the standard input stream as text mode by default. So the code changes it to binary mode. Also, add a helper function, nasm_set_binary_mode(), that is OS-agnostic, in the library. Reported-by: Didier Stevens <didier.stevens@gmail.com> Suggested-by: Didier Stevens <didier.stevens@gmail.com> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392649 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* error: replace nasm_verror() indirection with preproc callbackH. Peter Anvin2019-08-281-10/+10
| | | | | | | | | | Since pp_error_list_macros() was introduced, the only need for pp_verror() is to suppress error messages in certain contexts. Replace this function with a preprocessor callback, preproc->pp_suppress_error(), so we can drop the nasm_verror() function pointer entirely. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* errors: be more robust in handling unexpected fatal errorsH. Peter Anvin2019-08-281-4/+10
| | | | | | | | | | | | | Introduce a new error level, ERR_CRITICAL, beyond which we will minimize the amount of code that will be executed before we die; in particular don't execute any memory allocations, and if we somehow end up recursing, abort() immediately. Basically, "less than panic, more than fatal." At this point this level is used by nasm_alloc_failed(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Remove #includes already provided by "compiler.h"H. Peter Anvin2018-12-273-8/+0
| | | | | | | | "compiler.h" already includes a bunch of common include files. There is absolutely no reason to duplicate them in individual files, and in fact it robs us of central control of how these files are used. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Replace <ctype.h> includes with "nctype.h"H. Peter Anvin2018-12-271-1/+1
| | | | | | | For almost everything we should use "nctype.h". Right now we don't have a nasm_toupper() to use <ctype.h> for things that need toupper(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Move <string.h> inclusion to compiler.hH. Peter Anvin2018-12-262-2/+0
| | | | | | | There is absolutely no reason not to include <string.h> globally, and with the inline function for mempcpy() we need it there anyway. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* errors: change the severity parameter from "int" to "errflags"H. Peter Anvin (Intel)2018-12-131-1/+1
| | | | | | | Change the severity parameter to the error function from "int" to an unsigned typedef, currently uint32_t. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* ctype: create our own ctype tableH. Peter Anvin2018-11-281-1/+1
| | | | | | | | Create our own ctype table where we can do the tests we want to do cheaply, instead of calling ctype functions and then adding additional tests all over the code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* disasm: Fix buffer overread in ndisasmCyrill Gorcunov2018-08-163-7/+33
| | | | | | | https://nvd.nist.gov/vuln/detail/CVE-2018-10254 https://sourceforge.net/p/nasm/bugs/561/ Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* asm: support the +n syntax for register setsH. Peter Anvin2018-06-251-0/+3
| | | | | | | Support the +n syntax for multiple contiguous registers, and emit it in the output from ndisasm as well. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* asm/*: Move directive processing to its own file, refactor error handlingH. Peter Anvin2017-03-071-0/+1
| | | | | | | | Move directive processing to its own file, and move nasmlib/error.c to asm/error.c (it was not used by the disassembler); remove some extern declarations from .c files, and do some general code cleanups. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* disasm: Add support for 64-bit originRuslan Kabatsayev2017-02-125-13/+13
| | | | | | | | | | | | | | This fixes disassembly of instructions like jmp/call when target address is larger than 2^32-1, and also printing of current address when it's large. After this change ndisasm still assumes that the files to disassemble will never reach 4GiB: only offsets are made 64 bit, but not lengths. https://bugzilla.nasm.us/show_bug.cgi?id=3392349 Signed-off-by: Ruslan Kabatsayev <b7.10110111@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* disasm: matches -- fix operator priority error with parenthesisMartin Lindhe2017-01-051-1/+1
| | | | | | | | fixes pvs-studio error 'V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a lower priority than the '!=' operator.' Signed-off-by: Martin Lindhe <martin-commit@ubique.se> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Dont set @mod twiceMartin Lindhe2017-01-051-1/+0
| | | | | | | | pvs-studio: V519 The 'mod' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 398, 405. Signed-off-by: Martin Lindhe <martin-commit@ubique.se> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Reorganize the source code into subdirectoriesH. Peter Anvin2016-05-255-0/+2358
Make the source code easier to understand and keep track of by organizing it into subdirectories depending on the function. Signed-off-by: H. Peter Anvin <hpa@zytor.com>