MdeModulePkg/EbcDxe: Mitigate memcpy intrinsics

Assignments of structure values cause the emission of memcpy()
intrinsics by the CLANG38 toolchain. Substitute the assignments with
calls to CopyMem() to mitigate the issue.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin H?user <mhaeuser@posteo.de>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Marvin H?user
2021-08-16 04:11:56 +08:00
committed by mergify[bot]
parent 77d5fa8024
commit b04453d36b
3 changed files with 15 additions and 3 deletions

View File

@ -219,7 +219,11 @@ EdbCheckBreakpoint (
// //
// If hit, record current breakpoint // If hit, record current breakpoint
// //
DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX] = DebuggerPrivate->DebuggerBreakpointContext[Index]; CopyMem (
&DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX],
&DebuggerPrivate->DebuggerBreakpointContext[Index],
sizeof (DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX])
);
DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX].State = TRUE; DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX].State = TRUE;
// //
// Do not set Breakpoint flag. We record the address here just let it not patch breakpoint address when de-init. // Do not set Breakpoint flag. We record the address here just let it not patch breakpoint address when de-init.

View File

@ -158,7 +158,11 @@ DebuggerBreakpointDel (
// Delete this breakpoint // Delete this breakpoint
// //
for (BpIndex = Index; BpIndex < DebuggerPrivate->DebuggerBreakpointCount - 1; BpIndex++) { for (BpIndex = Index; BpIndex < DebuggerPrivate->DebuggerBreakpointCount - 1; BpIndex++) {
DebuggerPrivate->DebuggerBreakpointContext[BpIndex] = DebuggerPrivate->DebuggerBreakpointContext[BpIndex + 1]; CopyMem (
&DebuggerPrivate->DebuggerBreakpointContext[BpIndex],
&DebuggerPrivate->DebuggerBreakpointContext[BpIndex + 1],
sizeof (DebuggerPrivate->DebuggerBreakpointContext[BpIndex])
);
} }
ZeroMem ( ZeroMem (
&DebuggerPrivate->DebuggerBreakpointContext[BpIndex], &DebuggerPrivate->DebuggerBreakpointContext[BpIndex],

View File

@ -230,7 +230,11 @@ EbcDebuggerPushTraceDestEntry (
// //
ASSERT (mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_TRACE_MAX].Type == Type); ASSERT (mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_TRACE_MAX].Type == Type);
for (Index = 0; Index < EFI_DEBUGGER_TRACE_MAX; Index++) { for (Index = 0; Index < EFI_DEBUGGER_TRACE_MAX; Index++) {
mDebuggerPrivate.TraceEntry[Index] = mDebuggerPrivate.TraceEntry[Index + 1]; CopyMem (
&mDebuggerPrivate.TraceEntry[Index],
&mDebuggerPrivate.TraceEntry[Index + 1],
sizeof (mDebuggerPrivate.TraceEntry[Index])
);
} }
mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry; mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry;
mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX; mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;