How to disable weak symbol support for an embedded target

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all:

I am building a GCC 4.5.3 cross-compiler for an embedded PowerPC target, together with binutils-2.21 and newlib 1.19.0 .

I am building GCC with --enable-threads=posix , and newlib supplies headers like pthread.h , so I that I only have to provide the implementation of routines like pthread_mutex_lock() in my embedded OS, and that should do the trick.

I am experiencing a crash during the call to __eabi right at the beginning of main(). I tracked it down to a call to pthread_once() being a NULL pointer, that is somewhere inside _register_frame_info_bases(). I then found out that all references to the posix thread APIs are marked as weak symbols: if you forget to implement one, they end up being NULL, and the binary crashes.

This is the place where those weak symbols are defined:
[gthr-posix.h]
#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
# ifndef __gthrw_pragma
#  define __gthrw_pragma(pragma)
# endif
# define __gthrw2(name,name2,type) \
  static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
  __gthrw_pragma(weak type)
# define __gthrw_(name) __gthrw_ ## name


I thought the best way to deal with this problem would be to disable weak symbols all around. I don't need such advances features after all in my embedded software.

Well, I haven't managed to disable weak symbols yet. I first tried tracking down who sets SUPPORTS_WEAK or GTHREAD_USE_WEAK, to no avail. It seems that __GXX_WEAK__ is a predefined symbol in my GCC, and somehow that triggers the other symbols later on. That might be because the assembler and linker  from binutils do support weak symbols. Alas, there is no --disable-weak-symbol option in either GCC or in binutils.

I tried specifying "-fno-weak" in CFLAGS_FOR_TARGET. That variable only seems to be taken into account when running ./configure for GCC, if I set it just for the 'make' call, it's ignored. I also try with ./configure flag --enable-cxx-flags="-fno-weak" . In any case, the compiler calls building the affected libstdc++-v3 files do not include that flag, it looks like --enable-cxx-flags gets ignored.

Can someone help?

Please copy me on the answer, as I'm not subscribed to this list.

Many thanks in advance,
  R. Diez




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux