Hello.
Does someone understand FF code (or libxpcom_glue usage) good enough to comment on the following?

in nscore.h we define NS_COM_GLUE:

#ifdef MOZILLA_INTERNAL_API
#  define NS_COM_GLUE
   /*
     The frozen string API has different definitions of nsAC?String
     classes than the internal API. On systems that explicitly declare
     dllexport symbols this is not a problem, but on ELF systems
     internal symbols can accidentally "shine through"; we rename the
     internal classes to avoid symbol conflicts.
   */
#  define nsAString nsAString_internal
#  define nsACString nsACString_internal
#else
#  ifdef HAVE_VISIBILITY_ATTRIBUTE
#    define NS_COM_GLUE NS_VISIBILITY_HIDDEN
#  else
#    define NS_COM_GLUE
#  endif
#endif

And later while linking libxul.so, we link it to libxpcomglue_s.a with "-z allextract" (as I understand - to make libxpcomglue_s.a symbols available in libxul.so):

-Wl,-z -Wl,allextract /export/home/alp/srcs/oi-userland/components/xulrunner/build/i86/dist/lib/libxpcomglue_s.a -Wl,-z -Wl,defaultextract

so, definition in nsCategoryCache.h:
class NS_COM_GLUE nsCategoryObserver MOZ_FINAL : public nsIObserver {
  public:
    nsCategoryObserver(const char* aCategory,
                       nsCategoryListener* aCategoryListener);
    ~nsCategoryObserver();

    void ListenerDied();

    NS_DECL_ISUPPORTS
    NS_DECL_NSIOBSERVER
  private:
    NS_HIDDEN_(void) RemoveObservers();

    nsDataHashtable<nsCStringHashKey, nsCString> mHash;
    nsCategoryListener*                          mListener;
    nsCString                                    mCategory;
    bool                                         mObserversRemoved;
};

causes this class to be hidden.
But it appears in object's headers
$ elfdump nsCategoryCache.o  |grep nsCategoryObserver

Section Header[37]:  sh_name: .data.rel.ro._ZTV18nsCategoryObserver
Section Header[38]:  sh_name: .rel.data.rel.ro._ZTV18nsCategoryObserver
[5] 0x00000000 0x00000018 OBJT LOCL D 0 .data.rel.ro _ZZN18nsCategoryObserver14QueryInterfaceERK4nsIDPPvE5table [48] 0x00000000 0x0000000e FUNC GLOB H 0 .text _ZN18nsCategoryObserver6AddRefEv [49] 0x00000010 0x00000031 FUNC GLOB H 0 .text _ZN18nsCategoryObserver14QueryInterfaceERK4nsIDPPv [64] 0x00000050 0x000000d2 FUNC GLOB H 0 .text _ZN18nsCategoryObserver15RemoveObserversEv [68] 0x00000130 0x00000010 FUNC GLOB H 0 .text _ZN18nsCategoryObserver12ListenerDiedEv [69] 0x00000140 0x000003bd FUNC GLOB H 0 .text _ZN18nsCategoryObserver7ObserveEP11nsISupportsPKcPKt [87] 0x00000500 0x00000044 FUNC GLOB H 0 .text _ZN18nsCategoryObserverD2Ev [88] 0x00000000 0x00000018 OBJT WEAK H 0 .data.rel.ro._ _ZTV18nsCategoryObserver [89] 0x00000500 0x00000044 FUNC GLOB H 0 .text _ZN18nsCategoryObserverD1Ev [90] 0x00000550 0x00000055 FUNC GLOB H 0 .text _ZN18nsCategoryObserver7ReleaseEv [96] 0x000005b0 0x0000056e FUNC GLOB H 0 .text _ZN18nsCategoryObserverC2EPKcP18nsCategoryListener [103] 0x000005b0 0x0000056e FUNC GLOB H 0 .text _ZN18nsCategoryObserverC1EPKcP18nsCategoryListener
       [0]   [ COMDAT ]               _ZTV18nsCategoryObserver
       [1]   .data.rel.ro._ZTV18nsCategoryObserver [37]
R_386_PC32 0x450 .rel.text _ZN18nsCategoryObserver15RemoveObserversEv R_386_GOTOFF 0x51c .rel.text _ZTV18nsCategoryObserver R_386_PC32 0x581 .rel.text _ZN18nsCategoryObserverD1Ev R_386_GOTOFF 0x5d0 .rel.text _ZTV18nsCategoryObserver R_386_PC32 0x13c .rel.text _ZN18nsCategoryObserver15RemoveObserversEv
Relocation Section:  .rel.data.rel.ro._ZTV18nsCategoryObserver
R_386_32 0x8 .rel.data.rel. _ZN18nsCategoryObserver14QueryInterfaceERK4nsIDPPv R_386_32 0xc .rel.data.rel. _ZN18nsCategoryObserver6AddRefEv R_386_32 0x10 .rel.data.rel. _ZN18nsCategoryObserver7ReleaseEv R_386_32 0x14 .rel.data.rel. _ZN18nsCategoryObserver7ObserveEP11nsISupportsPKcPKt

And during linking this object is extracted from nsCategoryCache.o, this results in

ld: fatal: relocation error: R_386_GOTOFF: file ../../dist/lib/libxpcomglue_s.a(nsCategoryCache.o): symbol vtable for nsCategoryObserver: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file ../../dist/lib/libxpcomglue_s.a(nsCategoryCache.o): symbol vtable for nsCategoryObserver: a GOT relative relocation must reference a local symbol
collect2: error: ld returned 1 exit status
make[4]: *** [libxul.so] Error 1

The main question is how and why this works with Sun CC and doesn't work with GNU g++? What is the intention: to make all symbols public? How this class nsCategoryObserver is used? Will defining it public do any harm?
--
Best regards,
Alexander Pyhalov,
system administrator of Computer Center of Southern Federal University

_______________________________________________
oi-dev mailing list
[email protected]
http://openindiana.org/mailman/listinfo/oi-dev

Reply via email to