[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: -fPIE and stuff



Kurt Roeckx <kurt <at> roeckx.be> writes:
> > > > > As far as I understand things, this is supposed to work, and might
> > > > 
> > > > It cannot work in the usual setup. Relocations are not supported for
> > > > the main binary even on platforms that support them for shared
> > > > libraries.
> > > 
> > > I'm pretty sure that the main binary supports relocations.  Else
> > 
> > I meant the kind of text relocations that you can use in libraries on i386
> > but not on AMD64, and which -fPIC avoids.
> 
> Which has nothing to do with the executable?

That was part of the explanation why your "is supposed to work" is wrong. The
most obvious way how the non-fPIE case could theoretically work would be having
such text relocations for main executable; without them you can't expect things
to work without special tricks.

 
> I really see no point in exporting constants and then marking
> them protected.

Marking things protected is desirable at least if the performance of the code
using them in the library matters.

> About the only useful exported constant I can think of is something like a 
> version string.  And you really want to use a function for that.

There are some use cases - special objects like in my example are perhaps the
most obvious case where things actually break as a result (there are lots of
reasons why you'd want to export constant data tables, but that doesn't usually
break). And you don't really want to add function wrappers for everything.

Note that the problem is not limited to data only. Code like
"if (obj->destructor_func != default_destructor_func)" can also fail.


> For all other cases I can't see how it's supposed to work.

This sentence does not work in its context. What "it" are you referring to here?


Reply to: