nodes.
* ldlang.h (lang_new_vers_pattern): Add literal_p parameter.
* ldgram.y (vers_defns): Allow NAME as well as VERS_IDENTIFIER.
Adjust calls to lang_new_vers_pattern to pass literal_p argument.
* ldlang.c (lang_vers_match): Fix indentation. Do not glob-match
version nodes without a pattern.
(lang_new_vers_pattern): Add literal_p parameter.
(lang_do_version_exports_section): Pass it.
* ld-elfvers/vers.exp: Add vers31.
* ld-elfvers/vers31.c: New file.
* ld-elfvers/vers31.dsym: Likewise.
* ld-elfvers/vers31.map: Likewise.
* ld-elfvers/vers31.ver: Likewise.
+2005-10-13 Mark Mitchell <mark@codesourcery.com>
+
+ * ld.texino: Describe double-quoted string syntax for version
+ nodes.
+ * ldlang.h (lang_new_vers_pattern): Add literal_p parameter.
+ * ldgram.y (vers_defns): Allow NAME as well as VERS_IDENTIFIER.
+ Adjust calls to lang_new_vers_pattern to pass literal_p argument.
+ * ldlang.c (lang_vers_match): Fix indentation. Do not glob-match
+ version nodes without a pattern.
+ (lang_new_vers_pattern): Add literal_p parameter.
+ (lang_do_version_exports_section): Pass it.
+
2005-10-12 Mark Mitchell <mark@codesourcery.com>
* NEWS: Mention @file.
VERS_2.0 @{
bar1; bar2;
+ extern "C++" @{
+ ns::*;
+ "int f(int, double)";
+ @}
@} VERS_1.2;
@end smallexample
symbol whose name begins with @samp{old}, @samp{original}, or @samp{new}
is matched. The wildcard patterns available are the same as those used
in the shell when matching filenames (also known as ``globbing'').
+However, if you specify the symbol name inside double quotes, then the
+name is treated as literal, rather than as a glob pattern.
Next, the version script defines node @samp{VERS_1.2}. This node
depends upon @samp{VERS_1.1}. The script binds the symbol @samp{foo2}
demangle them according to @samp{lang} before matching them to the
patterns specified in @samp{version-script-commands}.
+Demangled names may contains spaces and other special characters. As
+described above, you can use a glob pattern to match demangled names,
+or you can use a double-quoted string to match the string exactly. In
+the latter case, be aware that minor differences (such as differing
+whitespace) between the version script and the demangler output will
+cause a mismatch. As the exact string generated by the demangler
+might change in the future, even if the mangled name does not, you
+should check that all of your version directives are behaving as you
+expect when you upgrade.
+
@node Expressions
@section Expressions in Linker Scripts
@cindex expressions
vers_defns:
VERS_IDENTIFIER
{
- $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE);
+ }
+ | NAME
+ {
+ $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE);
}
| vers_defns ';' VERS_IDENTIFIER
{
- $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE);
+ }
+ | vers_defns ';' NAME
+ {
+ $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE);
}
| vers_defns ';' EXTERN NAME '{'
{
}
| GLOBAL
{
- $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE);
}
| vers_defns ';' GLOBAL
{
- $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE);
}
| LOCAL
{
- $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE);
}
| vers_defns ';' LOCAL
{
- $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE);
}
| EXTERN
{
- $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE);
}
| vers_defns ';' EXTERN
{
- $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE);
}
;
while (expr && strcmp (expr->symbol, sym) == 0)
if (expr->mask == BFD_ELF_VERSION_C_TYPE)
goto out_ret;
- else
- expr = expr->next;
+ else
+ expr = expr->next;
}
/* Fallthrough */
case BFD_ELF_VERSION_C_TYPE:
while (expr && strcmp (expr->symbol, cxx_sym) == 0)
if (expr->mask == BFD_ELF_VERSION_CXX_TYPE)
goto out_ret;
- else
- expr = expr->next;
+ else
+ expr = expr->next;
}
/* Fallthrough */
case BFD_ELF_VERSION_CXX_TYPE:
while (expr && strcmp (expr->symbol, java_sym) == 0)
if (expr->mask == BFD_ELF_VERSION_JAVA_TYPE)
goto out_ret;
- else
- expr = expr->next;
+ else
+ expr = expr->next;
}
/* Fallthrough */
default:
expr = head->remaining;
else
expr = prev->next;
- while (expr)
+ for (; expr; expr = expr->next)
{
const char *s;
+ if (!expr->pattern)
+ continue;
+
if (expr->pattern[0] == '*' && expr->pattern[1] == '\0')
break;
s = sym;
if (fnmatch (expr->pattern, s, 0) == 0)
break;
- expr = expr->next;
}
out_ret:
}
}
-/* This is called for each variable name or match expression. */
+/* This is called for each variable name or match expression. NEW is
+ the name of the symbol to match, or, if LITERAL_P is FALSE, a glob
+ pattern to be matched against symbol names. */
struct bfd_elf_version_expr *
lang_new_vers_pattern (struct bfd_elf_version_expr *orig,
const char *new,
- const char *lang)
+ const char *lang,
+ bfd_boolean literal_p)
{
struct bfd_elf_version_expr *ret;
ret = xmalloc (sizeof *ret);
ret->next = orig;
- ret->pattern = new;
+ ret->pattern = literal_p ? NULL : new;
ret->symver = 0;
ret->script = 0;
- ret->symbol = realsymbol (new);
+ ret->symbol = literal_p ? new : realsymbol (new);
if (lang == NULL || strcasecmp (lang, "C") == 0)
ret->mask = BFD_ELF_VERSION_C_TYPE;
p = contents;
while (p < contents + len)
{
- greg = lang_new_vers_pattern (greg, p, NULL);
+ greg = lang_new_vers_pattern (greg, p, NULL, FALSE);
p = strchr (p, '\0') + 1;
}
sec->flags |= SEC_EXCLUDE;
}
- lreg = lang_new_vers_pattern (NULL, "*", NULL);
+ lreg = lang_new_vers_pattern (NULL, "*", NULL, FALSE);
lang_register_vers_node (command_line.version_exports_section,
lang_new_vers_node (greg, lreg), NULL);
}
extern struct bfd_elf_version_tree *lang_elf_version_info;
extern struct bfd_elf_version_expr *lang_new_vers_pattern
- (struct bfd_elf_version_expr *, const char *, const char *);
+ (struct bfd_elf_version_expr *, const char *, const char *, bfd_boolean);
extern struct bfd_elf_version_tree *lang_new_vers_node
(struct bfd_elf_version_expr *, struct bfd_elf_version_expr *);
extern struct bfd_elf_version_deps *lang_add_vers_depend
+2005-10-13 Mark Mitchell <mark@codesourcery.com>
+
+ * ld-elfvers/vers.exp: Add vers31.
+ * ld-elfvers/vers31.c: New file.
+ * ld-elfvers/vers31.dsym: Likewise.
+ * ld-elfvers/vers31.map: Likewise.
+ * ld-elfvers/vers31.ver: Likewise.
+
2005-10-08 Paul Brook <paul@codesourcery.com>
* ld-arm/arm-rel31.d: Ignore Arm object attribute sections.
# Test #30 - test handling of symbol names global, local and extern in the
# version script.
build_vers_lib_pic "vers30" vers30.c vers30 "" vers30.map vers30.ver vers30.dsym ""
+
+# Test #31 -- quoted strings in version sections.
+build_vers_lib_pic "vers31" vers31.c vers31 "" vers31.map vers31.ver vers31.dsym ""
--- /dev/null
+/* void f<int [3], char>(int (*) [3], char) */
+void _Z1fIA3_icEvPT_T0_() {}
+
+/* void f<double [3], long>(double (*) [3], long) */
+void _Z1fIA3_dlEvPT_T0_() {}
+
--- /dev/null
+[0]* g DO \*ABS\* [0]* VERS_31.0 VERS_31.0
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_31.0 _Z1fIA3_icEvPT_T0
--- /dev/null
+VERS_31.0 {
+ extern "C++" {
+ "void f<int [3], char>(int (*) [3], char)";
+ };
+};
--- /dev/null
+Version definitions:
+1 0x01 0x0966595f vers31.so
+2 0x00 0x07923ab0 VERS_31.0