Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lk(1) — Ultrix/UWS 4.2 VAX

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ar(1)

as(1)

cc(1)

ld(1)

ranlib(1)

lk(1)  —  VAX

Name

lk − link editor

Syntax

lk [option...] file...

Description

The lk command combines several object programs into one, resolves external references, and searches libraries. In the simplest case, several object files are given, and lk combines them, producing an object module which can be executed. The output of lk is always a standard ULTRIX a.out object module. This file is made executable only if no errors occurred during the load.

The argument routines are linked together in the order specified.  The entry point of the output is the beginning of the first routine, unless the −e option is specified. 

If the argument is a library, it is searched only once at the point it is encountered in the argument list.  Only those routines defining an unresolved external reference are loaded.  If a routine from a library references another routine in the library and the library has not been processed by ranlib(,), the referenced routine must appear after the referencing routine in the library. Thus the order of programs within libraries may be important. The first member of a library should be a file named ‘__.SYMDEF’, which is a dictionary for the library as produced by ranlib(.). The dictionary is searched repeatedly to satisfy as many references as possible.

The symbols ‘_etext’, ‘_edata’ and ‘_end’ (‘etext’, ‘edata’ and ‘end’ in C) are reserved, and if referred to, are set to the first location above the program, the first location above initialized data, and the first location above all data in that order.  It is an error to define these symbols. 

Like the ld linker, the lk linker can process ULTRIX object modules, a.out files, archived libraries (.a files), and ranlib-generated indexed libraries. Unlike the ld linker, however, the lk linker can also process object modules generated by the VAX FORTRAN compiler. All lk command options can also be specified on the fort command.

Options

The lk command has several options. Except for −l, they should appear before the file names. 

−D numberSets data segment length. The ‘number’ is a number specifying the desired length of the data segment. The linker pads the data segment to this length with zero bytes. 

−e symbolTake the argument as the name of the entry point of the loaded program.  Location 0 is the default. 

−H numberTakes number argument as a decimal integer, adds it to end of text, and starts data section at a higher address. 

−KProduces full load map, cross-referencing all defined symbols. 

−LdirAdd dir to the list of directories in which libraries are searched for.  Directories specified with −L are searched before the standard directories. 

−lxAbbreviation for the library name ‘/lib/libx.a’, where x is a string.  If that does not exist, lk tries ‘/usr/lib/libx.a’ A library is searched when its name is encountered, so the placement of a −l is significant. 

−MProduces full load map, consisting of a module and program section synopsis and  symbol cross-reference.  Only symbols that are referenced appear in the cross-reference.  Use −K to cross-reference all symbols. 

−NDo not make text portion read only or sharable.  (Use magic number 0407.) 

−nArranges (by giving the output file a 0410 “magic number”) that when the output file is executed, the text portion is read-only and shared among all users executing the file.  This involves moving the data areas up to the first possible 1024 byte boundary following the end of the text. 

−o nameTakes the name argument after −o as the name of the lk output file, instead of a.out.

−SStrips the output by removing all symbols except locals and globals. 

−sRemoves the symbol table and relocation bits to save space.  This impairs the usefulness of the debuggers.  This information can also be removed by strip(.).

−T numberTakes the argument as a hexadecimal number which sets the text segment origin.  The default origin is 0. 

−tDisplays the name of each file as it is processed. 

−u symbolEnters argument as undefined symbol in symbol table.  This is useful for loading from a library, since initially the symbol table is empty and an unresolved reference is needed to force the loading of the first routine. 

−XSaves local symbols except for those whose names begin with ‘L’.  This option is used by cc() to discard internally-generated labels while retaining symbols local to routines.

−xSuppresses saving nonglobal symbols in output symbol table; enters only external symbols.  This option saves some space in the output file. 

−YenvironmentAdjust the magic number in the output file so that the program runs in the specified environment .  The parameter can be POSIX, SYSTEM_FIVE, or BSD.  The parameter sets the program’s execution environment to conform with one of the three standards.  This parameter overrides the PROG_ENV environment variable, if it is present.  If neither this parameter nor the PROG_ENV variable is present, −YBSD is assumed. 

−ysymIndicates each file in which sym appears, its type and whether the file defines or references it.  Many such options may be given to trace many symbols.  (It is usually necessary to begin sym with an ‘_’, as external C and PASCAL variables begin with underscores.) 

−zLoads process on demand from the resulting executable file (413 format) rather than preloaded.  This is the default.  It results in a 1024 byte header on the output file followed by a text and data segment, whose size is a multiple of 1024 bytes (being padded out with nulls in the file if necessary).  With this format the first few BSS segment symbols may actually appear, from the output of size(,), to live in the data segment. This avoids wasting the space which results from the data segment size roundup.

The lk linker does not support the following ld options: −A, −d, or −r. 

Restrictions

The lk command pads the images which are to be demand loaded from the file system to the next page boundary.

When linking code containing GFLOAT instructions, the GFLOAT versions of libc and/or the math library must be used rather than the normal DFLOAT versions.  Link to these by using −lcg and/or −lmg. 

The compiler and the linker lk() cannot detect the use of mixed double floating point types, and your program may produce erroneous results.

Files

/lib/lib*.alibraries
/usr/lib/lib*.alibraries
/usr/local/lib/lib*.alibraries
a.outoutput file
a.mapmap file

See Also

ar(1), as(1), cc(1), ld(1), ranlib(1)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026