* plugin.cc (Plugin::load): Don't cast from void* to a function
authorIan Lance Taylor <ian@airs.com>
Thu, 10 Dec 2009 07:44:28 +0000 (07:44 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 10 Dec 2009 07:44:28 +0000 (07:44 +0000)
pointer.

gold/ChangeLog
gold/plugin.cc

index 1e6d07c6aeb6d84cb380d62aa14ec52431973759..339d6e1736352a847f4d3ffd9a3c096ef5e412e8 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-09  Ian Lance Taylor  <iant@google.com>
+
+       * plugin.cc (Plugin::load): Don't cast from void* to a function
+       pointer.
+
 2009-12-09  Ian Lance Taylor  <iant@google.com>
 
        * dynobj.cc (Sized_dynobj::do_read_symbols): Clear version
index 317fb7d09c8f1fe8104830b95ebea9d63663a8b9..ff9f98f282c989d58b7a3785e588c11f73740cdc 100644 (file)
@@ -109,14 +109,16 @@ Plugin::load()
     }
 
   // Find the plugin's onload entry point.
-  ld_plugin_onload onload = reinterpret_cast<ld_plugin_onload>
-    (dlsym(this->handle_, "onload"));
-  if (onload == NULL)
+  void* ptr = dlsym(this->handle_, "onload");
+  if (ptr == NULL)
     {
       gold_error(_("%s: could not find onload entry point"),
                  this->filename_.c_str());
       return;
     }
+  ld_plugin_onload onload;
+  gold_assert(sizeof(onload) == sizeof(ptr));
+  memcpy(&onload, &ptr, sizeof(ptr));
 
   // Get the linker's version number.
   const char* ver = get_version_string();