Skip to content

Instantly share code, notes, and snippets.

@izabera
Created August 16, 2018 14:30
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 izabera/c4ee292f47edbbb7a0aa57682608966f to your computer and use it in GitHub Desktop.
Save izabera/c4ee292f47edbbb7a0aa57682608966f to your computer and use it in GitHub Desktop.
#!/bin/bash -e
rm -rf build
mkdir build
cd build
echo "int main() {" > f.c
limit=${1-500}
for (( i = 0; i < ${1-500}; i++ )) do
printf "%s\r" "$i"
echo "void f$i(void) { }" > "f$i.c"
echo "void f$i(void); f$i();" >> f.c
gcc -shared -fPIC "f$i.c" -o "libf$i.so" &
(( i > 8 )) && wait -n
libs+=(-l"f$i")
done
echo "}" >> f.c
wait
gcc f.c -L. "${libs[@]}" -o f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment