文章预览
点击上方 蓝字 江湖评谈 设为关注/星标 前言 先看下rust-glibc/musl再看下.net-glibc。 rust-glibc 从linux内核态到用户态的第一个函数: // https://elixir.bootlin.com/glibc/glibc-2.35/source/sysdeps/x86_64/start.S ENTRY (_start) /* Clearing frame pointer is insufficient, use CFI. */ cfi_undefined (rip) /* Clear the frame pointer. The ABI suggests this be done, to mark the outermost frame obviously. */ xorl %ebp, %ebp mov %RDX_LP, %R9_LP /* Address of the shared library termination function. */ # ifdef __ILP32__ mov (%rsp), %esi /* Simulate popping 4-byte argument count. */ add $ 4 , %esp # else popq %rsi /* Pop the argument count. */ # endif /* argv starts just at the current stack top. */ mov %RSP_LP, %RDX_LP /* Align the stack to a 16 byte boundary to follow the ABI. */ and $~ 15 , %RSP_LP /* Push garbage because we push 8 more bytes. */ pushq %rax /* Provide the highest stack
………………………………