Skip to content

Commit dc81fc5

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Set default visibility of symbols in SBF binaries to hidden
Make a solana specific version of __rdl_oom handler that doesn't use a static variable. This variable can't be supported is Solana execution environment.
1 parent be84ef8 commit dc81fc5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler/rustc_target/src/spec/sbf_base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SECTIONS
3636
TargetOptions {
3737
allow_asm: true,
3838
c_int_width: "64".into(),
39+
default_hidden_visibility: true,
3940
dll_prefix: "".into(),
4041
dynamic_linking: true,
4142
eh_frame_header: false,

library/alloc/src/alloc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ pub mod __alloc_error_handler {
407407
// called via generated `__rust_alloc_error_handler` if there is no
408408
// `#[alloc_error_handler]`.
409409
#[rustc_std_internal_symbol]
410+
#[cfg(not(target_family = "solana"))]
410411
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
411412
extern "Rust" {
412413
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
@@ -423,6 +424,14 @@ pub mod __alloc_error_handler {
423424
)
424425
}
425426
}
427+
428+
#[rustc_std_internal_symbol]
429+
#[cfg(target_family = "solana")]
430+
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
431+
core::panicking::panic_nounwind_fmt(format_args!(
432+
"memory allocation of {size} bytes failed"
433+
))
434+
}
426435
}
427436

428437
#[cfg(not(no_global_oom_handling))]

0 commit comments

Comments
 (0)