diff --git a/BaseTools/ImageTool/ElfScan.c b/BaseTools/ImageTool/ElfScan.c index 6cad939a50..e2a75b694f 100644 --- a/BaseTools/ImageTool/ElfScan.c +++ b/BaseTools/ImageTool/ElfScan.c @@ -652,7 +652,7 @@ ScanElf ( OUT image_tool_image_info_t *ImageInfo, IN const void *File, IN uint32_t FileSize, - IN const char *SymbolsPath + IN const char *SymbolsPath OPTIONAL ) { RETURN_STATUS Status; @@ -678,7 +678,12 @@ ScanElf ( ImageInfo->HeaderInfo.IsXip = true; ImageInfo->SegmentInfo.SegmentAlignment = (uint32_t)Context.Alignment; ImageInfo->RelocInfo.RelocsStripped = false; - ImageInfo->DebugInfo.SymbolsPathLen = strlen (SymbolsPath); + + if (SymbolsPath != NULL) { + ImageInfo->DebugInfo.SymbolsPathLen = strlen (SymbolsPath); + } else { + assert (ImageInfo->DebugInfo.SymbolsPathLen == 0); + } switch (Ehdr->e_machine) { #if ELF_ARCH == 64 @@ -707,7 +712,11 @@ ScanElf ( return RETURN_OUT_OF_RESOURCES; }; - memmove (ImageInfo->DebugInfo.SymbolsPath, SymbolsPath, ImageInfo->DebugInfo.SymbolsPathLen + 1); + if (SymbolsPath != NULL) { + memmove (ImageInfo->DebugInfo.SymbolsPath, SymbolsPath, ImageInfo->DebugInfo.SymbolsPathLen + 1); + } else { + *ImageInfo->DebugInfo.SymbolsPath = '\0'; + } // // There is no corresponding ELF property. diff --git a/BaseTools/ImageTool/ElfScanCommon.c b/BaseTools/ImageTool/ElfScanCommon.c index 6bc47782f9..ff16164a26 100644 --- a/BaseTools/ImageTool/ElfScanCommon.c +++ b/BaseTools/ImageTool/ElfScanCommon.c @@ -10,7 +10,7 @@ ScanElf ( OUT image_tool_image_info_t *ImageInfo, IN const void *File, IN uint32_t FileSize, - IN const char *SymbolsPath + IN const char *SymbolsPath OPTIONAL ) { RETURN_STATUS Status; diff --git a/BaseTools/ImageTool/ElfScanCommon.h b/BaseTools/ImageTool/ElfScanCommon.h index 46f7353480..2a4b736b26 100644 --- a/BaseTools/ImageTool/ElfScanCommon.h +++ b/BaseTools/ImageTool/ElfScanCommon.h @@ -15,7 +15,7 @@ ScanElf32 ( OUT image_tool_image_info_t *ImageInfo, IN const void *File, IN uint32_t FileSize, - IN const char *SymbolsPath + IN const char *SymbolsPath OPTIONAL ); RETURN_STATUS @@ -23,7 +23,7 @@ ScanElf64 ( OUT image_tool_image_info_t *ImageInfo, IN const void *File, IN uint32_t FileSize, - IN const char *SymbolsPath + IN const char *SymbolsPath OPTIONAL ); #endif // ELF_SCAN_COMMON_H diff --git a/BaseTools/ImageTool/ImageTool.h b/BaseTools/ImageTool/ImageTool.h index bea58c6b1b..02abecbee8 100644 --- a/BaseTools/ImageTool/ImageTool.h +++ b/BaseTools/ImageTool/ImageTool.h @@ -137,7 +137,7 @@ ScanElf ( OUT image_tool_image_info_t *ImageInfo, IN const void *File, IN uint32_t FileSize, - IN const char *SymbolsPath + IN const char *SymbolsPath OPTIONAL ); extern CONST UINT8 mHiiResourceSectionHeaderSize;