This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Properly handle zero group count


objcopy may create a .o file with SHF_GROUP sections without section
group. objdump will fail to work on the bad .o file. This patch fixes
the bug in setup_group to properly handle zero group count.


H.J.
----
2005-04-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR 855
	* elf.c (setup_group): Properly handle zero group count.

--- bfd/elf.c.bad	2005-04-16 15:00:57.000000000 -0700
+++ bfd/elf.c	2005-04-16 14:55:12.000000000 -0700
@@ -481,14 +481,18 @@ setup_group (bfd *abfd, Elf_Internal_Shd
 	}
 
       if (num_group == 0)
-	num_group = (unsigned) -1;
-      elf_tdata (abfd)->num_group = num_group;
-
-      if (num_group > 0)
+	{
+	  num_group = (unsigned) -1;
+	  elf_tdata (abfd)->num_group = num_group;
+	}
+      else
 	{
 	  /* We keep a list of elf section headers for group sections,
 	     so we can find them quickly.  */
-	  bfd_size_type amt = num_group * sizeof (Elf_Internal_Shdr *);
+	  bfd_size_type amt;
+	  
+	  elf_tdata (abfd)->num_group = num_group;
+	  amt = num_group * sizeof (Elf_Internal_Shdr *);
 	  elf_tdata (abfd)->group_sect_ptr = bfd_alloc (abfd, amt);
 	  if (elf_tdata (abfd)->group_sect_ptr == NULL)
 	    return FALSE;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]