diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-04-03 19:06:29 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-04-03 19:06:39 -0700 |
commit | 3349112e380712432d5818154d67ab4660af056f (patch) | |
tree | 04ce7cebccd34983b3ae6545ffd161eba5e26c33 /bfd/elf.c | |
parent | 2612e26d4de95531627016c596fbc90d4517906c (diff) | |
download | gdb-3349112e380712432d5818154d67ab4660af056f.zip gdb-3349112e380712432d5818154d67ab4660af056f.tar.gz gdb-3349112e380712432d5818154d67ab4660af056f.tar.bz2 |
elf: Remove zero-sized relocation section from section group
Remove zero-sized relocation section from a section group since it has
been removed from the output.
PR ld/25767
* elf.c (_bfd_elf_fixup_group_sections): Remove zero-sized
relocation section from section group.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -7929,19 +7929,34 @@ _bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded) elf_section_flags (s->output_section) &= ~SHF_GROUP; elf_group_name (s->output_section) = NULL; } - /* Conversely, if the member section is not being output - but the SHT_GROUP section is, then adjust its size. */ - else if (s->output_section == discarded - && isec->output_section != discarded) + else { struct bfd_elf_section_data *elf_sec = elf_section_data (s); - removed += 4; - if (elf_sec->rel.hdr != NULL - && (elf_sec->rel.hdr->sh_flags & SHF_GROUP) != 0) - removed += 4; - if (elf_sec->rela.hdr != NULL - && (elf_sec->rela.hdr->sh_flags & SHF_GROUP) != 0) - removed += 4; + if (s->output_section == discarded + && isec->output_section != discarded) + { + /* Conversely, if the member section is not being + output but the SHT_GROUP section is, then adjust + its size. */ + removed += 4; + if (elf_sec->rel.hdr != NULL + && (elf_sec->rel.hdr->sh_flags & SHF_GROUP) != 0) + removed += 4; + if (elf_sec->rela.hdr != NULL + && (elf_sec->rela.hdr->sh_flags & SHF_GROUP) != 0) + removed += 4; + } + else + { + /* Also adjust for zero-sized relocation member + section. */ + if (elf_sec->rel.hdr != NULL + && elf_sec->rel.hdr->sh_size == 0) + removed += 4; + if (elf_sec->rela.hdr != NULL + && elf_sec->rela.hdr->sh_size == 0) + removed += 4; + } } s = elf_next_in_group (s); if (s == first) |