cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: stripping out unneccesary parts of libcrypto for smallest footprint possible

From: Hongli Lai <hongli_at_phusion.nl>
Date: Tue, 7 Dec 2010 13:03:37 +0100

On Tue, Dec 7, 2010 at 12:38 PM, RHYS TWELVES
<codemonkey12s_at_btopenworld.com> wrote:
> Hi there,
>
> Am using libCurl with openSSL to provide the PC web interface of a fixed &
> limited memory device.
> Unfortunately, the memory footprint of a cut-down (no-asm, no-des, no-dsa,
> no-md2, no-rc2, no-rc4, no-cast, no-bf, no-krb5, no-hw) libcrypto is still
> too much ~800kb.
>
> I'm trying to manually strip away parts that I think we can do without, but
> am new to openssl, so am not aware of the implicit dependencies between
> systems. Does anyone know of a better (less blind) method of targeting
> memory-hungry parts of libcrypto?

What kind of memory usage are you talking about, shared read-only or
private dirty? One of the reasons why libcrypto eats to much private
dirty RSS during startup is because of large amounts of
array-of-string constants in its source code, like

static const char *foo[] = { "str1", "str2", ... }

This causes the dynamic linker to perform relocations during startup,
making lots of memory dirty. This can be solved by changing it to

static const char foo[][] = { "str1", "str2", ... }

which avoids relocations at the cost of increasing the size of the
.text segment. But the libcrypto developers apparently have no
intention on making such changes [1] so you must do this yourself if
it really matters to you.

[1] http://vignatti.wordpress.com/2010/03/25/scrutinizing-x-memory-part-2-whats-taking-all-that-memory/#comment-1724
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-07