https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82999
Bug ID: 82999 Summary: a func has two entrys: one inlined, another is normal Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zuogang at huawei dot com Target Milestone: --- centos 7 kernel: 3.10.0-693.2.2.el7.x86_64 global func tcp_v4_mtu_reduced has two entrys , one is inlined when called in the same file (such as func tcp_v4_err call tcp_v4_mtu_reduced), aother is a normal entry call the .part. stub. the inlined entry of tcp_v4_mtu_reduced (part of code of func tcp_v4_err): /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:445 ffffffff817663ab: 89 83 30 07 00 00 mov %eax,0x730(%rbx) /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:446 ffffffff817663b1: 75 26 jne ffffffff817663d9 <tcp_v4_err+0x499> tcp_v4_mtu_reduced(): /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:276 ffffffff817663b3: 0f b6 43 12 movzbl 0x12(%rbx),%eax ffffffff817663b7: ba 80 04 00 00 mov $0x480,%edx ffffffff817663bc: 0f a3 c2 bt %eax,%edx ffffffff817663bf: 0f 82 b7 fd ff ff jb ffffffff8176617c <tcp_v4_err+0x23c> ffffffff817663c5: 48 89 df mov %rbx,%rdi ffffffff817663c8: e8 43 e2 ff ff callq ffffffff81764610 <tcp_v4_mtu_reduced.part.29> ffffffff817663cd: 48 8d 83 80 00 00 00 lea 0x80(%rbx),%rax ffffffff817663d4: e9 aa fd ff ff jmpq ffffffff81766183 <tcp_v4_err+0x243> test_and_set_bit(): /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/arch/x86/include/asm/bitops.h:206 ffffffff817663d9: f0 0f ba ab 30 05 00 lock btsl $0x5,0x530(%rbx) ffffffff817663e0: 00 05 ffffffff817663e2: 0f 82 94 fd ff ff jb ffffffff8176617c <tcp_v4_err+0x23c> the normal entry of tcp_v4_mtu_reduced: ffffffff817646c0 <tcp_v4_mtu_reduced>: tcp_v4_mtu_reduced(): /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:271 ffffffff817646c0: e8 3b f6 0b 00 callq ffffffff81823d00 <__fentry__> ffffffff817646c1: R_X86_64_PC32 __fentry__-0x4 /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:276 ffffffff817646c5: 0f b6 47 12 movzbl 0x12(%rdi),%eax ffffffff817646c9: ba 80 04 00 00 mov $0x480,%edx ffffffff817646ce: 0f a3 c2 bt %eax,%edx ffffffff817646d1: 73 01 jae ffffffff817646d4 <tcp_v4_mtu_reduced+0x14> /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:303 ffffffff817646d3: c3 retq /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:271 ffffffff817646d4: 55 push %rbp ffffffff817646d5: 48 89 e5 mov %rsp,%rbp ffffffff817646d8: e8 33 ff ff ff callq ffffffff81764610 <tcp_v4_mtu_reduced.part.29> /usr/src/debug/kernel-4.9.el7.centos/linux-4.9.54-203.el7.centos.x86_64/net/ipv4/tcp_ipv4.c:303 ffffffff817646dd: 5d pop %rbp ffffffff817646de: 66 90 xchg %ax,%ax ffffffff817646e0: c3 retq gcc generated code like this make ftrace and other kernel tools functions abnormal, when a func is called, ftrace cannot knew it, so I think when gcc want to do some works about generate stub func .part., should know the target func is global or not, if it is global, don't do like that, it will make a func has two entrys and confuse the kernel and peoples.