[PATCH, ARM, Ada] __ARM_EABI_UNWINDER__ vs _URC_FATAL_PHASE1_ERROR in gcc/ada/raise-gcc.c

Laurent GUERBY laurent@guerby.net
Sun Dec 28 18:00:00 GMT 2008


I'm trying to port Ada to arm now that we have an arm machine in the
compile farm. When enabling ZCX exceptions in the Ada RTS for this
target my first cross c,ada trunk cross compiler fails to build with:

/opt/crosstool/build3/./gcc/xgcc -B/opt/crosstool/build3/./gcc/
-isystem /opt/crosstool/release3/arm-unknown-linux-gnueabi/include
-isystem /opt/crosstool/release3/arm-unknown-linux-gnueabi/sys-include
-Wno-missing-prototypes -fexceptions -DIN_RTS |sed -e 's/-pedantic//g'
-e 's/-Wtraditional//g'`   -I. -I.. -I../..
-I/home/guerby/work/gcc/version-head/gcc/ada/.. -I./../.. raise-gcc.c \
	  -o raise-gcc.o
raise-gcc.c: In function '__gnat_eh_personality':
raise-gcc.c:1092: error: '_URC_FATAL_PHASE1_ERROR' undeclared (first use
in this function)
raise-gcc.c:1092: error: (Each undeclared identifier is reported only
raise-gcc.c:1092: error: for each function it appears in.)
make[4]: *** [raise-gcc.o] Error 1
make[4]: Leaving directory `/opt/crosstool/build3/gcc/ada/rts'
make[3]: *** [gnatlib] Error 2
make[3]: Leaving directory `/opt/crosstool/build3/gcc/ada'
make[2]: *** [gnatlib-plain] Error 2
make[2]: Leaving directory
make[1]: *** [all-target-libada] Error 2
make[1]: Leaving directory `/opt/crosstool/build3'
make: *** [all] Error 2

After looking around it looks like arm is the only target
redefining the _Unwind_Reason_Code enum (in gcc/config/arm/unwind-arm.h)
and it does not have _URC_FATAL_PHASE1_ERROR. gcc/unwind-c.c has #ifdef
and doing something else entirely.

The patches below allow the cross compiler to be built successfully
and cross compile a working hello world in Ada but it's not
enough to get exception working.

With patchv1 When an exception is raised I get a SIGSEGV:

(gdb) bt
#0  0x0001f344 in _Unwind_VRS_Get (context=<value optimized out>,
regclass=_UVRSC_CORE, regno=<value optimized out>, representation=<value
optimized out>, valuep=0xbefff3dc)
at /home/guerby/work/gcc/version-head/libgcc/../gcc/config/arm/unwind-arm.c:245
#1  0x00020408 in _Unwind_GetLanguageSpecificData (context=0x2f)
at /opt/crosstool/build3/./gcc/include/unwind.h:252
#2  0x0001e6a8 in __gnat_eh_personality (version_arg=<value optimized
out>, phases_arg=213008, uw_exception_class=<value optimized out>,
uw_exception=<value optimized out>, uw_context=0xffffffff)
    at raise-gcc.c:551
#3  0x0001fdac in __gnu_Unwind_RaiseException (ucbp=0x34010,
at /home/guerby/work/gcc/version-head/libgcc/../gcc/config/arm/unwind-arm.c:834
#4  0x0002033c in ___Unwind_RaiseException ()
at /home/guerby/work/gcc/version-head/libgcc/../gcc/config/arm/libunwind.S:339
#5  0x0000ade8 in
ada.exceptions.exception_propagation.propagate_exception (e=<value
optimized out>, from_signal_handler=<value optimized out>) at
#6  0x0000ba18 in <__gnat_raise_nodefer_with_msg> (e=Cannot access
memory at address 0xfffffff4
) at a-except.adb:829
#7  0x0000bd34 in ada.exceptions.raise_with_location_and_msg (e=0x2eb6c,
f=<value optimized out>, l=<value optimized out>, m=<value optimized
out>) at a-except.adb:993
#8  0x0000bccc in <__gnat_raise_program_error_msg> (file=48332, line=0,
msg=0) at a-except.adb:949
#9  0x0000bed8 in <__gnat_rcheck_19> (file=213008, line=0) at
#10 0x00009c94 in _ada_helloe ()

With patchv2 any exception raised reaches directly
the toplevel exception handler, that is there is no

Any help welcomed about what should be done here.

Thanks in advance,


2008-12-28  Laurent Guerby  <laurent@guerby.net>

	* raise-gcc.c (PERSONALITY_FUNCTION): Handle ARM.

=> patchv1
Index: gcc/ada/raise-gcc.c
--- gcc/ada/raise-gcc.c	(revision 142939)
+++ gcc/ada/raise-gcc.c	(working copy)
@@ -1089,7 +1089,9 @@
 	return __gnat_handle_vms_condition (version_arg, phases_arg);
+      #ifndef __ARM_EABI_UNWINDER__
       return _URC_FATAL_PHASE1_ERROR;
+      #endif
   db_indent (DB_INDENT_RESET);

=> patchv2
Index: gcc/ada/raise-gcc.c
--- gcc/ada/raise-gcc.c	(revision 142939)
+++ gcc/ada/raise-gcc.c	(working copy)
@@ -1089,7 +1089,11 @@
 	return __gnat_handle_vms_condition (version_arg, phases_arg);
+      #ifdef __ARM_EABI_UNWINDER__
+      return _URC_FAILURE;
+      #else
       return _URC_FATAL_PHASE1_ERROR;
+      #endif
   db_indent (DB_INDENT_RESET);

More information about the Gcc-patches mailing list