On 04/01/2011 04:08 PM, Jiri Olsa wrote: > 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.. :) Try -ffunction-sections . Andrew.