Subject: Re: Shrinking NetBSD - deep final distribution re-linker
To: Ian Zagorskih <firstname.lastname@example.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 10/20/2004 02:06:15
> 1. Crunched executable is statically linked. Does it mean, that when
> i load any crunched "utility" dynamicall linker loads the whole
> executable imageinto memory every time?
Well, the linker is not involved; when an executable is linked static,
all the linking is completed at build time.
Conceptually, the whole executable is loaded into memory at startup.
This is done lazily, though, by just setting up the process virtual
memory pages as demand-paged from the executable. The actual paging in
does not happen until the process tries to access those pages (eg,
execute out of them) and incurs page faults.
> I.e. it makes an own dedicated copy of code/data sections for each
> exec() and code sections are not shared between different processes?
No. The text segment (loosely speaking - for ELF executables, this
really means something more like "the .text and .rodata segments and
possibly others") is shared among all processes running the executable.
In particular, when running a crunched executable, only one copy of the
code should be in memory, even for multiple processes.
> 2. AFAIU crunchgen requires source or at least [...]. Futher more, i
> have some binary-only shared libraries i'd to use in some projects..
As I understand it, you cannot crunch them without hacking on
Conceptually, there is no reason you can't crunch everything and then
dynamically link the result, but actually doing that requires support
in crunchgen that I don't think exists. (In principle it is also
possible to take a shared library and statically link it in, doing the
equivalent of the dynamic-linking step, usually done at run time, at
link time. This requires linker support that also, as far as I know,
As you point out, this really just means that crunchgen isn't designed
to address the desires you outline; it will, unfortunately, stay that
way until the skill, motivation, and time to change it all come
together for someone. (Sounds as though you have the motivation, but
from what you wrote, I can't tell about the others.)
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML email@example.com
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B