PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Memory optimalisation for .dll-s

Guys,

I have run into strange linker problem.

I want to create a .dll file, and it seems that the EVC puts all not static functions into the code, even if I do not refer to them.
(if I declare them for static then the linker ignores them)

This is true for functions defined in .c files.
Functions defined in .cpp and not referred are properly ignored.

It is important for me to have the .dll as small as possible.

So I have two ways, one to find, redeclare static/delete all unused functions or to find a linker solution for it. :-)

(I do not want to do the first as some of these functions are part of generic modules and are used in other applications too)

If I link my code to .exe it is ok.

I have read the whole evc documentation.
No luck.

Any hints?

Thanks,
G.
Are you exporting the routines that are not being referenced but whose code is still linked in? Obviously if you export a routine it will be included in the DLL no matter what.

Dan East
Dan East wrote:
Are you exporting the routines that are not being referenced but whose code is still linked in? Obviously if you export a routine it will be included in the DLL no matter what.

Dan East


These are standard extern, but non static functions. I do not use __dllexport or link /EXPORT or EXPORT in .def to export them as DLL functions.

Example:
I have the fmod / zlib module (with full source) in it. I use about 50% of the functions they define.

( I do not use deflate in zlib, so when I compile it it should be ignored as it happens with .exe)

I have generated a .map file and these functions are in it.

You can try it, if you just define with no reference a simple function in .c :
Code:

void NoOneWouldUseThisFunctionForSure()
{
g_lSimpleLongVariableSomewhere = 12345678;
}

It will be linked into .dll.

G.
What if you func does not access global variables?

Dan East
Dan East wrote:
What if you func does not access global variables?

Dan East

same, the correct 4 bytes long
mov pc,lr
is linked. :-(

G.