Skip to main content
GameDev.net gamedev.net
🔒 Locked

Removing unused functions and data from executable

Started by Omnipotent Nov 19, 2004 at 2:34 PM 4 replies 1.4k views
Original Post
Omnipotent
Omnipotent
Hi All, I was wondering if there is a gcc linker option to remove unused functions and data from the executable? I can't seem to find one. With the .net compiler and linker I can use these options: -Gy (for compiling) -OPT:REF (For linking) Is there any equivalents for the gcc compiler? Thanks!!
Nice Coder
Nice Coder
-o3 should do it (optimizations should remove things linke that),

DENC
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
marijnh
marijnh
I do not think -O3 does that, -s (strip) is what you want.
Fruny
Fruny
Top result on google for "gcc discard unused functions".
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
markr
markr
Some things should be removed by default anyway.

As far as I'm aware, the compiler/linker should automatically (and probably without optimisation settings)

- Ditch unused static functions and variables
- Linker will ignore objects which aren't required (unless output is a library itself, or an option is specified to keep them)

Because the compile/link process is separate, the compiler cannot throw away functions that aren't used as it doesn't know what they're linked against. Likewise, the linker probably cannot move functions around in memory to compact space from unused ones, as it doesn't know about static items etc, which might be using them anyway.

Note to petewood: strip does not remove any unused functions or variables from the executable, just debugging info / unneeded symbols.

Mark

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.