This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: effect of -fPIC on code speed


> > It's pretty rare to compare the addresses of globals/functions for equality.
>? RTTI and exception handling, for example, break.


Interesting. I'm sure Windows works here, one way or another,
and gcc/ELF work. That is, this is low level, compiler/linker-specific
enough that they (Windows) probably either fail to link if not
__declspec(dllimport)ed enough, or they don't depend on the one definition.


For example, the "matching" that exception handling has to do
uses strcmp, so whatever associated type information is involved,
can be duplicated on each side of .dll (throw/catch) boundary, and still work.
One might imagine using pointer comparison instead, if the data was
guaranteed single instanced.


Imho cross .dll RTTI/exception handling aren't worth the headache
of keeping everything in sync (i.e. add any private member data, recompile/link
everything), but I know some people like using them.
There is also no documented stable ABI -- you can't do this stuff and mix compilers.
? Whereas it is easy to have a common C ABI, and a common COM ABI (it is just
?? either C, or a trivial use of C++).


Anything else?
I understand, you can do the pointer equality checks in arbitrary code.
So there is arbitrary breakage, given a certain uncommon construct.
? And as I showed, at least in the basic/common scenarios, the rules are either followed
? or breaking them in a slightly unusual construct gets a warning about this exact problem.
? (It's not unusual to take the address of a function, but intersect that with imported functions.)


(Maybe off-topic, but object model discussions are fascinating and maybe cross-cutting..)

?- Jay

----------------------------------------
> Date: Wed, 22 Sep 2010 09:00:00 +0100
> From: aph@redhat.com
> To: jay.krell@cornell.edu
> CC: gcc-help@gcc.gnu.org
> Subject: Re: effect of -fPIC on code speed
>
> On 22/09/10 05:58, Jay K wrote:
> >
> > >> It's actually part of the C standard: there may only be one definition
> > >> of any symbol, whether that symbol refers to a function or to data. So,
> > >> for every visible symbol X in a program, &X must be the same, no matter
> > >> who is asking.
> >
> > >> All manner of things break without this.
> >
> >
> > Some stuff breaks, but not much.
>
> LOL! Not enough to matter, right? :-)
>
> > It's pretty rare to compare the addresses of globals/functions for equality.
>
> Perhaps, but that's not the only problem when there are multiple instances
> of X. RTTI and exception handling, for example, break.
>
> Andrew.
 		 	   		  


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