Search code examples
c++cmemcpy

What C library provides memcpy?


How to figure out what gcc library provides the symbol for memcpy?

memcpy is provided by the header file , but I don't know what library provides the symbol.

$ objdump -ax libboost_filesystem.so | grep memcpy
0000000000000000       F *UND*  0000000000000000              wmemcpy@@GLIBC_2.2.5
0000000000000000       F *UND*  0000000000000000              memcpy@@GLIBC_2.14

It is clear that this shared object needs to find an implementation of memcpy.

How do I go about getting this information? It would be nice if I can query the compiler.


Solution

  • what gcc library provides the symbol for memcpy?

    The C standard library provides memcpy.

    There are some popular implementations of C standard library, on Linux it is most notably glibc (well, and musl on Alpine Linux).

    How do I go about getting this information?

    There are some approaches you can take. You can run something and see where it links to How to find which shared library exported which imported symbol in my binary? . You can index all libraries on your system (see man ld.so and /etc/ld.so.conf) and index all symbols in those libraries and query the symbol (this my script does that). Then you can query your system package manager to find out to which package the shared library belongs to.