Why is the heap in Go executable?

  • A+

I recently read this article http://codearcana.com/posts/2012/05/06/securing-and-exploiting-go-binaries.html which claims in Go that the heap is executable. This raises a few different questions for me about the interaction between the runtime and the operating system.

In C, when a program needs space on the heap, it makes a call to malloc, which in turn calls sbrk which gives it memory. As far as I know in C the heap is read-write only.

Why is the heap in Go executable? What is different about the application - OS interaction in Go then in C?



The heap is no longer executable.

Code was generated at runtime for function literals prior to Go 1.1, thus requiring an executable heap. Function calls were revamped in Go 1.1 to eliminate the need for an executable heap and to provide other benefits.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: