gpt4 book ai didi

rust - 如何将 Stack Canaries 添加到 Rust 可执行文件中?

转载 作者:行者123 更新时间:2023-11-29 07:46:04 25 4
gpt4 key购买 nike

我正在尝试强化我正在处理的项目中的一些可执行文件。为了测试,我使用了一个 hello world 程序,并使用 checksec 检查它。 ,它报告没有金丝雀。我是 Rust 的新手,Google 上缺乏信息让我觉得我遗漏了一些明显的东西。

对于 GCC,这是一个简单的编译器标志:-fstack-protector-all。我为 LLVM 找到的最接近的东西是 safe stack .但是,当我尝试将它传递给 LLVM 时,Rust 编译器似乎无法识别它。例如:

rustc -C llvm-args="-fsanitize=safe-stack" -C link-arg="-fsanitize=safe-stack" test.rust

结果

rustc: Unknown command line argument '-fsanitize=safe-stack'. Try: 'rustc -help' rustc: Did you mean '-spp-no-call'?

我正在使用 Rust 1.23.0。我试图不仅在 x86_64 上添加这些金丝雀,还在 armeabi-v7a 上添加这些金丝雀,以防相关。

最佳答案

目前不支持:

We updated LLVM so there's support for this [safe stack attribute] in our LLVM, and I think that turning this on by default probably wants some investigation and likely an RFC first, so I'm going to close this for now.

-- alexcrichton https://github.com/rust-lang/rust/issues/26612

我找不到此功能的 RFC。

编辑:通过 -Z stack-protector 在 nightly Rust 上提供对堆栈金丝雀的支持 https://github.com/rust-lang/rust/pull/84197

关于rust - 如何将 Stack Canaries 添加到 Rust 可执行文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48547475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com