get rid weak symbols code
Jeff Law
law@redhat.com
Mon Apr 4 16:11:00 GMT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 04/01/11 09:08, 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.. :)
You could try putting each function into its own section, then asking
the linker to garbage collect sections.
jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJNme18AAoJEBRtltQi2kC7D7wH+wcSYhB3PZnid1ZmulluDam8
iMEAxEhpvRiCDWbMdgxjYbo+fKOGPP1tkuFBGnQKHtYfntyA1mLRJNiD2c8+JLJ/
GM9dwUy+tiY20XpXuqu4mp8HLAgvvHTvWqYbtlqHSSArTNNherWSqkXpTmtfko0x
CyXkitRe8ycgf1bIf+Hwutg5zDSdq4q5Szt7JiZZGQaF/lcWgyWcwCFBM6wiaH50
wgz1N3z/CFCbKzK+QBma967UyAL8OQf7oSNGPUaBIMfVi1v5az+L4wD3Bh67jmfH
Rwu+bAoTHtdaCGPi9my/Dix6XXTcE88TdKDqW/BN0N9RsZLLuFW7/3ronjrgsgo=
=2X5L
-----END PGP SIGNATURE-----
More information about the Gcc-help
mailing list