http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46141

           Summary: -fno-builtin-strstr changes __builtin_strstr
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: hjl.to...@gmail.com


I don't expect -fno-builtin-strstr to change the behavior
of __builtin_strstr.  But I got

[...@gnu-6 asm-1]$ cat x.c
extern char *strstr(const char *, const char *) __asm ("my_strstr");
char *foo (const char *a, const char *b)
{
  return __builtin_strstr (a, b);
}
[...@gnu-6 asm-1]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O -S x.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -fno-builtin-strstr -O -S x.c
-o y.s
[...@gnu-6 asm-1]$ cat x.s 
    .file    "x.c"
    .text
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    call    my_strstr
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc
.LFE0:
    .size    foo, .-foo
    .ident    "GCC: (GNU) 4.6.0 20101021 (experimental)"
    .section    .note.GNU-stack,"",@progbits
[...@gnu-6 asm-1]$ cat y.s
    .file    "x.c"
    .text
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    call    strstr
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc
.LFE0:
    .size    foo, .-foo
    .ident    "GCC: (GNU) 4.6.0 20101021 (experimental)"
    .section    .note.GNU-stack,"",@progbits
[...@gnu-6 asm-1]$ 

Shouldn't my_strstr be generated with -fno-builtin-strstr?

Reply via email to