Re: Dead code stripping and void
Re: Dead code stripping and void
- Subject: Re: Dead code stripping and void
- From: Dair Grant <email@hidden>
- Date: Thu, 14 Jul 2005 18:17:49 +0100
Hi,
I have a bundle A, which links to a static library B. B contains some
functions which I don't want to end up in A, so I'm attempting to
dead-code strip them.
I've got dead code stripping turned on in both projects, have debug
symbols set to -gfull in both projects, and have an export file in A's
target to control the list of symbols that should be exported.
The functions in B that I want to lose definitely aren't referenced in
the link, as I can comment them out yet still link the bundle.
Both projects build with gcc 3.3 (under Xcode 2.1), for 10.2
compatibility.
The functions are just static functions within a class:
class COpenGLUtilities {
public:
static GLboolean IsBufferARB( GLuint buffer);
static void BufferDataARB( GLenum target);
static void BufferSubDataARB( GLenum target);
static void GetBufferSubDataARB(GLenum target);
};
If I pass -Wl,-M for the Other Linker Flags, the link map shows:
0x00075944 0x00000020 ... COpenGLUtilities::IsBufferARB
(dead stripped) ... COpenGLUtilities::BufferDataARB
(dead stripped) ... COpenGLUtilities::BufferSubDataARB
(dead stripped) ... COpenGLUtilities::GetBufferSubDataARB
The symbols are mangled in the link map, but the upshot is that three
of the functions are stripped but COpenGLUtilities::IsBufferARB is not.
If I change the return type of COpenGLUtilities::IsBufferARB to be
void, and make no other changes, then it is also stripped.
The same issue happens with several methods spread throughout a range
of classes - in each case the function doesn't get stripped if it has a
non-void return type, even if there are no references to it in the
final executable.
Presumably the linker starts with a set of known symbols and works out
from there to determine what's reachable, but why would changing the
return value cause it to think the function is referenced?
Looking at the final executable with otool shows that there are about
1500 functions (out of 3000) which are unreferenced - the definition is
present, but no other code appears to be able to reach them (some are
probably reachable through static initialisers/etc, but most of them
look completely unconnected to other functions).
Is there any way to force the linker, or some other tool, to
specifically remove a function's definition from the binary?
I've tried using -unexported_symbols_list with things like
COpenGLUtilities::IsBufferARB, but to no avail (using -y shows it as
"private extern", which I assumed made it a candidate for dead
stripping).
-dair
___________________________________________________
mailto:email@hidden http://www.zonic.co.uk/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden