#!/bin/bash # # This short shell script will extract all the strong "text" symbols from the # shared library and create a new "stub" shared library with the same symbols. # The body of these functions will be empty and therefore have no dependencies. # This scripts uses whatever CC is defined in the user's environment. # set -o pipefail # check arguments if [ $# -ne 2 ] ; then echo "Usage: $(basename $0) IN_LIBFILE OUT_LIBFILE" exit 1 fi IN_LIBFILE="$1" OUT_LIBFILE="$2" # check compiler if [ -z "${CC}" ] ; then echo "Error: Environment variable 'CC' has not been defined" exit 1 fi SONAME=$(readelf -d "${IN_LIBFILE}" | grep '(SONAME)' | cut -d [ -f 2 | cut -d ] -f 1) # make stub library nm -D "${IN_LIBFILE}" | \ awk '{if ($2 == "T") { print "void",$3,"() {}" }}' | \ "${CC}" -x c -O0 -fPIC -shared -Wl,-soname=${SONAME} -Wl,--strip-all -o "${OUT_LIBFILE}" - exit $?