@@ -379,6 +379,8 @@ mod desc {
379379 pub const parse_passes: & str = "a space-separated list of passes, or `all`" ;
380380 pub const parse_panic_strategy: & str = "either `unwind` or `abort`" ;
381381 pub const parse_on_broken_pipe: & str = "either `kill`, `error`, or `inherit`" ;
382+ pub const parse_patchable_function_entry: & str =
383+ "nop_count,entry_offset or nop_count (defaulting entry_offset=0)" ;
382384 pub const parse_opt_panic_strategy: & str = parse_panic_strategy;
383385 pub const parse_oom_strategy: & str = "either `panic` or `abort`" ;
384386 pub const parse_relro_level: & str = "one of: `full`, `partial`, or `off`" ;
@@ -709,6 +711,7 @@ mod parse {
709711 true
710712 }
711713
714+
712715 pub ( crate ) fn parse_on_broken_pipe ( slot : & mut OnBrokenPipe , v : Option < & str > ) -> bool {
713716 match v {
714717 // OnBrokenPipe::Default can't be explicitly specified
@@ -720,6 +723,30 @@ mod parse {
720723 true
721724 }
722725
726+ pub ( crate ) fn parse_patchable_function_entry (
727+ slot : & mut PatchableFunctionEntry ,
728+ v : Option < & str > ,
729+ ) -> bool {
730+ let mut nop_count = 0 ;
731+ let mut offset = 0 ;
732+
733+ if !parse_number ( & mut nop_count, v) {
734+ let parts = v. and_then ( |v| v. split_once ( ',' ) ) . unzip ( ) ;
735+ if !parse_number ( & mut nop_count, parts. 0 ) {
736+ return false ;
737+ }
738+ if !parse_number ( & mut offset, parts. 1 ) {
739+ return false ;
740+ }
741+ }
742+
743+ if let Some ( pfe) = PatchableFunctionEntry :: from_nop_count_and_offset ( nop_count, offset) {
744+ * slot = pfe;
745+ return true ;
746+ }
747+ false
748+ }
749+
723750 pub ( crate ) fn parse_oom_strategy ( slot : & mut OomStrategy , v : Option < & str > ) -> bool {
724751 match v {
725752 Some ( "panic" ) => * slot = OomStrategy :: Panic ,
@@ -1859,6 +1886,8 @@ options! {
18591886 "panic strategy for panics in drops" ) ,
18601887 parse_only: bool = ( false , parse_bool, [ UNTRACKED ] ,
18611888 "parse only; do not compile, assemble, or link (default: no)" ) ,
1889+ patchable_function_entry: PatchableFunctionEntry = ( PatchableFunctionEntry :: default ( ) , parse_patchable_function_entry, [ TRACKED ] ,
1890+ "nop padding at function entry" ) ,
18621891 plt: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
18631892 "whether to use the PLT when calling into shared libraries;
18641893 only has effect for PIC code on systems with ELF binaries
0 commit comments