From b55ebd6130e0c83ba95b1b7f9655b0bad76d676a Mon Sep 17 00:00:00 2001 From: Bryce Denney Date: Thu, 17 Oct 2002 05:53:50 +0000 Subject: [PATCH] - eliminate duplicat symbols across modules - modified: test9/module* test11/module* test12/module* --- .../plugin-test/test11-modglobalconstr/module1.cc | 1 + .../plugin-test/test11-modglobalconstr/module2.cc | 1 + .../plugin-test/test11-modglobalconstr/modules.h | 12 +++++++++++- .../plugin-test/test12-modglobalconstr2/module1.cc | 1 + .../plugin-test/test12-modglobalconstr2/module2.cc | 1 + .../plugin-test/test12-modglobalconstr2/modules.h | 12 +++++++++++- bochs-testing/plugin-test/test9-modclass/module1.cc | 1 + bochs-testing/plugin-test/test9-modclass/module2.cc | 1 + bochs-testing/plugin-test/test9-modclass/modules.h | 13 ++++++++++++- 9 files changed, 40 insertions(+), 3 deletions(-) diff --git a/bochs-testing/plugin-test/test11-modglobalconstr/module1.cc b/bochs-testing/plugin-test/test11-modglobalconstr/module1.cc index 8d1301aa2..749efe8d5 100644 --- a/bochs-testing/plugin-test/test11-modglobalconstr/module1.cc +++ b/bochs-testing/plugin-test/test11-modglobalconstr/module1.cc @@ -1,5 +1,6 @@ #include #include "main.h" +#define _buildsym(sym) libmodule1_LTX_##sym #include "modules.h" class CellPhone : public DeviceInterface { diff --git a/bochs-testing/plugin-test/test11-modglobalconstr/module2.cc b/bochs-testing/plugin-test/test11-modglobalconstr/module2.cc index f6fa2a09a..373d12ae3 100644 --- a/bochs-testing/plugin-test/test11-modglobalconstr/module2.cc +++ b/bochs-testing/plugin-test/test11-modglobalconstr/module2.cc @@ -2,6 +2,7 @@ #include #include #include "main.h" +#define _buildsym(sym) libmodule2_LTX_##sym #include "modules.h" class GPS_Receiver : public DeviceInterface { diff --git a/bochs-testing/plugin-test/test11-modglobalconstr/modules.h b/bochs-testing/plugin-test/test11-modglobalconstr/modules.h index b3df43f22..4fbe170a3 100644 --- a/bochs-testing/plugin-test/test11-modglobalconstr/modules.h +++ b/bochs-testing/plugin-test/test11-modglobalconstr/modules.h @@ -1,7 +1,17 @@ +#ifdef _buildsym +// This section is included by each module to rename all of its symbols, +// in order to avoid duplicate symbols in different modules. From the +// libtool docs: "Although some platforms support having the same symbols +// defined more than once it is generally not portable." + +#define module_init _buildsym(module_init) +#define operate _buildsym(operate) extern "C" { - // this prevents C++ name mangling + // the extern "C" prevents C++ name mangling class DeviceInterface * module_init (); + int operate (int a, int b); }; +#endif typedef class DeviceInterface* (*modload_func)(void); diff --git a/bochs-testing/plugin-test/test12-modglobalconstr2/module1.cc b/bochs-testing/plugin-test/test12-modglobalconstr2/module1.cc index 8d1301aa2..749efe8d5 100644 --- a/bochs-testing/plugin-test/test12-modglobalconstr2/module1.cc +++ b/bochs-testing/plugin-test/test12-modglobalconstr2/module1.cc @@ -1,5 +1,6 @@ #include #include "main.h" +#define _buildsym(sym) libmodule1_LTX_##sym #include "modules.h" class CellPhone : public DeviceInterface { diff --git a/bochs-testing/plugin-test/test12-modglobalconstr2/module2.cc b/bochs-testing/plugin-test/test12-modglobalconstr2/module2.cc index 2e470044c..92ef0be21 100644 --- a/bochs-testing/plugin-test/test12-modglobalconstr2/module2.cc +++ b/bochs-testing/plugin-test/test12-modglobalconstr2/module2.cc @@ -2,6 +2,7 @@ #include #include #include "main.h" +#define _buildsym(sym) libmodule2_LTX_##sym #include "modules.h" class GPS_Receiver : public DeviceInterface { diff --git a/bochs-testing/plugin-test/test12-modglobalconstr2/modules.h b/bochs-testing/plugin-test/test12-modglobalconstr2/modules.h index b3df43f22..4fbe170a3 100644 --- a/bochs-testing/plugin-test/test12-modglobalconstr2/modules.h +++ b/bochs-testing/plugin-test/test12-modglobalconstr2/modules.h @@ -1,7 +1,17 @@ +#ifdef _buildsym +// This section is included by each module to rename all of its symbols, +// in order to avoid duplicate symbols in different modules. From the +// libtool docs: "Although some platforms support having the same symbols +// defined more than once it is generally not portable." + +#define module_init _buildsym(module_init) +#define operate _buildsym(operate) extern "C" { - // this prevents C++ name mangling + // the extern "C" prevents C++ name mangling class DeviceInterface * module_init (); + int operate (int a, int b); }; +#endif typedef class DeviceInterface* (*modload_func)(void); diff --git a/bochs-testing/plugin-test/test9-modclass/module1.cc b/bochs-testing/plugin-test/test9-modclass/module1.cc index 0caa3b396..628beb873 100644 --- a/bochs-testing/plugin-test/test9-modclass/module1.cc +++ b/bochs-testing/plugin-test/test9-modclass/module1.cc @@ -1,5 +1,6 @@ #include #include "main.h" +#define _buildsym(sym) libmodule1_LTX_##sym #include "modules.h" class ModuleGadget* module_init () diff --git a/bochs-testing/plugin-test/test9-modclass/module2.cc b/bochs-testing/plugin-test/test9-modclass/module2.cc index ad69a9e11..14622e0f3 100644 --- a/bochs-testing/plugin-test/test9-modclass/module2.cc +++ b/bochs-testing/plugin-test/test9-modclass/module2.cc @@ -1,5 +1,6 @@ #include #include "main.h" +#define _buildsym(sym) libmodule2_LTX_##sym #include "modules.h" int n_operations = 0; diff --git a/bochs-testing/plugin-test/test9-modclass/modules.h b/bochs-testing/plugin-test/test9-modclass/modules.h index 77d2988f2..74db25879 100644 --- a/bochs-testing/plugin-test/test9-modclass/modules.h +++ b/bochs-testing/plugin-test/test9-modclass/modules.h @@ -1,7 +1,17 @@ +#ifdef _buildsym +// This section is included by each module to rename all of its symbols, +// in order to avoid duplicate symbols in different modules. From the +// libtool docs: "Although some platforms support having the same symbols +// defined more than once it is generally not portable." + +#define module_init _buildsym(module_init) +#define operate _buildsym(operate) extern "C" { - // this prevents C++ name mangling + // the extern "C" prevents C++ name mangling class ModuleGadget * module_init (); + int operate (int a, int b); }; +#endif typedef class ModuleGadget* (*modload_func)(void); @@ -14,3 +24,4 @@ public: virtual const char* getName (); virtual const char* getFeatures (); }; +