diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-11-25 16:14:13 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-11-25 16:14:29 -0800 |
commit | 58349d00f461904f20dae88d48c1fda11cbb47bc (patch) | |
tree | abac11dad512c2375cb95d025c470b7e2099f833 /bfd | |
parent | 93bbe484a4fd41832383d4d781140d8cb5b18e76 (diff) | |
download | gdb-58349d00f461904f20dae88d48c1fda11cbb47bc.zip gdb-58349d00f461904f20dae88d48c1fda11cbb47bc.tar.gz gdb-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')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elflink.c | 19 |
2 files changed, 21 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d47d518..eeb0b81 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-11-25 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/26936 + * elflink.c (_bfd_elf_check_kept_section): Get the real kept + section. + 2020-11-23 Nick Clifton <nickc@redhat.com> PR 26931 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; |