[Development] how to reduce the relocation <-- Use static qt libraries
Thiago Macieira
thiago.macieira at intel.com
Tue Jul 24 16:29:24 CEST 2012
On terça-feira, 24 de julho de 2012 13.22.25, song.7.liu at nokia.com wrote:
> Yes, the bottleneck of the loading now is the local relocations instead of
> inter-library's.
>
> So what we want to do will be reducing the number of local relocation.
>
> Based on my understanding, this local relocation should be caused by the
> "symbol inter-positioning".
That's not exactly the case. Some types of relocations do permit symbol
interpositioning. But some types of code require relocations even if they're
not interposable.
In my listing, all the "local" relocations are non-interposable.
More information:
http://www.macieira.org/blog/2012/01/sorry-state-of-dynamic-libraries-on-
linux/
http://www.macieira.org/blog/2012/01/update-and-benchmark-on-the-dynamic-
library-proposals/
> And from gcc option -Bsymbolic:
> "
> When creating a shared library, bind references to global symbols to the
> definition within the shared library, if any. Normally, it is possible for
> a program linked against a shared library to override the definition within
> the shared library. This option is only meaningful on ELF platforms which
> support shared libraries. "
>
> But for my case, it's not needed to override the definition within the
> libqt5.so.
Yes, it is.
But you didn't realise that your code requires relocations even if the symbols
can't be overridden.
In order to do that, you need a fully position *dependent* code that can't be
moved. Executables on Linux are like that, but all libraries are movable in
memory, even those compiled without -fPIC.
Since you're not running Linux, check if your OS supports that. Note that
you'll need to know the exact load address at build time and that it must
match the loaded address for the ROM if you want to do XIP.
> So, besides the prelink solution, I think the compiler (I mean
> armlink) should provide the ability to disable this symbol
> inter-positioning, just like the -Bsymbolic in gcc.
>
> Does anyone have idea from the compiler point of view ?
Sorry, you're barking up the wrong tree.
Your only option to reduce the number of relocations is to prelink to the
exact load address. There are two ways of doing that:
1) the ELF prelinker, which prelinks all relocations to a given address, but
does still allow relocating if the shared object is loaded at a different
address. The code is PIC, so XIP should work just fine.
2) compile without PIC and prelink at a specific address at link time, which
means that the code must be loaded there or it will fail to run. This is the
Windows DLL model.
>
> Also I see that Qt also uses the "-Bsymbolic-functions" to do some
> optimization, is that similar case to reduce the relocation ?
Yes. Read my blogs for more detail.
--
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/20120724/467e2088/attachment.sig>
More information about the Development
mailing list