lto: handle Apple platforms correctly by eliding __LLVM, from section name

This commit is contained in:
Augie Fackler 2023-09-07 11:56:25 -04:00
parent 942bdf910c
commit 9ad0396a34

View File

@ -154,7 +154,10 @@ fn get_bitcode_slice_from_object_data<'a>(
if obj.starts_with(b"\xDE\xC0\x17\x0B") || obj.starts_with(b"BC\xC0\xDE") {
return Ok(obj);
}
let section_name = bitcode_section_name(cgcx);
// We drop the "__LLVM," prefix here because on Apple platforms there's a notion of "segment name"
// which in the public API for sections gets treated as part of the section name, but internally
// in MachOObjectFile.cpp gets treated separately.
let section_name = bitcode_section_name(cgcx).trim_start_matches("__LLVM,");
let mut len = 0;
let data = unsafe {
llvm::LLVMRustGetSliceFromObjectDataByName(