mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-24 10:17:45 +02:00
ImageTool: Fix SymbolsPathLen inconsistencies
This commit is contained in:
parent
fbb0bac451
commit
ea97361c29
@ -784,7 +784,7 @@ ScanElf (
|
|||||||
mImageInfo.HeaderInfo.IsXip = true;
|
mImageInfo.HeaderInfo.IsXip = true;
|
||||||
mImageInfo.SegmentInfo.SegmentAlignment = (uint32_t)mPeAlignment;
|
mImageInfo.SegmentInfo.SegmentAlignment = (uint32_t)mPeAlignment;
|
||||||
mImageInfo.RelocInfo.RelocsStripped = false;
|
mImageInfo.RelocInfo.RelocsStripped = false;
|
||||||
mImageInfo.DebugInfo.SymbolsPathLen = strlen (ElfName) + 1;
|
mImageInfo.DebugInfo.SymbolsPathLen = strlen (ElfName);
|
||||||
|
|
||||||
switch (mEhdr->e_machine) {
|
switch (mEhdr->e_machine) {
|
||||||
case EM_386:
|
case EM_386:
|
||||||
@ -805,14 +805,14 @@ ScanElf (
|
|||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
mImageInfo.DebugInfo.SymbolsPath = calloc (1, mImageInfo.DebugInfo.SymbolsPathLen);
|
mImageInfo.DebugInfo.SymbolsPath = malloc (mImageInfo.DebugInfo.SymbolsPathLen + 1);
|
||||||
if (mImageInfo.DebugInfo.SymbolsPath == NULL) {
|
if (mImageInfo.DebugInfo.SymbolsPath == NULL) {
|
||||||
fprintf (stderr, "ImageTool: Could not allocate memory for Debug Data\n");
|
fprintf (stderr, "ImageTool: Could not allocate memory for Debug Data\n");
|
||||||
free (mEhdr);
|
free (mEhdr);
|
||||||
return RETURN_OUT_OF_RESOURCES;
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy (mImageInfo.DebugInfo.SymbolsPath, ElfName, mImageInfo.DebugInfo.SymbolsPathLen);
|
memmove (mImageInfo.DebugInfo.SymbolsPath, ElfName, mImageInfo.DebugInfo.SymbolsPathLen + 1);
|
||||||
|
|
||||||
if ((strcmp (ModuleType, "BASE") == 0)
|
if ((strcmp (ModuleType, "BASE") == 0)
|
||||||
|| (strcmp (ModuleType, "SEC") == 0)
|
|| (strcmp (ModuleType, "SEC") == 0)
|
||||||
|
@ -180,7 +180,7 @@ EmitPeGetDebugSectionSize (
|
|||||||
|
|
||||||
if (Image->DebugInfo.SymbolsPath != NULL) {
|
if (Image->DebugInfo.SymbolsPath != NULL) {
|
||||||
return !BaseOverflowAlignUpU32 (
|
return !BaseOverflowAlignUpU32 (
|
||||||
sizeof (DebugData) + Image->DebugInfo.SymbolsPathLen,
|
sizeof (DebugData) + Image->DebugInfo.SymbolsPathLen + 1,
|
||||||
Image->SegmentInfo.SegmentAlignment,
|
Image->SegmentInfo.SegmentAlignment,
|
||||||
DebugSize
|
DebugSize
|
||||||
);
|
);
|
||||||
@ -755,18 +755,18 @@ ToolImageEmitPeDebugTable (
|
|||||||
|
|
||||||
Context->PeHdr->SizeOfImage += ALIGN_VALUE (Context->DebugTableSize, Image->SegmentInfo.SegmentAlignment);
|
Context->PeHdr->SizeOfImage += ALIGN_VALUE (Context->DebugTableSize, Image->SegmentInfo.SegmentAlignment);
|
||||||
|
|
||||||
assert (Image->DebugInfo.SymbolsPathLen <= Context->DebugTableSize);
|
assert (Image->DebugInfo.SymbolsPathLen + 1 <= Context->DebugTableSize);
|
||||||
assert (Context->DebugTableSize <= *BufferSize);
|
assert (Context->DebugTableSize <= *BufferSize);
|
||||||
|
|
||||||
Data = (DebugData *) *Buffer;
|
Data = (DebugData *) *Buffer;
|
||||||
|
|
||||||
Data->Dir.Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW;
|
Data->Dir.Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW;
|
||||||
Data->Dir.SizeOfData = sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) + Image->DebugInfo.SymbolsPathLen;
|
Data->Dir.SizeOfData = sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) + Image->DebugInfo.SymbolsPathLen + 1;
|
||||||
Data->Dir.RVA = (Context->UnsignedFileSize - ALIGN_VALUE (Context->DebugTableSize, Context->FileAlignment)) + sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
|
Data->Dir.RVA = (Context->UnsignedFileSize - ALIGN_VALUE (Context->DebugTableSize, Context->FileAlignment)) + sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
|
||||||
Data->Dir.FileOffset = Data->Dir.RVA;
|
Data->Dir.FileOffset = Data->Dir.RVA;
|
||||||
|
|
||||||
Data->Nb10.Signature = CODEVIEW_SIGNATURE_NB10;
|
Data->Nb10.Signature = CODEVIEW_SIGNATURE_NB10;
|
||||||
snprintf (Data->Name, Image->DebugInfo.SymbolsPathLen, "%s", Image->DebugInfo.SymbolsPath);
|
memmove (Data->Name, Image->DebugInfo.SymbolsPath, Image->DebugInfo.SymbolsPathLen + 1);
|
||||||
|
|
||||||
*BufferSize -= Context->DebugTableSize;
|
*BufferSize -= Context->DebugTableSize;
|
||||||
*Buffer += Context->DebugTableSize;
|
*Buffer += Context->DebugTableSize;
|
||||||
|
@ -369,7 +369,7 @@ ScanPeGetDebugInfo (
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugInfo->SymbolsPath = calloc (1, PdbPathSize);
|
DebugInfo->SymbolsPath = malloc (PdbPathSize);
|
||||||
if (DebugInfo->SymbolsPath == NULL) {
|
if (DebugInfo->SymbolsPath == NULL) {
|
||||||
fprintf (stderr, "ImageTool: Could not allocate memory for SymbolsPath\n");
|
fprintf (stderr, "ImageTool: Could not allocate memory for SymbolsPath\n");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user