diff options
authorCyrill Gorcunov <gorcunov@gmail.com>2018-11-12 23:21:43 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2018-11-12 23:21:43 +0300
commit0135a8147ea9c083dc794dce5ddd740b24c3d7dd (patch)
parent7373a8e606cc52389da0b0568fefbc82f463336b (diff)
parent9a1216a1efa0ccb48e5df97acc763ea3de71e0ce (diff)
Merge nasm-2.14
* commit '9a1216a1efa0ccb48e5df97acc763ea3de71e0ce': NASM 2.14 nasmdoc.src: fix compound word doc: Add a description for a useful case of mangling symbols preproc: Don't access out of bound data on malformed input rdstrnum: Make sure we dont shift out of bound preproc: Fix out of bound access on malformed input doc: Clarify %include search directory semantics Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
4 files changed, 29 insertions, 18 deletions
diff --git a/asm/preproc.c b/asm/preproc.c
index 0ae712a9..b6afee39 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -2231,8 +2231,9 @@ static int do_directive(Token *tline, char **output)
if (!tline || !tok_type_(tline, TOK_PREPROC_ID) ||
- (tline->text[1] == '%' || tline->text[1] == '$'
- || tline->text[1] == '!'))
+ (tline->text[0] && (tline->text[1] == '%' ||
+ tline->text[1] == '$' ||
+ tline->text[1] == '!')))
i = pp_token_hash(tline->text);
@@ -3962,7 +3963,7 @@ static Token *expand_mmac_params(Token * tline)
thead = NULL;
while (tline) {
- if (tline->type == TOK_PREPROC_ID &&
+ if (tline->type == TOK_PREPROC_ID && tline->text && tline->text[0] &&
(((tline->text[1] == '+' || tline->text[1] == '-') && tline->text[2]) ||
(tline->text[1] >= '0' && tline->text[1] <= '9') ||
tline->text[1] == '%')) {
diff --git a/asm/rdstrnum.c b/asm/rdstrnum.c
index d9d2a69f..319f140a 100644
--- a/asm/rdstrnum.c
+++ b/asm/rdstrnum.c
@@ -55,12 +55,14 @@ int64_t readstrnum(char *str, int length, bool *warn)
for (i = 0; i < length; i++) {
if (charconst & UINT64_C(0xFF00000000000000))
*warn = true;
+ charconst &= ~UINT64_C(0xFF00000000000000);
charconst = (charconst << 8) + (uint8_t)*--str;
} else {
for (i = 0; i < length; i++) {
- if (charconst & 0xFF000000UL)
+ if (charconst & UINT32_C(0xFF000000))
*warn = true;
+ charconst &= ~UINT32_C(0xFF000000);
charconst = (charconst << 8) + (uint8_t)*--str;
diff --git a/doc/changes.src b/doc/changes.src
index 7da6662b..efed8a19 100644
--- a/doc/changes.src
+++ b/doc/changes.src
@@ -9,7 +9,7 @@ since 2007.
\S{cl-2.14} Version 2.14
-\b Fixed \c{-I} option handling when ending slash is not present.
+\b Changed \c{-I} option semantics by adding a trailing path separator unconditionally.
\b Fixed null dereference in corrupted invalid single line macros.
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index fb140e99..9ebe657e 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -628,16 +628,12 @@ library}, for example, by typing
(As usual, a space between \c{-i} and the path name is allowed, and
-NASM, in the interests of complete source-code portability, does not
-understand the file naming conventions of the OS it is running on;
-the string you provide as an argument to the \c{-i} option will be
-prepended exactly as written to the name of the include file.
-Therefore the trailing backslash in the above example is necessary.
-Under Unix, a trailing forward slash is similarly necessary.
-(You can use this to your advantage, if you're really \i{perverse},
-by noting that the option \c{-ifoo} will cause \c{%include "bar.i"}
-to search for the file \c{foobar.i}...)
+Prior NASM 2.14 a path provided in the option has been considered as
+a verbatim copy and providing a path separator been up to a caller.
+One could implicitly concatenate a search path together with a filename.
+Still this was rather a trick than something useful. Now the trailing
+path separator is made to always present, thus \c{-ifoo} will be
+considered as the \c{-ifoo/} directory.
If you want to define a \e{standard} \i{include search path},
similar to \c{/usr/include} on Unix systems, you should place one or
@@ -4711,6 +4707,18 @@ This is a macro implemented as a \c{%pragma}:
Commandline option is also possible. See also \k{opt-pfix}.
+Some toolchains is aware of a particular prefix for its own optimization
+options, such as code elimination. For instance, Mach-O backend has a
+linker that uses a simplistic naming scheme to chunk up sections into a
+meta section. When the \c{subsections_via_symbols} directive
+(\k{macho-ssvs}) is declared, each symbol is the start of a
+separate block. The meta section is, then, defined to include sections
+before the one that starts with a 'L'. \c{LPREFIX} is useful here to mark
+all local symbols with the 'L' prefix to be excluded to the meta section.
+It converts local symbols compatible with the particular toolchain.
+Note that local symbols declared with \c{STATIC} (\k{static})
+are excluded from the symbol mangling and also not marked as global.
\H{gen-namespace} \i\c{OUTPUT}, \i\c{DEBUG}: Generic Namespaces
@@ -5827,9 +5835,9 @@ right-hand side of the \c{WRT} operator:
\S{macho-ssvs} \c{macho} specfic directive \i\c{subsections_via_symbols}
The directive \c{subsections_via_symbols} sets the
-\c{MH_SUBSECTIONS_VIA_SYMBOLS} flag in the Mach-O header, which tells
-the linker that the symbols in the file matches the conventions
-required to allow for link-time dead code elimination.
+\c{MH_SUBSECTIONS_VIA_SYMBOLS} flag in the Mach-O header, that effectively
+separates a block (or a subsection) based on a symbol. It is often used
+for eliminating dead codes by a linker.
This directive takes no arguments.