-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jumarea Stefan <[email protected]> Signed-off-by: anindya_sen <[email protected]>
- Loading branch information
1 parent
5974451
commit 5f8c941
Showing
6 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Build unzip as static PIE | ||
|
||
Build the [unzip](https://infozip.sourceforge.net/UnZip.html) application as static PIE ELF running on Linux. | ||
|
||
## Requirements | ||
|
||
Make sure the following packages are installed: | ||
|
||
* GCC | ||
* GNU Make | ||
|
||
## Build | ||
|
||
The `unzip` static PIE ELF file is located in the current directory. | ||
In order to rebuild it you have to run the `build.sh` bash script. | ||
The `build.sh` script will download, extract, patch and build the code to generate the static PIE unzip binary. | ||
|
||
## Running | ||
|
||
```bash | ||
./unzip extract.zip | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
APP=unzip | ||
DIR=${APP}60 | ||
ARCHIVE=${DIR}.tar.gz | ||
URL=https://downloads.sourceforge.net/infozip/${ARCHIVE} | ||
|
||
# Clean up | ||
rm -rf ${ARCHIVE} | ||
rm -rf ${DIR} | ||
|
||
echo -n "Downloading ${APP} sources ... " | ||
wget -q ${URL} | ||
if test $? -ne 0; then | ||
echo "" | ||
echo "Unable to download ${APP} from ${URL}" | ||
exit 1 | ||
fi | ||
echo "DONE" | ||
|
||
echo "" | ||
echo -n "Unpacking ${APP} ... " | ||
tar -zxvf ${ARCHIVE} | ||
if test $? -ne 0; then | ||
echo "" | ||
echo "Unable to extract ${APP}" | ||
exit 1 | ||
fi | ||
echo "DONE" | ||
|
||
echo "" | ||
echo -n "Building ${APP} ... " | ||
echo "" | ||
pushd ${DIR} > /dev/null 2>&1 || exit 1 | ||
|
||
patch -p1 < ../patches/add-static-pie-flag.patch | ||
make -f unix/Makefile generic | ||
|
||
popd > /dev/null 2>&1 || exit 1 | ||
|
||
cp ${DIR}/${APP} . | ||
|
||
rm -rf ${DIR} | ||
rm -rf ${ARCHIVE} | ||
|
||
echo -n "Build complete!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/unix/Makefile b/unix/Makefile | ||
index ab32270..e00aa7b 100644 | ||
--- a/unix/Makefile | ||
+++ b/unix/Makefile | ||
@@ -53,6 +53,7 @@ CF = $(CFLAGS) $(CF_NOOPT) | ||
LFLAGS1 = | ||
LF = -o unzip$E $(LFLAGS1) | ||
LF2 = -s | ||
+LDFLAGS = -static-pie -static-libgcc | ||
|
||
# UnZipSFX flags | ||
SL = -o unzipsfx$E $(LFLAGS1) | ||
@@ -280,13 +281,13 @@ unzipsdocs: unzips docs | ||
# make utilities if default: change "unzip$E:" to "unzip$E:&" | ||
|
||
unzip$E: $(OBJS) $(LIBBZ2) # add `&' for parallel makes | ||
- $(LD) $(LF) -L$(IZ_BZIP2) $(LOBJS) $(L_BZ2) $(LF2) | ||
+ $(LD) $(LF) -L$(IZ_BZIP2) $(LOBJS) $(L_BZ2) $(LF2) $(LDFLAGS) | ||
|
||
unzipsfx$E: $(OBJX) # add `&' for parallel makes | ||
- $(LD) $(SL) $(LOBJX) $(SL2) | ||
+ $(LD) $(SL) $(LOBJX) $(SL2) $(LDFLAGS) | ||
|
||
funzip$E: $(OBJF) # add `&' for parallel makes | ||
- $(LD) $(FL) $(OBJF) $(FL2) | ||
+ $(LD) $(FL) $(OBJF) $(FL2) $(LDFLAGS) | ||
|
||
zipinfo$E: unzip$E # `&' is pointless here... | ||
@echo\ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a testfile used for compression using zip. |
Binary file not shown.