PATCH for bochs/plugins/libbx_usb_uhci.so: undefined symbol: _ZTV12usb_device_c

C Hanish Menon <[email protected]> Wed, 18 Nov 2015 16:01:46 +0530
Newsgroups gmane.comp.emulators.bochs.devel
Message-ID <CAAsnDqHN=kRnOhzw8s1bNcjAUJFg-dBN_k=OEm5Jm-i_4nYWvA@mail.gmail.com>
Hi,

I was testing bochs on Fedora 23, when I noticed this

bochs/plugins/libbx_usb_uhci.so: undefined symbol: _ZTV12usb_device_c

issue when trying to run bochs. As it was using a old 2.6.2 (2013)
version of bochs, I downloaded the latest svn source and compiled the
same with

./configure --enable-debugger --enable-disasm --with-all-libs
--enable-e1000 --enable-sb16  --enable-plugins --enable-usb

However the issue was there in the latest svn release (Built from SVN
snapshot after release 2.6.8) also.

So when I had a casual glance at it, it seems like there is a
dependence on usb_device_c declared in usb_common in usb_uhci, and has
RTLD_LAZY resolve only works for functions and not variables, it
doesn't help here. So I have changed the sequence of loading wrt
usb_uhci and usb_common, so that usb_common gets loaded first. However
if for any reason usb_uhci doesn't load and if no other usb
controllers are also loaded, then I take care of unloading usb_common,
so that the old behaviour wrt usb_common is not changed, even thou
location of loading of same is changed by my patch.

And this seems to solve the problem. However currently I am looking at
bochs to help with some experimentation with a bootloader, so I
haven't explicitly checked the usb logic, after my change, but
logically don't see any reason why there should be a problem with this
patch, and at same time it should resolve the problem I noticed, when
I tried compiling and using in Fedora.


--- iodev/devices.cc (revision 12882)
+++ iodev/devices.cc (working copy)
@@ -180,6 +180,7 @@
     PLUG_load_plugin(pci, PLUGTYPE_CORE);
     PLUG_load_plugin(pci2isa, PLUGTYPE_CORE);
 #if BX_SUPPORT_PCIUSB
+    PLUG_load_plugin(usb_common, PLUGTYPE_CORE);
     if (chipset == BX_PCI_CHIPSET_I440FX) {
       // UHCI is a part of the PIIX3, so load / enable it
       if (!PLUG_device_present("usb_uhci")) {
@@ -188,8 +189,10 @@
       SIM->get_param_bool(BXPN_UHCI_ENABLED)->set(1);
     }
     usb_enabled = is_usb_enabled();
-    if (usb_enabled)
-      PLUG_load_plugin(usb_common, PLUGTYPE_CORE);
+    if (!usb_enabled) {
+      PLUG_unload_plugin(usb_common);
+      BX_PANIC(("Bochs has failed to load usb_uhci???"));
+    }
 #endif
     if (chipset == BX_PCI_CHIPSET_I440FX) {
       PLUG_load_plugin(acpi, PLUGTYPE_STANDARD);

-- 
Keep ;-)
HanishKVC

------------------------------------------------------------------------------