summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-02-17 16:11:28 +0100
committerMark Wielaard <mark@klomp.org>2017-07-24 11:01:09 +0200
commit8abf0b5b580094af36b9dc4ed6748379caa32a0e (patch)
treebca019b54b6bd1441b2eb68acf7c50c52a4c27a9
parent1dd301b7c302b9df980946e2d04ca99748754991 (diff)
downloadelfutils-8abf0b5b580094af36b9dc4ed6748379caa32a0e.tar.gz
Unify linking of libasm, libelf, libdw, backends
Link them all with -z,defs,-z,relro,--no-undefined, provide complete dependencies for the link steps, and add libeu.a to each one. libeu.a contains useful library functionality that each of them might use. The linker will strip unneeded symbols, so linking it in won't hurt even if none of the functions are used. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--backends/ChangeLog6
-rw-r--r--backends/Makefile.am7
-rw-r--r--libasm/ChangeLog11
-rw-r--r--libasm/Makefile.am14
-rw-r--r--libdw/ChangeLog9
-rw-r--r--libdw/Makefile.am15
-rw-r--r--libelf/ChangeLog8
-rw-r--r--libelf/Makefile.am14
8 files changed, 64 insertions, 20 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index d6282451..784e6b03 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-17 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Add libeu.
+ (libebl_%so): Link with --no-undefined,-z,defs,-z,relro
+ and libeu.a.
+
2017-06-17 Mark Wielaard <mark@klomp.org>
* s390_initreg.c: Swap sys/ptrace.h and asm/ptrace.h include order.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index ac45a452..996602f2 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -45,6 +45,7 @@ noinst_DATA = $(libebl_pic:_pic.a=.so)
libelf = ../libelf/libelf.so
libdw = ../libdw/libdw.so
+libeu = ../lib/libeu.a
i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c \
@@ -129,14 +130,14 @@ libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
-libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
+libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libeu)
@rm -f $(@:.so=.map)
$(AM_V_at)echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
> $(@:.so=.map)
$(AM_V_CCLD)$(LINK) -shared -o $(@:.map=.so) \
-Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
- -Wl,--version-script,$(@:.so=.map) \
- -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw)
+ -Wl,--version-script,$(@:.so=.map),--no-undefined \
+ -Wl,-z,defs,-z,relro -Wl,--as-needed $(libelf) $(libdw) $(libeu)
@$(textrel_check)
libebl_i386.so: $(cpu_i386)
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index d2bc4086..262d2a92 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,14 @@
+2017-02-17 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Add libasm_so_DEPS to specify external libraries
+ that have to be linked in, and libasm_so_LIBS to specify the
+ archives libasm consists of. The dependencies include libeu.a.
+ (libasm_so_LDLIBS): Add $(libasm_so_DEPS).
+ (libasm_so$(EXEEXT): Use $(libasm_so_LIBS),
+ add --no-undefined,-z,defs,-z,relro,
+ drop the manual enumeration of dependencies,
+ specify the correct path for libasm.map.
+
2017-04-27 Ulf Hermann <ulf.hermann@qt.io>
* asm_end.c (binary_end): Fix nesting of braces.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 8094b05c..9effa6c5 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -55,17 +55,19 @@ libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
libasm_pic_a_SOURCES =
am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os)
-libasm_so_LDLIBS =
+libasm_so_DEPS = ../lib/libeu.a ../libebl/libebl.a ../libelf/libelf.so ../libdw/libdw.so
+libasm_so_LDLIBS = $(libasm_so_DEPS)
if USE_LOCKS
libasm_so_LDLIBS += -lpthread
endif
+libasm_so_LIBS = libasm_pic.a
libasm_so_SOURCES =
-libasm.so$(EXEEXT): libasm_pic.a libasm.map
- $(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
- -Wl,--soname,$@.$(VERSION) \
- ../libebl/libebl.a ../libelf/libelf.so ../libdw/libdw.so \
+libasm.so$(EXEEXT): $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS)
+ $(AM_V_CCLD)$(LINK) -shared -o $@ \
+ -Wl,--soname,$@.$(VERSION),-z,defs,-z,relro \
+ -Wl,--version-script,$<,--no-undefined \
+ -Wl,--whole-archive $(libasm_so_LIBS) -Wl,--no-whole-archive \
$(libasm_so_LDLIBS)
@$(textrel_check)
$(AM_V_at)ln -fs $@ $@.$(VERSION)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 1e282e4e..8eda70cd 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,12 @@
+2017-02-17 Ulf Hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Add libdw_so_LIBS to specify the archives libdw is is
+ made of, libdw_so_DEPS for libraries it depends on (including
+ libeu.a), libdw_so_LDLIBS to specify libraries libdw links against.
+ (libdw.so$(EXEEXT)): Add $(libdw_so_LDLIBS), remove enumeration of
+ library dependencies, use libdw_so_LIBS rather than relying on the
+ order of dependencies specified, add -z,relro.
+
2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
* libdw.h: Remove attribute macro declarations and use
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 082d96c7..634ac2ec 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -102,17 +102,20 @@ endif
libdw_pic_a_SOURCES =
am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
+libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
+ ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
+libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
+libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
libdw_so_SOURCES =
-libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
- ../libdwfl/libdwfl_pic.a ../libebl/libebl.a \
- ../libelf/libelf.so
+libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
# The rpath is necessary for libebl because its $ORIGIN use will
# not fly in a setuid executable that links in libdw.
- $(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--soname,$@.$(VERSION),-z,defs \
+ $(AM_V_CCLD)$(LINK) -shared -o $@ \
+ -Wl,--soname,$@.$(VERSION),-z,defs,-z,relro \
-Wl,--enable-new-dtags,-rpath,$(pkglibdir) \
-Wl,--version-script,$<,--no-undefined \
- -Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
- -ldl -lz $(argp_LDADD) $(zip_LIBS)
+ -Wl,--whole-archive $(libdw_so_LIBS) -Wl,--no-whole-archive \
+ $(libdw_so_LDLIBS)
@$(textrel_check)
$(AM_V_at)ln -fs $@ $@.$(VERSION)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 594bec99..214a4f7e 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,11 @@
+2017-02-17 Ulf hermann <ulf.hermann@qt.io>
+
+ * Makefile.am: Add libelf_so_DEPS, which include libeu.a,
+ libelf_so_LIBS.
+ (libelf_so_LDLIBS): Add $(libelf_so_DEPS).
+ (libelf.so$(EXEEXT): Use $(libelf_so_LIBS), require libelf.map
+ from the right directory.
+
2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
* libelfP.h: Don't include config.h.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 167a8322..88c1edd7 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -95,16 +95,20 @@ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
libelf_pic_a_SOURCES =
am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
-libelf_so_LDLIBS = -lz
+libelf_so_DEPS = ../lib/libeu.a
+libelf_so_LDLIBS = $(libelf_so_DEPS) -lz
if USE_LOCKS
libelf_so_LDLIBS += -lpthread
endif
+libelf_so_LIBS = libelf_pic.a
libelf_so_SOURCES =
-libelf.so$(EXEEXT): libelf_pic.a libelf.map
- $(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
- -Wl,--soname,$@.$(VERSION),-z,defs,-z,relro $(libelf_so_LDLIBS)
+libelf.so$(EXEEXT): $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS)
+ $(AM_V_CCLD)$(LINK) -shared -o $@ \
+ -Wl,--soname,$@.$(VERSION),-z,defs,-z,relro \
+ -Wl,--version-script,$<,--no-undefined \
+ -Wl,--whole-archive $(libelf_so_LIBS) -Wl,--no-whole-archive \
+ $(libelf_so_LDLIBS)
@$(textrel_check)
$(AM_V_at)ln -fs $@ $@.$(VERSION)