GCC的两个属性

来源:互联网 发布:最好的知已的内容 编辑:程序博客网 时间:2024/05/17 22:33

 

ld.so里有这么句代码

  1. /* If we would use strong_alias here the compiler would see a non-hidden definition.  
  2. * This would undo the effect of the previous declaration.  
  3. *So spell out was strong_alias does plus add the visibility attribute.  */
  4. extern struct rtld_global _rtld_local  __attribute__ ((alias ("_rtld_global"), visibility ("hidden")));
复制代码


这句话什么意思? extern和hidden不矛盾么?关键这句话怎么解释我不明白.

文件中还定义了一个变量  struct rtld_global _rtld_global ={.xxx=xxx, .xxx=xxx....................}
而struct rtld_global的结构定义,定义在另一个文件.


另外还想问一下,原符号定义了alias后,原符号怎么办?
是不是还如同没定义alias一般,其{全局,局部,弱},{默认,保护,隐藏,内部}这些属性都不变???

 

最佳答案fallshuang


QUOTE:
原帖由 塑料袋 于 2008-1-5 11:32 发表
extern int xxx __attribute__ (visibility ("hidden"));

链接时,xxx对所有obj可见
动态链接时,xxx仅本execute/so可见

难不成这个意思?????




难不成你没有仔细看我re的帖子么? 难不成你没有写个小程序测试下么?
so no other "module" (executable or shared library) can reference it directly.

外部app链接ld.so 时, 无法看见 _rtld_local   ,  但是glibc 中的其他 obj 能看见_rtld_local  ,就这个意思。

可以结帖了吧? 呵呵
原创粉丝点击