]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/CCode/Source/FwImage/fwimage.c
Add more judgement.
[mirror_edk2.git] / Tools / CCode / Source / FwImage / fwimage.c
index 11090952cd61d27162bc8b75ffee933ffdea8d12..97229ce09e57d1816d953095033b0fd172470bdb 100644 (file)
@@ -340,7 +340,9 @@ ScanSections(
       // Align the coff offset to meet with the alignment requirement of section\r
       // itself.\r
       // \r
-      CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {\r
+        CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
+      }\r
 \r
       /* Relocate entry.  */
       if ((Ehdr->e_entry >= shdr->sh_addr) && \r
@@ -364,8 +366,10 @@ ScanSections(
       // Align the coff offset to meet with the alignment requirement of section\r
       // itself.\r
       // \r
-      CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
-
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {\r
+        CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
+      }
+     \r
       CoffSectionsOffset[i] = CoffOffset;
       CoffOffset += shdr->sh_size;
     }