ld-coff(1) DG/UX R4.11 ld-coff(1)
NAME
ld - link editor for common object files
SYNOPSIS
ld [ options ] filename ... [ indirect-file ... ]
DESCRIPTION
The ld command combines several common object files into one,
performs relocation, resolves external symbols, and supports symbol
table information for symbolic debugging.
When given several object files, ld combines them, producing an
executable object module. If you include the -r option on the
command line, ld produces a linkable file (suitable for linking by
another ld command) instead of an executable one. The output of ld
is left in a.out by default. This file is executable if no errors
occurred during the load. If any input file is not an object file,
ld assumes it is either an archive library or an indirect file, a
text file containing link editor directives. In an indirect file,
one option letter, filename, or symbol assignment is put on each
line. (See Programmer's Guide: ANSI C and Programming Support Tools
for a discussion of input directives.)
If any argument is a library, the library is opened once, searched as
many times as required, and then closed. Only those routines
defining an unresolved external reference are loaded. Thus, library
members can be in any order.
Options are:
-ansi On absolute links, do not produce the symbols etext,
edata, or end, as these symbols are in the ansi
namespace. The symbols etext, edata, and end are
still defined by the linker.
-e symbol Set the default entry point address for the output file
to be that of the symbol symbol.
-f fill Set the default fill pattern for "holes" within an
output section as well as initialized bss sections.
The argument fill is a two-byte constant.
-F magic Give the program the magic number magic, in the
conventional format for octal, decimal, or hexadecimal
numbers. Octal numbers have a 0 prefix, hexadecimal
numbers have an 0x prefix. Two magic numbers are valid
for DG/UX: 0541 for DG/UX programs, 0555 for BCS
compliant programs. The default magic number is 0541.
-lname Search for library libname.a (name may be up to 9
characters in length). Ld searches in LIBDIR (usually
/lib) and LLIBDIR (usually /usr/lib) by default. See
-L. Note the format of the library name that ld
searches for. This option must be specified on the
command line after the object file names that contain
references to a module in libname.a.
-L dir Search for libraries in dir before searching LIBDIR and
LLIBDIR. For this option to have any effect, you must
also include the -l option. The -L option must precede
the -l option on the command line.
-m Produce a link map.
-M Warn about multiply defined external definitions.
-N Put the text section at the beginning of the text
segment rather than after all header information, and
put the data section immediately following text in the
core image.
-n Do not make contributions to output sections that are
not made by input files on the command line. Use of
this option may cause the link to fail if DG/UX
libraries or start-up code are used. It will also
prevent the linker from producing correct low level
debugging information with input .tdesc sections. (See
Programmer's Guide: ANSI C and Programming Support
Tools for a discussion of ld handling of special
sections.)
-o file Executable module is called file instead of a.out.
-r Retain relocation entries in the output object file.
Relocation entries must be saved if the output file is
to become an input file in a subsequent ld run. The
link editor will not complain about unresolved
references, and the output file will not be executable.
-a Create an absolute file. This is the default if the -r
option is not used. Used with the -r option, -a
allocates memory for common symbols.
-s Strip line number entries and symbol table information
from the output object file.
-t Turn off the warning about multiply-defined symbols
that are not the same size.
-u name Add name as an undefined symbol in the symbol table.
This is useful for loading entirely from a library,
since initially the symbol table is empty and an
unresolved reference is needed to force the loading of
the first routine. The placement of this option on the
ld command line is significant; it must be placed
before the library which will define the symbol.
-V Print the revision number of ld.
-x Strip local symbols from the output (leave only
external and static symbols). This option saves space
in the output file.
-z Do not bind anything to address zero. This option will
allow runtime detection of null pointers.
-Y [LU],dir Change the default directory used for finding
libraries. If L is specified, the first default
directory that ld searches, LIBDIR, is replaced by dir.
If U is specified, the second default directory that ld
searches, LLIBDIR, is replaced by dir. If ld was built
with only one default directory but you specify U
anyway, ld prints a warning and ignores the option.
FILES
LIBDIR/libx.a libraries
LLIBDIR/libx.a libraries
a.out output file
LIBDIR the first default search directory for
libraries, usually /lib.
LLIBDIR the second default search directory for
libraries, usually /usr/lib.
SEE ALSO
as(1), attdump(1), cc(1), ld(1), nm(1), size(1), exit(2), end(3C),
a.out(4), ar(4).
Programmer's Guide: ANSI C and Programming Support Tools
CAVEATS
Through its options and input directives, the common link editor
gives users great flexibility; however, those who use the input
directives must assume some added responsibilities. Input directives
and options should ensure the following properties for programs:
- C defines a zero pointer as null. A pointer to which zero has
been assigned must not point to any object. To satisfy this,
users must not place any object at virtual address zero in the
program's address space.
- When the link editor is called through cc(1), a startup
routine is linked with the user's program. This routine calls
exit(2) after execution of the main program. If the user
calls the link editor directly, the user must insure that the
program always calls exit rather than falling through the end
of the entry routine.
The symbols etext, edata, and end [see end(3C)] are reserved and are
defined by the link editor. It is incorrect for a user program to
redefine them.
If the link editor does not recognize an input file as an object file
or an archive file, it will assume that it contains link editor
directives and will attempt to parse it. This will occasionally
produce an error message complaining about "syntax errors."
Arithmetic expressions may have only one forward-referenced symbol
per expression.
Licensed material--property of copyright holder(s)