Skip to contentSkip to conversation

tools: link executables with libtinfo explicitly

PATCH Applied Daniel Kiper 3 participants 4 messages Jun 2, 2015 – Jun 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools: link executables with libtinfo explicitly

binutils 2.22 changed ld default from --copy-dt-needed-entries to -no-copy-dt-needed-entries. This revealed that some objects are linked implicitly with libtinfo and newer ld fails to build relevant executables.

Below is short explanation why we should not do that...

http://fedoraproject.org/wiki/UnderstandingDSOLinkChange says:

The default behaviour for ld (my note: before version 2.22) allows users to 'indirectly' link to required objects/libraries through intermediate objects/libraries. While this is convenient, it can also be dangerous because it makes your program's dependencies tied to the dependencies of other objects. If those objects ever change their linkages, they can break your program without any changes to your own code!

Please run autoconf in tools directory.

---
v2 - suggestions/fixes:
- do not include tools/configure changes in this patch (suggested by Wei Liu).

---
 config/Tools.mk.in            |    1 +
 tools/configure.ac            |    4 ++++
 tools/misc/Makefile           |    2 +-
 tools/xenstat/xentop/Makefile |    2 +-
 4 files changed, 7 insertions(+), 2 deletions(-)
config/Tools.mk.in +1 -0
index d67352e..aef9ed6 100644
@@ -77,5 +77,6 @@ CONFIG_LIBICONV     := @libiconv@
 CONFIG_GCRYPT       := @libgcrypt@
 EXTFS_LIBS          := @EXTFS_LIBS@
 CURSES_LIBS         := @CURSES_LIBS@
+TINFO_LIBS          := @TINFO_LIBS@
 
 FILE_OFFSET_BITS    := @FILE_OFFSET_BITS@
tools/configure.ac +4 -0
index 9bf6450..1a06ddf 100644
@@ -318,6 +318,10 @@ i[[3456]]86|x86_64)
 esac
  AX_CHECK_UUID
  AX_CHECK_CURSES
+AS_IF([test "$ncurses" = "y"], [
+AC_CHECK_LIB([tinfo], [define_key], [TINFO_LIBS=-ltinfo])
+])
+AC_SUBST(TINFO_LIBS)
 
 dnl The following are only required when upstream QEMU is built
 AS_IF([test "x$qemu_xen" = "xy"], [
tools/misc/Makefile +1 -1
index 3817317..82c361f 100644
@@ -100,7 +100,7 @@ xen-lowmemd: xen-lowmemd.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
 
 gtraceview: gtraceview.o
-	$(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(TINFO_LIBS) $(APPEND_LDFLAGS)
 
 xencov: xencov.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
tools/xenstat/xentop/Makefile +1 -1
index 2652c9d..97950b9 100644
@@ -19,7 +19,7 @@ all install xentop:
 else
 
 CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
-LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS) -lm -lyajl
+LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(TINFO_LIBS) $(SOCKET_LIBS) -lm -lyajl
 CFLAGS += -DHOST_$(XEN_OS)
 
 # Include configure output (config.h) to headers search path
Signature · 1 line
1.7.10.4
Acked-by on v2 1/1
#1 lore raw
Quoted 17 lines · Daniel Kiper

binutils 2.22 changed ld default from --copy-dt-needed-entries to -no-copy-dt-needed-entries. This revealed that some objects are linked implicitly with libtinfo and newer ld fails to build relevant executables.

Below is short explanation why we should not do that...

http://fedoraproject.org/wiki/UnderstandingDSOLinkChange says:

The default behaviour for ld (my note: before version 2.22) allows users to 'indirectly' link to required objects/libraries through intermediate objects/libraries. While this is convenient, it can also be dangerous because it makes your program's dependencies tied to the dependencies of other objects. If those objects ever change their linkages, they can break your program without any changes to your own code!

Quoted 3 lines

Please run autoconf in tools directory.

Applied
#2 lore raw
Quoted 5 lines · Wei Liu
Quoted 4 lines · Daniel Kiper

binutils 2.22 changed ld default from --copy-dt-needed-entries to -no-copy-dt-needed-entries. This revealed that some objects are linked implicitly with libtinfo and newer ld fails to build relevant executables.

For future reference "relevant executables" would be better as a list of the actual affected programs...

Quoted 13 lines
Quoted 13 lines

Below is short explanation why we should not do that...

http://fedoraproject.org/wiki/UnderstandingDSOLinkChange says:

The default behaviour for ld (my note: before version 2.22) allows users to 'indirectly' link to required objects/libraries through intermediate objects/libraries. While this is convenient, it can also be dangerous because it makes your program's dependencies tied to the dependencies of other objects. If those objects ever change their linkages, they can break your program without any changes to your own code!

Quoted 5 lines
Quoted 3 lines

Please run autoconf in tools directory.

Applied, running autoconf.

Ian.

#3 lore raw
Quoted 9 lines · Ian Campbell
Quoted 5 lines · Wei Liu
Quoted 4 lines · Daniel Kiper

binutils 2.22 changed ld default from --copy-dt-needed-entries to -no-copy-dt-needed-entries. This revealed that some objects are linked implicitly with libtinfo and newer ld fails to build relevant executables.

For future reference "relevant executables" would be better as a list of the actual affected programs...

Wilco.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Below is short explanation why we should not do that...

http://fedoraproject.org/wiki/UnderstandingDSOLinkChange says:

The default behaviour for ld (my note: before version 2.22) allows users to 'indirectly' link to required objects/libraries through intermediate objects/libraries. While this is convenient, it can also be dangerous because it makes your program's dependencies tied to the dependencies of other objects. If those objects ever change their linkages, they can break your program without any changes to your own code!

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Please run autoconf in tools directory.

Applied, running autoconf.

Thanks!

Daniel