Skip to content
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

[Mono.Cecil] Enforce empty body when a MethodDefinition's rva value is 0 #475

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

steveisok
Copy link
Member

The prior behavior assumed a MethodDefinition's RVA value of 0 meant an effectively empty body with a single RET instruction. This change removes the RET insertion and leaves the method completely empty. This is important for mono's UnsafeAccessor detection around methods specified as extern as it uses a quicker method of an empty vs non-empty body to bypass loading / checking custom attributes.

Fixes dotnet/runtime#102045

The prior behavior assumed a MethodDefinition's RVA value of 0 meant an effectively empty body with a single RET instruction. This change removes
the RET insertion and leaves the method completely empty. This is important for mono's UnsafeAccessor detection around methods specified as extern as it
uses a quicker method of an empty vs non-empty body to bypass loading / checking custom attributes.

Fixes dotnet/runtime#102045
@steveisok steveisok merged commit 3ed40d4 into dotnet:main Aug 7, 2024
6 checks passed
@steveisok steveisok deleted the enforce-no-body branch August 7, 2024 17:20
@akoeplinger
Copy link
Member

@steveisok this will need some changes to tests once it flows to runtime since we detect the ret pattern, see https://github.com/dotnet/runtime/pull/88167/files for the cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ILStrip task incorrectly adds a body to extern methods
3 participants