GNU Binutils with patches for OS216
Révision | a4a1c15754d144d14dc48cd8ff62601f977e908c (tree) |
---|---|
l'heure | 2016-05-03 18:31:22 |
Auteur | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Fix PR gdb/16818, workaround Python's forcing of -export-dynamic
GDB's use of --dynamic-list to only export the proc-service symbols is
broken due to Python's "python-config --ldflags" saying we should link
with -export-dynamic, causing us to export _all_ extern symbols
anyway. On Fedora 23:
Having GDB export all its symbols leads to issues such as PR gdb/16818
(GDB crashes when using name for target remote hostname:port), where a
GDB symbol unintentionally preempts a symbol in one of the NSS modules
glibc loads into the process. NSS modules should not define symbols
outside the implementation namespace or the relevant standards, but,
alas, that's a longstanding and hard to fix issue. See libc-alpha
discussion at:
Python should instead be either using GCC's symbol visibility feature
or -Wl,--dynamic-list as well, to only export Python API symbols, but,
it doesn't. There are bugs open upstream for that:
But that's taking a long while to resolve.
I thought of working around this Python issue by making GDB build with
-fvisibility=hidden, as Jan suggests in Python issue 10112, as then
Python's "-Xlinker -export-dynamic" has no effect. However, that
would need to be done in the whole source tree (bfd, libiberty, etc.),
and I think that would break GCC plugins, as I believe those have
access to all of GCCs symbols, by "design". So we'd need a new
configure switch, or have the libraries in the tree detect which of
GCC or GDB is being built, but that doesn't work, because the answer
can be "both" with combined builds...
So this patch instead works around Python's bug, by simply sed'ing
away "-Xlinker -export-dynamic" from the result of python-config.py
--ldflags, making -Wl,--dynamic-list work again as it used to. It's
ugly, but so is the bug...
Note that if -Wl,--dynamic-list doesn't work, we always link with
-rdynamic, so static Python should still work.
Tested on F23 with --python=python (Python 2.7) and
--python=python3.4.
gdb/ChangeLog:y
2016-05-03 Pedro Alves <palves@redhat.com>
* configure.ac (PYTHON_LIBS): Sed away "-Xlinker -export-dynamic".
* configure: Regenerate.
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2016-05-03 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * configure.ac (PYTHON_LIBS): Sed away "-Xlinker -export-dynamic". | |
4 | + * configure: Regenerate. | |
5 | + | |
6 | +2016-05-03 Pedro Alves <palves@redhat.com> | |
7 | + | |
3 | 8 | * configure.ac (checking for the dynamic export flag): Add |
4 | 9 | $PYTHON_CPPFLAGS to CPPFLAGS. |
5 | 10 | * configure: Regenerate. |
@@ -9413,6 +9413,14 @@ else | ||
9413 | 9413 | CONFIG_SRCS="$CONFIG_SRCS python/python.c" |
9414 | 9414 | fi |
9415 | 9415 | |
9416 | +# Work around Python http://bugs.python.org/issue10112. See also | |
9417 | +# http://bugs.python.org/issue11410, otherwise -Wl,--dynamic-list has | |
9418 | +# no effect. Note that the only test after this that uses Python is | |
9419 | +# the -rdynamic/-Wl,--dynamic-list test, and we do want that one to be | |
9420 | +# run without -export-dynamic too. | |
9421 | +PYTHON_LIBS=`echo $PYTHON_LIBS | sed -e 's/-Xlinker -export-dynamic//'` | |
9422 | + | |
9423 | + | |
9416 | 9424 | |
9417 | 9425 | |
9418 | 9426 | if test "${have_libpython}" != no; then |
@@ -13705,6 +13713,12 @@ rm -f core conftest.err conftest.$ac_objext \ | ||
13705 | 13713 | # libpythonX.Y.a would get its symbols required for |
13706 | 13714 | # pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list. |
13707 | 13715 | # Problem does not happen for the recommended libpythonX.Y.so linkage. |
13716 | + | |
13717 | + # Note the workaround for Python | |
13718 | + # http://bugs.python.org/issue10112 earlier has removed | |
13719 | + # -export-dynamic from PYTHON_LIBS. That's exactly what we want | |
13720 | + # here too, as otherwise it'd make this -Wl,--dynamic-list test | |
13721 | + # always pass. | |
13708 | 13722 | old_CFLAGS="$CFLAGS" |
13709 | 13723 | CFLAGS="$CFLAGS $PYTHON_CFLAGS" |
13710 | 13724 | old_LIBS="$LIBS" |
@@ -1024,6 +1024,14 @@ else | ||
1024 | 1024 | CONFIG_OBS="$CONFIG_OBS python.o" |
1025 | 1025 | CONFIG_SRCS="$CONFIG_SRCS python/python.c" |
1026 | 1026 | fi |
1027 | + | |
1028 | +# Work around Python http://bugs.python.org/issue10112. See also | |
1029 | +# http://bugs.python.org/issue11410, otherwise -Wl,--dynamic-list has | |
1030 | +# no effect. Note that the only test after this that uses Python is | |
1031 | +# the -rdynamic/-Wl,--dynamic-list test, and we do want that one to be | |
1032 | +# run without -export-dynamic too. | |
1033 | +PYTHON_LIBS=`echo $PYTHON_LIBS | sed -e 's/-Xlinker -export-dynamic//'` | |
1034 | + | |
1027 | 1035 | AC_SUBST(PYTHON_CFLAGS) |
1028 | 1036 | AC_SUBST(PYTHON_CPPFLAGS) |
1029 | 1037 | AC_SUBST(PYTHON_LIBS) |
@@ -1718,6 +1726,12 @@ if test "${gdb_native}" = yes; then | ||
1718 | 1726 | # libpythonX.Y.a would get its symbols required for |
1719 | 1727 | # pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list. |
1720 | 1728 | # Problem does not happen for the recommended libpythonX.Y.so linkage. |
1729 | + | |
1730 | + # Note the workaround for Python | |
1731 | + # http://bugs.python.org/issue10112 earlier has removed | |
1732 | + # -export-dynamic from PYTHON_LIBS. That's exactly what we want | |
1733 | + # here too, as otherwise it'd make this -Wl,--dynamic-list test | |
1734 | + # always pass. | |
1721 | 1735 | old_CFLAGS="$CFLAGS" |
1722 | 1736 | CFLAGS="$CFLAGS $PYTHON_CFLAGS" |
1723 | 1737 | old_LIBS="$LIBS" |