summaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-22 10:02:53 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-22 10:02:53 +0000
commitf219434a14581bb4a11910aaf0ac99ad4a833e5e (patch)
treea9e2655656965cafed01247c590941776bbf3bcc /gnu/usr.bin
parentb1d3171142efef3d21f576f0ba25905ac9504238 (diff)
Add emulation of binutils 2.x ld options: -rpath dir, -shared, -soname,
--whole-archive, --no-whole-archive for compatibility with ELF ports and to aid migration to bintils. Update manpage with new options; jonathan
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/ld/ld.144
-rw-r--r--gnu/usr.bin/ld/ld.c71
2 files changed, 111 insertions, 4 deletions
diff --git a/gnu/usr.bin/ld/ld.1 b/gnu/usr.bin/ld/ld.1
index 44330300ad8..dbb200c81b1 100644
--- a/gnu/usr.bin/ld/ld.1
+++ b/gnu/usr.bin/ld/ld.1
@@ -1,4 +1,4 @@
-.\"
+.\" $NetBSD: ld.1,v 1.14 1998/02/20 03:12:50 jonathan Exp $
.\" Copyright (c) 1993 Paul Kranenburg
.\" All rights reserved.
.\"
@@ -27,7 +27,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: ld.1,v 1.8 1997/06/02 08:50:47 deraadt Exp $
+.\" $Id: ld.1,v 1.9 1998/02/22 10:02:50 deraadt Exp $
.\"
.Dd October 14, 1993
.Dt LD 1
@@ -221,6 +221,46 @@ Trace the manipulations inflicted on
Make a
.Dv ZMAGIC
output file. This is the default.
+.Sh
+The following long options are exceptions to the normal option syntax
+described above, and are provided for compatibility with later versions of
+GNU
+.Nm ld ":"
+.Bl -tag -width indent
+.It Fl rpath Ar dir
+Record the given
+.Ar dir
+within the executable for run-time library
+search, as for
+.Fl R "."
+This only applies to dynamically linked executables.
+.It Fl shared
+Instructs the linker to build a shared object from the object files rather
+than a normal executable image.
+.It Fl soname Ar library-name
+This option and its
+.Ar libraryname
+argument are ignored. They are provided for compatibility with versions of
+.Nm ld ","
+which allow the user to specify an internal name and version number
+for dynamically-linked shared libraries.
+.It Fl Fl whole-archive
+A positional qualifier to force loading from archives.
+For each archive mentioned on the commandline after this option,
+include every object file from the archive in the link, rather than
+searching the archive for the required object files. This is normally used
+when building shared libraries.
+
+The positional syntax is not currently implemented;
+.Fl Fl whole-archive
+is treated exactly as
+.Fl B Ns Ar forcearchive .
+.It Fl Fl no-whole-archive
+This option should turn off the effect of a preceding
+.Fl Fl whole-archive
+for any subsequent archive files on the command line.
+It is currently ignored.
+.El
.Sh ENVIRONMENT
.Nm
utilizes the following environment variables:
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c
index 439c758e9d1..6a3a01a5b00 100644
--- a/gnu/usr.bin/ld/ld.c
+++ b/gnu/usr.bin/ld/ld.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.c,v 1.8 1997/04/10 10:50:29 deraadt Exp $ */
+/* $NetBSD: ld.c,v 1.52 1998/02/20 03:12:51 jonathan Exp $ */
/*-
* This code is derived from software copyrighted by the Free Software
@@ -55,6 +55,9 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
#include <stab.h>
#include <string.h>
+#define GNU_BINUTIL_COMPAT /* forwards compatiblity with binutils 2.x */
+/*#define DEBUG_COMPAT*/
+
#include "ld.h"
/* Vector of entries for input files specified by arguments.
@@ -233,6 +236,18 @@ int specified_data_size;
long *set_vectors;
int setv_fill_count;
+/*
+ * Control warnings if we see syntax obsolete in GNU binutils, or if
+ * our forwards-compatible emulation of binutils flags is not
+ * completely faithful.
+ */
+int warn_obsolete_syntax = 0;
+#ifdef DEBUG_COMPAT
+int warn_forwards_compatible_inexact = 1;
+#else
+int warn_forwards_compatible_inexact = 0;
+#endif
+
static void decode_option __P((char *, char *));
static void decode_command __P((int, char **));
static int classify_arg __P((char *));
@@ -449,6 +464,21 @@ classify_arg(arg)
if (!strcmp(&arg[2], "data"))
return 2;
return 1;
+
+ /* GNU binutils 2.x forward-compatible flags. */
+ case 'r':
+ /* Ignore "-rpath" and hope ld.so.conf will cover our sins. */
+ if (!strcmp(&arg[1], "rpath"))
+ return 2;
+ return 1;
+
+ case 's':
+ /* Treat "-shared" and "-soname' like binutils 2.x does. */
+ if (!strcmp(&arg[1], "shared"))
+ return 1;
+ if (!strcmp(&arg[1], "soname"))
+ return 2;
+ break;
}
return 1;
@@ -626,10 +656,46 @@ decode_option(swt, arg)
return;
if (!strcmp(swt + 1, "Bforcearchive"))
return;
- if (!strcmp(swt + 1, "Bshareable"))
+ if (!strcmp(swt + 1, "Bshareable")) {
+ if (warn_obsolete_syntax)
+ warnx("-Bshareable: obsolete syntax");
return;
+ }
if (!strcmp(swt + 1, "assert"))
return;
+#ifdef GNU_BINUTIL_COMPAT
+ if (strcmp(swt + 1, "-whole-archive") == 0) {
+ /* XXX incomplete emulation */
+ link_mode |= FORCEARCHIVE;
+ if (warn_forwards_compatible_inexact)
+ warnx("-no-whole-archive treated as -Bshareable");
+ return;
+ }
+ if (strcmp(swt + 1, "-no-whole-archive") == 0) {
+ /* XXX incomplete emulation */
+ if (warn_forwards_compatible_inexact)
+ warnx("-no-whole-archive ignored");
+ return;
+ }
+ if (strcmp(swt + 1, "shared") == 0) {
+ link_mode |= SHAREABLE;
+#ifdef DEBUG_COMPAT
+ warnx("-shared treated as -Bshareable");
+#endif
+ return;
+ }
+ if (strcmp(swt + 1, "soname") == 0) {
+ if (warn_forwards_compatible_inexact)
+ warnx("-soname %s ignored", arg);
+ return;
+ }
+ if (strcmp(swt + 1, "rpath") == 0) {
+ if (warn_forwards_compatible_inexact)
+ warnx("%s %s ignored", swt, arg);
+ goto do_rpath;
+ }
+#endif /* GNU_BINUTIL_COMPAT */
+
#ifdef SUN_COMPAT
if (!strcmp(swt + 1, "Bsilly"))
return;
@@ -689,6 +755,7 @@ decode_option(swt, arg)
return;
case 'R':
+do_rpath:
rrs_search_paths = (rrs_search_paths == NULL)
? strdup(arg)
: concat(rrs_search_paths, ":", arg);