From 6446bd46ed1b4e9f69da153665f82181ccaedad5 Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Fri, 1 Apr 2022 18:24:47 -0500 Subject: 14770 ld(1) should be 64bit only Reviewed by: Andy Fiddaman Reviewed by: Toomas Soome Approved by: Garrett D'Amore --- usr/src/cmd/sgs/Makefile.sub | 3 +- usr/src/cmd/sgs/ld/Makefile | 3 +- usr/src/cmd/sgs/ld/Makefile.com | 7 ++-- usr/src/cmd/sgs/ld/amd64/Makefile | 11 +++--- usr/src/cmd/sgs/ld/common/ld.c | 55 +++--------------------------- usr/src/cmd/sgs/ld/common/ld.msg | 2 -- usr/src/cmd/sgs/ld/i386/Makefile | 31 ----------------- usr/src/cmd/sgs/ld/sparc/Makefile | 31 ----------------- usr/src/cmd/sgs/ld/sparcv9/Makefile | 11 +++--- usr/src/cmd/sgs/libld/common/args.c | 6 ++-- usr/src/cmd/sgs/libld/common/libld.msg | 1 - usr/src/cmd/sgs/tools/SUNWonld-README | 1 + usr/src/pkg/manifests/developer-linker.p5m | 2 +- 13 files changed, 25 insertions(+), 139 deletions(-) delete mode 100644 usr/src/cmd/sgs/ld/i386/Makefile delete mode 100644 usr/src/cmd/sgs/ld/sparc/Makefile diff --git a/usr/src/cmd/sgs/Makefile.sub b/usr/src/cmd/sgs/Makefile.sub index f127f18287..a56899c95d 100644 --- a/usr/src/cmd/sgs/Makefile.sub +++ b/usr/src/cmd/sgs/Makefile.sub @@ -27,7 +27,8 @@ include $(SRC)/Makefile.master -SUBDIRS = $(MACH) $(EXTRASUBDIRS) +SUBDIRS = $(EXTRASUBDIRS) +$(BUILD32)SUBDIRS += $(MACH) $(BUILD64)SUBDIRS += $(MACH64) all := TARGET= all diff --git a/usr/src/cmd/sgs/ld/Makefile b/usr/src/cmd/sgs/ld/Makefile index 75eeaf1889..35c78efe07 100644 --- a/usr/src/cmd/sgs/ld/Makefile +++ b/usr/src/cmd/sgs/ld/Makefile @@ -23,6 +23,7 @@ # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" + +BUILD32 = $(POUND_SIGN) include $(SRC)/cmd/sgs/Makefile.sub diff --git a/usr/src/cmd/sgs/ld/Makefile.com b/usr/src/cmd/sgs/ld/Makefile.com index 32d435cc67..12187dbd21 100644 --- a/usr/src/cmd/sgs/ld/Makefile.com +++ b/usr/src/cmd/sgs/ld/Makefile.com @@ -41,12 +41,11 @@ SRCDIR = $(SGSHOME)/ld MAPFILES = $(SRCDIR)/common/mapfile-intf $(MAPFILE.NGB) MAPOPTS = $(MAPFILES:%=-Wl,-M%) -RPATH = '-R$$ORIGIN/../../lib' -RPATH64 = '-R$$ORIGIN/../../../lib/$(MACH64)' +RPATH = '-R$$ORIGIN/../../lib/$(MACH64)' LDFLAGS += $(VERSREF) $(MAPOPTS) $(RPATH) -LDLIBS += -lumem $(LDLIBDIR) -lld $(ELFLIBDIR) -lelf \ - $(LDDBGLIBDIR) -llddbg $(CONVLIBDIR) -lconv +LDLIBS += -lumem $(LDLIBDIR64) -lld $(ELFLIBDIR64) -lelf \ + $(LDDBGLIBDIR64) -llddbg $(CONVLIBDIR64) -lconv CERRWARN += -_gcc=-Wno-switch CERRWARN += -_gcc=-Wno-parentheses diff --git a/usr/src/cmd/sgs/ld/amd64/Makefile b/usr/src/cmd/sgs/ld/amd64/Makefile index 1315c657ff..2a4c3c5d37 100644 --- a/usr/src/cmd/sgs/ld/amd64/Makefile +++ b/usr/src/cmd/sgs/ld/amd64/Makefile @@ -27,14 +27,11 @@ include ../Makefile.com -LDLIBDIR = $(LDLIBDIR64) -ELFLIBDIR = $(ELFLIBDIR64) -LDDBGLIBDIR = $(LDDBGLIBDIR64) -CONVLIBDIR = $(CONVLIBDIR64) +install: all $(ROOTPROG) $(ROOTPROG64) \ + $(ROOTCCSBINLINK) $(ROOTCCSBINLINK64) -RPATH = $(RPATH64) - -install: all $(ROOTPROG64) $(ROOTCCSBINLINK64) +$(ROOTBIN64)/ld: + $(RM) $@; $(SYMLINK) ../../bin/ld $@ .KEEP_STATE: diff --git a/usr/src/cmd/sgs/ld/common/ld.c b/usr/src/cmd/sgs/ld/common/ld.c index 794f5e5e09..90e14b46c3 100644 --- a/usr/src/cmd/sgs/ld/common/ld.c +++ b/usr/src/cmd/sgs/ld/common/ld.c @@ -226,12 +226,11 @@ archive(int fd, Elf *elf, uchar_t *class_ret, Half *mach_ret) /* * Determine: * - ELFCLASS of resulting object (class) - * - Whether user specified class of the linker (ldclass) * - ELF machine type of resulting object (m_mach) * * In order of priority, we determine this information as follows: * - * - Command line options (-32, -64, -z altexec64, -z target). + * - Command line options (-32, -64 -z target). * - From the first plain object seen on the command line. (This is * by far the most common case.) * - From the first object contained within the first archive @@ -241,17 +240,11 @@ archive(int fd, Elf *elf, uchar_t *class_ret, Half *mach_ret) * entry: * argc, argv - Command line argument vector * class_ret - Address of variable to receive ELFCLASS of output object - * ldclass_ret - Address of variable to receive ELFCLASS of - * linker to use. This will be ELFCLASS32/ELFCLASS64 if one - * is explicitly specified, and ELFCLASSNONE otherwise. - * ELFCLASSNONE therefore means that we should use the best - * link-editor that the system/kernel will allow. */ static int -process_args(int argc, char **argv, uchar_t *class_ret, uchar_t *ldclass_ret, - Half *mach) +process_args(int argc, char **argv, uchar_t *class_ret, Half *mach) { - uchar_t ldclass = ELFCLASSNONE, class = ELFCLASSNONE, ar_class; + uchar_t class = ELFCLASSNONE, ar_class; Half mach32 = EM_NONE, mach64 = EM_NONE, ar_mach; int c, ar_found = 0; @@ -278,10 +271,6 @@ process_args(int argc, char **argv, uchar_t *class_ret, uchar_t *ldclass_ret, * a mix of 32 and 64-bit objects, and the first object * in that archive is 32-bit. * - * -z altexec64 - * Use the 64-bit linker regardless of the class - * of the output object. - * * -z target=platform * Produce output object for the specified platform. * This option is needed when producing an object @@ -313,14 +302,6 @@ getmore: break; case 'z': -#if !defined(_LP64) - /* -z altexec64 */ - if (strncmp(optarg, MSG_ORIG(MSG_ARG_ALTEXEC64), - MSG_ARG_ALTEXEC64_SIZE) == 0) { - ldclass = ELFCLASS64; - break; - } -#endif /* -z target=platform */ if (strncmp(optarg, MSG_ORIG(MSG_ARG_TARGET), MSG_ARG_TARGET_SIZE) == 0) { @@ -459,9 +440,6 @@ getmore: class = ar_found ? ar_class : ELFCLASS32; *class_ret = class; - /* ELFCLASS of link-editor to use */ - *ldclass_ret = ldclass; - /* * Machine type of output object: If we did not establish a machine * type from the command line, or from the first plain object, then @@ -660,8 +638,7 @@ ld_altexec(char **argv, char **envp) int main(int argc, char **argv, char **envp) { - char **oargv = argv; - uchar_t class, ldclass, checkclass; + uchar_t class; Half mach; /* @@ -690,31 +667,9 @@ main(int argc, char **argv, char **envp) * - link-editor class * - target machine */ - if (process_args(argc, argv, &class, &ldclass, &mach)) + if (process_args(argc, argv, &class, &mach)) return (1); - /* - * Unless a 32-bit link-editor was explicitly requested, try - * to exec the 64-bit version. - */ - if (ldclass != ELFCLASS32) - checkclass = conv_check_native(oargv, envp); - - /* - * If an attempt to exec the 64-bit link-editor fails: - * - Bail if the 64-bit linker was explicitly requested - * - Continue quietly if the 64-bit linker was not requested. - * This is undoubtedly due to hardware/kernel limitations, - * and therefore represents the best we can do. Note that - * the 32-bit linker is capable of linking anything the - * 64-bit version is, subject to a 4GB limit on memory, and - * 2GB object size. - */ - if ((ldclass == ELFCLASS64) && (checkclass != ELFCLASS64)) { - eprintf(0, ERR_FATAL, MSG_INTL(MSG_SYS_64)); - return (1); - } - /* Call the libld entry point for the specified ELFCLASS */ if (class == ELFCLASS64) return (ld64_main(argc, argv, mach)); diff --git a/usr/src/cmd/sgs/ld/common/ld.msg b/usr/src/cmd/sgs/ld/common/ld.msg index cc3dcd56c4..3b31deb37f 100644 --- a/usr/src/cmd/sgs/ld/common/ld.msg +++ b/usr/src/cmd/sgs/ld/common/ld.msg @@ -35,7 +35,6 @@ @ MSG_SYS_EXEC "file %s: exec failed: %s" @ MSG_SYS_ALLOC "alloc failed: %s" -@ MSG_SYS_64 "unable to execute 64-bit version of ld" @ MSG_ERR_BADTARG "unknown target platform: %s" @@ -60,7 +59,6 @@ @ MSG_ARG_TWO "2" @ MSG_ARG_FOUR "4" -@ MSG_ARG_ALTEXEC64 "altexec64" @ MSG_ARG_TARGET "target=" @ MSG_LD_OPTIONS "LD_OPTIONS" diff --git a/usr/src/cmd/sgs/ld/i386/Makefile b/usr/src/cmd/sgs/ld/i386/Makefile deleted file mode 100644 index c9a167d407..0000000000 --- a/usr/src/cmd/sgs/ld/i386/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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. -# -# 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 (c) 1996 by Sun Microsystems, Inc. -# All rights reserved. - -include ../Makefile.com - -.KEEP_STATE: - -install: all $(ROOTPROG) $(ROOTCCSBINLINK) - -include ../Makefile.targ diff --git a/usr/src/cmd/sgs/ld/sparc/Makefile b/usr/src/cmd/sgs/ld/sparc/Makefile deleted file mode 100644 index 999606887c..0000000000 --- a/usr/src/cmd/sgs/ld/sparc/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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. -# -# 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 (c) 1996 by Sun Microsystems, Inc. -# All rights reserved. - -include ../Makefile.com - -.KEEP_STATE: - -install: all $(ROOTBIN) $(ROOTCCSBINLINK) - -include ../Makefile.targ diff --git a/usr/src/cmd/sgs/ld/sparcv9/Makefile b/usr/src/cmd/sgs/ld/sparcv9/Makefile index 8cc2aab477..6ad7730834 100644 --- a/usr/src/cmd/sgs/ld/sparcv9/Makefile +++ b/usr/src/cmd/sgs/ld/sparcv9/Makefile @@ -26,16 +26,13 @@ include ../Makefile.com -LDLIBDIR = $(LDLIBDIR64) -ELFLIBDIR = $(ELFLIBDIR64) -LDDBGLIBDIR = $(LDDBGLIBDIR64) -CONVLIBDIR = $(CONVLIBDIR64) +install: all $(ROOTPROG) $(ROOTPROG64) \ + $(ROOTCCSBINLINK) $(ROOTCCSBINLINK64) -RPATH = $(RPATH64) +$(ROOTBIN64)/ld: + $(RM) $@; $(SYMLINK) ../../bin/ld $@ .KEEP_STATE: -install: all $(ROOTBIN64) $(ROOTCCSBINLINK64) - include ../Makefile.targ include $(SRC)/Makefile.master.64 diff --git a/usr/src/cmd/sgs/libld/common/args.c b/usr/src/cmd/sgs/libld/common/args.c index 2dfa6e4ca3..0ad5299b0a 100644 --- a/usr/src/cmd/sgs/libld/common/args.c +++ b/usr/src/cmd/sgs/libld/common/args.c @@ -192,7 +192,6 @@ usage_mesg(Boolean detail) (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_CY)); (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZA)); (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZAE)); - (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZAL)); (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZADLIB)); (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZC)); (void) fprintf(stderr, MSG_INTL(MSG_ARG_DETAIL_ZDEF)); @@ -1580,8 +1579,9 @@ parseopt_pass1(Ofl_desc *ofl, int argc, char **argv, int *usage) } /* * The following options just need validation as they - * are interpreted on the second pass through the - * command line arguments. + * are interpreted either on the second pass through + * the command line arguments, by ld(1) directly, or + * are merely accepted for compatibility. */ } else if ( strncmp(optarg, MSG_ORIG(MSG_ARG_INITARRAY), diff --git a/usr/src/cmd/sgs/libld/common/libld.msg b/usr/src/cmd/sgs/libld/common/libld.msg index 93e9889c0f..c14d1a7ff4 100644 --- a/usr/src/cmd/sgs/libld/common/libld.msg +++ b/usr/src/cmd/sgs/libld/common/libld.msg @@ -140,7 +140,6 @@ allow extraction of\n\ \t\t\tarchive members to resolve weak references from \ \n\t\t\t\archive files\n" -@ MSG_ARG_DETAIL_ZAL "\t[-z altexec64]\texecute the 64-bit link-editor\n" @ MSG_ARG_DETAIL_ZADLIB "\t[-z assert-deflib]\n\ \t\t\tenables warnings for linking with libraries in \ the \n\t\t\tdefault search path\n\ diff --git a/usr/src/cmd/sgs/tools/SUNWonld-README b/usr/src/cmd/sgs/tools/SUNWonld-README index 83906f59c3..fdcbd59a76 100644 --- a/usr/src/cmd/sgs/tools/SUNWonld-README +++ b/usr/src/cmd/sgs/tools/SUNWonld-README @@ -1689,3 +1689,4 @@ Bugid Risk Synopsis 4795 /usr/bin/ld manpage and help should indicate '-soname' not '--soname' 14090 ld(1) could use a normal allocator 14722 ld should keep group members in separate output sections +14770 ld(1) should be 64bit only diff --git a/usr/src/pkg/manifests/developer-linker.p5m b/usr/src/pkg/manifests/developer-linker.p5m index 795a5dabf0..d1ba314819 100644 --- a/usr/src/pkg/manifests/developer-linker.p5m +++ b/usr/src/pkg/manifests/developer-linker.p5m @@ -40,7 +40,7 @@ file path=usr/bin/$(ARCH32)/truss mode=0555 dir path=usr/bin/$(ARCH64) file path=usr/bin/$(ARCH64)/elfwrap mode=0555 file path=usr/bin/$(ARCH64)/gcore mode=0555 -file path=usr/bin/$(ARCH64)/ld mode=0755 +link path=usr/bin/$(ARCH64)/ld target=../../bin/ld file path=usr/bin/$(ARCH64)/ldd mode=0555 file path=usr/bin/$(ARCH64)/plimit mode=0555 file path=usr/bin/$(ARCH64)/pvs mode=0555 -- cgit v1.2.3