cirrus.yml: Compile FreeBSD with -Werror
[qemu/ar7.git] / scripts / undefsym.sh
blobb9ec332e958db776e3d92fed23b82b3ebe2eca54
1 #! /usr/bin/env bash
3 # Before a shared module's DSO is produced, a static library is built for it
4 # and passed to this script. The script generates -Wl,-u options to force
5 # the inclusion of symbol from libqemuutil.a if the shared modules need them,
6 # This is necessary because the modules may use functions not needed by the
7 # executable itself, which would cause the function to not be linked in.
8 # Then the DSO loading would fail because of the missing symbol.
10 if test $# -le 2; then
11 exit 0
14 NM=$1
15 staticlib=$2
16 shift 2
17 # Find symbols defined in static libraries and undefined in shared modules
18 comm -12 \
19 <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \
20 <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u)