From c7de7e44a6e85d8a9d0f63ee12f388049c382e5e Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Wed, 21 Oct 2015 22:43:14 -0400 Subject: [PATCH 1/2] create versioned library name and symlink unversioned name on *nix This allows executables (e.g. unit tests) to link against the libunicorn.so in the build directory, after the SONAME was added in 4860fdb3. Becuase libunicorn.so has an SONAME of libunicorn.so.0, the linker uses the SONAME for the DT_NEEDED entry of the tests. But because a library with that name did not exist, they would fail to run. --- .gitignore | 2 ++ Makefile | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3fdb76f7..6831c5b6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.o *.a *.dSYM +*.so +*.so.* qemu/config-all-devices.mak diff --git a/Makefile b/Makefile index 4ce64736..51f8b469 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,8 @@ LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) else ifeq ($(IS_CYGWIN),1) LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) else # *nix -LIBRARY = $(BLDIR)/lib$(LIBNAME).$(EXT) +LIBRARY = $(BLDIR)/lib$(LIBNAME).$(VERSION_EXT) +LIBRARY_SYMLINK = $(BLDIR)/lib$(LIBNAME).$(EXT) endif endif @@ -229,6 +230,9 @@ ifeq ($(V),0) else $(CC) $(CFLAGS) $($(LIBNAME)_LDFLAGS) -shared $^ -o $(LIBRARY) $(GLIB) -lm endif +ifneq (,$(LIBRARY_SYMLINK)) + @ln -sf $(LIBRARY) $(LIBRARY_SYMLINK) +endif endif $(ARCHIVE): $(UC_TARGET_OBJ) uc.o hook.o From efb0c87e392e4e719e7b22a4d171381a51998ff4 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Sat, 24 Oct 2015 16:43:34 -0400 Subject: [PATCH 2/2] fix install logic after changing LIBRARY Now that LIBRARY is the versioned name (e.g. "libunicorn.so.0"), we don't need this rename step; just create the symlink for libunicorn.so. If VERSION_EXT isn't set, then the library we installed already has the correct name, and no symlink is necessary. We should probably be running 'ldconfig' to handle this, or better yet, using libtool. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 51f8b469..bed04589 100644 --- a/Makefile +++ b/Makefile @@ -266,7 +266,6 @@ ifeq ($(UNICORN_SHARED),yes) $(INSTALL_LIB) $(LIBRARY) $(LIBDIR) ifneq ($(VERSION_EXT),) cd $(LIBDIR) && \ - mv lib$(LIBNAME).$(EXT) lib$(LIBNAME).$(VERSION_EXT) && \ ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT) endif endif