1

I've compiled a simple c program that uses printf and ran otool -l on the binary. In it /usr/lib/libSystem.B.dylib is mentioned in the LC_LOAD_DYLIB command. But when I do nm -a /usr/lib/libSystem.B.dylib to list the symbols in that lib I do not find printf. Where is it defined then?

scrrr
  • 5,135
  • 7
  • 42
  • 52

1 Answers1

2

First, otool -L is a simpler way to see the list of libraries that an executable links to.

Second, if you apply otool -L to libSystem.B.dylib, you'll see that it, in turn, depends on a bunch of libraries in /usr/lib/system. One of those is libsystem_c.dylib, which is the C library. That defines printf.

Going back to otool -l output for libSystem.B.dylib, you'll see that those dependencies are via the LC_REEXPORT_DYLIB load command. That's how the symbols in the other libraries are exported without actual symbol table entries for them.

I guess, arguably, it's a bug in nm that it doesn't show reexported symbols.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154