File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -559,6 +559,13 @@ fn recovery_table() -> &'static [RecoveryDescriptor] {
559559 static STOP_TRY_COPY : [ RecoveryDescriptor ; 0 ] ;
560560 }
561561
562+ // Ensure the section exists even if there no recovery descriptors get
563+ // generated.
564+ #[ cfg_attr( target_os = "linux" , unsafe ( link_section = "try_copy" ) ) ]
565+ #[ cfg_attr( target_os = "macos" , link_section = "__TEXT,__try_copy,regular" ) ]
566+ #[ used]
567+ static ENSURE_EXISTS : [ RecoveryDescriptor ; 0 ] = [ ] ;
568+
562569 // SAFETY: accessing the trycopy section as defined above.
563570 unsafe {
564571 std:: slice:: from_raw_parts (
@@ -623,7 +630,10 @@ fn recovery_table() -> &'static [RecoveryDescriptor] {
623630 } )
624631 }
625632
626- let ( start, len) = find_section ( * b".trycopy" ) . expect ( "could not find .trycopy section" ) ;
633+ let Some ( ( start, len) ) = find_section ( * b".trycopy" ) else {
634+ // No recovery descriptors.
635+ return & [ ]
636+ } ;
627637 assert_eq ! ( len % size_of:: <RecoveryDescriptor >( ) , 0 ) ;
628638 // SAFETY: this section is made up solely of RecoveryDescriptor entries.
629639 unsafe {
You can’t perform that action at this time.
0 commit comments