File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
compiler/rustc_codegen_ssa/src/back Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2064,9 +2064,23 @@ fn add_linked_symbol_object(
2064
2064
if let Err ( error) = result {
2065
2065
sess. dcx ( ) . emit_fatal ( errors:: FailedToWrite { path, error } ) ;
2066
2066
}
2067
+ if sess. target . arch == "sbf" {
2068
+ patch_synthetic_object_file ( sess, & path) ;
2069
+ }
2067
2070
cmd. add_object ( & path) ;
2068
2071
}
2069
2072
2073
+ fn patch_synthetic_object_file ( sess : & Session , path : & PathBuf ) {
2074
+ const EM_SBF : [ u8 ; 2 ] = [ 0x07 , 0x01 ] ;
2075
+ if let Ok ( mut sf) = fs:: OpenOptions :: new ( ) . write ( true ) . open ( path) {
2076
+ if let Ok ( _) = sf. seek ( SeekFrom :: Start ( 0x12 ) ) {
2077
+ sf. write ( & EM_SBF ) . unwrap ( ) ;
2078
+ }
2079
+ } else {
2080
+ sess. fatal ( & format ! ( "failed to patch {}" , path. display( ) ) ) ;
2081
+ }
2082
+ }
2083
+
2070
2084
/// Add object files containing code from the current crate.
2071
2085
fn add_local_crate_regular_objects ( cmd : & mut dyn Linker , codegen_results : & CodegenResults ) {
2072
2086
for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
You can’t perform that action at this time.
0 commit comments