I establish a new GNU Enviroment.
Enviroment version:
binutils-2.16
gcc-4.1.1
newlib-1.14.0
Enviroment variables are:
export TARGET=sh-elf
export HOST=i686-pc-cygwin
export BUILD=i686-pc-cygwin
export PREFIX=/usr/local/sh-elf
export CFLAGS="-O2"
export CXXFLAGS="-O2"
export CFLAGS_FOR_TARGET="-Os"
export CXXFLAGS_FOR_TARGET="Os"
Build binutils:
../binutils-2.16.92/configure --target=$TARGET --host=$HOST --build=$BUILD
--prefix=$PREFIX 2>&1 | tee config.out
make 2>&1 | tee makeall.out
make install 2>&1 | tee makeinstall.out
Build gcc:
##################before build "newlib"##############################
../gcc-4.1.1/configure --target=$TARGET --host=$HOST --build=$BUILD
--prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --enable-threads
--enable-languages=c,c++ --enable-version-specific-runtime-libs
--enable-sjlj-exceptions 2>&1 | tee config.out
make all-gcc 2>&1 | tee makeallgcc.out
make install-gcc 2>&1 | tee makeinstallgcc.out
##################after build "newlib"##############################
make all 2>&1 | tee makeall.out
make install 2>&1 | tee makeinstall.out
Build newlib:
../newlib-1.14.0/configure --target=$TARGET --host=$HOST --build=$BUILD
--prefix=$PREFIX 2>&1 | tee config.out
make 2>&1 | tee makenewlib.out
make install 2>&1 | tee makeinstallnewlib.out
My test function is(in a .cpp file) :(based on sh7710/T-Engine )
extern "C"
{
class A
{
public:
private:
char string[SIZE];
};
void test1(void)
{
A obj;
try
{
throw obj;
}
catch (A &e)
{
printf(" exception ! \n ");
}
}
}//extern "C"
Build cpp file:
sh-elf-gcc -m3 -mb -O2 -Wall -Wno-format -c test.cpp -o test.o
When I debug the program on the ICE.
"__cxa_allocate_exception" allocates memory for exception successfully,then
"__cxa_throw" is called ,and calls "__Unwind_SjLj_RaiseException" to raise
an exception.In the end,"longjmp" to catch block.
In the catch block,when SIZE < 68,jump to "___cxa_begin_catch",and the
program ended regularly;Hoever,when SIZE >68,jump to "___cxa_end_catch",and
the program crashed.
By the ICE,I found, when SIZE > 68,the stack pointer backup register is
assigned an illegal address,and when the system tried to restore the
stack,getting the stack pointer from this register,It will never fetch its
data from the wrong address correctly.
I have spent about one month on trying to solve the problem,but I'm new for
gcc and don't understand its structure.I'm afraid it's too difficult for me
to solve it.
I'm eagerly excepting your help.
Any suggestions?
thank you.
--David
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn