Files
rust/tests/ui/patchable-function-entry/patchable-function-entry-attribute.rs
T
Paul Murphy c340e8a2ba Allow section override when using patchable-function-entries
Sometimes it is necessary to group patchable function entrypoint
records in distinct linker sections. This is the case for some bpf
functions within the linux kernel which shouldn't be visible to
ftrace.

Extend `-Zpatchable-function-entry` to accept an argument of the form
`prefix_nops,total_nops,record_section`, which places all entry
record into a user specified section.

Likewise, extend the `patchable_function_entry` attribute to accept an
optional `section="name"` option to place a function into a specific
section.

This is made possible by llvm attribute `patchable-function-entry-section`
added in llvm 21.
2026-06-29 08:52:28 -05:00

43 lines
1.1 KiB
Rust

#![feature(patchable_function_entry)]
fn main() {}
#[patchable_function_entry(prefix_nops = 256, entry_nops = 0)]
//~^ ERROR malformed
pub fn too_high_pnops() {}
#[patchable_function_entry(prefix_nops = "stringvalue", entry_nops = 0)]
//~^ ERROR malformed
pub fn non_int_nop() {}
#[patchable_function_entry]
//~^ ERROR malformed `patchable_function_entry` attribute input
pub fn malformed_attribute() {}
#[patchable_function_entry(prefix_nops = 10, something = 0)]
//~^ ERROR malformed
pub fn unexpected_parameter_name() {}
#[patchable_function_entry()]
//~^ ERROR malformed
pub fn no_parameters_given() {}
#[patchable_function_entry(prefix_nops = 255, prefix_nops = 255)]
//~^ ERROR malformed
pub fn duplicate_parameter() {}
#[patchable_function_entry(section = 255)]
//~^ ERROR malformed
pub fn invalid_section_parameter() {}
#[patchable_function_entry(section = "foo", section = "bar")]
//~^ ERROR malformed
pub fn duplicate_section_parameter() {}
#[patchable_function_entry(section = "fo\0o")]
//~^ ERROR null characters
pub fn nul_in_section_parameter() {}
#[patchable_function_entry(section = "")]
//~^ ERROR empty
pub fn empty_section_parameter() {}