2 .\" Copyright (c) 2008 by Sun Microsystems, Inc. All rights reserved.
3 .\" 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.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" 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 the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH ELFWRAP 1 "Sep 10, 2013"
8 elfwrap \- wrap data in an \fBELF\fR file
12 \fBelfwrap\fR [\fB-64\fR] [\fB-o\fR \fIrelobj-file\fR] [\fB-z\fR target=\fBsparc\fR | \fBx86\fR]
19 The \fBelfwrap\fR utility creates an \fBELF\fR relocatable object file from one
20 or more data files. The relocatable object encapsulates each data file within
21 an individual section, together with symbols that can be used to reference the
22 section. The relocatable object is appropriate for inclusion with a subsequent
23 link-edit. Users can reference the encapsulated data using the associated
27 By default, a 32-bit \fBELF\fR relocatable object is created that is
28 appropriate for the machine on which \fBelfwrap\fR is executed. The \fB-64\fR
29 option can be used to create a 64-bit \fBELF\fR relocatable object. The \fB-z
30 target\fR option can be used to create a relocatable object for a specific
36 Any data encapsulated with \fBelfwrap\fR must be in a format appropriate for
37 the destination target.
41 By default, the relocatable object \fBa.wrap.o\fR is created. The \fB-o\fR
42 option can be used to specify an alternative relocatable object name.
45 The \fBbasename\fR(1) of each data file is used to create various pieces of
46 \fBELF\fR information. For example, if the input data file is
47 \fBISV/isv-data\fR, the following \fBELF\fR information is created within the
52 \fBAn \fBELF\fR section named \fB\&.isv-data\fR\fR
56 This section contains the entire contents of the input data file.
62 \fBAn \fBELF\fR symbol named \fBisv-data_start\fR\fR
66 This symbol reflects the starting address of the \fB\&.isv-data\fR section.
72 \fBAn \fBELF\fR symbol named \fBisv-data_end\fR\fR
76 This symbol reflects the address of the first location after the
77 \fB\&.isv-data\fR section.
83 The following options are supported:
91 Create a 64-bit \fBELF\fR relocatable object.
97 \fB\fB-o\fR \fIrelobj-file\fR\fR
101 Produce a relocatable object that is named \fIrelobj-file\fR.
107 \fB\fB-z\fR target=\fBsparc\fR | \fBx86\fR\fR
111 Specifies the machine type for the output relocatable object. Supported targets
112 are \fBsparc\fR and \fBx86\fR. The 32-bit machine type for the specified target
113 is used unless the \fB-64\fR option is also present, in which case the
114 corresponding 64-bit machine type is used. By default, the relocatable object
115 that is generated is 32-bit for the machine one which \fBelfwrap\fR is
122 The following example encapsulates the system \fBpasswd\fR file and the system
123 \fBgroup\fR file within a relocatable object \fBpassgroup.o\fR.
127 example% \fBelfwrap -o passgroup.o /etc/passwd /etc/group\fR
128 example% \fBelfdump -s passgroup.o | egrep "passwd|group"\fR
129 [2] 0x00000000 0x00000000 SECT LOCL D 0 .passwd
130 [3] 0x00000000 0x00000000 SECT LOCL D 0 .group
131 [7] 0x00000000 0x000002f0 OBJT GLOB D 0 .passwd passwd_start
132 [8] 0x000002f0 0x00000000 OBJT GLOB D 0 .passwd passwd_end
133 [9] 0x00000000 0x00000121 OBJT GLOB D 0 .group group_start
134 [10] 0x00000121 0x00000000 OBJT GLOB D 0 .group group_end
135 example% \fBstrings -N.passwd passgroup.o | head -1\fR
136 root:x:0:0:Super-User:/:/bin/sh
137 example% \fBstrings -N.group passgroup.o | head -1\fR
145 This relocatable object can be referenced from the following user code.
149 example% \fBcat main.c\fR
152 extern char passwd_start, passwd_end;
156 char *pstart = &passwd_start, *pend = &passwd_end;
159 for (lstr = str = pstart; str < pend; str++) {
160 if ((*str == '\en') && (str != (pend - 1))) {
161 (void) printf("%.*s", (++str - lstr), lstr);
166 example% \fBcc -o main main.c passgroup.o\fR
167 example% \fB\&./main\fR
168 root:x:0:0:Super-User:/:/bin/sh
170 nobody4:x:65534:65534:SunOS 4.x NFS Anonymous Access User:/:
182 The default relocatable object file created.
188 See \fBattributes\fR(5) for descriptions of the following attributes:
196 ATTRIBUTE TYPE ATTRIBUTE VALUE
198 Interface Stability Committed
204 \fBelfdump\fR(1), \fBld\fR(1), \fBstrings\fR(1), \fBelf\fR(3ELF),
205 \fBattributes\fR(5), \fBddi_modopen\fR(9F)
208 \fILinker and Libraries Guide\fR