public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Real fix for AIX exception handling
@ 2017-03-27 10:49 Michael Haubenwallner
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Haubenwallner @ 2017-03-27 10:49 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

Hi,

as far as I have discovered, the real problem with AIX exception handling is
that the exception landing pads are symbols that must not (but still are)
exported from shared libraries - even libstdc++.

I'm wondering if attached libtool(!)-patch would fix even that GDB problem
once applied to each(!) shared library creation procedure.

However, each workaround still applies as long as there's a single shared
library involved that has not stopped exporting these symbols yet.

Thoughts?

Maybe gcc's collect2 should apply this additional symbol filter itself when
calling (AIX) ld, rather than leaving this to each build system?

Thanks!
/haubi/

[-- Attachment #2: 0001-AIX-Stop-exporting-more-_GLOBAL__-symbols.patch --]
[-- Type: text/x-patch, Size: 2017 bytes --]

From 32ca0e6f7bf8d096cc653ac455d66c270b75fdf0 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Wed, 2 Mar 2016 15:06:48 +0100
Subject: [PATCH 1/4] AIX: Stop exporting more _GLOBAL__ symbols.

* m4/libtool.m4 (_LT_LINKER_SHLIBS): On AIX, GNU g++ generates
_GLOBAL__ symbols as, amongst others, landing pads for C++ exceptions.
These symbols must not be exported from shared libraries, or exception
handling may break for applications with runtime linking enabled.
---
 m4/libtool.m4 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index ee292af..c2e996c 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -4943,6 +4943,7 @@ m4_if([$1], [CXX], [
     else
       _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
+    _LT_TAGVAR(exclude_expsyms, $1)='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*|_GLOBAL__[FID]_.*'
     ;;
   pw32*)
     _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
@@ -5398,6 +5399,7 @@ _LT_EOF
 	else
 	  _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
+	_LT_TAGVAR(exclude_expsyms, $1)='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*|_GLOBAL__[FID]_.*'
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
-- 
2.10.2


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [PATCH] Real fix for AIX exception handling
@ 2017-03-27 15:44 David Edelsohn
  2017-03-29 20:21 ` Jeff Law
  0 siblings, 1 reply; 12+ messages in thread
From: David Edelsohn @ 2017-03-27 15:44 UTC (permalink / raw)
  To: Michael Haubenwallner; +Cc: GCC Patches

> As far as I have discovered, the real problem with AIX exception handling is
> that the exception landing pads are symbols that must not (but still are)
> exported from shared libraries - even libstdc++.
>
> I'm wondering if attached libtool(!)-patch would fix even that GDB problem
> once applied to each(!) shared library creation procedure.
>
> However, each workaround still applies as long as there's a single shared
> library involved that has not stopped exporting these symbols yet.
>
> Thoughts?
>
> Maybe gcc's collect2 should apply this additional symbol filter itself when
> calling (AIX) ld, rather than leaving this to each build system?
>
> * m4/libtool.m4 (_LT_LINKER_SHLIBS): On AIX, GNU g++ generates
> _GLOBAL__ symbols as, amongst others, landing pads for C++ exceptions.
> These symbols must not be exported from shared libraries, or exception
> handling may break for applications with runtime linking enabled.

Hi, Michael

Thanks for the analysis.

The problem with EH for GDB involves static linking, not runtime
linking. And there seems to be different behavior for GCC 4.8 and GCC
4.9.

The patch seems correct for the runtime linking case, but I don't
believe that it solves all of the EH issues -- at least more
explanation is needed.

I think that the problem for static linking needs to be addressed by collect2.

Thanks, David

P.S. Please explicitly copy me on AIX patches.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-03-31 14:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 10:49 [PATCH] Real fix for AIX exception handling Michael Haubenwallner
2017-03-27 15:44 David Edelsohn
2017-03-29 20:21 ` Jeff Law
2017-03-29 20:24   ` David Edelsohn
2017-03-29 20:49     ` Jeff Law
2017-03-29 21:11       ` David Edelsohn
2017-03-29 21:23         ` Jeff Law
2017-03-29 21:27           ` David Edelsohn
2017-03-29 22:29             ` Jeff Law
2017-03-30 10:37     ` Michael Haubenwallner
2017-03-30 13:10       ` David Edelsohn
2017-03-31 15:05       ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).