Thu May 16 00:31:44 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc/history.git] / extract-dynsym
blob421dbd6fd014b8bdfd31acb52ddfa7af605151c9
1 #!/bin/sh
3 # Extract from an ELF shared object file just the dynamic symbols necessary
4 # to link against it and the (GNU extension) warning sections that linking
5 # against it may use to produce warning messages.
7 infile=$1
8 outfile=$2
10 # Handle both objdump -h output formats.
11 osechdr='^SECTION [0-9]+ \['
12 nsechdr='^ +[0-9]+ '
14 $OBJCOPY -S `$OBJDUMP -h $infile | $AWK "
15 /($osechdr|$nsechdr)"'\.(hash|dyn[a-z]+|gnu\.warning[a-zA-Z_.]*) / { next; }
16 /'"$osechdr"'/ { printf "--remove-section=%s ", $3 }
17 /'"$nsechdr"'/ { printf "--remove-section=%s ", $2 }
18 ' |
19 # The old format puts brackets around section names. The new format fails
20 # to delimit long section names from the following hex digits.
21 sed -e 's/[][]//g' -e 's/0[0-9a-f]* / /g'` $infile $outfile.new
23 mv -f $outfile.new $outfile