This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [OT] Prevent linker from unnecessary symbol resolution
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Srikanth Madani <srikanth dot madani at vodafone dot com>
- Cc: gcc-help mailing list <gcc-help at gcc dot gnu dot org>
- Date: 10 May 2004 13:17:02 -0400
- Subject: Re: [OT] Prevent linker from unnecessary symbol resolution
- References: <FIENJLGJKDKHBKMKOPONOEBBCCAA.srikanth.madani@vodafone.com>
Srikanth Madani <srikanth.madani@vodafone.com> writes:
> Suppose I have a C file fun1.c containing two functions:
>
> __________
> void func1() {
> printf("\nIn function func1()\n");
> }
> void func2() {
> func3();
> }
> ___________
>
> and another called hello.c containing:
>
> ___________
> void main() {
> func1();
> }
> ___________
>
> Is it possible to create a staticly linked binary using just these two
> source files? Or do I have to provide a function definition for func3(),
> even though it is not called.
You have to define func3. You could do it on the linker command line
using something along the lines of '-Wl,--defsym,func3=0'.
If you compile with -ffunction-sections and link with --gc-sections,
you might get away with not defining func3. I haven't tried it,
though, and it would be inherently system dependent.
Ian