diff options
| author | mycroft <mycroft@NetBSD.org> | 2000-12-16 09:29:29 +0000 |
|---|---|---|
| committer | mycroft <mycroft@NetBSD.org> | 2000-12-16 09:29:29 +0000 |
| commit | bb747bc6631b7908f9b6c675740d695af052d8a9 (patch) | |
| tree | 11817705af7f9d52e9bafccacda0bcc6e9775835 /gnu/usr.bin | |
| parent | 34a059b3540841275df9b36984f10a7fef4d465c (diff) | |
Clean up MAJOR crack addiction:
--whole-archive and --no-whole-archive are by nature position-dependent. Make
it so.
Diffstat (limited to 'gnu/usr.bin')
| -rw-r--r-- | gnu/usr.bin/ld/ld/ld.c | 41 | ||||
| -rw-r--r-- | gnu/usr.bin/ld/ld/ld_i.h | 19 | ||||
| -rw-r--r-- | gnu/usr.bin/ld/ld/lib.c | 14 |
3 files changed, 35 insertions, 39 deletions
diff --git a/gnu/usr.bin/ld/ld/ld.c b/gnu/usr.bin/ld/ld/ld.c index da2b82d5030..1f21dde730e 100644 --- a/gnu/usr.bin/ld/ld/ld.c +++ b/gnu/usr.bin/ld/ld/ld.c @@ -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 @@ decode_command(argc, argv) 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 @@ decode_command(argc, argv) 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 @@ decode_command(argc, argv) 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 @@ decode_option(swt, arg) 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 --git a/gnu/usr.bin/ld/ld/ld_i.h b/gnu/usr.bin/ld/ld/ld_i.h index 1c5d8cb0458..ff8646c08b0 100644 --- a/gnu/usr.bin/ld/ld/ld_i.h +++ b/gnu/usr.bin/ld/ld/ld_i.h @@ -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 @@ struct file_entry { 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 --git a/gnu/usr.bin/ld/ld/lib.c b/gnu/usr.bin/ld/ld/lib.c index 73fe5df203f..4191e84ee15 100644 --- a/gnu/usr.bin/ld/ld/lib.c +++ b/gnu/usr.bin/ld/ld/lib.c @@ -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 @@ search_library(fd, entry) 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 @@ symdef_library(fd, entry, member_length) */ 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 @@ symdef_library(fd, entry, member_length) * 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 @@ symdef_library(fd, entry, member_length) * 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 @@ linear_library(fd, entry) 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 @@ linear_library(fd, entry) 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); |
