<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    libgcc2 is already in the toolset. This almost 100% certainly is a
    small<br>
    bug in c/src/lib/libbsp/sparc/shared/startup/linkcmds.base.  Look <br>
    at how the .ctors are referenced in the files elf32_sparc.x*
    installed<br>
    as part of the toolset in $prefix/sparc-rtems4.11/lib/ldscripts.
    They<br>
    have "." and a "*" in the KEEP lines. I don't think we have that.<br>
    <br>
    The problem was almost certainly introduced with function sections<br>
    being used and I missed a wildcard on the ctor/dtor lines.<br>
    <br>
    <div class="moz-cite-prefix">On 3/27/2014 3:04 AM, Thomas (Gmail)
      wrote:<br>
    </div>
    <blockquote
cite="mid:CADY8aTAdyy7EFiu7B0ERaPiJs_dzOt2SOuvAAOTHMK6oqQgpTQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">On referencing, I am a beginner regarding this.
        <div><br>
        </div>
        <div>As I know from googling information, name of the section
          for constructor is in .ctors section in linkcmds.base.</div>
        <div>below reference code is from gcc-4.8.2/libgcc/libgcc2.c</div>
        <div>because __do_global_ctors() function is in libgcc2.c, I
          tried to add libgcc.a in rtems building environment. but, I
          didn't complete.</div>
        <div><br>
        </div>
        <div>< libgcc2.c ></div>
        <div>
          <div>----------------------------------------------------------------------------------------------------</div>
          <div>/* Run all the global destructors on exit from the
            program.  */</div>
          <div>void<br>
          </div>
          <div>__do_global_ctors (void)</div>
          <div>{</div>
          <div>#ifdef EH_FRAME_SECTION_NAME</div>
          <div>  {</div>
          <div>    static struct object object;</div>
          <div>    __register_frame_info (__EH_FRAME_BEGIN__,
            &object);</div>
          <div>  }</div>
          <div>#endif</div>
          <div>  DO_GLOBAL_CTORS_BODY;</div>
          <div>  atexit (__do_global_dtors);</div>
          <div>}</div>
          <div>-------------------------------------------------------------------------------------<br>
          </div>
          <div><br>
          </div>
        </div>
        <div>< gbl-ctors.h></div>
        <div>-------------------------------------------------------------------------------------</div>
        <div>
          <pre style="color:rgb(0,0,0)"><span class="" style="font-style:italic;color:rgb(178,34,34)">/* Some systems use a different strategy for finding the ctors.
   For example, svr3.  */</span>
#<span class="" style="font-weight:bold;color:rgb(95,158,160)">ifndef</span> <span class="" style="font-weight:bold;color:rgb(184,134,11)">DO_GLOBAL_CTORS_BODY</span>
#<span class="" style="font-weight:bold;color:rgb(95,158,160)">define</span> <span class="" style="font-weight:bold;color:rgb(184,134,11)">DO_GLOBAL_CTORS_BODY</span>                                          \
<span class="" style="font-weight:bold;color:rgb(160,32,240)">do</span> {                                                                       \
  <span class="" style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> <span class="" style="font-weight:bold;color:rgb(34,139,34)">long</span> nptrs = (<span class="" style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> <span class="" style="font-weight:bold;color:rgb(34,139,34)">long</span>) __CTOR_LIST__[0];               \
  <span class="" style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> i;                                                               \
  <span class="" style="font-weight:bold;color:rgb(160,32,240)">if</span> (nptrs == (<span class="" style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> <span class="" style="font-weight:bold;color:rgb(34,139,34)">long</span>)-1)                                  \
    <span class="" style="font-weight:bold;color:rgb(160,32,240)">for</span> (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);               \
  <span class="" style="font-weight:bold;color:rgb(160,32,240)">for</span> (i = nptrs; i >= 1; i--)                                          \
    __CTOR_LIST__[i] ();                                                \
} <span class="" style="font-weight:bold;color:rgb(160,32,240)">while</span> (0) 
#<span class="" style="font-weight:bold;color:rgb(95,158,160)">endif</span></pre>
          <pre style="color:rgb(0,0,0)"><span style="font-family:arial;color:rgb(34,34,34)">-------------------------------------------------------------------------------------</span></pre>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">2014-03-27 16:33 GMT+09:00 Joel
          Sherrill <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:joel.sherrill@oarcorp.com" target="_blank">joel.sherrill@oarcorp.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
            On 3/27/2014 2:30 AM, Sebastian Huber wrote:<br>
            > On 2014-03-27 06:28, Thomas (Gmail) wrote:<br>
            >> I am tring to add libgcc.a in linking process for
            calling __do_global_ctors().<br>
            > If you have to do this by hand, then your build process
            is broken.  How did you<br>
            > get the RTEMS tool chain?  Which RTEMS version do you
            use?<br>
            ><br>
            >> Please could you let me know how to add libgcc.a in
            RTEMS building environment ?<br>
            >><br>
            >> If this approach is not correct, please let me know
            correct how-to-do for C++<br>
            >> global constructor for Sparc.<br>
            > It should work out of the box.<br>
            ><br>
            Just out of curiosity what is the name of the section that
            the<br>
            constructor is in?<br>
            <br>
            When I turned on function sections, it may now be in
            .initXXX instead of<br>
            just .init.<br>
            This would mean that an asterisk is needed in the
            linkcmds.base for init<br>
            and fini<br>
            to pick up all the methods. There is a KEEP() around them
            which I<br>
            thought might<br>
            be the issue.<br>
            <span class="HOEnZb"><font color="#888888"><br>
                --<br>
                Joel Sherrill, Ph.D.             Director of Research
                & Development<br>
                <a class="moz-txt-link-abbreviated" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a>        On-Line Applications
                Research<br>
                Ask me about RTEMS: a free RTOS  Huntsville AL 35805<br>
                Support Available                (256) 722-9985<br>
                <br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Joel Sherrill, Ph.D.             Director of Research & Development
<a class="moz-txt-link-abbreviated" href="mailto:joel.sherrill@OARcorp.com">joel.sherrill@OARcorp.com</a>        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985</pre>
  </body>
</html>