EmulatorPkg/Unix/Host: Fix symbol loading with clang

Fix symbol loading issues with clang compilers where
SecGdbSciptBreak() is optimized away and the gdb/lldb
breakpoint on that symbol is never hit and no symbols
are loaded for any modules.

Update the implementation of SecGdbScriptBreak() so it
is never inlined and add code to the implementation
of SecGdbScriptBreak() to guarantee that the entire
function is never optimized away by using a volatile
loop variable.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Michael D Kinney 2025-12-22 11:57:16 -08:00 committed by mergify[bot]
parent 30af217203
commit 1aaa37e00a

View file

@ -1112,9 +1112,7 @@ DlLoadImage (
#endif
}
#ifdef __APPLE__
__attribute__ ((noinline))
#endif
VOID
SecGdbScriptBreak (
char *FileName,
@ -1123,6 +1121,17 @@ SecGdbScriptBreak (
int AddSymbolFlag
)
{
volatile UINTN Index;
//
// Disable inline and have this function do some work to prevent
// optimizing this function away. It must always be in symbol table to
// set breakpoint for gdb script to run, load symbols, and set pending
// breakpoints.
//
for (Index = 0; Index < 1; Index++) {
}
return;
}