From: Theodore Ts'o Date: Sat, 4 Aug 2012 20:56:55 +0000 (-0400) Subject: Put ELF_OTHER_LIBS in the right place for the linker X-Git-Tag: v1.42.6~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5aa6a82b37a0e78d8882601e6ad9da9d9dcb4da;p=thirdparty%2Fe2fsprogs.git Put ELF_OTHER_LIBS in the right place for the linker Commit a7c17431b9 attempted to fix a problem where the system libraries might get used instead of local libraries for things like -lcom_err. It tried to accomplish this by moving $(ELF_OTHER_LIBS) to before $(LDFLAGS). Unfortunately, this was the wrong fix; $(ELF_OTHER_LIBS) *MUST* be after the object files, or the linker might not pull in the necessary library and not include it into the DT_NEEDED section of the shared library. The proper fix is to add a -L$(LIB) before $(LDFLAGS), and then remove the -L option from all of the ELF_OTHER_LIBS definitions in the library Makefiles. Addresses-Sourceforge-Bug: #3554345 Cc: Olivier Blin Reported-by: Mike Frysinger Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/Makefile.elf-lib b/lib/Makefile.elf-lib index c66281c80..78479d31a 100644 --- a/lib/Makefile.elf-lib +++ b/lib/Makefile.elf-lib @@ -24,8 +24,9 @@ image: $(ELF_LIB) $(ELF_LIB): $(OBJS) $(E) " GEN_ELF_SOLIB $(ELF_LIB)" - $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(ELF_OTHER_LIBS) \ - $(LDFLAGS) -Wl,-soname,$(ELF_SONAME) $(OBJS)) + $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \ + -L$(top_builddir)/../lib $(LDFLAGS) \ + -Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) $(Q) $(MV) elfshared/$(ELF_LIB) . $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \ diff --git a/lib/Makefile.solaris-lib b/lib/Makefile.solaris-lib index 66f2b4c88..5990be8a4 100644 --- a/lib/Makefile.solaris-lib +++ b/lib/Makefile.solaris-lib @@ -24,8 +24,9 @@ image: $(ELF_LIB) $(ELF_LIB): $(OBJS) $(E) " GEN_ELF_SOLIB $(ELF_LIB)" - $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(ELF_OTHER_LIBS) \ - $(LDFLAGS) -Wl,-h,$(ELF_SONAME) $(OBJS)) + $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \ + -L$(top_builddir)/../lib $(LDFLAGS) \ + -Wl,-h,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) $(Q) $(MV) elfshared/$(ELF_LIB) . $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \ diff --git a/lib/blkid/Makefile.in b/lib/blkid/Makefile.in index f23a1376b..0ec8564c9 100644 --- a/lib/blkid/Makefile.in +++ b/lib/blkid/Makefile.in @@ -36,7 +36,7 @@ ELF_SO_VERSION = 1 ELF_IMAGE = libblkid ELF_MYDIR = blkid ELF_INSTALL_DIR = $(root_libdir) -ELF_OTHER_LIBS = -L../.. -luuid +ELF_OTHER_LIBS = -luuid BSDLIB_VERSION = 2.0 BSDLIB_IMAGE = libblkid diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in index 0d9ac2194..fc196fb7a 100644 --- a/lib/ext2fs/Makefile.in +++ b/lib/ext2fs/Makefile.in @@ -180,7 +180,7 @@ ELF_SO_VERSION = 2 ELF_IMAGE = libext2fs ELF_MYDIR = ext2fs ELF_INSTALL_DIR = $(root_libdir) -ELF_OTHER_LIBS = -L../.. -lcom_err +ELF_OTHER_LIBS = -lcom_err BSDLIB_VERSION = 2.1 BSDLIB_IMAGE = libext2fs diff --git a/lib/quota/Makefile.in b/lib/quota/Makefile.in index 2851eac7d..720befd98 100644 --- a/lib/quota/Makefile.in +++ b/lib/quota/Makefile.in @@ -31,7 +31,7 @@ LIBDIR= quota #ELF_IMAGE = libquota #ELF_MYDIR = quota #ELF_INSTALL_DIR = $(root_libdir) -#ELF_OTHER_LIBS = -L../.. -lext2fs +#ELF_OTHER_LIBS = -lext2fs #BSDLIB_VERSION = 1.0 #BSDLIB_IMAGE = libquota diff --git a/lib/ss/Makefile.in b/lib/ss/Makefile.in index 19413cc21..c396f2deb 100644 --- a/lib/ss/Makefile.in +++ b/lib/ss/Makefile.in @@ -20,7 +20,7 @@ ELF_SO_VERSION = 2 ELF_IMAGE = libss ELF_MYDIR = ss ELF_INSTALL_DIR = $(root_libdir) -ELF_OTHER_LIBS = -L../.. -lcom_err $(DLOPEN_LIB) +ELF_OTHER_LIBS = -lcom_err $(DLOPEN_LIB) BSDLIB_VERSION = 1.0 BSDLIB_IMAGE = libss