summaryrefslogtreecommitdiff
path: root/output/codeview.c
Commit message (Collapse)AuthorAgeFilesLines
* BR 3392650: Codeview truncates symbol table length to 16 bitsH. Peter Anvin (Intel)2020-06-261-9/+9
| | | | | | | | | | If the source code is large, it is very reasonable for the symbol table length to exceed 2^16 bits. Use uint32_t to keep track of lengths, even where not necessary... there is no real reason to use uint16_t anywhere. Reported-by: <michael@mehlich.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392651: fix the .debug$T section in Codeview output formatH. Peter Anvin (Intel)2020-06-251-24/+20
| | | | | | | | | | | | | | The cv8 output format would generate an invalid .debug$T section, containing repeated invalid records, none of which are actually used (which is probably the only reason it actually worked.) Just in case, generate a *single* type record for void func(void); Furthermore, the argument list record should come before the procedure type record (forward references are at least normatively prohibited.) Reported-by: Alexandre Ganea <alexandre.ganea@ubisoft.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Additional listing options, improve help output, fix macro limitsH. Peter Anvin2019-08-101-1/+1
| | | | | | | | | | | | | | | | | | Additional listing options: -Ld to display counts in decimal -Lp to output a list file in every pass (to make sure one exists) Clean up the help output and make it comprehensive. The -hf and -y options are no longer necessary, although they are supported for backwards compatiblity. Fix macro-levels so it actually count descent levels; a new macro-tokens limit introduced for the actual token limit. Slightly simplify the limits code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Remove #includes already provided by "compiler.h"H. Peter Anvin2018-12-271-3/+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>
* nasm_assert(): try to run at compile time if possibleH. Peter Anvin (Intel)2018-12-141-2/+2
| | | | | | | | | | Try to make nasm_assert() do a static assert if the argument can be evaluated at compile time by any particular compiler. We also provide nasm_try_static_assert() which will assert a compile-time expression if and only if we can determine we have a constant at compile time *and* we know that the compiler has a way to handle it. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* hashtbl: revamp the hash table interface, support binary keysH. Peter Anvin (Intel)2018-12-111-1/+0
| | | | | | | Add binary key support to the hash table interface. Clean up the interface to contain less extraneous crud. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* output: codeview -- Use nasm_error helpersCyrill Gorcunov2018-12-011-3/+3
| | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* errors: simplify nasm_fatal() and nasm_panic()H. Peter Anvin2018-06-151-1/+1
| | | | | | | | | | | | | | | Nearly all instances of nasm_fatal() and nasm_panic() take a flags argument of zero. Simplify the code by making nasm_fatal and nasm_panic default to no flags, and add an alternate version if flags really are desired. This also means that every call site doesn't have to initialize a zero argument. Furthermore, ERR_NOFILE is now often not necessary, as the error code will no longer cause a null reference if there is no current file. Therefore, we can remove many instances of ERR_NOFILE which only deprives the user of information. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* output: codeview -- change version number writtenFabian Giesen2018-04-201-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows Store and Xbox One apps need to pass WACK, the Windows App Certification Kit, and part of that process involves a tool named BinScope that checks the debug info of all object files making up the final executable against a list of minimum versions. These minimum versions get increased periodically as new SDKs and compilers are released. In a patch 2 years ago, I made NASM pretend it was MASM and output a then-current MASM version number. Well, the minimum version number has increased again, and periodically hardcoding a new random MASM version to keep BinScope happy doesn't seem like the way to go. It turns out that BinScope does not impose any minimum version requirements on object files listing a source language BinScope doesn't know about. I have no idea how to officially request a new CodeView language ID (or whether there even is a way to do so for someone outside MS). But experimentally, using 'N' (0x4e) for NASM seems to be working just fine and is far away from the range of currently allocated language IDs (which stop at 0x10). Long story short, make NASM emit a source language ID of 0x4e, with the actual NASM version in the version number fields. BinScope is happy to accept that, and since the language ID field is purely an informational field in an optional debug info record that (as far as I can tell) is not used for anything else, this seems reasonably safe and unlikely to cause trouble. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Eliminate filename length restrictions, remote ofmt->filename()H. Peter Anvin2017-12-201-1/+1
| | | | | | | | | | | Get rid of remaining dependencies on FILENAME_MAX, which ought to have been removed a long time ago. Remove ofmt->filename(); all implementations pretty much do the same thing and there is absolutely no reason to duplicate that functionality all over the place. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* a) Fix handling of DZ/ZWORD; b) don't crash on TIMES JMPH. Peter Anvin2017-05-011-0/+3
| | | | | | | | | | | | | | | a) Fix a number of missing instances of DZ and ZWORD. b) NASM would crash if TIMES was used on an instruction which varies in size, e.g. JMP. Fix this by moving the handling of TIMES at a higher level, so we generate the instruction "de novo" for each iteration. The exception is INCBIN, so we can avoid reading the included file over and over. c) When using the RESx instructions, just fold TIMES into the reserved space size; there is absolutely no point to iterate over it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Add a generic pragma-handling infrastructureH. Peter Anvin2017-03-071-0/+1
| | | | | | | Add infrastructure for handling %pragmas with a variety of namespaces, etc., etc... Signed-off-by: H. Peter Anvin <hpa@linux.intel.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>
* output/codeview.c: remove C99-ismH. Peter Anvin2017-02-231-3/+4
| | | | | | | Remove a C99-ism, specifically the use of a variable declaration inside a for loop statement. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* codeview: Fix ill-formed "S_COMPILE2" record.Fabian Giesen2016-07-181-8/+16
| | | | | | | | | | | | | | write_symbolinfo_properties didn't match the S_COMPILE2 record it's supposed to be writing (the "compiler version" string was emitted starting in the final "version" field); fix that. Write version 8.0.50727; the Windows App Certification Kit (WACK) checks compiler versions as given in app debug info and complains when the toolchain is too old. 8.0.50727 is the lowest permitted "MASM" version for WACK to be happy, so that's what we write. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Reorganize the source code into subdirectoriesH. Peter Anvin2016-05-251-2/+2
| | | | | | | 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>
* Add wrappers around fopen(), use mmap on glibcH. Peter Anvin2016-05-251-1/+1
| | | | | | | | | | Add wrappers to fopen(). The intent is to replace references to FILE * with an internal structure which can also cache things like the filename and, when needed, the full pathname and checksums. Also, add the "m" flag if we are compiling for glibc, for speed. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Merge remote-tracking branch 'origin/nasm-2.12.xx'H. Peter Anvin2016-05-241-61/+155
|\ | | | | | | | | | | | | Resolved Conflicts: version Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * codeview: use nasm_realpath() to find the canonical name of the outfileH. Peter Anvin2016-05-241-21/+18
| | | | | | | | | | | | | | | | | | Concatenating the cwd with the name of the output file is incorrect for filenames which are specified as absolute. We already have nasm_realpath() for this purpose, use it. Cc: Jim Kukunas <james.t.kukunas@intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * codeview: don't walk the file list for every lineH. Peter Anvin2016-05-241-43/+54
| | | | | | | | | | | | | | | | | | Instead of walking a linear list of files for every line, make a simple comparison for the common case of the same file, and otherwise use a hash table. Cc: Jim Kukunas <james.t.kukunas@intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * codeview.c: register all filenamesJim Kukunas2016-05-171-2/+2
| | | | | | | | | | | | | | | | | | This essentially reverts 6503051dcc360172c49311d586f2b9cf4ab2ea81 since that workaround is no longer needed thanks to support for multiple source files Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * codeview.c: Add support for multiple source filesJim Kukunas2016-05-171-34/+120
| | | | | | | | | | | | | | | | Handle the existence of multiple source files, as is normal when using include files. Signed-of-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | Merge remote-tracking branch 'origin/nasm-2.12.xx'H. Peter Anvin2016-05-161-3/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved Conflicts: .gitignore Makefile.in Mkfiles/msvc.mak Mkfiles/netware.mak Mkfiles/openwcom.mak Mkfiles/owlinux.mak preproc-nop.c preproc.c version Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * codeview: use nasm_free() instead of plain free()H. Peter Anvin2016-05-101-3/+3
| | | | | | | | | | | | | | We want to consistently use our allocator wrapper functions whereever possible. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * codeview: Call register_file only when producing line numbersFabian Giesen2016-05-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, debug info would refer to the first file seen, even when it did not actually generate line numbers (e.g. segto=-1). Fix it so we only lock in the file name the first time we actually produce a line number record. Not as good as proper support for debug info referencing multiple source files but much more useful than the current behavior. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
| * codeview: Make md5sum calc read file in 'binary' modeFabian Giesen2016-05-101-1/+1
| | | | | | | | | | | | | | | | | | When assembling on Windows machines with CRLF line endings, computing the MD5 hash from the file read in "text" mode (transforms CRLF->LF) gives incorrect results. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
| * codeview: Look up %include path when determining files to hash.Fabian Giesen2016-05-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The hash calculation in calc_md5 tries to open the source file via "filename" again. For %includes, this is the file name that was specified in the %include directive, not the actual name of the file that was opened by the preprocessor. In other words, this fails if the include file is not in the current working directory. Add pp_input_fopen that uses the preprocessor include path lookup code to resolve a file name and open it, and use that in codeview.c. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | codeview: Call register_file only when producing line numbersFabian Giesen2016-04-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, debug info would refer to the first file seen, even when it did not actually generate line numbers (e.g. segto=-1). Fix it so we only lock in the file name the first time we actually produce a line number record. Not as good as proper support for debug info referencing multiple source files but much more useful than the current behavior. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | codeview: Make md5sum calc read file in 'binary' modeFabian Giesen2016-04-301-1/+1
| | | | | | | | | | | | | | | | | | When assembling on Windows machines with CRLF line endings, computing the MD5 hash from the file read in "text" mode (transforms CRLF->LF) gives incorrect results. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | codeview: Look up %include path when determining files to hash.Fabian Giesen2016-04-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The hash calculation in calc_md5 tries to open the source file via "filename" again. For %includes, this is the file name that was specified in the %include directive, not the actual name of the file that was opened by the preprocessor. In other words, this fails if the include file is not in the current working directory. Add pp_input_fopen that uses the preprocessor include path lookup code to resolve a file name and open it, and use that in codeview.c. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | Merge remote-tracking branch 'origin/nasm-2.12.xx'H. Peter Anvin2016-03-081-17/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | Resolved Conflicts: output/codeview.c output/outelf32.c output/outelf64.c output/outelfx32.c output/outform.c output/outform.h output/outieee.c output/outobj.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * codeview: remove hack for handling local labelsH. Peter Anvin2016-03-071-17/+2
| | | | | | | | | | | | | | | | | | | | Now when labels are properly concatenated in common code, there is no reason for the debugging backend to need to be aware of local symbols. We don't have to consider ..[^@] special symbols either, as they are now filtered in labels.c. Signed-off-by: H. Peter Anvin <hpa@zytor.com> Debugged-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
* | codeview: Don't treat labels starting with .. as local labelsJim Kukunas2016-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | For local labels, starting with '.', the label name is concatenated with the previous non-local label to produce a label that can be accessed from elsewhere. This is the name we want to generate debug info for. Labels starting with ".." are special and shouldn't be concatenated. Fix Bugzilla #3392342 Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
* | Merge branch 'nasm-2.12.xx'H. Peter Anvin2016-03-071-1/+1
|\ \ | |/ | | | | | | | | | | Resolved Conflicts: compiler.h Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * codeview: be a bit more explicit about the nature of a panicH. Peter Anvin2016-03-031-1/+1
| | | | | | | | | | | | | | | | When we have to die due to an assertion violation, then show the missing symbol. Also, use nasm_panic() rather than nasm_assert() for this purpose. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * Remove unnecessary C99-ismsH. Peter Anvin2016-03-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to make it more likely to compile cleanly with "C90 plus long long" style compilers, remove existing constructs (mostly commas at the end of enums) that aren't compliant. Ironically enough this was most likely an unintentional omission in C90... From master branch checkin 7214d18b405f883010a74a3f8281c7906a5a21ca Resolved Conflicts: output/outelf32.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Remove unnecessary C99-ismsH. Peter Anvin2016-03-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | In order to make it more likely to compile cleanly with "C90 plus long long" style compilers, make gcc warn for incompatible constructs. Remove existing constructs (mostly commas at the end of enums) that aren't compliant. Ironically enough this was most likely an unintentional omission in C90... Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Merge branch 'nasm-2.12.xx'H. Peter Anvin2016-03-011-9/+9
|\ \ | |/ | | | | | | | | | | | | Resolved Conflicts: configure.in output/codeview.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * Remove unnecessary C99 features which break Visual C++ 2010Knut St. Osmundsen2016-02-261-9/+9
| | | | | | | | | | | | | | | | Fixes Visual C++ 2010 breakage in recently added Codeview 8 code; these are C99 features which were not necessary to introduce. Signed-off-by: Knut St. Osmundsen <bird-nasm@anduin.net> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | codeview: make struct dfmt df_cv8 constH. Peter Anvin2016-02-181-1/+1
|/ | | | | | This one was not declared const; fix that. 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>
* coff: Add support for the Codeview 8 debug formatJim Kukunas2016-01-241-0/+720
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>