diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf index d0f82095cf..fdbebadab9 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf @@ -28,7 +28,7 @@ Ia32/ArchInterruptDefs.h [Sources.X64] - X64/Xcode5ExceptionHandlerAsm.nasm + X64/ExceptionHandlerAsm.nasm X64/ArchExceptionHandler.c X64/ArchInterruptDefs.h @@ -61,3 +61,6 @@ MemoryAllocationLib DebugLib CcExitLib + +[BuildOptions] + XCODE:*_*_X64_NASM_FLAGS = -D NO_ABSOLUTE_RELOCS_IN_TEXT diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf index 8f8a5dab79..27f0b96fa9 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf @@ -28,7 +28,7 @@ Ia32/ArchInterruptDefs.h [Sources.X64] - X64/Xcode5ExceptionHandlerAsm.nasm + X64/ExceptionHandlerAsm.nasm X64/ArchExceptionHandler.c X64/ArchInterruptDefs.h @@ -61,3 +61,5 @@ [FeaturePcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard ## CONSUMES +[BuildOptions] + XCODE:*_*_X64_NASM_FLAGS = -D NO_ABSOLUTE_RELOCS_IN_TEXT diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm similarity index 95% rename from UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm index 9574785742..3d64ac9080 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm @@ -59,7 +59,11 @@ AsmIdtVectorBegin: %rep 256 push strict dword %[Vector] ; This instruction pushes sign-extended 8-byte value on stack push rax +%ifdef NO_ABSOLUTE_RELOCS_IN_TEXT mov rax, strict qword 0 ; mov rax, ASM_PFX(CommonInterruptEntry) +%else + mov rax, ASM_PFX(CommonInterruptEntry) +%endif jmp rax %assign Vector Vector+1 %endrep @@ -69,8 +73,12 @@ HookAfterStubHeaderBegin: push strict dword 0 ; 0 will be fixed VectorNum: push rax +%ifdef NO_ABSOLUTE_RELOCS_IN_TEXT mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd JmpAbsoluteAddress: +%else + mov rax, HookAfterStubHeaderEnd +%endif jmp rax HookAfterStubHeaderEnd: mov rax, rsp @@ -457,6 +465,7 @@ ASM_PFX(AsmGetTemplateAddressMap): lea rax, [HookAfterStubHeaderBegin] mov qword [rcx + 0x10], rax +%ifdef NO_ABSOLUTE_RELOCS_IN_TEXT ; Fix up CommonInterruptEntry address lea rax, [ASM_PFX(CommonInterruptEntry)] lea rcx, [AsmIdtVectorBegin] @@ -468,6 +477,7 @@ ASM_PFX(AsmGetTemplateAddressMap): lea rax, [HookAfterStubHeaderEnd] lea rcx, [JmpAbsoluteAddress] mov qword [rcx - 8], rax +%endif ret