Subject: Re: dynamic linker
To: Wojciech Puchar <wojtek@chylonia.3miasto.net>
From: Greg A. Woods <woods@weird.com>
List: netbsd-users
Date: 03/19/2002 14:01:26
[ On Tuesday, March 19, 2002 at 19:23:46 (+0100), Wojciech Puchar wrote: ]
> Subject: dynamic linker
>
> i tested how long does it take to execute program that does nothing
> main() {}
> 
> it's 16ms normally and 8ms when using static link
> 
> 8ms is anyway million CPU cycles on my machine (pentium-133).

I'll bet there's a bunch of I/O, even if from buffers, in that
additional 8ms.

> what incredibly complicated operations ld-elf.so is doing to link such
> simple programs (containing minimal set of references to libs) to do it so
> long?

If you don't already know, you probably don't want to know.  It's really
quite a sick and horrid and inefficient hack the way dynamic libraries
work on SunOS-4 and now BSD for ELF binaries.  I've thought so since day
one (although back then I had a secret desire for making programs
extensible with machine code instead of interpreter code), and now that
I understand the security implications more deeply, I'm even more
certain of it (and my secret desire for more and easier extensibility
has been mostly quelled).  That's not to say there are not some specific
scenarios and some types of workloads which can benefit greatly from
such hacks (i.e. turn the performance disadvantages into significant
advantages), but....  :-)

See my archived postings (to current-users, I think) about just how much
faster my all-100%-static-linked NetBSD/sparc machine is
(even/especially with X11!).

-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods@acm.org>;  <g.a.woods@ieee.org>;  <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>