summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorab196087 <none@none>2008-03-19 09:39:36 -0700
committerab196087 <none@none>2008-03-19 09:39:36 -0700
commitdf14233e629298598736976c5bfcf4a31873745f (patch)
tree4279277a84b3a0e2391e188e22d3899b7cfbc7b1
parentb0e063115d0b1a4c7975d20f1c3c2792fe47bda8 (diff)
downloadillumos-joyent-df14233e629298598736976c5bfcf4a31873745f.tar.gz
6606203 link editor ought to allow creation of >2gb sized objects
-rw-r--r--usr/src/cmd/sgs/include/a.out.h33
-rw-r--r--usr/src/cmd/sgs/ldd/Makefile.com3
-rw-r--r--usr/src/cmd/sgs/ldd/Makefile.targ13
-rw-r--r--usr/src/cmd/sgs/ldd/amd64/Makefile40
-rw-r--r--usr/src/cmd/sgs/ldd/common/ldd.c22
-rw-r--r--usr/src/cmd/sgs/ldd/i386/Makefile10
-rw-r--r--usr/src/cmd/sgs/ldd/sparc/Makefile10
-rw-r--r--usr/src/cmd/sgs/ldd/sparcv9/Makefile40
-rw-r--r--usr/src/cmd/sgs/libelf/common/README.LFS159
-rw-r--r--usr/src/cmd/sgs/libelf/common/libelf.msg11
-rw-r--r--usr/src/cmd/sgs/libelf/common/update.c90
-rw-r--r--usr/src/cmd/sgs/packages/common/SUNWonld-README1
-rw-r--r--usr/src/cmd/sgs/packages/common/prototype_i3863
-rw-r--r--usr/src/cmd/sgs/packages/common/prototype_sparc3
-rw-r--r--usr/src/cmd/strings/Makefile28
-rw-r--r--usr/src/cmd/strings/Makefile.com50
-rw-r--r--usr/src/cmd/strings/amd64/Makefile31
-rw-r--r--usr/src/cmd/strings/i386/Makefile30
-rw-r--r--usr/src/cmd/strings/sparc/Makefile30
-rw-r--r--usr/src/cmd/strings/sparcv9/Makefile31
-rw-r--r--usr/src/pkgdefs/SUNWtoo/prototype_com4
-rw-r--r--usr/src/pkgdefs/SUNWtoo/prototype_i3865
-rw-r--r--usr/src/pkgdefs/SUNWtoo/prototype_sparc5
23 files changed, 583 insertions, 69 deletions
diff --git a/usr/src/cmd/sgs/include/a.out.h b/usr/src/cmd/sgs/include/a.out.h
index 858395a50b..706e1bf4e6 100644
--- a/usr/src/cmd/sgs/include/a.out.h
+++ b/usr/src/cmd/sgs/include/a.out.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,8 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1991 by Sun Microsystems, Inc.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -48,6 +48,29 @@ struct exec {
};
/*
+ * Version of struct exec intended to allow LP64 code to
+ * examine a 32-bit definition.
+ */
+struct exec32 {
+#ifdef sun
+ unsigned char a_dynamic:1; /* has a __DYNAMIC */
+ unsigned char a_toolversion:7; /* version of toolset used to create */
+ /* this file */
+ unsigned char a_machtype; /* machine type */
+ unsigned short a_magic; /* magic number */
+#else
+ unsigned int a_magic; /* magic number */
+#endif
+ unsigned int a_text; /* size of text segment */
+ unsigned int a_data; /* size of initialized data */
+ unsigned int a_bss; /* size of uninitialized data */
+ unsigned int a_syms; /* size of symbol table */
+ unsigned int a_entry; /* entry point */
+ unsigned int a_trsize; /* size of text relocation */
+ unsigned int a_drsize; /* size of data relocation */
+};
+
+/*
* Macros for identifying an a.out format file.
*/
#define M_SPARC 3 /* runs only on SPARC */
@@ -66,4 +89,4 @@ struct exec {
#define M_SEGSIZE 0x2000 /* 8k */
#endif
-#endif
+#endif /* A_DOT_OUT_DOT_H */
diff --git a/usr/src/cmd/sgs/ldd/Makefile.com b/usr/src/cmd/sgs/ldd/Makefile.com
index 314a06299b..4d54361420 100644
--- a/usr/src/cmd/sgs/ldd/Makefile.com
+++ b/usr/src/cmd/sgs/ldd/Makefile.com
@@ -20,7 +20,7 @@
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -53,6 +53,7 @@ LDFLAGS += $(VERSREF) $(USE_PROTO) $(MAPOPTS) \
'-R$$ORIGIN/../lib'
LDLIBS += $(CONVLIBDIR) $(CONV_LIB) -lelf $(DLLIB)
LINTFLAGS += -x
+LINTFLAGS64 += -x
BLTDEFS= msg.h
BLTDATA= msg.c
diff --git a/usr/src/cmd/sgs/ldd/Makefile.targ b/usr/src/cmd/sgs/ldd/Makefile.targ
index 6923989a05..c0c881ebd8 100644
--- a/usr/src/cmd/sgs/ldd/Makefile.targ
+++ b/usr/src/cmd/sgs/ldd/Makefile.targ
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -22,8 +21,8 @@
#
#ident "%Z%%M% %I% %E% SMI"
#
-# Copyright (c) 2001 by Sun Microsystems, Inc.
-# All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
%.o: ../common/%.c
$(COMPILE.c) $<
@@ -38,9 +37,7 @@ delete:
$(RM) $(PROG)
install \
-package: all
-
-lint: $(LINTOUT32) $(SGSLINTOUT)
+package: all $(ROOTPROG)
$(PROG): $(OBJS) $(MAPFILE)
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
diff --git a/usr/src/cmd/sgs/ldd/amd64/Makefile b/usr/src/cmd/sgs/ldd/amd64/Makefile
new file mode 100644
index 0000000000..fc1e7bd87c
--- /dev/null
+++ b/usr/src/cmd/sgs/ldd/amd64/Makefile
@@ -0,0 +1,40 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+#ident "%Z%%M% %I% %E% SMI"
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+
+.KEEP_STATE:
+
+CONVLIBDIR = $(CONVLIBDIR64)
+LINTFLAGS64 += $(VAR_LINTFLAGS64)
+
+ROOTPROG = $(ROOTPROG64)
+
+lint: $(LINTOUT64) $(SGSLINTOUT)
+
+include ../Makefile.targ
+include ../../Makefile.sub.64
diff --git a/usr/src/cmd/sgs/ldd/common/ldd.c b/usr/src/cmd/sgs/ldd/common/ldd.c
index bc4f225407..b876300b4a 100644
--- a/usr/src/cmd/sgs/ldd/common/ldd.c
+++ b/usr/src/cmd/sgs/ldd/common/ldd.c
@@ -174,7 +174,7 @@ list_append(List *lst, const void *item)
}
int
-main(int argc, char **argv)
+main(int argc, char **argv, char **envp)
{
char *str, *cname = argv[0];
@@ -186,6 +186,16 @@ main(int argc, char **argv)
Listnode *lnp;
/*
+ * If we're on a 64-bit kernel, try to exec a full 64-bit version of
+ * the binary. If successful, conv_check_native() won't return.
+ *
+ * This is done to ensure that ldd can handle objects >2GB.
+ * ldd uses libelf, which is not large file capable. The
+ * 64-bit ldd can handle any sized object.
+ */
+ (void) conv_check_native(argv, envp);
+
+ /*
* Establish locale.
*/
(void) setlocale(LC_MESSAGES, MSG_ORIG(MSG_STR_EMPTY));
@@ -399,7 +409,7 @@ main(int argc, char **argv)
static int
is_runnable(GElf_Ehdr *ehdr)
{
- if ((ehdr->e_ident[EI_CLASS] == M_CLASS) &&
+ if ((ehdr->e_ident[EI_CLASS] == ELFCLASS32) &&
(ehdr->e_ident[EI_DATA] == M_DATA))
return (ELFCLASS32);
@@ -576,7 +586,7 @@ elf_check(int nfile, char *fname, char *cname, Elf *elf, int fflag)
static int
aout_check(int nfile, char *fname, char *cname, int fd, int fflag)
{
- struct exec aout;
+ struct exec32 aout;
int err;
if (lseek(fd, 0, SEEK_SET) != 0) {
@@ -585,8 +595,7 @@ aout_check(int nfile, char *fname, char *cname, int fd, int fflag)
strerror(err));
return (1);
}
- if (read(fd, (char *)&aout, sizeof (struct exec)) !=
- sizeof (struct exec)) {
+ if (read(fd, (char *)&aout, sizeof (aout)) != sizeof (aout)) {
err = errno;
(void) fprintf(stderr, MSG_INTL(MSG_SYS_READ), cname, fname,
strerror(err));
@@ -609,8 +618,7 @@ aout_check(int nfile, char *fname, char *cname, int fd, int fflag)
/*
* Run the required program.
*/
- if ((aout.a_magic == ZMAGIC) &&
- (aout.a_entry <= sizeof (struct exec))) {
+ if ((aout.a_magic == ZMAGIC) && (aout.a_entry <= sizeof (aout))) {
load = load_elf;
return (run(nfile, cname, fname, conv_lddstub(ELFCLASS32),
ELFCLASS32));
diff --git a/usr/src/cmd/sgs/ldd/i386/Makefile b/usr/src/cmd/sgs/ldd/i386/Makefile
index 1f350200d5..32c0e146ac 100644
--- a/usr/src/cmd/sgs/ldd/i386/Makefile
+++ b/usr/src/cmd/sgs/ldd/i386/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -22,7 +21,8 @@
#
#ident "%Z%%M% %I% %E% SMI"
#
-# Copyright (c) 1994 by Sun Microsystems, Inc.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
#
include ../Makefile.com
@@ -32,4 +32,6 @@ include ../Makefile.com
install \
package: $(ROOTPROG)
+lint: $(LINTOUT32) $(SGSLINTOUT)
+
include ../Makefile.targ
diff --git a/usr/src/cmd/sgs/ldd/sparc/Makefile b/usr/src/cmd/sgs/ldd/sparc/Makefile
index 1f350200d5..32c0e146ac 100644
--- a/usr/src/cmd/sgs/ldd/sparc/Makefile
+++ b/usr/src/cmd/sgs/ldd/sparc/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -22,7 +21,8 @@
#
#ident "%Z%%M% %I% %E% SMI"
#
-# Copyright (c) 1994 by Sun Microsystems, Inc.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
#
include ../Makefile.com
@@ -32,4 +32,6 @@ include ../Makefile.com
install \
package: $(ROOTPROG)
+lint: $(LINTOUT32) $(SGSLINTOUT)
+
include ../Makefile.targ
diff --git a/usr/src/cmd/sgs/ldd/sparcv9/Makefile b/usr/src/cmd/sgs/ldd/sparcv9/Makefile
new file mode 100644
index 0000000000..fc1e7bd87c
--- /dev/null
+++ b/usr/src/cmd/sgs/ldd/sparcv9/Makefile
@@ -0,0 +1,40 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+#ident "%Z%%M% %I% %E% SMI"
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+
+.KEEP_STATE:
+
+CONVLIBDIR = $(CONVLIBDIR64)
+LINTFLAGS64 += $(VAR_LINTFLAGS64)
+
+ROOTPROG = $(ROOTPROG64)
+
+lint: $(LINTOUT64) $(SGSLINTOUT)
+
+include ../Makefile.targ
+include ../../Makefile.sub.64
diff --git a/usr/src/cmd/sgs/libelf/common/README.LFS b/usr/src/cmd/sgs/libelf/common/README.LFS
new file mode 100644
index 0000000000..99829cbcce
--- /dev/null
+++ b/usr/src/cmd/sgs/libelf/common/README.LFS
@@ -0,0 +1,159 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+
+
+
+Why 32-bit libelf is not Large File Aware
+-----------------------------------------
+
+The ELF format uses unsigned 32-bit integers for offsets, so the
+theoretical limit on a 32-bit ELF object is 4GB. However, libelf
+imposes a 2GB limit on the objects it can create. The Solaris
+link-editor and related tools are all based on libelf, so the
+32-bit version of the link-editor also has a 2GB limit, despite
+the theoretical limit of 4GB.
+
+Large file support (LFS) is a half step between the 32 and 64-bit
+worlds, in which an otherwise 32-bit limited process is allowed to
+read and write data to a file that can be larger than 2GB (the extent
+of a signed 32-bit integer, as represented by the system type off_t).
+LFS is useful if the program only needs to access a small subset of
+the file data at any given time (e.g. /usr/bin/cat). It is less useful
+if the program needs to access a large amount of data at once --- having
+been freed from the file limit, the program will simply hit the virtual
+memory limit (4GB).
+
+In particular, the link-editor generally requires twice as much
+memory as the size of the output object, half to hold the input
+objects, and half to hold the result. This means that a 32-bit
+link-editor process will hit the 2GB file size limit and the 4GB
+address space limit at roughly the same time. As a result, a
+large file aware 32-bit version of libelf has no significant value.
+Despite this, the question of what it would take to make libelf
+large file aware comes up from time to time.
+
+The first step would be to provide alternative versions of
+all public data structures that involve the off_t data type.
+These structs, found in /usr/include/libelf.h, are:
+
+ /*
+ * Archive member header
+ */
+ typedef struct {
+ char *ar_name;
+ time_t ar_date;
+ uid_t ar_uid;
+ gid_t ar_gid;
+ mode_t ar_mode;
+ off_t ar_size;
+ char *ar_rawname;
+ } Elf_Arhdr;
+
+
+ /*
+ * Data descriptor
+ */
+ typedef struct {
+ Elf_Void *d_buf;
+ Elf_Type d_type;
+ size_t d_size;
+ off_t d_off; /* offset into section */
+ size_t d_align; /* alignment in section */
+ unsigned d_version; /* elf version */
+ } Elf_Data;
+
+As off_t is a signed type, these alternative versions would have to use
+an off64_t type instead.
+
+In addition to providing alternative large file aware Elf_Arhdr and
+Elf_Data types, it would be necessary to implement large file aware
+versions of the public functions that use them, also found in
+/usr/include/libelf.h:
+
+ /*
+ * Function declarations
+ */
+ unsigned elf_flagdata(Elf_Data *, Elf_Cmd, unsigned);
+ Elf_Arhdr *elf_getarhdr(Elf *);
+ off_t elf_getbase(Elf *);
+ Elf_Data *elf_getdata(Elf_Scn *, Elf_Data *);
+ Elf_Data *elf_newdata(Elf_Scn *);
+ Elf_Data *elf_rawdata(Elf_Scn *, Elf_Data *);
+ off_t elf_update(Elf *, Elf_Cmd);
+ Elf_Data *elf32_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
+ Elf_Data *elf32_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
+ Elf_Data *elf64_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
+ Elf_Data *elf64_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
+
+It is important to note that these new versions cannot replace the
+original definitions. Those must continue to be available to support
+non-largefile-aware programs. These new types and functions would be in
+addition to the pre-existing versions.
+
+When you make code like this large file aware, it is necessary to undertake
+a careful analysis of the code to ensure that all the surrounding code uses
+variable types large enough to handle the increased range. Hence, this work
+is more complicated than simply supplying variants that use a bigger
+off_t and rebuilding --- that is just the first step.
+
+There are two standard preprocessor definitions used to control
+large file support:
+
+ _LARGEFILE64_SOURCE
+ _FILE_OFFSET_BITS
+
+These preprocessor definitions would be used to determine whether
+a given program linked against libelf would see the regular, or
+the large file aware versons of the above types and routines.
+This is the same approach used in other large file capable software,
+such as libc.
+
+Finally, all the applications that rely on libelf would need to be made
+large file aware. As with libelf itself, there is more to such an effort
+than recompiling with preprocessor macros set. The code in these
+applications would need to be examined carefully. Some of these programs
+are very old, and were not originally written with such type portability
+in mind. Such code can be difficult to transition.
+
+To work around the 2GB limit in 32-bit libelf:
+
+ - The fundamental limits of a 32-bit address space mean
+ that a program this large should be 64-bit. Only a 64-bit
+ address space has enough room for that much code, plus the
+ stack and heap needed to do useful work with it.
+
+ - The 64-bit version of libelf is also able to process
+ 32-bit objects, and does not have a 2GB file size limit.
+ Therefore, the 64-bit link-editor can be used to build a 32-bit
+ executable which is >2GB. The resulting program will consume over
+ half the available address space just to start running. However,
+ there may be enough address space left for it to do useful work.
+
+ Note that the 32-bit limit for sharable objects remains at
+ 2GB --- imposed by the runtime linker, which is also not large
+ file aware.
diff --git a/usr/src/cmd/sgs/libelf/common/libelf.msg b/usr/src/cmd/sgs/libelf/common/libelf.msg
index 2e01fe2fc8..043b18872e 100644
--- a/usr/src/cmd/sgs/libelf/common/libelf.msg
+++ b/usr/src/cmd/sgs/libelf/common/libelf.msg
@@ -1,13 +1,12 @@
#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -66,7 +65,9 @@
@ EFMT_SHTAB "Format error: shdr table truncated"
@ EFMT_VER2 "Format error: ehdr EI_VERSION/e_version mismatch"
@ EFMT_VM "Format error: reference outside file"
-@ EFMT_FBIG "Format error: file size exceeds 32-bit limit"
+@ EFMT_FBIG_CLASS32 "Format error: file size exceeds 4GB 32-bit limit"
+@ EFMT_FBIG_LARGEFILE "Format error: file size exceeds 2GB limit of 32-bit \
+ linker. 64-bit linker is recommended."
@ EFMT_ARSTRNM "Format error: archive strtab name"
@ EFMT_ARUNKNM "Format error: archive special name unknown"
diff --git a/usr/src/cmd/sgs/libelf/common/update.c b/usr/src/cmd/sgs/libelf/common/update.c
index 0a12578c89..aa80db57f1 100644
--- a/usr/src/cmd/sgs/libelf/common/update.c
+++ b/usr/src/cmd/sgs/libelf/common/update.c
@@ -87,6 +87,64 @@
#endif /* ELF64 */
+#if !(defined(_LP64) && defined(_ELF64))
+#define TEST_SIZE
+
+/*
+ * Handle the decision of whether the current linker can handle the
+ * desired object size, and if not, which error to issue.
+ *
+ * Input is the desired size. On failure, an error has been issued
+ * and 0 is returned. On success, 1 is returned.
+ */
+static int
+test_size(Lword hi)
+{
+#ifndef _LP64 /* 32-bit linker */
+ /*
+ * A 32-bit libelf is limited to a 2GB output file. This limit
+ * is due to the fact that off_t is a signed value, and that
+ * libelf cannot support large file support:
+ * - ABI reasons
+ * - Memory use generally is 2x output file size anyway,
+ * so lifting the file size limit will just send
+ * you crashing into the 32-bit VM limit.
+ * If the output is an ELFCLASS64 object, or an ELFCLASS32 object
+ * under 4GB, switching to the 64-bit version of libelf will help.
+ * However, an ELFCLASS32 object must not exceed 4GB.
+ */
+ if (hi > INT_MAX) { /* Bigger than 2GB */
+#ifndef _ELF64
+ /* ELFCLASS32 object is fundamentally too big? */
+ if (hi > UINT_MAX) {
+ _elf_seterr(EFMT_FBIG_CLASS32, 0);
+ return (0);
+ }
+#endif /* _ELF64 */
+
+ /* Should switch to the 64-bit libelf? */
+ _elf_seterr(EFMT_FBIG_LARGEFILE, 0);
+ return (0);
+ }
+#endif /* !_LP64 */
+
+
+#if defined(_LP64) && !defined(_ELF64) /* 64-bit linker, ELFCLASS32 */
+ /*
+ * A 64-bit linker can produce any size output
+ * file, but if the resulting file is ELFCLASS32,
+ * it must not exceed 4GB.
+ */
+ if (hi > UINT_MAX) {
+ _elf_seterr(EFMT_FBIG_CLASS32, 0);
+ return (0);
+ }
+#endif
+
+ return (1);
+}
+#endif /* TEST_SIZE */
+
/*
* Output file update
* These functions walk an Elf structure, update its information,
@@ -107,7 +165,7 @@ _elf_upd_lib(Elf * elf)
Lword hi;
Lword hibit;
Elf_Scn * s;
- register Xword sz;
+ register Lword sz;
Ehdr * eh = elf->ed_ehdr;
unsigned ver = eh->e_version;
register char *p = (char *)eh->e_ident;
@@ -175,7 +233,7 @@ _elf_upd_lib(Elf * elf)
(void) _elfxx_cookscn(s);
sh->sh_addralign = 1;
- if ((sz = (Xword)_elf_entsz(elf, sh->sh_type, ver)) != 0)
+ if ((sz = (Lword)_elf_entsz(elf, sh->sh_type, ver)) != 0)
/* LINTED */
sh->sh_entsize = (Half)sz;
sz = 0;
@@ -196,10 +254,10 @@ _elf_upd_lib(Elf * elf)
}
d->db_data.d_off = (off_t)sz;
d->db_xoff = sz;
- sz += (Xword)fsz;
+ sz += fsz;
}
- sh->sh_size = sz;
+ sh->sh_size = (Xword) sz;
/*
* We want to take into account the offsets for NOBITS
* sections and let the "sh_offsets" point to where
@@ -275,11 +333,9 @@ _elf_upd_lib(Elf * elf)
eh->e_shentsize = 0;
}
-#if !(defined(_LP64) && defined(_ELF64))
- if (hi > INT_MAX) {
- _elf_seterr(EFMT_FBIG, 0);
+#ifdef TEST_SIZE
+ if (test_size(hi) == 0)
return (0);
- }
#endif
return ((size_t)hi);
@@ -293,7 +349,7 @@ _elf_upd_usr(Elf * elf)
NOTE(ASSUMING_PROTECTED(*elf))
Lword hi;
Elf_Scn * s;
- register Xword sz;
+ register Lword sz;
Ehdr * eh = elf->ed_ehdr;
unsigned ver = eh->e_version;
register char *p = (char *)eh->e_ident;
@@ -343,7 +399,7 @@ _elf_upd_usr(Elf * elf)
}
for (; s != 0; s = s->s_next) {
register Dnode *d;
- register Xword fsz, j;
+ register Lword fsz, j;
Shdr *sh = s->s_shdr;
if ((s->s_myflags & SF_READY) == 0)
@@ -352,15 +408,15 @@ _elf_upd_usr(Elf * elf)
++eh->e_shnum;
sz = 0;
for (d = s->s_hdnode; d != 0; d = d->db_next) {
- if ((fsz = (Xword)elf_fsize(d->db_data.d_type, 1,
+ if ((fsz = elf_fsize(d->db_data.d_type, 1,
ver)) == 0)
return (0);
- j = (Xword)_elf_msize(d->db_data.d_type, ver);
- fsz *= (Xword)(d->db_data.d_size / j);
+ j = _elf_msize(d->db_data.d_type, ver);
+ fsz *= (d->db_data.d_size / j);
d->db_osz = (size_t)fsz;
if ((sh->sh_type != SHT_NOBITS) &&
- ((j = (Xword)(d->db_data.d_off + d->db_osz)) > sz))
+ ((j = (d->db_data.d_off + d->db_osz)) > sz))
sz = j;
}
if (sh->sh_size < sz) {
@@ -384,11 +440,9 @@ _elf_upd_usr(Elf * elf)
if ((sz = eh->e_shoff + eh->e_shentsize * eh->e_shnum) > hi)
hi = sz;
-#if !(defined(_LP64) && defined(_ELF64))
- if (hi > INT_MAX) {
- _elf_seterr(EFMT_FBIG, 0);
+#ifdef TEST_SIZE
+ if (test_size(hi) == 0)
return (0);
- }
#endif
return ((size_t)hi);
diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README
index 87237f6449..23186b2314 100644
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README
@@ -1323,3 +1323,4 @@ Bugid Risk Synopsis
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
6671255 link-editor should support cross linking
PSARC 2008/179 cross link-editor
+6606203 link editor ought to allow creation of >2gb sized objects
diff --git a/usr/src/cmd/sgs/packages/common/prototype_i386 b/usr/src/cmd/sgs/packages/common/prototype_i386
index dd1cbd697d..d7d2787cee 100644
--- a/usr/src/cmd/sgs/packages/common/prototype_i386
+++ b/usr/src/cmd/sgs/packages/common/prototype_i386
@@ -20,7 +20,7 @@
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -51,6 +51,7 @@ f none $SGSDIR/lib/amd64/librtld_db.so.1=lib/amd64/librtld_db.so.1 755 root bin
s none $SGSDIR/lib/amd64/librtld_db.so=librtld_db.so.1
d none $SGSDIR/usr/bin/amd64 755 root bin
f none $SGSDIR/usr/bin/amd64/crle=usr/bin/amd64/crle 555 root bin
+f none $SGSDIR/usr/bin/amd64/ldd=usr/bin/amd64/ldd 555 root bin
f none $SGSDIR/usr/bin/amd64/moe=usr/bin/amd64/moe 555 root bin
f none $SGSDIR/usr/bin/amd64/pvs=usr/bin/amd64/pvs 555 root bin
d none $SGSDIR/usr/ccs/bin/amd64 755 root bin
diff --git a/usr/src/cmd/sgs/packages/common/prototype_sparc b/usr/src/cmd/sgs/packages/common/prototype_sparc
index 9dad82ea34..b65d19bb55 100644
--- a/usr/src/cmd/sgs/packages/common/prototype_sparc
+++ b/usr/src/cmd/sgs/packages/common/prototype_sparc
@@ -20,7 +20,7 @@
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -51,6 +51,7 @@ f none $SGSDIR/lib/sparcv9/librtld_db.so.1=lib/sparcv9/librtld_db.so.1 755 root
s none $SGSDIR/lib/sparcv9/librtld_db.so=librtld_db.so.1
d none $SGSDIR/usr/bin/sparcv9 755 root bin
f none $SGSDIR/usr/bin/sparcv9/crle=usr/bin/sparcv9/crle 555 root bin
+f none $SGSDIR/usr/bin/sparcv9/ldd=usr/bin/sparcv9/ldd 555 root bin
f none $SGSDIR/usr/bin/sparcv9/moe=usr/bin/sparcv9/moe 555 root bin
f none $SGSDIR/usr/bin/sparcv9/pvs=usr/bin/sparcv9/pvs 555 root bin
d none $SGSDIR/usr/ccs/bin/sparcv9 755 root bin
diff --git a/usr/src/cmd/strings/Makefile b/usr/src/cmd/strings/Makefile
index d1b714ee9a..48aa4d15a7 100644
--- a/usr/src/cmd/strings/Makefile
+++ b/usr/src/cmd/strings/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -22,27 +21,34 @@
#
#ident "%Z%%M% %I% %E% SMI"
#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# cmd/strings/Makefile
-PROG= strings
+PROG:sh= basename `pwd`
include ../Makefile.cmd
-LDLIBS += -lelf
+SUBDIRS = $(MACH) $(MACH64)
-CFLAGS += $(CCVERBOSE)
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
.KEEP_STATE:
-all: $(PROG)
+all clean clobber lint: $(SUBDIRS)
-install: all $(ROOTPROG)
+install: $(SUBDIRS)
+ -$(RM) $(ROOTPROG)
+ -$(LN) $(ISAEXEC) $(ROOTPROG)
-clean:
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
-lint: lint_PROG
+FRC:
include ../Makefile.targ
diff --git a/usr/src/cmd/strings/Makefile.com b/usr/src/cmd/strings/Makefile.com
new file mode 100644
index 0000000000..5aee1b058d
--- /dev/null
+++ b/usr/src/cmd/strings/Makefile.com
@@ -0,0 +1,50 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#ident "%Z%%M% %I% %E% SMI"
+#
+
+PROG= strings
+SRCS= ../$(PROG).c
+
+include ../../Makefile.cmd
+
+LDLIBS += -lelf
+
+CFLAGS += $(CCVERBOSE)
+CFLAGS64 += $(CCVERBOSE)
+
+.KEEP_STATE:
+
+all: $(PROG)
+
+$(PROG): $(SRCS)
+ $(LINK.c) -o $(PROG) $(SRCS) $(LDLIBS)
+ $(POST_PROCESS)
+
+clean:
+
+lint: lint_SRCS
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/strings/amd64/Makefile b/usr/src/cmd/strings/amd64/Makefile
new file mode 100644
index 0000000000..ca569a48d1
--- /dev/null
+++ b/usr/src/cmd/strings/amd64/Makefile
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.cmd.64
+
+install: all $(ROOTPROG64)
diff --git a/usr/src/cmd/strings/i386/Makefile b/usr/src/cmd/strings/i386/Makefile
new file mode 100644
index 0000000000..874dfd606b
--- /dev/null
+++ b/usr/src/cmd/strings/i386/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTPROG32)
diff --git a/usr/src/cmd/strings/sparc/Makefile b/usr/src/cmd/strings/sparc/Makefile
new file mode 100644
index 0000000000..874dfd606b
--- /dev/null
+++ b/usr/src/cmd/strings/sparc/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTPROG32)
diff --git a/usr/src/cmd/strings/sparcv9/Makefile b/usr/src/cmd/strings/sparcv9/Makefile
new file mode 100644
index 0000000000..ca569a48d1
--- /dev/null
+++ b/usr/src/cmd/strings/sparcv9/Makefile
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# 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.
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.cmd.64
+
+install: all $(ROOTPROG64)
diff --git a/usr/src/pkgdefs/SUNWtoo/prototype_com b/usr/src/pkgdefs/SUNWtoo/prototype_com
index 2af44a98a7..7c5a1df96f 100644
--- a/usr/src/pkgdefs/SUNWtoo/prototype_com
+++ b/usr/src/pkgdefs/SUNWtoo/prototype_com
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -56,7 +56,7 @@ f none usr/bin/od 555 root bin
l none usr/bin/plimit=../../usr/lib/isaexec
f none usr/bin/pvs 555 root bin
f none usr/bin/sotruss 755 root bin
-f none usr/bin/strings 555 root bin
+l none usr/bin/strings=../../usr/lib/isaexec
l none usr/bin/truss=../../usr/lib/isaexec
f none usr/bin/whocalls 755 root bin
d none usr/ccs 755 root bin
diff --git a/usr/src/pkgdefs/SUNWtoo/prototype_i386 b/usr/src/pkgdefs/SUNWtoo/prototype_i386
index 4829a39a5f..83f416c03a 100644
--- a/usr/src/pkgdefs/SUNWtoo/prototype_i386
+++ b/usr/src/pkgdefs/SUNWtoo/prototype_i386
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -51,11 +51,14 @@
d none usr/bin/i86 755 root bin
f none usr/bin/i86/gcore 555 root bin
f none usr/bin/i86/plimit 555 root bin
+f none usr/bin/i86/strings 555 root bin
f none usr/bin/i86/truss 555 root bin
d none usr/bin/amd64 755 root bin
f none usr/bin/amd64/gcore 555 root bin
+f none usr/bin/amd64/ldd 555 root bin
f none usr/bin/amd64/plimit 555 root bin
f none usr/bin/amd64/pvs 555 root bin
+f none usr/bin/amd64/strings 555 root bin
f none usr/bin/amd64/truss 555 root bin
d none usr/ccs/bin/amd64 755 root bin
f none usr/bin/amd64/ld 755 root bin
diff --git a/usr/src/pkgdefs/SUNWtoo/prototype_sparc b/usr/src/pkgdefs/SUNWtoo/prototype_sparc
index c0c89169d7..97088cb8a3 100644
--- a/usr/src/pkgdefs/SUNWtoo/prototype_sparc
+++ b/usr/src/pkgdefs/SUNWtoo/prototype_sparc
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -50,11 +50,14 @@
#
d none usr/bin/sparcv7 755 root bin
f none usr/bin/sparcv7/gcore 555 root bin
+f none usr/bin/sparcv7/strings 555 root bin
f none usr/bin/sparcv7/truss 555 root bin
d none usr/bin/sparcv9 755 root bin
+f none usr/bin/sparcv9/ldd 555 root bin
f none usr/bin/sparcv9/gcore 555 root bin
f none usr/bin/sparcv9/plimit 555 root bin
f none usr/bin/sparcv9/pvs 555 root bin
+f none usr/bin/sparcv9/strings 555 root bin
f none usr/bin/sparcv9/truss 555 root bin
d none usr/ccs/bin/sparcv9 755 root bin
f none usr/bin/sparcv9/ld 755 root bin