-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RhpCallCatchFunclet .text relocation on amd64. #111227
base: main
Are you sure you want to change the base?
Fix RhpCallCatchFunclet .text relocation on amd64. #111227
Conversation
dotnet@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.
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM assuming CET pipeline in outerloop is green (cc @VSadov in case there are some CET considerations in general). Thanks!
c8e4f2c changed asm implementation in
RhpThrowHwEx
on amd64 from a relative jump, usingjmp RhpThrowHwEx
to amov rax, RhpThrowHwEx
that is later jumped to usingjmp rax
.This introduce an
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:
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 ofRhpThrowHwEx
. That will end up with aREL32
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 configurations that prevents relocations to .text section.