#!/bin/sh #set -xv #debuging # this assumes .text .bss .data .edata .idata .stab .stabstr .reloc .rsrc # order for sections, which has been true for all the ones I've seen # and according to Mr. Noer this will be needed until B18+ comes out SECTION=.reloc if [ x"$1" = x"" -o x"$2" != x"" ];then echo usage $0 dllname.dll 1>&2 # errors to stderr exit 1; elif ! { DUMP=`objdump --headers $1` && echo $DUMP |grep pei-i386 &>/dev/null ;};then echo $0: not an object file 1>&2 exit 1; # not an exe dll .a or .o file elif ! echo $DUMP|grep "5 ." &>/dev/null ;then exit 0; # already striped static elif echo $DUMP|grep "5 .reloc " &>/dev/null ;then exit 0; # already striped .reloc elif echo $DUMP|grep ".rsrc" &>/dev/null ;then if echo $DUMP|grep "7 .reloc " &>/dev/null ;then echo $0: Please adjust .rsrc VMA by hand map is in `dirname $1`/stripmap.$$ 1>&2 objdump --headers $1 &> `dirname $1`/stripmap.$$ else SECTION=.rsrc fi fi if ! echo $DUMP|grep "7 .reloc " &>/dev/null ;then if echo $DUMP|grep "5 .stab " &>/dev/null ;then strip $1 # static .dll exit 0; else echo $0: unknown Error 1>&2 exit 1; # no clue fi else NEWVMA=`objdump --headers $1|grep "5 .stab "|gawk --traditional '{print $4}'` if [ x"$NEWVMA" != x"" ];then objcopy -S --adjust-section-vma $SECTION=0x$NEWVMA $1; exit 0; else echo $0: unknown Error 1>&2 exit 1; # no clue fi fi [ -f `dirname $1`/stripmap.$$ ] && cat stripmap.$$ && --objdump --headers $1 && echo objcopy -S --adjust-section-vma .rsrc=0xNEWVMA $1