LD
linker is used to produce binary code that is ready to run.
This code can be any of:
EXEC
able program that can be run directly.RESPR
commands.
After the files comprising a C program have been compiled into
object (SROFF) files they must be linked, together with selected
library routines, to produce an executable program.
This is done by the program LD
, which replaces the
program LINK
that is the traditional linker commonly
used on the QL.
LD
is much more UNIX like in use than LINK
.
This is makes it more consistent with the rest of the C68 system
which has its origins on UNIX based system.
In addition, the LD
linker is far more efficient than
the original LINK
program in that it runs about 3 times
faster, and also the resulting program is smaller.
It is also possible to run LD
in a compatibility mode
where it can produce output in the same format as the original
LINK
program.
The different linkers have used different standards for the way
that they store relocation information in the output file.
To allow maximum flexibility, the LD
version 2.xx series
has the ability to produce output that uses a variety of different
formats:
LD
version 2.xx format that was introduced to
support the RLL system. This format (which is the default)
allows more information to be stored in the target file than
earlier formats catered for. >LD
version 1.xx. This is the format that was
used by all versions of the c68 system prior to release 4.30.LINK
format. This is the format produced by
the traditional GST linker, and the more recent Quanta
QLINK
variant. LD
linker.
Options | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-f n |
The output format required.
The values available for n are:
| ||||||||||||||||||||
Default: -f2 |
|||||||||||||||||||||
-L library path |
This option allows the order of searching of library files
to be changed. The order of searching for libraries is:
|
||||||||||||||||||||
-l libname |
Search a statically linked library looking for any modules in
the library that will satisfy any of the currently outstanding
external references. If any such modules are found then add them
to the output file.
Library names are normally specified on the command line after all the object files. This is, however, not mandatory. The libraries and object files are processed in the order specified on the command line. Note that only a single pass of a library is done so that including a library too early in the command line may cause routines to not be included that you might want.
By convention library names are given in a specially compact format.
The names for libraries are made up by adding a prefix of
Thus to link with the math library, you would use -Lflp1_mylib_ <object files .... > -lmine
-lc ) as if there are any outstanding
references when all the libraries you have explicitly mentioned
have been processed the libc_a library is
automatically searched as the last library (although you do no
damage if you specify it explicitly). The |
||||||||||||||||||||
-m listing_options |
This causes a listing file to be produced for the program.
The name of the file produced is always
output_file_name_map so if no output
name has been specified then the map file will be called
a_out_map . If the output file had been specified
using -otest then the listing file would be called
test_map.
The amount of detail included in the map file will depend on the
options supplied. There must be at least one option, but you can
specify more than one by simply concatenating them together
(e.g.
There is also a listing summary produced that shows the link statistics. This is inserted after the library/module listings and before the more detailed symbol listings.
Note that if the Default: |
||||||||||||||||||||
-o outputfile |
This allows the name of the output file to be specified.
For example using a -otest would cause a program
called test to be produced
Default: |
||||||||||||||||||||
-R name[/ version] |
This indicates that LD is to build a RLL rather than a normal program.
The name part of the parameter is the name that will be
given to the RLL thing. This has a maximum length of 16 characters
- and more than this will be ignored.
The (optional) version part is the version number
(which is of the form m.nn where m is the major version
number and nn is the minor version number. In practise
The use of this parameter will also modify the default behaviour of
|
||||||||||||||||||||
libname |
Search a RLL library.
A RLL library is one that is dynamically linked to a program
at runtime. Although LD does not add it to the output file it
does search it to determine which external references would be
satisfied by including this library. The same locations will be
searched as are specified earlier for the -l option.
The name of a RLL library is made in a similar way to that for
statically linked libraries except that the extension is
RLL libraries can also have what are called "RLL stub libraries".
These are small statically linked libraries that need to be linked
in to help interface to a RLL. These have the same name as the
associated RLL, but with an extension of _rls.
Therefore the stub version of the maths library specified using
Note that if a RLL library is linked in, it is necessary for this library to also be present at runtime for the program to run successfully. For more information on the RLL system see the main RLL documentation.
The other point to note is that no RLLs are linked in by default,
not even the |
||||||||||||||||||||
-s startup_file |
This option specifies a different start-up file from the standard one.
Using the special format of -s- means that no start-up
module is to be used.
The start-up file is the code that does all the run time relocation that allows C programs to run correctly where they have been loaded under QDOS. Unless you have written your own start-up file that does runtime relocation correctly it is probably best to leave this option alone. If this parameter is omitted, then the start-up modules that are used will be:
The start-up file is searched for using the same paths as are used when searching for libraries (as described under the -l option). Examples on when you might want to used different values are:
| ||||||||||||||||||||
-U
| Treat all external references as upper case.
This version of LD treats external references as case significant as this is the normal convention for C programs. However LD v1.x and the LINK linkers treat all external references as though they were upper case. Use this option to force compatibility with the way these earlier linkers handled the case of external symbols. | ||||||||||||||||||||
-V |
Output a message giving information about the version of
LD being used. This message will be sent to the
listing file if one is to be produced, and otherwise to the
console. |
||||||||||||||||||||
-v |
This means run in verbose mode.
It also implies the -V parameter.
This will always cause the program version to be output and a
link summary to always be produced.
If no listing file is being output these will be sent to the
console, otherwise to the listing file. |
||||||||||||||||||||
-z option(s) |
Specify what should be included in the binary file that will be produced.
If you want to specify more than one of the available options,
then they should all be written using a plus ('+') symbol as the separator.
The options available are:
| ||||||||||||||||||||
The following options will also be recognised by
LD for compatibility with earlier versions,
but they will simply be ignored and have no effect.
This is because the relevant areas are now allocated dynamically |
|||||||||||||||||||||
-bufl size[K] |
This allowed the user to specify the buffer size in reading
the object files and library files.
|
||||||||||||||||||||
-bufp size[K] |
This allowed the user to specify the size of buffer to hold the
complete image of the program that is being linked.
|
Following the options the object files to link are specified.
These may be any valid QL filename, with the directory extensions
provided by a C program (eg.test_o, test1_o, etc.).
No wildcards are allowed in the LD
command line as
the order of files linked is important in LD
, and
this could not be guaranteed if wildcards were used.
The linker produces files that are smaller than the equivalent
produced by the GST LINK linker
.
The program files produced set the job data size field in the QDOS files header. THIS MUST NOT BE MADE SMALLER by any toolkit routine
as if this is done the programs produced will FAIL to relocate properly
at runtime and crash the QL ! YOU HAVE BEEN WARNED!
Making it bigger is a waste of space as this data area is only used
during program initialisation, and is not used for the runtime stack
or heap.
LD
linker will make use of the Environment Variables
specified below if they are set. These environment variables are
processed before the command line options, so in the event of any clash,
the command line parameters will take precedence.
LIB_DIR |
This can be used to specify the default program directory. |
LD_OPTS |
Any parameters that would be valid on the LD command
line can be set in this environment variable |
LD
. In normal use one will not need to use
(or even understand) the contents of this section.
It revolves around the fact that normally the information held in the BSS section of a program or RLL is often only required at initial load time. After that it is no longer required. It would therefore save on memory if this space could be re-used for other purposes. Most programs also contain a UDATA section that is used to hold uninitialised data. If you can re-use this space after the initialisation phase is finished then the program will need less memory to run.
Another aspect to consider is whether any space for the
UDATA
area should actually be included in the data stored
as part of the program file header. Doing so reduces the size of
the file stored on disk, but means that the loading process needs
to take account of this.
The algorithm used by default with LD
is as follows:
UDATA
area starts at the same address as the start of the BSS Header.
The file header is used to store any additional space that needs
to be allocated to complete the UDATA
area.
UDATA
area starts after the end of
the BSS XDEF area. Any additional space required for
UDATA
is included as part of the data of the
program file.This default behaviour can be modified by use of the various -f and -z runtime options.
31 Dec 93 | DJW | Added section on Environment Variables that LD
will now recognised |
28 Mar 96 | DJW | Updated to reflect the new options that are now available for
use with LD version 2 |
01 Aug 97 | DJW | Changes to reflect conversion to HTML format. |