Skip to content

Commit 6c3fe0e

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 6663b45 commit 6c3fe0e

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
@@ -405,6 +405,7 @@ pub mod __alloc_error_handler {
405405
// called via generated `__rust_alloc_error_handler` if there is no
406406
// `#[alloc_error_handler]`.
407407
#[rustc_std_internal_symbol]
408+
#[cfg(not(target_family = "solana"))]
408409
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
409410
extern "Rust" {
410411
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
@@ -421,6 +422,14 @@ pub mod __alloc_error_handler {
421422
)
422423
}
423424
}
425+
426+
#[rustc_std_internal_symbol]
427+
#[cfg(target_family = "solana")]
428+
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
429+
core::panicking::panic_nounwind_fmt(format_args!(
430+
"memory allocation of {size} bytes failed"
431+
))
432+
}
424433
}
425434

426435
/// Specialize clones into pre-allocated, uninitialized memory.

0 commit comments

Comments
 (0)