Le 28 nov. 2011 à 12:16, Romain Geissler a écrit :

> Hi,
> 
> The current trunk have no support for the __stpncpy_chk function. As the 
> latest
> OS X (10.7 aka Lion) now defines stpncpy as a call to builtin__stpncpy_chk for
> GNUC compliant compiler, the following code won't link:
> 
> #include <string.h>
> 
> int main(){
>       char string[10];
>       stpncpy(string,"abcd",8);
> 
>       return 0;
> }
> 
> Undefined symbols for architecture x86_64:
>  "___builtin___stpncpy_chk", referenced from:
>      _main in ccGFZoZV.o
> ld: symbol(s) not found for architecture x86_64
> collect2: error: ld returned 1 exit status
> 
> 
> This patch add support for this builtin.
> Bootstrapped and tested without regression on darwin x86_64.
> 
> Romain Geissler
> 
> gcc/
> 
> 2011-11-28  Romain Geissler  <romain.geiss...@gmail.com>
> 
>       * builtins.def (BUILT_IN_STPNCPY_CHK): New definition.
>       * builtins.c (expand_builtin, fold_builtin_4, maybe_emit_chk_warning):
>       Add BUILT_IN_STPNCPY_CHK case.
>       * gimple-fold.c (gimple_fold_builtin): Likewise.
>       * tree-object-size.c (pass_through_call): Likewise.
>       * tree-ssa-alias.c (ref_maybe_used_by_call_p_1,
>       call_may_clobber_ref_p_1): Likewise.
>       * tree-ssa-structalias.c (find_func_aliases_for_builtin_call,
>       find_func_clobbers): Likewise.
>       * tree.h (fold_builtin_strncpy_chk): Rename to fold_builtin_stxncpy_chk
>       * builtins.c (fold_builtin_strncpy_chk): Likewise.
>       Rewrite stpncpy_chk calls to strncpy_chk calls if returned value is
>       ignored.
> 
> gcc/testsuite/
> 
> 2011-11-28  Romain Geissler  <romain.geiss...@gmail.com>
> 
>       * gcc.c-torture/execute/builtins/chk.h (stpncpy, stpncpy_disallowed):
>       New definitions.
>       * gcc.c-torture/execute/builtins/lib/chk.c (stpncpy_disallowed):
>       Likewise.
>       (stpncpy, __stpncpy_chk): New functions.
>       * gcc.c-torture/execute/builtins/stpncpy-chk-lib.c: New file.
>       * gcc.c-torture/execute/builtins/stpncpy-chk.c: Likewise.
> 
> <lion_build.patch>

Ping

Reply via email to