aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-11-25 16:14:13 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-11-25 16:14:29 -0800
commit58349d00f461904f20dae88d48c1fda11cbb47bc (patch)
treeabac11dad512c2375cb95d025c470b7e2099f833 /bfd/elflink.c
parent93bbe484a4fd41832383d4d781140d8cb5b18e76 (diff)
downloadbinutils-58349d00f461904f20dae88d48c1fda11cbb47bc.zip
binutils-58349d00f461904f20dae88d48c1fda11cbb47bc.tar.gz
binutils-58349d00f461904f20dae88d48c1fda11cbb47bc.tar.bz2
elf: Get the real kept section
When mixing linkonce and comdat sections, we need to keep searching to get the real kept section. bfd/ PR ld/26936 * elflink.c (_bfd_elf_check_kept_section): Get the real kept section. ld/ PR ld/26936 * testsuite/ld-elf/pr26936.d: New file. * testsuite/ld-elf/pr26936a.s: Likewise. * testsuite/ld-elf/pr26936b.s: Likewise. * testsuite/ld-elf/pr26936c.s: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7ba667a..0fbebca 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -10698,10 +10698,21 @@ _bfd_elf_check_kept_section (asection *sec, struct bfd_link_info *info)
{
if ((kept->flags & SEC_GROUP) != 0)
kept = match_group_member (sec, kept, info);
- if (kept != NULL
- && ((sec->rawsize != 0 ? sec->rawsize : sec->size)
- != (kept->rawsize != 0 ? kept->rawsize : kept->size)))
- kept = NULL;
+ if (kept != NULL)
+ {
+ if ((sec->rawsize != 0 ? sec->rawsize : sec->size)
+ != (kept->rawsize != 0 ? kept->rawsize : kept->size))
+ kept = NULL;
+ else
+ {
+ /* Get the real kept section. */
+ asection *next;
+ for (next = kept->kept_section;
+ next != NULL;
+ next = next->kept_section)
+ kept = next;
+ }
+ }
sec->kept_section = kept;
}
return kept;