<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I am confused. Did you build RTEMS with --enable-cxx?<br>
<br>
Did you make the linkcmds changes discussed?<br>
<br>
In RTEMS, the C++ global constructors are called by the first thread
<br>
that executes. Before that, almost anything a constructor is allowed<br>
to do that is not pure computation or memory initialization would <br>
not be valid because the OS and tasking are not running.<br>
<br>
There is a call in _Thread_Handler to the constructor execution
method.<br>
The name varies by target so it is a macro named INIT. A few lines
of code<br>
later the user init task is invoked.<br>
<br>
Let's keep this on rtems-users so others benefit from the
discussion.<br>
<br>
--joel<br>
<div class="moz-cite-prefix">On 3/27/2014 9:00 PM, Thomas (Gmail)
wrote:<br>
</div>
<blockquote
cite="mid:CADY8aTCPuncfZwxwHe0DcA=Co=H9kT64DNFyhkqSpuUEtRwBQQ@mail.gmail.com"
type="cite">
<div dir="ltr">On referencing, I misunderstood that _init() call
not C++ constructor function because there is not C++
constructor function in crti.o.
<div><br>
</div>
<div>Today, after I make object dump file about elf
file(cxx_throw.exe), I checked that below objdump information.
It included ++ constructor as like below;</div>
<div><br>
</div>
<div>
<div>02066130 <_init>:</div>
<div> 2066130:<span class="" style="white-space:pre"> </span>9d
e3 bf a0 <span class="" style="white-space:pre"> </span>save
%sp, -96, %sp</div>
<div> 2066134:<span class="" style="white-space:pre"> </span>7f
fe 6c 60 <span class="" style="white-space:pre"> </span>call
20012b4 <frame_dummy></div>
<div> 2066138:<span class="" style="white-space:pre"> </span>01
00 00 00 <span class="" style="white-space:pre"> </span>nop </div>
<div> 206613c:<span class="" style="white-space:pre"> </span>7f
ff e8 99 <span class="" style="white-space:pre"> </span>call
20603a0 <__do_global_ctors_aux></div>
<div> 2066140:<span class="" style="white-space:pre"> </span>01
00 00 00 <span class="" style="white-space:pre"> </span>nop </div>
<div> 2066144:<span class="" style="white-space:pre"> </span>81
e8 00 00 <span class="" style="white-space:pre"> </span>restore </div>
<div> 2066148:<span class="" style="white-space:pre"> </span>81
c3 e0 08 <span class="" style="white-space:pre"> </span>retl </div>
<div> 206614c:<span class="" style="white-space:pre"> </span>01
00 00 00 <span class="" style="white-space:pre"> </span>nop </div>
</div>
<div><br>
</div>
<div>I am sorry for my misunderstanding.</div>
<div><br>
</div>
<div>Best Regards</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-03-28 10:19 GMT+09:00 Thomas
(Gmail) <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:thomas73.kim@gmail.com" target="_blank">thomas73.kim@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>Please check that my modification is correct.</div>
<div><br>
</div>
I modified linkcmds.base according to your comment.
<div>
<br>
</div>
<div>(Before)</div>
<div>
<div> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o )
.ctors))</div>
<div> KEEP (*(SORT(.ctors.*)))</div>
<div> KEEP (*(.ctors))</div>
<div> KEEP (*crtbegin.o(.dtors))</div>
<div> KEEP (*crtbegin?.o(.dtors))</div>
<div> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o )
.dtors))</div>
<div> KEEP (*(SORT(.dtors.*)))</div>
<div> KEEP (*(.dtors))</div>
</div>
<div><br>
</div>
<div>(After)<br>
</div>
<div>
<div> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o )
.ctors))</div>
<div> KEEP (*(SORT(.ctors.*)))</div>
<div> KEEP (*(.ctors*))</div>
<div> KEEP (*crtbegin.o(.dtors))</div>
<div> KEEP (*crtbegin?.o(.dtors))</div>
<div> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o )
.dtors))</div>
<div> KEEP (*(SORT(.dtors.*)))</div>
<div> KEEP (*(.dtors*))</div>
</div>
<div><br>
</div>
<div>Also, I compared map file.</div>
<div><br>
</div>
<div>(Before)</div>
<div>
<div> *(.ctors)</div>
<div> .ctors 0x0206040c 0x4
/opt/rtems-4.11/lib/gcc/sparc-rtems4.11/4.8.2/crtend.o</div>
<div> *crtbegin.o(.dtors)</div>
<div> .dtors 0x02060410 0x4
/opt/rtems-4.11/lib/gcc/sparc-rtems4.11/4.8.2/crtbegin.o</div>
<div> *crtbegin?.o(.dtors)</div>
<div> *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)</div>
<div> *(SORT(.dtors.*))</div>
<div> *(.dtors)</div>
</div>
<div><br>
</div>
<div>(After)<br>
</div>
<div>
<div>*(.ctors*)</div>
<div> .ctors 0x0206040c 0x4
/opt/rtems-4.11/lib/gcc/sparc-rtems4.11/4.8.2/crtend.o</div>
<div> *crtbegin.o(.dtors)</div>
<div> .dtors 0x02060410 0x4
/opt/rtems-4.11/lib/gcc/sparc-rtems4.11/4.8.2/crtbegin.o</div>
<div> *crtbegin?.o(.dtors)</div>
<div> *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)</div>
<div> *(SORT(.dtors.*))</div>
<div> *(.dtors*)</div>
<div> </div>
</div>
<div>Best Regards</div>
<div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-03-28 2:00 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:0px
0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> I am out of
the country and teaching this week. Trying
adding an<br>
"*" after ctors and before the parentheses.
Ditto for dtors so it wild<br>
card matches.<br>
<br>
Look at how .text has a * on it <br>
<div>On 3/27/2014 10:25 AM, Thomas (Gmail)
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">I am tring to compare
linkcmd.base and toolchain's elf32_sparc.x.
<div>But, I am difficult to modify
linkcmd.base for this.</div>
<div><br>
</div>
<div>Please could you send to me the revised
linkcmd.base file ?</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-03-27 18:18
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:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div 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>On 3/27/2014 3:04 AM, Thomas
(Gmail) wrote:<br>
</div>
<blockquote 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><span style="font-style:italic;color:rgb(178,34,34)">/* Some systems use a different strategy for finding the ctors.
For example, svr3. */</span>
#<span style="font-weight:bold;color:rgb(95,158,160)">ifndef</span> <span style="font-weight:bold;color:rgb(184,134,11)">DO_GLOBAL_CTORS_BODY</span>
#<span style="font-weight:bold;color:rgb(95,158,160)">define</span> <span style="font-weight:bold;color:rgb(184,134,11)">DO_GLOBAL_CTORS_BODY</span> \
<span style="font-weight:bold;color:rgb(160,32,240)">do</span> { \
<span style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> <span style="font-weight:bold;color:rgb(34,139,34)">long</span> nptrs = (<span style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> <span style="font-weight:bold;color:rgb(34,139,34)">long</span>) __CTOR_LIST__[0]; \
<span style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> i; \
<span style="font-weight:bold;color:rgb(160,32,240)">if</span> (nptrs == (<span style="font-weight:bold;color:rgb(34,139,34)">unsigned</span> <span style="font-weight:bold;color:rgb(34,139,34)">long</span>)-1) \
<span style="font-weight:bold;color:rgb(160,32,240)">for</span> (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \
<span style="font-weight:bold;color:rgb(160,32,240)">for</span> (i = nptrs; i >= 1; i--) \
__CTOR_LIST__[i] (); \
} <span style="font-weight:bold;color:rgb(160,32,240)">while</span> (0)
#<span style="font-weight:bold;color:rgb(95,158,160)">endif</span></pre>
<pre><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:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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.<span><font
color="#888888"><br>
<span><font
color="#888888"><br>
--<br>
Joel Sherrill, Ph.D.
Director of
Research &
Development<br>
<a
moz-do-not-send="true"
href="mailto:joel.sherrill@OARcorp.com" target="_blank">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></font></span></blockquote>
<span><font color="#888888"> </font></span></div>
<span><font color="#888888"> <br>
<span class="HOEnZb"><font
color="#888888"><span><font
color="#888888"> </font></span></font></span></font></span></div>
<span class="HOEnZb"><font
color="#888888"><span><font
color="#888888"> <span><font
color="#888888"> </font></span></font></span></font></span></blockquote>
<span class="HOEnZb"><font
color="#888888"><span><font
color="#888888"> <span><font
color="#888888"> <br>
<pre cols="72">--
Joel Sherrill, Ph.D. Director of Research & Development
<a moz-do-not-send="true" href="mailto:joel.sherrill@OARcorp.com" target="_blank">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>
</font></span></font></span></font></span></div>
<span class="HOEnZb"><font
color="#888888"><span><font
color="#888888"> </font></span></font></span></blockquote>
<span class="HOEnZb"><font color="#888888"><span><font
color="#888888"> </font></span></font></span></div>
<span class="HOEnZb"><font color="#888888"><span><font
color="#888888"> <br>
</font></span></font></span></div>
<span class="HOEnZb"><font color="#888888"><span><font
color="#888888"> </font></span></font></span></blockquote>
<span class="HOEnZb"><font color="#888888"><span><font
color="#888888"> <br>
<pre cols="72">--
Joel Sherrill, Ph.D. Director of Research & Development
<a moz-do-not-send="true" href="mailto:joel.sherrill@OARcorp.com" target="_blank">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>
</font></span></font></span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</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>