[Development] Serious ABI issue discovered in -reduce-relocations

Thiago Macieira thiago.macieira at intel.com
Fri Jan 13 16:40:53 CET 2012


On Friday, 13 de January de 2012 15.55.06, Simon Hausmann wrote:
> On Friday, January 13, 2012 12:33:46 PM ext Thiago Macieira wrote:
> > Hello
> > 
> > We've got a problem with -reduce-relocations. tl;dr: it's a broken concept
> > and we either add a permanent workaround or we stop using it. The
> > permanent
> > workaround is to compile all executables in PIC/PIE mode.
> 
> I think calling -Bsymbolic-functions a broken concept is harsh, given that
> it makes a lot of sense - doesn't it?

It depends on the interpretation. One binutils hacker I talked to told me that 
you simply couldn't do it, so that would be a broken concept.

If we can convince the binutils community to fix the implementation or -- 
better yet -- improve code generation, then we can call it "broken 
implementation" today.

> The fact that it breaks when comparing addresses of functions sucks, but
> IMHO compiling PIC/PIE is still better than going back to all those
> unecessary relocations just because somebody _might_ interpose a symbol of
> the public API of the library.

Read the longer explanation. The reason why this exists is because of the ELF 
executable ABI. ELF executables contain position-dependent code without 
relocations. That means the code in executables must know the address of 
everything. To support that, the linker does copy relocations and forces 
certain symbols to be in the executable, even if they aren't really there.

This is all to improve performance of executable code, to the detriment of 
library code. I question that today: libraries are much bigger and more 
complex than user code. Moreover, for us in Qt, where QML will take such a 
proeminent place, user code is close to irrelevant.

Still, we can just add this to qobject.h:

#if defined(__ELF__) && !defined(__PIC__)
# error "Sorry, not supported. Please add -fPIC or -fPIE to your compilation 
flags"
#endif


-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120113/f5952fc2/attachment.sig>


More information about the Development mailing list