You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/3543-patchable-function-entry.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ nop
30
30
// Code goes here
31
31
```
32
32
33
-
To set this for all functions in a crate, use `-Z patchable-function-entry=nop_count,offset` where `nop_count = prefix + entry`, and `offset = prefix`. Usually, you'll want to copy this value from a corresponding `-fpatchable-function-entry=` being passed to the C compiler in your project.
33
+
To set this for all functions in a crate, use `-C patchable-function-entry=nop_count,offset` where `nop_count = prefix + entry`, and `offset = prefix`. Usually, you'll want to copy this value from a corresponding `-fpatchable-function-entry=` being passed to the C compiler in your project.
34
34
35
35
To set this for a specific function, use `#[patchable_function_entry(prefix(m), entry(n))]` to pad with m nops before the symbol and n after the symbol, but before the prelude. This will override the flag value.
36
36
@@ -64,18 +64,18 @@ Nop padding may not be supported on all architectures. As of the time of writing
64
64
`f_pad` addresses for every padded symbol are aggregated in the `__patchable_function_entries` section of the resulting object.
65
65
This is not a real symbol, just a collected location.
66
66
67
-
## Compiler flag `-Z patchable-function-entry`
67
+
## Compiler flag `-C patchable-function-entry`
68
68
69
69
This flag comes in two forms:
70
70
71
-
-`-Z patchable-function-entry=nop_count,offset`
72
-
-`-Z patchable-function-entry=nop_count`
71
+
-`-C patchable-function-entry=nop_count,offset`
72
+
-`-C patchable-function-entry=nop_count`
73
73
74
74
In the latter, offset is assumed to be zero. `nop_count` must be greater than or equal to `offset`, or it will be rejected.
75
75
76
76
If unspecified, the current behavior is maintained, which is equivalent to `=0` here.
77
77
78
-
This flag sets the default nop padding for all functions in the crate. Notably, this default *only applies to codegenned functions*. If a function is monomorphized during the compilation of another crate or any similar scenario, it will use the default from that crate's compilation. In most cases, all crates in a compilation should use the same value of `-Z patchable-function-entry` to reduce confusion.
78
+
This flag sets the default nop padding for all functions in the crate. Notably, this default *only applies to codegenned functions*. If a function is monomorphized during the compilation of another crate or any similar scenario, it will use the default from that crate's compilation. In most cases, all crates in a compilation should use the same value of `-C patchable-function-entry` to reduce confusion.
79
79
80
80
`prefix` is calculated as `offset`. `entry` is calculated as `nop_count - offset`. This unusual mode of specification is intended to mimic the compiler flags of `clang` and `gcc` for ease of build system integration.
81
81
@@ -102,7 +102,7 @@ This alternative runs the risk of the Rust-for-Linux experiment not leaving expe
102
102
The primary advantage of this design is that it does not require us to do anything.
103
103
104
104
### Only compiler flag
105
-
In this design, we only add the `-Z patchable-function-entry` flag and not the attribute. This is enough for today - it would allow Rust to participate in these schemes, and in the event that a user *deeply* needed an uninstrumented function, they could build it as a separate crate.
105
+
In this design, we only add the `-C patchable-function-entry` flag and not the attribute. This is enough for today - it would allow Rust to participate in these schemes, and in the event that a user *deeply* needed an uninstrumented function, they could build it as a separate crate.
106
106
107
107
This design has two drawbacks:
108
108
@@ -159,10 +159,10 @@ as modifiers to the attribute. We could make `prefix`/`entry` vs `nop_count`/`of
159
159
160
160
In addition to supporting `nop_count`/`offset` for attributes, we could support this on the command line as well. This would have three forms:
-`-C patchable-function-entry=nop_count=m,offset=n` (`nop_count=m`, `offset=n`, modern format, offset optional)
165
+
-`-C patchable-function-entry=prefix=m,entry=n` (`prefix=m`, `entry=n`, modern format, either optional)
166
166
167
167
This would have the benefit of making it more clear what's being specified and allowing users to employ the simpler format on the command line if not integrating with an existing build.
0 commit comments