Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/gnu/usr.bin/ld/ld Clean up MAJOR crack addiction:



details:   https://anonhg.NetBSD.org/src/rev/a4394a9b3a0c
branches:  trunk
changeset: 500677:a4394a9b3a0c
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sat Dec 16 09:29:29 2000 +0000

description:
Clean up MAJOR crack addiction:
--whole-archive and --no-whole-archive are by nature position-dependent.  Make
it so.

diffstat:

 gnu/usr.bin/ld/ld/ld.c   |  41 ++++++++++++++++++-----------------------
 gnu/usr.bin/ld/ld/ld_i.h |  19 ++++++++++---------
 gnu/usr.bin/ld/ld/lib.c  |  14 +++++++-------
 3 files changed, 35 insertions(+), 39 deletions(-)

diffs (194 lines):

diff -r eb2c65ef4d57 -r a4394a9b3a0c gnu/usr.bin/ld/ld/ld.c
--- a/gnu/usr.bin/ld/ld/ld.c    Sat Dec 16 06:17:09 2000 +0000
+++ b/gnu/usr.bin/ld/ld/ld.c    Sat Dec 16 09:29:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.72 2000/11/02 16:14:37 matt Exp $     */
+/*     $NetBSD: ld.c,v 1.73 2000/12/16 09:29:29 mycroft Exp $  */
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -88,7 +88,7 @@
 
 #ifndef lint
 /* from: "@(#)ld.c     6.10 (Berkeley) 5/22/91"; */
-__RCSID("$NetBSD: ld.c,v 1.72 2000/11/02 16:14:37 matt Exp $");
+__RCSID("$NetBSD: ld.c,v 1.73 2000/12/16 09:29:29 mycroft Exp $");
 #endif /* not lint */
 
 #define GNU_BINUTIL_COMPAT     /* forwards compatiblity with binutils 2.x */
@@ -763,6 +763,8 @@
                if (code == 0) {
                        p->filename = argv[i];
                        p->local_sym_name = argv[i];
+                       if (link_mode & FORCEARCHIVE)
+                               p->flags |= E_FORCE_ARCHIVE;
                        p++;
                        continue;
                }
@@ -788,8 +790,12 @@
                        else if (strcmp(string, "~silly") == 0)
                                link_mode &= ~SILLYARCHIVE;
 #endif
-               }
-               if (argv[i][1] == 'A') {
+               } else if (argv[i][1] == '-') {
+                       if (strcmp(string, "whole-archive") == 0)
+                               link_mode |= FORCEARCHIVE;
+                       else if (strcmp(string, "no-whole-archive") == 0)
+                               link_mode &= ~FORCEARCHIVE;
+               } else if (argv[i][1] == 'A') {
                        if (p != file_table)
                                errx(1, "-A specified before an input file other than the first");
                        p->filename = string;
@@ -797,13 +803,14 @@
                        p->flags |= E_JUST_SYMS;
                        link_mode &= ~DYNAMIC;
                        p++;
-               }
-               if (argv[i][1] == 'l') {
+               } else if (argv[i][1] == 'l') {
                        p->filename = string;
                        p->local_sym_name = concat("-l", string, "");
                        p->flags |= E_SEARCH_DIRS;
                        if (link_mode & DYNAMIC && !relocatable_output)
                                p->flags |= E_SEARCH_DYNAMIC;
+                       if (link_mode & FORCEARCHIVE)
+                               p->flags |= E_FORCE_ARCHIVE;
                        p++;
                }
                i += code - 1;
@@ -880,32 +887,20 @@
                return;
        if (!strcmp(swt + 1, "Bforcearchive"))
                return;
-       if (!strcmp(swt + 1, "Bshareable")) {
-               if (warn_obsolete_syntax)
-                       warnx("-Bshareable: obsolete syntax");
+       if (!strcmp(swt + 1, "Bshareable"))
                return;
-       }                       
        if (!strcmp(swt + 1, "assert"))
                return;
 #ifdef GNU_BINUTIL_COMPAT
-       if (strcmp(swt + 1, "-export-dynamic") == 0) {
+       if (!strcmp(swt + 1, "-export-dynamic")) {
                if (warn_forwards_compatible_inexact)
-                       warnx("%s ignored", swt + 1);
+                       warnx("-export-dynamic ignored");
                return;
        }
-       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");
+       if (!strcmp(swt + 1, "-whole-archive"))
                return;
-       }
-       if (strcmp(swt + 1, "-no-whole-archive") == 0) {
-               /* XXX incomplete emulation */
-               if (warn_forwards_compatible_inexact)
-                       warnx("-no-whole-archive ignored");
+       if (!strcmp(swt + 1, "-no-whole-archive"))
                return;
-       }
        if (strcmp(swt + 1, "shared") == 0) {
                link_mode |= SHAREABLE;
 #ifdef DEBUG_COMPAT
diff -r eb2c65ef4d57 -r a4394a9b3a0c gnu/usr.bin/ld/ld/ld_i.h
--- a/gnu/usr.bin/ld/ld/ld_i.h  Sat Dec 16 06:17:09 2000 +0000
+++ b/gnu/usr.bin/ld/ld/ld_i.h  Sat Dec 16 09:29:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld_i.h,v 1.1 1998/12/17 14:34:51 pk Exp $      */
+/*     $NetBSD: ld_i.h,v 1.2 2000/12/16 09:29:29 mycroft Exp $ */
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -283,15 +283,16 @@
        int     lib_major, lib_minor;   /* Version numbers of a shared object */
 
        int     flags;
-#define E_IS_LIBRARY           1       /* File is a an archive */
-#define E_HEADER_VALID         2       /* File's header has been read */
-#define E_SEARCH_DIRS          4       /* Search directories for file */
-#define E_SEARCH_DYNAMIC       8       /* Search for shared libs allowed */
-#define E_JUST_SYMS            0x10    /* File is used for incremental load */
-#define E_DYNAMIC              0x20    /* File is a shared object */
-#define E_SCRAPPED             0x40    /* Ignore this file */
-#define E_SYMBOLS_USED         0x80    /* Symbols from this entry were used */
+#define E_IS_LIBRARY           0x001   /* File is a an archive */
+#define E_HEADER_VALID         0x002   /* File's header has been read */
+#define E_SEARCH_DIRS          0x004   /* Search directories for file */
+#define E_SEARCH_DYNAMIC       0x008   /* Search for shared libs allowed */
+#define E_JUST_SYMS            0x010   /* File is used for incremental load */
+#define E_DYNAMIC              0x020   /* File is a shared object */
+#define E_SCRAPPED             0x040   /* Ignore this file */
+#define E_SYMBOLS_USED         0x080   /* Symbols from this entry were used */
 #define E_SECONDCLASS          0x100   /* Shared object is a subsidiary */
+#define        E_FORCE_ARCHIVE         0x200   /* Include all library symbols */
 };
 
 /*
diff -r eb2c65ef4d57 -r a4394a9b3a0c gnu/usr.bin/ld/ld/lib.c
--- a/gnu/usr.bin/ld/ld/lib.c   Sat Dec 16 06:17:09 2000 +0000
+++ b/gnu/usr.bin/ld/ld/lib.c   Sat Dec 16 09:29:29 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lib.c,v 1.22 2000/01/13 00:05:32 mycroft Exp $ */
+/*     $NetBSD: lib.c,v 1.23 2000/12/16 09:29:29 mycroft Exp $ */
 
 /*
  *     - library routines
@@ -48,7 +48,7 @@
        register char  *name;
        register struct file_entry *subentry;
 
-       if (!(link_mode & FORCEARCHIVE) && !undefined_global_sym_count)
+       if (!(entry->flags & E_FORCE_ARCHIVE) && !undefined_global_sym_count)
                return;
 
        /* Examine its first member, which starts SARMAG bytes in.  */
@@ -240,7 +240,7 @@
                 */
 
                for (i = 0; (i < nsymdefs &&
-                                       ((link_mode & FORCEARCHIVE) ||
+                                       ((entry->flags & E_FORCE_ARCHIVE) ||
                                        undefined_global_sym_count ||
                                        common_defined_global_count)); i++) {
 
@@ -276,7 +276,7 @@
                         * archive members to be searched for definitions
                         * satisfying undefined shared object symbols.
                         */
-                       if (!(link_mode & FORCEARCHIVE) &&
+                       if (!(entry->flags & E_FORCE_ARCHIVE) &&
                                (!sp || sp->defined ||
                                        (!(sp->flags & GS_REFERENCED) &&
                                                !sp->sorefs)))
@@ -314,7 +314,7 @@
                         * load.
                         */
 
-                       if (!(link_mode & FORCEARCHIVE) &&
+                       if (!(entry->flags & E_FORCE_ARCHIVE) &&
                                        !subfile_wanted_p(subentry)) {
                                if (subentry->symbols)
                                        free(subentry->symbols);
@@ -377,7 +377,7 @@
        struct  file_entry *prev = 0;
        int     this_subfile_offset = SARMAG;
 
-       while ((link_mode & FORCEARCHIVE) ||
+       while ((entry->flags & E_FORCE_ARCHIVE) ||
                undefined_global_sym_count || common_defined_global_count) {
 
                int                     member_length;
@@ -394,7 +394,7 @@
                subentry->strings = (char *)malloc(subentry->string_size);
                read_entry_strings(fd, subentry);
 
-               if (!(link_mode & FORCEARCHIVE) &&
+               if (!(entry->flags & E_FORCE_ARCHIVE) &&
                    !subfile_wanted_p(subentry)) {
                        if (subentry->symbols)
                                free(subentry->symbols);



Home | Main Index | Thread Index | Old Index