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.
CodePudding user response:
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.
CodePudding user response:
memcpy
is specified in the C standard as well as the POSIX standard, as well as a few other operating system specifications. Hence, it is provided by the C standard and/or the operating system library implementation.
The default standard library on a GNU system is the GNU C library aka glibc.
How do I go about getting this information?
Search engines are good for getting information in general, including this one. Searching for memcpy
should lead you to the information about what it is (a standard library function), and searching for your system's documentation should lead you to the information about its standard library implementation.
The objdump
command that you demonstrated seems to also have shown you the answer.
I'm trying to understand what is the file name in my system.
There's no standard way that applies to all systems. But let's assume that your operating system is Linux. The manual says
The pathname /lib/libc.so.6 (or something similar) is normally a symbolic link that points to the location of the glibc library, and executing this pathname will cause glibc to display various information about the version installed on your system.
You can use ldconfig -p | grep libc.so
to find the precise path.