免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1117 | 回复: 0
打印 上一主题 下一主题

GNU/Linux application programming [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-04 23:25 |只看该作者 |倒序浏览
chapter 06.Building Static Libraries
we use the ar command to build our library (libmyrand.a). The cru options are a standard set of options for creating or adding to an archive. The c option specifies to create the static library (unless it already exists, in which case the option is ignored). The r option tells ar to replace existing objects in the static library (if they already exist). Finally, the u option is a safety option to specify that objects are replaced in the archive only if the objects to be inserted are newer than existing objects in the archive (of the same name).
In this example, we use nm to print the symbols within the shared library, but then only emit those with the tag " T " to stdout (those symbols that are part of the .text section, or code segments). We also use the -n option to sort the output numerically by address, rather than the default, which is alphabetically by symbol name. This gives us relative address information within the library; if we wanted to know the specific sizes of these .text sections, we could use the -S option, as:
$ nm -n -S /usr/local/lib/libmyrand.so | grep " T "
00000608 T _init
0000074c 00000036 T initRand
00000784 0000003a T getSRand
000007be 00000050 T getRand
00000844 T _fini
$
From this example, we can see that the initRand is located at relative offset 0x74c in the library and its size is 0¥36 (decimal 54) bytes. Many other options are available; the nm mainpage provides more detail on this.
Dynamic Library APIs    #include
    void *dlopen( const char *filename, int flag );
    const char *dlerror( void );
    void *dlsym( void *handle, char *symbol );
    int dlclose( void *handle );

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/42908/showart_1813281.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP