首页 > 其他 > 详细

weak symbol的设计意图

时间:2015-04-13 12:52:19      阅读:285      评论:0      收藏:0      [点我收藏+]

用nm察看elf文件时,会输出各种符号,其中有两种符号,比较特别


           "V"
           "v" The symbol is a weak object.  When a weak defined symbol is linked with a normal defined
               symbol, the normal defined symbol is used with no error.  When a weak undefined symbol is
               linked and the symbol is not defined, the value of the weak symbol becomes zero with no error.
               On some systems, uppercase indicates that a default value has been specified.

           "W"
           "w" The symbol is a weak symbol that has not been specifically tagged as a weak object symbol.
               When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol
               is used with no error.  When a weak undefined symbol is linked and the symbol is not defined,
               the value of the symbol is determined in a system-specific manner without error.  On some
               systems, uppercase indicates that a default value has been specified.
上面是nm的manpage内容,只描述了what,没有why


在网上搜索许久,只能看到what和how,也没有讲why


不行,我要知其然更知其所以然


于是在wikipedia上找到了答案


简言之,就是一种link-time的overloading

weak symbol的设计意图

原文:http://blog.csdn.net/happen23/article/details/45023609

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!