aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-02-02 15:05:14 +1030
committerAlan Modra <amodra@gmail.com>2021-02-02 20:09:42 +1030
commit9918bff7cf2a566aaa2036d2242a61c140652dc7 (patch)
treeb2498f984c21d1aa2ef837e1dab0e281fd392a43 /bfd
parent2bd3e4b8d2580839a457e221d4e1e09105248215 (diff)
downloadgdb-9918bff7cf2a566aaa2036d2242a61c140652dc7.zip
gdb-9918bff7cf2a566aaa2036d2242a61c140652dc7.tar.gz
gdb-9918bff7cf2a566aaa2036d2242a61c140652dc7.tar.bz2
PR27311, ld.bfd (symbol from plugin): undefined reference
A default versioned symbol definition in a shared library is overridden by an unversioned definition in a regular object file, and thus should not be reason to make an as-needed library needed. bfd/ PR 27311 * elflink.c (_bfd_elf_add_default_symbol): Add override parameter. Use when handling default versioned symbol. Rename existing override variable to nondef_override and use for non-default versioned symbol. (elf_link_add_object_symbols): Adjust call to suit. Don't pull in as-needed libraries when override is set. ld/ * testsuite/ld-plugin/pr27311.d, * testsuite/ld-plugin/pr27311.ver, * testsuite/ld-plugin/pr27311a.c, * testsuite/ld-plugin/pr27311b.c, * testsuite/ld-plugin/pr27311c.c: New testcase. * testsuite/ld-plugin/lto.exp: Run it. Correct PR14918 and PR12982 entries.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elflink.c17
2 files changed, 20 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e0fa5a3..d65c56d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2021-02-02 Alan Modra <amodra@gmail.com>
+
+ PR 27311
+ * elflink.c (_bfd_elf_add_default_symbol): Add override parameter.
+ Use when handling default versioned symbol. Rename existing
+ override variable to nondef_override and use for non-default
+ versioned symbol.
+ (elf_link_add_object_symbols): Adjust call to suit. Don't
+ pull in as-needed libraries when override is set.
+
2021-02-01 Emery Hemingway <ehmry@posteo.net>
* config.bfd: Add *-*-genode* as a target for AArch64 and x86.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 3a3ca3b..7ac38ca 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1850,7 +1850,8 @@ _bfd_elf_add_default_symbol (bfd *abfd,
asection *sec,
bfd_vma value,
bfd **poldbfd,
- bfd_boolean *dynsym)
+ bfd_boolean *dynsym,
+ bfd **override)
{
bfd_boolean type_change_ok;
bfd_boolean size_change_ok;
@@ -1861,7 +1862,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
const struct elf_backend_data *bed;
bfd_boolean collect;
bfd_boolean dynamic;
- bfd *override;
+ bfd *nondef_override;
char *p;
size_t len, shortlen;
asection *tmp_sec;
@@ -1921,7 +1922,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
matched = TRUE;
tmp_sec = sec;
if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
- &hi, poldbfd, NULL, NULL, &skip, &override,
+ &hi, poldbfd, NULL, NULL, &skip, override,
&type_change_ok, &size_change_ok, &matched))
return FALSE;
@@ -1953,7 +1954,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
goto nondefault;
}
- if (! override)
+ if (!*override)
{
/* Add the default symbol if not performing a relocatable link. */
if (! bfd_link_relocatable (info))
@@ -2080,7 +2081,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
size_change_ok = FALSE;
tmp_sec = sec;
if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
- &hi, poldbfd, NULL, NULL, &skip, &override,
+ &hi, poldbfd, NULL, NULL, &skip, &nondef_override,
&type_change_ok, &size_change_ok, &matched))
return FALSE;
@@ -2104,7 +2105,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
else
return TRUE;
}
- else if (override)
+ else if (nondef_override)
{
/* Here SHORTNAME is a versioned name, so we don't expect to see
the type of override we do in the case above unless it is
@@ -5089,7 +5090,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
&& !(hi != h
&& hi->versioned == versioned_hidden))
if (!_bfd_elf_add_default_symbol (abfd, info, h, name, isym,
- sec, value, &old_bfd, &dynsym))
+ sec, value, &old_bfd, &dynsym,
+ &override))
goto error_free_vers;
/* Check the alignment when a common symbol is involved. This
@@ -5272,6 +5274,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
}
if (!add_needed
+ && !override
&& matched
&& definition
&& ((dynsym