diff options
-rw-r--r-- | libc/debian/crle.c | 94 | ||||
-rw-r--r-- | libc/debian/libc-bin.install | 1 | ||||
-rw-r--r-- | libc/debian/libc-bin.manpages | 1 | ||||
-rw-r--r-- | libc/debian/libc1-illumos-i386.install | 1 | ||||
-rw-r--r-- | libc/debian/libc1.install | 1 | ||||
-rw-r--r-- | libc/debian/patches/series | 1 | ||||
-rw-r--r-- | libc/debian/patches/sgs-crle-multiarch.patch | 307 | ||||
-rwxr-xr-x | libc/debian/rules | 16 |
8 files changed, 421 insertions, 1 deletions
diff --git a/libc/debian/crle.c b/libc/debian/crle.c new file mode 100644 index 0000000..fc71466 --- /dev/null +++ b/libc/debian/crle.c @@ -0,0 +1,94 @@ +/* +Copyright: 2012, Igor Pashev <pashev.igor@gmail.com> + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. +*/ + +/* + * Wrapper for real crle(1). + * + * Runtime linker uses binary config file, and + * 32- and 64-bit versions of the linker use different + * config files. To make changes to those files one must use + * crle(1) of corresponding bitness. + * + * Since we cannot have two or more files named '/usr/bin/crle', + * we create this wrapper, which will dispatch to corresponding + * real program residing under /usr/lib/<multiarch>/ and under + * /usr/lib32 (on 64-bit systems). + * + * For example, let's assume we are on amd64 system: + * /usr/bin/crle without -64 or -32 options will execute "native" crle + * (/usr/lib/x86_64-illumos/crle); with -32 option - /usr/lib32/crle; + * option -64 is noop. + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> + + +const char crle64 [] = DEB_USRLIBDIR_64 "/crle"; +const char crle32 [] = DEB_USRLIBDIR_32 "/crle"; +char* help [] = {"crle", "-h"}; + +#if DEB_HOST_ARCH_BITS == 64 +# define crle crle64 +#elif DEB_HOST_ARCH_BITS == 32 +# define crle crle32 +#else +# error DEB_HOST_ARCH_BITS is not set or has a wrong value +#endif + +static void +myexec(const char *path, char **argv) +{ + int rc; + rc = execv(path, argv); + perror(path); + exit(rc); +} + +int main(int argc, char **argv) +{ + int i; + int use_help = 0; + int use_64 = 0; + int use_32 = 0; + + for (i = 1; i < argc; i++) { + if (argv[i][0] == '-' && argv[i][1] == 'h') + use_help++; + else if (strcmp("-64", argv[i]) == 0) + use_64++; + else if (strcmp("-32", argv[i]) == 0) + use_32++; + } + + if (use_help) + myexec(crle, help); + + if (!use_64 && !use_32) + myexec(crle, argv); + + if (use_64 && !use_32) + myexec(crle64, argv); + + if (use_32 && !use_64) + myexec(crle32, argv); + + fprintf(stderr, "Options -32 and -64 cannot be used together\n"); + return EXIT_FAILURE; +} diff --git a/libc/debian/libc-bin.install b/libc/debian/libc-bin.install index bf4e0fc..e84f36b 100644 --- a/libc/debian/libc-bin.install +++ b/libc/debian/libc-bin.install @@ -1,3 +1,4 @@ +crle usr/bin/ usr/bin/getconf usr/bin/getent usr/bin/ldd diff --git a/libc/debian/libc-bin.manpages b/libc/debian/libc-bin.manpages index 6a988e5..0831405 100644 --- a/libc/debian/libc-bin.manpages +++ b/libc/debian/libc-bin.manpages @@ -1,3 +1,4 @@ +illumos-gate/usr/src/man/man1/crle.1 illumos-gate/usr/src/man/man1/getconf.1 illumos-gate/usr/src/man/man1/ld.so.1.1 illumos-gate/usr/src/man/man1/ldd.1 diff --git a/libc/debian/libc1-illumos-i386.install b/libc/debian/libc1-illumos-i386.install index 5369f36..7b13323 100644 --- a/libc/debian/libc1-illumos-i386.install +++ b/libc/debian/libc1-illumos-i386.install @@ -24,5 +24,6 @@ lib32/security/crypt_bsdmd5.so.1 lib32/security/crypt_sha256.so.1 lib32/security/crypt_sha512.so.1 lib32/security/crypt_sunmd5.so.1 +usr/lib32/crle usr/lib32/lddstub usr/lib32/libcrypt.so.1 diff --git a/libc/debian/libc1.install b/libc/debian/libc1.install index d34501f..189399e 100644 --- a/libc/debian/libc1.install +++ b/libc/debian/libc1.install @@ -24,5 +24,6 @@ lib/*/security/crypt_bsdmd5.so.1 lib/*/security/crypt_sha256.so.1 lib/*/security/crypt_sha512.so.1 lib/*/security/crypt_sunmd5.so.1 +usr/lib/*/crle usr/lib/*/lddstub usr/lib/*/libcrypt.so.1 diff --git a/libc/debian/patches/series b/libc/debian/patches/series index 01c4ff9..54c33b0 100644 --- a/libc/debian/patches/series +++ b/libc/debian/patches/series @@ -45,3 +45,4 @@ sgs-lddstub.patch objects-path.patch headers-limits.h-name-max.patch libnsl-gnu-make.patch +sgs-crle-multiarch.patch diff --git a/libc/debian/patches/sgs-crle-multiarch.patch b/libc/debian/patches/sgs-crle-multiarch.patch new file mode 100644 index 0000000..6dd5b54 --- /dev/null +++ b/libc/debian/patches/sgs-crle-multiarch.patch @@ -0,0 +1,307 @@ +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/illumos-gate/usr/src/cmd/sgs/crle/common/crle.c +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/common/crle.c 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/common/crle.c 2012-10-17 18:08:30.500958577 +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/illumos-gate/usr/src/cmd/sgs/crle/common/crle.msg +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/common/crle.msg 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/common/crle.msg 2012-10-17 14:17:37.476436461 +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" + + +@@ -229,12 +229,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/illumos-gate/usr/src/cmd/sgs/crle/Makefile.com +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/Makefile.com 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/Makefile.com 2012-10-16 03:10:50.991241260 +0400 +@@ -36,13 +36,10 @@ + + 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) ++ + LDFLAGS += $(VERSREF) $(CC_USE_PROTO) $(MAPOPT) \ + $(LLDFLAGS) $(ZNOLAZYLOAD) + LDLIBS += -lelf $(CONVLIBDIR) $(CONV_LIB) $(DLLIB) +Index: libc/illumos-gate/usr/src/cmd/sgs/crle/Makefile.targ +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/Makefile.targ 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/Makefile.targ 2012-10-16 21:18:37.076374460 +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/illumos-gate/usr/src/cmd/sgs/crle/amd64/Makefile +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/amd64/Makefile 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/amd64/Makefile 2012-10-16 21:19:08.127027881 +0400 +@@ -38,6 +38,7 @@ + LINTFLAGS64 += $(VAR_LINTFLAGS64) + + ROOTPROG = $(ROOTPROG64) ++_CRLE_LIBDIR = $(DEB_USRLIBDIR_64) + + lint: $(LINTOUT64) + +Index: libc/illumos-gate/usr/src/cmd/sgs/crle/common/_crle.h +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/common/_crle.h 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/common/_crle.h 2012-10-17 12:03:03.302810824 +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/illumos-gate/usr/src/cmd/sgs/crle/common/print.c +=================================================================== +--- libc.orig/illumos-gate/usr/src/cmd/sgs/crle/common/print.c 2012-10-08 04:25:33.000000000 +0400 ++++ libc/illumos-gate/usr/src/cmd/sgs/crle/common/print.c 2012-10-17 12:56:14.242549131 +0400 +@@ -340,11 +340,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); + } +Index: libc/illumos-gate/usr/src/man/man1/crle.1 +=================================================================== +--- libc.orig/illumos-gate/usr/src/man/man1/crle.1 2012-10-08 04:25:44.000000000 +0400 ++++ libc/illumos-gate/usr/src/man/man1/crle.1 2012-10-17 18:12:29.210327179 +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. diff --git a/libc/debian/rules b/libc/debian/rules index 1db69ab..a8eceb4 100755 --- a/libc/debian/rules +++ b/libc/debian/rules @@ -1,6 +1,8 @@ #!/usr/bin/make -f include /usr/share/dpkg/architecture.mk +include /usr/share/dpkg/buildflags.mk +CC = gcc # only for testing: #make = -m '/home/sunmake/make -j2 --sun' @@ -52,6 +54,7 @@ libld \ librtld \ rtld \ lddstub \ +crle \ # usr/src/cmd/* for libc functionality: # @@ -156,7 +159,7 @@ cmd-stamp: lib-stamp sgs-stamp dh_illumos_make --native $(make) $(cmd:%=usr/src/cmd/%) touch $@ -build-stamp: lib-stamp sgs-stamp nsswitch-stamp headers-stamp cmd-stamp debian/LC_DATA.gz debian/locales.config +build-stamp: lib-stamp sgs-stamp nsswitch-stamp headers-stamp cmd-stamp debian/LC_DATA.gz debian/locales.config crle for l in `find debian/tmp/lib32 -maxdepth 1 -type l -name \*.so`; do \ ln -sf `readlink -f $$l` debian/tmp/usr/lib32/`basename $$l`; \ done @@ -191,6 +194,8 @@ binary-stamp: build-stamp chmod 0755 \ debian/*/usr/lib/*/lddstub \ debian/*/usr/lib?*/lddstub \ + debian/*/usr/lib/*/crle \ + debian/*/usr/lib?*/crle \ debian/*/lib/*/ld.so.* \ debian/*/lib?*/ld.so.* \ @@ -215,6 +220,14 @@ debian/locales.config: debian/locales.config.in perl -pe 'BEGIN {undef $$/; open(IN, "debian/SUPPORTED"); $$j=<IN>;} s/__PROVIDED_LOCALES__/$$j/g;' \ $< > $@ +crle: debian/crle.c + . illumos-gate/env.sh; unset LD_ALTEXEC; \ + $(CC) $(CFLAGS) -o $@ \ + -DDEB_USRLIBDIR_32=\"$$DEB_USRLIBDIR_32\" \ + -DDEB_USRLIBDIR_64=\"$$DEB_USRLIBDIR_64\" \ + -DDEB_HOST_ARCH_BITS=$$DEB_HOST_ARCH_BITS \ + $< + clean: unpatch dh_testdir dh_testroot @@ -222,4 +235,5 @@ clean: unpatch rm -f debian/LC_DATA.* rm -f debian/locales.config rm -rf illumos-gate + rm -f crle |