ld man page on Ultrix

Man page or keyword search:  
man Server   3690 pages
apropos Keyword Search (all sections)
Output format
Ultrix logo
[printable version]

ld(1)									 ld(1)

Name
       ld - link editor

Syntax
       ld [option...] file...

Description
       The  command combines several object programs into one, resolves exter‐
       nal references, and searches libraries.	In the simplest case,  several
       object  files  are given, and combines them, producing an object module
       which can either be executed or can become the input for a further run.
       (In  the latter case, the -r option must be given to preserve the relo‐
       cation bits.)  The output of is left on a.out.  This file is only  made
       executable 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  the referenced routine must appear after the referencing
       routine in the library.	Thus, the order of programs  within  libraries
       is  important.	The  first  member of a library should be a file named
       __.SYMDEF, which is a dictionary for the library that  is  produced  by
       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 loca‐
       tion  above  all	 data,	in that order.	It is an error to define these
       symbols.

Options
       The command has several options.	 Except for the -l option, they should
       appear before the file names.

       -A	 Specifies  incremental	 loading.  Linking is done so that the
		 resulting object may be read into an already  executing  pro‐
		 gram.	 The  next argument is the name of a file whose symbol
		 table is used	to  define  additional	symbols.   Only	 newly
		 linked material is entered into the text and data portions of
		 a.out, but the new symbol table reflects every symbol defined
		 before	 and  after  the incremental load.  This argument must
		 appear before any other object file in the argument list.

		 The -T option may be used as well, and is taken to mean  that
		 the  newly  linked  segment  commences	 at  the corresponding
		 address (which must be a  multiple  of	 1024).	  The  default
		 value is the old value of _end.

       -D	 Takes	the next argument as a hexadecimal number and pads the
		 data segment with zero bytes to the indicated length.

       -d	 Forces definition of common storage even if the  -r  flag  is
		 present.

       -e	 Takes the next argument as the name of the entry point of the
		 loaded program; location 0 is the default.

       -Ldir	 Adds dir to the list of directories  that  are	 searched  for
		 libraries.  Directories specified with -L are searched before
		 the standard directories.

       -lx	 Abbreviates the library name libx.a, where  x	is  a  string.
		 The  command  searches for libraries first in any directories
		 specified with -L options, then in the	 standard  directories
		 /lib,	/usr/lib,  and	/usr/local/lib.	 A library is searched
		 when its name is encountered, so the placement	 of  a	-l  is
		 significant.

       -H	 Takes	the next argument as a decimal integer, adds it to the
		 end of text, and causes the data section to start at a higher
		 address.

       -M	 Produces a primitive load map, listing the names of the files
		 that are loaded.

       -N	 Indicates  a  portion	of  text  to  not  make	 read-only  or
		 sharable.  (Use magic number 0407.)

       -n	 Arranges (by giving the output file a 0410 magic number) that
		 the text portion is read-only and shared among all users exe‐
		 cuting	 the  file  when  the  output  file is executed.  This
		 involves moving the data areas up to the first possible  1024
		 byte boundary following the end of the text.

       -o	 Takes	the  name  argument after -o as the name of the output
		 file, instead of a.out.

       -r	 Generates relocation bits in the output file so that  it  can
		 be the subject of another run.	 This flag also prevents final
		 definitions from being given to common symbols and suppresses
		 the undefined symbol diagnostics.

       -S	 Strips	 the  output by removing all symbols except locals and
		 globals.

       -s	 Removes the symbol table and relocation bits  to  save	 space
		 (this	impairs the usefulness of the debuggers).  This infor‐
		 mation can also be removed by

       -T	 Takes the next argument as a hexadecimal  number  which  sets
		 the text segment origin.  The default origin is 0.

       -t(trace) Prints the name of each file as it is processed.

       -u	 Takes	the  next  argument as a symbol and enters it as unde‐
		 fined in the 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.

       -X	 Saves local symbols except for those whose names begin with a
		 capital L.  This option is used by to discard internally-gen‐
		 erated labels while retaining symbols local to routines.

       -x	 Discards  local (non-global) symbols in the output symbol ta‐
		 ble; only enters external symbols.  This  option  saves  some
		 space in the output file.

       -Yenvironment
		 Adjusts  the magic number in the output file so that the pro‐
		 gram runs in the specified environment .  The	parameter  can
		 be  POSIX, SYSTEM_FIVE, or BSD .  The parameter sets the pro‐
		 gram's execution environment to conform with one of the three
		 standards.   If  it  is present, this parameter overrides the
		 PROG_ENV environment variable.	 If no environment  is	given,
		 SYSTEM_FIVE  is  assumed.   If neither this parameter nor the
		 PROG_ENV variable is present, -YBSD is assumed.

       -ysym	 Indicates 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 underscore (_), because external C, FOR‐
		 TRAN and Pascal variables begin with underscores.

       -z	 Arranges for the process to be	 loaded	 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 seg‐
		 ment symbols may, from the output of appear to reside in  the
		 data  segment.	  This	avoids wasting the space which results
		 from the roundup of the data segment size.

Restrictions
       There is no way to force data to be page aligned.  The command pads the
       images  which  are to be demand loaded from the file system to the next
       page boundary.

       When linking code contains 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 cannot  detect  the	use  of	 mixed	double
       floating	 point	types, and your program may produce erroneous results.

Files
       /lib/lib*.a	   libraries.

       /usr/lib/lib*.a	   libraries

       /usr/local/lib/lib*.a
			   libraries

       a.out		   output file

See Also
       ar(1), as(1), cc(1), ranlib(1)

				      VAX				 ld(1)
[top]

List of man pages available for Ultrix

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net