#!/bin/sh # file: mkshlib.lnx G. Moody 26 January 1995 # Last revised: 15 April 1997 (comments only) # Generate an a.out-format shared DB library under Linux # # If you are simply installing the DB Software Package under Linux, you do not # need to recompile the shared DB library; the normal installation procedure # installs precompiled versions of it. # # You might wish to recompile the shared DB library if you have added support # for other signal or annotation file formats to the library sources. By # recompiling and reinstalling the shared DB library, you can enable existing # DB applications to support your formats without recompiling the applications # themselves. # # Rather than using this shell script, you should compile an ELF-format shared # library (using `make slib') if your Linux system supports it (and you should # consider upgrading your Linux system if it does not yet support ELF). ELF is # the format used by all new versions of Linux, and a.out format is rapidly # becoming obsolete. # # Keep in mind that the shared DB library is not *necessary* in any case; you # can always link your programs with libdb.a (the static library) if you can't # rebuild the shared library. # # If, despite the above, you still wish to recompile the shared DB library in # a.out format, run this shell script from within the directory that contains # the DB library sources. The programs `getvars', `getfuncs', `getsize', # `mkimage', `mkstubs', and `verify-shlib', if not installed on your system, # can be obtained by anonymous ftp from tsx-11.mit.edu; get # pub/linux/packages/GCC/src/tools-2.16.tar.gz # (or a later version if available). The `tools' package also includes # `jumpas', installed as /usr/bin/jumpas and used by gcc within this script as # a replacement for the standard `as' assembler. # # Making an a.out-format shared library work under Linux is a bit tricky. # Before you consider changing anything in this script, read the documentation # that comes with `tools' and study the example included with `tools' # carefully. Note that (at least as of version 2.16) the documentation omits # several crucial details, so you MUST study the example if you hope to # understand how this process works! # # A particularly thorny problem is that all a.out-format shared libraries must # contain unique load addresses between 0x60000000 and 0xc0000000. The # standard Linux and X11 libraries have been assigned addresses at the lower # end of this range (from 0x60000000 through 0x665fffff, as of version 2.16). # I have arbitrarily selected 0x9f000000 for the DB library load address. # Although the documentation for `tools' suggests that distributors of shared # libraries may wish to register their libraries' load addresses to avoid # conflicts, I have not done so, suspecting that the DB library will be of # interest to a rather small subset of Linux users. I have simply chosen an # address that I hope will be well clear of conflicts, at least for a while. # If you need to change it, do so, but you will need in this case to re-link # your programs as well. # # At the end of this script, `verify-shlib' should report that libdb.so.* and # libdb.sa have identical addresses. If it reports *any* discrepancies, these # must be resolved before continuing, or your DB applications will crash. # # Please let me know if you encounter problems using this script. Thanks! # -- george@hstbme.mit.edu case `uname -s` in Linux) ;; *) exit 1 ;; esac # The library version number must be passed in to this script as the first # and only argument. case $# in 1) VERSION=$1 ;; *) echo "usage: $0 version-number" exit 1 ;; esac # Note that JUMP_DIR must be an absolute pathname of a directory. JUMP_DIR=`pwd`/jump export JUMP_DIR JUMP_LIB=libdb export JUMP_LIB LOAD_ADDR=0x9f000000 LIB_NAME=libdb JUMP_SIZE=0x4000 GOT_SIZE=0x2000 OBJS='dbinit.o annot.o signal.o calib.o dbio.o' # It shouldn't be necessary to delete the previous JUMP_DIR, but if we don't, # and we are running as root, getvars and getfuncs complain that they can't # read jump.log. rm -rf $JUMP_DIR mkdir -p $JUMP_DIR make clean make "CC=gcc -B/usr/bin/jump -I/usr/local/include" lib ranlib $LIB_NAME.a cd jump getvars getfuncs rm jump.log cd .. make clean make "CC=gcc -B/usr/bin/jump -I/usr/local/include" lib cd jump getsize >jump.vars-new cd .. mkimage -l $LIB_NAME -v $VERSION -a $LOAD_ADDR -j $JUMP_SIZE -g $GOT_SIZE -- \ $OBJS -lc `gcc --print-libgcc-file-name` -lc mkstubs -l $LIB_NAME -v $VERSION -a $LOAD_ADDR -j $JUMP_SIZE -g $GOT_SIZE -- \ $LIB_NAME if verify-shlib -l $LIB_NAME.so.$VERSION $LIB_NAME.sa | grep -q "identical" then echo The shared DB library was built successfully. exit 0 else echo The shared DB library was not built successfully. echo Review `pwd`/verify.out and correct the errors before continuing. exit 1 fi