This is the mail archive of the
mailing list for the GCC project.
Re: ELF interposition and One Definition Rule
- From: Nathan Sidwell <nathan_sidwell at mentor dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, <gcc-patches at gcc dot gnu dot org>, <nathan at codesourcery dot com>, <gdr at integrable-solutions dot net>
- Date: Tue, 27 Aug 2013 08:53:00 -0400
- Subject: Re: ELF interposition and One Definition Rule
- Authentication-results: sourceware.org; auth=none
- References: <20130826152141 dot GA19918 at kam dot mff dot cuni dot cz> <521BF9C1 dot 8080806 at redhat dot com>
On 08/26/13 20:58, Jason Merrill wrote:
I would be happy with an even stronger default that optimizes on the assumption
that no interposition occurs; typically interposition is overriding a symbol
found in a dynamic library (i.e. malloc) rather than a symbol defined in the
same translation unit as the use.
I had thought that that case (overriding malloc etc) was what this patch was
dealing with. Perhaps I was confused.
There's nothing particularly special about ctors, dtors and virtual function
implementations. Their common feature, as Jan described, is that it's hard to
take their address:
* ctors don't have names.
* dtors do have names, but you can't take their address.
* virtual function implementations can't have their instance address taken --
you get the ptr-to-memfn object describing the vtable slot etc. There is (was?)
a GNU extension to work around that, IIRC.
So that stops a programmer calling these indirectly. However I don't really see
the semantic difference between:
fptr = &somefunc; ... fptr (...);
So treating those 3 types of function specially because you can't use the former
syntax with them seems odd.