The file sol2-ci.asm is assembled to yield crti.o for the sparc-rtems target. However sol2-ci.asm contains C preprocessor conditionals to select an appropriate stack frame size depending on whether or not we're building for the SPARC V9 architecture, but the language is specified as "-x assembler" rather than "-x assembler-with-cpp" when assembling. As a result the preprocessor directives (apparently) get treated as comments, and both the V9 and the non-V9 code goes into crti.o. The net effect of this is that the _init() and _fini() functions in crti.o each start with two SAVE instructions instead of one, as in the following fragment of disassembly... 02015f58 <_init>: 2015f58: 9d e3 bf 50 save %sp, -176, %sp 2015f5c: 9d e3 bf a0 save %sp, -96, %sp 2015f60: 7f ff ac 88 call 2001180 <frame_dummy> 2015f64: 01 00 00 00 nop 2015f68: 7f ff fb 11 call 2014bac <__do_global_ctors_aux> 2015f6c: 01 00 00 00 nop 2015f70: 81 c7 e0 08 ret 2015f74: 81 e8 00 00 restore 02015f78 <_fini>: 2015f78: 9d e3 bf 50 save %sp, -176, %sp 2015f7c: 9d e3 bf a0 save %sp, -96, %sp 2015f80: 7f ff ac 5c call 20010f0 <__do_global_dtors_aux> 2015f84: 01 00 00 00 nop 2015f88: 81 c7 e0 08 ret 2015f8c: 81 e8 00 00 restore Things get very confused after leaving _fini() due to the mismatch between the number of windows SAVEd versus the number RESTOREd -- the second window does not contain a valid return address (that's in the first window) so we end up jumping to wherever %i7 happens to be pointing. After checking in CVS, it would seem that this problem exists at the HEAD.
Created attachment 8260 [details] Suggested patch to fix bug. Here is a patch which does the trick...
Confirmed, a regression introduced with: Wed Sep 9 01:32:01 1998 David S. Miller <davem@pierdol.cobaltmicro.com> Add preliminary native sparcv9 Solaris support. * configure.in: Recognize sparv9-*-solaris2* * configure: Rebuilt. * config.sub: Recognize sparcv9 just like sparc64. * config/sparc/sol2-c1.asm config/sparc/sol2-ci.asm config/sparc/sol2-cn.asm: Macroize so it can be shared between 32-bit and 64-bit Solaris systems. * config/sparc/t-sol2: Assemble those with cpp. * config/sparc/sparc.h (TARGET_CPU_sparcv9): New alias for v9. (*TF*_LIBCALL): If ARCH64 use V9 names. * config/sparc/{xm-sysv4-64,sol2-sld-64}.h: New files.
Taking care of the patch.
Subject: Bug 20159 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2005-02-23 11:53:55 Modified files: gcc : ChangeLog gcc/config/sparc: t-elf Log message: PR target/20159 * config/sparc/t-elf (startup files): Assemble with CPP. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7568&r2=2.7569 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sparc/t-elf.diff?cvsroot=gcc&r1=1.6&r2=1.7
Subject: Bug 20159 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: ebotcazou@gcc.gnu.org 2005-02-23 11:55:03 Modified files: gcc : ChangeLog gcc/config/sparc: t-elf Log message: PR target/20159 * config/sparc/t-elf (startup files): Assemble with CPP. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.803&r2=2.2326.2.804 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sparc/t-elf.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.6&r2=1.6.54.1
Subject: Bug 20159 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: ebotcazou@gcc.gnu.org 2005-02-23 11:57:07 Modified files: gcc : ChangeLog gcc/config/sparc: t-elf Log message: PR target/20159 * config/sparc/t-elf (startup files): Assemble with CPP. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1060&r2=1.16114.2.1061 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sparc/t-elf.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.6&r2=1.6.20.1
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01405.html Thanks for the bug report and the fix!