aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-05-28 12:31:04 +0000
committermerakor <cem@ckyln.com>2020-05-28 12:31:04 +0000
commitc5ef3ea82ab4b4c15b2f64053f39227039e5dbcd (patch)
tree4940d2e247b80b8c885f42e0fe9a4d55e2083a2e
parent3e750af24018ea910ef2c04f4eccfe03ec405a55 (diff)
downloadcpt-c5ef3ea82ab4b4c15b2f64053f39227039e5dbcd.tar.gz
kiss: switch to POSIX od as well.
FossilOrigin-Name: 2c1751cff69369be953c903104ddfce893096bea52758febd894ade4613fb929
-rwxr-xr-xkiss32
1 files changed, 21 insertions, 11 deletions
diff --git a/kiss b/kiss
index 752a505..1f14a45 100755
--- a/kiss
+++ b/kiss
@@ -451,19 +451,29 @@ pkg_strip() {
log "$1" "Stripping binaries and libraries"
- # Strip only files matching the below ELF types.
- # NOTE: 'readelf' is used in place of 'file' as
- # it allows us to remove 'file' from the
- # core repositories altogether.
find "$pkg_dir/$1" -type f | while read -r file; do
- case $(readelf -h "$file") in
- *" DYN "*) strip_opt=unneeded ;;
- *" EXEC "*) strip_opt=all ;;
- *" REL "*) strip_opt=debug ;;
- *) continue
- esac
+ case $(od -A o -t c -N 18 "$file") in
+ # REL (object files (.o), static libraries (.a)).
+ *177*E*L*F*0000020\ 001\ *|*\!*\<*a*r*c*h*\>*)
+ strip -g -R .comment -R .note "$file"
+ strip_opt=DEBUG
+ ;;
+
+ # EXEC (static binaries).
+ *177*E*L*F*0000020\ 002\ *)
+ strip -s -R .comment -R .note "$file"
+ strip_opt=ALL
+ ;;
- strip "--strip-$strip_opt" "$file" &&
+ # DYN (shared libraries, dynamic binaries).
+ # Shared libraries keep global symbols in a separate ELF section
+ # called '.dynsym'. '--strip-all/-s' does not touch the dynamic
+ # symbol entries which makes this safe to do.
+ *177*E*L*F*0000020\ 003\ *)
+ strip -s -R .comment -R .note "$file"
+ strip_opt=UNNEEDED
+ ;;
+ esac
printf 'Stripped %10s %s\n' "($strip_opt)" "${file##$pkg_dir/$1}"
done 2>/dev/null ||:
}