这个电话去哪儿了?

Where does this call go?

也许这对cpp开发者来说太简单了,我想不通..

在第“3f”行和“2d”行的这个简单目标文件中,寻址是如何工作的? 14和0索引从何而来?

2d:   e8 e2 ff ff ff          callq  14 <_ZL9privatef2v>
3f:   e8 bc ff ff ff          callq  0 <_ZL8privatefii>

全反汇编:

Disassembly of section .text:

0000000000000000 <_ZL8privatefii>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   89 7d fc                mov    %edi,-0x4(%rbp)
   7:   89 75 f8                mov    %esi,-0x8(%rbp)
   a:   8b 45 f8                mov    -0x8(%rbp),%eax
   d:   8b 55 fc                mov    -0x4(%rbp),%edx
  10:   01 d0                   add    %edx,%eax
  12:   5d                      pop    %rbp
  13:   c3                      retq

0000000000000014 <_ZL9privatef2v>:
  14:   55                      push   %rbp
  15:   48 89 e5                mov    %rsp,%rbp
  18:   b8 86 00 00 00          mov    [=11=]x86,%eax
  1d:   5d                      pop    %rbp
  1e:   c3                      retq

000000000000001f <_Z3fooii>:
  1f:   55                      push   %rbp
  20:   48 89 e5                mov    %rsp,%rbp
  23:   48 83 ec 18             sub    [=11=]x18,%rsp
  27:   89 7d ec                mov    %edi,-0x14(%rbp)
  2a:   89 75 e8                mov    %esi,-0x18(%rbp)
  2d:   e8 e2 ff ff ff          callq  14 <_ZL9privatef2v>
  32:   89 45 fc                mov    %eax,-0x4(%rbp)
  35:   8b 55 e8                mov    -0x18(%rbp),%edx
  38:   8b 45 fc                mov    -0x4(%rbp),%eax
  3b:   89 d6                   mov    %edx,%esi
  3d:   89 c7                   mov    %eax,%edi
  3f:   e8 bc ff ff ff          callq  0 <_ZL8privatefii>
  44:   c9                      leaveq
  45:   c3                      retq

0000000000000046 <main>:
  46:   55                      push   %rbp
  47:   48 89 e5                mov    %rsp,%rbp
  4a:   48 83 ec 10             sub    [=11=]x10,%rsp
  4e:   be 0a 00 00 00          mov    [=11=]xa,%esi
  53:   bf 0a 00 00 00          mov    [=11=]xa,%edi
  58:   e8 00 00 00 00          callq  5d <main+0x17>
  5d:   89 45 fc                mov    %eax,-0x4(%rbp)
  60:   b8 00 00 00 00          mov    [=11=]x0,%eax
  65:   c9                      leaveq
  66:   c3                      retq

搬迁table:

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE
0000000000000059 R_X86_64_PC32     _Z3fooii-0x0000000000000004


RELOCATION RECORDS FOR [.eh_frame]:
OFFSET           TYPE              VALUE
0000000000000020 R_X86_64_PC32     .text
0000000000000040 R_X86_64_PC32     .text+0x0000000000000014
0000000000000060 R_X86_64_PC32     .text+0x000000000000001f
0000000000000080 R_X86_64_PC32     .text+0x0000000000000046

callq N, text 指令中,N 似乎是要调用的地址,文本似乎是分配给该地址的标签。因此,0 与 <_ZL8privatefii> 相同,14 与 <_ZL9privatef2v> 相同。