I want to trace the goid of go programs using ebpf
.
After reading for some posts and blogs, I know that %fs:0xfffffffffffffff8
points to the g
struct of go and mov %fs:0xfffffffffffffff8,%rcx
instruction always appear at the start of a go function.
Taking main.main
as an example:
func main() {
177341 458330: 64 48 8b 0c 25 f8 ff mov %fs:0xfffffffffffffff8,%rcx
177342 458337: ff ff
177343 458339: 48 3b 61 10 cmp 0x10(%rcx),%rsp
177344 45833d: 76 1a jbe 458359 <main.main+0x29>
177345 45833f: 48 83 ec 08 sub $0x8,%rsp
177346 458343: 48 89 2c 24 mov %rbp,(%rsp)
177347 458347: 48 8d 2c 24 lea (%rsp),%rbp
177348 myFunc()
177349 45834b: e8 10 00 00 00 callq 458360 <main.myFunc>
177350 }
I also know the goid information is stored in the g
struct of go. The value of fs register can be obtained via the ctx
argument of ebpf
function.
But I don't know what the real address of %fs:0xfffffffffffffff8
because I am new to assembly language. Could anyone give me some hints?
If the value of fs register were 0x88, what is the value of %fs:0xfffffffffffffff8
?