mirror of https://github.com/acidanthera/audk.git
[InOSEmPkg] Add OS malloc and free to the Thunk.
Added OS malloc and free so we can make MemoryAllocationLib instance that uses OS guard malloc. This will allow all the debug support built into the OS for finding malloc bugs to be used with a driver in the emulator. Signed-off-by: andrewfish git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11883 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
54e0b04c74
commit
c217506815
|
@ -78,6 +78,18 @@ BOOLEAN
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
typedef
|
||||||
|
VOID *
|
||||||
|
(EFIAPI *EMU_OS_MALLOC) (
|
||||||
|
IN UINTN Size
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef
|
||||||
|
VOID
|
||||||
|
(EFIAPI *EMU_OS_FREE) (
|
||||||
|
IN VOID *Ptr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -205,6 +217,13 @@ struct _EMU_THUNK_PROTOCOL {
|
||||||
EMU_READ_STD_IN ReadStdIn;
|
EMU_READ_STD_IN ReadStdIn;
|
||||||
EMU_POLL_STD_IN PollStdIn;
|
EMU_POLL_STD_IN PollStdIn;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Map OS malloc/free so we can use OS based guard malloc
|
||||||
|
//
|
||||||
|
EMU_OS_MALLOC Malloc;
|
||||||
|
EMU_OS_FREE Free;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// PE/COFF loader hooks to get symbols loaded
|
/// PE/COFF loader hooks to get symbols loaded
|
||||||
///
|
///
|
||||||
|
|
|
@ -118,6 +118,23 @@ SecPollStdIn (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID *
|
||||||
|
SecMalloc (
|
||||||
|
IN UINTN Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return malloc ((size_t)Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SecFree (
|
||||||
|
IN VOID *Ptr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
free (Ptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
settimer_handler (int sig)
|
settimer_handler (int sig)
|
||||||
|
@ -370,6 +387,8 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
|
||||||
GasketSecWriteStdOut,
|
GasketSecWriteStdOut,
|
||||||
GasketSecReadStdIn,
|
GasketSecReadStdIn,
|
||||||
GasketSecPollStdIn,
|
GasketSecPollStdIn,
|
||||||
|
GasketSecMalloc,
|
||||||
|
GasketSecFree,
|
||||||
GasketSecPeCoffGetEntryPoint,
|
GasketSecPeCoffGetEntryPoint,
|
||||||
GasketSecPeCoffRelocateImageExtraAction,
|
GasketSecPeCoffRelocateImageExtraAction,
|
||||||
GasketSecPeCoffUnloadImageExtraAction,
|
GasketSecPeCoffUnloadImageExtraAction,
|
||||||
|
|
|
@ -53,6 +53,16 @@ GasketSecPollStdIn (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
VOID *
|
||||||
|
EFIAPI
|
||||||
|
GasketSecMalloc (
|
||||||
|
IN UINTN Size
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
GasketSecFree (
|
||||||
|
IN VOID *Ptr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
|
|
|
@ -107,6 +107,34 @@ ASM_PFX(GasketSecPollStdIn):
|
||||||
leave
|
leave
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX(GasketSecMalloc)
|
||||||
|
ASM_PFX(GasketSecMalloc):
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp, %ebp
|
||||||
|
subl $24, %esp // sub extra 16 from the stack for alignment
|
||||||
|
and $-16, %esp // stack needs to end in 0xFFFFFFF0 before call
|
||||||
|
movl 8(%ebp), %eax
|
||||||
|
movl %eax, (%esp)
|
||||||
|
|
||||||
|
call ASM_PFX(SecMalloc)
|
||||||
|
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX(GasketSecFree)
|
||||||
|
ASM_PFX(GasketSecFree):
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp, %ebp
|
||||||
|
subl $24, %esp // sub extra 16 from the stack for alignment
|
||||||
|
and $-16, %esp // stack needs to end in 0xFFFFFFF0 before call
|
||||||
|
movl 8(%ebp), %eax
|
||||||
|
movl %eax, (%esp)
|
||||||
|
|
||||||
|
call ASM_PFX(SecFree)
|
||||||
|
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
|
ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
|
||||||
ASM_PFX(GasketSecSetTimer):
|
ASM_PFX(GasketSecSetTimer):
|
||||||
|
|
|
@ -126,6 +126,34 @@ ASM_PFX(GasketSecPollStdIn):
|
||||||
popq %rbp
|
popq %rbp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX(GasketSecMalloc)
|
||||||
|
ASM_PFX(GasketSecMalloc):
|
||||||
|
pushq %rbp // stack frame is for the debugger
|
||||||
|
movq %rsp, %rbp
|
||||||
|
|
||||||
|
pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
|
||||||
|
|
||||||
|
call ASM_PFX(SecMalloc)
|
||||||
|
|
||||||
|
popq %rdi // restore state
|
||||||
|
popq %rsi
|
||||||
|
popq %rbp
|
||||||
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX(GasketSecFree)
|
||||||
|
ASM_PFX(GasketSecFree):
|
||||||
|
pushq %rbp // stack frame is for the debugger
|
||||||
|
movq %rsp, %rbp
|
||||||
|
|
||||||
|
pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
|
||||||
|
|
||||||
|
call ASM_PFX(SecFree)
|
||||||
|
|
||||||
|
popq %rdi // restore state
|
||||||
|
popq %rsi
|
||||||
|
popq %rbp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
|
ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
|
||||||
ASM_PFX(GasketSecSetTimer):
|
ASM_PFX(GasketSecSetTimer):
|
||||||
|
|
Loading…
Reference in New Issue