jkmcnk / sx-gcc

The GNU Compiler Collection port to NEC SX CPU architecture.
GNU General Public License v2.0
0 stars 2 forks source link

the c++ exceptions don't work with SX yet #122

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When executing the rpogram below on a SX machine, it crashes with the
"Killed" message:

{{

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Exceptions testing.\n");

    int i=0;
    try {
        i=1;
        if (i<0)
            throw 3;
    }
    catch (int a) {
        i=a;
    }

    return 0;
}

}}

The problem is in the "throws" statemet. If it is commented out, the
program works fine. This issue was already predicted by Jaka, since he
mentioned that the c++ exceptions don't work on SX yet.

Original issue reported on code.google.com by nou...@gmail.com on 24 Apr 2009 at 5:40

GoogleCodeExporter commented 8 years ago

Original comment by jmoc...@gmail.com on 24 Apr 2009 at 6:20

GoogleCodeExporter commented 8 years ago
The termination of the program with the "Killed" message is a consequence of
incorrect section header flags for the sections that are linked into executable 
from
the "libstdc++.a" library.

If we execute the "sx8-nec-superux-objdump -h" command on the executable of the
program above, we get the following output:

************ OUTPUT BEGIN ******************
Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         000745b0  0000000400000000  0000000400000000  00000360  2**3
                  CONTENTS, ALLOC, LOAD, CODE
  1 .data         00008d80  0000000404000000  0000000404000000  00074910  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00002c10  0000000404009000  0000000404009000  00000000  2**3
                  ALLOC
  3 .comment      00008b48  0000000000000000  0000000000000000  0007d690  2**3
                  CONTENTS
  4 .bss._ZN      00000008  0000000000008b48  0000000000008b48  000861d8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  5 .bss.eme      00001008  0000000000008b50  0000000000008b50  000861e0  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  6 .rodata.      00001090  0000000000009b58  0000000000009b58  000871e8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  7 .bss.eh_      00000010  000000000000abe8  000000000000abe8  00088278  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  8 .bss._ZZ      00000008  000000000000abf8  000000000000abf8  00088288  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  9 .whoami       000011b0  000000000000ac00  000000000000ac00  00088290  2**3
                  CONTENTS, ALLOC, LOAD
************ OUTPUT END ********************

We can see that the functions ".bss._ZN", ".bss.eme", ".bss.eh_", ".bss._ZZ" and
".rodata." (those functions come from the "libstdc++.a" library) have the 
following
flags assigned: ALLOC, LOAD, DATA. The DATA flag is the reason the program 
crashes
(this is very similar to issue #111). After manually setting the flags of the
"libstdc++.a" sectons to "CONTENTS, ALLOC, LOAD", the program doesn't crash with
"Killed" message anymore (it crashes somewhere alse, but this is probably due to
unimplemented exceptions).

Original comment by nou...@gmail.com on 30 Apr 2009 at 4:06

GoogleCodeExporter commented 8 years ago
The source of the issue above was an incomplete "sxcoff.sc" linker script for 
the SX
target, which was unable to handle the sections whose names start with ".bss" 
and
".rodata". The issue above is resolved in r209 of sx-binutils.

However, there is still work to be done to make c++ exceptions work with SX.

Original comment by nou...@gmail.com on 19 May 2009 at 1:23

GoogleCodeExporter commented 8 years ago
This issue has the same cause as issue #126:

As it turns out the issue occured due to the bug in SX port of the "gas" 
assembler:
it was unable to add an offset to local symbol. With the r210 of sx-binutils, 
the
exceptions work fine.

Original comment by nou...@gmail.com on 25 May 2009 at 5:18