Subject: Re: Text relocations in shared libs
To: None <port-sh3@netbsd.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: port-dreamcast
Date: 01/06/2006 08:40:50
On Sun, Dec 25, 2005 at 16:02:11 +0300, Valeriy E. Ushakov wrote:

> [Thanks to Nick Hudson for discovering this]
> 
> For sh3 a few shared libraries in the base system has text
> relocations.  This means that ld.so needs to perform relocations
> during startup.  E.g.
> 
> nada# ktruss echo                                                              
> ...
>    600      1 echo     open("/lib/libc.so.12", 0, 0xfffff804) = 3, 6214
>    600      1 echo     __fstat30(0x3, 0x7fffd82c)  = 0, 6214
>    600      1 echo     mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0x20434000
>    600      1 echo     munmap(0x20434000, 0x1000)  = 0, 541254268
>    600      1 echo     mmap(0, 0xdc000, 0x5, 0x10000002, 0x3, 0, 0, 0) = 0x20440000
>    600      1 echo     mmap(0x20505000, 0x8000, 0x3, 0x12, 0x3, 0, 0xb5000, 0) = 0x20505000
>    600      1 echo     mmap(0x2050d000, 0xf000, 0x3, 0x1012, 0xffffffff, 0, 0, 0) = 0x2050d000
>    600      1 echo     mprotect(0x204f6000, 0xf000, 0) = 0
>    600      1 echo     close(0x3)                  = 0, 831372
> !->600      1 echo     mprotect(0x20440000, 0xb6000, 0x7) = 0
> !->600      1 echo     mprotect(0x20440000, 0xb6000, 0x5) = 0
> 
> This also means that the pages are no longer shared.
> 
> 
> Offending libraries are libc, libposix, and libpthread.  Text
> relocations come from the handwritten asm files.  libc and libposix
> (that borrows SYS.h code from libc) has a lot of relocs for cerror:

I have cleaned up libc from text relocs.  It should be truly shared
now.  And an unscientific test of running /bin/echo -n in a loop 100
times went down from ~11s to ~8s of wall time on my Jornada.

SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen