* extract-dynsym: New file. cvs/libc-960509
authorRoland McGrath <roland@gnu.org>
Thu, 9 May 1996 00:53:12 +0000 (00:53 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 9 May 1996 00:53:12 +0000 (00:53 +0000)
* Makefile (distribute): Add it.

ChangeLog
Makefile
extract-dynsym [new file with mode: 0755]

index 1609c71..5e459d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 Wed May  8 20:04:29 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
 
+       * extract-dynsym: New file.
+       * Makefile (distribute): Add it.
        * Rules (subdir_install): Depend on $(common-objpfx)sor-$(subdir).
        [! libc.so-version]: Clear static-only-routines.
        ($(common-objpfx)sor-$(subdir)): New target.
index 8c514f3..b9d0c9b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -225,6 +225,7 @@ distribute  := README INSTALL NOTES COPYING.LIB COPYING NEWS                \
               Makefile Makeconfig Makerules Rules Make-dist MakeTAGS   \
               extra-lib.mk o-iterator.mk                               \
               ansidecl.h mkinstalldirs move-if-change install-sh       \
+              extract-dynsym                                           \
               configure configure.in aclocal.m4 config.sub config.guess\
               config.make.in config-name.in Makefile.in                \
               munch-tmpl.c munch.awk sysdep.h set-hooks.h libc-symbols.h
diff --git a/extract-dynsym b/extract-dynsym
new file mode 100755 (executable)
index 0000000..421dbd6
--- /dev/null
@@ -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