aboutsummaryrefslogtreecommitdiff
path: root/extract-dynsym
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-05-09 00:53:12 +0000
committerRoland McGrath <roland@gnu.org>1996-05-09 00:53:12 +0000
commit03d0a7e2aa3c1a2134c9fa0a957292f4316e0ea5 (patch)
tree2decb264be5b187a966c07bb148d4112ba8414b9 /extract-dynsym
parent7c713e287e50dc338779ed1a6c6ac701720a3a41 (diff)
downloadglibc-03d0a7e2aa3c1a2134c9fa0a957292f4316e0ea5.tar
glibc-03d0a7e2aa3c1a2134c9fa0a957292f4316e0ea5.tar.gz
glibc-03d0a7e2aa3c1a2134c9fa0a957292f4316e0ea5.tar.bz2
glibc-03d0a7e2aa3c1a2134c9fa0a957292f4316e0ea5.zip
* extract-dynsym: New file.cvs/libc-960509
* Makefile (distribute): Add it.
Diffstat (limited to 'extract-dynsym')
-rwxr-xr-xextract-dynsym23
1 files changed, 23 insertions, 0 deletions
diff --git a/extract-dynsym b/extract-dynsym
new file mode 100755
index 0000000000..421dbd6fd0
--- /dev/null
+++ b/extract-dynsym
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Extract from an ELF shared object file just the dynamic symbols necessary
+# to link against it and the (GNU extension) warning sections that linking
+# against it may use to produce warning messages.
+
+infile=$1
+outfile=$2
+
+# Handle both objdump -h output formats.
+osechdr='^SECTION [0-9]+ \['
+nsechdr='^ +[0-9]+ '
+
+$OBJCOPY -S `$OBJDUMP -h $infile | $AWK "
+/($osechdr|$nsechdr)"'\.(hash|dyn[a-z]+|gnu\.warning[a-zA-Z_.]*) / { next; }
+/'"$osechdr"'/ { printf "--remove-section=%s ", $3 }
+/'"$nsechdr"'/ { printf "--remove-section=%s ", $2 }
+' |
+# The old format puts brackets around section names. The new format fails
+# to delimit long section names from the following hex digits.
+sed -e 's/[][]//g' -e 's/0[0-9a-f]* / /g'` $infile $outfile.new
+
+mv -f $outfile.new $outfile