1 '\" te 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" 7 .SH NAME 8 elfwrap \- wrap data in an \fBELF\fR file 9 .SH SYNOPSIS 10 .LP 11 .nf 12 \fBelfwrap\fR [\fB-64\fR] [\fB-o\fR \fIrelobj-file\fR] [\fB-z\fR target=\fBsparc\fR | \fBx86\fR] 13 \fIdata-file\fR... 14 .fi 15 16 .SH DESCRIPTION 17 .sp 18 .LP 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 24 symbols. 25 .sp 26 .LP 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 31 machine type. 32 .LP 33 Note - 34 .sp 35 .RS 2 36 Any data encapsulated with \fBelfwrap\fR must be in a format appropriate for 37 the destination target. 38 .RE 39 .sp 40 .LP 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. 43 .sp 44 .LP 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 48 relocatable object. 49 .sp 50 .ne 2 51 .na 52 \fBAn \fBELF\fR section named \fB\&.isv-data\fR\fR 53 .ad 54 .sp .6 55 .RS 4n 56 This section contains the entire contents of the input data file. 57 .RE 58 59 .sp 60 .ne 2 61 .na 62 \fBAn \fBELF\fR symbol named \fBisv-data_start\fR\fR 63 .ad 64 .sp .6 65 .RS 4n 66 This symbol reflects the starting address of the \fB\&.isv-data\fR section. 67 .RE 68 69 .sp 70 .ne 2 71 .na 72 \fBAn \fBELF\fR symbol named \fBisv-data_end\fR\fR 73 .ad 74 .sp .6 75 .RS 4n 76 This symbol reflects the address of the first location after the 77 \fB\&.isv-data\fR section. 78 .RE 79 80 .SH OPTIONS 81 .sp 82 .LP 83 The following options are supported: 84 .sp 85 .ne 2 86 .na 87 \fB\fB-64\fR\fR 88 .ad 89 .sp .6 90 .RS 4n 91 Create a 64-bit \fBELF\fR relocatable object. 92 .RE 93 94 .sp 95 .ne 2 96 .na 97 \fB\fB-o\fR \fIrelobj-file\fR\fR 98 .ad 99 .sp .6 100 .RS 4n 101 Produce a relocatable object that is named \fIrelobj-file\fR. 102 .RE 103 104 .sp 105 .ne 2 106 .na 107 \fB\fB-z\fR target=\fBsparc\fR | \fBx86\fR\fR 108 .ad 109 .sp .6 110 .RS 4n 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 116 executed. 117 .RE 118 119 .SH EXAMPLES 120 .sp 121 .LP 122 The following example encapsulates the system \fBpasswd\fR file and the system 123 \fBgroup\fR file within a relocatable object \fBpassgroup.o\fR. 124 .sp 125 .in +2 126 .nf 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:/:/sbin/sh 137 example% \fBstrings -N.group passgroup.o | head -1\fR 138 root::0: 139 .fi 140 .in -2 141 .sp 142 143 .sp 144 .LP 145 This relocatable object can be referenced from the following user code. 146 .sp 147 .in +2 148 .nf 149 example% \fBcat main.c\fR 150 #include <stdio.h> 151 152 extern char passwd_start, passwd_end; 153 154 void main() 155 { 156 char *pstart = &passwd_start, *pend = &passwd_end; 157 char *str, *lstr; 158 159 for (lstr = str = pstart; str < pend; str++) { 160 if ((*str == '\en') && (str != (pend - 1))) { 161 (void) printf("%.*s", (++str - lstr), lstr); 162 lstr = str; 163 } 164 } 165 } 166 example% \fBcc -o main main.c passgroup.o\fR 167 example% \fB\&./main\fR 168 root:x:0:0:Super-User:/:/sbin/sh 169 \&.... 170 nobody4:x:65534:65534:SunOS 4.x NFS Anonymous Access User:/: 171 .fi 172 .in -2 173 .sp 174 175 .SH FILES 176 .sp 177 .ne 2 178 .na 179 \fB\fBa.wrap.o\fR\fR 180 .ad 181 .RS 12n 182 The default relocatable object file created. 183 .RE 184 185 .SH ATTRIBUTES 186 .sp 187 .LP 188 See \fBattributes\fR(5) for descriptions of the following attributes: 189 .sp 190 191 .sp 192 .TS 193 box; 194 c | c 195 l | l . 196 ATTRIBUTE TYPE ATTRIBUTE VALUE 197 _ 198 Interface Stability Committed 199 .TE 200 201 .SH SEE ALSO 202 .sp 203 .LP 204 \fBelfdump\fR(1), \fBld\fR(1), \fBstrings\fR(1), \fBelf\fR(3ELF), 205 \fBattributes\fR(5), \fBddi_modopen\fR(9F) 206 .sp 207 .LP 208 \fILinker and Libraries Guide\fR