[PATCH] elf: Keep zero-sized relocation section in section group

H.J. Lu hjl.tools@gmail.com
Fri Apr 3 03:41:18 GMT 2020


We must keep zero-sized relocation section in a section group.  Otherwise,
the relocation section will be missing from the section group.

	PR ld/25767
	* elflink.c (bfd_elf_final_link): Keep zero-sized relocation
	section in section group.
---
 bfd/elflink.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7c0849423a..3b29cc127a 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12058,11 +12058,15 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
 
       if (o->reloc_count > 0)
 	o->flags |= SEC_RELOC;
-      else
+      else if (info->resolve_section_groups || !elf_group_name (o))
 	{
 	  /* Explicitly clear the SEC_RELOC flag.  The linker tends to
 	     set it (this is probably a bug) and if it is set
-	     assign_section_numbers will create a reloc section.  */
+	     assign_section_numbers will create a reloc section.
+
+	     PR ld/25767: We must keep zero-sized relocation section
+	     in a section group.  Otherwise, that relocation section
+	     will be missing from the section group.  */
 	  o->flags &=~ SEC_RELOC;
 	}
 
-- 
2.25.1




More information about the Binutils mailing list