0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00

labels: make the prefix/suffix options and pragmas consistent

Make the spellings for the label-mangling options and pragmas
consistent, and implement the directive forms which were documented
but never implemented.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel)
2025-10-07 18:46:39 -07:00
parent c08b4edca1
commit ae9335a0b9
11 changed files with 116 additions and 50 deletions

View File

@@ -36,8 +36,14 @@ It is the production version of NASM since 2025.
\b A new \c{--bits} option as convenience shorthand for \c{--before
"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}.
\b The options and pragmas for configuring external label mangling
were inconsistent, the former using the spelling \c{postfix} and
the latter \c{suffix}. Furthermore, these were also documented as
\e{directives} in addition to pragmas. Implement the already
documented directives (bracketed forms only) and allow both
\c{postfix} and \c{suffix} in all cases.
See \k{opt-pfix} and \k{mangling}.
\b Define additional permissive patterns and fix some opcode bugs.

View File

@@ -402,26 +402,38 @@ global variables).
Unlike \c{GLOBAL}, \c{STATIC} does not allow object formats to accept
private extensions mentioned in \k{global}.
\H{mangling} \i\c{(G|L)PREFIX}, \i\c{(G|L)POSTFIX}: Mangling Symbols
\IR{PREFIX} \c{[PREFIX]}
\IC{PREFIX}{GPREFIX} \c{[GPREFIX]}
\IC{PREFIX}{LPREFIX} \c{[LPREFIX]}
\IC{PREFIX}{SUFFIX} \c{[SUFFIX]}
\IC{PREFIX}{GSUFFIX} \c{[GSUFFIX]}
\IC{PREFIX}{LSUFFIX} \c{[LSUFFIX]}
\IC{PREFIX}{POSTFIX} \c{[POSTFIX]}
\IC{PREFIX}{GPOSTFIX} \c{[GPOSTFIX]}
\IC{PREFIX}{LPOSTFIX} \c{[LPOSTFIX]}
\c{PREFIX}, \c{GPREFIX}, \c{LPREFIX}, \c{POSTFIX}, \c{GPOSTFIX}, and
\c{LPOSTFIX} directives can prepend or append a string to a certain
\H{mangling} \I{PREFIX}\c{[GL]PREFIX}, \c{[GL]SUFFIX}: Mangling Symbols
\c{[PREFIX}, \c{[GPREFIX}, \c{[LPREFIX}, \c{[SUFFIX}, \c{[GSUFFIX}, and
\c{[LSUFFIX} directives can prepend or append a string to a certain
type of symbols, normally to fit specific ABI conventions
\b\c{PREFIX}|\c{GPREFIX}: Prepend the argument to all \c{EXTERN},
\b\c{[PREFIX}, \c{[GPREFIX}: Prepend the argument to all \c{EXTERN},
\c{COMMON}, \c{STATIC}, and \c{GLOBAL} symbols.
\b\c{LPREFIX}: Prepend the argument to all other symbols
\b\c{[LPREFIX}: Prepend the argument to all other symbols
such as local labels and backend defined symbols.
\b\c{POSTFIX}|\c{GPOSTFIX}: Append the argument to all \c{EXTERN},
\c{COMMON}, \c{STATIC}, and \c{GLOBAL} symbols.
\b\c{[SUFFIX]}, \c{[GSUFFIX]}, \c{[POSTFIX]}, \c{[GPOSTFIX]}: Append
the argument to all \c{EXTERN}, \c{COMMON}, \c{STATIC}, and
\c{GLOBAL} symbols.
\b\c{LPOSTFIX}: Append the argument to all other symbols
\b\c{[LSUFFIX]}, \c{[LPOSTFIX]}: Append the argument to all other symbols
such as local labels and backend defined symbols.
These are macros implemented as pragmas, and using \c{%pragma} syntax
can be restricted to specific backends (see \k{pragma}):
These directives are also implemented as pragmas, and using
\c{%pragma} syntax can be restricted to specific backends (see
\k{pragma}):
\c %pragma macho lprefix L_
@@ -443,13 +455,19 @@ naming scheme to chunk up sections into smaller subsections, each of
which may be eliminated. When the \c{subsections_via_symbols}
directive (\k{macho-ssvs}) is declared, each symbol is the start of a
separate block. The subsection is, then, defined to include sections
before the one that starts with a 'L'. \c{LPREFIX} is useful here to
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.
Earlier versions of NASM called the pragmas \i\c{suffix} and the
options \i\c{--postfix}, and did not implement directives at all
despite being so documented. Since NASM 3.01, the directive forms are
implemented, and directives, pragmas and options all support all
spellings.
\H{CPU} \i\c{CPU}: Defining CPU Dependencies

View File

@@ -557,9 +557,13 @@ 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.
See \k{mangling} for the equivalent directives and pragmas.
Earlier versions of NASM called the pragmas \i\c{suffix} and the
options \i\c{--postfix}, and did not implement directives at all
despite being so documented. Since NASM 3.01, the directive forms are
implemented, and directives, pragmas and options all support all
spellings.
\IR{--pragma} \c{--pragma} option