ld(XNX) 6 January 1993 ld(XNX) Name ld - invokes the link editor Syntax ld [options] file... Description ld is the XENIX link editor. It creates an executable program by combin- ing one or more object files and copying the executable result to the file a.out. The file must name an object or library file. By convention these names have the ``.o'' (for object) or ``.a'' (for archive library) extensions. If more than one name is given, the names must be separated by one or more spaces. If errors occur while linking, ld displays an error message; the resulting a.out file is unexecutable. ld concatenates the contents of the given object files in the order given in the command line. Library files in the command line are examined only if there are unresolved external references encountered from previous object files. Library files must be in ranlib(XNX) format, that is, the first member must be named .SYMDEF, which is a dictionary for the library. ld ignores the modification dates of the library and the .SYMDEF entry, so if object files have been added to the library since .SYMDEF was created, the link may result in an ``invalid object module.'' The library is searched iteratively to satisfy as many references as pos- sible and only those routines that define unresolved external references are concatenated. Object and library files are processed at the point they are encountered in the argument list, so the order of files in the command line is important. In general, all object files should be given before library files. ld sets the entry point of the resulting program to the beginning of the first routine. ld should be invoked using the cc(CP) command instead of invoking it directly. cc invokes ld as the last step of compilation, providing all the necessary C-language support routines. Invoking ld directly is not recommended since failure to give command line arguments in the correct order can result in errors. There are the following options: -A hex-num Creates a standalone program whose expected load address (in hexadecimal) is hex-num. This option sets the absolute flag in the header of the a.out file. Such program files can only be executed as standalone programs. Options -A and -F are mutually exclusive. -B hex-num Sets the text selector bias to the specified hexadecimal num- ber. -c num Alters the default target CPU in the x.out header. num can be 0, 1, 2, or 3 indicating 8086, 80186, 80286 and 80386 pro- cessors, respectively. The default on 8086/80286 systems is 0. The default on 80386 systems is 3. Note that this option only alters the default; if object modules containing code for a higher numbered processor are linked, then that will take precedence over the default. -C Causes the link editor to ignore the case of symbols. -D hex-num Sets the data selector bias to the specified hexadecimal num- ber. -F hex-num Sets the size of the program stack to hex-num bytes (in hexa- decimal). This option is ignored for 80386 programs which have a variable sized stack. By default 8086 programs have a variable stack located at the top of the first data segment, and 80286 programs have a fixed size 4096 byte stack. The -F option is incompatible with the -A option. -g Includes symbolic information for sdb. -i Creates separate instruction and data spaces for small model programs. When the output file is executed, the program text and data areas are allocated separate physical segments. The text portion will be read-only and shared by all users exe- cuting the file. -La Sets advisory file locking. Advisory locking is used on files with access modes that do not require mandatory locking. -Lm Sets mandatory file locking. Mandatory file locking is used on files that cannot be opened by more than one process at a time. -mname Creates a link map file named name that includes public sym- bols. -Mx Specifies the memory model. x can have the following values: s small m middle l large h huge e mixed -n num Truncates symbols to the length specified by num. -N hex-num Sets the page size to hex-num (which should be a multiple of 512 decimal) - the default is 400 (1024 decimal) for 80386 programs. 8086/80186/80286 programs do not normally have page-aligned x.out files and the default for these is 0. -o name Sets the executable program filename to name instead of a.out. -P Disables packing of segments -r Invokes the incremental linker, /lib/ldr, with the arguments passed to ld to produce a relocatable output file. -R Ensures that the relocation table is of non-zero size. Important for 8086 compatibility. -Rd hex-num Specify the data segment relocation offset (80386 only). hex-num is a hexadecimal number. -Rt hex-num Specify the text segment relocation offset (80386 only) hex- num is a hexadecimal number. -s Strips the symbol table. -S num Sets the maximum number of segments to num. If no argument is given, the default is 128. -u symbol Designates the specified symbol as undefined. -v num Specifies the version number. Acceptable values for num are 2, 3, or 5; 5 is the default. Files /bin/ld Notes The user must make sure that the most recent library versions have been processed with ranlib(XNX) before linking. If this is not done, ld can- not create executable programs using these libraries. ld operates on COFF files transparently, mapping COFF symbol types to standard XENIX x.out symbol types when possible. See also ar(XNX), masm(CP), cc(CP), ranlib(XNX) Standards conformance ld is conformant with: AT&T SVID Issue 2.