summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-06-11 15:13:35 +0100
committerNick Alcock <nick.alcock@oracle.com>2021-06-12 14:10:09 +0100
commitc1bb2d687962e0d64cfb7203af41599ccf95a012 (patch)
treeebd74db767c0a7fba39d6d65b50267739f523e5f
parentdd1396b5f08925ff2d26fec8f8431683da6e1da0 (diff)
downloadbinutils-gdb-users/nalcock/libctf-install-relink.tar.gz
libctf: link against libiberty before linking in libbfd or libctf-nobfdusers/nalcock/libctf-install-relink
This ensures that the CTF_LIBADD, which always contains at least this when doing a shared link: -L`pwd`/../libiberty/pic -liberty appears in the link line before any requirements pulled in by libbfd.la, which include -liberty but because it is install-time do not include the -L`pwd`/../libiberty/pic portion (in an indirect dep like this, the path comes from the libbfd.la file, and is an install path). libiberty also appears after libbfd in the link line by virtue of libctf-nobfd.la, because libctf-nobfd has to follow libbfd in the link line, and that needs symbols from libiberty too. Without this, an installed liberty might well be pulled in by libbfd, and if --enable-install-libiberty is not specified this libiberty might be completely incompatible with what is being installed and break either or boht of libbfd and libctf. (The specific problem observed here is that bsearch_r was not present, but other problems might easily be observed in future too.) Because ld links against libctf, this has a tendency to break the system linker at install time too, if installing with --prefix=/usr. That's quite unpleasant to recover from. libctf/ChangeLog 2021-06-12 Nick Alcock <nick.alcock@oracle.com> PR libctf/27360 * Makefile.am (libctf_la_LIBADD): Link against libiberty before pulling in libbfd.la or pulling in libctf-nobfd.la. * Makefile.in: Regenerate.
-rw-r--r--libctf/ChangeLog7
-rw-r--r--libctf/Makefile.am6
-rw-r--r--libctf/Makefile.in7
3 files changed, 18 insertions, 2 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 3df935a6d6a..acc4658a666 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-12 Nick Alcock <nick.alcock@oracle.com>
+
+ PR libctf/27360
+ * Makefile.am (libctf_la_LIBADD): Link against libiberty
+ before pulling in libbfd.la or pulling in libctf-nobfd.la.
+ * Makefile.in: Regenerate.
+
2021-01-24 Nick Clifton <nickc@redhat.com>
This is the 2.36 release.
diff --git a/libctf/Makefile.am b/libctf/Makefile.am
index f45433483c0..44a3cf742bc 100644
--- a/libctf/Makefile.am
+++ b/libctf/Makefile.am
@@ -52,7 +52,11 @@ if NEED_CTF_QSORT_R
libctf_nobfd_la_SOURCES += ctf-qsort_r.c
endif
-libctf_la_LIBADD = ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
+# @CTF_LIBADD@ appears here twice: once, to force libiberty to get searched before
+# install-time libbfd adds a -L to the install dir (possibly pointing at an
+# incompatible libiberty), and once via lictf_nobfd_la_LIBADD so that the
+# references in there get picked up.
+libctf_la_LIBADD = @CTF_LIBADD@ ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
diff --git a/libctf/Makefile.in b/libctf/Makefile.in
index d31d017c1f5..38c83899a15 100644
--- a/libctf/Makefile.in
+++ b/libctf/Makefile.in
@@ -464,7 +464,12 @@ libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c \
ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-dedup.c \
ctf-link.c ctf-lookup.c ctf-open.c ctf-sha1.c ctf-string.c \
ctf-subr.c ctf-types.c ctf-util.c $(am__append_1)
-libctf_la_LIBADD = ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
+
+# @CTF_LIBADD@ appears here twice: once, to force libiberty to get searched before
+# install-time libbfd adds a -L to the install dir (possibly pointing at an
+# incompatible libiberty), and once via lictf_nobfd_la_LIBADD so that the
+# references in there get picked up.
+libctf_la_LIBADD = @CTF_LIBADD@ ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c