This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Understanding symbols in .o or .dylib file
- From: Peng Yu <pengyu dot ut at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 16 May 2013 11:49:52 -0500
- Subject: Understanding symbols in .o or .dylib file
Hi,
I have the following .dylib. If I want to find the symbol
corresponding to myprint. I see __GLOBAL__I__Z7myprintv and
__Z7myprintv. What are the difference between them? Besides using
grep, is there a better way to search for symbols corresponding to a
function? Thanks.
On Mac OS X 10.8.3.
~/linux/test/gnu/binutils/nm/test_data/dynamiclib$ cat main.sh
#!/usr/bin/env bash
g++ -c -o hello.o hello.cpp
g++ -c -o main.o main.cpp
g++ -dynamiclib -undefined suppress -flat_namespace hello.o -o libhello.dylib
g++ main.o -L . -lhello -o main.exe
~/linux/test/gnu/binutils/nm/test_data/dynamiclib$ cat.sh *.cpp *.hpp
==> hello.cpp <==
#include <iostream>
void myprint() {
std::cout << "Hello World!" << std::endl;
}
==> main.cpp <==
#include "hello.hpp"
int main() {
myprint();
}
==> hello.hpp <==
void myprint();
~/linux/test/gnu/binutils/nm/test_data/dynamiclib$ ./main.sh
~/linux/test/gnu/binutils/nm/test_data/dynamiclib$ nm libhello.dylib
0000000000000df0 t __GLOBAL__I__Z7myprintv
0000000000000e10 t __Z41__static_initialization_and_destruction_0ii
0000000000000d80 T __Z7myprintv
U __ZNSolsEPFRSoS_E
U __ZNSt8ios_base4InitC1Ev
U __ZNSt8ios_base4InitD1Ev
U __ZSt4cout
U __ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
0000000000001050 b __ZStL8__ioinit
U __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
U ___cxa_atexit
0000000000000dc0 t ___tcf_0
U dyld_stub_binder
--
Regards,
Peng