title: Symbols not found - IOUSBHostHIDDevice - OSX kext
body: <p>I had to convert an existing driver to OSx10.11 (<a href="https://stackoverflow.com/questions/36478569/upgrading-osx-driver-for-10-11-changes-in-usb-stack">Previous Question</a>). </p>
  
  <p>I have replaced the deprecated and removed classes and methods to new ones introduced in 10.11. Now the kext builds successfully but cannot load the driver. </p>
  
  <p>The <code>OSBundleLibraries</code> was updated after issuing command <code>kextlibs -xml driver.kext</code>.</p>
  
  <pre><code>&lt;key&gt;OSBundleLibraries&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;com.apple.driver.IOBluetoothHIDDriver&lt;/key&gt;
          &lt;string&gt;4.4d69&lt;/string&gt;
          &lt;key&gt;com.apple.driver.usb.IOUSBHostHIDDevice&lt;/key&gt;
          &lt;string&gt;1.0&lt;/string&gt;
          &lt;key&gt;com.apple.iokit.IOHIDFamily&lt;/key&gt;
          &lt;string&gt;2.0&lt;/string&gt;
          &lt;key&gt;com.apple.iokit.IOUSBHostFamily&lt;/key&gt;
          &lt;string&gt;1.0&lt;/string&gt;
          &lt;key&gt;com.apple.kpi.bsd&lt;/key&gt;
          &lt;string&gt;15.0&lt;/string&gt;
          &lt;key&gt;com.apple.kpi.iokit&lt;/key&gt;
          &lt;string&gt;15.0&lt;/string&gt;
          &lt;key&gt;com.apple.kpi.libkern&lt;/key&gt;
          &lt;string&gt;15.0&lt;/string&gt;
          &lt;key&gt;com.apple.kpi.mach&lt;/key&gt;
          &lt;string&gt;15.0&lt;/string&gt;
      &lt;/dict&gt;
  </code></pre>
  
  <p>Also , giving <code>-all</code> to <code>kextlibs</code> stated that 20 symbols were not found. Please find below the relevant portion result of the command.</p>
  
  <pre><code>22 symbols not found in any library kext:
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice5Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice17Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice0Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice14Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice9Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice11Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice4Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice18Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice8Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice15Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice3Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice12Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice7Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice19Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice2Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice16Ev
  __ZN20IOBluetoothHIDDriver31_RESERVEDIOBluetoothHIDDriver12Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice13Ev
  __ZN20IOBluetoothHIDDriver31_RESERVEDIOBluetoothHIDDriver11Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice6Ev
  __ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice1Ev
  __ZN18IOUSBHostHIDDevice29_RESERVEDIOUSBHostHIDDevice10Ev
  </code></pre>
  
  <p>kextutil gave the following output</p>
  
  <pre><code>sudo kextutil -n -print-diagnostics prdt.kext
  kxld[com.comp.driver.prdt]: The super class vtable 'vtable for IOBluetoothHIDDriver' for vtable 'vtable for com_MadCatz_driver_bt_RATTe' is out of date. Make sure your kext has been built against the correct headers.
  kxld[com.comp.driver.prdt]: The super class vtable 'vtable for IOBluetoothHIDDriver' for vtable 'vtable for com_MadCatz_driver_bt_RATTe' is out of date. Make sure your kext has been built against the correct headers.
  kxld[com.comp.driver.prdt]: The vtable for com_comp_driver_usb_prdt was not patched because its parent, the vtable for IOUSBHostHIDDevice, was not found.
  Link failed (error code 5).
  Check library declarations for your kext with kextlibs(8).
  </code></pre>
  
  <p><b>What should be done to rectify the missing symbols?. How do I find where the symbols are located?. </b></p>
  
  <p>Any idea relating to the issue is highly appreciated, as I cannot figure out how to proceed.</p>
  
  <p>Also, what does the <code>__ZN18</code>, <code>28_</code> etc represent in <code>__ZN18IOUSBHostHIDDevice28_RESERVEDIOUSBHostHIDDevice5Ev</code>? Is there any way to trace the line of code in which the unknown symbols are located</p>
  
  <p><em>****** edited to add additional info ******</em></p>
  
  <h1>Additional Information </h1>
  
  <p>Demangled and sorted missing symbols from <code>kextlibs</code> result (listed above)</p>
  
  <pre><code>IOUSBHostHIDDevice::_RESERVEDIOUSBHostHIDDevice0();
  IOUSBHostHIDDevice::_RESERVEDIOUSBHostHIDDevice1();
  IOUSBHostHIDDevice::_RESERVEDIOUSBHostHIDDevice2();
  .
  .
  .
  IOUSBHostHIDDevice::_RESERVEDIOUSBHostHIDDevice17();
  IOUSBHostHIDDevice::_RESERVEDIOUSBHostHIDDevice18();
  IOUSBHostHIDDevice::_RESERVEDIOUSBHostHIDDevice19();
  IOBluetoothHIDDriver::_RESERVEDIOBluetoothHIDDriver11();
  IOBluetoothHIDDriver::_RESERVEDIOBluetoothHIDDriver12();
  </code></pre>
  
  <p>It seems like the <code>RESERVEDIOUSBHostHIDDevice</code> (listed above) are declared in  <code>IOKit/usb/IOUSBHostHIDDevice.h</code></p>
  
  <pre><code>//From IOUSBHostHIDDevice.h
  // Protected pad slots for future expansion
  OSMetaClassDeclareReservedUnused(IOUSBHostHIDDevice, 0);
  OSMetaClassDeclareReservedUnused(IOUSBHostHIDDevice, 1);
  OSMetaClassDeclareReservedUnused(IOUSBHostHIDDevice, 2);
  .
  .
  // Public pad slots for future expansion
  OSMetaClassDeclareReservedUnused(IOUSBHostHIDDevice, 10);
  .
  .
  OSMetaClassDeclareReservedUnused(IOUSBHostHIDDevice, 19);
  </code></pre>
  
  <p>However <code>RESERVEDIOBluetoothHIDDriver</code> is declared in <code>IOBluetoothHIDDriver.h</code>in which contains</p>
  
  <pre><code>OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 0 );
  OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 1 );
  .
  .
  .
  OSMetaClassDeclareReservedUnused( IOBluetoothHIDDriver, 19 );
  </code></pre>
  
  <p>is declared, however, <strong>Interestingly only <code>_RESERVEDIOBluetoothHIDDriver11()</code> and <code>_RESERVEDIOBluetoothHIDDriver12()</code> are the only methods that was not matched with kernel even though 1 to 19 were declared</strong> in <code>IOBluetoothHIDDriver.h</code>.</p>
  
  <p>where <code>OSMetaClassDeclareReservedUnused</code> is a macro declared in <code>OSMetaClass.h</code> as</p>
  
  <pre><code>#if APPLE_KEXT_VTABLE_PADDING
  #define OSMetaClassDeclareReservedUnused(className, index)        \
      private:                                                      \
      virtual void _RESERVED ## className ## index ()
  #else
  #define OSMetaClassDeclareReservedUnused(className, index)
  #endif
  </code></pre>