* section.c (bfd_make_section_anyway): Don't increment section_id
authorAlan Modra <amodra@gmail.com>
Tue, 13 Nov 2001 03:52:25 +0000 (03:52 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 13 Nov 2001 03:52:25 +0000 (03:52 +0000)
and the BFD's section_count if adding the section failed.
* vms.c (vms_new_section_hook): Adjust for bfd_make_section_anyway
change.

bfd/ChangeLog
bfd/section.c
bfd/vms.c

index 0a09617fce20bd17d6460945426e67b452312e29..e37b504a469c58395b6ec730a2cac1986e33909e 100644 (file)
@@ -1,3 +1,11 @@
+2001-11-13  John Marshall  <jmarshall@acm.org>
+           Alan Modra  <amodra@bigpond.net.au>
+
+       * section.c (bfd_make_section_anyway): Don't increment section_id
+       and the BFD's section_count if adding the section failed.
+       * vms.c (vms_new_section_hook): Adjust for bfd_make_section_anyway
+       change.
+
 2001-11-12  Orjan Friberg  <orjanf@axis.com>
 
        * elf32-cris.c (cris_elf_grok_prstatus): Adjust values to match new
index 53491f13551cd74de0debdf1409b30da2033ab43..0d95f117834ec2db241fd3801ffa45349b714bf2 100644 (file)
@@ -796,8 +796,8 @@ bfd_make_section_anyway (abfd, name)
     return NULL;
 
   newsect->name = name;
-  newsect->id = section_id++;
-  newsect->index = abfd->section_count++;
+  newsect->id = section_id;
+  newsect->index = abfd->section_count;
   newsect->flags = SEC_NO_FLAGS;
 
   newsect->userdata = NULL;
@@ -831,6 +831,8 @@ bfd_make_section_anyway (abfd, name)
       return NULL;
     }
 
+  section_id++;
+  abfd->section_count++;
   *prev = newsect;
   return newsect;
 }
index 94fa84e044cefa0d4b0dc1970f609c933de68bd1..55bcf6193cbe2facc7d04b389705b8ed3ed75e73 100644 (file)
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -733,19 +733,23 @@ vms_new_section_hook (abfd, section)
      bfd *abfd;
      asection *section;
 {
+  /* Count hasn't been incremented yet.  */
+  unsigned int section_count = abfd->section_count + 1;
+
 #if VMS_DEBUG
-  vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n", abfd, section->index, section->name, abfd->section_count);
+  vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
+            abfd, section->index, section->name, section_count);
 #endif
-  bfd_set_section_alignment(abfd, section, 4);
+  bfd_set_section_alignment (abfd, section, 4);
 
-  if (abfd->section_count > PRIV (section_count))
+  if (section_count > PRIV (section_count))
     {
-      bfd_size_type amt = abfd->section_count;
+      bfd_size_type amt = section_count;
       amt *= sizeof (asection *);
       PRIV (sections) = (asection **) bfd_realloc (PRIV (sections), amt);
       if (PRIV (sections) == 0)
        return false;
-      PRIV (section_count) = abfd->section_count;
+      PRIV (section_count) = section_count;
     }
 #if VMS_DEBUG
   vms_debug (6, "section_count: %d\n", PRIV (section_count));