get rid weak symbols code

Jiri Olsa jolsa@redhat.com
Fri Apr 1 15:08:00 GMT 2011


hi,

I'd like to ask if there's a way to compile/link out the weak
symbol's code that has been overloaded.

Having following objects:


1st object:
---
int __attribute__((weak)) krava(void)
{
        printf("weak krava\n");
        return 0;
}

int main(int argc, char **argv)
{
        krava();
        return 0;
}
---


2nd object:
---
int krava(void)
{
        printf("krava\n");
        return 0;
}
---


..the final executable will call krava function from 2nd object file,
so far so good.. :)

However, the function krava from the 1st object still stays in the
final executable with no symbol assigned.. as a dead code I'd say.

I guess it's probably not easy to get rid of that code during the
linking time.. and I haven't found any way to do that.
Is there any? Or what did I miss.. :)


thanks,
jirka



More information about the Gcc-help mailing list