File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -66,3 +66,17 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
6666extern "C" fn __stack_chk_fail ( ) -> ! {
6767 explode ( "stack smashing detected" ) ;
6868}
69+
70+ // Stack canary value for stack protection. In a production system, this would
71+ // be randomized at startup, but for nix-ld's minimal environment, a constant
72+ // suffices to satisfy the linker requirements from libcompiler_builtins.
73+ #[ unsafe( no_mangle) ]
74+ static __stack_chk_guard: usize = 0x1234567890abcdef_u64 as usize ;
75+
76+ // On 32-bit systems, PIC code uses __stack_chk_fail_local instead of __stack_chk_fail
77+ // as an optimization to avoid going through the PLT
78+ #[ cfg( target_pointer_width = "32" ) ]
79+ #[ unsafe( no_mangle) ]
80+ extern "C" fn __stack_chk_fail_local ( ) -> ! {
81+ explode ( "stack smashing detected" ) ;
82+ }
You can’t perform that action at this time.
0 commit comments