Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.


   3 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
   4 .\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved
   5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
   6 .\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
   7 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   8 .TH LD 1 "Sep 10, 2013"
   9 .SH NAME
  10 ld \- link-editor for object files
  11 .SH SYNOPSIS
  12 .LP
  13 .nf
  14 \fBld\fR [\fB-32\fR | \fB-64\fR] [\fB-a\fR | \fB-r\fR] [\fB-b\fR] [\fB-B\fRdirect | nodirect]
  15 [\fB-B\fR dynamic | static] [\fB-B\fR eliminate] [\fB-B\fR group] [\fB-B\fR local]
  16 [\fB-B\fR reduce] [\fB-B\fR symbolic] [\fB-c\fR \fIname\fR] [\fB-C\fR] [\fB-d\fR y | n]
  17 [\fB-D\fR \fItoken\fR,...] [\fB-e\fR \fIepsym\fR] [\fB-f\fR \fIname\fR | \fB-F\fR \fIname\fR] [\fB-G\fR] [\fB-h\fR \fIname\fR]
  18 [\fB-i\fR] [\fB-I\fR \fIname\fR] [\fB-l\fR \fIx\fR] [\fB-L\fR \fIpath\fR] [\fB-m\fR] [\fB-M\fR \fImapfile\fR]
  19 [\fB-N\fR \fIstring\fR] [\fB-o\fR \fIoutfile\fR] [\fB-p\fR \fIauditlib\fR] [\fB-P\fR \fIauditlib\fR]
  20 [\fB-Q\fR y | n] [\fB-R\fR \fIpath\fR] [\fB-s\fR] [\fB-S\fR \fIsupportlib\fR] [\fB-t\fR]
  21 [\fB-u\fR \fIsymname\fR] [\fB-V\fR] [\fB-Y P\fR\fI,dirlist\fR] [\fB-z\fR absexec]
  22 [\fB-z\fR allextract | defaultextract | weakextract ] [\fB-z\fR altexec64]
  23 [\fB-z\fR assert-deflib ] [ \fB-z\fR assert-deflib=\fIlibname\fR ]
  24 [\fB-z\fR combreloc | nocombreloc ] [\fB-z\fR defs | nodefs]
  25 [\fB-z\fR direct | nodirect] [\fB-z\fR endfiltee]
  26 [\fB-z\fR fatal-warnings | nofatal-warnings ] [\fB-z\fR finiarray=\fIfunction\fR]
  27 [\fB-z\fR globalaudit] [\fB-z\fR groupperm | nogroupperm] 
  28 [\fB-z\fR guidance[=\fIid1\fR,\fIid2\fR...] [\fB-z\fR help ]
  29 [\fB-z\fR ignore | record] [\fB-z\fR initarray=\fIfunction\fR] [\fB-z\fR initfirst]
  30 [\fB-z\fR interpose] [\fB-z\fR lazyload | nolazyload]
  31 [\fB-z\fR ld32=\fIarg1\fR,\fIarg2\fR,...] [\fB-z\fR ld64=\fIarg1\fR,\fIarg2\fR,...]
  32 [\fB-z\fR loadfltr] [\fB-z\fR muldefs] [\fB-z\fR nocompstrtab] [\fB-z\fR nodefaultlib]
  33 [\fB-z\fR nodelete] [\fB-z\fR nodlopen] [\fB-z\fR nodump] [\fB-z\fR noldynsym]
  34 [\fB-z\fR nopartial] [\fB-z\fR noversion] [\fB-z\fR now] [\fB-z\fR origin]
  35 [\fB-z\fR preinitarray=\fIfunction\fR] [\fB-z\fR redlocsym] [\fB-z\fR relaxreloc]
  36 [\fB-z\fR rescan-now] [\fB-z\fR recan] [\fB-z\fR rescan-start \fI\&...\fR \fB-z\fR rescan-end]]
  37 [\fB-z\fR target=sparc|x86] [\fB-z\fR text | textwarn | textoff]
  38 [\fB-z\fR verbose] [\fB-z\fR wrap=\fIsymbol\fR] \fIfilename\fR...
  39 .fi
  40 
  41 .SH DESCRIPTION
  42 .sp
  43 .LP
  44 The link-editor, \fBld\fR, combines relocatable object files by resolving
  45 symbol references to symbol definitions, together with performing relocations.
  46 \fBld\fR operates in two modes, static or dynamic, as governed by the \fB-d\fR
  47 option. In all cases, the output of \fBld\fR is left in the file \fBa.out\fR by
  48 default. See NOTES.
  49 .sp
  50 .LP
  51 In dynamic mode, \fB-dy\fR, the default, relocatable object files that are
  52 provided as arguments are combined to produce an executable object file. This
  53 file is linked at execution with any shared object files that are provided as
  54 arguments. If the \fB-G\fR option is specified, relocatable object files are
  55 combined to produce a shared object. Without the \fB-G\fR option, a dynamic
  56 executable is created.
  57 .sp
  58 .LP
  59 In static mode, \fB-dn\fR, relocatable object files that are provided as
  60 arguments are combined to produce a static executable file. If the \fB-r\fR
  61 option is specified, relocatable object files are combined to produce one
  62 relocatable object file. See \fBStatic Executables\fR.


  87 For an archive library, \fBld\fR loads only those routines that define an
  88 unresolved external reference. \fBld\fR searches the symbol table of the
  89 archive library sequentially to resolve external references that can be
  90 satisfied by library members. This search is repeated until no external
  91 references can be resolved by the archive. Thus, the order of members in the
  92 library is functionally unimportant, unless multiple library members exist that
  93 define the same external symbol. Archive libraries that have interdependencies
  94 can require multiple command line definitions, or the use of one of the
  95 \fB-z\fR \fBrescan\fR options. See \fIArchive Processing\fR in \fILinker and
  96 Libraries Guide\fR.
  97 .sp
  98 .LP
  99 \fBld\fR is a cross link-editor, able to link 32-bit objects or 64-bit objects,
 100 for Sparc or x86 targets. \fBld\fR uses the \fBELF\fR class and machine type of
 101 the first relocatable object on the command line to govern the mode in which to
 102 operate. The mixing of 32-bit objects and 64-bit objects is not permitted.
 103 Similarly, only objects of a single machine type are allowed. See the
 104 \fB-32\fR, \fB-64\fR and \fB-z target\fR options, and the \fBLD_NOEXEC_64\fR
 105 environment variable.
 106 .SS "Static Executables"
 107 .sp
 108 .LP
 109 The creation of static executables has been discouraged for many releases. In
 110 fact, 64-bit system archive libraries have never been provided. Because a
 111 static executable is built against system archive libraries, the executable
 112 contains system implementation details. This self-containment has a number of
 113 drawbacks.
 114 .RS +4
 115 .TP
 116 .ie t \(bu
 117 .el o
 118 The executable is immune to the benefits of system patches delivered as shared
 119 objects. The executable therefore, must be rebuilt to take advantage of many
 120 system improvements.
 121 .RE
 122 .RS +4
 123 .TP
 124 .ie t \(bu
 125 .el o
 126 The ability of the executable to run on future releases can be compromised.
 127 .RE
 128 .RS +4
 129 .TP
 130 .ie t \(bu
 131 .el o
 132 The duplication of system implementation details negatively affects system
 133 performance.
 134 .RE
 135 .sp
 136 .LP
 137 With Solaris 10, 32-bit system archive libraries are no longer provided.
 138 Without these libraries, specifically \fBlibc.a\fR, the creation of static
 139 executables is no longer achievable without specialized system knowledge.
 140 However, the capability of \fBld\fR to process static linking options, and the
 141 processing of archive libraries, remains unchanged.
 142 .SH OPTIONS
 143 .sp
 144 .LP
 145 The following options are supported.
 146 .sp
 147 .ne 2
 148 .na
 149 \fB\fB-32\fR | \fB-64\fR\fR
 150 .ad
 151 .sp .6
 152 .RS 4n
 153 Creates a 32-bit, or 64-bit object.
 154 .sp
 155 By default, the class of the object being generated is determined from the
 156 first \fBELF\fR object processed from the command line. If no objects are
 157 specified, the class is determined by the first object encountered within the
 158 first archive processed from the command line. If there are no objects or
 159 archives, the link-editor creates a 32-bit object.
 160 .sp
 161 The \fB-64\fR option is required to create a 64-bit object solely from a
 162 mapfile.
 163 .sp


 828 .RE
 829 
 830 .sp
 831 .ne 2
 832 .na
 833 \fB\fB-z\fR \fBaltexec64\fR\fR
 834 .ad
 835 .sp .6
 836 .RS 4n
 837 Execute the 64-bit \fBld\fR. The creation of very large 32-bit objects can
 838 exhaust the virtual memory that is available to the 32-bit \fBld\fR. The
 839 \fB-z\fR \fBaltexec64\fR option can be used to force the use of the associated
 840 64-bit \fBld\fR. The 64-bit \fBld\fR provides a larger virtual address space
 841 for building 32-bit objects. See \fIThe 32-bit link-editor and 64-bit
 842 link-editor\fR in \fILinker and Libraries Guide\fR.
 843 .RE
 844 
 845 .sp
 846 .ne 2
 847 .na

















 848 \fB\fB-z\fR \fBcombreloc\fR | \fBnocombreloc\fR\fR
 849 .ad
 850 .sp .6
 851 .RS 4n
 852 By default, \fBld\fR combines multiple relocation sections when building
 853 executables or shared objects. This section combination differs from
 854 relocatable objects, in which relocation sections are maintained in a
 855 one-to-one relationship with the sections to which the relocations must be
 856 applied. The \fB-z\fR \fBnocombreloc\fR option disables this merging of
 857 relocation sections, and preserves the one-to-one relationship found in the
 858 original relocatable objects.
 859 .sp
 860 \fBld\fR sorts the entries of data relocation sections by their symbol
 861 reference. This sorting reduces runtime symbol lookup. When multiple relocation
 862 sections are combined, this sorting produces the least possible relocation
 863 overhead when objects are loaded into memory, and speeds the runtime loading of
 864 dynamic objects.
 865 .sp
 866 Historically, the individual relocation sections were carried over to any
 867 executable or shared object, and the \fB-z\fR \fBcombreloc\fR option was


1612 __wrap_malloc(size_t c)
1613 {
1614         (void) printf("malloc called with %zu\en", c);
1615         return (__real_malloc(c));
1616 }
1617 .fi
1618 .in -2
1619 
1620 If you link other code with this file using \fB-z\fR \fBwrap=malloc\fR to
1621 compile all the objects, then all calls to \fBmalloc\fR will call the function
1622 \fB__wrap_malloc\fR instead. The call to \fB__real_malloc\fR will call the real
1623 \fBmalloc\fR function.
1624 .sp
1625 The real and wrapped functions should be maintained in separate source files.
1626 Otherwise, the compiler or assembler may resolve the call instead of leaving
1627 that operation for the link-editor to carry out, and prevent the wrap from
1628 occurring.
1629 .RE
1630 
1631 .SH ENVIRONMENT VARIABLES
1632 .sp
1633 .ne 2
1634 .na
1635 \fB\fBLD_ALTEXEC\fR\fR
1636 .ad
1637 .sp .6
1638 .RS 4n
1639 An alternative link-editor path name. \fBld\fR executes, and passes control to
1640 this alternative link-editor. This environment variable provides a generic
1641 means of overriding the default link-editor that is called from the various
1642 compiler drivers. See the \fB-z altexec64\fR option.
1643 .RE
1644 
1645 .sp
1646 .ne 2
1647 .na
1648 \fB\fBLD_LIBRARY_PATH\fR\fR
1649 .ad
1650 .sp .6
1651 .RS 4n
1652 A list of directories in which to search for the libraries specified using the


1741 .ne 2
1742 .na
1743 \fB\fBSGS_SUPPORT\fR\fR
1744 .ad
1745 .sp .6
1746 .RS 4n
1747 Provides a colon-separated list of shared objects that are loaded with the
1748 link-editor and given information regarding the linking process. This
1749 environment variable can be specified with a _32 or _64 suffix. This makes the
1750 environment variable specific, respectively, to the 32-bit or 64-bit class of
1751 \fBld\fR and overrides any non-suffixed version of the environment variable
1752 that is in effect. See the \fB-S\fR option.
1753 .RE
1754 
1755 .sp
1756 .LP
1757 Notice that environment variable-names that begin with the
1758 characters '\fBLD_\fR' are reserved for possible future enhancements to \fBld\fR and
1759 \fBld.so.1\fR(1).
1760 .SH FILES
1761 .sp
1762 .ne 2
1763 .na
1764 \fB\fBlib\fIx\fR.so\fR\fR
1765 .ad
1766 .RS 15n
1767 shared object libraries.
1768 .RE
1769 
1770 .sp
1771 .ne 2
1772 .na
1773 \fB\fBlib\fIx\fR.a\fR\fR
1774 .ad
1775 .RS 15n
1776 archive libraries.
1777 .RE
1778 
1779 .sp
1780 .ne 2
1781 .na


1791 \fB\fILIBPATH\fR\fR
1792 .ad
1793 .RS 15n
1794 For 32-bit libraries, the default search path is \fB/usr/ccs/lib\fR, followed
1795 by \fB/lib\fR, and finally \fB/usr/lib\fR. For 64-bit libraries, the default
1796 search path is \fB/lib/64\fR, followed by \fB/usr/lib/64\fR.
1797 .RE
1798 
1799 .sp
1800 .ne 2
1801 .na
1802 \fB\fB/usr/lib/ld\fR\fR
1803 .ad
1804 .RS 15n
1805 A directory containing several \fBmapfiles\fR that can be used during
1806 link-editing. These \fBmapfiles\fR provide various capabilities, such as
1807 defining memory layouts, aligning bss, and defining non-executable stacks.
1808 .RE
1809 
1810 .SH ATTRIBUTES
1811 .sp
1812 .LP
1813 See \fBattributes\fR(5) for descriptions of the following attributes:
1814 .sp
1815 
1816 .sp
1817 .TS
1818 box;
1819 c | c
1820 l | l .
1821 ATTRIBUTE TYPE  ATTRIBUTE VALUE
1822 _
1823 Interface Stability     Committed
1824 .TE
1825 
1826 .SH SEE ALSO
1827 .sp
1828 .LP
1829 \fBas\fR(1), \fBcrle\fR(1), \fBgprof\fR(1), \fBld.so.1\fR(1), \fBldd\fR(1),
1830 \fBmcs\fR(1), \fBpvs\fR(1), \fBexec\fR(2), \fBstat\fR(2), \fBdlopen\fR(3C),
1831 \fBdldump\fR(3C), \fBelf\fR(3ELF), \fBar.h\fR(3HEAD), \fBa.out\fR(4),
1832 \fBattributes\fR(5)
1833 .sp
1834 .LP
1835 \fILinker and Libraries Guide\fR
1836 .SH NOTES
1837 .sp
1838 .LP
1839 Default options applied by \fBld\fR are maintained for historic reasons. In
1840 today's programming environment, where dynamic objects dominate, alternative
1841 defaults would often make more sense. However, historic defaults must be
1842 maintained to ensure compatibility with existing program development
1843 environments. Historic defaults are called out wherever possible in this
1844 manual. For a description of the current recommended options, see Appendix A,
1845 \fILink-Editor Quick Reference,\fR in \fILinker and Libraries Guide\fR.
1846 .sp
1847 .LP
1848 If the file being created by \fBld\fR already exists, the file is unlinked
1849 after all input files have been processed. A new file with the specified name
1850 is then created. This allows \fBld\fR to create a new version of the file,
1851 while simultaneously allowing existing processes that are accessing the old
1852 file contents to continue running. If the old file has no other links, the disk
1853 space of the removed file is freed when the last process referencing the file
1854 terminates.
1855 .sp
1856 .LP
1857 The behavior of \fBld\fR when the file being created already exists was changed


   3 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
   4 .\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved
   5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
   6 .\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
   7 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   8 .TH LD 1 "Sep 10, 2013"
   9 .SH NAME
  10 ld \- link-editor for object files
  11 .SH SYNOPSIS
  12 .LP
  13 .nf
  14 \fBld\fR [\fB-32\fR | \fB-64\fR] [\fB-a\fR | \fB-r\fR] [\fB-b\fR] [\fB-B\fRdirect | nodirect]
  15 [\fB-B\fR dynamic | static] [\fB-B\fR eliminate] [\fB-B\fR group] [\fB-B\fR local]
  16 [\fB-B\fR reduce] [\fB-B\fR symbolic] [\fB-c\fR \fIname\fR] [\fB-C\fR] [\fB-d\fR y | n]
  17 [\fB-D\fR \fItoken\fR,...] [\fB-e\fR \fIepsym\fR] [\fB-f\fR \fIname\fR | \fB-F\fR \fIname\fR] [\fB-G\fR] [\fB-h\fR \fIname\fR]
  18 [\fB-i\fR] [\fB-I\fR \fIname\fR] [\fB-l\fR \fIx\fR] [\fB-L\fR \fIpath\fR] [\fB-m\fR] [\fB-M\fR \fImapfile\fR]
  19 [\fB-N\fR \fIstring\fR] [\fB-o\fR \fIoutfile\fR] [\fB-p\fR \fIauditlib\fR] [\fB-P\fR \fIauditlib\fR]
  20 [\fB-Q\fR y | n] [\fB-R\fR \fIpath\fR] [\fB-s\fR] [\fB-S\fR \fIsupportlib\fR] [\fB-t\fR]
  21 [\fB-u\fR \fIsymname\fR] [\fB-V\fR] [\fB-Y P\fR\fI,dirlist\fR] [\fB-z\fR absexec]
  22 [\fB-z\fR allextract | defaultextract | weakextract ] [\fB-z\fR altexec64]
  23 [\fB-z\fR aslr[=\fIstate\fR]] [\fB-z\fR assert-deflib] [ \fB-z\fR assert-deflib=\fIlibname\fR]
  24 [\fB-z\fR combreloc | nocombreloc ] [\fB-z\fR defs | nodefs]
  25 [\fB-z\fR direct | nodirect] [\fB-z\fR endfiltee]
  26 [\fB-z\fR fatal-warnings | nofatal-warnings ] [\fB-z\fR finiarray=\fIfunction\fR]
  27 [\fB-z\fR globalaudit] [\fB-z\fR groupperm | nogroupperm] 
  28 [\fB-z\fR guidance[=\fIid1\fR,\fIid2\fR...] [\fB-z\fR help ]
  29 [\fB-z\fR ignore | record] [\fB-z\fR initarray=\fIfunction\fR] [\fB-z\fR initfirst]
  30 [\fB-z\fR interpose] [\fB-z\fR lazyload | nolazyload]
  31 [\fB-z\fR ld32=\fIarg1\fR,\fIarg2\fR,...] [\fB-z\fR ld64=\fIarg1\fR,\fIarg2\fR,...]
  32 [\fB-z\fR loadfltr] [\fB-z\fR muldefs] [\fB-z\fR nocompstrtab] [\fB-z\fR nodefaultlib]
  33 [\fB-z\fR nodelete] [\fB-z\fR nodlopen] [\fB-z\fR nodump] [\fB-z\fR noldynsym]
  34 [\fB-z\fR nopartial] [\fB-z\fR noversion] [\fB-z\fR now] [\fB-z\fR origin]
  35 [\fB-z\fR preinitarray=\fIfunction\fR] [\fB-z\fR redlocsym] [\fB-z\fR relaxreloc]
  36 [\fB-z\fR rescan-now] [\fB-z\fR recan] [\fB-z\fR rescan-start \fI\&...\fR \fB-z\fR rescan-end]]
  37 [\fB-z\fR target=sparc|x86] [\fB-z\fR text | textwarn | textoff]
  38 [\fB-z\fR verbose] [\fB-z\fR wrap=\fIsymbol\fR] \fIfilename\fR...
  39 .fi
  40 
  41 .SH DESCRIPTION

  42 .LP
  43 The link-editor, \fBld\fR, combines relocatable object files by resolving
  44 symbol references to symbol definitions, together with performing relocations.
  45 \fBld\fR operates in two modes, static or dynamic, as governed by the \fB-d\fR
  46 option. In all cases, the output of \fBld\fR is left in the file \fBa.out\fR by
  47 default. See NOTES.
  48 .sp
  49 .LP
  50 In dynamic mode, \fB-dy\fR, the default, relocatable object files that are
  51 provided as arguments are combined to produce an executable object file. This
  52 file is linked at execution with any shared object files that are provided as
  53 arguments. If the \fB-G\fR option is specified, relocatable object files are
  54 combined to produce a shared object. Without the \fB-G\fR option, a dynamic
  55 executable is created.
  56 .sp
  57 .LP
  58 In static mode, \fB-dn\fR, relocatable object files that are provided as
  59 arguments are combined to produce a static executable file. If the \fB-r\fR
  60 option is specified, relocatable object files are combined to produce one
  61 relocatable object file. See \fBStatic Executables\fR.


  86 For an archive library, \fBld\fR loads only those routines that define an
  87 unresolved external reference. \fBld\fR searches the symbol table of the
  88 archive library sequentially to resolve external references that can be
  89 satisfied by library members. This search is repeated until no external
  90 references can be resolved by the archive. Thus, the order of members in the
  91 library is functionally unimportant, unless multiple library members exist that
  92 define the same external symbol. Archive libraries that have interdependencies
  93 can require multiple command line definitions, or the use of one of the
  94 \fB-z\fR \fBrescan\fR options. See \fIArchive Processing\fR in \fILinker and
  95 Libraries Guide\fR.
  96 .sp
  97 .LP
  98 \fBld\fR is a cross link-editor, able to link 32-bit objects or 64-bit objects,
  99 for Sparc or x86 targets. \fBld\fR uses the \fBELF\fR class and machine type of
 100 the first relocatable object on the command line to govern the mode in which to
 101 operate. The mixing of 32-bit objects and 64-bit objects is not permitted.
 102 Similarly, only objects of a single machine type are allowed. See the
 103 \fB-32\fR, \fB-64\fR and \fB-z target\fR options, and the \fBLD_NOEXEC_64\fR
 104 environment variable.
 105 .SS "Static Executables"

 106 .LP
 107 The creation of static executables has been discouraged for many releases. In
 108 fact, 64-bit system archive libraries have never been provided. Because a
 109 static executable is built against system archive libraries, the executable
 110 contains system implementation details. This self-containment has a number of
 111 drawbacks.
 112 .RS +4
 113 .TP
 114 .ie t \(bu
 115 .el o
 116 The executable is immune to the benefits of system patches delivered as shared
 117 objects. The executable therefore, must be rebuilt to take advantage of many
 118 system improvements.
 119 .RE
 120 .RS +4
 121 .TP
 122 .ie t \(bu
 123 .el o
 124 The ability of the executable to run on future releases can be compromised.
 125 .RE
 126 .RS +4
 127 .TP
 128 .ie t \(bu
 129 .el o
 130 The duplication of system implementation details negatively affects system
 131 performance.
 132 .RE
 133 .sp
 134 .LP
 135 With Solaris 10, 32-bit system archive libraries are no longer provided.
 136 Without these libraries, specifically \fBlibc.a\fR, the creation of static
 137 executables is no longer achievable without specialized system knowledge.
 138 However, the capability of \fBld\fR to process static linking options, and the
 139 processing of archive libraries, remains unchanged.
 140 .SH OPTIONS

 141 .LP
 142 The following options are supported.
 143 .sp
 144 .ne 2
 145 .na
 146 \fB\fB-32\fR | \fB-64\fR\fR
 147 .ad
 148 .sp .6
 149 .RS 4n
 150 Creates a 32-bit, or 64-bit object.
 151 .sp
 152 By default, the class of the object being generated is determined from the
 153 first \fBELF\fR object processed from the command line. If no objects are
 154 specified, the class is determined by the first object encountered within the
 155 first archive processed from the command line. If there are no objects or
 156 archives, the link-editor creates a 32-bit object.
 157 .sp
 158 The \fB-64\fR option is required to create a 64-bit object solely from a
 159 mapfile.
 160 .sp


 825 .RE
 826 
 827 .sp
 828 .ne 2
 829 .na
 830 \fB\fB-z\fR \fBaltexec64\fR\fR
 831 .ad
 832 .sp .6
 833 .RS 4n
 834 Execute the 64-bit \fBld\fR. The creation of very large 32-bit objects can
 835 exhaust the virtual memory that is available to the 32-bit \fBld\fR. The
 836 \fB-z\fR \fBaltexec64\fR option can be used to force the use of the associated
 837 64-bit \fBld\fR. The 64-bit \fBld\fR provides a larger virtual address space
 838 for building 32-bit objects. See \fIThe 32-bit link-editor and 64-bit
 839 link-editor\fR in \fILinker and Libraries Guide\fR.
 840 .RE
 841 
 842 .sp
 843 .ne 2
 844 .na
 845 \fB-z\fR \fBaslr[=\fIstate\fR]\fR
 846 .ad
 847 .sp .6
 848 .RS 4n
 849 Specify whether the executable's address space should be randomized on
 850 execution.  If \fIstate\fR is "enabled" randomization will always occur when
 851 this executable is run (regardless of inherited settings).  If \fIstate\fR is
 852 "disabled" randomization will never occur when this executable is run.  If
 853 \fIstate\fR is omitted, ASLR is enabled.
 854 
 855 An executable that should simply use the settings inherited from its
 856 environment should not use this flag at all.
 857 .RE
 858 
 859 .sp
 860 .ne 2
 861 .na
 862 \fB\fB-z\fR \fBcombreloc\fR | \fBnocombreloc\fR\fR
 863 .ad
 864 .sp .6
 865 .RS 4n
 866 By default, \fBld\fR combines multiple relocation sections when building
 867 executables or shared objects. This section combination differs from
 868 relocatable objects, in which relocation sections are maintained in a
 869 one-to-one relationship with the sections to which the relocations must be
 870 applied. The \fB-z\fR \fBnocombreloc\fR option disables this merging of
 871 relocation sections, and preserves the one-to-one relationship found in the
 872 original relocatable objects.
 873 .sp
 874 \fBld\fR sorts the entries of data relocation sections by their symbol
 875 reference. This sorting reduces runtime symbol lookup. When multiple relocation
 876 sections are combined, this sorting produces the least possible relocation
 877 overhead when objects are loaded into memory, and speeds the runtime loading of
 878 dynamic objects.
 879 .sp
 880 Historically, the individual relocation sections were carried over to any
 881 executable or shared object, and the \fB-z\fR \fBcombreloc\fR option was


1626 __wrap_malloc(size_t c)
1627 {
1628         (void) printf("malloc called with %zu\en", c);
1629         return (__real_malloc(c));
1630 }
1631 .fi
1632 .in -2
1633 
1634 If you link other code with this file using \fB-z\fR \fBwrap=malloc\fR to
1635 compile all the objects, then all calls to \fBmalloc\fR will call the function
1636 \fB__wrap_malloc\fR instead. The call to \fB__real_malloc\fR will call the real
1637 \fBmalloc\fR function.
1638 .sp
1639 The real and wrapped functions should be maintained in separate source files.
1640 Otherwise, the compiler or assembler may resolve the call instead of leaving
1641 that operation for the link-editor to carry out, and prevent the wrap from
1642 occurring.
1643 .RE
1644 
1645 .SH ENVIRONMENT VARIABLES

1646 .ne 2
1647 .na
1648 \fB\fBLD_ALTEXEC\fR\fR
1649 .ad
1650 .sp .6
1651 .RS 4n
1652 An alternative link-editor path name. \fBld\fR executes, and passes control to
1653 this alternative link-editor. This environment variable provides a generic
1654 means of overriding the default link-editor that is called from the various
1655 compiler drivers. See the \fB-z altexec64\fR option.
1656 .RE
1657 
1658 .sp
1659 .ne 2
1660 .na
1661 \fB\fBLD_LIBRARY_PATH\fR\fR
1662 .ad
1663 .sp .6
1664 .RS 4n
1665 A list of directories in which to search for the libraries specified using the


1754 .ne 2
1755 .na
1756 \fB\fBSGS_SUPPORT\fR\fR
1757 .ad
1758 .sp .6
1759 .RS 4n
1760 Provides a colon-separated list of shared objects that are loaded with the
1761 link-editor and given information regarding the linking process. This
1762 environment variable can be specified with a _32 or _64 suffix. This makes the
1763 environment variable specific, respectively, to the 32-bit or 64-bit class of
1764 \fBld\fR and overrides any non-suffixed version of the environment variable
1765 that is in effect. See the \fB-S\fR option.
1766 .RE
1767 
1768 .sp
1769 .LP
1770 Notice that environment variable-names that begin with the
1771 characters '\fBLD_\fR' are reserved for possible future enhancements to \fBld\fR and
1772 \fBld.so.1\fR(1).
1773 .SH FILES

1774 .ne 2
1775 .na
1776 \fB\fBlib\fIx\fR.so\fR\fR
1777 .ad
1778 .RS 15n
1779 shared object libraries.
1780 .RE
1781 
1782 .sp
1783 .ne 2
1784 .na
1785 \fB\fBlib\fIx\fR.a\fR\fR
1786 .ad
1787 .RS 15n
1788 archive libraries.
1789 .RE
1790 
1791 .sp
1792 .ne 2
1793 .na


1803 \fB\fILIBPATH\fR\fR
1804 .ad
1805 .RS 15n
1806 For 32-bit libraries, the default search path is \fB/usr/ccs/lib\fR, followed
1807 by \fB/lib\fR, and finally \fB/usr/lib\fR. For 64-bit libraries, the default
1808 search path is \fB/lib/64\fR, followed by \fB/usr/lib/64\fR.
1809 .RE
1810 
1811 .sp
1812 .ne 2
1813 .na
1814 \fB\fB/usr/lib/ld\fR\fR
1815 .ad
1816 .RS 15n
1817 A directory containing several \fBmapfiles\fR that can be used during
1818 link-editing. These \fBmapfiles\fR provide various capabilities, such as
1819 defining memory layouts, aligning bss, and defining non-executable stacks.
1820 .RE
1821 
1822 .SH ATTRIBUTES

1823 .LP
1824 See \fBattributes\fR(5) for descriptions of the following attributes:
1825 .sp
1826 
1827 .sp
1828 .TS
1829 box;
1830 c | c
1831 l | l .
1832 ATTRIBUTE TYPE  ATTRIBUTE VALUE
1833 _
1834 Interface Stability     Committed
1835 .TE
1836 
1837 .SH SEE ALSO

1838 .LP
1839 \fBas\fR(1), \fBcrle\fR(1), \fBgprof\fR(1), \fBld.so.1\fR(1), \fBldd\fR(1),
1840 \fBmcs\fR(1), \fBpvs\fR(1), \fBexec\fR(2), \fBstat\fR(2), \fBdlopen\fR(3C),
1841 \fBdldump\fR(3C), \fBelf\fR(3ELF), \fBar.h\fR(3HEAD), \fBa.out\fR(4),
1842 \fBattributes\fR(5)
1843 .sp
1844 .LP
1845 \fILinker and Libraries Guide\fR
1846 .SH NOTES

1847 .LP
1848 Default options applied by \fBld\fR are maintained for historic reasons. In
1849 today's programming environment, where dynamic objects dominate, alternative
1850 defaults would often make more sense. However, historic defaults must be
1851 maintained to ensure compatibility with existing program development
1852 environments. Historic defaults are called out wherever possible in this
1853 manual. For a description of the current recommended options, see Appendix A,
1854 \fILink-Editor Quick Reference,\fR in \fILinker and Libraries Guide\fR.
1855 .sp
1856 .LP
1857 If the file being created by \fBld\fR already exists, the file is unlinked
1858 after all input files have been processed. A new file with the specified name
1859 is then created. This allows \fBld\fR to create a new version of the file,
1860 while simultaneously allowing existing processes that are accessing the old
1861 file contents to continue running. If the old file has no other links, the disk
1862 space of the removed file is freed when the last process referencing the file
1863 terminates.
1864 .sp
1865 .LP
1866 The behavior of \fBld\fR when the file being created already exists was changed