GCC的兩個屬性

來源:互聯網
上載者:User

 

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  ,就這個意思。

可以結帖了吧? 呵呵

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.