1 '\" te
2 .\" Copyright 1989 AT&T
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 "Oct 24, 2012"
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 ]
1594 \fB\fB--wrap=\fR \fIsymbol\fR\fR
1595 .ad
1596 .sp .6
1597 .RS 4n
1598 Rename undefined references to \fIsymbol\fR in order to allow wrapper code to
1599 be linked into the output object without having to modify source code. When
1600 \fB-z wrap\fR is specified, all undefined references to \fIsymbol\fR are
1601 modified to reference \fB__wrap_\fR\fIsymbol\fR, and all references to
1602 \fB__real_\fR\fIsymbol\fR are modified to reference \fIsymbol\fR. The user is
1603 expected to provide an object containing the \fB__wrap_\fR\fIsymbol\fR
1604 function. This wrapper function can call \fB__real_\fR\fIsymbol\fR in order to
1605 reference the actual function being wrapped.
1606 .sp
1607 The following is an example of a wrapper for the \fBmalloc\fR(3C) function:
1608 .sp
1609 .in +2
1610 .nf
1611 void *
1612 __wrap_malloc(size_t c)
1613 {
1614 (void) printf("malloc called with %zu\n", 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
|
1 '\" te
2 .\" Copyright 1989 AT&T
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 ]
1594 \fB\fB--wrap=\fR \fIsymbol\fR\fR
1595 .ad
1596 .sp .6
1597 .RS 4n
1598 Rename undefined references to \fIsymbol\fR in order to allow wrapper code to
1599 be linked into the output object without having to modify source code. When
1600 \fB-z wrap\fR is specified, all undefined references to \fIsymbol\fR are
1601 modified to reference \fB__wrap_\fR\fIsymbol\fR, and all references to
1602 \fB__real_\fR\fIsymbol\fR are modified to reference \fIsymbol\fR. The user is
1603 expected to provide an object containing the \fB__wrap_\fR\fIsymbol\fR
1604 function. This wrapper function can call \fB__real_\fR\fIsymbol\fR in order to
1605 reference the actual function being wrapped.
1606 .sp
1607 The following is an example of a wrapper for the \fBmalloc\fR(3C) function:
1608 .sp
1609 .in +2
1610 .nf
1611 void *
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
|