ImageTool: Make ELF SymbolsPath optional

This commit is contained in:
Marvin Häuser 2023-04-23 22:45:15 +02:00 committed by Mikhail Krichanov
parent 5c75aaa8a7
commit 1edfc1f6b7
4 changed files with 16 additions and 7 deletions

View File

@ -652,7 +652,7 @@ ScanElf (
OUT image_tool_image_info_t *ImageInfo, OUT image_tool_image_info_t *ImageInfo,
IN const void *File, IN const void *File,
IN uint32_t FileSize, IN uint32_t FileSize,
IN const char *SymbolsPath IN const char *SymbolsPath OPTIONAL
) )
{ {
RETURN_STATUS Status; RETURN_STATUS Status;
@ -678,7 +678,12 @@ ScanElf (
ImageInfo->HeaderInfo.IsXip = true; ImageInfo->HeaderInfo.IsXip = true;
ImageInfo->SegmentInfo.SegmentAlignment = (uint32_t)Context.Alignment; ImageInfo->SegmentInfo.SegmentAlignment = (uint32_t)Context.Alignment;
ImageInfo->RelocInfo.RelocsStripped = false; 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) { switch (Ehdr->e_machine) {
#if ELF_ARCH == 64 #if ELF_ARCH == 64
@ -707,7 +712,11 @@ ScanElf (
return RETURN_OUT_OF_RESOURCES; 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. // There is no corresponding ELF property.

View File

@ -10,7 +10,7 @@ ScanElf (
OUT image_tool_image_info_t *ImageInfo, OUT image_tool_image_info_t *ImageInfo,
IN const void *File, IN const void *File,
IN uint32_t FileSize, IN uint32_t FileSize,
IN const char *SymbolsPath IN const char *SymbolsPath OPTIONAL
) )
{ {
RETURN_STATUS Status; RETURN_STATUS Status;

View File

@ -15,7 +15,7 @@ ScanElf32 (
OUT image_tool_image_info_t *ImageInfo, OUT image_tool_image_info_t *ImageInfo,
IN const void *File, IN const void *File,
IN uint32_t FileSize, IN uint32_t FileSize,
IN const char *SymbolsPath IN const char *SymbolsPath OPTIONAL
); );
RETURN_STATUS RETURN_STATUS
@ -23,7 +23,7 @@ ScanElf64 (
OUT image_tool_image_info_t *ImageInfo, OUT image_tool_image_info_t *ImageInfo,
IN const void *File, IN const void *File,
IN uint32_t FileSize, IN uint32_t FileSize,
IN const char *SymbolsPath IN const char *SymbolsPath OPTIONAL
); );
#endif // ELF_SCAN_COMMON_H #endif // ELF_SCAN_COMMON_H

View File

@ -137,7 +137,7 @@ ScanElf (
OUT image_tool_image_info_t *ImageInfo, OUT image_tool_image_info_t *ImageInfo,
IN const void *File, IN const void *File,
IN uint32_t FileSize, IN uint32_t FileSize,
IN const char *SymbolsPath IN const char *SymbolsPath OPTIONAL
); );
extern CONST UINT8 mHiiResourceSectionHeaderSize; extern CONST UINT8 mHiiResourceSectionHeaderSize;