]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Cleanup of loop to write out section content.
authorUlrich Drepper <drepper@redhat.com>
Thu, 22 Jan 2009 01:03:31 +0000 (17:03 -0800)
committerUlrich Drepper <drepper@redhat.com>
Thu, 22 Jan 2009 01:03:31 +0000 (17:03 -0800)
libelf/ChangeLog
libelf/elf32_updatefile.c

index be259e620852bc076c9fd4db52033cf43f145103..2f8ff2be68f67654976fbbc6cf63113b107ddf56 100644 (file)
@@ -1,5 +1,9 @@
 2009-01-21  Ulrich Drepper  <drepper@redhat.com>
 
+       * elf32_updatefile.c (elfXX_updatemmap): Skip most of the loop to
+       handle sections for NOBITS sections.
+       (elfXX_updatefile): Likewise.
+
        * elf32_updatefile.c (elfXX_updatemmap): When skipping non-NOBITS
        sections we haven't loaded, update last_position based on scn_start,
        not based on old value.  Don't run the loop for the dummy section 0.
index 111e1d2bb6ece147c79b5280ab5552bc165a526c..f23035a52c4f7f0a045e2aed85e83048af8e2e59 100644 (file)
@@ -292,12 +292,14 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
            }
 
          ElfW2(LIBELFBITS,Shdr) *shdr = scn->shdr.ELFW(e,LIBELFBITS);
+         if (shdr->sh_type == SHT_NOBITS)
+           goto next;
 
          char *scn_start = ((char *) elf->map_address
                             + elf->start_offset + shdr->sh_offset);
          Elf_Data_List *dl = &scn->data_list;
 
-         if (shdr->sh_type != SHT_NOBITS && scn->data_list_rear != NULL)
+         if (scn->data_list_rear != NULL)
            do
              {
                assert (dl->data.d.d_off >= 0);
@@ -369,10 +371,11 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
                dl = dl->next;
              }
            while (dl != NULL);
-         else if (shdr->sh_type != SHT_NOBITS)
+         else
            /* We have to trust the existing section header information.  */
            last_position = scn_start + shdr->sh_size;
 
+       next:
          scn->flags &= ~ELF_F_DIRTY;
        }
 
@@ -632,12 +635,13 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
            }
 
          ElfW2(LIBELFBITS,Shdr) *shdr = scn->shdr.ELFW(e,LIBELFBITS);
+         if (shdr->sh_type == SHT_NOBITS)
+           goto next;
 
          off_t scn_start = elf->start_offset + shdr->sh_offset;
          Elf_Data_List *dl = &scn->data_list;
 
-         if (shdr->sh_type != SHT_NOBITS && scn->data_list_rear != NULL
-             && scn->index != 0)
+         if (scn->data_list_rear != NULL)
            do
              {
                if ((scn->flags | dl->flags | elf->flags) & ELF_F_DIRTY)
@@ -709,9 +713,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
                dl = dl->next;
              }
            while (dl != NULL);
-         else if (shdr->sh_type != SHT_NOBITS)
+         else
            last_offset = scn_start + shdr->sh_size;
 
+       next:
          /* Collect the section header table information.  */
          if (unlikely (change_bo))
            (*shdr_fctp) (&shdr_data[scn->index],