Clean up MAJOR crack addiction:

--whole-archive and --no-whole-archive are by nature position-dependent.  Make
it so.
This commit is contained in:
mycroft 2000-12-16 09:29:29 +00:00
parent 34a059b354
commit bb747bc663
3 changed files with 35 additions and 39 deletions

View File

@ -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

View File

@ -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 */
};
/*

View File

@ -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);