RTEMS C++ global constructor for Sparc

Joel Sherrill joel.sherrill at OARcorp.com
Thu Mar 27 09:18:31 UTC 2014


libgcc2 is already in the toolset. This almost 100% certainly is a small
bug in c/src/lib/libbsp/sparc/shared/startup/linkcmds.base.  Look
at how the .ctors are referenced in the files elf32_sparc.x* installed
as part of the toolset in $prefix/sparc-rtems4.11/lib/ldscripts. They
have "." and a "*" in the KEEP lines. I don't think we have that.

The problem was almost certainly introduced with function sections
being used and I missed a wildcard on the ctor/dtor lines.

On 3/27/2014 3:04 AM, Thomas (Gmail) wrote:
> On referencing, I am a beginner regarding this.
>
> As I know from googling information, name of the section for
> constructor is in .ctors section in linkcmds.base.
> below reference code is from gcc-4.8.2/libgcc/libgcc2.c
> because __do_global_ctors() function is in libgcc2.c, I tried to add
> libgcc.a in rtems building environment. but, I didn't complete.
>
> < libgcc2.c >
> ----------------------------------------------------------------------------------------------------
> /* Run all the global destructors on exit from the program.  */
> void
> __do_global_ctors (void)
> {
> #ifdef EH_FRAME_SECTION_NAME
>   {
>     static struct object object;
>     __register_frame_info (__EH_FRAME_BEGIN__, &object);
>   }
> #endif
>   DO_GLOBAL_CTORS_BODY;
>   atexit (__do_global_dtors);
> }
> -------------------------------------------------------------------------------------
>
> < gbl-ctors.h>
> -------------------------------------------------------------------------------------
> /* Some systems use a different strategy for finding the ctors.
>    For example, svr3.  */
> #ifndef DO_GLOBAL_CTORS_BODY
> #define DO_GLOBAL_CTORS_BODY						\
> do {									\
>   unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];		\
>   unsigned i;								\
>   if (nptrs == (unsigned long)-1)				        \
>     for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);		\
>   for (i = nptrs; i >= 1; i--)						\
>     __CTOR_LIST__[i] ();						\
> } while (0) 
> #endif
> -------------------------------------------------------------------------------------
>
>
> 2014-03-27 16:33 GMT+09:00 Joel Sherrill <joel.sherrill at oarcorp.com
> <mailto:joel.sherrill at oarcorp.com>>:
>
>
>     On 3/27/2014 2:30 AM, Sebastian Huber wrote:
>     > On 2014-03-27 06:28, Thomas (Gmail) wrote:
>     >> I am tring to add libgcc.a in linking process for calling
>     __do_global_ctors().
>     > If you have to do this by hand, then your build process is
>     broken.  How did you
>     > get the RTEMS tool chain?  Which RTEMS version do you use?
>     >
>     >> Please could you let me know how to add libgcc.a in RTEMS
>     building environment ?
>     >>
>     >> If this approach is not correct, please let me know correct
>     how-to-do for C++
>     >> global constructor for Sparc.
>     > It should work out of the box.
>     >
>     Just out of curiosity what is the name of the section that the
>     constructor is in?
>
>     When I turned on function sections, it may now be in .initXXX
>     instead of
>     just .init.
>     This would mean that an asterisk is needed in the linkcmds.base
>     for init
>     and fini
>     to pick up all the methods. There is a KEEP() around them which I
>     thought might
>     be the issue.
>
>     --
>     Joel Sherrill, Ph.D.             Director of Research & Development
>     joel.sherrill at OARcorp.com        On-Line Applications Research
>     Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>     Support Available                (256) 722-9985
>
>

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20140327/f46bde31/attachment.html>


More information about the devel mailing list