File libqb-fix-linker-hack.patch of Package libqb.26134
Make the workaround check compatible with more binutils versions.
A symbol is visible not only with DEFAULT vis, but also with PROTECTED
vis, which is what modern binutils have for the __start/__stop section
symbols. And which is actually the correct thing to do (otherwise
the one from the executable or a random shared lib will prevail).
libqb's check if a work-around using a linker script plays badly with
that: it forces these symbols to be always generated (even if the section
is empty), and it makes them DEFAULT vis (not PROTECTED anymore). That
exactly leads to the problem the PROTECTED vis was supposed to solve.
So we must not use the linker script hack.
But the check only checked for DEFAULT vis being acceptable. What it
_wanted_ to check is if the symbols are visible from outside the
defining component (e.g. reachable with dlsym). That include PROTECTED
vis. The linker script hack isn't needed and actively harmful, so
fix the check that would enable its use.
Index: libqb-1.0.3+20171226.6d62b64/configure.ac
===================================================================
--- libqb-1.0.3+20171226.6d62b64.orig/configure.ac
+++ libqb-1.0.3+20171226.6d62b64/configure.ac
@@ -698,7 +698,7 @@ if test "x${GCC}" = xyes; then
# all) of the original behaviour, but the workaround is still provably
# needed
if test "x${gcc_has_attribute_section}" = xyes; then
- AC_MSG_CHECKING([whether linker emits global boundary symbols for orphan sections])
+ AC_MSG_CHECKING([whether linker emits non-local boundary symbols for orphan sections])
LIBS="${LIBS} -L. -l:conftest${shrext_cmds} -Wl,-rpath=$(pwd)"
dnl could be turned to AC_TRY_RUN (first assertion is equivalent to
dnl the further check in action-if-true), but that would prevent
@@ -727,7 +727,8 @@ if test "x${GCC}" = xyes; then
| sed -n '/__start___verbose/{s/^\s*//p;q}' \
| tr -s ' ' \
| cut -d" " -f6)
- test "${verbose_start_type}" = DEFAULT \
+ ( test "${verbose_start_type}" = DEFAULT \
+ || test "${verbose_start_type}" = PROTECTED ) \
&& gcc_has_attribute_section_visible=yes \
|| gcc_has_attribute_section_visible=no; }],
[gcc_has_attribute_section_visible=no]
Index: libqb-1.0.3+20171226.6d62b64/lib/Makefile.am
===================================================================
--- libqb-1.0.3+20171226.6d62b64.orig/lib/Makefile.am
+++ libqb-1.0.3+20171226.6d62b64/lib/Makefile.am
@@ -118,8 +118,7 @@ pkgconfigexec_DATA = libqb.pc
# qblog_script.ld as a template, storing result in place of original libqb.so
# (e.g., libqb.so := "INPUT(libqb.so.0) " [...] "SECTIONS { " [...] "}")
# NOTE: readlink nor realpath are POSIX; not chained links ready
-# NOTE: conservative check, i.e., not per NEED_GCC_ATTRIBUTE_SECTION_WORKAROUND
-if HAVE_GCC_ATTRIBUTE_SECTION
+if NEED_GCC_ATTRIBUTE_SECTION_WORKAROUND
install-exec-hook: qblog_script.ld
target=$$(ls -l "$(DESTDIR)$(libdir)/libqb.so" || :); \
target=$${target#* -> }; t1_bn=$$(basename "$${target}" || :); \