nm

How to determine inter-library dependencies?

六眼飞鱼酱① 提交于 2019-12-01 04:42:33
问题 My project consists of a couple of static libraries, which are linked together in a final step. Now I have the problem, that the link order of the library is important (otherwise I get an undefined symbol linker error). Sometimes I run into the problem, that I have to re-sort the linked libraries (-lcommon -lsetup -lcontrol etc). At the moment it's a stupid trial and error: re-sort, compile, check error, re-sort, compile and so on. So I wrote a small program to show me the inter-library

Tool for Library Dependency

社会主义新天地 提交于 2019-11-30 05:16:55
I'm looking for the tool / command on Unix platform to detect the library dependencies of the .so and .o files. I have already used the ldd / nm / truss , but I don't know the proper approach to detect library dependencies. It depends on what exactly is meant by "detect library dependencies". The ldd command works on shared libraries, not just on executables. It will display the dependencies of a shared library declared when the library was built: $ ldd /usr/lib/libgtk-3.so linux-vdso.so.1 (0x00007ffff8fff000) libgdk-3.so.0 => /usr/lib/libgdk-3.so.0 (0x00007f43fcf47000) libgmodule-2.0.so.0 =>

How to print the name of the symbols of ELF files like the nm?

家住魔仙堡 提交于 2019-11-29 16:28:27
I know the name of the symbols are in the shstrtab. But I don't get how to catch them. Should I cast my shstrab into a Elf64_Sym so that I can use the st_name? Elf64_Shdr *shdr = (Elf64_Shdr *) (data + elf->e_shoff); Elf64_Shdr *symtab; Elf64_Shdr *shstrtab; Elf64_Shdr *strtab; char *str = (char *) (data + shdr[elf->e_shstrndx].sh_offset); for (int i = 0; i < elf->e_shnum; i++) { if (shdr[i].sh_size) { printf("%s\n", &str[shdr[i].sh_name]); if (strcmp(&str[shdr[i].sh_name], ".symtab") == 0) symtab = (Elf64_Shdr *) &shdr[i]; if (strcmp(&str[shdr[i].sh_name], ".shstrtab") == 0) shstrtab = (Elf64

Tool for Library Dependency

元气小坏坏 提交于 2019-11-29 02:50:55
问题 I'm looking for the tool / command on Unix platform to detect the library dependencies of the .so and .o files. I have already used the ldd / nm / truss , but I don't know the proper approach to detect library dependencies. 回答1: It depends on what exactly is meant by "detect library dependencies". The ldd command works on shared libraries, not just on executables. It will display the dependencies of a shared library declared when the library was built: $ ldd /usr/lib/libgtk-3.so linux-vdso.so

How to print the name of the symbols of ELF files like the nm?

梦想的初衷 提交于 2019-11-28 11:28:49
问题 I know the name of the symbols are in the shstrtab. But I don't get how to catch them. Should I cast my shstrab into a Elf64_Sym so that I can use the st_name? Elf64_Shdr *shdr = (Elf64_Shdr *) (data + elf->e_shoff); Elf64_Shdr *symtab; Elf64_Shdr *shstrtab; Elf64_Shdr *strtab; char *str = (char *) (data + shdr[elf->e_shstrndx].sh_offset); for (int i = 0; i < elf->e_shnum; i++) { if (shdr[i].sh_size) { printf("%s\n", &str[shdr[i].sh_name]); if (strcmp(&str[shdr[i].sh_name], ".symtab") == 0)

Errors that refer to a bunch of unresolved OpenSSL symbols that clearly exist?

可紊 提交于 2019-11-27 09:31:12
I am building a shared library (we'll call it "foo") that makes use of another library (we'll call it "bar"). "bar" makes use of some functions from OpenSSL. Here's where the problem surfaces. "bar" was compiled as a static library and it would appear that OpenSSL was too. So when I link the library ("foo"), I include the: object files for "foo" static library libbar.a OpenSSL static libraries libcrypto.a and libssl.a The build command looks something like this: g++ -Wl,-soname,libfoo.so -shared file1.o file2.o libbar.a \ libcrypto.a libssl.a -o libfoo.so However, I get a ton of errors: ld: .

Microsoft equivalent of the nm command

你说的曾经没有我的故事 提交于 2019-11-27 03:56:48
I've long used cygwin's nm command for all my .lib symbol debugging needs, but recently I thought about referring to it in a SO answer and realized that most Windows developers don't have cygwin installed. So what is the Microsoft equivalent to nm, i.e., what command will list the symbols exported by a .lib file, the undefined symbols in the .lib, and so forth? For the curious, a sample nm man page is here . Tim Try dumpbin.exe. MSDN dumpbin.exe reference . Run vcvarsall.bat which might present in your installed path of Microsoft Visual Studio. This sets environmental variable required for

Errors that refer to a bunch of unresolved OpenSSL symbols that clearly exist?

北城余情 提交于 2019-11-26 14:46:42
问题 I am building a shared library (we'll call it "foo") that makes use of another library (we'll call it "bar"). "bar" makes use of some functions from OpenSSL. Here's where the problem surfaces. "bar" was compiled as a static library and it would appear that OpenSSL was too. So when I link the library ("foo"), I include the: object files for "foo" static library libbar.a OpenSSL static libraries libcrypto.a and libssl.a The build command looks something like this: g++ -Wl,-soname,libfoo.so

Microsoft equivalent of the nm command

南楼画角 提交于 2019-11-26 10:58:15
问题 I\'ve long used cygwin\'s nm command for all my .lib symbol debugging needs, but recently I thought about referring to it in a SO answer and realized that most Windows developers don\'t have cygwin installed. So what is the Microsoft equivalent to nm, i.e., what command will list the symbols exported by a .lib file, the undefined symbols in the .lib, and so forth? For the curious, a sample nm man page is here. 回答1: Try dumpbin.exe. MSDN dumpbin.exe reference. 回答2: Run vcvarsall.bat which