文章预览
点击上方 蓝字 江湖评谈 设为关注/星标 前言 前一篇: 从.NET9看Golang ,里面了解了下Go可执行文件,Main入口并没有经过Glibc,而是有Go自己的库调用的。本篇继续扩展,看下Rust。 先说下结论,实际上 经过个人测试,除了Go, Rust/.NET/C/C++都是 经过Glibc来调用Main的。 问题 首先解决下上一篇 从.NET9看Golang 的一个问题,也即是Go的main调用地方实际上是/usr/lib/go-1.18/src/runtime/proc.go:259堆栈处,实际249处,代码如下: func main() { 146 g := getg() 147 148 // Racectx of m0->g0 is used only as the parent of the main goroutine. 149 // It must not be used for anything else. 150 g.m.g0.racectx = 0 151 152 // Max stack size is 1 GB on 64-bit, 250 MB on 32-bit. 153 // Using decimal instead of binary GB and MB because 154 // they look nicer in the stack overflow failure message. 155
………………………………