Created
May 18, 2021 04:02
-
-
Save androm3da/83560d92f3fe637b58aa115ba6b68456 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
set -euo pipefail | |
echo creating init file | |
echo <<EOF > input.S | |
.section .text | |
EOF | |
echo '' > keep_syms.txt | |
for i in $(seq 0 100000) | |
do | |
echo -e "sym_${i}:\nnop\n" >> input.S | |
if [[ ${i} -lt 30000 ]]; then | |
echo "sym_${i}" >> keep_syms.txt | |
fi | |
done | |
echo <<EOF >> input.S | |
.section .ballast | |
nop | |
EOF | |
echo creating obj file | |
llvm-mc -triple arm-linux-androideabi -filetype=obj input.S -o out.o | |
echo creating shared obj file | |
ld.lld -shared out.o -o libtestcase.so | |
echo performing llvm objcopy | |
\time llvm-objcopy -S --remove-section .ballast \ | |
--keep-symbols=keep_syms.txt \ | |
libtestcase.so libtestcase_smaller.so | |
echo performing GNU objcopy | |
\time arm-linux-androideabi-objcopy -S --remove-section .ballast \ | |
--keep-symbols=keep_syms.txt \ | |
libtestcase.so libtestcase_smaller.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment