Skip to content

Instantly share code, notes, and snippets.

@androm3da
Created May 18, 2021 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save androm3da/83560d92f3fe637b58aa115ba6b68456 to your computer and use it in GitHub Desktop.
Save androm3da/83560d92f3fe637b58aa115ba6b68456 to your computer and use it in GitHub Desktop.
#!/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