diff --git a/BaseTools/ImageTool/ElfScan.c b/BaseTools/ImageTool/ElfScan.c index 7f47515aaa..27525411f6 100644 --- a/BaseTools/ImageTool/ElfScan.c +++ b/BaseTools/ImageTool/ElfScan.c @@ -214,23 +214,23 @@ ReadElfFile ( fprintf (stderr, "ImageTool: mEhdr->e_ident[4] = 0x%x expected 0x%x\n", mEhdr->e_ident[4], Ident[4]); fprintf (stderr, "ImageTool: mEhdr->e_ident[5] = 0x%x expected 0x%x\n", mEhdr->e_ident[5], Ident[5]); fprintf (stderr, "ImageTool: FileSize = 0x%x sizeof(*mEhdr) = 0x%lx\n", FileSize, sizeof (*mEhdr)); - return RETURN_VOLUME_CORRUPTED; + return RETURN_UNSUPPORTED; } if ((mEhdr->e_type != ET_EXEC) && (mEhdr->e_type != ET_DYN)) { fprintf (stderr, "ImageTool: ELF e_type not ET_EXEC or ET_DYN\n"); - return RETURN_UNSUPPORTED; + return RETURN_INCOMPATIBLE_VERSION; } #if defined(EFI_TARGET64) if ((mEhdr->e_machine != EM_X86_64) && (mEhdr->e_machine != EM_AARCH64)) { fprintf (stderr, "ImageTool: Unsupported ELF e_machine\n"); - return RETURN_UNSUPPORTED; + return RETURN_INCOMPATIBLE_VERSION; } #elif defined(EFI_TARGET32) if ((mEhdr->e_machine != EM_386) && (mEhdr->e_machine != EM_ARM)) { fprintf (stderr, "ImageTool: Unsupported ELF e_machine\n"); - return RETURN_UNSUPPORTED; + return RETURN_INCOMPATIBLE_VERSION; } #endif @@ -809,7 +809,7 @@ ScanElf ( default: fprintf (stderr, "ImageTool: Unknown ELF architecture %d\n", mEhdr->e_machine); free (mEhdr); - return RETURN_UNSUPPORTED; + return RETURN_INCOMPATIBLE_VERSION; } mImageInfo.DebugInfo.SymbolsPath = malloc (mImageInfo.DebugInfo.SymbolsPathLen + 1); diff --git a/BaseTools/ImageTool/ImageTool.c b/BaseTools/ImageTool/ImageTool.c index e4c1d11ebd..019e9730ba 100644 --- a/BaseTools/ImageTool/ImageTool.c +++ b/BaseTools/ImageTool/ImageTool.c @@ -24,7 +24,7 @@ PeXip ( { void *Pe; uint32_t PeSize; - bool Result; + RETURN_STATUS Status; image_tool_image_info_t Image; assert (OldName != NULL); @@ -37,12 +37,12 @@ PeXip ( return RETURN_ABORTED; } - Result = ToolContextConstructPe (&Image, Pe, PeSize, ModuleType); + Status = ToolContextConstructPe (&Image, Pe, PeSize, ModuleType); free (Pe); Pe = NULL; - if (!Result) { + if (RETURN_ERROR (Status)) { return RETURN_ABORTED; } diff --git a/BaseTools/ImageTool/ImageTool.h b/BaseTools/ImageTool/ImageTool.h index c36833d8b0..295930f8c1 100644 --- a/BaseTools/ImageTool/ImageTool.h +++ b/BaseTools/ImageTool/ImageTool.h @@ -148,7 +148,7 @@ ImageConvertToXip ( image_tool_image_info_t *Image ); -bool +RETURN_STATUS ToolContextConstructPe ( OUT image_tool_image_info_t *Image, IN const void *File, diff --git a/BaseTools/ImageTool/PeScan.c b/BaseTools/ImageTool/PeScan.c index 847eaff448..2752ceb769 100644 --- a/BaseTools/ImageTool/PeScan.c +++ b/BaseTools/ImageTool/PeScan.c @@ -393,7 +393,7 @@ ScanPeGetHiiInfo ( return true; } -bool +RETURN_STATUS ToolContextConstructPe ( OUT image_tool_image_info_t *Image, IN const void *File, @@ -415,13 +415,12 @@ ToolContextConstructPe ( if (FileSize > MAX_UINT32) { fprintf (stderr, "ImageTool: FileSize is too huge\n"); - return false; + return RETURN_UNSUPPORTED; } Status = PeCoffInitializeContext (&Context, File, (UINT32)FileSize); if (RETURN_ERROR (Status)) { - fprintf (stderr, "ImageTool: Could not initialise Context\n"); - return false; + return Status; } ImageSize = PeCoffGetSizeOfImage (&Context); @@ -435,14 +434,14 @@ ToolContextConstructPe ( ); if (Destination == NULL) { fprintf (stderr, "ImageTool: Could not allocate Destination buffer\n"); - return false; + return RETURN_OUT_OF_RESOURCES; } Status = PeCoffLoadImage (&Context, Destination, DestinationSize); if (RETURN_ERROR (Status)) { fprintf (stderr, "ImageTool: Could not Load Image\n"); FreeAlignedPages (Destination, DestinationPages); - return false; + return RETURN_VOLUME_CORRUPTED; } memset (Image, 0, sizeof (*Image)); @@ -452,7 +451,7 @@ ToolContextConstructPe ( fprintf (stderr, "ImageTool: Could not retrieve header info\n"); ToolImageDestruct (Image); FreeAlignedPages (Destination, DestinationPages); - return false; + return RETURN_VOLUME_CORRUPTED; } Result = ScanPeGetDebugInfo (&Image->DebugInfo, &Context); @@ -460,7 +459,7 @@ ToolContextConstructPe ( fprintf (stderr, "ImageTool: Could not retrieve debug info\n"); ToolImageDestruct (Image); FreeAlignedPages (Destination, DestinationPages); - return false; + return RETURN_VOLUME_CORRUPTED; } Result = ScanPeGetSegmentInfo (&Image->SegmentInfo, &Image->HiiInfo, &Context); @@ -468,16 +467,18 @@ ToolContextConstructPe ( fprintf (stderr, "ImageTool: Could not retrieve segment info\n"); ToolImageDestruct (Image); FreeAlignedPages (Destination, DestinationPages); - return false; + return RETURN_VOLUME_CORRUPTED; } Result = ScanPeGetRelocInfo (&Image->RelocInfo, &Context); if (!Result) { fprintf (stderr, "ImageTool: Could not retrieve reloc info\n"); ToolImageDestruct (Image); + FreeAlignedPages (Destination, DestinationPages); + return RETURN_VOLUME_CORRUPTED; } FreeAlignedPages (Destination, DestinationPages); - return Result; + return RETURN_SUCCESS; }