Skip to content

Commit e138b57

Browse files
dmakarovc410-f3r
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 eb3215d commit e138b57

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
@@ -425,6 +425,7 @@ pub mod __alloc_error_handler {
425425
// called via generated `__rust_alloc_error_handler` if there is no
426426
// `#[alloc_error_handler]`.
427427
#[rustc_std_internal_symbol]
428+
#[cfg(not(target_family = "solana"))]
428429
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
429430
extern "Rust" {
430431
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
@@ -441,4 +442,12 @@ pub mod __alloc_error_handler {
441442
)
442443
}
443444
}
445+
446+
#[rustc_std_internal_symbol]
447+
#[cfg(target_family = "solana")]
448+
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
449+
core::panicking::panic_nounwind_fmt(format_args!(
450+
"memory allocation of {size} bytes failed"
451+
))
452+
}
444453
}

0 commit comments

Comments
 (0)