gpt4 book ai didi

c - 如何使C程序的堆栈可执行?

转载 作者:行者123 更新时间:2023-12-02 05:17:18 25 4
gpt4 key购买 nike

有没有办法通过编译使 C 程序的堆栈可执行?

我做了

$ gcc -o convert -g convert

然后运行
$ readelf -l convert

检查堆栈是否可执行,但输出为:
GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4

最佳答案

与公认的答案所暗示的不同,使堆栈可执行的正确方法不需要禁用堆栈金丝雀。

这是正确的方法:

gcc -z execstack ...

这是做什么的, -z gcc 的选项传递给链接器 [ source ]:

keyword

-z is passed directly on to the linker along with the keyword keyword. See the section in the documentation of your linker for permitted values and their meanings.



来自 man ld [ source ]:

execstack

Marks the object as requiring executable stack.

关于c - 如何使C程序的堆栈可执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29272431/

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