]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Unify linking of libasm, libelf, libdw, backends
authorUlf Hermann <ulf.hermann@qt.io>
Fri, 17 Feb 2017 15:11:28 +0000 (16:11 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 24 Jul 2017 09:01:09 +0000 (11:01 +0200)
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>
backends/ChangeLog
backends/Makefile.am
libasm/ChangeLog
libasm/Makefile.am
libdw/ChangeLog
libdw/Makefile.am
libelf/ChangeLog
libelf/Makefile.am

index d62824513cdc88a83a201d98344f5f75745dd7d0..784e6b03bb72bc7bc3da381b1fd55378e42d73d4 100644 (file)
@@ -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.
index ac45a452bfcb747d583bed6d0f3ebc51c48bd088..996602f250d23253c8bd4637ea5c3333a2b830cc 100644 (file)
@@ -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)
index d2bc40860e7174f8c7eeeb815d0b9cf613eb5e62..262d2a92248320a697c7bcb03342ed2087edb791 100644 (file)
@@ -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.
index 8094b05ca6f9014d329d07ff9fdd72e9f7efaf1c..9effa6c50e091bb66f2d26ccbb6864683e34e755 100644 (file)
@@ -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)
index 1e282e4e3efb9cb6e56994519abe0370fb224def..8eda70cdf9a8d94341521f34068825438ec79463 100644 (file)
@@ -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
index 082d96c735fe608b9e67da7b4aca24b9122feef9..634ac2ecff5dfd2d34eca37b0efb246d08aa3fde 100644 (file)
@@ -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)
 
index 594bec995160905824dd424c1a50fe05a24a9ab0..214a4f7e7c00dca719a9032e426426ff2894b449 100644 (file)
@@ -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.
index 167a832228934cfe594f4feef7ebf89a6ce087e2..88c1edd74314445b702a231c54355372ca624114 100644 (file)
@@ -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)