-fvisibility=hidden的用法
来源:互联网 发布:下载播放软件 编辑:程序博客网 时间:2024/05/17 17:44
man gcc:
-fvisibility=[default|internal|hidden|protected] Set the default ELF image symbol visibility to the specified option---all symbols are marked with this unless overridden within the code. Using this feature can very substantially improve linking and load times of shared object libraries, produce more optimized code, provide near-perfect API export and prevent symbol clashes. It is strongly recommended that you use this in any shared objects you distribute. Despite the nomenclature, default always means public; i.e., available to be linked against from outside the shared object. protected and internal are pretty useless in real-world usage so the only other commonly used option is hidden. The default if -fvisibility isn't specified is default, i.e., make every symbol public. A good explanation of the benefits offered by ensuring ELF symbols have the correct visibility is given by "How To Write Shared Libraries" by Ulrich Drepper (which can be found at <http://www.akkadia.org/drepper/>)---however a superior solution made possible by this option to marking things hidden when the default is public is to make the default hidden and mark things public.
example code:
foo.c:
void foo(void){}gcc -shared -fpic -g -fvisibility=hidden foo.c -o libfoo.so
test.c
void foo();int main(void){foo();return 0;}
gcc test.c -L. -lfoo/tmp/cciIvtvi.o: In function `main':test.c:(.text+0x12): undefined reference to `foo'collect2: error: ld returned 1 exit status
修改 foo.c如下:
void __attribute__((visibility("default"))) foo(void){}
然后重新编动态库, link通过。
阅读全文
0 0
- -fvisibility=hidden的用法
- <input id="pjdxid_1" type="hidden" value="${fwpj.CPjdxId }" />中hidden的用法
- input type=hidden name='x'的用法总结
- overflow:hidden;的偏方用法(非主要用法)
- input type="hidden" 作用_ input的属性用法介绍
- <input type="hidden">的问题
- input type=\"hidden\" 的作用
- c:foreach jstl el表达式的用法以及c:foreach中的hidden的用法
- HTML5 的 hidden="hidden" 和CSS的 display:none有什么区别?
- Jquery选择器input:hidden和input[type=hidden]的区别
- html:hidden的使用
- html:hidden的使用
- html:hidden的使用
- Erlang的hidden节点
- overflow:hidden的作用
- overflow:hidden的作用
- overflow:hidden的作用
- overflow:hidden的作用
- Spring理解
- 线段树2(区间更新)
- 每日一点Js(四)
- HDU6095-Rikka with Competition
- 线段树【模板】
- -fvisibility=hidden的用法
- Fresco的实践历程
- HashMap的四种访问方式
- 产品到平台的思考1
- HDU6106 Classes
- Linux下Vi用法
- 创建Java线程的3种方式及对比
- java GUI界面之JTable详解
- <C语言>如何一步一步根据简单的代码联想到更多的功能?(实现输入一个整数,输出比它小包括它本身的所有素数。)