This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
RE: Remaining Itanium exception, static linking patches
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- To: "'Andrew Haley'" <aph at cambridge dot redhat dot com>, "Boehm, Hans" <hans_boehm at hp dot com>
- Cc: "'java-patches at gcc dot gnu dot org'" <java-patches at gcc dot gnu dot org>, "'tromey at redhat dot com'" <tromey at redhat dot com>, "MOSBERGER, DAVID (HP-PaloAlto,unix3)" <davidm at hpl dot hp dot com>
- Date: Thu, 14 Mar 2002 17:28:06 -0800
- Subject: RE: Remaining Itanium exception, static linking patches
> -----Original Message-----
> From: Andrew Haley [mailto:aph@cambridge.redhat.com]
> Boehm, Hans writes:
> > What, if anything, breaks if you don't apply that part of
> the patch and use
> > syscall(SYS_sigaction, ...)? I haven't tried it, but if
> it works elsewhere,
> > it should probably work on IA64.
>
> It should work; I haven't tried.
>
> > Remind me why we can't unwind through the glibc signal
> handler wrapper?
>
> Actually, it probably isn't a problem on IA-64, but on most of our
> targets glibc isn't built with unwind info. I've discussed this with
> Uli -- it is a known problem.
>
I tried it. It doesn't work. The superficial reason is that SYS_sigaction
doesn't exist. There's only SYS_rt_sigaction. The more serious issue is
that this code is broken to start with; the kernel sigaction structure
doesn't necessarily have the same layout as the user one. The X86 and IA64
implementations of sigaction in glibc perform a translation. This is being
bypassed if you go directly to the kernel. See
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/i3
86/sigaction.c?rev=1.30&content-type=text/x-cvsweb-markup&cvsroot=glibc .
AFAICT, it's purely concidental that this appears to do something reasonable
as it is.
It sounds to me like the only plausible solution here is to check in the
original patch which relies on __libc_sigaction. It's far less broken than
what's there now. Clearly at least parts of glibc need unwind information
on all platforms, at which point this can be done correctly.
OK to commit? Andrew - do you want to check it in? Or I can, and list you
as the author:
* include/dwarf2-signal.h (MAKE_THROW_FRAME): Define for IA64.
(INIT_SEGV): Use __libc_sigaction instead of syscall.
Index: libjava/include/dwarf2-signal.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/dwarf2-signal.h,v
retrieving revision 1.3
diff -u -r1.3 dwarf2-signal.h
--- dwarf2-signal.h 2001/05/29 17:50:50 1.3
+++ dwarf2-signal.h 2002/03/14 16:44:18
@@ -41,7 +41,22 @@
_sc->sc_pc += 4; \
} \
while (0)
+
+#elif defined(__ia64__)
+
+#define MAKE_THROW_FRAME(_exception) \
+do \
+{ \
+ /* IA-64 either leaves PC pointing at a faulting instruction or the \
+ following instruction, depending on the signal. SEGV always does \
+ the former, so we adjust the saved PC to point to the following \
+ instruction; this is what the handler in libgcc expects. */
\
+ struct sigcontext *_sc = (struct sigcontext *)_p; \
+ _sc->sc_ip++; /* fprintf (stderr, "%p si:%p sc:%p\n",
_sc->sc_ip, si, _p); */ \
+} \
+while (0)
#else
+#error
#define MAKE_THROW_FRAME(_exception) \
do \
{ \
@@ -50,6 +65,10 @@
while (0)
#endif
+extern "C" int __libc_sigaction (int __sig,
+ __const struct sigaction *__restrict __act,
+ struct sigaction *__restrict __oact) throw ();
+
#define INIT_SEGV \
do \
{ \
@@ -58,7 +77,7 @@
act.sa_sigaction = _Jv_catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = SA_SIGINFO; \
- syscall (SYS_sigaction, SIGSEGV, &act, NULL); \
+ __libc_sigaction (SIGSEGV, &act, NULL); \
} \
while (0)
@@ -71,7 +90,7 @@
act.sa_sigaction = _Jv_catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = SA_SIGINFO; \
- syscall (SYS_sigaction, SIGFPE, &act, NULL); \
+ __libc_sigaction (SIGFPE, &act, NULL); \
} \
while (0)