commit dd282500993041e6f2ab758b303f16b70fc30387 Author: outofmemo Date: Wed Oct 5 10:46:42 2022 +0800 packelf.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5a9e57 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +`packelf` was inspired by [the idea of Klaus D](https://askubuntu.com/a/546305). It is used to package the elf executable and its dependent libraries into a single executable. + + + +## usage + +``` +packelf.sh [ADDITIONAL_LIBS ...] +``` + + + +## example + +``` +~ # packelf.sh `which perf` /root/perf +~ # /root/perf --version +perf version 3.10.0-1160.49.1.el7.x86_64.debug +``` + diff --git a/packelf.sh b/packelf.sh new file mode 100755 index 0000000..b82a6b3 --- /dev/null +++ b/packelf.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -eo pipefail + +[ $# -lt 2 ] && { + echo "usage: $0 [ADDITIONAL_LIBS ...]" + exit 1 +} + +src="$1" +dst="$2" +shift +shift + +cat >"$dst" <>"$dst" "$@" 2> >(grep -v 'Removing leading' >&2) +chmod +x "$dst"