Skip to content

Commit 3ce4ae7

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 d9154bd commit 3ce4ae7

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
@@ -424,6 +424,7 @@ pub mod __alloc_error_handler {
424424
// called via generated `__rust_alloc_error_handler` if there is no
425425
// `#[alloc_error_handler]`.
426426
#[rustc_std_internal_symbol]
427+
#[cfg(not(target_family = "solana"))]
427428
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
428429
unsafe extern "Rust" {
429430
// 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)