aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-09-16 01:15:20 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-09-16 01:15:20 +0000
commitfd91d41947667d30f47b06c45cc57d4b4fcefade (patch)
treeda3232e7e4e059d4c297068470cab17acc047a84 /ld
parentd0bc107f79526a1e11682f4633b8c9e467d654b0 (diff)
downloadgdb-fd91d41947667d30f47b06c45cc57d4b4fcefade.zip
gdb-fd91d41947667d30f47b06c45cc57d4b4fcefade.tar.gz
gdb-fd91d41947667d30f47b06c45cc57d4b4fcefade.tar.bz2
Check if a symbol is hidden by linker script.
bfd/ 2011-09-15 H.J. Lu <hongjiu.lu@intel.com> PR ld/12975 * bfd-in.h (bfd_elf_size_dynamic_sections): Remove pointer to struct bfd_elf_version_tree. * elflink.c (elf_info_failed): Remove verdefs. (_bfd_elf_export_symbol): Updated. _bfd_elf_link_assign_sym_version): Likewise. (bfd_elf_size_dynamic_sections): Remove pointer to struct bfd_elf_version_tree. Updated. (bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is hidden by linker script. * linker.c (bfd_hide_sym_by_version): New. * bfd-in2.h: Regenerated. include/ 2011-09-15 H.J. Lu <hongjiu.lu@intel.com> PR ld/12975 * bfdlink.h (bfd_link_info): Add version_info. ld/ 2011-09-15 H.J. Lu <hongjiu.lu@intel.com> PR ld/12975 * ldlang.c (lang_elf_version_info): Removed. (lang_register_vers_node): Replace lang_elf_version_info with link_info.version_info. (lang_add_vers_depend): Likewise. * pe-dll.c (process_def_file_and_drectve): Likewise. * emultempl/solaris2.em (elf_solaris2_before_allocation): Likewise. * ldlang.h (lang_elf_version_info): Removed. * plugin.c (is_visible_from_outside): Check if symbol is hidden by version script. * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Remove lang_elf_version_info. ld/testsuite/ 2011-09-15 H.J. Lu <hongjiu.lu@intel.com> PR ld/12975 * ld-elf/pr12975.d: New. * ld-elf/pr12975.s: Likewise. * ld-elf/pr12975.t: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog18
-rw-r--r--ld/emultempl/elf32.em2
-rw-r--r--ld/emultempl/solaris2.em3
-rw-r--r--ld/ldlang.c18
-rw-r--r--ld/ldlang.h2
-rw-r--r--ld/pe-dll.c11
-rw-r--r--ld/plugin.c4
-rw-r--r--ld/testsuite/ChangeLog7
-rw-r--r--ld/testsuite/ld-elf/pr12975.d10
-rw-r--r--ld/testsuite/ld-elf/pr12975.s10
-rw-r--r--ld/testsuite/ld-elf/pr12975.t6
11 files changed, 69 insertions, 22 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 99ef7b1..cafca0e 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,21 @@
+2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/12975
+ * ldlang.c (lang_elf_version_info): Removed.
+ (lang_register_vers_node): Replace lang_elf_version_info with
+ link_info.version_info.
+ (lang_add_vers_depend): Likewise.
+ * pe-dll.c (process_def_file_and_drectve): Likewise.
+ * emultempl/solaris2.em (elf_solaris2_before_allocation): Likewise.
+
+ * ldlang.h (lang_elf_version_info): Removed.
+
+ * plugin.c (is_visible_from_outside): Check if symbol is hidden
+ by version script.
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
+ Remove lang_elf_version_info.
+
2011-09-15 Dmitry Gorbachev <d.g.gorbachev@gmail.com>
PR ld/13183
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 9bc363f..7c8e55b 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1535,7 +1535,7 @@ gld${EMULATION_NAME}_before_allocation (void)
(link_info.output_bfd, command_line.soname, rpath,
command_line.filter_shlib, audit, depaudit,
(const char * const *) command_line.auxiliary_filters,
- &link_info, &sinterp, lang_elf_version_info)))
+ &link_info, &sinterp)))
einfo ("%P%F: failed to set dynamic section sizes: %E\n");
${ELF_INTERPRETER_SET_DEFAULT}
diff --git a/ld/emultempl/solaris2.em b/ld/emultempl/solaris2.em
index 0b77375..2c24467 100644
--- a/ld/emultempl/solaris2.em
+++ b/ld/emultempl/solaris2.em
@@ -76,7 +76,8 @@ elf_solaris2_before_allocation (void)
/* Only do this if emitting a shared object and versioning is in place. */
if (link_info.shared
- && (lang_elf_version_info != NULL || link_info.create_default_symver))
+ && (link_info.version_info != NULL
+ || link_info.create_default_symver))
{
struct bfd_elf_version_expr *globals = NULL, *locals = NULL;
struct bfd_elf_version_tree *basever;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 5b548d0..7251a86 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7458,10 +7458,6 @@ lang_leave_overlay (etree_type *lma_expr,
/* Version handling. This is only useful for ELF. */
-/* This global variable holds the version tree that we build. */
-
-struct bfd_elf_version_tree *lang_elf_version_info;
-
/* If PREV is NULL, return first version pattern matching particular symbol.
If PREV is non-NULL, return first version pattern matching particular
symbol after PREV (previously returned by lang_vers_match). */
@@ -7803,8 +7799,8 @@ lang_register_vers_node (const char *name,
if (name == NULL)
name = "";
- if ((name[0] == '\0' && lang_elf_version_info != NULL)
- || (lang_elf_version_info && lang_elf_version_info->name[0] == '\0'))
+ if (link_info.version_info != NULL
+ && (name[0] == '\0' || link_info.version_info->name[0] == '\0'))
{
einfo (_("%X%P: anonymous version tag cannot be combined"
" with other version tags\n"));
@@ -7813,7 +7809,7 @@ lang_register_vers_node (const char *name,
}
/* Make sure this node has a unique name. */
- for (t = lang_elf_version_info; t != NULL; t = t->next)
+ for (t = link_info.version_info; t != NULL; t = t->next)
if (strcmp (t->name, name) == 0)
einfo (_("%X%P: duplicate version tag `%s'\n"), name);
@@ -7825,7 +7821,7 @@ lang_register_vers_node (const char *name,
for (e1 = version->globals.list; e1 != NULL; e1 = e1->next)
{
- for (t = lang_elf_version_info; t != NULL; t = t->next)
+ for (t = link_info.version_info; t != NULL; t = t->next)
{
struct bfd_elf_version_expr *e2;
@@ -7852,7 +7848,7 @@ lang_register_vers_node (const char *name,
for (e1 = version->locals.list; e1 != NULL; e1 = e1->next)
{
- for (t = lang_elf_version_info; t != NULL; t = t->next)
+ for (t = link_info.version_info; t != NULL; t = t->next)
{
struct bfd_elf_version_expr *e2;
@@ -7888,7 +7884,7 @@ lang_register_vers_node (const char *name,
else
version->vernum = 0;
- for (pp = &lang_elf_version_info; *pp != NULL; pp = &(*pp)->next)
+ for (pp = &link_info.version_info; *pp != NULL; pp = &(*pp)->next)
;
*pp = version;
}
@@ -7904,7 +7900,7 @@ lang_add_vers_depend (struct bfd_elf_version_deps *list, const char *name)
ret = (struct bfd_elf_version_deps *) xmalloc (sizeof *ret);
ret->next = list;
- for (t = lang_elf_version_info; t != NULL; t = t->next)
+ for (t = link_info.version_info; t != NULL; t = t->next)
{
if (strcmp (t->name, name) == 0)
{
diff --git a/ld/ldlang.h b/ld/ldlang.h
index a6d22ce..533fe74 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -628,8 +628,6 @@ extern void lang_leave_overlay
(etree_type *, int, fill_type *, const char *,
lang_output_section_phdr_list *, const char *);
-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 *, bfd_boolean);
extern struct bfd_elf_version_tree *lang_new_vers_node
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 682ce46..7848063 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -718,13 +718,10 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
bfd_boolean would_export = symbols[j]->section != &bfd_und_section
&& ((symbols[j]->flags & BSF_GLOBAL)
|| (symbols[j]->flags == 0));
- if (lang_elf_version_info && would_export)
- {
- bfd_boolean hide = 0;
- (void) bfd_find_version_for_sym (lang_elf_version_info,
- symbols[j]->name, &hide);
- would_export = !hide;
- }
+ if (link_info.version_info && would_export)
+ would_export
+ = !bfd_hide_sym_by_version (link_info.version_info,
+ symbols[j]->name);
if (would_export)
{
const char *sn = symbols[j]->name;
diff --git a/ld/plugin.c b/ld/plugin.c
index 0be7fa3a..b172111 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -454,6 +454,10 @@ is_visible_from_outside (struct ld_plugin_symbol *lsym, asection *section,
return TRUE;
if (link_info.export_dynamic || link_info.shared)
{
+ /* Check if symbol is hidden by version script. */
+ if (bfd_hide_sym_by_version (link_info.version_info,
+ blhe->root.string))
+ return FALSE;
/* Only ELF symbols really have visibility. */
if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour)
{
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 3c00fe4..7a90b26 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/12975
+ * ld-elf/pr12975.d: New.
+ * ld-elf/pr12975.s: Likewise.
+ * ld-elf/pr12975.t: Likewise.
+
2011-09-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/13178
diff --git a/ld/testsuite/ld-elf/pr12975.d b/ld/testsuite/ld-elf/pr12975.d
new file mode 100644
index 0000000..549e8d5
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr12975.d
@@ -0,0 +1,10 @@
+#ld: --gc-sections -shared -version-script pr12975.t
+#readelf: -s --wide
+#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-*
+#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+# generic linker targets don't support --gc-sections, nor do a bunch of others
+
+#failif
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +LOCAL +DEFAULT +[1-9]+ bar
+#...
diff --git a/ld/testsuite/ld-elf/pr12975.s b/ld/testsuite/ld-elf/pr12975.s
new file mode 100644
index 0000000..7429121
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr12975.s
@@ -0,0 +1,10 @@
+ .section .text.foo,"ax",%progbits
+ .globl foo
+ .type foo, %function
+foo:
+ .byte 0
+ .section .text.bar,"ax",%progbits
+ .type bar, %function
+ .globl bar
+bar:
+ .byte 0
diff --git a/ld/testsuite/ld-elf/pr12975.t b/ld/testsuite/ld-elf/pr12975.t
new file mode 100644
index 0000000..902c1f7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr12975.t
@@ -0,0 +1,6 @@
+{
+global:
+ foo;
+local:
+ *;
+};