切换到GCC 4.8后,我们注意到某些函数的代码以调用指令结束,如下所示:
0000000000000167 <function_a>:
167: 55 push %rbp
168: 89 fe mov %edi,%esi
16a: 48 8d 3d 00 00 00 00 lea 0x0(%rip),%rdi # 171 <function_a+0xa>
16d: R_X86_64_PC32 .LC0-0x4
171: 31 c0 xor %eax,%eax
173: 48 89 e5 mov %rsp,%rbp
176: e8 00 00 00 00 callq 17b <function_a+0x14>
177: R_X86_64_PLT32 function_c-0x4
17b: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 182 <function_a+0x1b>
17e: R_X86_64_PC32 .rodata+0x6afc
182: 48 8d 35 00 00 00 00 lea 0x0(%rip),%rsi # 189 <function_a+0x22>
185: R_X86_64_PC32 .LC1-0x4
189: 48 8d 3d 00 00 00 00 lea 0x0(%rip),%rdi # 190 <function_a+0x29>
18c: R_X86_64_PC32 .LC2-0x4
190: ba 88 00 00 00 mov $0x88,%edx
195: e8 00 00 00 00 callq 19a <function_b>
196: R_X86_64_PLT32 __assert_fail-0x4
000000000000019a <function_b>:
19a: 55 push %rbp
...
我们的程序尝试在某些情况下收集回溯,但在这种情况下我们的算法被破坏,因为返回地址属于另一个函数。
有没有办法禁止GCC生成这种类型的函数结束?