summaryrefslogtreecommitdiff
path: root/output/outrdf2.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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-261-1/+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>
* Clean up the handling of various passesH. Peter Anvin (Intel)2018-12-181-6/+4
| | | | | | | | | The use of pass0, pass1, pass2, and "pass" passed as an argument is really confusing and already caused a severe bug in the 2.14.01 release cycle. Clean them up and be far more explicit about what various passes mean. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* errors: simplify nasm_fatal() and nasm_panic()H. Peter Anvin2018-06-151-10/+9
| | | | | | | | | | | | | | | 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: remove ABSOLUTE handling, OUT_RAWDATA assertsH. Peter Anvin2018-06-151-10/+0
| | | | | | | | | | | ABSOLUTE handling can be done centrally, and shouldn't need to be in every backend. Simply drop the call to ofmt->output(). Many backends have an assert for OUT_RAWDATA not having a target segment; this doesn't make any sense as output/legacy.c will not allow that to happen. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* output: centralize the null definition of ofmt->segbaseH. Peter Anvin2018-06-141-6/+1
| | | | | | | Only two output formats (obj and ieee) actually need ofmt->segbase, so move the common dummy definion into nullout.c. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Add support for backend-defined subsections and label hacksH. Peter Anvin2018-05-301-0/+2
| | | | | | | | | | MachO has this odd thing called "subsections via symbols", by which a symbol can magically start what effectively is a new section. To support this, add support for a calldown into the backend when a new symbol is defined *at the current output location*, and allow it to switch the current segment. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Eliminate filename length restrictions, remote ofmt->filename()H. Peter Anvin2017-12-201-6/+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>
* Add generic perfect string hashes, use for directivesH. Peter Anvin2017-04-031-1/+1
| | | | | | | | | | | | | | Add a generic facility for generating perfect string hashes, where all that is needed is an enum and a string table. The existing mechanism using a custom Perl script wrapped around a module continues to be available for any use case where this particular approach isn't sophisticated enough. Much of this patch comes from renaming "enum directives" to "enum directive" as a result of the string hash generator expecting a set of uniform naming conventions. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* output: remove the completely unused set_info methodH. Peter Anvin2017-03-311-8/+0
| | | | | | | Every single backend has this method set to NULL. It is also a rather strange interface. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* output: make the return value from the directives method more meaningfulH. Peter Anvin2017-03-071-6/+7
| | | | | | | | | The directives code is already trying to do a bit more unified error handling, so give ourselves a bit richer interface. At this point, the conversion was pretty automatic so we probably return DIRR_OK instead of DIRR_ERROR in a fair number of places, but that's okay. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Add a generic pragma-handling infrastructureH. Peter Anvin2017-03-071-1/+2
| | | | | | | 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>
* backend: move wrapper for legacy output functions to a library routineH. Peter Anvin2016-09-241-0/+1
| | | | | | | Move the wrapper for legacy output into a library routine so the backends can be ported one at a time. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Reorganize the source code into subdirectoriesH. Peter Anvin2016-05-251-4/+4
| | | | | | | 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>
* lib: split library into stdlib and nasmlib; header handling fixesH. Peter Anvin2016-03-081-1/+0
| | | | | | | | | | | | | Split lib/ into nasmlib/ (for nasm-specific functions) and stdlib/ (for replacements for C library functions which may be missing.) Rename the ersatz inttypes.h to nasmint.h so we can use a simple test in compiler.h instead of dealing with include path magic. Remove tests in configure.in for ancient missing functions (which will break the build anyway.) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Merge remote-tracking branch 'origin/nasm-2.12.xx'H. Peter Anvin2016-03-081-3/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ofmt: get rid of the debuginfo parameter to ofmt->cleanup()H. Peter Anvin2016-03-071-3/+1
| | | | | | | | | | | | | | | | | | | | Get rid of the completely pointless "debuginfo" parameter to ofmt->cleanup(). Most backends completely ignore it, and the two that care (obj, ieee) can simply test dfmt instead. Also, dfmt is never NULL, so any test for a NULL dfmt is bogus. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Merge remote-tracking branch 'origin/nasm-2.12.xx'H. Peter Anvin2016-03-071-9/+9
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved Conflicts: .gitignore Makefile.in assemble.c configure.in eval.c float.c listing.c nasm.c nasmlib.c output/outform.h preproc.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * Replace nasm_error(ERR_FATAL/ERR_PANIC) with nasm_fatal/nasm_panicH. Peter Anvin2016-03-031-9/+9
| | | | | | | | | | | | | | | | Replace all instances of ERR_FATAL or ERR_PANIC with nasm_fatal or nasm_panic so the compiler knows that these functions cannot return, *and* we trigger abort() if we were to ever violate that constraint. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | output: make all instances of struct ofmt readonlyH. Peter Anvin2016-02-171-1/+1
|/ | | | | | | With current_dfmt gone, we can make all instances of struct ofmt const (read-only). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Replace global maxbits variable with field in struct ofmtH. Peter Anvin2016-02-111-2/+1
| | | | | | | maxbits is strictly a property of the output format, so get rid of this ad hoc method of reporting. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* LLVM portability fix for abs(size)H. Peter Anvin2016-02-051-1/+1
| | | | | | | | | 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>
* Replace unchecked fwrite() callsH. Peter Anvin2014-10-211-1/+1
| | | | | | | Instead of having unchecked fwrite() calls, introduce nasm_write() which does error checking (and fatal errors if the write fails). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* output: Allow OUT_ADDRESS with a negative size to mean signed relocationH. Peter Anvin2013-11-261-4/+5
| | | | | | This only matters for ELF64/ELFx32, at least for now. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Rename SEGALIGN to SECTALIGNCyrill Gorcunov2010-04-211-1/+1
| | | | | | | "sectalign" is preferred over "segalign" since it operates over section attributes. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* ofmt: Implement null_segalign stubsCyrill Gorcunov2010-04-211-0/+1
| | | | | | Set stubs for all targets Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Remove function pointers in output, simplify error handlingH. Peter Anvin2009-07-181-40/+30
| | | | | | | | | | | | | | | 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>
* Hash even backend-specific directives, unify null functionsH. Peter Anvin2009-07-121-15/+19
| | | | | | | | | Hash all directives, even the ones that are backend-specific, and instead pass the backend an already-parsed directive number. Furthermore, unify null functions across various backends. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Don't fclose() the output in the backendH. Peter Anvin2009-07-121-2/+0
| | | | | | | | | | | | | | | | We fopen() the output file in common code but fclose() it in the backend. This is bad for a variety of reasons: 1. it is generally an awkward interface to change ownership. 2. we should use ferror() to test for write errors, and that is better done in common code. 3. it requires more code. 4. we still need to fclose() in common code during error handing. Thus, move the fclose() of the output out of the backends, and add fflush() so we can test ferror() on output. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Make it possible for outputs to be either text or binaryH. Peter Anvin2009-07-051-1/+1
| | | | | | | | | | | Allow the backend to specify that an output format is either text or binary. For future uses, define this as a flag word so we can define other flags in the future if it would make sense. Currently, the ieee and dbg formats are text; all the others are binary. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Add new copyright headers to the output modulesH. Peter Anvin2009-06-281-5/+33
| | | | | | | | Add new copyright headers to the new output modules. As far as I know, the only module which we still don't have a green light to release under 2-BSD is outmacho. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Move prototypes for null_debug to outform.h and outlib.hH. Peter Anvin2009-06-271-0/+1
| | | | | | | | Move the prototypes for the null debugging format to outform.h (for the top-level structure declaration only) and outlib.h (for the internal routines.) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Move backend-specific code to output/; break out null debug stuffH. Peter Anvin2009-06-271-1/+1
| | | | | | | | 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>
* ctype.h: wrapper ctype functions with a cast to (unsigned char)H. Peter Anvin2008-06-211-3/+3
| | | | | | | | | 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.
* Move the output format macros into the macros.pl mechanismH. Peter Anvin2008-06-201-12/+1
| | | | | | | | | | Move the handling of "extra" macros (i.e. output format macros) into the macros.pl mechanism. This allows us to change the format of the internal macro store in the future - e.g. to a single byte store without redundant pointers. Also, stop using indicies into a long array when there is no good reason to not just use different arrays.
* Move all the SAA code out of nasmlibH. Peter Anvin2008-06-091-0/+1
| | | | | | 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.
* regularized spelling of license to match name of LICENSE fileBeroset2007-12-291-1/+1
|
* Address data is int64_t; simplify writing an address objectH. Peter Anvin2007-11-131-10/+3
| | | | | | | 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.
* Don't combine type and size into a single argumentH. Peter Anvin2007-11-091-16/+14
| | | | | | | Don't combine type and size into a single argument; *every* backend immediately breaks them apart, so it's really just a huge waste of effort. Additionally, it avoids using short immediates in the resulting code, which is a bad thing.
* Pass 64-bit instruction lengths to back-ends.Charles Crayne2007-11-061-2/+2
|
* Upgrade label functions to 64-bitCharles Crayne2007-11-051-1/+1
|
* Formatting: kill off "stealth whitespace"H. Peter Anvin2007-10-191-1/+1
| | | | | "Stealth whitespace" makes it harder to read diffs, and just generally cause unwanted weirdness. Do a source-wide pass to get rid of it.
* Additional uses of bool and enumH. Peter Anvin2007-10-111-5/+6
| | | | | | Proper use of bool and enum makes code easier to debug. Do more of it. In particular, we really should stomp out any residual uses of magic constants that aren't enums or, in some cases, even #defines.
* Portability fixesH. Peter Anvin2007-10-021-0/+2
| | | | | | | | | Concentrate compiler dependencies to compiler.h; make sure compiler.h is included first in every .c file (since some prototypes may depend on the presence of feature request macros.) Actually use the conditional inclusion of various functions (totally broken in previous releases.)
* Minor fixes needed to compile with MSVC++ 2005H. Peter Anvin2007-09-161-6/+4
| | | | | | | | Minor fixes to make it possible to compile with MS Visual C++ 2005. Unfortunately, MSVC++ is not fully C99 compliant; in particular, it doesn't handle interspersed declarations and other code. Furthermore, it chokes on some expressions in outelf64.c, which fortunately can be easily substituted with simpler expressions.
* Fixed RDF/2 to comply with "maxbits" use.Keith Kanios2007-04-181-1/+3
|
* Placated unreferenced types.Keith Kanios2007-04-141-0/+9
|
* Fixed distinction between char and int8_t data types.Keith Kanios2007-04-131-18/+18
|