From a80a7e51140551d0e14703dc9f8c85a85b0dd519 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 26 Nov 2008 01:04:10 +0000 Subject: [PATCH] include/ PR 7047 * bfdlink.h (struct bfd_elf_version_expr): Delete "symbol". Add "literal". bfd/ PR 7047 * configure.in: Bump version. * configure: Regenerate. * elflink.c (_bfd_elf_link_assign_sym_version): Continue matching against version nodes when a global match is a wildcard. Similarly continue matching on local wildcard matches, rather than only continuing for "*". Have any global wildcard match override a local wildcard match. Correct logic hiding unversioned symbol. (bfd_elf_size_dynamic_sections): Update for changes to struct bfd_elf_version_expr. ld/ PR 7047 * emultempl/ppc64elf.em (gld${EMULATION_NAME}_new_vers_pattern): Update for changes to struct bfd_elf_version_expr. * ldlang.c (lang_vers_match, version_expr_head_hash): Likewise. (version_expr_head_eq, lang_finalize_version_expr_head): Likewise. (lang_register_vers_node): Likewise. (lang_new_vers_pattern): Likewise. Ensure "literal" is set when no glob chars found in "pattern". (realsymbol): Correct backslash quote logic. * ld.texinfo (VERSION): Warn about global wildcards. --- bfd/ChangeLog | 13 ++++++++++ bfd/configure | 2 +- bfd/configure.in | 2 +- bfd/elflink.c | 72 ++++++++++++++++++++++++++++++------------------------- include/ChangeLog | 6 +++++ include/bfdlink.h | 4 ++-- 6 files changed, 62 insertions(+), 37 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9d4a323dd7..e0602882c9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,16 @@ +2008-11-26 Alan Modra + + PR 7047 + * configure.in: Bump version. + * configure: Regenerate. + * elflink.c (_bfd_elf_link_assign_sym_version): Continue matching + against version nodes when a global match is a wildcard. Similarly + continue matching on local wildcard matches, rather than only + continuing for "*". Have any global wildcard match override a + local wildcard match. Correct logic hiding unversioned symbol. + (bfd_elf_size_dynamic_sections): Update for changes to struct + bfd_elf_version_expr. + 2008-11-25 Joel Brobecker * configure.in: Deactivate large-file support on native x86-solaris diff --git a/bfd/configure b/bfd/configure index 042f5d1f74..8ff1234a1a 100755 --- a/bfd/configure +++ b/bfd/configure @@ -3033,7 +3033,7 @@ fi # Define the identity of the package. PACKAGE=bfd - VERSION=2.19.50 + VERSION=2.19.51 cat >>confdefs.h <<_ACEOF diff --git a/bfd/configure.in b/bfd/configure.in index 7297ee0e70..47ef10ccdf 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -8,7 +8,7 @@ AC_CONFIG_SRCDIR([libbfd.c]) AC_CANONICAL_TARGET AC_ISC_POSIX -AM_INIT_AUTOMAKE(bfd, 2.19.50) +AM_INIT_AUTOMAKE(bfd, 2.19.51) dnl These must be called before LT_INIT, because it may want dnl to call AC_CHECK_PROG. diff --git a/bfd/elflink.c b/bfd/elflink.c index ce1dff7d01..43379c71a6 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2010,41 +2010,36 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data) if (h->verinfo.vertree == NULL && sinfo->verdefs != NULL) { struct bfd_elf_version_tree *t; - struct bfd_elf_version_tree *local_ver; + struct bfd_elf_version_tree *local_ver, *global_ver, *exist_ver; struct bfd_elf_version_expr *d; /* See if can find what version this symbol is in. If the symbol is supposed to be local, then don't actually register it. */ local_ver = NULL; + global_ver = NULL; + exist_ver = NULL; for (t = sinfo->verdefs; t != NULL; t = t->next) { if (t->globals.list != NULL) { - bfd_boolean matched; - - matched = FALSE; d = NULL; while ((d = (*t->match) (&t->globals, d, h->root.root.string)) != NULL) - if (d->symver) - matched = TRUE; - else - { - /* There is a version without definition. Make - the symbol the default definition for this - version. */ - h->verinfo.vertree = t; - local_ver = NULL; - d->script = 1; + { + global_ver = t; + local_ver = NULL; + if (d->symver) + exist_ver = t; + d->script = 1; + /* If the match is a wildcard pattern, keep looking for + a more explicit, perhaps even local, match. */ + if (d->literal) break; - } + } + if (d != NULL) break; - else if (matched) - /* There is no undefined version for this symbol. Hide the - default one. */ - (*bed->elf_backend_hide_symbol) (info, h, TRUE); } if (t->locals.list != NULL) @@ -2054,11 +2049,14 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data) h->root.root.string)) != NULL) { local_ver = t; - /* If the match is "*", keep looking for a more - explicit, perhaps even global, match. - XXX: Shouldn't this be !d->wildcard instead? */ - if (d->pattern[0] != '*' || d->pattern[1] != '\0') - break; + /* If the match is a wildcard pattern, keep looking for + a more explicit, perhaps even global, match. */ + if (d->literal) + { + /* An exact match overrides a global wildcard. */ + global_ver = NULL; + break; + } } if (d != NULL) @@ -2066,14 +2064,22 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data) } } - if (local_ver != NULL) + if (global_ver != NULL) + { + h->verinfo.vertree = global_ver; + /* If we already have a versioned symbol that matches the + node for this symbol, then we don't want to create a + duplicate from the unversioned symbol. Instead hide the + unversioned symbol. */ + if (exist_ver == global_ver) + (*bed->elf_backend_hide_symbol) (info, h, TRUE); + } + else if (local_ver != NULL) { h->verinfo.vertree = local_ver; - if (h->dynindx != -1 - && ! info->export_dynamic) - { - (*bed->elf_backend_hide_symbol) (info, h, TRUE); - } + if (!info->export_dynamic + || exist_ver == local_ver) + (*bed->elf_backend_hide_symbol) (info, h, TRUE); } } @@ -5566,14 +5572,14 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, /* Make all global versions with definition. */ for (t = verdefs; t != NULL; t = t->next) for (d = t->globals.list; d != NULL; d = d->next) - if (!d->symver && d->symbol) + if (!d->symver && d->literal) { const char *verstr, *name; size_t namelen, verlen, newlen; char *newname, *p; struct elf_link_hash_entry *newh; - name = d->symbol; + name = d->pattern; namelen = strlen (name); verstr = t->name; verlen = strlen (verstr); @@ -5631,7 +5637,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, all_defined = TRUE; for (t = verdefs; t != NULL; t = t->next) for (d = t->globals.list; d != NULL; d = d->next) - if (!d->symver && !d->script) + if (d->literal && !d->symver && !d->script) { (*_bfd_error_handler) (_("%s: undefined version: %s"), diff --git a/include/ChangeLog b/include/ChangeLog index c6a6caef48..96c84746e2 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,9 @@ +2008-11-26 Alan Modra + + PR 7047 + * bfdlink.h (struct bfd_elf_version_expr): Delete "symbol". + Add "literal". + 2008-11-21 Sterling Augustine * xtensa-isa-internal.h (XTENSA_STATE_IS_SHARED_OR): New flag. diff --git a/include/bfdlink.h b/include/bfdlink.h index d27b5388d3..51c5b15cd6 100644 --- a/include/bfdlink.h +++ b/include/bfdlink.h @@ -707,8 +707,8 @@ struct bfd_elf_version_expr struct bfd_elf_version_expr *next; /* Glob pattern. */ const char *pattern; - /* NULL for a glob pattern, otherwise a straight symbol. */ - const char *symbol; + /* Set if pattern is not a glob. */ + unsigned int literal : 1; /* Defined by ".symver". */ unsigned int symver : 1; /* Defined by version script. */ -- 2.11.0