SUGGEST: Patch for compiling unzip using hardened CFLAGS

Aki Tuomi cmouse at youzen.ext.b2.fi
Mon Oct 10 11:19:53 PDT 2005


Thanks, here is a fixed patch and compilation instructions for LINUX/x86
target.

patch -Np1 -i ../unzip-5.52-fix_Makefile-1.patch &&
patch -Np1 -i ../unzip-5.52-fix_libz-1.patch &&
patch -Np1 -i ../unzip-5.52-dont_make_noise-1.patch &&
patch -Np1 -i ../unzip-5.52-hardened-cflags.patch &&
cp -v unix/Makefile . &&
make prefix=/usr LOCAL_UNZIP=-DUSE_UNSHRINK linux_noasm &&
make prefix=/usr LOCAL_UNZIP=-DUSE_UNSHRINK linux_shlibz

To test the results, issue: LD_LIBRARY_PATH=$PWD make check

Now, as the root user:

make prefix=/usr LOCAL_UNZIP=-DUSE_UNSHRINK install &&
cp -v -d libunzip.so* /usr/lib

On Mon, Oct 10, 2005 at 07:26:50PM +0200, Jaap Struyk wrote:
> Op ma 10-10-2005, om 15:48 schreef Aki Tuomi:
> 
> > Attached, patch for compiling unzip under HLFS. Removes compilation of ASM
> > components and uses proper CFLAGS.
> 
> When trying I got the following:
> 
> gcc -o unzip unzip.o crc32.o crctab.o crypt.o envargs.o explode.o extract.o fileio.o globals.o inflate.o list.o match.o process.o ttyio.o unreduce.o unshrink.o zipinfo.o unix.o -s
> extract.o: In function `memextract':
> extract.c:(.text+0x7b9): undefined reference to `crc32'
> extract.o: In function `.L109':
> extract.c:(.text+0x19b3): undefined reference to `crc32'
> fileio.o: In function `flush':
> fileio.c:(.text+0x950): undefined reference to `crc32'
> fileio.o: In function `.L132':
> fileio.c:(.text+0xf90): undefined reference to `crc32'
> collect2: ld returned 1 exit status
> make[1]: *** [unzip] Error 1
> make[1]: Leaving directory `/root/unzip-5.52'
> make: *** [linux_shlibz] Error 2
> -- 
> Groetjes Japie
> 
> -- 
> http://linuxfromscratch.org/mailman/listinfo/hlfs-dev
> FAQ: http://www.linuxfromscratch.org/faq/
> Unsubscribe: See the above information page

-- 
Aki Tuomi

-------------- next part --------------
diff -urN old/unix/Makefile new/unix/Makefile
--- old/unix/Makefile	2005-10-10 21:12:06.000000000 +0300
+++ new/unix/Makefile	2005-10-10 21:13:40.000000000 +0300
@@ -783,7 +783,7 @@
 # Linux (Posix, approximately SysV):  virtually any version since before 0.96,
 # for any platform.  Change "-O" to "-O3" or whatever, as desired...
 linux_noasm:	unix_make
-	$(MAKE) unzips CC=gcc LD=gcc CF="-O -Wall -I. $(LOC)"
+	$(MAKE) unzips CC=gcc LD="gcc -pie -fpie" CF="-O3 -Wall -I. $(LOC) -pie -fpie"
 
 # Linux with lcc compiler:  __inline__ (stat.h) not recognized, and must edit
 # /usr/include/gnu/types.h to get rid of "long long" if __LCC__ defined.  -O3
@@ -822,14 +822,12 @@
 # instead of the original UnZip version.  (libz was libgz prior to 0.94)
 linux_shlibz:	unix_make
 #	$(MAKE) objsdll CC=gcc CF="-O3 -Wall -I. -fPIC -DDLL -DUSE_ZLIB $(LOC)"
-	$(MAKE) objsdll CC=gcc AS=gcc AF="-fPIC -Di386 $(AF)" CRC32=crc_gcc\
-	 CF="-O3 -Wall -I. -fPIC -DDLL -DUSE_ZLIB -DASM_CRC $(LOC)"
-	ln -sf crc_gcc.pic.o crc32.pic.o
-	gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL)
+	$(MAKE) objsdll CC=gcc CRC32=crc32 CF="-O3 -Wall -I. -fPIC -DDLL -DUSE_ZLIB $(LOC) -fpie -pie"
+	gcc -shared -fPIC -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL)
 	ln -sf libunzip.so.0.4 libunzip.so.0
 	ln -sf libunzip.so.0.4 libunzip.so
 	gcc -c -O unzipstb.c
-	gcc -o unzip unzipstb.o -L. -lunzip -lz
+	gcc -pie -fpie -o unzip unzipstb.o -L. -lunzip -lz
 
 # LynxOS-x86 2.3.0 and newer, a real-time BSD-like OS; uses gcc.
 lynx:		unix_make


More information about the hlfs-dev mailing list