2003-10-24  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.h (NAME(bfd_elf,size_dynamic_sections)): Look up
	hash table for real symbols.

include/

2003-10-24  H.J. Lu  <hongjiu.lu@intel.com>

	* bfdlink.h (bfd_elf_version_expr): Add "symbol" and remove
	"wildcard".

ld/

2003-10-24  H.J. Lu  <hongjiu.lu@intel.com>

	* 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 '\\'.
This commit is contained in:
H.J. Lu 2003-10-24 14:55:14 +00:00
parent 383b84283a
commit 5e35cbc224
7 changed files with 94 additions and 31 deletions

View file

@ -1,3 +1,8 @@
2003-10-24 H.J. Lu <hongjiu.lu@intel.com>
* elflink.h (NAME(bfd_elf,size_dynamic_sections)): Look up
hash table for real symbols.
2003-10-23 Michael Snyder <msnyder@redhat.com> 2003-10-23 Michael Snyder <msnyder@redhat.com>
* section.c (asection): Fix typo in comment. * section.c (asection): Fix typo in comment.

View file

@ -2059,16 +2059,14 @@ NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd,
/* Make all global versions with definiton. */ /* Make all global versions with definiton. */
for (t = verdefs; t != NULL; t = t->next) for (t = verdefs; t != NULL; t = t->next)
for (d = t->globals.list; d != NULL; d = d->next) for (d = t->globals.list; d != NULL; d = d->next)
/* FIXME: Shouldn't this be !d->symver && d->wildcard == 0 if (!d->symver && d->symbol)
instead? */
if (!d->symver && strchr (d->pattern, '*') == NULL)
{ {
const char *verstr, *name; const char *verstr, *name;
size_t namelen, verlen, newlen; size_t namelen, verlen, newlen;
char *newname, *p; char *newname, *p;
struct elf_link_hash_entry *newh; struct elf_link_hash_entry *newh;
name = d->pattern; name = d->symbol;
namelen = strlen (name); namelen = strlen (name);
verstr = t->name; verstr = t->name;
verlen = strlen (verstr); verlen = strlen (verstr);

View file

@ -1,3 +1,8 @@
2003-10-24 H.J. Lu <hongjiu.lu@intel.com>
* bfdlink.h (bfd_elf_version_expr): Add "symbol" and remove
"wildcard".
2003-10-22 Joseph S. Myers <jsm@polyomino.org.uk> 2003-10-22 Joseph S. Myers <jsm@polyomino.org.uk>
* obstack.h: Merge the following change from gnulib: * obstack.h: Merge the following change from gnulib:

View file

@ -625,12 +625,12 @@ struct bfd_elf_version_expr
struct bfd_elf_version_expr *next; struct bfd_elf_version_expr *next;
/* Glob pattern. */ /* Glob pattern. */
const char *pattern; const char *pattern;
/* NULL for a glob pattern, otherwise a straight symbol. */
const char *symbol;
/* Defined by ".symver". */ /* Defined by ".symver". */
unsigned int symver : 1; unsigned int symver : 1;
/* Defined by version script. */ /* Defined by version script. */
unsigned int script : 1; unsigned int script : 1;
/* Is this a wildcard?. */
unsigned int wildcard : 1;
/* Pattern type. */ /* Pattern type. */
#define BFD_ELF_VERSION_C_TYPE 1 #define BFD_ELF_VERSION_C_TYPE 1
#define BFD_ELF_VERSION_CXX_TYPE 2 #define BFD_ELF_VERSION_CXX_TYPE 2

View file

@ -1,3 +1,14 @@
2003-10-24 H.J. Lu <hongjiu.lu@intel.com>
* 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 <nickc@redhat.com> 2003-10-24 Nick Clifton <nickc@redhat.com>
* emultempl/m68hc1xelf.em (before_allocation): Add missing second * emultempl/m68hc1xelf.em (before_allocation): Add missing second

View file

@ -5000,7 +5000,7 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
java_sym = sym; java_sym = sym;
} }
if (head->htab && (prev == NULL || prev->wildcard == 0)) if (head->htab && (prev == NULL || prev->symbol))
{ {
struct bfd_elf_version_expr e; struct bfd_elf_version_expr e;
@ -5009,9 +5009,9 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
case 0: case 0:
if (head->mask & BFD_ELF_VERSION_C_TYPE) if (head->mask & BFD_ELF_VERSION_C_TYPE)
{ {
e.pattern = sym; e.symbol = sym;
expr = htab_find (head->htab, &e); 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) if (expr->mask == BFD_ELF_VERSION_C_TYPE)
goto out_ret; goto out_ret;
else else
@ -5021,9 +5021,9 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
case BFD_ELF_VERSION_C_TYPE: case BFD_ELF_VERSION_C_TYPE:
if (head->mask & BFD_ELF_VERSION_CXX_TYPE) if (head->mask & BFD_ELF_VERSION_CXX_TYPE)
{ {
e.pattern = cxx_sym; e.symbol = cxx_sym;
expr = htab_find (head->htab, &e); 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) if (expr->mask == BFD_ELF_VERSION_CXX_TYPE)
goto out_ret; goto out_ret;
else else
@ -5033,9 +5033,9 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
case BFD_ELF_VERSION_CXX_TYPE: case BFD_ELF_VERSION_CXX_TYPE:
if (head->mask & BFD_ELF_VERSION_JAVA_TYPE) if (head->mask & BFD_ELF_VERSION_JAVA_TYPE)
{ {
e.pattern = java_sym; e.symbol = java_sym;
expr = htab_find (head->htab, &e); 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) if (expr->mask == BFD_ELF_VERSION_JAVA_TYPE)
goto out_ret; goto out_ret;
else else
@ -5048,7 +5048,7 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
} }
/* Finally, try the wildcards. */ /* Finally, try the wildcards. */
if (prev == NULL || prev->wildcard == 0) if (prev == NULL || prev->symbol)
expr = head->remaining; expr = head->remaining;
else else
expr = prev->next; expr = prev->next;
@ -5065,7 +5065,7 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
s = cxx_sym; s = cxx_sym;
else else
s = sym; s = sym;
if (fnmatch (expr->pattern, sym, 0) == 0) if (fnmatch (expr->pattern, s, 0) == 0)
break; break;
expr = expr->next; expr = expr->next;
} }
@ -5078,6 +5078,50 @@ out_ret:
return expr; 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. */ /* This is called for each variable name or match expression. */
struct bfd_elf_version_expr * struct bfd_elf_version_expr *
@ -5092,7 +5136,7 @@ lang_new_vers_pattern (struct bfd_elf_version_expr *orig,
ret->pattern = new; ret->pattern = new;
ret->symver = 0; ret->symver = 0;
ret->script = 0; ret->script = 0;
ret->wildcard = wildcardp (new); ret->symbol = realsymbol (new);
if (lang == NULL || strcasecmp (lang, "C") == 0) if (lang == NULL || strcasecmp (lang, "C") == 0)
ret->mask = BFD_ELF_VERSION_C_TYPE; 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; const struct bfd_elf_version_expr *e = p;
return htab_hash_string (e->pattern); return htab_hash_string (e->symbol);
} }
static int 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 *e1 = p1;
const struct bfd_elf_version_expr *e2 = p2; const struct bfd_elf_version_expr *e2 = p2;
return strcmp (e1->pattern, e2->pattern) == 0; return strcmp (e1->symbol, e2->symbol) == 0;
} }
static void 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) for (e = head->list; e; e = e->next)
{ {
if (!e->wildcard) if (e->symbol)
count++; count++;
head->mask |= e->mask; 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) for (e = head->list; e; e = next)
{ {
next = e->next; next = e->next;
if (e->wildcard) if (!e->symbol)
{ {
*remaining_loc = e; *remaining_loc = e;
remaining_loc = &e->next; remaining_loc = &e->next;
@ -5196,14 +5240,14 @@ lang_finalize_version_expr_head (struct bfd_elf_version_expr_head *head)
last = e1; last = e1;
e1 = e1->next; e1 = e1->next;
} }
while (e1 && strcmp (e1->pattern, e->pattern) == 0); while (e1 && strcmp (e1->symbol, e->symbol) == 0);
if (last == NULL) if (last == NULL)
{ {
/* This is a duplicate. */ /* This is a duplicate. */
/* FIXME: Memory leak. Sometimes pattern is not /* FIXME: Memory leak. Sometimes pattern is not
xmalloced alone, but in larger chunk of memory. */ xmalloced alone, but in larger chunk of memory. */
/* free (e->pattern); */ /* free (e->symbol); */
free (e); free (e);
} }
else else
@ -5266,18 +5310,18 @@ lang_register_vers_node (const char *name,
{ {
struct bfd_elf_version_expr *e2; 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); 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) if (e1->mask == e2->mask)
einfo (_("%X%P: duplicate expression `%s' in version information\n"), einfo (_("%X%P: duplicate expression `%s' in version information\n"),
e1->pattern); e1->symbol);
e2 = e2->next; e2 = e2->next;
} }
} }
else if (e1->wildcard) else if (!e1->symbol)
for (e2 = t->locals.remaining; e2 != NULL; e2 = e2->next) for (e2 = t->locals.remaining; e2 != NULL; e2 = e2->next)
if (strcmp (e1->pattern, e2->pattern) == 0 && e1->mask == e2->mask) if (strcmp (e1->pattern, e2->pattern) == 0 && e1->mask == e2->mask)
einfo (_("%X%P: duplicate expression `%s' in version information\n"), 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; 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); 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) if (e1->mask == e2->mask)
einfo (_("%X%P: duplicate expression `%s' in version information\n"), einfo (_("%X%P: duplicate expression `%s' in version information\n"),
e1->pattern); e1->symbol);
e2 = e2->next; e2 = e2->next;
} }
} }
else if (e1->wildcard) else if (!e1->symbol)
for (e2 = t->globals.remaining; e2 != NULL; e2 = e2->next) for (e2 = t->globals.remaining; e2 != NULL; e2 = e2->next)
if (strcmp (e1->pattern, e2->pattern) == 0 && e1->mask == e2->mask) if (strcmp (e1->pattern, e2->pattern) == 0 && e1->mask == e2->mask)
einfo (_("%X%P: duplicate expression `%s' in version information\n"), einfo (_("%X%P: duplicate expression `%s' in version information\n"),

View file

@ -113,7 +113,7 @@ WHITE [ \t\n\r]+
NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
V_TAG [.$_a-zA-Z][._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 SCRIPT
%s EXPRESSION %s EXPRESSION