Closed maurer closed 8 months ago
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:
@rustbot concern reason-for-concern
<description of the concern>
Concerns can be lifted with:
@rustbot resolve reason-for-concern
See documentation at https://forge.rust-lang.org
cc @rust-lang/compiler @rust-lang/compiler-contributors
Closing since this was converted into RFC 3543 which is now in FCP to accept.
Proposal
I am proposing that Rust support
patchable-function-entry
as present inclang
andgcc
. This feature is generally used to allow hotpatching and instrumentation of code.What
patchable-function-entry
provides configurable nop padding before function symbols and after function symbols but before any generated code. We refer to the former asprefix
padding and the latter asentry
padding. For example, if we had a functionf
withprefix
set to 3 andentry
to 2, we'd expect to see:f_pad
here is not a real symbol or label, it is only inserted here for explanatory purposes. A__patchable_function_entries
section will be added to the output object containing the addresses of eachf_pad
-like location in the object.prefix
andentry
correspond to the LLVM attribute implementation.The flag form instead uses
nop_count
andoffset
to match theclang
andgcc
flags for easier integration into build systems.Why
The Linux kernel uses
-fpatchable-function-entry
heavily, including forftrace
andFINEIBT
for x86. Today, enabling these features alongside Rust will lead to confusing or broken behavior (ftrace
will fail to trace Rust functions when developing,FINEIBT
will conflict with thekcfi
sanitizer, etc.).It also uses the
clang
andgcc
attributepatchable_function_entry
to disable this padding on fragile functions or those used for instrumentation. I have a companion RFC draft for this which covers both the flag described here and support for the attribute. This MCP is focused on just adding support for the flag, as this will unblock kernel work while we wait on RFC resolution for full support.Integrating Rust code into this and other large projects which expect all native code to have these nop buffers will be made easier by allowing them to request the same treatment of native functions they get in C and C++.
Mentors or Reviewers
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.