Previous Chapter | Contents | Index
rdf Extensions to the GLOBAL directive
global symbols can contain additional
information needed by the static linker. You can mark a global symbol as
exported, thus telling the linker do not strip it from target executable or
library file. Like in , you can also specify
whether an exported symbol is a procedure (function) or data object.
Suffixing the name with a colon and the word
you make the symbol exported:
global sys_open:export
To specify that exported symbol is a procedure (function), you add the
word or
after declaration:
global sys_open:export proc
Similarly, to specify exported data object, add the word
or to the
directive:
global kernel_ticks:export data
rdf Extensions to the EXTERN directiveBy default the directive in
declares a "pure external" symbol (i.e. the
static linker will complain if such a symbol is not resolved). To declare
an "imported" symbol, which must be resolved later during a dynamic linking
phase, offers an additional
modifier. As in
, you can also specify whether an imported
symbol is a procedure (function) or data object. For example:
library $libc
extern _open:import
extern _printf:import proc
extern _errno:import data
Here the directive is also included,
which gives the dynamic linker a hint as to where to find requested
symbols.
dbg : Debugging FormatThe output format is not built into NASM
in the default configuration. If you are building your own NASM executable
from the sources, you can define in
or on the compiler command line, and
obtain the output format.
The format does not output an object file
as such; instead, it outputs a text file which contains a complete list of
all the transactions between the main body of NASM and the output-format
back end module. It is primarily intended to aid people who want to write
their own output drivers, so that they can get a clearer idea of the
various requests the main program makes of the output driver, and in what
order they happen.
For simple files, one can easily use the
format like this:
nasm -f dbg filename.asm
which will generate a diagnostic file called
. However, this will not work well on
files which were designed for a different object format, because each
object format defines its own macros (usually user-level forms of
directives), and those macros will not be defined in the
format. Therefore it can be useful to run
NASM twice, in order to do the preprocessing with the native object format
selected:
nasm -e -f rdf -o rdfprog.i rdfprog.asm nasm -a -f dbg rdfprog.i
This preprocesses into
, keeping the
object format selected in order to make sure
RDF special directives are converted into primitive form correctly. Then
the preprocessed source is fed through the
format to generate the final diagnostic output.
This workaround will still typically not work for programs intended for
format, because the
and
directives have side effects of defining
the segment and group names as symbols; will
not do this, so the program will not assemble. You will have to work around
that by defining the symbols yourself (using
, for example) if you really need to get a
trace of an
-specific source file.
accepts any section name and any
directives at all, and logs them all to its output file.