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.

-- 
           Summary: Preprocessing needed when assembling
                    gcc/config/sparc/sol2-ci.asm
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: michaelb at ieee dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sparc-rtems


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20159

Reply via email to