Skip to content

Commit 513a079

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 33b0cee commit 513a079

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
@@ -428,6 +428,7 @@ pub mod __alloc_error_handler {
428428
// called via generated `__rust_alloc_error_handler` if there is no
429429
// `#[alloc_error_handler]`.
430430
#[rustc_std_internal_symbol]
431+
#[cfg(not(target_family = "solana"))]
431432
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
432433
extern "Rust" {
433434
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
@@ -444,4 +445,12 @@ pub mod __alloc_error_handler {
444445
)
445446
}
446447
}
448+
449+
#[rustc_std_internal_symbol]
450+
#[cfg(target_family = "solana")]
451+
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
452+
core::panicking::panic_nounwind_fmt(format_args!(
453+
"memory allocation of {size} bytes failed"
454+
))
455+
}
447456
}

0 commit comments

Comments
 (0)