Search code examples
c++cgccbuilt-in

where can i find builtin gcc memcpy?


In my program i use memcpy. Gcc generate code, that use __builtin___memcpy_chk. I have downloaded gcc source code https://github.com/gcc-mirror/gcc and do grep -A 10 -R "__builtin___memcpy_chk" . but i can't find implementation __builtin___memcpy_chk. Where can i find implementation for this function?


Solution

  • Builtins such as __builtin___memcpy_chk are not functions as such, so you may not find a "definition" for it.

    GCC is a compiler. It implements the language. It reads your function definitions an emits a binary with instructions for the CPU. In this case it emits instructions for the CPU without reading a C or C++ source file. Instead, it directly manipulates the internal data structure that it uses to represent the program that it is compiling.

    You may want to take a look at expand_builtin_memory_chk defined in gcc/builtins.c for what it does.