blob: a39a24db1dc546da85a0d30b378e82a9c07239d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# Usage:
# $1 : Destination merged, stripped, small shared library
# $2 : lib*_pic.a files from which to produce the final small library
# ${3:$} : executables and shared libraries whos dependencies we care about
MERGED_SO="$1"; shift
PIC_LIBS="$1"; shift
GCC=${GCC-i386-gnu-gcc}
LD=${LD-i386-gnu-ld}
OBJDUMP=${OBJDUMP-i386-gnu-objdump}
OBJCOPY=${OBJCOPY-i386-gnu-objcopy}
DEP_FLAGS_FILE=/tmp/,depflags.$$
MERGED_PIC_LIB=/tmp/,libmerged_pic.a.$$
#trap "rm -f $DEP_FLAGS_FILE $MERGED_PIC_LIB" 0
$OBJDUMP --dynamic-syms "$@" 2>/dev/null|sed -n 's/^.*\*UND\*.* \([^ ]*\)$/-u\1/p'|sort -u > $DEP_FLAGS_FILE
$LD -o $MERGED_PIC_LIB `cat $DEP_FLAGS_FILE` -r $PIC_LIBS \
&& $GCC -nostdlib -shared -Wl,-soname=`basename $MERGED_SO` \
-o $MERGED_SO.uns $MERGED_PIC_LIB \
&& $OBJCOPY --strip-debug $MERGED_SO.uns $MERGED_SO \
&& rm -f $MERGED_SO.uns
|