0
I compile docker-client by "hack/make.sh dynbinary" successfuly.
docker-17.06.0-dev: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32
But, the symbol in main.main is local, such as time.Now.
Thread 1 "docker-17.06.0-" hit Breakpoint 1, 0x0000000000404d10 in main.main ()
(gdb) disas
Dump of assembler code for function main.main:
0x0000000000404dcf <+191>: callq 0x4651a0 <fmt.Println>
0x0000000000404dd4 <+196>: callq 0x4b8b70 <time.Now>
when the demo program is compiled by "go build -compiler=gccgo", the symbol is external, as shown.
Thread 1 "test_2" hit Breakpoint 1, main.main () at /usr1/Code_Practice/Golang/src/test/test.go:7
(gdb) disas
Dump of assembler code for function main.main:
0x0000000000401fd6 <+224>: callq 0x401cd0 <fmt.Println@plt>
0x0000000000401fdb <+229>: add $0x20,%rsp
0x0000000000401fdf <+233>: mov -0xd0(%rbp),%rax
0x0000000000401fe6 <+240>: mov %rax,-0x1a0(%rbp)
0x0000000000401fed <+247>: mov -0xc8(%rbp),%rax
0x0000000000401ff4 <+254>: mov %rax,-0x198(%rbp)
0x0000000000401ffb <+261>: mov -0xc0(%rbp),%rax
0x0000000000402002 <+268>: mov %rax,-0x190(%rbp)
0x0000000000402009 <+275>: lea -0x170(%rbp),%rax
0x0000000000402010 <+282>: mov %rax,%rdi
0x0000000000402013 <+285>: callq 0x401cf0 <time.Now@plt>
Also, the different compile methods will result the different time.now.
Dump of assembler code for function time.now:
=> 0x000000000047ef50 <+0>: sub $0x18,%rsp
0x000000000047ef54 <+4>: xor %edi,%edi
0x000000000047ef56 <+6>: mov %rsp,%rsi
0x000000000047ef59 <+9>: callq 0x527bc0 <clock_gettime>
0x000000000047ef5e <+14>: mov 0x8(%rsp),%edx
0x000000000047ef62 <+18>: mov (%rsp),%rax
0x000000000047ef66 <+22>: add $0x18,%rsp
0x000000000047ef6a <+26>: retq
End of assembler dump.
Dump of assembler code for function time.now:
=> 0x0000000000483250 <+0>: sub $0x18,%rsp
0x0000000000483254 <+4>: xor %edi,%edi
0x0000000000483256 <+6>: mov %rsp,%rsi
0x0000000000483259 <+9>: callq 0x404060 <clock_gettime@plt>
0x000000000048325e <+14>: mov 0x8(%rsp),%edx
0x0000000000483262 <+18>: mov (%rsp),%rax
0x0000000000483266 <+22>: add $0x18,%rsp
0x000000000048326a <+26>: retq
End of assembler dump.
Dump of assembler code for function time.now:
=> 0x00000000004566b0 <+0>: sub $0x10,%rsp
0x00000000004566b4 <+4>: mov 0x1484d5(%rip),%rax # 0x59eb90 <runtime.__vdso_clock_gettime_sym>
0x00000000004566bb <+11>: cmp $0x0,%rax
0x00000000004566bf <+15>: je 0x4566e0 <time.now+48>
0x00000000004566c1 <+17>: xor %edi,%edi
0x00000000004566c3 <+19>: lea (%rsp),%rsi
0x00000000004566c7 <+23>: callq *%rax
I wanna compile docker to a pure dynamically linked binary, meaning that the symbol is external, resoluted by plt and got. For the purpose that I can hook it by LD_PRELOAD. May someone show me some method?