RE: [OT] Prevent linker from unnecessary symbol resolution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for the response Ian.

So, the conclusion is that my binary is stuck with unnecessary relocatable
code (of a function func3() which main() doesn't call).
Of course, I don't call func2() either, but I can accept that - as it is
defined within an object file which I use (fun1.o)

My interest in all this is to remove unused functions, and thus reduce the
size of my final binary.

I did find another thread on this list which dealt with removing dead code.
Here's the Google cache :
http://66.102.11.104/search?q=cache:5y73E-67cZAJ:gcc.gnu.org/ml/gcc-help/200
3-08/msg00128.html++site:gcc.gnu.org+removing+dead+code&hl=en

I'm not sure I can do this under Solaris though - I will post an update if I
manage it.

Best regards,
Srikanth Madani

ps: Here's the entire scenario - if someone wishes to recreate it.

[181]> \ls *.c
fun1.c    fun2.c    hello.c

[182]> cat fun1.c
void func1() {
        printf("\nIn function func1()\n");
}
void func2() {
        func3();
}


[183]> cat fun2.c
void func3() {
        printf("\nIn function func3()\n");
}


[184]> cat hello.c
void main() {
        func1();
}

[185]> cc hello.c fun1.c
hello.c:
fun1.c:
Undefined                       first referenced
 symbol                             in file
func3                               fun1.o
ld: fatal: Symbol referencing errors. No output written to a.out


And if I use fun2.c as well - then all goes well.

[186]> cc hello.c fun1.c fun2.c
hello.c:
fun1.c:
fun2.c:

[187]> \ls a.out
a.out


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux