This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GOLD] [PATCH] Casting plugin onload entry point


* Ian Lance Taylor wrote on Mon, Dec 14, 2009 at 11:17:51PM CET:
> Ralf Wildenhues writes:
> > * Ian Lance Taylor wrote on Thu, Dec 10, 2009 at 08:46:08AM CET:
> >> Viktor Kutuzov writes:
> >> 
> >> > The attached patch fixes this issue by using the workaround introduced by the POSIX.1-2003.
> >> 
> >> >   *(void **)(&onload) = dlsym(this->handle_, "onload");
> >> 
> >> Thanks for pointing that out.  I hope that POSIX doesn't really
> >> recommend your approach, though, as it is an aliasing violation.  I
> >> committed this patch to fix the problem in a way that should be
> >> standard compliant.
> >
> > This is what POSIX recommends, though.  There is a rationale:
[...]
> > So do I understand correctly that this is not an aliasing violation, and
> > the memcpy change was not really needed?
> 
> The aliasing violation is taking the address of onload, which has type
> ld_plugin_onload (== enum ld_plugin_status (*)(struct ld_plugin_tv*)),
> casting that address to void**, and then dereferencing the pointer.
> That means that the code was assigning to memory using type void* and
> then later accessing it as type ld_plugin_onload.  The aliasing
> violation is using one type to store the value and a different type to
> read it.  That is entirely independent of the quoted text above.

Yet this text is used to explain this code snippet.  So I guess a defect
report is in order, both for the code and the rationale.  I'm not sure
I'm the best person to write this, though; any volunteers?

Thanks,
Ralf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]