Given the following C function:
void go(char *data) {
char name[64];
strcpy(name, data);
}
GCC 5 and 6 on x86-64 compile (plain gcc -c -g -o
followed by objdump
) this to:
0000000000000000 <go>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 83 ec 50 sub $0x50,%rsp
8: 48 89 7d b8 mov %rdi,-0x48(%rbp)
c: 48 8b 55 b8 mov -0x48(%rbp),%rdx
10: 48 8d 45 c0 lea -0x40(%rbp),%rax
14: 48 89 d6 mov %rdx,%rsi
17: 48 89 c7 mov %rax,%rdi
1a: e8 00 00 00 00 callq 1f <go+0x1f>
1f: 90 nop
20: c9 leaveq
21: c3 retq
Is there any reason for GCC to insert the 90
/nop
at 1f
or is that just a side-effect that might happen when no optimizations are turned on?
Note: This question is different from most others because it asks about nop
inside a function body, not an external padding.
Compiler versions tested: GCC Debian 5.3.1-14 (5.3.1) and Debian 6-20160313-1 (6.0.0)