diff -urN binutils-2.7/COPYING binutils-2.8/COPYING --- binutils-2.7/COPYING Thu Jul 4 12:21:54 1996 +++ binutils-2.8/COPYING Wed Apr 30 12:57:43 1997 @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -279,7 +279,7 @@ END OF TERMS AND CONDITIONS - Appendix: How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -305,7 +305,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Also add information on how to contact you by electronic and paper mail. diff -urN binutils-2.7/Makefile.in binutils-2.8/Makefile.in --- binutils-2.7/Makefile.in Mon Jul 15 15:08:34 1996 +++ binutils-2.8/Makefile.in Wed Apr 30 13:06:20 1997 @@ -1,6 +1,6 @@ # # Makefile for directory with subdirs to build. -# Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation +# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ SHELL = /bin/sh -INSTALL = $${srcroot}/install.sh -c +INSTALL = $$s/install.sh -c INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) -m 644 INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)' @@ -68,6 +68,7 @@ CFLAGS = -g LIBCFLAGS = $(CFLAGS) CFLAGS_FOR_TARGET = $(CFLAGS) +LDFLAGS_FOR_TARGET = LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET) PICFLAG = PICFLAG_FOR_TARGET = @@ -101,7 +102,7 @@ then echo $$r/m4/m4 ; \ else echo m4 ; fi` -MAKEINFO = `if [ -f $$r/texinfo/makeinfo/makeinfo ] ; \ +MAKEINFO = `if [ -f $$r/texinfo/makeinfo/Makefile ] ; \ then echo $$r/texinfo/makeinfo/makeinfo ; \ else echo makeinfo ; fi` @@ -114,8 +115,8 @@ then echo $$r/expect/expect ; \ else echo expect ; fi` -RUNTEST = `if [ -f $${srcroot}/dejagnu/runtest ] ; \ - then echo $${srcroot}/dejagnu/runtest ; \ +RUNTEST = `if [ -f $$s/dejagnu/runtest ] ; \ + then echo $$s/dejagnu/runtest ; \ else echo runtest ; fi` @@ -161,9 +162,13 @@ CC_FOR_TARGET = ` \ - if [ -f $$r/gcc/Makefile ] ; then \ + if [ -f $$r/gcc/xgcc ] ; then \ if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \ - echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $${srcroot}/newlib/libc/include -nostdinc; \ + if [ -f $$r/$(TARGET_SUBDIR)/winsup/Makefile ] ; then \ + echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/newlib/ -L$$r/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + fi; \ else \ echo $$r/gcc/xgcc -B$$r/gcc/; \ fi; \ @@ -175,11 +180,21 @@ fi; \ fi` +# If CC_FOR_TARGET is not overriden on the command line, then this +# variable is passed down to the gcc Makefile, where it is used to +# build libgcc2.a. We define it here so that it can itself be +# overridden on the command line. +GCC_FOR_TARGET = $$r/gcc/xgcc -B$$r/gcc/ + CXX_FOR_TARGET = ` \ - if [ -f $$r/gcc/Makefile ] ; then \ + if [ -f $$r/gcc/xgcc ] ; then \ if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \ - echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $${srcroot}/newlib/libc/include -nostdinc; \ + if [ -f $$r/$(TARGET_SUBDIR)/winsup/Makefile ] ; then \ + echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/newlib/ -L$$r/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + fi; \ else \ echo $$r/gcc/xgcc -B$$r/gcc/; \ fi; \ @@ -276,7 +291,6 @@ "CXXFLAGS_FOR_TARGET=$(CXXFLAGS_FOR_TARGET)" \ "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \ "DLLTOOL_FOR_TARGET=$(DLLTOOL_FOR_TARGET)" \ - "GCC_FOR_TARGET=$(CC_FOR_TARGET)" \ "INSTALL=$(INSTALL)" \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ @@ -369,11 +383,13 @@ 'HOST_PREFIX_1=$(HOST_PREFIX_1)' \ 'NM=$(NM)' \ 'RANLIB=$$(RANLIB_FOR_TARGET)' \ + "GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \ `if test x"$(LANGUAGES)" != x; then echo "LANGUAGES=$(LANGUAGES)"; fi` \ `if test x"$(STMP_FIXPROTO)" != x; then echo "STMP_FIXPROTO=$(STMP_FIXPROTO)"; fi` \ `if test x"$(LIMITS_H_TEST)" != x; then echo "LIMITS_H_TEST=$(LIMITS_H_TEST)"; fi` \ `if test x"$(LIBGCC1_TEST)" != x; then echo "LIBGCC1_TEST=$(LIBGCC1_TEST)"; fi` \ `if test x"$(LIBGCC2_CFLAGS)" != x; then echo "LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)"; fi` \ + `if test x"$(LIBGCC2_DEBUG_CFLAGS)" != x; then echo "LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)"; fi` \ `if test x"$(LIBGCC2_INCLUDES)" != x; then echo "LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)"; fi` \ `if test x"$(ENQUIRE)" != x; then echo "ENQUIRE=$(ENQUIRE)"; fi` \ `if test x"$(BOOT_CFLAGS)" != x; then echo "BOOT_CFLAGS=$(BOOT_CFLAGS)"; fi` @@ -385,15 +401,18 @@ ALL_MODULES = \ all-apache \ all-autoconf \ + all-bash \ all-bfd \ all-binutils \ all-byacc \ all-cvs \ + all-db \ all-dejagnu \ all-diff \ all-dosutils \ all-etc \ all-fileutils \ + all-findutils \ all-find \ all-flex \ all-gas \ @@ -406,6 +425,7 @@ all-indent \ all-inet \ all-ispell \ + all-itcl \ all-ld \ all-libiberty \ all-m4 \ @@ -423,6 +443,7 @@ all-send-pr \ all-shellutils \ all-sim \ + all-sn \ all-tar \ all-tcl \ all-texinfo \ @@ -434,8 +455,6 @@ # This is a list of the check targets for all of the modules which are # compiled using $(FLAGS_TO_PASS). -# This is a list of the check targets for all of the modules which are -# compiled using $(FLAGS_TO_PASS). # # The list is in two parts. The first lists those tools which # are tested as part of the host's native tool-chain, and not @@ -447,13 +466,16 @@ CROSS_CHECK_MODULES = \ check-apache \ check-autoconf \ + check-bash \ check-bfd \ check-binutils \ check-cvs \ + check-db \ check-dejagnu \ check-diff \ check-etc \ check-fileutils \ + check-findutils \ check-find \ check-gas \ check-gawk \ @@ -464,6 +486,7 @@ check-indent \ check-inet \ check-ispell \ + check-itcl \ check-ld \ check-libiberty \ check-m4 \ @@ -479,6 +502,7 @@ check-sed \ check-send-pr \ check-shellutils \ + check-sn \ check-sim \ check-tar \ check-tcl \ @@ -496,15 +520,18 @@ INSTALL_MODULES = \ install-apache \ install-autoconf \ + install-bash \ install-bfd \ install-binutils \ install-byacc \ install-cvs \ + install-db \ install-dejagnu \ install-diff \ install-dosutils \ install-etc \ install-fileutils \ + install-findutils \ install-find \ install-flex \ install-gas \ @@ -517,6 +544,7 @@ install-indent \ install-inet \ install-ispell \ + install-itcl \ install-ld \ install-libiberty \ install-m4 \ @@ -533,6 +561,7 @@ install-send-pr \ install-shellutils \ install-sim \ + install-sn \ install-tar \ install-tcl \ install-textutils \ @@ -561,8 +590,7 @@ check-guile \ check-expect \ check-gash \ - check-tclX \ - check-tk + check-tclX # This is a list of the install targets for all the modules which are # compiled using $(X11_FLAGS_TO_PASS). @@ -627,15 +655,18 @@ CLEAN_MODULES = \ clean-apache \ clean-autoconf \ + clean-bash \ clean-bfd \ clean-binutils \ clean-byacc \ clean-cvs \ + clean-db \ clean-dejagnu \ clean-diff \ clean-dosutils \ clean-etc \ clean-fileutils \ + clean-findutils \ clean-find \ clean-flex \ clean-gas \ @@ -648,6 +679,7 @@ clean-indent \ clean-inet \ clean-ispell \ + clean-itcl \ clean-ld \ clean-libiberty \ clean-m4 \ @@ -665,6 +697,7 @@ clean-send-pr \ clean-shellutils \ clean-sim \ + clean-sn \ clean-tar \ clean-tcl \ clean-texinfo \ @@ -730,7 +763,7 @@ $(DO_X): @target=`echo $@ | sed -e 's/^do-//'`; \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ for i in $(SUBDIRS) -dummy-; do \ if [ -f ./$$i/Makefile ]; then \ @@ -758,7 +791,7 @@ done @target=`echo $@ | sed -e 's/^do-//'`; \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ for i in $(TARGET_CONFIGDIRS) -dummy-; do \ if [ -f $(TARGET_SUBDIR)/$$i/Makefile ]; then \ @@ -785,8 +818,11 @@ installcheck: do-installcheck dvi: do-dvi +# Make sure makeinfo is built before we do a `make info'. +do-info: all-texinfo + install-info: do-install-info dir.info - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ if [ -f dir.info ] ; then \ $(INSTALL_DATA) dir.info $(infodir)/dir.info ; \ else true ; fi @@ -795,7 +831,7 @@ -rm -f *.a TEMP errs core *.o *~ \#* TAGS *.E local-distclean: - -rm -f Makefile config.status + -rm -f Makefile config.status config.cache -if [ "$(TARGET_SUBDIR)" != "." ]; then \ rm -rf $(TARGET_SUBDIR); \ else true; fi @@ -817,7 +853,7 @@ @dir=`echo $@ | sed -e 's/clean-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) clean); \ else \ @@ -827,9 +863,10 @@ .PHONY: $(CLEAN_TARGET_MODULES) $(CLEAN_TARGET_MODULES): @dir=`echo $@ | sed -e 's/clean-target-//'`; \ + rm -f $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/tmpmulti.out; \ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) clean); \ else \ @@ -849,7 +886,7 @@ # Installation targets. .PHONY: install uninstall source-vault binary-vault vault-install -install: $(INSTALL_TARGET) +install: $(INSTALL_TARGET) install-info uninstall: @echo "the uninstall target is not supported in this tree" @@ -881,9 +918,9 @@ fi # inet-install is used because the I*Net wants DejaGNU installed but -# not built. +# not built. Similarly, gzip is built but not installed. inet-install: - $(MAKE) INSTALL_MODULES="`echo $(INSTALL_MODULES) | sed -e 's/install-dejagnu//'`" install + $(MAKE) INSTALL_MODULES="`echo $(INSTALL_MODULES) | sed -e 's/install-dejagnu//' -e 's/install-gzip//'`" install # install-no-fixedincludes is used because Cygnus can not distribute # the fixed header files. @@ -908,7 +945,7 @@ touch gcc/stmp-fixinc gcc/include/fixed; \ rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd` ; export srcroot; \ + s=`cd $(srcdir); pwd` ; export s; \ $(SET_LIB_PATH) \ (cd ./gcc; \ $(MAKE) $(GCC_FLAGS_TO_PASS) install); \ @@ -927,7 +964,7 @@ @dir=`echo $@ | sed -e 's/all-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) all); \ else \ @@ -944,7 +981,7 @@ dir=`echo $@ | sed -e 's/check-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \ else \ @@ -956,7 +993,7 @@ @dir=`echo $@ | sed -e 's/check-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \ else \ @@ -970,7 +1007,7 @@ @dir=`echo $@ | sed -e 's/install-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \ else \ @@ -982,13 +1019,33 @@ .PHONY: $(CONFIGURE_TARGET_MODULES) $(CONFIGURE_TARGET_MODULES): @dir=`echo $@ | sed -e 's/configure-target-//'`; \ - if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + if [ -d $(TARGET_SUBDIR)/$${dir} ]; then \ + r=`pwd`; export r; \ + $(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/$${dir}/tmpmulti.out 2> /dev/null; \ + if [ -s $(TARGET_SUBDIR)/$${dir}/tmpmulti.out ]; then \ + if [ -f $(TARGET_SUBDIR)/$${dir}/multilib.out ]; then \ + if cmp $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/tmpmulti.out > /dev/null; then \ + rm -f $(TARGET_SUBDIR)/$${dir}/tmpmulti.out; \ + else \ + echo "Multilibs changed for $${dir}, reconfiguring"; \ + rm -f $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/Makefile; \ + mv $(TARGET_SUBDIR)/$${dir}/tmpmulti.out $(TARGET_SUBDIR)/$${dir}/multilib.out; \ + fi; \ + else \ + mv $(TARGET_SUBDIR)/$${dir}/tmpmulti.out $(TARGET_SUBDIR)/$${dir}/multilib.out; \ + fi; \ + fi; \ + fi; exit 0 # break command into two pieces + @dir=`echo $@ | sed -e 's/configure-target-//'`; \ + if [ ! -d $(TARGET_SUBDIR) ]; then \ + true; \ + elif [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ true; \ elif echo " $(TARGET_CONFIGDIRS) " | grep " $${dir} " >/dev/null 2>&1; then \ if [ -d $(srcdir)/$${dir} ]; then \ [ -d $(TARGET_SUBDIR)/$${dir} ] || mkdir $(TARGET_SUBDIR)/$${dir};\ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ AR="$(AR_FOR_TARGET)"; export AR; \ AS="$(AS_FOR_TARGET)"; export AS; \ @@ -998,6 +1055,7 @@ CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \ DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \ LD="$(LD_FOR_TARGET)"; export LD; \ + LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \ NM="$(NM_FOR_TARGET)"; export NM; \ RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \ echo Configuring in $(TARGET_SUBDIR)/$${dir}; \ @@ -1013,7 +1071,7 @@ esac; \ if [ "$(srcdir)" = "." ] ; then \ if [ "$(TARGET_SUBDIR)" != "." ] ; then \ - if $(SHELL) $${srcroot}/symlink-tree $${topdir}/$${dir} "no-such-file" ; then \ + if $(SHELL) $$s/symlink-tree $${topdir}/$${dir} "no-such-file" ; then \ if [ -f Makefile ]; then \ if $(MAKE) distclean; then \ true; \ @@ -1033,14 +1091,14 @@ libsrcdir="."; \ else \ srcdiroption="--srcdir=$${topdir}/$${dir}"; \ - libsrcdir="$${srcroot}/$${dir}"; \ + libsrcdir="$$s/$${dir}"; \ fi; \ if [ -f $${libsrcdir}/configure ] ; then \ $(SHELL) $${libsrcdir}/configure \ $(CONFIG_ARGUMENTS) $${srcdiroption} \ --with-target-subdir="$(TARGET_SUBDIR)"; \ else \ - $(SHELL) $${srcroot}/configure \ + $(SHELL) $$s/configure \ $(CONFIG_ARGUMENTS) $${srcdiroption} \ --with-target-subdir="$(TARGET_SUBDIR)"; \ fi; \ @@ -1058,7 +1116,7 @@ @dir=`echo $@ | sed -e 's/all-target-//'`; \ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) all); \ else \ @@ -1072,7 +1130,7 @@ @dir=`echo $@ | sed -e 's/check-target-//'`; \ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $(TARGET_SUBDIR)/$${dir};$(MAKE) $(TARGET_FLAGS_TO_PASS) check);\ else \ @@ -1087,7 +1145,7 @@ @dir=`echo $@ | sed -e 's/install-target-//'`; \ if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $(TARGET_SUBDIR)/$${dir}; \ $(MAKE) $(TARGET_FLAGS_TO_PASS) install); \ @@ -1102,7 +1160,7 @@ @dir=`echo $@ | sed -e 's/all-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; \ $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) all); \ @@ -1117,7 +1175,7 @@ @dir=`echo $@ | sed -e 's/check-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; \ $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) check); \ @@ -1132,7 +1190,7 @@ @dir=`echo $@ | sed -e 's/install-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; \ $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install); \ @@ -1145,7 +1203,7 @@ all-gcc: @if [ -f ./gcc/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) all); \ else \ @@ -1156,7 +1214,7 @@ all-bootstrap: @if [ -f ./gcc/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) bootstrap); \ else \ @@ -1167,7 +1225,7 @@ check-gcc: @if [ -f ./gcc/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) check); \ else \ @@ -1178,7 +1236,7 @@ install-gcc: @if [ -f ./gcc/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) install); \ else \ @@ -1194,7 +1252,7 @@ @dir=`echo $@ | sed -e 's/install-//'`; \ if [ -f ./$${dir}/Makefile ] ; then \ r=`pwd`; export r; \ - srcroot=`cd $(srcdir); pwd`; export srcroot; \ + s=`cd $(srcdir); pwd`; export s; \ $(SET_LIB_PATH) \ (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \ else \ @@ -1207,10 +1265,12 @@ # This is a list of inter-dependencies among modules. all-apache: all-autoconf: all-m4 +all-bash: all-bfd: all-binutils: all-libiberty all-opcodes all-bfd all-flex all-byacc all-byacc: all-cvs: +all-db: all-dejagnu: all-tcl all-expect all-tk all-diff: all-libiberty all-emacs: @@ -1220,6 +1280,7 @@ all-target-examples: configure-target-examples all-expect: all-tcl all-tk all-fileutils: all-libiberty +all-findutils: all-find: all-flex: all-libiberty all-byacc all-gas: all-libiberty all-opcodes all-bfd @@ -1240,6 +1301,7 @@ all-indent: all-inet: all-tcl all-send-pr all-perl all-ispell: all-emacs19 +all-itcl: all-tcl all-tk all-ld: all-libiberty all-bfd all-opcodes all-byacc all-flex configure-target-libg++: $(ALL_GCC) configure-target-librx all-target-libg++: configure-target-libg++ all-gas all-ld all-gcc all-target-libiberty all-target-newlib all-target-libio all-target-librx all-target-libstdc++ @@ -1268,6 +1330,7 @@ all-send-pr: all-prms all-shellutils: all-sim: all-libiberty all-bfd all-opcodes +all-sn: all-tcl all-tk all-itcl all-db all-tar: all-libiberty all-tcl: all-tclX: all-tcl all-tk @@ -1277,7 +1340,7 @@ all-tgas: all-libiberty all-bfd all-opcodes all-time: all-wdiff: -all-target-winsup: all-target-newlib all-target-libiberty configure-target-winsup +all-target-winsup: all-target-newlib all-target-libiberty all-target-librx all-target-libio configure-target-winsup configure-target-winsup: configure-target-newlib all-uudecode: all-libiberty configure-target-libiberty: $(ALL_GCC) @@ -1292,7 +1355,8 @@ $(exec_prefix) .PHONY: install-dirs install-dirs: - @for i in $(MAKEDIRS) ; do \ + @for i in .. $(MAKEDIRS) ; do \ + if [ x$$i != x.. ]; then \ echo Making $$i... ; \ parent=`echo $$i | sed -e 's@/[^/]*$$@@' | sed -e 's@^$$@/@'`; \ if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi ; \ @@ -1305,9 +1369,9 @@ else \ true ; \ fi ; \ + else true; fi; \ done - dir.info: do-install-info if [ -f $(srcdir)/texinfo/gen-info-dir ] ; then \ $(srcdir)/texinfo/gen-info-dir $(infodir) $(srcdir)/texinfo/dir.info-template > dir.info.new ; \ @@ -1342,13 +1406,13 @@ # distribution (perhaps it would be better to include it anyway). DEVO_SUPPORT= README Makefile.in configure configure.in \ config.guess config.sub config move-if-change \ - mpw-README mpw-build.in mpw-config.in mpw-configure \ + mpw-README mpw-build.in mpw-config.in mpw-configure mpw-install \ COPYING COPYING.LIB install.sh config-ml.in symlink-tree # Files in devo/etc used in any net release. # ChangeLog omitted because it may refer to files which are not in this # distribution (perhaps it would be better to include it anyway). -ETC_SUPPORT= Makefile.in cfg-paper.texi configure.in configure.man \ +ETC_SUPPORT= Makefile.in cfg-paper.texi configure configure.in configure.man \ configure.texi standards.texi make-stds.texi \ configure.info* standards.info* cfg-paper.info* @@ -1356,7 +1420,7 @@ # this macro. SUPPORT_FILES = list-of-support-files-for-tool-in-question # Files where "byacc" (Cygnus version) should be changed to "bison -y" (FSF). -DISTBISONFILES= binutils/Makefile.in gas/Makefile.in gdb/Makefile.in +DISTBISONFILES= binutils/Makefile.in gas/Makefile.in gdb/Makefile.in ld/Makefile.in .PHONY: taz @@ -1422,24 +1486,28 @@ ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util ; \ else true; fi chmod og=u `find . -print` - (VER=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'`; \ - echo "==> Making $(TOOL)-$$VER.tar.gz"; \ - rm -f $(TOOL)-$$VER; ln -s proto-toplev $(TOOL)-$$VER; \ - tar cfh - $(TOOL)-$$VER \ - | $(GZIPPROG) -v -9 >$(TOOL)-$$VER.tar.gz ) + $(MAKE) -f Makefile.in do-tar-gz TOOL=$(TOOL) \ + VER=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'` + +do-tar-gz: + echo "==> Making $(TOOL)-$(VER).tar.gz" + -rm -f $(TOOL)-$(VER) + ln -s proto-toplev $(TOOL)-$(VER) + tar cfh $(TOOL)-$(VER).tar $(TOOL)-$(VER) + $(GZIPPROG) -v -9 $(TOOL)-$(VER).tar TEXINFO_SUPPORT= texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo DIST_SUPPORT= $(DEVO_SUPPORT) $(TEXINFO_SUPPORT) .PHONY: gas.tar.gz -GAS_SUPPORT_DIRS= bfd include libiberty opcodes make-all.com setup.com +GAS_SUPPORT_DIRS= bfd include libiberty opcodes setup.com makefile.vms gas.tar.gz: $(DIST_SUPPORT) $(GAS_SUPPORT_DIRS) gas $(MAKE) -f Makefile.in taz TOOL=gas \ SUPPORT_FILES="$(GAS_SUPPORT_DIRS)" # The FSF "binutils" release includes gprof and ld. .PHONY: binutils.tar.gz -BINUTILS_SUPPORT_DIRS= bfd gas include libiberty opcodes ld gprof make-all.com setup.com +BINUTILS_SUPPORT_DIRS= bfd gas include libiberty opcodes ld gprof setup.com makefile.vms binutils.tar.gz: $(DIST_SUPPORT) $(BINUTILS_SUPPORT_DIRS) binutils $(MAKE) -f Makefile.in taz TOOL=binutils \ SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS) makeall.bat configure.bat" diff -urN binutils-2.7/README binutils-2.8/README --- binutils-2.7/README Thu Jul 4 12:21:53 1996 +++ binutils-2.8/README Wed Apr 30 12:57:43 1997 @@ -4,7 +4,7 @@ debuggers, etc., plus their support routines, definitions, and documentation. If you are receiving this as part of a GDB release, see the file gdb/README. -If with a gas release, see gas/README; if with a libg++ release, +If with a binutils release, see binutils/README; if with a libg++ release, see libg++/README, etc. That'll give you info about this package -- supported targets, how to use it, how to report bugs, etc. @@ -19,7 +19,7 @@ then do: make install -If the configure script can't determine your type of computer, give it +(If the configure script can't determine your type of computer, give it the name as an argument, for instance ``./configure sun4''. You can use the script ``config.sub'' to test whether a name is recognized; if it is, config.sub translates it to a triplet specifying CPU, vendor, @@ -46,5 +46,5 @@ COPYING.LIB in the various directories, for a description of the GNU General Public License terms under which you can copy the files. -REPORTING BUGS: Again, see gdb/README, gas/README, etc., for info on where and -how to report problems. +REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info +on where and how to report problems. diff -urN binutils-2.7/bfd/COPYING binutils-2.8/bfd/COPYING --- binutils-2.7/bfd/COPYING Thu Jul 4 12:16:46 1996 +++ binutils-2.8/bfd/COPYING Wed Apr 30 12:55:43 1997 @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -279,7 +279,7 @@ END OF TERMS AND CONDITIONS - Appendix: How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -305,7 +305,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Also add information on how to contact you by electronic and paper mail. diff -urN binutils-2.7/bfd/ChangeLog binutils-2.8/bfd/ChangeLog --- binutils-2.7/bfd/ChangeLog Wed Jul 10 12:47:14 1996 +++ binutils-2.8/bfd/ChangeLog Wed Apr 30 12:55:44 1997 @@ -1,6 +1,2257 @@ -Wed Jul 10 11:19:43 1996 Ian Lance Taylor +Wed Apr 30 12:27:03 1997 Ian Lance Taylor - * Released binutils 2.7. + * elf.c (copy_private_bfd_data): Cast csecs to avoid sign + extension problems. + +Tue Apr 22 12:06:08 1997 Ian Lance Taylor + + * Makefile.in (do_maintainer_clean): Don't remove bfd-in2.h. + +Mon Apr 21 11:21:31 1997 Andreas Schwab + + * elf32-m68k.c: Follow the last changes in elf32-i386.c: + (struct elf_m68k_pcrel_relocs_copied, struct + elf_m68k_link_hash_entry, struct elf_m68k_link_hash_table, + elf_m68k_link_hash_traverse, elf_m68k_hash_table, + elf_m68k_link_hash_newfunc, elf_m68k_link_hash_table_create, + elf_m68k_discard_copies, bfd_elf32_bfd_link_hash_table_create): + New definitions. + (elf_m68k_check_relocs): If linking with -Bsymbolic, don't copy + PC relative relocs for a global symbol defined in a regular + object, and count the number of PC relative relocs copied for any + global symbol. + (elf_m68k_size_dynamic_sections): If linking with -Bsymbolic, + traverse with elf_m68k_discard_copies. + +Sat Apr 19 22:50:14 1997 Ian Lance Taylor + + * elf32-i386.c (elf_i386_check_relocs): Only count PC relative + relocs. From Jamie Lokier . + +Thu Apr 17 13:46:56 1997 Per Fogelstrom + + * configure.host (mips*-*-openbsd*): New target. + +Thu Apr 17 11:10:54 1997 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Only subtract the + section VMA from the symbol value if this is a fully linked file. + + * elf32-i386.c (struct elf_i386_pcrel_relocs_copied): Define. + (struct elf_i386_link_hash_entry): Define. + (struct elf_i386_link_hash_table): Define. + (elf_i386_link_hash_traverse): Define. + (elf_i386_hash_table): Define. + (elf_i386_link_hash_newfunc): New static function. + (elf_i386_link_hash_table_create): New static function. + (elf_i386_check_relocs): If linking with -Bsymbolic, don't copy + PC relative relocs for a global symbol defined in a regular + object, and count the number of PC relative relocs copied for any + global symbol. + (elf_i386_size_dynamic_sections): If linking with -Bsymbolic, + traverse with elf_i386_discard_copies. + (elf_i386_discard_copies): New static function. + (bfd_elf32_bfd_link_hash_table_create): Define. + + From Gordon W. Ross : + * aoutf1.h (MY_entry_is_text_address): Define if not defined. + (sunos4_aout_backend): Use MY_entry_is_text_address. + +Wed Apr 16 14:02:29 1997 Ian Lance Taylor + + From Gordon W. Ross : + * netbsd.h (N_SHARED_LIB): Define. + (SEGMENT_SIZE): Don't define. + * m68knetbsd.c (SEGMENT_SIZE): Don't define (revert change of + April 11). + * sparcnetbsd.c (TARGET_PAGE_SIZE): Define as 0x2000. + (SEGMENT_SIZE): Don't define. + + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Set .rela.bss size + to sizeof Rela structure, not sizeof Rel structure. From Gary + Thomas . + +Tue Apr 15 11:50:37 1997 Ian Lance Taylor + + * aout-target.h (MY(callback)): If entry_is_text_address, adjust + whenever entry is larger than text address, but only by whole + pages. From Gordon W. Ross . + + * elflink.h (elf_link_add_object_symbols): Don't call check_relocs + if this is a debugging section which we are stripping. + +Mon Apr 14 12:39:30 1997 Richard Henderson + + * elf64-alpha.c (elf64_alpha_object_p): Allocate the + alpha-specific target data struct. + +Mon Apr 14 11:45:46 1997 Ian Lance Taylor + + From Thomas Graichen : + * Makefile.in: Always use $(SHELL) when running move-if-change. + * configure.in: Use ${CONFIG_SHELL} when running $ac_config_sub. + * configure: Rebuild. + +Fri Apr 11 15:43:24 1997 Ian Lance Taylor + + * elfcode.h (elf_slurp_symbol_table): Only subtract the section + VMA if this is an executable file or a shared object. + + * targets.c (netbsd_core_vec): Declare. From Gordon W. Ross + . + + * libaout.h (struct aout_backend_data): Add entry_is_text_address + field. + * aout-target.h (SEGMENT_SIZE): Define to TARGET_PAGE_SIZE at the + start of the file. Remove uses later on which switch using + ifdef. + (MY(callback)): Handle entry_is_text_address. + (MY_entry_is_text_address): Define if not defined. + (MY(backend_data)): Initialize new field. + * aoutf1.h (sunos4_aout_backend): Likewise. + * i386aout.c (MY(backend_data)): Likewise. + * i386mach3.c (MY(backend_data)): Likewise. + * mipsbsd.c (MY(backend_data)): Likewise. + * sparclynx.c (sparclynx_aout_backend): Likewise. + * netbsd.h (SEGMENT_SIZE): Define if not defined. + (MY_entry_is_text_address): Define. + * m68knetbsd.c (SEGMENT_SIZE): Define as 0x20000. + +Fri Apr 11 11:57:15 1997 Niklas Hallqvist + + * config.bfd: (i[3456]86-*-openbsd*, m68*-*-openbsd*, + mips*el*-*-openbsd*, mips*-*-openbsd*, ns32k-*-openbsd*, + powerpc-*-*bsd*, sparc-*-openbsd*): New targets. + * configure.in (i[3456]86-*-openbsd*, mips*-*-openbsd*, + m68*-*-openbsd*, ns32k-*-openbsd*, powerpc-*-*bsd*, + sparc-*-openbsd*): New targets. + * configure: Rebuild. + +Tue Apr 8 18:09:29 1997 Jamie Lokier + + * stabs.c (struct stab_section_info): New field + `cumulative_skips'. + (_bfd_link_section_stabs): Fill the above array. + (_bfd_stab_section_offset): Use `cumulative_skips' to + speed up offset calculation. + +Mon Apr 7 16:47:09 1997 Ian Lance Taylor + + * configure.host: Set SHLIB_LIBS. + * configure.in: Substitute SHLIB_LIBS. + * configure: Rebuild. + * Makefile.in (SHLIB_LIBS): New variable. + ($(SHLIB)): Use $(SHLIB_LIBS). + +Fri Apr 4 11:37:15 1997 Ian Lance Taylor + + * configure.in: Update file names for bfd_elf32_mn10[23]00_vec. + Correct CPU file names for mn10[23]00. + * configure: Rebuild. + + * bfd.c (bfd_record_phdr): Cast count to size_t before + subtraction. + + * ppcboot.c (ppcboot_set_arch_mach): Make static. + (ppcboot_bfd_print_private_bfd_data): Likewise. + +Thu Apr 3 11:51:54 1997 Ian Lance Taylor + + * VERSION: Set to 2.8. + + * elf32-ppc.c (ppc_elf_check_relocs): Don't check SEC_ALLOC when + deciding whether to copy a reloc into a shared object. + (ppc_elf_relocate_section): Likewise. Relocate R_PPC_RELATIVE + relocs in unallocated sections. + * elf32-sparc.c (elf32_sparc_relocate_section): Relocate + R_SPARC_RELATIVE relocs in unallocated sections. + +Wed Apr 2 16:19:41 1997 Mike Meissner + + * elf32-ppc.c (ppc_elf_check_relocs): Undo March 26 change and + always create got section so that the _GLOBAL_OFFSET_TABLE_ label + is always created. + +Wed Apr 2 10:49:07 1997 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Let a common symbol + override an uninitialized symbol from a shared library with a + smaller size. + + * elf-m10200.c: Rename from elf32-mn10200.c. + * elf-m10300.c: Rename from elf32-mn10300.c. + * cpu-m10200.c: Rename from cpu-mn10200.c + * cpu-m10300.c: Rename from cpu-mn10300.c + * Makefile.in: Update accordingly. + + * elf32-mips.c (elf_mips_ctor64_howto): New static variable. + (elf_mips_isa): Move to earlier in file. + (mips_reloc_map): Remove BFD_RELOC_CTOR entry. + (bfd_elf32_bfd_reloc_type_lookup): Handle BFD_RELOC_CTOR + specially. + + * elf32-mips.c (mips16_jump_reloc): Print a warning rather than + calling abort. + +Tue Apr 1 16:18:05 1997 Klaus Kaempf + + * configure.com: New file. + * config.h-vms: Remove file. + * makefile.vms: Update for new configure scheme. + +Mon Mar 31 23:28:39 1997 H.J. Lu + + * libcoff-in.h (ppc_allocate_toc_section): Declare. + (ppc_process_before_allocation): Declare. + * libcoff.h: Rebuild. + + * coffcode.h (coff_mkobject_hook): Declare if not a macro. + +Mon Mar 31 16:29:50 1997 Joel Sherrill + + * config.bfd (hppa*-*-rtems*): New target, like hppa-*-*elf*. + +Mon Mar 31 16:11:35 1997 Ian Lance Taylor + + * coff-a29k.c (coff_a29k_relocate_section): Don't use symndx as a + symbol index for a R_IHCONST reloc. + +Mon Mar 31 15:40:59 1997 Philippe De Muyter + + * targmatch.sed: Do not use \(\) recursively. + +Fri Mar 28 14:44:08 1997 H.J. Lu + + * m68klinux.c (MACHTYPE_OK): Define. + * i386linux.c (MACHTYPE_OK): Define. + +Fri Mar 28 11:56:15 1997 Ian Lance Taylor + + From David S. Miller and H.J. Lu + : + * sparclinux.c: New file. + * bfd-in.h (bfd_sparclinux_size_dynamic_sections): Declare. + * bfd-in2.h: Rebuild. + * config.bfd (sparc-*-linuxaout*, sparc-*-linux*): New targets. + * configure.in (sparclinux_vec): Add to list of vectors. + * configure: Rebuild. + * targets.c (sparclinux_vec): Declare. + (bfd_target_vector): Add sparclinux_vec. + * Makefile.in: Rebuild dependencies. + (BFD32_BACKENDS): Add sparclinux.o. + (BFD32_BACKENDS_CFILES): Add sparclinux.c. + + * coff-mips.c (mips_ecoff_backend_data): Initialize new + bfd_coff_backend_data field. + * coff-alpha.c (alpha_ecoff_backend_data): Likewise. + + * config.bfd: Add bfd_elf64_{big,little}mips_vec to targ_selvecs + for mips*el*-*-linux* and mips*-*-linux*. From H.J. Lu + and Ralf Baechle . + + * bfd.c: Include "libiberty.h". + (strerror): Don't declare. + (bfd_errmsg): Call xstrerror rather than strerror. + +Thu Mar 27 12:55:42 1997 Ian Lance Taylor + + * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Generate a COPY + reloc even if the symbol is in the .bss section. + * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise. + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise. + * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise. + + * coffcode.h (bfd_coff_backend_data): Add new field + _bfd_coff_default_section_alignment_power. + (bfd_coff_default_section_alignment_power): Define. + (bfd_coff_std_swap_table): Initialize new field. + * libcoff.h: Rebuild. + * cofflink.c (coff_link_add_symbols): Limit alignment of a common + symbol to the default section alignment. + + * COPYING: Update FSF address. + +Wed Mar 26 14:50:20 1997 Ian Lance Taylor + + * elflink.c (_bfd_elf_create_linker_section): Don't set + bss_section and rel_section from existing sections. + + * elf32-ppc.c (ppc_elf_check_relocs): Only create the got section + if it is needed. + +Tue Mar 25 22:26:56 1997 Stu Grossman (grossman@critters.cygnus.com) + + * aoutx.h (some_aout_object_p): Change executable test to fix + problems with embedded a.out systems. + +Tue Mar 25 14:35:37 1997 Ian Lance Taylor + + * stabs.c (_bfd_stab_section_offset): New function. + * libbfd-in.h (_bfd_stab_section_offset): Declare. + * libbfd.h: Rebuild. + * elf32-i386.c (elf_i386_relocate_section): Adjust the offset of a + stab reloc. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-mips.c (mips_elf_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. + * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. + + * stabs.c (_bfd_link_section_stabs): Copy over the first header + symbol. Check for memory allocation failure of *psinfo. + (_bfd_write_section_stabs): Add psinfo parameter. Change all + callers. Set the value of the header symbol. + * libbfd-in.h (_bfd_write_section_stabs): Update declaration. + * libbfd.h: Rebuild. + +Mon Mar 24 13:41:00 1997 Ian Lance Taylor + + * targmatch.sed: Use the hold space to put the #ifdef around the + the string constant. + * targets.c (UNSUPPORTED_TARGET): Don't define. + (find_target): Don't check for UNSUPPORTED_TARGET. + (bfd_set_default_target): Don't try to optimize by checking for + default. + + * Makefile.in: Rebuild dependencies. + (ALL_MACHINES_CFILES): Add cpu-m32r.c. + (BFD32_BACKENDS_CFILES): Add elf32-m32r.c. + (elf32-m32r.o): Remove explicit target. + + * config.bfd: Don't set targ_underscore for i[3456]86-*-gnu* or + i[3456]86-*-linux*. + + * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Don't + count section symbols for sections that were created by the + linker, or are not allocatable or not loadable. + (elf32_sparc_finish_dynamic_sections): Output output section + symbols for section for which we made space for them. + +Fri Mar 21 13:08:26 1997 Ian Lance Taylor + + * elf32-sparc.c (elf32_sparc_size_dynamic_sections): If there is + no .rela.plt section, don't output a DT_PLTGOT dynamic entry. + +Fri Mar 21 12:36:46 1997 Doug Evans + + * elf32-m32r.c (m32r_elf_howto_table): Use special function for LO16. + (m32r_hi16_list): New static local. + (m32r_elf_hi16_reloc): Don't perform reloc, just queue it up. + (m32r_elf_do_hi16_reloc): Delete. + (m32r_elf_relocate_hi16): New function. + (m32r_elf_lo16_reloc): New function. + (m32r_elf_relocate_section): For HI16 relocs, scan for corresponding + LO16 reloc. + + Mon Mar 10 16:03:31 1997 Doug Evans + + * elf32-m32r.c (m32r_elf_create_linker_section): Delete. + (m32r_elf_add_symbol_hook): Rewrite _SDA_BASE_ support. + (m32r_elf_final_sda_base): New function. + (m32r_elf_relocate_section): Rewrite sdata support. + (m32r_elf_finish_dynamic_sections): Delete. + +Thu Mar 20 12:39:02 1997 Ian Lance Taylor + + Based on patches from Philippe De Muyter . + * coff-svm68k.c: New file. Just defines some macros and includes + coff-m68k.c. + * coff-m68k.c: Add functions to handle common addends, moved in + from cf-m68klynx.c. Control them using COFF_COMMON_ADDEND macro. + Control whether relocs are visible using STATIC_RELOCS. + * cf-m68klynx.c: Simplify greatly: just define macros to control + coff-m68k.c. + * coff-aux.c: Likewise. Just leave add_one_symbol routine. + * targets. (m68ksysvcoff_vec): Declare. + (bfd_target_vector): Add m68ksysvcoff_vec. + * config.bfd (m68*-motorola-sysv*): New target. + * configure.in (m68ksysvcoff_vec): New vector. + * configure: Rebuild. + * Makefile.in: Rebuild dependencies. + (BFD32_BACKENDS): Add coff-svm68k.o. + (BFD32_BACKENDS_CFILES): Add coff-svm68k.c. + + * binary.c (binary_set_section_contents): Don't get misled if the + first section is not loadable. From Matthew L. Martin + . + + * elflink.h (elf_bfd_final_link): Set the value of a section + symbol to the section address unless doing a relocateable link. + +Tue Mar 18 23:03:17 1997 Richard Henderson + + * elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Don't create + .plt entry if we've taken the function's address. + (elf64_alpha_merge_gots): Merge collected flags info as well. + +Tue Mar 18 22:40:09 1997 H.J. Lu + + * Many files: Add function prototypes. + * cpu-m68k.c (bfd_default_scan_num_mach): Don't declare. + * ecofflink.c: Include "libcoff.h" and "libecoff.h". + * elf32-ppc.c (ppc_elf_fake_sections): Make static. + * opncls.c (bfd_openstreamr): Change stream parameter to PTR. + * peicode.h: Change several void * parameters to PTR. + * srec.c (srec_get_symbol_info): Make static. + * syms.c (bfd_symbol_is_absolute): Remove. + * Makefile.in: Rebuild dependencies. + +Tue Mar 18 12:58:08 1997 Ian Lance Taylor + + * elf32-m32r.c (m32r_elf_is_local_label_name): Remove. + (bfd_elf32_bfd_is_local_label): Don't define. + + * xcofflink.c (_bfd_xcoff_bfd_final_link): Call bfd_malloc rather + than malloc. + +Mon Mar 17 11:32:53 1997 Ian Lance Taylor + + * bfd-in.h: Don't include obstack.h. + (struct bfd_hash_table): Change memory field to PTR. + * bfd.c (struct _bfd): Change memory field to PTR. + * bfd-in2.h: Rebuild. + * libbfd-in.h (bfd_release): Declare as function, don't define as + macro. + * libbfd.h: Rebuild. + * opncls.c: Include "objalloc.h" rather than "obstack.h". Use + objalloc routines rather than obstack routines. + (obstack_chunk_alloc, obstack_chunk_free): Don't define. + (getpagesize): Don't define. + (_bfd_new_bfd): Don't set _bfd_chunksize. + (bfd_openr): Free new bfd and objalloc on failure. + (bfd_fdopenr, bfd_openstreamr, bfd_openw): Likewise. + (bfd_alloc_size): Remove. + (bfd_release): New function. + * hash.c: Include "objalloc.h" rather than "obstack.h". Use + objalloc routines rather than obstack routines. + (obstack_chunk_alloc, obstack_chunk_free): Don't define. + * ecofflink.c: Include "objalloc.h" rather than "obstack.h". Use + objalloc routines rather than obstack routines. + (obstack_chunk_alloc, obstack_chunk_free): Don't define. + (struct accumulate): Change memory to struct objalloc *. + * liboasys.h (oasys_data_type): Remove oasys_obstack field. + * dep-in.sed: Don't remove obstack.h from dependency list. + * Makefile.in: Rebuild dependencies. + (BFD_H_DEPS): Remove obstack.h. + (install): Don't install obstack.h. + * Many files: Don't include "obstack.h". + * VERSION: Bump. + + * opncls.c (bfd_alloc_grow, bfd_alloc_finish): Remove. + * libbfd-in.h (bfd_alloc_grow, bfd_alloc_finish): Don't declare. + * libbfd.h: Rebuild. + * ieee.c (ieee_archive_p): Rewrite to not use bfd_alloc_grow. + * sunos.c (sunos_add_dynamic_symbols): Likewise. + * srec.c (srec_scan): Rewrite to not use obstack_1grow. + + * opncls.c (bfd_alloc): Rename from bfd_alloc_by_size_t. Remove + old version of bfd_alloc. + * libbfd-in.h (bfd_alloc_by_size_t): Don't declare. + * libbfd.h: Rebuild. + * Several files: Call bfd_alloc rather than bfd_alloc_by_size_t. + +Sat Mar 15 15:24:18 1997 Ian Lance Taylor + + * elf32-mips.c (mips_elf_is_local_label_name): Accept the generic + ELF local label syntax as well. + +Sat Mar 15 10:16:42 1997 Fred Fish + + * config.bfd (powerpc-*-beos*): New target. + * configure.in (powerpc-*-beos*): Add case that explicitly + does not set COREFILE for now. A future BeOS version is + expected to support core files. + * configure: Regenerate with autoconf. + +Fri Mar 14 16:43:22 1997 Ian Lance Taylor + + * elf32-mips.c (mips_elf_check_relocs): Give an error if CALL16 is + seen with a local symbol, rather than crashing. + + * elfcode.h (elf_slurp_symbol_table): Don't try to read the + version symbols if there aren't any. + +Thu Mar 13 14:08:53 1997 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Don't warn about type + or size changes because of a weak symbol. + + * cisco-core.c (SIGEMT): Define if not defined. + +Wed Mar 12 21:36:05 1997 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Use extsymoff when + setting ever. Sanity check the version number. Sort out copying + flags and other information when adding an indirect symbol. + (NAME(bfd_elf,size_dynamic_sections)): Preserve any dynamic + symbols added by the backend. Clear the entire contents of the + versym section. + (elf_export_symbol): Ignore indirect symbols. + (elf_link_output_extsym): Accept a section without an owner in an + assert. + * elfcode.h (elf_slurp_symbol_table): Add a sanity check on the + version count. Correct the allocation of x_versymp. + + * elf32-mips.c (mips_elf_add_symbol_hook): Don't set the owner of + the magic sections used for SHN_MIPS_TEXT and SHN_MIPS_DATA. + Don't return bfd_und_section_ptr when info->shared. + (mips_elf_final_link): Set the alignment of .rtproc to 4, not 12. + (mips_elf_create_dynamic_sections): Correct type: ^= for &=. + (mips_elf_check_relocs): Resolve an indirect symbol in + sym_hashes. + (mips_elf_finish_dynamic_symbol): Don't change SHN_ABS into + SHN_MIPS_TEXT or SHN_MIPS_DATA. + + * elf.c (bfd_elf_print_symbol): Tweak version output slightly. + +Tue Mar 11 01:38:36 1997 Ian Lance Taylor + + From Eric Youngdale : + * elf-bfd.h (ELF_LINK_FORCED_LOCAL): Define. + * elf.c (bfd_elf_print_symbol): Correct errors in last change. + * elflink.h (elf_link_add_object_symbols): Handle cases in which a + versioned symbol appears in both a regular and a shared object. + (elf_link_assign_sym_version): Set ELF_LINK_FORCED_LOCAL when + appropriate. Improve error message. + (struct elf_outext_info): Rename from elf_finfo_failed. Change + all uses. Add localsyms field. + (elf_bfd_final_link): When generating a shared library, call + elf_link_output_extsym to output all local symbols. + (elf_link_output_extsym): Handle symbols which were forced to + become local. + +Sun Mar 9 23:08:49 1997 Ian Lance Taylor + + From Eric Youngdale : + * elf-bfd.h (elf_symbol_type): Add version field. + * elfcode.h (elf_slurp_symbol_table): Set version field. + * elflink.h (elf_link_add_object_symbols): When creating an + indirect symbol for a default version symbol, set DEF_DYNAMIC if + appropriate. Set up an indirection from the nondefault version of + the symbol as well. + (NAME(bfd_elf,size_dynamic_sections)): Call + elf_link_assign_sym_version before checking whether there are any + versions. Always record the version name as a dynamic symbol. + Initialize counters. + (elf_link_assign_sym_version): After finding a version, see if a + symbol should be forced to local scope. Create a new version + definition if appropriate. + (elf_link_output_extsym): Correct indirect symbol handling. + * elf.c (bfd_elf_print_symbol): Print version information. + (bfd_section_from_shdr): Turn version sections into BFD sections. + (elf_fake_sections): Only copy cverdefs and cverrefs into sh_info + if sh_info is not already set. + (_bfd_elf_copy_private_section_data): Copy sh_info for version + sections. + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Tell + _bfd_stringtab_add to copy the name into permanent memory if + appropriate. + +Fri Mar 7 11:55:31 1997 H.J. Lu + + * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Fully parenthesize. + +Fri Mar 7 10:37:30 1997 Ian Lance Taylor + + * coffcode.h (bfd_coff_backend_data): Change + _bfd_coff_compute_section_file_positions to return a boolean + value. Change all callers. + (coff_compute_section_file_positions): Change return type to + boolean. If the size of the last section changed, then output a + zero byte at the end of the file. + * libcoff.h: Rebuild. + + * xcofflink.c (_bfd_xcoff_bfd_final_link): Always allocate space + for at least 6 output symbols. + (xcoff_write_global_symbol): When emitting TOC entry relocs, also + emit a TC csect to represent the space they take up. For an XO + symbol, just emit a reference, not a csect. + + * Makefile.in ($(SHLINK)): Just use ln -s, not ln -sf, since + Solaris doesn't like the combined options, and the -f is + unnecessary. + (stamp-tshlink, install): Likewise. + + * elf32-mips.c (mips_elf_relocate_section): Correct R_MIPS16_26 + handling when little endian. + +Thu Mar 6 13:51:51 1997 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c (mn10300_elf_final_link_relocate): New function. + (mn10300_elf_relocate_section): Likewise. + (elf_backend_relocate_section): Define. + + * elf32-mn10300.c (reloc_type): Remove PCREL{8,16,32}_{1,2}BYTE + relocs. Replace them with generic PCREL_{8,16,32} relocs. + (elf32_mn10300_howto_table): Likewise. + (elf32_mn10300_reloc_map): Likewise. + (bfd_elf32_mn10300_reloc): Delete unused function. + +Thu Mar 6 12:19:59 1997 Fred Fish + + * coffcode.h (coff_slurp_reloc_table): Pull duplicate declarations and + code fragment out of both legs of #ifdef RELOC_PROCESSING ... #endif + block. Use NULL for initializations of "ptr" rather than bare 0. + * coff-h8300.c: Fix typo in comment. + * coff-h8500.c: Ditto. + * coff-w65.c: Ditto + * coff-z8k.c: Ditto. + +Wed Mar 5 13:59:09 1997 Doug Evans + + * elf32-m32r.c (m32r_elf_do_10_pcrel_reloc): Fix overflow calc. + (m32r_elf_relax_section, m32r_elf_relax_delete_bytes, + m32r_elf_get_relocated_section_contents): First pass at relax support. + +Mon Mar 3 13:27:09 1997 Ulrich Drepper + + * elflink.h (elf_link_add_object_symbols): Use correct sh_size + entry for reading verdef records. + Use correct braces for computing increments of extverdaux and + exteverdef record pointers. + +Sun Mar 2 16:25:35 1997 Ian Lance Taylor + + * elflink.h (elf_link_find_version_dependencies): Check that + DEF_REGULAR is not set as well as checking that DEF_DYNAMIC is + set. + +Fri Feb 28 15:06:45 1997 Ian Lance Taylor + + * targets.c (bfd_default_vector): Make non-const. + (find_target): New static function, broken out of + bfd_find_target. + (bfd_set_default_target): New function. + (bfd_find_target): Call find_target. When defaulting, use + bfd_default_vector[0] if it is not NULL. + * libbfd-in.h (bfd_default_vector): Adjust declaration. + * bfd-in2.h, libbfd.h: Rebuild. + + * syms.c (bfd_is_local_label): Return false if the symbol has no + name. + * coff-i960.c (coff_i960_is_local_label_name): New function. + (coff_bfd_is_local_label_name): Define. + * coff-m68k.c (m68k_coff_is_local_label_name): New function. + (coff_bfd_is_local_label_name): Define. + * coff-rs6000.c (xcoff_is_local_label_name): New function. + (coff_bfd_is_local_label_name): Define. + * elf.c (_bfd_elf_is_local_label_name): Treat symbols beginning + with .. or _.L_ as local. + * elf32-i386.c (elf_i386_is_local_label_name): New function. + (bfd_elf32_bfd_is_local_label_name): Define. + * evax-alpha.c (evax_bfd_is_local_label_name): Treat symbols + beginning with $ as local. + +Thu Feb 27 18:36:23 1997 Ian Lance Taylor + + * aoutx.h (aout_link_write_symbols): Use bfd_is_local_label_name + rather than comparing against info->lprefix. + * cofflink.c (_bfd_coff_link_input_bfd): Likewise. + * elflink.h (elf_link_input_bfd): Likewise. + * linker.c (_bfd_generic_link_output_symbols): Likewise. + * xcofflink.c (xcoff_link_input_bfd): Likewise. + + * elfxx-target.h (bfd_elfNN_bfd_is_local_label_name): Define as + _bfd_elf_is_local_label_name if not already defined. + * elf.c (_bfd_elf_is_local_label_name): New function. + * elf-bfd.h (_bfd_elf_is_local_label_name): Declare. + + * coff-m88k.c (coff_bfd_is_local_label_name): Define. + (m88k_is_local_label_name): New static function. + + * coffcode.h (coff_bfd_is_local_label_name): Define as + _bfd_coff_is_local_label_name if not already defined. + * coffgen.c (_bfd_coff_is_local_label_name): New function. + * libcoff-in.h (_bfd_coff_is_local_label_name): Declare. + * libcoff.h: Rebuild. + + * targets.c (BFD_JUMP_TABLE_SYMBOLS): Change _bfd_is_local_label + to _bfd_is_local_label_name. + (bfd_target): Likewise. + * syms.c (bfd_is_local_label): Define as function, not macro. + (bfd_is_local_name): Define. + * libbfd.c (bfd_generic_is_local_label_name): Rename from + bfd_generic_is_local_label, and take a string rather than a + symbol. + * libbfd-in.h (_bfd_nosymbols_bfd_is_local_label): Don't define. + (_bfd_nosymbols_bfd_is_local_label_name): Define. + (bfd_generic_is_local_label): Don't declare. + (bfd_generic_is_local_label_name): Declare. + * bfd-in2.h, libbfd.h: Rebuild. + * All backends: Change local_label to local_label_name. + + * elf32-mips.c (struct mips_got_info): Add assigned_gotno field. + (mips_elf_relocate_got_local): Change return type to boolean. + Don't assume that the first zero entry is unassigned; instead, use + assigned_gotno. + (mips_elf_relocate_section): Check return value of + mips_elf_relocate_got_local. + (mips_elf_create_got_section): Initialize assigned_gotno field. + +Wed Feb 26 13:33:03 1997 Ian Lance Taylor + + * elflink.h (elf_link_input_bfd): Don't skip symbols from sections + that have no contents merely because linker_mark is not set. + +Tue Feb 25 18:51:35 1997 Stan Shebs + + * config.bfd (mips*-*-lnews*): New target. + * coff-mips.c (mips_relocate_section): Make assert compare + content byteorder instead of header byteorder. + (ecoff_biglittle_vec): New BFD, big-endian headers, little-endian + data. + * targets.c (bfd_target_vector): Add ecoff_biglittle_vec. + * configure.in (ecoff_biglittle_vec): Add case. + * configure: Update. + +Tue Feb 25 00:32:49 1997 Ian Lance Taylor + + * elf.c (elf_fake_sections): Use SHT_NOTE for any section whose + name begins with ".note". + (map_sections_to_segments): Add a PT_NOTE segment for any loadable + section whose name begins with ".note". + (get_program_header_size): Corresponding change. + + * elf32-mips.c (mips_elf_relocate_section): Check for misaligned + jal and for jal overflow. + +Mon Feb 24 17:53:14 1997 Ian Lance Taylor + + From Eric Youngdale : + * elflink.h (elf_link_add_archive_symbols): If a default symbol is + not found, try looking it up again without the version name. + (elf_link_add_object_symbols): Always link against the dynamic + symbol table of a dynamic object. When linking against a dynamic + object, include version strings in symbol names, and set up + version information. Add indirect symbols for default versions. + (elf_link_create_dynamic_sections): Add special version sections. + (struct elf_assign_sym_version_info): Define. + (struct elf_find_verdep_info): Define. + (NAME(bfd_elf,size_dynamic_sections)): Add verdefs parameter. Set + up version sections. + (elf_adjust_dynamic_symbol): Ignore indirect symbols. + (elf_link_find_version_dependencies): New static function. + (elf_link_assign_sym_version): New static function. + (elf_link_renumber_dynsyms): New static function. + (struct elf_final_link_info): Add symver_sec field. + (elf_bfd_final_link): Initialize finfo.symver_sec. Don't count + local symbols of a dynamic object. Handle DT_VER* constants. + (elf_link_output_extsym): Simplify BFD_ASSERT checking for a + dynamic object. Skip indirect symbols from ELF objects. Remove + the version name before choosing a hash bucket. Write out the + version information if appropriate. + (elf_link_input_bfd): Check for DYNAMIC, not ET_DYN. + * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration. + (bfd_elf64_size_dynamic_sections): Likewise. + * bfd-in2.h: Rebuild. + * elf-bfd.h (struct elf_link_hash_entry): Add verinfo field. + Change elf_link_hash_flags to unsigned short. + (ELF_LINK_HIDDEN): Define. + (struct elf_obj_tdata): Add fields dynversym_hdr, dynverref_hdr, + dynverdef_hdr, dynversym_section, dynverdef_section, + dynverref_section, cverdefs, cverrefs, verdef, verref. + (elf_dynversym, elf_dynverdef, elf_dynverref): Define. + (_bfd_elf_swap_verdef_in, _bfd_elf_swap_verdef_out): Declare. + (_bfd_elf_swap_verdaux_in, _bfd_elf_swap_verdaux_out): Declare. + (_bfd_elf_swap_verneed_in, _bfd_elf_swap_verneed_out): Declare. + (_bfd_elf_swap_vernaux_in, _bfd_elf_swap_vernaux_out): Declare. + (_bfd_elf_swap_versym_in, _bfd_elf_swap_versym_out): Declare. + (_bfd_elf_slurp_version_tables): Declare. + * elf.c (_bfd_elf_swap_verdef_in): New function. + (_bfd_elf_swap_verdef_out): Likewise. + (_bfd_elf_swap_verdaux_in, _bfd_elf_swap_verdaux_out): Likewise. + (_bfd_elf_swap_verneed_in, _bfd_elf_swap_verneed_out): Likewise. + (_bfd_elf_swap_vernaux_in, _bfd_elf_swap_vernaux_out): Likewise. + (_bfd_elf_swap_versym_in, _bfd_elf_swap_versym_out): Likewise. + (_bfd_elf_print_private_bfd_data): Add DT_VER* constants. Print + version information if there is any. + (_bfd_elf_link_hash_newfunc): Initialize verinfo field. + (bfd_section_from_shdr): Handle SHT_GNU_ver* section types. + (elf_fake_sections): Handle .gnu.version* section names. + (assign_section_numbers): Handle SHT_GNU_ver* section types. + (_bfd_elf_slurp_version_tables): New function. + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Don't include + version name in string entered in dynamic hash table. + * elfcode.h: Include fnmatch.h. + * elf32-i386.c (elf_i386_relocate_section): Handle a dynamic + symbol which was forced to become local. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. + * elf64-alpha.c (alpha_elf_dynamic_symbol_p): Likewise. + +Fri Feb 21 16:15:18 1997 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10200.c (mn10200_elf_final_link_relocate): Simplify + somewhat. + (mn10200_elf_relax_section): Correctly compute a symbol's value + when the symbol is local, but not in the same section as we are + relaxing. Implement abs24 -> abs16, imm24 -> imm16 and d24 -> d16 + relaxing. + +Fri Feb 21 13:55:14 1997 Doug Evans + + * elf32-m32r.c: Rewrite to use ELF backend linker. + Store lower 16 bits of addend in R_M32R_HI16_[SU]LO insns. + Add small data area support (R_M32R_SDA16). + * reloc.c: Document BFD_RELOC_M32R_SDA16. + * bfd-in2.h,libbfd.h: Regenerated. + +Thu Feb 20 23:50:31 1997 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10200.c (mn10200_elf_relax_section): New function. + (mn10200_elf_relax_delete_bytes): Likewise. + (mn10200_elf_symbol_address_p): Likewise. + (mn10200_elf_get_relocated_section_contents): Likewise. + (bfd_elf32_bfd_relax_section): Define. + (bfd_elf32_bfd_get_relocated_section_contents): Likewise. + + * elf32-mn10200.c (mn10200_elf_final_link_relocate): New function. + (mn10200_elf_relocate_section): Likewise. + (elf_backend_relocate_section): Define. + +Tue Feb 18 15:31:48 1997 Fred Fish + + * reloc.c (struct reloc_howto_struct): Fix typo in comment. + * bfd-in2.h: Regenerated. + +Tue Feb 18 11:41:00 1996 Dawn Perchik + + * sysdep.h: Don't define errno in MSVC if error.h is included. + +Mon Feb 17 11:28:40 1997 Ian Lance Taylor + + * hp300hpux.c (convert_sym_type): Don't convert a secondary common + symbol into a weak undefined symbol; leave it as a common symbol. + +Fri Feb 14 19:08:03 1997 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Don't issue a warning + about a symbol defined in a dynamic object if it has already been + defined in a regular object. + +Thu Feb 13 20:53:22 1997 Klaus Kaempf (kkaempf@progis.de) + + * makefile.vms: Add gcc flags to allow compiling with current gcc + snapshot + (targmatch.h): New dependency. + + * reloc.c (BFD_RELOC_ALPHA_CODEADDR): New relocation for + openVMS/Alpha. + * evax.h (ALPHA_R_CODEADDR): New relocation. + * evax-alpha.c (ALPHA_R_CODEADDR): 64 bit procedure relocation for + openVMS/Alpha. + * evax-etir.c (ALPHA_R_CODEADDR): Output object code for this + relocation. + * bfd-in2.h, libbfd.h: Rebuild. + + Restrict symbol length to 64 bytes, case preserving: + * evax-emh.c (_bfd_evax_write_emh): Remove case hacking. + * evax-misc.c (_bfd_evax_case_hack_symbol): Remove. + (_bfd_evax_length_hash_symbol): Added. + * evax-etir.c (_bfd_evax_write_etir): Call + _bfd_evax_length_hash_symbol before output of symbol. + * evax-egsd.c (_bfd_evax_write_egsd): Likewise. + * evax.h (flag_hash_long_names, flag_show_after_trunc): Remove. + + * evax-emh.c: Output filename to object file without path. + + * evax-egsd.c: New sections for local and global commons. + + * evax-alpha.c, evax-emh.c, evax-egsd.c, evax-etir.c, + evax-misc.c, evax.h: Remove 8 bit characters from copyright + notices. Replace AXP with Alpha. + +Wed Feb 12 18:10:30 1997 Ian Lance Taylor + + * sunos.c (sunos_create_dynamic_sections): We need the dynamic + sections if we are creating a shared library. + +Tue Feb 11 15:45:43 1997 Doug Evans + + * configure.host (i386-windows): Don't set host64=true. + +Tue Feb 11 15:27:32 1997 Ian Lance Taylor + + * elf32-mips.c (reloc_type): Add R_MIPS16_GPREL. + (elf_mips16_gprel_howto): New static variable. + (mips16_gprel_reloc): New static function. + (bfd_elf32_bfd_reloc_type_lookup): Handle BFD_RELOC_MIPS16_GPREL. + (mips_info_to_howto_rel): Handle R_MIPS16_GPREL. + (mips_elf_relocate_section): Handle R_MIPS16_GPREL. + * reloc.c (BFD_RELOC_MIPS16_GPREL): Define. + * bfd-in2.h, libbfd.h: Rebuild. + +Mon Feb 10 23:25:00 1997 Doug Evans + + * elf32-m32r.c (elf_m32r_howto_table): Change partial_inplace to true + for R_M32R_{16,32,24,HI16_ULO,HI16_SLO,LO16}. + +Fri Feb 7 12:39:11 1997 Ian Lance Taylor + + * elflink.h (elf_link_input_bfd): If we've discarded a section, + the output section will be the absolute section; don't print an + assertion message for that case when doing a relocateable link. + +Thu Feb 6 16:55:43 1997 Ian Lance Taylor + + * elf32-mips.c (FN_STUB, CALL_STUB, CALL_FP_STUB): Define. + (struct mips_elf_link_hash_entry): Add new fields fn_stub, + need_fn_sub, call_stub, and call_fp_stub. + (struct mips_elf_link_hash_table): Add field mips16_stubs_seen. + (mips_elf_link_hash_newfunc): Initialize new fields. + (mips_elf_link_hash_table_create): Likewise. + (mips_elf_relocate_section): Redirect relocations to use mips16 + stubs when appropriate. + (mips_elf_check_relocs): Attach stub sections to the appropriate + symbol. Set need_fn_stub when appropriate. + (mips_elf_always_size_sections): New static function. + (mips_elf_check_mips16_stubs): New static function. + (elf_backend_always_size_sections): Define. + * elf-bfd.h (struct elf_obj_tdata): Add local_stubs field. + + * elflink.h (elf_link_input_bfd): Discard local symbols that are + attached to sections which are not being included in the link. + +Wed Feb 5 13:20:17 1997 Ian Lance Taylor + + * cofflink.c (_bfd_coff_generic_relocate_section): Ignore the + symbol value when computing the addend for a pc_relative + pcrel_offset reloc. + +Mon Feb 3 11:54:06 1997 Ian Lance Taylor + + * cofflink.c (_bfd_coff_generic_relocate_section): If doing a + relocateable link, just skip pc_relative pcrel_offset relocs. + * coff-arm.c (coff_arm_rtype_to_howto): Return a different howto + structure for an ARM26 reloc which can be resolved. + (coff_arm_adjust_symndx): Only convert ARM26 to ARM26D if the + reloc can be resolved. + + * coff-h8300.c (h8300_reloc16_extra_cases): Correct off by one + error in overflow check for R_RELBYTE. + +Fri Jan 31 14:07:27 1997 Ian Lance Taylor + + * ieee.c (ieee_slurp_section_data): Pick up the start address. + From Mark Rasin . + + * aoutx.h (aout_link_write_symbols): Don't apply discard_l to + debugging symbols. + +Wed Jan 29 00:00:49 1997 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10200.c (reloc_type): Add 16bit pc-relative reloc. + (elf_mn10200_howto_table): Likewise. + (mn10200_reloc_map): Likewise. + +Mon Jan 27 12:07:35 1997 Doug Evans + + * reloc.c: Add relocs BFD_RELOC_M32R_{HI16_[US]LO,LO16}. + * bfd-in2.h, libbfd.h: Regenerated. + * elf32-m32r.c: Add support for them. + +Mon Jan 27 12:25:02 1997 Ian Lance Taylor + + * aout-arm.c (MY_swap_std_reloc_in): Remove unused r_length. + * elf32-ppc.c (ppc_elf_check_relocs): Remove unused plt. + * riscix.c (MY_final_link_callback): Define to dummy value. + + * elf32-i386.c (elf_i386_size_dynamic_sections): When checking for + relocations against the text segment, look up the output name of + the reloc section. + * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise. + * elf32-mips.c (mips_elf_size_dynamic_sections): Likewise. + * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. + * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Likewise. + * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise. + +Thu Jan 16 17:45:57 1997 Ian Lance Taylor + + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Change type of + auxiliary_filters parameter to be const char * const *. Accept a + NULL terminated array. + * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration. + (bfd_elf32_size_dynamic_sections): Update declaration. + * bfd-in2.h: Rebuild. + +Wed Jan 15 11:21:32 1997 Ian Lance Taylor + + * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Treat a + NOTYPE symbol in a text section as a FUNC symbol. + + * coffcode.h (coff_compute_section_file_positions): Force + relocbase to be aligned to COFF_DEFAULT_SECTION_ALIGNMENT_POWER. + +Tue Jan 14 08:46:33 1997 Doug Evans + + * libaout.h (machine_type): Reserve several values for sparclet. + +Mon Jan 6 13:28:35 1997 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10200.c (elf_mn10200_howto): Don't ever set partial-inplace. + Use bfd_elf_generic_reloc as special function for all relocs. + (bfd_elf32_mn10200_reloc): Remove unnecessary function. + + * elf32-mn10200.c (elf_mn10200_howto): Set pcrel_offset for + 24bit pc-relative reloc. + +Fri Jan 3 16:54:08 1997 Jeffrey A Law (law@cygnus.com) + + * reloc.c: Add BFD_RELOC_24. + * elf32-mn10200.c (enum reloc_type): Add 24bit and pcrel relocs. + (elf_mn10200_howto, mn10200_reloc_map): Corresponding changes. + * bfd-in2.h, libbfd.h: Rebuilt. + +Fri Jan 3 16:58:31 1997 Richard Henderson + + elf64-alpha multiple .got rewrite: + + * elf-bfd.h (struct elf_backend_data): Add always_size_sections entry. + (bfd_elf*_mkobject): Don't define here ... + * elfxx-target.h: ... but rather here. Default always_size_sections + hook to NULL. + * elf.c (elf_mkobject): Rename to bfd_elf_mkobject, since that was + what the #defines in elf-bfd.h transmuted it to anyway. + + * section.c: Add SEC_LINKER_CREATED flag. + * bfd-in2.h: Rebuild. + * elf32-i386.c (elf_i386_check_relocs): Add SEC_LINKER_CREATED to + relocation section flags. + (elf_i386_size_dynamic_sections): Use SEC_LINKER_CREATED instead of + SEC_IN_MEMORY to recognize generated bits. + * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_size_dynamic_sections): + Likewise. + * elf32-mips.c (mips_elf_final_link, mips_elf_create_dynamic_sections, + mips_elf_create_compact_rel_section, mips_elf_create_got_section, + mips_elf_check_relocs, mips_elf_size_dynamic_sections): Likewise. + * elf32-ppc.c (ppc_elf_create_linker_section, + ppc_elf_size_dynamic_sections): Likewise. + * elf32-sparc.c (elf32_sparc_check_relocs, + elf32_sparc_size_dynamic_sections): Likewise. + * elflink.c (_bfd_elf_create_got_section): Add SEC_LINKER_CREATED to + section flags. + (_bfd_elf_create_dynamic_sections): Likewise. + (_bfd_elf_make_linker_section_rela): Likewise. + * elflink.h (elf_link_create_dynamic_sections): Likewise. + (bfd_elf,size_dynamic_sections): Call the always_size_sections hook. + (elf_bfd_final_link): Use SEC_LINKER_CREATED instead of SEC_IN_MEMORY + to identify generated bits. + (elf_link_input_bfd): Likewise. + + * elf64-alpha.c: Rewrite everything touching relocations. + +Tue Dec 31 14:44:50 1996 Ian Lance Taylor + + * config.bfd (mips*el-*-linux*): New target. + (mips*-*-linux*): New target. + + * elf32-mips.c (_bfd_mips_elf_merge_private_bfd_data): Clean up. + Return a useful value. + + * Makefile.in (ALL_CFLAGS): Add -D_GNU_SOURCE. + + * configure.in: Check ac_cv_func_mmap_fixed_mapped, not + ac_cv_func_mmap. + * configure: Rebuild. + * configure.host: Use ac_cv_func_mmap_fixed_mapped instead of + ac_cv_func_mmap in bfd/configure.host. + + * elflink.h (NAME(bfd_elf,size_dynamic_sections)): Add + filter_shlib and auxiliary_filter_shlib parameters. + * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_AUXILIARY and + DT_FILTER. + * bfd-in.h (bfd_elf32_size_dynamic_sections): Update declaration. + (bfd_elf64_size_dynamic_sections): Likewise. + * bfd-in2.h: Rebuild. + +Mon Dec 30 18:48:52 1996 Ian Lance Taylor + + * xcofflink.c (xcoff_build_ldsyms): When exporting all defined + symbols, don't export a symbol which is defined by an object in an + archive which contains shared objects. + +Mon Dec 30 11:54:56 1996 Ian Lance Taylor + + * libbfd.c: Patch up the mmap code so that it is only built if BFD + is configured with --with-mmap. + +Fri Dec 27 20:56:41 1996 Fred Fish + + * TODO: Correct a misspelling. + +Fri Dec 27 11:48:12 1996 H.J. Lu + + * elflink.h (elf_buckets): Add some more values for larger + binaries. + +Thu Dec 26 18:36:54 1996 Ian Lance Taylor + + * Makefile.in (install): Move subdir_do out of conditional. From + Fred Fish . + +Wed Dec 18 10:04:30 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10200.c (enum reloc_type): Enable basic 8, 16, and + 32 bit relocs. + (elf_mn10200_howto_table): Likewise. + (mn10200_reloc_map): Likewise. + +Tue Dec 17 11:09:36 1996 Ian Lance Taylor + + * elf32-mips.c (mips_elf_add_symbol_hook): Add 1 to the value of a + mips16 symbol during the link. + (mips_elf_finish_dynamic_symbol): Subtract 1 from the value of a + mips16 symbol. + (mips_elf_link_output_symbol_hook): New static function. + (elf_backend_link_output_symbol_hook): Define. + + * elf.c (bfd_elf_print_symbol): Print the st_other field if it is + not zero. + +Mon Dec 16 14:38:39 1996 Ian Lance Taylor + + * elf.c (bfd_section_from_shdr): Don't check for reloc sections + against SEC_DEBUGGING sections here (revert patch of December 5). + * elfcode.h (elf_object_p): Check for them here, instead. + +Sun Dec 15 14:46:06 1996 Ian Lance Taylor + + * elfcode.h (elf_slurp_reloc_table): Add dynamic parameter. + * elf.c (_bfd_elf_canonicalize_reloc): Pass new argument to + slurp_reloc_table. + (_bfd_elf_get_dynamic_reloc_upper_bound): New function. + (_bfd_elf_canonicalize_dynamic_reloc): New function. + * elf-bfd.h (struct elf_size_info): Update declaration of + slurp_reloc_table. + (_bfd_elf_get_dynamic_reloc_upper_bound): Declare. + (_bfd_elf_canonicalize_dynamic_reloc): Declare. + * elfxx-target.h: Use new dynamic reloc routines by default. + * elf64-mips.c (mips_elf64_slurp_reloc_table): Add dynamic + parameter. + +Fri Dec 13 13:18:49 1996 Dan Wilder + + * coffcode.h (coff_set_flags): Use MC68KBCSMAGIC for bfd_arch_m68k + if NAMES_HAVE_UNDERSCORE is defined. + +Fri Dec 13 11:13:23 1996 Doug Evans + + * libaout.h (enum machine_type): Change M_SPARCLET from 142 to 131. + +Thu Dec 12 15:07:20 1996 Michael Meissner + + * elf32-ppc.c (ppc_elf_check_relocs): Move R_PPC_PLTREL24 into the + supported relocs. + +Thu Dec 12 14:55:41 1996 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Only add a weak + symbol if the real definition is in the dynamic symbol table. + After finding the real definition, then, if it is dynamic, add the + weak symbol to the dynamic symbol table. + + * coff-aux.c (coff_m68k_aux_link_add_one_symbol): Make static. + + * ppcboot.c (ppcboot_set_arch_mach): Don't define; it's a + function. + (ppcboot_bfd_print_private_bfd_data): Don't take the address of an + array. + +Tue Dec 10 23:23:52 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c (reloc_type): Remove big endian mn10300 reloc + variants. + (elf32_mn10300_howto_table, mn10300_reloc_map): Likewise. + (bfd_elf32_mn10300_reloc): Write data in little endian format. + * reloc.c: Remove mn10300 big endian relocs. + * bfd-in2.h, libbfd.h: Rebuilt. + + * elf32-mn10200.c: Update from elf32-mn10300.c. + +Fri Dec 6 15:18:05 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c (elf_symbol_leading_char): Define. + + * elf32-mn10300.c: Add some comments. + +Fri Dec 6 17:16:43 1996 Ian Lance Taylor + + * ihex.c (ihex_scan): Always initialize buf before jumping to + error_return. + (ihex_read_section): Likewise. + +Thu Dec 5 22:29:18 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c (elf_mn10300_howto_table): Don't set partial- + inplace for most relocs. + +Thu Dec 5 13:24:46 1996 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Calling check_relocs + even if SEC_ALLOC is not set. + * elf32-i386.c (elf_i386_check_relocs): Don't check SEC_ALLOC + when deciding whether to copy a reloc into a shared object. + (elf_i386_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_check_relocs): Likewise. + (elf32_sparc_relocate_section): Likewise. + * elf32-i386.c (elf_i386_check_relocs): Don't set SEC_ALLOC in a + reloc section if it is not set in the source section. + * elf32-sparc.c (elf32_sparc_check_relocs): Likewise. + * elf.c (bfd_section_from_shdr): Mark a reloc section associated + with a SEC_DEBUGGING section as SEC_DEBUGGING. + +Wed Dec 4 14:18:13 1996 Michael Meissner + + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): #if 0 code that + expects a .got.plt until we actually create it. + +Mon Dec 2 12:13:51 1996 Ian Lance Taylor + + * cofflink.c (_bfd_coff_generic_relocate_section): Print an error + message for bfd_reloc_outofrange, rather than aborting. From + Philippe De Muyter . + + * cofflink.c (_bfd_coff_final_link): If there aren't any relocs in + a relocateable link, don't try to process them. From Heinz Wrobel + . + +Mon Dec 2 00:39:24 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c (mn10300_info_howto): Renamed from + mn10300_info_howto_rel. Tweak reloc argument to be an + Elf32_Internal_Rela. + (USE_RELA): Define instead of USE_REL. + (elf_info_to_howto, elf_info_howto_rel): Corresponding changes. + +Sun Dec 1 00:18:59 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * configure.in, configure: Handle mips*-sgi-irix6*. + * irix-core.c (irix_core_core_file_p): Accept CORE_MAGICN32 + core files. + +Wed Nov 27 12:10:25 1996 Ian Lance Taylor + + * elf32-i386.c (elf_i386_relocate_section): Warn about a + relocation against a symbol defined in a section with no output + section. + +Tue Nov 26 11:07:31 1996 Ian Lance Taylor + + * aclocal.m4 (BFD_CC_FOR_BUILD): Don't require AC_C_CROSS. + * configure, config.in: Rebuild with autoconf 2.12. + + * elf-bfd.h (struct elf_link_hash_entry): Add other field. + * elf.c (_bfd_elf_link_hash_newfunc): Initialize other field. + (swap_out_syms): Set st_other from existing st_other field. + * elflink.h (elf_link_add_object_symbols): Store st_other in hash + table other field. + (elf_link_output_extsym): Set the other field from the global hash + table entry. + * elf32-mips.c (enum reloc_type): Add R_MIPS16_26. + (elf_mips16_jump_howto): New static variable. + (mips16_jump_reloc): New static function. + (bfd_elf32_bfd_reloc_type_lookup): Handle BFD_RELOC_MIPS16_JMP. + (mips_info_to_howto_rel): Handle R_MIPS16_26. + (mips_elf_relocate_section): Handle R_MIPS16_26. Handle R_MIPS_26 + to a mips16 symbol. + * reloc.c (BFD_RELOC_MIPS16_JMP): Add to list of relocs. + * bfd-in2.h, libbfd.h: Rebuild. + * cpu-mips.c (arch_info_struct): Add mips:16 entry. + +Mon Nov 25 11:23:32 1996 Ian Lance Taylor + + * configure.host: Use long long for mips-sgi-irix6*. + + * coffswap.h (coff_swap_scnhdr_out): Make line number overflow + only a warning. From Philippe De Muyter . + +Mon Nov 25 08:52:29 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c (bfd_elf32_mn10300_reloc): New function. + (enum reloc_type): Add more reloc types. + (elf32_mn10300_howto_table): Update for new reloc types. + (elf32_mn10300_reloc_map): Update for new reloc types. + * reloc.c: Add some new relocs for the mn10300 series. + * bfd-in2.h, libbfd.h: Rebuilt. + +Sat Nov 23 13:26:18 1996 Jeffrey A Law (law@cygnus.com) + + * som.c (setup_sections): Don't lose for a space which has + no data, but some symbols. + +Fri Nov 22 11:32:13 1996 Ian Lance Taylor + + * sunos.c (struct sunos_link_hash_table): Add got_needed field. + (sunos_link_hash_table_create): Initialize got_needed. + (sunos_create_dynamic_sections): Only set .got section size if it + is not already set. Set got_needed. + (bfd_sunos_size_dynamic_sections): Check got_needed. Only set + sdynptr, and only handle dynamic sections, if dynamic sections are + needed. + (sunos_scan_std_relocs): Pass false to create_dynamic_sections. + Initialize .got section. + (sunos_scan_ext_relocs): Likewise. + (sunos_write_dynamic_symbol): Set up PLT entry even if this is not + a dynamic symbol. + (sunos_finish_dynamic_link): Check got_needed. Only set up + dynamic linking information if needed. + +Thu Nov 21 10:31:31 1996 Rob Savoye (rob@cygnus.com) + + * config.bfd: Added VersaDOS format to the Ericsson configuration. + +Wed Nov 20 16:31:31 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-mn10300.c: Rough cut at relocs for the mn10300. + +Wed Nov 13 08:12:38 1996 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (elf32-d10v.o): Don't depend on elf/d10v.h + anymore. + +Tue Nov 12 13:30:00 1996 Dawn Perchik + + * filemode.c: Include sysdep.h. + * ihex.c: Add casts to eliminate compiler warnings. + * sunos.c: Add casts to eliminate compiler warnings. + +Mon Nov 11 10:37:02 1996 Michael Meissner + + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Create .got.plt + section. + (ppc_elf_check_relocs): Add support for R_PPC_LOCAL24PC. Make + appropriate relocations in the .so file if shared. + (ppc_elf_relocate_section): Ditto. + +Tue Oct 29 15:03:02 1996 Doug Evans + + * elf32-m32r.c (elf_m32r_howto_table, R_M32R_24): Use + complain_overflow_unsigned. + +Tue Oct 29 12:53:46 1996 Martin M. Hunt + + * elf32-d10v.c (elf_d10v_howto_table): Don't complain on + overflows for R_D10V_16 and R_D10V_18. + +Tue Oct 29 13:23:53 1996 Ian Lance Taylor + + * ieee.c (ieee_write_section_part): Use LMA rather than VMA. + (do_with_relocs): Likewise. + (do_as_repeat): Likewise. + (copy_expression): Likewise. + +Fri Oct 25 16:56:40 1996 Ian Lance Taylor + + * ieee.c (ieee_write_external_part): Correctly record whether + there is an external part. + +Thu Oct 24 09:08:47 1996 Stu Grossman (grossman@critters.cygnus.com) + + * aclocal.m4, configure: Set USE_BINARY_FOPEN for *-*-windows. + +Wed Oct 23 00:20:34 1996 Ian Lance Taylor + + * xcofflink.c (bfd_xcoff_import_symbol): Don't allocate ldsym. + Store import file index in ldindx. + (xcoff_build_ldsyms): Assume that ldsym was not previously + allocated. For an imported symbol, copy ldindx into l_ifile. + +Tue Oct 22 17:22:43 1996 Ian Lance Taylor + + * binary.c (binary_set_section_contents): Ignore sections which + don't have SEC_LOAD and SEC_ALLOC set. + +Mon Oct 21 12:13:05 1996 Jeffrey A Law (law@cygnus.com) + + * linker.c (_bfd_generic_final_link): Avoid losing static + symbols in the .bss section. + +Mon Oct 21 10:54:58 1996 Ian Lance Taylor + + * elf32-mips.c (elf_mips_howto_table): Describe R_MIPS_64. + (mips32_64bit_reloc): New static function. + (mips_reloc_map): Add entry for BFD_RELOC_64. + (mips_elf_relocate_section): Handle R_MIPS_64. + + * linker.c (default_indirect_link_order): Print an error message + when attempting to do a relocateable link with different object + file formats, rather than calling abort. + +Thu Oct 17 10:43:29 1996 Doug Evans + + * reloc.c (m32r relocs): Rename them. + * bfd-in2.h, libbfd.h: Regenerated. + * elf32-m32r.c: Update. + (m32r_elf_10_pcrel_reloc): New function. + (elf_m32r_howto_table, R_M32R_10_PCREL entry): Use it. + (elf_m32r_howto_table, R_M32R_24 entry): Fix {src,dst}_masks. + +Wed Oct 16 11:24:35 1996 Jeffrey A Law (law@cygnus.com) + + * linker.c (_bfd_generic_final_link): Set "linker_mark" for + all sections that will be included in the output file. + (_bfd_generic_link_output_symbols): Discard symbols in sections + which are being discarded. + +Tue Oct 15 12:40:41 1996 Ian Lance Taylor + + * VERSION: Bump for new relocation. + + * hosts/i386bsd.h: If NBPG is not defined, define it as + PAGE_SIZE, for recent versions of FreeBSD. + +Mon Oct 14 12:37:26 1996 Ian Lance Taylor + + * configure.host: Use `long long' as the 64 bit type on a Solaris + host, since both gcc and the SunPRO compilers support it. + +Mon Oct 14 11:17:24 1996 Richard Henderson + + * reloc.c: Create a new BFD_RELOC_ALPHA_ELF_LITERAL. It was a + mistake to have reused the ECOFF LITERAL for ELF since they have + different semantics. + * elf64-alpha.c (elf_reloc_map): Map from ELF_LITERAL. + * bfd-in2.h, libbfd.h: Rebuild. + + * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Trap .got + section overflow. + + * elf64-alpha.c (elf64_alpha_relocate_section): Do not emit a + dynamic relocation for an undefweak symbol when we are building + a static executable. + +Thu Oct 10 11:15:06 1996 Stan Shebs + + * mpw-make.sed (config.bfd, targmatch.sed): Edit references to + point explicitly to srcdir. + (targmatch.h): Edit references to point explicitly to objdir. + +Thu Oct 10 14:14:23 1996 Ian Lance Taylor + + * config.bfd: When setting targ_cpu, don't get confused by + linux-gnu. + +Tue Oct 8 08:51:19 1996 Stu Grossman (grossman@critters.cygnus.com) + + * configure.host: Add support for windows host (a build done + under the Microsoft build environment). + +Tue Oct 8 11:40:16 1996 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): If a symbol is a weak + definition in a dynamic object, add it to the dynamic symbol table + if any dynamic object mentions it. Reverts part of last patch. + + * sunos.c (struct sunos_link_hash_table): Add got_base field. + (sunos_link_hash_table_create): Initialize got_base. + (bfd_sunos_size_dynamic_sections): If the .got section is more + than 0x1000 bytes, set __GLOBAL_OFFSET_TABLE_ and got_base to + 0x1000. + (sunos_check_dynamic_reloc): Subtract got_base from a base + relative relocation. + + * elf32-mips.c (elf_mips_isa): New static function. + (_bfd_mips_elf_merge_private_bfd_data): Don't warn about linking + -mips1 and -mips2 code together, or -mips3 and -mips4 code. + +Mon Oct 7 11:44:17 1996 Ian Lance Taylor + + * archive.c (do_slurp_coff_armap): Only treat archive as little + endian for i960 COFF. + +Fri Oct 4 13:49:01 1996 Ian Lance Taylor + + * coffcode.h (coff_compute_section_file_positions): Adjust sofar + by the change in size of the section when EXEC_P is not set. + + * coff-m68k.c (coff_rtype_to_howto): Define if not defined. + (m68kcoff_rtype_to_howto): New static function. + * cf-m68klynx.c (coff_m68k_lynx_rtype_to_howto): Add the section + VMA to the addend for a PC relative reloc. + + * dep-in.sed: Rework backslash loop a bit to avoid bug in sed on + HP/UX 10.20. + * Makefile.in: Rebuild dependencies. + + * dep-in.sed: Remove ../bfd/sysdep.h, since it will appear when + som.h is included. + +Fri Oct 4 11:41:39 1996 Jeffrey A Law (law@cygnus.com) + + * Makefile.in: Remove explicit dependencies for mn10200 and + mn10300 files. + (ALL_MACHINE_CFILES): Add cpu-mn10200.c and cpu-mn10300.c. + (BFD32_BACKENDS_CFILES): Add elf32-mn10200.c and elf32-mn10300.c + (dependencies): Rebuilt. + +Thu Oct 3 16:57:51 1996 Ian Lance Taylor + + * cofflink.c (coff_link_add_symbols): Set obj_coff_keep_syms + during this function. + + * elflink.c (_bfd_elf_create_linker_section): Only use an existing + section if the flags are compatible. + + * configure.in: Add havevecs, and put it in tdefaults. + * mpw-config.in: Likewise. + * configure: Rebuild. + * targmatch.sed: New file; a sed script to build targmatch.h from + config.bfd. + * config.bfd: Add #if, #endif, and comments for targmatch.h. + * targets.c: Include "fnmatch.h". + (struct targmatch): Define. + (bfd_target_match): Define by including targmatch.h. + (bfd_find_target): If the target is not found by name, search for + it as a configuration triplet. + * Makefile.in: Rebuild dependencies. + (BFD32_BACKENDS): Add aout-arm.o, aout-sparcle.o, hp300bsd.o, + i386dynix.o, m68k4knetbsd.o, and riscix.o. + (BFD32_BACKENDS_CFILES): Add aout-arm.c, aout-sparcle.c, + hp300bsd.c, i386dynix.c, m68k4knetbsd.c, and riscix.c. + (HFILES): Add targmatch.h. Also, alphabetize and reindent. + (CFILES): Remove i386dynix.c and hp300bsd.c. + (targmatch.h): New target. + (do_clean): Remove targmatch.h. + + * configure.in: Add BFD_NEED_DECLARATION(getenv). + * acconfig.h: Add NEED_DECLARATION_GETENV. + * configure, config.in: Rebuild. + * sysdep.h: If NEED_DECLARATION_GETENV, declare getenv. + * aout-adobe.c (aout_adobe_object_p): Don't declare getenv. + +Thu Oct 3 09:29:09 1996 Jeffrey A Law (law@cygnus.com) + + * cpu-mn10x00.c, elf32-mn10x00: Removed. + * cpu-mn10200.c, cpu-mn10300.c: New files. + * elf32-mn10200.c, elf32-mn10300.c: New files. + * Makefile.in: Break mn10x00 support into two separate + configurations, mn10200 and mn10300. + * archures.c, config.bfd, configure.in, elf.c, targets.c: Likewise. + * bfd-in2.h, configure: Rebuilt. + +Thu Oct 3 15:38:19 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (do_clean): Move config.log to do_distclean. + +Wed Oct 2 21:40:55 1996 Jeffrey A Law (law@cygnus.com) + + * cpu-mn10x00.c, elf32-mn10x00.c: New files. + * Makefile.in (ALL_MACHINES): Add cpu-mn10x00.o. + (BFD32_BACKENDS): Similarly for elf32-mn10x00.o. + (elf32-mn10x00.o): Add dependencies. + * archures.c (enum bfd_architecture): Add bfd_arch_mn10x00. + (bfd_mn10x00_arch): Declare. + (bfd_archures_list): Add bfd_mn10x00_arch. + * config.bfd: Add mn10x00-*-*. + * configure.in: Add bfd_elf32_mn10x00_vec. + * elf.c (prep_headers): Handle bfd_arch_mn10x00. + * targets.c (bfd_elf32_mn10x00_vec): Declare. + (bfd_target_vector): Add bfd_elf32_mn10x00_vec. + * bfd-in2.h, configure: Rebuilt. + +Wed Oct 2 15:46:45 1996 Klaus Kaempf + + openVMS/Alpha: Provide filename and case_hack flags via + symbol table from gas. + Add case_hack code for symbol output from vax/vms. + * evax-alpha.c (evax_initialize): Remove filename handling, + filename is provided via symbol table. + (evax_get_symtab): Use local symbol count when setting up table. + * evax-egsd.c (_bfd_evax_slurp_egsd): Print correct name when + debugging. + (_bfd_evax_write_egsd): Skip file name symbol. + * evax-emh.c (get_vms_time_string): Local function now. + (_bfd_evax_write_emh): Extract source filename and case_hack flags + from symbol table. + * evax_write_etir (_bfd_evax_write_etir): Pass all symbol names + through _bfd_evax_case_hack_symbol. + * evax-misc.c (hash_string, _bfd_evax_case_hack_symbol): New + functions. + (_bfd_evax_basename): Removed. + (_bfd_get_vms_time_string): Moved to evax-emh.c. + * evax.h (evax_private_data_struct): Remove filename. + (flag_hash_long_names, flag_show_after_trunc, + flag_no_hash_mixed_case, vms_name_mapping): New flags for + vms_case_hack. + +Wed Oct 2 12:02:02 1996 Ian Lance Taylor + + * freebsd.h (N_GET_MAGIC_NET): Don't use ntohl. + (N_GETMID_NET, N_GETFLAG_NET): Likewise. + (NO_SWAP_MAGIC): Don't define. + (SWAP_MAGIC): Define. + + * cofflink.c (_bfd_coff_link_input_bfd): Don't crash if there is + no hash table entry for a global symbol. + +Tue Oct 1 16:14:22 1996 Joel Sherrill + + * config.bfd (mips*-*-rtems*): New target, like mips*-*-elf*. + +Tue Oct 1 12:31:39 1996 Ian Lance Taylor + + * cofflink.c (coff_link_add_symbols): Don't override a meaningful + symbol type with T_NULL. Warn if symbol type changes. Based on + patch from Philippe De Muyter . + + * elflink.h (elf_link_add_object_symbols): Only put a symbol from + a dynamic object in the dynamic symbol table if it is referenced + or defined by a regular object. + +Mon Sep 23 13:33:00 1996 Ian Lance Taylor + + * elf32-ppc.c (ppc_elf_add_symbol_hook): Create the .sbss section + by hand, rather than by calling bfd_make_section. + +Mon Sep 23 09:23:41 1996 Doug Evans + + * reloc.c: Rename m32r relocs. + * bfd-in2.h, libbfd.h: Rebuilt. + * elf32-m32r.c: Update. + +Fri Sep 20 11:43:43 1996 Ian Lance Taylor + + * aoutx.h (aout_link_input_section_ext): When doing a relocateable + link, adjust the symbol index of a base relative reloc. Don't + change the addend of a PC relative reloc if pcrel_offset is set. + * sunos.c (bfd_sunos_size_dynamic_sections): Don't do anything for + a relocateable link. + + * reloc.c (bfd_perform_relocation): Apply the relocation even if + it is zero, in case src_mask matters. + (bfd_install_relocation): Likewise. + +Thu Sep 19 11:03:06 1996 Ian Lance Taylor + + * xcofflink.c (xcoff_link_add_symbols): Always initialize + keep_syms. + (_bfd_xcoff_bfd_final_link): Don't set target_index + to an uninitialized value. + +Tue Sep 17 14:18:31 1996 Ian Lance Taylor + + * coffcode.h (coff_slurp_line_table): Warn about illegal symbol + indices, rather than crashing. + (coff_slurp_reloc_table): Likewise. Check whether the howto field + is NULL. + * coff-sh.c (sh_relocate_section): Check for an illegal symbol + index. + +Mon Sep 16 12:39:36 1996 Ian Lance Taylor + + * coff-arm.c (aoutarm_std_reloc_howto): Change dst_mask for ARM26D + reloc to 0. + (coff_arm_adjust_symndx): New static function. + (coff_adjust_symndx): Define. + + * srec.c (srec_scan): Accept multiple symbols on a single line. + From Pascal Martin . + + * README: New file. + +Fri Sep 13 14:32:42 1996 Doug Evans + + * aoutf1.h (MY_bfd_merge_private_bfd_data): Define. + (sunos_merge_private_bfd_data): New function. + +Fri Sep 13 15:50:57 1996 Ian Lance Taylor + + * bfd.c (bfd_copy_private_bfd_data): Switch on output BFD rather + than input BFD. + (bfd_merge_private_bfd_data): Likewise. + * section.c (bfd_copy_private_section_data): Likewise. + * syms.c (bfd_copy_private_symbol_data): Likewise. + * bfd-in2.h: Rebuild. + * aout-target.h (MY_bfd_copy_private_section_data): Check that + both BFD's are the right flavour. + * ecoff.c (_bfd_ecoff_bfd_copy_private_bfd_data): Likewise. + * elf.c (_bfd_elf_copy_private_symbol_data): Likewise. + * elf32-mips.c (_bfd_mips_elf_copy_private_bfd_data): Likewise. + (_bfd_mips_elf_merge_private_bfd_data): Likewise. + * elf32-ppc.c (ppc_elf_copy_private_bfd_data): Likewise. + (ppc_elf_merge_private_bfd_data): Likewise. + * elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Likewise. + * peicode.h (pe_bfd_copy_private_section_data): Likewise. + + * elf32-hppa.c (elf_hppa_howto_table): Fill in some fields for + R_PARISC_DIR32, so that _bfd_stab_section_find_nearest_line passes + its sanity check. + +Thu Sep 12 11:45:57 1996 Doug Evans + + * reloc.c: Add m32r relocs. + * bfd-in2.h, libbfd.h: Rebuilt. + * cpu-m32r.c,elf32-m32r.c: New files. + +Thu Sep 12 11:10:05 1996 Ian Lance Taylor + + * ieee.c (ieee_vec): Set symbol_leading_char field to '_'. + +Wed Sep 11 11:57:56 1996 Ian Lance Taylor + + * tekhex.c (first_phase): Change type parameter from char to int. + (out): Likewise. + (pass_over): Change func to expect int, not char. + + * elf.c (assign_file_positions_for_segments): Test SEC_ALLOC + rather than SEC_LOAD when aligning the file offset for the first + section in a segment. + +Tue Sep 10 16:18:30 1996 Fred Fish + + * syms.c (coff_section_type): Make arg const. + * irix-core.c (irix_core_core_file_p): Remove extraneous extra arg + to make_bfd_asection(). + * elf-bfd.h (bfd_section_from_phdr): Add prototype. + * elfcode.h (bfd_section_from_phdr): Remove prototype. + (_bfd_elf_stringtab_init): Remove prototype. + + * netbsd-core.c (swap_abort): Add prototype. + * aix386-core.c (swap_abort): Ditto & make static + * hpux-core.c (swap_abort): Ditto & make static. + * irix-core.c (swap_abort): Ditto & make static. + * ptrace-core.c (swap_abort): Ditto & make static. + * trad-core.c (swap_abort): Ditto & make static. + * coffswap.h (coff_swap_reloc_in): Ditto. + (coff_swap_reloc_out): Ditto. + (coff_swap_filehdr_in): Ditto. + (coff_swap_filehdr_out): Ditto. + (coff_swap_sym_in): Ditto. + (coff_swap_sym_out): Ditto. + (coff_swap_aux_in): Ditto. + (coff_swap_aux_out): Ditto. + (coff_swap_lineno_in): Ditto. + (coff_swap_lineno_out): Ditto. + (coff_swap_aouthdr_in): Ditto. + (coff_swap_aouthdr_out): Ditto. + (coff_swap_scnhdr_in): Ditto. + (coff_swap_scnhdr_out): Ditto. + * ihex.c (ihex_sizeof_headers): Ditto. + * tekhex.c (getsym): Ditto. + (find_chunk): Ditto & make static. + (insert_byte): Ditto. + (first_phase): Ditto. + (pass_over): Ditto. + (tekhex_get_symtab): Ditto & make static. + (tekhex_get_symtab_upper_bound): Ditto & make static. + (tekhex_mkobject): Ditto. + (tekhex_object_p): Ditto. + (move_section_contents): Ditto. + (tekhex_get_section_contents): Ditto. + (tekhex_set_arch_mach): Ditto & make static. + (tekhex_set_section_contents): Ditto. + (writevalue): Ditto. + (writesym): Ditto. + (out): Ditto. + (tekhex_write_object_contents): Ditto. + (tekhex_sizeof_headers): Ditto. + (tekhex_make_empty_symbol): Ditto. + (tekhex_get_symbol_info): Ditto. + (tekhex_print_symbol): Ditto. + * irix-core.c (make_bfd_asection): Ditto. + (irix_core_core_file_p): Ditto. + (irix_core_core_file_failing_command): Ditto. + (irix_core_core_file_failing_signal): Ditto. + (irix_core_core_file_matches_executable_p): Ditto. + (irix_core_make_empty_symbol): Ditto. + * coff-mips.c (mips_bfd_reloc_type_lookup): Ditto. + * srec.c (srec_new_symbol): Ditto. + (srec_get_section_contents): Ditto. + (srec_set_arch_mach): Ditto. + (srec_set_section_contents): Ditto. + (internal_srec_write_object_contents): Ditto. + (srec_write_object_contents): Ditto. + (symbolsrec_write_object_contents): Ditto. + (srec_sizeof_headers): Ditto. + (srec_make_empty_symbol): Ditto. + (srec_get_symtab_upper_bound): Ditto. + (srec_get_symtab): Ditto. + (srec_print_symbol): Ditto and make static. + * elf.c (elf_read): Ditto + (assign_section_numbers): Ditto. + (elf_fake_sections): Ditto. + (sym_is_global): Ditto. + (elf_map_symbols): Ditto. + (get_program_header_size): Ditto. + * coffgen.c (make_a_section_from_file): Ditto. + (coff_real_object_p): Ditto. + (fixup_symbol_value): Ditto. + (build_debug_section): Ditto. + (copy_name): Ditto. + * syms.c (coff_section_type): Ditto. + +Mon Sep 9 22:36:01 1996 Jeffrey A Law (law@cygnus.com) + + * bfd-in2.h: Rebuilt after m32r changes. + +Mon Sep 9 12:31:22 1996 Doug Evans + + * config.bfd,configure.in,configure: Add m32r support. + * Makefile.in,archures.c,elf.c,targets.c: Likewise. + * config.bfd: Keep target list alphabetically sorted. + +Fri Sep 6 17:04:39 1996 Martin M. Hunt + + * elf32-d10v.c (elf_d10v_howto_table): Modify the size of R_D10V_16 + and R_D10V_18 to be 1 (word). + +Thu Sep 5 15:23:08 1996 Ian Lance Taylor + + * stabs.c (_bfd_link_section_stabs): If the output_section field + of either section is bfd_abs_section, then the linker is + discarding the section and we should not optimize it. + +Tue Sep 3 12:16:20 1996 Doug Evans + + * Makefile.in (aout-sparcle.o): New target. + * aoutf1.h (TARGET_IS_BIG_ENDIAN_P): Don't define if little endian. + * config.bfd (sparclet-*-aout*): Add case. + * configure.in (sparcle_aout_vec): Add case. + * configure: Regenerated. + * targets.c (sparcle_aout_vec): Declare. + (bfd_target_vector): Add sparcle_aout_vec. + * aout-sparcle.c: New file. + +Mon Sep 2 12:12:34 1996 Ian Lance Taylor + + * cpu-mips.c: Add an explicit mips:3000 entry, and change the + default architecture to a machine number of 0. + * elf32-mips.c (_bfd_mips_elf_object_p): Set the machine number + for E_MIPS_ARCH_1. + (_bfd_mips_elf_merge_private_bfd_data): If the machine number of + the output BFD is the default, set it from the first input BFD. + +Sun Sep 1 15:41:08 1996 Ian Lance Taylor + + * rs6000-core.c (rs6000coff_core_file_matches_executable_p): + Rewrite to use BFD file read routines and to avoid using a fixed + length for the file name. + +Fri Aug 30 11:49:19 1996 Ian Lance Taylor + + Add SH ELF support. + * elf32-sh.c: New file. + * elf.c (prep_headers): Handle bfd_arch_sh. + * elfcode.h (write_relocs): Handle absolute symbol. + * elf-bfd.h (_bfd_elf32_link_read_relocs): Declare. + (_bfd_elf64_link_read_relocs): Declare. + * elflink.h (NAME(_bfd_elf,link_read_relocs)): Rename from + elf_link_read_relocs. Make globally visible. Change all + callers. + (elf_link_input_bfd): Get external symbols from cache in + symtab_hdr->contents. Get contents from cache in + elf_section_data. + * elfxx-target.h (bfD_elfNN_bfd_relax_section): Only define if not + already defined. + * reloc.c: Define BFD_RELOC_SH_* relocs. + * libbfd-in.h (_bfd_sh_align_load_span): Declare. + * coff-sh.c (sh_insns_conflict): Fix a return value. + (_bfd_sh_align_load_span): New globally visible function, broken + out of sh_align_load. + (sh_align_load): Call _bfd_sh_align_load_span. + (sh_swap_insns): Change relocs parameter to PTR. + * bfd-in2.h, libbfd.h: Rebuild. + * targets.c (bfd_elf32_sh_vec): Declare. + (bfd_elf32_shl_vec): Declare. + * config.bfd (sh-*-elf*): New target. + * configure.in (bfd_elf32_sh_vec): New target vector. + (bfd_elf32_shl_vec): New target vector. + * configure: Rebuild. + * Makefile.in: Rebuild dependencies. + (BFD32_BACKENDS): Add elf32-sh.o. + (BFD32_BACKENDS_CFILES): Add elf32-sh.c. + + * elf.c (map_sections_to_segments): Check that LMA does not skip a + page before checking D_PAGED. + + * ihex.c (ihex_scan): Removed unnecessary extbase variable. + (ihex_write_object_contents): Remove extbase; always use segbase + instead. + +Thu Aug 29 16:52:17 1996 Michael Meissner + + * configure.in (i[345]86-*-*): Recognize i686 for pentium pro. + * configure.host (i[345]86-*-*): Ditto. + * config.bfd (i[345]86-*-*): Ditto. + * configure: Regenerate. + + * config.bfd (i[3456]86-*-dgux*): Recognize as a synonym for x86 + elf. + +Tue Aug 27 09:18:18 1996 Jeffrey A Law (law@cygnus.com) + + * elf32-hppa.c (hppa_elf_gen_reloc_type): Add new argument. + * elf32-hppa.h (hppa_elf_gen_reloc_type): Update prototype. + * som.c (hppa_som_gen_reloc_type): Add new argument. If + we encounter an R_DATA_ONE_SYMBOL reloc against a symbol that + will have an ST_CODE type, change the symbol's type to ST_DATA. + * som.c (hppa_som_gen_reloc_type): Update prototype. + +Tue Aug 27 00:12:22 1996 Ian Lance Taylor + + * elf32-mips.c (mips_elf_check_relocs): Set dynobj if needed for + R_MIPS_32 and R_MIPS_REL32. Set sgot and g as soon as possible. + (mips_elf_size_dynamic_sections): Don't require .got to exist. + (mips_elf_finish_dynamic_sections): Likewise. + +Thu Aug 22 10:54:38 1996 Ian Lance Taylor + + * configure.host (HLDENV): New variable to set. Set it for + *-*-sysv4*, since those linkers may not support -R but they always + support LD_RUN_PATH. + + * libieee.h (NSECTIONS): Don't define. + (ieee_data_struct): Change section_table to asection **. Add + section_table_size. + * ieee.c (get_section_entry): If the table isn't big enough, make + it bigger. + (ieee_slurp_sections): Remove assertion about number of sections. + (ieee_object_p): Adjust initialization of ieee to match changes to + the structure. + + * xcofflink.c (xcoff_mark): Don't copy relocs for undefined + symbols merely because we are generating a shared library. + (xcoff_build_ldsyms): Don't set up global linkage code for an + undefined symbol merely because we are generating a shared + library. + +Fri Aug 16 16:25:35 1996 Ian Lance Taylor + + * xcofflink.c (xcoff_link_add_dynamic_symbols): Create and define + a function code symbol for an XMC_XO symbol. + +Thu Aug 15 12:33:29 1996 Stan Shebs + + * mpw-config.in: Update editing of autoconf vars to reflect + Jul 18 configure.in change. + * mpw-make.sed: Update editing of include pathnames to be + more general, add @DASH_C_FLAG@ to explicit compile rule edit. + +Thu Aug 15 10:35:13 1996 Richard Henderson + + * elf64-alpha.c (elf64_alpha_output_extsym): The section from + which to offset to get the .plt entry address is ".plt". + +Thu Aug 15 16:40:30 1996 James G. Smith + + * reloc.c: (BFD_RELOC_ARM_THUMB_ADD, BFD_RELOC_ARM_THUMB_IMM, + BFD_RELOC_ARM_THUMB_SHIFT, BFD_RELOC_ARM_THUMB_OFFSET): + Added, for internal use by the ARM gas. + * libbfd.h: Rebuilt + * bfd-in2.h: Rebuilt + +Wed Aug 14 17:02:09 1996 Richard Henderson + + * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Correct typo + in section dynidx start. + +Tue Aug 13 14:35:38 1996 Ian Lance Taylor + + * elf.c (_bfd_elf_make_section_from_shdr): Treat sections whose + name begins with .gnu.linkonce as SEC_LINK_ONCE. This is an + optimization for g++. + +Tue Aug 13 17:04:40 1996 Michael Meissner + + * elf32-ppc.c (ppc_elf_merge_private_bfd_data): If one module has + the -mrelocatable-lib bit set and the other doesn't, clear the + -mrelocatable-lib bit in the header. + +Sat Aug 10 22:59:17 1996 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Do not resolve a common + symbol against a STT_FUNC symbol in a shared library. + +Fri Aug 9 12:44:57 1996 Ian Lance Taylor + + * xcofflink.c (xcoff_link_add_dynamic_symbols): If a descriptor + symbol is found, automatically define the corresponding function + code. + + * cofflink.c (coff_link_add_symbols): Only set (*sym_hash)->numaux + if sym.n_numaux is not zero. + (_bfd_coff_link_input_bfd): Permit the symbol and the hash table + entry to disagree about the number of aux entries if the symbol + has zero. + + * elf32-mips.c (mips_elf_check_relocs): Create the .rel.dyn + section if it might be needed, not just if info->shared. + (mips_elf_adjust_dynamic_symbol): Make room for a null element at + the start of .rel.dyn if we are going to use it. + (mips_elf_finish_dynamic_sections): Only clear the first element + of .rel.dyn if the size is greater than zero. + +Thu Aug 8 16:24:55 1996 Ian Lance Taylor + + * xcofflink.c (xcoff_link_input_bfd): If we already called the + undefined_symbol callback for a symbol, then don't issue any more + warnings about loader relocs. + (_bfd_ppc_xcoff_relocate_section): Don't do any further processing + after calling the undefined_symbol callback. + + * xcofflink.c (XCOFF_MULTIPLY_DEFINED): Define. + (xcoff_link_add_symbols): Permit multiple definitions of a symbol + as the AIX linker seems to do. + +Thu Aug 8 12:21:56 1996 Klaus Kaempf + + * evax-alpha.c (evax_alpha_vec): Corrected flags, cleanup. + (evax_initialize): Remove evax_reloc_table. + (evax_close_and_cleanup): Ditto. + (reloc_nil): Ditto. + (alpha_howto_table): Remove ALPHA_R_SWREL32 and ALPHA_R_SWREL64 + entries. + (evax_bfd_reloc_type_lookup): Ditto. + * evax-egsd.c (_bfd_evax_slurp_egsd): Add a few casts; set + cooked_size == raw_size. + * evax-emh.c (_bfd_evax_register_filename): Remove. + * evax-etir.c (etir_stc): Allow ETIR_S_C_STC_xx commands. + * evax-misc.c (add_new_contents): Malloc section at full size. + (_bfd_save_evax_section): Memcpy section contents directly. + * evax.h (ALPHA_R_SWREL32, ALPHA_R_SWREL64): Remove. + (evax_reloc_table): Remove. + + * hosts/alphavms.h (O_ACCMODE): Define if needed. + + * makefile.vms: Add better support for DEC C compilation + Add evax.h dependencies + + * reloc.c (bfd_get_reloc_size): Add case for 16 byte reloc. + (BFD_RELOC_SWREL32,BFD_RELOC_SWREL64): Remove. + (BFD_RELOC_ALPHA_BASEREG): Remove. + * bfd-in2.h, libbfd.h: Rebuild. + +Thu Aug 8 08:17:32 1996 Stu Grossman (grossman@critters.cygnus.com) + + * archive.c (bsd_write_armap): Ifdef around calls to getuid and + getgid if _WIN32 is defined. + * opncls.c (bfd_fdopenr): Remove unnecessary WINGDB ifdef. + +Wed Aug 7 23:19:00 1996 Stu Grossman (grossman@critters.cygnus.com) + + * aoutx.h bfd-in.h bfd-in2.h opncls.c riscix.c som.c targets.c: + Change NO_FLAGS to BFD_NO_FLAGS to avoid conflict with an HPUX + include file. + * libbfd.c: Create dummy getpagesize() macro if HAVE_GETPAGESIZE + isn't defined. + +Wed Aug 7 14:11:44 1996 Philippe De Muyter + + * configure.in: Call BFD_NEEDED_DECLARATION on strstr and + realloc. + * acconfig.h (NEED_DECLARATION_STRSTR): New macro. + (NEED_DECLARATION_REALLOC): New macro. + * configure, config.in: Rebuild. + * sysdep.h (strstr): Declare if NEED_DECLARATION_STRSTR. + (realloc): Declare if NEED_DECLARATION_REALLOC. + + * aclocal.m4 (BFD_NEED_DECLARATION): Include or + if they exist. + + * ieee.c (ieee_set_section_contents): Cast bfd_alloc return. + +Wed Aug 7 12:12:03 1996 Ian Lance Taylor + + * cpu-i386.c (i8086_arch): Architecture info for the i8086. + + Based on patches from Eric Valette : + * elf32-i386.c (enum reloc_type): Add FIRST_INVALID_RELOC, + LAST_INVALID_RELOC, R_386_16, R_386_PC16, R_386_8, R_386_PC8. + (elf_howto_table): Add entries for new relocs. + (elf_i386_reloc_type_lookup): Handle new relocs. + (elf_i386_info_to_howto): Just call abort. + (elf_i386_info_to_howto_rel): Check that the reloc type is valid. + (elf_i386_relocate_section): Likewise. + +Tue Aug 6 12:54:56 1996 Martin M. Hunt + + * elf32-d10v.c (elf_d10v_howto_table): Added R_D10V_32. + +Mon Aug 5 13:42:41 1996 Ian Lance Taylor + + * elf.c (_bfd_elf_make_section_from_shdr): For a loadable section, + only get the LMA from the phdr if they are in the same part of the + file. + + * elf.c (map_sections_to_segments): Rewrite tests for starting a + new segment to make them more comprehensible. If the relationship + between the LMA and the VMA changed, start a new segment. Don't + check dynsec when deciding whether to start a new segment for a + writeable section; -N will now handle this. + +Thu Aug 1 22:43:08 1996 Jeffrey A Law (law@cygnus.com) + + * libhppa.h: Remove "esel" changes. Not the right approach. + * som.c: Corresponding changes. + (som_bfd_derive_misc_symbol_info): Use ST_DATA for symbols + which don't have a SOM symbol type associated with them. + Reverses a 1994 change. + +Wed Jul 31 15:50:55 1996 Ian Lance Taylor + + Make ld -N more reasonable for ELF: + * elf.c (map_sections_to_segments): If D_PAGED is not set, set + phdr_in_section to false, and always use a single load segment. + (elf_sort_sections): Sort sections by LMA after VMA. + (assign_file_positions_for_segments): If D_PAGED is not set, don't + align to maxpagesize. + (assign_file_positions_except_relocs): Likewise. + * elfcode.h (elf_object_p): If a section is loaded but not page + aligned, clear D_PAGED. + +Wed Jul 31 15:00:12 1996 James G. Smith + + * reloc.c: (BFD_RELOC_ARM_OFFSETIMM8, BFD_RELOC_ARM_HWLITERAL): + Added, for internal use by the ARM gas. + * libbfd.h: Rebuilt + * bfd-in2.h: Rebuilt + +Tue Jul 30 14:14:57 1996 Jeffrey A Law (law@cygnus.com) + + * libhppa.h (R_HPPA_ESEL): New field selector. + (e_esel): Similarly. + * som.c (hppa_som_gen_reloc_type): If we encounter an e_esel, + then generate R_COMP2 (PUSH_SYM), R_DATA_EXPR fixup stream. + (som_write_fixups): Handle R_DATA_EXPR just like R_CODE_EXPR. + +Tue Jul 30 13:31:27 1996 Ian Lance Taylor + + * xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Do the regular + archive search before looking for stripped dynamic objects. + +Fri Jul 26 17:51:39 1996 Ian Lance Taylor + + * xcofflink.c (xcoff_build_ldsyms): Make exporting an undefined + symbol a warning rather than an error. + +Wed Jul 24 12:02:53 1996 Ian Lance Taylor + + * elf.c (assign_file_positions_for_segments): Track the virtual + memory position separately from the file position, and use it to + compute the alignment adjustment. + +Tue Jul 23 10:43:31 1996 Martin M. Hunt + + * elf32-d10v.c (elf_d10v_howto_table): Changed all relocs to "long" + and fixed mask on R_D10V_10_PCREL_L. + +Mon Jul 22 15:30:30 1996 Ian Lance Taylor + + * elf64-mips.c: Include "aout/ar.h". + (mips_elf64_slurp_armap): New static function. + (mips_elf64_write_armap): New static function. + (bfd_elf64_archive_*): Define. + * elfxx-target.h (bfd_elfNN_archive_p): Define if not defined. + Use instead of bfd_generic_archive_p. + (bfd_elfNN_write_archive_contents): Define if not defined. Use + instead of _bfd_write_archive_contents. + (bfd_elfNN_mkdarchive): Define if not defined. Use instead of + _bfd_generic_mkarchive. + (TARGET_BIG_SYM): If bfd_elfNN_archive_functions is defined, use + bfd_elfNN_archive in BFD_JUMP_TABLE_ARCHIVE rather than + _bfd_archive_coff. + (TARGET_LITTLE_SYM): Likewise. + * archive.c (bfd_slurp_armap): Check for and reject an archive map + name of /SYM64/. + * Makefile.in: Rebuild dependencies. + + * elf32-mips.c (_bfd_mips_elf_final_write_processing): Handle + SHT_MIPS_LIBLIST, SHT_MIPS_CONTENT, SHT_MIPS_SYMBOL_LIB, and + SHT_MIPS_EVENTS sections. + (_bfd_mips_elf_section_from_shdr): Handle SHT_MIPS_IFACE, + SHT_MIPS_CONTENT, SHT_MIPS_SYMBOL_LIB, and SHT_MIPS_EVENTS + sections. + (_bfd_mips_elf_fake_sections): Likewise. + + * libecoff.h (ecoff_data_type): Add rdata_in_text field. + * ecoff.c (ecoff_compute_section_file_positions): Copy + rdata_in_text from backend info to tdata. Clear it if any data + section comes before .rdata. + (_bfd_ecoff_write_object_contents): Use rdata_in_text field in + tdata rather than backend info. + +Fri Jul 19 18:15:51 1996 Ian Lance Taylor + + * configure.in: Fix test for whether a compiler has a 64 bit + type. From Jim Wilson . + +Thu Jul 18 15:39:10 1996 Ian Lance Taylor + + * configure.host (mips-sgi-irix6*): New host. + + * configure.in: Set and substitute VERSION, BFD_HOST_64BIT_LONG + (replacing HOST_64BITLONG), BFD_HOST_64_BIT_DEFINED, + BFD_HOST_64_BIT, and BFD_HOST_U_64_BIT. Add bfd-in2.h:bfd-in2.h + to AC_OUTPUT call. + * configure: Rebuild. + * bfd-in.h (BFD_ARCH_SIZE): Define as @wordsize@, not @WORDSIZE@. + (BFD_HOST_64_BIT): Define conditionally. + (BFD_HOST_U_64_BIT): Define when BFD_HOST_64_BIT is defined. + (bfd_vma): Typedef as BFD_HOST_U_64_BIT. + (symvalue, bfd_size_type): Likewise. + * bfd-in2.h: Rebuild. + * Makefile.in (do_clean): Remove bfd-tmp.h. + (do_distclean): Remove bfd-in3.h. + (stmp-bfd.h): Just do copy-if-change bfd-in3.h bfd.h. + (bfd-in3.h): New target. + + * config.bfd (sparc-*-sysv4*): Don't build sunos_big_vec. From + Andrew Gierth . + + * configure.host: Set INSTALL_SHLIB. + * configure.in: Call AC_SUBST (INSTALL_SHLIB). + * configure: Rebuild. + * Makefile.in (install): Use @INSTALL_SHLIB@. + + * config.bfd (mips*-*-irix6*): New target. + * configure.host: Handle Irix 6 shared library like Irix 5. + + * xcofflink.c (xcoff_link_add_symbols): Don't check an XMC_TD + symbol for a magic name. + (xcoff_link_input_bfd): Don't change the reloc symbol for an + XMC_TD symbol. + (_bfd_ppc_xcoff_relocate_section): Don't get the TOC offset for an + XMC_TD symbol. + +Thu Jul 18 11:36:31 1996 Stan Shebs + + * mpw-config.in: Add ELF support to mips config, create the + elf32-target.h file in the object dir. + * mpw-make.sed: Edit elfXX-target.h refs at beginnings of lines. + +Wed Jul 17 18:02:32 1996 Kim Knuttila + + * coff-ppc.c: Redid debug scheme - numerous fprintf's gone. + Also removed most abort calls, in favor of using bfd reporting. + +Wed Jul 17 14:51:52 1996 Martin M. Hunt + + * Makefile.in (ALL_MACHINES): Add cpu-d10v.o. + (BFD32_BACKENDS) Add elf32-d10v.o. + * archures.c: Add bfd_d10v_arch. + * bfd-in2.h: Add bfd_d10v_arch. + * config.bfd (d10v-*-*): New target. + * configure: (bfd_elf32_d10v_vec) New vector. + * configure.in: (bfd_elf32_d10v_vec) New vector. + * cpu-d10v.c: New file. + * elf.c (prep_headers): Added case bfd_arch_d10v. + * elf32-d10v.c: New file. + * libbfd.h: Rebuild. + * reloc.c (BFD_RELOC_D10V_10_PCREL_R, BFD_RELOC_D10V_10_PCREL_L, + BFD_RELOC_D10V_18, BFD_RELOC_D10V_18_PCREL): Define. + * targets.c (bfd_elf32_d10v_vec): New vector. + +Wed Jul 17 10:58:55 1996 Kim Knuttila + + * coff-ppc.c (coff_ppc_relocate_section): Removed bogus fprintf + +Tue Jul 16 23:49:02 1996 Stu Grossman (grossman@critters.cygnus.com) + + * archures.c bfd-in2.h: Add bfd_mach_i386_i386 and + bfd_mach_i386_i8086 machine types. + +Wed Jul 10 12:42:56 1996 Ian Lance Taylor * ecoff.c (_bfd_ecoff_new_section_hook): Set SEC_CODE for _INIT and _FINI sections. @@ -10,7 +2261,15 @@ * coffcode.h (coff_set_section_contents): A/UX does not require special handling of the _LIB section. -Tue Jul 9 12:26:30 1996 Ian Lance Taylor +Tue Jul 9 15:52:20 1996 Jeffrey A Law (law@cygnus.com) + + * coff-h8300.c (h8300_reloc16_extra_cases): Use the correct + value for R_RELBYTE. + + * reloc16.c (bfd_coff_reloc16_relax_section): Only "shrinks" + array if one was allocated. + +Tue Jul 9 12:21:54 1996 Ian Lance Taylor From Kazumoto Kojima : * elf32-mips.c (struct mips_elf_link_hash_table): Add new fields @@ -26,9 +2285,38 @@ __rld_obj_head symbol. (mips_elf_finish_dynamic_sections): Handle DT_MIPS_RLD_MAP. +Mon Jul 8 16:18:03 1996 Ian Lance Taylor + + * elf32-mips.c (mips_reloc_map): Remove BFD_RELOC_32_PCREL entry. + + * elf32-ppc.c (ppc_elf_howto_raw): For R_PPC_ADDR16_HA, use + ppc_elf_addr16_ha_reloc. + (ppc_elf_addr16_ha_reloc): New static function. + + * coff-mips.c (struct mips_hi): Define. + (mips_refhi_list): New static variable. + (mips_refhi_addr, mips_refhi_addend): Remove. + (mips_refhi_reloc): Maintain a list of unmatched REFHI relocs. + (mips_reflo_reloc): Process mips_refhi_list. + (mips_relhi_list): New static variable. + (mips_relhi_addr, mips_relhi_addend): Remove. + (mips_relhi_reloc): Maintain a list of unmatched RELHI relocs. + (mips_rello_reloc): Process mips_relhi_list. + (mips_relocate_section): Permit an arbitrary number of REFHI or + RELHI relocs before the associated REFLO or RELLO reloc. + +Fri Jul 5 19:27:49 1996 Ian Lance Taylor + + * aout-target.h (MY(callback)): Set reloc_count fields. + Thu Jul 4 12:00:37 1996 Ian Lance Taylor - * VERSION: Set to 2.7. + * sunos.c (sunos_add_dynamic_symbols): Don't create dynamic + sections unless this is a SunOS link. + + * VERSION: Set to 2.7.1. + + * Released binutils 2.7. Wed Jul 3 14:59:47 1996 Ian Lance Taylor @@ -230,6 +2518,18 @@ * coff-h8300.c: Remove #if 0 code. (compatable): Don't allow mixing/matching of different architectures. + * archures.c (bfd_mach_h8300s): Add. + * bfd-in2.h: Rebuilt. + * coff-h8300.c (funcvec_hash_newfunc): Handle H8/S too. + (BADMAG): Likewise. + (h8300_reloc16_estimate): Likewise. + (h8300_reloc16_extra_cases): Likewise. + (h8300_bfd_link_add_symbols): Likewise. + * coffcode.h (coff_set_arch_mach_hook): Likewise. + (coff_set_flags): Likewise. + * cpu-h8300.c (h8300_scan): Likewise. + Add H8/S to bfd_h8300_arch list. + Tue Jun 18 14:42:58 1996 Klaus Kaempf Added support for Alpha OpenVMS: @@ -4618,7 +6918,7 @@ Local Variables: -mode: indented-text +mode: change-log left-margin: 8 fill-column: 74 version-control: never diff -urN binutils-2.7/bfd/Makefile.in binutils-2.8/bfd/Makefile.in --- binutils-2.7/bfd/Makefile.in Thu Jul 4 12:30:37 1996 +++ binutils-2.8/bfd/Makefile.in Wed Apr 30 12:55:44 1997 @@ -1,5 +1,5 @@ # Makefile template for Configure for the BFD library. -# Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 +# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 # Free Software Foundation, Inc. # Written by Cygnus Support. # @@ -64,6 +64,7 @@ SHLIB = @SHLIB@ SHLIB_CC = @SHLIB_CC@ SHLIB_CFLAGS = @SHLIB_CFLAGS@ +SHLIB_LIBS = @SHLIB_LIBS@ COMMON_SHLIB = @COMMON_SHLIB@ SHLINK = @SHLINK@ @@ -113,15 +114,19 @@ cpu-a29k.o \ cpu-alpha.o \ cpu-arm.o \ + cpu-d10v.o \ cpu-h8300.o \ cpu-h8500.o \ cpu-hppa.o \ cpu-i386.o \ cpu-i860.o \ cpu-i960.o \ + cpu-m32r.o \ cpu-m68k.o \ cpu-m88k.o \ cpu-mips.o \ + cpu-m10200.o \ + cpu-m10300.o \ cpu-ns32k.o \ cpu-powerpc.o \ cpu-rs6000.o \ @@ -142,9 +147,12 @@ cpu-i386.c \ cpu-i860.c \ cpu-i960.c \ + cpu-m32r.c \ cpu-m68k.c \ cpu-m88k.c \ cpu-mips.c \ + cpu-m10200.c \ + cpu-m10300.c \ cpu-ns32k.c \ cpu-powerpc.c \ cpu-rs6000.c \ @@ -159,7 +167,9 @@ # target_vector in targets.c if configured with --enable-targets=all. BFD32_BACKENDS = \ aout-adobe.o \ + aout-arm.o \ aout-ns32k.o \ + aout-sparcle.o \ aout0.o \ aout32.o \ bout.o \ @@ -183,6 +193,7 @@ coff-rs6000.o \ coff-sh.o \ coff-sparc.o \ + coff-svm68k.o \ coff-u68k.o \ coff-we32k.o \ coff-w65.o \ @@ -190,21 +201,28 @@ cofflink.o \ ecoff.o \ ecofflink.o \ + elf32-d10v.o \ elf32-gen.o \ elf32-hppa.o \ elf32-i386.o \ elf32-i860.o \ + elf32-m32r.o \ elf32-m68k.o \ elf32-m88k.o \ elf32-mips.o \ + elf-m10200.o \ + elf-m10300.o \ elf32-ppc.o \ + elf32-sh.o \ elf32-sparc.o \ elf32.o \ elflink.o \ + hp300bsd.o \ hp300hpux.o \ som.o \ i386aout.o \ i386bsd.o \ + i386dynix.o \ i386freebsd.o \ i386linux.o \ i386lynx.o \ @@ -213,6 +231,7 @@ i386mach3.o \ i386os9k.o \ ieee.o \ + m68k4knetbsd.o \ m68klinux.o \ m68klynx.o \ m68knetbsd.o \ @@ -235,6 +254,8 @@ pei-ppc.o \ ppcboot.o \ reloc16.o \ + riscix.o \ + sparclinux.o \ sparclynx.o \ sparcnetbsd.o \ sunos.o \ @@ -244,7 +265,9 @@ BFD32_BACKENDS_CFILES = \ aout-adobe.c \ + aout-arm.c \ aout-ns32k.c \ + aout-sparcle.c \ aout0.c \ aout32.c \ bout.c \ @@ -268,6 +291,7 @@ coff-rs6000.c \ coff-sh.c \ coff-sparc.c \ + coff-svm68k.c \ coff-u68k.c \ coff-we32k.c \ coff-w65.c \ @@ -279,17 +303,23 @@ elf32-hppa.c \ elf32-i386.c \ elf32-i860.c \ + elf32-m32r.c \ elf32-m68k.c \ elf32-m88k.c \ elf32-mips.c \ + elf-m10200.c \ + elf-m10300.c \ elf32-ppc.c \ + elf32-sh.c \ elf32-sparc.c \ elf32.c \ elflink.c \ + hp300bsd.c \ hp300hpux.c \ som.c \ i386aout.c \ i386bsd.c \ + i386dynix.c \ i386freebsd.c \ i386linux.c \ i386lynx.c \ @@ -298,6 +328,7 @@ i386mach3.c \ i386os9k.c \ ieee.c \ + m68k4knetbsd.c \ m68klinux.c \ m68klynx.c \ m68knetbsd.c \ @@ -320,6 +351,8 @@ pei-ppc.c \ ppcboot.c \ reloc16.c \ + riscix.c \ + sparclinux.c \ sparclynx.c \ sparcnetbsd.c \ sunos.c \ @@ -406,7 +439,7 @@ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" -ALL_CFLAGS=@HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) $(CFLAGS) +ALL_CFLAGS=-D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) $(CFLAGS) .c.o: if [ -n "$(PICFLAG)" ]; then \ $(CC) -c $(PICFLAG) $(ALL_CFLAGS) $< -o pic/$@; \ @@ -425,14 +458,15 @@ $(ALL_MACHINES_CFILES) \ $(BFD32_BACKENDS_CFILES) \ $(BFD64_BACKENDS_CFILES) \ - $(OPTIONAL_BACKENDS_CFILES) \ - i386dynix.c hp300bsd.c + $(OPTIONAL_BACKENDS_CFILES) -HFILES = aout-target.h aoutf1.h aoutx.h coffcode.h \ - coffswap.h ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \ - elfcode.h evax.h hppa_stubs.h libaout.h libbfd.h \ - libcoff.h libecoff.h elf-bfd.h libhppa.h libieee.h libnlm.h \ - liboasys.h nlm-target.h nlmcode.h som.h genlink.h netbsd.h ns32k.h +HFILES = \ + aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h \ + ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \ + elfcode.h evax.h genlink.h hppa_stubs.h libaout.h libbfd.h \ + libcoff.h libecoff.h elf-bfd.h libhppa.h libieee.h libnlm.h \ + liboasys.h netbsd.h nlm-target.h nlmcode.h ns32k.h som.h \ + targmatch.h all: Makefile $(ALLLIBS) @PICLIST@ @$(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) @@ -475,7 +509,7 @@ esac ; \ done ; \ echo $$f > tofiles - $(srcdir)/../move-if-change tofiles ofiles + $(SHELL) $(srcdir)/../move-if-change tofiles ofiles touch stamp-ofiles ofiles: stamp-ofiles ; @true @@ -493,14 +527,14 @@ else \ cp ofiles tpiclist; \ fi - $(srcdir)/../move-if-change tpiclist piclist + $(SHELL) $(srcdir)/../move-if-change tpiclist piclist touch stamp-piclist piclist: stamp-piclist ; @true $(SHLIB): stamp-picdir $(OFILES) piclist rm -f $(SHLIB) - $(SHLIB_CC) $(SHLIB_CFLAGS) -o $(SHLIB) `cat piclist` + $(SHLIB_CC) $(SHLIB_CFLAGS) -o $(SHLIB) `cat piclist` $(SHLIB_LIBS) # We make a link from libbfd.so to libbfd.so.VERSION for linking, and # also a link from libTARGET-bfd.so.VERSION for running. @@ -508,10 +542,10 @@ ts=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed -e '$(program_transform_name)'`; \ if [ "$$ts" != "$(SHLIB)" ]; then \ rm -f $$ts; \ - ln -sf $(SHLIB) $$ts; \ + ln -s $(SHLIB) $$ts; \ else true; fi rm -f $(SHLINK) - ln -sf $(SHLIB) $(SHLINK) + ln -s $(SHLIB) $(SHLINK) # This target creates libTARGET-bfd.so.VERSION as a symlink to # libbfd.so.VERSION. It is used on SunOS, which does not have SONAME. @@ -519,10 +553,18 @@ tf=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \ if [ "$$tf" != "$(SHLIB)" ]; then \ rm -f $$tf; \ - ln -sf $(SHLIB) $$tf; \ + ln -s $(SHLIB) $$tf; \ else true; fi touch stamp-tshlink +# This file holds an array associating configuration triplets and +# vector names. It is built from config.bfd. It is not compiled by +# itself, but is included by targets.c. +targmatch.h: config.bfd targmatch.sed + rm -f targmatch.h + sed -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new + mv -f targmatch.new targmatch.h + # When compiling archures.c and targets.c, supply the default target # info from configure. @@ -563,17 +605,22 @@ etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c do_mostlyclean: - rm -f *.o *~ core *.E *.p *.ip aout-params.h gen-aout config.log \ - pic/*.o + rm -f *.o *~ core *.E *.p *.ip aout-params.h gen-aout pic/*.o do_clean: do_mostlyclean - rm -f libbfd.a TAGS bfd.h stmp-bfd.h ofiles stamp-ofiles \ + rm -f libbfd.a TAGS bfd.h stmp-bfd.h bfd-tmp.h ofiles stamp-ofiles \ elf32-target.h elf64-target.h $(SHLIB) $(SHLINK) \ - piclist stamp-piclist + piclist stamp-piclist targmatch.h do_distclean: do_clean - rm -f Makefile config.status config.cache config.h stamp-h + rm -f Makefile config.status config.cache config.h config.log \ + stamp-h bfd-in3.h rm -rf pic stamp-picdir + +# do_maintainer_clean really should remove bfd-in2.h, since it is a +# generated file. However, the GNU standards say that +# maintainer-clean should not delete anything which needs to exist in +# order to run configure, and bfd-in2.h is used by configure. do_maintainer_clean: do_distclean - rm -f $(srcdir)/bfd-in2.h $(srcdir)/libbfd.h $(srcdir)/libcoff.h + rm -f $(srcdir)/libbfd.h $(srcdir)/libcoff.h mostlyclean: do_mostlyclean $(MAKE) subdir_do DO=mostlyclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) @@ -588,7 +635,7 @@ $(MAKE) subdir_do DO=maintainer-clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) $(MAKE) do_maintainer_clean -BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/obstack.h +BFD_H_DEPS= $(INCDIR)/ansidecl.h LOCAL_H_DEPS= libbfd.h sysdep.h config.h $(BFD_LIBS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS) $(BFD_MACHINES): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS) @@ -656,9 +703,9 @@ rm -f $(libdir)/$$tf; \ if [ "$$f" = "$(SHLINK)" ]; then \ ts=lib`echo $(SHLIB) | sed -e 's/^lib//' | sed '$(program_transform_name)'`; \ - ln -sf $$ts $(libdir)/$$tf; \ + ln -s $$ts $(libdir)/$$tf; \ elif [ "$$f" = "$(SHLIB)" ]; then \ - $(INSTALL_PROGRAM) $$f $(libdir)/$$tf; \ + @INSTALL_SHLIB@ \ else \ $(INSTALL_DATA) $$f $(libdir)/$$tf; \ $(RANLIB) $(libdir)/$$tf; \ @@ -671,15 +718,13 @@ $(INSTALL_DATA) $(BFD_H) $(includedir)/bfd.h $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(includedir)/ansidecl.h $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(includedir)/bfdlink.h - $(INSTALL_DATA) $(INCDIR)/obstack.h $(includedir)/obstack.h -if test -z "$(oldincludedir)"; then true; else \ test -d $(oldincludedir) || mkdir $(oldincludedir); \ $(INSTALL_DATA) $(BFD_H) $(oldincludedir)/bfd.h; \ $(INSTALL_DATA) $(INCDIR)/ansidecl.h $(oldincludedir)/ansidecl.h; \ $(INSTALL_DATA) $(INCDIR)/bfdlink.h $(oldincludedir)/bfdlink.h; \ - $(INSTALL_DATA) $(INCDIR)/obstack.h $(oldincludedir)/obstack.h; \ - $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS); \ fi + $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) Makefile: Makefile.in config.status CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status @@ -709,7 +754,7 @@ $(DEP) -f .dep2a $(ALL_CFLAGS) $? sed -e '/DO NOT DELETE/d' -e '/^$$/d' < .dep2a >> .dep2 rm -f .dep2a - $(srcdir)/../move-if-change .dep2 .dep1 + $(SHELL) $(srcdir)/../move-if-change .dep2 .dep1 dep.sed: dep-in.sed config.status sed <$(srcdir)/dep-in.sed >dep.sed \ @@ -720,12 +765,12 @@ dep: .dep sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile cat .dep >> tmp-Makefile - $(srcdir)/../move-if-change tmp-Makefile Makefile + $(SHELL) $(srcdir)/../move-if-change tmp-Makefile Makefile dep-in: .dep sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in cat .dep >> tmp-Makefile.in - $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in + $(SHELL) $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in host-aout.o: Makefile @@ -740,40 +785,40 @@ $(BFD_H): stmp-bfd.h ; @true -stmp-bfd.h : $(srcdir)/bfd-in2.h Makefile - rm -f bfd.h-new - sed -e 's/@WORDSIZE@/$(WORDSIZE)/' \ - -e "s/@VERSION@/`cat $(srcdir)/VERSION`/" \ - -e 's/@BFD_HOST_64BIT_LONG@/@HOST_64BIT_LONG@/' \ - < $(srcdir)/bfd-in2.h \ - > bfd.h-new - $(srcdir)/../move-if-change bfd.h-new $(BFD_H) +stmp-bfd.h: bfd-in3.h + rm -f bfd-tmp.h + cp bfd-in3.h bfd-tmp.h + $(SHELL) $(srcdir)/../move-if-change bfd-tmp.h $(BFD_H) + rm -f bfd-tmp.h touch stmp-bfd.h +bfd-in3.h: bfd-in2.h config.status + CONFIG_FILES=bfd-in3.h:bfd-in2.h CONFIG_HEADERS= $(SHELL) ./config.status + # Could really use a "copy-if-change"... headers: (cd $(docdir); $(MAKE) protos $(FLAGS_TO_PASS)) cp $(docdir)/bfd.h bfd-in2.h-new - $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h + $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h cp $(docdir)/libbfd.h libbfd.h-new - $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h + $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h cp $(docdir)/libcoff.h libcoff.h-new - $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h + $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h # The rules for the generated header files are here so that people can # type `make bfd-in2.h' if they remove it. They are not run by default. $(srcdir)/bfd-in2.h: (cd $(docdir); $(MAKE) bfd.h $(FLAGS_TO_PASS)) cp $(docdir)/bfd.h bfd-in2.h-new - $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h + $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h $(srcdir)/libbfd.h: (cd $(docdir); $(MAKE) libbfd.h $(FLAGS_TO_PASS)) cp $(docdir)/libbfd.h libbfd.h-new - $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h + $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h $(srcdir)/libcoff.h: (cd $(docdir); $(MAKE) libcoff.h $(FLAGS_TO_PASS)) cp $(docdir)/libcoff.h libcoff.h-new - $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h + $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h bfd.info: (cd $(docdir); $(MAKE) bfd.info $(FLAGS_TO_PASS)) @@ -785,6 +830,13 @@ (cd $(docdir); $(MAKE) bfd.ps $(FLAGS_TO_PASS)) +elf32-d10v.o: elf32-d10v.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + elf32-target.h + + + + $(OFILES): stamp-picdir stamp-picdir: @@ -799,10 +851,10 @@ # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. archive.o: archive.c $(INCDIR)/aout/ar.h $(INCDIR)/aout/ranlib.h archures.o: archures.c -bfd.o: bfd.c $(INCDIR)/bfdlink.h $(INCDIR)/coff/internal.h \ - $(INCDIR)/coff/sym.h libcoff.h libecoff.h $(INCDIR)/coff/ecoff.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h +bfd.o: bfd.c $(INCDIR)/libiberty.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h libcoff.h \ + libecoff.h $(INCDIR)/coff/ecoff.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h cache.o: cache.c coffgen.o: coffgen.c $(INCDIR)/coff/internal.h libcoff.h \ $(INCDIR)/bfdlink.h @@ -810,13 +862,13 @@ format.o: format.c init.o: init.c libbfd.o: libbfd.c -opncls.o: opncls.c +opncls.o: opncls.c $(INCDIR)/objalloc.h reloc.o: reloc.c $(INCDIR)/bfdlink.h section.o: section.c syms.o: syms.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def -targets.o: targets.c -hash.o: hash.c +targets.o: targets.c $(INCDIR)/fnmatch.h targmatch.h +hash.o: hash.c $(INCDIR)/objalloc.h linker.o: linker.c $(INCDIR)/bfdlink.h genlink.h elf.o: elf.c $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h @@ -836,9 +888,12 @@ cpu-i386.o: cpu-i386.c cpu-i860.o: cpu-i860.c cpu-i960.o: cpu-i960.c +cpu-m32r.o: cpu-m32r.c cpu-m68k.o: cpu-m68k.c cpu-m88k.o: cpu-m88k.c cpu-mips.o: cpu-mips.c +cpu-m10200.o: cpu-m10200.c +cpu-m10300.o: cpu-m10300.c cpu-ns32k.o: cpu-ns32k.c ns32k.h cpu-powerpc.o: cpu-powerpc.c cpu-rs6000.o: cpu-rs6000.c @@ -850,8 +905,15 @@ cpu-z8k.o: cpu-z8k.c aout-adobe.o: aout-adobe.c $(INCDIR)/aout/adobe.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def libaout.h $(INCDIR)/bfdlink.h +aout-arm.o: aout-arm.c libaout.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/aout/aout64.h aoutx.h $(INCDIR)/aout/stab_gnu.h \ + $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h aout-ns32k.o: aout-ns32k.c $(INCDIR)/aout/aout64.h \ ns32k.h libaout.h $(INCDIR)/bfdlink.h +aout-sparcle.o: aout-sparcle.c $(INCDIR)/bfdlink.h \ + libaout.h aoutf1.h $(INCDIR)/aout/sun4.h $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \ + aout-target.h aout0.o: aout0.c aoutf1.h $(INCDIR)/aout/sun4.h libaout.h \ $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h @@ -911,6 +973,9 @@ $(INCDIR)/coff/internal.h libcoff.h coffcode.h coffswap.h coff-sparc.o: coff-sparc.c $(INCDIR)/coff/sparc.h $(INCDIR)/coff/internal.h \ libcoff.h $(INCDIR)/bfdlink.h coffcode.h coffswap.h +coff-svm68k.o: coff-svm68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \ + $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \ + coffcode.h coffswap.h coff-u68k.o: coff-u68k.c coff-m68k.c $(INCDIR)/coff/m68k.h \ $(INCDIR)/coff/internal.h libcoff.h $(INCDIR)/bfdlink.h \ coffcode.h coffswap.h @@ -927,9 +992,10 @@ libaout.h $(INCDIR)/aout/aout64.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ libcoff.h libecoff.h -ecofflink.o: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h \ - $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h \ - $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h +ecofflink.o: ecofflink.c $(INCDIR)/bfdlink.h $(INCDIR)/objalloc.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h \ + $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ + libcoff.h libecoff.h elf32-gen.o: elf32-gen.c elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ elf32-target.h @@ -943,6 +1009,9 @@ elf32-i860.o: elf32-i860.c elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ elf32-target.h +elf32-m32r.o: elf32-m32r.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/m32r.h elf32-target.h elf32-m68k.o: elf32-m68k.c $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ elf32-target.h @@ -955,28 +1024,44 @@ $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \ elf32-target.h +elf-m10200.o: elf-m10200.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + elf32-target.h +elf-m10300.o: elf-m10300.c elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + elf32-target.h elf32-ppc.o: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/elf/ppc.h elf32-target.h +elf32-sh.o: elf32-sh.c $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + elf32-target.h elf32-sparc.o: elf32-sparc.c $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/elf/sparc.h elf32-target.h elf32.o: elf32.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ - elfcore.h elflink.h + $(INCDIR)/fnmatch.h elfcore.h elflink.h elflink.o: elflink.c $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h +hp300bsd.o: hp300bsd.c libaout.h $(INCDIR)/bfdlink.h \ + aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ + $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h hp300hpux.o: hp300hpux.c $(INCDIR)/aout/hp300hpux.h \ aoutx.h $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \ $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \ aout-target.h som.o: som.c -i386aout.o: i386aout.c libaout.h $(INCDIR)/bfdlink.h \ - aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ +i386aout.o: i386aout.c $(INCDIR)/aout/aout64.h libaout.h \ + $(INCDIR)/bfdlink.h aout-target.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h i386bsd.o: i386bsd.c libaout.h $(INCDIR)/bfdlink.h \ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h +i386dynix.o: i386dynix.c $(INCDIR)/aout/dynix3.h aoutx.h \ + $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \ + aout-target.h i386freebsd.o: i386freebsd.c freebsd.h libaout.h $(INCDIR)/bfdlink.h \ aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h @@ -996,6 +1081,9 @@ i386os9k.o: i386os9k.c $(INCDIR)/bfdlink.h libaout.h \ $(INCDIR)/os9k.h ieee.o: ieee.c $(INCDIR)/ieee.h libieee.h +m68k4knetbsd.o: m68k4knetbsd.c netbsd.h libaout.h $(INCDIR)/bfdlink.h \ + aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ + $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h m68klinux.o: m68klinux.c $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h libaout.h \ $(INCDIR)/bfdlink.h aout-target.h @@ -1055,6 +1143,12 @@ ppcboot.o: ppcboot.c reloc16.o: reloc16.c $(INCDIR)/bfdlink.h genlink.h \ $(INCDIR)/coff/internal.h libcoff.h +riscix.o: riscix.c libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \ + aout-target.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \ + $(INCDIR)/aout/ar.h +sparclinux.o: sparclinux.c $(INCDIR)/aout/aout64.h \ + $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \ + libaout.h $(INCDIR)/bfdlink.h aout-target.h sparclynx.o: sparclynx.c $(INCDIR)/aout/sun4.h libaout.h \ $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h @@ -1086,8 +1180,8 @@ elf64-gen.o: elf64-gen.c elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ elf64-target.h -elf64-mips.o: elf64-mips.c $(INCDIR)/bfdlink.h genlink.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ +elf64-mips.o: elf64-mips.c $(INCDIR)/aout/ar.h $(INCDIR)/bfdlink.h \ + genlink.h elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/coff/sym.h \ $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \ @@ -1097,7 +1191,7 @@ $(INCDIR)/elf/sparc.h elf64-target.h elf64.o: elf64.c elfcode.h $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ - elfcore.h elflink.h + $(INCDIR)/fnmatch.h elfcore.h elflink.h evax-alpha.o: evax-alpha.c $(INCDIR)/bfdlink.h evax.h evax-egsd.o: evax-egsd.c $(INCDIR)/bfdlink.h evax.h evax-etir.o: evax-etir.c $(INCDIR)/bfdlink.h evax.h @@ -1116,11 +1210,4 @@ osf-core.o: osf-core.c trad-core.o: trad-core.c libaout.h $(INCDIR)/bfdlink.h cisco-core.o: cisco-core.c -i386dynix.o: i386dynix.c $(INCDIR)/aout/dynix3.h aoutx.h \ - $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \ - $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h \ - aout-target.h -hp300bsd.o: hp300bsd.c libaout.h $(INCDIR)/bfdlink.h \ - aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ - $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff -urN binutils-2.7/bfd/README binutils-2.8/bfd/README --- binutils-2.7/bfd/README Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/README Wed Apr 30 12:55:45 1997 @@ -0,0 +1,48 @@ +BFD is a an object file library. It permits applications to use the +same routines to process object files regardless of their format. + +BFD is used by the GNU debugger, assembler, linker, and the binary +utilities. + +The documentation on using BFD is scanty and may be occasionally +incorrect. Pointers to documentation problems, or an entirely +rewritten manual, would be appreciated. + +BFD is normally built as part of another package. See the build +instructions for that package, probably in a README file in the +appropriate directory. + +BFD supports the following configure options: + + --target=TARGET + The default target for which to build the library. TARGET is + a configuration target triplet, such as sparc-sun-solaris. + --enable-targets=TARGET,TARGET,TARGET... + Additional targets the library should support. To include + support for all known targets, use --enable-targets=all. + --enable-64-bit-bfd + Include support for 64 bit targets. This is automatically + turned on if you explicitly request a 64 bit target, but not + for --enable-targets=all. This requires a compiler with a 64 + bit integer type, such as gcc. + --enable-shared + Build BFD as a shared library. + --enable-commonbfdlib + Build BFD, opcodes, and libiberty as a single shared library. + --with-mmap + Use mmap when accessing files. This is faster on some hosts, + but slower on others. It may not work on all hosts. + +Report bugs with BFD to bug-gnu-utils@prep.ai.mit.edu. + +Patches are encouraged. When sending patches, always send the output +of diff -u or diff -c from the original file to the new file. Do not +send default diff output. Do not make the diff from the new file to +the original file. Remember that any patch must not break other +systems. Remember that BFD must support cross compilation from any +host to any target, so patches which use ``#ifdef HOST'' are not +acceptable. Please also read the ``Reporting Bugs'' section of the +gcc manual. + +Bug reports without patches will be remembered, but they may never get +fixed until somebody volunteers to fix them. diff -urN binutils-2.7/bfd/TODO binutils-2.8/bfd/TODO --- binutils-2.7/bfd/TODO Thu Jul 4 12:17:31 1996 +++ binutils-2.8/bfd/TODO Wed Apr 30 12:55:45 1997 @@ -4,7 +4,7 @@ is in a single bfd_target structure. Hence all the code for *writing* object files is still pulled into all the applications that only care about *reading* (gdb, nm, objdump), while gas has - to carry along all the unneded baggage for reading objects. And + to carry along all the unneeded baggage for reading objects. And so on. This would be a substantial change, and the payoff would not all that great (essentially none if bfd is used as a shared library). diff -urN binutils-2.7/bfd/VERSION binutils-2.8/bfd/VERSION --- binutils-2.7/bfd/VERSION Thu Jul 4 15:28:15 1996 +++ binutils-2.8/bfd/VERSION Wed Apr 30 12:55:45 1997 @@ -1 +1 @@ -2.7 +2.8 diff -urN binutils-2.7/bfd/acconfig.h binutils-2.8/bfd/acconfig.h --- binutils-2.7/bfd/acconfig.h Thu Jul 4 12:17:31 1996 +++ binutils-2.8/bfd/acconfig.h Wed Apr 30 12:55:45 1997 @@ -1,9 +1,18 @@ +/* Whether strstr must be declared even if is included. */ +#undef NEED_DECLARATION_STRSTR + /* Whether malloc must be declared even if is included. */ #undef NEED_DECLARATION_MALLOC +/* Whether realloc must be declared even if is included. */ +#undef NEED_DECLARATION_REALLOC + /* Whether free must be declared even if is included. */ #undef NEED_DECLARATION_FREE + +/* Whether getenv must be declared even if is included. */ +#undef NEED_DECLARATION_GETENV @TOP@ /* Do we need to use the b modifier when opening binary files? */ diff -urN binutils-2.7/bfd/aclocal.m4 binutils-2.8/bfd/aclocal.m4 --- binutils-2.7/bfd/aclocal.m4 Thu Jul 4 12:17:31 1996 +++ binutils-2.8/bfd/aclocal.m4 Wed Apr 30 12:55:45 1997 @@ -3,7 +3,7 @@ [AC_REQUIRE([AC_CANONICAL_SYSTEM]) case "${host}" in changequote(,)dnl -i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32) +i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32 | *-*-windows) changequote([,])dnl AC_DEFINE(USE_BINARY_FOPEN) ;; esac])dnl @@ -11,7 +11,6 @@ dnl Get a default for CC_FOR_BUILD to put into Makefile. AC_DEFUN(BFD_CC_FOR_BUILD, [# Put a plausible default for CC_FOR_BUILD in Makefile. -AC_REQUIRE([AC_C_CROSS])dnl if test -z "$CC_FOR_BUILD"; then if test "x$cross_compiling" = "xno"; then CC_FOR_BUILD='$(CC)' @@ -27,6 +26,13 @@ AC_CACHE_VAL(bfd_cv_decl_needed_$1, [AC_TRY_COMPILE([ #include +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif #ifdef HAVE_STDLIB_H #include #endif diff -urN binutils-2.7/bfd/aix386-core.c binutils-2.8/bfd/aix386-core.c --- binutils-2.7/bfd/aix386-core.c Thu Jul 4 12:17:31 1996 +++ binutils-2.8/bfd/aix386-core.c Wed Apr 30 12:55:45 1997 @@ -1,7 +1,8 @@ /* BFD back-end for AIX on PS/2 core files. This was based on trad-core.c, which was written by John Gilmore of Cygnus Support. - Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1988, 89, 91, 92, 93, 94, 95, 96, 1997 + Free Software Foundation, Inc. Written by Minh Tran-Le . Converted to back end form by Ian Lance Taylor . @@ -24,7 +25,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/i386.h" #include "coff/internal.h" #include "libcoff.h" @@ -68,6 +68,8 @@ asection *sections[MAX_CORE_SEGS]; }; +static void swap_abort PARAMS ((void)); + static const bfd_target * aix386_core_file_p (abfd) bfd *abfd; @@ -234,7 +236,7 @@ } /* If somebody calls any byte-swapping routines, shoot them. */ -void +static void swap_abort() { abort(); /* This way doesn't require any declaration for ANSI to fuck up */ diff -urN binutils-2.7/bfd/aout-adobe.c binutils-2.8/bfd/aout-adobe.c --- binutils-2.7/bfd/aout-adobe.c Thu Jul 4 12:17:31 1996 +++ binutils-2.8/bfd/aout-adobe.c Wed Apr 30 12:55:45 1997 @@ -112,8 +112,6 @@ take just about any a.out file as an Adobe a.out file. FIXME! */ if (N_BADMAG (anexec)) { - extern char *getenv (); - targ = getenv ("GNUTARGET"); if (targ && !strcmp (targ, a_out_adobe_vec.name)) ; /* Just continue anyway, if specifically set to this format */ diff -urN binutils-2.7/bfd/aout-arm.c binutils-2.8/bfd/aout-arm.c --- binutils-2.7/bfd/aout-arm.c Thu Jul 4 12:17:32 1996 +++ binutils-2.8/bfd/aout-arm.c Wed Apr 30 12:55:45 1997 @@ -1,5 +1,5 @@ /* BFD back-end for raw ARM a.out binaries. - Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -38,7 +38,6 @@ #include "bfd.h" #include "sysdep.h" -#include "assert.h" #define MYARM(OP) CAT(aoutarm_,OP) reloc_howto_type *MYARM(bfd_reloc_type_lookup) @@ -348,7 +347,6 @@ { int r_index; int r_extern; - unsigned int r_length; int r_pcrel; struct aoutdata *su = &(abfd->tdata.aout_data->a); diff -urN binutils-2.7/bfd/aout-sparcle.c binutils-2.8/bfd/aout-sparcle.c --- binutils-2.7/bfd/aout-sparcle.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/aout-sparcle.c Wed Apr 30 12:55:46 1997 @@ -0,0 +1,32 @@ +/* BFD backend for sparc little-endian aout binaries. + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Cygnus Support. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define TARGETNAME "a.out-sparc-little" +#define MY(OP) CAT(sparcle_aout_,OP) + +#include "bfd.h" +#include "bfdlink.h" +#include "libaout.h" + +#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_SPARCLET) + +/* Include the usual a.out support. */ +#define TARGET_IS_LITTLE_ENDIAN_P +#include "aoutf1.h" diff -urN binutils-2.7/bfd/aout-target.h binutils-2.8/bfd/aout-target.h --- binutils-2.7/bfd/aout-target.h Thu Jul 4 12:17:33 1996 +++ binutils-2.8/bfd/aout-target.h Wed Apr 30 12:55:46 1997 @@ -1,5 +1,6 @@ /* Define a target vector and some small routines for a variant of a.out. - Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -22,11 +23,19 @@ #include "aout/ar.h" /*#include "libaout.h"*/ -extern reloc_howto_type * NAME(aout,reloc_type_lookup) (); +#ifndef SEGMENT_SIZE +#define SEGMENT_SIZE TARGET_PAGE_SIZE +#endif + +extern reloc_howto_type * NAME(aout,reloc_type_lookup) + PARAMS ((bfd *, bfd_reloc_code_real_type)); /* Set parameters about this a.out file that are machine-dependent. This routine is called from some_aout_object_p just before it returns. */ #ifndef MY_callback + +static const bfd_target *MY(callback) PARAMS ((bfd *)); + static const bfd_target * MY(callback) (abfd) bfd *abfd; @@ -43,6 +52,23 @@ obj_datasec (abfd)->vma = N_DATADDR(*execp); obj_bsssec (abfd)->vma = N_BSSADDR(*execp); + /* For some targets, if the entry point is not in the same page + as the start of the text, then adjust the VMA so that it is. + FIXME: Do this with a macro like SET_ARCH_MACH instead? */ + if (aout_backend_info (abfd)->entry_is_text_address + && execp->a_entry > obj_textsec (abfd)->vma) + { + bfd_vma adjust; + + adjust = execp->a_entry - obj_textsec (abfd)->vma; + /* Adjust only by whole pages. */ + adjust &= ~(TARGET_PAGE_SIZE - 1); + obj_textsec (abfd)->vma += adjust; + obj_datasec (abfd)->vma += adjust; + obj_bsssec (abfd)->vma += adjust; + } + + /* Set the load addresses to be the same as the virtual addresses. */ obj_textsec (abfd)->lma = obj_textsec (abfd)->vma; obj_datasec (abfd)->lma = obj_datasec (abfd)->vma; obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma; @@ -66,6 +92,15 @@ bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0); #endif + /* The number of relocation records. This must be called after + SET_ARCH_MACH. It assumes that SET_ARCH_MACH will set + obj_reloc_entry_size correctly, if the reloc size is not + RELOC_STD_SIZE. */ + obj_textsec (abfd)->reloc_count = + execp->a_trsize / obj_reloc_entry_size (abfd); + obj_datasec (abfd)->reloc_count = + execp->a_drsize / obj_reloc_entry_size (abfd); + /* Now that we know the architecture, set the alignments of the sections. This is normally done by NAME(aout,new_section_hook), but when the initial sections were created the architecture had @@ -90,11 +125,7 @@ Sizes get set in set_sizes callback, later. */ #if 0 adata(abfd).page_size = TARGET_PAGE_SIZE; -#ifdef SEGMENT_SIZE adata(abfd).segment_size = SEGMENT_SIZE; -#else - adata(abfd).segment_size = TARGET_PAGE_SIZE; -#endif adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE; #endif @@ -105,6 +136,8 @@ #ifndef MY_object_p /* Finish up the reading of an a.out file header */ +static const bfd_target *MY(object_p) PARAMS ((bfd *)); + static const bfd_target * MY(object_p) (abfd) bfd *abfd; @@ -166,6 +199,9 @@ #ifndef MY_mkobject + +static boolean MY(mkobject) PARAMS ((bfd *)); + static boolean MY(mkobject) (abfd) bfd *abfd; @@ -175,11 +211,7 @@ #if 0 /* Sizes get set in set_sizes callback, later, after we know the architecture and machine. */ adata(abfd).page_size = TARGET_PAGE_SIZE; -#ifdef SEGMENT_SIZE adata(abfd).segment_size = SEGMENT_SIZE; -#else - adata(abfd).segment_size = TARGET_PAGE_SIZE; -#endif adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE; #endif return true; @@ -195,6 +227,9 @@ section contents, and copy_private_bfd_data is not called until after the section contents have been set. */ +static boolean MY_bfd_copy_private_section_data + PARAMS ((bfd *, asection *, bfd *, asection *)); + /*ARGSUSED*/ static boolean MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec) @@ -203,7 +238,8 @@ bfd *obfd; asection *osec; { - if (bfd_get_flavour (obfd) == bfd_target_aout_flavour) + if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour + && bfd_get_flavour (obfd) == bfd_target_aout_flavour) obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); return true; } @@ -236,17 +272,15 @@ #endif #ifndef MY_set_sizes + +static boolean MY(set_sizes) PARAMS ((bfd *)); + static boolean MY(set_sizes) (abfd) bfd *abfd; { adata(abfd).page_size = TARGET_PAGE_SIZE; - -#ifdef SEGMENT_SIZE adata(abfd).segment_size = SEGMENT_SIZE; -#else - adata(abfd).segment_size = TARGET_PAGE_SIZE; -#endif #ifdef ZMAGIC_DISK_BLOCK_SIZE adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE; @@ -272,6 +306,9 @@ #ifndef MY_text_includes_header #define MY_text_includes_header 0 #endif +#ifndef MY_entry_is_text_address +#define MY_entry_is_text_address 0 +#endif #ifndef MY_exec_header_not_counted #define MY_exec_header_not_counted 0 #endif @@ -297,6 +334,7 @@ static CONST struct aout_backend_data MY(backend_data) = { MY_zmagic_contiguous, MY_text_includes_header, + MY_entry_is_text_address, MY_exec_hdr_flags, 0, /* text vma? */ MY_set_sizes, @@ -339,6 +377,8 @@ /* Final link routine. We need to use a call back to get the correct offsets in the output file. */ +static boolean MY_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *)); + static boolean MY_bfd_final_link (abfd, info) bfd *abfd; @@ -512,8 +552,8 @@ #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags #endif -#ifndef MY_bfd_is_local_label -#define MY_bfd_is_local_label bfd_generic_is_local_label +#ifndef MY_bfd_is_local_label_name +#define MY_bfd_is_local_label_name bfd_generic_is_local_label_name #endif #ifndef MY_bfd_free_cached_info diff -urN binutils-2.7/bfd/aoutf1.h binutils-2.8/bfd/aoutf1.h --- binutils-2.7/bfd/aoutf1.h Thu Jul 4 12:17:33 1996 +++ binutils-2.8/bfd/aoutf1.h Wed Apr 30 12:55:47 1997 @@ -1,5 +1,5 @@ /* A.out "format 1" file handling code for BFD. - Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -65,13 +65,52 @@ /*SUPPRESS558*/ /*SUPPRESS529*/ -static void #if ARCH_SIZE == 64 -sunos_64_set_arch_mach +#define sunos_set_arch_mach sunos_64_set_arch_mach +#define sunos_write_object_contents aout_64_sunos4_write_object_contents #else -sunos_32_set_arch_mach +#define sunos_set_arch_mach sunos_32_set_arch_mach +#define sunos_write_object_contents aout_32_sunos4_write_object_contents #endif - (abfd, machtype) + +static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *)); +static void sunos_set_arch_mach PARAMS ((bfd *, int)); +static void choose_reloc_size PARAMS ((bfd *)); +static boolean sunos_write_object_contents PARAMS ((bfd *)); +static const bfd_target *sunos4_core_file_p PARAMS ((bfd *)); +static char *sunos4_core_file_failing_command PARAMS ((bfd *)); +static int sunos4_core_file_failing_signal PARAMS ((bfd *)); +static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *)); +static boolean sunos4_set_sizes PARAMS ((bfd *)); + +/* Merge backend data into the output file. + This is necessary on sparclet-aout where we want the resultant machine + number to be M_SPARCLET if any input file is M_SPARCLET. */ + +#define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data + +static boolean +sunos_merge_private_bfd_data (ibfd, obfd) + bfd *ibfd, *obfd; +{ + if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour + || bfd_get_flavour (obfd) != bfd_target_aout_flavour) + return true; + + if (bfd_get_arch (obfd) == bfd_arch_sparc) + { + if (bfd_get_mach (obfd) < bfd_get_mach (ibfd)) + bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd)); + } + + return true; +} + +/* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach, + depending upon ARCH_SIZE. */ + +static void +sunos_set_arch_mach (abfd, machtype) bfd *abfd; int machtype; { @@ -155,17 +194,14 @@ } } -/* Write an object file in SunOS format. - Section contents have already been written. We write the - file header, symbols, and relocation. */ +/* Write an object file in SunOS format. Section contents have + already been written. We write the file header, symbols, and + relocation. The real name of this function is either + aout_64_sunos4_write_object_contents or + aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */ static boolean -#if ARCH_SIZE == 64 -aout_64_sunos4_write_object_contents -#else -aout_32_sunos4_write_object_contents -#endif - (abfd) +sunos_write_object_contents (abfd) bfd *abfd; { struct external_exec exec_bytes; @@ -361,6 +397,13 @@ int c_ucode; /* Exception no. from u_code */ }; +static void swapcore_sun3 + PARAMS ((bfd *, char *, struct internal_sunos_core *)); +static void swapcore_sparc + PARAMS ((bfd *, char *, struct internal_sunos_core *)); +static void swapcore_solaris_bcp + PARAMS ((bfd *, char *, struct internal_sunos_core *)); + /* byte-swap in the Sun-3 core structure */ static void swapcore_sun3 (abfd, ext, intcore) @@ -749,6 +792,9 @@ #define MY_exec_hdr_flags 1 #endif +#ifndef MY_entry_is_text_address +#define MY_entry_is_text_address 0 +#endif #ifndef MY_add_dynamic_symbols #define MY_add_dynamic_symbols 0 #endif @@ -772,6 +818,7 @@ { 0, /* zmagic files are not contiguous */ 1, /* text includes header */ + MY_entry_is_text_address, MY_exec_hdr_flags, 0, /* default text vma */ sunos4_set_sizes, @@ -796,6 +843,8 @@ #define MY_write_object_contents NAME(aout,sunos4_write_object_contents) #define MY_backend_data &sunos4_aout_backend +#ifndef TARGET_IS_LITTLE_ENDIAN_P #define TARGET_IS_BIG_ENDIAN_P +#endif #include "aout-target.h" diff -urN binutils-2.7/bfd/aoutx.h binutils-2.8/bfd/aoutx.h --- binutils-2.7/bfd/aoutx.h Thu Jul 4 12:17:37 1996 +++ binutils-2.8/bfd/aoutx.h Wed Apr 30 12:55:47 1997 @@ -1,5 +1,5 @@ /* BFD semi-generic back-end for a.out binaries. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -136,6 +136,9 @@ PARAMS ((bfd *, aout_symbol_type *)); static boolean translate_to_native_sym_flags PARAMS ((bfd *, asymbol *, struct external_nlist *)); +static void adjust_o_magic PARAMS ((bfd *, struct internal_exec *)); +static void adjust_z_magic PARAMS ((bfd *, struct internal_exec *)); +static void adjust_n_magic PARAMS ((bfd *, struct internal_exec *)); /* SUBSECTION @@ -449,7 +452,7 @@ execp = abfd->tdata.aout_data->a.hdr; /* Set the file flags */ - abfd->flags = NO_FLAGS; + abfd->flags = BFD_NO_FLAGS; if (execp->a_drsize || execp->a_trsize) abfd->flags |= HAS_RELOC; /* Setting of EXEC_P has been deferred to the bottom of this function */ @@ -582,9 +585,20 @@ guess at whether the file is executable. If the entry point is within the text segment, assume it is. (This makes files executable even if their entry point address is 0, as long as - their text starts at zero.). */ - if ((execp->a_entry >= obj_textsec(abfd)->vma) && - (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size)) + their text starts at zero.). + + This test had to be changed to deal with systems where the text segment + runs at a different location than the default. The problem is that the + entry address can appear to be outside the text segment, thus causing an + erroneous conclusion that the file isn't executable. + + To fix this, we now accept any non-zero entry point as an indication of + executability. This will work most of the time, since only the linker + sets the entry point, and that is likely to be non-zero for most systems. */ + + if (execp->a_entry != 0 + || (execp->a_entry >= obj_textsec(abfd)->vma + && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size)) abfd->flags |= EXEC_P; #ifdef STAT_FOR_EXEC else @@ -1236,7 +1250,7 @@ syms = (struct external_nlist *) obj_aout_sym_window (abfd).data; #else /* We allocate using malloc to make the values easy to free - later on. If we put them on the obstack it might not be + later on. If we put them on the objalloc it might not be possible to free them. */ syms = ((struct external_nlist *) bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE)); @@ -1941,6 +1955,9 @@ /* Standard reloc stuff */ /* Output standard relocation information to a file in target byte order. */ +extern void NAME(aout,swap_std_reloc_out) + PARAMS ((bfd *, arelent *, struct reloc_std_external *)); + void NAME(aout,swap_std_reloc_out) (abfd, g, natptr) bfd *abfd; @@ -2036,6 +2053,9 @@ /* Extended stuff */ /* Output extended relocation information to a file in target byte order. */ +extern void NAME(aout,swap_ext_reloc_out) + PARAMS ((bfd *, arelent *, struct reloc_ext_external *)); + void NAME(aout,swap_ext_reloc_out) (abfd, g, natptr) bfd *abfd; @@ -4262,10 +4282,8 @@ case discard_none: break; case discard_l: - if (*name == *finfo->info->lprefix - && (finfo->info->lprefix_len == 1 - || strncmp (name, finfo->info->lprefix, - finfo->info->lprefix_len) == 0)) + if ((type & N_STAB) == 0 + && bfd_is_local_label_name (input_bfd, name)) skip = true; break; case discard_all: @@ -5085,12 +5103,20 @@ { /* We are generating a relocateable output file, and must modify the reloc accordingly. */ - if (r_extern) + if (r_extern + || r_type == RELOC_BASE10 + || r_type == RELOC_BASE13 + || r_type == RELOC_BASE22) { /* If we know the symbol this relocation is against, convert it into a relocation against a section. This is what the native linker does. */ - h = sym_hashes[r_index]; + if (r_type == RELOC_BASE10 + || r_type == RELOC_BASE13 + || r_type == RELOC_BASE22) + h = NULL; + else + h = sym_hashes[r_index]; if (h != (struct aout_link_hash_entry *) NULL && (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak)) @@ -5206,8 +5232,12 @@ } /* As described above, we must always adjust a PC relative - reloc by the change in VMA of the source. */ - if (howto_table_ext[r_type].pc_relative) + reloc by the change in VMA of the source. However, if + pcrel_offset is set, then the addend does not include the + location within the section, in which case we don't need + to adjust anything. */ + if (howto_table_ext[r_type].pc_relative + && ! howto_table_ext[r_type].pcrel_offset) relocation -= (input_section->output_section->vma + input_section->output_offset - input_section->vma); diff -urN binutils-2.7/bfd/archive.c binutils-2.8/bfd/archive.c --- binutils-2.7/bfd/archive.c Thu Jul 4 12:17:38 1996 +++ binutils-2.8/bfd/archive.c Wed Apr 30 12:55:47 1997 @@ -1,5 +1,5 @@ /* BFD back-end for archive files (libraries). - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault. This file is part of BFD, the Binary File Descriptor library. @@ -142,12 +142,9 @@ #define BFD_GNU960_ARMAG(abfd) (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB) #endif -/* Can't define this in hosts/foo.h, because (e.g. in gprof) the hosts file - is included, then obstack.h, which thinks if offsetof is defined, it - doesn't need to include stddef.h. */ /* Define offsetof for those systems which lack it */ -#if !defined (offsetof) +#ifndef offsetof #define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) #endif @@ -780,7 +777,7 @@ ardata->first_file_filepos += (ardata->first_file_filepos) % 2; /* FIXME, we should provide some way to free raw_ardata when we are done using the strings from it. For now, it seems - to be allocated on an obstack anyway... */ + to be allocated on an objalloc anyway... */ bfd_has_map (abfd) = true; return true; } @@ -826,7 +823,9 @@ little, because our tools changed. Here's a horrible hack to clean up the crap. */ - if (stringsize > 0xfffff) + if (stringsize > 0xfffff + && bfd_get_arch (abfd) == bfd_arch_i960 + && bfd_get_flavour (abfd) == bfd_target_coff_flavour) { /* This looks dangerous, let's do it the other way around */ nsymz = bfd_getl32 ((PTR) int_buf); @@ -930,6 +929,12 @@ return do_slurp_bsd_armap (abfd); else if (!strncmp (nextname, "/ ", 16)) return do_slurp_coff_armap (abfd); + else if (!strncmp (nextname, "/SYM64/ ", 16)) + { + /* Irix 6 archive--must be recognized by code in elf64-mips.c. */ + bfd_set_error (bfd_error_wrong_format); + return false; + } bfd_has_map (abfd) = false; return true; @@ -1034,7 +1039,7 @@ ardata->first_file_filepos += (ardata->first_file_filepos) % 2; /* FIXME, we should provide some way to free raw_ardata when we are done using the strings from it. For now, it seems - to be allocated on an obstack anyway... */ + to be allocated on an objalloc anyway... */ bfd_has_map (abfd) = true; return true; } @@ -1117,7 +1122,7 @@ (bfd_ardata (abfd)->first_file_filepos) % 2; /* FIXME, we can't release namedata here because it was allocated - below extended_names on the obstack... */ + below extended_names on the objalloc... */ /* bfd_release (abfd, namedata); */ } return true; @@ -1720,7 +1725,7 @@ if (map == NULL) goto error_return; - /* We put the symbol names on the arch obstack, and then discard + /* We put the symbol names on the arch objalloc, and then discard them when done. */ first_name = bfd_alloc (arch, 1); if (first_name == NULL) @@ -1873,8 +1878,13 @@ bfd_ardata (arch)->armap_datepos = (SARMAG + offsetof (struct ar_hdr, ar_date[0])); sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp); +#ifndef _WIN32 sprintf (hdr.ar_uid, "%ld", (long) getuid ()); sprintf (hdr.ar_gid, "%ld", (long) getgid ()); +#else + sprintf (hdr.ar_uid, "%ld", (long) 666); + sprintf (hdr.ar_gid, "%ld", (long) 42); +#endif sprintf (hdr.ar_size, "%-10d", (int) mapsize); strncpy (hdr.ar_fmag, ARFMAG, 2); for (i = 0; i < sizeof (struct ar_hdr); i++) diff -urN binutils-2.7/bfd/archures.c binutils-2.8/bfd/archures.c --- binutils-2.7/bfd/archures.c Thu Jul 4 12:30:47 1996 +++ binutils-2.8/bfd/archures.c Wed Apr 30 12:55:47 1997 @@ -1,5 +1,5 @@ /* BFD library support routines for architectures. - Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Hacked by John Gilmore and Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -104,6 +104,8 @@ . ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a) . bfd_arch_mips, {* MIPS Rxxxx *} . bfd_arch_i386, {* Intel 386 *} +.#define bfd_mach_i386_i386 0 +.#define bfd_mach_i386_i8086 1 . bfd_arch_we32k, {* AT&T WE32xxx *} . bfd_arch_tahoe, {* CCI/Harris Tahoe *} . bfd_arch_i860, {* Intel 860 *} @@ -115,9 +117,11 @@ . bfd_arch_h8300, {* Hitachi H8/300 *} .#define bfd_mach_h8300 1 .#define bfd_mach_h8300h 2 +.#define bfd_mach_h8300s 3 . bfd_arch_powerpc, {* PowerPC *} . bfd_arch_rs6000, {* IBM RS/6000 *} . bfd_arch_hppa, {* HP PA RISC *} +. bfd_arch_d10v, {* Mitsubishi D10V *} . bfd_arch_z8k, {* Zilog Z8000 *} .#define bfd_mach_z8001 1 .#define bfd_mach_z8002 2 @@ -127,6 +131,9 @@ . bfd_arch_arm, {* Advanced Risc Machines ARM *} . bfd_arch_ns32k, {* National Semiconductors ns32000 *} . bfd_arch_w65, {* WDC 65816 *} +. bfd_arch_m32r, {* Mitsubishi M32R/D *} +. bfd_arch_mn10200, {* Matsushita MN10200 *} +. bfd_arch_mn10300, {* Matsushita MN10300 *} . bfd_arch_last . }; @@ -168,15 +175,19 @@ extern const bfd_arch_info_type bfd_a29k_arch; extern const bfd_arch_info_type bfd_alpha_arch; extern const bfd_arch_info_type bfd_arm_arch; +extern const bfd_arch_info_type bfd_d10v_arch; extern const bfd_arch_info_type bfd_h8300_arch; extern const bfd_arch_info_type bfd_h8500_arch; extern const bfd_arch_info_type bfd_hppa_arch; extern const bfd_arch_info_type bfd_i386_arch; extern const bfd_arch_info_type bfd_i860_arch; extern const bfd_arch_info_type bfd_i960_arch; +extern const bfd_arch_info_type bfd_m32r_arch; extern const bfd_arch_info_type bfd_m68k_arch; extern const bfd_arch_info_type bfd_m88k_arch; extern const bfd_arch_info_type bfd_mips_arch; +extern const bfd_arch_info_type bfd_mn10200_arch; +extern const bfd_arch_info_type bfd_mn10300_arch; extern const bfd_arch_info_type bfd_powerpc_arch; extern const bfd_arch_info_type bfd_rs6000_arch; extern const bfd_arch_info_type bfd_sh_arch; @@ -195,15 +206,19 @@ &bfd_a29k_arch, &bfd_alpha_arch, &bfd_arm_arch, + &bfd_d10v_arch, &bfd_h8300_arch, &bfd_h8500_arch, &bfd_hppa_arch, &bfd_i386_arch, &bfd_i860_arch, &bfd_i960_arch, + &bfd_m32r_arch, &bfd_m68k_arch, &bfd_m88k_arch, &bfd_mips_arch, + &bfd_mn10200_arch, + &bfd_mn10300_arch, &bfd_powerpc_arch, &bfd_rs6000_arch, &bfd_sh_arch, diff -urN binutils-2.7/bfd/bfd-in.h binutils-2.8/bfd/bfd-in.h --- binutils-2.7/bfd/bfd-in.h Thu Jul 4 12:17:39 1996 +++ binutils-2.8/bfd/bfd-in.h Wed Apr 30 12:55:47 1997 @@ -1,5 +1,5 @@ /* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Contributed by Cygnus Support. ** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them; @@ -49,12 +49,15 @@ #endif #include "ansidecl.h" -#include "obstack.h" /* These two lines get substitutions done by commands in Makefile.in. */ #define BFD_VERSION "@VERSION@" -#define BFD_ARCH_SIZE @WORDSIZE@ +#define BFD_ARCH_SIZE @wordsize@ #define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@ +#if @BFD_HOST_64_BIT_DEFINED@ +#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@ +#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@ +#endif #if BFD_ARCH_SIZE >= 64 #define BFD64 @@ -114,27 +117,29 @@ /* Support for different sizes of target format ints and addresses. If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be set to 1 above. Otherwise, if gcc is being used, this code will - use gcc's "long long" type. Otherwise, the compilation will fail - if 64-bit targets are requested. */ + use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be + defined above. */ #ifdef BFD64 #ifndef BFD_HOST_64_BIT #if BFD_HOST_64BIT_LONG #define BFD_HOST_64_BIT long +#define BFD_HOST_U_64_BIT unsigned long #else #ifdef __GNUC__ #define BFD_HOST_64_BIT long long +#define BFD_HOST_U_64_BIT unsigned long long #else /* ! defined (__GNUC__) */ #error No 64 bit integer type available #endif /* ! defined (__GNUC__) */ #endif /* ! BFD_HOST_64BIT_LONG */ #endif /* ! defined (BFD_HOST_64_BIT) */ -typedef unsigned BFD_HOST_64_BIT bfd_vma; +typedef BFD_HOST_U_64_BIT bfd_vma; typedef BFD_HOST_64_BIT bfd_signed_vma; -typedef unsigned BFD_HOST_64_BIT bfd_size_type; -typedef unsigned BFD_HOST_64_BIT symvalue; +typedef BFD_HOST_U_64_BIT bfd_size_type; +typedef BFD_HOST_U_64_BIT symvalue; #ifndef fprintf_vma #if BFD_HOST_64BIT_LONG @@ -193,7 +198,7 @@ to another, and are not necessarily correct). */ /* No flags. */ -#define NO_FLAGS 0x00 +#define BFD_NO_FLAGS 0x00 /* BFD contains relocation entries. */ #define HAS_RELOC 0x01 @@ -374,8 +379,9 @@ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); - /* An obstack for this hash table. */ - struct obstack memory; + /* An objalloc for this hash table. This is a struct objalloc *, + but we use PTR to avoid requiring the inclusion of objalloc.h. */ + PTR memory; }; /* Initialize a hash table. */ @@ -533,6 +539,7 @@ struct symbol_cache_entry; struct bfd_link_info; struct bfd_link_hash_entry; +struct bfd_elf_version_tree; #endif extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd)); extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value)); @@ -599,11 +606,13 @@ extern struct bfd_link_needed_list *bfd_elf_get_needed_list PARAMS ((bfd *, struct bfd_link_info *)); extern boolean bfd_elf32_size_dynamic_sections - PARAMS ((bfd *, const char *, const char *, boolean, - struct bfd_link_info *, struct sec **)); + PARAMS ((bfd *, const char *, const char *, boolean, const char *, + const char * const *, struct bfd_link_info *, struct sec **, + struct bfd_elf_version_tree *)); extern boolean bfd_elf64_size_dynamic_sections - PARAMS ((bfd *, const char *, const char *, boolean, - struct bfd_link_info *, struct sec **)); + PARAMS ((bfd *, const char *, const char *, boolean, const char *, + const char * const *, struct bfd_link_info *, struct sec **, + struct bfd_elf_version_tree *)); extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *)); extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *)); @@ -622,6 +631,8 @@ extern boolean bfd_i386linux_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); extern boolean bfd_m68klinux_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_sparclinux_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); /* mmap hacks */ diff -urN binutils-2.7/bfd/bfd-in2.h binutils-2.8/bfd/bfd-in2.h --- binutils-2.7/bfd/bfd-in2.h Thu Jul 4 12:30:50 1996 +++ binutils-2.8/bfd/bfd-in2.h Wed Apr 30 12:55:48 1997 @@ -1,5 +1,5 @@ /* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Contributed by Cygnus Support. ** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them; @@ -49,12 +49,15 @@ #endif #include "ansidecl.h" -#include "obstack.h" /* These two lines get substitutions done by commands in Makefile.in. */ #define BFD_VERSION "@VERSION@" -#define BFD_ARCH_SIZE @WORDSIZE@ +#define BFD_ARCH_SIZE @wordsize@ #define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@ +#if @BFD_HOST_64_BIT_DEFINED@ +#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@ +#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@ +#endif #if BFD_ARCH_SIZE >= 64 #define BFD64 @@ -114,27 +117,29 @@ /* Support for different sizes of target format ints and addresses. If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be set to 1 above. Otherwise, if gcc is being used, this code will - use gcc's "long long" type. Otherwise, the compilation will fail - if 64-bit targets are requested. */ + use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be + defined above. */ #ifdef BFD64 #ifndef BFD_HOST_64_BIT #if BFD_HOST_64BIT_LONG #define BFD_HOST_64_BIT long +#define BFD_HOST_U_64_BIT unsigned long #else #ifdef __GNUC__ #define BFD_HOST_64_BIT long long +#define BFD_HOST_U_64_BIT unsigned long long #else /* ! defined (__GNUC__) */ #error No 64 bit integer type available #endif /* ! defined (__GNUC__) */ #endif /* ! BFD_HOST_64BIT_LONG */ #endif /* ! defined (BFD_HOST_64_BIT) */ -typedef unsigned BFD_HOST_64_BIT bfd_vma; +typedef BFD_HOST_U_64_BIT bfd_vma; typedef BFD_HOST_64_BIT bfd_signed_vma; -typedef unsigned BFD_HOST_64_BIT bfd_size_type; -typedef unsigned BFD_HOST_64_BIT symvalue; +typedef BFD_HOST_U_64_BIT bfd_size_type; +typedef BFD_HOST_U_64_BIT symvalue; #ifndef fprintf_vma #if BFD_HOST_64BIT_LONG @@ -193,7 +198,7 @@ to another, and are not necessarily correct). */ /* No flags. */ -#define NO_FLAGS 0x00 +#define BFD_NO_FLAGS 0x00 /* BFD contains relocation entries. */ #define HAS_RELOC 0x01 @@ -374,8 +379,9 @@ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); - /* An obstack for this hash table. */ - struct obstack memory; + /* An objalloc for this hash table. This is a struct objalloc *, + but we use PTR to avoid requiring the inclusion of objalloc.h. */ + PTR memory; }; /* Initialize a hash table. */ @@ -533,6 +539,7 @@ struct symbol_cache_entry; struct bfd_link_info; struct bfd_link_hash_entry; +struct bfd_elf_version_tree; #endif extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd)); extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value)); @@ -599,11 +606,13 @@ extern struct bfd_link_needed_list *bfd_elf_get_needed_list PARAMS ((bfd *, struct bfd_link_info *)); extern boolean bfd_elf32_size_dynamic_sections - PARAMS ((bfd *, const char *, const char *, boolean, - struct bfd_link_info *, struct sec **)); + PARAMS ((bfd *, const char *, const char *, boolean, const char *, + const char * const *, struct bfd_link_info *, struct sec **, + struct bfd_elf_version_tree *)); extern boolean bfd_elf64_size_dynamic_sections - PARAMS ((bfd *, const char *, const char *, boolean, - struct bfd_link_info *, struct sec **)); + PARAMS ((bfd *, const char *, const char *, boolean, const char *, + const char * const *, struct bfd_link_info *, struct sec **, + struct bfd_elf_version_tree *)); extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *)); extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *)); @@ -623,6 +632,8 @@ PARAMS ((bfd *, struct bfd_link_info *)); extern boolean bfd_m68klinux_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_sparclinux_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); /* mmap hacks */ @@ -690,7 +701,7 @@ bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd)); bfd * -bfd_openstreamr PARAMS (()); +bfd_openstreamr PARAMS ((const char *, const char *, PTR)); bfd * bfd_openw PARAMS ((CONST char *filename, CONST char *target)); @@ -701,9 +712,6 @@ boolean bfd_close_all_done PARAMS ((bfd *)); -bfd_size_type -bfd_alloc_size PARAMS ((bfd *abfd)); - bfd * bfd_create PARAMS ((CONST char *filename, bfd *templ)); @@ -933,6 +941,12 @@ contents. */ #define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000 + /* This section was created by the linker as part of dynamic + relocation or other arcane processing. It is skipped when + going through the first-pass output, trusting that someone + else up the line will take care of it later. */ +#define SEC_LINKER_CREATED 0x800000 + /* End of section flags. */ /* Some internal packed boolean fields. */ @@ -1140,7 +1154,7 @@ bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec)); #define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ - BFD_SEND (ibfd, _bfd_copy_private_section_data, \ + BFD_SEND (obfd, _bfd_copy_private_section_data, \ (ibfd, isection, obfd, osection)) enum bfd_architecture { @@ -1181,6 +1195,8 @@ ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a) bfd_arch_mips, /* MIPS Rxxxx */ bfd_arch_i386, /* Intel 386 */ +#define bfd_mach_i386_i386 0 +#define bfd_mach_i386_i8086 1 bfd_arch_we32k, /* AT&T WE32xxx */ bfd_arch_tahoe, /* CCI/Harris Tahoe */ bfd_arch_i860, /* Intel 860 */ @@ -1192,9 +1208,11 @@ bfd_arch_h8300, /* Hitachi H8/300 */ #define bfd_mach_h8300 1 #define bfd_mach_h8300h 2 +#define bfd_mach_h8300s 3 bfd_arch_powerpc, /* PowerPC */ bfd_arch_rs6000, /* IBM RS/6000 */ bfd_arch_hppa, /* HP PA RISC */ + bfd_arch_d10v, /* Mitsubishi D10V */ bfd_arch_z8k, /* Zilog Z8000 */ #define bfd_mach_z8001 1 #define bfd_mach_z8002 2 @@ -1204,6 +1222,9 @@ bfd_arch_arm, /* Advanced Risc Machines ARM */ bfd_arch_ns32k, /* National Semiconductors ns32000 */ bfd_arch_w65, /* WDC 65816 */ + bfd_arch_m32r, /* Mitsubishi M32R/D */ + bfd_arch_mn10200, /* Matsushita MN10200 */ + bfd_arch_mn10300, /* Matsushita MN10300 */ bfd_arch_last }; @@ -1333,7 +1354,7 @@ struct reloc_howto_struct { - /* The type field has mainly a documetary use - the back end can + /* The type field has mainly a documentary use - the back end can do what it wants with it, though normally the back end's external idea of what a reloc number is stored in this field. For example, a PC relative word relocation @@ -1461,6 +1482,7 @@ BFD_RELOC_64, BFD_RELOC_32, BFD_RELOC_26, + BFD_RELOC_24, BFD_RELOC_16, BFD_RELOC_14, BFD_RELOC_8, @@ -1537,11 +1559,6 @@ BFD_RELOC_GPREL16, BFD_RELOC_GPREL32, -/* For openVMS/Alpha systems, these are displacements for switch -tables. */ - BFD_RELOC_SWREL32, - BFD_RELOC_SWREL64, - /* Reloc types used for i960/b.out. */ BFD_RELOC_I960_CALLJ, @@ -1613,6 +1630,12 @@ in with the file's GP value on reading, for convenience, as with the GPDISP_LO16 reloc. +The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. +It should refer to the symbol to be referenced, as with 16_GOTOFF, +but it generates output not based on the position within the .got +section, but relative to the GP value chosen for the file during the +final link stage. + The LITUSE reloc, on the instruction using the loaded address, gives information to the linker that it might be able to use to optimize away some literal section references. The symbol is ignored (read @@ -1624,6 +1647,7 @@ The GNU linker currently doesn't do any of this optimizing. */ BFD_RELOC_ALPHA_LITERAL, + BFD_RELOC_ALPHA_ELF_LITERAL, BFD_RELOC_ALPHA_LITUSE, /* The HINT relocation indicates a value that should be filled into the @@ -1631,17 +1655,24 @@ prediction logic which may be provided on some processors. */ BFD_RELOC_ALPHA_HINT, -/* The LINKAGE relocation outputs a special code in the object file, -the rest is handled by the linker. */ +/* The LINKAGE relocation outputs a linkage pair in the object file, +which is filled by the linker. */ BFD_RELOC_ALPHA_LINKAGE, -/* The BASEREG relocation calculates differences to basereg. */ - BFD_RELOC_ALPHA_BASEREG, +/* The CODEADDR relocation outputs a STO_CA in the object file, +which is filled by the linker. */ + BFD_RELOC_ALPHA_CODEADDR, /* Bits 27..2 of the relocation address shifted right 2 bits; simple reloc otherwise. */ BFD_RELOC_MIPS_JMP, +/* The MIPS16 jump instruction. */ + BFD_RELOC_MIPS16_JMP, + +/* MIPS16 GP relative reloc. */ + BFD_RELOC_MIPS16_GPREL, + /* High 16 bits of 32-bit value; simple reloc. */ BFD_RELOC_HI16, @@ -1752,6 +1783,92 @@ BFD_RELOC_ARM_LDR_IMM, BFD_RELOC_ARM_LITERAL, BFD_RELOC_ARM_IN_POOL, + BFD_RELOC_ARM_OFFSET_IMM8, + BFD_RELOC_ARM_HWLITERAL, + BFD_RELOC_ARM_THUMB_ADD, + BFD_RELOC_ARM_THUMB_IMM, + BFD_RELOC_ARM_THUMB_SHIFT, + BFD_RELOC_ARM_THUMB_OFFSET, + +/* Hitachi SH relocs. Not all of these appear in object files. */ + BFD_RELOC_SH_PCDISP8BY2, + BFD_RELOC_SH_PCDISP12BY2, + BFD_RELOC_SH_IMM4, + BFD_RELOC_SH_IMM4BY2, + BFD_RELOC_SH_IMM4BY4, + BFD_RELOC_SH_IMM8, + BFD_RELOC_SH_IMM8BY2, + BFD_RELOC_SH_IMM8BY4, + BFD_RELOC_SH_PCRELIMM8BY2, + BFD_RELOC_SH_PCRELIMM8BY4, + BFD_RELOC_SH_SWITCH16, + BFD_RELOC_SH_SWITCH32, + BFD_RELOC_SH_USES, + BFD_RELOC_SH_COUNT, + BFD_RELOC_SH_ALIGN, + BFD_RELOC_SH_CODE, + BFD_RELOC_SH_DATA, + BFD_RELOC_SH_LABEL, + + +/* Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_10_PCREL_R, + +/* Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. This is the same as the previous reloc +except it is in the left container, i.e., +shifted left 15 bits. */ + BFD_RELOC_D10V_10_PCREL_L, + +/* This is an 18-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_18, + +/* This is an 18-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_18_PCREL, + + + +/* Mitsubishi M32R relocs. +This is a 24 bit absolute address. */ + BFD_RELOC_M32R_24, + +/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_10_PCREL, + +/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_18_PCREL, + +/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_26_PCREL, + +/* This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as unsigned. */ + BFD_RELOC_M32R_HI16_ULO, + +/* This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as signed. */ + BFD_RELOC_M32R_HI16_SLO, + +/* This is a 16-bit reloc containing the lower 16 bits of an address. */ + BFD_RELOC_M32R_LO16, + +/* This is a 16-bit reloc containing the small data area offset for use in +add3, load, and store instructions. */ + BFD_RELOC_M32R_SDA16, + + +/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. */ + BFD_RELOC_MN10300_32_PCREL, + +/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. */ + BFD_RELOC_MN10300_16_PCREL, BFD_RELOC_UNUSED }; typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; reloc_howto_type * @@ -1884,8 +2001,11 @@ boolean bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym)); -#define bfd_is_local_label(abfd, sym) \ - BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym)) +boolean +bfd_is_local_label_name PARAMS ((bfd *abfd, const char *name)); + +#define bfd_is_local_label_name(abfd, name) \ + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) #define bfd_canonicalize_symtab(abfd, location) \ BFD_SEND (abfd, _bfd_canonicalize_symtab,\ (abfd, location)) @@ -1909,7 +2029,7 @@ bfd_copy_private_symbol_data PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym)); #define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ - BFD_SEND (ibfd, _bfd_copy_private_symbol_data, \ + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ (ibfd, isymbol, obfd, osymbol)) struct _bfd { @@ -2061,8 +2181,10 @@ /* Used by the application to hold private data*/ PTR usrdata; - /* Where all the allocated stuff under this BFD goes */ - struct obstack memory; + /* Where all the allocated stuff under this BFD goes. This is a + struct objalloc *, but we use PTR to avoid requiring the inclusion of + objalloc.h. */ + PTR memory; }; typedef enum bfd_error @@ -2149,13 +2271,13 @@ bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); #define bfd_copy_private_bfd_data(ibfd, obfd) \ - BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \ + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ (ibfd, obfd)) boolean bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); #define bfd_merge_private_bfd_data(ibfd, obfd) \ - BFD_SEND (ibfd, _bfd_merge_private_bfd_data, \ + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ (ibfd, obfd)) boolean bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags)); @@ -2414,7 +2536,7 @@ CAT(NAME,_make_empty_symbol),\ CAT(NAME,_print_symbol),\ CAT(NAME,_get_symbol_info),\ -CAT(NAME,_bfd_is_local_label),\ +CAT(NAME,_bfd_is_local_label_name),\ CAT(NAME,_get_lineno),\ CAT(NAME,_find_nearest_line),\ CAT(NAME,_bfd_make_debug_symbol),\ @@ -2433,7 +2555,7 @@ struct symbol_cache_entry *, symbol_info *)); #define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e)) - boolean (*_bfd_is_local_label) PARAMS ((bfd *, asymbol *)); + boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *)); alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *)); boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd, @@ -2529,6 +2651,9 @@ PTR backend_data; } bfd_target; +boolean +bfd_set_default_target PARAMS ((const char *name)); + const bfd_target * bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd)); diff -urN binutils-2.7/bfd/bfd.c binutils-2.8/bfd/bfd.c --- binutils-2.7/bfd/bfd.c Thu Jul 4 12:17:42 1996 +++ binutils-2.8/bfd/bfd.c Wed Apr 30 12:55:48 1997 @@ -1,5 +1,6 @@ /* Generic BFD library interface and support routines. - Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -182,8 +183,10 @@ . {* Used by the application to hold private data*} . PTR usrdata; . -. {* Where all the allocated stuff under this BFD goes *} -. struct obstack memory; +. {* Where all the allocated stuff under this BFD goes. This is a +. struct objalloc *, but we use PTR to avoid requiring the inclusion of +. objalloc.h. *} +. PTR memory; .}; . */ @@ -197,6 +200,7 @@ #include #endif +#include "libiberty.h" #include "bfdlink.h" #include "libbfd.h" #include "coff/internal.h" @@ -263,9 +267,6 @@ . */ -#undef strerror -extern char *strerror(); - static bfd_error_type bfd_error = bfd_error_no_error; CONST char *CONST bfd_errmsgs[] = { @@ -345,19 +346,7 @@ extern int errno; #endif if (error_tag == bfd_error_system_call) - { - const char *errmsg; - - errmsg = strerror (errno); - if (errmsg == NULL) - { - static char buf[32]; - - sprintf (buf, "Error %d", errno); - errmsg = buf; - } - return errmsg; - } + return xstrerror (errno); if ((((int)error_tag <(int) bfd_error_no_error) || ((int)error_tag > (int)bfd_error_invalid_error_code))) @@ -615,7 +604,7 @@ arelent **location; unsigned int count; { - asect->orelocation = location; + asect->orelocation = location; asect->reloc_count = count; } @@ -954,7 +943,7 @@ Not enough memory exists to create private data for @var{obfd}. .#define bfd_copy_private_bfd_data(ibfd, obfd) \ -. BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \ +. BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ . (ibfd, obfd)) */ @@ -975,7 +964,7 @@ Not enough memory exists to create private data for @var{obfd}. .#define bfd_merge_private_bfd_data(ibfd, obfd) \ -. BFD_SEND (ibfd, _bfd_merge_private_bfd_data, \ +. BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ . (ibfd, obfd)) */ @@ -1124,7 +1113,7 @@ m = ((struct elf_segment_map *) bfd_alloc (abfd, (sizeof (struct elf_segment_map) - + (count - 1) * sizeof (asection *)))); + + ((size_t) count - 1) * sizeof (asection *)))); if (m == NULL) return false; diff -urN binutils-2.7/bfd/binary.c binutils-2.8/bfd/binary.c --- binutils-2.7/bfd/binary.c Thu Jul 4 12:17:42 1996 +++ binutils-2.8/bfd/binary.c Wed Apr 30 12:55:48 1997 @@ -1,5 +1,5 @@ /* BFD back-end for binary objects. - Copyright 1994 Free Software Foundation, Inc. + Copyright 1994, 95, 96, 1997 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, This file is part of BFD, the Binary File Descriptor library. @@ -229,7 +229,7 @@ bfd_symbol_info (symbol, ret); } -#define binary_bfd_is_local_label bfd_generic_is_local_label +#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name #define binary_get_lineno _bfd_nosymbols_get_lineno #define binary_find_nearest_line _bfd_nosymbols_find_nearest_line #define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol @@ -255,19 +255,31 @@ file_ptr offset; bfd_size_type size; { + /* We don't want to output anything for a section that is neither + loaded nor allocated. The contents of such a section are not + meaningful in the binary format. */ + if ((sec->flags & (SEC_LOAD | SEC_ALLOC)) == 0) + return true; + if (! abfd->output_has_begun) { + boolean found_low; bfd_vma low; asection *s; /* The lowest section LMA sets the virtual address of the start of the file. We use this to set the file position of all the sections. */ - low = abfd->sections->lma; - for (s = abfd->sections->next; s != NULL; s = s->next) - if ((s->flags & SEC_HAS_CONTENTS) != 0 - && s->lma < low) - low = s->lma; + found_low = false; + low = 0; + for (s = abfd->sections; s != NULL; s = s->next) + if (((s->flags & (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC)) + == (SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC)) + && (! found_low || s->lma < low)) + { + low = s->lma; + found_low = true; + } for (s = abfd->sections; s != NULL; s = s->next) s->filepos = s->lma - low; diff -urN binutils-2.7/bfd/cf-m68klynx.c binutils-2.8/bfd/cf-m68klynx.c --- binutils-2.7/bfd/cf-m68klynx.c Thu Jul 4 12:17:45 1996 +++ binutils-2.8/bfd/cf-m68klynx.c Wed Apr 30 12:55:49 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Motorola M68K COFF LynxOS files. - Copyright 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -20,204 +20,9 @@ #define TARGET_SYM m68klynx_coff_vec #define TARGET_NAME "coff-m68k-lynx" - #define LYNXOS - #define COFF_LONG_FILENAMES - -#define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table -#define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto -#define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype -#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup - -#define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn - -#include "bfd.h" -#include "sysdep.h" - -#ifdef ANSI_PROTOTYPES -struct internal_reloc; -struct coff_link_hash_entry; -struct internal_syment; -#endif - -static bfd_reloc_status_type _bfd_m68klynx_special_fn - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static reloc_howto_type *coff_m68k_lynx_rtype_to_howto - PARAMS ((bfd *, asection *, struct internal_reloc *, - struct coff_link_hash_entry *, struct internal_syment *, - bfd_vma *)); - -/* For some reason when using m68k COFF the value stored in the .text - section for a reference to a common symbol is the value itself plus - any desired offset. (taken from work done by Ian Taylor, Cygnus Support, - for I386 COFF). */ - -/* If we are producing relocateable output, we need to do some - adjustments to the object file that are not done by the - bfd_perform_relocation function. This function is called by every - reloc type to make any required adjustments. */ - -static bfd_reloc_status_type -_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; -{ - symvalue diff; - - if (output_bfd == (bfd *) NULL) - return bfd_reloc_continue; - - if (bfd_is_com_section (symbol->section)) - { - /* We are relocating a common symbol. The current value in the - object file is ORIG + OFFSET, where ORIG is the value of the - common symbol as seen by the object file when it was compiled - (this may be zero if the symbol was undefined) and OFFSET is - the offset into the common symbol (normally zero, but may be - non-zero when referring to a field in a common structure). - ORIG is the negative of reloc_entry->addend, which is set by - the CALC_ADDEND macro below. We want to replace the value in - the object file with NEW + OFFSET, where NEW is the value of - the common symbol which we are going to put in the final - object file. NEW is symbol->value. */ - diff = symbol->value + reloc_entry->addend; - } - else - { - /* For some reason bfd_perform_relocation always effectively - ignores the addend for a COFF target when producing - relocateable output. This seems to be always wrong for 386 - COFF, so we handle the addend here instead. */ - diff = reloc_entry->addend; - } - -#define DOIT(x) \ - x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask)) - - if (diff != 0) - { - reloc_howto_type *howto = reloc_entry->howto; - unsigned char *addr = (unsigned char *) data + reloc_entry->address; - - switch (howto->size) - { - case 0: - { - char x = bfd_get_8 (abfd, addr); - DOIT (x); - bfd_put_8 (abfd, x, addr); - } - break; - - case 1: - { - short x = bfd_get_16 (abfd, addr); - DOIT (x); - bfd_put_16 (abfd, x, addr); - } - break; - - case 2: - { - long x = bfd_get_32 (abfd, addr); - DOIT (x); - bfd_put_32 (abfd, x, addr); - } - break; - - default: - abort (); - } - } - - /* Now let bfd_perform_relocation finish everything up. */ - return bfd_reloc_continue; -} -/* Compute the addend of a reloc. If the reloc is to a common symbol, - the object file contains the value of the common symbol. By the - time this is called, the linker may be using a different symbol - from a different object file with a different value. Therefore, we - hack wildly to locate the original symbol from this file so that we - can make the correct adjustment. This macro sets coffsym to the - symbol from the original file, and uses it to set the addend value - correctly. If this is not a common symbol, the usual addend - calculation is done, except that an additional tweak is needed for - PC relative relocs. - FIXME: This macro refers to symbols and asect; these are from the - calling function, not the macro arguments. */ - -#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ - { \ - coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \ - if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ - coffsym = (obj_symbols (abfd) \ - + (cache_ptr->sym_ptr_ptr - symbols)); \ - else if (ptr) \ - coffsym = coff_symbol_from (abfd, ptr); \ - if (coffsym != (coff_symbol_type *) NULL \ - && coffsym->native->u.syment.n_scnum == 0) \ - cache_ptr->addend = - coffsym->native->u.syment.n_value; \ - else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ - && ptr->section != (asection *) NULL) \ - cache_ptr->addend = - (ptr->section->vma + ptr->value); \ - else \ - cache_ptr->addend = 0; \ - if (ptr && (reloc.r_type == R_PCRBYTE \ - || reloc.r_type == R_PCRWORD \ - || reloc.r_type == R_PCRLONG)) \ - cache_ptr->addend += asect->vma; \ - } - -#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto +#define STATIC_RELOCS +#define COFF_COMMON_ADDEND #include "coff-m68k.c" - -/* coff-m68k.c uses the special COFF backend linker. We need to - adjust common symbols. - - We can't define this function until after we have included - coff-m68k.c, because it uses RTYPE2HOWTO. */ - -/*ARGSUSED*/ -static reloc_howto_type * -coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; - asection *sec; - struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; - bfd_vma *addendp; -{ - arelent relent; - reloc_howto_type *howto; - - RTYPE2HOWTO (&relent, rel); - - howto = relent.howto; - - if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0) - { - /* This is a common symbol. The section contents include the - size (sym->n_value) as an addend. The relocate_section - function will be adding in the final value of the symbol. We - need to subtract out the current size in order to get the - correct result. */ - BFD_ASSERT (h != NULL); - *addendp -= sym->n_value; - } - - /* If the output symbol is common (in which case this must be a - relocateable link), we need to add in the final size of the - common symbol. */ - if (h != NULL && h->root.type == bfd_link_hash_common) - *addendp += h->root.u.c.size; - - return howto; -} diff -urN binutils-2.7/bfd/cisco-core.c binutils-2.8/bfd/cisco-core.c --- binutils-2.7/bfd/cisco-core.c Thu Jul 4 12:17:45 1996 +++ binutils-2.8/bfd/cisco-core.c Wed Apr 30 12:55:49 1997 @@ -184,6 +184,9 @@ /* NAN */ case 54: abfd->tdata.cisco_core_data->sig = SIGFPE; break; default: +#ifndef SIGEMT +#define SIGEMT SIGTRAP +#endif /* "software generated"*/ abfd->tdata.cisco_core_data->sig = SIGEMT; } diff -urN binutils-2.7/bfd/coff-a29k.c binutils-2.8/bfd/coff-a29k.c --- binutils-2.7/bfd/coff-a29k.c Thu Jul 4 12:17:46 1996 +++ binutils-2.8/bfd/coff-a29k.c Wed Apr 30 12:55:49 1997 @@ -1,5 +1,5 @@ /* BFD back-end for AMD 29000 COFF binaries. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. Contributed by David Wood at New York University 7/8/91. This file is part of BFD, the Binary File Descriptor library. @@ -23,7 +23,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/a29k.h" #include "coff/internal.h" #include "libcoff.h" @@ -354,7 +353,7 @@ symndx = rel->r_symndx; loc = contents + rel->r_vaddr - input_section->vma; - if (symndx == -1) + if (symndx == -1 || rel->r_type == R_IHCONST) h = NULL; else h = obj_coff_sym_hashes (input_bfd)[symndx]; diff -urN binutils-2.7/bfd/coff-alpha.c binutils-2.8/bfd/coff-alpha.c --- binutils-2.7/bfd/coff-alpha.c Thu Jul 4 12:17:47 1996 +++ binutils-2.8/bfd/coff-alpha.c Wed Apr 30 12:55:49 1997 @@ -1,5 +1,5 @@ /* BFD back-end for ALPHA Extended-Coff files. - Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. Modified from coff-mips.c by Steve Chamberlain and Ian Lance Taylor . @@ -47,6 +47,8 @@ arelent *)); static void alpha_adjust_reloc_out PARAMS ((bfd *, const arelent *, struct internal_reloc *)); +static reloc_howto_type *alpha_bfd_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); static bfd_byte *alpha_ecoff_get_relocated_section_contents PARAMS ((bfd *abfd, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *data, boolean relocateable, asymbol **symbols)); @@ -2264,7 +2266,7 @@ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */ alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out, alpha_ecoff_swap_scnhdr_out, - FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true, false, + FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true, false, 4, alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in, alpha_ecoff_swap_scnhdr_in, NULL, alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, diff -urN binutils-2.7/bfd/coff-apollo.c binutils-2.8/bfd/coff-apollo.c --- binutils-2.7/bfd/coff-apollo.c Thu Jul 4 12:17:48 1996 +++ binutils-2.8/bfd/coff-apollo.c Wed Apr 30 12:55:49 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Apollo 68000 COFF binaries. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. By Troy Rollo (troy@cbme.unsw.edu.au) Based on m68k standard COFF version Written by Cygnus Support. @@ -22,7 +22,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/apollo.h" #include "coff/internal.h" #include "libcoff.h" diff -urN binutils-2.7/bfd/coff-arm.c binutils-2.8/bfd/coff-arm.c --- binutils-2.7/bfd/coff-arm.c Thu Jul 4 12:17:48 1996 +++ binutils-2.8/bfd/coff-arm.c Wed Apr 30 12:55:50 1997 @@ -1,5 +1,5 @@ /* BFD back-end for ARM COFF files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -21,7 +21,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/arm.h" @@ -44,7 +43,9 @@ static bfd_reloc_status_type coff_arm_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - +static boolean coff_arm_adjust_symndx + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, + struct internal_reloc *, boolean *)); /* Used by the assembler. */ static bfd_reloc_status_type @@ -216,7 +217,7 @@ "ARM26D", true, 0x00ffffff, - 0x00ffffff, + 0x0, false), {-1}, HOWTO( 9, @@ -294,6 +295,37 @@ { *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase; } + + /* The relocation_section function will skip pcrel_offset relocs + when doing a relocateable link. However, we want to convert + ARM26 to ARM26D relocs if possible. We return a fake howto in + this case without pcrel_offset set, and adjust the addend to + compensate. */ + if (rel->r_type == 3 + && h != NULL + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + && h->root.u.def.section->output_section == sec->output_section) + { + static reloc_howto_type fake_arm26_reloc = + HOWTO (3, + 2, + 2, + 26, + true, + 0, + complain_overflow_signed, + aoutarm_fix_pcrel_26 , + "ARM26", + false, + 0x00ffffff, + 0x00ffffff, + false); + + *addendp -= rel->r_vaddr - sec->vma; + return &fake_arm26_reloc; + } + return howto; } @@ -419,6 +451,34 @@ /* We use the special COFF backend linker. */ #define coff_relocate_section _bfd_coff_generic_relocate_section +/* When doing a relocateable link, we want to convert ARM26 relocs + into ARM26D relocs. */ + +static boolean +coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) + bfd *obfd; + struct bfd_link_info *info; + bfd *ibfd; + asection *sec; + struct internal_reloc *irel; + boolean *adjustedp; +{ + if (irel->r_type == 3) + { + struct coff_link_hash_entry *h; + + h = obj_coff_sym_hashes (ibfd)[irel->r_symndx]; + if (h != NULL + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + && h->root.u.def.section->output_section == sec->output_section) + irel->r_type = 7; + } + *adjustedp = false; + return true; +} + +#define coff_adjust_symndx coff_arm_adjust_symndx #include "coffcode.h" diff -urN binutils-2.7/bfd/coff-aux.c binutils-2.8/bfd/coff-aux.c --- binutils-2.7/bfd/coff-aux.c Thu Jul 4 12:17:48 1996 +++ binutils-2.8/bfd/coff-aux.c Wed Apr 30 12:55:50 1997 @@ -1,8 +1,6 @@ /* BFD back-end for Apple M68K COFF A/UX 3.x files. - Copyright 1996 Free Software Foundation, Inc. - Portions written by Richard Henderson , - COMMON symbol munging cribbed from cf-m68klynx.c which was - written by Cygnus Support. + Copyright 1996, 1997 Free Software Foundation, Inc. + Written by Richard Henderson . This file is part of BFD, the Binary File Descriptor library. @@ -35,225 +33,30 @@ /* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */ #define BSS_NOLOAD_IS_SHARED_LIBRARY -#define _bfd_m68kcoff_howto_table _bfd_m68kaux_howto_table -#define _bfd_m68kcoff_rtype2howto _bfd_m68kaux_rtype2howto -#define _bfd_m68kcoff_howto2rtype _bfd_m68kaux_howto2rtype -#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68kaux_reloc_type_lookup +#define STATIC_RELOCS -/* Rather than change names lots of places, reuse the same hack */ -#define LYNX_SPECIAL_FN _bfd_m68kaux_special_fn +#define COFF_COMMON_ADDEND #include "bfd.h" #include "sysdep.h" -#ifdef ANSI_PROTOTYPES -struct internal_reloc; -struct coff_link_hash_entry; -struct internal_syment; -#endif - - -static bfd_reloc_status_type _bfd_m68kaux_special_fn - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static reloc_howto_type *coff_m68k_aux_rtype_to_howto - PARAMS ((bfd *, asection *, struct internal_reloc *, - struct coff_link_hash_entry *, struct internal_syment *, - bfd_vma *)); static boolean coff_m68k_aux_link_add_one_symbol PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *, bfd_vma, const char *, boolean, boolean, struct bfd_link_hash_entry **)); - -#define coff_rtype_to_howto coff_m68k_aux_rtype_to_howto #define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol - -/* Compute the addend of a reloc. If the reloc is to a common symbol, - the object file contains the value of the common symbol. By the - time this is called, the linker may be using a different symbol - from a different object file with a different value. Therefore, we - hack wildly to locate the original symbol from this file so that we - can make the correct adjustment. This macro sets coffsym to the - symbol from the original file, and uses it to set the addend value - correctly. If this is not a common symbol, the usual addend - calculation is done, except that an additional tweak is needed for - PC relative relocs. - FIXME: This macro refers to symbols and asect; these are from the - calling function, not the macro arguments. */ - -#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ - { \ - coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \ - if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ - coffsym = (obj_symbols (abfd) \ - + (cache_ptr->sym_ptr_ptr - symbols)); \ - else if (ptr) \ - coffsym = coff_symbol_from (abfd, ptr); \ - if (coffsym != (coff_symbol_type *) NULL \ - && coffsym->native->u.syment.n_scnum == 0) \ - cache_ptr->addend = - coffsym->native->u.syment.n_value; \ - else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ - && ptr->section != (asection *) NULL) \ - cache_ptr->addend = - (ptr->section->vma + ptr->value); \ - else \ - cache_ptr->addend = 0; \ - if (ptr && (reloc.r_type == R_PCRBYTE \ - || reloc.r_type == R_PCRWORD \ - || reloc.r_type == R_PCRLONG)) \ - cache_ptr->addend += asect->vma; \ - } - - - #include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */ #include "coff-m68k.c" - - -/* For some reason when using m68k COFF the value stored in the .text - section for a reference to a common symbol is the value itself plus - any desired offset. (taken from work done by Ian Taylor, Cygnus Support, - for I386 COFF). */ - -/* If we are producing relocateable output, we need to do some - adjustments to the object file that are not done by the - bfd_perform_relocation function. This function is called by every - reloc type to make any required adjustments. */ - -static bfd_reloc_status_type -_bfd_m68kaux_special_fn (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; -{ - symvalue diff; - - if (output_bfd == (bfd *) NULL) - return bfd_reloc_continue; - - if (bfd_is_com_section (symbol->section)) - { - /* We are relocating a common symbol. The current value in the - object file is ORIG + OFFSET, where ORIG is the value of the - common symbol as seen by the object file when it was compiled - (this may be zero if the symbol was undefined) and OFFSET is - the offset into the common symbol (normally zero, but may be - non-zero when referring to a field in a common structure). - ORIG is the negative of reloc_entry->addend, which is set by - the CALC_ADDEND macro below. We want to replace the value in - the object file with NEW + OFFSET, where NEW is the value of - the common symbol which we are going to put in the final - object file. NEW is symbol->value. */ - diff = symbol->value + reloc_entry->addend; - } - else - { - /* For some reason bfd_perform_relocation always effectively - ignores the addend for a COFF target when producing - relocateable output. This seems to be always wrong for 386 - COFF, so we handle the addend here instead. */ - diff = reloc_entry->addend; - } - -#define DOIT(x) \ - x = ((x & ~howto->dst_mask) | \ - (((x & howto->src_mask) + diff) & howto->dst_mask)) - - if (diff != 0) - { - reloc_howto_type *howto = reloc_entry->howto; - unsigned char *addr = (unsigned char *) data + reloc_entry->address; - - switch (howto->size) - { - case 0: - { - char x = bfd_get_8 (abfd, addr); - DOIT (x); - bfd_put_8 (abfd, x, addr); - } - break; - - case 1: - { - short x = bfd_get_16 (abfd, addr); - DOIT (x); - bfd_put_16 (abfd, x, addr); - } - break; - - case 2: - { - long x = bfd_get_32 (abfd, addr); - DOIT (x); - bfd_put_32 (abfd, x, addr); - } - break; - - default: - abort (); - } - } - - /* Now let bfd_perform_relocation finish everything up. */ - return bfd_reloc_continue; -} - - -/* coff-m68k.c uses the special COFF backend linker. We need to - adjust common symbols. */ - -/*ARGSUSED*/ -static reloc_howto_type * -coff_m68k_aux_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd; - asection *sec; - struct internal_reloc *rel; - struct coff_link_hash_entry *h; - struct internal_syment *sym; - bfd_vma *addendp; -{ - arelent relent; - reloc_howto_type *howto; - - RTYPE2HOWTO (&relent, rel); - - howto = relent.howto; - - if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0) - { - /* This is a common symbol. The section contents include the - size (sym->n_value) as an addend. The relocate_section - function will be adding in the final value of the symbol. We - need to subtract out the current size in order to get the - correct result. */ - BFD_ASSERT (h != NULL); - *addendp -= sym->n_value; - } - - /* If the output symbol is common (in which case this must be a - relocateable link), we need to add in the final size of the - common symbol. */ - if (h != NULL && h->root.type == bfd_link_hash_common) - *addendp += h->root.u.c.size; - - return howto; -} - - /* We need non-absolute symbols to override absolute symbols. This mirrors Apple's "solution" to let a static library symbol override a shared library symbol. On the whole not a good thing, given how shared libraries work here, but can work if you are careful with what you include in the shared object. */ -boolean +static boolean coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value, string, copy, collect, hashp) struct bfd_link_info *info; diff -urN binutils-2.7/bfd/coff-h8300.c binutils-2.8/bfd/coff-h8300.c --- binutils-2.7/bfd/coff-h8300.c Thu Jul 4 12:30:47 1996 +++ binutils-2.8/bfd/coff-h8300.c Wed Apr 30 12:55:51 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Hitachi H8/300 COFF binaries. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Steve Chamberlain, . This file is part of BFD, the Binary File Descriptor library. @@ -20,7 +20,6 @@ #include "bfd.h" #include "sysdep.h" -#include "obstack.h" #include "libbfd.h" #include "bfdlink.h" #include "genlink.h" @@ -139,7 +138,7 @@ if (bfd_get_mach (table->abfd) == bfd_mach_h8300) table->offset += 2; else if (bfd_get_mach (table->abfd) == bfd_mach_h8300h - ) + || bfd_get_mach (table->abfd) == bfd_mach_h8300s) table->offset += 4; else return NULL; @@ -259,10 +258,7 @@ #define SELECT_RELOC(x,howto) \ { x.r_type = select_reloc(howto); } -#define BADMAG(x)\ - (H8300BADMAG(x) \ - && H8300HBADMAG(x) \ - ) +#define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x)) #define H8300 1 /* Customize coffcode.h */ #define __A_MAGIC_SET__ @@ -362,7 +358,7 @@ #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) -/* Perform any necessaru magic to the addend in a reloc entry */ +/* Perform any necessary magic to the addend in a reloc entry */ #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ @@ -570,7 +566,7 @@ && value >= 0xff00 && value <= 0xffff) || ((bfd_get_mach (abfd) == bfd_mach_h8300h - ) + || bfd_get_mach (abfd) == bfd_mach_h8300s) && value >= 0xffff00 && value <= 0xffffff)) { @@ -593,7 +589,7 @@ /* The address is in 0xffff00..0xffffff inclusive on the h8300h, then we can relax this mov.b */ if ((bfd_get_mach (abfd) == bfd_mach_h8300h - ) + || bfd_get_mach (abfd) == bfd_mach_h8300s) && value >= 0xffff00 && value <= 0xffffff) { @@ -736,7 +732,7 @@ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); /* Sanity check. */ - if (value < 0xff + if (value <= 0xff || (value >= 0x0000ff00 && value <= 0x0000ffff) || (value >= 0x00ffff00 && value <= 0x00ffffff) || (value >= 0xffffff00 && value <= 0xffffffff)) @@ -744,7 +740,7 @@ /* Everything looks OK. Apply the relocation and update the src/dst address appropriately. */ - bfd_put_8 (abfd, gap, data + dst_address); + bfd_put_8 (abfd, value & 0xff, data + dst_address); dst_address += 1; src_address += 1; } @@ -1132,7 +1128,7 @@ input_section), vectors_sec->contents + h->offset); else if (bfd_get_mach (input_section->owner) == bfd_mach_h8300h - ) + || bfd_get_mach (input_section->owner) == bfd_mach_h8300s) bfd_put_32 (abfd, bfd_coff_reloc16_get_value (reloc, link_info, @@ -1302,7 +1298,7 @@ if (bfd_get_mach (abfd) == bfd_mach_h8300) h8300_coff_hash_table (info)->vectors_sec->_raw_size += 2; else if (bfd_get_mach (abfd) == bfd_mach_h8300h - ) + || bfd_get_mach (abfd) == bfd_mach_h8300s) h8300_coff_hash_table (info)->vectors_sec->_raw_size += 4; } } diff -urN binutils-2.7/bfd/coff-h8500.c binutils-2.8/bfd/coff-h8500.c --- binutils-2.7/bfd/coff-h8500.c Thu Jul 4 12:17:51 1996 +++ binutils-2.8/bfd/coff-h8500.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Hitachi H8/500 COFF binaries. - Copyright 1993, 1994 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 1997 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain, . @@ -21,7 +21,6 @@ #include "bfd.h" #include "sysdep.h" -#include "obstack.h" #include "libbfd.h" #include "bfdlink.h" #include "coff/h8500.h" @@ -137,7 +136,7 @@ #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) -/* Perform any necessaru magic to the addend in a reloc entry */ +/* Perform any necessary magic to the addend in a reloc entry */ #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ diff -urN binutils-2.7/bfd/coff-i386.c binutils-2.8/bfd/coff-i386.c --- binutils-2.7/bfd/coff-i386.c Thu Jul 4 12:17:52 1996 +++ binutils-2.8/bfd/coff-i386.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 COFF files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -21,7 +21,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/i386.h" diff -urN binutils-2.7/bfd/coff-i860.c binutils-2.8/bfd/coff-i860.c --- binutils-2.7/bfd/coff-i860.c Thu Jul 4 12:17:52 1996 +++ binutils-2.8/bfd/coff-i860.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Intel 860 COFF files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. Created mostly by substituting "860" for "386" in coff-i386.c Harry Dolan , October 1995 @@ -22,7 +22,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/i860.h" diff -urN binutils-2.7/bfd/coff-i960.c binutils-2.8/bfd/coff-i960.c --- binutils-2.7/bfd/coff-i960.c Thu Jul 4 12:17:53 1996 +++ binutils-2.8/bfd/coff-i960.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Intel 960 COFF files. - Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -24,11 +24,11 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/i960.h" #include "coff/internal.h" #include "libcoff.h" /* to allow easier abstraction-breaking */ +static boolean coff_i960_is_local_label_name PARAMS ((bfd *, const char *)); static bfd_reloc_status_type optcall_callback PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); static bfd_reloc_status_type coff_i960_relocate @@ -52,6 +52,20 @@ #define COFF_LONG_FILENAMES +/* This set of local label names is taken from gas. */ + +static boolean +coff_i960_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + return (name[0] == 'L' + || (name[0] == '.' + && (name[1] == 'C' + || name[1] == 'I' + || name[1] == '.'))); +} + /* This is just like the usual CALC_ADDEND, but it includes the section VMA for PC relative relocs. */ #ifndef CALC_ADDEND @@ -584,6 +598,8 @@ return true; } + +#define coff_bfd_is_local_label_name coff_i960_is_local_label_name #define coff_start_final_link coff_i960_start_final_link diff -urN binutils-2.7/bfd/coff-m68k.c binutils-2.8/bfd/coff-m68k.c --- binutils-2.7/bfd/coff-m68k.c Thu Jul 4 12:17:53 1996 +++ binutils-2.8/bfd/coff-m68k.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Motorola 68000 COFF binaries. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -21,14 +21,30 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/m68k.h" #include "coff/internal.h" #include "libcoff.h" -#ifndef LYNX_SPECIAL_FN -#define LYNX_SPECIAL_FN 0 -#endif +/* This source file is compiled multiple times for various m68k COFF + variants. The following macros control its behaviour: + + TARGET_SYM + The C name of the BFD target vector. The default is m68kcoff_vec. + TARGET_NAME + The user visible target name. The default is "coff-m68k". + NAMES_HAVE_UNDERSCORE + Whether symbol names have an underscore. + ONLY_DECLARE_RELOCS + Only declare the relocation howto array. Don't actually compile + it. The actual array will be picked up in another version of the + file. + STATIC_RELOCS + Make the relocation howto array, and associated functions, static. + COFF_COMMON_ADDEND + If this is defined, then, for a relocation against a common + symbol, the object file holds the value (the size) of the common + symbol. If this is not defined, then, for a relocation against a + common symbol, the object file holds zero. */ #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) @@ -37,24 +53,58 @@ #define COFF_PAGE_SIZE 0x2000 #endif +#ifndef COFF_COMMON_ADDEND +#define RELOC_SPECIAL_FN 0 +#else +static bfd_reloc_status_type m68kcoff_common_addend_special_fn + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static reloc_howto_type *m68kcoff_common_addend_rtype_to_howto + PARAMS ((bfd *, asection *, struct internal_reloc *, + struct coff_link_hash_entry *, struct internal_syment *, + bfd_vma *)); +#define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn +#endif + +static boolean m68k_coff_is_local_label_name PARAMS ((bfd *, const char *)); + +/* On the delta, a symbol starting with L% is local. We won't see + such a symbol on other platforms, so it should be safe to always + consider it local here. */ + +static boolean +m68k_coff_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + if (name[0] == 'L' && name[1] == '%') + return true; + + return _bfd_coff_is_local_label_name (abfd, name); +} + +#ifndef STATIC_RELOCS /* Clean up namespace. */ #define m68kcoff_howto_table _bfd_m68kcoff_howto_table #define m68k_rtype2howto _bfd_m68kcoff_rtype2howto #define m68k_howto2rtype _bfd_m68kcoff_howto2rtype #define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup +#endif #ifdef ONLY_DECLARE_RELOCS extern reloc_howto_type m68kcoff_howto_table[]; #else +#ifdef STATIC_RELOCS +static +#endif reloc_howto_type m68kcoff_howto_table[] = { - HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false), - HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false), - HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false), - HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false), - HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false), - HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false), - HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false), + HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false), + HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false), + HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false), + HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false), + HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false), + HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, RELOC_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false), + HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, RELOC_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false), }; #endif /* not ONLY_DECLARE_RELOCS */ @@ -71,6 +121,9 @@ extern reloc_howto_type *m68k_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type)); #else +#ifdef STATIC_RELOCS +static +#endif void m68k_rtype2howto(internal, relocentry) arelent *internal; @@ -88,6 +141,9 @@ } } +#ifdef STATIC_RELOCS +static +#endif int m68k_howto2rtype (internal) reloc_howto_type *internal; @@ -113,6 +169,9 @@ return R_RELLONG; } +#ifdef STATIC_RELOCS +static +#endif reloc_howto_type * m68k_reloc_type_lookup (abfd, code) bfd *abfd; @@ -139,26 +198,244 @@ m68k_rtype2howto(internal, (relocentry)->r_type) #define SELECT_RELOC(external, internal) \ - external.r_type = m68k_howto2rtype(internal); + external.r_type = m68k_howto2rtype (internal) #define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup +#ifndef COFF_COMMON_ADDEND +#ifndef coff_rtype_to_howto + +#define coff_rtype_to_howto m68kcoff_rtype_to_howto + +static reloc_howto_type *m68kcoff_rtype_to_howto + PARAMS ((bfd *, asection *, struct internal_reloc *, + struct coff_link_hash_entry *, struct internal_syment *, + bfd_vma *)); + +/*ARGSUSED*/ +static reloc_howto_type * +m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp) + bfd *abfd; + asection *sec; + struct internal_reloc *rel; + struct coff_link_hash_entry *h; + struct internal_syment *sym; + bfd_vma *addendp; +{ + arelent relent; + reloc_howto_type *howto; + + RTYPE2HOWTO (&relent, rel); + + howto = relent.howto; + + if (howto->pc_relative) + *addendp += sec->vma; + + return howto; +} + +#endif /* ! defined (coff_rtype_to_howto) */ +#endif /* ! defined (COFF_COMMON_ADDEND) */ + +#ifdef COFF_COMMON_ADDEND + +/* If COFF_COMMON_ADDEND is defined, then when using m68k COFF the + value stored in the .text section for a reference to a common + symbol is the value itself plus any desired offset. (taken from + work done by Ian Taylor, Cygnus Support, for I386 COFF). */ + +/* If we are producing relocateable output, we need to do some + adjustments to the object file that are not done by the + bfd_perform_relocation function. This function is called by every + reloc type to make any required adjustments. */ + +static bfd_reloc_status_type +m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + symvalue diff; + + if (output_bfd == (bfd *) NULL) + return bfd_reloc_continue; + + if (bfd_is_com_section (symbol->section)) + { + /* We are relocating a common symbol. The current value in the + object file is ORIG + OFFSET, where ORIG is the value of the + common symbol as seen by the object file when it was compiled + (this may be zero if the symbol was undefined) and OFFSET is + the offset into the common symbol (normally zero, but may be + non-zero when referring to a field in a common structure). + ORIG is the negative of reloc_entry->addend, which is set by + the CALC_ADDEND macro below. We want to replace the value in + the object file with NEW + OFFSET, where NEW is the value of + the common symbol which we are going to put in the final + object file. NEW is symbol->value. */ + diff = symbol->value + reloc_entry->addend; + } + else + { + /* For some reason bfd_perform_relocation always effectively + ignores the addend for a COFF target when producing + relocateable output. This seems to be always wrong for 386 + COFF, so we handle the addend here instead. */ + diff = reloc_entry->addend; + } + +#define DOIT(x) \ + x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask)) + + if (diff != 0) + { + reloc_howto_type *howto = reloc_entry->howto; + unsigned char *addr = (unsigned char *) data + reloc_entry->address; + + switch (howto->size) + { + case 0: + { + char x = bfd_get_8 (abfd, addr); + DOIT (x); + bfd_put_8 (abfd, x, addr); + } + break; + + case 1: + { + short x = bfd_get_16 (abfd, addr); + DOIT (x); + bfd_put_16 (abfd, x, addr); + } + break; + + case 2: + { + long x = bfd_get_32 (abfd, addr); + DOIT (x); + bfd_put_32 (abfd, x, addr); + } + break; + + default: + abort (); + } + } + + /* Now let bfd_perform_relocation finish everything up. */ + return bfd_reloc_continue; +} + +/* Compute the addend of a reloc. If the reloc is to a common symbol, + the object file contains the value of the common symbol. By the + time this is called, the linker may be using a different symbol + from a different object file with a different value. Therefore, we + hack wildly to locate the original symbol from this file so that we + can make the correct adjustment. This macro sets coffsym to the + symbol from the original file, and uses it to set the addend value + correctly. If this is not a common symbol, the usual addend + calculation is done, except that an additional tweak is needed for + PC relative relocs. + FIXME: This macro refers to symbols and asect; these are from the + calling function, not the macro arguments. */ + +#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ + { \ + coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \ + if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ + coffsym = (obj_symbols (abfd) \ + + (cache_ptr->sym_ptr_ptr - symbols)); \ + else if (ptr) \ + coffsym = coff_symbol_from (abfd, ptr); \ + if (coffsym != (coff_symbol_type *) NULL \ + && coffsym->native->u.syment.n_scnum == 0) \ + cache_ptr->addend = - coffsym->native->u.syment.n_value; \ + else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ + && ptr->section != (asection *) NULL) \ + cache_ptr->addend = - (ptr->section->vma + ptr->value); \ + else \ + cache_ptr->addend = 0; \ + if (ptr && (reloc.r_type == R_PCRBYTE \ + || reloc.r_type == R_PCRWORD \ + || reloc.r_type == R_PCRLONG)) \ + cache_ptr->addend += asect->vma; \ + } + +#ifndef coff_rtype_to_howto + +/* coff-m68k.c uses the special COFF backend linker. We need to + adjust common symbols. */ + +/*ARGSUSED*/ +static reloc_howto_type * +m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp) + bfd *abfd; + asection *sec; + struct internal_reloc *rel; + struct coff_link_hash_entry *h; + struct internal_syment *sym; + bfd_vma *addendp; +{ + arelent relent; + reloc_howto_type *howto; + + RTYPE2HOWTO (&relent, rel); + + howto = relent.howto; + + if (howto->pc_relative) + *addendp += sec->vma; + + if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0) + { + /* This is a common symbol. The section contents include the + size (sym->n_value) as an addend. The relocate_section + function will be adding in the final value of the symbol. We + need to subtract out the current size in order to get the + correct result. */ + BFD_ASSERT (h != NULL); + *addendp -= sym->n_value; + } + + /* If the output symbol is common (in which case this must be a + relocateable link), we need to add in the final size of the + common symbol. */ + if (h != NULL && h->root.type == bfd_link_hash_common) + *addendp += h->root.u.c.size; + + return howto; +} + +#define coff_rtype_to_howto m68kcoff_common_addend_rtype_to_howto + +#endif /* ! defined (coff_rtype_to_howto) */ + +#endif /* COFF_COMMON_ADDEND */ + +#define coff_bfd_is_local_label_name m68k_coff_is_local_label_name + #define coff_relocate_section _bfd_coff_generic_relocate_section #include "coffcode.h" -const bfd_target -#ifdef TARGET_SYM - TARGET_SYM = -#else - m68kcoff_vec = +#ifndef TARGET_SYM +#define TARGET_SYM m68kcoff_vec +#endif + +#ifndef TARGET_NAME +#define TARGET_NAME "coff-m68k" #endif + +const bfd_target TARGET_SYM = { -#ifdef TARGET_NAME TARGET_NAME, -#else - "coff-m68k", /* name */ -#endif bfd_target_coff_flavour, BFD_ENDIAN_BIG, /* data byte order is big */ BFD_ENDIAN_BIG, /* header byte order is big */ @@ -200,4 +477,4 @@ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), COFF_SWAP_TABLE - }; +}; diff -urN binutils-2.7/bfd/coff-m88k.c binutils-2.8/bfd/coff-m88k.c --- binutils-2.7/bfd/coff-m88k.c Thu Jul 4 12:17:53 1996 +++ binutils-2.8/bfd/coff-m88k.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -22,11 +22,11 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/m88k.h" #include "coff/internal.h" #include "libcoff.h" +static boolean m88k_is_local_label_name PARAMS ((bfd *, const char *)); static bfd_reloc_status_type m88k_special_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); static void rtype2howto PARAMS ((arelent *, struct internal_reloc *)); @@ -34,6 +34,18 @@ PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *)); #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) + +/* On coff-m88k, local labels start with '@'. */ + +#define coff_bfd_is_local_label_name m88k_is_local_label_name + +static boolean +m88k_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + return name[0] == '@'; +} static bfd_reloc_status_type m88k_special_reloc (abfd, reloc_entry, symbol, data, diff -urN binutils-2.7/bfd/coff-mips.c binutils-2.8/bfd/coff-mips.c --- binutils-2.7/bfd/coff-mips.c Thu Jul 4 12:17:55 1996 +++ binutils-2.8/bfd/coff-mips.c Wed Apr 30 12:55:53 1997 @@ -1,5 +1,5 @@ /* BFD back-end for MIPS Extended-Coff files. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. @@ -112,6 +112,9 @@ asection *, struct ecoff_link_hash_entry *, bfd_byte *, bfd_vma)); +static reloc_howto_type *mips_bfd_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); + /* ECOFF has COFF sections, but the debugging information is stored in a completely different format. ECOFF targets use some of the @@ -623,10 +626,21 @@ REFLO reloc, because there is a carry from the REFLO to the REFHI. Here we just save the information we need; we do the actual relocation when we see the REFLO. MIPS ECOFF requires that the - REFLO immediately follow the REFHI, so this ought to work. */ + REFLO immediately follow the REFHI. As a GNU extension, we permit + an arbitrary number of HI relocs to be associated with a single LO + reloc. This extension permits gcc to output the HI and LO relocs + itself. */ + +struct mips_hi +{ + struct mips_hi *next; + bfd_byte *addr; + bfd_vma addend; +}; -static bfd_byte *mips_refhi_addr; -static bfd_vma mips_refhi_addend; +/* FIXME: This should not be a static variable. */ + +static struct mips_hi *mips_refhi_list; static bfd_reloc_status_type mips_refhi_reloc (abfd, @@ -646,6 +660,7 @@ { bfd_reloc_status_type ret; bfd_vma relocation; + struct mips_hi *n; /* If we're relocating, and this an external symbol, we don't want to change anything. */ @@ -675,8 +690,13 @@ return bfd_reloc_outofrange; /* Save the information, and let REFLO do the actual relocation. */ - mips_refhi_addr = (bfd_byte *) data + reloc_entry->address; - mips_refhi_addend = relocation; + n = (struct mips_hi *) bfd_malloc (sizeof *n); + if (n == NULL) + return bfd_reloc_outofrange; + n->addr = (bfd_byte *) data + reloc_entry->address; + n->addend = relocation; + n->next = mips_refhi_list; + mips_refhi_list = n; if (output_bfd != (bfd *) NULL) reloc_entry->address += input_section->output_offset; @@ -704,36 +724,48 @@ bfd *output_bfd; char **error_message; { - if (mips_refhi_addr != (bfd_byte *) NULL) + if (mips_refhi_list != NULL) { - unsigned long insn; - unsigned long val; - unsigned long vallo; - - /* Do the REFHI relocation. Note that we actually don't need to - know anything about the REFLO itself, except where to find - the low 16 bits of the addend needed by the REFHI. */ - insn = bfd_get_32 (abfd, mips_refhi_addr); - vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) - & 0xffff); - val = ((insn & 0xffff) << 16) + vallo; - val += mips_refhi_addend; - - /* The low order 16 bits are always treated as a signed value. - Therefore, a negative value in the low order bits requires an - adjustment in the high order bits. We need to make this - adjustment in two ways: once for the bits we took from the - data, and once for the bits we are putting back in to the - data. */ - if ((vallo & 0x8000) != 0) - val -= 0x10000; - if ((val & 0x8000) != 0) - val += 0x10000; + struct mips_hi *l; - insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); - bfd_put_32 (abfd, insn, mips_refhi_addr); + l = mips_refhi_list; + while (l != NULL) + { + unsigned long insn; + unsigned long val; + unsigned long vallo; + struct mips_hi *next; + + /* Do the REFHI relocation. Note that we actually don't + need to know anything about the REFLO itself, except + where to find the low 16 bits of the addend needed by the + REFHI. */ + insn = bfd_get_32 (abfd, l->addr); + vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) + & 0xffff); + val = ((insn & 0xffff) << 16) + vallo; + val += l->addend; + + /* The low order 16 bits are always treated as a signed + value. Therefore, a negative value in the low order bits + requires an adjustment in the high order bits. We need + to make this adjustment in two ways: once for the bits we + took from the data, and once for the bits we are putting + back in to the data. */ + if ((vallo & 0x8000) != 0) + val -= 0x10000; + if ((val & 0x8000) != 0) + val += 0x10000; + + insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); + bfd_put_32 (abfd, insn, l->addr); + + next = l->next; + free (l); + l = next; + } - mips_refhi_addr = (bfd_byte *) NULL; + mips_refhi_list = NULL; } /* Now do the REFLO reloc in the usual way. */ @@ -888,8 +920,9 @@ are Cygnus extensions used when generating position independent code for embedded systems. */ -static bfd_byte *mips_relhi_addr; -static bfd_vma mips_relhi_addend; +/* FIXME: This should not be a static variable. */ + +static struct mips_hi *mips_relhi_list; static bfd_reloc_status_type mips_relhi_reloc (abfd, @@ -909,6 +942,7 @@ { bfd_reloc_status_type ret; bfd_vma relocation; + struct mips_hi *n; /* If this is a reloc against a section symbol, then it is correct in the object file. The only time we want to change this case is @@ -947,8 +981,13 @@ return bfd_reloc_outofrange; /* Save the information, and let RELLO do the actual relocation. */ - mips_relhi_addr = (bfd_byte *) data + reloc_entry->address; - mips_relhi_addend = relocation; + n = (struct mips_hi *) bfd_malloc (sizeof *n); + if (n == NULL) + return bfd_reloc_outofrange; + n->addr = (bfd_byte *) data + reloc_entry->address; + n->addend = relocation; + n->next = mips_relhi_list; + mips_relhi_list = n; if (output_bfd != (bfd *) NULL) reloc_entry->address += input_section->output_offset; @@ -976,46 +1015,58 @@ bfd *output_bfd; char **error_message; { - if (mips_relhi_addr != (bfd_byte *) NULL) + if (mips_relhi_list != NULL) { - unsigned long insn; - unsigned long val; - unsigned long vallo; - - /* Do the RELHI relocation. Note that we actually don't need to - know anything about the RELLO itself, except where to find - the low 16 bits of the addend needed by the RELHI. */ - insn = bfd_get_32 (abfd, mips_relhi_addr); - vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) - & 0xffff); - val = ((insn & 0xffff) << 16) + vallo; - val += mips_relhi_addend; - - /* If the symbol is defined, make val PC relative. If the - symbol is not defined we don't want to do this, because we - don't want the value in the object file to incorporate the - address of the reloc. */ - if (! bfd_is_und_section (bfd_get_section (symbol)) - && ! bfd_is_com_section (bfd_get_section (symbol))) - val -= (input_section->output_section->vma - + input_section->output_offset - + reloc_entry->address); - - /* The low order 16 bits are always treated as a signed value. - Therefore, a negative value in the low order bits requires an - adjustment in the high order bits. We need to make this - adjustment in two ways: once for the bits we took from the - data, and once for the bits we are putting back in to the - data. */ - if ((vallo & 0x8000) != 0) - val -= 0x10000; - if ((val & 0x8000) != 0) - val += 0x10000; + struct mips_hi *l; - insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); - bfd_put_32 (abfd, insn, mips_relhi_addr); + l = mips_relhi_list; + while (l != NULL) + { + unsigned long insn; + unsigned long val; + unsigned long vallo; + struct mips_hi *next; + + /* Do the RELHI relocation. Note that we actually don't + need to know anything about the RELLO itself, except + where to find the low 16 bits of the addend needed by the + RELHI. */ + insn = bfd_get_32 (abfd, l->addr); + vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) + & 0xffff); + val = ((insn & 0xffff) << 16) + vallo; + val += l->addend; + + /* If the symbol is defined, make val PC relative. If the + symbol is not defined we don't want to do this, because + we don't want the value in the object file to incorporate + the address of the reloc. */ + if (! bfd_is_und_section (bfd_get_section (symbol)) + && ! bfd_is_com_section (bfd_get_section (symbol))) + val -= (input_section->output_section->vma + + input_section->output_offset + + reloc_entry->address); + + /* The low order 16 bits are always treated as a signed + value. Therefore, a negative value in the low order bits + requires an adjustment in the high order bits. We need + to make this adjustment in two ways: once for the bits we + took from the data, and once for the bits we are putting + back in to the data. */ + if ((vallo & 0x8000) != 0) + val -= 0x10000; + if ((val & 0x8000) != 0) + val += 0x10000; + + insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); + bfd_put_32 (abfd, insn, l->addr); + + next = l->next; + free (l); + l = next; + } - mips_relhi_addr = (bfd_byte *) NULL; + mips_relhi_list = NULL; } /* If this is a reloc against a section symbol, then it is correct @@ -1194,8 +1245,8 @@ boolean got_lo; struct internal_reloc lo_int_rel; - BFD_ASSERT (input_bfd->xvec->header_byteorder - == output_bfd->xvec->header_byteorder); + BFD_ASSERT (input_bfd->xvec->byteorder + == output_bfd->xvec->byteorder); /* We keep a table mapping the symndx found in an internal reloc to the appropriate section. This is faster than looking up the @@ -1261,6 +1312,7 @@ for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++) { struct internal_reloc int_rel; + boolean use_lo; bfd_vma addend; reloc_howto_type *howto; struct ecoff_link_hash_entry *h = NULL; @@ -1285,16 +1337,33 @@ if (int_rel.r_type == MIPS_R_REFHI || int_rel.r_type == MIPS_R_RELHI) { - BFD_ASSERT ((ext_rel + 1) < ext_rel_end); - mips_ecoff_swap_reloc_in (input_bfd, (PTR) (ext_rel + 1), - &lo_int_rel); - BFD_ASSERT ((lo_int_rel.r_type - == (int_rel.r_type == MIPS_R_REFHI - ? MIPS_R_REFLO - : MIPS_R_RELLO)) - && int_rel.r_extern == lo_int_rel.r_extern - && int_rel.r_symndx == lo_int_rel.r_symndx); - got_lo = true; + struct external_reloc *lo_ext_rel; + + /* As a GNU extension, permit an arbitrary number of REFHI + or RELHI relocs before the REFLO or RELLO reloc. This + permits gcc to emit the HI and LO relocs itself. */ + for (lo_ext_rel = ext_rel + 1; + lo_ext_rel < ext_rel_end; + lo_ext_rel++) + { + mips_ecoff_swap_reloc_in (input_bfd, (PTR) lo_ext_rel, + &lo_int_rel); + if (lo_int_rel.r_type != int_rel.r_type) + break; + } + + if (lo_ext_rel < ext_rel_end + && (lo_int_rel.r_type + == (int_rel.r_type == MIPS_R_REFHI + ? MIPS_R_REFLO + : MIPS_R_RELLO)) + && int_rel.r_extern == lo_int_rel.r_extern + && int_rel.r_symndx == lo_int_rel.r_symndx) + { + use_lo = true; + if (lo_ext_rel == ext_rel + 1) + got_lo = true; + } } howto = &mips_howto_table[int_rel.r_type]; @@ -1570,8 +1639,8 @@ being against a section, we must put a special value into the r_offset field. This value is the old addend. The r_offset for - both the RELOHI and RELLO relocs are the - same, and we set both when we see RELHI. */ + both the RELHI and RELLO relocs are the same, + and we set both when we see RELHI. */ if (int_rel.r_type == MIPS_R_RELHI) { long addhi, addlo; @@ -1586,17 +1655,23 @@ addhi -= 0x10000; addhi <<= 16; - addlo = bfd_get_32 (input_bfd, - (contents - + adjust - + lo_int_rel.r_vaddr - - input_section->vma)); - addlo &= 0xffff; - if (addlo & 0x8000) - addlo -= 0x10000; + if (! use_lo) + addlo = 0; + else + { + addlo = bfd_get_32 (input_bfd, + (contents + + adjust + + lo_int_rel.r_vaddr + - input_section->vma)); + addlo &= 0xffff; + if (addlo & 0x8000) + addlo -= 0x10000; + + lo_int_rel.r_offset = addhi + addlo; + } int_rel.r_offset = addhi + addlo; - lo_int_rel.r_offset = int_rel.r_offset; } } @@ -1660,7 +1735,8 @@ - input_section->vma)); else { - mips_relocate_hi (&int_rel, &lo_int_rel, + mips_relocate_hi (&int_rel, + use_lo ? &lo_int_rel : NULL, input_bfd, input_section, contents, adjust, relocation, int_rel.r_type == MIPS_R_RELHI); @@ -1714,7 +1790,7 @@ adding in the start address. */ if (howto->pc_relative) { - if (int_rel.r_type != MIPS_R_RELHI) + if (int_rel.r_type != MIPS_R_RELHI || ! use_lo) relocation += int_rel.r_vaddr + adjust; else relocation += lo_int_rel.r_vaddr + adjust; @@ -1734,8 +1810,9 @@ addend); else { - mips_relocate_hi (&int_rel, &lo_int_rel, input_bfd, - input_section, contents, adjust, + mips_relocate_hi (&int_rel, + use_lo ? &lo_int_rel : NULL, + input_bfd, input_section, contents, adjust, relocation, int_rel.r_type == MIPS_R_RELHI); r = bfd_reloc_ok; @@ -1801,7 +1878,7 @@ if (section_tdata == (struct ecoff_section_tdata *) NULL) { sec->used_by_bfd = - (PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata)); + (PTR) bfd_alloc (abfd, sizeof (struct ecoff_section_tdata)); if (sec->used_by_bfd == NULL) return false; @@ -2037,7 +2114,7 @@ size_t size; size = sec->reloc_count * sizeof (long); - offsets = (long *) bfd_alloc_by_size_t (abfd, size); + offsets = (long *) bfd_alloc (abfd, size); if (offsets == (long *) NULL) goto error_return; memset (offsets, 0, size); @@ -2420,7 +2497,7 @@ (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */ mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out, mips_ecoff_swap_scnhdr_out, - FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true, false, + FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true, false, 4, mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in, mips_ecoff_swap_scnhdr_in, NULL, mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, @@ -2581,6 +2658,48 @@ _bfd_generic_mkarchive, bfd_false}, {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, + + BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), + BFD_JUMP_TABLE_COPY (_bfd_ecoff), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff), + BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), + BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), + BFD_JUMP_TABLE_WRITE (_bfd_ecoff), + BFD_JUMP_TABLE_LINK (_bfd_ecoff), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + (PTR) &mips_ecoff_backend_data +}; + +const bfd_target ecoff_biglittle_vec = +{ + "ecoff-biglittlemips", /* name */ + bfd_target_ecoff_flavour, + BFD_ENDIAN_LITTLE, /* data byte order is little */ + BFD_ENDIAN_BIG, /* header byte order is big */ + + (HAS_RELOC | EXEC_P | /* object flags */ + HAS_LINENO | HAS_DEBUG | + HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), + + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), + 0, /* leading underscore */ + ' ', /* ar_pad_char */ + 15, /* ar_max_namelen */ + bfd_getl64, bfd_getl_signed_64, bfd_putl64, + bfd_getl32, bfd_getl_signed_32, bfd_putl32, + bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ + + {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ + _bfd_ecoff_archive_p, _bfd_dummy_target}, + {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */ + _bfd_generic_mkarchive, bfd_false}, + {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */ + _bfd_write_archive_contents, bfd_false}, BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), BFD_JUMP_TABLE_COPY (_bfd_ecoff), diff -urN binutils-2.7/bfd/coff-ppc.c binutils-2.8/bfd/coff-ppc.c --- binutils-2.7/bfd/coff-ppc.c Thu Jul 4 12:17:57 1996 +++ binutils-2.8/bfd/coff-ppc.c Wed Apr 30 12:55:53 1997 @@ -1,5 +1,5 @@ /* BFD back-end for PowerPC Microsoft Portable Executable files. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Original version pieced together by Kim Knuttila (krk@cygnus.com) @@ -36,7 +36,6 @@ #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/powerpc.h" #include "coff/internal.h" @@ -51,6 +50,12 @@ #include "libcoff.h" +/* This file is compiled more than once, but we only compile the + final_link routine once. */ +extern boolean ppc_bfd_coff_final_link + PARAMS ((bfd *, struct bfd_link_info *)); +extern void dump_toc PARAMS ((PTR)); + /* The toc is a set of bfd_vma fields. We use the fact that valid */ /* addresses are even (i.e. the bit representing "1" is off) to allow */ /* us to encode a little extra information in the field */ @@ -68,6 +73,33 @@ #define MARK_AS_WRITTEN(x) ((x) |= 1) #define MAKE_ADDR_AGAIN(x) ((x) &= ~1) + +/* Turn on this check if you suspect something amiss in the hash tables */ +#ifdef DEBUG_HASH + +/* Need a 7 char string for an eye catcher */ +#define EYE "krkjunk" + +#define HASH_CHECK_DCL char eye_catcher[8]; +#define HASH_CHECK_INIT(ret) strcpy(ret->eye_catcher, EYE) +#define HASH_CHECK(addr) \ + if (strcmp(addr->eye_catcher, EYE) != 0) \ + { \ + fprintf(stderr,\ + "File %s, line %d, Hash check failure, bad eye %8s\n", \ + __FILE__, __LINE__, addr->eye_catcher); \ + abort(); \ + } + + +#else + +#define HASH_CHECK_DCL +#define HASH_CHECK_INIT(ret) +#define HASH_CHECK(addr) + +#endif + /* In order not to add an int to every hash table item for every coff linker, we define our own hash table, derived from the coff one */ @@ -82,20 +114,10 @@ bfd_vma toc_offset; /* Our addition, as required */ int symbol_is_glue; unsigned long int glue_insn; - char eye_catcher[8]; -}; -/* Need a 7 char string for an eye catcher */ -#define EYE "krkjunk" + HASH_CHECK_DCL +}; -#define CHECK_EYE(addr) \ - if (strcmp(addr, EYE) != 0) \ - { \ - fprintf(stderr,\ - "File %s, line %d, Hash check failure, bad eye %8s\n", \ - __FILE__, __LINE__, addr); \ - abort(); \ - } /* PE linker hash table. */ @@ -107,6 +129,20 @@ static struct bfd_hash_entry *ppc_coff_link_hash_newfunc PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static boolean ppc_coff_link_hash_table_init + PARAMS ((struct ppc_coff_link_hash_table *, bfd *, + struct bfd_hash_entry *(*) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *))); +static struct bfd_link_hash_table *ppc_coff_link_hash_table_create + PARAMS ((bfd *)); +static boolean coff_ppc_relocate_section + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + struct internal_reloc *, struct internal_syment *, asection **)); +static reloc_howto_type *coff_ppc_rtype_to_howto + PARAMS ((bfd *, asection *, struct internal_reloc *, + struct coff_link_hash_entry *, struct internal_syment *, + bfd_vma *)); /* Routine to create an entry in the link hash table. */ @@ -140,7 +176,8 @@ SET_UNALLOCATED(ret->toc_offset); ret->symbol_is_glue = 0; ret->glue_insn = 0; - strcpy(ret->eye_catcher, EYE); + + HASH_CHECK_INIT(ret); } return (struct bfd_hash_entry *) ret; @@ -186,8 +223,8 @@ /* The nt loader points the toc register to &toc + 32768, in order to */ -/* use the complete range of a 16-bit displacement (I guess). We have */ -/* to adjust for this when we fix up loads displaced off the toc reg. */ +/* use the complete range of a 16-bit displacement. We have to adjust */ +/* for this when we fix up loads displaced off the toc reg. */ #define TOC_LOAD_ADJUSTMENT (-32768) #define TOC_SECTION_NAME ".private.toc" @@ -786,6 +823,10 @@ /* toc construction and management routines */ + +/* This file is compiled twice, and these variables are defined in one + of the compilations. FIXME: This is confusing and weird. Also, + BFD should not use global variables. */ extern bfd* bfd_of_toc_owner; extern long int global_toc_size; @@ -819,8 +860,11 @@ extern struct list_ele *head; extern struct list_ele *tail; +static void record_toc + PARAMS ((asection *, int, enum ref_category, const char *)); + static void -record_toc(toc_section, our_toc_offset, cat, name) +record_toc (toc_section, our_toc_offset, cat, name) asection *toc_section; int our_toc_offset; enum ref_category cat; @@ -851,8 +895,13 @@ #ifdef COFF_IMAGE_WITH_PE +static boolean ppc_record_toc_entry + PARAMS ((bfd *, struct bfd_link_info *, asection *, int, enum toc_type)); +static void ppc_mark_symbol_as_glue + PARAMS ((bfd *, int, struct internal_reloc *)); + /* record a toc offset against a symbol */ -static int +static boolean ppc_record_toc_entry(abfd, info, sec, sym, toc_kind) bfd *abfd; struct bfd_link_info *info; @@ -861,7 +910,6 @@ enum toc_type toc_kind; { struct ppc_coff_link_hash_entry *h; - int ret_val; const char *name; int *local_syms; @@ -871,7 +919,7 @@ h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]); if (h != 0) { - CHECK_EYE(h->eye_catcher); + HASH_CHECK(h); } if (h == 0) @@ -896,31 +944,15 @@ if (IS_UNALLOCATED(local_syms[sym])) { local_syms[sym] = global_toc_size; - ret_val = global_toc_size; global_toc_size += 4; /* The size must fit in a 16bit displacment */ - if (global_toc_size >= 65535) + if (global_toc_size > 65535) { - fprintf(stderr, - "Exceeded toc size of 65535\n"); - abort(); + (*_bfd_error_handler) ("TOC overflow"); + bfd_set_error (bfd_error_file_too_big); + return false; } - -#ifdef TOC_DEBUG - fprintf(stderr, - "Setting toc_offset for local sym %d to %d\n", - sym, ret_val); -#endif - } - else - { - ret_val = local_syms[sym]; -#ifdef TOC_DEBUG - fprintf(stderr, - "toc_offset already set for local sym %d to %d\n", - sym, ret_val); -#endif } } else @@ -932,155 +964,21 @@ if (IS_UNALLOCATED(h->toc_offset)) { h->toc_offset = global_toc_size; - ret_val = global_toc_size; global_toc_size += 4; /* The size must fit in a 16bit displacment */ if (global_toc_size >= 65535) { - fprintf(stderr, - "Exceeded toc size of 65535\n"); - abort(); + (*_bfd_error_handler) ("TOC overflow"); + bfd_set_error (bfd_error_file_too_big); + return false; } - -#ifdef TOC_DEBUG - fprintf(stderr, - "Setting toc_offset for sym %d (%s) [h=%p] to %d\n", - sym, name, h, ret_val); -#endif - } - else - { - ret_val = h->toc_offset; -#ifdef TOC_DEBUG - fprintf(stderr, - "toc_offset already set for sym %d (%s) [h=%p] to %d\n", - sym, name, h, ret_val); -#endif } } - return ret_val; -} - -#endif /* COFF_IMAGE_WITH_PE */ - -#if 0 - -/* FIXME: record a toc offset against a data-in-toc symbol */ -/* Now, there is currenly some confusion on what this means. In some - compilers one sees the moral equivalent of: - .tocd - define some data - .text - refer to the data with a [tocv] qualifier - In general, one sees something to indicate that a tocd has been - seen, and that would trigger the allocation of data in toc. The IBM - docs seem to suggest that anything with the TOCDEFN qualifier should - never trigger storage allocation. However, in the kernel32.lib that - we've been using for our test bed, there are a couple of variables - referenced that fail that test. - - So it can't work that way. -*/ -static int -ppc_record_data_in_toc_entry(abfd, info, sec, sym, toc_kind) - bfd *abfd; - struct bfd_link_info *info; - asection *sec; - int sym; - enum toc_type toc_kind; -{ - struct ppc_coff_link_hash_entry *h = 0; - int ret_val; - const char *name; - - int *local_syms; - - h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]); - - if (h == 0) - { - local_syms = obj_coff_local_toc_table(abfd); - if (local_syms == 0) - { - int i; - /* allocate a table */ - local_syms = - (int *) bfd_zalloc (abfd, - obj_raw_syment_count(abfd) * sizeof(int)); - if (local_syms == 0) - return false; - obj_coff_local_toc_table(abfd) = local_syms; - for (i = 0; i < obj_raw_syment_count(abfd); ++i) - { - SET_UNALLOCATED(local_syms[i]); - } - } - - if (IS_UNALLOCATED(local_syms[sym])) - { - local_syms[sym] = global_toc_size; - ret_val = global_toc_size; - global_toc_size += 4; -#ifdef TOC_DEBUG - fprintf(stderr, - "Setting data_in_toc_offset for local sym %d to %d\n", - sym, ret_val); -#endif - } - else - { - ret_val = local_syms[sym]; -#ifdef TOC_DEBUG - fprintf(stderr, - "data_in_toc_offset already set for local sym %d to %d\n", - sym, ret_val); -#endif - } - } - else - { - CHECK_EYE(h->eye_catcher); - - name = h->root.root.root.string; - - /* check to see if there's a toc slot allocated. If not, do it - here. It will be used in relocate_section */ - if (IS_UNALLOCATED(h->toc_offset)) - { -#if 0 - h->toc_offset = global_toc_size; -#endif - ret_val = global_toc_size; - /* We're allocating a chunk of the toc, as opposed to a slot */ - /* FIXME: alignment? */ - - global_toc_size += 4; -#ifdef TOC_DEBUG - fprintf(stderr, - "Setting data_in_toc_offset for sym %d (%s) [h=%p] to %d\n", - sym, name, h, ret_val); -#endif - } - else - { - ret_val = h->toc_offset; -#ifdef TOC_DEBUG - fprintf(stderr, - "data_in_toc_offset already set for sym %d (%s) [h=%p] to %d\n", - sym, name, h, ret_val); -#endif - } - } - - return ret_val; + return true; } -#endif /* 0 */ - -#ifdef COFF_IMAGE_WITH_PE - /* record a toc offset against a symbol */ static void ppc_mark_symbol_as_glue(abfd, sym, rel) @@ -1091,11 +989,8 @@ struct ppc_coff_link_hash_entry *h; h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]); -#ifdef DEBUG_RELOC - fprintf(stderr, - "ppc_mark_symbol_as_glue:\n"); -#endif - CHECK_EYE(h->eye_catcher); + + HASH_CHECK(h); h->symbol_is_glue = 1; h->glue_insn = bfd_get_32 (abfd, (bfd_byte *) &rel->r_vaddr); @@ -1105,32 +1000,6 @@ #endif /* COFF_IMAGE_WITH_PE */ -#if 0 - -/* Provided the symbol, returns the value reffed */ -static long get_symbol_value PARAMS ((asymbol *)); - -static long -get_symbol_value (symbol) - asymbol *symbol; -{ - long relocation = 0; - - if (bfd_is_com_section (symbol->section)) - { - relocation = 0; - } - else - { - relocation = symbol->value + - symbol->section->output_section->vma + - symbol->section->output_offset; - } - - return(relocation); -} - -#endif /* 0 */ /* Return true if this relocation should appear in the output .reloc section. */ @@ -1180,8 +1049,6 @@ unsigned short r_type; unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/ - fprintf(stderr, "pe_ppc_reloc (%s)\n", TARGET_LITTLE_NAME); - r_type = reloc_entry->howto->type; if (output_bfd) @@ -1240,15 +1107,6 @@ bfd_vma relocation; reloc_howto_type *howto = 0; -#ifdef DEBUG_RELOC - fprintf(stderr, - "pe_ppc_relocate_section (%s) for %s in bfd %s\n", - TARGET_LITTLE_NAME, - input_section->name, - input_bfd->filename); - -#endif - /* If we are performing a relocateable link, we don't need to do a thing. The caller will take care of adjusting the reloc addresses and symbol indices. */ @@ -1274,23 +1132,6 @@ unsigned short r_type = EXTRACT_TYPE (rel->r_type); unsigned short r_flags = EXTRACT_FLAGS(rel->r_type); -#ifdef DEBUG_RELOC - /* now examine flags */ - if (r_flags != 0) - { - fprintf (stderr, "Reloc with flags found!"); - if ( r_flags & IMAGE_REL_PPC_NEG ) - fprintf (stderr, " NEG"); - if ( r_flags & IMAGE_REL_PPC_BRTAKEN ) - fprintf (stderr, " BRTAKEN"); - if ( r_flags & IMAGE_REL_PPC_BRNTAKEN ) - fprintf (stderr, " BRNTAKEN"); - if ( r_flags & IMAGE_REL_PPC_TOCDEFN ) - fprintf (stderr, " TOCDEFN"); - fprintf(stderr, "\n"); - } -#endif - symndx = rel->r_symndx; loc = contents + rel->r_vaddr - input_section->vma; @@ -1308,7 +1149,7 @@ (obj_coff_sym_hashes (input_bfd)[symndx]); if (h != 0) { - CHECK_EYE(h->eye_catcher); + HASH_CHECK(h); } sym = syms + symndx; @@ -1316,8 +1157,7 @@ if (r_type == IMAGE_REL_PPC_IMGLUE && h == 0) { - fprintf(stderr, - "relocate_section: IMGLUE reloc has no name!\n"); + /* An IMGLUE reloc must have a name. Something is very wrong. */ abort(); } @@ -1340,7 +1180,7 @@ } else { - CHECK_EYE(h->eye_catcher); + HASH_CHECK(h); if (h->root.root.type == bfd_link_hash_defined || h->root.root.type == bfd_link_hash_defweak) @@ -1352,8 +1192,6 @@ } else { - fprintf(stderr, - "missing %s\n",h->root.root.root.string); if (! ((*info->callbacks->undefined_symbol) (info, h->root.root.root.string, input_bfd, input_section, rel->r_vaddr - input_section->vma))) @@ -1367,11 +1205,10 @@ switch (r_type) { default: - fprintf( stderr, - "ERROR: during reloc processing -- unsupported reloc %s\n", - howto->name); + (*_bfd_error_handler) + ("%s: unsupported relocation type 0x%02x", + bfd_get_filename (input_bfd), r_type); bfd_set_error (bfd_error_bad_value); - abort(); return false; case IMAGE_REL_PPC_TOCREL16: { @@ -1384,17 +1221,10 @@ { toc_section = bfd_get_section_by_name (bfd_of_toc_owner, TOC_SECTION_NAME); -#ifdef TOC_DEBUG - - fprintf(stderr, - "BFD of toc owner %p (%s), section addr of %s %p\n", - bfd_of_toc_owner, bfd_of_toc_owner->filename, - TOC_SECTION_NAME, toc_section); -#endif if ( toc_section == NULL ) { - fprintf(stderr, "No Toc section!\n"); + /* There is no toc section. Something is very wrong. */ abort(); } } @@ -1425,27 +1255,14 @@ again. */ MAKE_ADDR_AGAIN(our_toc_offset); -#ifdef TOC_DEBUG - - fprintf(stderr, - "Not writing out toc_offset of %d for %s\n", - our_toc_offset, name); -#endif } else { /* write out the toc entry */ - record_toc(toc_section, our_toc_offset, priv, strdup(name)); -#ifdef TOC_DEBUG - fprintf(stderr, - "Writing out toc_offset " - "toc_section (%p,%p)+%d val %d for %s\n", - toc_section, - toc_section->contents, - our_toc_offset, - val, - name); -#endif + record_toc(toc_section, + our_toc_offset, + priv, + strdup(name)); bfd_put_32(output_bfd, val, @@ -1477,29 +1294,19 @@ dll linkage, takes advantage of that and considers the IAT to be part of the toc, thus saving a load. */ -#ifdef DEBUG_RELOC - fprintf(stderr, - "TOCDEFN is on, (%s) (%p) our_toc_offset = %x, val (%x) vma (%x) off (%x)\n", - name, h, our_toc_offset, - val, toc_section->output_section->vma, - toc_section->output_offset); -#endif our_toc_offset = val - (toc_section->output_section->vma + toc_section->output_offset); -#ifdef DEBUG_RELOC - fprintf(stderr, - " our_toc_offset set to %x\n", our_toc_offset); -#endif - /* The size must still fit in a 16bit displacment */ if (our_toc_offset >= 65535) { - fprintf(stderr, - "Error: TOCDEFN Relocation of %d for %s exceeded displacement of 65535\n", our_toc_offset, name); - abort(); + (*_bfd_error_handler) + ("%s: Relocation for %s of %x exceeds Toc size limit", + bfd_get_filename (input_bfd), name, our_toc_offset); + bfd_set_error (bfd_error_bad_value); + return false; } record_toc(toc_section, our_toc_offset, pub, strdup(name)); @@ -1511,28 +1318,11 @@ again. */ MAKE_ADDR_AGAIN(our_toc_offset); -#ifdef TOC_DEBUG - fprintf(stderr, - "Not writing out toc_offset of %d for %s\n", - our_toc_offset, name); -#endif } else { record_toc(toc_section, our_toc_offset, pub, strdup(name)); -#ifdef TOC_DEBUG - /* write out the toc entry */ - fprintf(stderr, - "Writing out toc_offset " - "toc_section (%p,%p)+%d val %d for %s\n", - toc_section, - toc_section->contents, - our_toc_offset, - val, - name); -#endif - /* write out the toc entry */ bfd_put_32(output_bfd, val, @@ -1560,10 +1350,6 @@ if (coff_data(output_bfd)->pe) addr -= pe_data(output_bfd)->pe_opthdr.ImageBase; -#ifdef DEBUG_RELOC - fprintf(stderr, - " Toc Section .reloc candidate addr = %x\n", addr); -#endif fwrite (&addr, 1,4, (FILE *) info->base_file); } @@ -1572,9 +1358,12 @@ if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN && our_toc_offset > toc_section->_raw_size) { - fprintf(stderr, - "reloc offset is bigger than the toc size!\n"); - abort(); + (*_bfd_error_handler) + ("%s: Relocation exceeds allocated TOC (%x)", + bfd_get_filename (input_bfd), + toc_section->_raw_size); + bfd_set_error (bfd_error_bad_value); + return false; } /* Now we know the relocation for this toc reference */ @@ -1647,15 +1436,13 @@ if (h->symbol_is_glue == 1) break; my_name = h->root.root.root.string; - fprintf(stderr, - "Warning: previously missed IMGLUE reloc %s \n", - howto->name, - bfd_get_filename(input_bfd), - input_section->name); - break; + (*_bfd_error_handler) + ("%s: Out of order IMGLUE reloc for %s", + bfd_get_filename (input_bfd), my_name); + bfd_set_error (bfd_error_bad_value); + return false; } - break; case IMAGE_REL_PPC_ADDR32NB: { @@ -1686,12 +1473,6 @@ "__idata4_magic__", false, false, true); import_table_size = myh->root.u.def.value; -#ifdef DEBUG_RELOC - fprintf(stderr, - "first computation triggered fta %x, ts %d(%x), its %d(%x)\n", - first_thunk_address, thunk_size, thunk_size, import_table_size, - import_table_size); -#endif } if (h == 0) @@ -1720,7 +1501,7 @@ false, false, true); if (myh == 0) { - fprintf(stderr, "Missing idata magic cookies, this cannot work anyway...\n"); + /* Missing magic cookies. Something is very wrong. */ abort(); } @@ -1747,13 +1528,6 @@ "__idata4_magic__", false, false, true); import_table_size = myh->root.u.def.value; -#ifdef DEBUG_RELOC - - fprintf(stderr, - "second computation triggered fta %x, ts %d(%x), its %d(%x)\n", - first_thunk_address, thunk_size, thunk_size, import_table_size, - import_table_size); -#endif } } } @@ -1803,19 +1577,8 @@ if (coff_data(output_bfd)->pe) { -#ifdef DEBUG_RELOC - bfd_vma before_addr = addr; -#endif addr -= pe_data(output_bfd)->pe_opthdr.ImageBase; -#ifdef DEBUG_RELOC - fprintf(stderr, - " adjusted down from %x to %x", before_addr, addr); -#endif } -#ifdef DEBUG_RELOC - fprintf(stderr, "\n"); -#endif - fwrite (&addr, 1,4, (FILE *) info->base_file); } } @@ -1846,28 +1609,12 @@ buf[SYMNMLEN] = '\0'; name = buf; } -#if 0 - else - { - name = _bfd_coff_internal_syment_name (input_bfd, sym, buf); - if (name == NULL) - return false; - } -#endif if (! ((*info->callbacks->reloc_overflow) (info, name, howto->name, (bfd_vma) 0, input_bfd, input_section, rel->r_vaddr - input_section->vma))) { -#ifdef DEBUG_RELOC - fprintf(stderr, - "pe_ppc_relocate_section (%s) for %s in bfd %s RETURNING TRUE\n", - TARGET_LITTLE_NAME, - input_section->name, - input_bfd->filename); - -#endif return false; } } @@ -1875,21 +1622,15 @@ } -#ifdef DEBUG_RELOC - fprintf(stderr, - "pe_ppc_relocate_section (%s) for %s in bfd %s RETURNING TRUE\n", - TARGET_LITTLE_NAME, - input_section->name, - input_bfd->filename); - -#endif - return true; } - #ifdef COFF_IMAGE_WITH_PE +/* FIXME: BFD should not use global variables. This file is compiled + twice, and these variables are shared. This is confusing and + weird. */ + long int global_toc_size = 4; bfd* bfd_of_toc_owner = 0; @@ -1909,8 +1650,8 @@ h3 = " Offset spelling (if present)\n"; void -dump_toc(vfile) - void *vfile; +dump_toc (vfile) + PTR vfile; { FILE *file = vfile; struct list_ele *t; @@ -1967,15 +1708,14 @@ if (bfd_of_toc_owner == 0) { - fprintf(stderr, - "There is no bfd that owns the toc section!\n"); + /* No toc owner? Something is very wrong. */ abort(); } s = bfd_get_section_by_name ( bfd_of_toc_owner , TOC_SECTION_NAME); if (s == NULL) { - fprintf(stderr, "No Toc section!\n"); + /* No toc section? Something is very wrong. */ abort(); } @@ -1996,12 +1736,6 @@ asection *sec; struct internal_reloc *i, *rel; -#ifdef DEBUG_RELOC - fprintf(stderr, - "ppc_process_before_allocation: BFD %s\n", - bfd_get_filename(abfd)); -#endif - /* here we have a bfd that is to be included on the link. We have a hook to do reloc rummaging, before section sizes are nailed down. */ @@ -2017,15 +1751,6 @@ for (; sec != 0; sec = sec->next) { - int toc_offset; - -#ifdef DEBUG_RELOC - fprintf(stderr, - " section %s reloc count %d\n", - sec->name, - sec->reloc_count); -#endif - if (sec->reloc_count == 0) continue; @@ -2040,46 +1765,20 @@ { unsigned short r_type = EXTRACT_TYPE (rel->r_type); unsigned short r_flags = EXTRACT_FLAGS(rel->r_type); + boolean ok = true; -#ifdef DEBUG_RELOC - /* now examine flags */ - if (r_flags != 0) - { - fprintf (stderr, "Reloc with flags found!"); - if ( r_flags & IMAGE_REL_PPC_NEG ) - fprintf (stderr, " NEG"); - if ( r_flags & IMAGE_REL_PPC_BRTAKEN ) - fprintf (stderr, " BRTAKEN"); - if ( r_flags & IMAGE_REL_PPC_BRNTAKEN ) - fprintf (stderr, " BRNTAKEN"); - if ( r_flags & IMAGE_REL_PPC_TOCDEFN ) - fprintf (stderr, " TOCDEFN"); - fprintf(stderr, "\n"); - } -#endif - DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel); switch(r_type) { case IMAGE_REL_PPC_TOCREL16: -#if 0 - /* FIXME: - This remains unimplemented for now, as it currently adds - un-necessary elements to the toc. All we need to do today - is not do anything if TOCDEFN is on. - */ - if ( r_flags & IMAGE_REL_PPC_TOCDEFN ) - toc_offset = ppc_record_data_in_toc_entry(abfd, info, sec, - rel->r_symndx, - default_toc); - else - toc_offset = ppc_record_toc_entry(abfd, info, sec, - rel->r_symndx, default_toc); -#endif + /* if TOCDEFN is on, ignore as someone else has allocated the + toc entry */ if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN ) - toc_offset = ppc_record_toc_entry(abfd, info, sec, - rel->r_symndx, default_toc); + ok = ppc_record_toc_entry(abfd, info, sec, + rel->r_symndx, default_toc); + if (!ok) + return false; break; case IMAGE_REL_PPC_IMGLUE: ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel); @@ -2346,38 +2045,11 @@ /* the masking process only slices off the bottom byte for r_type. */ if ( r_type > MAX_RELOC_INDEX ) - { - fprintf(stderr, - "ppc_coff_rtype2howto: reloc index %d out of range [%d, %ld]\n", - internal->r_type, 0, (long) MAX_RELOC_INDEX); - abort(); - } + abort(); /* check for absolute crap */ if ( junk != 0 ) - { - fprintf(stderr, - "ppc_coff_rtype2howto: reloc index %d contains junk %d\n", - internal->r_type, junk); - abort(); - } - -#ifdef DEBUG_RELOC - /* now examine flags */ - if (r_flags != 0) - { - fprintf (stderr, "Reloc with flags found!"); - if ( r_flags & IMAGE_REL_PPC_NEG ) - fprintf (stderr, " NEG"); - if ( r_flags & IMAGE_REL_PPC_BRTAKEN ) - fprintf (stderr, " BRTAKEN"); - if ( r_flags & IMAGE_REL_PPC_BRNTAKEN ) - fprintf (stderr, " BRNTAKEN"); - if ( r_flags & IMAGE_REL_PPC_TOCDEFN ) - fprintf (stderr, " TOCDEFN"); - fprintf(stderr, "\n"); - } -#endif + abort(); switch(r_type) { @@ -2444,39 +2116,12 @@ /* the masking process only slices off the bottom byte for r_type. */ if ( r_type > MAX_RELOC_INDEX ) - { - fprintf(stderr, - "coff_ppc_rtype_to_howto: index %d out of range [%d, %ld]\n", - r_type, 0, (long) MAX_RELOC_INDEX); - abort(); - } + abort(); /* check for absolute crap */ if ( junk != 0 ) - { - fprintf(stderr, - "coff_ppc_rtype_to_howto: reloc index %d contains junk %d\n", - rel->r_type, junk); - abort(); - } - -#ifdef DEBUG_RELOC - /* now examine flags */ - if (r_flags != 0) - { - fprintf (stderr, "Reloc with flags found!"); - if ( r_flags & IMAGE_REL_PPC_NEG ) - fprintf (stderr, " NEG"); - if ( r_flags & IMAGE_REL_PPC_BRTAKEN ) - fprintf (stderr, " BRTAKEN"); - if ( r_flags & IMAGE_REL_PPC_BRNTAKEN ) - fprintf (stderr, " BRNTAKEN"); - if ( r_flags & IMAGE_REL_PPC_TOCDEFN ) - fprintf (stderr, " TOCDEFN"); - fprintf(stderr, "\n"); - } -#endif - + abort(); + switch(r_type) { case IMAGE_REL_PPC_ADDR32NB: @@ -2530,12 +2175,6 @@ bfd *abfd; bfd_reloc_code_real_type code; { - -#ifdef DEBUG_RELOC - fprintf(stderr, "ppc_coff_reloc_type_lookup for %s\n", - bfd_get_reloc_code_name(code)); -#endif - switch (code) { HOW2MAP(BFD_RELOC_32_GOTOFF, IMAGE_REL_PPC_IMGLUE); @@ -2561,8 +2200,7 @@ #define RTYPE2HOWTO(cache_ptr, dst) ppc_coff_rtype2howto (cache_ptr, dst) #ifndef COFF_IMAGE_WITH_PE -static void -ppc_coff_swap_sym_in_hook (); +static void ppc_coff_swap_sym_in_hook PARAMS ((bfd *, PTR, PTR)); #endif /* We use the special COFF backend linker, with our own special touch. */ @@ -2625,20 +2263,13 @@ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ; -#ifdef TOC_DEBUG - fprintf(stderr, - "ppc_coff_swap_sym_in_hook: about to create the %s section\n", - TOC_SECTION_NAME); -#endif - s = bfd_make_section (abfd, TOC_SECTION_NAME); if (s == NULL || !bfd_set_section_flags (abfd, s, flags) || !bfd_set_section_alignment (abfd, s, 2)) { - fprintf(stderr, - "toc section allocation failed!\n"); + /* FIXME: set appropriate bfd error */ abort(); } @@ -2650,13 +2281,13 @@ } #endif -boolean -ppc_bfd_coff_final_link (); - #ifndef COFF_IMAGE_WITH_PE +static boolean ppc_do_last PARAMS ((bfd *)); +static bfd *ppc_get_last PARAMS ((void)); + static boolean -ppc_do_last(abfd) +ppc_do_last (abfd) bfd *abfd; { if (abfd == bfd_of_toc_owner) @@ -2740,7 +2371,10 @@ /* Compute the file positions for all the sections. */ if (! abfd->output_has_begun) - bfd_coff_compute_section_file_positions (abfd); + { + if (! bfd_coff_compute_section_file_positions (abfd)) + return false; + } /* Count the line numbers and relocation entries required for the output file. Set the file positions for the relocs. */ @@ -2965,7 +2599,6 @@ #ifdef POWERPC_LE_PE { - extern bfd* ppc_get_last(); bfd* last_one = ppc_get_last(); if (last_one) { diff -urN binutils-2.7/bfd/coff-rs6000.c binutils-2.8/bfd/coff-rs6000.c --- binutils-2.7/bfd/coff-rs6000.c Thu Jul 4 12:17:58 1996 +++ binutils-2.8/bfd/coff-rs6000.c Wed Apr 30 12:55:53 1997 @@ -1,5 +1,5 @@ /* BFD back-end for IBM RS/6000 "XCOFF" files. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. FIXME: Can someone provide a transliteration of this name into ASCII? Using the following chars caused a compiler warning on HIUX (so I replaced them with octal escapes), and isn't useful without an understanding of what @@ -31,7 +31,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/internal.h" #include "coff/rs6000.h" #include "libcoff.h" @@ -40,6 +39,7 @@ static boolean xcoff_mkobject PARAMS ((bfd *)); static boolean xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *)); +static boolean xcoff_is_local_label_name PARAMS ((bfd *, const char *)); static void xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); static reloc_howto_type *xcoff_reloc_type_lookup @@ -53,6 +53,7 @@ static boolean xcoff_write_armap PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int)); static boolean xcoff_write_archive_contents PARAMS ((bfd *)); +static int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean)); /* We use our own tdata type. Its first field is the COFF tdata type, so the COFF routines are compatible. */ @@ -130,6 +131,19 @@ ox->maxstack = ix->maxstack; return true; } + +/* I don't think XCOFF really has a notion of local labels based on + name. This will mean that ld -X doesn't actually strip anything. + The AIX native linker does not have a -X option, and it ignores the + -x option. */ + +static boolean +xcoff_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + return false; +} /* The XCOFF reloc table. Actually, XCOFF relocations specify the bitsize and whether they are signed or not, along with a @@ -541,6 +555,7 @@ #define coff_mkobject xcoff_mkobject #define coff_bfd_copy_private_bfd_data xcoff_copy_private_bfd_data +#define coff_bfd_is_local_label_name xcoff_is_local_label_name #define coff_bfd_reloc_type_lookup xcoff_reloc_type_lookup #define coff_relocate_section _bfd_ppc_xcoff_relocate_section diff -urN binutils-2.7/bfd/coff-sh.c binutils-2.8/bfd/coff-sh.c --- binutils-2.7/bfd/coff-sh.c Thu Jul 4 12:18:00 1996 +++ binutils-2.8/bfd/coff-sh.c Wed Apr 30 12:55:53 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Hitachi Super-H COFF binaries. - Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain, . Relaxing code written by Ian Lance Taylor, . @@ -22,7 +22,6 @@ #include "bfd.h" #include "sysdep.h" -#include "obstack.h" #include "libbfd.h" #include "bfdlink.h" #include "coff/sh.h" @@ -41,7 +40,7 @@ static boolean sh_align_loads PARAMS ((bfd *, asection *, struct internal_reloc *, bfd_byte *, boolean *)); static boolean sh_swap_insns - PARAMS ((bfd *, asection *, struct internal_reloc *, bfd_byte *, bfd_vma)); + PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma)); static boolean sh_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, struct internal_reloc *, struct internal_syment *, asection **)); @@ -1883,7 +1882,8 @@ /* See whether instructions I1 and I2 conflict, assuming I1 comes before I2. OP1 and OP2 are the corresponding sh_opcode structures. - This should return true if the instructions can be swapped safely. */ + This should return true if there is a conflict, or false if the + instructions can be swapped safely. */ static boolean sh_insns_conflict (i1, op1, i2, op2) @@ -1902,7 +1902,7 @@ return true; if ((f1 & SETSSP) != 0 && (f2 & USESSP) != 0) - return false; + return true; if ((f2 & SETSSP) != 0 && (f1 & USESSP) != 0) return true; @@ -1972,6 +1972,189 @@ return false; } +/* Try to align loads and stores within a span of memory. This is + called by both the ELF and the COFF sh targets. ABFD and SEC are + the BFD and section we are examining. CONTENTS is the contents of + the section. SWAP is the routine to call to swap two instructions. + RELOCS is a pointer to the internal relocation information, to be + passed to SWAP. PLABEL is a pointer to the current label in a + sorted list of labels; LABEL_END is the end of the list. START and + STOP are the range of memory to examine. If a swap is made, + *PSWAPPED is set to true. */ + +boolean +_bfd_sh_align_load_span (abfd, sec, contents, swap, relocs, + plabel, label_end, start, stop, pswapped) + bfd *abfd; + asection *sec; + bfd_byte *contents; + boolean (*swap) PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma)); + PTR relocs; + bfd_vma **plabel; + bfd_vma *label_end; + bfd_vma start; + bfd_vma stop; + boolean *pswapped; +{ + bfd_vma i; + + /* Instructions should be aligned on 2 byte boundaries. */ + if ((start & 1) == 1) + ++start; + + /* Now look through the unaligned addresses. */ + i = start; + if ((i & 2) == 0) + i += 2; + for (; i < stop; i += 4) + { + unsigned int insn; + const struct sh_opcode *op; + unsigned int prev_insn = 0; + const struct sh_opcode *prev_op = NULL; + + insn = bfd_get_16 (abfd, contents + i); + op = sh_insn_info (insn); + if (op == NULL + || (op->flags & (LOAD | STORE)) == 0) + continue; + + /* This is a load or store which is not on a four byte boundary. */ + + while (*plabel < label_end && **plabel < i) + ++*plabel; + + if (i > start) + { + prev_insn = bfd_get_16 (abfd, contents + i - 2); + prev_op = sh_insn_info (prev_insn); + + /* If the load/store instruction is in a delay slot, we + can't swap. */ + if (prev_op == NULL + || (prev_op->flags & DELAY) != 0) + continue; + } + if (i > start + && (*plabel >= label_end || **plabel != i) + && prev_op != NULL + && (prev_op->flags & (LOAD | STORE)) == 0 + && ! sh_insns_conflict (prev_insn, prev_op, insn, op)) + { + boolean ok; + + /* The load/store instruction does not have a label, and + there is a previous instruction; PREV_INSN is not + itself a load/store instruction, and PREV_INSN and + INSN do not conflict. */ + + ok = true; + + if (i >= start + 4) + { + unsigned int prev2_insn; + const struct sh_opcode *prev2_op; + + prev2_insn = bfd_get_16 (abfd, contents + i - 4); + prev2_op = sh_insn_info (prev2_insn); + + /* If the instruction before PREV_INSN has a delay + slot--that is, PREV_INSN is in a delay slot--we + can not swap. */ + if (prev2_op == NULL + || (prev2_op->flags & DELAY) != 0) + ok = false; + + /* If the instruction before PREV_INSN is a load, + and it sets a register which INSN uses, then + putting INSN immediately after PREV_INSN will + cause a pipeline bubble, so there is no point to + making the swap. */ + if (ok + && (prev2_op->flags & LOAD) != 0 + && sh_load_use (prev2_insn, prev2_op, insn, op)) + ok = false; + } + + if (ok) + { + if (! (*swap) (abfd, sec, relocs, contents, i - 2)) + return false; + *pswapped = true; + continue; + } + } + + while (*plabel < label_end && **plabel < i + 2) + ++*plabel; + + if (i + 2 < stop + && (*plabel >= label_end || **plabel != i + 2)) + { + unsigned int next_insn; + const struct sh_opcode *next_op; + + /* There is an instruction after the load/store + instruction, and it does not have a label. */ + next_insn = bfd_get_16 (abfd, contents + i + 2); + next_op = sh_insn_info (next_insn); + if (next_op != NULL + && (next_op->flags & (LOAD | STORE)) == 0 + && ! sh_insns_conflict (insn, op, next_insn, next_op)) + { + boolean ok; + + /* NEXT_INSN is not itself a load/store instruction, + and it does not conflict with INSN. */ + + ok = true; + + /* If PREV_INSN is a load, and it sets a register + which NEXT_INSN uses, then putting NEXT_INSN + immediately after PREV_INSN will cause a pipeline + bubble, so there is no reason to make this swap. */ + if (prev_op != NULL + && (prev_op->flags & LOAD) != 0 + && sh_load_use (prev_insn, prev_op, next_insn, next_op)) + ok = false; + + /* If INSN is a load, and it sets a register which + the insn after NEXT_INSN uses, then doing the + swap will cause a pipeline bubble, so there is no + reason to make the swap. However, if the insn + after NEXT_INSN is itself a load or store + instruction, then it is misaligned, so + optimistically hope that it will be swapped + itself, and just live with the pipeline bubble if + it isn't. */ + if (ok + && i + 4 < stop + && (op->flags & LOAD) != 0) + { + unsigned int next2_insn; + const struct sh_opcode *next2_op; + + next2_insn = bfd_get_16 (abfd, contents + i + 4); + next2_op = sh_insn_info (next2_insn); + if ((next2_op->flags & (LOAD | STORE)) == 0 + && sh_load_use (insn, op, next2_insn, next2_op)) + ok = false; + } + + if (ok) + { + if (! (*swap) (abfd, sec, relocs, contents, i)) + return false; + *pswapped = true; + continue; + } + } + } + } + + return true; +} + /* Look for loads and stores which we can align to four byte boundaries. See the longer comment above sh_relax_section for why this is desirable. This sets *PSWAPPED if some instruction was @@ -2015,7 +2198,7 @@ for (irel = internal_relocs; irel < irelend; irel++) { - bfd_vma start, stop, i; + bfd_vma start, stop; if (irel->r_type != R_SH_CODE) continue; @@ -2030,162 +2213,10 @@ else stop = sec->_cooked_size; - /* Instructions should be aligned on 2 byte boundaries. */ - if ((start & 1) == 1) - ++start; - - /* Now look through the unaligned addresses. */ - i = start; - if ((i & 2) == 0) - i += 2; - for (; i < stop; i += 4) - { - unsigned int insn; - const struct sh_opcode *op; - unsigned int prev_insn = 0; - const struct sh_opcode *prev_op = NULL; - - insn = bfd_get_16 (abfd, contents + i); - op = sh_insn_info (insn); - if (op == NULL - || (op->flags & (LOAD | STORE)) == 0) - continue; - - /* This is a load or store which is not on a four byte - boundary. */ - - while (label < label_end && *label < i) - ++label; - - if (i > start) - { - prev_insn = bfd_get_16 (abfd, contents + i - 2); - prev_op = sh_insn_info (prev_insn); - - /* If the load/store instruction is in a delay slot, we - can't swap. */ - if (prev_op == NULL - || (prev_op->flags & DELAY) != 0) - continue; - } - if (i > start - && (label >= label_end || *label != i) - && prev_op != NULL - && (prev_op->flags & (LOAD | STORE)) == 0 - && ! sh_insns_conflict (prev_insn, prev_op, insn, op)) - { - boolean ok; - - /* The load/store instruction does not have a label, and - there is a previous instruction; PREV_INSN is not - itself a load/store instruction, and PREV_INSN and - INSN do not conflict. */ - - ok = true; - - if (i >= start + 4) - { - unsigned int prev2_insn; - const struct sh_opcode *prev2_op; - - prev2_insn = bfd_get_16 (abfd, contents + i - 4); - prev2_op = sh_insn_info (prev2_insn); - - /* If the instruction before PREV_INSN has a delay - slot--that is, PREV_INSN is in a delay slot--we - can not swap. */ - if (prev2_op == NULL - || (prev2_op->flags & DELAY) != 0) - ok = false; - - /* If the instruction before PREV_INSN is a load, - and it sets a register which INSN uses, then - putting INSN immediately after PREV_INSN will - cause a pipeline bubble, so there is no point to - making the swap. */ - if (ok - && (prev2_op->flags & LOAD) != 0 - && sh_load_use (prev2_insn, prev2_op, insn, op)) - ok = false; - } - - if (ok) - { - if (! sh_swap_insns (abfd, sec, internal_relocs, - contents, i - 2)) - goto error_return; - *pswapped = true; - continue; - } - } - - while (label < label_end && *label < i + 2) - ++label; - - if (i + 2 < stop - && (label >= label_end || *label != i + 2)) - { - unsigned int next_insn; - const struct sh_opcode *next_op; - - /* There is an instruction after the load/store - instruction, and it does not have a label. */ - next_insn = bfd_get_16 (abfd, contents + i + 2); - next_op = sh_insn_info (next_insn); - if (next_op != NULL - && (next_op->flags & (LOAD | STORE)) == 0 - && ! sh_insns_conflict (insn, op, next_insn, next_op)) - { - boolean ok; - - /* NEXT_INSN is not itself a load/store instruction, - and it does not conflict with INSN. */ - - ok = true; - - /* If PREV_INSN is a load, and it sets a register - which NEXT_INSN uses, then putting NEXT_INSN - immediately after PREV_INSN will cause a pipeline - bubble, so there is no reason to make this swap. */ - if (prev_op != NULL - && (prev_op->flags & LOAD) != 0 - && sh_load_use (prev_insn, prev_op, next_insn, next_op)) - ok = false; - - /* If INSN is a load, and it sets a register which - the insn after NEXT_INSN uses, then doing the - swap will cause a pipeline bubble, so there is no - reason to make the swap. However, if the insn - after NEXT_INSN is itself a load or store - instruction, then it is misaligned, so - optimistically hope that it will be swapped - itself, and just live with the pipeline bubble if - it isn't. */ - if (ok - && i + 4 < stop - && (op->flags & LOAD) != 0) - { - unsigned int next2_insn; - const struct sh_opcode *next2_op; - - next2_insn = bfd_get_16 (abfd, contents + i + 4); - next2_op = sh_insn_info (next2_insn); - if ((next2_op->flags & (LOAD | STORE)) == 0 - && sh_load_use (insn, op, next2_insn, next2_op)) - ok = false; - } - - if (ok) - { - if (! sh_swap_insns (abfd, sec, internal_relocs, - contents, i)) - goto error_return; - *pswapped = true; - continue; - } - } - } - } + if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_swap_insns, + (PTR) internal_relocs, &label, + label_end, start, stop, pswapped)) + goto error_return; } free (labels); @@ -2201,13 +2232,14 @@ /* Swap two SH instructions. */ static boolean -sh_swap_insns (abfd, sec, internal_relocs, contents, addr) +sh_swap_insns (abfd, sec, relocs, contents, addr) bfd *abfd; asection *sec; - struct internal_reloc *internal_relocs; + PTR relocs; bfd_byte *contents; bfd_vma addr; { + struct internal_reloc *internal_relocs = (struct internal_reloc *) relocs; unsigned short i1, i2; struct internal_reloc *irel, *irelend; @@ -2374,6 +2406,14 @@ } else { + if (symndx < 0 || symndx >= obj_raw_syment_count (input_bfd)) + { + (*_bfd_error_handler) + ("%s: illegal symbol index %ld in relocs", + bfd_get_filename (input_bfd), symndx); + bfd_set_error (bfd_error_bad_value); + return false; + } h = obj_coff_sym_hashes (input_bfd)[symndx]; sym = syms + symndx; } diff -urN binutils-2.7/bfd/coff-sparc.c binutils-2.8/bfd/coff-sparc.c --- binutils-2.7/bfd/coff-sparc.c Thu Jul 4 12:18:01 1996 +++ binutils-2.8/bfd/coff-sparc.c Wed Apr 30 12:55:53 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Sparc COFF files. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -21,7 +21,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/sparc.h" #include "coff/internal.h" #include "libcoff.h" diff -urN binutils-2.7/bfd/coff-svm68k.c binutils-2.8/bfd/coff-svm68k.c --- binutils-2.7/bfd/coff-svm68k.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/coff-svm68k.c Wed Apr 30 12:55:53 1997 @@ -0,0 +1,26 @@ +/* BFD back-end for Motorola sysv68 + Copyright 1997 Free Software Foundation, Inc. + Written by Philippe De Muyter . + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define TARGET_SYM m68ksysvcoff_vec +#define TARGET_NAME "coff-m68k-sysv" +#define STATIC_RELOCS +#define COFF_COMMON_ADDEND + +#include "coff-m68k.c" diff -urN binutils-2.7/bfd/coff-w65.c binutils-2.8/bfd/coff-w65.c --- binutils-2.7/bfd/coff-w65.c Thu Jul 4 12:18:01 1996 +++ binutils-2.8/bfd/coff-w65.c Wed Apr 30 12:55:54 1997 @@ -1,5 +1,5 @@ /* BFD back-end for WDC 65816 COFF binaries. - Copyright 1995 Free Software Foundation, Inc. + Copyright 1995, 96, 1997 Free Software Foundation, Inc. Written by Steve Chamberlain, . This file is part of BFD, the Binary File Descriptor library. @@ -20,7 +20,6 @@ #include "bfd.h" #include "sysdep.h" -#include "obstack.h" #include "libbfd.h" #include "bfdlink.h" #include "coff/w65.h" @@ -83,7 +82,7 @@ #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) -/* Perform any necessaru magic to the addend in a reloc entry */ +/* Perform any necessary magic to the addend in a reloc entry */ #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ diff -urN binutils-2.7/bfd/coff-we32k.c binutils-2.8/bfd/coff-we32k.c --- binutils-2.7/bfd/coff-we32k.c Thu Jul 4 12:18:01 1996 +++ binutils-2.8/bfd/coff-we32k.c Wed Apr 30 12:55:54 1997 @@ -1,5 +1,5 @@ /* BFD back-end for we32k COFF files. - Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 1997 Free Software Foundation, Inc. Contributed by Brendan Kehoe (brendan@cs.widener.edu). This file is part of BFD, the Binary File Descriptor library. @@ -21,7 +21,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -#include "obstack.h" #include "coff/we32k.h" #include "coff/internal.h" #include "libcoff.h" diff -urN binutils-2.7/bfd/coff-z8k.c binutils-2.8/bfd/coff-z8k.c --- binutils-2.7/bfd/coff-z8k.c Thu Jul 4 12:18:01 1996 +++ binutils-2.8/bfd/coff-z8k.c Wed Apr 30 12:55:54 1997 @@ -1,5 +1,5 @@ /* BFD back-end for Zilog Z800n COFF binaries. - Copyright 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1992, 93, 94, 95, 1997 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain, . @@ -21,7 +21,6 @@ #include "bfd.h" #include "sysdep.h" -#include "obstack.h" #include "libbfd.h" #include "bfdlink.h" #include "coff/z8k.h" @@ -112,7 +111,7 @@ #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry) -/* Perform any necessaru magic to the addend in a reloc entry */ +/* Perform any necessary magic to the addend in a reloc entry */ #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ diff -urN binutils-2.7/bfd/coffcode.h binutils-2.8/bfd/coffcode.h --- binutils-2.7/bfd/coffcode.h Wed Jul 10 11:19:29 1996 +++ binutils-2.8/bfd/coffcode.h Wed Apr 30 12:55:54 1997 @@ -1,5 +1,5 @@ /* Support for the generic parts of most COFF variants, for BFD. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -310,6 +310,30 @@ #endif #define STRING_SIZE_SIZE (4) + +static long sec_to_styp_flags PARAMS ((const char *, flagword)); +static flagword styp_to_sec_flags PARAMS ((bfd *, PTR, const char *)); +static boolean coff_bad_format_hook PARAMS ((bfd *, PTR)); +static boolean coff_new_section_hook PARAMS ((bfd *, asection *)); +static boolean coff_set_arch_mach_hook PARAMS ((bfd *, PTR)); +static boolean coff_write_relocs PARAMS ((bfd *, int)); +static boolean coff_set_flags + PARAMS ((bfd *, unsigned int *, unsigned short *)); +static boolean coff_set_arch_mach + PARAMS ((bfd *, enum bfd_architecture, unsigned long)); +static boolean coff_compute_section_file_positions PARAMS ((bfd *)); +static boolean coff_write_object_contents PARAMS ((bfd *)); +static boolean coff_set_section_contents + PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); +static PTR buy_and_read PARAMS ((bfd *, file_ptr, int, size_t)); +static boolean coff_slurp_line_table PARAMS ((bfd *, asection *)); +static boolean coff_slurp_symbol_table PARAMS ((bfd *)); +static boolean coff_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **)); +static long coff_canonicalize_reloc + PARAMS ((bfd *, asection *, arelent **, asymbol **)); +#ifndef coff_mkobject_hook +static PTR coff_mkobject_hook PARAMS ((bfd *, PTR, PTR)); +#endif /* void warning(); */ @@ -727,6 +751,7 @@ . unsigned int _bfd_linesz; . boolean _bfd_coff_long_filenames; . boolean _bfd_coff_long_section_names; +. unsigned int _bfd_coff_default_section_alignment_power; . void (*_bfd_coff_swap_filehdr_in) PARAMS (( . bfd *abfd, . PTR ext, @@ -796,7 +821,7 @@ . boolean (*_bfd_coff_sym_is_global) PARAMS (( . bfd *abfd, . struct internal_syment *)); -. void (*_bfd_coff_compute_section_file_positions) PARAMS (( +. boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( . bfd *abfd)); . boolean (*_bfd_coff_start_final_link) PARAMS (( . bfd *output_bfd, @@ -880,6 +905,8 @@ .#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames) .#define bfd_coff_long_section_names(abfd) \ . (coff_backend_info (abfd)->_bfd_coff_long_section_names) +.#define bfd_coff_default_section_alignment_power(abfd) \ +. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) .#define bfd_coff_swap_filehdr_in(abfd, i,o) \ . ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) . @@ -1033,6 +1060,8 @@ /* Set the alignment of a BFD section. */ +static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR)); + static void coff_set_alignment_hook (abfd, section, scnhdr) bfd * abfd; @@ -1064,6 +1093,8 @@ section->alignment_power = y;\ } +static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR)); + static void coff_set_alignment_hook (abfd, section, scnhdr) bfd * abfd; @@ -1151,6 +1182,8 @@ When we see one, we correct the reloc and line number counts in the real header, and remove the section we just created. */ +static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR)); + static void coff_set_alignment_hook (abfd, section, scnhdr) bfd *abfd; @@ -1192,6 +1225,9 @@ #endif /* ! I960 */ #ifndef coff_mkobject + +static boolean coff_mkobject PARAMS ((bfd *)); + static boolean coff_mkobject (abfd) bfd * abfd; @@ -1499,6 +1535,15 @@ break; #endif +#ifdef H8300SMAGIC + case H8300SMAGIC: + arch = bfd_arch_h8300; + machine = bfd_mach_h8300s; + /* !! FIXME this probably isn't the right place for this */ + abfd->flags |= BFD_IS_RELAXABLE; + break; +#endif + #ifdef SH_ARCH_MAGIC_BIG case SH_ARCH_MAGIC_BIG: case SH_ARCH_MAGIC_LITTLE: @@ -1524,6 +1569,12 @@ break; #endif +#ifdef TIC80_ARCH_MAGIC + case TIC80_ARCH_MAGIC: + arch = bfd_arch_tic80; + break; +#endif + default: /* Unreadable input file type */ arch = bfd_arch_obscure; break; @@ -1535,6 +1586,9 @@ #ifdef SYMNAME_IN_DEBUG +static boolean symname_in_debug_hook + PARAMS ((bfd *, struct internal_syment *)); + static boolean symname_in_debug_hook (abfd, sym) bfd * abfd; @@ -1825,7 +1879,7 @@ static boolean coff_set_flags (abfd, magicp, flagsp) bfd * abfd; - unsigned *magicp; + unsigned int *magicp; unsigned short *flagsp; { switch (bfd_get_arch (abfd)) @@ -1923,8 +1977,13 @@ #ifdef APOLLOM68KMAGIC *magicp = APOLLO_COFF_VERSION_NUMBER; #else + /* NAMES_HAVE_UNDERSCORE may be defined by coff-u68k.c. */ +#ifdef NAMES_HAVE_UNDERSCORE + *magicp = MC68KBCSMAGIC; +#else *magicp = MC68MAGIC; #endif +#endif #ifdef LYNXOS /* Just overwrite the usual value if we're doing Lynx. */ *magicp = LYNXCOFFMAGIC; @@ -1949,6 +2008,9 @@ case bfd_mach_h8300h: *magicp = H8300HMAGIC; return true; + case bfd_mach_h8300s: + *magicp = H8300SMAGIC; + return true; } break; #endif @@ -2039,13 +2101,14 @@ /* Calculate the file position for each section. */ -static void +static boolean coff_compute_section_file_positions (abfd) bfd * abfd; { asection *current; asection *previous = (asection *) NULL; file_ptr sofar = FILHSZ; + boolean align_adjust; #ifndef I960 file_ptr old_sofar; @@ -2131,6 +2194,7 @@ sofar += SCNHSZ; #endif + align_adjust = false; for (current = abfd->sections, count = 1; current != (asection *) NULL; current = current->next, ++count) @@ -2179,20 +2243,14 @@ current->used_by_bfd = (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)); if (current->used_by_bfd == NULL) - { - /* FIXME: Return error. */ - abort (); - } + return false; } if (pei_section_data (abfd, current) == NULL) { coff_section_data (abfd, current)->tdata = (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata)); if (coff_section_data (abfd, current)->tdata == NULL) - { - /* FIXME: Return error. */ - abort (); - } + return false; } if (pei_section_data (abfd, current)->virt_size == 0) pei_section_data (abfd, current)->virt_size = current->_raw_size; @@ -2205,12 +2263,20 @@ #ifndef I960 /* make sure that this section is of the right size too */ if ((abfd->flags & EXEC_P) == 0) - current->_raw_size = BFD_ALIGN (current->_raw_size, - 1 << current->alignment_power); + { + bfd_size_type old_size; + + old_size = current->_raw_size; + current->_raw_size = BFD_ALIGN (current->_raw_size, + 1 << current->alignment_power); + align_adjust = current->_raw_size != old_size; + sofar += current->_raw_size - old_size; + } else { old_sofar = sofar; sofar = BFD_ALIGN (sofar, 1 << current->alignment_power); + align_adjust = sofar != old_sofar; current->_raw_size += sofar - old_sofar; } #endif @@ -2226,9 +2292,30 @@ previous = current; } + /* It is now safe to write to the output file. If we needed an + alignment adjustment for the last section, then make sure that + there is a byte at offset sofar. If there are no symbols and no + relocs, then nothing follows the last section. If we don't force + the last byte out, then the file may appear to be truncated. */ + if (align_adjust) + { + bfd_byte b; + + b = 0; + if (bfd_seek (abfd, sofar - 1, SEEK_SET) != 0 + || bfd_write (&b, 1, 1, abfd) != 1) + return false; + } + + /* Make sure the relocations are aligned. We don't need to make + sure that this byte exists, because it will only matter if there + really are relocs. */ + sofar = BFD_ALIGN (sofar, 1 << COFF_DEFAULT_SECTION_ALIGNMENT_POWER); + obj_relocbase (abfd) = sofar; abfd->output_has_begun = true; + return true; } #if 0 @@ -2285,7 +2372,7 @@ if (!need_text && !need_data && !need_bss && !need_file) return true; nsyms += need_text + need_data + need_bss + need_file; - sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *)); + sympp2 = (asymbol **) bfd_alloc (abfd, nsyms * sizeof (asymbol *)); if (!sympp2) return false; memcpy (sympp2, sympp, i * sizeof (asymbol *)); @@ -2340,7 +2427,10 @@ lnno_size = coff_count_linenumbers (abfd) * LINESZ; if (abfd->output_has_begun == false) - coff_compute_section_file_positions (abfd); + { + if (! coff_compute_section_file_positions (abfd)) + return false; + } reloc_base = obj_relocbase (abfd); @@ -2698,6 +2788,10 @@ internal_a.magic = NMAGIC; /* Assume separate i/d */ #define __A_MAGIC_SET__ #endif /* A29K */ +#ifdef TIC80 + internal_a.magic = TIC80_ARCH_MAGIC; +#define __A_MAGIC_SET__ +#endif /* TIC80 */ #ifdef I860 /* FIXME: What are the a.out magic numbers for the i860? */ internal_a.magic = 0; @@ -2972,7 +3066,10 @@ bfd_size_type count; { if (abfd->output_has_begun == false) /* set by bfd.c handler */ - coff_compute_section_file_positions (abfd); + { + if (! coff_compute_section_file_positions (abfd)) + return false; + } #if defined(_LIB) && !defined(TARG_AUX) @@ -3049,8 +3146,7 @@ return false; } - /* We depend on bfd_close to free all the memory on the obstack. */ - /* FIXME if bfd_release is not using obstacks! */ + /* We depend on bfd_close to free all the memory on the objalloc. */ return true; } @@ -3126,11 +3222,27 @@ if (cache_ptr->line_number == 0) { - coff_symbol_type *sym = - (coff_symbol_type *) (dst.l_addr.l_symndx - + obj_raw_syments (abfd))->u.syment._n._n_n._n_zeroes; + boolean warned; + long symndx; + coff_symbol_type *sym; + + warned = false; + symndx = dst.l_addr.l_symndx; + if (symndx < 0 || symndx >= obj_raw_syment_count (abfd)) + { + (*_bfd_error_handler) + ("%s: warning: illegal symbol index %ld in line numbers", + bfd_get_filename (abfd), dst.l_addr.l_symndx); + symndx = 0; + warned = true; + } + /* FIXME: We should not be casting between ints and + pointers like this. */ + sym = ((coff_symbol_type *) + ((symndx + obj_raw_syments (abfd)) + ->u.syment._n._n_n._n_zeroes)); cache_ptr->u.sym = (asymbol *) sym; - if (sym->lineno != NULL) + if (sym->lineno != NULL && ! warned) { (*_bfd_error_handler) ("%s: warning: duplicate line number information for `%s'", @@ -3464,6 +3576,8 @@ #ifdef OTHER_GLOBAL_CLASS +static boolean coff_sym_is_global PARAMS ((bfd *, struct internal_syment *)); + static boolean coff_sym_is_global (abfd, syment) bfd *abfd; @@ -3568,40 +3682,43 @@ for (idx = 0; idx < asect->reloc_count; idx++) { -#ifdef RELOC_PROCESSING struct internal_reloc dst; struct external_reloc *src; - - cache_ptr = reloc_cache + idx; - src = native_relocs + idx; - coff_swap_reloc_in (abfd, src, &dst); - - RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); -#else - struct internal_reloc dst; +#ifndef RELOC_PROCESSING asymbol *ptr; - struct external_reloc *src; +#endif cache_ptr = reloc_cache + idx; src = native_relocs + idx; coff_swap_reloc_in (abfd, src, &dst); - +#ifdef RELOC_PROCESSING + RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect); +#else cache_ptr->address = dst.r_vaddr; if (dst.r_symndx != -1) { - /* @@ Should never be greater than count of symbols! */ - if (dst.r_symndx >= obj_conv_table_size (abfd)) - abort (); - cache_ptr->sym_ptr_ptr = symbols + obj_convert (abfd)[dst.r_symndx]; - ptr = *(cache_ptr->sym_ptr_ptr); + if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd)) + { + (*_bfd_error_handler) + ("%s: warning: illegal symbol index %ld in relocs", + bfd_get_filename (abfd), dst.r_symndx); + cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; + ptr = NULL; + } + else + { + cache_ptr->sym_ptr_ptr = (symbols + + obj_convert (abfd)[dst.r_symndx]); + ptr = *(cache_ptr->sym_ptr_ptr); + } } else { cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; - ptr = 0; + ptr = NULL; } /* The symbols definitions that we have read in have been @@ -3619,8 +3736,16 @@ /* Fill in the cache_ptr->howto field from dst.r_type */ RTYPE2HOWTO (cache_ptr, &dst); -#endif +#endif /* RELOC_PROCESSING */ + if (cache_ptr->howto == NULL) + { + (*_bfd_error_handler) + ("%s: illegal relocation type %d at address 0x%lx", + bfd_get_filename (abfd), dst.r_type, (long) dst.r_vaddr); + bfd_set_error (bfd_error_bad_value); + return false; + } } asect->relocation = reloc_cache; @@ -3717,6 +3842,10 @@ #ifndef coff_reloc16_estimate #define coff_reloc16_estimate dummy_reloc16_estimate +static int dummy_reloc16_estimate + PARAMS ((bfd *, asection *, arelent *, unsigned int, + struct bfd_link_info *)); + static int dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info) bfd *abfd; @@ -3731,8 +3860,15 @@ #endif #ifndef coff_reloc16_extra_cases + #define coff_reloc16_extra_cases dummy_reloc16_extra_cases + /* This works even if abort is not declared in any header file. */ + +static void dummy_reloc16_extra_cases + PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, + bfd_byte *, unsigned int *, unsigned int *)); + static void dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) @@ -3802,6 +3938,7 @@ #else false, #endif + COFF_DEFAULT_SECTION_ALIGNMENT_POWER, coff_swap_filehdr_in, coff_swap_aouthdr_in, coff_swap_scnhdr_in, coff_swap_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, @@ -3835,8 +3972,8 @@ #define coff_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data #endif -#ifndef coff_bfd_is_local_label -#define coff_bfd_is_local_label bfd_generic_is_local_label +#ifndef coff_bfd_is_local_label_name +#define coff_bfd_is_local_label_name _bfd_coff_is_local_label_name #endif #ifndef coff_read_minisymbols #define coff_read_minisymbols _bfd_generic_read_minisymbols diff -urN binutils-2.7/bfd/coffgen.c binutils-2.8/bfd/coffgen.c --- binutils-2.7/bfd/coffgen.c Thu Jul 4 12:18:05 1996 +++ binutils-2.8/bfd/coffgen.c Wed Apr 30 12:55:54 1997 @@ -1,5 +1,5 @@ /* Support for the generic parts of COFF, for BFD. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -56,6 +56,17 @@ static void coff_pointerize_aux PARAMS ((bfd *, combined_entry_type *, combined_entry_type *, unsigned int, combined_entry_type *)); +static boolean make_a_section_from_file + PARAMS ((bfd *, struct internal_scnhdr *, unsigned int)); +static const bfd_target *coff_real_object_p + PARAMS ((bfd *, unsigned, struct internal_filehdr *, + struct internal_aouthdr *)); +static void fixup_symbol_value + PARAMS ((coff_symbol_type *, struct internal_syment *)); +static char *build_debug_section + PARAMS ((bfd *)); +static char *copy_name + PARAMS ((bfd *, char *, int)); #define STRING_SIZE_SIZE (4) @@ -639,9 +650,8 @@ asymbol **newsyms; unsigned int i; - newsyms = (asymbol **) bfd_alloc_by_size_t (bfd_ptr, - sizeof (asymbol *) - * (symbol_count + 1)); + newsyms = (asymbol **) bfd_alloc (bfd_ptr, + sizeof (asymbol *) * (symbol_count + 1)); if (!newsyms) return false; bfd_ptr->outsymbols = newsyms; @@ -1369,7 +1379,7 @@ combined_entry_type e[10]; }; struct foo *f; - f = (struct foo *) bfd_alloc_by_size_t (abfd, sizeof (*f)); + f = (struct foo *) bfd_alloc (abfd, sizeof (*f)); if (!f) { bfd_set_error (bfd_error_no_error); @@ -2072,6 +2082,19 @@ symbol->name); } } +} + +/* Return whether a symbol name implies a local symbol. In COFF, + local symbols generally start with ``.L''. Most targets use this + function for the is_local_label_name entry point, but some may + override it. */ + +boolean +_bfd_coff_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + return name[0] == '.' && name[1] == 'L'; } /* Provided a BFD, a section and an offset into the section, calculate diff -urN binutils-2.7/bfd/cofflink.c binutils-2.8/bfd/cofflink.c --- binutils-2.7/bfd/cofflink.c Thu Jul 4 12:18:07 1996 +++ binutils-2.8/bfd/cofflink.c Wed Apr 30 12:55:54 1997 @@ -1,5 +1,5 @@ /* COFF specific linker code. - Copyright 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -34,6 +34,10 @@ static boolean coff_link_check_ar_symbols PARAMS ((bfd *, struct bfd_link_info *, boolean *)); static boolean coff_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *)); +static char *dores_com PARAMS ((char *, bfd *, int)); +static char *get_name PARAMS ((char *, char **)); +static int process_embedded_commands + PARAMS ((bfd *, struct bfd_link_info *, bfd *)); /* Create an entry in a COFF linker hash table. */ @@ -283,6 +287,7 @@ struct bfd_link_info *info; { boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *)); + boolean keep_syms; boolean default_copy; bfd_size_type symcount; struct coff_link_hash_entry **sym_hash; @@ -290,6 +295,11 @@ bfd_byte *esym; bfd_byte *esym_end; + /* Keep the symbols during this function, in case the linker needs + to read the generic symbols in order to report an error message. */ + keep_syms = obj_coff_keep_syms (abfd); + obj_coff_keep_syms (abfd) = true; + sym_is_global = coff_backend_info (abfd)->_bfd_coff_sym_is_global; if (info->keep_memory) @@ -306,7 +316,7 @@ ((size_t) symcount * sizeof (struct coff_link_hash_entry *)))); if (sym_hash == NULL && symcount != 0) - return false; + goto error_return; obj_coff_sym_hashes (abfd) = sym_hash; memset (sym_hash, 0, (size_t) symcount * sizeof (struct coff_link_hash_entry *)); @@ -335,7 +345,7 @@ name = _bfd_coff_internal_syment_name (abfd, &sym, buf); if (name == NULL) - return false; + goto error_return; /* We must copy the name into memory if we got it from the syment itself, rather than the string table. */ @@ -370,7 +380,14 @@ (info, abfd, name, flags, section, value, (const char *) NULL, copy, false, (struct bfd_link_hash_entry **) sym_hash))) - return false; + goto error_return; + + if (section == bfd_com_section_ptr + && (*sym_hash)->root.type == bfd_link_hash_common + && ((*sym_hash)->root.u.c.p->alignment_power + > bfd_coff_default_section_alignment_power (abfd))) + (*sym_hash)->root.u.c.p->alignment_power + = bfd_coff_default_section_alignment_power (abfd); if (info->hash->creator->flavour == bfd_get_flavour (abfd)) { @@ -381,8 +398,16 @@ && (*sym_hash)->root.type != bfd_link_hash_defined)) { (*sym_hash)->class = sym.n_sclass; - (*sym_hash)->type = sym.n_type; - (*sym_hash)->numaux = sym.n_numaux; + if (sym.n_type != T_NULL) + { + if ((*sym_hash)->type != T_NULL + && (*sym_hash)->type != sym.n_type) + (*_bfd_error_handler) + ("Warning: type of symbol `%s' changed from %d to %d in %s", + name, (*sym_hash)->type, sym.n_type, + bfd_get_filename (abfd)); + (*sym_hash)->type = sym.n_type; + } (*sym_hash)->auxbfd = abfd; if (sym.n_numaux != 0) { @@ -391,12 +416,13 @@ bfd_byte *eaux; union internal_auxent *iaux; + (*sym_hash)->numaux = sym.n_numaux; alloc = ((union internal_auxent *) bfd_hash_allocate (&info->hash->table, (sym.n_numaux * sizeof (*alloc)))); if (alloc == NULL) - return false; + goto error_return; for (i = 0, eaux = esym + symesz, iaux = alloc; i < sym.n_numaux; i++, eaux += symesz, iaux++) @@ -439,7 +465,7 @@ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)); if (stab->used_by_bfd == NULL) - return false; + goto error_return; secdata = coff_section_data (abfd, stab); } @@ -448,12 +474,18 @@ if (! _bfd_link_section_stabs (abfd, &table->stab_info, stab, stabstr, &secdata->stab_info)) - return false; + goto error_return; } } } + obj_coff_keep_syms (abfd) = keep_syms; + return true; + + error_return: + obj_coff_keep_syms (abfd) = keep_syms; + return false; } /* Do the final link step. */ @@ -512,7 +544,10 @@ /* Compute the file positions for all the sections. */ if (! abfd->output_has_begun) - bfd_coff_compute_section_file_positions (abfd); + { + if (! bfd_coff_compute_section_file_positions (abfd)) + goto error_return; + } /* Count the line numbers and relocation entries required for the output file. Set the file positions for the relocs. */ @@ -817,7 +852,7 @@ finfo.outsyms = NULL; } - if (info->relocateable) + if (info->relocateable && max_output_reloc_count > 0) { /* Now that we have written out all the global symbols, we know the symbol indices to use for relocs against them, and we can @@ -1237,8 +1272,7 @@ false) == NULL)) || (! global && finfo->info->discard == discard_l - && strncmp (name, finfo->info->lprefix, - finfo->info->lprefix_len) == 0)) + && bfd_is_local_label_name (input_bfd, name))) skip = true; } @@ -1505,7 +1539,13 @@ indx = ((esym - (bfd_byte *) obj_coff_external_syms (input_bfd)) / isymesz); h = obj_coff_sym_hashes (input_bfd)[indx]; - BFD_ASSERT (h != NULL); + if (h == NULL) + { + /* This can happen if there were errors earlier in + the link. */ + bfd_set_error (bfd_error_bad_value); + return false; + } h->indx = output_index; } @@ -1554,7 +1594,12 @@ if (*indexp < 0) { h = *sym_hash; - BFD_ASSERT (h->numaux == isymp->n_numaux); + + /* The m68k-motorola-sysv assembler will sometimes + generate two symbols with the same name, but only one + will have aux entries. */ + BFD_ASSERT (isymp->n_numaux == 0 + || h->numaux == isymp->n_numaux); } esym += isymesz; @@ -2055,8 +2100,9 @@ } else { - if (! _bfd_write_section_stabs (output_bfd, o, &secdata->stab_info, - contents)) + if (! (_bfd_write_section_stabs + (output_bfd, &coff_hash_table (finfo->info)->stab_info, + o, &secdata->stab_info, contents))) return false; } } @@ -2391,6 +2437,18 @@ if (howto == NULL) return false; + /* If we are doing a relocateable link, then we can just ignore + a PC relative reloc that is pcrel_offset. It will already + have the correct value. If this is not a relocateable link, + then we should ignore the symbol value. */ + if (howto->pc_relative && howto->pcrel_offset) + { + if (info->relocateable) + continue; + if (sym != NULL && sym->n_scnum != 0) + addend += sym->n_value; + } + val = 0; if (h == NULL) @@ -2463,6 +2521,13 @@ abort (); case bfd_reloc_ok: break; + case bfd_reloc_outofrange: + (*_bfd_error_handler) + ("%s: bad reloc address 0x%lx in section `%s'", + bfd_get_filename (input_bfd), + (unsigned long) rel->r_vaddr, + bfd_get_section_name (input_bfd, input_section)); + return false; case bfd_reloc_overflow: { const char *name; diff -urN binutils-2.7/bfd/coffswap.h binutils-2.8/bfd/coffswap.h --- binutils-2.7/bfd/coffswap.h Thu Jul 4 12:18:07 1996 +++ binutils-2.8/bfd/coffswap.h Wed Apr 30 12:55:55 1997 @@ -169,6 +169,27 @@ #define PUT_SCNHDR_LNNOPTR bfd_h_put_32 #endif +static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR)); +static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR)); +static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR)); +#ifndef NO_COFF_RELOCS +static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR)); +#endif /* NO_COFF_RELOCS */ +#ifndef NO_COFF_SYMBOLS +static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR)); +static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR)); +static unsigned int coff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR)); +#endif /* NO_COFF_SYMBOLS */ +#ifndef NO_COFF_LINENOS +static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR)); +static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR)); +#endif /* NO_COFF_LINENOS */ + #ifndef NO_COFF_RELOCS static void @@ -196,7 +217,6 @@ #endif } - static unsigned int coff_swap_reloc_out (abfd, src, dst) bfd *abfd; @@ -580,7 +600,6 @@ #endif /* NO_COFF_LINENOS */ - static void coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1) bfd *abfd; @@ -791,12 +810,11 @@ memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name)); buf[sizeof (scnhdr_int->s_name)] = '\0'; - (*_bfd_error_handler) ("%s: %s: line number overflow: 0x%lx > 0xffff", - bfd_get_filename (abfd), - buf, scnhdr_int->s_nlnno); - bfd_set_error (bfd_error_file_truncated); + (*_bfd_error_handler) + ("%s: warning: %s: line number overflow: 0x%lx > 0xffff", + bfd_get_filename (abfd), + buf, scnhdr_int->s_nlnno); PUTHALF (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno); - ret = 0; } if (scnhdr_int->s_nreloc <= 0xffff) PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc); diff -urN binutils-2.7/bfd/config.bfd binutils-2.8/bfd/config.bfd --- binutils-2.7/bfd/config.bfd Thu Jul 4 12:30:46 1996 +++ binutils-2.8/bfd/config.bfd Wed Apr 30 12:55:55 1997 @@ -7,7 +7,11 @@ # targ_selvecs Vectors to build for this target # targ_archs Architectures for this target # targ_cflags $(CFLAGS) for this target (FIXME: pretty bogus) -# targ_undercore Whether underscores are used: yes or no +# targ_underscore Whether underscores are used: yes or no + +# Part of this file is processed by targmatch.sed to generate the +# targmatch.h file. The #ifdef and #endif lines that appear below are +# copied directly into targmatch.h. # The binutils c++filt program wants to know whether underscores are # stripped or not. That is why we set targ_underscore. c++filt uses @@ -22,11 +26,11 @@ targ_cflags= targ_underscore=no -targ_cpu=`echo $targ | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` +targ_cpu=`echo $targ | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` case "${targ_cpu}" in arm*) targ_archs=bfd_arm_arch ;; hppa*) targ_archs=bfd_hppa_arch ;; -i[345]86) targ_archs=bfd_i386_arch ;; +i[3456]86) targ_archs=bfd_i386_arch ;; m68*) targ_archs=bfd_m68k_arch ;; m88*) targ_archs=bfd_m88k_arch ;; mips*) targ_archs=bfd_mips_arch ;; @@ -43,6 +47,8 @@ # convention, else the table becomes a real mess to understand and maintain. case "${targ}" in +# START OF targmatch.h +#ifdef BFD64 alpha-*-netware*) targ_defvec=ecoffalpha_little_vec targ_selvecs=nlm32_alpha_vec @@ -61,6 +67,7 @@ alpha-*-*) targ_defvec=ecoffalpha_little_vec ;; +#endif /* BFD64 */ arm-*-riscix*) targ_defvec=riscix_vec @@ -95,6 +102,11 @@ targ_underscore=yes ;; + d10v-*-*) + targ_defvec=bfd_elf32_d10v_vec + ;; + + h8300*-*-*) targ_defvec=h8300coff_vec targ_underscore=yes @@ -105,15 +117,10 @@ targ_underscore=yes ;; - sh-*-*) - targ_defvec=shcoff_vec - targ_selvecs="shcoff_vec shlcoff_vec" - targ_underscore=yes - ;; - - hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-sysv4*) + hppa*-*-*elf* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*) targ_defvec=bfd_elf32_hppa_vec ;; +#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) hppa*-*-bsd*) targ_defvec=som_vec targ_selvecs=bfd_elf32_hppa_vec @@ -125,82 +132,82 @@ targ_defvec=som_vec targ_selvecs=bfd_elf32_hppa_vec ;; +#endif /* defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) */ - i[345]86-*-sysv4* | i[345]86-*-unixware | i[345]86-*-solaris2* | \ - i[345]86-*-elf | i[345]86-*-sco*elf* | i[345]86-*-freebsdelf*) + i[3456]86-*-sysv4* | i[3456]86-*-unixware | i[3456]86-*-solaris2* | \ + i[3456]86-*-elf | i[3456]86-*-sco*elf* | i[3456]86-*-freebsdelf* | \ + i[3456]86-*-dgux*) targ_defvec=bfd_elf32_i386_vec targ_selvecs=i386coff_vec ;; - i[345]86-*-sysv* | i[345]86-*-isc* | i[345]86-*-sco* | i[345]86-*-coff | \ - i[345]86-*-aix* | i[345]86-*-go32* | i[345]86*-*-rtems*) + i[3456]86-*-sysv* | i[3456]86-*-isc* | i[3456]86-*-sco* | i[3456]86-*-coff | \ + i[3456]86-*-aix* | i[3456]86-*-go32* | i[3456]86*-*-rtems*) targ_defvec=i386coff_vec ;; - i[345]86-sequent-bsd*) + i[3456]86-sequent-bsd*) targ_defvec=i386dynix_vec targ_underscore=yes ;; - i[345]86-*-bsd*) + i[3456]86-*-bsd*) targ_defvec=i386bsd_vec targ_underscore=yes ;; - i[345]86-*-freebsd*) + i[3456]86-*-freebsd*) targ_defvec=i386freebsd_vec targ_selvecs=i386bsd_vec targ_underscore=yes ;; - i[345]86-*-netbsd*) + i[3456]86-*-netbsd* | i[3456]86-*-openbsd*) targ_defvec=i386netbsd_vec targ_selvecs=i386bsd_vec targ_underscore=yes ;; - i[345]86-*-netware*) + i[3456]86-*-netware*) targ_defvec=bfd_elf32_i386_vec targ_selvecs="nlm32_i386_vec i386coff_vec i386aout_vec" ;; - i[345]86-*-linuxaout*) + i[3456]86-*-linuxaout*) targ_defvec=i386linux_vec targ_selvecs=bfd_elf32_i386_vec targ_underscore=yes ;; - i[345]86-*-linux*) + i[3456]86-*-linux*) targ_defvec=bfd_elf32_i386_vec targ_selvecs=i386linux_vec - targ_underscore=yes ;; - i[345]86-*-lynxos*) + i[3456]86-*-lynxos*) targ_defvec=i386lynx_coff_vec targ_selvecs=i386lynx_aout_vec ;; - i[345]86-*-gnu*) + i[3456]86-*-gnu*) targ_defvec=bfd_elf32_i386_vec targ_selvecs=i386mach3_vec targ_cflags=-DSTAT_FOR_EXEC - targ_underscore=yes ;; - i[345]86-*-mach* | i[345]86-*-osf1mk*) + i[3456]86-*-mach* | i[3456]86-*-osf1mk*) targ_defvec=i386mach3_vec targ_cflags=-DSTAT_FOR_EXEC targ_underscore=yes ;; - i[345]86-*-os9k) + i[3456]86-*-os9k) targ_defvec=i386os9k_vec ;; - i[345]86-*-msdos*) + i[3456]86-*-msdos*) targ_defvec=i386aout_vec targ_selvecs=i386msdos_vec ;; - i[345]86-*-moss*) + i[3456]86-*-moss*) targ_defvec=bfd_elf32_i386_vec targ_selvecs="i386msdos_vec i386aout_vec" ;; - i[345]86-*-cygwin32 | i[345]86-*-winnt | i[345]86-*-pe) + i[3456]86-*-cygwin32 | i[3456]86-*-winnt | i[3456]86-*-pe) targ_defvec=i386pe_vec targ_selvecs="i386pe_vec i386pei_vec" ;; - i[345]86-none-*) + i[3456]86-none-*) targ_defvec=i386coff_vec ;; - i[345]86-*-aout* | i[345]86*-*-vsta*) + i[3456]86-*-aout* | i[3456]86*-*-vsta*) targ_defvec=i386aout_vec ;; @@ -227,6 +234,10 @@ targ_underscore=yes ;; + m32r-*-*) + targ_defvec=bfd_elf32_m32r_vec + ;; + m68*-apollo-*) targ_defvec=apollocoff_vec ;; @@ -234,6 +245,9 @@ targ_defvec=m68kcoffun_vec targ_underscore=yes ;; + m68*-motorola-sysv*) + targ_defvec=m68ksysvcoff_vec + ;; m68*-hp-bsd*) targ_defvec=hp300bsd_vec targ_underscore=yes @@ -276,7 +290,7 @@ targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec" targ_underscore=yes ;; - m68*-*-netbsd*) + m68*-*-netbsd* | m68*-*-openbsd*) targ_defvec=m68knetbsd_vec targ_selvecs="m68k4knetbsd_vec hp300bsd_vec sunos_big_vec" targ_underscore=yes @@ -288,7 +302,7 @@ ;; m68*-ericsson-*) targ_defvec=sunos_big_vec - targ_selvecs="m68kcoff_vec tekhex_vec" + targ_selvecs="m68kcoff_vec versados_vec tekhex_vec" targ_underscore=yes ;; m68*-cbm-*) @@ -341,6 +355,10 @@ targ_defvec=ecoff_big_vec targ_selvecs=ecoff_little_vec ;; + mips*-*-irix6*) + targ_defvec=bfd_elf32_bigmips_vec + targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" + ;; mips*-*-irix5*) targ_defvec=bfd_elf32_bigmips_vec targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec" @@ -349,6 +367,10 @@ targ_defvec=ecoff_big_vec targ_selvecs=ecoff_little_vec ;; + mips*-*-lnews*) + targ_defvec=ecoff_biglittle_vec + targ_selvecs="ecoff_little_vec ecoff_big_vec" + ;; mips*-*-mach3*) targ_defvec=aout_mips_little_vec targ_cflags=-DSTAT_FOR_EXEC @@ -365,24 +387,44 @@ targ_defvec=bfd_elf32_littlemips_vec targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" ;; - mips*-*-elf*) + mips*-*-elf* | mips*-*-rtems*) targ_defvec=bfd_elf32_bigmips_vec targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" ;; + mips*-*-none) + targ_defvec=bfd_elf32_bigmips_vec + targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" + ;; + mips*el*-*-linux* | mips*el*-*-openbsd*) + targ_defvec=bfd_elf32_littlemips_vec + targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_little_vec ecoff_big_vec" + ;; + mips*-*-linux* | mips*-*-openbsd*) + targ_defvec=bfd_elf32_bigmips_vec + targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec" + ;; + + mn10200-*-*) + targ_defvec=bfd_elf32_mn10200_vec + ;; + + mn10300-*-*) + targ_defvec=bfd_elf32_mn10300_vec + ;; ns32k-pc532-mach* | ns32k-pc532-ux*) targ_defvec=pc532machaout_vec targ_underscore=yes ;; - ns32k-*-netbsd* | ns32k-*-lites*) + ns32k-*-netbsd* | ns32k-*-lites* | ns32k-*-openbsd*) targ_defvec=pc532netbsd_vec targ_underscore=yes ;; - powerpc-*-aix*) + powerpc-*-aix* | powerpc-*-beos*) targ_defvec=rs6000coff_vec ;; - powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \ + powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \ powerpc-*-solaris2* | powerpc-*-linux* | powerpc-*-rtems*) targ_defvec=bfd_elf32_powerpc_vec targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec ppcboot_vec" @@ -409,26 +451,56 @@ targ_defvec=rs6000coff_vec ;; + sh-*-elf*) + targ_defvec=bfd_elf32_sh_vec + targ_selvecs="bfd_elf32_shl_vec shcoff_vec shlcoff_vec" + targ_underscore=yes + ;; + sh-*-*) + targ_defvec=shcoff_vec + targ_selvecs="shcoff_vec shlcoff_vec" + targ_underscore=yes + ;; + + sparclet-*-aout*) + targ_defvec=sunos_big_vec + targ_selvecs=sparcle_aout_vec + targ_underscore=yes + ;; + sparc-*-linuxaout*) + targ_defvec=sparclinux_vec + targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" + targ_underscore=yes + ;; + sparc-*-linux*) + targ_defvec=bfd_elf32_sparc_vec + targ_selvecs="sparclinux_vec sunos_big_vec" + ;; sparc-*-lynxos*) targ_defvec=sparclynx_coff_vec targ_selvecs=sparclynx_aout_vec ;; - sparc-*-netbsd*) + sparc-*-netbsd* | sparc-*-openbsd*) targ_defvec=sparcnetbsd_vec targ_underscore=yes ;; - sparc-*-elf* | sparc-*-sysv4* | sparc-*-solaris2*) + sparc-*-elf* | sparc-*-solaris2*) targ_defvec=bfd_elf32_sparc_vec targ_selvecs=sunos_big_vec ;; + sparc-*-sysv4*) + targ_defvec=bfd_elf32_sparc_vec + ;; sparc64-*-aout*) targ_defvec=sunos_big_vec targ_underscore=yes ;; +#ifdef BFD64 sparc64-*-elf*) targ_defvec=bfd_elf64_sparc_vec targ_selvecs=bfd_elf32_sparc_vec ;; +#endif /* BFD64 */ sparc-*-netware*) targ_defvec=bfd_elf32_sparc_vec targ_selvecs="nlm32_sparc_vec sunos_big_vec" @@ -441,20 +513,19 @@ targ_underscore=yes ;; +#if 0 tahoe-*-*) targ_defvec=host_aout_vec targ_underscore=yes ;; +#endif - vax-*-vms*) - echo 1>&2 "*** BFD does not support target ${targ}." - echo 1>&2 "*** Look in bfd/config.bfd for supported targets." - exit 1 - ;; - vax-*-*) +#if 0 + vax-*-bsd* | vax-*-ultrix*) targ_defvec=host_aout_vec targ_underscore=yes ;; +#endif we32k-*-*) targ_defvec=we32kcoff_vec @@ -474,7 +545,7 @@ ;; *-adobe-*) - targ_defvec=a_aout_adobe_vec + targ_defvec=a_out_adobe_vec targ_underscore=yes ;; @@ -487,7 +558,7 @@ targ_defvec=m68kcoff_vec targ_selvecs=ieee_vec ;; - +# END OF targmatch.h *) echo 1>&2 "*** BFD does not support target ${targ}." echo 1>&2 "*** Look in bfd/config.bfd for supported targets." diff -urN binutils-2.7/bfd/config.h-vms binutils-2.8/bfd/config.h-vms --- binutils-2.7/bfd/config.h-vms Thu Jul 4 12:18:08 1996 +++ binutils-2.8/bfd/config.h-vms Wed Dec 31 19:00:00 1969 @@ -1,59 +0,0 @@ -/* config.h-vms. Generated by hand by Klaus Kämpf, kkaempf@didymus.rmi.de. */ -/* config.in. Generated automatically from configure.in by autoheader. */ - -/* Whether malloc must be declared even if is included. */ -/* #undef NEED_DECLARATION_MALLOC */ - -/* Whether free must be declared even if is included. */ -/* #undef NEED_DECLARATION_FREE */ - -/* Define if you have a working `mmap' system call. */ -/* #define HAVE_MMAP 1 */ - -/* Do we need to use the b modifier when opening binary files? */ -/* #undef USE_BINARY_FOPEN */ - -/* Name of host specific header file to include in trad-core.c. */ -/* #undef TRAD_HEADER */ - -/* Define only if is available *and* it defines prstatus_t. */ -/* #undef HAVE_SYS_PROCFS_H */ - -/* Do we really want to use mmap if it's available? */ -/* #undef USE_MMAP */ - -/* Define if you have the fcntl function. */ -#define HAVE_FCNTL 1 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the madvise function. */ -#define HAVE_MADVISE 1 - -/* Define if you have the mprotect function. */ -#define HAVE_MPROTECT 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 diff -urN binutils-2.7/bfd/config.in binutils-2.8/bfd/config.in --- binutils-2.7/bfd/config.in Thu Jul 4 12:18:08 1996 +++ binutils-2.8/bfd/config.in Wed Apr 30 12:55:55 1997 @@ -1,11 +1,20 @@ /* config.in. Generated automatically from configure.in by autoheader. */ +/* Whether strstr must be declared even if is included. */ +#undef NEED_DECLARATION_STRSTR + /* Whether malloc must be declared even if is included. */ #undef NEED_DECLARATION_MALLOC +/* Whether realloc must be declared even if is included. */ +#undef NEED_DECLARATION_REALLOC + /* Whether free must be declared even if is included. */ #undef NEED_DECLARATION_FREE +/* Whether getenv must be declared even if is included. */ +#undef NEED_DECLARATION_GETENV + /* Define if you have a working `mmap' system call. */ #undef HAVE_MMAP @@ -44,9 +53,6 @@ /* Define if you have the sysconf function. */ #undef HAVE_SYSCONF - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC /* Define if you have the header file. */ #undef HAVE_FCNTL_H diff -urN binutils-2.7/bfd/configure binutils-2.8/bfd/configure --- binutils-2.7/bfd/configure Thu Jul 4 12:30:42 1996 +++ binutils-2.8/bfd/configure Wed Apr 30 12:55:55 1997 @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.10 +# Generated automatically using autoconf version 2.12 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -59,6 +59,8 @@ # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 ac_prev= for ac_option @@ -340,7 +342,7 @@ verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.10" + echo "configure generated by autoconf version 2.12" exit 0 ;; -with-* | --with-*) @@ -442,11 +444,14 @@ done # NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h @@ -508,6 +513,7 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. @@ -624,6 +630,7 @@ fi echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:634: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -638,12 +645,13 @@ esac host=`$ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:655: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -655,12 +663,13 @@ esac target=`$ac_config_sub $target_alias` -target_cpu=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` -target_vendor=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` -target_os=`echo $target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:673: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -672,9 +681,9 @@ esac build=`$ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$build" 1>&6 test "$host_alias" != "$target_alias" && @@ -728,6 +737,7 @@ # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:741: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -756,6 +766,7 @@ # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:770: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -802,7 +813,47 @@ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:818: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:852: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:857: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -811,7 +862,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:815: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:866: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -819,29 +870,34 @@ fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + if test $ac_cv_prog_gcc = yes; then GCC=yes - if test "${CFLAGS+set}" != set; then - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:881: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_gcc_g=yes + ac_cv_prog_cc_g=yes else - ac_cv_prog_gcc_g=no + ac_cv_prog_cc_g=no fi rm -f conftest* fi -echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6 - if test $ac_cv_prog_gcc_g = yes; then - CFLAGS="-g -O" - else - CFLAGS="-O" - fi +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" fi else GCC= @@ -850,6 +906,7 @@ echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 +echo "configure:910: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -883,6 +940,7 @@ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:944: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -913,6 +971,7 @@ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:975: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -943,6 +1002,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1006: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -984,11 +1044,12 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1048: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in @@ -1011,7 +1072,7 @@ ;; esac done - IFS="$ac_save_ifs" + IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then @@ -1048,6 +1109,7 @@ + if test "${commonbfdlib}" = "true"; then COMMON_SHLIB=yes PICLIST=piclist @@ -1059,37 +1121,25 @@ -HOST_64BIT_LONG=0 + +VERSION=`cat ${srcdir}/VERSION` + + +BFD_HOST_64BIT_LONG=0 +BFD_HOST_64_BIT_DEFINED=0 +BFD_HOST_64_BIT= +BFD_HOST_U_64_BIT= if test "x${HOST_64BIT_TYPE}" = "xlong"; then - HOST_64BIT_LONG=1 + BFD_HOST_64BIT_LONG=1 +elif test "x${HOST_64BIT_TYPE}" != "x"; then + BFD_HOST_64_BIT_DEFINED=1 + BFD_HOST_64_BIT=${HOST_64BIT_TYPE} + BFD_HOST_U_64_BIT=${HOST_U_64BIT_TYPE} fi -# If we cannot run a trivial program, we must be cross compiling. -echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - ac_cv_c_cross=yes -else -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } -if test -s conftest && (./conftest; exit) 2>/dev/null; then - ac_cv_c_cross=no -else - ac_cv_c_cross=yes -fi -fi -rm -fr conftest* -fi -echo "$ac_t""$ac_cv_c_cross" 1>&6 -cross_compiling=$ac_cv_c_cross + # Put a plausible default for CC_FOR_BUILD in Makefile. if test -z "$CC_FOR_BUILD"; then @@ -1102,6 +1152,7 @@ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1156: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1116,33 +1167,37 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1126: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1177: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : else echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1194: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : else echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi @@ -1159,24 +1214,27 @@ for ac_hdr in stddef.h string.h strings.h stdlib.h time.h unistd.h do -ac_safe=`echo "$ac_hdr" | tr './\055' '___'` +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1220: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1174: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1230: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi @@ -1184,7 +1242,7 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'` + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 +echo "configure:1260: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1211: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1270: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi @@ -1221,7 +1282,7 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'` + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 +echo "configure:1297: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include -int main() { return 0; } -int t() { +int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:1250: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_time=no fi rm -f conftest* - fi echo "$ac_t""$ac_cv_header_time" 1>&6 @@ -1268,11 +1330,12 @@ for ac_func in fcntl getpagesize setitimer sysconf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1334: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* - fi + if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` @@ -1321,42 +1385,98 @@ case "${host}" in -i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32) +i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32 | *-*-windows) cat >> confdefs.h <<\EOF #define USE_BINARY_FOPEN 1 EOF ;; esac +echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6 +echo "configure:1397: checking whether strstr must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +int main() { +char *(*pfn) = (char *(*)) strstr +; return 0; } +EOF +if { (eval echo configure:1423: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_strstr=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_strstr=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_strstr" 1>&6 +if test $bfd_cv_decl_needed_strstr = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo strstr | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +echo "configure:1445: checking whether malloc must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_malloc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif -int main() { return 0; } -int t() { +int main() { char *(*pfn) = (char *(*)) malloc ; return 0; } EOF -if { (eval echo configure:1352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1471: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_malloc=no else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* bfd_cv_decl_needed_malloc=yes fi rm -f conftest* - fi echo "$ac_t""$bfd_cv_decl_needed_malloc" 1>&6 @@ -1368,35 +1488,91 @@ fi +echo $ac_n "checking whether realloc must be declared""... $ac_c" 1>&6 +echo "configure:1493: checking whether realloc must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_realloc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +int main() { +char *(*pfn) = (char *(*)) realloc +; return 0; } +EOF +if { (eval echo configure:1519: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_realloc=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_realloc=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_realloc" 1>&6 +if test $bfd_cv_decl_needed_realloc = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo realloc | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +echo "configure:1541: checking whether free must be declared" >&5 if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif -int main() { return 0; } -int t() { +int main() { char *(*pfn) = (char *(*)) free ; return 0; } EOF -if { (eval echo configure:1392: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_decl_needed_free=no else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* bfd_cv_decl_needed_free=yes fi rm -f conftest* - fi echo "$ac_t""$bfd_cv_decl_needed_free" 1>&6 @@ -1408,6 +1584,54 @@ fi +echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6 +echo "configure:1589: checking whether getenv must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +int main() { +char *(*pfn) = (char *(*)) getenv +; return 0; } +EOF +if { (eval echo configure:1615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_getenv=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_getenv=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_getenv" 1>&6 +if test $bfd_cv_decl_needed_getenv = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo getenv | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF #define TRAD_HEADER "hosts/symmetry.h" EOF ;; - i[345]86-sequent-sysv4*) ;; - i[345]86-sequent-sysv*) + i[3456]86-sequent-sysv4*) ;; + i[3456]86-sequent-sysv*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF #define TRAD_HEADER "hosts/symmetry.h" EOF ;; - i[345]86-*-bsd* | i[345]86-*-freebsd*) + i[3456]86-*-bsd* | i[3456]86-*-freebsd*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF #define TRAD_HEADER "hosts/i386bsd.h" EOF ;; - i[345]86-*-netbsd*) + i[3456]86-*-netbsd* | i[3456]86-*-openbsd*) COREFILE=netbsd-core.o ;; - i[345]86-esix-sysv3*) + i[3456]86-esix-sysv3*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF #define TRAD_HEADER "hosts/esix.h" EOF ;; - i[345]86-*-sco* | i[345]86-*-isc*) + i[3456]86-*-sco* | i[3456]86-*-isc*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF #define TRAD_HEADER "hosts/i386sco.h" EOF ;; - i[345]86-*-mach3*) + i[3456]86-*-mach3*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF #define TRAD_HEADER "hosts/i386mach3.h" EOF ;; - i[345]86-*-linux*) + i[3456]86-*-linux*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF #define TRAD_HEADER "hosts/i386linux.h" EOF ;; - i[345]86-*-isc*) COREFILE=trad-core.o ;; - i[345]86-*-aix*) COREFILE=aix386-core.o ;; + i[3456]86-*-isc*) COREFILE=trad-core.o ;; + i[3456]86-*-aix*) COREFILE=aix386-core.o ;; i860-*-mach3* | i860-*-osf1*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF @@ -1503,7 +1727,7 @@ EOF ;; - mips-*-netbsd*) + mips-*-netbsd* | mips*-*-openbsd*) COREFILE=netbsd-core.o ;; mips-dec-*) @@ -1515,6 +1739,7 @@ ;; mips-sgi-irix4*) COREFILE=irix-core.o ;; mips-sgi-irix5*) COREFILE=irix-core.o ;; + mips-sgi-irix6*) COREFILE=irix-core.o ;; mips-*-mach3*) COREFILE=trad-core.o cat >> confdefs.h <<\EOF @@ -1573,7 +1798,7 @@ EOF ;; - m68*-*-netbsd*) + m68*-*-netbsd* | m68*-*-openbsd*) COREFILE=netbsd-core.o ;; m68*-apple-aux*) @@ -1599,15 +1824,17 @@ EOF ;; - ns32k-*-netbsd*) + ns32k-*-netbsd* | ns32k-*-openbsd*) COREFILE=netbsd-core.o ;; rs6000-*-lynx*) COREFILE=lynx-core.o ;; rs6000-*-aix4*) COREFILE=rs6000-core.o ;; rs6000-*-*) COREFILE=rs6000-core.o ;; + powerpc-*-*bsd*) COREFILE=netbsd-core.o ;; powerpc-*-aix4*) COREFILE=rs6000-core.o ;; powerpc-*-aix*) COREFILE=rs6000-core.o ;; - sparc-*-netbsd*) + powerpc-*-beos*) ;; + sparc-*-netbsd* | sparc-*-openbsd*) COREFILE=netbsd-core.o ;; tahoe-*-*) @@ -1656,27 +1883,28 @@ # Define HAVE_SYS_PROCFS_H if the file exists and defines # prstatus_t. echo $ac_n "checking for sys/procfs.h""... $ac_c" 1>&6 +echo "configure:1887: checking for sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_header_sys_procfs_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < -int main() { return 0; } -int t() { +int main() { prstatus_t t; ; return 0; } EOF -if { (eval echo configure:1672: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1899: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_header_sys_procfs_h=yes else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* bfd_cv_header_sys_procfs_h=no fi rm -f conftest* - fi echo "$ac_t""$bfd_cv_header_sys_procfs_h" 1>&6 @@ -1697,7 +1925,7 @@ if test -n "$enable_targets" ; then for targ in `echo $enable_targets | sed 's/,/ /g'` do - result=`$ac_config_sub $targ 2>/dev/null` + result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null` if test -n "$result" ; then canon_targets="$canon_targets $result" else @@ -1787,6 +2015,7 @@ bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;; bfd_elf64_bigmips_vec) tb="$tb elf64-mips.o elf64.o elf32-mips.o elf32.o $elf ecofflink.o" target64=true ;; + bfd_elf32_d10v_vec) tb="$tb elf32-d10v.o elf32.o $elf" ;; bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o $elf" ;; bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o $elf" ;; bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o $elf" ;; @@ -1794,10 +2023,15 @@ bfd_elf32_littlemips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;; bfd_elf64_littlemips_vec) tb="$tb elf64-mips.o elf64.o elf32-mips.o elf32.o $elf ecofflink.o" target64=true ;; + bfd_elf32_m32r_vec) tb="$tb elf32-m32r.o elf32.o $elf" ;; bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o $elf" ;; bfd_elf32_m88k_vec) tb="$tb elf32-m88k.o elf32.o $elf" ;; + bfd_elf32_mn10200_vec) tb="$tb elf-m10200.o elf32.o $elf" ;; + bfd_elf32_mn10300_vec) tb="$tb elf-m10300.o elf32.o $elf" ;; bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;; bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;; + bfd_elf32_sh_vec) tb="$tb elf32-sh.o elf32.o $elf coff-sh.o" ;; + bfd_elf32_shl_vec) tb="$tb elf32-sh.o elf32.o $elf coff-sh.o" ;; bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o $elf" ;; bfd_elf64_big_generic_vec) tb="$tb elf64-gen.o elf64.o $elf" target64=true ;; @@ -1810,6 +2044,7 @@ target64=true ;; ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;; ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;; + ecoff_biglittle_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;; ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o" target64=true ;; evax_alpha_vec) tb="$tb evax-alpha.o evax-emh.o evax-egsd.o evax-etir.o evax-misc.o" @@ -1845,6 +2080,7 @@ m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;; m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;; m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;; + m68ksysvcoff_vec) tb="$tb coff-svm68k.o cofflink.o" ;; m88kbcs_vec) tb="$tb coff-m88k.o" ;; newsos3_vec) tb="$tb newsos3.o aout32.o" ;; nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;; @@ -1865,6 +2101,8 @@ shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;; shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;; som_vec) tb="$tb som.o" ;; + sparcle_aout_vec) tb="$tb aout-sparcle.o aout32.o" ;; + sparclinux_vec) tb="$tb sparclinux.o aout32.o stab-syms.o" ;; sparclynx_aout_vec) tb="$tb sparclynx.o lynx-core.o aout32.o" ;; sparclynx_coff_vec) tb="$tb cf-sparclynx.o lynx-core.o" ;; sparcnetbsd_vec) tb="$tb sparcnetbsd.o aout32.o" ;; @@ -1884,7 +2122,9 @@ done # Target architecture .o files. -ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g` +# A couple of CPUs use shorter file names to avoid problems on DOS +# filesystems. +ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g -e s/mn10200/m10200/ -e s/mn10300/m10300/` # Weed out duplicate .o files. f="" @@ -1912,9 +2152,13 @@ bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)' bfd_machines="${bfd_machines}"' $(ALL_MACHINES)' selvecs= + havevecs= selarchs= else # all_targets is true # Only set these if they will be nonempty, for the clever echo. + havevecs= + test -n "$selvecs" && + havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'` test -n "$selvecs" && selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'` test -n "$selarchs" && @@ -1925,7 +2169,7 @@ *true*) wordsize=64 all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)' - if test -z "$GCC" && test "$HOST_64BIT_LONG" = "0"; then + if test -z "$GCC" && test "$BFD_HOST_64BIT_LONG" = "0" && test "$BFD_HOST_64_BIT_DEFINED" = "0"; then echo "configure: warning: You have requested a 64 bit BFD configuration, but" 1>&2 echo "configure: warning: your compiler may not have a 64 bit integral type" 1>&2 fi @@ -1945,16 +2189,58 @@ test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}" test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'" test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'" +test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}" -for ac_func in valloc getpagesize +for ac_hdr in unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:2200: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2210: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2239: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:2267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* - fi + if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` @@ -2001,94 +2288,170 @@ done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_func_mmap'+set}'`\" = set"; then +echo "configure:2292: checking for working mmap" >&5 +if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then - ac_cv_func_mmap=no + ac_cv_func_mmap_fixed_mapped=no else -cat > conftest.$ac_ext < conftest.$ac_ext < #include #include +/* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif -# else -# ifdef NBPC -# define getpagesize() NBPC -# else -# define getpagesize() PAGESIZE /* SVR4 */ -# endif -# endif +# ifdef HAVE_UNISTD_H +# include # endif -#endif -#ifndef HAVE_VALLOC -# define valloc malloc -#endif +/* Assume that all systems that can run configure have sys/param.h. */ +# ifndef HAVE_SYS_PARAM_H +# define HAVE_SYS_PARAM_H 1 +# endif + +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# ifdef HAVE_SYS_PARAM_H +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ #ifdef __cplusplus -extern "C" { void *valloc(unsigned), *malloc(unsigned); } +extern "C" { void *malloc(unsigned); } #else -char *valloc(), *malloc(); +char *malloc(); #endif int main() { - char *buf1, *buf2, *buf3; - int i = getpagesize(), j; - int i2 = i * 2; - int fd; - - buf1 = (char *)valloc(i2); - buf2 = (char *)valloc(i); - buf3 = (char *)malloc(i2); - for (j = 0; j < i2; ++j) - *(buf1 + j) = rand(); - fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); - write(fd, buf1, i2); - mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); - for (j = 0; j < i; ++j) - if (*(buf1 + j) != *(buf2 + j)) - exit(1); - lseek(fd, (long)i, 0); - read(fd, buf2, i); /* read into mapped memory -- file should not change */ - /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */ - lseek(fd, (long)0, 0); - read(fd, buf3, i2); - for (j = 0; j < i2; ++j) - if (*(buf1 + j) != *(buf3 + j)) - exit(1); - exit(0); + char *data, *data2, *data3; + int i, pagesize; + int fd; + + pagesize = getpagesize(); + + /* + * First, make a file with some known garbage in it. + */ + data = malloc(pagesize); + if (!data) + exit(1); + for (i = 0; i < pagesize; ++i) + *(data + i) = rand(); + umask(0); + fd = creat("conftestmmap", 0600); + if (fd < 0) + exit(1); + if (write(fd, data, pagesize) != pagesize) + exit(1); + close(fd); + + /* + * Next, try to mmap the file at a fixed address which + * already has something else allocated at it. If we can, + * also make sure that we see the same garbage. + */ + fd = open("conftestmmap", O_RDWR); + if (fd < 0) + exit(1); + data2 = malloc(2 * pagesize); + if (!data2) + exit(1); + data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); + if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + exit(1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + exit(1); + + /* + * Finally, make sure that changes to the mapped area + * do not percolate back to the file as seen by read(). + * (This is a bug on some variants of i386 svr4.0.) + */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = malloc(pagesize); + if (!data3) + exit(1); + if (read(fd, data3, pagesize) != pagesize) + exit(1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + exit(1); + close(fd); + unlink("conftestmmap"); + exit(0); } EOF -{ (eval echo configure:2085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } -if test -s conftest && (./conftest; exit) 2>/dev/null; then - ac_cv_func_mmap=yes +if { (eval echo configure:2440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_func_mmap_fixed_mapped=yes else - ac_cv_func_mmap=no -fi + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_mmap_fixed_mapped=no fi rm -fr conftest* fi -echo "$ac_t""$ac_cv_func_mmap" 1>&6 -if test $ac_cv_func_mmap = yes; then +fi + +echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6 +if test $ac_cv_func_mmap_fixed_mapped = yes; then cat >> confdefs.h <<\EOF #define HAVE_MMAP 1 EOF @@ -2098,11 +2461,12 @@ for ac_func in madvise mprotect do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2465: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:2493: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* - fi + if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` @@ -2148,7 +2513,7 @@ fi done -case ${want_mmap}+${ac_cv_func_mmap} in +case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in true+yes ) cat >> confdefs.h <<\EOF #define USE_MMAP 1 EOF @@ -2173,11 +2538,25 @@ # --recheck option to rerun configure. # EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \ - >> confcache + case `(ac_space=' '; set) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache if cmp -s $cache_file confcache; then : else @@ -2232,7 +2611,7 @@ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.10" + echo "$CONFIG_STATUS generated by autoconf version 2.12" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -2243,7 +2622,7 @@ ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile doc/Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "Makefile doc/Makefile bfd-in3.h:bfd-in2.h config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac - # Adjust relative srcdir, etc. for subdirectories. + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` @@ -2357,6 +2778,7 @@ [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac + echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." @@ -2365,14 +2787,16 @@ # $configure_input" ;; *) ac_comsub= ;; esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g -" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done -rm -f conftest.subs +rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. @@ -2393,11 +2817,17 @@ ac_eC=' ' ac_eD='%g' -CONFIG_HEADERS=${CONFIG_HEADERS-"config.h:config.in"} +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac @@ -2405,7 +2835,8 @@ echo creating $ac_file rm -f conftest.frag conftest.in conftest.out - cp $ac_given_srcdir/$ac_file_in conftest.in + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in EOF @@ -2433,8 +2864,6 @@ # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. -# Maximum number of lines to put in a single here document. -ac_max_here_lines=12 rm -f conftest.tail while : @@ -2476,7 +2905,11 @@ fi fi; done +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac exit 0 EOF diff -urN binutils-2.7/bfd/configure.com binutils-2.8/bfd/configure.com --- binutils-2.7/bfd/configure.com Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/configure.com Wed Apr 30 12:55:55 1997 @@ -0,0 +1,133 @@ +$! +$! This file configures the bfd library for use with openVMS/Alpha +$! We do not use the configure script, since we do not have /bin/sh +$! to execute it. +$! +$! Written by Klaus K"ampf (kkaempf@progis.de) +$! +$arch_indx = 1 + ((f$getsyi("CPU").ge.128).and.1) ! vax==1, alpha==2 +$arch = f$element(arch_indx,"|","|VAX|Alpha|") +$if arch .eqs. "VAX" +$then +$ write sys$output "Target VAX not supported." +$ exit 2 +$endif +$! +$! copy bfd-in2.h to bfd.h, replacing @ macros +$! +$ edit/tpu/nojournal/nosection/nodisplay/command=sys$input - + []bfd-in2.h /output=[]bfd.h +$DECK +! +! Copy file, changing lines with macros (@@) +! +! + vfile := CREATE_BUFFER("vfile", "VERSION."); + POSITION(BEGINNING_OF(vfile)); + vers := CURRENT_LINE; + + file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name")); + rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file)); + + match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang); + IF match_pos <> 0 THEN; + POSITION(BEGINNING_OF(match_pos)); + ERASE(match_pos); + COPY_TEXT(vers); + ENDIF; + match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang); + IF match_pos <> 0 THEN; + POSITION(BEGINNING_OF(match_pos)); + ERASE(match_pos); + COPY_TEXT('64'); + ENDIF; + match_pos := SEARCH_QUIETLY('@BFD_HOST_64BIT_LONG@', FORWARD, EXACT, rang); + IF match_pos <> 0 THEN; + POSITION(BEGINNING_OF(match_pos)); + ERASE(match_pos); + COPY_TEXT('0'); + ENDIF; + match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT_DEFINED@', FORWARD, EXACT, rang); + IF match_pos <> 0 THEN; + POSITION(BEGINNING_OF(match_pos)); + ERASE(match_pos); + COPY_TEXT('0'); + ENDIF; + match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang); + IF match_pos <> 0 THEN; + POSITION(BEGINNING_OF(match_pos)); + ERASE(match_pos); + COPY_TEXT(''); + ENDIF; + match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang); + IF match_pos <> 0 THEN; + POSITION(BEGINNING_OF(match_pos)); + ERASE(match_pos); + COPY_TEXT(''); + ENDIF; + WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file")); + QUIT +$ EOD +$ write sys$output "Generated `bfd.h' from `bfd-in2.h'." +$! +$! +$! create targmatch.h +$! +$ open/write tfile []targmatch.h +$ write tfile "{ " + """alpha-*-*vms*""" + "," +$ write tfile "#if !defined (SELECT_VECS) || defined (HAVE_evax_alpha_vec)" +$ write tfile "&evax_alpha_vec" +$ write tfile "#else" +$ write tfile "UNSUPPORTED_TARGET" +$ write tfile "#endif" +$ write tfile "}," +$ close tfile +$ write sys$output "Generated `targmatch.h'" +$! +$! +$! create config.h +$! +$ create []config.h +/* config.h-vms. Generated by hand by Klaus Kämpf, kkaempf@didymus.rmi.de. */ +/* config.in. Generated automatically from configure.in by autoheader. */ +/* Whether malloc must be declared even if is included. */ +/* #undef NEED_DECLARATION_MALLOC */ +/* Whether free must be declared even if is included. */ +/* #undef NEED_DECLARATION_FREE */ +/* Define if you have a working `mmap' system call. */ +/* #define HAVE_MMAP 1 */ +/* Do we need to use the b modifier when opening binary files? */ +/* #undef USE_BINARY_FOPEN */ +/* Name of host specific header file to include in trad-core.c. */ +/* #undef TRAD_HEADER */ +/* Define only if is available *and* it defines prstatus_t. */ +/* #undef HAVE_SYS_PROCFS_H */ +/* Do we really want to use mmap if it's available? */ +/* #undef USE_MMAP */ +/* Define if you have the fcntl function. */ +#define HAVE_FCNTL 1 +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 +/* Define if you have the madvise function. */ +#define HAVE_MADVISE 1 +/* Define if you have the mprotect function. */ +#define HAVE_MPROTECT 1 +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 +/* Define if you have the header file. */ +#define HAVE_STDDEF_H 1 +/* Define if you have the header file. */ +#define HAVE_STDLIB_H 1 +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 +/* Define if you have the header file. */ +#define HAVE_STRINGS_H 1 +/* Define if you have the header file. */ +#define HAVE_SYS_FILE_H 1 +/* Define if you have the header file. */ +#define HAVE_TIME_H 1 +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 +$! +$ write sys$output "Generated `config.h'" + diff -urN binutils-2.7/bfd/configure.host binutils-2.8/bfd/configure.host --- binutils-2.7/bfd/configure.host Thu Jul 4 12:18:12 1996 +++ binutils-2.8/bfd/configure.host Wed Apr 30 12:55:56 1997 @@ -8,15 +8,19 @@ # This sets the following shell variables: # HDEFINES host specific compiler options -# host64 set to true if this is a 64 bit host +# host64 set to true if 64 bit types are as fast as 32 bit # HOST_64BIT_TYPE host 64 bit type +# HOST_U_64BIT_TYPE unsigned 64 bit type (not needed if 64BIT_TYPE is long) # SHLIB_CC compiler to use when building shared library # SHLIB_CFLAGS flags to use when building shared library +# SHLIB_LIBS libraries to use when building shared library # PICFLAG may be set to flag to use to compile PIC # SHLINK may be set to the name to link the shared library to # ALLLIBS may be set to libraries to build # HLDFLAGS LDFLAGS specific to the host +# HLDENV environment variable to set when linking for the host # RPATH_ENVVAR environment variable used to find shared libraries +# INSTALL_SHLIB install a shared library HDEFINES= host64=false @@ -31,33 +35,62 @@ hppa*-*-bsd*) HDEFINES=-DHOST_HPPABSD ;; hppa*-*-osf*) HDEFINES=-DHOST_HPPAOSF ;; -i[345]86-sequent-bsd*) HDEFINES=-Dshared=genshared ;; -i[345]86-sequent-sysv4*) ;; -i[345]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;; - -mips-dec-netbsd*) ;; -mips-dec-*) HDEFINES="-G 4" ;; -mips-sgi-irix3*) HDEFINES="-G 4" ;; -mips-sgi-irix4*) HDEFINES="-G 4" ;; -mips-*-sysv4*) ;; -mips-*-sysv*) HDEFINES="-G 4" ;; -mips-*-riscos*) HDEFINES="-G 4" ;; +i[3456]86-sequent-bsd*) HDEFINES=-Dshared=genshared ;; +i[3456]86-sequent-sysv4*) ;; +i[3456]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;; + +mips*-dec-netbsd*) ;; +mips*-*-openbsd*) ;; +mips*-dec-*) HDEFINES="-G 4" ;; +mips*-sgi-irix3*) HDEFINES="-G 4" ;; +mips*-sgi-irix4*) HDEFINES="-G 4" ;; +mips*-sgi-irix6*) host64=true + HOST_64BIT_TYPE="long long"; + HOST_U_64BIT_TYPE="unsigned long long"; + ;; +mips*-*-sysv4*) ;; +mips*-*-sysv*) HDEFINES="-G 4" ;; +mips*-*-riscos*) HDEFINES="-G 4" ;; m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;; +*-*-solaris*) HOST_64BIT_TYPE="long long" + HOST_U_64BIT_TYPE="unsigned long long" + ;; + +*-*-windows*) + HOST_64BIT_TYPE=__int64 + HOST_U_64BIT_TYPE="unsigned __int64" +# The following krock is necessary because we can't run the build compiler +# (MSVC) on the configure host, so we have to explicitly set the values here. +# Note that this file is never run through autoconf, so we can't use any +# autoconf macros here. Because of this, we have to muck with autoconf +# variables explicitly. + ac_cv_func_mmap_fixed_mapped=no + ac_cv_header_time=no + ac_cv_func_getpagesize=no + ac_cv_func_madvise=no + ac_cv_func_mprotect=no + ac_cv_header_sys_file_h=no + ac_cv_header_sys_time_h=no + ac_cv_header_unistd_h=no + ;; esac # If we are configuring with --enable-shared, adjust the shared # library support based on the host. This support must work for both # the BFD and the opcodes libraries. HLDFLAGS= +HLDENV= RPATH_ENVVAR=LD_LIBRARY_PATH SHLIB_CC='$(CC)' SHLIB_CFLAGS='-shared' +SHLIB_LIBS= +INSTALL_SHLIB='$(INSTALL_PROGRAM) $$f $(libdir)/$$tf;' if [ "${shared}" = "true" ]; then case "${host}" in hppa*-*-*) picfrag=${srcdir}/../config/mh-papic ;; - i[3456]86-*-*) picfrag=${srcdir}/../config/mh-x86pic ;; + i[34566]86-*-*) picfrag=${srcdir}/../config/mh-x86pic ;; *-*-*) picfrag=${srcdir}/../config/mh-${host_cpu}pic ;; esac if [ -f "${picfrag}" ]; then @@ -80,9 +113,10 @@ SHLIB_CFLAGS='-shared $(PICFLAG)' HLDFLAGS='-Wl,+s,+b,$(libdir)' RPATH_ENVVAR=SHLIB_PATH + INSTALL_SHLIB='$(INSTALL_PROGRAM) $$f $(libdir)/$$tf; chmod -w $(libdir)/$$tf;' ;; - *-*-irix5*) - # -fpic is not needed on Irix 5. + *-*-irix[56]*) + # -fpic is not needed on Irix 5 or 6. PICFLAG= SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)' HLDFLAGS='-Wl,-rpath,$(libdir)' @@ -95,10 +129,17 @@ /lib | /usr/lib) ;; *) HLDFLAGS='-Wl,-rpath,$(libdir)' ;; esac + # On Linux, apparently, linking against -lc lets ldconfig figure + # out which version of libc should be used. + SHLIB_LIBS=-lc ;; - *-*-sysv4* | *-*-solaris*) + *-*-solaris*) SHLIB_CFLAGS='-shared -h $(SONAME)' HLDFLAGS='-R $(libdir)' + ;; + *-*-sysv4*) + SHLIB_CFLAGS='-shared -h $(SONAME)' + HLDENV='if test -z "$${LD_RUN_PATH}"; then LD_RUN_PATH=$(libdir); else LD_RUN_PATH=$${LD_RUN_PATH}:$(libdir); fi; export LD_RUN_PATH;' ;; *-*-sunos*) # Build a libTARGET-bfd.so.VERSION symlink in the object directory. diff -urN binutils-2.7/bfd/configure.in binutils-2.8/bfd/configure.in --- binutils-2.7/bfd/configure.in Thu Jul 4 12:30:41 1996 +++ binutils-2.8/bfd/configure.in Wed Apr 30 12:55:56 1997 @@ -99,6 +99,7 @@ AC_SUBST(SHLIB) AC_SUBST(SHLIB_CC) AC_SUBST(SHLIB_CFLAGS) +AC_SUBST(SHLIB_LIBS) if test "${commonbfdlib}" = "true"; then COMMON_SHLIB=yes PICLIST=piclist @@ -109,12 +110,26 @@ AC_SUBST(COMMON_SHLIB) AC_SUBST(PICLIST) AC_SUBST(SHLINK) +AC_SUBST(INSTALL_SHLIB) -HOST_64BIT_LONG=0 +VERSION=`cat ${srcdir}/VERSION` +AC_SUBST(VERSION) + +BFD_HOST_64BIT_LONG=0 +BFD_HOST_64_BIT_DEFINED=0 +BFD_HOST_64_BIT= +BFD_HOST_U_64_BIT= if test "x${HOST_64BIT_TYPE}" = "xlong"; then - HOST_64BIT_LONG=1 + BFD_HOST_64BIT_LONG=1 +elif test "x${HOST_64BIT_TYPE}" != "x"; then + BFD_HOST_64_BIT_DEFINED=1 + BFD_HOST_64_BIT=${HOST_64BIT_TYPE} + BFD_HOST_U_64_BIT=${HOST_U_64BIT_TYPE} fi -AC_SUBST(HOST_64BIT_LONG) +AC_SUBST(BFD_HOST_64BIT_LONG) +AC_SUBST(BFD_HOST_64_BIT_DEFINED) +AC_SUBST(BFD_HOST_64_BIT) +AC_SUBST(BFD_HOST_U_64_BIT) BFD_CC_FOR_BUILD @@ -125,8 +140,11 @@ BFD_BINARY_FOPEN +BFD_NEED_DECLARATION(strstr) BFD_NEED_DECLARATION(malloc) +BFD_NEED_DECLARATION(realloc) BFD_NEED_DECLARATION(free) +BFD_NEED_DECLARATION(getenv) # If we are configured native, pick a core file support file. COREFILE= @@ -144,56 +162,56 @@ hppa*-*-bsd*) COREFILE="hpux-core.o hppabsd-core.o" COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;; changequote(,)dnl - i[345]86-sequent-bsd*) + i[3456]86-sequent-bsd*) changequote([,])dnl COREFILE=trad-core.o; AC_DEFINE(TRAD_HEADER,"hosts/symmetry.h") ;; changequote(,)dnl - i[345]86-sequent-sysv4*) ;; - i[345]86-sequent-sysv*) + i[3456]86-sequent-sysv4*) ;; + i[3456]86-sequent-sysv*) changequote([,])dnl COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/symmetry.h") ;; changequote(,)dnl - i[345]86-*-bsd* | i[345]86-*-freebsd*) + i[3456]86-*-bsd* | i[3456]86-*-freebsd*) changequote([,])dnl COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/i386bsd.h") ;; changequote(,)dnl - i[345]86-*-netbsd*) + i[3456]86-*-netbsd* | i[3456]86-*-openbsd*) changequote([,])dnl COREFILE=netbsd-core.o ;; changequote(,)dnl - i[345]86-esix-sysv3*) + i[3456]86-esix-sysv3*) changequote([,])dnl COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/esix.h") ;; changequote(,)dnl - i[345]86-*-sco* | i[345]86-*-isc*) + i[3456]86-*-sco* | i[3456]86-*-isc*) changequote([,])dnl COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/i386sco.h") ;; changequote(,)dnl - i[345]86-*-mach3*) + i[3456]86-*-mach3*) changequote([,])dnl COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/i386mach3.h") ;; changequote(,)dnl - i[345]86-*-linux*) + i[3456]86-*-linux*) changequote([,])dnl COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/i386linux.h") ;; changequote(,)dnl - i[345]86-*-isc*) COREFILE=trad-core.o ;; - i[345]86-*-aix*) COREFILE=aix386-core.o ;; + i[3456]86-*-isc*) COREFILE=trad-core.o ;; + i[3456]86-*-aix*) COREFILE=aix386-core.o ;; changequote([,])dnl i860-*-mach3* | i860-*-osf1*) COREFILE=trad-core.o @@ -207,7 +225,7 @@ COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/mipsmach3.h") ;; - mips-*-netbsd*) + mips-*-netbsd* | mips*-*-openbsd*) COREFILE=netbsd-core.o ;; mips-dec-*) @@ -216,6 +234,7 @@ ;; mips-sgi-irix4*) COREFILE=irix-core.o ;; mips-sgi-irix5*) COREFILE=irix-core.o ;; + mips-sgi-irix6*) COREFILE=irix-core.o ;; mips-*-mach3*) COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/mipsmach3.h") @@ -250,7 +269,7 @@ COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/news.h") ;; - m68*-*-netbsd*) + m68*-*-netbsd* | m68*-*-openbsd*) COREFILE=netbsd-core.o ;; m68*-apple-aux*) @@ -267,15 +286,17 @@ COREFILE=trad-core.o AC_DEFINE(TRAD_HEADER,"hosts/pc532mach.h") ;; - ns32k-*-netbsd*) + ns32k-*-netbsd* | ns32k-*-openbsd*) COREFILE=netbsd-core.o ;; rs6000-*-lynx*) COREFILE=lynx-core.o ;; rs6000-*-aix4*) COREFILE=rs6000-core.o ;; rs6000-*-*) COREFILE=rs6000-core.o ;; + powerpc-*-*bsd*) COREFILE=netbsd-core.o ;; powerpc-*-aix4*) COREFILE=rs6000-core.o ;; powerpc-*-aix*) COREFILE=rs6000-core.o ;; - sparc-*-netbsd*) + powerpc-*-beos*) ;; + sparc-*-netbsd* | sparc-*-openbsd*) COREFILE=netbsd-core.o ;; tahoe-*-*) @@ -331,7 +352,7 @@ if test -n "$enable_targets" ; then for targ in `echo $enable_targets | sed 's/,/ /g'` do - result=`$ac_config_sub $targ 2>/dev/null` + result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ 2>/dev/null` if test -n "$result" ; then canon_targets="$canon_targets $result" else @@ -421,6 +442,7 @@ bfd_elf32_bigmips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;; bfd_elf64_bigmips_vec) tb="$tb elf64-mips.o elf64.o elf32-mips.o elf32.o $elf ecofflink.o" target64=true ;; + bfd_elf32_d10v_vec) tb="$tb elf32-d10v.o elf32.o $elf" ;; bfd_elf32_hppa_vec) tb="$tb elf32-hppa.o elf32.o $elf" ;; bfd_elf32_i386_vec) tb="$tb elf32-i386.o elf32.o $elf" ;; bfd_elf32_i860_vec) tb="$tb elf32-i860.o elf32.o $elf" ;; @@ -428,10 +450,15 @@ bfd_elf32_littlemips_vec) tb="$tb elf32-mips.o elf32.o $elf ecofflink.o" ;; bfd_elf64_littlemips_vec) tb="$tb elf64-mips.o elf64.o elf32-mips.o elf32.o $elf ecofflink.o" target64=true ;; + bfd_elf32_m32r_vec) tb="$tb elf32-m32r.o elf32.o $elf" ;; bfd_elf32_m68k_vec) tb="$tb elf32-m68k.o elf32.o $elf" ;; bfd_elf32_m88k_vec) tb="$tb elf32-m88k.o elf32.o $elf" ;; + bfd_elf32_mn10200_vec) tb="$tb elf-m10200.o elf32.o $elf" ;; + bfd_elf32_mn10300_vec) tb="$tb elf-m10300.o elf32.o $elf" ;; bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;; bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.o elf32.o $elf" ;; + bfd_elf32_sh_vec) tb="$tb elf32-sh.o elf32.o $elf coff-sh.o" ;; + bfd_elf32_shl_vec) tb="$tb elf32-sh.o elf32.o $elf coff-sh.o" ;; bfd_elf32_sparc_vec) tb="$tb elf32-sparc.o elf32.o $elf" ;; bfd_elf64_big_generic_vec) tb="$tb elf64-gen.o elf64.o $elf" target64=true ;; @@ -444,6 +471,7 @@ target64=true ;; ecoff_big_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;; ecoff_little_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;; + ecoff_biglittle_vec) tb="$tb coff-mips.o ecoff.o ecofflink.o" ;; ecoffalpha_little_vec) tb="$tb coff-alpha.o ecoff.o ecofflink.o" target64=true ;; evax_alpha_vec) tb="$tb evax-alpha.o evax-emh.o evax-egsd.o evax-etir.o evax-misc.o" @@ -479,6 +507,7 @@ m68knetbsd_vec) tb="$tb m68knetbsd.o aout32.o" ;; m68k4knetbsd_vec) tb="$tb m68k4knetbsd.o aout32.o" ;; m68kaux_coff_vec) tb="$tb coff-aux.o coff-m68k.o cofflink.o" ;; + m68ksysvcoff_vec) tb="$tb coff-svm68k.o cofflink.o" ;; m88kbcs_vec) tb="$tb coff-m88k.o" ;; newsos3_vec) tb="$tb newsos3.o aout32.o" ;; nlm32_i386_vec) tb="$tb nlm32-i386.o nlm32.o nlm.o" ;; @@ -499,6 +528,8 @@ shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;; shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;; som_vec) tb="$tb som.o" ;; + sparcle_aout_vec) tb="$tb aout-sparcle.o aout32.o" ;; + sparclinux_vec) tb="$tb sparclinux.o aout32.o stab-syms.o" ;; sparclynx_aout_vec) tb="$tb sparclynx.o lynx-core.o aout32.o" ;; sparclynx_coff_vec) tb="$tb cf-sparclynx.o lynx-core.o" ;; sparcnetbsd_vec) tb="$tb sparcnetbsd.o aout32.o" ;; @@ -518,7 +549,9 @@ done # Target architecture .o files. -ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g` +# A couple of CPUs use shorter file names to avoid problems on DOS +# filesystems. +ta=`echo $selarchs | sed -e s/bfd_/cpu-/g -e s/_arch/.o/g -e s/mn10200/m10200/ -e s/mn10300/m10300/` # Weed out duplicate .o files. f="" @@ -546,9 +579,13 @@ bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)' bfd_machines="${bfd_machines}"' $(ALL_MACHINES)' selvecs= + havevecs= selarchs= else # all_targets is true # Only set these if they will be nonempty, for the clever echo. + havevecs= + test -n "$selvecs" && + havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'` test -n "$selvecs" && selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'` test -n "$selarchs" && @@ -559,7 +596,7 @@ *true*) wordsize=64 all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)' - if test -z "$GCC" && test "$HOST_64BIT_LONG" = "0"; then + if test -z "$GCC" && test "$BFD_HOST_64BIT_LONG" = "0" && test "$BFD_HOST_64_BIT_DEFINED" = "0"; then AC_MSG_WARN([You have requested a 64 bit BFD configuration, but]) AC_MSG_WARN([your compiler may not have a 64 bit integral type]) fi @@ -579,15 +616,16 @@ test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}" test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'" test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'" +test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}" AC_SUBST(tdefaults) dnl AC_CHECK_HEADERS(sys/mman.h) AC_FUNC_MMAP AC_CHECK_FUNCS(madvise mprotect) -case ${want_mmap}+${ac_cv_func_mmap} in +case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in true+yes ) AC_DEFINE(USE_MMAP) ;; esac rm -f doc/config.status -AC_OUTPUT(Makefile doc/Makefile, +AC_OUTPUT(Makefile doc/Makefile bfd-in3.h:bfd-in2.h, [case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac]) diff -urN binutils-2.7/bfd/cpu-d10v.c binutils-2.8/bfd/cpu-d10v.c --- binutils-2.7/bfd/cpu-d10v.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/cpu-d10v.c Wed Apr 30 12:55:56 1997 @@ -0,0 +1,40 @@ +/* BFD support for the D10V processor + Copyright 1996 Free Software Foundation, Inc. + Contributed by Martin Hunt (hunt@cygnus.com). + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_d10v_arch = +{ + 16, /* 16 bits in a word */ + 16, /* 16 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_d10v, + 0, + "d10v", + "d10v", + 4, /* section alignment power */ + true, + bfd_default_compatible, + bfd_default_scan, + 0, +}; + diff -urN binutils-2.7/bfd/cpu-h8300.c binutils-2.8/bfd/cpu-h8300.c --- binutils-2.7/bfd/cpu-h8300.c Thu Jul 4 12:30:49 1996 +++ binutils-2.8/bfd/cpu-h8300.c Wed Apr 30 12:55:56 1997 @@ -55,6 +55,10 @@ { return (info->mach == bfd_mach_h8300h); } + else if (*string == 's' || *string == 'S') + { + return (info->mach == bfd_mach_h8300s); + } else { return info->mach == bfd_mach_h8300; @@ -78,7 +82,6 @@ return in; } -#define H8300H_INFO_STRUCT bfd_h8300_arch static const bfd_arch_info_type h8300_info_struct = { 16, /* 16 bits in a word */ @@ -96,7 +99,7 @@ 0, }; -const bfd_arch_info_type H8300H_INFO_STRUCT = +static const bfd_arch_info_type h8300h_info_struct = { 32, /* 32 bits in a word */ 32, /* 32 bits in an address */ @@ -113,5 +116,19 @@ &h8300_info_struct, }; - -#undef H8300_INFO_STRUCT +const bfd_arch_info_type bfd_h8300_arch = +{ + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_h8300, + bfd_mach_h8300s, + "h8300s", /* arch_name */ + "h8300s", /* printable name */ + 1, + false, /* the default machine */ + compatible, + h8300_scan, +/* local_bfd_reloc_type_lookup, */ + &h8300h_info_struct, +}; diff -urN binutils-2.7/bfd/cpu-i386.c binutils-2.8/bfd/cpu-i386.c --- binutils-2.7/bfd/cpu-i386.c Thu Jul 4 12:18:14 1996 +++ binutils-2.8/bfd/cpu-i386.c Wed Apr 30 12:55:56 1997 @@ -1,5 +1,5 @@ /* BFD support for the Intel 386 architecture. - Copyright 1992 Free Software Foundation, Inc. + Copyright 1992, 94, 95, 1996 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -21,18 +21,34 @@ #include "sysdep.h" #include "libbfd.h" +static const bfd_arch_info_type i8086_arch = +{ + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address (well, not really) */ + 8, /* 8 bits in a byte */ + bfd_arch_i386, + bfd_mach_i386_i8086, + "i8086", + "i8086", + 3, + false, + bfd_default_compatible, + bfd_default_scan , + 0, +}; + const bfd_arch_info_type bfd_i386_arch = - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_i386, - 0, /* only 1 machine */ - "i386", - "i386", - 3, - true, /* the one and only */ - bfd_default_compatible, - bfd_default_scan , - 0, - }; +{ + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_i386, + bfd_mach_i386_i386, + "i386", + "i386", + 3, + true, + bfd_default_compatible, + bfd_default_scan , + &i8086_arch, +}; diff -urN binutils-2.7/bfd/cpu-m10200.c binutils-2.8/bfd/cpu-m10200.c --- binutils-2.7/bfd/cpu-m10200.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/cpu-m10200.c Wed Apr 30 12:55:56 1997 @@ -0,0 +1,38 @@ +/* BFD support for the Matsushita 10200 processor + Copyright 1996, 1997 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_mn10200_arch = + { + 16, /* 16 bits in a word */ + 24, /* 16 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_mn10200, + 200, + "mn10200", + "mn10200", + 2, + true, /* the one and only */ + bfd_default_compatible, + bfd_default_scan , + 0, + }; diff -urN binutils-2.7/bfd/cpu-m10300.c binutils-2.8/bfd/cpu-m10300.c --- binutils-2.7/bfd/cpu-m10300.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/cpu-m10300.c Wed Apr 30 12:55:56 1997 @@ -0,0 +1,38 @@ +/* BFD support for the Matsushita 10300 processor + Copyright 1996, 1997 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_mn10300_arch = + { + 32, /* 16 bits in a word */ + 32, /* 16 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_mn10300, + 300, + "mn10300", + "mn10300", + 2, + true, /* the one and only */ + bfd_default_compatible, + bfd_default_scan , + 0, + }; diff -urN binutils-2.7/bfd/cpu-m32r.c binutils-2.8/bfd/cpu-m32r.c --- binutils-2.7/bfd/cpu-m32r.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/cpu-m32r.c Wed Apr 30 12:55:57 1997 @@ -0,0 +1,38 @@ +/* BFD support for the M32R processor. + Copyright (C) 1996 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_m32r_arch = +{ + 32, /* bits in a word */ + 32, /* bits in an address */ + 8, /* bits in a byte */ + bfd_arch_m32r, + 0, + "m32r", + "m32r", + 4, /* section alignment power */ + true, /* the default */ + bfd_default_compatible, + bfd_default_scan, + 0 +}; diff -urN binutils-2.7/bfd/cpu-m68k.c binutils-2.8/bfd/cpu-m68k.c --- binutils-2.7/bfd/cpu-m68k.c Thu Jul 4 12:18:14 1996 +++ binutils-2.8/bfd/cpu-m68k.c Wed Apr 30 12:55:57 1997 @@ -1,5 +1,5 @@ /* BFD library support routines for architectures. - Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -21,9 +21,6 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" - -int bfd_default_scan_num_mach(); - #define N(name, print,d,next) \ { 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_default_compatible,bfd_default_scan, next, } diff -urN binutils-2.7/bfd/cpu-mips.c binutils-2.8/bfd/cpu-mips.c --- binutils-2.7/bfd/cpu-mips.c Thu Jul 4 12:18:14 1996 +++ binutils-2.8/bfd/cpu-mips.c Wed Apr 30 12:55:57 1997 @@ -1,5 +1,5 @@ /* bfd back-end for mips support - Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -29,6 +29,20 @@ 32, /* 32 bits in an address */ 8, /* 8 bits in a byte */ bfd_arch_mips, + 3000, + "mips", + "mips:3000", + 3, + false, + bfd_default_compatible, + bfd_default_scan, + &arch_info_struct[1], + }, + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_mips, 6000, "mips", "mips:6000", @@ -36,7 +50,7 @@ false, bfd_default_compatible, bfd_default_scan, - &arch_info_struct[1], + &arch_info_struct[2], }, { 64, /* 64 bits in a word */ @@ -50,7 +64,7 @@ false, bfd_default_compatible, bfd_default_scan , - &arch_info_struct[2], + &arch_info_struct[3], }, { 64, /* 64 bits in a word */ @@ -64,19 +78,37 @@ false, bfd_default_compatible, bfd_default_scan , + &arch_info_struct[4], + }, + { + 64, /* 64 bits in a word */ + 64, /* 64 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_mips, + 16, + "mips", + "mips:16", + 3, + false, + bfd_default_compatible, + bfd_default_scan , 0, } }; +/* The default architecture is mips:3000, but with a machine number of + zero. This lets the linker distinguish between a default setting + of mips, and an explicit setting of mips:3000. */ + const bfd_arch_info_type bfd_mips_arch = { 32, /* 32 bits in a word */ 32, /* 32 bits in an address */ 8, /* 8 bits in a byte */ bfd_arch_mips, - 3000, + 0, + "mips", "mips", - "mips:3000", 3, true, bfd_default_compatible, diff -urN binutils-2.7/bfd/cpu-sparc.c binutils-2.8/bfd/cpu-sparc.c --- binutils-2.7/bfd/cpu-sparc.c Thu Jul 4 12:18:15 1996 +++ binutils-2.8/bfd/cpu-sparc.c Wed Apr 30 12:55:57 1997 @@ -1,5 +1,5 @@ /* BFD support for the SPARC architecture. - Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 1997 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -22,6 +22,9 @@ #include "libbfd.h" /* Don't mix 32 bit and 64 bit files. */ + +static const bfd_arch_info_type *sparc_compatible + PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *)); static const bfd_arch_info_type * sparc_compatible (a, b) diff -urN binutils-2.7/bfd/dep-in.sed binutils-2.8/bfd/dep-in.sed --- binutils-2.7/bfd/dep-in.sed Thu Jul 4 12:18:15 1996 +++ binutils-2.8/bfd/dep-in.sed Wed Apr 30 12:55:59 1997 @@ -1,17 +1,18 @@ :loop /\\$/N -/\\$/b loop +s/\\\n */ /g +t loop s! @BFD_H@!!g s!@INCDIR@!$(INCDIR)!g s!@SRCDIR@/!!g s!hosts/[^ ]*\.h ! !g s/ sysdep.h//g +s! \.\./bfd/sysdep.h!!g s/ libbfd.h//g s/ config.h//g s! \$(INCDIR)/fopen-[^ ]*\.h!!g s! \$(INCDIR)/ansidecl\.h!!g -s! \$(INCDIR)/obstack\.h!!g s/\\\n */ /g diff -urN binutils-2.7/bfd/doc/ChangeLog binutils-2.8/bfd/doc/ChangeLog --- binutils-2.7/bfd/doc/ChangeLog Thu Jul 4 12:20:15 1996 +++ binutils-2.8/bfd/doc/ChangeLog Wed Apr 30 12:56:24 1997 @@ -1,3 +1,20 @@ +Tue Apr 8 12:49:46 1997 Ian Lance Taylor + + * Makefile.in (install-info): Permit info files to be in srcdir. + (stamp-*): Add a stamp-X target for each X.texi target. + (*.texi): Just depend upon stamp-X. + (clean): Remove stamp-*. + (distclean): Depend upon mostlyclean. Remove stamp-*. Don't + remove $(DOCFILES). + +Mon Apr 7 15:23:26 1997 Ian Lance Taylor + + * Makefile.in (distclean): Don't remove *.info files. + +Thu Feb 13 20:50:02 1997 Klaus Kaempf (kkaempf@progis.de) + + * makefile.vms: New file. + Tue Jun 18 18:32:28 1996 Ian Lance Taylor * chew.c (kill_bogus_lines): Reset sl when not at the start of a diff -urN binutils-2.7/bfd/doc/Makefile.in binutils-2.8/bfd/doc/Makefile.in --- binutils-2.7/bfd/doc/Makefile.in Thu Jul 4 12:20:15 1996 +++ binutils-2.8/bfd/doc/Makefile.in Wed Apr 30 12:56:24 1997 @@ -109,8 +109,13 @@ dvi: bfd.dvi install-info: info - for i in *.info* ; do \ - $(INSTALL_DATA) $$i $(infodir)/$$i ; \ + if [ -r bfd.info ]; then \ + dir=.; \ + else \ + dir=$(srcdir); \ + fi; \ + for i in `cd $$dir; echo *.info*`; do \ + $(INSTALL_DATA) $$dir/$$i $(infodir)/$$i; \ done docs: $(MKDOC) protos bfd.info bfd.dvi bfd.ps @@ -127,62 +132,126 @@ # We can't replace these rules with an implicit rule, because # makes without VPATH support couldn't find the .h files in `..'. -aoutx.texi: $(MKDOC) $(srcdir)/../aoutx.h $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../aoutx.h >aoutx.texi - -archive.texi: $(MKDOC) $(srcdir)/../archive.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../archive.c >archive.texi - -archures.texi: $(MKDOC) $(srcdir)/../archures.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../archures.c >archures.texi - -bfd.texi: $(MKDOC) $(srcdir)/../bfd.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../bfd.c >bfd.texi - -cache.texi: $(MKDOC) $(srcdir)/../cache.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../cache.c >cache.texi - -coffcode.texi: $(MKDOC) $(srcdir)/../coffcode.h $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../coffcode.h >coffcode.texi - -core.texi: $(MKDOC) $(srcdir)/../corefile.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../corefile.c >core.texi - -elf.texi: $(MKDOC) $(srcdir)/../elf.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elf.c >elf.texi - -elfcode.texi: $(MKDOC) $(srcdir)/../elfcode.h $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elfcode.h >elfcode.texi - -format.texi: $(MKDOC) $(srcdir)/../format.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../format.c >format.texi - -libbfd.texi: $(MKDOC) $(srcdir)/../libbfd.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../libbfd.c >libbfd.texi - -opncls.texi: $(MKDOC) $(srcdir)/../opncls.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../opncls.c >opncls.texi - -reloc.texi : $(MKDOC) $(srcdir)/../reloc.c - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../reloc.c >reloc.texi - -section.texi: $(MKDOC) $(srcdir)/../section.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../section.c >section.texi - -syms.texi : $(MKDOC) $(srcdir)/../syms.c - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../syms.c >syms.texi - -targets.texi: $(MKDOC) $(srcdir)/../targets.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../targets.c >targets.texi - -init.texi: $(MKDOC) $(srcdir)/../init.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../init.c >init.texi - -hash.texi: $(MKDOC) $(srcdir)/../hash.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../hash.c >hash.texi - -linker.texi: $(MKDOC) $(srcdir)/../linker.c $(srcdir)/doc.str - $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../linker.c >linker.texi +# We use stamp-XXX targets so that we can distribute the info files, +# and permit people to rebuild them, without requiring the makeinfo +# program. If somebody tries to rebuild info, but none of the .texi +# files have changed, then this Makefile will build chew, and will +# build all of the stamp files, but will not actually have to rebuild +# bfd.info. + +stamp-aoutx: $(MKDOC) $(srcdir)/../aoutx.h $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../aoutx.h >aoutx.tmp + $(srcdir)/../../move-if-change aoutx.tmp aoutx.texi + touch stamp-aoutx +aoutx.texi: stamp-aoutx + +stamp-archive: $(MKDOC) $(srcdir)/../archive.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../archive.c >archive.tmp + $(srcdir)/../../move-if-change archive.tmp archive.texi + touch stamp-archive +archive.texi: stamp-archive + +stamp-archures: $(MKDOC) $(srcdir)/../archures.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../archures.c >archures.tmp + $(srcdir)/../../move-if-change archures.tmp archures.texi + touch stamp-archures +archures.texi: stamp-archures + +stamp-bfd: $(MKDOC) $(srcdir)/../bfd.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../bfd.c >bfd.tmp + $(srcdir)/../../move-if-change bfd.tmp bfd.texi + touch stamp-bfd +bfd.texi: stamp-bfd + +stamp-cache: $(MKDOC) $(srcdir)/../cache.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../cache.c >cache.tmp + $(srcdir)/../../move-if-change cache.tmp cache.texi + touch stamp-cache +cache.texi: stamp-cache + +stamp-coffcode: $(MKDOC) $(srcdir)/../coffcode.h $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../coffcode.h >coffcode.tmp + $(srcdir)/../../move-if-change coffcode.tmp coffcode.texi + touch stamp-coffcode +coffcode.texi: stamp-coffcode + +stamp-core: $(MKDOC) $(srcdir)/../corefile.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../corefile.c >core.tmp + $(srcdir)/../../move-if-change core.tmp core.texi + touch stamp-core +core.texi: stamp-core + +stamp-elf: $(MKDOC) $(srcdir)/../elf.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elf.c >elf.tmp + $(srcdir)/../../move-if-change elf.tmp elf.texi + touch stamp-elf +elf.texi: stamp-elf + +stamp-elfcode: $(MKDOC) $(srcdir)/../elfcode.h $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../elfcode.h >elfcode.tmp + $(srcdir)/../../move-if-change elfcode.tmp elfcode.texi + touch stamp-elfcode +elfcode.texi: stamp-elfcode + +stamp-format: $(MKDOC) $(srcdir)/../format.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../format.c >format.tmp + $(srcdir)/../../move-if-change format.tmp format.texi + touch stamp-format +format.texi: stamp-format + +stamp-libbfd: $(MKDOC) $(srcdir)/../libbfd.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str < $(srcdir)/../libbfd.c >libbfd.tmp + $(srcdir)/../../move-if-change libbfd.tmp libbfd.texi + touch stamp-libbfd +libbfd.texi: stamp-libbfd + +stamp-opncls: $(MKDOC) $(srcdir)/../opncls.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../opncls.c >opncls.tmp + $(srcdir)/../../move-if-change opncls.tmp opncls.texi + touch stamp-opncls +opncls.texi: stamp-opncls + +stamp-reloc: $(MKDOC) $(srcdir)/../reloc.c + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../reloc.c >reloc.tmp + $(srcdir)/../../move-if-change reloc.tmp reloc.texi + touch stamp-reloc +reloc.texi: stamp-reloc + +stamp-section: $(MKDOC) $(srcdir)/../section.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../section.c >section.tmp + $(srcdir)/../../move-if-change section.tmp section.texi + touch stamp-section +section.texi: stamp-section + +stamp-syms: $(MKDOC) $(srcdir)/../syms.c + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../syms.c >syms.tmp + $(srcdir)/../../move-if-change syms.tmp syms.texi + touch stamp-syms +syms.texi: stamp-syms + +stamp-targets: $(MKDOC) $(srcdir)/../targets.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../targets.c >targets.tmp + $(srcdir)/../../move-if-change targets.tmp targets.texi + touch stamp-targets +targets.texi: stamp-targets + +stamp-init: $(MKDOC) $(srcdir)/../init.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../init.c >init.tmp + $(srcdir)/../../move-if-change init.tmp init.texi + touch stamp-init +init.texi: stamp-init + +stamp-hash: $(MKDOC) $(srcdir)/../hash.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../hash.c >hash.tmp + $(srcdir)/../../move-if-change hash.tmp hash.texi + touch stamp-hash +hash.texi: stamp-hash + +stamp-linker: $(MKDOC) $(srcdir)/../linker.c $(srcdir)/doc.str + $(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../linker.c >linker.tmp + $(srcdir)/../../move-if-change linker.tmp linker.texi + touch stamp-linker +linker.texi: stamp-linker libbfd.h: $(srcdir)/../libbfd-in.h \ $(srcdir)/../init.c \ @@ -253,10 +322,12 @@ rm -rf *.log *.ps *~* *.dvi *# $(MKDOC) *.o clean: mostlyclean - rm -rf $(STAGESTUFF) + rm -rf $(STAGESTUFF) stamp-* rm -f *.p *.ip bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log -distclean: clean +distclean: mostlyclean + rm -f *.p *.ip bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log + rm -f stamp-* rm -f Makefile config.status maintainer-clean realclean: clean diff -urN binutils-2.7/bfd/doc/aoutx.texi binutils-2.8/bfd/doc/aoutx.texi --- binutils-2.7/bfd/doc/aoutx.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/aoutx.texi Wed Apr 30 12:56:24 1997 @@ -0,0 +1,211 @@ +@section a.out backends + +@* +@strong{Description}@* +BFD supports a number of different flavours of a.out format, +though the major differences are only the sizes of the +structures on disk, and the shape of the relocation +information. + +The support is split into a basic support file @file{aoutx.h} +and other files which derive functions from the base. One +derivation file is @file{aoutf1.h} (for a.out flavour 1), and +adds to the basic a.out functions support for sun3, sun4, 386 +and 29k a.out files, to create a target jump vector for a +specific target. + +This information is further split out into more specific files +for each machine, including @file{sunos.c} for sun3 and sun4, +@file{newsos3.c} for the Sony NEWS, and @file{demo64.c} for a +demonstration of a 64 bit a.out format. + +The base file @file{aoutx.h} defines general mechanisms for +reading and writing records to and from disk and various +other methods which BFD requires. It is included by +@file{aout32.c} and @file{aout64.c} to form the names +@code{aout_32_swap_exec_header_in}, @code{aout_64_swap_exec_header_in}, etc. + +As an example, this is what goes on to make the back end for a +sun4, from @file{aout32.c}: + +@example + #define ARCH_SIZE 32 + #include "aoutx.h" +@end example + +Which exports names: + +@example + ... + aout_32_canonicalize_reloc + aout_32_find_nearest_line + aout_32_get_lineno + aout_32_get_reloc_upper_bound + ... +@end example + +from @file{sunos.c}: + +@example + #define TARGET_NAME "a.out-sunos-big" + #define VECNAME sunos_big_vec + #include "aoutf1.h" +@end example + +requires all the names from @file{aout32.c}, and produces the jump vector + +@example + sunos_big_vec +@end example + +The file @file{host-aout.c} is a special case. It is for a large set +of hosts that use ``more or less standard'' a.out files, and +for which cross-debugging is not interesting. It uses the +standard 32-bit a.out support routines, but determines the +file offsets and addresses of the text, data, and BSS +sections, the machine architecture and machine type, and the +entry point address, in a host-dependent manner. Once these +values have been determined, generic code is used to handle +the object file. + +When porting it to run on a new system, you must supply: + +@example + HOST_PAGE_SIZE + HOST_SEGMENT_SIZE + HOST_MACHINE_ARCH (optional) + HOST_MACHINE_MACHINE (optional) + HOST_TEXT_START_ADDR + HOST_STACK_END_ADDR +@end example + +in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These +values, plus the structures and macros defined in @file{a.out.h} on +your host system, will produce a BFD target that will access +ordinary a.out files on your host. To configure a new machine +to use @file{host-aout.c}, specify: + +@example + TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec + TDEPFILES= host-aout.o trad-core.o +@end example + +in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in} +to use the +@file{@var{XXX}.mt} file (by setting "@code{bfd_target=XXX}") when your +configuration is selected. +@* +@subsection Relocations + +@* +@strong{Description}@* +The file @file{aoutx.h} provides for both the @emph{standard} +and @emph{extended} forms of a.out relocation records. + +The standard records contain only an +address, a symbol index, and a type field. The extended records +(used on 29ks and sparcs) also have a full integer for an +addend. +@* +@subsection Internal entry points + +@* +@strong{Description}@* +@file{aoutx.h} exports several routines for accessing the +contents of an a.out file, which are gathered and exported in +turn by various format specific files (eg sunos.c). +@* +@findex aout_@var{size}_swap_exec_header_in +@subsubsection @code{aout_@var{size}_swap_exec_header_in} +@strong{Synopsis} +@example +void aout_@var{size}_swap_exec_header_in, + (bfd *abfd, + struct external_exec *raw_bytes, + struct internal_exec *execp); +@end example +@strong{Description}@* +Swap the information in an executable header @var{raw_bytes} taken +from a raw byte stream memory image into the internal exec header +structure @var{execp}. +@* +@findex aout_@var{size}_swap_exec_header_out +@subsubsection @code{aout_@var{size}_swap_exec_header_out} +@strong{Synopsis} +@example +void aout_@var{size}_swap_exec_header_out + (bfd *abfd, + struct internal_exec *execp, + struct external_exec *raw_bytes); +@end example +@strong{Description}@* +Swap the information in an internal exec header structure +@var{execp} into the buffer @var{raw_bytes} ready for writing to disk. +@* +@findex aout_@var{size}_some_aout_object_p +@subsubsection @code{aout_@var{size}_some_aout_object_p} +@strong{Synopsis} +@example +const bfd_target *aout_@var{size}_some_aout_object_p + (bfd *abfd, + const bfd_target *(*callback_to_real_object_p)()); +@end example +@strong{Description}@* +Some a.out variant thinks that the file open in @var{abfd} +checking is an a.out file. Do some more checking, and set up +for access if it really is. Call back to the calling +environment's "finish up" function just before returning, to +handle any last-minute setup. +@* +@findex aout_@var{size}_mkobject +@subsubsection @code{aout_@var{size}_mkobject} +@strong{Synopsis} +@example +boolean aout_@var{size}_mkobject, (bfd *abfd); +@end example +@strong{Description}@* +Initialize BFD @var{abfd} for use with a.out files. +@* +@findex aout_@var{size}_machine_type +@subsubsection @code{aout_@var{size}_machine_type} +@strong{Synopsis} +@example +enum machine_type aout_@var{size}_machine_type + (enum bfd_architecture arch, + unsigned long machine)); + @end example +@strong{Description}@* +Keep track of machine architecture and machine type for +a.out's. Return the @code{machine_type} for a particular +architecture and machine, or @code{M_UNKNOWN} if that exact architecture +and machine can't be represented in a.out format. + +If the architecture is understood, machine type 0 (default) +is always understood. +@* +@findex aout_@var{size}_set_arch_mach +@subsubsection @code{aout_@var{size}_set_arch_mach} +@strong{Synopsis} +@example +boolean aout_@var{size}_set_arch_mach, + (bfd *, + enum bfd_architecture arch, + unsigned long machine)); + @end example +@strong{Description}@* +Set the architecture and the machine of the BFD @var{abfd} to the +values @var{arch} and @var{machine}. Verify that @var{abfd}'s format +can support the architecture required. +@* +@findex aout_@var{size}_new_section_hook +@subsubsection @code{aout_@var{size}_new_section_hook} +@strong{Synopsis} +@example +boolean aout_@var{size}_new_section_hook, + (bfd *abfd, + asection *newsect)); + @end example +@strong{Description}@* +Called by the BFD in response to a @code{bfd_make_section} +request. +@* diff -urN binutils-2.7/bfd/doc/archive.texi binutils-2.8/bfd/doc/archive.texi --- binutils-2.7/bfd/doc/archive.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/archive.texi Wed Apr 30 12:56:24 1997 @@ -0,0 +1,95 @@ +@section Archives + +@* +@strong{Description}@* +An archive (or library) is just another BFD. It has a symbol +table, although there's not much a user program will do with it. + +The big difference between an archive BFD and an ordinary BFD +is that the archive doesn't have sections. Instead it has a +chain of BFDs that are considered its contents. These BFDs can +be manipulated like any other. The BFDs contained in an +archive opened for reading will all be opened for reading. You +may put either input or output BFDs into an archive opened for +output; they will be handled correctly when the archive is closed. + +Use @code{bfd_openr_next_archived_file} to step through +the contents of an archive opened for input. You don't +have to read the entire archive if you don't want +to! Read it until you find what you want. + +Archive contents of output BFDs are chained through the +@code{next} pointer in a BFD. The first one is findable through +the @code{archive_head} slot of the archive. Set it with +@code{bfd_set_archive_head} (q.v.). A given BFD may be in only one +open output archive at a time. + +As expected, the BFD archive code is more general than the +archive code of any given environment. BFD archives may +contain files of different formats (e.g., a.out and coff) and +even different architectures. You may even place archives +recursively into archives! + +This can cause unexpected confusion, since some archive +formats are more expressive than others. For instance, Intel +COFF archives can preserve long filenames; SunOS a.out archives +cannot. If you move a file from the first to the second +format and back again, the filename may be truncated. +Likewise, different a.out environments have different +conventions as to how they truncate filenames, whether they +preserve directory names in filenames, etc. When +interoperating with native tools, be sure your files are +homogeneous. + +Beware: most of these formats do not react well to the +presence of spaces in filenames. We do the best we can, but +can't always handle this case due to restrictions in the format of +archives. Many Unix utilities are braindead in regards to +spaces and such in filenames anyway, so this shouldn't be much +of a restriction. + +Archives are supported in BFD in @code{archive.c}. +@* +@findex bfd_get_next_mapent +@subsubsection @code{bfd_get_next_mapent} +@strong{Synopsis} +@example +symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym); +@end example +@strong{Description}@* +Step through archive @var{abfd}'s symbol table (if it +has one). Successively update @var{sym} with the next symbol's +information, returning that symbol's (internal) index into the +symbol table. + +Supply @code{BFD_NO_MORE_SYMBOLS} as the @var{previous} entry to get +the first one; returns @code{BFD_NO_MORE_SYMBOLS} when you've already +got the last one. + +A @code{carsym} is a canonical archive symbol. The only +user-visible element is its name, a null-terminated string. +@* +@findex bfd_set_archive_head +@subsubsection @code{bfd_set_archive_head} +@strong{Synopsis} +@example +boolean bfd_set_archive_head(bfd *output, bfd *new_head); +@end example +@strong{Description}@* +Set the head of the chain of +BFDs contained in the archive @var{output} to @var{new_head}. +@* +@findex bfd_openr_next_archived_file +@subsubsection @code{bfd_openr_next_archived_file} +@strong{Synopsis} +@example +bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous); +@end example +@strong{Description}@* +Provided a BFD, @var{archive}, containing an archive and NULL, open +an input BFD on the first contained element and returns that. +Subsequent calls should pass +the archive and the previous return value to return a created +BFD to the next contained element. NULL is returned when there +are no more. +@* diff -urN binutils-2.7/bfd/doc/archures.texi binutils-2.8/bfd/doc/archures.texi --- binutils-2.7/bfd/doc/archures.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/archures.texi Wed Apr 30 12:56:25 1997 @@ -0,0 +1,307 @@ +@section Architectures +BFD keeps one atom in a BFD describing the +architecture of the data attached to the BFD: a pointer to a +@code{bfd_arch_info_type}. + +Pointers to structures can be requested independently of a BFD +so that an architecture's information can be interrogated +without access to an open BFD. + +The architecture information is provided by each architecture package. +The set of default architectures is selected by the macro +@code{SELECT_ARCHITECTURES}. This is normally set up in the +@file{config/@var{target}.mt} file of your choice. If the name is not +defined, then all the architectures supported are included. + +When BFD starts up, all the architectures are called with an +initialize method. It is up to the architecture back end to +insert as many items into the list of architectures as it wants to; +generally this would be one for each machine and one for the +default case (an item with a machine field of 0). + +BFD's idea of an architecture is implemented in @file{archures.c}. +@* +@subsection bfd_architecture + +@* +@strong{Description}@* +This enum gives the object file's CPU architecture, in a +global sense---i.e., what processor family does it belong to? +Another field indicates which processor within +the family is in use. The machine gives a number which +distinguishes different versions of the architecture, +containing, for example, 2 and 3 for Intel i960 KA and i960 KB, +and 68020 and 68030 for Motorola 68020 and 68030. +@example +enum bfd_architecture +@{ + bfd_arch_unknown, /* File arch not known */ + bfd_arch_obscure, /* Arch known, not one of these */ + bfd_arch_m68k, /* Motorola 68xxx */ + bfd_arch_vax, /* DEC Vax */ + bfd_arch_i960, /* Intel 960 */ + /* The order of the following is important. + lower number indicates a machine type that + only accepts a subset of the instructions + available to machines with higher numbers. + The exception is the "ca", which is + incompatible with all other machines except + "core". */ + +#define bfd_mach_i960_core 1 +#define bfd_mach_i960_ka_sa 2 +#define bfd_mach_i960_kb_sb 3 +#define bfd_mach_i960_mc 4 +#define bfd_mach_i960_xa 5 +#define bfd_mach_i960_ca 6 +#define bfd_mach_i960_jx 7 +#define bfd_mach_i960_hx 8 + + bfd_arch_a29k, /* AMD 29000 */ + bfd_arch_sparc, /* SPARC */ +#define bfd_mach_sparc 1 + /* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ +#define bfd_mach_sparc_sparclet 2 +#define bfd_mach_sparc_sparclite 3 +#define bfd_mach_sparc_v8plus 4 +#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns */ +#define bfd_mach_sparc_v9 6 +#define bfd_mach_sparc_v9a 7 /* with ultrasparc add'ns */ + /* Nonzero if MACH has the v9 instruction set. */ +#define bfd_mach_sparc_v9_p(mach) \ + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a) + bfd_arch_mips, /* MIPS Rxxxx */ + bfd_arch_i386, /* Intel 386 */ +#define bfd_mach_i386_i386 0 +#define bfd_mach_i386_i8086 1 + bfd_arch_we32k, /* AT&T WE32xxx */ + bfd_arch_tahoe, /* CCI/Harris Tahoe */ + bfd_arch_i860, /* Intel 860 */ + bfd_arch_romp, /* IBM ROMP PC/RT */ + bfd_arch_alliant, /* Alliant */ + bfd_arch_convex, /* Convex */ + bfd_arch_m88k, /* Motorola 88xxx */ + bfd_arch_pyramid, /* Pyramid Technology */ + bfd_arch_h8300, /* Hitachi H8/300 */ +#define bfd_mach_h8300 1 +#define bfd_mach_h8300h 2 +#define bfd_mach_h8300s 3 + bfd_arch_powerpc, /* PowerPC */ + bfd_arch_rs6000, /* IBM RS/6000 */ + bfd_arch_hppa, /* HP PA RISC */ + bfd_arch_d10v, /* Mitsubishi D10V */ + bfd_arch_z8k, /* Zilog Z8000 */ +#define bfd_mach_z8001 1 +#define bfd_mach_z8002 2 + bfd_arch_h8500, /* Hitachi H8/500 */ + bfd_arch_sh, /* Hitachi SH */ + bfd_arch_alpha, /* Dec Alpha */ + bfd_arch_arm, /* Advanced Risc Machines ARM */ + bfd_arch_ns32k, /* National Semiconductors ns32000 */ + bfd_arch_w65, /* WDC 65816 */ + bfd_arch_m32r, /* Mitsubishi M32R/D */ + bfd_arch_mn10200, /* Matsushita MN10200 */ + bfd_arch_mn10300, /* Matsushita MN10300 */ + bfd_arch_last + @}; +@end example +@* +@subsection bfd_arch_info + +@* +@strong{Description}@* +This structure contains information on architectures for use +within BFD. +@example + +typedef struct bfd_arch_info +@{ + int bits_per_word; + int bits_per_address; + int bits_per_byte; + enum bfd_architecture arch; + unsigned long mach; + const char *arch_name; + const char *printable_name; + unsigned int section_align_power; + /* true if this is the default machine for the architecture */ + boolean the_default; + const struct bfd_arch_info * (*compatible) + PARAMS ((const struct bfd_arch_info *a, + const struct bfd_arch_info *b)); + + boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *)); + + const struct bfd_arch_info *next; +@} bfd_arch_info_type; +@end example +@* +@findex bfd_printable_name +@subsubsection @code{bfd_printable_name} +@strong{Synopsis} +@example +const char *bfd_printable_name(bfd *abfd); +@end example +@strong{Description}@* +Return a printable string representing the architecture and machine +from the pointer to the architecture info structure. +@* +@findex bfd_scan_arch +@subsubsection @code{bfd_scan_arch} +@strong{Synopsis} +@example +const bfd_arch_info_type *bfd_scan_arch(const char *string); +@end example +@strong{Description}@* +Figure out if BFD supports any cpu which could be described with +the name @var{string}. Return a pointer to an @code{arch_info} +structure if a machine is found, otherwise NULL. +@* +@findex bfd_arch_get_compatible +@subsubsection @code{bfd_arch_get_compatible} +@strong{Synopsis} +@example +const bfd_arch_info_type *bfd_arch_get_compatible( + const bfd *abfd, + const bfd *bbfd); +@end example +@strong{Description}@* +Determine whether two BFDs' +architectures and machine types are compatible. Calculates +the lowest common denominator between the two architectures +and machine types implied by the BFDs and returns a pointer to +an @code{arch_info} structure describing the compatible machine. +@* +@findex bfd_default_arch_struct +@subsubsection @code{bfd_default_arch_struct} +@strong{Description}@* +The @code{bfd_default_arch_struct} is an item of +@code{bfd_arch_info_type} which has been initialized to a fairly +generic state. A BFD starts life by pointing to this +structure, until the correct back end has determined the real +architecture of the file. +@example +extern const bfd_arch_info_type bfd_default_arch_struct; +@end example +@* +@findex bfd_set_arch_info +@subsubsection @code{bfd_set_arch_info} +@strong{Synopsis} +@example +void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg); +@end example +@strong{Description}@* +Set the architecture info of @var{abfd} to @var{arg}. +@* +@findex bfd_default_set_arch_mach +@subsubsection @code{bfd_default_set_arch_mach} +@strong{Synopsis} +@example +boolean bfd_default_set_arch_mach(bfd *abfd, + enum bfd_architecture arch, + unsigned long mach); +@end example +@strong{Description}@* +Set the architecture and machine type in BFD @var{abfd} +to @var{arch} and @var{mach}. Find the correct +pointer to a structure and insert it into the @code{arch_info} +pointer. +@* +@findex bfd_get_arch +@subsubsection @code{bfd_get_arch} +@strong{Synopsis} +@example +enum bfd_architecture bfd_get_arch(bfd *abfd); +@end example +@strong{Description}@* +Return the enumerated type which describes the BFD @var{abfd}'s +architecture. +@* +@findex bfd_get_mach +@subsubsection @code{bfd_get_mach} +@strong{Synopsis} +@example +unsigned long bfd_get_mach(bfd *abfd); +@end example +@strong{Description}@* +Return the long type which describes the BFD @var{abfd}'s +machine. +@* +@findex bfd_arch_bits_per_byte +@subsubsection @code{bfd_arch_bits_per_byte} +@strong{Synopsis} +@example +unsigned int bfd_arch_bits_per_byte(bfd *abfd); +@end example +@strong{Description}@* +Return the number of bits in one of the BFD @var{abfd}'s +architecture's bytes. +@* +@findex bfd_arch_bits_per_address +@subsubsection @code{bfd_arch_bits_per_address} +@strong{Synopsis} +@example +unsigned int bfd_arch_bits_per_address(bfd *abfd); +@end example +@strong{Description}@* +Return the number of bits in one of the BFD @var{abfd}'s +architecture's addresses. +@* +@findex bfd_default_compatible +@subsubsection @code{bfd_default_compatible} +@strong{Synopsis} +@example +const bfd_arch_info_type *bfd_default_compatible + (const bfd_arch_info_type *a, + const bfd_arch_info_type *b); +@end example +@strong{Description}@* +The default function for testing for compatibility. +@* +@findex bfd_default_scan +@subsubsection @code{bfd_default_scan} +@strong{Synopsis} +@example +boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string); +@end example +@strong{Description}@* +The default function for working out whether this is an +architecture hit and a machine hit. +@* +@findex bfd_get_arch_info +@subsubsection @code{bfd_get_arch_info} +@strong{Synopsis} +@example +const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd); +@end example +@strong{Description}@* +Return the architecture info struct in @var{abfd}. +@* +@findex bfd_lookup_arch +@subsubsection @code{bfd_lookup_arch} +@strong{Synopsis} +@example +const bfd_arch_info_type *bfd_lookup_arch + (enum bfd_architecture + arch, + unsigned long machine); +@end example +@strong{Description}@* +Look for the architecure info structure which matches the +arguments @var{arch} and @var{machine}. A machine of 0 matches the +machine/architecture structure which marks itself as the +default. +@* +@findex bfd_printable_arch_mach +@subsubsection @code{bfd_printable_arch_mach} +@strong{Synopsis} +@example +const char *bfd_printable_arch_mach + (enum bfd_architecture arch, unsigned long machine); +@end example +@strong{Description}@* +Return a printable string representing the architecture and +machine type. + +This routine is depreciated. +@* diff -urN binutils-2.7/bfd/doc/bfd.info binutils-2.8/bfd/doc/bfd.info --- binutils-2.7/bfd/doc/bfd.info Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.info Wed Apr 30 13:14:27 1997 @@ -0,0 +1,94 @@ +This is Info file bfd.info, produced by Makeinfo-1.64 from the input +file ./bfd.texinfo. + +START-INFO-DIR-ENTRY +* Bfd: (bfd). The Binary File Descriptor library. +END-INFO-DIR-ENTRY + + This file documents the BFD library. + + Copyright (C) 1991 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, subject to the +terms of the GNU General Public License, which includes the provision +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +Indirect: +bfd.info-1: 936 +bfd.info-2: 50487 +bfd.info-3: 91356 +bfd.info-4: 139850 +bfd.info-5: 181537 + +Tag Table: +(Indirect) +Node: Top936 +Node: Overview1201 +Node: History2251 +Node: How It Works3192 +Node: What BFD Version 2 Can Do4733 +Node: BFD information loss6047 +Node: Canonical format8570 +Node: BFD front end12931 +Node: Memory Usage31295 +Node: Initialization32518 +Node: Sections32890 +Node: Section Input33365 +Node: Section Output34717 +Node: typedef asection37178 +Node: section prototypes50487 +Node: Symbols56231 +Node: Reading Symbols57818 +Node: Writing Symbols58898 +Node: Mini Symbols60458 +Node: typedef asymbol61419 +Node: symbol handling functions66065 +Node: Archives70069 +Node: Formats73671 +Node: Relocations76452 +Node: typedef arelent77168 +Node: howto manager91356 +Node: Core Files106226 +Node: Targets107231 +Node: bfd_target109189 +Node: Architectures126860 +Node: Opening and Closing136295 +Node: Internal139850 +Node: File Caching144788 +Node: Linker Functions147532 +Node: Creating a Linker Hash Table149195 +Node: Adding Symbols to the Hash Table150918 +Node: Differing file formats151804 +Node: Adding symbols from an object file153533 +Node: Adding symbols from an archive155665 +Node: Performing the Final Link158060 +Node: Information provided by the linker159288 +Node: Relocating the section contents160420 +Node: Writing the symbol table162153 +Node: Hash Tables164740 +Node: Creating and Freeing a Hash Table165928 +Node: Looking Up or Entering a String167080 +Node: Traversing a Hash Table168318 +Node: Deriving a New Hash Table Type169092 +Node: Define the Derived Structures170144 +Node: Write the Derived Creation Routine171206 +Node: Write Other Derived Routines173884 +Node: BFD back ends175180 +Node: What to Put Where175399 +Node: aout175537 +Node: coff181537 +Node: elf206935 +Node: Index207760 + +End Tag Table diff -urN binutils-2.7/bfd/doc/bfd.info-1 binutils-2.8/bfd/doc/bfd.info-1 --- binutils-2.7/bfd/doc/bfd.info-1 Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.info-1 Wed Apr 30 13:14:26 1997 @@ -0,0 +1,1306 @@ +This is Info file bfd.info, produced by Makeinfo-1.64 from the input +file ./bfd.texinfo. + +START-INFO-DIR-ENTRY +* Bfd: (bfd). The Binary File Descriptor library. +END-INFO-DIR-ENTRY + + This file documents the BFD library. + + Copyright (C) 1991 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, subject to the +terms of the GNU General Public License, which includes the provision +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: bfd.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir) + + This file documents the binary file descriptor library libbfd. + +* Menu: + +* Overview:: Overview of BFD +* BFD front end:: BFD front end +* BFD back ends:: BFD back ends +* Index:: Index + + +File: bfd.info, Node: Overview, Next: BFD front end, Prev: Top, Up: Top + +Introduction +************ + + BFD is a package which allows applications to use the same routines +to operate on object files whatever the object file format. A new +object file format can be supported simply by creating a new BFD back +end and adding it to the library. + + BFD is split into two parts: the front end, and the back ends (one +for each object file format). + * The front end of BFD provides the interface to the user. It manages + memory and various canonical data structures. The front end also + decides which back end to use and when to call back end routines. + + * The back ends provide BFD its view of the real world. Each back + end provides a set of calls which the BFD front end can use to + maintain its canonical form. The back ends also may keep around + information for their own use, for greater efficiency. + +* Menu: + +* History:: History +* How It Works:: How It Works +* What BFD Version 2 Can Do:: What BFD Version 2 Can Do + + +File: bfd.info, Node: History, Next: How It Works, Prev: Overview, Up: Overview + +History +======= + + One spur behind BFD was the desire, on the part of the GNU 960 team +at Intel Oregon, for interoperability of applications on their COFF and +b.out file formats. Cygnus was providing GNU support for the team, and +was contracted to provide the required functionality. + + The name came from a conversation David Wallace was having with +Richard Stallman about the library: RMS said that it would be quite +hard--David said "BFD". Stallman was right, but the name stuck. + + At the same time, Ready Systems wanted much the same thing, but for +different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k +coff. + + BFD was first implemented by members of Cygnus Support; Steve +Chamberlain (`sac@cygnus.com'), John Gilmore (`gnu@cygnus.com'), K. +Richard Pixley (`rich@cygnus.com') and David Henkel-Wallace +(`gumby@cygnus.com'). + + +File: bfd.info, Node: How It Works, Next: What BFD Version 2 Can Do, Prev: History, Up: Overview + +How To Use BFD +============== + + To use the library, include `bfd.h' and link with `libbfd.a'. + + BFD provides a common interface to the parts of an object file for a +calling application. + + When an application sucessfully opens a target file (object, +archive, or whatever), a pointer to an internal structure is returned. +This pointer points to a structure called `bfd', described in `bfd.h'. +Our convention is to call this pointer a BFD, and instances of it +within code `abfd'. All operations on the target object file are +applied as methods to the BFD. The mapping is defined within `bfd.h' +in a set of macros, all beginning with `bfd_' to reduce namespace +pollution. + + For example, this sequence does what you would probably expect: +return the number of sections in an object file attached to a BFD +`abfd'. + + #include "bfd.h" + + unsigned int number_of_sections(abfd) + bfd *abfd; + { + return bfd_count_sections(abfd); + } + + The abstraction used within BFD is that an object file has: + + * a header, + + * a number of sections containing raw data (*note Sections::.), + + * a set of relocations (*note Relocations::.), and + + * some symbol information (*note Symbols::.). + +Also, BFDs opened for archives have the additional attribute of an index +and contain subordinate BFDs. This approach is fine for a.out and coff, +but loses efficiency when applied to formats such as S-records and +IEEE-695. + + +File: bfd.info, Node: What BFD Version 2 Can Do, Prev: How It Works, Up: Overview + +What BFD Version 2 Can Do +========================= + + When an object file is opened, BFD subroutines automatically +determine the format of the input object file. They then build a +descriptor in memory with pointers to routines that will be used to +access elements of the object file's data structures. + + As different information from the the object files is required, BFD +reads from different sections of the file and processes them. For +example, a very common operation for the linker is processing symbol +tables. Each BFD back end provides a routine for converting between +the object file's representation of symbols and an internal canonical +format. When the linker asks for the symbol table of an object file, it +calls through a memory pointer to the routine from the relevant BFD +back end which reads and converts the table into a canonical form. The +linker then operates upon the canonical form. When the link is finished +and the linker writes the output file's symbol table, another BFD back +end routine is called to take the newly created symbol table and +convert it into the chosen output format. + +* Menu: + +* BFD information loss:: Information Loss +* Canonical format:: The BFD canonical object-file format + + +File: bfd.info, Node: BFD information loss, Next: Canonical format, Up: What BFD Version 2 Can Do + +Information Loss +---------------- + + *Information can be lost during output.* The output formats +supported by BFD do not provide identical facilities, and information +which can be described in one form has nowhere to go in another format. +One example of this is alignment information in `b.out'. There is +nowhere in an `a.out' format file to store alignment information on the +contained data, so when a file is linked from `b.out' and an `a.out' +image is produced, alignment information will not propagate to the +output file. (The linker will still use the alignment information +internally, so the link is performed correctly). + + Another example is COFF section names. COFF files may contain an +unlimited number of sections, each one with a textual section name. If +the target of the link is a format which does not have many sections +(e.g., `a.out') or has sections without names (e.g., the Oasys format), +the link cannot be done simply. You can circumvent this problem by +describing the desired input-to-output section mapping with the linker +command language. + + *Information can be lost during canonicalization.* The BFD internal +canonical form of the external formats is not exhaustive; there are +structures in input formats for which there is no direct representation +internally. This means that the BFD back ends cannot maintain all +possible data richness through the transformation between external to +internal and back to external formats. + + This limitation is only a problem when an application reads one +format and writes another. Each BFD back end is responsible for +maintaining as much data as possible, and the internal BFD canonical +form has structures which are opaque to the BFD core, and exported only +to the back ends. When a file is read in one format, the canonical form +is generated for BFD and the application. At the same time, the back +end saves away any information which may otherwise be lost. If the data +is then written back in the same format, the back end routine will be +able to use the canonical form provided by the BFD core as well as the +information it prepared earlier. Since there is a great deal of +commonality between back ends, there is no information lost when +linking or copying big endian COFF to little endian COFF, or `a.out' to +`b.out'. When a mixture of formats is linked, the information is only +lost from the files whose format differs from the destination. + + +File: bfd.info, Node: Canonical format, Prev: BFD information loss, Up: What BFD Version 2 Can Do + +The BFD canonical object-file format +------------------------------------ + + The greatest potential for loss of information occurs when there is +the least overlap between the information provided by the source +format, that stored by the canonical format, and that needed by the +destination format. A brief description of the canonical form may help +you understand which kinds of data you can count on preserving across +conversions. + +*files* + Information stored on a per-file basis includes target machine + architecture, particular implementation format type, a demand + pageable bit, and a write protected bit. Information like Unix + magic numbers is not stored here--only the magic numbers' meaning, + so a `ZMAGIC' file would have both the demand pageable bit and the + write protected text bit set. The byte order of the target is + stored on a per-file basis, so that big- and little-endian object + files may be used with one another. + +*sections* + Each section in the input file contains the name of the section, + the section's original address in the object file, size and + alignment information, various flags, and pointers into other BFD + data structures. + +*symbols* + Each symbol contains a pointer to the information for the object + file which originally defined it, its name, its value, and various + flag bits. When a BFD back end reads in a symbol table, it + relocates all symbols to make them relative to the base of the + section where they were defined. Doing this ensures that each + symbol points to its containing section. Each symbol also has a + varying amount of hidden private data for the BFD back end. Since + the symbol points to the original file, the private data format + for that symbol is accessible. `ld' can operate on a collection + of symbols of wildly different formats without problems. + + Normal global and simple local symbols are maintained on output, + so an output file (no matter its format) will retain symbols + pointing to functions and to global, static, and common variables. + Some symbol information is not worth retaining; in `a.out', type + information is stored in the symbol table as long symbol names. + This information would be useless to most COFF debuggers; the + linker has command line switches to allow users to throw it away. + + There is one word of type information within the symbol, so if the + format supports symbol type information within symbols (for + example, COFF, IEEE, Oasys) and the type is simple enough to fit + within one word (nearly everything but aggregates), the + information will be preserved. + +*relocation level* + Each canonical BFD relocation record contains a pointer to the + symbol to relocate to, the offset of the data to relocate, the + section the data is in, and a pointer to a relocation type + descriptor. Relocation is performed by passing messages through + the relocation type descriptor and the symbol pointer. Therefore, + relocations can be performed on output data using a relocation + method that is only available in one of the input formats. For + instance, Oasys provides a byte relocation format. A relocation + record requesting this relocation type would point indirectly to a + routine to perform this, so the relocation may be performed on a + byte being written to a 68k COFF file, even though 68k COFF has no + such relocation type. + +*line numbers* + Object formats can contain, for debugging purposes, some form of + mapping between symbols, source line numbers, and addresses in the + output file. These addresses have to be relocated along with the + symbol information. Each symbol with an associated list of line + number records points to the first record of the list. The head + of a line number list consists of a pointer to the symbol, which + allows finding out the address of the function whose line number + is being described. The rest of the list is made up of pairs: + offsets into the section and line numbers. Any format which can + simply derive this information can pass it successfully between + formats (COFF, IEEE and Oasys). + + +File: bfd.info, Node: BFD front end, Next: BFD back ends, Prev: Overview, Up: Top + +BFD front end +************* + +`typedef bfd' +============= + + A BFD has type `bfd'; objects of this type are the cornerstone of +any application using BFD. Using BFD consists of making references +though the BFD and to data in the BFD. + + Here is the structure that defines the type `bfd'. It contains the +major data about the file and pointers to the rest of the data. +. + struct _bfd + { + /* The filename the application opened the BFD with. */ + CONST char *filename; + + /* A pointer to the target jump table. */ + const struct bfd_target *xvec; + + /* To avoid dragging too many header files into every file that + includes ``bfd.h'', IOSTREAM has been declared as a "char + *", and MTIME as a "long". Their correct types, to which they + are cast when used, are "FILE *" and "time_t". The iostream + is the result of an fopen on the filename. However, if the + BFD_IN_MEMORY flag is set, then iostream is actually a pointer + to a bfd_in_memory struct. */ + PTR iostream; + + /* Is the file descriptor being cached? That is, can it be closed as + needed, and re-opened when accessed later? */ + + boolean cacheable; + + /* Marks whether there was a default target specified when the + BFD was opened. This is used to select which matching algorithm + to use to choose the back end. */ + + boolean target_defaulted; + + /* The caching routines use these to maintain a + least-recently-used list of BFDs */ + + struct _bfd *lru_prev, *lru_next; + + /* When a file is closed by the caching routines, BFD retains + state information on the file here: */ + + file_ptr where; + + /* and here: (``once'' means at least once) */ + + boolean opened_once; + + /* Set if we have a locally maintained mtime value, rather than + getting it from the file each time: */ + + boolean mtime_set; + + /* File modified time, if mtime_set is true: */ + + long mtime; + + /* Reserved for an unimplemented file locking extension.*/ + + int ifd; + + /* The format which belongs to the BFD. (object, core, etc.) */ + + bfd_format format; + + /* The direction the BFD was opened with*/ + + enum bfd_direction {no_direction = 0, + read_direction = 1, + write_direction = 2, + both_direction = 3} direction; + + /* Format_specific flags*/ + + flagword flags; + + /* Currently my_archive is tested before adding origin to + anything. I believe that this can become always an add of + origin, with origin set to 0 for non archive files. */ + + file_ptr origin; + + /* Remember when output has begun, to stop strange things + from happening. */ + boolean output_has_begun; + + /* Pointer to linked list of sections*/ + struct sec *sections; + + /* The number of sections */ + unsigned int section_count; + + /* Stuff only useful for object files: + The start address. */ + bfd_vma start_address; + + /* Used for input and output*/ + unsigned int symcount; + + /* Symbol table for output BFD (with symcount entries) */ + struct symbol_cache_entry **outsymbols; + + /* Pointer to structure which contains architecture information*/ + const struct bfd_arch_info *arch_info; + + /* Stuff only useful for archives:*/ + PTR arelt_data; + struct _bfd *my_archive; /* The containing archive BFD. */ + struct _bfd *next; /* The next BFD in the archive. */ + struct _bfd *archive_head; /* The first BFD in the archive. */ + boolean has_armap; + + /* A chain of BFD structures involved in a link. */ + struct _bfd *link_next; + + /* A field used by _bfd_generic_link_add_archive_symbols. This will + be used only for archive elements. */ + int archive_pass; + + /* Used by the back end to hold private data. */ + + union + { + struct aout_data_struct *aout_data; + struct artdata *aout_ar_data; + struct _oasys_data *oasys_obj_data; + struct _oasys_ar_data *oasys_ar_data; + struct coff_tdata *coff_obj_data; + struct pe_tdata *pe_obj_data; + struct xcoff_tdata *xcoff_obj_data; + struct ecoff_tdata *ecoff_obj_data; + struct ieee_data_struct *ieee_data; + struct ieee_ar_data_struct *ieee_ar_data; + struct srec_data_struct *srec_data; + struct ihex_data_struct *ihex_data; + struct tekhex_data_struct *tekhex_data; + struct elf_obj_tdata *elf_obj_data; + struct nlm_obj_tdata *nlm_obj_data; + struct bout_data_struct *bout_data; + struct sun_core_struct *sun_core_data; + struct trad_core_struct *trad_core_data; + struct som_data_struct *som_data; + struct hpux_core_struct *hpux_core_data; + struct hppabsd_core_struct *hppabsd_core_data; + struct sgi_core_struct *sgi_core_data; + struct lynx_core_struct *lynx_core_data; + struct osf_core_struct *osf_core_data; + struct cisco_core_struct *cisco_core_data; + struct versados_data_struct *versados_data; + struct netbsd_core_struct *netbsd_core_data; + PTR any; + } tdata; + + /* Used by the application to hold private data*/ + PTR usrdata; + + /* Where all the allocated stuff under this BFD goes. This is a + struct objalloc *, but we use PTR to avoid requiring the inclusion of + objalloc.h. */ + PTR memory; + }; + +Error reporting +=============== + + Most BFD functions return nonzero on success (check their individual +documentation for precise semantics). On an error, they call +`bfd_set_error' to set an error condition that callers can check by +calling `bfd_get_error'. If that returns `bfd_error_system_call', then +check `errno'. + + The easiest way to report a BFD error to the user is to use +`bfd_perror'. +Type `bfd_error_type' +--------------------- + +The values returned by `bfd_get_error' are defined by the enumerated +type `bfd_error_type'. +. + typedef enum bfd_error + { + bfd_error_no_error = 0, + bfd_error_system_call, + bfd_error_invalid_target, + bfd_error_wrong_format, + bfd_error_invalid_operation, + bfd_error_no_memory, + bfd_error_no_symbols, + bfd_error_no_armap, + bfd_error_no_more_archived_files, + bfd_error_malformed_archive, + bfd_error_file_not_recognized, + bfd_error_file_ambiguously_recognized, + bfd_error_no_contents, + bfd_error_nonrepresentable_section, + bfd_error_no_debug_section, + bfd_error_bad_value, + bfd_error_file_truncated, + bfd_error_file_too_big, + bfd_error_invalid_error_code + } bfd_error_type; + +`bfd_get_error' +............... + + *Synopsis* + bfd_error_type bfd_get_error (void); + *Description* +Return the current BFD error condition. +`bfd_set_error' +............... + +*Synopsis* + void bfd_set_error (bfd_error_type error_tag); + *Description* +Set the BFD error condition to be ERROR_TAG. +`bfd_errmsg' +............ + +*Synopsis* + CONST char *bfd_errmsg (bfd_error_type error_tag); + *Description* +Return a string describing the error ERROR_TAG, or the system error if +ERROR_TAG is `bfd_error_system_call'. +`bfd_perror' +............ + +*Synopsis* + void bfd_perror (CONST char *message); + *Description* +Print to the standard error stream a string describing the last BFD +error that occurred, or the last system error if the last BFD error was +a system call failure. If MESSAGE is non-NULL and non-empty, the error +string printed is preceded by MESSAGE, a colon, and a space. It is +followed by a newline. +BFD error handler +----------------- + +Some BFD functions want to print messages describing the problem. They +call a BFD error handler function. This function may be overriden by +the program. + + The BFD error handler acts like printf. +. + typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...)); + +`bfd_set_error_handler' +....................... + + *Synopsis* + bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); + *Description* +Set the BFD error handler function. Returns the previous function. +`bfd_set_error_program_name' +............................ + +*Synopsis* + void bfd_set_error_program_name (const char *); + *Description* +Set the program name to use when printing a BFD error. This is printed +before the error message followed by a colon and space. The string +must not be changed after it is passed to this function. +Symbols +======= + +`bfd_get_reloc_upper_bound' +........................... + +*Synopsis* + long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect); + *Description* +Return the number of bytes required to store the relocation information +associated with section SECT attached to bfd ABFD. If an error occurs, +return -1. +`bfd_canonicalize_reloc' +........................ + +*Synopsis* + long bfd_canonicalize_reloc + (bfd *abfd, + asection *sec, + arelent **loc, + asymbol **syms); + *Description* +Call the back end associated with the open BFD ABFD and translate the +external form of the relocation information attached to SEC into the +internal canonical form. Place the table into memory at LOC, which has +been preallocated, usually by a call to `bfd_get_reloc_upper_bound'. +Returns the number of relocs, or -1 on error. + + The SYMS table is also needed for horrible internal magic reasons. +`bfd_set_reloc' +............... + +*Synopsis* + void bfd_set_reloc + (bfd *abfd, asection *sec, arelent **rel, unsigned int count) + *Description* +Set the relocation pointer and count within section SEC to the values +REL and COUNT. The argument ABFD is ignored. +`bfd_set_file_flags' +.................... + +*Synopsis* + boolean bfd_set_file_flags(bfd *abfd, flagword flags); + *Description* +Set the flag word in the BFD ABFD to the value FLAGS. + + Possible errors are: + * `bfd_error_wrong_format' - The target bfd was not of object format. + + * `bfd_error_invalid_operation' - The target bfd was open for + reading. + + * `bfd_error_invalid_operation' - The flag word contained a bit + which was not applicable to the type of file. E.g., an attempt + was made to set the `D_PAGED' bit on a BFD format which does not + support demand paging. +`bfd_set_start_address' +....................... + +*Synopsis* + boolean bfd_set_start_address(bfd *abfd, bfd_vma vma); + *Description* +Make VMA the entry point of output BFD ABFD. +*Returns* +Returns `true' on success, `false' otherwise. +`bfd_get_mtime' +............... + +*Synopsis* + long bfd_get_mtime(bfd *abfd); + *Description* +Return the file modification time (as read from the file system, or +from the archive header for archive members). +`bfd_get_size' +.............. + +*Synopsis* + long bfd_get_size(bfd *abfd); + *Description* +Return the file size (as read from file system) for the file associated +with BFD ABFD. + + The initial motivation for, and use of, this routine is not so we +can get the exact size of the object the BFD applies to, since that +might not be generally possible (archive members for example). It +would be ideal if someone could eventually modify it so that such +results were guaranteed. + + Instead, we want to ask questions like "is this NNN byte sized +object I'm about to try read from file offset YYY reasonable?" As as +example of where we might do this, some object formats use string +tables for which the first `sizeof(long)' bytes of the table contain +the size of the table itself, including the size bytes. If an +application tries to read what it thinks is one of these string tables, +without some way to validate the size, and for some reason the size is +wrong (byte swapping error, wrong location for the string table, etc.), +the only clue is likely to be a read error when it tries to read the +table, or a "virtual memory exhausted" error when it tries to allocate +15 bazillon bytes of space for the 15 bazillon byte table it is about +to read. This function at least allows us to answer the quesion, "is +the size reasonable?". +`bfd_get_gp_size' +................. + +*Synopsis* + int bfd_get_gp_size(bfd *abfd); + *Description* +Return the maximum size of objects to be optimized using the GP +register under MIPS ECOFF. This is typically set by the `-G' argument +to the compiler, assembler or linker. +`bfd_set_gp_size' +................. + +*Synopsis* + void bfd_set_gp_size(bfd *abfd, int i); + *Description* +Set the maximum size of objects to be optimized using the GP register +under ECOFF or MIPS ELF. This is typically set by the `-G' argument to +the compiler, assembler or linker. +`bfd_scan_vma' +.............. + +*Synopsis* + bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base); + *Description* +Convert, like `strtoul', a numerical expression STRING into a `bfd_vma' +integer, and return that integer. (Though without as many bells and +whistles as `strtoul'.) The expression is assumed to be unsigned (i.e., +positive). If given a BASE, it is used as the base for conversion. A +base of 0 causes the function to interpret the string in hex if a +leading "0x" or "0X" is found, otherwise in octal if a leading zero is +found, otherwise in decimal. + + Overflow is not detected. +`bfd_copy_private_bfd_data' +........................... + +*Synopsis* + boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd); + *Description* +Copy private BFD information from the BFD IBFD to the the BFD OBFD. +Return `true' on success, `false' on error. Possible error returns are: + + * `bfd_error_no_memory' - Not enough memory exists to create private + data for OBFD. + #define bfd_copy_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ + (ibfd, obfd)) + +`bfd_merge_private_bfd_data' +............................ + +*Synopsis* + boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd); + *Description* +Merge private BFD information from the BFD IBFD to the the output file +BFD OBFD when linking. Return `true' on success, `false' on error. +Possible error returns are: + + * `bfd_error_no_memory' - Not enough memory exists to create private + data for OBFD. + #define bfd_merge_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ + (ibfd, obfd)) + +`bfd_set_private_flags' +....................... + +*Synopsis* + boolean bfd_set_private_flags(bfd *abfd, flagword flags); + *Description* +Set private BFD flag information in the BFD ABFD. Return `true' on +success, `false' on error. Possible error returns are: + + * `bfd_error_no_memory' - Not enough memory exists to create private + data for OBFD. + #define bfd_set_private_flags(abfd, flags) \ + BFD_SEND (abfd, _bfd_set_private_flags, \ + (abfd, flags)) + +`stuff' +....... + +*Description* +Stuff which should be documented: + #define bfd_sizeof_headers(abfd, reloc) \ + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) + + #define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ + BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line)) + + /* Do these three do anything useful at all, for any back end? */ + #define bfd_debug_info_start(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) + + #define bfd_debug_info_end(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) + + #define bfd_debug_info_accumulate(abfd, section) \ + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) + + + #define bfd_stat_arch_elt(abfd, stat) \ + BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) + + #define bfd_update_armap_timestamp(abfd) \ + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) + + #define bfd_set_arch_mach(abfd, arch, mach)\ + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) + + #define bfd_relax_section(abfd, section, link_info, again) \ + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) + + #define bfd_link_hash_table_create(abfd) \ + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) + + #define bfd_link_add_symbols(abfd, info) \ + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) + + #define bfd_final_link(abfd, info) \ + BFD_SEND (abfd, _bfd_final_link, (abfd, info)) + + #define bfd_free_cached_info(abfd) \ + BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) + + #define bfd_get_dynamic_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) + + #define bfd_print_private_bfd_data(abfd, file)\ + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) + + #define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) + + #define bfd_get_dynamic_reloc_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) + + #define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) + + extern bfd_byte *bfd_get_relocated_section_contents + PARAMS ((bfd *, struct bfd_link_info *, + struct bfd_link_order *, bfd_byte *, + boolean, asymbol **)); + +* Menu: + +* Memory Usage:: +* Initialization:: +* Sections:: +* Symbols:: +* Archives:: +* Formats:: +* Relocations:: +* Core Files:: +* Targets:: +* Architectures:: +* Opening and Closing:: +* Internal:: +* File Caching:: +* Linker Functions:: +* Hash Tables:: + + +File: bfd.info, Node: Memory Usage, Next: Initialization, Prev: BFD front end, Up: BFD front end + +Memory usage +============ + + BFD keeps all of its internal structures in obstacks. There is one +obstack per open BFD file, into which the current state is stored. When +a BFD is closed, the obstack is deleted, and so everything which has +been allocated by BFD for the closing file is thrown away. + + BFD does not free anything created by an application, but pointers +into `bfd' structures become invalid on a `bfd_close'; for example, +after a `bfd_close' the vector passed to `bfd_canonicalize_symtab' is +still around, since it has been allocated by the application, but the +data that it pointed to are lost. + + The general rule is to not close a BFD until all operations dependent +upon data from the BFD have been completed, or all the data from within +the file has been copied. To help with the management of memory, there +is a function (`bfd_alloc_size') which returns the number of bytes in +obstacks associated with the supplied BFD. This could be used to select +the greediest open BFD, close it to reclaim the memory, perform some +operation and reopen the BFD again, to get a fresh copy of the data +structures. + + +File: bfd.info, Node: Initialization, Next: Sections, Prev: Memory Usage, Up: BFD front end + +Initialization +============== + + These are the functions that handle initializing a BFD. +`bfd_init' +.......... + +*Synopsis* + void bfd_init(void); + *Description* +This routine must be called before any other BFD function to initialize +magical internal data structures. + +File: bfd.info, Node: Sections, Next: Symbols, Prev: Initialization, Up: BFD front end + +Sections +======== + +The raw data contained within a BFD is maintained through the section +abstraction. A single BFD may have any number of sections. It keeps +hold of them by pointing to the first; each one points to the next in +the list. + + Sections are supported in BFD in `section.c'. + +* Menu: + +* Section Input:: +* Section Output:: +* typedef asection:: +* section prototypes:: + + +File: bfd.info, Node: Section Input, Next: Section Output, Prev: Sections, Up: Sections + +Section input +------------- + +When a BFD is opened for reading, the section structures are created +and attached to the BFD. + + Each section has a name which describes the section in the outside +world--for example, `a.out' would contain at least three sections, +called `.text', `.data' and `.bss'. + + Names need not be unique; for example a COFF file may have several +sections named `.data'. + + Sometimes a BFD will contain more than the "natural" number of +sections. A back end may attach other sections containing constructor +data, or an application may add a section (using `bfd_make_section') to +the sections attached to an already open BFD. For example, the linker +creates an extra section `COMMON' for each input file's BFD to hold +information about common storage. + + The raw data is not necessarily read in when the section descriptor +is created. Some targets may leave the data in place until a +`bfd_get_section_contents' call is made. Other back ends may read in +all the data at once. For example, an S-record file has to be read +once to determine the size of the data. An IEEE-695 file doesn't +contain raw data in sections, but data and relocation expressions +intermixed, so the data area has to be parsed to get out the data and +relocations. + +File: bfd.info, Node: Section Output, Next: typedef asection, Prev: Section Input, Up: Sections + +Section output +-------------- + +To write a new object style BFD, the various sections to be written +have to be created. They are attached to the BFD in the same way as +input sections; data is written to the sections using +`bfd_set_section_contents'. + + Any program that creates or combines sections (e.g., the assembler +and linker) must use the `asection' fields `output_section' and +`output_offset' to indicate the file sections to which each section +must be written. (If the section is being created from scratch, +`output_section' should probably point to the section itself and +`output_offset' should probably be zero.) + + The data to be written comes from input sections attached (via +`output_section' pointers) to the output sections. The output section +structure can be considered a filter for the input section: the output +section determines the vma of the output data and the name, but the +input section determines the offset into the output section of the data +to be written. + + E.g., to create a section "O", starting at 0x100, 0x123 long, +containing two subsections, "A" at offset 0x0 (i.e., at vma 0x100) and +"B" at offset 0x20 (i.e., at vma 0x120) the `asection' structures would +look like: + + section name "A" + output_offset 0x00 + size 0x20 + output_section -----------> section name "O" + | vma 0x100 + section name "B" | size 0x123 + output_offset 0x20 | + size 0x103 | + output_section --------| + +Link orders +----------- + +The data within a section is stored in a "link_order". These are much +like the fixups in `gas'. The link_order abstraction allows a section +to grow and shrink within itself. + + A link_order knows how big it is, and which is the next link_order +and where the raw data for it is; it also points to a list of +relocations which apply to it. + + The link_order is used by the linker to perform relaxing on final +code. The compiler creates code which is as big as necessary to make +it work without relaxing, and the user can select whether to relax. +Sometimes relaxing takes a lot of time. The linker runs around the +relocations to see if any are attached to data which can be shrunk, if +so it does it on a link_order by link_order basis. + +File: bfd.info, Node: typedef asection, Next: section prototypes, Prev: Section Output, Up: Sections + +typedef asection +---------------- + +Here is the section structure: +. + typedef struct sec + { + /* The name of the section; the name isn't a copy, the pointer is + the same as that passed to bfd_make_section. */ + + CONST char *name; + + /* Which section is it; 0..nth. */ + + int index; + + /* The next section in the list belonging to the BFD, or NULL. */ + + struct sec *next; + + /* The field flags contains attributes of the section. Some + flags are read in from the object file, and some are + synthesized from other information. */ + + flagword flags; + + #define SEC_NO_FLAGS 0x000 + + /* Tells the OS to allocate space for this section when loading. + This is clear for a section containing debug information + only. */ + #define SEC_ALLOC 0x001 + + /* Tells the OS to load the section from the file when loading. + This is clear for a .bss section. */ + #define SEC_LOAD 0x002 + + /* The section contains data still to be relocated, so there is + some relocation information too. */ + #define SEC_RELOC 0x004 + + #if 0 /* Obsolete ? */ + #define SEC_BALIGN 0x008 + #endif + + /* A signal to the OS that the section contains read only + data. */ + #define SEC_READONLY 0x010 + + /* The section contains code only. */ + #define SEC_CODE 0x020 + + /* The section contains data only. */ + #define SEC_DATA 0x040 + + /* The section will reside in ROM. */ + #define SEC_ROM 0x080 + + /* The section contains constructor information. This section + type is used by the linker to create lists of constructors and + destructors used by `g++'. When a back end sees a symbol + which should be used in a constructor list, it creates a new + section for the type of name (e.g., `__CTOR_LIST__'), attaches + the symbol to it, and builds a relocation. To build the lists + of constructors, all the linker has to do is catenate all the + sections called `__CTOR_LIST__' and relocate the data + contained within - exactly the operations it would peform on + standard data. */ + #define SEC_CONSTRUCTOR 0x100 + + /* The section is a constuctor, and should be placed at the + end of the text, data, or bss section(?). */ + #define SEC_CONSTRUCTOR_TEXT 0x1100 + #define SEC_CONSTRUCTOR_DATA 0x2100 + #define SEC_CONSTRUCTOR_BSS 0x3100 + + /* The section has contents - a data section could be + `SEC_ALLOC' | `SEC_HAS_CONTENTS'; a debug section could be + `SEC_HAS_CONTENTS' */ + #define SEC_HAS_CONTENTS 0x200 + + /* An instruction to the linker to not output the section + even if it has information which would normally be written. */ + #define SEC_NEVER_LOAD 0x400 + + /* The section is a COFF shared library section. This flag is + only for the linker. If this type of section appears in + the input file, the linker must copy it to the output file + without changing the vma or size. FIXME: Although this + was originally intended to be general, it really is COFF + specific (and the flag was renamed to indicate this). It + might be cleaner to have some more general mechanism to + allow the back end to control what the linker does with + sections. */ + #define SEC_COFF_SHARED_LIBRARY 0x800 + + /* The section contains common symbols (symbols may be defined + multiple times, the value of a symbol is the amount of + space it requires, and the largest symbol value is the one + used). Most targets have exactly one of these (which we + translate to bfd_com_section_ptr), but ECOFF has two. */ + #define SEC_IS_COMMON 0x8000 + + /* The section contains only debugging information. For + example, this is set for ELF .debug and .stab sections. + strip tests this flag to see if a section can be + discarded. */ + #define SEC_DEBUGGING 0x10000 + + /* The contents of this section are held in memory pointed to + by the contents field. This is checked by + bfd_get_section_contents, and the data is retrieved from + memory if appropriate. */ + #define SEC_IN_MEMORY 0x20000 + + /* The contents of this section are to be excluded by the + linker for executable and shared objects unless those + objects are to be further relocated. */ + #define SEC_EXCLUDE 0x40000 + + /* The contents of this section are to be sorted by the + based on the address specified in the associated symbol + table. */ + #define SEC_SORT_ENTRIES 0x80000 + + /* When linking, duplicate sections of the same name should be + discarded, rather than being combined into a single section as + is usually done. This is similar to how common symbols are + handled. See SEC_LINK_DUPLICATES below. */ + #define SEC_LINK_ONCE 0x100000 + + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker + should handle duplicate sections. */ + #define SEC_LINK_DUPLICATES 0x600000 + + /* This value for SEC_LINK_DUPLICATES means that duplicate + sections with the same name should simply be discarded. */ + #define SEC_LINK_DUPLICATES_DISCARD 0x0 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if there are any duplicate sections, although + it should still only link one copy. */ + #define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections are a different size. */ + #define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections contain different + contents. */ + #define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000 + + /* This section was created by the linker as part of dynamic + relocation or other arcane processing. It is skipped when + going through the first-pass output, trusting that someone + else up the line will take care of it later. */ + #define SEC_LINKER_CREATED 0x800000 + + /* End of section flags. */ + + /* Some internal packed boolean fields. */ + + /* See the vma field. */ + unsigned int user_set_vma : 1; + + /* Whether relocations have been processed. */ + unsigned int reloc_done : 1; + + /* A mark flag used by some of the linker backends. */ + unsigned int linker_mark : 1; + + /* End of internal packed boolean fields. */ + + /* The virtual memory address of the section - where it will be + at run time. The symbols are relocated against this. The + user_set_vma flag is maintained by bfd; if it's not set, the + backend can assign addresses (for example, in `a.out', where + the default address for `.data' is dependent on the specific + target and various flags). */ + + bfd_vma vma; + + /* The load address of the section - where it would be in a + rom image; really only used for writing section header + information. */ + + bfd_vma lma; + + /* The size of the section in bytes, as it will be output. + contains a value even if the section has no contents (e.g., the + size of `.bss'). This will be filled in after relocation */ + + bfd_size_type _cooked_size; + + /* The original size on disk of the section, in bytes. Normally this + value is the same as the size, but if some relaxing has + been done, then this value will be bigger. */ + + bfd_size_type _raw_size; + + /* If this section is going to be output, then this value is the + offset into the output section of the first byte in the input + section. E.g., if this was going to start at the 100th byte in + the output section, this value would be 100. */ + + bfd_vma output_offset; + + /* The output section through which to map on output. */ + + struct sec *output_section; + + /* The alignment requirement of the section, as an exponent of 2 - + e.g., 3 aligns to 2^3 (or 8). */ + + unsigned int alignment_power; + + /* If an input section, a pointer to a vector of relocation + records for the data in this section. */ + + struct reloc_cache_entry *relocation; + + /* If an output section, a pointer to a vector of pointers to + relocation records for the data in this section. */ + + struct reloc_cache_entry **orelocation; + + /* The number of relocation records in one of the above */ + + unsigned reloc_count; + + /* Information below is back end specific - and not always used + or updated. */ + + /* File position of section data */ + + file_ptr filepos; + + /* File position of relocation info */ + + file_ptr rel_filepos; + + /* File position of line data */ + + file_ptr line_filepos; + + /* Pointer to data for applications */ + + PTR userdata; + + /* If the SEC_IN_MEMORY flag is set, this points to the actual + contents. */ + unsigned char *contents; + + /* Attached line number information */ + + alent *lineno; + + /* Number of line number records */ + + unsigned int lineno_count; + + /* When a section is being output, this value changes as more + linenumbers are written out */ + + file_ptr moving_line_filepos; + + /* What the section number is in the target world */ + + int target_index; + + PTR used_by_bfd; + + /* If this is a constructor section then here is a list of the + relocations created to relocate items within it. */ + + struct relent_chain *constructor_chain; + + /* The BFD which owns the section. */ + + bfd *owner; + + /* A symbol which points at this section only */ + struct symbol_cache_entry *symbol; + struct symbol_cache_entry **symbol_ptr_ptr; + + struct bfd_link_order *link_order_head; + struct bfd_link_order *link_order_tail; + } asection ; + + /* These sections are global, and are managed by BFD. The application + and target back end are not permitted to change the values in + these sections. New code should use the section_ptr macros rather + than referring directly to the const sections. The const sections + may eventually vanish. */ + #define BFD_ABS_SECTION_NAME "*ABS*" + #define BFD_UND_SECTION_NAME "*UND*" + #define BFD_COM_SECTION_NAME "*COM*" + #define BFD_IND_SECTION_NAME "*IND*" + + /* the absolute section */ + extern const asection bfd_abs_section; + #define bfd_abs_section_ptr ((asection *) &bfd_abs_section) + #define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) + /* Pointer to the undefined section */ + extern const asection bfd_und_section; + #define bfd_und_section_ptr ((asection *) &bfd_und_section) + #define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) + /* Pointer to the common section */ + extern const asection bfd_com_section; + #define bfd_com_section_ptr ((asection *) &bfd_com_section) + /* Pointer to the indirect section */ + extern const asection bfd_ind_section; + #define bfd_ind_section_ptr ((asection *) &bfd_ind_section) + #define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) + + extern const struct symbol_cache_entry * const bfd_abs_symbol; + extern const struct symbol_cache_entry * const bfd_com_symbol; + extern const struct symbol_cache_entry * const bfd_und_symbol; + extern const struct symbol_cache_entry * const bfd_ind_symbol; + #define bfd_get_section_size_before_reloc(section) \ + (section->reloc_done ? (abort(),1): (section)->_raw_size) + #define bfd_get_section_size_after_reloc(section) \ + ((section->reloc_done) ? (section)->_cooked_size: (abort(),1)) + diff -urN binutils-2.7/bfd/doc/bfd.info-2 binutils-2.8/bfd/doc/bfd.info-2 --- binutils-2.7/bfd/doc/bfd.info-2 Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.info-2 Wed Apr 30 13:14:26 1997 @@ -0,0 +1,1121 @@ +This is Info file bfd.info, produced by Makeinfo-1.64 from the input +file ./bfd.texinfo. + +START-INFO-DIR-ENTRY +* Bfd: (bfd). The Binary File Descriptor library. +END-INFO-DIR-ENTRY + + This file documents the BFD library. + + Copyright (C) 1991 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, subject to the +terms of the GNU General Public License, which includes the provision +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: bfd.info, Node: section prototypes, Prev: typedef asection, Up: Sections + +Section prototypes +------------------ + + These are the functions exported by the section handling part of BFD. +`bfd_get_section_by_name' +......................... + +*Synopsis* + asection *bfd_get_section_by_name(bfd *abfd, CONST char *name); + *Description* +Run through ABFD and return the one of the `asection's whose name +matches NAME, otherwise `NULL'. *Note Sections::, for more information. + + This should only be used in special cases; the normal way to process +all sections of a given name is to use `bfd_map_over_sections' and +`strcmp' on the name (or better yet, base it on the section flags or +something else) for each section. +`bfd_make_section_old_way' +.......................... + +*Synopsis* + asection *bfd_make_section_old_way(bfd *abfd, CONST char *name); + *Description* +Create a new empty section called NAME and attach it to the end of the +chain of sections for the BFD ABFD. An attempt to create a section with +a name which is already in use returns its pointer without changing the +section chain. + + It has the funny name since this is the way it used to be before it +was rewritten.... + + Possible errors are: + * `bfd_error_invalid_operation' - If output has already started for + this BFD. + + * `bfd_error_no_memory' - If memory allocation fails. +`bfd_make_section_anyway' +......................... + +*Synopsis* + asection *bfd_make_section_anyway(bfd *abfd, CONST char *name); + *Description* +Create a new empty section called NAME and attach it to the end of the +chain of sections for ABFD. Create a new section even if there is +already a section with that name. + + Return `NULL' and set `bfd_error' on error; possible errors are: + * `bfd_error_invalid_operation' - If output has already started for + ABFD. + + * `bfd_error_no_memory' - If memory allocation fails. +`bfd_make_section' +.................. + +*Synopsis* + asection *bfd_make_section(bfd *, CONST char *name); + *Description* +Like `bfd_make_section_anyway', but return `NULL' (without calling +bfd_set_error ()) without changing the section chain if there is +already a section named NAME. If there is an error, return `NULL' and +set `bfd_error'. +`bfd_set_section_flags' +....................... + +*Synopsis* + boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags); + *Description* +Set the attributes of the section SEC in the BFD ABFD to the value +FLAGS. Return `true' on success, `false' on error. Possible error +returns are: + + * `bfd_error_invalid_operation' - The section cannot have one or + more of the attributes requested. For example, a .bss section in + `a.out' may not have the `SEC_HAS_CONTENTS' field set. +`bfd_map_over_sections' +....................... + +*Synopsis* + void bfd_map_over_sections(bfd *abfd, + void (*func)(bfd *abfd, + asection *sect, + PTR obj), + PTR obj); + *Description* +Call the provided function FUNC for each section attached to the BFD +ABFD, passing OBJ as an argument. The function will be called as if by + + func(abfd, the_section, obj); + + This is the prefered method for iterating over sections; an +alternative would be to use a loop: + + section *p; + for (p = abfd->sections; p != NULL; p = p->next) + func(abfd, p, ...) + +`bfd_set_section_size' +...................... + +*Synopsis* + boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val); + *Description* +Set SEC to the size VAL. If the operation is ok, then `true' is +returned, else `false'. + + Possible error returns: + * `bfd_error_invalid_operation' - Writing has started to the BFD, so + setting the size is invalid. +`bfd_set_section_contents' +.......................... + +*Synopsis* + boolean bfd_set_section_contents + (bfd *abfd, + asection *section, + PTR data, + file_ptr offset, + bfd_size_type count); + *Description* +Sets the contents of the section SECTION in BFD ABFD to the data +starting in memory at DATA. The data is written to the output section +starting at offset OFFSET for COUNT bytes. + + Normally `true' is returned, else `false'. Possible error returns +are: + * `bfd_error_no_contents' - The output section does not have the + `SEC_HAS_CONTENTS' attribute, so nothing can be written to it. + + * and some more too This routine is front end to the back end +function `_bfd_set_section_contents'. +`bfd_get_section_contents' +.......................... + +*Synopsis* + boolean bfd_get_section_contents + (bfd *abfd, asection *section, PTR location, + file_ptr offset, bfd_size_type count); + *Description* +Read data from SECTION in BFD ABFD into memory starting at LOCATION. +The data is read at an offset of OFFSET from the start of the input +section, and is read for COUNT bytes. + + If the contents of a constructor with the `SEC_CONSTRUCTOR' flag set +are requested or if the section does not have the `SEC_HAS_CONTENTS' +flag set, then the LOCATION is filled with zeroes. If no errors occur, +`true' is returned, else `false'. +`bfd_copy_private_section_data' +............................... + +*Synopsis* + boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec); + *Description* +Copy private section information from ISEC in the BFD IBFD to the +section OSEC in the BFD OBFD. Return `true' on success, `false' on +error. Possible error returns are: + + * `bfd_error_no_memory' - Not enough memory exists to create private + data for OSEC. + #define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ + BFD_SEND (obfd, _bfd_copy_private_section_data, \ + (ibfd, isection, obfd, osection)) + + +File: bfd.info, Node: Symbols, Next: Archives, Prev: Sections, Up: BFD front end + +Symbols +======= + +BFD tries to maintain as much symbol information as it can when it +moves information from file to file. BFD passes information to +applications though the `asymbol' structure. When the application +requests the symbol table, BFD reads the table in the native form and +translates parts of it into the internal format. To maintain more than +the information passed to applications, some targets keep some +information "behind the scenes" in a structure only the particular back +end knows about. For example, the coff back end keeps the original +symbol table structure as well as the canonical structure when a BFD is +read in. On output, the coff back end can reconstruct the output symbol +table so that no information is lost, even information unique to coff +which BFD doesn't know or understand. If a coff symbol table were read, +but were written through an a.out back end, all the coff specific +information would be lost. The symbol table of a BFD is not necessarily +read in until a canonicalize request is made. Then the BFD back end +fills in a table provided by the application with pointers to the +canonical information. To output symbols, the application provides BFD +with a table of pointers to pointers to `asymbol's. This allows +applications like the linker to output a symbol as it was read, since +the "behind the scenes" information will be still available. + +* Menu: + +* Reading Symbols:: +* Writing Symbols:: +* Mini Symbols:: +* typedef asymbol:: +* symbol handling functions:: + + +File: bfd.info, Node: Reading Symbols, Next: Writing Symbols, Prev: Symbols, Up: Symbols + +Reading symbols +--------------- + +There are two stages to reading a symbol table from a BFD: allocating +storage, and the actual reading process. This is an excerpt from an +application which reads the symbol table: + + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long i; + + storage_needed = bfd_get_symtab_upper_bound (abfd); + + if (storage_needed < 0) + FAIL + + if (storage_needed == 0) { + return ; + } + symbol_table = (asymbol **) xmalloc (storage_needed); + ... + number_of_symbols = + bfd_canonicalize_symtab (abfd, symbol_table); + + if (number_of_symbols < 0) + FAIL + + for (i = 0; i < number_of_symbols; i++) { + process_symbol (symbol_table[i]); + } + + All storage for the symbols themselves is in an objalloc connected +to the BFD; it is freed when the BFD is closed. + +File: bfd.info, Node: Writing Symbols, Next: Mini Symbols, Prev: Reading Symbols, Up: Symbols + +Writing symbols +--------------- + +Writing of a symbol table is automatic when a BFD open for writing is +closed. The application attaches a vector of pointers to pointers to +symbols to the BFD being written, and fills in the symbol count. The +close and cleanup code reads through the table provided and performs +all the necessary operations. The BFD output code must always be +provided with an "owned" symbol: one which has come from another BFD, +or one which has been created using `bfd_make_empty_symbol'. Here is an +example showing the creation of a symbol table with only one element: + + #include "bfd.h" + main() + { + bfd *abfd; + asymbol *ptrs[2]; + asymbol *new; + + abfd = bfd_openw("foo","a.out-sunos-big"); + bfd_set_format(abfd, bfd_object); + new = bfd_make_empty_symbol(abfd); + new->name = "dummy_symbol"; + new->section = bfd_make_section_old_way(abfd, ".text"); + new->flags = BSF_GLOBAL; + new->value = 0x12345; + + ptrs[0] = new; + ptrs[1] = (asymbol *)0; + + bfd_set_symtab(abfd, ptrs, 1); + bfd_close(abfd); + } + + ./makesym + nm foo + 00012345 A dummy_symbol + + Many formats cannot represent arbitary symbol information; for +instance, the `a.out' object format does not allow an arbitary number +of sections. A symbol pointing to a section which is not one of +`.text', `.data' or `.bss' cannot be described. + +File: bfd.info, Node: Mini Symbols, Next: typedef asymbol, Prev: Writing Symbols, Up: Symbols + +Mini Symbols +------------ + +Mini symbols provide read-only access to the symbol table. They use +less memory space, but require more time to access. They can be useful +for tools like nm or objdump, which may have to handle symbol tables of +extremely large executables. + + The `bfd_read_minisymbols' function will read the symbols into +memory in an internal form. It will return a `void *' pointer to a +block of memory, a symbol count, and the size of each symbol. The +pointer is allocated using `malloc', and should be freed by the caller +when it is no longer needed. + + The function `bfd_minisymbol_to_symbol' will take a pointer to a +minisymbol, and a pointer to a structure returned by +`bfd_make_empty_symbol', and return a `asymbol' structure. The return +value may or may not be the same as the value from +`bfd_make_empty_symbol' which was passed in. + +File: bfd.info, Node: typedef asymbol, Next: symbol handling functions, Prev: Mini Symbols, Up: Symbols + +typedef asymbol +--------------- + +An `asymbol' has the form: +. + typedef struct symbol_cache_entry + { + /* A pointer to the BFD which owns the symbol. This information + is necessary so that a back end can work out what additional + information (invisible to the application writer) is carried + with the symbol. + + This field is *almost* redundant, since you can use section->owner + instead, except that some symbols point to the global sections + bfd_{abs,com,und}_section. This could be fixed by making + these globals be per-bfd (or per-target-flavor). FIXME. */ + + struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ + + /* The text of the symbol. The name is left alone, and not copied; the + application may not alter it. */ + CONST char *name; + + /* The value of the symbol. This really should be a union of a + numeric value with a pointer, since some flags indicate that + a pointer to another symbol is stored here. */ + symvalue value; + + /* Attributes of a symbol: */ + + #define BSF_NO_FLAGS 0x00 + + /* The symbol has local scope; `static' in `C'. The value + is the offset into the section of the data. */ + #define BSF_LOCAL 0x01 + + /* The symbol has global scope; initialized data in `C'. The + value is the offset into the section of the data. */ + #define BSF_GLOBAL 0x02 + + /* The symbol has global scope and is exported. The value is + the offset into the section of the data. */ + #define BSF_EXPORT BSF_GLOBAL /* no real difference */ + + /* A normal C symbol would be one of: + `BSF_LOCAL', `BSF_FORT_COMM', `BSF_UNDEFINED' or + `BSF_GLOBAL' */ + + /* The symbol is a debugging record. The value has an arbitary + meaning. */ + #define BSF_DEBUGGING 0x08 + + /* The symbol denotes a function entry point. Used in ELF, + perhaps others someday. */ + #define BSF_FUNCTION 0x10 + + /* Used by the linker. */ + #define BSF_KEEP 0x20 + #define BSF_KEEP_G 0x40 + + /* A weak global symbol, overridable without warnings by + a regular global symbol of the same name. */ + #define BSF_WEAK 0x80 + + /* This symbol was created to point to a section, e.g. ELF's + STT_SECTION symbols. */ + #define BSF_SECTION_SYM 0x100 + + /* The symbol used to be a common symbol, but now it is + allocated. */ + #define BSF_OLD_COMMON 0x200 + + /* The default value for common data. */ + #define BFD_FORT_COMM_DEFAULT_VALUE 0 + + /* In some files the type of a symbol sometimes alters its + location in an output file - ie in coff a `ISFCN' symbol + which is also `C_EXT' symbol appears where it was + declared and not at the end of a section. This bit is set + by the target BFD part to convey this information. */ + + #define BSF_NOT_AT_END 0x400 + + /* Signal that the symbol is the label of constructor section. */ + #define BSF_CONSTRUCTOR 0x800 + + /* Signal that the symbol is a warning symbol. The name is a + warning. The name of the next symbol is the one to warn about; + if a reference is made to a symbol with the same name as the next + symbol, a warning is issued by the linker. */ + #define BSF_WARNING 0x1000 + + /* Signal that the symbol is indirect. This symbol is an indirect + pointer to the symbol with the same name as the next symbol. */ + #define BSF_INDIRECT 0x2000 + + /* BSF_FILE marks symbols that contain a file name. This is used + for ELF STT_FILE symbols. */ + #define BSF_FILE 0x4000 + + /* Symbol is from dynamic linking information. */ + #define BSF_DYNAMIC 0x8000 + + /* The symbol denotes a data object. Used in ELF, and perhaps + others someday. */ + #define BSF_OBJECT 0x10000 + + flagword flags; + + /* A pointer to the section to which this symbol is + relative. This will always be non NULL, there are special + sections for undefined and absolute symbols. */ + struct sec *section; + + /* Back end special data. */ + union + { + PTR p; + bfd_vma i; + } udata; + + } asymbol; + + +File: bfd.info, Node: symbol handling functions, Prev: typedef asymbol, Up: Symbols + +Symbol handling functions +------------------------- + +`bfd_get_symtab_upper_bound' +............................ + +*Description* +Return the number of bytes required to store a vector of pointers to +`asymbols' for all the symbols in the BFD ABFD, including a terminal +NULL pointer. If there are no symbols in the BFD, then return 0. If an +error occurs, return -1. + #define bfd_get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) + +`bfd_is_local_label' +.................... + +*Synopsis* + boolean bfd_is_local_label(bfd *abfd, asymbol *sym); + *Description* +Return true if the given symbol SYM in the BFD ABFD is a compiler +generated local label, else return false. +`bfd_is_local_label_name' +......................... + +*Synopsis* + boolean bfd_is_local_label_name(bfd *abfd, const char *name); + *Description* +Return true if a symbol with the name NAME in the BFD ABFD is a +compiler generated local label, else return false. This just checks +whether the name has the form of a local label. + #define bfd_is_local_label_name(abfd, name) \ + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) + +`bfd_canonicalize_symtab' +......................... + +*Description* +Read the symbols from the BFD ABFD, and fills in the vector LOCATION +with pointers to the symbols and a trailing NULL. Return the actual +number of symbol pointers, not including the NULL. + #define bfd_canonicalize_symtab(abfd, location) \ + BFD_SEND (abfd, _bfd_canonicalize_symtab,\ + (abfd, location)) + +`bfd_set_symtab' +................ + +*Synopsis* + boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count); + *Description* +Arrange that when the output BFD ABFD is closed, the table LOCATION of +COUNT pointers to symbols will be written. +`bfd_print_symbol_vandf' +........................ + +*Synopsis* + void bfd_print_symbol_vandf(PTR file, asymbol *symbol); + *Description* +Print the value and flags of the SYMBOL supplied to the stream FILE. +`bfd_make_empty_symbol' +....................... + +*Description* +Create a new `asymbol' structure for the BFD ABFD and return a pointer +to it. + + This routine is necessary because each back end has private +information surrounding the `asymbol'. Building your own `asymbol' and +pointing to it will not create the private information, and will cause +problems later on. + #define bfd_make_empty_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) + +`bfd_make_debug_symbol' +....................... + +*Description* +Create a new `asymbol' structure for the BFD ABFD, to be used as a +debugging symbol. Further details of its use have yet to be worked out. + #define bfd_make_debug_symbol(abfd,ptr,size) \ + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) + +`bfd_decode_symclass' +..................... + +*Description* +Return a character corresponding to the symbol class of SYMBOL, or '?' +for an unknown class. +*Synopsis* + int bfd_decode_symclass(asymbol *symbol); + +`bfd_symbol_info' +................. + + *Description* +Fill in the basic info about symbol that nm needs. Additional info may +be added by the back-ends after calling this function. +*Synopsis* + void bfd_symbol_info(asymbol *symbol, symbol_info *ret); + +`bfd_copy_private_symbol_data' +.............................. + + *Synopsis* + boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); + *Description* +Copy private symbol information from ISYM in the BFD IBFD to the symbol +OSYM in the BFD OBFD. Return `true' on success, `false' on error. +Possible error returns are: + + * `bfd_error_no_memory' - Not enough memory exists to create private + data for OSEC. + #define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ + (ibfd, isymbol, obfd, osymbol)) + + +File: bfd.info, Node: Archives, Next: Formats, Prev: Symbols, Up: BFD front end + +Archives +======== + +*Description* +An archive (or library) is just another BFD. It has a symbol table, +although there's not much a user program will do with it. + + The big difference between an archive BFD and an ordinary BFD is +that the archive doesn't have sections. Instead it has a chain of BFDs +that are considered its contents. These BFDs can be manipulated like +any other. The BFDs contained in an archive opened for reading will +all be opened for reading. You may put either input or output BFDs +into an archive opened for output; they will be handled correctly when +the archive is closed. + + Use `bfd_openr_next_archived_file' to step through the contents of +an archive opened for input. You don't have to read the entire archive +if you don't want to! Read it until you find what you want. + + Archive contents of output BFDs are chained through the `next' +pointer in a BFD. The first one is findable through the `archive_head' +slot of the archive. Set it with `bfd_set_archive_head' (q.v.). A +given BFD may be in only one open output archive at a time. + + As expected, the BFD archive code is more general than the archive +code of any given environment. BFD archives may contain files of +different formats (e.g., a.out and coff) and even different +architectures. You may even place archives recursively into archives! + + This can cause unexpected confusion, since some archive formats are +more expressive than others. For instance, Intel COFF archives can +preserve long filenames; SunOS a.out archives cannot. If you move a +file from the first to the second format and back again, the filename +may be truncated. Likewise, different a.out environments have different +conventions as to how they truncate filenames, whether they preserve +directory names in filenames, etc. When interoperating with native +tools, be sure your files are homogeneous. + + Beware: most of these formats do not react well to the presence of +spaces in filenames. We do the best we can, but can't always handle +this case due to restrictions in the format of archives. Many Unix +utilities are braindead in regards to spaces and such in filenames +anyway, so this shouldn't be much of a restriction. + + Archives are supported in BFD in `archive.c'. +`bfd_get_next_mapent' +..................... + +*Synopsis* + symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym); + *Description* +Step through archive ABFD's symbol table (if it has one). Successively +update SYM with the next symbol's information, returning that symbol's +(internal) index into the symbol table. + + Supply `BFD_NO_MORE_SYMBOLS' as the PREVIOUS entry to get the first +one; returns `BFD_NO_MORE_SYMBOLS' when you've already got the last one. + + A `carsym' is a canonical archive symbol. The only user-visible +element is its name, a null-terminated string. +`bfd_set_archive_head' +...................... + +*Synopsis* + boolean bfd_set_archive_head(bfd *output, bfd *new_head); + *Description* +Set the head of the chain of BFDs contained in the archive OUTPUT to +NEW_HEAD. +`bfd_openr_next_archived_file' +.............................. + +*Synopsis* + bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous); + *Description* +Provided a BFD, ARCHIVE, containing an archive and NULL, open an input +BFD on the first contained element and returns that. Subsequent calls +should pass the archive and the previous return value to return a +created BFD to the next contained element. NULL is returned when there +are no more. + +File: bfd.info, Node: Formats, Next: Relocations, Prev: Archives, Up: BFD front end + +File formats +============ + +A format is a BFD concept of high level file contents type. The formats +supported by BFD are: + + * `bfd_object' The BFD may contain data, symbols, relocations and +debug info. + + * `bfd_archive' The BFD contains other BFDs and an optional index. + + * `bfd_core' The BFD contains the result of an executable core dump. +`bfd_check_format' +.................. + +*Synopsis* + boolean bfd_check_format(bfd *abfd, bfd_format format); + *Description* +Verify if the file attached to the BFD ABFD is compatible with the +format FORMAT (i.e., one of `bfd_object', `bfd_archive' or `bfd_core'). + + If the BFD has been set to a specific target before the call, only +the named target and format combination is checked. If the target has +not been set, or has been set to `default', then all the known target +backends is interrogated to determine a match. If the default target +matches, it is used. If not, exactly one target must recognize the +file, or an error results. + + The function returns `true' on success, otherwise `false' with one +of the following error codes: + + * `bfd_error_invalid_operation' - if `format' is not one of + `bfd_object', `bfd_archive' or `bfd_core'. + + * `bfd_error_system_call' - if an error occured during a read - even + some file mismatches can cause bfd_error_system_calls. + + * `file_not_recognised' - none of the backends recognised the file + format. + + * `bfd_error_file_ambiguously_recognized' - more than one backend + recognised the file format. +`bfd_check_format_matches' +.......................... + +*Synopsis* + boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching); + *Description* +Like `bfd_check_format', except when it returns false with `bfd_errno' +set to `bfd_error_file_ambiguously_recognized'. In that case, if +MATCHING is not NULL, it will be filled in with a NULL-terminated list +of the names of the formats that matched, allocated with `malloc'. +Then the user may choose a format and try again. + + When done with the list that MATCHING points to, the caller should +free it. +`bfd_set_format' +................ + +*Synopsis* + boolean bfd_set_format(bfd *abfd, bfd_format format); + *Description* +This function sets the file format of the BFD ABFD to the format +FORMAT. If the target set in the BFD does not support the format +requested, the format is invalid, or the BFD is not open for writing, +then an error occurs. +`bfd_format_string' +................... + +*Synopsis* + CONST char *bfd_format_string(bfd_format format); + *Description* +Return a pointer to a const string `invalid', `object', `archive', +`core', or `unknown', depending upon the value of FORMAT. + +File: bfd.info, Node: Relocations, Next: Core Files, Prev: Formats, Up: BFD front end + +Relocations +=========== + +BFD maintains relocations in much the same way it maintains symbols: +they are left alone until required, then read in en-mass and translated +into an internal form. A common routine `bfd_perform_relocation' acts +upon the canonical form to do the fixup. + + Relocations are maintained on a per section basis, while symbols are +maintained on a per BFD basis. + + All that a back end has to do to fit the BFD interface is to create +a `struct reloc_cache_entry' for each relocation in a particular +section, and fill in the right bits of the structures. + +* Menu: + +* typedef arelent:: +* howto manager:: + + +File: bfd.info, Node: typedef arelent, Next: howto manager, Prev: Relocations, Up: Relocations + +typedef arelent +--------------- + +This is the structure of a relocation entry: +. + typedef enum bfd_reloc_status + { + /* No errors detected */ + bfd_reloc_ok, + + /* The relocation was performed, but there was an overflow. */ + bfd_reloc_overflow, + + /* The address to relocate was not within the section supplied. */ + bfd_reloc_outofrange, + + /* Used by special functions */ + bfd_reloc_continue, + + /* Unsupported relocation size requested. */ + bfd_reloc_notsupported, + + /* Unused */ + bfd_reloc_other, + + /* The symbol to relocate against was undefined. */ + bfd_reloc_undefined, + + /* The relocation was performed, but may not be ok - presently + generated only when linking i960 coff files with i960 b.out + symbols. If this type is returned, the error_message argument + to bfd_perform_relocation will be set. */ + bfd_reloc_dangerous + } + bfd_reloc_status_type; + + + typedef struct reloc_cache_entry + { + /* A pointer into the canonical table of pointers */ + struct symbol_cache_entry **sym_ptr_ptr; + + /* offset in section */ + bfd_size_type address; + + /* addend for relocation value */ + bfd_vma addend; + + /* Pointer to how to perform the required relocation */ + reloc_howto_type *howto; + + } arelent; + *Description* +Here is a description of each of the fields within an `arelent': + + * `sym_ptr_ptr' The symbol table pointer points to a pointer to the +symbol associated with the relocation request. It is the pointer into +the table returned by the back end's `get_symtab' action. *Note +Symbols::. The symbol is referenced through a pointer to a pointer so +that tools like the linker can fix up all the symbols of the same name +by modifying only one pointer. The relocation routine looks in the +symbol and uses the base of the section the symbol is attached to and +the value of the symbol as the initial relocation offset. If the symbol +pointer is zero, then the section provided is looked up. + + * `address' The `address' field gives the offset in bytes from the +base of the section data which owns the relocation record to the first +byte of relocatable information. The actual data relocated will be +relative to this point; for example, a relocation type which modifies +the bottom two bytes of a four byte word would not touch the first byte +pointed to in a big endian world. + + * `addend' The `addend' is a value provided by the back end to be +added (!) to the relocation offset. Its interpretation is dependent upon +the howto. For example, on the 68k the code: + + char foo[]; + main() + { + return foo[0x12345678]; + } + + Could be compiled into: + + linkw fp,#-4 + moveb @#12345678,d0 + extbl d0 + unlk fp + rts + + This could create a reloc pointing to `foo', but leave the offset in +the data, something like: + + RELOCATION RECORDS FOR [.text]: + offset type value + 00000006 32 _foo + + 00000000 4e56 fffc ; linkw fp,#-4 + 00000004 1039 1234 5678 ; moveb @#12345678,d0 + 0000000a 49c0 ; extbl d0 + 0000000c 4e5e ; unlk fp + 0000000e 4e75 ; rts + + Using coff and an 88k, some instructions don't have enough space in +them to represent the full address range, and pointers have to be +loaded in two parts. So you'd get something like: + + or.u r13,r0,hi16(_foo+0x12345678) + ld.b r2,r13,lo16(_foo+0x12345678) + jmp r1 + + This should create two relocs, both pointing to `_foo', and with +0x12340000 in their addend field. The data would consist of: + + RELOCATION RECORDS FOR [.text]: + offset type value + 00000002 HVRT16 _foo+0x12340000 + 00000006 LVRT16 _foo+0x12340000 + + 00000000 5da05678 ; or.u r13,r0,0x5678 + 00000004 1c4d5678 ; ld.b r2,r13,0x5678 + 00000008 f400c001 ; jmp r1 + + The relocation routine digs out the value from the data, adds it to +the addend to get the original offset, and then adds the value of +`_foo'. Note that all 32 bits have to be kept around somewhere, to cope +with carry from bit 15 to bit 16. + + One further example is the sparc and the a.out format. The sparc has +a similar problem to the 88k, in that some instructions don't have room +for an entire offset, but on the sparc the parts are created in odd +sized lumps. The designers of the a.out format chose to not use the +data within the section for storing part of the offset; all the offset +is kept within the reloc. Anything in the data should be ignored. + + save %sp,-112,%sp + sethi %hi(_foo+0x12345678),%g2 + ldsb [%g2+%lo(_foo+0x12345678)],%i0 + ret + restore + + Both relocs contain a pointer to `foo', and the offsets contain junk. + + RELOCATION RECORDS FOR [.text]: + offset type value + 00000004 HI22 _foo+0x12345678 + 00000008 LO10 _foo+0x12345678 + + 00000000 9de3bf90 ; save %sp,-112,%sp + 00000004 05000000 ; sethi %hi(_foo+0),%g2 + 00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 + 0000000c 81c7e008 ; ret + 00000010 81e80000 ; restore + + * `howto' The `howto' field can be imagined as a relocation +instruction. It is a pointer to a structure which contains information +on what to do with all of the other information in the reloc record and +data section. A back end would normally have a relocation instruction +set and turn relocations into pointers to the correct structure on +input - but it would be possible to create each howto field on demand. +`enum complain_overflow' +........................ + +Indicates what sort of overflow checking should be done when performing +a relocation. +. + enum complain_overflow + { + /* Do not complain on overflow. */ + complain_overflow_dont, + + /* Complain if the bitfield overflows, whether it is considered + as signed or unsigned. */ + complain_overflow_bitfield, + + /* Complain if the value overflows when considered as signed + number. */ + complain_overflow_signed, + + /* Complain if the value overflows when considered as an + unsigned number. */ + complain_overflow_unsigned + }; + +`reloc_howto_type' +.................. + + The `reloc_howto_type' is a structure which contains all the +information that libbfd needs to know to tie up a back end's data. +.struct symbol_cache_entry; /* Forward declaration */ + + struct reloc_howto_struct + { + /* The type field has mainly a documentary use - the back end can + do what it wants with it, though normally the back end's + external idea of what a reloc number is stored + in this field. For example, a PC relative word relocation + in a coff environment has the type 023 - because that's + what the outside world calls a R_PCRWORD reloc. */ + unsigned int type; + + /* The value the final relocation is shifted right by. This drops + unwanted data from the relocation. */ + unsigned int rightshift; + + /* The size of the item to be relocated. This is *not* a + power-of-two measure. To get the number of bytes operated + on by a type of relocation, use bfd_get_reloc_size. */ + int size; + + /* The number of bits in the item to be relocated. This is used + when doing overflow checking. */ + unsigned int bitsize; + + /* Notes that the relocation is relative to the location in the + data section of the addend. The relocation function will + subtract from the relocation value the address of the location + being relocated. */ + boolean pc_relative; + + /* The bit position of the reloc value in the destination. + The relocated value is left shifted by this amount. */ + unsigned int bitpos; + + /* What type of overflow error should be checked for when + relocating. */ + enum complain_overflow complain_on_overflow; + + /* If this field is non null, then the supplied function is + called rather than the normal function. This allows really + strange relocation methods to be accomodated (e.g., i960 callj + instructions). */ + bfd_reloc_status_type (*special_function) + PARAMS ((bfd *abfd, + arelent *reloc_entry, + struct symbol_cache_entry *symbol, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message)); + + /* The textual name of the relocation type. */ + char *name; + + /* When performing a partial link, some formats must modify the + relocations rather than the data - this flag signals this.*/ + boolean partial_inplace; + + /* The src_mask selects which parts of the read in data + are to be used in the relocation sum. E.g., if this was an 8 bit + bit of data which we read and relocated, this would be + 0x000000ff. When we have relocs which have an addend, such as + sun4 extended relocs, the value in the offset part of a + relocating field is garbage so we never use it. In this case + the mask would be 0x00000000. */ + bfd_vma src_mask; + + /* The dst_mask selects which parts of the instruction are replaced + into the instruction. In most cases src_mask == dst_mask, + except in the above special case, where dst_mask would be + 0x000000ff, and src_mask would be 0x00000000. */ + bfd_vma dst_mask; + + /* When some formats create PC relative instructions, they leave + the value of the pc of the place being relocated in the offset + slot of the instruction, so that a PC relative relocation can + be made just by adding in an ordinary offset (e.g., sun3 a.out). + Some formats leave the displacement part of an instruction + empty (e.g., m88k bcs); this flag signals the fact.*/ + boolean pcrel_offset; + + }; + +`The HOWTO Macro' +................. + + *Description* +The HOWTO define is horrible and will go away. + #define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ + {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} + +*Description* +And will be replaced with the totally magic way. But for the moment, we +are compatible, so do it this way. + #define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) + +*Description* +Helper routine to turn a symbol into a relocation value. + #define HOWTO_PREPARE(relocation, symbol) \ + { \ + if (symbol != (asymbol *)NULL) { \ + if (bfd_is_com_section (symbol->section)) { \ + relocation = 0; \ + } \ + else { \ + relocation = symbol->value; \ + } \ + } \ + } + +`bfd_get_reloc_size' +.................... + +*Synopsis* + int bfd_get_reloc_size (reloc_howto_type *); + *Description* +For a reloc_howto_type that operates on a fixed number of bytes, this +returns the number of bytes operated on. +`arelent_chain' +............... + +*Description* +How relocs are tied together in an `asection': + typedef struct relent_chain { + arelent relent; + struct relent_chain *next; + } arelent_chain; + +`bfd_perform_relocation' +........................ + +*Synopsis* + bfd_reloc_status_type + bfd_perform_relocation + (bfd *abfd, + arelent *reloc_entry, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message); + *Description* +If OUTPUT_BFD is supplied to this function, the generated image will be +relocatable; the relocations are copied to the output file after they +have been changed to reflect the new state of the world. There are two +ways of reflecting the results of partial linkage in an output file: by +modifying the output data in place, and by modifying the relocation +record. Some native formats (e.g., basic a.out and basic coff) have no +way of specifying an addend in the relocation type, so the addend has +to go in the output data. This is no big deal since in these formats +the output data slot will always be big enough for the addend. Complex +reloc types with addends were invented to solve just this problem. The +ERROR_MESSAGE argument is set to an error message if this return +`bfd_reloc_dangerous'. +`bfd_install_relocation' +........................ + +*Synopsis* + bfd_reloc_status_type + bfd_install_relocation + (bfd *abfd, + arelent *reloc_entry, + PTR data, bfd_vma data_start, + asection *input_section, + char **error_message); + *Description* +This looks remarkably like `bfd_perform_relocation', except it does not +expect that the section contents have been filled in. I.e., it's +suitable for use when creating, rather than applying a relocation. + + For now, this function should be considered reserved for the +assembler. diff -urN binutils-2.7/bfd/doc/bfd.info-3 binutils-2.8/bfd/doc/bfd.info-3 --- binutils-2.7/bfd/doc/bfd.info-3 Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.info-3 Wed Apr 30 13:14:27 1997 @@ -0,0 +1,1322 @@ +This is Info file bfd.info, produced by Makeinfo-1.64 from the input +file ./bfd.texinfo. + +START-INFO-DIR-ENTRY +* Bfd: (bfd). The Binary File Descriptor library. +END-INFO-DIR-ENTRY + + This file documents the BFD library. + + Copyright (C) 1991 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, subject to the +terms of the GNU General Public License, which includes the provision +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: bfd.info, Node: howto manager, Prev: typedef arelent, Up: Relocations + +The howto manager +================= + +When an application wants to create a relocation, but doesn't know what +the target machine might call it, it can find out by using this bit of +code. +`bfd_reloc_code_type' +..................... + +*Description* +The insides of a reloc code. The idea is that, eventually, there will +be one enumerator for every type of relocation we ever do. Pass one of +these values to `bfd_reloc_type_lookup', and it'll return a howto +pointer. + + This does mean that the application must determine the correct +enumerator value; you can't get a howto pointer from a random set of +attributes. +Here are the possible values for `enum bfd_reloc_code_real': + + - : BFD_RELOC_64 + - : BFD_RELOC_32 + - : BFD_RELOC_26 + - : BFD_RELOC_24 + - : BFD_RELOC_16 + - : BFD_RELOC_14 + - : BFD_RELOC_8 + Basic absolute relocations of N bits. + + - : BFD_RELOC_64_PCREL + - : BFD_RELOC_32_PCREL + - : BFD_RELOC_24_PCREL + - : BFD_RELOC_16_PCREL + - : BFD_RELOC_12_PCREL + - : BFD_RELOC_8_PCREL + PC-relative relocations. Sometimes these are relative to the + address of the relocation itself; sometimes they are relative to + the start of the section containing the relocation. It depends on + the specific target. + + The 24-bit relocation is used in some Intel 960 configurations. + + - : BFD_RELOC_32_GOT_PCREL + - : BFD_RELOC_16_GOT_PCREL + - : BFD_RELOC_8_GOT_PCREL + - : BFD_RELOC_32_GOTOFF + - : BFD_RELOC_16_GOTOFF + - : BFD_RELOC_LO16_GOTOFF + - : BFD_RELOC_HI16_GOTOFF + - : BFD_RELOC_HI16_S_GOTOFF + - : BFD_RELOC_8_GOTOFF + - : BFD_RELOC_32_PLT_PCREL + - : BFD_RELOC_24_PLT_PCREL + - : BFD_RELOC_16_PLT_PCREL + - : BFD_RELOC_8_PLT_PCREL + - : BFD_RELOC_32_PLTOFF + - : BFD_RELOC_16_PLTOFF + - : BFD_RELOC_LO16_PLTOFF + - : BFD_RELOC_HI16_PLTOFF + - : BFD_RELOC_HI16_S_PLTOFF + - : BFD_RELOC_8_PLTOFF + For ELF. + + - : BFD_RELOC_68K_GLOB_DAT + - : BFD_RELOC_68K_JMP_SLOT + - : BFD_RELOC_68K_RELATIVE + Relocations used by 68K ELF. + + - : BFD_RELOC_32_BASEREL + - : BFD_RELOC_16_BASEREL + - : BFD_RELOC_LO16_BASEREL + - : BFD_RELOC_HI16_BASEREL + - : BFD_RELOC_HI16_S_BASEREL + - : BFD_RELOC_8_BASEREL + - : BFD_RELOC_RVA + Linkage-table relative. + + - : BFD_RELOC_8_FFnn + Absolute 8-bit relocation, but used to form an address like 0xFFnn. + + - : BFD_RELOC_32_PCREL_S2 + - : BFD_RELOC_16_PCREL_S2 + - : BFD_RELOC_23_PCREL_S2 + These PC-relative relocations are stored as word displacements - + i.e., byte displacements shifted right two bits. The 30-bit word + displacement (<<32_PCREL_S2>> - 32 bits, shifted 2) is used on the + SPARC. (SPARC tools generally refer to this as <>.) The + signed 16-bit displacement is used on the MIPS, and the 23-bit + displacement is used on the Alpha. + + - : BFD_RELOC_HI22 + - : BFD_RELOC_LO10 + High 22 bits and low 10 bits of 32-bit value, placed into lower + bits of the target word. These are used on the SPARC. + + - : BFD_RELOC_GPREL16 + - : BFD_RELOC_GPREL32 + For systems that allocate a Global Pointer register, these are + displacements off that register. These relocation types are + handled specially, because the value the register will have is + decided relatively late. + + - : BFD_RELOC_I960_CALLJ + Reloc types used for i960/b.out. + + - : BFD_RELOC_NONE + - : BFD_RELOC_SPARC_WDISP22 + - : BFD_RELOC_SPARC22 + - : BFD_RELOC_SPARC13 + - : BFD_RELOC_SPARC_GOT10 + - : BFD_RELOC_SPARC_GOT13 + - : BFD_RELOC_SPARC_GOT22 + - : BFD_RELOC_SPARC_PC10 + - : BFD_RELOC_SPARC_PC22 + - : BFD_RELOC_SPARC_WPLT30 + - : BFD_RELOC_SPARC_COPY + - : BFD_RELOC_SPARC_GLOB_DAT + - : BFD_RELOC_SPARC_JMP_SLOT + - : BFD_RELOC_SPARC_RELATIVE + - : BFD_RELOC_SPARC_UA32 + SPARC ELF relocations. There is probably some overlap with other + relocation types already defined. + + - : BFD_RELOC_SPARC_BASE13 + - : BFD_RELOC_SPARC_BASE22 + I think these are specific to SPARC a.out (e.g., Sun 4). + + - : BFD_RELOC_SPARC_64 + - : BFD_RELOC_SPARC_10 + - : BFD_RELOC_SPARC_11 + - : BFD_RELOC_SPARC_OLO10 + - : BFD_RELOC_SPARC_HH22 + - : BFD_RELOC_SPARC_HM10 + - : BFD_RELOC_SPARC_LM22 + - : BFD_RELOC_SPARC_PC_HH22 + - : BFD_RELOC_SPARC_PC_HM10 + - : BFD_RELOC_SPARC_PC_LM22 + - : BFD_RELOC_SPARC_WDISP16 + - : BFD_RELOC_SPARC_WDISP19 + - : BFD_RELOC_SPARC_GLOB_JMP + - : BFD_RELOC_SPARC_7 + - : BFD_RELOC_SPARC_6 + - : BFD_RELOC_SPARC_5 + Some relocations we're using for SPARC V9 - subject to change. + + - : BFD_RELOC_ALPHA_GPDISP_HI16 + Alpha ECOFF and ELF relocations. Some of these treat the symbol or + "addend" in some special way. For GPDISP_HI16 ("gpdisp") + relocations, the symbol is ignored when writing; when reading, it + will be the absolute section symbol. The addend is the + displacement in bytes of the "lda" instruction from the "ldah" + instruction (which is at the address of this reloc). + + - : BFD_RELOC_ALPHA_GPDISP_LO16 + For GPDISP_LO16 ("ignore") relocations, the symbol is handled as + with GPDISP_HI16 relocs. The addend is ignored when writing the + relocations out, and is filled in with the file's GP value on + reading, for convenience. + + - : BFD_RELOC_ALPHA_GPDISP + The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 + relocation except that there is no accompanying GPDISP_LO16 + relocation. + + - : BFD_RELOC_ALPHA_LITERAL + - : BFD_RELOC_ALPHA_ELF_LITERAL + - : BFD_RELOC_ALPHA_LITUSE + The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; + the assembler turns it into a LDQ instruction to load the address + of the symbol, and then fills in a register in the real + instruction. + + The LITERAL reloc, at the LDQ instruction, refers to the .lita + section symbol. The addend is ignored when writing, but is filled + in with the file's GP value on reading, for convenience, as with + the GPDISP_LO16 reloc. + + The ELF_LITERAL reloc is somewhere between 16_GOTOFF and + GPDISP_LO16. It should refer to the symbol to be referenced, as + with 16_GOTOFF, but it generates output not based on the position + within the .got section, but relative to the GP value chosen for + the file during the final link stage. + + The LITUSE reloc, on the instruction using the loaded address, + gives information to the linker that it might be able to use to + optimize away some literal section references. The symbol is + ignored (read as the absolute section symbol), and the "addend" + indicates the type of instruction using the register: 1 - "memory" + fmt insn 2 - byte-manipulation (byte offset reg) 3 - jsr (target + of branch) + + The GNU linker currently doesn't do any of this optimizing. + + - : BFD_RELOC_ALPHA_HINT + The HINT relocation indicates a value that should be filled into + the "hint" field of a jmp/jsr/ret instruction, for possible branch- + prediction logic which may be provided on some processors. + + - : BFD_RELOC_ALPHA_LINKAGE + The LINKAGE relocation outputs a linkage pair in the object file, + which is filled by the linker. + + - : BFD_RELOC_ALPHA_CODEADDR + The CODEADDR relocation outputs a STO_CA in the object file, which + is filled by the linker. + + - : BFD_RELOC_MIPS_JMP + Bits 27..2 of the relocation address shifted right 2 bits; simple + reloc otherwise. + + - : BFD_RELOC_MIPS16_JMP + The MIPS16 jump instruction. + + - : BFD_RELOC_MIPS16_GPREL + MIPS16 GP relative reloc. + + - : BFD_RELOC_HI16 + High 16 bits of 32-bit value; simple reloc. + + - : BFD_RELOC_HI16_S + High 16 bits of 32-bit value but the low 16 bits will be sign + extended and added to form the final result. If the low 16 bits + form a negative number, we need to add one to the high value to + compensate for the borrow when the low bits are added. + + - : BFD_RELOC_LO16 + Low 16 bits. + + - : BFD_RELOC_PCREL_HI16_S + Like BFD_RELOC_HI16_S, but PC relative. + + - : BFD_RELOC_PCREL_LO16 + Like BFD_RELOC_LO16, but PC relative. + + - : BFD_RELOC_MIPS_GPREL + Relocation relative to the global pointer. + + - : BFD_RELOC_MIPS_LITERAL + Relocation against a MIPS literal section. + + - : BFD_RELOC_MIPS_GOT16 + - : BFD_RELOC_MIPS_CALL16 + - : BFD_RELOC_MIPS_GPREL32 + - : BFD_RELOC_MIPS_GOT_HI16 + - : BFD_RELOC_MIPS_GOT_LO16 + - : BFD_RELOC_MIPS_CALL_HI16 + - : BFD_RELOC_MIPS_CALL_LO16 + MIPS ELF relocations. + + - : BFD_RELOC_386_GOT32 + - : BFD_RELOC_386_PLT32 + - : BFD_RELOC_386_COPY + - : BFD_RELOC_386_GLOB_DAT + - : BFD_RELOC_386_JUMP_SLOT + - : BFD_RELOC_386_RELATIVE + - : BFD_RELOC_386_GOTOFF + - : BFD_RELOC_386_GOTPC + i386/elf relocations + + - : BFD_RELOC_NS32K_IMM_8 + - : BFD_RELOC_NS32K_IMM_16 + - : BFD_RELOC_NS32K_IMM_32 + - : BFD_RELOC_NS32K_IMM_8_PCREL + - : BFD_RELOC_NS32K_IMM_16_PCREL + - : BFD_RELOC_NS32K_IMM_32_PCREL + - : BFD_RELOC_NS32K_DISP_8 + - : BFD_RELOC_NS32K_DISP_16 + - : BFD_RELOC_NS32K_DISP_32 + - : BFD_RELOC_NS32K_DISP_8_PCREL + - : BFD_RELOC_NS32K_DISP_16_PCREL + - : BFD_RELOC_NS32K_DISP_32_PCREL + ns32k relocations + + - : BFD_RELOC_PPC_B26 + - : BFD_RELOC_PPC_BA26 + - : BFD_RELOC_PPC_TOC16 + - : BFD_RELOC_PPC_B16 + - : BFD_RELOC_PPC_B16_BRTAKEN + - : BFD_RELOC_PPC_B16_BRNTAKEN + - : BFD_RELOC_PPC_BA16 + - : BFD_RELOC_PPC_BA16_BRTAKEN + - : BFD_RELOC_PPC_BA16_BRNTAKEN + - : BFD_RELOC_PPC_COPY + - : BFD_RELOC_PPC_GLOB_DAT + - : BFD_RELOC_PPC_JMP_SLOT + - : BFD_RELOC_PPC_RELATIVE + - : BFD_RELOC_PPC_LOCAL24PC + - : BFD_RELOC_PPC_EMB_NADDR32 + - : BFD_RELOC_PPC_EMB_NADDR16 + - : BFD_RELOC_PPC_EMB_NADDR16_LO + - : BFD_RELOC_PPC_EMB_NADDR16_HI + - : BFD_RELOC_PPC_EMB_NADDR16_HA + - : BFD_RELOC_PPC_EMB_SDAI16 + - : BFD_RELOC_PPC_EMB_SDA2I16 + - : BFD_RELOC_PPC_EMB_SDA2REL + - : BFD_RELOC_PPC_EMB_SDA21 + - : BFD_RELOC_PPC_EMB_MRKREF + - : BFD_RELOC_PPC_EMB_RELSEC16 + - : BFD_RELOC_PPC_EMB_RELST_LO + - : BFD_RELOC_PPC_EMB_RELST_HI + - : BFD_RELOC_PPC_EMB_RELST_HA + - : BFD_RELOC_PPC_EMB_BIT_FLD + - : BFD_RELOC_PPC_EMB_RELSDA + Power(rs6000) and PowerPC relocations. + + - : BFD_RELOC_CTOR + The type of reloc used to build a contructor table - at the moment + probably a 32 bit wide absolute relocation, but the target can + choose. It generally does map to one of the other relocation + types. + + - : BFD_RELOC_ARM_PCREL_BRANCH + ARM 26 bit pc-relative branch. The lowest two bits must be zero + and are not stored in the instruction. + + - : BFD_RELOC_ARM_IMMEDIATE + - : BFD_RELOC_ARM_OFFSET_IMM + - : BFD_RELOC_ARM_SHIFT_IMM + - : BFD_RELOC_ARM_SWI + - : BFD_RELOC_ARM_MULTI + - : BFD_RELOC_ARM_CP_OFF_IMM + - : BFD_RELOC_ARM_ADR_IMM + - : BFD_RELOC_ARM_LDR_IMM + - : BFD_RELOC_ARM_LITERAL + - : BFD_RELOC_ARM_IN_POOL + - : BFD_RELOC_ARM_OFFSET_IMM8 + - : BFD_RELOC_ARM_HWLITERAL + - : BFD_RELOC_ARM_THUMB_ADD + - : BFD_RELOC_ARM_THUMB_IMM + - : BFD_RELOC_ARM_THUMB_SHIFT + - : BFD_RELOC_ARM_THUMB_OFFSET + These relocs are only used within the ARM assembler. They are not + (at present) written to any object files. + + - : BFD_RELOC_SH_PCDISP8BY2 + - : BFD_RELOC_SH_PCDISP12BY2 + - : BFD_RELOC_SH_IMM4 + - : BFD_RELOC_SH_IMM4BY2 + - : BFD_RELOC_SH_IMM4BY4 + - : BFD_RELOC_SH_IMM8 + - : BFD_RELOC_SH_IMM8BY2 + - : BFD_RELOC_SH_IMM8BY4 + - : BFD_RELOC_SH_PCRELIMM8BY2 + - : BFD_RELOC_SH_PCRELIMM8BY4 + - : BFD_RELOC_SH_SWITCH16 + - : BFD_RELOC_SH_SWITCH32 + - : BFD_RELOC_SH_USES + - : BFD_RELOC_SH_COUNT + - : BFD_RELOC_SH_ALIGN + - : BFD_RELOC_SH_CODE + - : BFD_RELOC_SH_DATA + - : BFD_RELOC_SH_LABEL + Hitachi SH relocs. Not all of these appear in object files. + + - : BFD_RELOC_D10V_10_PCREL_R + Mitsubishi D10V relocs. This is a 10-bit reloc with the right 2 + bits assumed to be 0. + + - : BFD_RELOC_D10V_10_PCREL_L + Mitsubishi D10V relocs. This is a 10-bit reloc with the right 2 + bits assumed to be 0. This is the same as the previous reloc + except it is in the left container, i.e., shifted left 15 bits. + + - : BFD_RELOC_D10V_18 + This is an 18-bit reloc with the right 2 bits assumed to be 0. + + - : BFD_RELOC_D10V_18_PCREL + This is an 18-bit reloc with the right 2 bits assumed to be 0. + + - : BFD_RELOC_M32R_24 + Mitsubishi M32R relocs. This is a 24 bit absolute address. + + - : BFD_RELOC_M32R_10_PCREL + This is a 10-bit pc-relative reloc with the right 2 bits assumed + to be 0. + + - : BFD_RELOC_M32R_18_PCREL + This is an 18-bit reloc with the right 2 bits assumed to be 0. + + - : BFD_RELOC_M32R_26_PCREL + This is a 26-bit reloc with the right 2 bits assumed to be 0. + + - : BFD_RELOC_M32R_HI16_ULO + This is a 16-bit reloc containing the high 16 bits of an address + used when the lower 16 bits are treated as unsigned. + + - : BFD_RELOC_M32R_HI16_SLO + This is a 16-bit reloc containing the high 16 bits of an address + used when the lower 16 bits are treated as signed. + + - : BFD_RELOC_M32R_LO16 + This is a 16-bit reloc containing the lower 16 bits of an address. + + - : BFD_RELOC_M32R_SDA16 + This is a 16-bit reloc containing the small data area offset for + use in add3, load, and store instructions. + + - : BFD_RELOC_MN10300_32_PCREL + This is a 32bit pcrel reloc for the mn10300, offset by two bytes + in the instruction. + + - : BFD_RELOC_MN10300_16_PCREL + This is a 16bit pcrel reloc for the mn10300, offset by two bytes + in the instruction. + . + typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; + +`bfd_reloc_type_lookup' +....................... + + *Synopsis* + reloc_howto_type * + bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); + *Description* +Return a pointer to a howto structure which, when invoked, will perform +the relocation CODE on data from the architecture noted. +`bfd_default_reloc_type_lookup' +............................... + +*Synopsis* + reloc_howto_type *bfd_default_reloc_type_lookup + (bfd *abfd, bfd_reloc_code_real_type code); + *Description* +Provides a default relocation lookup routine for any architecture. +`bfd_get_reloc_code_name' +......................... + +*Synopsis* + const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); + *Description* +Provides a printable name for the supplied relocation code. Useful +mainly for printing error messages. +`bfd_generic_relax_section' +........................... + +*Synopsis* + boolean bfd_generic_relax_section + (bfd *abfd, + asection *section, + struct bfd_link_info *, + boolean *); + *Description* +Provides default handling for relaxing for back ends which don't do +relaxing - i.e., does nothing. +`bfd_generic_get_relocated_section_contents' +............................................ + +*Synopsis* + bfd_byte * + bfd_generic_get_relocated_section_contents (bfd *abfd, + struct bfd_link_info *link_info, + struct bfd_link_order *link_order, + bfd_byte *data, + boolean relocateable, + asymbol **symbols); + *Description* +Provides default handling of relocation effort for back ends which +can't be bothered to do it efficiently. + +File: bfd.info, Node: Core Files, Next: Targets, Prev: Relocations, Up: BFD front end + +Core files +========== + +*Description* +These are functions pertaining to core files. +`bfd_core_file_failing_command' +............................... + +*Synopsis* + CONST char *bfd_core_file_failing_command(bfd *abfd); + *Description* +Return a read-only string explaining which program was running when it +failed and produced the core file ABFD. +`bfd_core_file_failing_signal' +.............................. + +*Synopsis* + int bfd_core_file_failing_signal(bfd *abfd); + *Description* +Returns the signal number which caused the core dump which generated +the file the BFD ABFD is attached to. +`core_file_matches_executable_p' +................................ + +*Synopsis* + boolean core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + *Description* +Return `true' if the core file attached to CORE_BFD was generated by a +run of the executable file attached to EXEC_BFD, `false' otherwise. + +File: bfd.info, Node: Targets, Next: Architectures, Prev: Core Files, Up: BFD front end + +Targets +======= + +*Description* +Each port of BFD to a different machine requries the creation of a +target back end. All the back end provides to the root part of BFD is a +structure containing pointers to functions which perform certain low +level operations on files. BFD translates the applications's requests +through a pointer into calls to the back end routines. + + When a file is opened with `bfd_openr', its format and target are +unknown. BFD uses various mechanisms to determine how to interpret the +file. The operations performed are: + + * Create a BFD by calling the internal routine `_bfd_new_bfd', then + call `bfd_find_target' with the target string supplied to + `bfd_openr' and the new BFD pointer. + + * If a null target string was provided to `bfd_find_target', look up + the environment variable `GNUTARGET' and use that as the target + string. + + * If the target string is still `NULL', or the target string is + `default', then use the first item in the target vector as the + target type, and set `target_defaulted' in the BFD to cause + `bfd_check_format' to loop through all the targets. *Note + bfd_target::. *Note Formats::. + + * Otherwise, inspect the elements in the target vector one by one, + until a match on target name is found. When found, use it. + + * Otherwise return the error `bfd_error_invalid_target' to + `bfd_openr'. + + * `bfd_openr' attempts to open the file using `bfd_open_file', and + returns the BFD. Once the BFD has been opened and the target +selected, the file format may be determined. This is done by calling +`bfd_check_format' on the BFD with a suggested format. If +`target_defaulted' has been set, each possible target type is tried to +see if it recognizes the specified format. `bfd_check_format' returns +`true' when the caller guesses right. + +* Menu: + +* bfd_target:: + + +File: bfd.info, Node: bfd_target, Prev: Targets, Up: Targets + +bfd_target +---------- + +*Description* +This structure contains everything that BFD knows about a target. It +includes things like its byte order, name, and which routines to call +to do various operations. + + Every BFD points to a target structure with its `xvec' member. + + The macros below are used to dispatch to functions through the +`bfd_target' vector. They are used in a number of macros further down +in `bfd.h', and are also used when calling various routines by hand +inside the BFD implementation. The ARGLIST argument must be +parenthesized; it contains all the arguments to the called function. + + They make the documentation (more) unpleasant to read, so if someone +wants to fix this and not break the above, please do. + #define BFD_SEND(bfd, message, arglist) \ + ((*((bfd)->xvec->message)) arglist) + + #ifdef DEBUG_BFD_SEND + #undef BFD_SEND + #define BFD_SEND(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + ((*((bfd)->xvec->message)) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) + #endif + For operations which index on the BFD format: + #define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) + + #ifdef DEBUG_BFD_SEND + #undef BFD_SEND_FMT + #define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) + #endif + This is the structure which defines the type of BFD this is. The +`xvec' member of the struct `bfd' itself points here. Each module that +implements access to a different target under BFD, defines one of these. + + FIXME, these names should be rationalised with the names of the +entry points which call them. Too bad we can't have one macro to define +them both! + enum bfd_flavour { + bfd_target_unknown_flavour, + bfd_target_aout_flavour, + bfd_target_coff_flavour, + bfd_target_ecoff_flavour, + bfd_target_elf_flavour, + bfd_target_ieee_flavour, + bfd_target_nlm_flavour, + bfd_target_oasys_flavour, + bfd_target_tekhex_flavour, + bfd_target_srec_flavour, + bfd_target_ihex_flavour, + bfd_target_som_flavour, + bfd_target_os9k_flavour, + bfd_target_versados_flavour, + bfd_target_msdos_flavour, + bfd_target_evax_flavour + }; + + enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN }; + + /* Forward declaration. */ + typedef struct bfd_link_info _bfd_link_info; + + typedef struct bfd_target + { + Identifies the kind of target, e.g., SunOS4, Ultrix, etc. + char *name; + The "flavour" of a back end is a general indication about the +contents of a file. + enum bfd_flavour flavour; + The order of bytes within the data area of a file. + enum bfd_endian byteorder; + The order of bytes within the header parts of a file. + enum bfd_endian header_byteorder; + A mask of all the flags which an executable may have set - from the +set `BFD_NO_FLAGS', `HAS_RELOC', ...`D_PAGED'. + flagword object_flags; + A mask of all the flags which a section may have set - from the set +`SEC_NO_FLAGS', `SEC_ALLOC', ...`SET_NEVER_LOAD'. + flagword section_flags; + The character normally found at the front of a symbol (if any), +perhaps `_'. + char symbol_leading_char; + The pad character for file names within an archive header. + char ar_pad_char; + The maximum number of characters in an archive header. + unsigned short ar_max_namelen; + Entries for byte swapping for data. These are different from the +other entry points, since they don't take a BFD asthe first argument. +Certain other handlers could do the same. + bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *)); + void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *)); + void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *)); + void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *)); + Byte swapping for the headers + bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *)); + Format dependent routines: these are vectors of entry points within +the target vector structure, one for each format to check. + + Check the format of a file being read. Return a `bfd_target *' or +zero. + const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *)); + Set the format of a file being written. + boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *)); + Write cached information into a file being written, at `bfd_close'. + boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *)); + The general target vector. + + /* Generic entry points. */ + #define BFD_JUMP_TABLE_GENERIC(NAME)\ + CAT(NAME,_close_and_cleanup),\ + CAT(NAME,_bfd_free_cached_info),\ + CAT(NAME,_new_section_hook),\ + CAT(NAME,_get_section_contents),\ + CAT(NAME,_get_section_contents_in_window) + + /* Called when the BFD is being closed to do any necessary cleanup. */ + boolean (*_close_and_cleanup) PARAMS ((bfd *)); + /* Ask the BFD to free all cached information. */ + boolean (*_bfd_free_cached_info) PARAMS ((bfd *)); + /* Called when a new section is created. */ + boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr)); + /* Read the contents of a section. */ + boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); + boolean (*_bfd_get_section_contents_in_window) + PARAMS ((bfd *, sec_ptr, bfd_window *, + file_ptr, bfd_size_type)); + + /* Entry points to copy private data. */ + #define BFD_JUMP_TABLE_COPY(NAME)\ + CAT(NAME,_bfd_copy_private_bfd_data),\ + CAT(NAME,_bfd_merge_private_bfd_data),\ + CAT(NAME,_bfd_copy_private_section_data),\ + CAT(NAME,_bfd_copy_private_symbol_data),\ + CAT(NAME,_bfd_set_private_flags),\ + CAT(NAME,_bfd_print_private_bfd_data)\ + /* Called to copy BFD general private data from one object file + to another. */ + boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *)); + /* Called to merge BFD general private data from one object file + to a common output file when linking. */ + boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *)); + /* Called to copy BFD private section data from one object file + to another. */ + boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr, + bfd *, sec_ptr)); + /* Called to copy BFD private symbol data from one symbol + to another. */ + boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *, + bfd *, asymbol *)); + /* Called to set private backend flags */ + boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword)); + + /* Called to print private BFD data */ + boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR)); + + /* Core file entry points. */ + #define BFD_JUMP_TABLE_CORE(NAME)\ + CAT(NAME,_core_file_failing_command),\ + CAT(NAME,_core_file_failing_signal),\ + CAT(NAME,_core_file_matches_executable_p) + char * (*_core_file_failing_command) PARAMS ((bfd *)); + int (*_core_file_failing_signal) PARAMS ((bfd *)); + boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *)); + + /* Archive entry points. */ + #define BFD_JUMP_TABLE_ARCHIVE(NAME)\ + CAT(NAME,_slurp_armap),\ + CAT(NAME,_slurp_extended_name_table),\ + CAT(NAME,_construct_extended_name_table),\ + CAT(NAME,_truncate_arname),\ + CAT(NAME,_write_armap),\ + CAT(NAME,_read_ar_hdr),\ + CAT(NAME,_openr_next_archived_file),\ + CAT(NAME,_get_elt_at_index),\ + CAT(NAME,_generic_stat_arch_elt),\ + CAT(NAME,_update_armap_timestamp) + boolean (*_bfd_slurp_armap) PARAMS ((bfd *)); + boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *)); + boolean (*_bfd_construct_extended_name_table) + PARAMS ((bfd *, char **, bfd_size_type *, const char **)); + void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *)); + boolean (*write_armap) PARAMS ((bfd *arch, + unsigned int elength, + struct orl *map, + unsigned int orl_count, + int stridx)); + PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *)); + bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev)); + #define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i)) + bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex)); + int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *)); + boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *)); + + /* Entry points used for symbols. */ + #define BFD_JUMP_TABLE_SYMBOLS(NAME)\ + CAT(NAME,_get_symtab_upper_bound),\ + CAT(NAME,_get_symtab),\ + CAT(NAME,_make_empty_symbol),\ + CAT(NAME,_print_symbol),\ + CAT(NAME,_get_symbol_info),\ + CAT(NAME,_bfd_is_local_label_name),\ + CAT(NAME,_get_lineno),\ + CAT(NAME,_find_nearest_line),\ + CAT(NAME,_bfd_make_debug_symbol),\ + CAT(NAME,_read_minisymbols),\ + CAT(NAME,_minisymbol_to_symbol) + long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); + long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, + struct symbol_cache_entry **)); + struct symbol_cache_entry * + (*_bfd_make_empty_symbol) PARAMS ((bfd *)); + void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, + struct symbol_cache_entry *, + bfd_print_symbol_type)); + #define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) + void (*_bfd_get_symbol_info) PARAMS ((bfd *, + struct symbol_cache_entry *, + symbol_info *)); + #define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e)) + boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *)); + + alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *)); + boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd, + struct sec *section, struct symbol_cache_entry **symbols, + bfd_vma offset, CONST char **file, CONST char **func, + unsigned int *line)); + /* Back-door to allow format-aware applications to create debug symbols + while using BFD for everything else. Currently used by the assembler + when creating COFF files. */ + asymbol * (*_bfd_make_debug_symbol) PARAMS (( + bfd *abfd, + void *ptr, + unsigned long size)); + #define bfd_read_minisymbols(b, d, m, s) \ + BFD_SEND (b, _read_minisymbols, (b, d, m, s)) + long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *, + unsigned int *)); + #define bfd_minisymbol_to_symbol(b, d, m, f) \ + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) + asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR, + asymbol *)); + + /* Routines for relocs. */ + #define BFD_JUMP_TABLE_RELOCS(NAME)\ + CAT(NAME,_get_reloc_upper_bound),\ + CAT(NAME,_canonicalize_reloc),\ + CAT(NAME,_bfd_reloc_type_lookup) + long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); + long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, + struct symbol_cache_entry **)); + /* See documentation on reloc types. */ + reloc_howto_type * + (*reloc_type_lookup) PARAMS ((bfd *abfd, + bfd_reloc_code_real_type code)); + + /* Routines used when writing an object file. */ + #define BFD_JUMP_TABLE_WRITE(NAME)\ + CAT(NAME,_set_arch_mach),\ + CAT(NAME,_set_section_contents) + boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture, + unsigned long)); + boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); + + /* Routines used by the linker. */ + #define BFD_JUMP_TABLE_LINK(NAME)\ + CAT(NAME,_sizeof_headers),\ + CAT(NAME,_bfd_get_relocated_section_contents),\ + CAT(NAME,_bfd_relax_section),\ + CAT(NAME,_bfd_link_hash_table_create),\ + CAT(NAME,_bfd_link_add_symbols),\ + CAT(NAME,_bfd_final_link),\ + CAT(NAME,_bfd_link_split_section) + int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); + bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *, + struct bfd_link_info *, struct bfd_link_order *, + bfd_byte *data, boolean relocateable, + struct symbol_cache_entry **)); + + boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *, + struct bfd_link_info *, boolean *again)); + + /* Create a hash table for the linker. Different backends store + different information in this table. */ + struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); + + /* Add symbols from this object file into the hash table. */ + boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Do a link based on the link_order structures attached to each + section of the BFD. */ + boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Should this section be split up into smaller pieces during linking. */ + boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *)); + + /* Routines to handle dynamic symbols and relocs. */ + #define BFD_JUMP_TABLE_DYNAMIC(NAME)\ + CAT(NAME,_get_dynamic_symtab_upper_bound),\ + CAT(NAME,_canonicalize_dynamic_symtab),\ + CAT(NAME,_get_dynamic_reloc_upper_bound),\ + CAT(NAME,_canonicalize_dynamic_reloc) + /* Get the amount of memory required to hold the dynamic symbols. */ + long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *)); + /* Read in the dynamic symbols. */ + long (*_bfd_canonicalize_dynamic_symtab) + PARAMS ((bfd *, struct symbol_cache_entry **)); + /* Get the amount of memory required to hold the dynamic relocs. */ + long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *)); + /* Read in the dynamic relocs. */ + long (*_bfd_canonicalize_dynamic_reloc) + PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); + Data for use by back-end routines, which isn't generic enough to +belong in this structure. + PTR backend_data; + } bfd_target; + +`bfd_set_default_target' +........................ + +*Synopsis* + boolean bfd_set_default_target (const char *name); + *Description* +Set the default target vector to use when recognizing a BFD. This +takes the name of the target, which may be a BFD target name or a +configuration triplet. +`bfd_find_target' +................. + +*Synopsis* + const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd); + *Description* +Return a pointer to the transfer vector for the object target named +TARGET_NAME. If TARGET_NAME is `NULL', choose the one in the +environment variable `GNUTARGET'; if that is null or not defined, then +choose the first entry in the target list. Passing in the string +"default" or setting the environment variable to "default" will cause +the first entry in the target list to be returned, and +"target_defaulted" will be set in the BFD. This causes +`bfd_check_format' to loop over all the targets to find the one that +matches the file being read. +`bfd_target_list' +................. + +*Synopsis* + const char **bfd_target_list(void); + *Description* +Return a freshly malloced NULL-terminated vector of the names of all +the valid BFD targets. Do not modify the names. + +File: bfd.info, Node: Architectures, Next: Opening and Closing, Prev: Targets, Up: BFD front end + +Architectures +============= + +BFD keeps one atom in a BFD describing the architecture of the data +attached to the BFD: a pointer to a `bfd_arch_info_type'. + + Pointers to structures can be requested independently of a BFD so +that an architecture's information can be interrogated without access +to an open BFD. + + The architecture information is provided by each architecture +package. The set of default architectures is selected by the macro +`SELECT_ARCHITECTURES'. This is normally set up in the +`config/TARGET.mt' file of your choice. If the name is not defined, +then all the architectures supported are included. + + When BFD starts up, all the architectures are called with an +initialize method. It is up to the architecture back end to insert as +many items into the list of architectures as it wants to; generally +this would be one for each machine and one for the default case (an +item with a machine field of 0). + + BFD's idea of an architecture is implemented in `archures.c'. +bfd_architecture +---------------- + +*Description* +This enum gives the object file's CPU architecture, in a global +sense--i.e., what processor family does it belong to? Another field +indicates which processor within the family is in use. The machine +gives a number which distinguishes different versions of the +architecture, containing, for example, 2 and 3 for Intel i960 KA and +i960 KB, and 68020 and 68030 for Motorola 68020 and 68030. + enum bfd_architecture + { + bfd_arch_unknown, /* File arch not known */ + bfd_arch_obscure, /* Arch known, not one of these */ + bfd_arch_m68k, /* Motorola 68xxx */ + bfd_arch_vax, /* DEC Vax */ + bfd_arch_i960, /* Intel 960 */ + /* The order of the following is important. + lower number indicates a machine type that + only accepts a subset of the instructions + available to machines with higher numbers. + The exception is the "ca", which is + incompatible with all other machines except + "core". */ + + #define bfd_mach_i960_core 1 + #define bfd_mach_i960_ka_sa 2 + #define bfd_mach_i960_kb_sb 3 + #define bfd_mach_i960_mc 4 + #define bfd_mach_i960_xa 5 + #define bfd_mach_i960_ca 6 + #define bfd_mach_i960_jx 7 + #define bfd_mach_i960_hx 8 + + bfd_arch_a29k, /* AMD 29000 */ + bfd_arch_sparc, /* SPARC */ + #define bfd_mach_sparc 1 + /* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ + #define bfd_mach_sparc_sparclet 2 + #define bfd_mach_sparc_sparclite 3 + #define bfd_mach_sparc_v8plus 4 + #define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns */ + #define bfd_mach_sparc_v9 6 + #define bfd_mach_sparc_v9a 7 /* with ultrasparc add'ns */ + /* Nonzero if MACH has the v9 instruction set. */ + #define bfd_mach_sparc_v9_p(mach) \ + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a) + bfd_arch_mips, /* MIPS Rxxxx */ + bfd_arch_i386, /* Intel 386 */ + #define bfd_mach_i386_i386 0 + #define bfd_mach_i386_i8086 1 + bfd_arch_we32k, /* AT&T WE32xxx */ + bfd_arch_tahoe, /* CCI/Harris Tahoe */ + bfd_arch_i860, /* Intel 860 */ + bfd_arch_romp, /* IBM ROMP PC/RT */ + bfd_arch_alliant, /* Alliant */ + bfd_arch_convex, /* Convex */ + bfd_arch_m88k, /* Motorola 88xxx */ + bfd_arch_pyramid, /* Pyramid Technology */ + bfd_arch_h8300, /* Hitachi H8/300 */ + #define bfd_mach_h8300 1 + #define bfd_mach_h8300h 2 + #define bfd_mach_h8300s 3 + bfd_arch_powerpc, /* PowerPC */ + bfd_arch_rs6000, /* IBM RS/6000 */ + bfd_arch_hppa, /* HP PA RISC */ + bfd_arch_d10v, /* Mitsubishi D10V */ + bfd_arch_z8k, /* Zilog Z8000 */ + #define bfd_mach_z8001 1 + #define bfd_mach_z8002 2 + bfd_arch_h8500, /* Hitachi H8/500 */ + bfd_arch_sh, /* Hitachi SH */ + bfd_arch_alpha, /* Dec Alpha */ + bfd_arch_arm, /* Advanced Risc Machines ARM */ + bfd_arch_ns32k, /* National Semiconductors ns32000 */ + bfd_arch_w65, /* WDC 65816 */ + bfd_arch_m32r, /* Mitsubishi M32R/D */ + bfd_arch_mn10200, /* Matsushita MN10200 */ + bfd_arch_mn10300, /* Matsushita MN10300 */ + bfd_arch_last + }; + +bfd_arch_info +------------- + +*Description* +This structure contains information on architectures for use within BFD. + + typedef struct bfd_arch_info + { + int bits_per_word; + int bits_per_address; + int bits_per_byte; + enum bfd_architecture arch; + unsigned long mach; + const char *arch_name; + const char *printable_name; + unsigned int section_align_power; + /* true if this is the default machine for the architecture */ + boolean the_default; + const struct bfd_arch_info * (*compatible) + PARAMS ((const struct bfd_arch_info *a, + const struct bfd_arch_info *b)); + + boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *)); + + const struct bfd_arch_info *next; + } bfd_arch_info_type; + +`bfd_printable_name' +.................... + +*Synopsis* + const char *bfd_printable_name(bfd *abfd); + *Description* +Return a printable string representing the architecture and machine +from the pointer to the architecture info structure. +`bfd_scan_arch' +............... + +*Synopsis* + const bfd_arch_info_type *bfd_scan_arch(const char *string); + *Description* +Figure out if BFD supports any cpu which could be described with the +name STRING. Return a pointer to an `arch_info' structure if a machine +is found, otherwise NULL. +`bfd_arch_get_compatible' +......................... + +*Synopsis* + const bfd_arch_info_type *bfd_arch_get_compatible( + const bfd *abfd, + const bfd *bbfd); + *Description* +Determine whether two BFDs' architectures and machine types are +compatible. Calculates the lowest common denominator between the two +architectures and machine types implied by the BFDs and returns a +pointer to an `arch_info' structure describing the compatible machine. +`bfd_default_arch_struct' +......................... + +*Description* +The `bfd_default_arch_struct' is an item of `bfd_arch_info_type' which +has been initialized to a fairly generic state. A BFD starts life by +pointing to this structure, until the correct back end has determined +the real architecture of the file. + extern const bfd_arch_info_type bfd_default_arch_struct; + +`bfd_set_arch_info' +................... + +*Synopsis* + void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg); + *Description* +Set the architecture info of ABFD to ARG. +`bfd_default_set_arch_mach' +........................... + +*Synopsis* + boolean bfd_default_set_arch_mach(bfd *abfd, + enum bfd_architecture arch, + unsigned long mach); + *Description* +Set the architecture and machine type in BFD ABFD to ARCH and MACH. +Find the correct pointer to a structure and insert it into the +`arch_info' pointer. +`bfd_get_arch' +.............. + +*Synopsis* + enum bfd_architecture bfd_get_arch(bfd *abfd); + *Description* +Return the enumerated type which describes the BFD ABFD's architecture. +`bfd_get_mach' +.............. + +*Synopsis* + unsigned long bfd_get_mach(bfd *abfd); + *Description* +Return the long type which describes the BFD ABFD's machine. +`bfd_arch_bits_per_byte' +........................ + +*Synopsis* + unsigned int bfd_arch_bits_per_byte(bfd *abfd); + *Description* +Return the number of bits in one of the BFD ABFD's architecture's bytes. +`bfd_arch_bits_per_address' +........................... + +*Synopsis* + unsigned int bfd_arch_bits_per_address(bfd *abfd); + *Description* +Return the number of bits in one of the BFD ABFD's architecture's +addresses. +`bfd_default_compatible' +........................ + +*Synopsis* + const bfd_arch_info_type *bfd_default_compatible + (const bfd_arch_info_type *a, + const bfd_arch_info_type *b); + *Description* +The default function for testing for compatibility. +`bfd_default_scan' +.................. + +*Synopsis* + boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string); + *Description* +The default function for working out whether this is an architecture +hit and a machine hit. +`bfd_get_arch_info' +................... + +*Synopsis* + const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd); + *Description* +Return the architecture info struct in ABFD. +`bfd_lookup_arch' +................. + +*Synopsis* + const bfd_arch_info_type *bfd_lookup_arch + (enum bfd_architecture + arch, + unsigned long machine); + *Description* +Look for the architecure info structure which matches the arguments +ARCH and MACHINE. A machine of 0 matches the machine/architecture +structure which marks itself as the default. +`bfd_printable_arch_mach' +......................... + +*Synopsis* + const char *bfd_printable_arch_mach + (enum bfd_architecture arch, unsigned long machine); + *Description* +Return a printable string representing the architecture and machine +type. + + This routine is depreciated. + +File: bfd.info, Node: Opening and Closing, Next: Internal, Prev: Architectures, Up: BFD front end + +Opening and closing BFDs +======================== + +`bfd_openr' +........... + +*Synopsis* + bfd *bfd_openr(CONST char *filename, CONST char *target); + *Description* +Open the file FILENAME (using `fopen') with the target TARGET. Return +a pointer to the created BFD. + + Calls `bfd_find_target', so TARGET is interpreted as by that +function. + + If `NULL' is returned then an error has occured. Possible errors +are `bfd_error_no_memory', `bfd_error_invalid_target' or `system_call' +error. +`bfd_fdopenr' +............. + +*Synopsis* + bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd); + *Description* +`bfd_fdopenr' is to `bfd_fopenr' much like `fdopen' is to `fopen'. It +opens a BFD on a file already described by the FD supplied. + + When the file is later `bfd_close'd, the file descriptor will be +closed. + + If the caller desires that this file descriptor be cached by BFD +(opened as needed, closed as needed to free descriptors for other +opens), with the supplied FD used as an initial file descriptor (but +subject to closure at any time), call bfd_set_cacheable(bfd, 1) on the +returned BFD. The default is to assume no cacheing; the file +descriptor will remain open until `bfd_close', and will not be affected +by BFD operations on other files. + + Possible errors are `bfd_error_no_memory', +`bfd_error_invalid_target' and `bfd_error_system_call'. +`bfd_openstreamr' +................. + +*Synopsis* + bfd *bfd_openstreamr(const char *, const char *, PTR); + *Description* +Open a BFD for read access on an existing stdio stream. When the BFD +is passed to `bfd_close', the stream will be closed. +`bfd_openw' +........... + +*Synopsis* + bfd *bfd_openw(CONST char *filename, CONST char *target); + *Description* +Create a BFD, associated with file FILENAME, using the file format +TARGET, and return a pointer to it. + + Possible errors are `bfd_error_system_call', `bfd_error_no_memory', +`bfd_error_invalid_target'. +`bfd_close' +........... + +*Synopsis* + boolean bfd_close(bfd *abfd); + *Description* +Close a BFD. If the BFD was open for writing, then pending operations +are completed and the file written out and closed. If the created file +is executable, then `chmod' is called to mark it as such. + + All memory attached to the BFD is released. + + The file descriptor associated with the BFD is closed (even if it +was passed in to BFD by `bfd_fdopenr'). +*Returns* +`true' is returned if all is ok, otherwise `false'. +`bfd_close_all_done' +.................... + +*Synopsis* + boolean bfd_close_all_done(bfd *); + *Description* +Close a BFD. Differs from `bfd_close' since it does not complete any +pending operations. This routine would be used if the application had +just used BFD for swapping and didn't want to use any of the writing +code. + + If the created file is executable, then `chmod' is called to mark it +as such. + + All memory attached to the BFD is released. +*Returns* +`true' is returned if all is ok, otherwise `false'. +`bfd_create' +............ + +*Synopsis* + bfd *bfd_create(CONST char *filename, bfd *templ); + *Description* +Create a new BFD in the manner of `bfd_openw', but without opening a +file. The new BFD takes the target from the target used by TEMPLATE. The +format is always set to `bfd_object'. +`bfd_alloc' +........... + +*Synopsis* + PTR bfd_alloc (bfd *abfd, size_t wanted); + *Description* +Allocate a block of WANTED bytes of memory attached to `abfd' and +return a pointer to it. diff -urN binutils-2.7/bfd/doc/bfd.info-4 binutils-2.8/bfd/doc/bfd.info-4 --- binutils-2.7/bfd/doc/bfd.info-4 Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.info-4 Wed Apr 30 13:14:27 1997 @@ -0,0 +1,1023 @@ +This is Info file bfd.info, produced by Makeinfo-1.64 from the input +file ./bfd.texinfo. + +START-INFO-DIR-ENTRY +* Bfd: (bfd). The Binary File Descriptor library. +END-INFO-DIR-ENTRY + + This file documents the BFD library. + + Copyright (C) 1991 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, subject to the +terms of the GNU General Public License, which includes the provision +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: bfd.info, Node: Internal, Next: File Caching, Prev: Opening and Closing, Up: BFD front end + +Internal functions +================== + +*Description* +These routines are used within BFD. They are not intended for export, +but are documented here for completeness. +`bfd_write_bigendian_4byte_int' +............................... + +*Synopsis* + void bfd_write_bigendian_4byte_int(bfd *abfd, int i); + *Description* +Write a 4 byte integer I to the output BFD ABFD, in big endian order +regardless of what else is going on. This is useful in archives. +`bfd_put_size' +.............. + +`bfd_get_size' +.............. + +*Description* +These macros as used for reading and writing raw data in sections; each +access (except for bytes) is vectored through the target format of the +BFD and mangled accordingly. The mangling performs any necessary endian +translations and removes alignment restrictions. Note that types +accepted and returned by these macros are identical so they can be +swapped around in macros--for example, `libaout.h' defines `GET_WORD' +to either `bfd_get_32' or `bfd_get_64'. + + In the put routines, VAL must be a `bfd_vma'. If we are on a system +without prototypes, the caller is responsible for making sure that is +true, with a cast if necessary. We don't cast them in the macro +definitions because that would prevent `lint' or `gcc -Wall' from +detecting sins such as passing a pointer. To detect calling these with +less than a `bfd_vma', use `gcc -Wconversion' on a host with 64 bit +`bfd_vma''s. + + /* Byte swapping macros for user section data. */ + + #define bfd_put_8(abfd, val, ptr) \ + (*((unsigned char *)(ptr)) = (unsigned char)(val)) + #define bfd_put_signed_8 \ + bfd_put_8 + #define bfd_get_8(abfd, ptr) \ + (*(unsigned char *)(ptr)) + #define bfd_get_signed_8(abfd, ptr) \ + ((*(unsigned char *)(ptr) ^ 0x80) - 0x80) + + #define bfd_put_16(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx16, ((val),(ptr))) + #define bfd_put_signed_16 \ + bfd_put_16 + #define bfd_get_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx16, (ptr)) + #define bfd_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) + + #define bfd_put_32(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx32, ((val),(ptr))) + #define bfd_put_signed_32 \ + bfd_put_32 + #define bfd_get_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx32, (ptr)) + #define bfd_get_signed_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx_signed_32, (ptr)) + + #define bfd_put_64(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx64, ((val), (ptr))) + #define bfd_put_signed_64 \ + bfd_put_64 + #define bfd_get_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx64, (ptr)) + #define bfd_get_signed_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) + +`bfd_h_put_size' +................ + +*Description* +These macros have the same function as their `bfd_get_x' bretheren, +except that they are used for removing information for the header +records of object files. Believe it or not, some object files keep +their header records in big endian order and their data in little +endian order. + + /* Byte swapping macros for file header data. */ + + #define bfd_h_put_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) + #define bfd_h_put_signed_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) + #define bfd_h_get_8(abfd, ptr) \ + bfd_get_8 (abfd, ptr) + #define bfd_h_get_signed_8(abfd, ptr) \ + bfd_get_signed_8 (abfd, ptr) + + #define bfd_h_put_16(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) + #define bfd_h_put_signed_16 \ + bfd_h_put_16 + #define bfd_h_get_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx16,(ptr)) + #define bfd_h_get_signed_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr)) + + #define bfd_h_put_32(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) + #define bfd_h_put_signed_32 \ + bfd_h_put_32 + #define bfd_h_get_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx32,(ptr)) + #define bfd_h_get_signed_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr)) + + #define bfd_h_put_64(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) + #define bfd_h_put_signed_64 \ + bfd_h_put_64 + #define bfd_h_get_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx64,(ptr)) + #define bfd_h_get_signed_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr)) + +`bfd_log2' +.......... + +*Synopsis* + unsigned int bfd_log2(bfd_vma x); + *Description* +Return the log base 2 of the value supplied, rounded up. E.g., an X of +1025 returns 11. + +File: bfd.info, Node: File Caching, Next: Linker Functions, Prev: Internal, Up: BFD front end + +File caching +============ + +The file caching mechanism is embedded within BFD and allows the +application to open as many BFDs as it wants without regard to the +underlying operating system's file descriptor limit (often as low as 20 +open files). The module in `cache.c' maintains a least recently used +list of `BFD_CACHE_MAX_OPEN' files, and exports the name +`bfd_cache_lookup', which runs around and makes sure that the required +BFD is open. If not, then it chooses a file to close, closes it and +opens the one wanted, returning its file handle. +`BFD_CACHE_MAX_OPEN macro' +.......................... + +*Description* +The maximum number of files which the cache will keep open at one time. + #define BFD_CACHE_MAX_OPEN 10 + +`bfd_last_cache' +................ + +*Synopsis* + extern bfd *bfd_last_cache; + *Description* +Zero, or a pointer to the topmost BFD on the chain. This is used by +the `bfd_cache_lookup' macro in `libbfd.h' to determine when it can +avoid a function call. +`bfd_cache_lookup' +.................. + +*Description* +Check to see if the required BFD is the same as the last one looked up. +If so, then it can use the stream in the BFD with impunity, since it +can't have changed since the last lookup; otherwise, it has to perform +the complicated lookup function. + #define bfd_cache_lookup(x) \ + ((x)==bfd_last_cache? \ + (FILE*)(bfd_last_cache->iostream): \ + bfd_cache_lookup_worker(x)) + +`bfd_cache_init' +................ + +*Synopsis* + boolean bfd_cache_init (bfd *abfd); + *Description* +Add a newly opened BFD to the cache. +`bfd_cache_close' +................. + +*Synopsis* + boolean bfd_cache_close (bfd *abfd); + *Description* +Remove the BFD ABFD from the cache. If the attached file is open, then +close it too. +*Returns* +`false' is returned if closing the file fails, `true' is returned if +all is well. +`bfd_open_file' +............... + +*Synopsis* + FILE* bfd_open_file(bfd *abfd); + *Description* +Call the OS to open a file for ABFD. Return the `FILE *' (possibly +`NULL') that results from this operation. Set up the BFD so that +future accesses know the file is open. If the `FILE *' returned is +`NULL', then it won't have been put in the cache, so it won't have to +be removed from it. +`bfd_cache_lookup_worker' +......................... + +*Synopsis* + FILE *bfd_cache_lookup_worker(bfd *abfd); + *Description* +Called when the macro `bfd_cache_lookup' fails to find a quick answer. +Find a file descriptor for ABFD. If necessary, it open it. If there +are already more than `BFD_CACHE_MAX_OPEN' files open, it tries to +close one first, to avoid running out of file descriptors. + +File: bfd.info, Node: Linker Functions, Next: Hash Tables, Prev: File Caching, Up: BFD front end + +Linker Functions +================ + +The linker uses three special entry points in the BFD target vector. +It is not necessary to write special routines for these entry points +when creating a new BFD back end, since generic versions are provided. +However, writing them can speed up linking and make it use +significantly less runtime memory. + + The first routine creates a hash table used by the other routines. +The second routine adds the symbols from an object file to the hash +table. The third routine takes all the object files and links them +together to create the output file. These routines are designed so +that the linker proper does not need to know anything about the symbols +in the object files that it is linking. The linker merely arranges the +sections as directed by the linker script and lets BFD handle the +details of symbols and relocs. + + The second routine and third routines are passed a pointer to a +`struct bfd_link_info' structure (defined in `bfdlink.h') which holds +information relevant to the link, including the linker hash table +(which was created by the first routine) and a set of callback +functions to the linker proper. + + The generic linker routines are in `linker.c', and use the header +file `genlink.h'. As of this writing, the only back ends which have +implemented versions of these routines are a.out (in `aoutx.h') and +ECOFF (in `ecoff.c'). The a.out routines are used as examples +throughout this section. + +* Menu: + +* Creating a Linker Hash Table:: +* Adding Symbols to the Hash Table:: +* Performing the Final Link:: + + +File: bfd.info, Node: Creating a Linker Hash Table, Next: Adding Symbols to the Hash Table, Prev: Linker Functions, Up: Linker Functions + +Creating a linker hash table +---------------------------- + +The linker routines must create a hash table, which must be derived +from `struct bfd_link_hash_table' described in `bfdlink.c'. *Note Hash +Tables:: for information on how to create a derived hash table. This +entry point is called using the target vector of the linker output file. + + The `_bfd_link_hash_table_create' entry point must allocate and +initialize an instance of the desired hash table. If the back end does +not require any additional information to be stored with the entries in +the hash table, the entry point may simply create a `struct +bfd_link_hash_table'. Most likely, however, some additional +information will be needed. + + For example, with each entry in the hash table the a.out linker +keeps the index the symbol has in the final output file (this index +number is used so that when doing a relocateable link the symbol index +used in the output file can be quickly filled in when copying over a +reloc). The a.out linker code defines the required structures and +functions for a hash table derived from `struct bfd_link_hash_table'. +The a.out linker hash table is created by the function +`NAME(aout,link_hash_table_create)'; it simply allocates space for the +hash table, initializes it, and returns a pointer to it. + + When writing the linker routines for a new back end, you will +generally not know exactly which fields will be required until you have +finished. You should simply create a new hash table which defines no +additional fields, and then simply add fields as they become necessary. + +File: bfd.info, Node: Adding Symbols to the Hash Table, Next: Performing the Final Link, Prev: Creating a Linker Hash Table, Up: Linker Functions + +Adding symbols to the hash table +-------------------------------- + +The linker proper will call the `_bfd_link_add_symbols' entry point for +each object file or archive which is to be linked (typically these are +the files named on the command line, but some may also come from the +linker script). The entry point is responsible for examining the file. +For an object file, BFD must add any relevant symbol information to +the hash table. For an archive, BFD must determine which elements of +the archive should be used and adding them to the link. + + The a.out version of this entry point is +`NAME(aout,link_add_symbols)'. + +* Menu: + +* Differing file formats:: +* Adding symbols from an object file:: +* Adding symbols from an archive:: + + +File: bfd.info, Node: Differing file formats, Next: Adding symbols from an object file, Prev: Adding Symbols to the Hash Table, Up: Adding Symbols to the Hash Table + +Differing file formats +...................... + +Normally all the files involved in a link will be of the same format, +but it is also possible to link together different format object files, +and the back end must support that. The `_bfd_link_add_symbols' entry +point is called via the target vector of the file to be added. This +has an important consequence: the function may not assume that the hash +table is the type created by the corresponding +`_bfd_link_hash_table_create' vector. All the `_bfd_link_add_symbols' +function can assume about the hash table is that it is derived from +`struct bfd_link_hash_table'. + + Sometimes the `_bfd_link_add_symbols' function must store some +information in the hash table entry to be used by the `_bfd_final_link' +function. In such a case the `creator' field of the hash table must be +checked to make sure that the hash table was created by an object file +of the same format. + + The `_bfd_final_link' routine must be prepared to handle a hash +entry without any extra information added by the +`_bfd_link_add_symbols' function. A hash entry without extra +information will also occur when the linker script directs the linker +to create a symbol. Note that, regardless of how a hash table entry is +added, all the fields will be initialized to some sort of null value by +the hash table entry initialization function. + + See `ecoff_link_add_externals' for an example of how to check the +`creator' field before saving information (in this case, the ECOFF +external symbol debugging information) in a hash table entry. + +File: bfd.info, Node: Adding symbols from an object file, Next: Adding symbols from an archive, Prev: Differing file formats, Up: Adding Symbols to the Hash Table + +Adding symbols from an object file +.................................. + +When the `_bfd_link_add_symbols' routine is passed an object file, it +must add all externally visible symbols in that object file to the hash +table. The actual work of adding the symbol to the hash table is +normally handled by the function `_bfd_generic_link_add_one_symbol'. +The `_bfd_link_add_symbols' routine is responsible for reading all the +symbols from the object file and passing the correct information to +`_bfd_generic_link_add_one_symbol'. + + The `_bfd_link_add_symbols' routine should not use +`bfd_canonicalize_symtab' to read the symbols. The point of providing +this routine is to avoid the overhead of converting the symbols into +generic `asymbol' structures. + + `_bfd_generic_link_add_one_symbol' handles the details of combining +common symbols, warning about multiple definitions, and so forth. It +takes arguments which describe the symbol to add, notably symbol flags, +a section, and an offset. The symbol flags include such things as +`BSF_WEAK' or `BSF_INDIRECT'. The section is a section in the object +file, or something like `bfd_und_section_ptr' for an undefined symbol +or `bfd_com_section_ptr' for a common symbol. + + If the `_bfd_final_link' routine is also going to need to read the +symbol information, the `_bfd_link_add_symbols' routine should save it +somewhere attached to the object file BFD. However, the information +should only be saved if the `keep_memory' field of the `info' argument +is true, so that the `-no-keep-memory' linker switch is effective. + + The a.out function which adds symbols from an object file is +`aout_link_add_object_symbols', and most of the interesting work is in +`aout_link_add_symbols'. The latter saves pointers to the hash tables +entries created by `_bfd_generic_link_add_one_symbol' indexed by symbol +number, so that the `_bfd_final_link' routine does not have to call the +hash table lookup routine to locate the entry. + +File: bfd.info, Node: Adding symbols from an archive, Prev: Adding symbols from an object file, Up: Adding Symbols to the Hash Table + +Adding symbols from an archive +.............................. + +When the `_bfd_link_add_symbols' routine is passed an archive, it must +look through the symbols defined by the archive and decide which +elements of the archive should be included in the link. For each such +element it must call the `add_archive_element' linker callback, and it +must add the symbols from the object file to the linker hash table. + + In most cases the work of looking through the symbols in the archive +should be done by the `_bfd_generic_link_add_archive_symbols' function. +This function builds a hash table from the archive symbol table and +looks through the list of undefined symbols to see which elements +should be included. `_bfd_generic_link_add_archive_symbols' is passed +a function to call to make the final decision about adding an archive +element to the link and to do the actual work of adding the symbols to +the linker hash table. + + The function passed to `_bfd_generic_link_add_archive_symbols' must +read the symbols of the archive element and decide whether the archive +element should be included in the link. If the element is to be +included, the `add_archive_element' linker callback routine must be +called with the element as an argument, and the elements symbols must +be added to the linker hash table just as though the element had itself +been passed to the `_bfd_link_add_symbols' function. + + When the a.out `_bfd_link_add_symbols' function receives an archive, +it calls `_bfd_generic_link_add_archive_symbols' passing +`aout_link_check_archive_element' as the function argument. +`aout_link_check_archive_element' calls `aout_link_check_ar_symbols'. +If the latter decides to add the element (an element is only added if +it provides a real, non-common, definition for a previously undefined +or common symbol) it calls the `add_archive_element' callback and then +`aout_link_check_archive_element' calls `aout_link_add_symbols' to +actually add the symbols to the linker hash table. + + The ECOFF back end is unusual in that it does not normally call +`_bfd_generic_link_add_archive_symbols', because ECOFF archives already +contain a hash table of symbols. The ECOFF back end searches the +archive itself to avoid the overhead of creating a new hash table. + +File: bfd.info, Node: Performing the Final Link, Prev: Adding Symbols to the Hash Table, Up: Linker Functions + +Performing the final link +------------------------- + +When all the input files have been processed, the linker calls the +`_bfd_final_link' entry point of the output BFD. This routine is +responsible for producing the final output file, which has several +aspects. It must relocate the contents of the input sections and copy +the data into the output sections. It must build an output symbol +table including any local symbols from the input files and the global +symbols from the hash table. When producing relocateable output, it +must modify the input relocs and write them into the output file. +There may also be object format dependent work to be done. + + The linker will also call the `write_object_contents' entry point +when the BFD is closed. The two entry points must work together in +order to produce the correct output file. + + The details of how this works are inevitably dependent upon the +specific object file format. The a.out `_bfd_final_link' routine is +`NAME(aout,final_link)'. + +* Menu: + +* Information provided by the linker:: +* Relocating the section contents:: +* Writing the symbol table:: + + +File: bfd.info, Node: Information provided by the linker, Next: Relocating the section contents, Prev: Performing the Final Link, Up: Performing the Final Link + +Information provided by the linker +.................................. + +Before the linker calls the `_bfd_final_link' entry point, it sets up +some data structures for the function to use. + + The `input_bfds' field of the `bfd_link_info' structure will point +to a list of all the input files included in the link. These files are +linked through the `link_next' field of the `bfd' structure. + + Each section in the output file will have a list of `link_order' +structures attached to the `link_order_head' field (the `link_order' +structure is defined in `bfdlink.h'). These structures describe how to +create the contents of the output section in terms of the contents of +various input sections, fill constants, and, eventually, other types of +information. They also describe relocs that must be created by the BFD +backend, but do not correspond to any input file; this is used to +support -Ur, which builds constructors while generating a relocateable +object file. + +File: bfd.info, Node: Relocating the section contents, Next: Writing the symbol table, Prev: Information provided by the linker, Up: Performing the Final Link + +Relocating the section contents +............................... + +The `_bfd_final_link' function should look through the `link_order' +structures attached to each section of the output file. Each +`link_order' structure should either be handled specially, or it should +be passed to the function `_bfd_default_link_order' which will do the +right thing (`_bfd_default_link_order' is defined in `linker.c'). + + For efficiency, a `link_order' of type `bfd_indirect_link_order' +whose associated section belongs to a BFD of the same format as the +output BFD must be handled specially. This type of `link_order' +describes part of an output section in terms of a section belonging to +one of the input files. The `_bfd_final_link' function should read the +contents of the section and any associated relocs, apply the relocs to +the section contents, and write out the modified section contents. If +performing a relocateable link, the relocs themselves must also be +modified and written out. + + The functions `_bfd_relocate_contents' and +`_bfd_final_link_relocate' provide some general support for performing +the actual relocations, notably overflow checking. Their arguments +include information about the symbol the relocation is against and a +`reloc_howto_type' argument which describes the relocation to perform. +These functions are defined in `reloc.c'. + + The a.out function which handles reading, relocating, and writing +section contents is `aout_link_input_section'. The actual relocation +is done in `aout_link_input_section_std' and +`aout_link_input_section_ext'. + +File: bfd.info, Node: Writing the symbol table, Prev: Relocating the section contents, Up: Performing the Final Link + +Writing the symbol table +........................ + +The `_bfd_final_link' function must gather all the symbols in the input +files and write them out. It must also write out all the symbols in +the global hash table. This must be controlled by the `strip' and +`discard' fields of the `bfd_link_info' structure. + + The local symbols of the input files will not have been entered into +the linker hash table. The `_bfd_final_link' routine must consider +each input file and include the symbols in the output file. It may be +convenient to do this when looking through the `link_order' structures, +or it may be done by stepping through the `input_bfds' list. + + The `_bfd_final_link' routine must also traverse the global hash +table to gather all the externally visible symbols. It is possible +that most of the externally visible symbols may be written out when +considering the symbols of each input file, but it is still necessary +to traverse the hash table since the linker script may have defined +some symbols that are not in any of the input files. + + The `strip' field of the `bfd_link_info' structure controls which +symbols are written out. The possible values are listed in +`bfdlink.h'. If the value is `strip_some', then the `keep_hash' field +of the `bfd_link_info' structure is a hash table of symbols to keep; +each symbol should be looked up in this hash table, and only symbols +which are present should be included in the output file. + + If the `strip' field of the `bfd_link_info' structure permits local +symbols to be written out, the `discard' field is used to further +controls which local symbols are included in the output file. If the +value is `discard_l', then all local symbols which begin with a certain +prefix are discarded; this is controlled by the +`bfd_is_local_label_name' entry point. + + The a.out backend handles symbols by calling +`aout_link_write_symbols' on each input BFD and then traversing the +global hash table with the function `aout_link_write_other_symbol'. It +builds a string table while writing out the symbols, which is written +to the output file at the end of `NAME(aout,final_link)'. +`bfd_link_split_section' +........................ + +*Synopsis* + boolean bfd_link_split_section(bfd *abfd, asection *sec); + *Description* +Return nonzero if SEC should be split during a reloceatable or final +link. + #define bfd_link_split_section(abfd, sec) \ + BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) + + +File: bfd.info, Node: Hash Tables, Prev: Linker Functions, Up: BFD front end + +Hash Tables +=========== + +BFD provides a simple set of hash table functions. Routines are +provided to initialize a hash table, to free a hash table, to look up a +string in a hash table and optionally create an entry for it, and to +traverse a hash table. There is currently no routine to delete an +string from a hash table. + + The basic hash table does not permit any data to be stored with a +string. However, a hash table is designed to present a base class from +which other types of hash tables may be derived. These derived types +may store additional information with the string. Hash tables were +implemented in this way, rather than simply providing a data pointer in +a hash table entry, because they were designed for use by the linker +back ends. The linker may create thousands of hash table entries, and +the overhead of allocating private data and storing and following +pointers becomes noticeable. + + The basic hash table code is in `hash.c'. + +* Menu: + +* Creating and Freeing a Hash Table:: +* Looking Up or Entering a String:: +* Traversing a Hash Table:: +* Deriving a New Hash Table Type:: + + +File: bfd.info, Node: Creating and Freeing a Hash Table, Next: Looking Up or Entering a String, Prev: Hash Tables, Up: Hash Tables + +Creating and freeing a hash table +--------------------------------- + +To create a hash table, create an instance of a `struct bfd_hash_table' +(defined in `bfd.h') and call `bfd_hash_table_init' (if you know +approximately how many entries you will need, the function +`bfd_hash_table_init_n', which takes a SIZE argument, may be used). +`bfd_hash_table_init' returns `false' if some sort of error occurs. + + The function `bfd_hash_table_init' take as an argument a function to +use to create new entries. For a basic hash table, use the function +`bfd_hash_newfunc'. *Note Deriving a New Hash Table Type:: for why you +would want to use a different value for this argument. + + `bfd_hash_table_init' will create an objalloc which will be used to +allocate new entries. You may allocate memory on this objalloc using +`bfd_hash_allocate'. + + Use `bfd_hash_table_free' to free up all the memory that has been +allocated for a hash table. This will not free up the `struct +bfd_hash_table' itself, which you must provide. + +File: bfd.info, Node: Looking Up or Entering a String, Next: Traversing a Hash Table, Prev: Creating and Freeing a Hash Table, Up: Hash Tables + +Looking up or entering a string +------------------------------- + +The function `bfd_hash_lookup' is used both to look up a string in the +hash table and to create a new entry. + + If the CREATE argument is `false', `bfd_hash_lookup' will look up a +string. If the string is found, it will returns a pointer to a `struct +bfd_hash_entry'. If the string is not found in the table +`bfd_hash_lookup' will return `NULL'. You should not modify any of the +fields in the returns `struct bfd_hash_entry'. + + If the CREATE argument is `true', the string will be entered into +the hash table if it is not already there. Either way a pointer to a +`struct bfd_hash_entry' will be returned, either to the existing +structure or to a newly created one. In this case, a `NULL' return +means that an error occurred. + + If the CREATE argument is `true', and a new entry is created, the +COPY argument is used to decide whether to copy the string onto the +hash table objalloc or not. If COPY is passed as `false', you must be +careful not to deallocate or modify the string as long as the hash table +exists. + +File: bfd.info, Node: Traversing a Hash Table, Next: Deriving a New Hash Table Type, Prev: Looking Up or Entering a String, Up: Hash Tables + +Traversing a hash table +----------------------- + +The function `bfd_hash_traverse' may be used to traverse a hash table, +calling a function on each element. The traversal is done in a random +order. + + `bfd_hash_traverse' takes as arguments a function and a generic +`void *' pointer. The function is called with a hash table entry (a +`struct bfd_hash_entry *') and the generic pointer passed to +`bfd_hash_traverse'. The function must return a `boolean' value, which +indicates whether to continue traversing the hash table. If the +function returns `false', `bfd_hash_traverse' will stop the traversal +and return immediately. + +File: bfd.info, Node: Deriving a New Hash Table Type, Prev: Traversing a Hash Table, Up: Hash Tables + +Deriving a new hash table type +------------------------------ + +Many uses of hash tables want to store additional information which +each entry in the hash table. Some also find it convenient to store +additional information with the hash table itself. This may be done +using a derived hash table. + + Since C is not an object oriented language, creating a derived hash +table requires sticking together some boilerplate routines with a few +differences specific to the type of hash table you want to create. + + An example of a derived hash table is the linker hash table. The +structures for this are defined in `bfdlink.h'. The functions are in +`linker.c'. + + You may also derive a hash table from an already derived hash table. +For example, the a.out linker backend code uses a hash table derived +from the linker hash table. + +* Menu: + +* Define the Derived Structures:: +* Write the Derived Creation Routine:: +* Write Other Derived Routines:: + + +File: bfd.info, Node: Define the Derived Structures, Next: Write the Derived Creation Routine, Prev: Deriving a New Hash Table Type, Up: Deriving a New Hash Table Type + +Define the derived structures +............................. + +You must define a structure for an entry in the hash table, and a +structure for the hash table itself. + + The first field in the structure for an entry in the hash table must +be of the type used for an entry in the hash table you are deriving +from. If you are deriving from a basic hash table this is `struct +bfd_hash_entry', which is defined in `bfd.h'. The first field in the +structure for the hash table itself must be of the type of the hash +table you are deriving from itself. If you are deriving from a basic +hash table, this is `struct bfd_hash_table'. + + For example, the linker hash table defines `struct +bfd_link_hash_entry' (in `bfdlink.h'). The first field, `root', is of +type `struct bfd_hash_entry'. Similarly, the first field in `struct +bfd_link_hash_table', `table', is of type `struct bfd_hash_table'. + +File: bfd.info, Node: Write the Derived Creation Routine, Next: Write Other Derived Routines, Prev: Define the Derived Structures, Up: Deriving a New Hash Table Type + +Write the derived creation routine +.................................. + +You must write a routine which will create and initialize an entry in +the hash table. This routine is passed as the function argument to +`bfd_hash_table_init'. + + In order to permit other hash tables to be derived from the hash +table you are creating, this routine must be written in a standard way. + + The first argument to the creation routine is a pointer to a hash +table entry. This may be `NULL', in which case the routine should +allocate the right amount of space. Otherwise the space has already +been allocated by a hash table type derived from this one. + + After allocating space, the creation routine must call the creation +routine of the hash table type it is derived from, passing in a pointer +to the space it just allocated. This will initialize any fields used +by the base hash table. + + Finally the creation routine must initialize any local fields for +the new hash table type. + + Here is a boilerplate example of a creation routine. FUNCTION_NAME +is the name of the routine. ENTRY_TYPE is the type of an entry in the +hash table you are creating. BASE_NEWFUNC is the name of the creation +routine of the hash table type your hash table is derived from. +.struct bfd_hash_entry * + FUNCTION_NAME (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; + { + struct ENTRY_TYPE *ret = (ENTRY_TYPE *) entry; + + /* Allocate the structure if it has not already been allocated by a + derived class. */ + if (ret == (ENTRY_TYPE *) NULL) + { + ret = ((ENTRY_TYPE *) + bfd_hash_allocate (table, sizeof (ENTRY_TYPE))); + if (ret == (ENTRY_TYPE *) NULL) + return NULL; + } + + /* Call the allocation method of the base class. */ + ret = ((ENTRY_TYPE *) + BASE_NEWFUNC ((struct bfd_hash_entry *) ret, table, string)); + + /* Initialize the local fields here. */ + + return (struct bfd_hash_entry *) ret; + } + *Description* +The creation routine for the linker hash table, which is in `linker.c', +looks just like this example. FUNCTION_NAME is +`_bfd_link_hash_newfunc'. ENTRY_TYPE is `struct bfd_link_hash_entry'. +BASE_NEWFUNC is `bfd_hash_newfunc', the creation routine for a basic +hash table. + + `_bfd_link_hash_newfunc' also initializes the local fields in a +linker hash table entry: `type', `written' and `next'. + +File: bfd.info, Node: Write Other Derived Routines, Prev: Write the Derived Creation Routine, Up: Deriving a New Hash Table Type + +Write other derived routines +............................ + +You will want to write other routines for your new hash table, as well. + + You will want an initialization routine which calls the +initialization routine of the hash table you are deriving from and +initializes any other local fields. For the linker hash table, this is +`_bfd_link_hash_table_init' in `linker.c'. + + You will want a lookup routine which calls the lookup routine of the +hash table you are deriving from and casts the result. The linker hash +table uses `bfd_link_hash_lookup' in `linker.c' (this actually takes an +additional argument which it uses to decide how to return the looked up +value). + + You may want a traversal routine. This should just call the +traversal routine of the hash table you are deriving from with +appropriate casts. The linker hash table uses `bfd_link_hash_traverse' +in `linker.c'. + + These routines may simply be defined as macros. For example, the +a.out backend linker hash table, which is derived from the linker hash +table, uses macros for the lookup and traversal routines. These are +`aout_link_hash_lookup' and `aout_link_hash_traverse' in aoutx.h. + +File: bfd.info, Node: BFD back ends, Next: Index, Prev: BFD front end, Up: Top + +BFD back ends +************* + +* Menu: + +* What to Put Where:: +* aout :: a.out backends +* coff :: coff backends +* elf :: elf backends + + +File: bfd.info, Node: What to Put Where, Next: aout, Prev: BFD back ends, Up: BFD back ends + + All of BFD lives in one directory. + + +File: bfd.info, Node: aout, Next: coff, Prev: What to Put Where, Up: BFD back ends + +a.out backends +============== + +*Description* +BFD supports a number of different flavours of a.out format, though the +major differences are only the sizes of the structures on disk, and the +shape of the relocation information. + + The support is split into a basic support file `aoutx.h' and other +files which derive functions from the base. One derivation file is +`aoutf1.h' (for a.out flavour 1), and adds to the basic a.out functions +support for sun3, sun4, 386 and 29k a.out files, to create a target +jump vector for a specific target. + + This information is further split out into more specific files for +each machine, including `sunos.c' for sun3 and sun4, `newsos3.c' for +the Sony NEWS, and `demo64.c' for a demonstration of a 64 bit a.out +format. + + The base file `aoutx.h' defines general mechanisms for reading and +writing records to and from disk and various other methods which BFD +requires. It is included by `aout32.c' and `aout64.c' to form the names +`aout_32_swap_exec_header_in', `aout_64_swap_exec_header_in', etc. + + As an example, this is what goes on to make the back end for a sun4, +from `aout32.c': + + #define ARCH_SIZE 32 + #include "aoutx.h" + + Which exports names: + + ... + aout_32_canonicalize_reloc + aout_32_find_nearest_line + aout_32_get_lineno + aout_32_get_reloc_upper_bound + ... + + from `sunos.c': + + #define TARGET_NAME "a.out-sunos-big" + #define VECNAME sunos_big_vec + #include "aoutf1.h" + + requires all the names from `aout32.c', and produces the jump vector + + sunos_big_vec + + The file `host-aout.c' is a special case. It is for a large set of +hosts that use "more or less standard" a.out files, and for which +cross-debugging is not interesting. It uses the standard 32-bit a.out +support routines, but determines the file offsets and addresses of the +text, data, and BSS sections, the machine architecture and machine +type, and the entry point address, in a host-dependent manner. Once +these values have been determined, generic code is used to handle the +object file. + + When porting it to run on a new system, you must supply: + + HOST_PAGE_SIZE + HOST_SEGMENT_SIZE + HOST_MACHINE_ARCH (optional) + HOST_MACHINE_MACHINE (optional) + HOST_TEXT_START_ADDR + HOST_STACK_END_ADDR + + in the file `../include/sys/h-XXX.h' (for your host). These values, +plus the structures and macros defined in `a.out.h' on your host +system, will produce a BFD target that will access ordinary a.out files +on your host. To configure a new machine to use `host-aout.c', specify: + + TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec + TDEPFILES= host-aout.o trad-core.o + + in the `config/XXX.mt' file, and modify `configure.in' to use the +`XXX.mt' file (by setting "`bfd_target=XXX'") when your configuration +is selected. +Relocations +----------- + +*Description* +The file `aoutx.h' provides for both the *standard* and *extended* +forms of a.out relocation records. + + The standard records contain only an address, a symbol index, and a +type field. The extended records (used on 29ks and sparcs) also have a +full integer for an addend. +Internal entry points +--------------------- + +*Description* +`aoutx.h' exports several routines for accessing the contents of an +a.out file, which are gathered and exported in turn by various format +specific files (eg sunos.c). +`aout_SIZE_swap_exec_header_in' +............................... + +*Synopsis* + void aout_SIZE_swap_exec_header_in, + (bfd *abfd, + struct external_exec *raw_bytes, + struct internal_exec *execp); + *Description* +Swap the information in an executable header RAW_BYTES taken from a raw +byte stream memory image into the internal exec header structure EXECP. +`aout_SIZE_swap_exec_header_out' +................................ + +*Synopsis* + void aout_SIZE_swap_exec_header_out + (bfd *abfd, + struct internal_exec *execp, + struct external_exec *raw_bytes); + *Description* +Swap the information in an internal exec header structure EXECP into +the buffer RAW_BYTES ready for writing to disk. +`aout_SIZE_some_aout_object_p' +.............................. + +*Synopsis* + const bfd_target *aout_SIZE_some_aout_object_p + (bfd *abfd, + const bfd_target *(*callback_to_real_object_p)()); + *Description* +Some a.out variant thinks that the file open in ABFD checking is an +a.out file. Do some more checking, and set up for access if it really +is. Call back to the calling environment's "finish up" function just +before returning, to handle any last-minute setup. +`aout_SIZE_mkobject' +.................... + +*Synopsis* + boolean aout_SIZE_mkobject, (bfd *abfd); + *Description* +Initialize BFD ABFD for use with a.out files. +`aout_SIZE_machine_type' +........................ + +*Synopsis* + enum machine_type aout_SIZE_machine_type + (enum bfd_architecture arch, + unsigned long machine)); + *Description* +Keep track of machine architecture and machine type for a.out's. Return +the `machine_type' for a particular architecture and machine, or +`M_UNKNOWN' if that exact architecture and machine can't be represented +in a.out format. + + If the architecture is understood, machine type 0 (default) is +always understood. +`aout_SIZE_set_arch_mach' +......................... + +*Synopsis* + boolean aout_SIZE_set_arch_mach, + (bfd *, + enum bfd_architecture arch, + unsigned long machine)); + *Description* +Set the architecture and the machine of the BFD ABFD to the values ARCH +and MACHINE. Verify that ABFD's format can support the architecture +required. +`aout_SIZE_new_section_hook' +............................ + +*Synopsis* + boolean aout_SIZE_new_section_hook, + (bfd *abfd, + asection *newsect)); + *Description* +Called by the BFD in response to a `bfd_make_section' request. diff -urN binutils-2.7/bfd/doc/bfd.info-5 binutils-2.8/bfd/doc/bfd.info-5 --- binutils-2.7/bfd/doc/bfd.info-5 Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.info-5 Wed Apr 30 13:14:27 1997 @@ -0,0 +1,991 @@ +This is Info file bfd.info, produced by Makeinfo-1.64 from the input +file ./bfd.texinfo. + +START-INFO-DIR-ENTRY +* Bfd: (bfd). The Binary File Descriptor library. +END-INFO-DIR-ENTRY + + This file documents the BFD library. + + Copyright (C) 1991 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, subject to the +terms of the GNU General Public License, which includes the provision +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: bfd.info, Node: coff, Next: elf, Prev: aout, Up: BFD back ends + +coff backends +============= + +BFD supports a number of different flavours of coff format. The major +differences between formats are the sizes and alignments of fields in +structures on disk, and the occasional extra field. + + Coff in all its varieties is implemented with a few common files and +a number of implementation specific files. For example, The 88k bcs +coff format is implemented in the file `coff-m88k.c'. This file +`#include's `coff/m88k.h' which defines the external structure of the +coff format for the 88k, and `coff/internal.h' which defines the +internal structure. `coff-m88k.c' also defines the relocations used by +the 88k format *Note Relocations::. + + The Intel i960 processor version of coff is implemented in +`coff-i960.c'. This file has the same structure as `coff-m88k.c', +except that it includes `coff/i960.h' rather than `coff-m88k.h'. +Porting to a new version of coff +-------------------------------- + +The recommended method is to select from the existing implementations +the version of coff which is most like the one you want to use. For +example, we'll say that i386 coff is the one you select, and that your +coff flavour is called foo. Copy `i386coff.c' to `foocoff.c', copy +`../include/coff/i386.h' to `../include/coff/foo.h', and add the lines +to `targets.c' and `Makefile.in' so that your new back end is used. +Alter the shapes of the structures in `../include/coff/foo.h' so that +they match what you need. You will probably also have to add `#ifdef's +to the code in `coff/internal.h' and `coffcode.h' if your version of +coff is too wild. + + You can verify that your new BFD backend works quite simply by +building `objdump' from the `binutils' directory, and making sure that +its version of what's going on and your host system's idea (assuming it +has the pretty standard coff dump utility, usually called `att-dump' or +just `dump') are the same. Then clean up your code, and send what +you've done to Cygnus. Then your stuff will be in the next release, and +you won't have to keep integrating it. +How the coff backend works +-------------------------- + +File layout +........... + +The Coff backend is split into generic routines that are applicable to +any Coff target and routines that are specific to a particular target. +The target-specific routines are further split into ones which are +basically the same for all Coff targets except that they use the +external symbol format or use different values for certain constants. + + The generic routines are in `coffgen.c'. These routines work for +any Coff target. They use some hooks into the target specific code; +the hooks are in a `bfd_coff_backend_data' structure, one of which +exists for each target. + + The essentially similar target-specific routines are in +`coffcode.h'. This header file includes executable C code. The +various Coff targets first include the appropriate Coff header file, +make any special defines that are needed, and then include `coffcode.h'. + + Some of the Coff targets then also have additional routines in the +target source file itself. + + For example, `coff-i960.c' includes `coff/internal.h' and +`coff/i960.h'. It then defines a few constants, such as `I960', and +includes `coffcode.h'. Since the i960 has complex relocation types, +`coff-i960.c' also includes some code to manipulate the i960 relocs. +This code is not in `coffcode.h' because it would not be used by any +other target. +Bit twiddling +............. + +Each flavour of coff supported in BFD has its own header file +describing the external layout of the structures. There is also an +internal description of the coff layout, in `coff/internal.h'. A major +function of the coff backend is swapping the bytes and twiddling the +bits to translate the external form of the structures into the normal +internal form. This is all performed in the `bfd_swap'_thing_direction +routines. Some elements are different sizes between different versions +of coff; it is the duty of the coff version specific include file to +override the definitions of various packing routines in `coffcode.h'. +E.g., the size of line number entry in coff is sometimes 16 bits, and +sometimes 32 bits. `#define'ing `PUT_LNSZ_LNNO' and `GET_LNSZ_LNNO' +will select the correct one. No doubt, some day someone will find a +version of coff which has a varying field size not catered to at the +moment. To port BFD, that person will have to add more `#defines'. +Three of the bit twiddling routines are exported to `gdb'; +`coff_swap_aux_in', `coff_swap_sym_in' and `coff_swap_linno_in'. `GDB' +reads the symbol table on its own, but uses BFD to fix things up. More +of the bit twiddlers are exported for `gas'; `coff_swap_aux_out', +`coff_swap_sym_out', `coff_swap_lineno_out', `coff_swap_reloc_out', +`coff_swap_filehdr_out', `coff_swap_aouthdr_out', +`coff_swap_scnhdr_out'. `Gas' currently keeps track of all the symbol +table and reloc drudgery itself, thereby saving the internal BFD +overhead, but uses BFD to swap things on the way out, making cross +ports much safer. Doing so also allows BFD (and thus the linker) to +use the same header files as `gas', which makes one avenue to disaster +disappear. +Symbol reading +.............. + +The simple canonical form for symbols used by BFD is not rich enough to +keep all the information available in a coff symbol table. The back end +gets around this problem by keeping the original symbol table around, +"behind the scenes". + + When a symbol table is requested (through a call to +`bfd_canonicalize_symtab'), a request gets through to +`coff_get_normalized_symtab'. This reads the symbol table from the coff +file and swaps all the structures inside into the internal form. It +also fixes up all the pointers in the table (represented in the file by +offsets from the first symbol in the table) into physical pointers to +elements in the new internal table. This involves some work since the +meanings of fields change depending upon context: a field that is a +pointer to another structure in the symbol table at one moment may be +the size in bytes of a structure at the next. Another pass is made +over the table. All symbols which mark file names (`C_FILE' symbols) +are modified so that the internal string points to the value in the +auxent (the real filename) rather than the normal text associated with +the symbol (`".file"'). + + At this time the symbol names are moved around. Coff stores all +symbols less than nine characters long physically within the symbol +table; longer strings are kept at the end of the file in the string +table. This pass moves all strings into memory and replaces them with +pointers to the strings. + + The symbol table is massaged once again, this time to create the +canonical table used by the BFD application. Each symbol is inspected +in turn, and a decision made (using the `sclass' field) about the +various flags to set in the `asymbol'. *Note Symbols::. The generated +canonical table shares strings with the hidden internal symbol table. + + Any linenumbers are read from the coff file too, and attached to the +symbols which own the functions the linenumbers belong to. +Symbol writing +.............. + +Writing a symbol to a coff file which didn't come from a coff file will +lose any debugging information. The `asymbol' structure remembers the +BFD from which the symbol was taken, and on output the back end makes +sure that the same destination target as source target is present. + + When the symbols have come from a coff file then all the debugging +information is preserved. + + Symbol tables are provided for writing to the back end in a vector +of pointers to pointers. This allows applications like the linker to +accumulate and output large symbol tables without having to do too much +byte copying. + + This function runs through the provided symbol table and patches +each symbol marked as a file place holder (`C_FILE') to point to the +next file place holder in the list. It also marks each `offset' field +in the list with the offset from the first symbol of the current symbol. + + Another function of this procedure is to turn the canonical value +form of BFD into the form used by coff. Internally, BFD expects symbol +values to be offsets from a section base; so a symbol physically at +0x120, but in a section starting at 0x100, would have the value 0x20. +Coff expects symbols to contain their final value, so symbols have +their values changed at this point to reflect their sum with their +owning section. This transformation uses the `output_section' field of +the `asymbol''s `asection' *Note Sections::. + + * `coff_mangle_symbols' This routine runs though the provided symbol +table and uses the offsets generated by the previous pass and the +pointers generated when the symbol table was read in to create the +structured hierachy required by coff. It changes each pointer to a +symbol into the index into the symbol table of the asymbol. + + * `coff_write_symbols' This routine runs through the symbol table +and patches up the symbols from their internal form into the coff way, +calls the bit twiddlers, and writes out the table to the file. +`coff_symbol_type' +.................. + +*Description* +The hidden information for an `asymbol' is described in a +`combined_entry_type': +. + typedef struct coff_ptr_struct + { + + /* Remembers the offset from the first symbol in the file for + this symbol. Generated by coff_renumber_symbols. */ + unsigned int offset; + + /* Should the value of this symbol be renumbered. Used for + XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */ + unsigned int fix_value : 1; + + /* Should the tag field of this symbol be renumbered. + Created by coff_pointerize_aux. */ + unsigned int fix_tag : 1; + + /* Should the endidx field of this symbol be renumbered. + Created by coff_pointerize_aux. */ + unsigned int fix_end : 1; + + /* Should the x_csect.x_scnlen field be renumbered. + Created by coff_pointerize_aux. */ + unsigned int fix_scnlen : 1; + + /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the + index into the line number entries. Set by + coff_slurp_symbol_table. */ + unsigned int fix_line : 1; + + /* The container for the symbol structure as read and translated + from the file. */ + + union { + union internal_auxent auxent; + struct internal_syment syment; + } u; + } combined_entry_type; + + + /* Each canonical asymbol really looks like this: */ + + typedef struct coff_symbol_struct + { + /* The actual symbol which the rest of BFD works with */ + asymbol symbol; + + /* A pointer to the hidden information for this symbol */ + combined_entry_type *native; + + /* A pointer to the linenumber information for this symbol */ + struct lineno_cache_entry *lineno; + + /* Have the line numbers been relocated yet ? */ + boolean done_lineno; + } coff_symbol_type; + +`bfd_coff_backend_data' +....................... + + Special entry points for gdb to swap in coff symbol table parts: + typedef struct + { + void (*_bfd_coff_swap_aux_in) PARAMS (( + bfd *abfd, + PTR ext, + int type, + int class, + int indaux, + int numaux, + PTR in)); + + void (*_bfd_coff_swap_sym_in) PARAMS (( + bfd *abfd , + PTR ext, + PTR in)); + + void (*_bfd_coff_swap_lineno_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + Special entry points for gas to swap out coff parts: + unsigned int (*_bfd_coff_swap_aux_out) PARAMS (( + bfd *abfd, + PTR in, + int type, + int class, + int indaux, + int numaux, + PTR ext)); + + unsigned int (*_bfd_coff_swap_sym_out) PARAMS (( + bfd *abfd, + PTR in, + PTR ext)); + + unsigned int (*_bfd_coff_swap_lineno_out) PARAMS (( + bfd *abfd, + PTR in, + PTR ext)); + + unsigned int (*_bfd_coff_swap_reloc_out) PARAMS (( + bfd *abfd, + PTR src, + PTR dst)); + + unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS (( + bfd *abfd, + PTR in, + PTR out)); + + unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS (( + bfd *abfd, + PTR in, + PTR out)); + + unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS (( + bfd *abfd, + PTR in, + PTR out)); + Special entry points for generic COFF routines to call target +dependent COFF routines: + unsigned int _bfd_filhsz; + unsigned int _bfd_aoutsz; + unsigned int _bfd_scnhsz; + unsigned int _bfd_symesz; + unsigned int _bfd_auxesz; + unsigned int _bfd_relsz; + unsigned int _bfd_linesz; + boolean _bfd_coff_long_filenames; + boolean _bfd_coff_long_section_names; + unsigned int _bfd_coff_default_section_alignment_power; + void (*_bfd_coff_swap_filehdr_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + void (*_bfd_coff_swap_aouthdr_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + void (*_bfd_coff_swap_scnhdr_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + void (*_bfd_coff_swap_reloc_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + boolean (*_bfd_coff_bad_format_hook) PARAMS (( + bfd *abfd, + PTR internal_filehdr)); + boolean (*_bfd_coff_set_arch_mach_hook) PARAMS (( + bfd *abfd, + PTR internal_filehdr)); + PTR (*_bfd_coff_mkobject_hook) PARAMS (( + bfd *abfd, + PTR internal_filehdr, + PTR internal_aouthdr)); + flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( + bfd *abfd, + PTR internal_scnhdr, + const char *name)); + void (*_bfd_set_alignment_hook) PARAMS (( + bfd *abfd, + asection *sec, + PTR internal_scnhdr)); + boolean (*_bfd_coff_slurp_symbol_table) PARAMS (( + bfd *abfd)); + boolean (*_bfd_coff_symname_in_debug) PARAMS (( + bfd *abfd, + struct internal_syment *sym)); + boolean (*_bfd_coff_pointerize_aux_hook) PARAMS (( + bfd *abfd, + combined_entry_type *table_base, + combined_entry_type *symbol, + unsigned int indaux, + combined_entry_type *aux)); + boolean (*_bfd_coff_print_aux) PARAMS (( + bfd *abfd, + FILE *file, + combined_entry_type *table_base, + combined_entry_type *symbol, + combined_entry_type *aux, + unsigned int indaux)); + void (*_bfd_coff_reloc16_extra_cases) PARAMS (( + bfd *abfd, + struct bfd_link_info *link_info, + struct bfd_link_order *link_order, + arelent *reloc, + bfd_byte *data, + unsigned int *src_ptr, + unsigned int *dst_ptr)); + int (*_bfd_coff_reloc16_estimate) PARAMS (( + bfd *abfd, + asection *input_section, + arelent *r, + unsigned int shrink, + struct bfd_link_info *link_info)); + boolean (*_bfd_coff_sym_is_global) PARAMS (( + bfd *abfd, + struct internal_syment *)); + boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( + bfd *abfd)); + boolean (*_bfd_coff_start_final_link) PARAMS (( + bfd *output_bfd, + struct bfd_link_info *info)); + boolean (*_bfd_coff_relocate_section) PARAMS (( + bfd *output_bfd, + struct bfd_link_info *info, + bfd *input_bfd, + asection *input_section, + bfd_byte *contents, + struct internal_reloc *relocs, + struct internal_syment *syms, + asection **sections)); + reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS (( + bfd *abfd, + asection *sec, + struct internal_reloc *rel, + struct coff_link_hash_entry *h, + struct internal_syment *sym, + bfd_vma *addendp)); + boolean (*_bfd_coff_adjust_symndx) PARAMS (( + bfd *obfd, + struct bfd_link_info *info, + bfd *ibfd, + asection *sec, + struct internal_reloc *reloc, + boolean *adjustedp)); + boolean (*_bfd_coff_link_add_one_symbol) PARAMS (( + struct bfd_link_info *info, + bfd *abfd, + const char *name, + flagword flags, + asection *section, + bfd_vma value, + const char *string, + boolean copy, + boolean collect, + struct bfd_link_hash_entry **hashp)); + + } bfd_coff_backend_data; + + #define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data) + + #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ + ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) + + #define bfd_coff_swap_sym_in(a,e,i) \ + ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) + + #define bfd_coff_swap_lineno_in(a,e,i) \ + ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) + + #define bfd_coff_swap_reloc_out(abfd, i, o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) + + #define bfd_coff_swap_lineno_out(abfd, i, o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) + + #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ + ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) + + #define bfd_coff_swap_sym_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) + + #define bfd_coff_swap_scnhdr_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) + + #define bfd_coff_swap_filehdr_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) + + #define bfd_coff_swap_aouthdr_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) + + #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) + #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) + #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) + #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) + #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) + #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) + #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) + #define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames) + #define bfd_coff_long_section_names(abfd) \ + (coff_backend_info (abfd)->_bfd_coff_long_section_names) + #define bfd_coff_default_section_alignment_power(abfd) \ + (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) + #define bfd_coff_swap_filehdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) + + #define bfd_coff_swap_aouthdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) + + #define bfd_coff_swap_scnhdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) + + #define bfd_coff_swap_reloc_in(abfd, i, o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) + + #define bfd_coff_bad_format_hook(abfd, filehdr) \ + ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) + + #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ + ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) + #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ + ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) + + #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\ + ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name)) + + #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ + ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) + + #define bfd_coff_slurp_symbol_table(abfd)\ + ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) + + #define bfd_coff_symname_in_debug(abfd, sym)\ + ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) + + #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ + ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ + (abfd, file, base, symbol, aux, indaux)) + + #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\ + ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ + (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) + + #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ + ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ + (abfd, section, reloc, shrink, link_info)) + + #define bfd_coff_sym_is_global(abfd, sym)\ + ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\ + (abfd, sym)) + + #define bfd_coff_compute_section_file_positions(abfd)\ + ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ + (abfd)) + + #define bfd_coff_start_final_link(obfd, info)\ + ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ + (obfd, info)) + #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ + ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ + (obfd, info, ibfd, o, con, rel, isyms, secs)) + #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ + ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ + (abfd, sec, rel, h, sym, addendp)) + #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ + ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ + (obfd, info, ibfd, sec, rel, adjustedp)) + #define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\ + ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ + (info, abfd, name, flags, section, value, string, cp, coll, hashp)) + +Writing relocations +................... + + To write relocations, the back end steps though the canonical +relocation table and create an `internal_reloc'. The symbol index to +use is removed from the `offset' field in the symbol table supplied. +The address comes directly from the sum of the section base address and +the relocation offset; the type is dug directly from the howto field. +Then the `internal_reloc' is swapped into the shape of an +`external_reloc' and written out to disk. +Reading linenumbers +................... + +Creating the linenumber table is done by reading in the entire coff +linenumber table, and creating another table for internal use. + + A coff linenumber table is structured so that each function is +marked as having a line number of 0. Each line within the function is +an offset from the first line in the function. The base of the line +number information for the table is stored in the symbol associated +with the function. + + The information is copied from the external to the internal table, +and each symbol which marks a function is marked by pointing its... + + How does this work ? +Reading relocations +................... + +Coff relocations are easily transformed into the internal BFD form +(`arelent'). + + Reading a coff relocation table is done in the following stages: + + * Read the entire coff relocation table into memory. + + * Process each relocation in turn; first swap it from the external + to the internal form. + + * Turn the symbol referenced in the relocation's symbol index into a + pointer into the canonical symbol table. This table is the same + as the one returned by a call to `bfd_canonicalize_symtab'. The + back end will call that routine and save the result if a + canonicalization hasn't been done. + + * The reloc index is turned into a pointer to a howto structure, in + a back end specific way. For instance, the 386 and 960 use the + `r_type' to directly produce an index into a howto table vector; + the 88k subtracts a number from the `r_type' field and creates an + addend field. + +File: bfd.info, Node: elf, Prev: coff, Up: BFD back ends + +ELF backends +============ + +BFD support for ELF formats is being worked on. Currently, the best +supported back ends are for sparc and i386 (running svr4 or Solaris 2). + + Documentation of the internals of the support code still needs to be +written. The code is changing quickly enough that we haven't bothered +yet. +`bfd_elf_find_section' +...................... + +*Synopsis* + struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name); + *Description* +Helper functions for GDB to locate the string tables. Since BFD hides +string tables from callers, GDB needs to use an internal hook to find +them. Sun's .stabstr, in particular, isn't even pointed to by the +.stab section, so ordinary mechanisms wouldn't work to find it, even if +we had some. + +File: bfd.info, Node: Index, Prev: BFD back ends, Up: Top + +Index +***** + +* Menu: + +* _bfd_final_link_relocate: Relocating the section contents. +* _bfd_generic_link_add_archive_symbols: Adding symbols from an archive. +* _bfd_generic_link_add_one_symbol: Adding symbols from an object file. +* _bfd_link_add_symbols in target vector: Adding Symbols to the Hash Table. +* _bfd_link_final_link in target vector: Performing the Final Link. +* _bfd_link_hash_table_create in target vector: Creating a Linker Hash Table. +* _bfd_relocate_contents: Relocating the section contents. +* aout_SIZE_machine_type: aout. +* aout_SIZE_mkobject: aout. +* aout_SIZE_new_section_hook: aout. +* aout_SIZE_set_arch_mach: aout. +* aout_SIZE_some_aout_object_p: aout. +* aout_SIZE_swap_exec_header_in: aout. +* aout_SIZE_swap_exec_header_out: aout. +* arelent_chain: typedef arelent. +* BFD: Overview. +* BFD canonical format: Canonical format. +* bfd_alloc: Opening and Closing. +* bfd_arch_bits_per_address: Architectures. +* bfd_arch_bits_per_byte: Architectures. +* bfd_arch_get_compatible: Architectures. +* bfd_cache_close: File Caching. +* bfd_cache_init: File Caching. +* bfd_cache_lookup: File Caching. +* bfd_cache_lookup_worker: File Caching. +* BFD_CACHE_MAX_OPEN macro: File Caching. +* bfd_canonicalize_reloc: BFD front end. +* bfd_canonicalize_symtab: symbol handling functions. +* bfd_check_format: Formats. +* bfd_check_format_matches: Formats. +* bfd_close: Opening and Closing. +* bfd_close_all_done: Opening and Closing. +* bfd_coff_backend_data: coff. +* bfd_copy_private_bfd_data: BFD front end. +* bfd_copy_private_section_data: section prototypes. +* bfd_copy_private_symbol_data: symbol handling functions. +* bfd_core_file_failing_command: Core Files. +* bfd_core_file_failing_signal: Core Files. +* bfd_create: Opening and Closing. +* bfd_decode_symclass: symbol handling functions. +* bfd_default_arch_struct: Architectures. +* bfd_default_compatible: Architectures. +* bfd_default_reloc_type_lookup: howto manager. +* bfd_default_scan: Architectures. +* bfd_default_set_arch_mach: Architectures. +* bfd_elf_find_section: elf. +* bfd_errmsg: BFD front end. +* bfd_fdopenr: Opening and Closing. +* bfd_find_target: bfd_target. +* bfd_format_string: Formats. +* bfd_generic_get_relocated_section_contents: howto manager. +* bfd_generic_relax_section: howto manager. +* bfd_get_arch: Architectures. +* bfd_get_arch_info: Architectures. +* bfd_get_error: BFD front end. +* bfd_get_gp_size: BFD front end. +* bfd_get_mach: Architectures. +* bfd_get_mtime: BFD front end. +* bfd_get_next_mapent: Archives. +* bfd_get_reloc_code_name: howto manager. +* bfd_get_reloc_size: typedef arelent. +* bfd_get_reloc_upper_bound: BFD front end. +* bfd_get_section_by_name: section prototypes. +* bfd_get_section_contents: section prototypes. +* bfd_get_size <1>: Internal. +* bfd_get_size: BFD front end. +* bfd_get_symtab_upper_bound: symbol handling functions. +* bfd_h_put_size: Internal. +* bfd_hash_allocate: Creating and Freeing a Hash Table. +* bfd_hash_lookup: Looking Up or Entering a String. +* bfd_hash_newfunc: Creating and Freeing a Hash Table. +* bfd_hash_table_free: Creating and Freeing a Hash Table. +* bfd_hash_table_init: Creating and Freeing a Hash Table. +* bfd_hash_table_init_n: Creating and Freeing a Hash Table. +* bfd_hash_traverse: Traversing a Hash Table. +* bfd_init: Initialization. +* bfd_install_relocation: typedef arelent. +* bfd_is_local_label: symbol handling functions. +* bfd_is_local_label_name: symbol handling functions. +* bfd_last_cache: File Caching. +* bfd_link_split_section: Writing the symbol table. +* bfd_log2: Internal. +* bfd_lookup_arch: Architectures. +* bfd_make_debug_symbol: symbol handling functions. +* bfd_make_empty_symbol: symbol handling functions. +* bfd_make_section: section prototypes. +* bfd_make_section_anyway: section prototypes. +* bfd_make_section_old_way: section prototypes. +* bfd_map_over_sections: section prototypes. +* bfd_merge_private_bfd_data: BFD front end. +* bfd_open_file: File Caching. +* bfd_openr: Opening and Closing. +* bfd_openr_next_archived_file: Archives. +* bfd_openstreamr: Opening and Closing. +* bfd_openw: Opening and Closing. +* bfd_perform_relocation: typedef arelent. +* bfd_perror: BFD front end. +* bfd_print_symbol_vandf: symbol handling functions. +* bfd_printable_arch_mach: Architectures. +* bfd_printable_name: Architectures. +* bfd_put_size: Internal. +* BFD_RELOC_12_PCREL: howto manager. +* BFD_RELOC_14: howto manager. +* BFD_RELOC_16: howto manager. +* BFD_RELOC_16_BASEREL: howto manager. +* BFD_RELOC_16_GOT_PCREL: howto manager. +* BFD_RELOC_16_GOTOFF: howto manager. +* BFD_RELOC_16_PCREL: howto manager. +* BFD_RELOC_16_PCREL_S2: howto manager. +* BFD_RELOC_16_PLT_PCREL: howto manager. +* BFD_RELOC_16_PLTOFF: howto manager. +* BFD_RELOC_23_PCREL_S2: howto manager. +* BFD_RELOC_24: howto manager. +* BFD_RELOC_24_PCREL: howto manager. +* BFD_RELOC_24_PLT_PCREL: howto manager. +* BFD_RELOC_26: howto manager. +* BFD_RELOC_32: howto manager. +* BFD_RELOC_32_BASEREL: howto manager. +* BFD_RELOC_32_GOT_PCREL: howto manager. +* BFD_RELOC_32_GOTOFF: howto manager. +* BFD_RELOC_32_PCREL: howto manager. +* BFD_RELOC_32_PCREL_S2: howto manager. +* BFD_RELOC_32_PLT_PCREL: howto manager. +* BFD_RELOC_32_PLTOFF: howto manager. +* BFD_RELOC_386_COPY: howto manager. +* BFD_RELOC_386_GLOB_DAT: howto manager. +* BFD_RELOC_386_GOT32: howto manager. +* BFD_RELOC_386_GOTOFF: howto manager. +* BFD_RELOC_386_GOTPC: howto manager. +* BFD_RELOC_386_JUMP_SLOT: howto manager. +* BFD_RELOC_386_PLT32: howto manager. +* BFD_RELOC_386_RELATIVE: howto manager. +* BFD_RELOC_64: howto manager. +* BFD_RELOC_64_PCREL: howto manager. +* BFD_RELOC_68K_GLOB_DAT: howto manager. +* BFD_RELOC_68K_JMP_SLOT: howto manager. +* BFD_RELOC_68K_RELATIVE: howto manager. +* BFD_RELOC_8: howto manager. +* BFD_RELOC_8_BASEREL: howto manager. +* BFD_RELOC_8_FFnn: howto manager. +* BFD_RELOC_8_GOT_PCREL: howto manager. +* BFD_RELOC_8_GOTOFF: howto manager. +* BFD_RELOC_8_PCREL: howto manager. +* BFD_RELOC_8_PLT_PCREL: howto manager. +* BFD_RELOC_8_PLTOFF: howto manager. +* BFD_RELOC_ALPHA_CODEADDR: howto manager. +* BFD_RELOC_ALPHA_ELF_LITERAL: howto manager. +* BFD_RELOC_ALPHA_GPDISP: howto manager. +* BFD_RELOC_ALPHA_GPDISP_HI16: howto manager. +* BFD_RELOC_ALPHA_GPDISP_LO16: howto manager. +* BFD_RELOC_ALPHA_HINT: howto manager. +* BFD_RELOC_ALPHA_LINKAGE: howto manager. +* BFD_RELOC_ALPHA_LITERAL: howto manager. +* BFD_RELOC_ALPHA_LITUSE: howto manager. +* BFD_RELOC_ARM_ADR_IMM: howto manager. +* BFD_RELOC_ARM_CP_OFF_IMM: howto manager. +* BFD_RELOC_ARM_HWLITERAL: howto manager. +* BFD_RELOC_ARM_IMMEDIATE: howto manager. +* BFD_RELOC_ARM_IN_POOL: howto manager. +* BFD_RELOC_ARM_LDR_IMM: howto manager. +* BFD_RELOC_ARM_LITERAL: howto manager. +* BFD_RELOC_ARM_MULTI: howto manager. +* BFD_RELOC_ARM_OFFSET_IMM: howto manager. +* BFD_RELOC_ARM_OFFSET_IMM8: howto manager. +* BFD_RELOC_ARM_PCREL_BRANCH: howto manager. +* BFD_RELOC_ARM_SHIFT_IMM: howto manager. +* BFD_RELOC_ARM_SWI: howto manager. +* BFD_RELOC_ARM_THUMB_ADD: howto manager. +* BFD_RELOC_ARM_THUMB_IMM: howto manager. +* BFD_RELOC_ARM_THUMB_OFFSET: howto manager. +* BFD_RELOC_ARM_THUMB_SHIFT: howto manager. +* bfd_reloc_code_type: howto manager. +* BFD_RELOC_CTOR: howto manager. +* BFD_RELOC_D10V_10_PCREL_L: howto manager. +* BFD_RELOC_D10V_10_PCREL_R: howto manager. +* BFD_RELOC_D10V_18: howto manager. +* BFD_RELOC_D10V_18_PCREL: howto manager. +* BFD_RELOC_GPREL16: howto manager. +* BFD_RELOC_GPREL32: howto manager. +* BFD_RELOC_HI16: howto manager. +* BFD_RELOC_HI16_BASEREL: howto manager. +* BFD_RELOC_HI16_GOTOFF: howto manager. +* BFD_RELOC_HI16_PLTOFF: howto manager. +* BFD_RELOC_HI16_S: howto manager. +* BFD_RELOC_HI16_S_BASEREL: howto manager. +* BFD_RELOC_HI16_S_GOTOFF: howto manager. +* BFD_RELOC_HI16_S_PLTOFF: howto manager. +* BFD_RELOC_HI22: howto manager. +* BFD_RELOC_I960_CALLJ: howto manager. +* BFD_RELOC_LO10: howto manager. +* BFD_RELOC_LO16: howto manager. +* BFD_RELOC_LO16_BASEREL: howto manager. +* BFD_RELOC_LO16_GOTOFF: howto manager. +* BFD_RELOC_LO16_PLTOFF: howto manager. +* BFD_RELOC_M32R_10_PCREL: howto manager. +* BFD_RELOC_M32R_18_PCREL: howto manager. +* BFD_RELOC_M32R_24: howto manager. +* BFD_RELOC_M32R_26_PCREL: howto manager. +* BFD_RELOC_M32R_HI16_SLO: howto manager. +* BFD_RELOC_M32R_HI16_ULO: howto manager. +* BFD_RELOC_M32R_LO16: howto manager. +* BFD_RELOC_M32R_SDA16: howto manager. +* BFD_RELOC_MIPS16_GPREL: howto manager. +* BFD_RELOC_MIPS16_JMP: howto manager. +* BFD_RELOC_MIPS_CALL16: howto manager. +* BFD_RELOC_MIPS_CALL_HI16: howto manager. +* BFD_RELOC_MIPS_CALL_LO16: howto manager. +* BFD_RELOC_MIPS_GOT16: howto manager. +* BFD_RELOC_MIPS_GOT_HI16: howto manager. +* BFD_RELOC_MIPS_GOT_LO16: howto manager. +* BFD_RELOC_MIPS_GPREL: howto manager. +* BFD_RELOC_MIPS_GPREL32: howto manager. +* BFD_RELOC_MIPS_JMP: howto manager. +* BFD_RELOC_MIPS_LITERAL: howto manager. +* BFD_RELOC_MN10300_16_PCREL: howto manager. +* BFD_RELOC_MN10300_32_PCREL: howto manager. +* BFD_RELOC_NONE: howto manager. +* BFD_RELOC_NS32K_DISP_16: howto manager. +* BFD_RELOC_NS32K_DISP_16_PCREL: howto manager. +* BFD_RELOC_NS32K_DISP_32: howto manager. +* BFD_RELOC_NS32K_DISP_32_PCREL: howto manager. +* BFD_RELOC_NS32K_DISP_8: howto manager. +* BFD_RELOC_NS32K_DISP_8_PCREL: howto manager. +* BFD_RELOC_NS32K_IMM_16: howto manager. +* BFD_RELOC_NS32K_IMM_16_PCREL: howto manager. +* BFD_RELOC_NS32K_IMM_32: howto manager. +* BFD_RELOC_NS32K_IMM_32_PCREL: howto manager. +* BFD_RELOC_NS32K_IMM_8: howto manager. +* BFD_RELOC_NS32K_IMM_8_PCREL: howto manager. +* BFD_RELOC_PCREL_HI16_S: howto manager. +* BFD_RELOC_PCREL_LO16: howto manager. +* BFD_RELOC_PPC_B16: howto manager. +* BFD_RELOC_PPC_B16_BRNTAKEN: howto manager. +* BFD_RELOC_PPC_B16_BRTAKEN: howto manager. +* BFD_RELOC_PPC_B26: howto manager. +* BFD_RELOC_PPC_BA16: howto manager. +* BFD_RELOC_PPC_BA16_BRNTAKEN: howto manager. +* BFD_RELOC_PPC_BA16_BRTAKEN: howto manager. +* BFD_RELOC_PPC_BA26: howto manager. +* BFD_RELOC_PPC_COPY: howto manager. +* BFD_RELOC_PPC_EMB_BIT_FLD: howto manager. +* BFD_RELOC_PPC_EMB_MRKREF: howto manager. +* BFD_RELOC_PPC_EMB_NADDR16: howto manager. +* BFD_RELOC_PPC_EMB_NADDR16_HA: howto manager. +* BFD_RELOC_PPC_EMB_NADDR16_HI: howto manager. +* BFD_RELOC_PPC_EMB_NADDR16_LO: howto manager. +* BFD_RELOC_PPC_EMB_NADDR32: howto manager. +* BFD_RELOC_PPC_EMB_RELSDA: howto manager. +* BFD_RELOC_PPC_EMB_RELSEC16: howto manager. +* BFD_RELOC_PPC_EMB_RELST_HA: howto manager. +* BFD_RELOC_PPC_EMB_RELST_HI: howto manager. +* BFD_RELOC_PPC_EMB_RELST_LO: howto manager. +* BFD_RELOC_PPC_EMB_SDA21: howto manager. +* BFD_RELOC_PPC_EMB_SDA2I16: howto manager. +* BFD_RELOC_PPC_EMB_SDA2REL: howto manager. +* BFD_RELOC_PPC_EMB_SDAI16: howto manager. +* BFD_RELOC_PPC_GLOB_DAT: howto manager. +* BFD_RELOC_PPC_JMP_SLOT: howto manager. +* BFD_RELOC_PPC_LOCAL24PC: howto manager. +* BFD_RELOC_PPC_RELATIVE: howto manager. +* BFD_RELOC_PPC_TOC16: howto manager. +* BFD_RELOC_RVA: howto manager. +* BFD_RELOC_SH_ALIGN: howto manager. +* BFD_RELOC_SH_CODE: howto manager. +* BFD_RELOC_SH_COUNT: howto manager. +* BFD_RELOC_SH_DATA: howto manager. +* BFD_RELOC_SH_IMM4: howto manager. +* BFD_RELOC_SH_IMM4BY2: howto manager. +* BFD_RELOC_SH_IMM4BY4: howto manager. +* BFD_RELOC_SH_IMM8: howto manager. +* BFD_RELOC_SH_IMM8BY2: howto manager. +* BFD_RELOC_SH_IMM8BY4: howto manager. +* BFD_RELOC_SH_LABEL: howto manager. +* BFD_RELOC_SH_PCDISP12BY2: howto manager. +* BFD_RELOC_SH_PCDISP8BY2: howto manager. +* BFD_RELOC_SH_PCRELIMM8BY2: howto manager. +* BFD_RELOC_SH_PCRELIMM8BY4: howto manager. +* BFD_RELOC_SH_SWITCH16: howto manager. +* BFD_RELOC_SH_SWITCH32: howto manager. +* BFD_RELOC_SH_USES: howto manager. +* BFD_RELOC_SPARC13: howto manager. +* BFD_RELOC_SPARC22: howto manager. +* BFD_RELOC_SPARC_10: howto manager. +* BFD_RELOC_SPARC_11: howto manager. +* BFD_RELOC_SPARC_5: howto manager. +* BFD_RELOC_SPARC_6: howto manager. +* BFD_RELOC_SPARC_64: howto manager. +* BFD_RELOC_SPARC_7: howto manager. +* BFD_RELOC_SPARC_BASE13: howto manager. +* BFD_RELOC_SPARC_BASE22: howto manager. +* BFD_RELOC_SPARC_COPY: howto manager. +* BFD_RELOC_SPARC_GLOB_DAT: howto manager. +* BFD_RELOC_SPARC_GLOB_JMP: howto manager. +* BFD_RELOC_SPARC_GOT10: howto manager. +* BFD_RELOC_SPARC_GOT13: howto manager. +* BFD_RELOC_SPARC_GOT22: howto manager. +* BFD_RELOC_SPARC_HH22: howto manager. +* BFD_RELOC_SPARC_HM10: howto manager. +* BFD_RELOC_SPARC_JMP_SLOT: howto manager. +* BFD_RELOC_SPARC_LM22: howto manager. +* BFD_RELOC_SPARC_OLO10: howto manager. +* BFD_RELOC_SPARC_PC10: howto manager. +* BFD_RELOC_SPARC_PC22: howto manager. +* BFD_RELOC_SPARC_PC_HH22: howto manager. +* BFD_RELOC_SPARC_PC_HM10: howto manager. +* BFD_RELOC_SPARC_PC_LM22: howto manager. +* BFD_RELOC_SPARC_RELATIVE: howto manager. +* BFD_RELOC_SPARC_UA32: howto manager. +* BFD_RELOC_SPARC_WDISP16: howto manager. +* BFD_RELOC_SPARC_WDISP19: howto manager. +* BFD_RELOC_SPARC_WDISP22: howto manager. +* BFD_RELOC_SPARC_WPLT30: howto manager. +* bfd_reloc_type_lookup: howto manager. +* bfd_scan_arch: Architectures. +* bfd_scan_vma: BFD front end. +* bfd_set_arch_info: Architectures. +* bfd_set_archive_head: Archives. +* bfd_set_default_target: bfd_target. +* bfd_set_error: BFD front end. +* bfd_set_error_handler: BFD front end. +* bfd_set_error_program_name: BFD front end. +* bfd_set_file_flags: BFD front end. +* bfd_set_format: Formats. +* bfd_set_gp_size: BFD front end. +* bfd_set_private_flags: BFD front end. +* bfd_set_reloc: BFD front end. +* bfd_set_section_contents: section prototypes. +* bfd_set_section_flags: section prototypes. +* bfd_set_section_size: section prototypes. +* bfd_set_start_address: BFD front end. +* bfd_set_symtab: symbol handling functions. +* bfd_symbol_info: symbol handling functions. +* bfd_target_list: bfd_target. +* bfd_write_bigendian_4byte_int: Internal. +* coff_symbol_type: coff. +* core_file_matches_executable_p: Core Files. +* Hash tables: Hash Tables. +* internal object-file format: Canonical format. +* Linker: Linker Functions. +* stuff: BFD front end. +* target vector (_bfd_final_link): Performing the Final Link. +* target vector (_bfd_link_add_symbols): Adding Symbols to the Hash Table. +* target vector (_bfd_link_hash_table_create): Creating a Linker Hash Table. +* The HOWTO Macro: typedef arelent. +* what is it?: Overview. + + diff -urN binutils-2.7/bfd/doc/bfd.texi binutils-2.8/bfd/doc/bfd.texi --- binutils-2.7/bfd/doc/bfd.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/bfd.texi Wed Apr 30 12:56:26 1997 @@ -0,0 +1,585 @@ +@section @code{typedef bfd} +A BFD has type @code{bfd}; objects of this type are the +cornerstone of any application using BFD. Using BFD +consists of making references though the BFD and to data in the BFD. + +Here is the structure that defines the type @code{bfd}. It +contains the major data about the file and pointers +to the rest of the data. +@* +. +@example +struct _bfd +@{ + /* The filename the application opened the BFD with. */ + CONST char *filename; + + /* A pointer to the target jump table. */ + const struct bfd_target *xvec; + + /* To avoid dragging too many header files into every file that + includes `@code{bfd.h}', IOSTREAM has been declared as a "char + *", and MTIME as a "long". Their correct types, to which they + are cast when used, are "FILE *" and "time_t". The iostream + is the result of an fopen on the filename. However, if the + BFD_IN_MEMORY flag is set, then iostream is actually a pointer + to a bfd_in_memory struct. */ + PTR iostream; + + /* Is the file descriptor being cached? That is, can it be closed as + needed, and re-opened when accessed later? */ + + boolean cacheable; + + /* Marks whether there was a default target specified when the + BFD was opened. This is used to select which matching algorithm + to use to choose the back end. */ + + boolean target_defaulted; + + /* The caching routines use these to maintain a + least-recently-used list of BFDs */ + + struct _bfd *lru_prev, *lru_next; + + /* When a file is closed by the caching routines, BFD retains + state information on the file here: */ + + file_ptr where; + + /* and here: (``once'' means at least once) */ + + boolean opened_once; + + /* Set if we have a locally maintained mtime value, rather than + getting it from the file each time: */ + + boolean mtime_set; + + /* File modified time, if mtime_set is true: */ + + long mtime; + + /* Reserved for an unimplemented file locking extension.*/ + + int ifd; + + /* The format which belongs to the BFD. (object, core, etc.) */ + + bfd_format format; + + /* The direction the BFD was opened with*/ + + enum bfd_direction @{no_direction = 0, + read_direction = 1, + write_direction = 2, + both_direction = 3@} direction; + + /* Format_specific flags*/ + + flagword flags; + + /* Currently my_archive is tested before adding origin to + anything. I believe that this can become always an add of + origin, with origin set to 0 for non archive files. */ + + file_ptr origin; + + /* Remember when output has begun, to stop strange things + from happening. */ + boolean output_has_begun; + + /* Pointer to linked list of sections*/ + struct sec *sections; + + /* The number of sections */ + unsigned int section_count; + + /* Stuff only useful for object files: + The start address. */ + bfd_vma start_address; + + /* Used for input and output*/ + unsigned int symcount; + + /* Symbol table for output BFD (with symcount entries) */ + struct symbol_cache_entry **outsymbols; + + /* Pointer to structure which contains architecture information*/ + const struct bfd_arch_info *arch_info; + + /* Stuff only useful for archives:*/ + PTR arelt_data; + struct _bfd *my_archive; /* The containing archive BFD. */ + struct _bfd *next; /* The next BFD in the archive. */ + struct _bfd *archive_head; /* The first BFD in the archive. */ + boolean has_armap; + + /* A chain of BFD structures involved in a link. */ + struct _bfd *link_next; + + /* A field used by _bfd_generic_link_add_archive_symbols. This will + be used only for archive elements. */ + int archive_pass; + + /* Used by the back end to hold private data. */ + + union + @{ + struct aout_data_struct *aout_data; + struct artdata *aout_ar_data; + struct _oasys_data *oasys_obj_data; + struct _oasys_ar_data *oasys_ar_data; + struct coff_tdata *coff_obj_data; + struct pe_tdata *pe_obj_data; + struct xcoff_tdata *xcoff_obj_data; + struct ecoff_tdata *ecoff_obj_data; + struct ieee_data_struct *ieee_data; + struct ieee_ar_data_struct *ieee_ar_data; + struct srec_data_struct *srec_data; + struct ihex_data_struct *ihex_data; + struct tekhex_data_struct *tekhex_data; + struct elf_obj_tdata *elf_obj_data; + struct nlm_obj_tdata *nlm_obj_data; + struct bout_data_struct *bout_data; + struct sun_core_struct *sun_core_data; + struct trad_core_struct *trad_core_data; + struct som_data_struct *som_data; + struct hpux_core_struct *hpux_core_data; + struct hppabsd_core_struct *hppabsd_core_data; + struct sgi_core_struct *sgi_core_data; + struct lynx_core_struct *lynx_core_data; + struct osf_core_struct *osf_core_data; + struct cisco_core_struct *cisco_core_data; + struct versados_data_struct *versados_data; + struct netbsd_core_struct *netbsd_core_data; + PTR any; + @} tdata; + + /* Used by the application to hold private data*/ + PTR usrdata; + + /* Where all the allocated stuff under this BFD goes. This is a + struct objalloc *, but we use PTR to avoid requiring the inclusion of + objalloc.h. */ + PTR memory; +@}; + +@end example +@section Error reporting +Most BFD functions return nonzero on success (check their +individual documentation for precise semantics). On an error, +they call @code{bfd_set_error} to set an error condition that callers +can check by calling @code{bfd_get_error}. +If that returns @code{bfd_error_system_call}, then check +@code{errno}. + +The easiest way to report a BFD error to the user is to +use @code{bfd_perror}. +@* +@subsection Type @code{bfd_error_type} +The values returned by @code{bfd_get_error} are defined by the +enumerated type @code{bfd_error_type}. +@* +. +@example +typedef enum bfd_error +@{ + bfd_error_no_error = 0, + bfd_error_system_call, + bfd_error_invalid_target, + bfd_error_wrong_format, + bfd_error_invalid_operation, + bfd_error_no_memory, + bfd_error_no_symbols, + bfd_error_no_armap, + bfd_error_no_more_archived_files, + bfd_error_malformed_archive, + bfd_error_file_not_recognized, + bfd_error_file_ambiguously_recognized, + bfd_error_no_contents, + bfd_error_nonrepresentable_section, + bfd_error_no_debug_section, + bfd_error_bad_value, + bfd_error_file_truncated, + bfd_error_file_too_big, + bfd_error_invalid_error_code +@} bfd_error_type; + +@end example +@findex bfd_get_error +@subsubsection @code{bfd_get_error} +@strong{Synopsis} +@example +bfd_error_type bfd_get_error (void); +@end example +@strong{Description}@* +Return the current BFD error condition. +@* +@findex bfd_set_error +@subsubsection @code{bfd_set_error} +@strong{Synopsis} +@example +void bfd_set_error (bfd_error_type error_tag); +@end example +@strong{Description}@* +Set the BFD error condition to be @var{error_tag}. +@* +@findex bfd_errmsg +@subsubsection @code{bfd_errmsg} +@strong{Synopsis} +@example +CONST char *bfd_errmsg (bfd_error_type error_tag); +@end example +@strong{Description}@* +Return a string describing the error @var{error_tag}, or +the system error if @var{error_tag} is @code{bfd_error_system_call}. +@* +@findex bfd_perror +@subsubsection @code{bfd_perror} +@strong{Synopsis} +@example +void bfd_perror (CONST char *message); +@end example +@strong{Description}@* +Print to the standard error stream a string describing the +last BFD error that occurred, or the last system error if +the last BFD error was a system call failure. If @var{message} +is non-NULL and non-empty, the error string printed is preceded +by @var{message}, a colon, and a space. It is followed by a newline. +@* +@subsection BFD error handler +Some BFD functions want to print messages describing the +problem. They call a BFD error handler function. This +function may be overriden by the program. + +The BFD error handler acts like printf. +@* +. +@example +typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...)); + +@end example +@findex bfd_set_error_handler +@subsubsection @code{bfd_set_error_handler} +@strong{Synopsis} +@example +bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); +@end example +@strong{Description}@* +Set the BFD error handler function. Returns the previous +function. +@* +@findex bfd_set_error_program_name +@subsubsection @code{bfd_set_error_program_name} +@strong{Synopsis} +@example +void bfd_set_error_program_name (const char *); +@end example +@strong{Description}@* +Set the program name to use when printing a BFD error. This +is printed before the error message followed by a colon and +space. The string must not be changed after it is passed to +this function. +@* +@section Symbols + +@* +@findex bfd_get_reloc_upper_bound +@subsubsection @code{bfd_get_reloc_upper_bound} +@strong{Synopsis} +@example +long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect); +@end example +@strong{Description}@* +Return the number of bytes required to store the +relocation information associated with section @var{sect} +attached to bfd @var{abfd}. If an error occurs, return -1. +@* +@findex bfd_canonicalize_reloc +@subsubsection @code{bfd_canonicalize_reloc} +@strong{Synopsis} +@example +long bfd_canonicalize_reloc + (bfd *abfd, + asection *sec, + arelent **loc, + asymbol **syms); +@end example +@strong{Description}@* +Call the back end associated with the open BFD +@var{abfd} and translate the external form of the relocation +information attached to @var{sec} into the internal canonical +form. Place the table into memory at @var{loc}, which has +been preallocated, usually by a call to +@code{bfd_get_reloc_upper_bound}. Returns the number of relocs, or +-1 on error. + +The @var{syms} table is also needed for horrible internal magic +reasons. +@* +@findex bfd_set_reloc +@subsubsection @code{bfd_set_reloc} +@strong{Synopsis} +@example +void bfd_set_reloc + (bfd *abfd, asection *sec, arelent **rel, unsigned int count) +@end example +@strong{Description}@* +Set the relocation pointer and count within +section @var{sec} to the values @var{rel} and @var{count}. +The argument @var{abfd} is ignored. +@* +@findex bfd_set_file_flags +@subsubsection @code{bfd_set_file_flags} +@strong{Synopsis} +@example +boolean bfd_set_file_flags(bfd *abfd, flagword flags); +@end example +@strong{Description}@* +Set the flag word in the BFD @var{abfd} to the value @var{flags}. + +Possible errors are: +@itemize @bullet + +@item +@code{bfd_error_wrong_format} - The target bfd was not of object format. +@item +@code{bfd_error_invalid_operation} - The target bfd was open for reading. +@item +@code{bfd_error_invalid_operation} - +The flag word contained a bit which was not applicable to the +type of file. E.g., an attempt was made to set the @code{D_PAGED} bit +on a BFD format which does not support demand paging. +@end itemize +@* +@findex bfd_set_start_address +@subsubsection @code{bfd_set_start_address} +@strong{Synopsis} +@example +boolean bfd_set_start_address(bfd *abfd, bfd_vma vma); +@end example +@strong{Description}@* +Make @var{vma} the entry point of output BFD @var{abfd}. +@* +@strong{Returns}@* +Returns @code{true} on success, @code{false} otherwise. +@* +@findex bfd_get_mtime +@subsubsection @code{bfd_get_mtime} +@strong{Synopsis} +@example +long bfd_get_mtime(bfd *abfd); +@end example +@strong{Description}@* +Return the file modification time (as read from the file system, or +from the archive header for archive members). +@* +@findex bfd_get_size +@subsubsection @code{bfd_get_size} +@strong{Synopsis} +@example +long bfd_get_size(bfd *abfd); +@end example +@strong{Description}@* +Return the file size (as read from file system) for the file +associated with BFD @var{abfd}. + +The initial motivation for, and use of, this routine is not +so we can get the exact size of the object the BFD applies to, since +that might not be generally possible (archive members for example). +It would be ideal if someone could eventually modify +it so that such results were guaranteed. + +Instead, we want to ask questions like "is this NNN byte sized +object I'm about to try read from file offset YYY reasonable?" +As as example of where we might do this, some object formats +use string tables for which the first @code{sizeof(long)} bytes of the +table contain the size of the table itself, including the size bytes. +If an application tries to read what it thinks is one of these +string tables, without some way to validate the size, and for +some reason the size is wrong (byte swapping error, wrong location +for the string table, etc.), the only clue is likely to be a read +error when it tries to read the table, or a "virtual memory +exhausted" error when it tries to allocate 15 bazillon bytes +of space for the 15 bazillon byte table it is about to read. +This function at least allows us to answer the quesion, "is the +size reasonable?". +@* +@findex bfd_get_gp_size +@subsubsection @code{bfd_get_gp_size} +@strong{Synopsis} +@example +int bfd_get_gp_size(bfd *abfd); +@end example +@strong{Description}@* +Return the maximum size of objects to be optimized using the GP +register under MIPS ECOFF. This is typically set by the @code{-G} +argument to the compiler, assembler or linker. +@* +@findex bfd_set_gp_size +@subsubsection @code{bfd_set_gp_size} +@strong{Synopsis} +@example +void bfd_set_gp_size(bfd *abfd, int i); +@end example +@strong{Description}@* +Set the maximum size of objects to be optimized using the GP +register under ECOFF or MIPS ELF. This is typically set by +the @code{-G} argument to the compiler, assembler or linker. +@* +@findex bfd_scan_vma +@subsubsection @code{bfd_scan_vma} +@strong{Synopsis} +@example +bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base); +@end example +@strong{Description}@* +Convert, like @code{strtoul}, a numerical expression +@var{string} into a @code{bfd_vma} integer, and return that integer. +(Though without as many bells and whistles as @code{strtoul}.) +The expression is assumed to be unsigned (i.e., positive). +If given a @var{base}, it is used as the base for conversion. +A base of 0 causes the function to interpret the string +in hex if a leading "0x" or "0X" is found, otherwise +in octal if a leading zero is found, otherwise in decimal. + +Overflow is not detected. +@* +@findex bfd_copy_private_bfd_data +@subsubsection @code{bfd_copy_private_bfd_data} +@strong{Synopsis} +@example +boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd); +@end example +@strong{Description}@* +Copy private BFD information from the BFD @var{ibfd} to the +the BFD @var{obfd}. Return @code{true} on success, @code{false} on error. +Possible error returns are: + +@itemize @bullet + +@item +@code{bfd_error_no_memory} - +Not enough memory exists to create private data for @var{obfd}. +@end itemize +@example +#define bfd_copy_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ + (ibfd, obfd)) +@end example +@* +@findex bfd_merge_private_bfd_data +@subsubsection @code{bfd_merge_private_bfd_data} +@strong{Synopsis} +@example +boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd); +@end example +@strong{Description}@* +Merge private BFD information from the BFD @var{ibfd} to the +the output file BFD @var{obfd} when linking. Return @code{true} +on success, @code{false} on error. Possible error returns are: + +@itemize @bullet + +@item +@code{bfd_error_no_memory} - +Not enough memory exists to create private data for @var{obfd}. +@end itemize +@example +#define bfd_merge_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ + (ibfd, obfd)) +@end example +@* +@findex bfd_set_private_flags +@subsubsection @code{bfd_set_private_flags} +@strong{Synopsis} +@example +boolean bfd_set_private_flags(bfd *abfd, flagword flags); +@end example +@strong{Description}@* +Set private BFD flag information in the BFD @var{abfd}. +Return @code{true} on success, @code{false} on error. Possible error +returns are: + +@itemize @bullet + +@item +@code{bfd_error_no_memory} - +Not enough memory exists to create private data for @var{obfd}. +@end itemize +@example +#define bfd_set_private_flags(abfd, flags) \ + BFD_SEND (abfd, _bfd_set_private_flags, \ + (abfd, flags)) +@end example +@* +@findex stuff +@subsubsection @code{stuff} +@strong{Description}@* +Stuff which should be documented: +@example +#define bfd_sizeof_headers(abfd, reloc) \ + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) + +#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ + BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line)) + + /* Do these three do anything useful at all, for any back end? */ +#define bfd_debug_info_start(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) + +#define bfd_debug_info_end(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) + +#define bfd_debug_info_accumulate(abfd, section) \ + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) + + +#define bfd_stat_arch_elt(abfd, stat) \ + BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) + +#define bfd_update_armap_timestamp(abfd) \ + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) + +#define bfd_set_arch_mach(abfd, arch, mach)\ + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) + +#define bfd_relax_section(abfd, section, link_info, again) \ + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) + +#define bfd_link_hash_table_create(abfd) \ + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) + +#define bfd_link_add_symbols(abfd, info) \ + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) + +#define bfd_final_link(abfd, info) \ + BFD_SEND (abfd, _bfd_final_link, (abfd, info)) + +#define bfd_free_cached_info(abfd) \ + BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) + +#define bfd_get_dynamic_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) + +#define bfd_print_private_bfd_data(abfd, file)\ + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) + +#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) + +#define bfd_get_dynamic_reloc_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) + +#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) + +extern bfd_byte *bfd_get_relocated_section_contents + PARAMS ((bfd *, struct bfd_link_info *, + struct bfd_link_order *, bfd_byte *, + boolean, asymbol **)); + +@end example +@* diff -urN binutils-2.7/bfd/doc/cache.texi binutils-2.8/bfd/doc/cache.texi --- binutils-2.7/bfd/doc/cache.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/cache.texi Wed Apr 30 12:56:26 1997 @@ -0,0 +1,95 @@ +@section File caching +The file caching mechanism is embedded within BFD and allows +the application to open as many BFDs as it wants without +regard to the underlying operating system's file descriptor +limit (often as low as 20 open files). The module in +@code{cache.c} maintains a least recently used list of +@code{BFD_CACHE_MAX_OPEN} files, and exports the name +@code{bfd_cache_lookup}, which runs around and makes sure that +the required BFD is open. If not, then it chooses a file to +close, closes it and opens the one wanted, returning its file +handle. +@* +@findex BFD_CACHE_MAX_OPEN macro +@subsubsection @code{BFD_CACHE_MAX_OPEN macro} +@strong{Description}@* +The maximum number of files which the cache will keep open at +one time. +@example +#define BFD_CACHE_MAX_OPEN 10 +@end example +@* +@findex bfd_last_cache +@subsubsection @code{bfd_last_cache} +@strong{Synopsis} +@example +extern bfd *bfd_last_cache; +@end example +@strong{Description}@* +Zero, or a pointer to the topmost BFD on the chain. This is +used by the @code{bfd_cache_lookup} macro in @file{libbfd.h} to +determine when it can avoid a function call. +@* +@findex bfd_cache_lookup +@subsubsection @code{bfd_cache_lookup} +@strong{Description}@* +Check to see if the required BFD is the same as the last one +looked up. If so, then it can use the stream in the BFD with +impunity, since it can't have changed since the last lookup; +otherwise, it has to perform the complicated lookup function. +@example +#define bfd_cache_lookup(x) \ + ((x)==bfd_last_cache? \ + (FILE*)(bfd_last_cache->iostream): \ + bfd_cache_lookup_worker(x)) +@end example +@* +@findex bfd_cache_init +@subsubsection @code{bfd_cache_init} +@strong{Synopsis} +@example +boolean bfd_cache_init (bfd *abfd); +@end example +@strong{Description}@* +Add a newly opened BFD to the cache. +@* +@findex bfd_cache_close +@subsubsection @code{bfd_cache_close} +@strong{Synopsis} +@example +boolean bfd_cache_close (bfd *abfd); +@end example +@strong{Description}@* +Remove the BFD @var{abfd} from the cache. If the attached file is open, +then close it too. +@* +@strong{Returns}@* +@code{false} is returned if closing the file fails, @code{true} is +returned if all is well. +@* +@findex bfd_open_file +@subsubsection @code{bfd_open_file} +@strong{Synopsis} +@example +FILE* bfd_open_file(bfd *abfd); +@end example +@strong{Description}@* +Call the OS to open a file for @var{abfd}. Return the @code{FILE *} +(possibly @code{NULL}) that results from this operation. Set up the +BFD so that future accesses know the file is open. If the @code{FILE *} +returned is @code{NULL}, then it won't have been put in the +cache, so it won't have to be removed from it. +@* +@findex bfd_cache_lookup_worker +@subsubsection @code{bfd_cache_lookup_worker} +@strong{Synopsis} +@example +FILE *bfd_cache_lookup_worker(bfd *abfd); +@end example +@strong{Description}@* +Called when the macro @code{bfd_cache_lookup} fails to find a +quick answer. Find a file descriptor for @var{abfd}. If +necessary, it open it. If there are already more than +@code{BFD_CACHE_MAX_OPEN} files open, it tries to close one first, to +avoid running out of file descriptors. +@* diff -urN binutils-2.7/bfd/doc/coffcode.texi binutils-2.8/bfd/doc/coffcode.texi --- binutils-2.7/bfd/doc/coffcode.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/coffcode.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,627 @@ +@section coff backends +BFD supports a number of different flavours of coff format. +The major differences between formats are the sizes and +alignments of fields in structures on disk, and the occasional +extra field. + +Coff in all its varieties is implemented with a few common +files and a number of implementation specific files. For +example, The 88k bcs coff format is implemented in the file +@file{coff-m88k.c}. This file @code{#include}s +@file{coff/m88k.h} which defines the external structure of the +coff format for the 88k, and @file{coff/internal.h} which +defines the internal structure. @file{coff-m88k.c} also +defines the relocations used by the 88k format +@xref{Relocations}. + +The Intel i960 processor version of coff is implemented in +@file{coff-i960.c}. This file has the same structure as +@file{coff-m88k.c}, except that it includes @file{coff/i960.h} +rather than @file{coff-m88k.h}. +@* +@subsection Porting to a new version of coff +The recommended method is to select from the existing +implementations the version of coff which is most like the one +you want to use. For example, we'll say that i386 coff is +the one you select, and that your coff flavour is called foo. +Copy @file{i386coff.c} to @file{foocoff.c}, copy +@file{../include/coff/i386.h} to @file{../include/coff/foo.h}, +and add the lines to @file{targets.c} and @file{Makefile.in} +so that your new back end is used. Alter the shapes of the +structures in @file{../include/coff/foo.h} so that they match +what you need. You will probably also have to add +@code{#ifdef}s to the code in @file{coff/internal.h} and +@file{coffcode.h} if your version of coff is too wild. + +You can verify that your new BFD backend works quite simply by +building @file{objdump} from the @file{binutils} directory, +and making sure that its version of what's going on and your +host system's idea (assuming it has the pretty standard coff +dump utility, usually called @code{att-dump} or just +@code{dump}) are the same. Then clean up your code, and send +what you've done to Cygnus. Then your stuff will be in the +next release, and you won't have to keep integrating it. +@* +@subsection How the coff backend works + +@* +@subsubsection File layout +The Coff backend is split into generic routines that are +applicable to any Coff target and routines that are specific +to a particular target. The target-specific routines are +further split into ones which are basically the same for all +Coff targets except that they use the external symbol format +or use different values for certain constants. + +The generic routines are in @file{coffgen.c}. These routines +work for any Coff target. They use some hooks into the target +specific code; the hooks are in a @code{bfd_coff_backend_data} +structure, one of which exists for each target. + +The essentially similar target-specific routines are in +@file{coffcode.h}. This header file includes executable C code. +The various Coff targets first include the appropriate Coff +header file, make any special defines that are needed, and +then include @file{coffcode.h}. + +Some of the Coff targets then also have additional routines in +the target source file itself. + +For example, @file{coff-i960.c} includes +@file{coff/internal.h} and @file{coff/i960.h}. It then +defines a few constants, such as @code{I960}, and includes +@file{coffcode.h}. Since the i960 has complex relocation +types, @file{coff-i960.c} also includes some code to +manipulate the i960 relocs. This code is not in +@file{coffcode.h} because it would not be used by any other +target. +@* +@subsubsection Bit twiddling +Each flavour of coff supported in BFD has its own header file +describing the external layout of the structures. There is also +an internal description of the coff layout, in +@file{coff/internal.h}. A major function of the +coff backend is swapping the bytes and twiddling the bits to +translate the external form of the structures into the normal +internal form. This is all performed in the +@code{bfd_swap}_@i{thing}_@i{direction} routines. Some +elements are different sizes between different versions of +coff; it is the duty of the coff version specific include file +to override the definitions of various packing routines in +@file{coffcode.h}. E.g., the size of line number entry in coff is +sometimes 16 bits, and sometimes 32 bits. @code{#define}ing +@code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the +correct one. No doubt, some day someone will find a version of +coff which has a varying field size not catered to at the +moment. To port BFD, that person will have to add more @code{#defines}. +Three of the bit twiddling routines are exported to +@code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in} +and @code{coff_swap_linno_in}. @code{GDB} reads the symbol +table on its own, but uses BFD to fix things up. More of the +bit twiddlers are exported for @code{gas}; +@code{coff_swap_aux_out}, @code{coff_swap_sym_out}, +@code{coff_swap_lineno_out}, @code{coff_swap_reloc_out}, +@code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out}, +@code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track +of all the symbol table and reloc drudgery itself, thereby +saving the internal BFD overhead, but uses BFD to swap things +on the way out, making cross ports much safer. Doing so also +allows BFD (and thus the linker) to use the same header files +as @code{gas}, which makes one avenue to disaster disappear. +@* +@subsubsection Symbol reading +The simple canonical form for symbols used by BFD is not rich +enough to keep all the information available in a coff symbol +table. The back end gets around this problem by keeping the original +symbol table around, "behind the scenes". + +When a symbol table is requested (through a call to +@code{bfd_canonicalize_symtab}), a request gets through to +@code{coff_get_normalized_symtab}. This reads the symbol table from +the coff file and swaps all the structures inside into the +internal form. It also fixes up all the pointers in the table +(represented in the file by offsets from the first symbol in +the table) into physical pointers to elements in the new +internal table. This involves some work since the meanings of +fields change depending upon context: a field that is a +pointer to another structure in the symbol table at one moment +may be the size in bytes of a structure at the next. Another +pass is made over the table. All symbols which mark file names +(@code{C_FILE} symbols) are modified so that the internal +string points to the value in the auxent (the real filename) +rather than the normal text associated with the symbol +(@code{".file"}). + +At this time the symbol names are moved around. Coff stores +all symbols less than nine characters long physically +within the symbol table; longer strings are kept at the end of +the file in the string table. This pass moves all strings +into memory and replaces them with pointers to the strings. + +The symbol table is massaged once again, this time to create +the canonical table used by the BFD application. Each symbol +is inspected in turn, and a decision made (using the +@code{sclass} field) about the various flags to set in the +@code{asymbol}. @xref{Symbols}. The generated canonical table +shares strings with the hidden internal symbol table. + +Any linenumbers are read from the coff file too, and attached +to the symbols which own the functions the linenumbers belong to. +@* +@subsubsection Symbol writing +Writing a symbol to a coff file which didn't come from a coff +file will lose any debugging information. The @code{asymbol} +structure remembers the BFD from which the symbol was taken, and on +output the back end makes sure that the same destination target as +source target is present. + +When the symbols have come from a coff file then all the +debugging information is preserved. + +Symbol tables are provided for writing to the back end in a +vector of pointers to pointers. This allows applications like +the linker to accumulate and output large symbol tables +without having to do too much byte copying. + +This function runs through the provided symbol table and +patches each symbol marked as a file place holder +(@code{C_FILE}) to point to the next file place holder in the +list. It also marks each @code{offset} field in the list with +the offset from the first symbol of the current symbol. + +Another function of this procedure is to turn the canonical +value form of BFD into the form used by coff. Internally, BFD +expects symbol values to be offsets from a section base; so a +symbol physically at 0x120, but in a section starting at +0x100, would have the value 0x20. Coff expects symbols to +contain their final value, so symbols have their values +changed at this point to reflect their sum with their owning +section. This transformation uses the +@code{output_section} field of the @code{asymbol}'s +@code{asection} @xref{Sections}. + +@itemize @bullet + +@item +@code{coff_mangle_symbols} +@end itemize +This routine runs though the provided symbol table and uses +the offsets generated by the previous pass and the pointers +generated when the symbol table was read in to create the +structured hierachy required by coff. It changes each pointer +to a symbol into the index into the symbol table of the asymbol. + +@itemize @bullet + +@item +@code{coff_write_symbols} +@end itemize +This routine runs through the symbol table and patches up the +symbols from their internal form into the coff way, calls the +bit twiddlers, and writes out the table to the file. +@* +@findex coff_symbol_type +@subsubsection @code{coff_symbol_type} +@strong{Description}@* +The hidden information for an @code{asymbol} is described in a +@code{combined_entry_type}: +@* +. +@example +typedef struct coff_ptr_struct +@{ + + /* Remembers the offset from the first symbol in the file for + this symbol. Generated by coff_renumber_symbols. */ +unsigned int offset; + + /* Should the value of this symbol be renumbered. Used for + XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */ +unsigned int fix_value : 1; + + /* Should the tag field of this symbol be renumbered. + Created by coff_pointerize_aux. */ +unsigned int fix_tag : 1; + + /* Should the endidx field of this symbol be renumbered. + Created by coff_pointerize_aux. */ +unsigned int fix_end : 1; + + /* Should the x_csect.x_scnlen field be renumbered. + Created by coff_pointerize_aux. */ +unsigned int fix_scnlen : 1; + + /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the + index into the line number entries. Set by + coff_slurp_symbol_table. */ +unsigned int fix_line : 1; + + /* The container for the symbol structure as read and translated + from the file. */ + +union @{ + union internal_auxent auxent; + struct internal_syment syment; + @} u; +@} combined_entry_type; + + +/* Each canonical asymbol really looks like this: */ + +typedef struct coff_symbol_struct +@{ + /* The actual symbol which the rest of BFD works with */ +asymbol symbol; + + /* A pointer to the hidden information for this symbol */ +combined_entry_type *native; + + /* A pointer to the linenumber information for this symbol */ +struct lineno_cache_entry *lineno; + + /* Have the line numbers been relocated yet ? */ +boolean done_lineno; +@} coff_symbol_type; +@end example +@findex bfd_coff_backend_data +@subsubsection @code{bfd_coff_backend_data} +Special entry points for gdb to swap in coff symbol table parts: +@example +typedef struct +@{ + void (*_bfd_coff_swap_aux_in) PARAMS (( + bfd *abfd, + PTR ext, + int type, + int class, + int indaux, + int numaux, + PTR in)); + + void (*_bfd_coff_swap_sym_in) PARAMS (( + bfd *abfd , + PTR ext, + PTR in)); + + void (*_bfd_coff_swap_lineno_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + +@end example +Special entry points for gas to swap out coff parts: +@example + unsigned int (*_bfd_coff_swap_aux_out) PARAMS (( + bfd *abfd, + PTR in, + int type, + int class, + int indaux, + int numaux, + PTR ext)); + + unsigned int (*_bfd_coff_swap_sym_out) PARAMS (( + bfd *abfd, + PTR in, + PTR ext)); + + unsigned int (*_bfd_coff_swap_lineno_out) PARAMS (( + bfd *abfd, + PTR in, + PTR ext)); + + unsigned int (*_bfd_coff_swap_reloc_out) PARAMS (( + bfd *abfd, + PTR src, + PTR dst)); + + unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS (( + bfd *abfd, + PTR in, + PTR out)); + + unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS (( + bfd *abfd, + PTR in, + PTR out)); + + unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS (( + bfd *abfd, + PTR in, + PTR out)); + +@end example +Special entry points for generic COFF routines to call target +dependent COFF routines: +@example + unsigned int _bfd_filhsz; + unsigned int _bfd_aoutsz; + unsigned int _bfd_scnhsz; + unsigned int _bfd_symesz; + unsigned int _bfd_auxesz; + unsigned int _bfd_relsz; + unsigned int _bfd_linesz; + boolean _bfd_coff_long_filenames; + boolean _bfd_coff_long_section_names; + unsigned int _bfd_coff_default_section_alignment_power; + void (*_bfd_coff_swap_filehdr_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + void (*_bfd_coff_swap_aouthdr_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + void (*_bfd_coff_swap_scnhdr_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + void (*_bfd_coff_swap_reloc_in) PARAMS (( + bfd *abfd, + PTR ext, + PTR in)); + boolean (*_bfd_coff_bad_format_hook) PARAMS (( + bfd *abfd, + PTR internal_filehdr)); + boolean (*_bfd_coff_set_arch_mach_hook) PARAMS (( + bfd *abfd, + PTR internal_filehdr)); + PTR (*_bfd_coff_mkobject_hook) PARAMS (( + bfd *abfd, + PTR internal_filehdr, + PTR internal_aouthdr)); + flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( + bfd *abfd, + PTR internal_scnhdr, + const char *name)); + void (*_bfd_set_alignment_hook) PARAMS (( + bfd *abfd, + asection *sec, + PTR internal_scnhdr)); + boolean (*_bfd_coff_slurp_symbol_table) PARAMS (( + bfd *abfd)); + boolean (*_bfd_coff_symname_in_debug) PARAMS (( + bfd *abfd, + struct internal_syment *sym)); + boolean (*_bfd_coff_pointerize_aux_hook) PARAMS (( + bfd *abfd, + combined_entry_type *table_base, + combined_entry_type *symbol, + unsigned int indaux, + combined_entry_type *aux)); + boolean (*_bfd_coff_print_aux) PARAMS (( + bfd *abfd, + FILE *file, + combined_entry_type *table_base, + combined_entry_type *symbol, + combined_entry_type *aux, + unsigned int indaux)); + void (*_bfd_coff_reloc16_extra_cases) PARAMS (( + bfd *abfd, + struct bfd_link_info *link_info, + struct bfd_link_order *link_order, + arelent *reloc, + bfd_byte *data, + unsigned int *src_ptr, + unsigned int *dst_ptr)); + int (*_bfd_coff_reloc16_estimate) PARAMS (( + bfd *abfd, + asection *input_section, + arelent *r, + unsigned int shrink, + struct bfd_link_info *link_info)); + boolean (*_bfd_coff_sym_is_global) PARAMS (( + bfd *abfd, + struct internal_syment *)); + boolean (*_bfd_coff_compute_section_file_positions) PARAMS (( + bfd *abfd)); + boolean (*_bfd_coff_start_final_link) PARAMS (( + bfd *output_bfd, + struct bfd_link_info *info)); + boolean (*_bfd_coff_relocate_section) PARAMS (( + bfd *output_bfd, + struct bfd_link_info *info, + bfd *input_bfd, + asection *input_section, + bfd_byte *contents, + struct internal_reloc *relocs, + struct internal_syment *syms, + asection **sections)); + reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS (( + bfd *abfd, + asection *sec, + struct internal_reloc *rel, + struct coff_link_hash_entry *h, + struct internal_syment *sym, + bfd_vma *addendp)); + boolean (*_bfd_coff_adjust_symndx) PARAMS (( + bfd *obfd, + struct bfd_link_info *info, + bfd *ibfd, + asection *sec, + struct internal_reloc *reloc, + boolean *adjustedp)); + boolean (*_bfd_coff_link_add_one_symbol) PARAMS (( + struct bfd_link_info *info, + bfd *abfd, + const char *name, + flagword flags, + asection *section, + bfd_vma value, + const char *string, + boolean copy, + boolean collect, + struct bfd_link_hash_entry **hashp)); + +@} bfd_coff_backend_data; + +#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data) + +#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ + ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) + +#define bfd_coff_swap_sym_in(a,e,i) \ + ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) + +#define bfd_coff_swap_lineno_in(a,e,i) \ + ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) + +#define bfd_coff_swap_reloc_out(abfd, i, o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) + +#define bfd_coff_swap_lineno_out(abfd, i, o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) + +#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ + ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) + +#define bfd_coff_swap_sym_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) + +#define bfd_coff_swap_scnhdr_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) + +#define bfd_coff_swap_filehdr_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) + +#define bfd_coff_swap_aouthdr_out(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) + +#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) +#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) +#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) +#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) +#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) +#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) +#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) +#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames) +#define bfd_coff_long_section_names(abfd) \ + (coff_backend_info (abfd)->_bfd_coff_long_section_names) +#define bfd_coff_default_section_alignment_power(abfd) \ + (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) +#define bfd_coff_swap_filehdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) + +#define bfd_coff_swap_aouthdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) + +#define bfd_coff_swap_scnhdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) + +#define bfd_coff_swap_reloc_in(abfd, i, o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) + +#define bfd_coff_bad_format_hook(abfd, filehdr) \ + ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) + +#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ + ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) +#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ + ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) + +#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\ + ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name)) + +#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ + ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) + +#define bfd_coff_slurp_symbol_table(abfd)\ + ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) + +#define bfd_coff_symname_in_debug(abfd, sym)\ + ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) + +#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ + ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ + (abfd, file, base, symbol, aux, indaux)) + +#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\ + ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ + (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) + +#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ + ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ + (abfd, section, reloc, shrink, link_info)) + +#define bfd_coff_sym_is_global(abfd, sym)\ + ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\ + (abfd, sym)) + +#define bfd_coff_compute_section_file_positions(abfd)\ + ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ + (abfd)) + +#define bfd_coff_start_final_link(obfd, info)\ + ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ + (obfd, info)) +#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ + ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ + (obfd, info, ibfd, o, con, rel, isyms, secs)) +#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ + ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ + (abfd, sec, rel, h, sym, addendp)) +#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ + ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ + (obfd, info, ibfd, sec, rel, adjustedp)) +#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\ + ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ + (info, abfd, name, flags, section, value, string, cp, coll, hashp)) + +@end example +@subsubsection Writing relocations +To write relocations, the back end steps though the +canonical relocation table and create an +@code{internal_reloc}. The symbol index to use is removed from +the @code{offset} field in the symbol table supplied. The +address comes directly from the sum of the section base +address and the relocation offset; the type is dug directly +from the howto field. Then the @code{internal_reloc} is +swapped into the shape of an @code{external_reloc} and written +out to disk. +@* +@subsubsection Reading linenumbers +Creating the linenumber table is done by reading in the entire +coff linenumber table, and creating another table for internal use. + +A coff linenumber table is structured so that each function +is marked as having a line number of 0. Each line within the +function is an offset from the first line in the function. The +base of the line number information for the table is stored in +the symbol associated with the function. + +The information is copied from the external to the internal +table, and each symbol which marks a function is marked by +pointing its... + +How does this work ? +@* +@subsubsection Reading relocations +Coff relocations are easily transformed into the internal BFD form +(@code{arelent}). + +Reading a coff relocation table is done in the following stages: + +@itemize @bullet + +@item +Read the entire coff relocation table into memory. + +@item +Process each relocation in turn; first swap it from the +external to the internal form. + +@item +Turn the symbol referenced in the relocation's symbol index +into a pointer into the canonical symbol table. +This table is the same as the one returned by a call to +@code{bfd_canonicalize_symtab}. The back end will call that +routine and save the result if a canonicalization hasn't been done. + +@item +The reloc index is turned into a pointer to a howto +structure, in a back end specific way. For instance, the 386 +and 960 use the @code{r_type} to directly produce an index +into a howto table vector; the 88k subtracts a number from the +@code{r_type} field and creates an addend field. +@end itemize +@* diff -urN binutils-2.7/bfd/doc/core.texi binutils-2.8/bfd/doc/core.texi --- binutils-2.7/bfd/doc/core.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/core.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,38 @@ +@section Core files + +@* +@strong{Description}@* +These are functions pertaining to core files. +@* +@findex bfd_core_file_failing_command +@subsubsection @code{bfd_core_file_failing_command} +@strong{Synopsis} +@example +CONST char *bfd_core_file_failing_command(bfd *abfd); +@end example +@strong{Description}@* +Return a read-only string explaining which program was running +when it failed and produced the core file @var{abfd}. +@* +@findex bfd_core_file_failing_signal +@subsubsection @code{bfd_core_file_failing_signal} +@strong{Synopsis} +@example +int bfd_core_file_failing_signal(bfd *abfd); +@end example +@strong{Description}@* +Returns the signal number which caused the core dump which +generated the file the BFD @var{abfd} is attached to. +@* +@findex core_file_matches_executable_p +@subsubsection @code{core_file_matches_executable_p} +@strong{Synopsis} +@example +boolean core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); +@end example +@strong{Description}@* +Return @code{true} if the core file attached to @var{core_bfd} +was generated by a run of the executable file attached to +@var{exec_bfd}, @code{false} otherwise. +@* diff -urN binutils-2.7/bfd/doc/elf.texi binutils-2.8/bfd/doc/elf.texi --- binutils-2.7/bfd/doc/elf.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/elf.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,22 @@ +@section ELF backends +BFD support for ELF formats is being worked on. +Currently, the best supported back ends are for sparc and i386 +(running svr4 or Solaris 2). + +Documentation of the internals of the support code still needs +to be written. The code is changing quickly enough that we +haven't bothered yet. +@* +@findex bfd_elf_find_section +@subsubsection @code{bfd_elf_find_section} +@strong{Synopsis} +@example +struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name); +@end example +@strong{Description}@* +Helper functions for GDB to locate the string tables. +Since BFD hides string tables from callers, GDB needs to use an +internal hook to find them. Sun's .stabstr, in particular, +isn't even pointed to by the .stab section, so ordinary +mechanisms wouldn't work to find it, even if we had some. +@* diff -urN binutils-2.7/bfd/doc/format.texi binutils-2.8/bfd/doc/format.texi --- binutils-2.7/bfd/doc/format.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/format.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,108 @@ +@section File formats +A format is a BFD concept of high level file contents type. The +formats supported by BFD are: + +@itemize @bullet + +@item +@code{bfd_object} +@end itemize +The BFD may contain data, symbols, relocations and debug info. + +@itemize @bullet + +@item +@code{bfd_archive} +@end itemize +The BFD contains other BFDs and an optional index. + +@itemize @bullet + +@item +@code{bfd_core} +@end itemize +The BFD contains the result of an executable core dump. +@* +@findex bfd_check_format +@subsubsection @code{bfd_check_format} +@strong{Synopsis} +@example +boolean bfd_check_format(bfd *abfd, bfd_format format); +@end example +@strong{Description}@* +Verify if the file attached to the BFD @var{abfd} is compatible +with the format @var{format} (i.e., one of @code{bfd_object}, +@code{bfd_archive} or @code{bfd_core}). + +If the BFD has been set to a specific target before the +call, only the named target and format combination is +checked. If the target has not been set, or has been set to +@code{default}, then all the known target backends is +interrogated to determine a match. If the default target +matches, it is used. If not, exactly one target must recognize +the file, or an error results. + +The function returns @code{true} on success, otherwise @code{false} +with one of the following error codes: + +@itemize @bullet + +@item +@code{bfd_error_invalid_operation} - +if @code{format} is not one of @code{bfd_object}, @code{bfd_archive} or +@code{bfd_core}. + +@item +@code{bfd_error_system_call} - +if an error occured during a read - even some file mismatches +can cause bfd_error_system_calls. + +@item +@code{file_not_recognised} - +none of the backends recognised the file format. + +@item +@code{bfd_error_file_ambiguously_recognized} - +more than one backend recognised the file format. +@end itemize +@* +@findex bfd_check_format_matches +@subsubsection @code{bfd_check_format_matches} +@strong{Synopsis} +@example +boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching); +@end example +@strong{Description}@* +Like @code{bfd_check_format}, except when it returns false with +@code{bfd_errno} set to @code{bfd_error_file_ambiguously_recognized}. In that +case, if @var{matching} is not NULL, it will be filled in with +a NULL-terminated list of the names of the formats that matched, +allocated with @code{malloc}. +Then the user may choose a format and try again. + +When done with the list that @var{matching} points to, the caller +should free it. +@* +@findex bfd_set_format +@subsubsection @code{bfd_set_format} +@strong{Synopsis} +@example +boolean bfd_set_format(bfd *abfd, bfd_format format); +@end example +@strong{Description}@* +This function sets the file format of the BFD @var{abfd} to the +format @var{format}. If the target set in the BFD does not +support the format requested, the format is invalid, or the BFD +is not open for writing, then an error occurs. +@* +@findex bfd_format_string +@subsubsection @code{bfd_format_string} +@strong{Synopsis} +@example +CONST char *bfd_format_string(bfd_format format); +@end example +@strong{Description}@* +Return a pointer to a const string +@code{invalid}, @code{object}, @code{archive}, @code{core}, or @code{unknown}, +depending upon the value of @var{format}. +@* diff -urN binutils-2.7/bfd/doc/hash.texi binutils-2.8/bfd/doc/hash.texi --- binutils-2.7/bfd/doc/hash.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/hash.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,244 @@ +@section Hash Tables +@cindex Hash tables +BFD provides a simple set of hash table functions. Routines +are provided to initialize a hash table, to free a hash table, +to look up a string in a hash table and optionally create an +entry for it, and to traverse a hash table. There is +currently no routine to delete an string from a hash table. + +The basic hash table does not permit any data to be stored +with a string. However, a hash table is designed to present a +base class from which other types of hash tables may be +derived. These derived types may store additional information +with the string. Hash tables were implemented in this way, +rather than simply providing a data pointer in a hash table +entry, because they were designed for use by the linker back +ends. The linker may create thousands of hash table entries, +and the overhead of allocating private data and storing and +following pointers becomes noticeable. + +The basic hash table code is in @code{hash.c}. + +@menu +* Creating and Freeing a Hash Table:: +* Looking Up or Entering a String:: +* Traversing a Hash Table:: +* Deriving a New Hash Table Type:: +@end menu +@* +@node Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables +@subsection Creating and freeing a hash table +@findex bfd_hash_table_init +@findex bfd_hash_table_init_n +To create a hash table, create an instance of a @code{struct +bfd_hash_table} (defined in @code{bfd.h}) and call +@code{bfd_hash_table_init} (if you know approximately how many +entries you will need, the function @code{bfd_hash_table_init_n}, +which takes a @var{size} argument, may be used). +@code{bfd_hash_table_init} returns @code{false} if some sort of +error occurs. + +@findex bfd_hash_newfunc +The function @code{bfd_hash_table_init} take as an argument a +function to use to create new entries. For a basic hash +table, use the function @code{bfd_hash_newfunc}. @xref{Deriving +a New Hash Table Type} for why you would want to use a +different value for this argument. + +@findex bfd_hash_allocate +@code{bfd_hash_table_init} will create an objalloc which will be +used to allocate new entries. You may allocate memory on this +objalloc using @code{bfd_hash_allocate}. + +@findex bfd_hash_table_free +Use @code{bfd_hash_table_free} to free up all the memory that has +been allocated for a hash table. This will not free up the +@code{struct bfd_hash_table} itself, which you must provide. +@* +@node Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables +@subsection Looking up or entering a string +@findex bfd_hash_lookup +The function @code{bfd_hash_lookup} is used both to look up a +string in the hash table and to create a new entry. + +If the @var{create} argument is @code{false}, @code{bfd_hash_lookup} +will look up a string. If the string is found, it will +returns a pointer to a @code{struct bfd_hash_entry}. If the +string is not found in the table @code{bfd_hash_lookup} will +return @code{NULL}. You should not modify any of the fields in +the returns @code{struct bfd_hash_entry}. + +If the @var{create} argument is @code{true}, the string will be +entered into the hash table if it is not already there. +Either way a pointer to a @code{struct bfd_hash_entry} will be +returned, either to the existing structure or to a newly +created one. In this case, a @code{NULL} return means that an +error occurred. + +If the @var{create} argument is @code{true}, and a new entry is +created, the @var{copy} argument is used to decide whether to +copy the string onto the hash table objalloc or not. If +@var{copy} is passed as @code{false}, you must be careful not to +deallocate or modify the string as long as the hash table +exists. +@* +@node Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables +@subsection Traversing a hash table +@findex bfd_hash_traverse +The function @code{bfd_hash_traverse} may be used to traverse a +hash table, calling a function on each element. The traversal +is done in a random order. + +@code{bfd_hash_traverse} takes as arguments a function and a +generic @code{void *} pointer. The function is called with a +hash table entry (a @code{struct bfd_hash_entry *}) and the +generic pointer passed to @code{bfd_hash_traverse}. The function +must return a @code{boolean} value, which indicates whether to +continue traversing the hash table. If the function returns +@code{false}, @code{bfd_hash_traverse} will stop the traversal and +return immediately. +@* +@node Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables +@subsection Deriving a new hash table type +Many uses of hash tables want to store additional information +which each entry in the hash table. Some also find it +convenient to store additional information with the hash table +itself. This may be done using a derived hash table. + +Since C is not an object oriented language, creating a derived +hash table requires sticking together some boilerplate +routines with a few differences specific to the type of hash +table you want to create. + +An example of a derived hash table is the linker hash table. +The structures for this are defined in @code{bfdlink.h}. The +functions are in @code{linker.c}. + +You may also derive a hash table from an already derived hash +table. For example, the a.out linker backend code uses a hash +table derived from the linker hash table. + +@menu +* Define the Derived Structures:: +* Write the Derived Creation Routine:: +* Write Other Derived Routines:: +@end menu +@* +@node Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type +@subsubsection Define the derived structures +You must define a structure for an entry in the hash table, +and a structure for the hash table itself. + +The first field in the structure for an entry in the hash +table must be of the type used for an entry in the hash table +you are deriving from. If you are deriving from a basic hash +table this is @code{struct bfd_hash_entry}, which is defined in +@code{bfd.h}. The first field in the structure for the hash +table itself must be of the type of the hash table you are +deriving from itself. If you are deriving from a basic hash +table, this is @code{struct bfd_hash_table}. + +For example, the linker hash table defines @code{struct +bfd_link_hash_entry} (in @code{bfdlink.h}). The first field, +@code{root}, is of type @code{struct bfd_hash_entry}. Similarly, +the first field in @code{struct bfd_link_hash_table}, @code{table}, +is of type @code{struct bfd_hash_table}. +@* +@node Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type +@subsubsection Write the derived creation routine +You must write a routine which will create and initialize an +entry in the hash table. This routine is passed as the +function argument to @code{bfd_hash_table_init}. + +In order to permit other hash tables to be derived from the +hash table you are creating, this routine must be written in a +standard way. + +The first argument to the creation routine is a pointer to a +hash table entry. This may be @code{NULL}, in which case the +routine should allocate the right amount of space. Otherwise +the space has already been allocated by a hash table type +derived from this one. + +After allocating space, the creation routine must call the +creation routine of the hash table type it is derived from, +passing in a pointer to the space it just allocated. This +will initialize any fields used by the base hash table. + +Finally the creation routine must initialize any local fields +for the new hash table type. + +Here is a boilerplate example of a creation routine. +@var{function_name} is the name of the routine. +@var{entry_type} is the type of an entry in the hash table you +are creating. @var{base_newfunc} is the name of the creation +routine of the hash table type your hash table is derived +from. +@* +.struct bfd_hash_entry * +@example +@var{function_name} (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +@{ + struct @var{entry_type} *ret = (@var{entry_type} *) entry; + + /* Allocate the structure if it has not already been allocated by a + derived class. */ + if (ret == (@var{entry_type} *) NULL) + @{ + ret = ((@var{entry_type} *) + bfd_hash_allocate (table, sizeof (@var{entry_type}))); + if (ret == (@var{entry_type} *) NULL) + return NULL; + @} + + /* Call the allocation method of the base class. */ + ret = ((@var{entry_type} *) + @var{base_newfunc} ((struct bfd_hash_entry *) ret, table, string)); + + /* Initialize the local fields here. */ + + return (struct bfd_hash_entry *) ret; +@} +@end example +@strong{Description}@* +The creation routine for the linker hash table, which is in +@code{linker.c}, looks just like this example. +@var{function_name} is @code{_bfd_link_hash_newfunc}. +@var{entry_type} is @code{struct bfd_link_hash_entry}. +@var{base_newfunc} is @code{bfd_hash_newfunc}, the creation +routine for a basic hash table. + +@code{_bfd_link_hash_newfunc} also initializes the local fields +in a linker hash table entry: @code{type}, @code{written} and +@code{next}. +@* +@node Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type +@subsubsection Write other derived routines +You will want to write other routines for your new hash table, +as well. + +You will want an initialization routine which calls the +initialization routine of the hash table you are deriving from +and initializes any other local fields. For the linker hash +table, this is @code{_bfd_link_hash_table_init} in @code{linker.c}. + +You will want a lookup routine which calls the lookup routine +of the hash table you are deriving from and casts the result. +The linker hash table uses @code{bfd_link_hash_lookup} in +@code{linker.c} (this actually takes an additional argument which +it uses to decide how to return the looked up value). + +You may want a traversal routine. This should just call the +traversal routine of the hash table you are deriving from with +appropriate casts. The linker hash table uses +@code{bfd_link_hash_traverse} in @code{linker.c}. + +These routines may simply be defined as macros. For example, +the a.out backend linker hash table, which is derived from the +linker hash table, uses macros for the lookup and traversal +routines. These are @code{aout_link_hash_lookup} and +@code{aout_link_hash_traverse} in aoutx.h. +@* diff -urN binutils-2.7/bfd/doc/init.texi binutils-2.8/bfd/doc/init.texi --- binutils-2.7/bfd/doc/init.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/init.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,13 @@ +@section Initialization +These are the functions that handle initializing a BFD. +@* +@findex bfd_init +@subsubsection @code{bfd_init} +@strong{Synopsis} +@example +void bfd_init(void); +@end example +@strong{Description}@* +This routine must be called before any other BFD function to +initialize magical internal data structures. +@* diff -urN binutils-2.7/bfd/doc/libbfd.texi binutils-2.8/bfd/doc/libbfd.texi --- binutils-2.7/bfd/doc/libbfd.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/libbfd.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,142 @@ +@section Internal functions + +@* +@strong{Description}@* +These routines are used within BFD. +They are not intended for export, but are documented here for +completeness. +@* +@findex bfd_write_bigendian_4byte_int +@subsubsection @code{bfd_write_bigendian_4byte_int} +@strong{Synopsis} +@example +void bfd_write_bigendian_4byte_int(bfd *abfd, int i); +@end example +@strong{Description}@* +Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big +endian order regardless of what else is going on. This is useful in +archives. +@* +@findex bfd_put_size +@subsubsection @code{bfd_put_size} +@findex bfd_get_size +@subsubsection @code{bfd_get_size} +@strong{Description}@* +These macros as used for reading and writing raw data in +sections; each access (except for bytes) is vectored through +the target format of the BFD and mangled accordingly. The +mangling performs any necessary endian translations and +removes alignment restrictions. Note that types accepted and +returned by these macros are identical so they can be swapped +around in macros---for example, @file{libaout.h} defines @code{GET_WORD} +to either @code{bfd_get_32} or @code{bfd_get_64}. + +In the put routines, @var{val} must be a @code{bfd_vma}. If we are on a +system without prototypes, the caller is responsible for making +sure that is true, with a cast if necessary. We don't cast +them in the macro definitions because that would prevent @code{lint} +or @code{gcc -Wall} from detecting sins such as passing a pointer. +To detect calling these with less than a @code{bfd_vma}, use +@code{gcc -Wconversion} on a host with 64 bit @code{bfd_vma}'s. +@example + + /* Byte swapping macros for user section data. */ + +#define bfd_put_8(abfd, val, ptr) \ + (*((unsigned char *)(ptr)) = (unsigned char)(val)) +#define bfd_put_signed_8 \ + bfd_put_8 +#define bfd_get_8(abfd, ptr) \ + (*(unsigned char *)(ptr)) +#define bfd_get_signed_8(abfd, ptr) \ + ((*(unsigned char *)(ptr) ^ 0x80) - 0x80) + +#define bfd_put_16(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx16, ((val),(ptr))) +#define bfd_put_signed_16 \ + bfd_put_16 +#define bfd_get_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx16, (ptr)) +#define bfd_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) + +#define bfd_put_32(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx32, ((val),(ptr))) +#define bfd_put_signed_32 \ + bfd_put_32 +#define bfd_get_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx32, (ptr)) +#define bfd_get_signed_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx_signed_32, (ptr)) + +#define bfd_put_64(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx64, ((val), (ptr))) +#define bfd_put_signed_64 \ + bfd_put_64 +#define bfd_get_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx64, (ptr)) +#define bfd_get_signed_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) + +@end example +@* +@findex bfd_h_put_size +@subsubsection @code{bfd_h_put_size} +@strong{Description}@* +These macros have the same function as their @code{bfd_get_x} +bretheren, except that they are used for removing information +for the header records of object files. Believe it or not, +some object files keep their header records in big endian +order and their data in little endian order. +@example + + /* Byte swapping macros for file header data. */ + +#define bfd_h_put_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_put_signed_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_get_8(abfd, ptr) \ + bfd_get_8 (abfd, ptr) +#define bfd_h_get_signed_8(abfd, ptr) \ + bfd_get_signed_8 (abfd, ptr) + +#define bfd_h_put_16(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) +#define bfd_h_put_signed_16 \ + bfd_h_put_16 +#define bfd_h_get_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx16,(ptr)) +#define bfd_h_get_signed_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr)) + +#define bfd_h_put_32(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) +#define bfd_h_put_signed_32 \ + bfd_h_put_32 +#define bfd_h_get_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx32,(ptr)) +#define bfd_h_get_signed_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr)) + +#define bfd_h_put_64(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) +#define bfd_h_put_signed_64 \ + bfd_h_put_64 +#define bfd_h_get_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx64,(ptr)) +#define bfd_h_get_signed_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr)) + +@end example +@* +@findex bfd_log2 +@subsubsection @code{bfd_log2} +@strong{Synopsis} +@example +unsigned int bfd_log2(bfd_vma x); +@end example +@strong{Description}@* +Return the log base 2 of the value supplied, rounded up. E.g., an +@var{x} of 1025 returns 11. +@* diff -urN binutils-2.7/bfd/doc/linker.texi binutils-2.8/bfd/doc/linker.texi --- binutils-2.7/bfd/doc/linker.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/linker.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,365 @@ +@section Linker Functions +@cindex Linker +The linker uses three special entry points in the BFD target +vector. It is not necessary to write special routines for +these entry points when creating a new BFD back end, since +generic versions are provided. However, writing them can +speed up linking and make it use significantly less runtime +memory. + +The first routine creates a hash table used by the other +routines. The second routine adds the symbols from an object +file to the hash table. The third routine takes all the +object files and links them together to create the output +file. These routines are designed so that the linker proper +does not need to know anything about the symbols in the object +files that it is linking. The linker merely arranges the +sections as directed by the linker script and lets BFD handle +the details of symbols and relocs. + +The second routine and third routines are passed a pointer to +a @code{struct bfd_link_info} structure (defined in +@code{bfdlink.h}) which holds information relevant to the link, +including the linker hash table (which was created by the +first routine) and a set of callback functions to the linker +proper. + +The generic linker routines are in @code{linker.c}, and use the +header file @code{genlink.h}. As of this writing, the only back +ends which have implemented versions of these routines are +a.out (in @code{aoutx.h}) and ECOFF (in @code{ecoff.c}). The a.out +routines are used as examples throughout this section. + +@menu +* Creating a Linker Hash Table:: +* Adding Symbols to the Hash Table:: +* Performing the Final Link:: +@end menu +@* +@node Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions +@subsection Creating a linker hash table +@cindex _bfd_link_hash_table_create in target vector +@cindex target vector (_bfd_link_hash_table_create) +The linker routines must create a hash table, which must be +derived from @code{struct bfd_link_hash_table} described in +@code{bfdlink.c}. @xref{Hash Tables} for information on how to +create a derived hash table. This entry point is called using +the target vector of the linker output file. + +The @code{_bfd_link_hash_table_create} entry point must allocate +and initialize an instance of the desired hash table. If the +back end does not require any additional information to be +stored with the entries in the hash table, the entry point may +simply create a @code{struct bfd_link_hash_table}. Most likely, +however, some additional information will be needed. + +For example, with each entry in the hash table the a.out +linker keeps the index the symbol has in the final output file +(this index number is used so that when doing a relocateable +link the symbol index used in the output file can be quickly +filled in when copying over a reloc). The a.out linker code +defines the required structures and functions for a hash table +derived from @code{struct bfd_link_hash_table}. The a.out linker +hash table is created by the function +@code{NAME(aout,link_hash_table_create)}; it simply allocates +space for the hash table, initializes it, and returns a +pointer to it. + +When writing the linker routines for a new back end, you will +generally not know exactly which fields will be required until +you have finished. You should simply create a new hash table +which defines no additional fields, and then simply add fields +as they become necessary. +@* +@node Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions +@subsection Adding symbols to the hash table +@cindex _bfd_link_add_symbols in target vector +@cindex target vector (_bfd_link_add_symbols) +The linker proper will call the @code{_bfd_link_add_symbols} +entry point for each object file or archive which is to be +linked (typically these are the files named on the command +line, but some may also come from the linker script). The +entry point is responsible for examining the file. For an +object file, BFD must add any relevant symbol information to +the hash table. For an archive, BFD must determine which +elements of the archive should be used and adding them to the +link. + +The a.out version of this entry point is +@code{NAME(aout,link_add_symbols)}. + +@menu +* Differing file formats:: +* Adding symbols from an object file:: +* Adding symbols from an archive:: +@end menu +@* +@node Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table +@subsubsection Differing file formats +Normally all the files involved in a link will be of the same +format, but it is also possible to link together different +format object files, and the back end must support that. The +@code{_bfd_link_add_symbols} entry point is called via the target +vector of the file to be added. This has an important +consequence: the function may not assume that the hash table +is the type created by the corresponding +@code{_bfd_link_hash_table_create} vector. All the +@code{_bfd_link_add_symbols} function can assume about the hash +table is that it is derived from @code{struct +bfd_link_hash_table}. + +Sometimes the @code{_bfd_link_add_symbols} function must store +some information in the hash table entry to be used by the +@code{_bfd_final_link} function. In such a case the @code{creator} +field of the hash table must be checked to make sure that the +hash table was created by an object file of the same format. + +The @code{_bfd_final_link} routine must be prepared to handle a +hash entry without any extra information added by the +@code{_bfd_link_add_symbols} function. A hash entry without +extra information will also occur when the linker script +directs the linker to create a symbol. Note that, regardless +of how a hash table entry is added, all the fields will be +initialized to some sort of null value by the hash table entry +initialization function. + +See @code{ecoff_link_add_externals} for an example of how to +check the @code{creator} field before saving information (in this +case, the ECOFF external symbol debugging information) in a +hash table entry. +@* +@node Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table +@subsubsection Adding symbols from an object file +When the @code{_bfd_link_add_symbols} routine is passed an object +file, it must add all externally visible symbols in that +object file to the hash table. The actual work of adding the +symbol to the hash table is normally handled by the function +@code{_bfd_generic_link_add_one_symbol}. The +@code{_bfd_link_add_symbols} routine is responsible for reading +all the symbols from the object file and passing the correct +information to @code{_bfd_generic_link_add_one_symbol}. + +The @code{_bfd_link_add_symbols} routine should not use +@code{bfd_canonicalize_symtab} to read the symbols. The point of +providing this routine is to avoid the overhead of converting +the symbols into generic @code{asymbol} structures. + +@findex _bfd_generic_link_add_one_symbol +@code{_bfd_generic_link_add_one_symbol} handles the details of +combining common symbols, warning about multiple definitions, +and so forth. It takes arguments which describe the symbol to +add, notably symbol flags, a section, and an offset. The +symbol flags include such things as @code{BSF_WEAK} or +@code{BSF_INDIRECT}. The section is a section in the object +file, or something like @code{bfd_und_section_ptr} for an undefined +symbol or @code{bfd_com_section_ptr} for a common symbol. + +If the @code{_bfd_final_link} routine is also going to need to +read the symbol information, the @code{_bfd_link_add_symbols} +routine should save it somewhere attached to the object file +BFD. However, the information should only be saved if the +@code{keep_memory} field of the @code{info} argument is true, so +that the @code{-no-keep-memory} linker switch is effective. + +The a.out function which adds symbols from an object file is +@code{aout_link_add_object_symbols}, and most of the interesting +work is in @code{aout_link_add_symbols}. The latter saves +pointers to the hash tables entries created by +@code{_bfd_generic_link_add_one_symbol} indexed by symbol number, +so that the @code{_bfd_final_link} routine does not have to call +the hash table lookup routine to locate the entry. +@* +@node Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table +@subsubsection Adding symbols from an archive +When the @code{_bfd_link_add_symbols} routine is passed an +archive, it must look through the symbols defined by the +archive and decide which elements of the archive should be +included in the link. For each such element it must call the +@code{add_archive_element} linker callback, and it must add the +symbols from the object file to the linker hash table. + +@findex _bfd_generic_link_add_archive_symbols +In most cases the work of looking through the symbols in the +archive should be done by the +@code{_bfd_generic_link_add_archive_symbols} function. This +function builds a hash table from the archive symbol table and +looks through the list of undefined symbols to see which +elements should be included. +@code{_bfd_generic_link_add_archive_symbols} is passed a function +to call to make the final decision about adding an archive +element to the link and to do the actual work of adding the +symbols to the linker hash table. + +The function passed to +@code{_bfd_generic_link_add_archive_symbols} must read the +symbols of the archive element and decide whether the archive +element should be included in the link. If the element is to +be included, the @code{add_archive_element} linker callback +routine must be called with the element as an argument, and +the elements symbols must be added to the linker hash table +just as though the element had itself been passed to the +@code{_bfd_link_add_symbols} function. + +When the a.out @code{_bfd_link_add_symbols} function receives an +archive, it calls @code{_bfd_generic_link_add_archive_symbols} +passing @code{aout_link_check_archive_element} as the function +argument. @code{aout_link_check_archive_element} calls +@code{aout_link_check_ar_symbols}. If the latter decides to add +the element (an element is only added if it provides a real, +non-common, definition for a previously undefined or common +symbol) it calls the @code{add_archive_element} callback and then +@code{aout_link_check_archive_element} calls +@code{aout_link_add_symbols} to actually add the symbols to the +linker hash table. + +The ECOFF back end is unusual in that it does not normally +call @code{_bfd_generic_link_add_archive_symbols}, because ECOFF +archives already contain a hash table of symbols. The ECOFF +back end searches the archive itself to avoid the overhead of +creating a new hash table. +@* +@node Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions +@subsection Performing the final link +@cindex _bfd_link_final_link in target vector +@cindex target vector (_bfd_final_link) +When all the input files have been processed, the linker calls +the @code{_bfd_final_link} entry point of the output BFD. This +routine is responsible for producing the final output file, +which has several aspects. It must relocate the contents of +the input sections and copy the data into the output sections. +It must build an output symbol table including any local +symbols from the input files and the global symbols from the +hash table. When producing relocateable output, it must +modify the input relocs and write them into the output file. +There may also be object format dependent work to be done. + +The linker will also call the @code{write_object_contents} entry +point when the BFD is closed. The two entry points must work +together in order to produce the correct output file. + +The details of how this works are inevitably dependent upon +the specific object file format. The a.out +@code{_bfd_final_link} routine is @code{NAME(aout,final_link)}. + +@menu +* Information provided by the linker:: +* Relocating the section contents:: +* Writing the symbol table:: +@end menu +@* +@node Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link +@subsubsection Information provided by the linker +Before the linker calls the @code{_bfd_final_link} entry point, +it sets up some data structures for the function to use. + +The @code{input_bfds} field of the @code{bfd_link_info} structure +will point to a list of all the input files included in the +link. These files are linked through the @code{link_next} field +of the @code{bfd} structure. + +Each section in the output file will have a list of +@code{link_order} structures attached to the @code{link_order_head} +field (the @code{link_order} structure is defined in +@code{bfdlink.h}). These structures describe how to create the +contents of the output section in terms of the contents of +various input sections, fill constants, and, eventually, other +types of information. They also describe relocs that must be +created by the BFD backend, but do not correspond to any input +file; this is used to support -Ur, which builds constructors +while generating a relocateable object file. +@* +@node Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link +@subsubsection Relocating the section contents +The @code{_bfd_final_link} function should look through the +@code{link_order} structures attached to each section of the +output file. Each @code{link_order} structure should either be +handled specially, or it should be passed to the function +@code{_bfd_default_link_order} which will do the right thing +(@code{_bfd_default_link_order} is defined in @code{linker.c}). + +For efficiency, a @code{link_order} of type +@code{bfd_indirect_link_order} whose associated section belongs +to a BFD of the same format as the output BFD must be handled +specially. This type of @code{link_order} describes part of an +output section in terms of a section belonging to one of the +input files. The @code{_bfd_final_link} function should read the +contents of the section and any associated relocs, apply the +relocs to the section contents, and write out the modified +section contents. If performing a relocateable link, the +relocs themselves must also be modified and written out. + +@findex _bfd_relocate_contents +@findex _bfd_final_link_relocate +The functions @code{_bfd_relocate_contents} and +@code{_bfd_final_link_relocate} provide some general support for +performing the actual relocations, notably overflow checking. +Their arguments include information about the symbol the +relocation is against and a @code{reloc_howto_type} argument +which describes the relocation to perform. These functions +are defined in @code{reloc.c}. + +The a.out function which handles reading, relocating, and +writing section contents is @code{aout_link_input_section}. The +actual relocation is done in @code{aout_link_input_section_std} +and @code{aout_link_input_section_ext}. +@* +@node Writing the symbol table, , Relocating the section contents, Performing the Final Link +@subsubsection Writing the symbol table +The @code{_bfd_final_link} function must gather all the symbols +in the input files and write them out. It must also write out +all the symbols in the global hash table. This must be +controlled by the @code{strip} and @code{discard} fields of the +@code{bfd_link_info} structure. + +The local symbols of the input files will not have been +entered into the linker hash table. The @code{_bfd_final_link} +routine must consider each input file and include the symbols +in the output file. It may be convenient to do this when +looking through the @code{link_order} structures, or it may be +done by stepping through the @code{input_bfds} list. + +The @code{_bfd_final_link} routine must also traverse the global +hash table to gather all the externally visible symbols. It +is possible that most of the externally visible symbols may be +written out when considering the symbols of each input file, +but it is still necessary to traverse the hash table since the +linker script may have defined some symbols that are not in +any of the input files. + +The @code{strip} field of the @code{bfd_link_info} structure +controls which symbols are written out. The possible values +are listed in @code{bfdlink.h}. If the value is @code{strip_some}, +then the @code{keep_hash} field of the @code{bfd_link_info} +structure is a hash table of symbols to keep; each symbol +should be looked up in this hash table, and only symbols which +are present should be included in the output file. + +If the @code{strip} field of the @code{bfd_link_info} structure +permits local symbols to be written out, the @code{discard} field +is used to further controls which local symbols are included +in the output file. If the value is @code{discard_l}, then all +local symbols which begin with a certain prefix are discarded; +this is controlled by the @code{bfd_is_local_label_name} entry point. + +The a.out backend handles symbols by calling +@code{aout_link_write_symbols} on each input BFD and then +traversing the global hash table with the function +@code{aout_link_write_other_symbol}. It builds a string table +while writing out the symbols, which is written to the output +file at the end of @code{NAME(aout,final_link)}. +@* +@findex bfd_link_split_section +@subsubsection @code{bfd_link_split_section} +@strong{Synopsis} +@example +boolean bfd_link_split_section(bfd *abfd, asection *sec); +@end example +@strong{Description}@* +Return nonzero if @var{sec} should be split during a +reloceatable or final link. +@example +#define bfd_link_split_section(abfd, sec) \ + BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) + +@end example +@* diff -urN binutils-2.7/bfd/doc/makefile.vms binutils-2.8/bfd/doc/makefile.vms --- binutils-2.7/bfd/doc/makefile.vms Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/makefile.vms Wed Apr 30 12:56:27 1997 @@ -0,0 +1,5 @@ +CFLAGS = /noopt/include=([],[-],[-.-.include]) +LDFLAGS = /nomap +LDLIBS = ,sys$$library:vaxcrtl.olb/lib + +all: chew.exe diff -urN binutils-2.7/bfd/doc/opncls.texi binutils-2.8/bfd/doc/opncls.texi --- binutils-2.7/bfd/doc/opncls.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/opncls.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,128 @@ +@section Opening and closing BFDs + +@* +@findex bfd_openr +@subsubsection @code{bfd_openr} +@strong{Synopsis} +@example +bfd *bfd_openr(CONST char *filename, CONST char *target); +@end example +@strong{Description}@* +Open the file @var{filename} (using @code{fopen}) with the target +@var{target}. Return a pointer to the created BFD. + +Calls @code{bfd_find_target}, so @var{target} is interpreted as by +that function. + +If @code{NULL} is returned then an error has occured. Possible errors +are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or @code{system_call} error. +@* +@findex bfd_fdopenr +@subsubsection @code{bfd_fdopenr} +@strong{Synopsis} +@example +bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd); +@end example +@strong{Description}@* +@code{bfd_fdopenr} is to @code{bfd_fopenr} much like @code{fdopen} is to @code{fopen}. +It opens a BFD on a file already described by the @var{fd} +supplied. + +When the file is later @code{bfd_close}d, the file descriptor will be closed. + +If the caller desires that this file descriptor be cached by BFD +(opened as needed, closed as needed to free descriptors for +other opens), with the supplied @var{fd} used as an initial +file descriptor (but subject to closure at any time), call +bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to +assume no cacheing; the file descriptor will remain open until +@code{bfd_close}, and will not be affected by BFD operations on other +files. + +Possible errors are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} and @code{bfd_error_system_call}. +@* +@findex bfd_openstreamr +@subsubsection @code{bfd_openstreamr} +@strong{Synopsis} +@example +bfd *bfd_openstreamr(const char *, const char *, PTR); +@end example +@strong{Description}@* +Open a BFD for read access on an existing stdio stream. When +the BFD is passed to @code{bfd_close}, the stream will be closed. +@* +@findex bfd_openw +@subsubsection @code{bfd_openw} +@strong{Synopsis} +@example +bfd *bfd_openw(CONST char *filename, CONST char *target); +@end example +@strong{Description}@* +Create a BFD, associated with file @var{filename}, using the +file format @var{target}, and return a pointer to it. + +Possible errors are @code{bfd_error_system_call}, @code{bfd_error_no_memory}, +@code{bfd_error_invalid_target}. +@* +@findex bfd_close +@subsubsection @code{bfd_close} +@strong{Synopsis} +@example +boolean bfd_close(bfd *abfd); +@end example +@strong{Description}@* +Close a BFD. If the BFD was open for writing, +then pending operations are completed and the file written out +and closed. If the created file is executable, then +@code{chmod} is called to mark it as such. + +All memory attached to the BFD is released. + +The file descriptor associated with the BFD is closed (even +if it was passed in to BFD by @code{bfd_fdopenr}). +@* +@strong{Returns}@* +@code{true} is returned if all is ok, otherwise @code{false}. +@* +@findex bfd_close_all_done +@subsubsection @code{bfd_close_all_done} +@strong{Synopsis} +@example +boolean bfd_close_all_done(bfd *); +@end example +@strong{Description}@* +Close a BFD. Differs from @code{bfd_close} +since it does not complete any pending operations. This +routine would be used if the application had just used BFD for +swapping and didn't want to use any of the writing code. + +If the created file is executable, then @code{chmod} is called +to mark it as such. + +All memory attached to the BFD is released. +@* +@strong{Returns}@* +@code{true} is returned if all is ok, otherwise @code{false}. +@* +@findex bfd_create +@subsubsection @code{bfd_create} +@strong{Synopsis} +@example +bfd *bfd_create(CONST char *filename, bfd *templ); +@end example +@strong{Description}@* +Create a new BFD in the manner of +@code{bfd_openw}, but without opening a file. The new BFD +takes the target from the target used by @var{template}. The +format is always set to @code{bfd_object}. +@* +@findex bfd_alloc +@subsubsection @code{bfd_alloc} +@strong{Synopsis} +@example +PTR bfd_alloc (bfd *abfd, size_t wanted); +@end example +@strong{Description}@* +Allocate a block of @var{wanted} bytes of memory attached to +@code{abfd} and return a pointer to it. +@* diff -urN binutils-2.7/bfd/doc/reloc.texi binutils-2.8/bfd/doc/reloc.texi --- binutils-2.7/bfd/doc/reloc.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/reloc.texi Wed Apr 30 13:14:11 1997 @@ -0,0 +1,914 @@ +@section Relocations +BFD maintains relocations in much the same way it maintains +symbols: they are left alone until required, then read in +en-mass and translated into an internal form. A common +routine @code{bfd_perform_relocation} acts upon the +canonical form to do the fixup. + +Relocations are maintained on a per section basis, +while symbols are maintained on a per BFD basis. + +All that a back end has to do to fit the BFD interface is to create +a @code{struct reloc_cache_entry} for each relocation +in a particular section, and fill in the right bits of the structures. + +@menu +* typedef arelent:: +* howto manager:: +@end menu +@* + +@node typedef arelent, howto manager, Relocations, Relocations +@subsection typedef arelent +This is the structure of a relocation entry: +@* +. +@example +typedef enum bfd_reloc_status +@{ + /* No errors detected */ + bfd_reloc_ok, + + /* The relocation was performed, but there was an overflow. */ + bfd_reloc_overflow, + + /* The address to relocate was not within the section supplied. */ + bfd_reloc_outofrange, + + /* Used by special functions */ + bfd_reloc_continue, + + /* Unsupported relocation size requested. */ + bfd_reloc_notsupported, + + /* Unused */ + bfd_reloc_other, + + /* The symbol to relocate against was undefined. */ + bfd_reloc_undefined, + + /* The relocation was performed, but may not be ok - presently + generated only when linking i960 coff files with i960 b.out + symbols. If this type is returned, the error_message argument + to bfd_perform_relocation will be set. */ + bfd_reloc_dangerous + @} + bfd_reloc_status_type; + + +typedef struct reloc_cache_entry +@{ + /* A pointer into the canonical table of pointers */ + struct symbol_cache_entry **sym_ptr_ptr; + + /* offset in section */ + bfd_size_type address; + + /* addend for relocation value */ + bfd_vma addend; + + /* Pointer to how to perform the required relocation */ + reloc_howto_type *howto; + +@} arelent; +@end example +@strong{Description}@* +Here is a description of each of the fields within an @code{arelent}: + +@itemize @bullet + +@item +@code{sym_ptr_ptr} +@end itemize +The symbol table pointer points to a pointer to the symbol +associated with the relocation request. It is +the pointer into the table returned by the back end's +@code{get_symtab} action. @xref{Symbols}. The symbol is referenced +through a pointer to a pointer so that tools like the linker +can fix up all the symbols of the same name by modifying only +one pointer. The relocation routine looks in the symbol and +uses the base of the section the symbol is attached to and the +value of the symbol as the initial relocation offset. If the +symbol pointer is zero, then the section provided is looked up. + +@itemize @bullet + +@item +@code{address} +@end itemize +The @code{address} field gives the offset in bytes from the base of +the section data which owns the relocation record to the first +byte of relocatable information. The actual data relocated +will be relative to this point; for example, a relocation +type which modifies the bottom two bytes of a four byte word +would not touch the first byte pointed to in a big endian +world. + +@itemize @bullet + +@item +@code{addend} +@end itemize +The @code{addend} is a value provided by the back end to be added (!) +to the relocation offset. Its interpretation is dependent upon +the howto. For example, on the 68k the code: + +@example + char foo[]; + main() + @{ + return foo[0x12345678]; + @} +@end example + +Could be compiled into: + +@example + linkw fp,#-4 + moveb @@#12345678,d0 + extbl d0 + unlk fp + rts +@end example + +This could create a reloc pointing to @code{foo}, but leave the +offset in the data, something like: + +@example +RELOCATION RECORDS FOR [.text]: +offset type value +00000006 32 _foo + +00000000 4e56 fffc ; linkw fp,#-4 +00000004 1039 1234 5678 ; moveb @@#12345678,d0 +0000000a 49c0 ; extbl d0 +0000000c 4e5e ; unlk fp +0000000e 4e75 ; rts +@end example + +Using coff and an 88k, some instructions don't have enough +space in them to represent the full address range, and +pointers have to be loaded in two parts. So you'd get something like: + +@example + or.u r13,r0,hi16(_foo+0x12345678) + ld.b r2,r13,lo16(_foo+0x12345678) + jmp r1 +@end example + +This should create two relocs, both pointing to @code{_foo}, and with +0x12340000 in their addend field. The data would consist of: + +@example +RELOCATION RECORDS FOR [.text]: +offset type value +00000002 HVRT16 _foo+0x12340000 +00000006 LVRT16 _foo+0x12340000 + +00000000 5da05678 ; or.u r13,r0,0x5678 +00000004 1c4d5678 ; ld.b r2,r13,0x5678 +00000008 f400c001 ; jmp r1 +@end example + +The relocation routine digs out the value from the data, adds +it to the addend to get the original offset, and then adds the +value of @code{_foo}. Note that all 32 bits have to be kept around +somewhere, to cope with carry from bit 15 to bit 16. + +One further example is the sparc and the a.out format. The +sparc has a similar problem to the 88k, in that some +instructions don't have room for an entire offset, but on the +sparc the parts are created in odd sized lumps. The designers of +the a.out format chose to not use the data within the section +for storing part of the offset; all the offset is kept within +the reloc. Anything in the data should be ignored. + +@example + save %sp,-112,%sp + sethi %hi(_foo+0x12345678),%g2 + ldsb [%g2+%lo(_foo+0x12345678)],%i0 + ret + restore +@end example + +Both relocs contain a pointer to @code{foo}, and the offsets +contain junk. + +@example +RELOCATION RECORDS FOR [.text]: +offset type value +00000004 HI22 _foo+0x12345678 +00000008 LO10 _foo+0x12345678 + +00000000 9de3bf90 ; save %sp,-112,%sp +00000004 05000000 ; sethi %hi(_foo+0),%g2 +00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 +0000000c 81c7e008 ; ret +00000010 81e80000 ; restore +@end example + +@itemize @bullet + +@item +@code{howto} +@end itemize +The @code{howto} field can be imagined as a +relocation instruction. It is a pointer to a structure which +contains information on what to do with all of the other +information in the reloc record and data section. A back end +would normally have a relocation instruction set and turn +relocations into pointers to the correct structure on input - +but it would be possible to create each howto field on demand. +@* +@subsubsection @code{enum complain_overflow} +Indicates what sort of overflow checking should be done when +performing a relocation. +@* +. +@example +enum complain_overflow +@{ + /* Do not complain on overflow. */ + complain_overflow_dont, + + /* Complain if the bitfield overflows, whether it is considered + as signed or unsigned. */ + complain_overflow_bitfield, + + /* Complain if the value overflows when considered as signed + number. */ + complain_overflow_signed, + + /* Complain if the value overflows when considered as an + unsigned number. */ + complain_overflow_unsigned +@}; +@end example +@subsubsection @code{reloc_howto_type} +The @code{reloc_howto_type} is a structure which contains all the +information that libbfd needs to know to tie up a back end's data. +@* +.struct symbol_cache_entry; /* Forward declaration */ +@example + +struct reloc_howto_struct +@{ + /* The type field has mainly a documentary use - the back end can + do what it wants with it, though normally the back end's + external idea of what a reloc number is stored + in this field. For example, a PC relative word relocation + in a coff environment has the type 023 - because that's + what the outside world calls a R_PCRWORD reloc. */ + unsigned int type; + + /* The value the final relocation is shifted right by. This drops + unwanted data from the relocation. */ + unsigned int rightshift; + + /* The size of the item to be relocated. This is *not* a + power-of-two measure. To get the number of bytes operated + on by a type of relocation, use bfd_get_reloc_size. */ + int size; + + /* The number of bits in the item to be relocated. This is used + when doing overflow checking. */ + unsigned int bitsize; + + /* Notes that the relocation is relative to the location in the + data section of the addend. The relocation function will + subtract from the relocation value the address of the location + being relocated. */ + boolean pc_relative; + + /* The bit position of the reloc value in the destination. + The relocated value is left shifted by this amount. */ + unsigned int bitpos; + + /* What type of overflow error should be checked for when + relocating. */ + enum complain_overflow complain_on_overflow; + + /* If this field is non null, then the supplied function is + called rather than the normal function. This allows really + strange relocation methods to be accomodated (e.g., i960 callj + instructions). */ + bfd_reloc_status_type (*special_function) + PARAMS ((bfd *abfd, + arelent *reloc_entry, + struct symbol_cache_entry *symbol, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message)); + + /* The textual name of the relocation type. */ + char *name; + + /* When performing a partial link, some formats must modify the + relocations rather than the data - this flag signals this.*/ + boolean partial_inplace; + + /* The src_mask selects which parts of the read in data + are to be used in the relocation sum. E.g., if this was an 8 bit + bit of data which we read and relocated, this would be + 0x000000ff. When we have relocs which have an addend, such as + sun4 extended relocs, the value in the offset part of a + relocating field is garbage so we never use it. In this case + the mask would be 0x00000000. */ + bfd_vma src_mask; + + /* The dst_mask selects which parts of the instruction are replaced + into the instruction. In most cases src_mask == dst_mask, + except in the above special case, where dst_mask would be + 0x000000ff, and src_mask would be 0x00000000. */ + bfd_vma dst_mask; + + /* When some formats create PC relative instructions, they leave + the value of the pc of the place being relocated in the offset + slot of the instruction, so that a PC relative relocation can + be made just by adding in an ordinary offset (e.g., sun3 a.out). + Some formats leave the displacement part of an instruction + empty (e.g., m88k bcs); this flag signals the fact.*/ + boolean pcrel_offset; + +@}; +@end example +@findex The HOWTO Macro +@subsubsection @code{The HOWTO Macro} +@strong{Description}@* +The HOWTO define is horrible and will go away. +@example +#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ + @{(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC@} +@end example +@* +@strong{Description}@* +And will be replaced with the totally magic way. But for the +moment, we are compatible, so do it this way. +@example +#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) + +@end example +@* +@strong{Description}@* +Helper routine to turn a symbol into a relocation value. +@example +#define HOWTO_PREPARE(relocation, symbol) \ + @{ \ + if (symbol != (asymbol *)NULL) @{ \ + if (bfd_is_com_section (symbol->section)) @{ \ + relocation = 0; \ + @} \ + else @{ \ + relocation = symbol->value; \ + @} \ + @} \ +@} +@end example +@* +@findex bfd_get_reloc_size +@subsubsection @code{bfd_get_reloc_size} +@strong{Synopsis} +@example +int bfd_get_reloc_size (reloc_howto_type *); +@end example +@strong{Description}@* +For a reloc_howto_type that operates on a fixed number of bytes, +this returns the number of bytes operated on. +@* +@findex arelent_chain +@subsubsection @code{arelent_chain} +@strong{Description}@* +How relocs are tied together in an @code{asection}: +@example +typedef struct relent_chain @{ + arelent relent; + struct relent_chain *next; +@} arelent_chain; +@end example +@* +@findex bfd_perform_relocation +@subsubsection @code{bfd_perform_relocation} +@strong{Synopsis} +@example +bfd_reloc_status_type +bfd_perform_relocation + (bfd *abfd, + arelent *reloc_entry, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message); +@end example +@strong{Description}@* +If @var{output_bfd} is supplied to this function, the +generated image will be relocatable; the relocations are +copied to the output file after they have been changed to +reflect the new state of the world. There are two ways of +reflecting the results of partial linkage in an output file: +by modifying the output data in place, and by modifying the +relocation record. Some native formats (e.g., basic a.out and +basic coff) have no way of specifying an addend in the +relocation type, so the addend has to go in the output data. +This is no big deal since in these formats the output data +slot will always be big enough for the addend. Complex reloc +types with addends were invented to solve just this problem. +The @var{error_message} argument is set to an error message if +this return @code{bfd_reloc_dangerous}. +@* +@findex bfd_install_relocation +@subsubsection @code{bfd_install_relocation} +@strong{Synopsis} +@example +bfd_reloc_status_type +bfd_install_relocation + (bfd *abfd, + arelent *reloc_entry, + PTR data, bfd_vma data_start, + asection *input_section, + char **error_message); +@end example +@strong{Description}@* +This looks remarkably like @code{bfd_perform_relocation}, except it +does not expect that the section contents have been filled in. +I.e., it's suitable for use when creating, rather than applying +a relocation. + +For now, this function should be considered reserved for the +assembler. +@* + +@node howto manager, , typedef arelent, Relocations +@section The howto manager +When an application wants to create a relocation, but doesn't +know what the target machine might call it, it can find out by +using this bit of code. +@* +@findex bfd_reloc_code_type +@subsubsection @code{bfd_reloc_code_type} +@strong{Description}@* +The insides of a reloc code. The idea is that, eventually, there +will be one enumerator for every type of relocation we ever do. +Pass one of these values to @code{bfd_reloc_type_lookup}, and it'll +return a howto pointer. + +This does mean that the application must determine the correct +enumerator value; you can't get a howto pointer from a random set +of attributes. +@* +Here are the possible values for @code{enum bfd_reloc_code_real}: + +@deffn {} BFD_RELOC_64 +@deffnx {} BFD_RELOC_32 +@deffnx {} BFD_RELOC_26 +@deffnx {} BFD_RELOC_24 +@deffnx {} BFD_RELOC_16 +@deffnx {} BFD_RELOC_14 +@deffnx {} BFD_RELOC_8 +Basic absolute relocations of N bits. +@end deffn +@deffn {} BFD_RELOC_64_PCREL +@deffnx {} BFD_RELOC_32_PCREL +@deffnx {} BFD_RELOC_24_PCREL +@deffnx {} BFD_RELOC_16_PCREL +@deffnx {} BFD_RELOC_12_PCREL +@deffnx {} BFD_RELOC_8_PCREL +PC-relative relocations. Sometimes these are relative to the address +of the relocation itself; sometimes they are relative to the start of +the section containing the relocation. It depends on the specific target. + +The 24-bit relocation is used in some Intel 960 configurations. +@end deffn +@deffn {} BFD_RELOC_32_GOT_PCREL +@deffnx {} BFD_RELOC_16_GOT_PCREL +@deffnx {} BFD_RELOC_8_GOT_PCREL +@deffnx {} BFD_RELOC_32_GOTOFF +@deffnx {} BFD_RELOC_16_GOTOFF +@deffnx {} BFD_RELOC_LO16_GOTOFF +@deffnx {} BFD_RELOC_HI16_GOTOFF +@deffnx {} BFD_RELOC_HI16_S_GOTOFF +@deffnx {} BFD_RELOC_8_GOTOFF +@deffnx {} BFD_RELOC_32_PLT_PCREL +@deffnx {} BFD_RELOC_24_PLT_PCREL +@deffnx {} BFD_RELOC_16_PLT_PCREL +@deffnx {} BFD_RELOC_8_PLT_PCREL +@deffnx {} BFD_RELOC_32_PLTOFF +@deffnx {} BFD_RELOC_16_PLTOFF +@deffnx {} BFD_RELOC_LO16_PLTOFF +@deffnx {} BFD_RELOC_HI16_PLTOFF +@deffnx {} BFD_RELOC_HI16_S_PLTOFF +@deffnx {} BFD_RELOC_8_PLTOFF +For ELF. +@end deffn +@deffn {} BFD_RELOC_68K_GLOB_DAT +@deffnx {} BFD_RELOC_68K_JMP_SLOT +@deffnx {} BFD_RELOC_68K_RELATIVE +Relocations used by 68K ELF. +@end deffn +@deffn {} BFD_RELOC_32_BASEREL +@deffnx {} BFD_RELOC_16_BASEREL +@deffnx {} BFD_RELOC_LO16_BASEREL +@deffnx {} BFD_RELOC_HI16_BASEREL +@deffnx {} BFD_RELOC_HI16_S_BASEREL +@deffnx {} BFD_RELOC_8_BASEREL +@deffnx {} BFD_RELOC_RVA +Linkage-table relative. +@end deffn +@deffn {} BFD_RELOC_8_FFnn +Absolute 8-bit relocation, but used to form an address like 0xFFnn. +@end deffn +@deffn {} BFD_RELOC_32_PCREL_S2 +@deffnx {} BFD_RELOC_16_PCREL_S2 +@deffnx {} BFD_RELOC_23_PCREL_S2 +These PC-relative relocations are stored as word displacements -- +i.e., byte displacements shifted right two bits. The 30-bit word +displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the +SPARC. (SPARC tools generally refer to this as <>.) The +signed 16-bit displacement is used on the MIPS, and the 23-bit +displacement is used on the Alpha. +@end deffn +@deffn {} BFD_RELOC_HI22 +@deffnx {} BFD_RELOC_LO10 +High 22 bits and low 10 bits of 32-bit value, placed into lower bits of +the target word. These are used on the SPARC. +@end deffn +@deffn {} BFD_RELOC_GPREL16 +@deffnx {} BFD_RELOC_GPREL32 +For systems that allocate a Global Pointer register, these are +displacements off that register. These relocation types are +handled specially, because the value the register will have is +decided relatively late. +@end deffn +@deffn {} BFD_RELOC_I960_CALLJ +Reloc types used for i960/b.out. +@end deffn +@deffn {} BFD_RELOC_NONE +@deffnx {} BFD_RELOC_SPARC_WDISP22 +@deffnx {} BFD_RELOC_SPARC22 +@deffnx {} BFD_RELOC_SPARC13 +@deffnx {} BFD_RELOC_SPARC_GOT10 +@deffnx {} BFD_RELOC_SPARC_GOT13 +@deffnx {} BFD_RELOC_SPARC_GOT22 +@deffnx {} BFD_RELOC_SPARC_PC10 +@deffnx {} BFD_RELOC_SPARC_PC22 +@deffnx {} BFD_RELOC_SPARC_WPLT30 +@deffnx {} BFD_RELOC_SPARC_COPY +@deffnx {} BFD_RELOC_SPARC_GLOB_DAT +@deffnx {} BFD_RELOC_SPARC_JMP_SLOT +@deffnx {} BFD_RELOC_SPARC_RELATIVE +@deffnx {} BFD_RELOC_SPARC_UA32 +SPARC ELF relocations. There is probably some overlap with other +relocation types already defined. +@end deffn +@deffn {} BFD_RELOC_SPARC_BASE13 +@deffnx {} BFD_RELOC_SPARC_BASE22 +I think these are specific to SPARC a.out (e.g., Sun 4). +@end deffn +@deffn {} BFD_RELOC_SPARC_64 +@deffnx {} BFD_RELOC_SPARC_10 +@deffnx {} BFD_RELOC_SPARC_11 +@deffnx {} BFD_RELOC_SPARC_OLO10 +@deffnx {} BFD_RELOC_SPARC_HH22 +@deffnx {} BFD_RELOC_SPARC_HM10 +@deffnx {} BFD_RELOC_SPARC_LM22 +@deffnx {} BFD_RELOC_SPARC_PC_HH22 +@deffnx {} BFD_RELOC_SPARC_PC_HM10 +@deffnx {} BFD_RELOC_SPARC_PC_LM22 +@deffnx {} BFD_RELOC_SPARC_WDISP16 +@deffnx {} BFD_RELOC_SPARC_WDISP19 +@deffnx {} BFD_RELOC_SPARC_GLOB_JMP +@deffnx {} BFD_RELOC_SPARC_7 +@deffnx {} BFD_RELOC_SPARC_6 +@deffnx {} BFD_RELOC_SPARC_5 +Some relocations we're using for SPARC V9 -- subject to change. +@end deffn +@deffn {} BFD_RELOC_ALPHA_GPDISP_HI16 +Alpha ECOFF and ELF relocations. Some of these treat the symbol or +"addend" in some special way. +For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when +writing; when reading, it will be the absolute section symbol. The +addend is the displacement in bytes of the "lda" instruction from +the "ldah" instruction (which is at the address of this reloc). +@end deffn +@deffn {} BFD_RELOC_ALPHA_GPDISP_LO16 +For GPDISP_LO16 ("ignore") relocations, the symbol is handled as +with GPDISP_HI16 relocs. The addend is ignored when writing the +relocations out, and is filled in with the file's GP value on +reading, for convenience. +@end deffn +@deffn {} BFD_RELOC_ALPHA_GPDISP +The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 +relocation except that there is no accompanying GPDISP_LO16 +relocation. +@end deffn +@deffn {} BFD_RELOC_ALPHA_LITERAL +@deffnx {} BFD_RELOC_ALPHA_ELF_LITERAL +@deffnx {} BFD_RELOC_ALPHA_LITUSE +The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; +the assembler turns it into a LDQ instruction to load the address of +the symbol, and then fills in a register in the real instruction. + +The LITERAL reloc, at the LDQ instruction, refers to the .lita +section symbol. The addend is ignored when writing, but is filled +in with the file's GP value on reading, for convenience, as with the +GPDISP_LO16 reloc. + +The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. +It should refer to the symbol to be referenced, as with 16_GOTOFF, +but it generates output not based on the position within the .got +section, but relative to the GP value chosen for the file during the +final link stage. + +The LITUSE reloc, on the instruction using the loaded address, gives +information to the linker that it might be able to use to optimize +away some literal section references. The symbol is ignored (read +as the absolute section symbol), and the "addend" indicates the type +of instruction using the register: +1 - "memory" fmt insn +2 - byte-manipulation (byte offset reg) +3 - jsr (target of branch) + +The GNU linker currently doesn't do any of this optimizing. +@end deffn +@deffn {} BFD_RELOC_ALPHA_HINT +The HINT relocation indicates a value that should be filled into the +"hint" field of a jmp/jsr/ret instruction, for possible branch- +prediction logic which may be provided on some processors. +@end deffn +@deffn {} BFD_RELOC_ALPHA_LINKAGE +The LINKAGE relocation outputs a linkage pair in the object file, +which is filled by the linker. +@end deffn +@deffn {} BFD_RELOC_ALPHA_CODEADDR +The CODEADDR relocation outputs a STO_CA in the object file, +which is filled by the linker. +@end deffn +@deffn {} BFD_RELOC_MIPS_JMP +Bits 27..2 of the relocation address shifted right 2 bits; +simple reloc otherwise. +@end deffn +@deffn {} BFD_RELOC_MIPS16_JMP +The MIPS16 jump instruction. +@end deffn +@deffn {} BFD_RELOC_MIPS16_GPREL +MIPS16 GP relative reloc. +@end deffn +@deffn {} BFD_RELOC_HI16 +High 16 bits of 32-bit value; simple reloc. +@end deffn +@deffn {} BFD_RELOC_HI16_S +High 16 bits of 32-bit value but the low 16 bits will be sign +extended and added to form the final result. If the low 16 +bits form a negative number, we need to add one to the high value +to compensate for the borrow when the low bits are added. +@end deffn +@deffn {} BFD_RELOC_LO16 +Low 16 bits. +@end deffn +@deffn {} BFD_RELOC_PCREL_HI16_S +Like BFD_RELOC_HI16_S, but PC relative. +@end deffn +@deffn {} BFD_RELOC_PCREL_LO16 +Like BFD_RELOC_LO16, but PC relative. +@end deffn +@deffn {} BFD_RELOC_MIPS_GPREL +Relocation relative to the global pointer. +@end deffn +@deffn {} BFD_RELOC_MIPS_LITERAL +Relocation against a MIPS literal section. +@end deffn +@deffn {} BFD_RELOC_MIPS_GOT16 +@deffnx {} BFD_RELOC_MIPS_CALL16 +@deffnx {} BFD_RELOC_MIPS_GPREL32 +@deffnx {} BFD_RELOC_MIPS_GOT_HI16 +@deffnx {} BFD_RELOC_MIPS_GOT_LO16 +@deffnx {} BFD_RELOC_MIPS_CALL_HI16 +@deffnx {} BFD_RELOC_MIPS_CALL_LO16 +MIPS ELF relocations. +@end deffn +@deffn {} BFD_RELOC_386_GOT32 +@deffnx {} BFD_RELOC_386_PLT32 +@deffnx {} BFD_RELOC_386_COPY +@deffnx {} BFD_RELOC_386_GLOB_DAT +@deffnx {} BFD_RELOC_386_JUMP_SLOT +@deffnx {} BFD_RELOC_386_RELATIVE +@deffnx {} BFD_RELOC_386_GOTOFF +@deffnx {} BFD_RELOC_386_GOTPC +i386/elf relocations +@end deffn +@deffn {} BFD_RELOC_NS32K_IMM_8 +@deffnx {} BFD_RELOC_NS32K_IMM_16 +@deffnx {} BFD_RELOC_NS32K_IMM_32 +@deffnx {} BFD_RELOC_NS32K_IMM_8_PCREL +@deffnx {} BFD_RELOC_NS32K_IMM_16_PCREL +@deffnx {} BFD_RELOC_NS32K_IMM_32_PCREL +@deffnx {} BFD_RELOC_NS32K_DISP_8 +@deffnx {} BFD_RELOC_NS32K_DISP_16 +@deffnx {} BFD_RELOC_NS32K_DISP_32 +@deffnx {} BFD_RELOC_NS32K_DISP_8_PCREL +@deffnx {} BFD_RELOC_NS32K_DISP_16_PCREL +@deffnx {} BFD_RELOC_NS32K_DISP_32_PCREL +ns32k relocations +@end deffn +@deffn {} BFD_RELOC_PPC_B26 +@deffnx {} BFD_RELOC_PPC_BA26 +@deffnx {} BFD_RELOC_PPC_TOC16 +@deffnx {} BFD_RELOC_PPC_B16 +@deffnx {} BFD_RELOC_PPC_B16_BRTAKEN +@deffnx {} BFD_RELOC_PPC_B16_BRNTAKEN +@deffnx {} BFD_RELOC_PPC_BA16 +@deffnx {} BFD_RELOC_PPC_BA16_BRTAKEN +@deffnx {} BFD_RELOC_PPC_BA16_BRNTAKEN +@deffnx {} BFD_RELOC_PPC_COPY +@deffnx {} BFD_RELOC_PPC_GLOB_DAT +@deffnx {} BFD_RELOC_PPC_JMP_SLOT +@deffnx {} BFD_RELOC_PPC_RELATIVE +@deffnx {} BFD_RELOC_PPC_LOCAL24PC +@deffnx {} BFD_RELOC_PPC_EMB_NADDR32 +@deffnx {} BFD_RELOC_PPC_EMB_NADDR16 +@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_LO +@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_HI +@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_HA +@deffnx {} BFD_RELOC_PPC_EMB_SDAI16 +@deffnx {} BFD_RELOC_PPC_EMB_SDA2I16 +@deffnx {} BFD_RELOC_PPC_EMB_SDA2REL +@deffnx {} BFD_RELOC_PPC_EMB_SDA21 +@deffnx {} BFD_RELOC_PPC_EMB_MRKREF +@deffnx {} BFD_RELOC_PPC_EMB_RELSEC16 +@deffnx {} BFD_RELOC_PPC_EMB_RELST_LO +@deffnx {} BFD_RELOC_PPC_EMB_RELST_HI +@deffnx {} BFD_RELOC_PPC_EMB_RELST_HA +@deffnx {} BFD_RELOC_PPC_EMB_BIT_FLD +@deffnx {} BFD_RELOC_PPC_EMB_RELSDA +Power(rs6000) and PowerPC relocations. +@end deffn +@deffn {} BFD_RELOC_CTOR +The type of reloc used to build a contructor table - at the moment +probably a 32 bit wide absolute relocation, but the target can choose. +It generally does map to one of the other relocation types. +@end deffn +@deffn {} BFD_RELOC_ARM_PCREL_BRANCH +ARM 26 bit pc-relative branch. The lowest two bits must be zero and are +not stored in the instruction. +@end deffn +@deffn {} BFD_RELOC_ARM_IMMEDIATE +@deffnx {} BFD_RELOC_ARM_OFFSET_IMM +@deffnx {} BFD_RELOC_ARM_SHIFT_IMM +@deffnx {} BFD_RELOC_ARM_SWI +@deffnx {} BFD_RELOC_ARM_MULTI +@deffnx {} BFD_RELOC_ARM_CP_OFF_IMM +@deffnx {} BFD_RELOC_ARM_ADR_IMM +@deffnx {} BFD_RELOC_ARM_LDR_IMM +@deffnx {} BFD_RELOC_ARM_LITERAL +@deffnx {} BFD_RELOC_ARM_IN_POOL +@deffnx {} BFD_RELOC_ARM_OFFSET_IMM8 +@deffnx {} BFD_RELOC_ARM_HWLITERAL +@deffnx {} BFD_RELOC_ARM_THUMB_ADD +@deffnx {} BFD_RELOC_ARM_THUMB_IMM +@deffnx {} BFD_RELOC_ARM_THUMB_SHIFT +@deffnx {} BFD_RELOC_ARM_THUMB_OFFSET +These relocs are only used within the ARM assembler. They are not +(at present) written to any object files. +@end deffn +@deffn {} BFD_RELOC_SH_PCDISP8BY2 +@deffnx {} BFD_RELOC_SH_PCDISP12BY2 +@deffnx {} BFD_RELOC_SH_IMM4 +@deffnx {} BFD_RELOC_SH_IMM4BY2 +@deffnx {} BFD_RELOC_SH_IMM4BY4 +@deffnx {} BFD_RELOC_SH_IMM8 +@deffnx {} BFD_RELOC_SH_IMM8BY2 +@deffnx {} BFD_RELOC_SH_IMM8BY4 +@deffnx {} BFD_RELOC_SH_PCRELIMM8BY2 +@deffnx {} BFD_RELOC_SH_PCRELIMM8BY4 +@deffnx {} BFD_RELOC_SH_SWITCH16 +@deffnx {} BFD_RELOC_SH_SWITCH32 +@deffnx {} BFD_RELOC_SH_USES +@deffnx {} BFD_RELOC_SH_COUNT +@deffnx {} BFD_RELOC_SH_ALIGN +@deffnx {} BFD_RELOC_SH_CODE +@deffnx {} BFD_RELOC_SH_DATA +@deffnx {} BFD_RELOC_SH_LABEL +Hitachi SH relocs. Not all of these appear in object files. +@end deffn +@deffn {} BFD_RELOC_D10V_10_PCREL_R +Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. +@end deffn +@deffn {} BFD_RELOC_D10V_10_PCREL_L +Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. This is the same as the previous reloc +except it is in the left container, i.e., +shifted left 15 bits. +@end deffn +@deffn {} BFD_RELOC_D10V_18 +This is an 18-bit reloc with the right 2 bits +assumed to be 0. +@end deffn +@deffn {} BFD_RELOC_D10V_18_PCREL +This is an 18-bit reloc with the right 2 bits +assumed to be 0. +@end deffn +@deffn {} BFD_RELOC_M32R_24 +Mitsubishi M32R relocs. +This is a 24 bit absolute address. +@end deffn +@deffn {} BFD_RELOC_M32R_10_PCREL +This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. +@end deffn +@deffn {} BFD_RELOC_M32R_18_PCREL +This is an 18-bit reloc with the right 2 bits assumed to be 0. +@end deffn +@deffn {} BFD_RELOC_M32R_26_PCREL +This is a 26-bit reloc with the right 2 bits assumed to be 0. +@end deffn +@deffn {} BFD_RELOC_M32R_HI16_ULO +This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as unsigned. +@end deffn +@deffn {} BFD_RELOC_M32R_HI16_SLO +This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as signed. +@end deffn +@deffn {} BFD_RELOC_M32R_LO16 +This is a 16-bit reloc containing the lower 16 bits of an address. +@end deffn +@deffn {} BFD_RELOC_M32R_SDA16 +This is a 16-bit reloc containing the small data area offset for use in +add3, load, and store instructions. +@end deffn +@deffn {} BFD_RELOC_MN10300_32_PCREL +This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. +@end deffn +@deffn {} BFD_RELOC_MN10300_16_PCREL +This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. +@end deffn +. +@example +typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; +@end example +@findex bfd_reloc_type_lookup +@subsubsection @code{bfd_reloc_type_lookup} +@strong{Synopsis} +@example +reloc_howto_type * +bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); +@end example +@strong{Description}@* +Return a pointer to a howto structure which, when +invoked, will perform the relocation @var{code} on data from the +architecture noted. +@* +@findex bfd_default_reloc_type_lookup +@subsubsection @code{bfd_default_reloc_type_lookup} +@strong{Synopsis} +@example +reloc_howto_type *bfd_default_reloc_type_lookup + (bfd *abfd, bfd_reloc_code_real_type code); +@end example +@strong{Description}@* +Provides a default relocation lookup routine for any architecture. +@* +@findex bfd_get_reloc_code_name +@subsubsection @code{bfd_get_reloc_code_name} +@strong{Synopsis} +@example +const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); +@end example +@strong{Description}@* +Provides a printable name for the supplied relocation code. +Useful mainly for printing error messages. +@* +@findex bfd_generic_relax_section +@subsubsection @code{bfd_generic_relax_section} +@strong{Synopsis} +@example +boolean bfd_generic_relax_section + (bfd *abfd, + asection *section, + struct bfd_link_info *, + boolean *); +@end example +@strong{Description}@* +Provides default handling for relaxing for back ends which +don't do relaxing -- i.e., does nothing. +@* +@findex bfd_generic_get_relocated_section_contents +@subsubsection @code{bfd_generic_get_relocated_section_contents} +@strong{Synopsis} +@example +bfd_byte * +bfd_generic_get_relocated_section_contents (bfd *abfd, + struct bfd_link_info *link_info, + struct bfd_link_order *link_order, + bfd_byte *data, + boolean relocateable, + asymbol **symbols); +@end example +@strong{Description}@* +Provides default handling of relocation effort for back ends +which can't be bothered to do it efficiently. +@* diff -urN binutils-2.7/bfd/doc/section.texi binutils-2.8/bfd/doc/section.texi --- binutils-2.7/bfd/doc/section.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/section.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,649 @@ +@section Sections +The raw data contained within a BFD is maintained through the +section abstraction. A single BFD may have any number of +sections. It keeps hold of them by pointing to the first; +each one points to the next in the list. + +Sections are supported in BFD in @code{section.c}. + +@menu +* Section Input:: +* Section Output:: +* typedef asection:: +* section prototypes:: +@end menu +@* +@node Section Input, Section Output, Sections, Sections +@subsection Section input +When a BFD is opened for reading, the section structures are +created and attached to the BFD. + +Each section has a name which describes the section in the +outside world---for example, @code{a.out} would contain at least +three sections, called @code{.text}, @code{.data} and @code{.bss}. + +Names need not be unique; for example a COFF file may have several +sections named @code{.data}. + +Sometimes a BFD will contain more than the ``natural'' number of +sections. A back end may attach other sections containing +constructor data, or an application may add a section (using +@code{bfd_make_section}) to the sections attached to an already open +BFD. For example, the linker creates an extra section +@code{COMMON} for each input file's BFD to hold information about +common storage. + +The raw data is not necessarily read in when +the section descriptor is created. Some targets may leave the +data in place until a @code{bfd_get_section_contents} call is +made. Other back ends may read in all the data at once. For +example, an S-record file has to be read once to determine the +size of the data. An IEEE-695 file doesn't contain raw data in +sections, but data and relocation expressions intermixed, so +the data area has to be parsed to get out the data and +relocations. +@* +@node Section Output, typedef asection, Section Input, Sections +@subsection Section output +To write a new object style BFD, the various sections to be +written have to be created. They are attached to the BFD in +the same way as input sections; data is written to the +sections using @code{bfd_set_section_contents}. + +Any program that creates or combines sections (e.g., the assembler +and linker) must use the @code{asection} fields @code{output_section} and +@code{output_offset} to indicate the file sections to which each +section must be written. (If the section is being created from +scratch, @code{output_section} should probably point to the section +itself and @code{output_offset} should probably be zero.) + +The data to be written comes from input sections attached +(via @code{output_section} pointers) to +the output sections. The output section structure can be +considered a filter for the input section: the output section +determines the vma of the output data and the name, but the +input section determines the offset into the output section of +the data to be written. + +E.g., to create a section "O", starting at 0x100, 0x123 long, +containing two subsections, "A" at offset 0x0 (i.e., at vma +0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the @code{asection} +structures would look like: + +@example + section name "A" + output_offset 0x00 + size 0x20 + output_section -----------> section name "O" + | vma 0x100 + section name "B" | size 0x123 + output_offset 0x20 | + size 0x103 | + output_section --------| +@end example +@* +@subsection Link orders +The data within a section is stored in a @dfn{link_order}. +These are much like the fixups in @code{gas}. The link_order +abstraction allows a section to grow and shrink within itself. + +A link_order knows how big it is, and which is the next +link_order and where the raw data for it is; it also points to +a list of relocations which apply to it. + +The link_order is used by the linker to perform relaxing on +final code. The compiler creates code which is as big as +necessary to make it work without relaxing, and the user can +select whether to relax. Sometimes relaxing takes a lot of +time. The linker runs around the relocations to see if any +are attached to data which can be shrunk, if so it does it on +a link_order by link_order basis. +@* + +@node typedef asection, section prototypes, Section Output, Sections +@subsection typedef asection +Here is the section structure: +@* +. +@example +typedef struct sec +@{ + /* The name of the section; the name isn't a copy, the pointer is + the same as that passed to bfd_make_section. */ + + CONST char *name; + + /* Which section is it; 0..nth. */ + + int index; + + /* The next section in the list belonging to the BFD, or NULL. */ + + struct sec *next; + + /* The field flags contains attributes of the section. Some + flags are read in from the object file, and some are + synthesized from other information. */ + + flagword flags; + +#define SEC_NO_FLAGS 0x000 + + /* Tells the OS to allocate space for this section when loading. + This is clear for a section containing debug information + only. */ +#define SEC_ALLOC 0x001 + + /* Tells the OS to load the section from the file when loading. + This is clear for a .bss section. */ +#define SEC_LOAD 0x002 + + /* The section contains data still to be relocated, so there is + some relocation information too. */ +#define SEC_RELOC 0x004 + +#if 0 /* Obsolete ? */ +#define SEC_BALIGN 0x008 +#endif + + /* A signal to the OS that the section contains read only + data. */ +#define SEC_READONLY 0x010 + + /* The section contains code only. */ +#define SEC_CODE 0x020 + + /* The section contains data only. */ +#define SEC_DATA 0x040 + + /* The section will reside in ROM. */ +#define SEC_ROM 0x080 + + /* The section contains constructor information. This section + type is used by the linker to create lists of constructors and + destructors used by @code{g++}. When a back end sees a symbol + which should be used in a constructor list, it creates a new + section for the type of name (e.g., @code{__CTOR_LIST__}), attaches + the symbol to it, and builds a relocation. To build the lists + of constructors, all the linker has to do is catenate all the + sections called @code{__CTOR_LIST__} and relocate the data + contained within - exactly the operations it would peform on + standard data. */ +#define SEC_CONSTRUCTOR 0x100 + + /* The section is a constuctor, and should be placed at the + end of the text, data, or bss section(?). */ +#define SEC_CONSTRUCTOR_TEXT 0x1100 +#define SEC_CONSTRUCTOR_DATA 0x2100 +#define SEC_CONSTRUCTOR_BSS 0x3100 + + /* The section has contents - a data section could be + @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be + @code{SEC_HAS_CONTENTS} */ +#define SEC_HAS_CONTENTS 0x200 + + /* An instruction to the linker to not output the section + even if it has information which would normally be written. */ +#define SEC_NEVER_LOAD 0x400 + + /* The section is a COFF shared library section. This flag is + only for the linker. If this type of section appears in + the input file, the linker must copy it to the output file + without changing the vma or size. FIXME: Although this + was originally intended to be general, it really is COFF + specific (and the flag was renamed to indicate this). It + might be cleaner to have some more general mechanism to + allow the back end to control what the linker does with + sections. */ +#define SEC_COFF_SHARED_LIBRARY 0x800 + + /* The section contains common symbols (symbols may be defined + multiple times, the value of a symbol is the amount of + space it requires, and the largest symbol value is the one + used). Most targets have exactly one of these (which we + translate to bfd_com_section_ptr), but ECOFF has two. */ +#define SEC_IS_COMMON 0x8000 + + /* The section contains only debugging information. For + example, this is set for ELF .debug and .stab sections. + strip tests this flag to see if a section can be + discarded. */ +#define SEC_DEBUGGING 0x10000 + + /* The contents of this section are held in memory pointed to + by the contents field. This is checked by + bfd_get_section_contents, and the data is retrieved from + memory if appropriate. */ +#define SEC_IN_MEMORY 0x20000 + + /* The contents of this section are to be excluded by the + linker for executable and shared objects unless those + objects are to be further relocated. */ +#define SEC_EXCLUDE 0x40000 + + /* The contents of this section are to be sorted by the + based on the address specified in the associated symbol + table. */ +#define SEC_SORT_ENTRIES 0x80000 + + /* When linking, duplicate sections of the same name should be + discarded, rather than being combined into a single section as + is usually done. This is similar to how common symbols are + handled. See SEC_LINK_DUPLICATES below. */ +#define SEC_LINK_ONCE 0x100000 + + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker + should handle duplicate sections. */ +#define SEC_LINK_DUPLICATES 0x600000 + + /* This value for SEC_LINK_DUPLICATES means that duplicate + sections with the same name should simply be discarded. */ +#define SEC_LINK_DUPLICATES_DISCARD 0x0 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if there are any duplicate sections, although + it should still only link one copy. */ +#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections are a different size. */ +#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections contain different + contents. */ +#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000 + + /* This section was created by the linker as part of dynamic + relocation or other arcane processing. It is skipped when + going through the first-pass output, trusting that someone + else up the line will take care of it later. */ +#define SEC_LINKER_CREATED 0x800000 + + /* End of section flags. */ + + /* Some internal packed boolean fields. */ + + /* See the vma field. */ + unsigned int user_set_vma : 1; + + /* Whether relocations have been processed. */ + unsigned int reloc_done : 1; + + /* A mark flag used by some of the linker backends. */ + unsigned int linker_mark : 1; + + /* End of internal packed boolean fields. */ + + /* The virtual memory address of the section - where it will be + at run time. The symbols are relocated against this. The + user_set_vma flag is maintained by bfd; if it's not set, the + backend can assign addresses (for example, in @code{a.out}, where + the default address for @code{.data} is dependent on the specific + target and various flags). */ + + bfd_vma vma; + + /* The load address of the section - where it would be in a + rom image; really only used for writing section header + information. */ + + bfd_vma lma; + + /* The size of the section in bytes, as it will be output. + contains a value even if the section has no contents (e.g., the + size of @code{.bss}). This will be filled in after relocation */ + + bfd_size_type _cooked_size; + + /* The original size on disk of the section, in bytes. Normally this + value is the same as the size, but if some relaxing has + been done, then this value will be bigger. */ + + bfd_size_type _raw_size; + + /* If this section is going to be output, then this value is the + offset into the output section of the first byte in the input + section. E.g., if this was going to start at the 100th byte in + the output section, this value would be 100. */ + + bfd_vma output_offset; + + /* The output section through which to map on output. */ + + struct sec *output_section; + + /* The alignment requirement of the section, as an exponent of 2 - + e.g., 3 aligns to 2^3 (or 8). */ + + unsigned int alignment_power; + + /* If an input section, a pointer to a vector of relocation + records for the data in this section. */ + + struct reloc_cache_entry *relocation; + + /* If an output section, a pointer to a vector of pointers to + relocation records for the data in this section. */ + + struct reloc_cache_entry **orelocation; + + /* The number of relocation records in one of the above */ + + unsigned reloc_count; + + /* Information below is back end specific - and not always used + or updated. */ + + /* File position of section data */ + + file_ptr filepos; + + /* File position of relocation info */ + + file_ptr rel_filepos; + + /* File position of line data */ + + file_ptr line_filepos; + + /* Pointer to data for applications */ + + PTR userdata; + + /* If the SEC_IN_MEMORY flag is set, this points to the actual + contents. */ + unsigned char *contents; + + /* Attached line number information */ + + alent *lineno; + + /* Number of line number records */ + + unsigned int lineno_count; + + /* When a section is being output, this value changes as more + linenumbers are written out */ + + file_ptr moving_line_filepos; + + /* What the section number is in the target world */ + + int target_index; + + PTR used_by_bfd; + + /* If this is a constructor section then here is a list of the + relocations created to relocate items within it. */ + + struct relent_chain *constructor_chain; + + /* The BFD which owns the section. */ + + bfd *owner; + + /* A symbol which points at this section only */ + struct symbol_cache_entry *symbol; + struct symbol_cache_entry **symbol_ptr_ptr; + + struct bfd_link_order *link_order_head; + struct bfd_link_order *link_order_tail; +@} asection ; + + /* These sections are global, and are managed by BFD. The application + and target back end are not permitted to change the values in + these sections. New code should use the section_ptr macros rather + than referring directly to the const sections. The const sections + may eventually vanish. */ +#define BFD_ABS_SECTION_NAME "*ABS*" +#define BFD_UND_SECTION_NAME "*UND*" +#define BFD_COM_SECTION_NAME "*COM*" +#define BFD_IND_SECTION_NAME "*IND*" + + /* the absolute section */ +extern const asection bfd_abs_section; +#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) +#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) + /* Pointer to the undefined section */ +extern const asection bfd_und_section; +#define bfd_und_section_ptr ((asection *) &bfd_und_section) +#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) + /* Pointer to the common section */ +extern const asection bfd_com_section; +#define bfd_com_section_ptr ((asection *) &bfd_com_section) + /* Pointer to the indirect section */ +extern const asection bfd_ind_section; +#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) +#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) + +extern const struct symbol_cache_entry * const bfd_abs_symbol; +extern const struct symbol_cache_entry * const bfd_com_symbol; +extern const struct symbol_cache_entry * const bfd_und_symbol; +extern const struct symbol_cache_entry * const bfd_ind_symbol; +#define bfd_get_section_size_before_reloc(section) \ + (section->reloc_done ? (abort(),1): (section)->_raw_size) +#define bfd_get_section_size_after_reloc(section) \ + ((section->reloc_done) ? (section)->_cooked_size: (abort(),1)) +@end example + +@node section prototypes, , typedef asection, Sections +@subsection Section prototypes +These are the functions exported by the section handling part of BFD. +@* +@findex bfd_get_section_by_name +@subsubsection @code{bfd_get_section_by_name} +@strong{Synopsis} +@example +asection *bfd_get_section_by_name(bfd *abfd, CONST char *name); +@end example +@strong{Description}@* +Run through @var{abfd} and return the one of the +@code{asection}s whose name matches @var{name}, otherwise @code{NULL}. +@xref{Sections}, for more information. + +This should only be used in special cases; the normal way to process +all sections of a given name is to use @code{bfd_map_over_sections} and +@code{strcmp} on the name (or better yet, base it on the section flags +or something else) for each section. +@* +@findex bfd_make_section_old_way +@subsubsection @code{bfd_make_section_old_way} +@strong{Synopsis} +@example +asection *bfd_make_section_old_way(bfd *abfd, CONST char *name); +@end example +@strong{Description}@* +Create a new empty section called @var{name} +and attach it to the end of the chain of sections for the +BFD @var{abfd}. An attempt to create a section with a name which +is already in use returns its pointer without changing the +section chain. + +It has the funny name since this is the way it used to be +before it was rewritten.... + +Possible errors are: +@itemize @bullet + +@item +@code{bfd_error_invalid_operation} - +If output has already started for this BFD. +@item +@code{bfd_error_no_memory} - +If memory allocation fails. +@end itemize +@* +@findex bfd_make_section_anyway +@subsubsection @code{bfd_make_section_anyway} +@strong{Synopsis} +@example +asection *bfd_make_section_anyway(bfd *abfd, CONST char *name); +@end example +@strong{Description}@* +Create a new empty section called @var{name} and attach it to the end of +the chain of sections for @var{abfd}. Create a new section even if there +is already a section with that name. + +Return @code{NULL} and set @code{bfd_error} on error; possible errors are: +@itemize @bullet + +@item +@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}. +@item +@code{bfd_error_no_memory} - If memory allocation fails. +@end itemize +@* +@findex bfd_make_section +@subsubsection @code{bfd_make_section} +@strong{Synopsis} +@example +asection *bfd_make_section(bfd *, CONST char *name); +@end example +@strong{Description}@* +Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling +bfd_set_error ()) without changing the section chain if there is already a +section named @var{name}. If there is an error, return @code{NULL} and set +@code{bfd_error}. +@* +@findex bfd_set_section_flags +@subsubsection @code{bfd_set_section_flags} +@strong{Synopsis} +@example +boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags); +@end example +@strong{Description}@* +Set the attributes of the section @var{sec} in the BFD +@var{abfd} to the value @var{flags}. Return @code{true} on success, +@code{false} on error. Possible error returns are: + +@itemize @bullet + +@item +@code{bfd_error_invalid_operation} - +The section cannot have one or more of the attributes +requested. For example, a .bss section in @code{a.out} may not +have the @code{SEC_HAS_CONTENTS} field set. +@end itemize +@* +@findex bfd_map_over_sections +@subsubsection @code{bfd_map_over_sections} +@strong{Synopsis} +@example +void bfd_map_over_sections(bfd *abfd, + void (*func)(bfd *abfd, + asection *sect, + PTR obj), + PTR obj); +@end example +@strong{Description}@* +Call the provided function @var{func} for each section +attached to the BFD @var{abfd}, passing @var{obj} as an +argument. The function will be called as if by + +@example + func(abfd, the_section, obj); +@end example + +This is the prefered method for iterating over sections; an +alternative would be to use a loop: + +@example + section *p; + for (p = abfd->sections; p != NULL; p = p->next) + func(abfd, p, ...) +@end example +@* +@findex bfd_set_section_size +@subsubsection @code{bfd_set_section_size} +@strong{Synopsis} +@example +boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val); +@end example +@strong{Description}@* +Set @var{sec} to the size @var{val}. If the operation is +ok, then @code{true} is returned, else @code{false}. + +Possible error returns: +@itemize @bullet + +@item +@code{bfd_error_invalid_operation} - +Writing has started to the BFD, so setting the size is invalid. +@end itemize +@* +@findex bfd_set_section_contents +@subsubsection @code{bfd_set_section_contents} +@strong{Synopsis} +@example +boolean bfd_set_section_contents + (bfd *abfd, + asection *section, + PTR data, + file_ptr offset, + bfd_size_type count); +@end example +@strong{Description}@* +Sets the contents of the section @var{section} in BFD +@var{abfd} to the data starting in memory at @var{data}. The +data is written to the output section starting at offset +@var{offset} for @var{count} bytes. + +Normally @code{true} is returned, else @code{false}. Possible error +returns are: +@itemize @bullet + +@item +@code{bfd_error_no_contents} - +The output section does not have the @code{SEC_HAS_CONTENTS} +attribute, so nothing can be written to it. +@item +and some more too +@end itemize +This routine is front end to the back end function +@code{_bfd_set_section_contents}. +@* +@findex bfd_get_section_contents +@subsubsection @code{bfd_get_section_contents} +@strong{Synopsis} +@example +boolean bfd_get_section_contents + (bfd *abfd, asection *section, PTR location, + file_ptr offset, bfd_size_type count); +@end example +@strong{Description}@* +Read data from @var{section} in BFD @var{abfd} +into memory starting at @var{location}. The data is read at an +offset of @var{offset} from the start of the input section, +and is read for @var{count} bytes. + +If the contents of a constructor with the @code{SEC_CONSTRUCTOR} +flag set are requested or if the section does not have the +@code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled +with zeroes. If no errors occur, @code{true} is returned, else +@code{false}. +@* +@findex bfd_copy_private_section_data +@subsubsection @code{bfd_copy_private_section_data} +@strong{Synopsis} +@example +boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec); +@end example +@strong{Description}@* +Copy private section information from @var{isec} in the BFD +@var{ibfd} to the section @var{osec} in the BFD @var{obfd}. +Return @code{true} on success, @code{false} on error. Possible error +returns are: + +@itemize @bullet + +@item +@code{bfd_error_no_memory} - +Not enough memory exists to create private data for @var{osec}. +@end itemize +@example +#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ + BFD_SEND (obfd, _bfd_copy_private_section_data, \ + (ibfd, isection, obfd, osection)) +@end example +@* diff -urN binutils-2.7/bfd/doc/syms.texi binutils-2.8/bfd/doc/syms.texi --- binutils-2.7/bfd/doc/syms.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/syms.texi Wed Apr 30 12:56:27 1997 @@ -0,0 +1,407 @@ +@section Symbols +BFD tries to maintain as much symbol information as it can when +it moves information from file to file. BFD passes information +to applications though the @code{asymbol} structure. When the +application requests the symbol table, BFD reads the table in +the native form and translates parts of it into the internal +format. To maintain more than the information passed to +applications, some targets keep some information ``behind the +scenes'' in a structure only the particular back end knows +about. For example, the coff back end keeps the original +symbol table structure as well as the canonical structure when +a BFD is read in. On output, the coff back end can reconstruct +the output symbol table so that no information is lost, even +information unique to coff which BFD doesn't know or +understand. If a coff symbol table were read, but were written +through an a.out back end, all the coff specific information +would be lost. The symbol table of a BFD +is not necessarily read in until a canonicalize request is +made. Then the BFD back end fills in a table provided by the +application with pointers to the canonical information. To +output symbols, the application provides BFD with a table of +pointers to pointers to @code{asymbol}s. This allows applications +like the linker to output a symbol as it was read, since the ``behind +the scenes'' information will be still available. +@menu +* Reading Symbols:: +* Writing Symbols:: +* Mini Symbols:: +* typedef asymbol:: +* symbol handling functions:: +@end menu +@* +@node Reading Symbols, Writing Symbols, Symbols, Symbols +@subsection Reading symbols +There are two stages to reading a symbol table from a BFD: +allocating storage, and the actual reading process. This is an +excerpt from an application which reads the symbol table: + +@example + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long i; + + storage_needed = bfd_get_symtab_upper_bound (abfd); + + if (storage_needed < 0) + FAIL + + if (storage_needed == 0) @{ + return ; + @} + symbol_table = (asymbol **) xmalloc (storage_needed); + ... + number_of_symbols = + bfd_canonicalize_symtab (abfd, symbol_table); + + if (number_of_symbols < 0) + FAIL + + for (i = 0; i < number_of_symbols; i++) @{ + process_symbol (symbol_table[i]); + @} +@end example + +All storage for the symbols themselves is in an objalloc +connected to the BFD; it is freed when the BFD is closed. +@* +@node Writing Symbols, Mini Symbols, Reading Symbols, Symbols +@subsection Writing symbols +Writing of a symbol table is automatic when a BFD open for +writing is closed. The application attaches a vector of +pointers to pointers to symbols to the BFD being written, and +fills in the symbol count. The close and cleanup code reads +through the table provided and performs all the necessary +operations. The BFD output code must always be provided with an +``owned'' symbol: one which has come from another BFD, or one +which has been created using @code{bfd_make_empty_symbol}. Here is an +example showing the creation of a symbol table with only one element: + +@example + #include "bfd.h" + main() + @{ + bfd *abfd; + asymbol *ptrs[2]; + asymbol *new; + + abfd = bfd_openw("foo","a.out-sunos-big"); + bfd_set_format(abfd, bfd_object); + new = bfd_make_empty_symbol(abfd); + new->name = "dummy_symbol"; + new->section = bfd_make_section_old_way(abfd, ".text"); + new->flags = BSF_GLOBAL; + new->value = 0x12345; + + ptrs[0] = new; + ptrs[1] = (asymbol *)0; + + bfd_set_symtab(abfd, ptrs, 1); + bfd_close(abfd); + @} + + ./makesym + nm foo + 00012345 A dummy_symbol +@end example + +Many formats cannot represent arbitary symbol information; for +instance, the @code{a.out} object format does not allow an +arbitary number of sections. A symbol pointing to a section +which is not one of @code{.text}, @code{.data} or @code{.bss} cannot +be described. +@* +@node Mini Symbols, typedef asymbol, Writing Symbols, Symbols +@subsection Mini Symbols +Mini symbols provide read-only access to the symbol table. +They use less memory space, but require more time to access. +They can be useful for tools like nm or objdump, which may +have to handle symbol tables of extremely large executables. + +The @code{bfd_read_minisymbols} function will read the symbols +into memory in an internal form. It will return a @code{void *} +pointer to a block of memory, a symbol count, and the size of +each symbol. The pointer is allocated using @code{malloc}, and +should be freed by the caller when it is no longer needed. + +The function @code{bfd_minisymbol_to_symbol} will take a pointer +to a minisymbol, and a pointer to a structure returned by +@code{bfd_make_empty_symbol}, and return a @code{asymbol} structure. +The return value may or may not be the same as the value from +@code{bfd_make_empty_symbol} which was passed in. +@* + +@node typedef asymbol, symbol handling functions, Mini Symbols, Symbols +@subsection typedef asymbol +An @code{asymbol} has the form: +@* +. +@example +typedef struct symbol_cache_entry +@{ + /* A pointer to the BFD which owns the symbol. This information + is necessary so that a back end can work out what additional + information (invisible to the application writer) is carried + with the symbol. + + This field is *almost* redundant, since you can use section->owner + instead, except that some symbols point to the global sections + bfd_@{abs,com,und@}_section. This could be fixed by making + these globals be per-bfd (or per-target-flavor). FIXME. */ + + struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ + + /* The text of the symbol. The name is left alone, and not copied; the + application may not alter it. */ + CONST char *name; + + /* The value of the symbol. This really should be a union of a + numeric value with a pointer, since some flags indicate that + a pointer to another symbol is stored here. */ + symvalue value; + + /* Attributes of a symbol: */ + +#define BSF_NO_FLAGS 0x00 + + /* The symbol has local scope; @code{static} in @code{C}. The value + is the offset into the section of the data. */ +#define BSF_LOCAL 0x01 + + /* The symbol has global scope; initialized data in @code{C}. The + value is the offset into the section of the data. */ +#define BSF_GLOBAL 0x02 + + /* The symbol has global scope and is exported. The value is + the offset into the section of the data. */ +#define BSF_EXPORT BSF_GLOBAL /* no real difference */ + + /* A normal C symbol would be one of: + @code{BSF_LOCAL}, @code{BSF_FORT_COMM}, @code{BSF_UNDEFINED} or + @code{BSF_GLOBAL} */ + + /* The symbol is a debugging record. The value has an arbitary + meaning. */ +#define BSF_DEBUGGING 0x08 + + /* The symbol denotes a function entry point. Used in ELF, + perhaps others someday. */ +#define BSF_FUNCTION 0x10 + + /* Used by the linker. */ +#define BSF_KEEP 0x20 +#define BSF_KEEP_G 0x40 + + /* A weak global symbol, overridable without warnings by + a regular global symbol of the same name. */ +#define BSF_WEAK 0x80 + + /* This symbol was created to point to a section, e.g. ELF's + STT_SECTION symbols. */ +#define BSF_SECTION_SYM 0x100 + + /* The symbol used to be a common symbol, but now it is + allocated. */ +#define BSF_OLD_COMMON 0x200 + + /* The default value for common data. */ +#define BFD_FORT_COMM_DEFAULT_VALUE 0 + + /* In some files the type of a symbol sometimes alters its + location in an output file - ie in coff a @code{ISFCN} symbol + which is also @code{C_EXT} symbol appears where it was + declared and not at the end of a section. This bit is set + by the target BFD part to convey this information. */ + +#define BSF_NOT_AT_END 0x400 + + /* Signal that the symbol is the label of constructor section. */ +#define BSF_CONSTRUCTOR 0x800 + + /* Signal that the symbol is a warning symbol. The name is a + warning. The name of the next symbol is the one to warn about; + if a reference is made to a symbol with the same name as the next + symbol, a warning is issued by the linker. */ +#define BSF_WARNING 0x1000 + + /* Signal that the symbol is indirect. This symbol is an indirect + pointer to the symbol with the same name as the next symbol. */ +#define BSF_INDIRECT 0x2000 + + /* BSF_FILE marks symbols that contain a file name. This is used + for ELF STT_FILE symbols. */ +#define BSF_FILE 0x4000 + + /* Symbol is from dynamic linking information. */ +#define BSF_DYNAMIC 0x8000 + + /* The symbol denotes a data object. Used in ELF, and perhaps + others someday. */ +#define BSF_OBJECT 0x10000 + + flagword flags; + + /* A pointer to the section to which this symbol is + relative. This will always be non NULL, there are special + sections for undefined and absolute symbols. */ + struct sec *section; + + /* Back end special data. */ + union + @{ + PTR p; + bfd_vma i; + @} udata; + +@} asymbol; +@end example + +@node symbol handling functions, , typedef asymbol, Symbols +@subsection Symbol handling functions + +@* +@findex bfd_get_symtab_upper_bound +@subsubsection @code{bfd_get_symtab_upper_bound} +@strong{Description}@* +Return the number of bytes required to store a vector of pointers +to @code{asymbols} for all the symbols in the BFD @var{abfd}, +including a terminal NULL pointer. If there are no symbols in +the BFD, then return 0. If an error occurs, return -1. +@example +#define bfd_get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) +@end example +@* +@findex bfd_is_local_label +@subsubsection @code{bfd_is_local_label} +@strong{Synopsis} +@example +boolean bfd_is_local_label(bfd *abfd, asymbol *sym); +@end example +@strong{Description}@* +Return true if the given symbol @var{sym} in the BFD @var{abfd} is +a compiler generated local label, else return false. +@* +@findex bfd_is_local_label_name +@subsubsection @code{bfd_is_local_label_name} +@strong{Synopsis} +@example +boolean bfd_is_local_label_name(bfd *abfd, const char *name); +@end example +@strong{Description}@* +Return true if a symbol with the name @var{name} in the BFD +@var{abfd} is a compiler generated local label, else return +false. This just checks whether the name has the form of a +local label. +@example +#define bfd_is_local_label_name(abfd, name) \ + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) +@end example +@* +@findex bfd_canonicalize_symtab +@subsubsection @code{bfd_canonicalize_symtab} +@strong{Description}@* +Read the symbols from the BFD @var{abfd}, and fills in +the vector @var{location} with pointers to the symbols and +a trailing NULL. +Return the actual number of symbol pointers, not +including the NULL. +@example +#define bfd_canonicalize_symtab(abfd, location) \ + BFD_SEND (abfd, _bfd_canonicalize_symtab,\ + (abfd, location)) +@end example +@* +@findex bfd_set_symtab +@subsubsection @code{bfd_set_symtab} +@strong{Synopsis} +@example +boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count); +@end example +@strong{Description}@* +Arrange that when the output BFD @var{abfd} is closed, +the table @var{location} of @var{count} pointers to symbols +will be written. +@* +@findex bfd_print_symbol_vandf +@subsubsection @code{bfd_print_symbol_vandf} +@strong{Synopsis} +@example +void bfd_print_symbol_vandf(PTR file, asymbol *symbol); +@end example +@strong{Description}@* +Print the value and flags of the @var{symbol} supplied to the +stream @var{file}. +@* +@findex bfd_make_empty_symbol +@subsubsection @code{bfd_make_empty_symbol} +@strong{Description}@* +Create a new @code{asymbol} structure for the BFD @var{abfd} +and return a pointer to it. + +This routine is necessary because each back end has private +information surrounding the @code{asymbol}. Building your own +@code{asymbol} and pointing to it will not create the private +information, and will cause problems later on. +@example +#define bfd_make_empty_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) +@end example +@* +@findex bfd_make_debug_symbol +@subsubsection @code{bfd_make_debug_symbol} +@strong{Description}@* +Create a new @code{asymbol} structure for the BFD @var{abfd}, +to be used as a debugging symbol. Further details of its use have +yet to be worked out. +@example +#define bfd_make_debug_symbol(abfd,ptr,size) \ + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) +@end example +@* +@findex bfd_decode_symclass +@subsubsection @code{bfd_decode_symclass} +@strong{Description}@* +Return a character corresponding to the symbol +class of @var{symbol}, or '?' for an unknown class. +@* +@strong{Synopsis} +@example +int bfd_decode_symclass(asymbol *symbol); +@end example +@findex bfd_symbol_info +@subsubsection @code{bfd_symbol_info} +@strong{Description}@* +Fill in the basic info about symbol that nm needs. +Additional info may be added by the back-ends after +calling this function. +@* +@strong{Synopsis} +@example +void bfd_symbol_info(asymbol *symbol, symbol_info *ret); +@end example +@findex bfd_copy_private_symbol_data +@subsubsection @code{bfd_copy_private_symbol_data} +@strong{Synopsis} +@example +boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); +@end example +@strong{Description}@* +Copy private symbol information from @var{isym} in the BFD +@var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}. +Return @code{true} on success, @code{false} on error. Possible error +returns are: + +@itemize @bullet + +@item +@code{bfd_error_no_memory} - +Not enough memory exists to create private data for @var{osec}. +@end itemize +@example +#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ + (ibfd, isymbol, obfd, osymbol)) +@end example +@* diff -urN binutils-2.7/bfd/doc/targets.texi binutils-2.8/bfd/doc/targets.texi --- binutils-2.7/bfd/doc/targets.texi Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/doc/targets.texi Wed Apr 30 12:56:28 1997 @@ -0,0 +1,478 @@ +@section Targets + +@* +@strong{Description}@* +Each port of BFD to a different machine requries the creation +of a target back end. All the back end provides to the root +part of BFD is a structure containing pointers to functions +which perform certain low level operations on files. BFD +translates the applications's requests through a pointer into +calls to the back end routines. + +When a file is opened with @code{bfd_openr}, its format and +target are unknown. BFD uses various mechanisms to determine +how to interpret the file. The operations performed are: + +@itemize @bullet + +@item +Create a BFD by calling the internal routine +@code{_bfd_new_bfd}, then call @code{bfd_find_target} with the +target string supplied to @code{bfd_openr} and the new BFD pointer. + +@item +If a null target string was provided to @code{bfd_find_target}, +look up the environment variable @code{GNUTARGET} and use +that as the target string. + +@item +If the target string is still @code{NULL}, or the target string is +@code{default}, then use the first item in the target vector +as the target type, and set @code{target_defaulted} in the BFD to +cause @code{bfd_check_format} to loop through all the targets. +@xref{bfd_target}. @xref{Formats}. + +@item +Otherwise, inspect the elements in the target vector +one by one, until a match on target name is found. When found, +use it. + +@item +Otherwise return the error @code{bfd_error_invalid_target} to +@code{bfd_openr}. + +@item +@code{bfd_openr} attempts to open the file using +@code{bfd_open_file}, and returns the BFD. +@end itemize +Once the BFD has been opened and the target selected, the file +format may be determined. This is done by calling +@code{bfd_check_format} on the BFD with a suggested format. +If @code{target_defaulted} has been set, each possible target +type is tried to see if it recognizes the specified format. +@code{bfd_check_format} returns @code{true} when the caller guesses right. +@menu +* bfd_target:: +@end menu +@* +@node bfd_target, , Targets, Targets + +@subsection bfd_target + +@* +@strong{Description}@* +This structure contains everything that BFD knows about a +target. It includes things like its byte order, name, and which +routines to call to do various operations. + +Every BFD points to a target structure with its @code{xvec} +member. + +The macros below are used to dispatch to functions through the +@code{bfd_target} vector. They are used in a number of macros further +down in @file{bfd.h}, and are also used when calling various +routines by hand inside the BFD implementation. The @var{arglist} +argument must be parenthesized; it contains all the arguments +to the called function. + +They make the documentation (more) unpleasant to read, so if +someone wants to fix this and not break the above, please do. +@example +#define BFD_SEND(bfd, message, arglist) \ + ((*((bfd)->xvec->message)) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND +#define BFD_SEND(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + ((*((bfd)->xvec->message)) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif +@end example +For operations which index on the BFD format: +@example +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND_FMT +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif +@end example +This is the structure which defines the type of BFD this is. The +@code{xvec} member of the struct @code{bfd} itself points here. Each +module that implements access to a different target under BFD, +defines one of these. + +FIXME, these names should be rationalised with the names of +the entry points which call them. Too bad we can't have one +macro to define them both! +@example +enum bfd_flavour @{ + bfd_target_unknown_flavour, + bfd_target_aout_flavour, + bfd_target_coff_flavour, + bfd_target_ecoff_flavour, + bfd_target_elf_flavour, + bfd_target_ieee_flavour, + bfd_target_nlm_flavour, + bfd_target_oasys_flavour, + bfd_target_tekhex_flavour, + bfd_target_srec_flavour, + bfd_target_ihex_flavour, + bfd_target_som_flavour, + bfd_target_os9k_flavour, + bfd_target_versados_flavour, + bfd_target_msdos_flavour, + bfd_target_evax_flavour +@}; + +enum bfd_endian @{ BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN @}; + + /* Forward declaration. */ +typedef struct bfd_link_info _bfd_link_info; + +typedef struct bfd_target +@{ +@end example +Identifies the kind of target, e.g., SunOS4, Ultrix, etc. +@example + char *name; +@end example +The "flavour" of a back end is a general indication about the contents +of a file. +@example + enum bfd_flavour flavour; +@end example +The order of bytes within the data area of a file. +@example + enum bfd_endian byteorder; +@end example +The order of bytes within the header parts of a file. +@example + enum bfd_endian header_byteorder; +@end example +A mask of all the flags which an executable may have set - +from the set @code{BFD_NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}. +@example + flagword object_flags; +@end example +A mask of all the flags which a section may have set - from +the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}. +@example + flagword section_flags; +@end example +The character normally found at the front of a symbol +(if any), perhaps `_'. +@example + char symbol_leading_char; +@end example +The pad character for file names within an archive header. +@example + char ar_pad_char; +@end example +The maximum number of characters in an archive header. +@example + unsigned short ar_max_namelen; +@end example +Entries for byte swapping for data. These are different from the other +entry points, since they don't take a BFD asthe first argument. +Certain other handlers could do the same. +@example + bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *)); + void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *)); + void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *)); + void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *)); +@end example +Byte swapping for the headers +@example + bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *)); +@end example +Format dependent routines: these are vectors of entry points +within the target vector structure, one for each format to check. + +Check the format of a file being read. Return a @code{bfd_target *} or zero. +@example + const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *)); +@end example +Set the format of a file being written. +@example + boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *)); +@end example +Write cached information into a file being written, at @code{bfd_close}. +@example + boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *)); +@end example +The general target vector. +@example + + /* Generic entry points. */ +#define BFD_JUMP_TABLE_GENERIC(NAME)\ +CAT(NAME,_close_and_cleanup),\ +CAT(NAME,_bfd_free_cached_info),\ +CAT(NAME,_new_section_hook),\ +CAT(NAME,_get_section_contents),\ +CAT(NAME,_get_section_contents_in_window) + + /* Called when the BFD is being closed to do any necessary cleanup. */ + boolean (*_close_and_cleanup) PARAMS ((bfd *)); + /* Ask the BFD to free all cached information. */ + boolean (*_bfd_free_cached_info) PARAMS ((bfd *)); + /* Called when a new section is created. */ + boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr)); + /* Read the contents of a section. */ + boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); + boolean (*_bfd_get_section_contents_in_window) + PARAMS ((bfd *, sec_ptr, bfd_window *, + file_ptr, bfd_size_type)); + + /* Entry points to copy private data. */ +#define BFD_JUMP_TABLE_COPY(NAME)\ +CAT(NAME,_bfd_copy_private_bfd_data),\ +CAT(NAME,_bfd_merge_private_bfd_data),\ +CAT(NAME,_bfd_copy_private_section_data),\ +CAT(NAME,_bfd_copy_private_symbol_data),\ +CAT(NAME,_bfd_set_private_flags),\ +CAT(NAME,_bfd_print_private_bfd_data)\ + /* Called to copy BFD general private data from one object file + to another. */ + boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *)); + /* Called to merge BFD general private data from one object file + to a common output file when linking. */ + boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *)); + /* Called to copy BFD private section data from one object file + to another. */ + boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr, + bfd *, sec_ptr)); + /* Called to copy BFD private symbol data from one symbol + to another. */ + boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *, + bfd *, asymbol *)); + /* Called to set private backend flags */ + boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword)); + + /* Called to print private BFD data */ + boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR)); + + /* Core file entry points. */ +#define BFD_JUMP_TABLE_CORE(NAME)\ +CAT(NAME,_core_file_failing_command),\ +CAT(NAME,_core_file_failing_signal),\ +CAT(NAME,_core_file_matches_executable_p) + char * (*_core_file_failing_command) PARAMS ((bfd *)); + int (*_core_file_failing_signal) PARAMS ((bfd *)); + boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *)); + + /* Archive entry points. */ +#define BFD_JUMP_TABLE_ARCHIVE(NAME)\ +CAT(NAME,_slurp_armap),\ +CAT(NAME,_slurp_extended_name_table),\ +CAT(NAME,_construct_extended_name_table),\ +CAT(NAME,_truncate_arname),\ +CAT(NAME,_write_armap),\ +CAT(NAME,_read_ar_hdr),\ +CAT(NAME,_openr_next_archived_file),\ +CAT(NAME,_get_elt_at_index),\ +CAT(NAME,_generic_stat_arch_elt),\ +CAT(NAME,_update_armap_timestamp) + boolean (*_bfd_slurp_armap) PARAMS ((bfd *)); + boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *)); + boolean (*_bfd_construct_extended_name_table) + PARAMS ((bfd *, char **, bfd_size_type *, const char **)); + void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *)); + boolean (*write_armap) PARAMS ((bfd *arch, + unsigned int elength, + struct orl *map, + unsigned int orl_count, + int stridx)); + PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *)); + bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev)); +#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i)) + bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex)); + int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *)); + boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *)); + + /* Entry points used for symbols. */ +#define BFD_JUMP_TABLE_SYMBOLS(NAME)\ +CAT(NAME,_get_symtab_upper_bound),\ +CAT(NAME,_get_symtab),\ +CAT(NAME,_make_empty_symbol),\ +CAT(NAME,_print_symbol),\ +CAT(NAME,_get_symbol_info),\ +CAT(NAME,_bfd_is_local_label_name),\ +CAT(NAME,_get_lineno),\ +CAT(NAME,_find_nearest_line),\ +CAT(NAME,_bfd_make_debug_symbol),\ +CAT(NAME,_read_minisymbols),\ +CAT(NAME,_minisymbol_to_symbol) + long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); + long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, + struct symbol_cache_entry **)); + struct symbol_cache_entry * + (*_bfd_make_empty_symbol) PARAMS ((bfd *)); + void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, + struct symbol_cache_entry *, + bfd_print_symbol_type)); +#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) + void (*_bfd_get_symbol_info) PARAMS ((bfd *, + struct symbol_cache_entry *, + symbol_info *)); +#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e)) + boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *)); + + alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *)); + boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd, + struct sec *section, struct symbol_cache_entry **symbols, + bfd_vma offset, CONST char **file, CONST char **func, + unsigned int *line)); + /* Back-door to allow format-aware applications to create debug symbols + while using BFD for everything else. Currently used by the assembler + when creating COFF files. */ + asymbol * (*_bfd_make_debug_symbol) PARAMS (( + bfd *abfd, + void *ptr, + unsigned long size)); +#define bfd_read_minisymbols(b, d, m, s) \ + BFD_SEND (b, _read_minisymbols, (b, d, m, s)) + long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *, + unsigned int *)); +#define bfd_minisymbol_to_symbol(b, d, m, f) \ + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) + asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR, + asymbol *)); + + /* Routines for relocs. */ +#define BFD_JUMP_TABLE_RELOCS(NAME)\ +CAT(NAME,_get_reloc_upper_bound),\ +CAT(NAME,_canonicalize_reloc),\ +CAT(NAME,_bfd_reloc_type_lookup) + long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); + long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, + struct symbol_cache_entry **)); + /* See documentation on reloc types. */ + reloc_howto_type * + (*reloc_type_lookup) PARAMS ((bfd *abfd, + bfd_reloc_code_real_type code)); + + /* Routines used when writing an object file. */ +#define BFD_JUMP_TABLE_WRITE(NAME)\ +CAT(NAME,_set_arch_mach),\ +CAT(NAME,_set_section_contents) + boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture, + unsigned long)); + boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); + + /* Routines used by the linker. */ +#define BFD_JUMP_TABLE_LINK(NAME)\ +CAT(NAME,_sizeof_headers),\ +CAT(NAME,_bfd_get_relocated_section_contents),\ +CAT(NAME,_bfd_relax_section),\ +CAT(NAME,_bfd_link_hash_table_create),\ +CAT(NAME,_bfd_link_add_symbols),\ +CAT(NAME,_bfd_final_link),\ +CAT(NAME,_bfd_link_split_section) + int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); + bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *, + struct bfd_link_info *, struct bfd_link_order *, + bfd_byte *data, boolean relocateable, + struct symbol_cache_entry **)); + + boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *, + struct bfd_link_info *, boolean *again)); + + /* Create a hash table for the linker. Different backends store + different information in this table. */ + struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); + + /* Add symbols from this object file into the hash table. */ + boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Do a link based on the link_order structures attached to each + section of the BFD. */ + boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Should this section be split up into smaller pieces during linking. */ + boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *)); + + /* Routines to handle dynamic symbols and relocs. */ +#define BFD_JUMP_TABLE_DYNAMIC(NAME)\ +CAT(NAME,_get_dynamic_symtab_upper_bound),\ +CAT(NAME,_canonicalize_dynamic_symtab),\ +CAT(NAME,_get_dynamic_reloc_upper_bound),\ +CAT(NAME,_canonicalize_dynamic_reloc) + /* Get the amount of memory required to hold the dynamic symbols. */ + long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *)); + /* Read in the dynamic symbols. */ + long (*_bfd_canonicalize_dynamic_symtab) + PARAMS ((bfd *, struct symbol_cache_entry **)); + /* Get the amount of memory required to hold the dynamic relocs. */ + long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *)); + /* Read in the dynamic relocs. */ + long (*_bfd_canonicalize_dynamic_reloc) + PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); + +@end example +Data for use by back-end routines, which isn't generic enough to belong +in this structure. +@example + PTR backend_data; +@} bfd_target; +@end example +@* +@findex bfd_set_default_target +@subsubsection @code{bfd_set_default_target} +@strong{Synopsis} +@example +boolean bfd_set_default_target (const char *name); +@end example +@strong{Description}@* +Set the default target vector to use when recognizing a BFD. +This takes the name of the target, which may be a BFD target +name or a configuration triplet. +@* +@findex bfd_find_target +@subsubsection @code{bfd_find_target} +@strong{Synopsis} +@example +const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd); +@end example +@strong{Description}@* +Return a pointer to the transfer vector for the object target +named @var{target_name}. If @var{target_name} is @code{NULL}, choose the +one in the environment variable @code{GNUTARGET}; if that is null or not +defined, then choose the first entry in the target list. +Passing in the string "default" or setting the environment +variable to "default" will cause the first entry in the target +list to be returned, and "target_defaulted" will be set in the +BFD. This causes @code{bfd_check_format} to loop over all the +targets to find the one that matches the file being read. +@* +@findex bfd_target_list +@subsubsection @code{bfd_target_list} +@strong{Synopsis} +@example +const char **bfd_target_list(void); +@end example +@strong{Description}@* +Return a freshly malloced NULL-terminated +vector of the names of all the valid BFD targets. Do not +modify the names. +@* diff -urN binutils-2.7/bfd/ecoff.c binutils-2.8/bfd/ecoff.c --- binutils-2.7/bfd/ecoff.c Wed Jul 10 12:46:45 1996 +++ binutils-2.8/bfd/ecoff.c Wed Apr 30 12:55:52 1997 @@ -1,5 +1,5 @@ /* Generic ECOFF (Extended-COFF) routines. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. @@ -1443,11 +1443,11 @@ /*ARGSUSED*/ boolean -_bfd_ecoff_bfd_is_local_label (abfd, symbol) +_bfd_ecoff_bfd_is_local_label_name (abfd, name) bfd *abfd; - asymbol *symbol; + const char *name; { - return symbol->name[0] == '$'; + return name[0] == '$'; } /* Print information about an ECOFF symbol. */ @@ -1856,10 +1856,10 @@ size_t c; boolean local; - /* This function is selected based on the input vector. We only - want to copy information over if the output BFD also uses ECOFF + /* We only want to copy information over if both BFD's use ECOFF format. */ - if (bfd_get_flavour (obfd) != bfd_target_ecoff_flavour) + if (bfd_get_flavour (ibfd) != bfd_target_ecoff_flavour + || bfd_get_flavour (obfd) != bfd_target_ecoff_flavour) return true; /* Copy the GP value and the register masks. */ @@ -2043,6 +2043,7 @@ asection *current; unsigned int i; file_ptr old_sofar; + boolean rdata_in_text; boolean first_data, first_nonalloc; const bfd_vma round = ecoff_backend (abfd)->round; @@ -2063,6 +2064,27 @@ qsort (sorted_hdrs, abfd->section_count, sizeof (asection *), ecoff_sort_hdrs); + /* Some versions of the OSF linker put the .rdata section in the + text segment, and some do not. */ + rdata_in_text = ecoff_backend (abfd)->rdata_in_text; + if (rdata_in_text) + { + for (i = 0; i < abfd->section_count; i++) + { + current = sorted_hdrs[i]; + if (strcmp (current->name, _RDATA) == 0) + break; + if ((current->flags & SEC_CODE) == 0 + && strcmp (current->name, _PDATA) != 0 + && strcmp (current->name, _RCONST) != 0) + { + rdata_in_text = false; + break; + } + } + } + ecoff_data (abfd)->rdata_in_text = rdata_in_text; + first_data = true; first_nonalloc = true; for (i = 0; i < abfd->section_count; i++) @@ -2090,7 +2112,7 @@ && (abfd->flags & D_PAGED) != 0 && ! first_data && (current->flags & SEC_CODE) == 0 - && (! ecoff_backend (abfd)->rdata_in_text + && (! rdata_in_text || strcmp (current->name, _RDATA) != 0) && strcmp (current->name, _PDATA) != 0 && strcmp (current->name, _RCONST) != 0) @@ -2545,7 +2567,7 @@ if ((section.s_flags & STYP_TEXT) != 0 || ((section.s_flags & STYP_RDATA) != 0 - && backend->rdata_in_text) + && ecoff_data (abfd)->rdata_in_text) || section.s_flags == STYP_PDATA || (section.s_flags & STYP_DYNAMIC) != 0 || (section.s_flags & STYP_LIBLIST) != 0 diff -urN binutils-2.7/bfd/ecofflink.c binutils-2.8/bfd/ecofflink.c --- binutils-2.7/bfd/ecofflink.c Thu Jul 4 12:18:27 1996 +++ binutils-2.8/bfd/ecofflink.c Wed Apr 30 12:56:00 1997 @@ -1,5 +1,5 @@ /* Routines to link ECOFF debugging information. - Copyright 1993, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, . This file is part of BFD, the Binary File Descriptor library. @@ -22,12 +22,14 @@ #include "sysdep.h" #include "bfdlink.h" #include "libbfd.h" -#include "obstack.h" +#include "objalloc.h" #include "aout/stab_gnu.h" #include "coff/internal.h" #include "coff/sym.h" #include "coff/symconst.h" #include "coff/ecoff.h" +#include "libcoff.h" +#include "libecoff.h" static boolean ecoff_add_bytes PARAMS ((char **buf, char **bufend, size_t need)); @@ -49,10 +51,6 @@ static boolean lookup_line PARAMS ((bfd *, struct ecoff_debug_info * const, const struct ecoff_debug_swap * const, struct ecoff_find_line *)); - -/* Obstack allocation and deallocation routines. */ -#define obstack_chunk_alloc malloc -#define obstack_chunk_free free /* Routines to swap auxiliary information in and out. I am assuming that the auxiliary information format is always going to be target @@ -395,8 +393,8 @@ struct shuffle *rfd_end; /* The size of the largest file shuffle. */ unsigned long largest_file_shuffle; - /* An obstack for debugging information. */ - struct obstack memory; + /* An objalloc for debugging information. */ + struct objalloc *memory; }; /* Add a file entry to a shuffle list. */ @@ -429,8 +427,8 @@ return true; } - n = (struct shuffle *) obstack_alloc (&ainfo->memory, - sizeof (struct shuffle)); + n = (struct shuffle *) objalloc_alloc (ainfo->memory, + sizeof (struct shuffle)); if (!n) { bfd_set_error (bfd_error_no_memory); @@ -468,8 +466,8 @@ { struct shuffle *n; - n = (struct shuffle *) obstack_alloc (&ainfo->memory, - sizeof (struct shuffle)); + n = (struct shuffle *) objalloc_alloc (ainfo->memory, + sizeof (struct shuffle)); if (!n) { bfd_set_error (bfd_error_no_memory); @@ -537,7 +535,8 @@ output_debug->symbolic_header.issMax = 1; } - if (!obstack_begin (&ainfo->memory, 4050)) + ainfo->memory = objalloc_create (); + if (ainfo->memory == NULL) { bfd_set_error (bfd_error_no_memory); return NULL; @@ -564,7 +563,7 @@ if (! info->relocateable) bfd_hash_table_free (&ainfo->str_hash.table); - obstack_free (&ainfo->memory, (PTR) NULL); + objalloc_free (ainfo->memory); free (ainfo); } @@ -669,7 +668,7 @@ * sizeof (RFDT))); sz = (input_symhdr->crfd + input_symhdr->ifdMax) * external_rfd_size; - rfd_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz); + rfd_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz); if (!input_debug->ifdmap || !rfd_out) { bfd_set_error (bfd_error_no_memory); @@ -769,7 +768,7 @@ /* Look through the FDR's and copy over all associated debugging information. */ sz = copied * external_fdr_size; - fdr_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz); + fdr_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz); if (!fdr_out) { bfd_set_error (bfd_error_no_memory); @@ -824,7 +823,7 @@ out again. */ fgotfilename = false; sz = fdr.csym * external_sym_size; - sym_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz); + sym_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz); if (!sym_out) { bfd_set_error (bfd_error_no_memory); @@ -1025,7 +1024,7 @@ + fdr.ipdFirst * insz); end = in + fdr.cpd * insz; sz = fdr.cpd * outsz; - out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz); + out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz); if (!out) { bfd_set_error (bfd_error_no_memory); @@ -1066,7 +1065,7 @@ + fdr.ioptBase * insz); end = in + fdr.copt * insz; sz = fdr.copt * outsz; - out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz); + out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz); if (!out) { bfd_set_error (bfd_error_no_memory); @@ -1247,8 +1246,8 @@ internal_sym.sc = scUndefined; internal_sym.index = indexNil; - external_sym = (PTR) obstack_alloc (&ainfo->memory, - output_swap->external_sym_size); + external_sym = (PTR) objalloc_alloc (ainfo->memory, + output_swap->external_sym_size); if (!external_sym) { bfd_set_error (bfd_error_no_memory); @@ -1267,8 +1266,8 @@ the lang field to be langC. The fBigendian field will indicate little endian format, but it doesn't matter because it only applies to aux fields and there are none. */ - external_fdr = (PTR) obstack_alloc (&ainfo->memory, - output_swap->external_fdr_size); + external_fdr = (PTR) objalloc_alloc (ainfo->memory, + output_swap->external_fdr_size); if (!external_fdr) { bfd_set_error (bfd_error_no_memory); diff -urN binutils-2.7/bfd/elf-bfd.h binutils-2.8/bfd/elf-bfd.h --- binutils-2.7/bfd/elf-bfd.h Thu Jul 4 12:18:28 1996 +++ binutils-2.8/bfd/elf-bfd.h Wed Apr 30 12:56:00 1997 @@ -1,5 +1,5 @@ /* BFD back-end data structures for ELF files. - Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -62,6 +62,12 @@ PTR any; } tc_data; + + /* Version information. This is from an Elf_Internal_Versym + structure in a SHT_GNU_versym section. It is zero if there is no + version information. */ + unsigned short version; + } elf_symbol_type; /* ELF linker hash table entries. */ @@ -107,11 +113,27 @@ from the beginning of the section. */ struct elf_linker_section_pointers *linker_section_pointer; + /* Version information. */ + union + { + /* This field is used for a symbol which is not defined in a + regular object. It points to the version information read in + from the dynamic object. */ + Elf_Internal_Verdef *verdef; + /* This field is used for a symbol which is defined in a regular + object. It is set up in size_dynamic_sections. It points to + the version information we should write out for this symbol. */ + struct bfd_elf_version_tree *vertree; + } verinfo; + /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */ char type; + /* Symbol st_other value. */ + unsigned char other; + /* Some flags; legal values follow. */ - unsigned char elf_link_hash_flags; + unsigned short elf_link_hash_flags; /* Symbol is referenced by a non-shared object. */ #define ELF_LINK_HASH_REF_REGULAR 01 /* Symbol is defined by a non-shared object. */ @@ -128,8 +150,10 @@ #define ELF_LINK_HASH_NEEDS_PLT 0100 /* Symbol appears in a non-ELF input file. */ #define ELF_LINK_NON_ELF 0200 - /* Note: If you add more flags, you must change the type of - elf_link_hash_flags. */ + /* Symbol should be marked as hidden in the version information. */ +#define ELF_LINK_HIDDEN 0400 + /* Symbol was forced to local scope due to a version script file. */ +#define ELF_LINK_FORCED_LOCAL 01000 }; /* ELF linker hash table. */ @@ -193,7 +217,8 @@ boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *)); void (*write_relocs) PARAMS ((bfd *, asection *, PTR)); void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR)); - boolean (*slurp_reloc_table) PARAMS ((bfd *, asection *, asymbol **)); + boolean (*slurp_reloc_table) + PARAMS ((bfd *, asection *, asymbol **, boolean)); long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean)); void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *)); }; @@ -356,6 +381,13 @@ boolean (*elf_backend_adjust_dynamic_symbol) PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h)); + /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker + after all the linker input files have been seen but before the + section sizes have been set. This is called after + ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */ + boolean (*elf_backend_always_size_sections) + PARAMS ((bfd *output_bfd, struct bfd_link_info *info)); + /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend linker after all the linker input files have been seen but before the sections sizes have been set. This is called after @@ -561,8 +593,12 @@ Elf_Internal_Shdr strtab_hdr; Elf_Internal_Shdr dynsymtab_hdr; Elf_Internal_Shdr dynstrtab_hdr; + Elf_Internal_Shdr dynversym_hdr; + Elf_Internal_Shdr dynverref_hdr; + Elf_Internal_Shdr dynverdef_hdr; unsigned int symtab_section, shstrtab_section; unsigned int strtab_section, dynsymtab_section; + unsigned int dynversym_section, dynverdef_section, dynverref_section; file_ptr next_file_pos; void *prstatus; /* The raw /proc prstatus structure */ void *prpsinfo; /* The raw /proc prpsinfo structure */ @@ -615,9 +651,26 @@ find_nearest_line. */ struct mips_elf_find_line *find_line_info; + /* An array of stub sections indexed by symbol number, used by the + MIPS ELF linker. FIXME: We should figure out some way to only + include this field for a MIPS ELF target. */ + asection **local_stubs; + /* Used to determine if the e_flags field has been initialized */ boolean flags_init; + /* Number of symbol version definitions we are about to emit. */ + int cverdefs; + + /* Number of symbol version references we are about to emit. */ + int cverrefs; + + /* Symbol version definitions in external objects. */ + Elf_Internal_Verdef *verdef; + + /* Symbol version references to external objects. */ + Elf_Internal_Verneed *verref; + /* Linker sections that we are interested in. */ struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ]; }; @@ -628,6 +681,9 @@ #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr) #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section) #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section) +#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section) +#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section) +#define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section) #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals) #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals) #define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms) @@ -643,6 +699,27 @@ #define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init) #define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n]) +extern void _bfd_elf_swap_verdef_in + PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *)); +extern void _bfd_elf_swap_verdef_out + PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *)); +extern void _bfd_elf_swap_verdaux_in + PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *)); +extern void _bfd_elf_swap_verdaux_out + PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *)); +extern void _bfd_elf_swap_verneed_in + PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *)); +extern void _bfd_elf_swap_verneed_out + PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *)); +extern void _bfd_elf_swap_vernaux_in + PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *)); +extern void _bfd_elf_swap_vernaux_out + PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *)); +extern void _bfd_elf_swap_versym_in + PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *)); +extern void _bfd_elf_swap_versym_out + PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *)); + extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *)); extern char *bfd_elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned)); @@ -656,9 +733,6 @@ #define bfd_elf32_print_symbol bfd_elf_print_symbol #define bfd_elf64_print_symbol bfd_elf_print_symbol -#define bfd_elf32_mkobject bfd_elf_mkobject -#define bfd_elf64_mkobject bfd_elf_mkobject -#define elf_mkobject bfd_elf_mkobject extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *)); @@ -682,6 +756,7 @@ struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *))); +extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *)); extern boolean _bfd_elf_copy_private_symbol_data PARAMS ((bfd *, asymbol *, bfd *, asymbol *)); @@ -698,9 +773,13 @@ extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); +extern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *)); +extern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **, + asymbol **)); extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *)); extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); +extern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *)); extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *)); extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, unsigned long)); @@ -719,6 +798,7 @@ Elf_Internal_Rela *)); extern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex)); +extern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int)); extern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **)); @@ -835,6 +915,8 @@ PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma)); extern boolean bfd_elf32_link_create_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); +extern Elf_Internal_Rela *_bfd_elf32_link_read_relocs + PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean)); extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *)); extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *)); @@ -876,6 +958,8 @@ PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma)); extern boolean bfd_elf64_link_create_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); +extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs + PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean)); #define bfd_elf32_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol #define bfd_elf64_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol diff -urN binutils-2.7/bfd/elf-m10200.c binutils-2.8/bfd/elf-m10200.c --- binutils-2.7/bfd/elf-m10200.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/elf-m10200.c Wed Apr 30 12:56:00 1997 @@ -0,0 +1,1525 @@ +/* Matsushita 10200 specific support for 32-bit ELF + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" +#include "elf-bfd.h" + +static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup + PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); +static void mn10200_info_to_howto + PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); +static boolean mn10200_elf_relax_delete_bytes + PARAMS ((bfd *, asection *, bfd_vma, int)); +static boolean mn10200_elf_symbol_address_p + PARAMS ((bfd *, asection *, Elf32_External_Sym *, bfd_vma)); + +/* We have to use RELA instructions since md_apply_fix3 in the assembler + does absolutely nothing. */ +#define USE_RELA + +enum reloc_type +{ + R_MN10200_NONE = 0, + R_MN10200_32, + R_MN10200_16, + R_MN10200_8, + R_MN10200_24, + R_MN10200_PCREL8, + R_MN10200_PCREL16, + R_MN10200_PCREL24, + R_MN10200_MAX +}; + +static reloc_howto_type elf_mn10200_howto_table[] = +{ + /* Dummy relocation. Does nothing. */ + HOWTO (R_MN10200_NONE, + 0, + 2, + 16, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_NONE", + false, + 0, + 0, + false), + /* Standard 32 bit reloc. */ + HOWTO (R_MN10200_32, + 0, + 2, + 32, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_32", + false, + 0xffffffff, + 0xffffffff, + false), + /* Standard 16 bit reloc. */ + HOWTO (R_MN10200_16, + 0, + 1, + 16, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_16", + false, + 0xffff, + 0xffff, + false), + /* Standard 8 bit reloc. */ + HOWTO (R_MN10200_8, + 0, + 0, + 8, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_8", + false, + 0xff, + 0xff, + false), + /* Standard 24 bit reloc. */ + HOWTO (R_MN10200_24, + 0, + 2, + 24, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_24", + false, + 0xffffff, + 0xffffff, + false), + /* Simple 8 pc-relative reloc. */ + HOWTO (R_MN10200_PCREL8, + 0, + 0, + 8, + true, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_PCREL8", + false, + 0xff, + 0xff, + true), + /* Simple 16 pc-relative reloc. */ + HOWTO (R_MN10200_PCREL16, + 0, + 1, + 16, + true, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_PCREL16", + false, + 0xffff, + 0xffff, + true), + /* Simple 32bit pc-relative reloc with a 1 byte adjustment + to get the pc-relative offset correct. */ + HOWTO (R_MN10200_PCREL24, + 0, + 2, + 24, + true, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10200_PCREL24", + false, + 0xffffff, + 0xffffff, + true), +}; + +struct mn10200_reloc_map +{ + unsigned char bfd_reloc_val; + unsigned char elf_reloc_val; +}; + +static const struct mn10200_reloc_map mn10200_reloc_map[] = +{ + { BFD_RELOC_NONE, R_MN10200_NONE, }, + { BFD_RELOC_32, R_MN10200_32, }, + { BFD_RELOC_16, R_MN10200_16, }, + { BFD_RELOC_8, R_MN10200_8, }, + { BFD_RELOC_24, R_MN10200_24, }, + { BFD_RELOC_8_PCREL, R_MN10200_PCREL8, }, + { BFD_RELOC_16_PCREL, R_MN10200_PCREL16, }, + { BFD_RELOC_24_PCREL, R_MN10200_PCREL24, }, +}; + +static reloc_howto_type * +bfd_elf32_bfd_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; + i < sizeof (mn10200_reloc_map) / sizeof (struct mn10200_reloc_map); + i++) + { + if (mn10200_reloc_map[i].bfd_reloc_val == code) + return &elf_mn10200_howto_table[mn10200_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Set the howto pointer for an MN10200 ELF reloc. */ + +static void +mn10200_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd; + arelent *cache_ptr; + Elf32_Internal_Rela *dst; +{ + unsigned int r_type; + + r_type = ELF32_R_TYPE (dst->r_info); + BFD_ASSERT (r_type < (unsigned int) R_MN10200_MAX); + cache_ptr->howto = &elf_mn10200_howto_table[r_type]; +} + +/* Perform a relocation as part of a final link. */ +static bfd_reloc_status_type +mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd, + input_section, contents, offset, value, + addend, info, sym_sec, is_local) + reloc_howto_type *howto; + bfd *input_bfd; + bfd *output_bfd; + asection *input_section; + bfd_byte *contents; + bfd_vma offset; + bfd_vma value; + bfd_vma addend; + struct bfd_link_info *info; + asection *sym_sec; + int is_local; +{ + unsigned long r_type = howto->type; + bfd_byte *hit_data = contents + offset; + + switch (r_type) + { + + case R_MN10200_NONE: + return bfd_reloc_ok; + + case R_MN10200_32: + value += addend; + bfd_put_32 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10200_16: + value += addend; + + if ((long)value > 0x7fff || (long)value < -0x8000) + return bfd_reloc_overflow; + + bfd_put_16 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10200_8: + value += addend; + + if ((long)value > 0x7fff || (long)value < -0x8000) + return bfd_reloc_overflow; + + bfd_put_8 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10200_24: + value += addend; + + if ((long)value > 0x7fffff || (long)value < -0x800000) + return bfd_reloc_overflow; + + value &= 0xffffff; + value |= (bfd_get_32 (input_bfd, hit_data) & 0xff000000); + bfd_put_32 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10200_PCREL8: + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= offset; + value += addend; + + if ((long)value > 0xff || (long)value < -0x100) + return bfd_reloc_overflow; + + bfd_put_8 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10200_PCREL16: + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= offset; + value += addend; + + if ((long)value > 0xffff || (long)value < -0x10000) + return bfd_reloc_overflow; + + bfd_put_16 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10200_PCREL24: + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= offset; + value += addend; + + if ((long)value > 0xffffff || (long)value < -0x1000000) + return bfd_reloc_overflow; + + value &= 0xffffff; + value |= (bfd_get_32 (input_bfd, hit_data) & 0xff000000); + bfd_put_32 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + default: + return bfd_reloc_notsupported; + } +} + + +/* Relocate an MN10200 ELF section. */ +static boolean +mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section, + contents, relocs, local_syms, local_sections) + bfd *output_bfd; + struct bfd_link_info *info; + bfd *input_bfd; + asection *input_section; + bfd_byte *contents; + Elf_Internal_Rela *relocs; + Elf_Internal_Sym *local_syms; + asection **local_sections; +{ + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + Elf_Internal_Rela *rel, *relend; + + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (input_bfd); + + rel = relocs; + relend = relocs + input_section->reloc_count; + for (; rel < relend; rel++) + { + int r_type; + reloc_howto_type *howto; + unsigned long r_symndx; + Elf_Internal_Sym *sym; + asection *sec; + struct elf_link_hash_entry *h; + bfd_vma relocation; + bfd_reloc_status_type r; + + r_symndx = ELF32_R_SYM (rel->r_info); + r_type = ELF32_R_TYPE (rel->r_info); + howto = elf_mn10200_howto_table + r_type; + + if (info->relocateable) + { + /* This is a relocateable link. We don't have to change + anything, unless the reloc is against a section symbol, + in which case we have to adjust according to where the + section symbol winds up in the output section. */ + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) + { + sec = local_sections[r_symndx]; + rel->r_addend += sec->output_offset + sym->st_value; + } + } + + continue; + } + + /* This is a final link. */ + h = NULL; + sym = NULL; + sec = NULL; + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + sec = local_sections[r_symndx]; + relocation = (sec->output_section->vma + + sec->output_offset + + sym->st_value); + } + else + { + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + { + sec = h->root.u.def.section; + relocation = (h->root.u.def.value + + sec->output_section->vma + + sec->output_offset); + } + else if (h->root.type == bfd_link_hash_undefweak) + relocation = 0; + else + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset))) + return false; + relocation = 0; + } + } + + r = mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd, + input_section, + contents, rel->r_offset, + relocation, rel->r_addend, + info, sec, h == NULL); + + if (r != bfd_reloc_ok) + { + const char *name; + const char *msg = (const char *)0; + + if (h != NULL) + name = h->root.root.string; + else + { + name = (bfd_elf_string_from_elf_section + (input_bfd, symtab_hdr->sh_link, sym->st_name)); + if (name == NULL || *name == '\0') + name = bfd_section_name (input_bfd, sec); + } + + switch (r) + { + case bfd_reloc_overflow: + if (! ((*info->callbacks->reloc_overflow) + (info, name, howto->name, (bfd_vma) 0, + input_bfd, input_section, rel->r_offset))) + return false; + break; + + case bfd_reloc_undefined: + if (! ((*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, + rel->r_offset))) + return false; + break; + + case bfd_reloc_outofrange: + msg = "internal error: out of range error"; + goto common_error; + + case bfd_reloc_notsupported: + msg = "internal error: unsupported relocation error"; + goto common_error; + + case bfd_reloc_dangerous: + msg = "internal error: dangerous error"; + goto common_error; + + default: + msg = "internal error: unknown error"; + /* fall through */ + + common_error: + if (!((*info->callbacks->warning) + (info, msg, name, input_bfd, input_section, + rel->r_offset))) + return false; + break; + } + } + } + + return true; +} + +/* This function handles relaxing for the mn10200. + + There's quite a few relaxing opportunites available on the mn10200: + + * jsr:24 -> jsr:16 2 bytes + + * jmp:24 -> jmp:16 2 bytes + * jmp:16 -> bra:8 1 byte + + * If the previous instruction is a conditional branch + around the jump/bra, we may be able to reverse its condition + and change its target to the jump's target. The jump/bra + can then be deleted. 2 bytes + + * mov abs24 -> mov abs16 2 byte savings + + * Most instructions which accept imm24 can relax to imm16 2 bytes + - Most instructions which accept imm16 can relax to imm8 1 byte + + * Most instructions which accept d24 can relax to d16 2 bytes + - Most instructions which accept d16 can relax to d8 1 byte + + abs24, imm24, d24 all look the same at the reloc level. It + might make the code simpler if we had different relocs for + the various relaxable operand types. + + We don't handle imm16->imm8 or d16->d8 as they're very rare + and somewhat more difficult to support. */ + +static boolean +mn10200_elf_relax_section (abfd, sec, link_info, again) + bfd *abfd; + asection *sec; + struct bfd_link_info *link_info; + boolean *again; +{ + Elf_Internal_Shdr *symtab_hdr; + Elf_Internal_Rela *internal_relocs; + Elf_Internal_Rela *free_relocs = NULL; + Elf_Internal_Rela *irel, *irelend; + bfd_byte *contents = NULL; + bfd_byte *free_contents = NULL; + Elf32_External_Sym *extsyms = NULL; + Elf32_External_Sym *free_extsyms = NULL; + + /* Assume nothing changes. */ + *again = false; + + /* We don't have to do anything for a relocateable link, if + this section does not have relocs, or if this is not a + code section. */ + if (link_info->relocateable + || (sec->flags & SEC_RELOC) == 0 + || sec->reloc_count == 0 + || (sec->flags & SEC_CODE) == 0) + return true; + + /* If this is the first time we have been called for this section, + initialize the cooked size. */ + if (sec->_cooked_size == 0) + sec->_cooked_size = sec->_raw_size; + + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + + /* Get a copy of the native relocations. */ + internal_relocs = (_bfd_elf32_link_read_relocs + (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL, + link_info->keep_memory)); + if (internal_relocs == NULL) + goto error_return; + if (! link_info->keep_memory) + free_relocs = internal_relocs; + + /* Walk through them looking for relaxing opportunities. */ + irelend = internal_relocs + sec->reloc_count; + for (irel = internal_relocs; irel < irelend; irel++) + { + bfd_vma symval; + + /* If this isn't something that can be relaxed, then ignore + this reloc. */ + if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_NONE + || ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_8 + || ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_MAX) + continue; + + /* Get the section contents if we haven't done so already. */ + if (contents == NULL) + { + /* Get cached copy if it exists. */ + if (elf_section_data (sec)->this_hdr.contents != NULL) + contents = elf_section_data (sec)->this_hdr.contents; + else + { + /* Go get them off disk. */ + contents = (bfd_byte *) bfd_malloc (sec->_raw_size); + if (contents == NULL) + goto error_return; + free_contents = contents; + + if (! bfd_get_section_contents (abfd, sec, contents, + (file_ptr) 0, sec->_raw_size)) + goto error_return; + } + } + + /* Read the local symbols if we haven't done so already. */ + if (extsyms == NULL) + { + /* Get cached copy if it exists. */ + if (symtab_hdr->contents != NULL) + extsyms = (Elf32_External_Sym *) symtab_hdr->contents; + else + { + /* Go get them off disk. */ + extsyms = ((Elf32_External_Sym *) + bfd_malloc (symtab_hdr->sh_info + * sizeof (Elf32_External_Sym))); + if (extsyms == NULL) + goto error_return; + free_extsyms = extsyms; + if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 + || (bfd_read (extsyms, sizeof (Elf32_External_Sym), + symtab_hdr->sh_info, abfd) + != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))) + goto error_return; + } + } + + /* Get the value of the symbol referred to by the reloc. */ + if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info) + { + Elf_Internal_Sym isym; + asection *sym_sec; + + /* A local symbol. */ + bfd_elf32_swap_symbol_in (abfd, + extsyms + ELF32_R_SYM (irel->r_info), + &isym); + + sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx); + symval = (isym.st_value + + sym_sec->output_section->vma + + sym_sec->output_offset); + } + else + { + unsigned long indx; + struct elf_link_hash_entry *h; + + /* An external symbol. */ + indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info; + h = elf_sym_hashes (abfd)[indx]; + BFD_ASSERT (h != NULL); + if (h->root.type != bfd_link_hash_defined + && h->root.type != bfd_link_hash_defweak) + { + /* This appears to be a reference to an undefined + symbol. Just ignore it--it will be caught by the + regular reloc processing. */ + continue; + } + + symval = (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); + } + + /* For simplicity of coding, we are going to modify the section + contents, the section relocs, and the BFD symbol table. We + must tell the rest of the code not to free up this + information. It would be possible to instead create a table + of changes which have to be made, as is done in coff-mips.c; + that would be more work, but would require less memory when + the linker is run. */ + + + /* Try to turn a 24bit pc-relative branch/call into a 16bit pc-relative + branch/call. */ + if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_PCREL24) + { + bfd_vma value = symval; + + /* Deal with pc-relative gunk. */ + value -= (sec->output_section->vma + sec->output_offset); + value -= irel->r_offset; + value += irel->r_addend; + + /* See if the value will fit in 16 bits, note the high value is + 0x7fff + 2 as the target will be two bytes closer if we are + able to relax. */ + if ((long)value < 0x8001 && (long)value > -0x8000) + { + unsigned char code; + + /* Get the opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 1); + + if (code != 0xe0 && code != 0xe1) + continue; + + /* Note that we've changed the relocs, section contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + /* Fix the opcode. */ + if (code == 0xe0) + bfd_put_8 (abfd, 0xfc, contents + irel->r_offset - 2); + else if (code == 0xe1) + bfd_put_8 (abfd, 0xfd, contents + irel->r_offset - 2); + + /* Fix the relocation's type. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + R_MN10200_PCREL16); + + /* The opcode got shorter too, so we have to fix the + addend and offset too! */ + irel->r_addend -= 1; + irel->r_offset -= 1; + + /* Delete two bytes of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 1, 2)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + } + } + + /* Try to turn a 16bit pc-relative branch into a 8bit pc-relative + branch. */ + if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_PCREL16) + { + bfd_vma value = symval; + + /* Deal with pc-relative gunk. */ + value -= (sec->output_section->vma + sec->output_offset); + value -= irel->r_offset; + value += irel->r_addend; + + /* See if the value will fit in 8 bits, note the high value is + 0x7f + 1 as the target will be one bytes closer if we are + able to relax. */ + if ((long)value < 0x80 && (long)value > -0x80) + { + unsigned char code; + + /* Get the opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 1); + + if (code != 0xfc) + continue; + + /* Note that we've changed the relocs, section contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + /* Fix the opcode. */ + bfd_put_8 (abfd, 0xea, contents + irel->r_offset - 1); + + /* Fix the relocation's type. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + R_MN10200_PCREL8); + + /* Delete one byte of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 1, 1)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + } + } + + /* Try to eliminate an unconditional 8 bit pc-relative branch + which immediately follows a conditional 8 bit pc-relative + branch around the unconditional branch. + + original: new: + bCC lab1 bCC' lab2 + bra lab2 + lab1: lab1: + + + This happens when the bCC can't reach lab2 at assembly time, + but due to other relaxations it can reach at link time. */ + if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_PCREL8) + { + Elf_Internal_Rela *nrel; + bfd_vma value = symval; + unsigned char code; + + /* Deal with pc-relative gunk. */ + value -= (sec->output_section->vma + sec->output_offset); + value -= irel->r_offset; + value += irel->r_addend; + + /* Do nothing if this reloc is the last byte in the section. */ + if (irel->r_offset == sec->_cooked_size) + continue; + + /* See if the next instruction is an unconditional pc-relative + branch, more often than not this test will fail, so we + test it first to speed things up. */ + code = bfd_get_8 (abfd, contents + irel->r_offset + 1); + if (code != 0xea) + continue; + + /* Also make sure the next relocation applies to the next + instruction and that it's a pc-relative 8 bit branch. */ + nrel = irel + 1; + if (nrel == irelend + || irel->r_offset + 2 != nrel->r_offset + || ELF32_R_TYPE (nrel->r_info) != (int) R_MN10200_PCREL8) + continue; + + /* Make sure our destination immediately follows the + unconditional branch. */ + if (symval != (sec->output_section->vma + sec->output_offset + + irel->r_offset + 3)) + continue; + + /* Now make sure we are a conditional branch. This may not + be necessary, but why take the chance. + + Note these checks assume that R_MN10200_PCREL8 relocs + only occur on bCC and bCCx insns. If they occured + elsewhere, we'd need to know the start of this insn + for this check to be accurate. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 1); + if (code != 0xe0 && code != 0xe1 && code != 0xe2 + && code != 0xe3 && code != 0xe4 && code != 0xe5 + && code != 0xe6 && code != 0xe7 && code != 0xe8 + && code != 0xe9 && code != 0xec && code != 0xed + && code != 0xee && code != 0xef && code != 0xfc + && code != 0xfd && code != 0xfe && code != 0xff) + continue; + + /* We also have to be sure there is no symbol/label + at the unconditional branch. */ + if (mn10200_elf_symbol_address_p (abfd, sec, extsyms, + irel->r_offset + 1)) + continue; + + /* Note that we've changed the relocs, section contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + /* Reverse the condition of the first branch. */ + switch (code) + { + case 0xfc: + code = 0xfd; + break; + case 0xfd: + code = 0xfc; + break; + case 0xfe: + code = 0xff; + break; + case 0xff: + code = 0xfe; + break; + case 0xe8: + code = 0xe9; + break; + case 0xe9: + code = 0xe8; + break; + case 0xe0: + code = 0xe2; + break; + case 0xe2: + code = 0xe0; + break; + case 0xe3: + code = 0xe1; + break; + case 0xe1: + code = 0xe3; + break; + case 0xe4: + code = 0xe6; + break; + case 0xe6: + code = 0xe4; + break; + case 0xe7: + code = 0xe5; + break; + case 0xe5: + code = 0xe7; + break; + case 0xec: + code = 0xed; + break; + case 0xed: + code = 0xec; + break; + case 0xee: + code = 0xef; + break; + case 0xef: + code = 0xee; + break; + } + bfd_put_8 (abfd, code, contents + irel->r_offset - 1); + + /* Set the reloc type and symbol for the first branch + from the second branch. */ + irel->r_info = nrel->r_info; + + /* Make the reloc for the second branch a null reloc. */ + nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info), + R_MN10200_NONE); + + /* Delete two bytes of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 1, 2)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + } + + /* Try to turn a 24bit immediate, displacement or absolute address + into a 16bit immediate, displacement or absolute address. */ + if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10200_24) + { + bfd_vma value = symval; + + /* See if the value will fit in 16 bits. + We allow any 16bit match here. We prune those we can't + handle below. */ + if ((long)value < 0x7fff && (long)value > -0x8000) + { + unsigned char code; + + /* All insns which have 24bit operands are 5 bytes long, + the first byte will always be 0xf4, but we double check + it just in case. */ + + /* Get the first opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 2); + + if (code != 0xf4) + continue; + + /* Get the second opcode. */ + code = bfd_get_8 (abfd, contents + irel->r_offset - 1); + + switch (code & 0xfc) + { + /* mov imm24,dn -> mov imm16,dn */ + case 0x70: + /* Not safe if the high bit is on as relaxing may + move the value out of high mem and thus not fit + in a signed 16bit value. */ + if (value & 0x8000) + continue; + + /* Note that we've changed the reldection contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + /* Fix the opcode. */ + bfd_put_8 (abfd, 0xf8 + (code & 0x03), + contents + irel->r_offset - 2); + + /* Fix the relocation's type. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + R_MN10200_16); + + /* The opcode got shorter too, so we have to fix the + addend and offset too! */ + irel->r_offset -= 1; + + /* Delete two bytes of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 1, 2)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + break; + + /* mov imm24,an -> mov imm16,an + cmp imm24,an -> cmp imm16,an + mov (abs24),dn -> mov (abs16),dn + mov dn,(abs24) -> mov dn,(abs16) + movb dn,(abs24) -> movb dn,(abs16) + movbu (abs24),dn -> movbu (abs16),dn */ + case 0x74: + case 0x7c: + case 0xc0: + case 0x40: + case 0x44: + case 0xc8: + /* Note that we've changed the reldection contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + if ((code & 0xfc) == 0x74) + code = 0xdc + (code & 0x03); + else if ((code & 0xfc) == 0x7c) + code = 0xec + (code & 0x03); + else if ((code & 0xfc) == 0xc0) + code = 0xc8 + (code & 0x03); + else if ((code & 0xfc) == 0x40) + code = 0xc0 + (code & 0x03); + else if ((code & 0xfc) == 0x44) + code = 0xc4 + (code & 0x03); + else if ((code & 0xfc) == 0xc8) + code = 0xcc + (code & 0x03); + + /* Fix the opcode. */ + bfd_put_8 (abfd, code, contents + irel->r_offset - 2); + + /* Fix the relocation's type. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + R_MN10200_16); + + /* The opcode got shorter too, so we have to fix the + addend and offset too! */ + irel->r_offset -= 1; + + /* Delete two bytes of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 1, 2)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + break; + + /* cmp imm24,dn -> cmp imm16,dn + mov (abs24),an -> mov (abs16),an + mov an,(abs24) -> mov an,(abs16) + add imm24,dn -> add imm16,dn + add imm24,an -> add imm16,an + sub imm24,dn -> sub imm16,dn + sub imm24,an -> sub imm16,an + And all d24->d16 in memory ops. */ + case 0x78: + case 0xd0: + case 0x50: + case 0x60: + case 0x64: + case 0x68: + case 0x6c: + case 0x80: + case 0xf0: + case 0x00: + case 0x10: + case 0xb0: + case 0x30: + case 0xa0: + case 0x20: + case 0x90: + /* Not safe if the high bit is on as relaxing may + move the value out of high mem and thus not fit + in a signed 16bit value. */ + if (((code & 0xfc) == 0x78 + || (code & 0xfc) == 0x60 + || (code & 0xfc) == 0x64 + || (code & 0xfc) == 0x68 + || (code & 0xfc) == 0x6c + || (code & 0xfc) == 0x80 + || (code & 0xfc) == 0xf0 + || (code & 0xfc) == 0x00 + || (code & 0xfc) == 0x10 + || (code & 0xfc) == 0xb0 + || (code & 0xfc) == 0x30 + || (code & 0xfc) == 0xa0 + || (code & 0xfc) == 0x20 + || (code & 0xfc) == 0x90) + && (value & 0x8000) != 0) + continue; + + /* Note that we've changed the reldection contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + /* Fix the opcode. */ + bfd_put_8 (abfd, 0xf7, contents + irel->r_offset - 2); + + if ((code & 0xfc) == 0x78) + code = 0x48 + (code & 0x03); + else if ((code & 0xfc) == 0xd0) + code = 0x30 + (code & 0x03); + else if ((code & 0xfc) == 0x50) + code = 0x20 + (code & 0x03); + else if ((code & 0xfc) == 0x60) + code = 0x18 + (code & 0x03); + else if ((code & 0xfc) == 0x64) + code = 0x08 + (code & 0x03); + else if ((code & 0xfc) == 0x68) + code = 0x1c + (code & 0x03); + else if ((code & 0xfc) == 0x6c) + code = 0x0c + (code & 0x03); + else if ((code & 0xfc) == 0x80) + code = 0xc0 + (code & 0x07); + else if ((code & 0xfc) == 0xf0) + code = 0xb0 + (code & 0x07); + else if ((code & 0xfc) == 0x00) + code = 0x80 + (code & 0x07); + else if ((code & 0xfc) == 0x10) + code = 0xa0 + (code & 0x07); + else if ((code & 0xfc) == 0xb0) + code = 0x70 + (code & 0x07); + else if ((code & 0xfc) == 0x30) + code = 0x60 + (code & 0x07); + else if ((code & 0xfc) == 0xa0) + code = 0xd0 + (code & 0x07); + else if ((code & 0xfc) == 0x20) + code = 0x90 + (code & 0x07); + else if ((code & 0xfc) == 0x90) + code = 0x50 + (code & 0x07); + + bfd_put_8 (abfd, code, contents + irel->r_offset - 1); + + /* Fix the relocation's type. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + R_MN10200_16); + + /* Delete one bytes of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 2, 1)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + break; + + /* movb (abs24),dn ->movbu (abs16),dn extxb bn */ + case 0xc4: + /* Note that we've changed the reldection contents, etc. */ + elf_section_data (sec)->relocs = internal_relocs; + free_relocs = NULL; + + elf_section_data (sec)->this_hdr.contents = contents; + free_contents = NULL; + + symtab_hdr->contents = (bfd_byte *) extsyms; + free_extsyms = NULL; + + bfd_put_8 (abfd, 0xcc + (code & 0x03), + contents + irel->r_offset - 2); + + bfd_put_8 (abfd, 0xb8 + (code & 0x03), + contents + irel->r_offset - 1); + + /* Fix the relocation's type. */ + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + R_MN10200_16); + + /* The reloc will be applied one byte in front of its + current location. */ + irel->r_offset -= 1; + + /* Delete one bytes of data. */ + if (!mn10200_elf_relax_delete_bytes (abfd, sec, + irel->r_offset + 2, 1)) + goto error_return; + + /* That will change things, so, we should relax again. + Note that this is not required, and it may be slow. */ + *again = true; + break; + } + } + } + } + + if (free_relocs != NULL) + { + free (free_relocs); + free_relocs = NULL; + } + + if (free_contents != NULL) + { + if (! link_info->keep_memory) + free (free_contents); + else + { + /* Cache the section contents for elf_link_input_bfd. */ + elf_section_data (sec)->this_hdr.contents = contents; + } + free_contents = NULL; + } + + if (free_extsyms != NULL) + { + if (! link_info->keep_memory) + free (free_extsyms); + else + { + /* Cache the symbols for elf_link_input_bfd. */ + symtab_hdr->contents = extsyms; + } + free_extsyms = NULL; + } + + return true; + + error_return: + if (free_relocs != NULL) + free (free_relocs); + if (free_contents != NULL) + free (free_contents); + if (free_extsyms != NULL) + free (free_extsyms); + return false; +} + +/* Delete some bytes from a section while relaxing. */ + +static boolean +mn10200_elf_relax_delete_bytes (abfd, sec, addr, count) + bfd *abfd; + asection *sec; + bfd_vma addr; + int count; +{ + Elf_Internal_Shdr *symtab_hdr; + Elf32_External_Sym *extsyms; + int shndx; + bfd_byte *contents; + Elf_Internal_Rela *irel, *irelend; + Elf_Internal_Rela *irelalign; + bfd_vma toaddr; + Elf32_External_Sym *esym, *esymend; + struct elf_link_hash_entry **sym_hash, **sym_hash_end; + + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + extsyms = (Elf32_External_Sym *) symtab_hdr->contents; + + shndx = _bfd_elf_section_from_bfd_section (abfd, sec); + + contents = elf_section_data (sec)->this_hdr.contents; + + /* The deletion must stop at the next ALIGN reloc for an aligment + power larger than the number of bytes we are deleting. */ + + irelalign = NULL; + toaddr = sec->_cooked_size; + + irel = elf_section_data (sec)->relocs; + irelend = irel + sec->reloc_count; + + /* Actually delete the bytes. */ + memmove (contents + addr, contents + addr + count, toaddr - addr - count); + sec->_cooked_size -= count; + + /* Adjust all the relocs. */ + for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++) + { + /* Get the new reloc address. */ + if ((irel->r_offset > addr + && irel->r_offset < toaddr)) + irel->r_offset -= count; + } + + /* Adjust all the symbols. */ + esym = extsyms; + esymend = esym + symtab_hdr->sh_info; + for (; esym < esymend; esym++) + { + Elf_Internal_Sym isym; + + bfd_elf32_swap_symbol_in (abfd, esym, &isym); + + if (isym.st_shndx == shndx + && isym.st_value > addr + && isym.st_value < toaddr) + { + isym.st_value -= count; + bfd_elf32_swap_symbol_out (abfd, &isym, esym); + } + } + + sym_hash = elf_sym_hashes (abfd); + sym_hash_end = (sym_hash + + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) + - symtab_hdr->sh_info)); + for (; sym_hash < sym_hash_end; sym_hash++) + { + if (((*sym_hash)->root.type == bfd_link_hash_defined + || (*sym_hash)->root.type == bfd_link_hash_defweak) + && (*sym_hash)->root.u.def.section == sec + && (*sym_hash)->root.u.def.value > addr + && (*sym_hash)->root.u.def.value < toaddr) + { + (*sym_hash)->root.u.def.value -= count; + } + } + + return true; +} + +/* Return true if a symbol exists at the given address, else return + false. */ +static boolean +mn10200_elf_symbol_address_p (abfd, sec, extsyms, addr) + bfd *abfd; + asection *sec; + Elf32_External_Sym *extsyms; + bfd_vma addr; +{ + Elf_Internal_Shdr *symtab_hdr; + int shndx; + Elf32_External_Sym *esym, *esymend; + struct elf_link_hash_entry **sym_hash, **sym_hash_end; + + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + shndx = _bfd_elf_section_from_bfd_section (abfd, sec); + + /* Examine all the symbols. */ + esym = extsyms; + esymend = esym + symtab_hdr->sh_info; + for (; esym < esymend; esym++) + { + Elf_Internal_Sym isym; + + bfd_elf32_swap_symbol_in (abfd, esym, &isym); + + if (isym.st_shndx == shndx + && isym.st_value == addr) + return true; + } + + sym_hash = elf_sym_hashes (abfd); + sym_hash_end = (sym_hash + + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) + - symtab_hdr->sh_info)); + for (; sym_hash < sym_hash_end; sym_hash++) + { + if (((*sym_hash)->root.type == bfd_link_hash_defined + || (*sym_hash)->root.type == bfd_link_hash_defweak) + && (*sym_hash)->root.u.def.section == sec + && (*sym_hash)->root.u.def.value == addr) + return true; + } + return false; +} + +/* This is a version of bfd_generic_get_relocated_section_contents + which uses mn10200_elf_relocate_section. */ + +static bfd_byte * +mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order, + data, relocateable, symbols) + bfd *output_bfd; + struct bfd_link_info *link_info; + struct bfd_link_order *link_order; + bfd_byte *data; + boolean relocateable; + asymbol **symbols; +{ + Elf_Internal_Shdr *symtab_hdr; + asection *input_section = link_order->u.indirect.section; + bfd *input_bfd = input_section->owner; + asection **sections = NULL; + Elf_Internal_Rela *internal_relocs = NULL; + Elf32_External_Sym *external_syms = NULL; + Elf_Internal_Sym *internal_syms = NULL; + + /* We only need to handle the case of relaxing, or of having a + particular set of section contents, specially. */ + if (relocateable + || elf_section_data (input_section)->this_hdr.contents == NULL) + return bfd_generic_get_relocated_section_contents (output_bfd, link_info, + link_order, data, + relocateable, + symbols); + + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + + memcpy (data, elf_section_data (input_section)->this_hdr.contents, + input_section->_raw_size); + + if ((input_section->flags & SEC_RELOC) != 0 + && input_section->reloc_count > 0) + { + Elf_Internal_Sym *isymp; + asection **secpp; + Elf32_External_Sym *esym, *esymend; + + if (symtab_hdr->contents != NULL) + external_syms = (Elf32_External_Sym *) symtab_hdr->contents; + else + { + external_syms = ((Elf32_External_Sym *) + bfd_malloc (symtab_hdr->sh_info + * sizeof (Elf32_External_Sym))); + if (external_syms == NULL && symtab_hdr->sh_info > 0) + goto error_return; + if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 + || (bfd_read (external_syms, sizeof (Elf32_External_Sym), + symtab_hdr->sh_info, input_bfd) + != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))) + goto error_return; + } + + internal_relocs = (_bfd_elf32_link_read_relocs + (input_bfd, input_section, (PTR) NULL, + (Elf_Internal_Rela *) NULL, false)); + if (internal_relocs == NULL) + goto error_return; + + internal_syms = ((Elf_Internal_Sym *) + bfd_malloc (symtab_hdr->sh_info + * sizeof (Elf_Internal_Sym))); + if (internal_syms == NULL && symtab_hdr->sh_info > 0) + goto error_return; + + sections = (asection **) bfd_malloc (symtab_hdr->sh_info + * sizeof (asection *)); + if (sections == NULL && symtab_hdr->sh_info > 0) + goto error_return; + + isymp = internal_syms; + secpp = sections; + esym = external_syms; + esymend = esym + symtab_hdr->sh_info; + for (; esym < esymend; ++esym, ++isymp, ++secpp) + { + asection *isec; + + bfd_elf32_swap_symbol_in (input_bfd, esym, isymp); + + if (isymp->st_shndx == SHN_UNDEF) + isec = bfd_und_section_ptr; + else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE) + isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx); + else if (isymp->st_shndx == SHN_ABS) + isec = bfd_abs_section_ptr; + else if (isymp->st_shndx == SHN_COMMON) + isec = bfd_com_section_ptr; + else + { + /* Who knows? */ + isec = NULL; + } + + *secpp = isec; + } + + if (! mn10200_elf_relocate_section (output_bfd, link_info, input_bfd, + input_section, data, internal_relocs, + internal_syms, sections)) + goto error_return; + + if (sections != NULL) + free (sections); + sections = NULL; + if (internal_syms != NULL) + free (internal_syms); + internal_syms = NULL; + if (external_syms != NULL && symtab_hdr->contents == NULL) + free (external_syms); + external_syms = NULL; + if (internal_relocs != elf_section_data (input_section)->relocs) + free (internal_relocs); + internal_relocs = NULL; + } + + return data; + + error_return: + if (internal_relocs != NULL + && internal_relocs != elf_section_data (input_section)->relocs) + free (internal_relocs); + if (external_syms != NULL && symtab_hdr->contents == NULL) + free (external_syms); + if (internal_syms != NULL) + free (internal_syms); + if (sections != NULL) + free (sections); + return NULL; +} + + +#define TARGET_LITTLE_SYM bfd_elf32_mn10200_vec +#define TARGET_LITTLE_NAME "elf32-mn10200" +#define ELF_ARCH bfd_arch_mn10200 +#define ELF_MACHINE_CODE EM_CYGNUS_MN10200 +#define ELF_MAXPAGESIZE 0x1000 + +#define elf_info_to_howto mn10200_info_to_howto +#define elf_info_to_howto_rel 0 +#define elf_backend_relocate_section mn10200_elf_relocate_section +#define bfd_elf32_bfd_relax_section mn10200_elf_relax_section +#define bfd_elf32_bfd_get_relocated_section_contents \ + mn10200_elf_get_relocated_section_contents + +#define elf_symbol_leading_char '_' + +#include "elf32-target.h" diff -urN binutils-2.7/bfd/elf-m10300.c binutils-2.8/bfd/elf-m10300.c --- binutils-2.7/bfd/elf-m10300.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/elf-m10300.c Wed Apr 30 12:56:01 1997 @@ -0,0 +1,461 @@ +/* Matsushita 10300 specific support for 32-bit ELF + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" +#include "elf-bfd.h" + +static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup + PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); +static void mn10300_info_to_howto + PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); +static bfd_reloc_status_type bfd_elf32_mn10300_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + + +/* We have to use RELA instructions since md_apply_fix3 in the assembler + does absolutely nothing. */ +#define USE_RELA + +enum reloc_type +{ + R_MN10300_NONE = 0, + R_MN10300_32, + R_MN10300_16, + R_MN10300_8, + R_MN10300_PCREL32, + R_MN10300_PCREL16, + R_MN10300_PCREL8, + R_MN10300_MAX +}; + +static reloc_howto_type elf_mn10300_howto_table[] = +{ + /* Dummy relocation. Does nothing. */ + HOWTO (R_MN10300_NONE, + 0, + 2, + 16, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_NONE", + false, + 0, + 0, + false), + /* Standard 32 bit reloc. */ + HOWTO (R_MN10300_32, + 0, + 2, + 32, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_32", + false, + 0xffffffff, + 0xffffffff, + false), + /* Standard 16 bit reloc. */ + HOWTO (R_MN10300_16, + 0, + 1, + 16, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_16", + false, + 0xffff, + 0xffff, + false), + /* Standard 8 bit reloc. */ + HOWTO (R_MN10300_8, + 0, + 0, + 8, + false, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_8", + false, + 0xff, + 0xff, + false), + /* Standard 32bit pc-relative reloc. */ + HOWTO (R_MN10300_PCREL32, + 0, + 2, + 32, + true, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_PCREL32", + false, + 0xffffffff, + 0xffffffff, + true), + /* Standard 16bit pc-relative reloc. */ + HOWTO (R_MN10300_PCREL16, + 0, + 1, + 16, + true, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_PCREL16", + false, + 0xffff, + 0xffff, + true), + /* Standard 8 pc-relative reloc. */ + HOWTO (R_MN10300_PCREL8, + 0, + 0, + 8, + true, + 0, + complain_overflow_bitfield, + bfd_elf_generic_reloc, + "R_MN10300_PCREL8", + false, + 0xff, + 0xff, + true), +}; + +struct mn10300_reloc_map +{ + unsigned char bfd_reloc_val; + unsigned char elf_reloc_val; +}; + +static const struct mn10300_reloc_map mn10300_reloc_map[] = +{ + { BFD_RELOC_NONE, R_MN10300_NONE, }, + { BFD_RELOC_32, R_MN10300_32, }, + { BFD_RELOC_16, R_MN10300_16, }, + { BFD_RELOC_8, R_MN10300_8, }, + { BFD_RELOC_32_PCREL, R_MN10300_PCREL32, }, + { BFD_RELOC_16_PCREL, R_MN10300_PCREL16, }, + { BFD_RELOC_8_PCREL, R_MN10300_PCREL8, }, +}; + +static reloc_howto_type * +bfd_elf32_bfd_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; + i < sizeof (mn10300_reloc_map) / sizeof (struct mn10300_reloc_map); + i++) + { + if (mn10300_reloc_map[i].bfd_reloc_val == code) + return &elf_mn10300_howto_table[mn10300_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Set the howto pointer for an MN10300 ELF reloc. */ + +static void +mn10300_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd; + arelent *cache_ptr; + Elf32_Internal_Rela *dst; +{ + unsigned int r_type; + + r_type = ELF32_R_TYPE (dst->r_info); + BFD_ASSERT (r_type < (unsigned int) R_MN10300_MAX); + cache_ptr->howto = &elf_mn10300_howto_table[r_type]; +} + +/* Perform a relocation as part of a final link. */ +static bfd_reloc_status_type +mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd, + input_section, contents, offset, value, + addend, info, sym_sec, is_local) + reloc_howto_type *howto; + bfd *input_bfd; + bfd *output_bfd; + asection *input_section; + bfd_byte *contents; + bfd_vma offset; + bfd_vma value; + bfd_vma addend; + struct bfd_link_info *info; + asection *sym_sec; + int is_local; +{ + unsigned long r_type = howto->type; + bfd_byte *hit_data = contents + offset; + + switch (r_type) + { + + case R_MN10300_NONE: + return bfd_reloc_ok; + + case R_MN10300_32: + value += addend; + bfd_put_32 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10300_16: + value += addend; + + if ((long)value > 0x7fff || (long)value < -0x8000) + return bfd_reloc_overflow; + + bfd_put_16 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10300_8: + value += addend; + + if ((long)value > 0x7fff || (long)value < -0x8000) + return bfd_reloc_overflow; + + bfd_put_8 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10300_PCREL8: + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= offset; + value += addend; + + if ((long)value > 0xff || (long)value < -0x100) + return bfd_reloc_overflow; + + bfd_put_8 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10300_PCREL16: + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= offset; + value += addend; + + if ((long)value > 0xffff || (long)value < -0x10000) + return bfd_reloc_overflow; + + bfd_put_16 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + case R_MN10300_PCREL32: + value -= (input_section->output_section->vma + + input_section->output_offset); + value -= offset; + value += addend; + + bfd_put_32 (input_bfd, value, hit_data); + return bfd_reloc_ok; + + default: + return bfd_reloc_notsupported; + } +} + + +/* Relocate an MN10300 ELF section. */ +static boolean +mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, + contents, relocs, local_syms, local_sections) + bfd *output_bfd; + struct bfd_link_info *info; + bfd *input_bfd; + asection *input_section; + bfd_byte *contents; + Elf_Internal_Rela *relocs; + Elf_Internal_Sym *local_syms; + asection **local_sections; +{ + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + Elf_Internal_Rela *rel, *relend; + + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (input_bfd); + + rel = relocs; + relend = relocs + input_section->reloc_count; + for (; rel < relend; rel++) + { + int r_type; + reloc_howto_type *howto; + unsigned long r_symndx; + Elf_Internal_Sym *sym; + asection *sec; + struct elf_link_hash_entry *h; + bfd_vma relocation; + bfd_reloc_status_type r; + + r_symndx = ELF32_R_SYM (rel->r_info); + r_type = ELF32_R_TYPE (rel->r_info); + howto = elf_mn10300_howto_table + r_type; + + if (info->relocateable) + { + /* This is a relocateable link. We don't have to change + anything, unless the reloc is against a section symbol, + in which case we have to adjust according to where the + section symbol winds up in the output section. */ + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) + { + sec = local_sections[r_symndx]; + rel->r_addend += sec->output_offset + sym->st_value; + } + } + + continue; + } + + /* This is a final link. */ + h = NULL; + sym = NULL; + sec = NULL; + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + sec = local_sections[r_symndx]; + relocation = (sec->output_section->vma + + sec->output_offset + + sym->st_value); + } + else + { + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + { + sec = h->root.u.def.section; + relocation = (h->root.u.def.value + + sec->output_section->vma + + sec->output_offset); + } + else if (h->root.type == bfd_link_hash_undefweak) + relocation = 0; + else + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset))) + return false; + relocation = 0; + } + } + + r = mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd, + input_section, + contents, rel->r_offset, + relocation, rel->r_addend, + info, sec, h == NULL); + + if (r != bfd_reloc_ok) + { + const char *name; + const char *msg = (const char *)0; + + if (h != NULL) + name = h->root.root.string; + else + { + name = (bfd_elf_string_from_elf_section + (input_bfd, symtab_hdr->sh_link, sym->st_name)); + if (name == NULL || *name == '\0') + name = bfd_section_name (input_bfd, sec); + } + + switch (r) + { + case bfd_reloc_overflow: + if (! ((*info->callbacks->reloc_overflow) + (info, name, howto->name, (bfd_vma) 0, + input_bfd, input_section, rel->r_offset))) + return false; + break; + + case bfd_reloc_undefined: + if (! ((*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, + rel->r_offset))) + return false; + break; + + case bfd_reloc_outofrange: + msg = "internal error: out of range error"; + goto common_error; + + case bfd_reloc_notsupported: + msg = "internal error: unsupported relocation error"; + goto common_error; + + case bfd_reloc_dangerous: + msg = "internal error: dangerous error"; + goto common_error; + + default: + msg = "internal error: unknown error"; + /* fall through */ + + common_error: + if (!((*info->callbacks->warning) + (info, msg, name, input_bfd, input_section, + rel->r_offset))) + return false; + break; + } + } + } + + return true; +} + +#define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec +#define TARGET_LITTLE_NAME "elf32-mn10300" +#define ELF_ARCH bfd_arch_mn10300 +#define ELF_MACHINE_CODE EM_CYGNUS_MN10300 +#define ELF_MAXPAGESIZE 0x1000 + +#define elf_info_to_howto mn10300_info_to_howto +#define elf_info_to_howto_rel 0 +#define elf_backend_relocate_section mn10300_elf_relocate_section + +#define elf_symbol_leading_char '_' + +#include "elf32-target.h" diff -urN binutils-2.7/bfd/elf.c binutils-2.8/bfd/elf.c --- binutils-2.7/bfd/elf.c Thu Jul 4 12:30:44 1996 +++ binutils-2.8/bfd/elf.c Wed Apr 30 12:55:59 1997 @@ -1,5 +1,5 @@ /* ELF executable support for BFD. - Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -40,12 +40,163 @@ static INLINE struct elf_segment_map *make_mapping PARAMS ((bfd *, asection **, unsigned int, unsigned int, boolean)); +static boolean map_sections_to_segments PARAMS ((bfd *)); static int elf_sort_sections PARAMS ((const PTR, const PTR)); static boolean assign_file_positions_for_segments PARAMS ((bfd *)); static boolean assign_file_positions_except_relocs PARAMS ((bfd *)); static boolean prep_headers PARAMS ((bfd *)); static boolean swap_out_syms PARAMS ((bfd *, struct bfd_strtab_hash **)); static boolean copy_private_bfd_data PARAMS ((bfd *, bfd *)); +static char *elf_read PARAMS ((bfd *, long, unsigned int)); +static void elf_fake_sections PARAMS ((bfd *, asection *, PTR)); +static boolean assign_section_numbers PARAMS ((bfd *)); +static INLINE int sym_is_global PARAMS ((bfd *, asymbol *)); +static boolean elf_map_symbols PARAMS ((bfd *)); +static bfd_size_type get_program_header_size PARAMS ((bfd *)); + +/* Swap version information in and out. The version information is + currently size independent. If that ever changes, this code will + need to move into elfcode.h. */ + +/* Swap in a Verdef structure. */ + +void +_bfd_elf_swap_verdef_in (abfd, src, dst) + bfd *abfd; + const Elf_External_Verdef *src; + Elf_Internal_Verdef *dst; +{ + dst->vd_version = bfd_h_get_16 (abfd, src->vd_version); + dst->vd_flags = bfd_h_get_16 (abfd, src->vd_flags); + dst->vd_ndx = bfd_h_get_16 (abfd, src->vd_ndx); + dst->vd_cnt = bfd_h_get_16 (abfd, src->vd_cnt); + dst->vd_hash = bfd_h_get_32 (abfd, src->vd_hash); + dst->vd_aux = bfd_h_get_32 (abfd, src->vd_aux); + dst->vd_next = bfd_h_get_32 (abfd, src->vd_next); +} + +/* Swap out a Verdef structure. */ + +void +_bfd_elf_swap_verdef_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Verdef *src; + Elf_External_Verdef *dst; +{ + bfd_h_put_16 (abfd, src->vd_version, dst->vd_version); + bfd_h_put_16 (abfd, src->vd_flags, dst->vd_flags); + bfd_h_put_16 (abfd, src->vd_ndx, dst->vd_ndx); + bfd_h_put_16 (abfd, src->vd_cnt, dst->vd_cnt); + bfd_h_put_32 (abfd, src->vd_hash, dst->vd_hash); + bfd_h_put_32 (abfd, src->vd_aux, dst->vd_aux); + bfd_h_put_32 (abfd, src->vd_next, dst->vd_next); +} + +/* Swap in a Verdaux structure. */ + +void +_bfd_elf_swap_verdaux_in (abfd, src, dst) + bfd *abfd; + const Elf_External_Verdaux *src; + Elf_Internal_Verdaux *dst; +{ + dst->vda_name = bfd_h_get_32 (abfd, src->vda_name); + dst->vda_next = bfd_h_get_32 (abfd, src->vda_next); +} + +/* Swap out a Verdaux structure. */ + +void +_bfd_elf_swap_verdaux_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Verdaux *src; + Elf_External_Verdaux *dst; +{ + bfd_h_put_32 (abfd, src->vda_name, dst->vda_name); + bfd_h_put_32 (abfd, src->vda_next, dst->vda_next); +} + +/* Swap in a Verneed structure. */ + +void +_bfd_elf_swap_verneed_in (abfd, src, dst) + bfd *abfd; + const Elf_External_Verneed *src; + Elf_Internal_Verneed *dst; +{ + dst->vn_version = bfd_h_get_16 (abfd, src->vn_version); + dst->vn_cnt = bfd_h_get_16 (abfd, src->vn_cnt); + dst->vn_file = bfd_h_get_32 (abfd, src->vn_file); + dst->vn_aux = bfd_h_get_32 (abfd, src->vn_aux); + dst->vn_next = bfd_h_get_32 (abfd, src->vn_next); +} + +/* Swap out a Verneed structure. */ + +void +_bfd_elf_swap_verneed_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Verneed *src; + Elf_External_Verneed *dst; +{ + bfd_h_put_16 (abfd, src->vn_version, dst->vn_version); + bfd_h_put_16 (abfd, src->vn_cnt, dst->vn_cnt); + bfd_h_put_32 (abfd, src->vn_file, dst->vn_file); + bfd_h_put_32 (abfd, src->vn_aux, dst->vn_aux); + bfd_h_put_32 (abfd, src->vn_next, dst->vn_next); +} + +/* Swap in a Vernaux structure. */ + +void +_bfd_elf_swap_vernaux_in (abfd, src, dst) + bfd *abfd; + const Elf_External_Vernaux *src; + Elf_Internal_Vernaux *dst; +{ + dst->vna_hash = bfd_h_get_32 (abfd, src->vna_hash); + dst->vna_flags = bfd_h_get_16 (abfd, src->vna_flags); + dst->vna_other = bfd_h_get_16 (abfd, src->vna_other); + dst->vna_name = bfd_h_get_32 (abfd, src->vna_name); + dst->vna_next = bfd_h_get_32 (abfd, src->vna_next); +} + +/* Swap out a Vernaux structure. */ + +void +_bfd_elf_swap_vernaux_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Vernaux *src; + Elf_External_Vernaux *dst; +{ + bfd_h_put_32 (abfd, src->vna_hash, dst->vna_hash); + bfd_h_put_16 (abfd, src->vna_flags, dst->vna_flags); + bfd_h_put_16 (abfd, src->vna_other, dst->vna_other); + bfd_h_put_32 (abfd, src->vna_name, dst->vna_name); + bfd_h_put_32 (abfd, src->vna_next, dst->vna_next); +} + +/* Swap in a Versym structure. */ + +void +_bfd_elf_swap_versym_in (abfd, src, dst) + bfd *abfd; + const Elf_External_Versym *src; + Elf_Internal_Versym *dst; +{ + dst->vs_vers = bfd_h_get_16 (abfd, src->vs_vers); +} + +/* Swap out a Versym structure. */ + +void +_bfd_elf_swap_versym_out (abfd, src, dst) + bfd *abfd; + const Elf_Internal_Versym *src; + Elf_External_Versym *dst; +{ + bfd_h_put_16 (abfd, src->vs_vers, dst->vs_vers); +} /* Standard ELF hash function. Do not change this function; you will cause invalid hash tables to be generated. (Well, you would if this @@ -96,7 +247,7 @@ } boolean -elf_mkobject (abfd) +bfd_elf_mkobject (abfd) bfd * abfd; { /* this just does initialization */ @@ -211,6 +362,15 @@ || strncmp (name, ".stab", sizeof ".stab" - 1) == 0) flags |= SEC_DEBUGGING; + /* As a GNU extension, if the name begins with .gnu.linkonce, we + only link a single copy of the section. This is used to support + g++. g++ will emit each template expansion in its own section. + The symbols will be defined as weak, so that multiple definitions + are permitted. The GNU linker extension is to actually discard + all but one of the sections. */ + if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) + flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; + if (! bfd_set_section_flags (abfd, newsect, flags)) return false; @@ -227,7 +387,11 @@ && phdr->p_paddr != 0 && phdr->p_vaddr != phdr->p_paddr && phdr->p_vaddr <= hdr->sh_addr - && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size) + && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size + && ((flags & SEC_LOAD) == 0 + || (phdr->p_offset <= hdr->sh_offset + && (phdr->p_offset + phdr->p_filesz + >= hdr->sh_offset + hdr->sh_size)))) { newsect->lma += phdr->p_paddr - phdr->p_vaddr; break; @@ -453,6 +617,13 @@ case DT_DEBUG: name = "DEBUG"; break; case DT_TEXTREL: name = "TEXTREL"; break; case DT_JMPREL: name = "JMPREL"; break; + case DT_AUXILIARY: name = "AUXILIARY"; stringp = true; break; + case DT_FILTER: name = "FILTER"; stringp = true; break; + case DT_VERSYM: name = "VERSYM"; break; + case DT_VERDEF: name = "VERDEF"; break; + case DT_VERDEFNUM: name = "VERDEFNUM"; break; + case DT_VERNEED: name = "VERNEED"; break; + case DT_VERNEEDNUM: name = "VERNEEDNUM"; break; } fprintf (f, " %-11s ", name); @@ -475,6 +646,52 @@ dynbuf = NULL; } + if ((elf_dynverdef (abfd) != 0 && elf_tdata (abfd)->verdef == NULL) + || (elf_dynverref (abfd) != 0 && elf_tdata (abfd)->verref == NULL)) + { + if (! _bfd_elf_slurp_version_tables (abfd)) + return false; + } + + if (elf_dynverdef (abfd) != 0) + { + Elf_Internal_Verdef *t; + + fprintf (f, "\nVersion definitions:\n"); + for (t = elf_tdata (abfd)->verdef; t != NULL; t = t->vd_nextdef) + { + fprintf (f, "%d 0x%2.2x 0x%8.8lx %s\n", t->vd_ndx, + t->vd_flags, t->vd_hash, t->vd_nodename); + if (t->vd_auxptr->vda_nextptr != NULL) + { + Elf_Internal_Verdaux *a; + + fprintf (f, "\t"); + for (a = t->vd_auxptr->vda_nextptr; + a != NULL; + a = a->vda_nextptr) + fprintf (f, "%s ", a->vda_nodename); + fprintf (f, "\n"); + } + } + } + + if (elf_dynverref (abfd) != 0) + { + Elf_Internal_Verneed *t; + + fprintf (f, "\nVersion References:\n"); + for (t = elf_tdata (abfd)->verref; t != NULL; t = t->vn_nextref) + { + Elf_Internal_Vernaux *a; + + fprintf (f, " required from %s:\n", t->vn_filename); + for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) + fprintf (f, " 0x%8.8lx 0x%2.2x %2.2d %s\n", a->vna_hash, + a->vna_flags, a->vna_other, a->vna_nodename); + } + } + return true; error_return: @@ -484,9 +701,10 @@ } /* Display ELF-specific fields of a symbol. */ + void -bfd_elf_print_symbol (ignore_abfd, filep, symbol, how) - bfd *ignore_abfd; +bfd_elf_print_symbol (abfd, filep, symbol, how) + bfd *abfd; PTR filep; asymbol *symbol; bfd_print_symbol_type how; @@ -516,6 +734,64 @@ (bfd_is_com_section (symbol->section) ? ((elf_symbol_type *) symbol)->internal_elf_sym.st_value : ((elf_symbol_type *) symbol)->internal_elf_sym.st_size)); + + /* If we have version information, print it. */ + if (elf_tdata (abfd)->dynversym_section != 0 + && (elf_tdata (abfd)->dynverdef_section != 0 + || elf_tdata (abfd)->dynverref_section != 0)) + { + unsigned int vernum; + const char *version_string; + + vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION; + + if (vernum == 0) + version_string = ""; + else if (vernum == 1) + version_string = "Base"; + else if (vernum <= elf_tdata (abfd)->cverdefs) + version_string = + elf_tdata (abfd)->verdef[vernum - 1].vd_nodename; + else + { + Elf_Internal_Verneed *t; + + version_string = ""; + for (t = elf_tdata (abfd)->verref; + t != NULL; + t = t->vn_nextref) + { + Elf_Internal_Vernaux *a; + + for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) + { + if (a->vna_other == vernum) + { + version_string = a->vna_nodename; + break; + } + } + } + } + + if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0) + fprintf (file, " %-11s", version_string); + else + { + int i; + + fprintf (file, " (%s)", version_string); + for (i = 10 - strlen (version_string); i > 0; --i) + putc (' ', file); + } + } + + /* If the st_other field is not zero, print it. */ + if (((elf_symbol_type *) symbol)->internal_elf_sym.st_other != 0) + fprintf (file, " 0x%02x", + ((unsigned int) + ((elf_symbol_type *) symbol)->internal_elf_sym.st_other)); + fprintf (file, " %s", symbol->name); } break; @@ -555,7 +831,9 @@ ret->got_offset = (bfd_vma) -1; ret->plt_offset = (bfd_vma) -1; ret->linker_section_pointer = (elf_linker_section_pointers_t *)0; + ret->verinfo.verdef = NULL; ret->type = STT_NOTYPE; + ret->other = 0; /* Assume that we have been called by a non-ELF symbol reader. This flag is then reset by the code which reads an ELF input file. This ensures that a symbol created by a non-ELF symbol @@ -871,6 +1149,24 @@ } break; + case SHT_GNU_verdef: + elf_dynverdef (abfd) = shindex; + elf_tdata (abfd)->dynverdef_hdr = *hdr; + return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + break; + + case SHT_GNU_versym: + elf_dynversym (abfd) = shindex; + elf_tdata (abfd)->dynversym_hdr = *hdr; + return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + break; + + case SHT_GNU_verneed: + elf_dynverref (abfd) = shindex; + elf_tdata (abfd)->dynverref_hdr = *hdr; + return _bfd_elf_make_section_from_shdr (abfd, hdr, name); + break; + case SHT_SHLIB: return true; @@ -1085,11 +1381,42 @@ this_hdr->sh_type = SHT_REL; this_hdr->sh_entsize = bed->s->sizeof_rel; } - else if (strcmp (asect->name, ".note") == 0) + else if (strncmp (asect->name, ".note", 5) == 0) this_hdr->sh_type = SHT_NOTE; else if (strncmp (asect->name, ".stab", 5) == 0 && strcmp (asect->name + strlen (asect->name) - 3, "str") == 0) this_hdr->sh_type = SHT_STRTAB; + else if (strcmp (asect->name, ".gnu.version") == 0) + { + this_hdr->sh_type = SHT_GNU_versym; + this_hdr->sh_entsize = sizeof (Elf_External_Versym); + } + else if (strcmp (asect->name, ".gnu.version_d") == 0) + { + this_hdr->sh_type = SHT_GNU_verdef; + this_hdr->sh_entsize = 0; + /* objcopy or strip will copy over sh_info, but may not set + cverdefs. The linker will set cverdefs, but sh_info will be + zero. */ + if (this_hdr->sh_info == 0) + this_hdr->sh_info = elf_tdata (abfd)->cverdefs; + else + BFD_ASSERT (elf_tdata (abfd)->cverdefs == 0 + || this_hdr->sh_info == elf_tdata (abfd)->cverdefs); + } + else if (strcmp (asect->name, ".gnu.version_r") == 0) + { + this_hdr->sh_type = SHT_GNU_verneed; + this_hdr->sh_entsize = 0; + /* objcopy or strip will copy over sh_info, but may not set + cverrefs. The linker will set cverrefs, but sh_info will be + zero. */ + if (this_hdr->sh_info == 0) + this_hdr->sh_info = elf_tdata (abfd)->cverrefs; + else + BFD_ASSERT (elf_tdata (abfd)->cverrefs == 0 + || this_hdr->sh_info == elf_tdata (abfd)->cverrefs); + } else if ((asect->flags & SEC_ALLOC) != 0 && (asect->flags & SEC_LOAD) != 0) this_hdr->sh_type = SHT_PROGBITS; @@ -1295,16 +1622,20 @@ case SHT_DYNAMIC: case SHT_DYNSYM: + case SHT_GNU_verneed: + case SHT_GNU_verdef: /* sh_link is the section header index of the string table - used for the dynamic entries or symbol table. */ + used for the dynamic entries, or the symbol table, or the + version strings. */ s = bfd_get_section_by_name (abfd, ".dynstr"); if (s != NULL) d->this_hdr.sh_link = elf_section_data (s)->this_idx; break; case SHT_HASH: + case SHT_GNU_versym: /* sh_link is the section header index of the symbol table - this hash table is for. */ + this hash table or version table is for. */ s = bfd_get_section_by_name (abfd, ".dynsym"); if (s != NULL) d->this_hdr.sh_link = elf_section_data (s)->this_idx; @@ -1746,36 +2077,76 @@ phdr_size = elf_tdata (abfd)->program_header_size; if (phdr_size == 0) phdr_size = get_elf_backend_data (abfd)->s->sizeof_phdr; - if (sections[0]->lma % maxpagesize < phdr_size % maxpagesize) + if ((abfd->flags & D_PAGED) == 0 + || sections[0]->lma % maxpagesize < phdr_size % maxpagesize) phdr_in_section = false; } for (i = 0, hdrpp = sections; i < count; i++, hdrpp++) { asection *hdr; + boolean new_segment; hdr = *hdrpp; /* See if this section and the last one will fit in the same - segment. Don't put a loadable section after a non-loadable - section. If we are building a dynamic executable, don't put - a writable section in a read only segment, unless they're on - the same page anyhow (we don't do this for a non-dynamic - executable because some people prefer to have only one - program segment; anybody can use PHDRS in their linker script - to control what happens anyhow). */ - if (last_hdr == NULL - || ((BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize) - >= hdr->lma) - && ((last_hdr->flags & SEC_LOAD) != 0 - || (hdr->flags & SEC_LOAD) == 0) - && (dynsec == NULL - || writable - || (hdr->flags & SEC_READONLY) != 0 - || (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, - maxpagesize) - > hdr->lma)))) - + segment. */ + + if (last_hdr == NULL) + { + /* If we don't have a segment yet, then we don't need a new + one (we build the last one after this loop). */ + new_segment = false; + } + else if (last_hdr->lma - last_hdr->vma != hdr->lma - hdr->vma) + { + /* If this section has a different relation between the + virtual address and the load address, then we need a new + segment. */ + new_segment = true; + } + else if (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize) + < hdr->lma) + { + /* If putting this section in this segment would force us to + skip a page in the segment, then we need a new segment. */ + new_segment = true; + } + else if ((abfd->flags & D_PAGED) == 0) + { + /* If the file is not demand paged, which means that we + don't require the sections to be correctly aligned in the + file, then there is no other reason for a new segment. */ + new_segment = false; + } + else if ((last_hdr->flags & SEC_LOAD) == 0 + && (hdr->flags & SEC_LOAD) != 0) + { + /* We don't want to put a loadable section after a + nonloadable section in the same segment. */ + new_segment = true; + } + else if (! writable + && (hdr->flags & SEC_READONLY) == 0 + && (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize) + == hdr->lma)) + { + /* We don't want to put a writable section in a read only + segment, unless they are on the same page in memory + anyhow. We already know that the last section does not + bring us past the current section on the page, so the + only case in which the new section is not on the same + page as the previous section is when the previous section + ends precisely on a page boundary. */ + new_segment = true; + } + else + { + /* Otherwise, we can use the same segment. */ + new_segment = false; + } + + if (! new_segment) { if ((hdr->flags & SEC_READONLY) == 0) writable = true; @@ -1783,9 +2154,8 @@ continue; } - /* This section won't fit in the program segment. We must - create a new program header holding all the sections from - phdr_index until hdr. */ + /* We need a new program segment. We must create a new program + header holding all the sections from phdr_index until hdr. */ m = make_mapping (abfd, sections, phdr_index, i, phdr_in_section); if (m == NULL) @@ -1831,6 +2201,30 @@ pm = &m->next; } + /* For each loadable .note section, add a PT_NOTE segment. We don't + use bfd_get_section_by_name, because if we link together + nonloadable .note sections and loadable .note sections, we will + generate two .note sections in the output file. FIXME: Using + names for section types is bogus anyhow. */ + for (s = abfd->sections; s != NULL; s = s->next) + { + if ((s->flags & SEC_LOAD) != 0 + && strncmp (s->name, ".note", 5) == 0) + { + m = ((struct elf_segment_map *) + bfd_zalloc (abfd, sizeof (struct elf_segment_map))); + if (m == NULL) + goto error_return; + m->next = NULL; + m->p_type = PT_NOTE; + m->count = 1; + m->sections[0] = s; + + *pm = m; + pm = &m->next; + } + } + free (sections); sections = NULL; @@ -1858,6 +2252,13 @@ else if (sec1->vma > sec2->vma) return 1; + /* Sort by LMA. Normally the LMA and the VMA will be the same, and + this will do nothing. */ + if (sec1->lma < sec2->lma) + return -1; + else if (sec1->lma > sec2->lma) + return 1; + /* Put !SEC_LOAD sections after SEC_LOAD ones. */ #define TOEND(x) (((x)->flags & SEC_LOAD) == 0) @@ -1897,7 +2298,7 @@ struct elf_segment_map *m; unsigned int alloc; Elf_Internal_Phdr *phdrs; - file_ptr off; + file_ptr off, voff; bfd_vma filehdr_vaddr, filehdr_paddr; bfd_vma phdrs_vaddr, phdrs_paddr; Elf_Internal_Phdr *p; @@ -1975,8 +2376,14 @@ if (p->p_type == PT_LOAD && m->count > 0 - && (m->sections[0]->flags & SEC_LOAD) != 0) - off += (m->sections[0]->vma - off) % bed->maxpagesize; + && (m->sections[0]->flags & SEC_ALLOC) != 0) + { + if ((abfd->flags & D_PAGED) != 0) + off += (m->sections[0]->vma - off) % bed->maxpagesize; + else + off += ((m->sections[0]->vma - off) + % (1 << bfd_get_section_alignment (abfd, m->sections[0]))); + } if (m->count == 0) p->p_vaddr = 0; @@ -1990,7 +2397,8 @@ else p->p_paddr = m->sections[0]->lma; - if (p->p_type == PT_LOAD) + if (p->p_type == PT_LOAD + && (abfd->flags & D_PAGED) != 0) p->p_align = bed->maxpagesize; else if (m->count == 0) p->p_align = bed->s->file_align; @@ -2068,6 +2476,7 @@ } } + voff = off; for (i = 0, secpp = m->sections; i < m->count; i++, secpp++) { asection *sec; @@ -2076,6 +2485,7 @@ sec = *secpp; flags = sec->flags; + align = 1 << bfd_get_section_alignment (abfd, sec); if (p->p_type == PT_LOAD) { @@ -2085,13 +2495,17 @@ the page size. */ if ((flags & SEC_ALLOC) != 0) { - adjust = (sec->vma - off) % bed->maxpagesize; + if ((abfd->flags & D_PAGED) != 0) + adjust = (sec->vma - voff) % bed->maxpagesize; + else + adjust = (sec->vma - voff) % align; if (adjust != 0) { if (i == 0) abort (); p->p_memsz += adjust; off += adjust; + voff += adjust; if ((flags & SEC_LOAD) != 0) p->p_filesz += adjust; } @@ -2101,6 +2515,8 @@ if ((flags & SEC_LOAD) != 0) off += sec->_raw_size; + if ((flags & SEC_ALLOC) != 0) + voff += sec->_raw_size; } p->p_memsz += sec->_raw_size; @@ -2108,7 +2524,6 @@ if ((flags & SEC_LOAD) != 0) p->p_filesz += sec->_raw_size; - align = 1 << bfd_get_section_alignment (abfd, sec); if (align > p->p_align) p->p_align = align; @@ -2224,6 +2639,16 @@ ++segs; } + for (s = abfd->sections; s != NULL; s = s->next) + { + if ((s->flags & SEC_LOAD) != 0 + && strncmp (s->name, ".note", 5) == 0) + { + /* We need a PT_NOTE segment. */ + ++segs; + } + } + /* Let the backend count up any program headers it might need. */ if (bed->elf_backend_additional_program_headers) { @@ -2320,7 +2745,10 @@ (hdr->bfd_section == NULL ? "*unknown*" : hdr->bfd_section->name))); - off += (hdr->sh_addr - off) % bed->maxpagesize; + if ((abfd->flags & D_PAGED) != 0) + off += (hdr->sh_addr - off) % bed->maxpagesize; + else + off += (hdr->sh_addr - off) % hdr->sh_addralign; off = _bfd_elf_assign_file_position_for_section (hdr, off, false); } @@ -2419,6 +2847,21 @@ case bfd_arch_alpha: i_ehdrp->e_machine = EM_ALPHA; break; + case bfd_arch_sh: + i_ehdrp->e_machine = EM_SH; + break; + case bfd_arch_d10v: + i_ehdrp->e_machine = EM_CYGNUS_D10V; + break; + case bfd_arch_m32r: + i_ehdrp->e_machine = EM_CYGNUS_M32R; + break; + case bfd_arch_mn10200: + i_ehdrp->e_machine = EM_CYGNUS_MN10200; + break; + case bfd_arch_mn10300: + i_ehdrp->e_machine = EM_CYGNUS_MN10300; + break; /* also note that EM_M32, AT&T WE32100 is unknown to bfd */ default: i_ehdrp->e_machine = EM_NONE; @@ -2704,7 +3147,7 @@ m = ((struct elf_segment_map *) bfd_alloc (obfd, (sizeof (struct elf_segment_map) - + (csecs - 1) * sizeof (asection *)))); + + ((size_t) csecs - 1) * sizeof (asection *)))); if (m == NULL) return false; @@ -2798,7 +3241,9 @@ ohdr->sh_entsize = ihdr->sh_entsize; if (ihdr->sh_type == SHT_SYMTAB - || ihdr->sh_type == SHT_DYNSYM) + || ihdr->sh_type == SHT_DYNSYM + || ihdr->sh_type == SHT_GNU_verneed + || ihdr->sh_type == SHT_GNU_verdef) ohdr->sh_info = ihdr->sh_info; return true; @@ -2824,6 +3269,10 @@ { elf_symbol_type *isym, *osym; + if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) + return true; + isym = elf_symbol_from (ibfd, isymarg); osym = elf_symbol_from (obfd, osymarg); @@ -3036,7 +3485,11 @@ sym.st_info = ELF_ST_INFO (bind, type); } - sym.st_other = 0; + if (type_ptr != NULL) + sym.st_other = type_ptr->internal_elf_sym.st_other; + else + sym.st_other = 0; + bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms); outbound_syms += bed->s->sizeof_sym; } @@ -3116,7 +3569,10 @@ arelent *tblptr; unsigned int i; - if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd, section, symbols)) + if (! get_elf_backend_data (abfd)->s->slurp_reloc_table (abfd, + section, + symbols, + false)) return -1; tblptr = section->relocation; @@ -3148,6 +3604,264 @@ return get_elf_backend_data (abfd)->s->slurp_symbol_table (abfd, alocation, true); } +/* Return the size required for the dynamic reloc entries. Any + section that was actually installed in the BFD, and has type + SHT_REL or SHT_RELA, and uses the dynamic symbol table, is + considered to be a dynamic reloc section. */ + +long +_bfd_elf_get_dynamic_reloc_upper_bound (abfd) + bfd *abfd; +{ + long ret; + asection *s; + + if (elf_dynsymtab (abfd) == 0) + { + bfd_set_error (bfd_error_invalid_operation); + return -1; + } + + ret = sizeof (arelent *); + for (s = abfd->sections; s != NULL; s = s->next) + if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd) + && (elf_section_data (s)->this_hdr.sh_type == SHT_REL + || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)) + ret += ((s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize) + * sizeof (arelent *)); + + return ret; +} + +/* Canonicalize the dynamic relocation entries. Note that we return + the dynamic relocations as a single block, although they are + actually associated with particular sections; the interface, which + was designed for SunOS style shared libraries, expects that there + is only one set of dynamic relocs. Any section that was actually + installed in the BFD, and has type SHT_REL or SHT_RELA, and uses + the dynamic symbol table, is considered to be a dynamic reloc + section. */ + +long +_bfd_elf_canonicalize_dynamic_reloc (abfd, storage, syms) + bfd *abfd; + arelent **storage; + asymbol **syms; +{ + boolean (*slurp_relocs) PARAMS ((bfd *, asection *, asymbol **, boolean)); + asection *s; + long ret; + + if (elf_dynsymtab (abfd) == 0) + { + bfd_set_error (bfd_error_invalid_operation); + return -1; + } + + slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; + ret = 0; + for (s = abfd->sections; s != NULL; s = s->next) + { + if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd) + && (elf_section_data (s)->this_hdr.sh_type == SHT_REL + || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)) + { + arelent *p; + long count, i; + + if (! (*slurp_relocs) (abfd, s, syms, true)) + return -1; + count = s->_raw_size / elf_section_data (s)->this_hdr.sh_entsize; + p = s->relocation; + for (i = 0; i < count; i++) + *storage++ = p++; + ret += count; + } + } + + *storage = NULL; + + return ret; +} + +/* Read in the version information. */ + +boolean +_bfd_elf_slurp_version_tables (abfd) + bfd *abfd; +{ + bfd_byte *contents = NULL; + + if (elf_dynverdef (abfd) != 0) + { + Elf_Internal_Shdr *hdr; + Elf_External_Verdef *everdef; + Elf_Internal_Verdef *iverdef; + unsigned int i; + + hdr = &elf_tdata (abfd)->dynverdef_hdr; + + elf_tdata (abfd)->verdef = + ((Elf_Internal_Verdef *) + bfd_zalloc (abfd, hdr->sh_info * sizeof (Elf_Internal_Verdef))); + if (elf_tdata (abfd)->verdef == NULL) + goto error_return; + + elf_tdata (abfd)->cverdefs = hdr->sh_info; + + contents = (bfd_byte *) bfd_malloc (hdr->sh_size); + if (contents == NULL) + goto error_return; + if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0 + || bfd_read ((PTR) contents, 1, hdr->sh_size, abfd) != hdr->sh_size) + goto error_return; + + everdef = (Elf_External_Verdef *) contents; + iverdef = elf_tdata (abfd)->verdef; + for (i = 0; i < hdr->sh_info; i++, iverdef++) + { + Elf_External_Verdaux *everdaux; + Elf_Internal_Verdaux *iverdaux; + unsigned int j; + + _bfd_elf_swap_verdef_in (abfd, everdef, iverdef); + + iverdef->vd_bfd = abfd; + + iverdef->vd_auxptr = ((Elf_Internal_Verdaux *) + bfd_alloc (abfd, + (iverdef->vd_cnt + * sizeof (Elf_Internal_Verdaux)))); + if (iverdef->vd_auxptr == NULL) + goto error_return; + + everdaux = ((Elf_External_Verdaux *) + ((bfd_byte *) everdef + iverdef->vd_aux)); + iverdaux = iverdef->vd_auxptr; + for (j = 0; j < iverdef->vd_cnt; j++, iverdaux++) + { + _bfd_elf_swap_verdaux_in (abfd, everdaux, iverdaux); + + iverdaux->vda_nodename = + bfd_elf_string_from_elf_section (abfd, hdr->sh_link, + iverdaux->vda_name); + if (iverdaux->vda_nodename == NULL) + goto error_return; + + if (j + 1 < iverdef->vd_cnt) + iverdaux->vda_nextptr = iverdaux + 1; + else + iverdaux->vda_nextptr = NULL; + + everdaux = ((Elf_External_Verdaux *) + ((bfd_byte *) everdaux + iverdaux->vda_next)); + } + + iverdef->vd_nodename = iverdef->vd_auxptr->vda_nodename; + + if (i + 1 < hdr->sh_info) + iverdef->vd_nextdef = iverdef + 1; + else + iverdef->vd_nextdef = NULL; + + everdef = ((Elf_External_Verdef *) + ((bfd_byte *) everdef + iverdef->vd_next)); + } + + free (contents); + contents = NULL; + } + + if (elf_dynverref (abfd) != 0) + { + Elf_Internal_Shdr *hdr; + Elf_External_Verneed *everneed; + Elf_Internal_Verneed *iverneed; + unsigned int i; + + hdr = &elf_tdata (abfd)->dynverref_hdr; + + elf_tdata (abfd)->verref = + ((Elf_Internal_Verneed *) + bfd_zalloc (abfd, hdr->sh_info * sizeof (Elf_Internal_Verneed))); + if (elf_tdata (abfd)->verref == NULL) + goto error_return; + + elf_tdata (abfd)->cverrefs = hdr->sh_info; + + contents = (bfd_byte *) bfd_malloc (hdr->sh_size); + if (contents == NULL) + goto error_return; + if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0 + || bfd_read ((PTR) contents, 1, hdr->sh_size, abfd) != hdr->sh_size) + goto error_return; + + everneed = (Elf_External_Verneed *) contents; + iverneed = elf_tdata (abfd)->verref; + for (i = 0; i < hdr->sh_info; i++, iverneed++) + { + Elf_External_Vernaux *evernaux; + Elf_Internal_Vernaux *ivernaux; + unsigned int j; + + _bfd_elf_swap_verneed_in (abfd, everneed, iverneed); + + iverneed->vn_bfd = abfd; + + iverneed->vn_filename = + bfd_elf_string_from_elf_section (abfd, hdr->sh_link, + iverneed->vn_file); + if (iverneed->vn_filename == NULL) + goto error_return; + + iverneed->vn_auxptr = + ((Elf_Internal_Vernaux *) + bfd_alloc (abfd, + iverneed->vn_cnt * sizeof (Elf_Internal_Vernaux))); + + evernaux = ((Elf_External_Vernaux *) + ((bfd_byte *) everneed + iverneed->vn_aux)); + ivernaux = iverneed->vn_auxptr; + for (j = 0; j < iverneed->vn_cnt; j++, ivernaux++) + { + _bfd_elf_swap_vernaux_in (abfd, evernaux, ivernaux); + + ivernaux->vna_nodename = + bfd_elf_string_from_elf_section (abfd, hdr->sh_link, + ivernaux->vna_name); + if (ivernaux->vna_nodename == NULL) + goto error_return; + + if (j + 1 < iverneed->vn_cnt) + ivernaux->vna_nextptr = ivernaux + 1; + else + ivernaux->vna_nextptr = NULL; + + evernaux = ((Elf_External_Vernaux *) + ((bfd_byte *) evernaux + ivernaux->vna_next)); + } + + if (i + 1 < hdr->sh_info) + iverneed->vn_nextref = iverneed + 1; + else + iverneed->vn_nextref = NULL; + + everneed = ((Elf_External_Verneed *) + ((bfd_byte *) everneed + iverneed->vn_next)); + } + + free (contents); + contents = NULL; + } + + return true; + + error_return: + if (contents == NULL) + free (contents); + return false; +} + asymbol * _bfd_elf_make_empty_symbol (abfd) bfd *abfd; @@ -3171,6 +3885,36 @@ symbol_info *ret; { bfd_symbol_info (symbol, ret); +} + +/* Return whether a symbol name implies a local symbol. Most targets + use this function for the is_local_label_name entry point, but some + override it. */ + +boolean +_bfd_elf_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + /* Normal local symbols start with ``.L''. */ + if (name[0] == '.' && name[1] == 'L') + return true; + + /* At least some SVR4 compilers (e.g., UnixWare 2.1 cc) generate + DWARF debugging symbols starting with ``..''. */ + if (name[0] == '.' && name[1] == '.') + return true; + + /* gcc will sometimes generate symbols beginning with ``_.L_'' when + emitting DWARF debugging output. I suspect this is actually a + small bug in gcc (it calls ASM_OUTPUT_LABEL when it should call + ASM_GENERATE_INTERNAL_LABEL, and this causes the leading + underscore to be emitted on some ELF targets). For ease of use, + we treat such symbols as local. */ + if (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_') + return true; + + return false; } alent * diff -urN binutils-2.7/bfd/elf32-d10v.c binutils-2.8/bfd/elf32-d10v.c --- binutils-2.7/bfd/elf32-d10v.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/elf32-d10v.c Wed Apr 30 12:56:01 1997 @@ -0,0 +1,223 @@ +/* D10V-specific support for 32-bit ELF + Copyright (C) 1996 Free Software Foundation, Inc. + Contributed by Martin Hunt (hunt@cygnus.com). + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" +#include "elf-bfd.h" +/* #include "elf/d10v.h" */ + +static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup + PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); +static void d10v_info_to_howto_rel + PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); + + +/* Use REL instead of RELA to save space */ +#define USE_REL + +enum reloc_type +{ + R_D10V_NONE = 0, + R_D10V_10_PCREL_R, + R_D10V_10_PCREL_L, + R_D10V_16, + R_D10V_18, + R_D10V_18_PCREL, + R_D10V_32, + R_D10V_max +}; + +static reloc_howto_type elf_d10v_howto_table[] = +{ + /* This reloc does nothing. */ + HOWTO (R_D10V_NONE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_NONE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + /* An PC Relative 10-bit relocation, shifted by 2 */ + /* right container */ + HOWTO (R_D10V_10_PCREL_R, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_10_PCREL_R", /* name */ + false, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + true), /* pcrel_offset */ + + /* An PC Relative 10-bit relocation, shifted by 2 */ + /* left container */ + HOWTO (R_D10V_10_PCREL_L, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + true, /* pc_relative */ + 15, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_10_PCREL_L", /* name */ + false, /* partial_inplace */ + 0x07f8000, /* src_mask */ + 0x07f8000, /* dst_mask */ + true), /* pcrel_offset */ + + /* A 16 bit absolute relocation */ + HOWTO (R_D10V_16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* An 18 bit absolute relocation, right shifted 2 */ + HOWTO (R_D10V_18, /* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_18", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A relative 18 bit relocation, right shifted by 2 */ + HOWTO (R_D10V_18_PCREL, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_18_PCREL", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A 32 bit absolute relocation */ + HOWTO (R_D10V_32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_D10V_32", /* name */ + false, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + +}; + +/* Map BFD reloc types to D10V ELF reloc types. */ + +struct d10v_reloc_map +{ + unsigned char bfd_reloc_val; + unsigned char elf_reloc_val; +}; + + static const struct d10v_reloc_map d10v_reloc_map[] = +{ + { BFD_RELOC_NONE, R_D10V_NONE, }, + { BFD_RELOC_D10V_10_PCREL_R, R_D10V_10_PCREL_R }, + { BFD_RELOC_D10V_10_PCREL_L, R_D10V_10_PCREL_L }, + { BFD_RELOC_16, R_D10V_16 }, + { BFD_RELOC_D10V_18, R_D10V_18 }, + { BFD_RELOC_D10V_18_PCREL, R_D10V_18_PCREL }, + { BFD_RELOC_32, R_D10V_32 }, +}; + +static reloc_howto_type * +bfd_elf32_bfd_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; + i < sizeof (d10v_reloc_map) / sizeof (struct d10v_reloc_map); + i++) + { + if (d10v_reloc_map[i].bfd_reloc_val == code) + return &elf_d10v_howto_table[d10v_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Set the howto pointer for an D10V ELF reloc. */ + +static void +d10v_info_to_howto_rel (abfd, cache_ptr, dst) + bfd *abfd; + arelent *cache_ptr; + Elf32_Internal_Rel *dst; +{ + unsigned int r_type; + + r_type = ELF32_R_TYPE (dst->r_info); + BFD_ASSERT (r_type < (unsigned int) R_D10V_max); + cache_ptr->howto = &elf_d10v_howto_table[r_type]; +} + +#define ELF_ARCH bfd_arch_d10v +#define ELF_MACHINE_CODE EM_CYGNUS_D10V +#define ELF_MAXPAGESIZE 0x1000 + +#define TARGET_BIG_SYM bfd_elf32_d10v_vec +#define TARGET_BIG_NAME "elf32-d10v" + +#define elf_info_to_howto 0 +#define elf_info_to_howto_rel d10v_info_to_howto_rel +#define elf_backend_object_p 0 +#define elf_backend_final_write_processing 0 + +#include "elf32-target.h" diff -urN binutils-2.7/bfd/elf32-hppa.c binutils-2.8/bfd/elf32-hppa.c --- binutils-2.7/bfd/elf32-hppa.c Thu Jul 4 12:18:33 1996 +++ binutils-2.8/bfd/elf32-hppa.c Wed Apr 30 12:56:02 1997 @@ -1,5 +1,6 @@ /* BFD back-end for HP PA-RISC ELF files. - Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 + Free Software Foundation, Inc. Written by @@ -27,7 +28,6 @@ #include "sysdep.h" #include "bfdlink.h" #include "libbfd.h" -#include "obstack.h" #include "elf-bfd.h" /* The internal type of a symbol table extension entry. */ @@ -234,7 +234,7 @@ static void elf_hppa_tc_make_sections PARAMS ((bfd *, symext_chainS *)); -static boolean hppa_elf_is_local_label PARAMS ((bfd *, asymbol *)); +static boolean hppa_elf_is_local_label_name PARAMS ((bfd *, const char *)); static boolean elf32_hppa_add_symbol_hook PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, @@ -296,7 +296,9 @@ static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] = { {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_NONE"}, - {R_PARISC_DIR32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR32"}, + /* The values in DIR32 are to placate the check in + _bfd_stab_section_find_nearest_line. */ + {R_PARISC_DIR32, 0, 2, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false}, {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR21L"}, {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17R"}, {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17F"}, @@ -939,25 +941,26 @@ relocation with modifications based on format and field. */ elf32_hppa_reloc_type ** -hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore) +hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore, sym) bfd *abfd; elf32_hppa_reloc_type base_type; int format; int field; int ignore; + asymbol *sym; { elf32_hppa_reloc_type *finaltype; elf32_hppa_reloc_type **final_types; /* Allocate slots for the BFD relocation. */ - final_types = (elf32_hppa_reloc_type **) - bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 2); + final_types = ((elf32_hppa_reloc_type **) + bfd_alloc (abfd, sizeof (elf32_hppa_reloc_type *) * 2)); if (final_types == NULL) return NULL; /* Allocate space for the relocation itself. */ - finaltype = (elf32_hppa_reloc_type *) - bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type)); + finaltype = ((elf32_hppa_reloc_type *) + bfd_alloc (abfd, sizeof (elf32_hppa_reloc_type))); if (finaltype == NULL) return NULL; @@ -1550,11 +1553,11 @@ /* Return true if SYM represents a local label symbol. */ static boolean -hppa_elf_is_local_label (abfd, sym) +hppa_elf_is_local_label_name (abfd, name) bfd *abfd; - asymbol *sym; + const char *name; { - return (sym->name[0] == 'L' && sym->name[1] == '$'); + return (name[0] == 'L' && name[1] == '$'); } /* Do any backend specific processing when beginning to write an object @@ -2956,7 +2959,7 @@ /* Misc BFD support code. */ #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup -#define bfd_elf32_bfd_is_local_label hppa_elf_is_local_label +#define bfd_elf32_bfd_is_local_label_name hppa_elf_is_local_label_name /* Symbol extension stuff. */ #define bfd_elf32_set_section_contents elf32_hppa_set_section_contents diff -urN binutils-2.7/bfd/elf32-hppa.h binutils-2.8/bfd/elf32-hppa.h --- binutils-2.7/bfd/elf32-hppa.h Thu Jul 4 12:18:33 1996 +++ binutils-2.8/bfd/elf32-hppa.h Wed Apr 30 12:56:02 1997 @@ -141,7 +141,7 @@ #define R_HPPA_COMPLEX R_PARISC_UNIMPLEMENTED elf32_hppa_reloc_type **hppa_elf_gen_reloc_type - PARAMS ((bfd *, elf32_hppa_reloc_type, int, int, int)); + PARAMS ((bfd *, elf32_hppa_reloc_type, int, int, int, asymbol *)); boolean elf32_hppa_size_stubs PARAMS ((bfd *, bfd *, struct bfd_link_info *)); diff -urN binutils-2.7/bfd/elf32-i386.c binutils-2.8/bfd/elf32-i386.c --- binutils-2.7/bfd/elf32-i386.c Thu Jul 4 12:18:34 1996 +++ binutils-2.8/bfd/elf32-i386.c Wed Apr 30 12:56:02 1997 @@ -1,5 +1,5 @@ /* Intel 80386/80486-specific support for 32-bit ELF - Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -29,6 +29,11 @@ PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); static void elf_i386_info_to_howto_rel PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); +static boolean elf_i386_is_local_label_name PARAMS ((bfd *, const char *)); +static struct bfd_hash_entry *elf_i386_link_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static struct bfd_link_hash_table *elf_i386_link_hash_table_create + PARAMS ((bfd *)); static boolean elf_i386_check_relocs PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *)); @@ -60,6 +65,13 @@ R_386_RELATIVE, R_386_GOTOFF, R_386_GOTPC, + FIRST_INVALID_RELOC, + LAST_INVALID_RELOC = 19, + /* The remaining relocs are a GNU extension. */ + R_386_16 = 20, + R_386_PC16, + R_386_8, + R_386_PC8, R_386_max }; @@ -93,6 +105,20 @@ HOWTO(R_386_RELATIVE, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false), HOWTO(R_386_GOTOFF, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false), HOWTO(R_386_GOTPC, 0,2,32,true,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTPC", true,0xffffffff,0xffffffff,true), + { 11 }, + { 12 }, + { 13 }, + { 14 }, + { 15 }, + { 16 }, + { 17 }, + { 18 }, + { 19 }, + /* The remaining relocs are a GNU extension. */ + HOWTO(R_386_16, 0,1,16,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_16", true,0xffff,0xffff,false), + HOWTO(R_386_PC16, 0,1,16,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC16", true,0xffff,0xffff,true), + HOWTO(R_386_8, 0,0,8,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_8", true,0xff,0xff,false), + HOWTO(R_386_PC8, 0,0,8,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC8", true,0xff,0xff,true), }; #ifdef DEBUG_GEN_RELOC @@ -152,6 +178,23 @@ TRACE ("BFD_RELOC_386_GOTPC"); return &elf_howto_table[ (int)R_386_GOTPC ]; + /* The remaining relocs are a GNU extension. */ + case BFD_RELOC_16: + TRACE ("BFD_RELOC_16"); + return &elf_howto_table[(int) R_386_16]; + + case BFD_RELOC_16_PCREL: + TRACE ("BFD_RELOC_16_PCREL"); + return &elf_howto_table[(int) R_386_PC16]; + + case BFD_RELOC_8: + TRACE ("BFD_RELOC_8"); + return &elf_howto_table[(int) R_386_8]; + + case BFD_RELOC_8_PCREL: + TRACE ("BFD_RELOC_8_PCREL"); + return &elf_howto_table[(int) R_386_PC8]; + default: break; } @@ -166,20 +209,39 @@ arelent *cache_ptr; Elf32_Internal_Rela *dst; { - BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max); - - cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)]; + abort (); } static void elf_i386_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd; - arelent *cache_ptr; + bfd *abfd; + arelent *cache_ptr; Elf32_Internal_Rel *dst; { - BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max); + enum reloc_type type; + + type = (enum reloc_type) ELF32_R_TYPE (dst->r_info); + BFD_ASSERT (type < R_386_max); + BFD_ASSERT (type < FIRST_INVALID_RELOC || type > LAST_INVALID_RELOC); - cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)]; + cache_ptr->howto = &elf_howto_table[(int) type]; +} + +/* Return whether a symbol name implies a local label. The UnixWare + 2.1 cc generates temporary symbols that start with .X, so we + recognize them here. FIXME: do other SVR4 compilers also use .X?. + If so, we should move the .X recognition into + _bfd_elf_is_local_label_name. */ + +static boolean +elf_i386_is_local_label_name (abfd, name) + bfd *abfd; + const char *name; +{ + if (name[0] == '.' && name[1] == 'X') + return true; + + return _bfd_elf_is_local_label_name (abfd, name); } /* Functions for the i386 ELF linker. */ @@ -222,8 +284,8 @@ static const bfd_byte elf_i386_pic_plt0_entry[PLT_ENTRY_SIZE] = { - 0xff, 0xb3, 4, 0, 0, 0, /* pushl 4(%ebx) */ - 0xff, 0xa3, 8, 0, 0, 0, /* jmp *8(%ebx) */ + 0xff, 0xb3, 4, 0, 0, 0, /* pushl 4(%ebx) */ + 0xff, 0xa3, 8, 0, 0, 0, /* jmp *8(%ebx) */ 0, 0, 0, 0 /* pad out to 16 bytes. */ }; @@ -239,6 +301,115 @@ 0, 0, 0, 0 /* replaced with offset to start of .plt. */ }; +/* The i386 linker needs to keep track of the number of relocs that it + decides to copy in check_relocs for each symbol. This is so that + it can discard PC relative relocs if it doesn't need them when + linking with -Bsymbolic. We store the information in a field + extending the regular ELF linker hash table. */ + +/* This structure keeps track of the number of PC relative relocs we + have copied for a given symbol. */ + +struct elf_i386_pcrel_relocs_copied +{ + /* Next section. */ + struct elf_i386_pcrel_relocs_copied *next; + /* A section in dynobj. */ + asection *section; + /* Number of relocs copied in this section. */ + bfd_size_type count; +}; + +/* i386 ELF linker hash entry. */ + +struct elf_i386_link_hash_entry +{ + struct elf_link_hash_entry root; + + /* Number of PC relative relocs copied for this symbol. */ + struct elf_i386_pcrel_relocs_copied *pcrel_relocs_copied; +}; + +/* i386 ELF linker hash table. */ + +struct elf_i386_link_hash_table +{ + struct elf_link_hash_table root; +}; + +/* Declare this now that the above structures are defined. */ + +static boolean elf_i386_discard_copies + PARAMS ((struct elf_i386_link_hash_entry *, PTR)); + +/* Traverse an i386 ELF linker hash table. */ + +#define elf_i386_link_hash_traverse(table, func, info) \ + (elf_link_hash_traverse \ + (&(table)->root, \ + (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ + (info))) + +/* Get the i386 ELF linker hash table from a link_info structure. */ + +#define elf_i386_hash_table(p) \ + ((struct elf_i386_link_hash_table *) ((p)->hash)) + +/* Create an entry in an i386 ELF linker hash table. */ + +static struct bfd_hash_entry * +elf_i386_link_hash_newfunc (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +{ + struct elf_i386_link_hash_entry *ret = + (struct elf_i386_link_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == (struct elf_i386_link_hash_entry *) NULL) + ret = ((struct elf_i386_link_hash_entry *) + bfd_hash_allocate (table, + sizeof (struct elf_i386_link_hash_entry))); + if (ret == (struct elf_i386_link_hash_entry *) NULL) + return (struct bfd_hash_entry *) ret; + + /* Call the allocation method of the superclass. */ + ret = ((struct elf_i386_link_hash_entry *) + _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, + table, string)); + if (ret != (struct elf_i386_link_hash_entry *) NULL) + { + ret->pcrel_relocs_copied = NULL; + } + + return (struct bfd_hash_entry *) ret; +} + +/* Create an i386 ELF linker hash table. */ + +static struct bfd_link_hash_table * +elf_i386_link_hash_table_create (abfd) + bfd *abfd; +{ + struct elf_i386_link_hash_table *ret; + + ret = ((struct elf_i386_link_hash_table *) + bfd_alloc (abfd, sizeof (struct elf_i386_link_hash_table))); + if (ret == (struct elf_i386_link_hash_table *) NULL) + return NULL; + + if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, + elf_i386_link_hash_newfunc)) + { + bfd_release (abfd, ret); + return NULL; + } + + return &ret->root.root; +} + /* Look through the relocs for a section during the first phase, and allocate space in the global offset table or procedure linkage table. */ @@ -307,7 +478,7 @@ { case R_386_GOT32: /* This symbol requires a global offset table entry. */ - + if (sgot == NULL) { sgot = bfd_get_section_by_name (dynobj, ".got"); @@ -327,6 +498,7 @@ | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, srelgot, 2)) return false; @@ -407,9 +579,24 @@ case R_386_32: case R_386_PC32: + /* If we are creating a shared library, and this is a reloc + against a global symbol, or a non PC relative reloc + against a local symbol, then we need to copy the reloc + into the shared library. However, if we are linking with + -Bsymbolic, we do not need to copy a reloc against a + global symbol which is defined in an object we are + including in the link (i.e., DEF_REGULAR is set). At + this point we have not seen all the input files, so it is + possible that DEF_REGULAR is not set now but will be set + later (it is never cleared). We account for that + possibility below by storing information in the + pcrel_relocs_copied field of the hash table entry. */ if (info->shared - && (sec->flags & SEC_ALLOC) != 0 - && (ELF32_R_TYPE (rel->r_info) != R_386_PC32 || h != NULL)) + && (ELF32_R_TYPE (rel->r_info) != R_386_PC32 + || (h != NULL + && (! info->symbolic + || (h->elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0)))) { /* When creating a shared object, we must copy these reloc types into the output file. We create a reloc @@ -432,22 +619,58 @@ sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) { + flagword flags; + sreloc = bfd_make_section (dynobj, name); + flags = (SEC_HAS_CONTENTS | SEC_READONLY + | SEC_IN_MEMORY | SEC_LINKER_CREATED); + if ((sec->flags & SEC_ALLOC) != 0) + flags |= SEC_ALLOC | SEC_LOAD; if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_READONLY)) + || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return false; } } sreloc->_raw_size += sizeof (Elf32_External_Rel); + + /* If we are linking with -Bsymbolic, and this is a + global symbol, we count the number of PC relative + relocations we have entered for this symbol, so that + we can discard them again if the symbol is later + defined by a regular object. Note that this function + is only called if we are using an elf_i386 linker + hash table, which means that h is really a pointer to + an elf_i386_link_hash_entry. */ + if (h != NULL && info->symbolic + && ELF32_R_TYPE (rel->r_info) == R_386_PC32) + { + struct elf_i386_link_hash_entry *eh; + struct elf_i386_pcrel_relocs_copied *p; + + eh = (struct elf_i386_link_hash_entry *) h; + + for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next) + if (p->section == sreloc) + break; + + if (p == NULL) + { + p = ((struct elf_i386_pcrel_relocs_copied *) + bfd_alloc (dynobj, sizeof *p)); + if (p == NULL) + return false; + p->next = eh->pcrel_relocs_copied; + eh->pcrel_relocs_copied = p; + p->section = sreloc; + p->count = 0; + } + + ++p->count; + } } - + break; default: @@ -588,14 +811,11 @@ s = bfd_get_section_by_name (dynobj, ".dynbss"); BFD_ASSERT (s != NULL); - /* If the symbol is currently defined in the .bss section of the - dynamic object, then it is OK to simply initialize it to zero. - If the symbol is in some other section, we must generate a - R_386_COPY reloc to tell the dynamic linker to copy the initial - value out of the dynamic object and into the runtime process - image. We need to remember the offset into the .rel.bss section - we are going to use. */ - if ((h->root.u.def.section->flags & SEC_LOAD) != 0) + /* We must generate a R_386_COPY reloc to tell the dynamic linker to + copy the initial value out of the dynamic object and into the + runtime process image. We need to remember the offset into the + .rel.bss section we are going to use. */ + if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { asection *srel; @@ -669,6 +889,15 @@ s->_raw_size = 0; } + /* If this is a -Bsymbolic shared link, then we need to discard all + PC relative relocs against symbols defined in a regular object. + We allocated space for them in the check_relocs routine, but we + will not fill them in in the relocate_section routine. */ + if (info->shared && info->symbolic) + elf_i386_link_hash_traverse (elf_i386_hash_table (info), + elf_i386_discard_copies, + (PTR) NULL); + /* The check_relocs and adjust_dynamic_symbol entry points have determined the sizes of the various dynamic sections. Allocate memory for them. */ @@ -680,7 +909,7 @@ const char *name; boolean strip; - if ((s->flags & SEC_IN_MEMORY) == 0) + if ((s->flags & SEC_LINKER_CREATED) == 0) continue; /* It's OK to base decisions on the section name, because none @@ -726,6 +955,8 @@ than .rel.plt. */ if (strcmp (name, ".rel.plt") != 0) { + const char *outname; + relocs = true; /* If this relocation section applies to a read only @@ -733,7 +964,9 @@ entry. The entries in the .rel.plt section really apply to the .got section, which we created ourselves and so know is not readonly. */ - target = bfd_get_section_by_name (output_bfd, name + 4); + outname = bfd_get_section_name (output_bfd, + s->output_section); + target = bfd_get_section_by_name (output_bfd, outname + 4); if (target != NULL && (target->flags & SEC_READONLY) != 0) reltext = true; @@ -769,7 +1002,7 @@ if (s->contents == NULL && s->_raw_size != 0) return false; } - + if (elf_hash_table (info)->dynamic_sections_created) { /* Add some entries to the .dynamic section. We fill in the @@ -811,6 +1044,31 @@ return true; } +/* This function is called via elf_i386_link_hash_traverse if we are + creating a shared object with -Bsymbolic. It discards the space + allocated to copy PC relative relocs against symbols which are + defined in regular objects. We allocated space for them in the + check_relocs routine, but we won't fill them in in the + relocate_section routine. */ + +/*ARGSUSED*/ +static boolean +elf_i386_discard_copies (h, ignore) + struct elf_i386_link_hash_entry *h; + PTR ignore; +{ + struct elf_i386_pcrel_relocs_copied *s; + + /* We only discard relocs for symbols defined in a regular object. */ + if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + return true; + + for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) + s->section->_raw_size -= s->count * sizeof (Elf32_External_Rel); + + return true; +} + /* Relocate an i386 ELF section. */ static boolean @@ -858,7 +1116,10 @@ bfd_reloc_status_type r; r_type = ELF32_R_TYPE (rel->r_info); - if (r_type < 0 || r_type >= (int) R_386_max) + if (r_type < 0 + || r_type >= (int) R_386_max + || (r_type >= (int) FIRST_INVALID_RELOC + && r_type <= (int) LAST_INVALID_RELOC)) { bfd_set_error (bfd_error_bad_value); return false; @@ -926,14 +1187,21 @@ || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) && (r_type == R_386_32 - || r_type == R_386_PC32) - && (input_section->flags & SEC_ALLOC) != 0)) + || r_type == R_386_PC32))) { /* In these cases, we don't need the relocation value. We check specially because in some obscure cases sec->output_section will be NULL. */ relocation = 0; } + else if (sec->output_section == NULL) + { + (*_bfd_error_handler) + ("%s: warning: unresolvable relocation against symbol `%s' from %s section", + bfd_get_filename (input_bfd), h->root.root.string, + bfd_get_section_name (input_bfd, input_section)); + relocation = 0; + } else relocation = (h->root.u.def.value + sec->output_section->vma @@ -1108,7 +1376,6 @@ case R_386_32: case R_386_PC32: if (info->shared - && (input_section->flags & SEC_ALLOC) != 0 && (r_type != R_386_PC32 || (h != NULL && (! info->symbolic @@ -1116,7 +1383,7 @@ & ELF_LINK_HASH_DEF_REGULAR) == 0)))) { Elf_Internal_Rel outrel; - boolean relocate; + boolean skip, relocate; /* When generating a shared object, these relocations are copied into the output file to be resolved at run @@ -1142,10 +1409,33 @@ BFD_ASSERT (sreloc != NULL); } - outrel.r_offset = (rel->r_offset - + input_section->output_section->vma - + input_section->output_offset); - if (r_type == R_386_PC32) + skip = false; + + if (elf_section_data (input_section)->stab_info == NULL) + outrel.r_offset = rel->r_offset; + else + { + bfd_vma off; + + off = (_bfd_stab_section_offset + (output_bfd, &elf_hash_table (info)->stab_info, + input_section, + &elf_section_data (input_section)->stab_info, + rel->r_offset)); + if (off == (bfd_vma) -1) + skip = true; + outrel.r_offset = off; + } + + outrel.r_offset += (input_section->output_section->vma + + input_section->output_offset); + + if (skip) + { + memset (&outrel, 0, sizeof outrel); + relocate = false; + } + else if (r_type == R_386_PC32) { BFD_ASSERT (h != NULL && h->dynindx != -1); relocate = false; @@ -1153,8 +1443,10 @@ } else { + /* h->dynindx may be -1 if this symbol was marked to + become local. */ if (h == NULL - || (info->symbolic + || ((info->symbolic || h->dynindx == -1) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)) { @@ -1330,7 +1622,7 @@ /* This symbol has an entry in the global offset table. Set it up. */ - + BFD_ASSERT (h->dynindx != -1); sgot = bfd_get_section_by_name (dynobj, ".got"); @@ -1523,12 +1815,16 @@ #define TARGET_LITTLE_NAME "elf32-i386" #define ELF_ARCH bfd_arch_i386 #define ELF_MACHINE_CODE EM_386 +#define ELF_MAXPAGESIZE 0x1000 #define elf_info_to_howto elf_i386_info_to_howto #define elf_info_to_howto_rel elf_i386_info_to_howto_rel #define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup -#define ELF_MAXPAGESIZE 0x1000 +#define bfd_elf32_bfd_is_local_label_name \ + elf_i386_is_local_label_name #define elf_backend_create_dynamic_sections \ _bfd_elf_create_dynamic_sections +#define bfd_elf32_bfd_link_hash_table_create \ + elf_i386_link_hash_table_create #define elf_backend_check_relocs elf_i386_check_relocs #define elf_backend_adjust_dynamic_symbol \ elf_i386_adjust_dynamic_symbol diff -urN binutils-2.7/bfd/elf32-m32r.c binutils-2.8/bfd/elf32-m32r.c --- binutils-2.7/bfd/elf32-m32r.c Wed Dec 31 19:00:00 1969 +++ binutils-2.8/bfd/elf32-m32r.c Wed Apr 30 12:56:03 1997 @@ -0,0 +1,1758 @@ +/* M32R-specific support for 32-bit ELF. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" +#include "elf-bfd.h" +#include "elf/m32r.h" + +static bfd_reloc_status_type m32r_elf_10_pcrel_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type m32r_elf_do_10_pcrel_reloc + PARAMS ((bfd *, reloc_howto_type *, asection *, + bfd_byte *, bfd_vma, asection *, bfd_vma, bfd_vma)); +static bfd_reloc_status_type m32r_elf_hi16_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static void m32r_elf_relocate_hi16 + PARAMS ((bfd *, int, Elf_Internal_Rela *, Elf_Internal_Rela *, + bfd_byte *, bfd_vma)); +bfd_reloc_status_type m32r_elf_lo16_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type m32r_elf_sda16_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup + PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); +static void m32r_info_to_howto_rel + PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); +boolean _bfd_m32r_elf_section_from_bfd_section + PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *)); +void _bfd_m32r_elf_symbol_processing + PARAMS ((bfd *, asymbol *)); +static boolean m32r_elf_add_symbol_hook + PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + const char **, flagword *, asection **, bfd_vma *)); +static boolean m32r_elf_relocate_section + PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); +#if 0 /* not yet */ +static boolean m32r_elf_relax_delete_bytes + PARAMS ((bfd *, asection *, bfd_vma, int)); +#endif + +/* Use REL instead of RELA to save space. + This only saves space in libraries and object files, but perhaps + relocs will be put in ROM? All in all though, REL relocs are a pain + to work with. */ +#define USE_REL + +static reloc_howto_type m32r_elf_howto_table[] = +{ + /* This reloc does nothing. */ + HOWTO (R_M32R_NONE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M32R_NONE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 16 bit absolute relocation. */ + HOWTO (R_M32R_16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M32R_16", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 32 bit absolute relocation. */ + HOWTO (R_M32R_32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M32R_32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* A 24 bit address. */ + HOWTO (R_M32R_24, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 24, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M32R_24", /* name */ + true, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* An PC Relative 10-bit relocation, shifted by 2. + This reloc is complicated because relocations are relative to pc & -4. + i.e. branches in the right insn slot use the address of the left insn + slot for pc. */ + /* ??? It's not clear whether this should have partial_inplace set or not. + Branch relaxing in the assembler can store the addend in the insn, + and if bfd_install_relocation gets called the addend may get added + again. */ + HOWTO (R_M32R_10_PCREL, /* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + m32r_elf_10_pcrel_reloc, /* special_function */ + "R_M32R_10_PCREL", /* name */ + false, /* partial_inplace */ + 0xff, /* src_mask */ + 0xff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A relative 18 bit relocation, right shifted by 2. */ + HOWTO (R_M32R_18_PCREL, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M32R_18_PCREL", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* A relative 26 bit relocation, right shifted by 2. */ + /* ??? It's not clear whether this should have partial_inplace set or not. + Branch relaxing in the assembler can store the addend in the insn, + and if bfd_install_relocation gets called the addend may get added + again. */ + HOWTO (R_M32R_26_PCREL, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 26, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M32R_26_PCREL", /* name */ + false, /* partial_inplace */ + 0xffffff, /* src_mask */ + 0xffffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* High 16 bits of address when lower 16 is or'd in. */ + HOWTO (R_M32R_HI16_ULO, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + m32r_elf_hi16_reloc, /* special_function */ + "R_M32R_HI16_ULO", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* High 16 bits of address when lower 16 is added in. */ + HOWTO (R_M32R_HI16_SLO, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + m32r_elf_hi16_reloc, /* special_function */ + "R_M32R_HI16_SLO", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* Lower 16 bits of address. */ + HOWTO (R_M32R_LO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + m32r_elf_lo16_reloc, /* special_function */ + "R_M32R_LO16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* Small data area 16 bits offset. */ + HOWTO (R_M32R_SDA16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + m32r_elf_sda16_reloc, /* special_function */ + "R_M32R_SDA16", /* name */ + true, /* partial_inplace */ /* FIXME: correct? */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + false), /* pcrel_offset */ +}; + +/* Handle the R_M32R_10_PCREL reloc. */ + +static bfd_reloc_status_type +m32r_elf_10_pcrel_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + /* This part is from bfd_elf_generic_reloc. */ + if (output_bfd != (bfd *) NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (! reloc_entry->howto->partial_inplace + || reloc_entry->addend == 0)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + if (output_bfd != NULL) + { + /* FIXME: See bfd_perform_relocation. Is this right? */ + return bfd_reloc_continue; + } + + return m32r_elf_do_10_pcrel_reloc (abfd, reloc_entry->howto, + input_section, + data, reloc_entry->address, + symbol->section, + (symbol->value + + symbol->section->output_section->vma + + symbol->section->output_offset), + reloc_entry->addend); +} + +/* Utility to actually perform an R_M32R_10_PCREL reloc. */ + +static bfd_reloc_status_type +m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset, + symbol_section, symbol_value, addend) + bfd *abfd; + reloc_howto_type *howto; + asection *input_section; + bfd_byte *data; + bfd_vma offset; + asection *symbol_section; + bfd_vma symbol_value; + bfd_vma addend; +{ + bfd_signed_vma relocation; + unsigned long x; + bfd_reloc_status_type status; + + /* Sanity check the address (offset in section). */ + if (offset > input_section->_cooked_size) + return bfd_reloc_outofrange; + + relocation = symbol_value + addend; + /* Make it pc relative. */ + relocation -= (input_section->output_section->vma + + input_section->output_offset); + /* These jumps mask off the lower two bits of the current address + before doing pcrel calculations. */ + relocation -= (offset & -4L); + + if (relocation < -0x200 || relocation > 0x1ff) + status = bfd_reloc_overflow; + else + status = bfd_reloc_ok; + + x = bfd_get_16 (abfd, data + offset); + relocation >>= howto->rightshift; + relocation <<= howto->bitpos; + x = (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask); + bfd_put_16 (abfd, x, data + offset); + + return status; +} + +/* Handle the R_M32R_HI16_[SU]LO relocs. + HI16_SLO is for the add3 and load/store with displacement instructions. + HI16_ULO is for the or3 instruction. + For R_M32R_HI16_SLO, the lower 16 bits are sign extended when added to + the high 16 bytes so if the lower 16 bits are negative (bit 15 == 1) then + we must add one to the high 16 bytes (which will get subtracted off when + the low 16 bits are added). + These relocs have to be done in combination with an R_M32R_LO16 reloc + because there is a carry from the LO16 to the HI16. Here we just save + the information we need; we do the actual relocation when we see the LO16. + This code is copied from the elf32-mips.c. We also support an arbitrary + number of HI16 relocs to be associated with a single LO16 reloc. The + assembler sorts the relocs to ensure each HI16 immediately precedes its + LO16. However if there are multiple copies, the assembler may not find + the real LO16 so it picks the first one it finds. */ + +struct m32r_hi16 +{ + struct m32r_hi16 *next; + bfd_byte *addr; + bfd_vma addend; +}; + +/* FIXME: This should not be a static variable. */ + +static struct m32r_hi16 *m32r_hi16_list; + +static bfd_reloc_status_type +m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + bfd_reloc_status_type ret; + bfd_vma relocation; + struct m32r_hi16 *n; + + /* This part is from bfd_elf_generic_reloc. + If we're relocating, and this an external symbol, we don't want + to change anything. */ + if (output_bfd != (bfd *) NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && reloc_entry->addend == 0) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + /* Sanity check the address (offset in section). */ + if (reloc_entry->address > input_section->_cooked_size) + return bfd_reloc_outofrange; + + ret = bfd_reloc_ok; + if (bfd_is_und_section (symbol->section) + && output_bfd == (bfd *) NULL) + ret = bfd_reloc_undefined; + + if (bfd_is_com_section (symbol->section)) + relocation = 0; + else + relocation = symbol->value; + + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + relocation += reloc_entry->addend; + + /* Save the information, and let LO16 do the actual relocation. */ + n = (struct m32r_hi16 *) bfd_malloc (sizeof *n); + if (n == NULL) + return bfd_reloc_outofrange; + n->addr = (bfd_byte *) data + reloc_entry->address; + n->addend = relocation; + n->next = m32r_hi16_list; + m32r_hi16_list = n; + + if (output_bfd != (bfd *) NULL) + reloc_entry->address += input_section->output_offset; + + return ret; +} + +/* Handle an M32R ELF HI16 reloc. */ + +static void +m32r_elf_relocate_hi16 (input_bfd, type, relhi, rello, contents, addend) + bfd *input_bfd; + int type; + Elf_Internal_Rela *relhi; + Elf_Internal_Rela *rello; + bfd_byte *contents; + bfd_vma addend; +{ + unsigned long insn; + bfd_vma addlo; + + insn = bfd_get_32 (input_bfd, contents + relhi->r_offset); + + addlo = bfd_get_32 (input_bfd, contents + rello->r_offset); + if (type == R_M32R_HI16_SLO) + addlo = ((addlo & 0xffff) ^ 0x8000) - 0x8000; + else + addlo &= 0xffff; + + addend += ((insn & 0xffff) << 16) + addlo; + + /* Reaccount for sign extension of low part. */ + if (type == R_M32R_HI16_SLO + && (addend & 0x8000) != 0) + addend += 0x10000; + + bfd_put_32 (input_bfd, + (insn & 0xffff0000) | ((addend >> 16) & 0xffff), + contents + relhi->r_offset); +} + +/* Do an R_M32R_LO16 relocation. This is a straightforward 16 bit + inplace relocation; this function exists in order to do the + R_M32R_HI16_[SU]LO relocation described above. */ + +bfd_reloc_status_type +m32r_elf_lo16_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + if (m32r_hi16_list != NULL) + { + struct m32r_hi16 *l; + + l = m32r_hi16_list; + while (l != NULL) + { + unsigned long insn; + unsigned long val; + unsigned long vallo; + struct m32r_hi16 *next; + + /* Do the HI16 relocation. Note that we actually don't need + to know anything about the LO16 itself, except where to + find the low 16 bits of the addend needed by the LO16. */ + insn = bfd_get_32 (abfd, l->addr); + vallo = ((bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) + & 0xffff) ^ 0x8000) - 0x8000; + val = ((insn & 0xffff) << 16) + vallo; + val += l->addend; + + /* Reaccount for sign extension of low part. */ + if ((val & 0x8000) != 0) + val += 0x10000; + + insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); + bfd_put_32 (abfd, insn, l->addr); + + next = l->next; + free (l); + l = next; + } + + m32r_hi16_list = NULL; + } + + /* Now do the LO16 reloc in the usual way. */ + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); +} + +/* Handle the R_M32R_SDA16 reloc. + This reloc is used to compute the address of objects in the small data area + and to perform loads and stores from that area. + The lower 16 bits are sign extended and added to the register specified + in the instruction, which is assumed to point to _SDA_BASE_. */ + +static bfd_reloc_status_type +m32r_elf_sda16_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + bfd_vma sda_base; + unsigned long x; + reloc_howto_type *howto; + + /* This part is from bfd_elf_generic_reloc. */ + if (output_bfd != (bfd *) NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (! reloc_entry->howto->partial_inplace + || reloc_entry->addend == 0)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + if (output_bfd != NULL) + { + /* FIXME: See bfd_perform_relocation. Is this right? */ + return bfd_reloc_continue; + } + + /* FIXME: not sure what to do here yet. But then again, the linker + may never call us. */ + abort (); +} + +/* Map BFD reloc types to M32R ELF reloc types. */ + +struct m32r_reloc_map +{ + unsigned char bfd_reloc_val; + unsigned char elf_reloc_val; +}; + +static const struct m32r_reloc_map m32r_reloc_map[] = +{ + { BFD_RELOC_NONE, R_M32R_NONE }, + { BFD_RELOC_16, R_M32R_16 }, + { BFD_RELOC_32, R_M32R_32 }, + { BFD_RELOC_M32R_24, R_M32R_24 }, + { BFD_RELOC_M32R_10_PCREL, R_M32R_10_PCREL }, + { BFD_RELOC_M32R_18_PCREL, R_M32R_18_PCREL }, + { BFD_RELOC_M32R_26_PCREL, R_M32R_26_PCREL }, + { BFD_RELOC_M32R_HI16_ULO, R_M32R_HI16_ULO }, + { BFD_RELOC_M32R_HI16_SLO, R_M32R_HI16_SLO }, + { BFD_RELOC_M32R_LO16, R_M32R_LO16 }, + { BFD_RELOC_M32R_SDA16, R_M32R_SDA16 }, +}; + +static reloc_howto_type * +bfd_elf32_bfd_reloc_type_lookup (abfd, code) + bfd *abfd; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; + i < sizeof (m32r_reloc_map) / sizeof (struct m32r_reloc_map); + i++) + { + if (m32r_reloc_map[i].bfd_reloc_val == code) + return &m32r_elf_howto_table[m32r_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Set the howto pointer for an M32R ELF reloc. */ + +static void +m32r_info_to_howto_rel (abfd, cache_ptr, dst) + bfd *abfd; + arelent *cache_ptr; + Elf32_Internal_Rel *dst; +{ + unsigned int r_type; + + r_type = ELF32_R_TYPE (dst->r_info); + BFD_ASSERT (r_type < (unsigned int) R_M32R_max); + cache_ptr->howto = &m32r_elf_howto_table[r_type]; +} + +/* Given a BFD section, try to locate the corresponding ELF section + index. */ + +boolean +_bfd_m32r_elf_section_from_bfd_section (abfd, hdr, sec, retval) + bfd *abfd; + Elf32_Internal_Shdr *hdr; + asection *sec; + int *retval; +{ + if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0) + { + *retval = SHN_M32R_SCOMMON; + return true; + } + return false; +} + +/* M32R ELF uses two common sections. One is the usual one, and the other + is for small objects. All the small objects are kept together, and then + referenced via one register, which yields faster assembler code. It is + up to the compiler to emit an instruction to load the register with + _SDA_BASE. This is what we use for the small common section. This + approach is copied from elf32-mips.c. */ +static asection m32r_elf_scom_section; +static asymbol m32r_elf_scom_symbol; +static asymbol *m32r_elf_scom_symbol_ptr; + +/* Handle the special M32R section numbers that a symbol may use. */ + +void +_bfd_m32r_elf_symbol_processing (abfd, asym) + bfd *abfd; + asymbol *asym; +{ + elf_symbol_type *elfsym; + + elfsym = (elf_symbol_type *) asym; + + switch (elfsym->internal_elf_sym.st_shndx) + { + case SHN_M32R_SCOMMON: + if (m32r_elf_scom_section.name == NULL) + { + /* Initialize the small common section. */ + m32r_elf_scom_section.name = ".scommon"; + m32r_elf_scom_section.flags = SEC_IS_COMMON; + m32r_elf_scom_section.output_section = &m32r_elf_scom_section; + m32r_elf_scom_section.symbol = &m32r_elf_scom_symbol; + m32r_elf_scom_section.symbol_ptr_ptr = &m32r_elf_scom_symbol_ptr; + m32r_elf_scom_symbol.name = ".scommon"; + m32r_elf_scom_symbol.flags = BSF_SECTION_SYM; + m32r_elf_scom_symbol.section = &m32r_elf_scom_section; + m32r_elf_scom_symbol_ptr = &m32r_elf_scom_symbol; + } + asym->section = &m32r_elf_scom_section; + asym->value = elfsym->internal_elf_sym.st_size; + break; + } +} + +/* Hook called by the linker routine which adds symbols from an object + file. We must handle the special M32R section numbers here. + We also keep watching for whether we need to create the sdata special + linker sections. */ + +static boolean +m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) + bfd *abfd; + struct bfd_link_info *info; + const Elf_Internal_Sym *sym; + const char **namep; + flagword *flagsp; + asection **secp; + bfd_vma *valp; +{ + if (! info->relocateable + && (*namep)[0] == '_' && (*namep)[1] == 'S' + && strcmp (*namep, "_SDA_BASE_") == 0) + { + /* This is simpler than using _bfd_elf_create_linker_section + (our needs are simpler than ppc's needs). Also + _bfd_elf_create_linker_section currently has a bug where if a .sdata + section already exists a new one is created that follows it which + screws of _SDA_BASE_ address calcs because output_offset != 0. */ + struct elf_link_hash_entry *h; + asection *s = bfd_get_section_by_name (abfd, ".sdata"); + + /* The following code was cobbled from elf32-ppc.c and elflink.c. */ + + if (s == NULL) + { + int flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_IN_MEMORY | SEC_LINKER_CREATED); + + s = bfd_make_section_anyway (abfd, ".sdata"); + if (s == NULL) + return false; + bfd_set_section_flags (abfd, s, flags); + bfd_set_section_alignment (abfd, s, 2); + } + + h = (struct elf_link_hash_entry *) + bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, false); + + if ((h == NULL || h->root.type == bfd_link_hash_undefined) + && !(_bfd_generic_link_add_one_symbol (info, + abfd, + "_SDA_BASE_", + BSF_GLOBAL, + s, + 32768, + (const char *) NULL, + false, + get_elf_backend_data (abfd)->collect, + (struct bfd_link_hash_entry **) &h))) + return false; + h->type = STT_OBJECT; + } + + switch (sym->st_shndx) + { + case SHN_M32R_SCOMMON: + *secp = bfd_make_section_old_way (abfd, ".scommon"); + (*secp)->flags |= SEC_IS_COMMON; + *valp = sym->st_size; + break; + } + + return true; +} + +/* We have to figure out the SDA_BASE value, so that we can adjust the + symbol value correctly. We look up the symbol _SDA_BASE_ in the output + BFD. If we can't find it, we're stuck. We cache it in the ELF + target data. We don't need to adjust the symbol value for an + external symbol if we are producing relocateable output. */ + +static bfd_reloc_status_type +m32r_elf_final_sda_base (output_bfd, info, error_message, psb) + bfd *output_bfd; + struct bfd_link_info *info; + const char **error_message; + bfd_vma *psb; +{ + if (elf_gp (output_bfd) == 0) + { + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, true); + if (h != (struct bfd_link_hash_entry *) NULL + && h->type == bfd_link_hash_defined) + elf_gp (output_bfd) = (h->u.def.value + + h->u.def.section->output_section->vma + + h->u.def.section->output_offset); + else + { + /* Only get the error once. */ + *psb = elf_gp (output_bfd) = 4; + *error_message = + (const char *) "SDA relocation when _SDA_BASE_ not defined"; + return bfd_reloc_dangerous; + } + } + *psb = elf_gp (output_bfd); + return bfd_reloc_ok; +} + +/* Relocate an M32R/D ELF section. + There is some attempt to make this function usable for many architectures, + both USE_REL and USE_RELA ['twould be nice if such a critter existed], + if only to serve as a learning tool. + + The RELOCATE_SECTION function is called by the new ELF backend linker + to handle the relocations for a section. + + The relocs are always passed as R