https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78932

            Bug ID: 78932
           Summary: [ARM] -O2 generates wrong code
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xqr4n54r1 at hotmail dot com
  Target Milestone: ---
              Host: arm-linux
            Target: arm-linux-uclibcgnueabi
             Build: x86_64-pc-linux-gnu

Created attachment 40414
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40414&action=edit
Attachment has following :   - filter_with_O2.{c|i|s} :  Indicates that the
problem has occurred.  - filter_without_bbro.{c|i|s} : Indicates solution that
compile without bbro  I mentioned above as 1.

I compiled the linux-2.6.27
(https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tag/?h=v2.6.37)
for broadcom arm. I noticed that the chksum of some TCP packages was broken. I
found the function (sk_run_filter:filter.c) that was the problem, and I made
the following changes on it to fix the problem.

1. unsigned int __attribute__((optimize("-fno-reorder-blocks")))
sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)

2. unsigned int __attribute__((optimize("-Os"))) sk_run_filter(struct sk_buff
*skb, struct sock_filter *filter, int flen)

3. unsigned int __attribute__((optimize("-O1"))) sk_run_filter(struct sk_buff
*skb, struct sock_filter *filter, int flen)

4. static void *load_pointer(struct sk_buff *skb, int k, unsigned int size,
void *buffer)  -> the inline function used is removed inline keyword.

--> These above results brought me to a bug of optimize gcc.

Compile options:

arm-linux-gcc -Wp,-MD,net/core/.filter.o.d  -nostdinc -isystem
/usr/lib/arm-linux-uclibcgnueabi/4.5.3/include
-I/kernel/linux-2_6.37/arch/arm/include -Iinclude  -include
include/generated/autoconf.h -D__KERNEL__ -mlittle-endian
-Iarch/arm/mach-brcm-hnd/include -Iarch/arm/plat-brcm/include -Wall -Wundef
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-Werror-implicit-function-declaration -Wno-format-security
-fno-delete-null-pointer-checks -fwrapv -Dlinux -DHNDCTF -DCTFPOOL -DCTFMAP
-DPKTC -DCTF_IPV6 -O2 -marm -ffreestanding -fno-dwarf2-cfi-asm
-mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7
-march=armv7-a -msoft-float -Uarm -ggdb -Wframe-larger-than=2048
-fno-stack-protector -fomit-frame-pointer -Wdeclaration-after-statement
-Wno-pointer-sign -fno-strict-overflow -fconserve-stack   
-D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(filter)" 
-D"KBUILD_MODNAME=KBUILD_STR(filter)"  -c -o net/core/.tmp_filter.o
net/core/filter.c

--------------------------

Attachment has following :

 - filter_with_O2.{c|i|s} :  Indicates that the problem has occurred.
 - filter_without_bbro.{c|i|s} : Indicates solution that compile without bbro 
I mentioned above as 1.
 - filter_without_inline.{c|i|s} : Indicates solution that compile without
inline I mentioned above as 4.

Reply via email to