From b59befec8e8a9bec906f2a0ae623db822c9ef2cd Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 10 Dec 2009 07:44:28 +0000 Subject: [PATCH] * plugin.cc (Plugin::load): Don't cast from void* to a function pointer. --- gold/ChangeLog | 5 +++++ gold/plugin.cc | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 1e6d07c6aeb..339d6e17363 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2009-12-09 Ian Lance Taylor + + * plugin.cc (Plugin::load): Don't cast from void* to a function + pointer. + 2009-12-09 Ian Lance Taylor * dynobj.cc (Sized_dynobj::do_read_symbols): Clear version diff --git a/gold/plugin.cc b/gold/plugin.cc index 317fb7d09c8..ff9f98f282c 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -109,14 +109,16 @@ Plugin::load() } // Find the plugin's onload entry point. - ld_plugin_onload onload = reinterpret_cast - (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(); -- 2.30.2