File tree 2 files changed +10
-5
lines changed
src/librustc_codegen_llvm
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -1736,7 +1736,9 @@ extern "C" {
1736
1736
pub fn LLVMRustArchiveIteratorFree ( AIR : & ' a mut ArchiveIterator < ' a > ) ;
1737
1737
pub fn LLVMRustDestroyArchive ( AR : & ' static mut Archive ) ;
1738
1738
1739
- pub fn LLVMRustGetSectionName ( SI : & SectionIterator < ' _ > , data : & mut * const c_char ) -> size_t ;
1739
+ #[ allow( improper_ctypes) ]
1740
+ pub fn LLVMRustGetSectionName ( SI : & SectionIterator < ' _ > ,
1741
+ data : & mut Option < std:: ptr:: NonNull < c_char > > ) -> size_t ;
1740
1742
1741
1743
#[ allow( improper_ctypes) ]
1742
1744
pub fn LLVMRustWriteTwineToString ( T : & Twine , s : & RustString ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ use rustc_data_structures::owning_ref::OwningRef;
8
8
use rustc_codegen_ssa:: METADATA_FILENAME ;
9
9
10
10
use std:: path:: Path ;
11
- use std:: ptr;
12
11
use std:: slice;
13
12
use rustc_fs_util:: path_to_c_string;
14
13
@@ -67,10 +66,14 @@ fn search_meta_section<'a>(of: &'a ObjectFile,
67
66
unsafe {
68
67
let si = mk_section_iter ( of. llof ) ;
69
68
while llvm:: LLVMIsSectionIteratorAtEnd ( of. llof , si. llsi ) == False {
70
- let mut name_buf = ptr :: null ( ) ;
69
+ let mut name_buf = None ;
71
70
let name_len = llvm:: LLVMRustGetSectionName ( si. llsi , & mut name_buf) ;
72
- let name = slice:: from_raw_parts ( name_buf as * const u8 , name_len as usize ) . to_vec ( ) ;
73
- let name = String :: from_utf8 ( name) . unwrap ( ) ;
71
+ let name = name_buf. map_or (
72
+ "" . to_string ( ) ,
73
+ |buf| String :: from_utf8 (
74
+ slice:: from_raw_parts ( buf. as_ptr ( ) as * const u8 ,
75
+ name_len as usize )
76
+ . to_vec ( ) ) . unwrap ( ) ) ;
74
77
debug ! ( "get_metadata_section: name {}" , name) ;
75
78
if read_metadata_section_name ( target) == name {
76
79
let cbuf = llvm:: LLVMGetSectionContents ( si. llsi ) ;
You can’t perform that action at this time.
0 commit comments