[fpc-pascal] Placing binary data (resources) in object files?

Anthony Walter sysrpl at gmail.com
Mon Jun 3 22:22:08 CEST 2013

Okay I found some interesting results after a bit of testing...

When using bin2obj you get a byte of array typed constant which you can
include in your sources. The compiler will always include the resource
whether it is referenced from code or not. Stripping the app (strip -s -g
appname) does not remove the size the constants add to the app even if they
aren't referenced by any other code.

Using an untyped constant such as "const Image = {$r image.base64};" still
adds to the app size even if it's not referenced, but it can only be
stripped out if no units are included which reference access to the
constant. This means if a "function A" sets a string using part of the
constant, then Image (in the example above) will be embedded and cannot be
stripped, even if no code calls "function A".

image.base64 contains 480kb of encoded text

What this means is that all string constants and typed constants are take
up space in your executable whether your use them or not, which is not
ideal IMO. The compiler ought to be able to detect when these constants are
not referenced (much like not including the machine code of unused
functions) and exclude them from the final app.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130603/3ed8668f/attachment.html>

More information about the fpc-pascal mailing list