This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Understanding symbols in .o or .dylib file


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
#!/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$ *.cpp  *.hpp
==> hello.cpp <==
#include <iostream>

void myprint() {
  std::cout << "Hello World!" << std::endl;

==> main.cpp <==
#include "hello.hpp"

int main() {
==> hello.hpp <==
void myprint();
~/linux/test/gnu/binutils/nm/test_data/dynamiclib$ ./
~/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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]