From 0a1a9789ec4af3609a1142ea8d2c20b91fd750c2 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin (Intel)" Date: Tue, 7 Oct 2025 10:48:48 -0700 Subject: [PATCH] Fix confusion between "postfix" and "suffix" "suffix" is the more common English term, but NASM used "postfix" for a long time. Allow them as aliases, and tidy up the documentation accordingly. While making these changes, tidy up the handling of options in the index. Fixes: https://github.com/netwide-assembler/nasm/pull/61 Signed-off-by: H. Peter Anvin (Intel) --- asm/nasm.c | 11 +++++++---- doc/changes.src | 5 ++++- doc/index.src | 3 ++- doc/ndisasm.src | 24 +++++++++++------------- doc/running.src | 39 +++++++++++++++++++++++++++++++++++---- 5 files changed, 59 insertions(+), 23 deletions(-) diff --git a/asm/nasm.c b/asm/nasm.c index b5da12851..db28bef97 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -934,10 +934,13 @@ static const struct textargs textopts[] = { {"abort-on-panic", OPT_ABORT_ON_PANIC, ARG_NO, 0}, {"prefix", OPT_MANGLE, ARG_YES, LM_GPREFIX}, {"postfix", OPT_MANGLE, ARG_YES, LM_GSUFFIX}, + {"suffix", OPT_MANGLE, ARG_YES, LM_GSUFFIX}, {"gprefix", OPT_MANGLE, ARG_YES, LM_GPREFIX}, {"gpostfix", OPT_MANGLE, ARG_YES, LM_GSUFFIX}, + {"gsuffix", OPT_MANGLE, ARG_YES, LM_GSUFFIX}, {"lprefix", OPT_MANGLE, ARG_YES, LM_LPREFIX}, {"lpostfix", OPT_MANGLE, ARG_YES, LM_LSUFFIX}, + {"lsuffix", OPT_MANGLE, ARG_YES, LM_LSUFFIX}, {"include", OPT_INCLUDE, ARG_YES, 0}, {"pragma", OPT_PRAGMA, ARG_YES, 0}, {"before", OPT_BEFORE, ARG_YES, 0}, @@ -2477,10 +2480,10 @@ static void help(FILE *out, const char *what) " --before str add line (usually a preprocessor statement) before the input\n" " --bits nn set bits to nn (equivalent to --before \"BITS nn\")\n" " --no-line ignore %line directives in input\n" - " --prefix str prepend the given string to the names of all extern,\n" - " common and global symbols (also --gprefix)\n" - " --suffix str append the given string to the names of all extern,\n" - " common and global symbols (also --gprefix)\n" + " --gprefix str prepend the given string to the names of all extern,\n" + " common and global symbols (also --prefix)\n" + " --gpostfix str append the given string to the names of all extern,\n" + " common and global symbols (also --postfix)\n" " --lprefix str prepend the given string to local symbols\n" " --lpostfix str append the given string to local symbols\n" " --reproducible attempt to produce run-to-run identical output\n" diff --git a/doc/changes.src b/doc/changes.src index 9bc008549..35d03b1c8 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -34,7 +34,10 @@ It is the production version of NASM since 2025. \b A new \c{%selbits()} preprocessor function. See \k{f_selbits}. \b A new \c{--bits} option as convenience shorthand for \c{--before -"BITS ..."}. See \k{opt-bits}. + "BITS ..."}. See \k{opt-bits}. + +\b Add aliases \c{--suffix}, \c{--gsuffix} and \c{--lsuffix} for the + corresponding \c{postfix} options. See \k{opt-pfix}. \S{cl-3.00} Version 3.00 diff --git a/doc/index.src b/doc/index.src index fd5aa53c8..321846afc 100644 --- a/doc/index.src +++ b/doc/index.src @@ -26,8 +26,9 @@ \IR{-p} \c{-p} option \IR{-s} \c{-s} option \IR{-u} \c{-u} option -\IR{-v} \c{-v} option \IR{-W} \c{-W} option +\IR{-t} \c{-t} option +\IR{-soname} \c{-soname}, linker option \IR{-Werror} \c{-Werror} option \IR{-Wno-error} \c{-Wno-error} option \IR{-w} \c{-w} option diff --git a/doc/ndisasm.src b/doc/ndisasm.src index e01ec6cbe..9c448af3c 100644 --- a/doc/ndisasm.src +++ b/doc/ndisasm.src @@ -14,11 +14,11 @@ instruction table (and some other bits of code) with NASM. The Netwide Disassembler does nothing except to produce disassemblies of \e{binary} source files. NDISASM does not have any understanding of object file formats, like \c{objdump}, and it will -not understand \c{DOS .EXE} files like \c{debug} will. It just +not understand DOS \c{.EXE} files like \c{debug} will. It just disassembles. -\H{ndisrun} Running NDISASM +\H{ndisrun} \I{options, disassembler}Running NDISASM To disassemble a file, you will typically use a command of the form @@ -26,11 +26,11 @@ To disassemble a file, you will typically use a command of the form NDISASM can disassemble 16-, 32- or 64-bit code equally easily, provided of course that you remember to specify which it is to work -with. If no \i\c{-b} switch is present, NDISASM works in 16-bit mode -by default. The \i\c{-u} switch (for USE32) also invokes 32-bit mode. +with. If no \c{-b} switch is present, NDISASM works in 16-bit mode +by default. The \c{-u} switch (for USE32) also invokes 32-bit mode. -Two more command line options are \i\c{-r} which reports the version -number of NDISASM you are running, and \i\c{-h} which gives a short +Two more command line options are \c{-r} which reports the version +number of NDISASM you are running, and \c{-h} which gives a short summary of command line options. @@ -42,7 +42,7 @@ rather than at zero. NDISASM, which assumes by default that any file you give it is loaded at zero, will therefore need to be informed of this. -The \i\c{-o} option allows you to declare a different origin for the +The \c{-o} option allows you to declare a different origin for the file you are disassembling. Its argument may be expressed in any of the NASM numeric formats: decimal by default, if it begins with `\c{$}' or `\c{0x}' or ends in `\c{H}' it's \c{hex}, if it ends in `\c{Q}' it's @@ -84,7 +84,7 @@ instruction and output a `\c{db}' instead. So it \e{will} start disassembly exactly from the sync point, and so you \e{will} see all the instructions in your code section. -Sync points are specified using the \i\c{-s} option: they are measured +Sync points are specified using the \c{-s} option: they are measured in terms of the program origin, not the file position. So if you want to synchronize after 32 bytes of a \c{.COM} file, you would have to do @@ -116,7 +116,7 @@ be, surely, would be to read the \c{JMP} instruction, and then to use its target address as a sync point. So can NDISASM do that for you? The answer, of course, is yes: using either of the synonymous -switches \i\c{-a} (for automatic sync) or \i\c{-i} (for intelligent +switches \c{-a} (for automatic sync) or \c{-i} (for intelligent sync) will enable \c{auto-sync} mode. Auto-sync mode automatically generates a sync point for any forward-referring PC-relative jump or call instruction that NDISASM encounters. (Since NDISASM is one-pass, @@ -153,16 +153,14 @@ suppress disassembly of the data area. \S{ndisother} Other Options -The \i\c{-e} option skips a header on the file, by ignoring the first N +The \c{-e} option skips a header on the file, by ignoring the first N bytes. This means that the header is \e{not} counted towards the disassembly offset: if you give \c{-e10 -o10}, disassembly will start at byte 10 in the file, and this will be given offset 10, not 20. -The \i\c{-k} option is provided with two comma-separated numeric +The \c{-k} option is provided with two comma-separated numeric arguments, the first of which is an assembly offset and the second is a number of bytes to skip. This \e{will} count the skipped bytes towards the assembly offset: its use is to suppress disassembly of a data section which wouldn't contain anything you wanted to see anyway. - - diff --git a/doc/running.src b/doc/running.src index 366b452ed..f0e65277a 100644 --- a/doc/running.src +++ b/doc/running.src @@ -515,6 +515,9 @@ the \i\c{[WARNING]} directive. See \k{asmdir-warning}. See \k{warnings} for the complete list of warning classes. +\IR{-v} \c{-v} option +\IR{--v} \c{--v} option + \S{opt-v} The \i\c{-v} Option: Display \i{Version} Info Typing \c{NASM -v} will display the version of NASM which you are using, @@ -526,13 +529,22 @@ For command-line compatibility with Yasm, the form \i\c{--v} is also accepted for this option starting in NASM version 2.11.05. -\S{opt-pfix} The \i\c{--(g|l)prefix}, \i\c{--(g|l)postfix} Options. +\IR{--prefix} \c{--prefix} option +\IC{--prefix}{--gprefix} \c{--gprefix} option +\IC{--prefix}{--lprefix} \c{--lprefix} option +\IC{--prefix}{--gpostfix} \c{--gpostfix} option +\IC{--prefix}{--lpostfix} \c{--lpostfix} option +\IC{--prefix}{--suffix} \c{--suffix} option +\IC{--prefix}{--gsuffix} \c{--gsuffix} option +\IC{--prefix}{--lsuffix} \c{--lsuffix} option + +\S{opt-pfix} The \I{--prefix}\c{--[gl]prefix} and \c{--[gl]postfix} Options The \c{--gprefix} option prepends the given argument to all \c{extern}, \c{common}, \c{static}, and \c{global} symbols, and the \c{--lprefix} option prepends to all other symbols. Similarly, \c{--gpostfix} and \c{--lpostfix} options append -the argument, in a manner similar to the \c{--(g|l)prefix} options. +the argument, in a manner similar to the \c{--[gl]prefix} options. Running this: @@ -543,6 +555,15 @@ at the start of the file (\k{mangling}). It will prepend the underscore to all global and external variables, as C requires it in some, but not all, system calling conventions. +\c{--prefix} is an alias for \c{--gprefix}. + +Starting with NASM 3.01, \c{--suffix}, \c{--gsuffix}, and +\c{--lsuffix} are accepted as aliases for the corresponding +\c{postfix} options. + + +\IR{--pragma} \c{--pragma} option + \S{opt-pragma} The \i\c{--pragma} Option NASM accepts an argument as \c{%pragma} option, which is like placing @@ -554,6 +575,8 @@ Running this: is equivalent to the example in \k{opt-pfix}. See \k{pragma}. +\IR{--before} \c{--before} option + \S{opt-before} The \i\c{--before} Option Insert a statement (usually, but not necessarily) a preprocess @@ -563,6 +586,8 @@ is the same as running this: \c nasm -f macho --before "%pragma macho gprefix _" +\IR{--bits} \c{--bits} option + \S{opt-bits} The \i\c{--bits} Option Set the processor mode by inserting a \c{BITS} directive (kee @@ -575,10 +600,11 @@ exactly equivalent: The \c{--bits} option was introduced in NASM 3.01; the \c{--before} form can be used for compatibility with older versions of NASM. +\IR{--limit-} \c{--limit-} options -\S{opt-limit} The \i\c{--limit-X} Option +\S{opt-limit} The \i\c{--limit-} Options -This option allows user to setup various maximum values after which +These options allows user to setup various maximum values after which NASM will terminate with a fatal error rather than consume arbitrary amount of compute time. Each limit can be set to a positive number or \c{unlimited}. @@ -616,18 +642,23 @@ example: \c %pragma limit lines 1000 +\IR{--keep-all} \c{--keep-all} option \S{opt-keep-all} The \i\c{--keep-all} Option This option prevents NASM from deleting any output files even if an error happens. +\IR{--no-line} \c{--no-line} option + \S{opt-no-line} The \i\c{--no-line} Option If this option is given, all \i\c{%line} directives in the source code are ignored. This can be useful for debugging already preprocessed code. See \k{line}. +\IR{--reproducible} \c{--reproducible} option + \S{opt-reproducible} The \i\c{--reproducible} Option If this option is given, NASM will not emit information that is