为什么Go中的堆是可执行的?

时间:2018-09-25 02:33:27

标签: go memory-management operating-system heap-memory exploit

我最近阅读了这篇文章http://codearcana.com/posts/2012/05/06/securing-and-exploiting-go-binaries.html 在Go中声称堆是可执行的。关于运行时和操作系统之间的交互,这给我提出了一些不同的问题。

在C语言中,当程序在堆上需要空间时,它将调用malloc,后者依次调用sbrk并为其提供内存。据我所知,在C中堆是只读的。

为什么Go中的堆是可执行文件?应用程序有何不同-Go语言中的OS与C语言中的OS交互?

谢谢

2 个答案:

答案 0 :(得分:9)

heap is no longer executable

代码是在运行时为Go 1.1之前的函数文字生成的,因此需要可执行堆。函数调用是revamped in Go 1.1,以消除对可执行堆的需求并提供其他好处。

答案 1 :(得分:5)

  

为什么Go中的堆是可执行文件?

自2013年以来,Go堆不可执行。