Compiler
Operation
-
Linking
a C
Program
3.5
Linking
a C
Program
The TMS34010 C compiler and assembly language tools support modular
programming by allowing you
to
compile and assemble individual modules
and then link them together. To link compiled and assembled code, enter:
gsplnk
-c/-cr
filenames
grams.
gsplnk
-c
filenames
-0
name.out -I
rts.lib
[-I
flib.lib]
or
gsplnk
-cr
filenames
-0
name.
out
-I
rts.lib
[-I
flib.lib]
is
the command that invokes the linker.
are
options that tell the linker
to
use
special conventions that
are
defined by the C environment.
are
object files created by compiling and assembling C pro-
-0
name.
out
names the output file.
If
you
don't
use
the
-0
option, the linker
creates
an
output file
with
the default name
of
a.
out.
rts.lib/
rts
.lib
is
an
archive library that contains C runtime-support
flib.lib
functions, and
flib.lib
is
the floating-point arithmetic
li-
brary. (The -I option tells the linker that a file is
an
object
li-
brary.) Both libraries
are
shipped
with
the C compiler. It
you're linking C code, you must
use
rts
.lib;
you only need
f
lib
.lib
if
you're using the floating-point functions.
Who..:
never you specify a library
as
linker input, the linker includes
and links only those library members that resolve undefined
references.
For example, you
can
link a C program consisting
of
modules
progl,
prog2,
and
prog3'
(the output file
is
named
prog.
out):
qsp1nk
-c
proq1
proq2
prog3
-1
rts.1ib
-0
proq.out
The linker
uses
a default allocation algorithm
to
allocate your program into me-
mory. You can
use
the MEMORY and SECTIONS directives
to
customize the
allocation process. For more information about the linker,
see
the TMS34010
Assembly Language Tools User's Guide.
3.5.1
Runtime
Initialization
and
Runtime
Support
All C programs must
be
linked
with
the
boot.
obj
object module; this module
contains code for the C boot routine. The
boot.
obj
module is a member of
the runtime-support object library,
rts
.lib.
To
use
the module, simply use
-c or -cr and include the library
in
the link:
qsp1nk
-c
-1
rts.1ib
...
The linker automatically extracts
boot.
obj
and links it in when you use the
-c
or -cr option.
When a
C program begins running,
it
must execute
boot.
obj
first. The
symbol
-c-intOO
is
the starting
point
in
boot.
obj;
if
you
use
the
-c
or
-cr
option, then
-c-intOO
is
automatically defined
as
the entry point for the
program.
If
your program begins running from reset, you should set up the
reset vector
to
generate a branch to
-c_intOO
so that the TMS34010 exe-
cutes
boot.
obj
first. The
boot.
obj
module contains code and data for ini-
tializing the runtime environment; the module performs the following tasks: