]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/CCode/Source/PeiRebase/PeiRebaseExe.c
1. Updated LOG file format generated by PeiRebase.
[mirror_edk2.git] / Tools / CCode / Source / PeiRebase / PeiRebaseExe.c
index 93acb635f5c2c217a7299a15a82b928c684bd8e1..459d8db11e29c2c1f9e32ebbbf935c7ee42b356e 100644 (file)
@@ -104,27 +104,22 @@ Returns:
   // Set utility name for error/warning reporting purposes.\r
   //\r
   SetUtilityName (UTILITY_NAME);\r
-  \r
-  if (argc == 1) {\r
-    Usage();\r
-    return STATUS_ERROR;\r
-  }\r
-    \r
+\r
   if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||\r
       (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {\r
     Usage();\r
     return STATUS_ERROR;\r
   }\r
-  \r
+\r
   if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {\r
     Version();\r
     return STATUS_ERROR;\r
   }\r
\r
+\r
   //\r
   // Verify the correct number of arguments\r
   //\r
-  if (argc != MAX_ARGS) {\r
+  if (argc < MAX_ARGS) {\r
     Usage ();\r
     return STATUS_ERROR;\r
   }\r
@@ -147,7 +142,7 @@ Returns:
   //\r
   // Parse the command line arguments\r
   //\r
-  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
+  for (Index = 1; Index < argc; Index += 2) {\r
     //\r
     // Make sure argument pair begin with - or /\r
     //\r
@@ -293,7 +288,7 @@ Returns:
   // Open the log file\r
   //\r
   strcat (InputFileName, ".log");\r
-  LogFile = fopen (InputFileName, "a");\r
+  LogFile = fopen (InputFileName, "w");\r
   if (LogFile == NULL) {\r
     Error (NULL, 0, 0, InputFileName, "could not append to log file");\r
   }\r
@@ -552,7 +547,7 @@ Returns:
 --*/\r
 {\r
   Version();\r
-  \r
+\r
   printf (\r
     "Usage: %s -I InputFileName -O OutputFileName -B BaseAddress [-F InputFvInfName]\n",\r
     UTILITY_NAME\r
@@ -612,7 +607,7 @@ Returns:
   EFI_FFS_FILE_TAIL                     TailValue;\r
   EFI_PHYSICAL_ADDRESS                  *BaseToUpdate;\r
   EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
-  \r
+\r
 \r
   //\r
   // Verify input parameters\r
@@ -687,14 +682,14 @@ Returns:
     PeHdr = (EFI_IMAGE_NT_HEADERS *)((UINTN)ImageContext.ImageAddress + ImageContext.PeCoffHeaderOffset);\r
     if (PeHdr->OptionalHeader.SectionAlignment != PeHdr->OptionalHeader.FileAlignment) {\r
       //\r
-      // Nor XIP module can be ignored. \r
+      // Nor XIP module can be ignored.\r
       //\r
       if ((Flags & 1) == 0) {\r
         continue;\r
       }\r
       Error (NULL, 0, 0, "Section-Alignment and File-Alignment does not match", FileGuidString);\r
       return EFI_ABORTED;\r
-    } \r
+    }\r
 \r
     //\r
     // Update CodeView and PdbPointer in ImageContext\r
@@ -703,8 +698,8 @@ Returns:
                     ImageContext.ImageAddress +\r
                     ImageContext.DebugDirectoryEntryRva\r
                     );\r
-    ImageContext.CodeView = (VOID *)(UINTN)( \r
-                              ImageContext.ImageAddress + \r
+    ImageContext.CodeView = (VOID *)(UINTN)(\r
+                              ImageContext.ImageAddress +\r
                               DebugEntry->RVA\r
                               );\r
     switch (*(UINT32 *) ImageContext.CodeView) {\r
@@ -803,10 +798,9 @@ Returns:
     //\r
     fprintf (\r
       LogFile,\r
-      "%s %016I64X %s\n",\r
+      "%s %016I64X\n",\r
       FileGuidString,\r
-      ImageContext.DestinationAddress,\r
-      ImageContext.PdbPointer == NULL ? "*" : ImageContext.PdbPointer\r
+      ImageContext.DestinationAddress\r
       );\r
     *BaseToUpdate += EFI_SIZE_TO_PAGES (ImageContext.ImageSize) * EFI_PAGE_SIZE;\r
 \r
@@ -855,7 +849,7 @@ Returns:
     //\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   //\r
   // Now process TE sections\r
   //\r
@@ -921,7 +915,7 @@ Returns:
 \r
     //\r
     // Reloacate TeImage\r
-    // \r
+    //\r
     ImageContext.DestinationAddress = XipBase + (UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) \\r
                                       - TEImageHeader->StrippedSize - (UINTN) FfsFile;\r
     Status                          = PeCoffLoaderRelocateImage (&ImageContext);\r
@@ -963,13 +957,12 @@ Returns:
 \r
     fprintf (\r
       LogFile,\r
-      "%s %016I64X %s\n",\r
+      "%s %016I64X\n",\r
       FileGuidString,\r
-      ImageContext.DestinationAddress,\r
-      ImageContext.PdbPointer == NULL ? "*" : ImageContext.PdbPointer\r
+      ImageContext.DestinationAddress\r
       );\r
   }\r
\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r