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: b/usr/src/cmd/sgs/crle/common/crle.c =================================================================== --- a/usr/src/cmd/sgs/crle/common/crle.c +++ b/usr/src/cmd/sgs/crle/common/crle.c @@ -137,6 +137,7 @@ main(int argc, char **argv, char **envp) 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 @@ main(int argc, char **argv, char **envp) 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 @@ main(int argc, char **argv, char **envp) 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 @@ main(int argc, char **argv, char **envp) } } - /* - * 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 @@ main(int argc, char **argv, char **envp) * can access any directories. */ if (crle.c_flags & CRLE_DUMP) { - Objdir *objdir; + Objdir *objdir = NULL; Aliste idx; int err = 0; @@ -504,8 +481,9 @@ main(int argc, char **argv, char **envp) switch (c) { - case '6': - break; + case '6': + case '3': + break; /* ignore for convenience */ case 'A': /* alternative is optional */ flag = RTC_OBJ_OPTINAL; Index: b/usr/src/cmd/sgs/crle/common/crle.msg =================================================================== --- a/usr/src/cmd/sgs/crle/common/crle.msg +++ b/usr/src/cmd/sgs/crle/common/crle.msg @@ -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: b/usr/src/cmd/sgs/crle/Makefile.com =================================================================== --- a/usr/src/cmd/sgs/crle/Makefile.com +++ b/usr/src/cmd/sgs/crle/Makefile.com @@ -36,13 +36,15 @@ TOOLSOBJ= alist.o 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: b/usr/src/cmd/sgs/crle/Makefile.targ =================================================================== --- a/usr/src/cmd/sgs/crle/Makefile.targ +++ b/usr/src/cmd/sgs/crle/Makefile.targ @@ -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: b/usr/src/cmd/sgs/crle/amd64/Makefile =================================================================== --- a/usr/src/cmd/sgs/crle/amd64/Makefile +++ b/usr/src/cmd/sgs/crle/amd64/Makefile @@ -38,6 +38,7 @@ LDDBGLIBDIR = $(LDDBGLIBDIR64) LINTFLAGS64 += $(VAR_LINTFLAGS64) ROOTPROG = $(ROOTPROG64) +_CRLE_LIBDIR = $(DEB_USRLIBDIR_64) lint: $(LINTOUT64) Index: b/usr/src/cmd/sgs/crle/common/_crle.h =================================================================== --- a/usr/src/cmd/sgs/crle/common/_crle.h +++ b/usr/src/cmd/sgs/crle/common/_crle.h @@ -154,6 +154,7 @@ typedef struct crle_desc { 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: b/usr/src/cmd/sgs/crle/common/print.c =================================================================== --- a/usr/src/cmd/sgs/crle/common/print.c +++ b/usr/src/cmd/sgs/crle/common/print.c @@ -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 @@ fablib(Crle_desc * crle, int flag) 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 @@ scanconfig(Crle_desc * crle, Addr addr, } - 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 @@ scanconfig(Crle_desc * crle, Addr addr, /* * 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 @@ scanconfig(Crle_desc * crle, Addr addr, /* * 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 @@ inspectconfig(Crle_desc * crle, int c_cl #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: b/usr/src/man/man1/crle.1 =================================================================== --- a/usr/src/man/man1/crle.1 +++ b/usr/src/man/man1/crle.1 @@ -9,9 +9,9 @@ crle \- configure runtime linking enviro .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 @@ The following options are supported. .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 @@ is provided. .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.