LegacyBiosInt86() sets a pointer to 0 and dereferences it. From a C standard
point of view this is considered undefined behavior. The clang optimizer emits
a trap instruction and throws all the code after the reference away. The trap
is replaced via a compiler flag to be a function that does not exist, and thus
this is why we get a link failure.
The optimizer needs to avoid optimizations on a volatile variable, so the only
safe way to write to zero in C is to use a volatile variable. See
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Anderw Fish <[email protected]>
~/work/src/edk2(master)>git diff
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c
index 3d9a8b9..a5d2f14 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/Thunk.c
@@ -57,7 +57,7 @@ LegacyBiosInt86 (
IN EFI_IA32_REGISTER_SET *Regs
)
{
- UINT32 *VectorBase;
+ volatile UINT32 *VectorBase;
Regs->X.Flags.Reserved1 = 1;
Regs->X.Flags.Reserved2 = 0;
Thanks,
Andrew Fish
PS I finally got around to testing clang out on OVFM. Right now I’m in a “World
of Hurt”(TM) trying to get UefiCpuPkg/Library/CpuExceptionHandlerLib to work.
It seems that CpuExceptionHandlerLib assembly has a lot of X64 relocations that
the Xcode linker does not support. ------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel