Skip to content

Commit d81ce00

Browse files
authored
Fix RhpCallCatchFunclet .text relocation on amd64. (#111227)
c8e4f2c changed asm implementation in RhpThrowHwEx on amd64 from a relative jump, using jmp RhpThrowHwEx to a mov rax, RhpThrowHwEx that is later jumped to using jmp rax. This introduce a ADDR64 relocation record in the generated object file: 000004EC ADDR64 00000000 00000000 2A RhpThrowHwEx That will then be left as a relocation that needs to be fixed up by the loader: 73000 RVA, C SizeOfBlock F7C DIR64 0000000140073A90 RhpThrowHwEx 0 ABS Where the RVA 73000 is part of the .text section that is read, execute section. Having relocations done to the .text section is however not supported on all Windows platform configurations leading to loader errors blocking use of nativeaot on these configurations. This commit change the mov to a lea instruction using relative offset to calculate address of RhpThrowHwEx. That will end up with a REL32 relocation record in the generated object file: 000004ED REL32 00000000 2A RhpThrowHwEx Since this uses relative addressing it won't leave any relocation in the final image making sure the generated nativeaot image can be successfully loaded on Windows platforms with configurations preventing relocation in .text section.
1 parent 845dc11 commit d81ce00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/coreclr/nativeaot/Runtime/amd64/ExceptionHandling.asm

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ endif
532532
;; It was the ThreadAbortException, so rethrow it
533533
mov rcx, STATUS_REDHAWK_THREAD_ABORT
534534
mov rdx, rax ;; rdx <- continuation address as exception RIP
535-
mov rax, RhpThrowHwEx ;; Throw the ThreadAbortException as a special kind of hardware exception
535+
lea rax, [RhpThrowHwEx] ;; Throw the ThreadAbortException as a special kind of hardware exception
536536

537537
;; reset RSP and jump to RAX
538538
@@: mov rsp, r8 ;; reset the SP to resume SP value

0 commit comments

Comments
 (0)