mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 23:54:02 +02:00
InOsEmuPkg/Unix: Rebase firmware SEC image
Apply PE/COFF relocation to SEC image within the firmware volume so it will be able to run at the address that it was loaded. Signed-off-by: jljusten git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11650 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
7d6cc71015
commit
0ede3853bc
@ -553,16 +553,29 @@ SecPeCoffGetEntryPoint (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
||||||
|
|
||||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data;
|
ZeroMem (&ImageContext, sizeof (ImageContext));
|
||||||
ImageContext.SizeOfHeaders = PeCoffGetSizeOfHeaders (Pe32Data);
|
ImageContext.Handle = Pe32Data;
|
||||||
ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer (Pe32Data);
|
ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) SecImageRead;
|
||||||
Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
Status = PeCoffLoaderGetImageInfo (&ImageContext);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageContext.EntryPoint = (UINTN)EntryPoint;
|
//
|
||||||
|
// Relocate image to match the address where it resides
|
||||||
|
//
|
||||||
|
ImageContext.ImageAddress = Pe32Data;
|
||||||
|
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
// On Unix a dlopen is done that will change the entry point
|
// On Unix a dlopen is done that will change the entry point
|
||||||
SecPeCoffRelocateImageExtraAction (&ImageContext);
|
SecPeCoffRelocateImageExtraAction (&ImageContext);
|
||||||
@ -655,6 +668,45 @@ CountSeperatorsInString (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SecImageRead (
|
||||||
|
IN VOID *FileHandle,
|
||||||
|
IN UINTN FileOffset,
|
||||||
|
IN OUT UINTN *ReadSize,
|
||||||
|
OUT VOID *Buffer
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
FileHandle - The handle to the PE/COFF file
|
||||||
|
FileOffset - The offset, in bytes, into the file to read
|
||||||
|
ReadSize - The number of bytes to read from the file starting at FileOffset
|
||||||
|
Buffer - A pointer to the buffer to read the data into.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
|
||||||
|
|
||||||
|
**/
|
||||||
|
{
|
||||||
|
CHAR8 *Destination8;
|
||||||
|
CHAR8 *Source8;
|
||||||
|
UINTN Length;
|
||||||
|
|
||||||
|
Destination8 = Buffer;
|
||||||
|
Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
|
||||||
|
Length = *ReadSize;
|
||||||
|
while (Length--) {
|
||||||
|
*(Destination8++) = *(Source8++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user