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.
This commit is contained in:
Paul Murphy
2026-06-03 16:40:12 -05:00
parent 7dc2c162b9
commit c340e8a2ba
18 changed files with 257 additions and 74 deletions

View File

@@ -24,3 +24,19 @@ 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() {}