error printed to stderr: "Could not find implementation lookup function...."

This error gets printed for all Darwin programs that are not objective C and is quite annoying in AppleObjCTrampolineHandler.cpp:

  if (m_impl_fn_addr == LLDB_INVALID_ADDRESS) {
    // If we can't even find the ordinary get method implementation function,
    // then we aren't going to be able to
    // step through any method dispatches. Warn to that effect and get out of
    // here.
    if (process_sp->CanJIT()) {
          "Could not find implementation lookup function \"%s\""
          " step in through ObjC method dispatch will not work.\n",
  } ...

Can we quiet this error when libobjc isn't loaded? Our IDE prints out anything it gets on stderr and this error always has people worried there is something wrong.


Something is going wrong here before you get to this point. You can't get to the code in question (creating the AppleObjCTrampolineHandler) if you don't have an ObjCLanguageRuntime of some sort. The only way the trampoline gets made is in ReadObjCLibrary, which is a pure virtual method on ObjCLanguageRuntime, so somebody had to successfully made an ObjCLanguageRuntime.

However, the CreateInstance for the concrete ObjCLanguageRuntimes calls AppleObjCRuntime::GetObjCVersion and then checks that the version is the right one for the V1 or V2 implementations. That will only return something different from eObjC_VersionUnknown if a scan over the loaded modules finds one for which AppleObjCRuntime::AppleIsModuleObjCLibrary returns true. But that just checks that libobjc.A.dylib is in the target list.

So I don't see how you can get to this error if you don't have libobjc.A.dylib loaded. OTOH, I don't know how you are seeing a libobjc.A.dylib that doesn't have class_getMethodImplementation in it...


(lldb) b s -p return
Breakpoint 1: where = hello`main + 13 at hello.c:6, address = 0x0000000100000fad
(lldb) run
Process 56377 launched: '/tmp/hello' (x86_64)
Process 56377 stopped
* thread #1, queue = '', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000fad hello`main at hello.c:6
   3 int
   4 main()
   5 {
-> 6 return 0;
   7 }
Target 0: (hello) stopped.
(lldb) image list libobjc.A.dylib
[ 0] DD9E5EC5-B507-3249-B700-93433E2D5EDF 0x00007fff5093f000 /usr/lib/libobjc.A.dylib

So I'm also not sure it is possible to make a darwin binary that doesn't load libobjc.A.dylib.