This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Provide build rules for a compatibility library


We need to export open(), close(), malloc(), and free() from the C
library we are using so that we can handle resources passed to and from
elfutils correctly. For example, on Windows, calling free() on memory
malloc()'d with a different C library will not work. In addition, having
__cxa_demangle from the GNU libstdc++ available is very helpful, so we
include that, too.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 ChangeLog            |  4 ++++
 configure.ac         |  1 +
 lib/ChangeLog        |  6 ++++++
 lib/Makefile.am      | 35 +++++++++++++++++++++++++++++++++--
 lib/eu_compat.def.in |  7 +++++++
 5 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 lib/eu_compat.def.in

diff --git a/ChangeLog b/ChangeLog
index 2cf7bd6..187ef59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* configure.ac: Determine names for eu_compat library.
+
+2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* configure.ac: Check for fork().
 
 2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
diff --git a/configure.ac b/configure.ac
index 5fa20c0..c0efdfc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,7 @@ AM_CONDITIONAL(NATIVE_MACHO, test "$LIBEXT" = ".dylib")
 eu_LIBNAME(elf,1)
 eu_LIBNAME(dw,1)
 eu_LIBNAME(asm,1)
+eu_LIBNAME(eu_compat,1)
 
 AC_ARG_ENABLE(deterministic-archives,
 [AS_HELP_STRING([--enable-deterministic-archives],
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 0433f02..ceb6ac2 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,5 +1,11 @@
 2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* Makefile.am: On windows, build an eu_compat.dll to forward symbols
+	from the C and std C++ libraries elfutils links against.
+	* eu_compat.def.in: New file.
+
+2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* printversion.h: Define ARGP_PROGRAM_VERSION_HOOK_DEF and
 	ARGP_BUG_ADDRESS_DEF to be non-const and drop the asm tricks.
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index afff717..48947c6 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -57,5 +57,36 @@ install-headers:
 uninstall-headers:
 endif
 
-install: install-am install-headers
-uninstall: uninstall-am uninstall-headers
+EXTRA_DIST += eu_compat.def.in
+if NATIVE_PE
+eu_compat.def: eu_compat.def.in
+	cp $< $@
+
+$(libeu_compat_BARE): eu_compat.def
+	$(CCLD) $(dso_LDFLAGS) $(LDFLAGS) -o $@ $< -lstdc++
+
+noinst_DATA = $(eu_compat_BARE)
+
+install-lib: $(libeu_compat_BARE) $(libeu_compat_BARE:.dll=.lib)
+	$(mkinstalldirs) $(DESTDIR)$(libdir)
+	$(INSTALL_PROGRAM) $(libeu_compat_BARE) $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED)
+	ln -fs $(libeu_compat_VERSIONED) $(DESTDIR)$(libdir)/$(libeu_compat_SONAME)
+	ln -fs $(libeu_compat_SONAME) $(DESTDIR)$(libdir)/$(libeu_compat_BARE)
+	$(INSTALL_PROGRAM) $(libeu_compat_BARE:.dll=.lib) $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED:.dll=.lib)
+	ln -fs $(libeu_compat_VERSIONED:.dll=.lib) $(DESTDIR)$(libdir)/$(libeu_compat_SONAME:.dll=.lib)
+	ln -fs $(libeu_compat_SONAME:.dll=.lib) $(DESTDIR)$(libdir)/$(libeu_compat_BARE:.dll=.lib)
+uninstall-lib:
+	rm -f $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED)
+	rm -f $(DESTDIR)$(libdir)/$(libeu_compat_SONAME)
+	rm -f $(DESTDIR)$(libdir)/$(libeu_compat_BARE)
+	rm -f $(DESTDIR)$(libdir)/$(libeu_compat_VERSIONED:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libeu_compat_SONAME:.dll=.lib)
+	rm -f $(DESTDIR)$(libdir)/$(libeu_compat_BARE:.dll=.lib)
+CLEANFILES += $(libeu_compat_BARE:.dll=.lib) $(libeu_compat_BARE:.dll=.exp)
+else
+install-lib:
+uninstall-lib:
+endif
+
+install: install-am install-headers install-lib
+uninstall: uninstall-am uninstall-headers install-lib
diff --git a/lib/eu_compat.def.in b/lib/eu_compat.def.in
new file mode 100644
index 0000000..c2aa88f
--- /dev/null
+++ b/lib/eu_compat.def.in
@@ -0,0 +1,7 @@
+LIBRARY "eu_compat.dll"
+EXPORTS
+eu_compat_demangle=__cxa_demangle
+eu_compat_open=msvcrt._open
+eu_compat_close=msvcrt._close
+eu_compat_malloc=msvcrt.malloc
+eu_compat_free=msvcrt.free
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]