This is the mail archive of the binutils@sourceware.org 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]

Re: Make asection->id and asection->index unsigned


On Mon, Aug 31, 2015 at 01:50:14PM +0930, Alan Modra wrote:
> These int vars are really unsigned, so make them so.
> 
> 	* section.c (struct bfd_section): Make "id" and "index" unsigned.

Apparently the gdb build-bot compiler is more fussy than mine, but
just as well, as it made be check over bfd usage of section->id and
section->index again.  That let to discovering a place in elflink.c
using the wrong type.

	* elflink.c (elf_sort_symbol): Use correctly sized type for
	calculating signed section->id difference.
	(elf_link_add_object_symbols): Likewise.
	* pef.c (bfd_pef_scan_start_address): Warning fix.
	* vms-alpha.c (vms_new_section_hook): Likewise.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 192ce15..4f86700 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3247,7 +3247,7 @@ elf_sort_symbol (const void *arg1, const void *arg2)
     return vdiff > 0 ? 1 : -1;
   else
     {
-      long sdiff = h1->root.u.def.section->id - h2->root.u.def.section->id;
+      int sdiff = h1->root.u.def.section->id - h2->root.u.def.section->id;
       if (sdiff != 0)
 	return sdiff > 0 ? 1 : -1;
     }
@@ -4830,7 +4830,7 @@ error_free_dyn:
 		i = idx + 1;
 	      else
 		{
-		  long sdiff = slook->id - h->root.u.def.section->id;
+		  int sdiff = slook->id - h->root.u.def.section->id;
 		  if (sdiff < 0)
 		    j = idx;
 		  else if (sdiff > 0)
diff --git a/bfd/pef.c b/bfd/pef.c
index 18be73b..dfca122 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -487,7 +487,7 @@ bfd_pef_scan_start_address (bfd *abfd)
     goto end;
 
   for (section = abfd->sections; section != NULL; section = section->next)
-    if ((section->index + 1) == header.main_section)
+    if ((long) (section->index + 1) == header.main_section)
       break;
 
   if (section == NULL)
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index a0219d8..4b0b23f 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -9013,13 +9013,13 @@ vms_new_section_hook (bfd * abfd, asection *section)
 {
   bfd_size_type amt;
 
-  vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n",
+  vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
                abfd, section->index, section->name));
 
   if (! bfd_set_section_alignment (abfd, section, 0))
     return FALSE;
 
-  vms_debug2 ((7, "%d: %s\n", section->index, section->name));
+  vms_debug2 ((7, "%u: %s\n", section->index, section->name));
 
   amt = sizeof (struct vms_section_data_struct);
   section->used_by_bfd = bfd_zalloc (abfd, amt);

-- 
Alan Modra
Australia Development Lab, IBM


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