This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ATTRIBUTE_WEAK not working in crtstuff.c?


Hi,

For a couple of weeks, I've been getting shared libraries with
non-weak references to __register_frame_info_bases when compiled with
a GCC built off the trunk.

  $ nm --dynamic libfreetype.so
  [snip]
           w _Jv_RegisterClasses
  00049f1c A __bss_start
           U __ctype_b
           w __cxa_finalize
           U __deregister_frame_info_bases
           U __fxstat
           w __gmon_start__
           U __register_frame_info_bases
           U __sigsetjmp

Notice the weak reference to __cxa_finalize and the strong reference
to __register_frame_info_bases.  In crtstuff.c, both are marked with
ATTRIBUTE_WEAK, but __register_frame_info_bases has a declaration
without ATTRIBUTE_WEAK in unwind-dw2-fde.h, which is included in
crtstuff.c.  The comment in crtstuff.c says:

  /* We do not want to add the weak attribute to the declarations of these
     routines in unwind-dw2-fde.h because that will cause the definition of
     these symbols to be weak as well.

     This exposes a core issue, how to handle creating weak references vs
     how to create weak definitions.  Either we have to have the definition
     of TARGET_WEAK_ATTRIBUTE be conditional in the shared header files or
     have a second declaration if we want a function's references to be weak,
     but not its definition.

     Making TARGET_WEAK_ATTRIBUTE conditional seems like a good solution until
     one thinks about scaling to larger problems -- ie, the condition under
     which TARGET_WEAK_ATTRIBUTE is active will eventually get far too
     complicated.

     So, we take an approach similar to #pragma weak -- we have a second
     declaration for functions that we want to have weak references.

     Neither way is particularly good.  */

It seems to me, on a cursory glance, that this approach of adding a
weak attribute to a second declaration isn't working.

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]