<div dir="ltr">I am testing cxx_throw example on Sparc SIS using rtems 4.10.99 and rtems toolchain(gcc 4.8.2).<div>Because cxx_throw example is not working, I am analyzing this problem.</div><div><br></div><div>I post backtrace information regarding this.</div>
<div>------------------------------------------------------------------------------------------------------------------------------------</div><div><div>Breakpoint 1, classify_object_over_fdes (ob=ob@entry=0x2067de8 <object.2802>, </div>
<div>    this_fde=0x2060703 <__EH_FRAME_BEGIN__+3>) at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:613</div><div>613<span class="" style="white-space:pre">    </span>  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))</div>
<div>(gdb) bt</div><div>#0  classify_object_over_fdes (ob=ob@entry=0x2067de8 <object.2802>, this_fde=0x2060703 <__EH_FRAME_BEGIN__+3>)</div><div>    at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:613</div><div>
#1  0x0203503c in init_object (ob=0x2067de8 <object.2802>) at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:750</div><div>#2  search_object (ob=ob@entry=0x2067de8 <object.2802>, pc=pc@entry=0x2033e1b <_Unwind_RaiseException+23>)</div>
<div>    at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:962</div><div>#3  0x02035760 in _Unwind_Find_FDE (pc=0x2033e1b <_Unwind_RaiseException+23>, bases=bases@entry=0x2072944)</div><div>    at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:1026</div>
<div>#4  0x0203212c in uw_frame_state_for (context=context@entry=0x2072798, fs=fs@entry=0x20723c8)</div><div>    at ../../../gcc-4.8.2/libgcc/unwind-dw2.c:1245</div><div>#5  0x02033564 in uw_init_context_1 (context=context@entry=0x2072798, outer_cfa=outer_cfa@entry=0x2072f60, outer_ra=</div>
<div>    0x2001db0 <__cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*))+80>)</div><div>    at ../../../gcc-4.8.2/libgcc/unwind-dw2.c:1566</div><div>#6  0x02033e1c in _Unwind_RaiseException (exc=0x20743c8) at ../../../gcc-4.8.2/libgcc/unwind.inc:88</div>
<div>#7  0x02001db8 in __cxxabiv1::__cxa_throw (obj=0x20743e0, tinfo=0x2060b48 <typeinfo for char const*>, dest=0x0)</div><div>    at ../../../../gcc-4.8.2/libstdc++-v3/libsupc++/eh_throw.cc:79</div><div>#8  0x020017d0 in cdtest () at init.cc:124</div>
<div>#9  0x020018c0 in Init () at init.cc:149</div><div>#10 0x02045320 in _Thread_Handler () at ../../../../../../rtems/c/src/../../cpukit/score/src/threadhandler.c:192</div><div>#11 0x02045228 in _Thread_Handler () at ../../../../../../rtems/c/src/../../cpukit/score/src/threadhandler.c:94</div>
</div><div><div>------------------------------------------------------------------------------------------------------------------------------------</div><div></div><div><br></div><div>I found the reason "memory address not aligned" error message.</div>
<div><a href="http://theofilos.cs.columbia.edu/blog/2013/09/22/base_abi/">http://theofilos.cs.columbia.edu/blog/2013/09/22/base_abi/</a></div></div><div>As I know in this URL, eh_frame section is needed for handling C++ exception.</div>
<div>But, If orignal linkcmds.base is used, eh_frame section is not generated.</div><div>In this case, _EH_FRAME_BEGIN_ is pointed to __CTORS_LIST__.</div><div><div><br></div><div>02060700 <__CTOR_LIST__>:</div><div>
 2060700:<span class="" style="white-space:pre">      </span>ff ff ff ff 02 00 18 e8 02 00 20 b8 02 00 2f 94     .......... .../.</div><div> 2060710:<span class="" style="white-space:pre">      </span>02 01 12 f4 02 02 f2 98 02 03 00 84                 ............</div>
</div><div><br></div><div>Error line is 613 of unwind-dw2-fde.c as like below;</div><div><div><br></div><div>classify_object_over_fdes (struct object *ob, const fde *this_fde)</div><div>{</div><div>  const struct dwarf_cie *last_cie = 0;</div>
<div>  size_t count = 0;</div><div>  int encoding = DW_EH_PE_absptr;</div><div>  _Unwind_Ptr base = 0;</div><div><br></div><div>  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde)) ==> Error Here !!!</div>
</div><div>  ...</div><div>}</div><div> </div><div><div>static inline const fde *</div><div>next_fde (const fde *f)</div><div>{</div><div>  return (const fde *) ((const char *) f + f->length + sizeof (f->length));</div>
<div>}</div></div><div><br></div><div>f = 0x2060700</div><div>f->length = 0xffffffff</div><div>sizeof (f->length) = 4</div><div><br></div><div>fde return 0x2060703.</div><div><br></div><div>At this time, I am tring to modify linkcmd.base for generating eh_frame section.</div>
<div><br></div><div>I modified linkcmd.base as like below;</div><div><br></div><div><div><div><div> .text :</div><div>  {</div><div>    CREATE_OBJECT_SYMBOLS</div><div>    text_start = .;</div><div>    _text_start = .;</div>
<div>    *(.text*)</div><div>    . = ALIGN (16);</div><div><br></div><div>    *(.eh_frame_hdr) ==> Added!!!</div><div>    *(.eh_frame)</div><div>    *(.gcc_except_table .gcc_except_table.*)  ==> Added!!!</div></div>
</div></div><div>   ...</div><div>}</div><div><br></div><div>After I changed this, cxx_throw executable is changed. that is, __EH_FRAME_BEGIN of eh_frame is generated.</div><div><br></div><div><div>020603f0 <__EH_FRAME_BEGIN__>:</div>
<div> 20603f0:<span class="" style="white-space:pre">   </span>ff ff 01 0e 24 18 84 01 00 60 10 00 00 8c 01 08     ....$....`......</div><div> 2060400:<span class="" style="white-space:pre">      </span>00 00 ff ff 01 0e 24 18 84 01 00 60 10 00 00 8c     ......$....`....</div>
<div> 2060410:<span class="" style="white-space:pre">   </span>01 08 00 00 ff ff 01 0e 2c 10 00 00 74 10 98 01     ........,...t...</div><div> 2060420:<span class="" style="white-space:pre">      </span>00 a0 01 08 00 00 00 00 ff 00 65 01 5b 2c 10 00     ..........e.[,..</div>
</div><div> ....</div><div><div>02061610 <__CTOR_LIST__>:</div><div> 2061610:<span class="" style="white-space:pre">  </span>ff ff ff ff 02 00 18 e8 02 00 20 b8 02 00 2f 94     .......... .../.</div><div> 2061620:<span class="" style="white-space:pre">      </span>02 01 12 f4 02 02 f2 98 02 03 00 84                 ............</div>
<div><br></div><div>0206162c <__CTOR_END__>:</div><div> 206162c:<span class="" style="white-space:pre">     </span>00 00 00 00                                         ....</div></div><div><br></div><div>But, even though __EH_FRAME_BEGIN__ is generated, unwind exception processing is not working.</div>
<div>current error log is below;</div><div><div><br></div><div>*** CONSTRUCTOR/DESTRUCTOR TEST ***</div><div>Hey I'm in base class constructor number 4 for 0x2072d00.</div><div>Hey I'm in base class constructor number 5 for 0x2072d08.</div>
<div>Hey I'm in base class constructor number 6 for 0x2072d10.</div><div>Hey I'm in base class constructor number 7 for 0x2072d18.</div><div>Hey I'm in derived class constructor number 8 for 0x2072d18.</div><div>
Testing a C++ I/O stream</div><div>before try block</div><div>Memory exception at dded7ffc (illegal address)</div><div>Unexpected trap ( 9) at address 0x02049980</div><div>data access exception at 0xDDED7FFC</div><div>IU in error mode (257)</div>
<div>   367917  020363cc  91d02000  Address 0x020363cc is out of bounds.</div></div><div><br></div><div><br></div><div>Do you have any idea for resolving this ?</div><div><br></div><div><br></div><div> </div><div><br></div>
</div>