[Development] Q_GADGET = relocation on staticMetaObject; Q_OBJECT = no relocation; known?

Thiago Macieira thiago.macieira at intel.com
Tue Oct 1 04:42:45 CEST 2013


On segunda-feira, 30 de setembro de 2013 17:30:33, Thiago Macieira wrote:
> # Here's where the size of the object is useful
> $ objdump -R libQt5Core.so.5 | egrep '^0000000000669(0e|0f|10).' | sort
> 00000000006690e8 R_X86_64_RELATIVE  *ABS*+0x0000000000565800
> 00000000006690f0 R_X86_64_RELATIVE  *ABS*+0x0000000000564d20
> 
> $ objdump -R libQt5Core.so.5 | grep '^00000000006703[abc].' | sort
> 00000000006703a0 R_X86_64_64       _ZN7QObject16staticMetaObjectE
> 00000000006703a8 R_X86_64_RELATIVE  *ABS*+0x0000000000564c00
> 00000000006703b0 R_X86_64_RELATIVE  *ABS*+0x0000000000564a60
> 00000000006703b8 R_X86_64_RELATIVE  *ABS*+0x0000000000432560
> 
> So here is seemingly the cause: a relocation by name, as opposed to a
> relative  relocation.
> 
> So it's not that nullptr causes a relocation. It *removes* a relocation. 
> That's the difference.
> 
> You may be asking what the difference is. Well, I guess the difference
> wouldn't  show up on a library. It would only show up on an executable,
> where the relocations to the base address would be resolved by the static
> linker.

Oh, I'm sorry, there's one benefit even for libraries:

If this library is prelinked and the library is loaded at the prelinked 
address, the pages for .data.rel.ro.local would always be clean, thus 
sharable. The pages for .data.rel.ro are subject to symbol interposition and 
might not be sharable. 

More importantly, the dynamic linker knows whether it succeeded in loading the 
library at the prelinked address, so it knows that it doesn't have to perform 
the R_*_RELATIVE relocations. But it will perform the other ones, even if 
there was no interposition and the pointer to be written is equal to the 
pointer that is already there. This writing causes the page to become dirty 
and not sharable. (it can be made shared again via KSM).

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- 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/20130930/43827501/attachment.sig>


More information about the Development mailing list