Gordan Bobic wrote:
Adding -ffunction-sections -fdata-sections to defaults can help
considerably in producing smaller binaries, and is not the default.
Linking with -Wl,--gc-sections helps a lot and is not the default
Well, -ffunction-sections -fdata-sections -Wl,--gc-sections mostly helps if
the binary contains a lot of unused code. This is not often the case in
dynamically linked executables or shared libraries. Where it typically
happens is statically linked binaries (where the static libraries contain
APIs not used by the statically linked executable), and even there only if
the library is not actually designed for static linking (in which case it
would put separate APIs into separate compilation units to begin with). And
static linking is a bad idea for RAM consumption anyway, at least on
GNU/Linux where dynamically linked executables actually share the code
sections of shared libraries in RAM too, not just on disk.
So I'm afraid you will probably find those options to be less useful in
practice than you expect.
Kevin Kofler