summaryrefslogtreecommitdiff
path: root/libc/debian/patches/sgs-crle-multiarch.patch
blob: cba5ffa6a4707b4457268551b7d5a6f7a37cbbb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
Description: multiarch support for crle(1)
 For 32-bit runtime linker we need 32-bit clre, same for 64-bit.
 So we cannot use /usr/bin/crle for both. Instead /usr/bin/crle
 a wrapper which execute the right version of crle, e. g.:
 /usr/lib/x86_64-illumos/crle for 64 bits, and
 /usr/lib32/crle for 32 bits on amd64 system.
Index: libc/usr/src/cmd/sgs/crle/common/crle.c
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/common/crle.c	2012-10-19 13:55:51.048787918 +0400
+++ libc/usr/src/cmd/sgs/crle/common/crle.c	2012-10-19 13:57:04.368515632 +0400
@@ -137,6 +137,7 @@
 	crle.c_flags |= CRLE_ADDID;
 	crle.c_strbkts = 503;
 	crle.c_inobkts = 251;
+	crle.c_bits = NULL;
 	c_class = M_CLASS;
 
 	/*
@@ -145,17 +146,16 @@
 	while ((c = getopt(argc, argv, MSG_ORIG(MSG_ARG_OPTIONS))) != -1) {
 		switch (c) {
 
-		case '6':			/* operate on 64-bit objects */
-			if (optarg[0] != '4') {
-				(void) fprintf(stderr,
-				    MSG_INTL(MSG_ARG_ILLEGAL), crle.c_name,
-				    MSG_ORIG(MSG_ARG_6), optarg);
-				error = 1;
-			}
-
-			c_class = ELFCLASS64;
+		/* Options -64 and -32 do nothing here.
+		 * They are only for convenience to execute
+		 * crle from the wrapper.
+		 */
+		case '6':
+			crle.c_bits = "-64";
+			break;
+		case '3':
+			crle.c_bits = "-32";
 			break;
-
 		case 'A':			/* create optional */
 			/* FALLTHROUGH */	/*	alternative */
 		case 'a':			/* create alternative */
@@ -256,6 +256,11 @@
 			crle.c_flags |= CRLE_VERBOSE;
 			break;
 
+        case 'h':
+			(void) printf(MSG_INTL(MSG_ARG_USAGE),
+			    crle.c_name);
+            return (1);
+
 		default:
 			error = 2;
 		}
@@ -321,34 +326,6 @@
 		}
 	}
 
-	/*
-	 * Ensure that the right version (32 or 64-bit) of this program
-	 * is running. The 32 and 64-bit compilers may align fields within
-	 * structures differently. Using the right version of crle for
-	 * the config file ensures that all linker components will see
-	 * the same layout, without the need for special code.
-	 */
-#ifdef _ELF64
-	if (c_class == ELFCLASS32) {
-		(void) fprintf(stderr, MSG_INTL(MSG_ARG_CLASS),
-		    crle.c_name, crle.c_confil);
-		return (1);
-	}
-#else
-	if (c_class == ELFCLASS64) {
-		(void) conv_check_native(argv, envp);
-
-		/*
-		 * conv_check_native() should not return, as we expect
-		 * the 64-bit version to have executed on top of us.
-		 * If it does, it means there is no 64-bit support
-		 * available on this system.
-		 */
-		(void) fprintf(stderr, MSG_INTL(MSG_ISA32_NO64SUP),
-		    crle.c_name);
-		return (1);
-	}
-#endif
 
 	if (crle.c_flags & CRLE_VERBOSE)
 		(void) printf(MSG_INTL(MSG_DIA_CONFILE), crle.c_confil);
@@ -435,7 +412,7 @@
 		 * can access any directories.
 		 */
 		if (crle.c_flags & CRLE_DUMP) {
-			Objdir	*objdir;
+			Objdir	*objdir = NULL;
 			Aliste	idx;
 			int	err = 0;
 
@@ -504,8 +481,9 @@
 
 		switch (c) {
 
-		case '6':
-			break;
+        case '6':
+        case '3':
+            break; /* ignore for convenience */
 
 		case 'A':			/* alternative is optional */
 			flag = RTC_OBJ_OPTINAL;
Index: libc/usr/src/cmd/sgs/crle/common/crle.msg
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/common/crle.msg	2012-10-19 13:55:51.048719984 +0400
+++ libc/usr/src/cmd/sgs/crle/common/crle.msg	2012-10-19 13:57:04.369756046 +0400
@@ -33,11 +33,10 @@
 
 # Argument usage messages.
 
-@ MSG_ARG_USAGE		"usage: %s [-64] [-a name] [-A name] [-c conf] \
-			 [-e env] [-E env] [-f flags] [-g name] [-G name ] \
-			 [-i name] [-I name] [-l dir] [-o dir ] [-s dir] \
-			 [-t ELF|AOUT] [-u] [-v]\n\
-			 \t[-64]\t\tprocess 64-bit objects\n\
+@ MSG_ARG_USAGE		"Usage: %s [options]\n\
+             Options:\n\
+             \t[-64/-32]\tprocess 64-bit or 32-bit objects\n\
+             \t\t\tdefault is native (e. i. 64 on amd64) \n\
 			 \t[-a name]\tdefine an alternative object name\n\
 			 \t[-A name]\tdefine an optional alternative object \
 			  name\n\
@@ -59,20 +58,21 @@
 			 \t[-t ELF|AOUT]\ttoggle object type for -l and -s\n\
 			 \t[-u]\t\tupdate existing configuration file\n\
 			 \t[-v]\t\tprovide verbose processing information\n\
+			 \t[-h]\t\tshow this help message\n\
 			 \n\
-			 \tNote: without the -u option, the information \
+			 Note: without the -u option, the information \
 			  defined by the options\n\
-			 \tto crle() result in the replacement of any existing \
+			 to crle() result in the replacement of any existing \
 			  configuration\n\
-			 \tfile, or default search paths.  With the -u option, \
+			 file, or default search paths.  With the -u option, \
 			  the information\n\
-			 \tdefined by the options to crle() is appended to any \
+			 defined by the options to crle() is appended to any \
 			  existing\n\
-			 \tconfiguration file, or default search paths.\n\
+			 configuration file, or default search paths.\n\
 			 \n\
-			 \tSet the environment variable LD_NOCONFIG=yes to \
+			 Set the environment variable LD_NOCONFIG=yes to \
 			  disable the processing\n\
-			 \tof any configuration file information.  \
+			 of any configuration file information.  \
 			  See ld.so.1(1).\n"
 
 
@@ -141,20 +141,16 @@
 
 @ MSG_DEF_NOCONF	"\nDefault configuration file (%s) not found\n"
 
-@ MSG_DEF_NEWDLP	"  Default Library Path (ELF):\t/lib:/usr/lib  \
-			 (system default)\n"
+@ MSG_DEF_NEWDLP	"  Default Library Path (ELF):\t%s (system default)\n"
 @ MSG_DEF_OLDDLP	"  Default Library Path (ELF):\t/usr/lib  \
 			 (system default)\n"
-@ MSG_DEF_NEWTD		"  Trusted Directories (ELF):\t\
-			 /lib/secure:/usr/lib/secure  (system default)\n"
+@ MSG_DEF_NEWTD		"  Trusted Directories (ELF):\t%s (system default)\n"
 @ MSG_DEF_OLDTD		"  Trusted Directories (ELF):\t/usr/lib/secure  \
 			 (system default)\n"
-@ MSG_DEF_NEWDLP_64	"  Default Library Path (ELF):\t/lib/64:/usr/lib/64  \
-			 (system default)\n"
+@ MSG_DEF_NEWDLP_64	"  Default Library Path (ELF):\t%s (system default)\n"
 @ MSG_DEF_OLDDLP_64	"  Default Library Path (ELF):\t/usr/lib/64  \
 			 (system default)\n"
-@ MSG_DEF_NEWTD_64	"  Trusted Directories (ELF):\t\
-			 /lib/secure/64:/usr/lib/secure/64  (system default)\n"
+@ MSG_DEF_NEWTD_64	"  Trusted Directories (ELF):\t%s (system default)\n"
 @ MSG_DEF_OLDTD_64	"  Trusted Directories (ELF):\t\
 			 /usr/lib/secure/64  (system default)\n"
 
@@ -229,12 +225,10 @@
 # Reference to this strings is via the MSG_ORIG() macro, and thus no message
 # translation is required.
 
-@ MSG_ARG_OPTIONS	"6:a:A:c:e:E:f:G:g:I:i:l:o:s:t:uv"
-@ MSG_ARG_6		"-6"
+@ MSG_ARG_OPTIONS	"3:6:a:A:c:e:E:f:G:g:I:i:l:o:s:t:uvh"
 @ MSG_ARG_C		"-c"
 @ MSG_ARG_F		"-f"
 
-@ MSG_CMD_64		"-64"
 @ MSG_CMD_ALTER		"-a %s"
 @ MSG_CMD_OPTIONAL	"-A %s"
 @ MSG_CMD_CONF		"-c %s"
Index: libc/usr/src/cmd/sgs/crle/Makefile.com
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/Makefile.com	2012-10-19 13:55:51.048845858 +0400
+++ libc/usr/src/cmd/sgs/crle/Makefile.com	2012-10-19 13:57:04.371029829 +0400
@@ -36,13 +36,15 @@
 
 OBJS=		$(BLTOBJ) $(COMOBJ) $(TOOLSOBJ)
 
-MAPFILE=	$(MAPFILE.NGB)
-MAPOPT=		$(MAPFILE:%=-M%)
-
 CPPFLAGS +=	-I$(SRC)/common/sgsrtcid -I$(SRCBASE)/uts/$(ARCH)/sys \
 		-D__EXTENSIONS__
-LLDFLAGS =	'-R$$ORIGIN/../lib'
-LLDFLAGS64 =	'-R$$ORIGIN/../../lib/$(MACH64)'
+CPPFLAGS += \
+	-DDEB_HOST_ARCH_BITS=$(DEB_HOST_ARCH_BITS) \
+	-DDEB_LIBDIR_32=\"$(DEB_LIBDIR_32)\" \
+	-DDEB_USRLIBDIR_32=\"$(DEB_USRLIBDIR_32)\" \
+	-DDEB_LIBDIR_64=\"$(DEB_LIBDIR_64)\" \
+	-DDEB_USRLIBDIR_64=\"$(DEB_USRLIBDIR_64)\" \
+
 LDFLAGS +=	$(VERSREF) $(CC_USE_PROTO) $(MAPOPT) \
 			$(LLDFLAGS) $(ZNOLAZYLOAD)
 LDLIBS +=	-lelf $(CONVLIBDIR) $(CONV_LIB) $(DLLIB)
Index: libc/usr/src/cmd/sgs/crle/Makefile.targ
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/Makefile.targ	2012-10-19 13:55:51.048904330 +0400
+++ libc/usr/src/cmd/sgs/crle/Makefile.targ	2012-10-19 13:57:04.372060701 +0400
@@ -29,8 +29,14 @@
 		$(COMPILE.c) $<
 		$(POST_PROCESS_O)
 
+# Allow override for 64-bit version:
+_CRLE_LIBDIR ?= $(DEB_USRLIBDIR_32)
+
 install \
-package:	all $(ROOTPROG)
+package:	all $(ROOT)/$(_CRLE_LIBDIR)/$(PROG)
+
+$(ROOT)/$(_CRLE_LIBDIR)/$(PROG): $(PROG)
+	$(INS.file)
 
 all:		$(PROG)
 
Index: libc/usr/src/cmd/sgs/crle/amd64/Makefile
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/amd64/Makefile	2012-10-19 13:55:51.048874361 +0400
+++ libc/usr/src/cmd/sgs/crle/amd64/Makefile	2012-10-19 13:57:04.373193326 +0400
@@ -38,6 +38,7 @@
 LINTFLAGS64 +=	$(VAR_LINTFLAGS64)
 
 ROOTPROG =	$(ROOTPROG64)
+_CRLE_LIBDIR = $(DEB_USRLIBDIR_64)
 
 lint:		$(LINTOUT64)
 
Index: libc/usr/src/cmd/sgs/crle/common/_crle.h
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/common/_crle.h	2012-10-19 13:55:51.048758407 +0400
+++ libc/usr/src/cmd/sgs/crle/common/_crle.h	2012-10-19 13:57:04.374128803 +0400
@@ -154,6 +154,7 @@
 	APlist		*c_flt;		/* filter/filtee associations */
 	uint_t		c_fltrnum;	/*	and associated filter number */
 	uint_t		c_fltenum;	/*	and associated filtee number */
+    const char  *c_bits;    /* if called with -64/-32, will print: crle [{-64|-32}] ... */
 } Crle_desc;
 
 #define	CRLE_CREAT	0x0001		/* config file creation required */
Index: libc/usr/src/cmd/sgs/crle/common/print.c
===================================================================
--- libc.orig/usr/src/cmd/sgs/crle/common/print.c	2012-10-19 13:55:51.048816786 +0400
+++ libc/usr/src/cmd/sgs/crle/common/print.c	2012-10-19 14:00:17.230111553 +0400
@@ -38,6 +38,19 @@
 #include	"_crle.h"
 #include	"msg.h"
 
+#if M_CLASS == ELFCLASS64 && DEB_HOST_ARCH_BITS == 64
+#  define _USR_LIB ":/usr/lib"
+#elif M_CLASS == ELFCLASS32 && DEB_HOST_ARCH_BITS == 32
+#  define _USR_LIB ":/usr/lib"
+#else
+#  define _USR_LIB ""
+#endif
+
+#if M_CLASS == ELFCLASS64
+#  define DEB_LIB_PATH DEB_LIBDIR_64 ":" DEB_USRLIBDIR_64 _USR_LIB
+#else
+#  define DEB_LIB_PATH DEB_LIBDIR_32 ":" DEB_USRLIBDIR_32 _USR_LIB
+#endif
 
 /*
  * Display the command line required to regenerate the configuration file.
@@ -137,36 +150,12 @@
 
 	switch (flag) {
 	case CRLE_EDLIB:
-#if M_CLASS == ELFCLASS64
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-		path = MSG_ORIG(MSG_PTH_NEWDLP_64);
-#else
-		path = MSG_ORIG(MSG_PTH_OLDDLP_64);
-#endif
-#else
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-		path = MSG_ORIG(MSG_PTH_NEWDLP);
-#else
-		path = MSG_ORIG(MSG_PTH_OLDDLP);
-#endif
-#endif
+		path = DEB_LIB_PATH;
 		list = &crle->c_edlibpath;
 		break;
 
 	case CRLE_ESLIB:
-#if M_CLASS == ELFCLASS64
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-		path = MSG_ORIG(MSG_PTH_NEWTD_64);
-#else
-		path = MSG_ORIG(MSG_PTH_OLDTD_64);
-#endif
-#else
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-		path = MSG_ORIG(MSG_PTH_NEWTD);
-#else
-		path = MSG_ORIG(MSG_PTH_OLDTD);
-#endif
-#endif
+		path = DEB_LIB_PATH;
 		list = &crle->c_eslibpath;
 		break;
 
@@ -340,11 +329,11 @@
 	}
 
 
-	if (!(crle->c_flags & CRLE_UPDATE) && (head->ch_cnflags & RTC_HDR_64)) {
+	if (!(crle->c_flags & CRLE_UPDATE) && (crle->c_bits != NULL)) {
 		/*
 		 * Construct the original command line argument.
 		 */
-		cmd = strdupa(MSG_ORIG(MSG_CMD_64));
+		cmd = strdupa(crle->c_bits);
 		if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL)
 			return (INSCFG_RET_FAIL);
 	}
@@ -507,19 +496,7 @@
 			/*
 			 * Indicate any system default.
 			 */
-#if M_CLASS == ELFCLASS64
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-			(void) printf(MSG_INTL(MSG_DEF_NEWDLP_64));
-#else
-			(void) printf(MSG_INTL(MSG_DEF_OLDDLP_64));
-#endif
-#else
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-			(void) printf(MSG_INTL(MSG_DEF_NEWDLP));
-#else
-			(void) printf(MSG_INTL(MSG_DEF_OLDDLP));
-#endif
-#endif
+			(void) printf(MSG_INTL(MSG_DEF_NEWDLP), DEB_LIB_PATH);
 		}
 	}
 
@@ -574,19 +551,7 @@
 			/*
 			 * Indicate any system default.
 			 */
-#if M_CLASS == ELFCLASS64
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-			(void) printf(MSG_INTL(MSG_DEF_NEWTD_64));
-#else
-			(void) printf(MSG_INTL(MSG_DEF_OLDTD_64));
-#endif
-#else
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-			(void) printf(MSG_INTL(MSG_DEF_NEWTD));
-#else
-			(void) printf(MSG_INTL(MSG_DEF_OLDTD));
-#endif
-#endif
+			(void) printf(MSG_INTL(MSG_DEF_NEWTD), DEB_LIB_PATH);
 		}
 	}
 
@@ -1076,27 +1041,12 @@
 #else
 					fmt2 = MSG_INTL(MSG_DEF_AOUTOLDTD);
 #endif
+					(void) printf(fmt1);
+					(void) printf(fmt2);
 				} else {
-#if M_CLASS == ELFCLASS64
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-					fmt1 = MSG_INTL(MSG_DEF_NEWDLP_64);
-					fmt2 = MSG_INTL(MSG_DEF_NEWTD_64);
-#else
-					fmt1 = MSG_INTL(MSG_DEF_OLDDLP_64);
-					fmt2 = MSG_INTL(MSG_DEF_OLDTD_64);
-#endif
-#else
-#ifndef	SGS_PRE_UNIFIED_PROCESS
-					fmt1 = MSG_INTL(MSG_DEF_NEWDLP);
-					fmt2 = MSG_INTL(MSG_DEF_NEWTD);
-#else
-					fmt1 = MSG_INTL(MSG_DEF_OLDDLP);
-					fmt2 = MSG_INTL(MSG_DEF_OLDTD);
-#endif
-#endif
+					(void) printf(MSG_INTL(MSG_DEF_NEWDLP), DEB_LIB_PATH);
+					(void) printf(MSG_INTL(MSG_DEF_NEWTD), DEB_LIB_PATH);
 				}
-				(void) printf(fmt1);
-				(void) printf(fmt2);
 
 				return (INSCFG_RET_OK);
 			}
Index: libc/usr/src/man/man1/crle.1
===================================================================
--- libc.orig/usr/src/man/man1/crle.1	2012-10-19 13:55:51.048661253 +0400
+++ libc/usr/src/man/man1/crle.1	2012-10-19 13:57:04.377756089 +0400
@@ -9,9 +9,9 @@
 .SH SYNOPSIS
 .LP
 .nf
-\fBcrle\fR [\fB-64\fR] [\fB-a\fR \fIname\fR] [\fB-A\fR \fIname\fR] [\fB-c\fR \fIconf\fR] [\fB-e\fR \fIenv\fR] [\fB-E\fR \fIenv\fR]
+\fBcrle\fR [{\fB-64|-32\fR}] [\fB-a\fR \fIname\fR] [\fB-A\fR \fIname\fR] [\fB-c\fR \fIconf\fR] [\fB-e\fR \fIenv\fR] [\fB-E\fR \fIenv\fR]
      [\fB-f\fR \fIflags\fR] [\fB-i\fR \fIname\fR] [\fB-I\fR \fIname\fR] [\fB-g\fR \fIname\fR] [\fB-G\fR \fIname\fR]
-     [\fB-l\fR \fIdir\fR] [\fB-o\fR \fIdir\fR] [\fB-s\fR \fIdir\fR] [\fB-t\fR [ ELF | AOUT]] [\fB-u\fR] [\fB-v\fR]
+     [\fB-l\fR \fIdir\fR] [\fB-o\fR \fIdir\fR] [\fB-s\fR \fIdir\fR] [\fB-t\fR [ ELF | AOUT]] [\fB-u\fR] [\fB-v\fR] [\fB-h\fR]
 .fi
 
 .SH DESCRIPTION
@@ -189,12 +189,12 @@
 .sp
 .ne 2
 .na
-\fB\fB-64\fR\fR
+\fB\fB-64/-32\fR\fR
 .ad
 .sp .6
 .RS 4n
-Specify to process 64-bit objects, the default is 32-bit. Use \fB-64\fR to
-create a 64-bit specific configuration file.
+Explicitly specify to process 64-bit or 32-bit objects. The default is native, e. i.
+-64 on 64-bit system (like amd64) and -32 on 32-bit system (like i386).
 .RE
 
 .sp
@@ -493,6 +493,16 @@
 .RE
 
 .sp
+.ne 2
+.na
+\fB\fB-h\fR\fR
+.ad
+.sp .6
+.RS 4n
+Display help and exit.
+.RE
+
+.sp
 .LP
 By default, the runtime linker attempts to read the configuration file
 \fB/var/ld/ld.config\fR for each 32-bit application processed.