From 5e35cbc224bd9b78e4547073ca92b1fd85ad9301 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 24 Oct 2003 14:55:14 +0000 Subject: [PATCH] bfd/ 2003-10-24 H.J. Lu * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Look up hash table for real symbols. include/ 2003-10-24 H.J. Lu * bfdlink.h (bfd_elf_version_expr): Add "symbol" and remove "wildcard". ld/ 2003-10-24 H.J. Lu * ldlang.c (lang_vers_match): Check "symbol" instead of "wildcard" and "pattern". Fix a typo. (lang_finalize_version_expr_head): Likewise. (lang_register_vers_node): Likewise. (realsymbol): New function. (lang_new_vers_pattern): Set "symbol" and remove "wildcard". * ldlex.l (V_IDENTIFIER): Allow '\\'. --- bfd/ChangeLog | 5 +++ bfd/elflink.h | 6 ++-- include/ChangeLog | 5 +++ include/bfdlink.h | 4 +-- ld/ChangeLog | 11 ++++++ ld/ldlang.c | 92 ++++++++++++++++++++++++++++++++++------------- ld/ldlex.l | 2 +- 7 files changed, 94 insertions(+), 31 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 926b2a1bdd2..2c7c4cc481e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2003-10-24 H.J. Lu + + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Look up + hash table for real symbols. + 2003-10-23 Michael Snyder * section.c (asection): Fix typo in comment. diff --git a/bfd/elflink.h b/bfd/elflink.h index e53911df855..aa74573f7e0 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -2059,16 +2059,14 @@ NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd, /* Make all global versions with definiton. */ for (t = verdefs; t != NULL; t = t->next) for (d = t->globals.list; d != NULL; d = d->next) - /* FIXME: Shouldn't this be !d->symver && d->wildcard == 0 - instead? */ - if (!d->symver && strchr (d->pattern, '*') == NULL) + if (!d->symver && d->symbol) { const char *verstr, *name; size_t namelen, verlen, newlen; char *newname, *p; struct elf_link_hash_entry *newh; - name = d->pattern; + name = d->symbol; namelen = strlen (name); verstr = t->name; verlen = strlen (verstr); diff --git a/include/ChangeLog b/include/ChangeLog index cae750579d1..d523637d87f 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2003-10-24 H.J. Lu + + * bfdlink.h (bfd_elf_version_expr): Add "symbol" and remove + "wildcard". + 2003-10-22 Joseph S. Myers * obstack.h: Merge the following change from gnulib: diff --git a/include/bfdlink.h b/include/bfdlink.h index fd77c294442..75ea39d50f7 100644 --- a/include/bfdlink.h +++ b/include/bfdlink.h @@ -625,12 +625,12 @@ 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; /* Defined by ".symver". */ unsigned int symver : 1; /* Defined by version script. */ unsigned int script : 1; - /* Is this a wildcard?. */ - unsigned int wildcard : 1; /* Pattern type. */ #define BFD_ELF_VERSION_C_TYPE 1 #define BFD_ELF_VERSION_CXX_TYPE 2 diff --git a/ld/ChangeLog b/ld/ChangeLog index 287e28e78fa..a6dcf1cc56c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2003-10-24 H.J. Lu + + * ldlang.c (lang_vers_match): Check "symbol" instead of + "wildcard" and "pattern". Fix a typo. + (lang_finalize_version_expr_head): Likewise. + (lang_register_vers_node): Likewise. + (realsymbol): New function. + (lang_new_vers_pattern): Set "symbol" and remove "wildcard". + + * ldlex.l (V_IDENTIFIER): Allow '\\'. + 2003-10-24 Nick Clifton * emultempl/m68hc1xelf.em (before_allocation): Add missing second diff --git a/ld/ldlang.c b/ld/ldlang.c index b180edeb34a..e57f6f9eb69 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -5000,7 +5000,7 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, java_sym = sym; } - if (head->htab && (prev == NULL || prev->wildcard == 0)) + if (head->htab && (prev == NULL || prev->symbol)) { struct bfd_elf_version_expr e; @@ -5009,9 +5009,9 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, case 0: if (head->mask & BFD_ELF_VERSION_C_TYPE) { - e.pattern = sym; + e.symbol = sym; expr = htab_find (head->htab, &e); - while (expr && strcmp (expr->pattern, sym) == 0) + while (expr && strcmp (expr->symbol, sym) == 0) if (expr->mask == BFD_ELF_VERSION_C_TYPE) goto out_ret; else @@ -5021,9 +5021,9 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, case BFD_ELF_VERSION_C_TYPE: if (head->mask & BFD_ELF_VERSION_CXX_TYPE) { - e.pattern = cxx_sym; + e.symbol = cxx_sym; expr = htab_find (head->htab, &e); - while (expr && strcmp (expr->pattern, sym) == 0) + while (expr && strcmp (expr->symbol, sym) == 0) if (expr->mask == BFD_ELF_VERSION_CXX_TYPE) goto out_ret; else @@ -5033,9 +5033,9 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, case BFD_ELF_VERSION_CXX_TYPE: if (head->mask & BFD_ELF_VERSION_JAVA_TYPE) { - e.pattern = java_sym; + e.symbol = java_sym; expr = htab_find (head->htab, &e); - while (expr && strcmp (expr->pattern, sym) == 0) + while (expr && strcmp (expr->symbol, sym) == 0) if (expr->mask == BFD_ELF_VERSION_JAVA_TYPE) goto out_ret; else @@ -5048,7 +5048,7 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, } /* Finally, try the wildcards. */ - if (prev == NULL || prev->wildcard == 0) + if (prev == NULL || prev->symbol) expr = head->remaining; else expr = prev->next; @@ -5065,7 +5065,7 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, s = cxx_sym; else s = sym; - if (fnmatch (expr->pattern, sym, 0) == 0) + if (fnmatch (expr->pattern, s, 0) == 0) break; expr = expr->next; } @@ -5078,6 +5078,50 @@ out_ret: return expr; } +/* Return NULL if the PATTERN argument is a glob pattern, otherwise, + return a string pointing to the symbol name. */ + +static const char * +realsymbol (const char *pattern) +{ + const char *p; + bfd_boolean changed = FALSE, backslash = FALSE; + char *s, *symbol = xmalloc (strlen (pattern) + 1); + + for (p = pattern, s = symbol; *p != '\0'; ++p) + { + /* It is a glob pattern only if there is no preceding + backslash. */ + if (! backslash && (*p == '?' || *p == '*' || *p == '[')) + { + free (symbol); + return NULL; + } + + if (backslash) + { + /* Remove the preceding backslash. */ + *(s - 1) = *p; + changed = TRUE; + } + else + *s++ = *p; + + backslash = *p == '\\'; + } + + if (changed) + { + *s = '\0'; + return symbol; + } + else + { + free (symbol); + return pattern; + } +} + /* This is called for each variable name or match expression. */ struct bfd_elf_version_expr * @@ -5092,7 +5136,7 @@ lang_new_vers_pattern (struct bfd_elf_version_expr *orig, ret->pattern = new; ret->symver = 0; ret->script = 0; - ret->wildcard = wildcardp (new); + ret->symbol = realsymbol (new); if (lang == NULL || strcasecmp (lang, "C") == 0) ret->mask = BFD_ELF_VERSION_C_TYPE; @@ -5136,7 +5180,7 @@ version_expr_head_hash (const void *p) { const struct bfd_elf_version_expr *e = p; - return htab_hash_string (e->pattern); + return htab_hash_string (e->symbol); } static int @@ -5145,7 +5189,7 @@ version_expr_head_eq (const void *p1, const void *p2) const struct bfd_elf_version_expr *e1 = p1; const struct bfd_elf_version_expr *e2 = p2; - return strcmp (e1->pattern, e2->pattern) == 0; + return strcmp (e1->symbol, e2->symbol) == 0; } static void @@ -5157,7 +5201,7 @@ lang_finalize_version_expr_head (struct bfd_elf_version_expr_head *head) for (e = head->list; e; e = e->next) { - if (!e->wildcard) + if (e->symbol) count++; head->mask |= e->mask; } @@ -5171,7 +5215,7 @@ lang_finalize_version_expr_head (struct bfd_elf_version_expr_head *head) for (e = head->list; e; e = next) { next = e->next; - if (e->wildcard) + if (!e->symbol) { *remaining_loc = e; remaining_loc = &e->next; @@ -5196,14 +5240,14 @@ lang_finalize_version_expr_head (struct bfd_elf_version_expr_head *head) last = e1; e1 = e1->next; } - while (e1 && strcmp (e1->pattern, e->pattern) == 0); + while (e1 && strcmp (e1->symbol, e->symbol) == 0); if (last == NULL) { /* This is a duplicate. */ /* FIXME: Memory leak. Sometimes pattern is not xmalloced alone, but in larger chunk of memory. */ - /* free (e->pattern); */ + /* free (e->symbol); */ free (e); } else @@ -5266,18 +5310,18 @@ lang_register_vers_node (const char *name, { struct bfd_elf_version_expr *e2; - if (t->locals.htab && e1->wildcard == 0) + if (t->locals.htab && e1->symbol) { e2 = htab_find (t->locals.htab, e1); - while (e2 && strcmp (e1->pattern, e2->pattern) == 0) + while (e2 && strcmp (e1->symbol, e2->symbol) == 0) { if (e1->mask == e2->mask) einfo (_("%X%P: duplicate expression `%s' in version information\n"), - e1->pattern); + e1->symbol); e2 = e2->next; } } - else if (e1->wildcard) + else if (!e1->symbol) for (e2 = t->locals.remaining; e2 != NULL; e2 = e2->next) if (strcmp (e1->pattern, e2->pattern) == 0 && e1->mask == e2->mask) einfo (_("%X%P: duplicate expression `%s' in version information\n"), @@ -5291,18 +5335,18 @@ lang_register_vers_node (const char *name, { struct bfd_elf_version_expr *e2; - if (t->globals.htab && e1->wildcard == 0) + if (t->globals.htab && e1->symbol) { e2 = htab_find (t->globals.htab, e1); - while (e2 && strcmp (e1->pattern, e2->pattern) == 0) + while (e2 && strcmp (e1->symbol, e2->symbol) == 0) { if (e1->mask == e2->mask) einfo (_("%X%P: duplicate expression `%s' in version information\n"), - e1->pattern); + e1->symbol); e2 = e2->next; } } - else if (e1->wildcard) + else if (!e1->symbol) for (e2 = t->globals.remaining; e2 != NULL; e2 = e2->next) if (strcmp (e1->pattern, e2->pattern) == 0 && e1->mask == e2->mask) einfo (_("%X%P: duplicate expression `%s' in version information\n"), diff --git a/ld/ldlex.l b/ld/ldlex.l index b52e1cfd7be..aeac817c84f 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -113,7 +113,7 @@ WHITE [ \t\n\r]+ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] V_TAG [.$_a-zA-Z][._a-zA-Z0-9]* -V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^]([*?.$_a-zA-Z0-9\[\]\-\!\^]|::)* +V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* %s SCRIPT %s EXPRESSION -- 2.30.2