diff options
author | Daniel Jacobowitz <drow@false.org> | 2004-10-16 18:13:54 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2004-10-16 18:13:54 +0000 |
commit | b58f81aef6a84930bcb58db39f2bad0c45383a6d (patch) | |
tree | 3898cd356f0d9f0d894b447a4fdb46915a7bfac0 /ld/ldlang.c | |
parent | fd5008162e2dc522e4fea16de38a355f7e1a43be (diff) | |
download | gdb-b58f81aef6a84930bcb58db39f2bad0c45383a6d.zip gdb-b58f81aef6a84930bcb58db39f2bad0c45383a6d.tar.gz gdb-b58f81aef6a84930bcb58db39f2bad0c45383a6d.tar.bz2 |
bfd/
* bfd-in2.h: Regenerate.
* bfd.c (struct bfd): Add no_export.
* elflink.c (elf_link_add_object_symbols): Handle no_export.
ld/
* ldlang.c (struct excluded_lib, excluded_libs, add_excluded_libs)
(check_excluded_libs): New.
(load_symbols): Call check_excluded_libs.
* ldlang.h (add_excluded_libs): New prototype.
* emultempl/elf32.em (OPTION_EXCLUDED_LIBS): Define.
(gld${EMULATION_NAME}_add_options): Add --exclude-libs.
(gld${EMULATION_NAME}_handle_option): Handle --exclude-libs.
* ld.texinfo (Command Line Variables): Document --exclude-libs.
(Options Specific to i386 PE Targets): Remove --exclude-libs.
ld/testsuite/
* ld-elf/exclude1.s, ld-elf/exclude2.s, ld-elf/exclude.exp: New.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index fee5950..4cc5927 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1692,6 +1692,67 @@ lookup_name (const char *name) return search; } +/* Save LIST as a list of libraries whose symbols should not be exported. */ + +struct excluded_lib +{ + char *name; + struct excluded_lib *next; +}; +static struct excluded_lib *excluded_libs; + +void +add_excluded_libs (const char *list) +{ + const char *p = list, *end; + + while (*p != '\0') + { + struct excluded_lib *entry; + end = strpbrk (p, ",:"); + if (end == NULL) + end = p + strlen (p); + entry = xmalloc (sizeof (*entry)); + entry->next = excluded_libs; + entry->name = xmalloc (end - p + 1); + memcpy (entry->name, p, end - p); + entry->name[end - p] = '\0'; + excluded_libs = entry; + if (*end == '\0') + break; + p = end + 1; + } +} + +static void +check_excluded_libs (bfd *abfd) +{ + struct excluded_lib *lib = excluded_libs; + + while (lib) + { + int len = strlen (lib->name); + const char *filename = lbasename (abfd->filename); + + if (strcmp (lib->name, "ALL") == 0) + { + abfd->no_export = TRUE; + return; + } + + if (strncmp (lib->name, filename, len) == 0 + && (filename[len] == '\0' + || (filename[len] == '.' && filename[len + 1] == 'a' + && filename[len + 2] == '\0'))) + { + abfd->no_export = TRUE; + return; + } + + lib = lib->next; + } +} + /* Get the symbols for an input file. */ static bfd_boolean @@ -1776,6 +1837,8 @@ load_symbols (lang_input_statement_type *entry, break; case bfd_archive: + check_excluded_libs (entry->the_bfd); + if (entry->whole_archive) { bfd *member = NULL; |