This commit was manufactured by cvs2svn to create branch 'jimb-
macro-020506-branch'.

Sprout from gdb_5_2-branch 2002-03-27 05:12:36 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'gdb_5_2-branch'.'
Cherrypick from gdb_5_2-branch 2002-03-02 23:00:05 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'gdb_5_2-branch'.':
    intl/ChangeLog
    intl/Makefile.in
Cherrypick from master 2002-05-06 21:00:21 UTC Jim Blandy <jimb@codesourcery.com> 'Separate the job of reading the line number info statement program':
    ChangeLog
    MAINTAINERS
    Makefile.in
    bfd/ChangeLog
    bfd/ChangeLog-9495
    bfd/Makefile.am
    bfd/Makefile.in
    bfd/aix5ppc-core.c
    bfd/aout-adobe.c
    bfd/aout-target.h
    bfd/aout-tic30.c
    bfd/aoutx.h
    bfd/archive.c
    bfd/archures.c
    bfd/bfd-in.h
    bfd/bfd-in2.h
    bfd/bfd.c
    bfd/binary.c
    bfd/bout.c
    bfd/coff-arm.c
    bfd/coff-h8300.c
    bfd/coff-mcore.c
    bfd/coff-ppc.c
    bfd/coff-rs6000.c
    bfd/coff-sh.c
    bfd/coff-z8k.c
    bfd/coff64-rs6000.c
    bfd/coffcode.h
    bfd/cofflink.c
    bfd/coffswap.h
    bfd/config.bfd
    bfd/configure
    bfd/configure.in
    bfd/cpu-h8300.c
    bfd/cpu-i370.c
    bfd/cpu-i386.c
    bfd/cpu-mips.c
    bfd/cpu-powerpc.c
    bfd/cpu-s390.c
    bfd/cpu-sh.c
    bfd/cpu-sparc.c
    bfd/dep-in.sed
    bfd/doc/ChangeLog
    bfd/doc/Makefile.in
    bfd/dwarf2.c
    bfd/ecoff.c
    bfd/elf-bfd.h
    bfd/elf-eh-frame.c
    bfd/elf-hppa.h
    bfd/elf-m10300.c
    bfd/elf.c
    bfd/elf32-arm.h
    bfd/elf32-cris.c
    bfd/elf32-hppa.c
    bfd/elf32-hppa.h
    bfd/elf32-i370.c
    bfd/elf32-i386.c
    bfd/elf32-m32r.c
    bfd/elf32-m68k.c
    bfd/elf32-mips.c
    bfd/elf32-ppc.c
    bfd/elf32-s390.c
    bfd/elf32-sh.c
    bfd/elf32-sh64.c
    bfd/elf32-sparc.c
    bfd/elf32-xstormy16.c
    bfd/elf64-alpha.c
    bfd/elf64-hppa.c
    bfd/elf64-mips.c
    bfd/elf64-mmix.c
    bfd/elf64-ppc.c
    bfd/elf64-ppc.h
    bfd/elf64-s390.c
    bfd/elf64-sh64.c
    bfd/elf64-sparc.c
    bfd/elf64-x86-64.c
    bfd/elfarm-nabi.c
    bfd/elflink.c
    bfd/elflink.h
    bfd/elfxx-ia64.c
    bfd/elfxx-mips.c
    bfd/elfxx-mips.h
    bfd/elfxx-target.h
    bfd/i386linux.c
    bfd/i386msdos.c
    bfd/i386os9k.c
    bfd/ieee.c
    bfd/ihex.c
    bfd/libbfd-in.h
    bfd/libbfd.c
    bfd/libbfd.h
    bfd/libcoff-in.h
    bfd/libcoff.h
    bfd/libecoff.h
    bfd/libxcoff.h
    bfd/linker.c
    bfd/m68klinux.c
    bfd/merge.c
    bfd/mmo.c
    bfd/nlm-target.h
    bfd/oasys.c
    bfd/opncls.c
    bfd/pdp11.c
    bfd/po/SRC-POTFILES.in
    bfd/po/fr.po
    bfd/ppcboot.c
    bfd/reloc.c
    bfd/rs6000-core.c
    bfd/som.c
    bfd/sparclinux.c
    bfd/srec.c
    bfd/sunos.c
    bfd/syms.c
    bfd/targets.c
    bfd/tekhex.c
    bfd/versados.c
    bfd/version.h
    bfd/vms.c
    bfd/xcofflink.c
    config.guess
    config.sub
    config/ChangeLog
    config/acinclude.m4
    config/mh-a68bsd
    config/mh-apollo68
    config/mh-cxux
    config/mh-decstation
    config/mh-dgux
    config/mh-dgux386
    config/mh-djgpp
    config/mh-hp300
    config/mh-hpux
    config/mh-hpux8
    config/mh-interix
    config/mh-irix5
    config/mh-irix6
    config/mh-lynxrs6k
    config/mh-mingw32
    config/mh-ncr3000
    config/mh-ncrsvr43
    config/mh-necv4
    config/mh-openedition
    config/mh-riscos
    config/mh-sco
    config/mh-solaris
    config/mh-sysv
    config/mh-sysv4
    config/mh-sysv5
    config/mt-aix43
    config/mt-alphaieee
    config/mt-linux
    configure
    configure.in
    gdb/ChangeLog
    gdb/MAINTAINERS
    gdb/Makefile.in
    gdb/NEWS
    gdb/PROBLEMS
    gdb/README
    gdb/acconfig.h
    gdb/acinclude.m4
    gdb/aclocal.m4
    gdb/alpha-linux-tdep.c
    gdb/alpha-nat.c
    gdb/alpha-osf1-tdep.c
    gdb/alpha-tdep.c
    gdb/alpha-tdep.h
    gdb/alphabsd-nat.c
    gdb/alphafbsd-tdep.c
    gdb/alphanbsd-nat.c
    gdb/alphanbsd-tdep.c
    gdb/arc-tdep.c
    gdb/arch-utils.c
    gdb/arch-utils.h
    gdb/arm-tdep.c
    gdb/arm-tdep.h
    gdb/avr-tdep.c
    gdb/bcache.c
    gdb/blockframe.c
    gdb/breakpoint.c
    gdb/builtin-regs.c
    gdb/builtin-regs.h
    gdb/c-exp.y
    gdb/c-lang.c
    gdb/cli-out.c
    gdb/cli/cli-cmds.c
    gdb/cli/cli-decode.c
    gdb/cli/cli-decode.h
    gdb/cli/cli-dump.c
    gdb/cli/cli-dump.h
    gdb/cli/cli-script.c
    gdb/coffread.c
    gdb/command.h
    gdb/completer.c
    gdb/config.in
    gdb/config/alpha/alpha-linux.mt
    gdb/config/alpha/alpha-osf1.mt
    gdb/config/alpha/nbsd.mh
    gdb/config/alpha/nbsd.mt
    gdb/config/alpha/nm-linux.h
    gdb/config/alpha/nm-nbsd.h
    gdb/config/alpha/nm-osf.h
    gdb/config/alpha/tm-alpha.h
    gdb/config/alpha/tm-alphalinux.h
    gdb/config/alpha/tm-fbsd.h
    gdb/config/alpha/tm-nbsd.h
    gdb/config/arc/tm-arc.h
    gdb/config/avr/avr.mt
    gdb/config/djgpp/README
    gdb/config/h8500/tm-h8500.h
    gdb/config/i386/fbsd.mh
    gdb/config/i386/i386gnu.mh
    gdb/config/i386/i386lynx.mh
    gdb/config/i386/i386v42mp.mh
    gdb/config/i386/nbsd.mt
    gdb/config/i386/nbsdelf.mt
    gdb/config/i386/nm-fbsd.h
    gdb/config/i386/nm-x86-64.h
    gdb/config/i386/tm-linux.h
    gdb/config/i386/x86-64linux.mt
    gdb/config/i960/tm-i960.h
    gdb/config/m32r/m32r.mt
    gdb/config/m68k/m68klynx.mh
    gdb/config/m68k/nbsd.mt
    gdb/config/m68k/sun3os4.mh
    gdb/config/m68k/tm-nbsd.h
    gdb/config/mcore/tm-mcore.h
    gdb/config/mips/vr5000.mt
    gdb/config/mn10200/tm-mn10200.h
    gdb/config/ns32k/nbsd.mt
    gdb/config/pa/hppabsd.mh
    gdb/config/pa/hppaosf.mh
    gdb/config/pa/hpux1020.mh
    gdb/config/pa/hpux11.mh
    gdb/config/pa/hpux11w.mh
    gdb/config/pa/tm-hppa.h
    gdb/config/powerpc/nbsd.mt
    gdb/config/powerpc/tm-ppc-eabi.h
    gdb/config/rs6000/rs6000lynx.mh
    gdb/config/rs6000/tm-rs6000.h
    gdb/config/s390/s390.mh
    gdb/config/s390/s390.mt
    gdb/config/s390/s390x.mt
    gdb/config/sparc/fbsd.mh
    gdb/config/sparc/fbsd.mt
    gdb/config/sparc/linux.mh
    gdb/config/sparc/sparclynx.mh
    gdb/config/sparc/sun4os4.mh
    gdb/config/sparc/tm-linux.h
    gdb/config/sparc/tm-sp64.h
    gdb/config/sparc/tm-sp64linux.h
    gdb/config/sparc/tm-sparc.h
    gdb/config/v850/tm-v850.h
    gdb/config/vax/tm-vax.h
    gdb/configure
    gdb/configure.host
    gdb/configure.in
    gdb/configure.tgt
    gdb/core-sol2.c
    gdb/corefile.c
    gdb/corelow.c
    gdb/cp-valprint.c
    gdb/cris-tdep.c
    gdb/d10v-tdep.c
    gdb/d30v-tdep.c
    gdb/dbxread.c
    gdb/defs.h
    gdb/doc/ChangeLog
    gdb/doc/gdb.texinfo
    gdb/doc/gdbint.texinfo
    gdb/dwarf2cfi.c
    gdb/dwarf2read.c
    gdb/elfread.c
    gdb/eval.c
    gdb/event-top.c
    gdb/exec.c
    gdb/f-exp.y
    gdb/f-lang.c
    gdb/fbsd-proc.c
    gdb/findvar.c
    gdb/frame.c
    gdb/frame.h
    gdb/gcore.c
    gdb/gdb-events.c
    gdb/gdb-events.h
    gdb/gdb-events.sh
    gdb/gdbarch.c
    gdb/gdbarch.h
    gdb/gdbarch.sh
    gdb/gdbserver/Makefile.in
    gdb/gdbserver/config.in
    gdb/gdbserver/configure
    gdb/gdbserver/configure.in
    gdb/gdbserver/gdbreplay.c
    gdb/gdbserver/inferiors.c
    gdb/gdbserver/linux-arm-low.c
    gdb/gdbserver/linux-i386-low.c
    gdb/gdbserver/linux-ia64-low.c
    gdb/gdbserver/linux-low.c
    gdb/gdbserver/linux-low.h
    gdb/gdbserver/linux-m68k-low.c
    gdb/gdbserver/linux-mips-low.c
    gdb/gdbserver/linux-ppc-low.c
    gdb/gdbserver/linux-s390-low.c
    gdb/gdbserver/linux-sh-low.c
    gdb/gdbserver/linux-x86-64-low.c
    gdb/gdbserver/mem-break.c
    gdb/gdbserver/mem-break.h
    gdb/gdbserver/regcache.c
    gdb/gdbserver/regcache.h
    gdb/gdbserver/remote-utils.c
    gdb/gdbserver/server.c
    gdb/gdbserver/server.h
    gdb/gdbserver/target.c
    gdb/gdbserver/target.h
    gdb/gdbserver/utils.c
    gdb/gdbtypes.c
    gdb/gdbtypes.h
    gdb/gnu-nat.c
    gdb/gnu-v3-abi.c
    gdb/go32-nat.c
    gdb/gregset.h
    gdb/h8300-tdep.c
    gdb/h8500-tdep.c
    gdb/hppa-tdep.c
    gdb/hpread.c
    gdb/i386-linux-tdep.c
    gdb/i386-tdep.c
    gdb/i386gnu-nat.c
    gdb/i387-nat.c
    gdb/i960-tdep.c
    gdb/ia64-tdep.c
    gdb/infcmd.c
    gdb/inferior.h
    gdb/inflow.c
    gdb/infrun.c
    gdb/jv-exp.y
    gdb/kod.c
    gdb/language.c
    gdb/lin-lwp.c
    gdb/linespec.c
    gdb/linux-proc.c
    gdb/m2-exp.y
    gdb/m3-nat.c
    gdb/m68hc11-tdep.c
    gdb/m68klinux-nat.c
    gdb/maint.c
    gdb/mcore-tdep.c
    gdb/mdebugread.c
    gdb/mem-break.c
    gdb/mi/ChangeLog
    gdb/mi/mi-cmd-break.c
    gdb/mi/mi-cmd-disas.c
    gdb/mi/mi-cmd-stack.c
    gdb/mi/mi-cmd-var.c
    gdb/mi/mi-console.c
    gdb/mi/mi-main.c
    gdb/mi/mi-out.c
    gdb/mi/mi-parse.c
    gdb/minsyms.c
    gdb/mips-tdep.c
    gdb/mipsread.c
    gdb/mn10300-tdep.c
    gdb/monitor.c
    gdb/ocd.c
    gdb/p-exp.y
    gdb/p-lang.c
    gdb/p-lang.h
    gdb/p-typeprint.c
    gdb/p-valprint.c
    gdb/parse.c
    gdb/parser-defs.h
    gdb/ppc-bdm.c
    gdb/ppc-linux-nat.c
    gdb/ppc-linux-tdep.c
    gdb/ppc-tdep.h
    gdb/printcmd.c
    gdb/proc-api.c
    gdb/regcache.c
    gdb/regformats/reg-ppc.dat
    gdb/regformats/reg-x86-64.dat
    gdb/remote-array.c
    gdb/remote-e7000.c
    gdb/remote-es.c
    gdb/remote-mips.c
    gdb/remote-os9k.c
    gdb/remote-rdi.c
    gdb/remote-rdp.c
    gdb/remote-st.c
    gdb/remote-utils.c
    gdb/remote-vxsparc.c
    gdb/remote.c
    gdb/rs6000-nat.c
    gdb/rs6000-tdep.c
    gdb/s390-tdep.c
    gdb/scm-lang.c
    gdb/ser-unix.h
    gdb/serial.c
    gdb/sh-tdep.c
    gdb/solib-legacy.c
    gdb/solib-svr4.c
    gdb/solib.c
    gdb/somread.c
    gdb/source.c
    gdb/sparc-nat.c
    gdb/sparc-tdep.c
    gdb/stabsread.c
    gdb/stack.c
    gdb/std-regs.c
    gdb/symfile.c
    gdb/symfile.h
    gdb/symmisc.c
    gdb/symtab.c
    gdb/symtab.h
    gdb/target.c
    gdb/target.h
    gdb/testsuite/ChangeLog
    gdb/testsuite/config/sid.exp
    gdb/testsuite/gdb.asm/Makefile.in
    gdb/testsuite/gdb.asm/asm-source.exp
    gdb/testsuite/gdb.asm/configure
    gdb/testsuite/gdb.asm/configure.in
    gdb/testsuite/gdb.asm/powerpc.inc
    gdb/testsuite/gdb.asm/sparc64.inc
    gdb/testsuite/gdb.base/annota1.exp
    gdb/testsuite/gdb.base/attach.exp
    gdb/testsuite/gdb.base/bar.c
    gdb/testsuite/gdb.base/baz.c
    gdb/testsuite/gdb.base/completion.exp
    gdb/testsuite/gdb.base/cvexpr.c
    gdb/testsuite/gdb.base/dbx.exp
    gdb/testsuite/gdb.base/default.exp
    gdb/testsuite/gdb.base/dump.c
    gdb/testsuite/gdb.base/dump.exp
    gdb/testsuite/gdb.base/ending-run.exp
    gdb/testsuite/gdb.base/foo.c
    gdb/testsuite/gdb.base/funcargs.c
    gdb/testsuite/gdb.base/funcargs.exp
    gdb/testsuite/gdb.base/gcore.exp
    gdb/testsuite/gdb.base/grbx.c
    gdb/testsuite/gdb.base/help.exp
    gdb/testsuite/gdb.base/list.exp
    gdb/testsuite/gdb.base/long_long.exp
    gdb/testsuite/gdb.base/maint.exp
    gdb/testsuite/gdb.base/opaque.exp
    gdb/testsuite/gdb.base/overlays.exp
    gdb/testsuite/gdb.base/ovlymgr.c
    gdb/testsuite/gdb.base/printcmds.exp
    gdb/testsuite/gdb.base/ptype.exp
    gdb/testsuite/gdb.base/relocate.c
    gdb/testsuite/gdb.base/relocate.exp
    gdb/testsuite/gdb.base/scope.exp
    gdb/testsuite/gdb.base/shlib-call.exp
    gdb/testsuite/gdb.base/step-test.exp
    gdb/testsuite/gdb.base/watchpoint.exp
    gdb/testsuite/gdb.base/whatis.exp
    gdb/testsuite/gdb.c++/classes.exp
    gdb/testsuite/gdb.c++/cplusfuncs.exp
    gdb/testsuite/gdb.c++/hang.H
    gdb/testsuite/gdb.c++/hang.exp
    gdb/testsuite/gdb.c++/hang1.C
    gdb/testsuite/gdb.c++/hang2.C
    gdb/testsuite/gdb.c++/hang3.C
    gdb/testsuite/gdb.c++/local.cc
    gdb/testsuite/gdb.c++/local.exp
    gdb/testsuite/gdb.c++/method.exp
    gdb/testsuite/gdb.c++/misc.exp
    gdb/testsuite/gdb.c++/ovldbreak.exp
    gdb/testsuite/gdb.gdb/xfullpath.exp
    gdb/testsuite/gdb.java/jmisc1.exp
    gdb/testsuite/gdb.java/jmisc2.exp
    gdb/testsuite/gdb.mi/ChangeLog
    gdb/testsuite/gdb.mi/mi-var-cmd.exp
    gdb/testsuite/gdb.mi/mi0-var-cmd.exp
    gdb/testsuite/gdb.threads/linux-dp.exp
    gdb/testsuite/gdb.trace/gdb_c_test.c
    gdb/testsuite/lib/gdb.exp
    gdb/thread-db.c
    gdb/thread.c
    gdb/top.c
    gdb/top.h
    gdb/tracepoint.c
    gdb/tui/ChangeLog
    gdb/tui/tui-out.c
    gdb/ui-file.c
    gdb/ui-out.c
    gdb/utils.c
    gdb/valarith.c
    gdb/valops.c
    gdb/valprint.c
    gdb/value.h
    gdb/varobj.c
    gdb/vax-tdep.c
    gdb/vax-tdep.h
    gdb/version.in
    gdb/win32-nat.c
    gdb/x86-64-linux-nat.c
    gdb/x86-64-tdep.c
    gdb/x86-64-tdep.h
    gdb/xcoffread.c
    gdb/xstormy16-tdep.c
    gdb/z8k-tdep.c
    include/ChangeLog
    include/coff/ChangeLog
    include/coff/rs6k64.h
    include/dyn-string.h
    include/elf/ChangeLog
    include/elf/dwarf2.h
    include/floatformat.h
    include/opcode/ChangeLog
    include/opcode/i386.h
    include/opcode/mips.h
    include/opcode/pdp11.h
    include/xregex2.h
    libiberty/ChangeLog
    libiberty/Makefile.in
    libiberty/config.table
    libiberty/configure
    libiberty/configure.in
    libiberty/cp-demangle.c
    libiberty/dyn-string.c
    libiberty/floatformat.c
    libiberty/functions.texi
    libiberty/hashtab.c
    libiberty/hex.c
    libiberty/splay-tree.c
    libiberty/strtod.c
    libiberty/xatexit.c
    libiberty/xmalloc.c
    ltmain.sh
    mmalloc/ChangeLog
    mmalloc/mmap-sup.c
    opcodes/ChangeLog
    opcodes/Makefile.am
    opcodes/Makefile.in
    opcodes/configure
    opcodes/configure.in
    opcodes/dep-in.sed
    opcodes/i386-dis.c
    opcodes/mips-dis.c
    opcodes/mips-opc.c
    opcodes/pdp11-dis.c
    opcodes/pdp11-opc.c
    opcodes/po/fr.po
    opcodes/po/id.po
    opcodes/ppc-opc.c
    opcodes/s390-dis.c
    opcodes/z8k-dis.c
    opcodes/z8k-opc.h
    opcodes/z8kgen.c
    sim/ChangeLog
    sim/MAINTAINERS
    sim/arm/ChangeLog
    sim/arm/wrapper.c
    sim/common/ChangeLog
    sim/common/callback.c
    sim/igen/ChangeLog
    sim/igen/gen.c
    sim/igen/igen.c
    sim/m68hc11/ChangeLog
    sim/m68hc11/dv-m68hc11.c
    sim/m68hc11/dv-m68hc11spi.c
    sim/m68hc11/dv-m68hc11tim.c
    sim/m68hc11/interp.c
    sim/m68hc11/interrupts.c
    sim/m68hc11/interrupts.h
    sim/m68hc11/m68hc11_sim.c
    sim/m68hc11/sim-main.h
    sim/mips/ChangeLog
    sim/mips/Makefile.in
    sim/mips/configure
    sim/mips/configure.in
    sim/mips/cp1.c
    sim/mips/interp.c
    sim/mips/mips.igen
    sim/mips/sim-main.h
    sim/ppc/ChangeLog
    sim/ppc/hw_disk.c
    sim/ppc/ppc-instructions
    sim/ppc/sim_calls.c
    sim/z8k/ChangeLog
    sim/z8k/writecode.c
Delete:
    config/mh-irix4
    config/mh-lynxos
    config/mh-sun3
    config/mh-vaxult2
    config/mt-armpic
    config/mt-elfalphapic
    config/mt-i370pic
    config/mt-ia64pic
    config/mt-m68kpic
    config/mt-papic
    config/mt-ppcpic
    config/mt-s390pic
    config/mt-sparcpic
    config/mt-x86pic
    gdb/a29k-tdep.c
    gdb/config/a29k/a29k-udi.mt
    gdb/config/a29k/a29k.mt
    gdb/config/a29k/tm-a29k.h
    gdb/config/a29k/tm-vx29k.h
    gdb/config/a29k/vx29k.mt
    gdb/remote-adapt.c
    gdb/remote-eb.c
    gdb/remote-mm.c
    gdb/remote-udi.c
    gdb/signals.c
    gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.c
    gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.exp
    gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.c
    gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.exp
    gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.c
    gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.exp
diff --git a/ChangeLog b/ChangeLog
index 96154c0..3a200af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,495 @@
+2002-05-05  Alexandre Oliva  <aoliva@redhat.com>
+
+	* configure.in (noconfigdirs): Don't disable libgcj on
+	sparc64-*-solaris* and sparcv9-*-solaris*.
+
+2002-05-03  Alexandre Oliva  <aoliva@redhat.com>
+
+	* configure.in: Revert 2002-04-18's patch; fixed in libjava.
+
+2002-05-03  Thomas Fitzsimmons  <fitzsim@redhat.com>
+
+	* configure.in (FLAGS_FOR_TARGET): Do not add
+	-B$$r/$(TARGET_SUBDIR)/newlib/ when compiling newlib natively
+	on i[3456]86-*-linux*.
+
+2002-05-01  Thomas Fitzsimmons  <fitzsim@redhat.com>
+
+	* configure.in (noconfigdirs): Replace [ ] with test.
+
+	* configure.in (noconfigdirs): Do not add target-newlib if
+	target == i[3456]86-*-linux*, and host == target.
+
+2002-04-29  Mark Mitchell  <mark@codesourcery.com>
+
+	* config.guess: Updated to 2002-04-26's version.
+	* config.sub: Updated to 2002-04-26's version.
+
+2002-04-29  Nathanael Nerode  <neroden@doctormoo.dyndns.org>
+
+	* configure.in: delete reference to absent file
+
+	* configure.in: replace '[' with 'test'
+
+	* configure.in: Eliminate references to gash.
+	* Makefile.in: Eliminate references to gash.
+
+	* configure.in: remove useless references to 'pic' makefile fragments.
+
+	* configure.in: (*-*-windows*) Finish removing.
+
+	* configure.in: Eliminate redundant test for libgui.
+
+2002-04-26  Joel Sherrill  <joel@OARcorp.com>
+
+	* configure.in (h8300*-*-rtems*): Disable libf2c and libgcj.
+	(sparc-*-elf*, sparc64-*-elf*): Disable libgcj.
+
+2002-04-19  Nathanael Nerode  <neroden@twcny.rr.com>
+
+	* configure.in: remove references to dead files
+
+2002-04-18  Tom Tromey  <tromey@redhat.com>
+
+	* configure.in: Disallow configuring libgcj when it is already
+	installed and we're using Solaris 2.8 linker.  Do enable libgcj on
+	Solaris 2.8 by default.  For PR libgcj/6158.
+
+2002-04-17  Nathanael Nerode  <neroden@twcny.rr.com>
+
+	* configure.in:  Move default CC setting out of config/mh-* fragments
+	directly into here.
+
+2002-04-17  Nathanael Nerode  <neroden@twcny.rr.com>
+
+	* configure.in: don't even try to configure or make a subdirectory
+	if there's no configure script for it.
+
+2002-04-15  Mark Mitchell  <mark@codesourcery.com>
+
+	* MAINTAINERS: Remove chill maintainers.
+	* Makefile.in (CHILLFLAGS): Remove.
+	(CHILL_LIB): Remove.
+	(TARGET_CONFIGDIRS): Remove libchill.
+	(CHILL_FOR_TARGET): Remove.
+	(BASE_FLAGS_TO_PASS): Don't pass CHILLFLAGS, CHILL_FOR_TARGET, or
+	CHILL_LIB.
+	(CONFIGURE_TARGET_MODULES): Remove configure-target-libchill.
+	(CHECK_TARGET_MODULES): Likewise.
+	(INSTALL_TARGET_MODULES): Likewise.
+	(CLEAN_TARGET_MODULES): Likewise.
+	(configure-target-libchill): Remove.
+	(all-target-libchill): Remove.
+	* configure.in (target_libs): Remove target-libchill.
+	Do not compute CHILL_FOR_TARGET.
+	* libchill: Remove directory.
+	
+2002-04-15  DJ Delorie  <dj@redhat.com>
+
+	* Makefile.in, configure.in, configure: Sync with gcc, entries
+	follow...
+
+2002-04-08  Tom Tromey  <tromey@redhat.com>
+
+	* configure.in: Add FLAGS_FOR_TARGET to GCJ_FOR_TARGET.
+	Fixes PR libgcj/6068.
+
+2002-03-30  Krister Walfridsson  <cato@df.lth.se>
+
+	* configure.in (i*86-*-netbsdelf*): Don't disable libgcj.
+
+2002-03-27  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+	* configure.in (alpha*-dec-osf*): Enable libgcj.
+
+2002-03-24  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	Fix for: PR bootstrap/3591, target/5676
+	* configure.in (mcore-pe): Disable the configuration of
+	libstdc++-v3 since exceptions are not supported.
+
+2002-03-20  Anthony Green  <green@redhat.com>
+
+	* configure.in: Enable libgcj for xscale-elf target.
+
+2002-02-28  Alexandre Oliva  <aoliva@redhat.com>
+
+	* configure.in (libstdcxx_flags): Don't add libstdc++-v3 flags for
+	libjava.
+	(CXX_FOR_TARGET): Explain why -shared-libgcc here.
+
+2002-02-22  Alexandre Oliva  <aoliva@redhat.com>
+
+	* configure.in (CXX_FOR_TARGET): Add -shared-libgcc for
+	libstdc++-v3 and libjava.
+
+2002-02-11  Adam Megacz <adam@xwt.org>
+
+	* gcc/Makefile.in: Removed libstdc++-v3 dependancy for libjava and
+	boehm-gc
+
+2002-02-09  Alexandre Oliva  <aoliva@redhat.com>
+
+	* config.guess: Updated to 2002-01-30's version.
+	* config.sub: Updated to 2002-02-01's version.
+	Contribute sh64-elf.
+	2000-12-01  Alexandre Oliva  <aoliva@redhat.com>
+	* configure.in: Added sh64-*-*.
+
+2002-01-17  H.J. Lu <hjl@gnu.org>
+
+	* Makefile.in (all-fastjar): Also depend on all-libiberty.
+	(all-target-fastjar): Also depend on all-target-libiberty.
+
+Wed Dec  5 07:33:45 2001  Douglas B. Rupp  <rupp@gnat.com>
+
+	* configure, configure.in: Use temp file for long sed commands.
+
+2001-11-14  Hans-Peter Nilsson  <hp@bitrange.com>
+
+	* configure.in (noconfigdirs) [h8300*-*-*, h8500-*-*]: Disable
+	libf2c.
+
+2001-11-03  Hans-Peter Nilsson  <hp@bitrange.com>
+
+	* configure.in (noconfigdirs) [mmix-*-*]: Disable libgcj.
+
+2001-10-11  Hans-Peter Nilsson  <hp@axis.com>
+
+	* configure.in (noconfigdirs) [cris-*-*]: Disable libgcj.
+
+2001-10-02  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+	* configure: Handle temporary files securely using mkdir.
+
+2001-09-26  Will Cohen <wcohen@redhat.com>
+
+	* configure.in (*-*-linux*): Disable configuration of target-newlib
+	and target-libgloss.
+
+2001-09-26  Alexandre Oliva  <aoliva@redhat.com>
+
+	* Makefile.in (EXTRA_TARGET_FLAGS): Pass RANLIB_FOR_TARGET for
+	RANLIB.
+
+2001-08-11  Graham Stott  <grahams@redhat.com>
+
+	* Makefile.in (check-c++): Add missing semicolon.
+
+2001-07-25  Andrew Haley  <aph@cambridge.redhat.com>
+
+	* configure.in (sh-*-linux*): New.
+
+2001-07-12  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
+
+	* configure.in (noconfigdirs): Don't compile libiberty, libstdcxx
+	and libgcj on m68hc11/m68hc12.
+
+2001-06-27  H.J. Lu  (hjl@gnu.org)
+
+	* Makefile (CFLAGS_FOR_BUILD): New.
+	(EXTRA_GCC_FLAGS): Add CFLAGS_FOR_BUILD.
+
+2001-06-01  Hans-Peter Nilsson  <hp@axis.com>
+
+	* configure.in (libstdcxx_flags): Do not try to execute
+	libstdc++-v3/testsuite_flags until it exists.
+
+2001-05-18  Benjamin Kosnik  <bkoz@redhat.com>
+
+	* configure.in (libstdcxx_flags): Remove reference to libstdc++.INC.
+
+2001-05-09  Jeffrey Oldham  <oldham@codesourcery.com>
+
+	* ltcf-cxx.sh: Add -nostdlib to IRIX 6 archive_cmds.
+
+Mon Apr 23 09:15:03 2001  Anthony Green  <green@redhat.com>
+
+	* configure.in: Move *-chorusos target case to the proper switch.
+	Disable libgcj.
+
+2001-04-13  Franz Sirl  <Franz.Sirl-kernel@lauterbach.com>
+
+	* Makefile.in (STAGE1_CFLAGS): Pass down.
+
+2001-04-13  Alan Modra  <amodra@one.net.au>
+
+	* config.guess: Add hppa64-linux support.  Note for next import that
+	this is already in the master file.
+	* configure.in: Likewise.  Accept `parisc' alias for `hppa'.
+
+2001-03-22  Colin Howell  <chowell@redhat.com>
+
+	* Makefile.in (DO_X): Do not backslash single-quotes in
+	backquotes (two places).
+
+2001-03-18  Laurynas Biveinis  <lauras@softhome.net>
+
+	* Makefile.in (DO_X): Quote nested quotes.
+
+2001-03-15  Laurynas Biveinis  <lauras@softhome.net>
+
+	* Makefile.in (DO_X): Use double quotes for quoting
+	"RANLIB=$${RANLIB}".
+
+2001-03-09  Nicola Pero <n.pero@mi.flashnet.it>
+
+	* configure.in: Only use `lang_requires' for languages athat are
+	actually enabled.
+
+2001-03-07  Tom Tromey  <tromey@redhat.com>
+
+	* configure.in: Allow config-lang.in to set `lang_requires' to list
+	of other required languages.
+
+2001-03-06  Laurynas Biveinis  <lauras@softhome.net>
+
+	* Makefile.in: Remove RANLIB definition. Use RANLIB
+	in RANLIB_FOR_TARGET, EXTRA_HOST_FLAGS, EXTRA_TARGET_FLAGS,
+	EXTRA_GCC_FLAGS, $(DO_X) targets only when the RANLIB is set.
+
+2001-02-28  Benjamin Kosnik  <bkoz@redhat.com>
+	    Alexandre Oliva  <aoliva@redhat.com>
+
+	* Makefile.in (check-c++): Use tabs, not spaces.
+
+2001-02-19  Benjamin Kosnik  <bkoz@redhat.com>
+
+	* Makefile.in (check-c++): New rule.
+
+	* configure.in (target_libs): Remove libg++.
+	(noconfigdirs): Remove libg++.
+	(noconfigdirs): Same.
+	(noconfigdirs): Same.
+	(noconfigdirs): Same.
+
+	* config-ml.in: Remove libg++ references.
+
+	* Makefile.in (TARGET_CONFIGDIRS): Remove libio, libstdc++, libg++.
+	(ALL_TARGET_MODULES): Same.
+	(configure-target-libg++): Remove.
+	(all-target-libg++): Remove.
+	(configure-target-libio): Remove.
+	(all-target-libio): Remove.
+	(check-target-libio): Remove.
+	(.PHONY): Remove.
+	(libg++.tar.bz2): Remove.
+	(all-target-cygmon): Remove libio.
+	(all-target-libstdc++): Remove.
+	(configure-target-libstdc++): Remove.
+	(TARGET_LIB_PATH): Remove libstdc++.
+	(ALL_GCC_CXX): Remove libstdc++.
+	(all-target-gperf): Correct.
+
+2001-02-15  Anthony Green  <green@redhat.com>
+
+	* configure: Introduce GCJ_FOR_TARGET.
+	* configure.in: Ditto.
+	* Makefile.in: Ditto.
+
+2001-02-08  Chandrakala Chavva <cchavva@redhat.com>
+
+	* configure.in: for *-chorusos, don't config target-newlib and
+	target-libgloss.
+
+2001-02-04  Mark Mitchell  <mark@codesourcery.com>
+
+	Remove V2 C++ library.
+	* configure.in: Remove --enable-libstdcxx_v3 support.
+
+2001-01-27  Richard Henderson  <rth@redhat.com>
+
+	* configure.in (target_makefile_frag) [alpha*-*]: Use mt-alphaieee.
+
+2001-01-26  Tom Tromey  <tromey@redhat.com>
+
+	* configure.in: Allow libgcj to be built on Sparc Solaris.
+
+2001-01-23  Bryce McKinlay  <bryce@albatross.co.nz>
+
+	* configure.in: Enable libgcj on several additional platforms.
+
+2001-01-22  Bryce McKinlay  <bryce@albatross.co.nz>
+
+	* configure.in: Enable libgcj for linux targets.
+
+2001-01-09  Mike Stump  <mrs@wrs.com>
+
+	* Makefile.in (CONFIGURE_TARGET_MODULES): Pass back configuration
+	failures of subdirectories.
+
+2001-01-02  Laurynas Biveinis  <lauras@softhome.net>
+
+	* configure: handle DOS-style absolute paths.
+
+2001-01-02  Laurynas Biveinis  <lauras@softhome.net>
+
+	* configure.in: remove supported directories from $noconfigdirs for DJGPP.
+
+2000-12-18  Benjamin Kosnik  <bkoz@redhat.com>
+
+	* Makefile.in (BASE_FLAGS_TO_PASS): Alphabetize.
+	(libstdcxx_incdir): Pass down.
+	* config.if: Remove expired bits for cxx_interface, add stub.
+	(libstdcxx_incdir): Add variable for g++ include directory.
+	* configure.in (gxx_include_dir): Use it.
+
+2000-12-15  Andreas Jaeger  <aj@suse.de>
+
+	* configure.in: Handle lang_dirs.
+
+2000-12-13  Anthony Green  <green@redhat.com>
+
+	* configure.in: Disable libgcj for any target not specifically
+	listed.  Disable libgcj for x86 and Alpha Linux until compatible
+	with g++ abi.
+
+2000-12-13  Mike Stump  <mrs@wrs.com>
+
+	* Makefile.in (local-distclean): Also remove fastjar.
+
+2000-12-10  Anthony Green  <green@redhat.com>
+
+	* configure.in: Define libgcj.  Disable libgcj target libraries for
+	most targets.
+
+2000-12-09  Alexandre Petit-Bianco  <apbianco@cygnus.com>
+
+	* configure.in (target_libs): Revert 2000-12-08 patch.
+	(noconfigdirs): Added target-libjava.
+
+2000-12-09  Laurynas Biveinis  <lauras@softhome.net>
+
+	* Makefile.in: handle DOS-style absolute paths.
+
+2000-12-08  Alexandre Petit-Bianco  <apbianco@cygnus.com>
+
+	* Makefile.in (TARGET_CONFIGDIRS): Wrong place. Removed note about
+	libjava.
+	* configure.in (target_libs): Removed `target-libjava'.
+
+2000-12-08  Alexandre Petit-Bianco  <apbianco@cygnus.com>
+
+	* Makefile.in (TARGET_CONFIGDIRS): Added note about libjava.
+	(ALL_MODULES): Added fastjar.
+	(NATIVE_CHECK_MODULES, INSTALL_MODULES, CLEAN_MODULES): Likewise.
+	(all-target-libjava): all-fastjar replaces all-zip.
+	(all-fastjar): Added.
+	(configure-target-fastjar, all-target-fastjar): Likewise.
+	* configure.in (host_tools): Added fastjar.
+
+2000-12-07  Mike Stump  <mrs@wrs.com>
+
+	* Makefile.in (local-distclean): Remove leftover built files.
+
+2000-11-16  Fred Fish  <fnf@be.com>
+
+	* configure.in (enable_libstdcxx_v3): Fix typo,
+	libstd++ -> libstdc++.
+
+2000-11-13  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+	* configure: Provide the original toplevel configure arguments
+	(including $0) to subprocesses in the environment rather than
+	through gcc/configargs.h.
+
+2000-11-12  Mark Mitchell  <mark@codesourcery.com>
+
+	* configure: Turn on libstdc++ V3 by default.
+
+2000-10-16  Michael Meissner  <meissner@redhat.com>
+
+	* configure (gcc/configargs.h): Only create if there is a build GCC
+	directory created.
+
+2000-10-05  Phil Edwards  <pme@gcc.gnu.org>
+
+	* configure: Save configure arguments to gcc/configargs.h.
+
+2000-10-04  Andris Pavenis  <pavenis@latnet.lv>
+
+	* Makefile.in (bootstrap): avoid recursion if subdir missing
+	(cross): ditto
+	(do-proto-toplev): ditto
+
+Wed Sep 13 11:11:29 2000  Jeffrey A Law  (law@cygnus.com)
+
+	* configure.in: Do not build byacc for hppa64.  Provide paths to the
+	X11 libraries for hppa64.
+
+2000-09-02  Anthony Green  <green@cygnus.com>
+
+	* Makefile.in (all-gcc): Depend on all-zlib.
+	(CLEAN_MODULES): Add clean-zlib.
+	(ALL_MODULES): Add all-zlib.
+	* configure.in (host_libs): Add zlib.
+
+2000-08-25  Alexandre Oliva  <aoliva@redhat.com>
+
+	* configure.in (FLAGS_FOR_TARGET): Use $target_configdirs and
+	$targargs to tell whether newlib is going to be built.
+
+	* configure.in [disable-libstdcxx-v3] (libstdcxx_flags): Search
+	$$r/TARGET_SUBDIR/libio for _G_config.h.
+
+2000-08-14  Zack Weinberg  <zack@wolery.cumb.org>
+
+	* configure.in (libstdcxx_flags): Remove -isystem $$s/libio/stdio.
+
+	* configure: Make enable_threads and enable_shared defaults
+	explicit.  Substitute enable_threads into generated Makefiles.
+	* configure.in: Accept *-*-linux* not just *-*-linux-gnu*.
+	* libtool.m4: Accept *-*-linux* not just *-*-linux-gnu*.
+
+2000-08-02  Manfred Hollstein  <manfredh@redhat.com>
+
+	* configure.in: Re-enable all references to libg++ and librx.
+
+2002-04-09  Loren James Rittle  <rittle@labs.mot.com>
+	
+	* configure.in: Add *-*-freebsd* configurations.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* Makefile.in (do-tar-bz2): Delete rule.  Replace with ...
+	(do-tar, do-bz2): New rules.
+	(taz): Update.  Replace do-tar-bz2 with do-tar and do-bz2.
+	(gdb-tar): New rule.
+	(gdb-taz): Rewrite.  Use gdb-tar and do-bz2.
+	(insight_dejagnu.tar): New rule.
+	(insight.tar): New rule.
+	(gdb+dejagnu.tar): New rule.
+	(gdb.tar): New rule.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* MAINTAINERS: Update dejagnu/
+
+2002-03-16  Alexandre Oliva  <aoliva@redhat.com>
+
+	* ltmain.sh (relink_command): Fix typo in previous change.
+
+2002-03-15  Alexandre Oliva  <aoliva@redhat.com>
+
+	* ltmain.sh (taglist): Initialized.  Don't let `CC' tag out of it.
+	(relink_command): Added --tag flags.
+	(mode=install): If relinking fails; error out.
+
+2002-03-12  Richard Henderson  <rth@redhat.com>
+
+	* Makefile.in (NOTPARALLEL): New.  Use it instead of explicit
+	.NOTPARALLEL tag.
+	(do-check): Rename from check.
+	(check): Allow parallel check.
+
+2002-03-11  Richard Henderson  <rth@redhat.com>
+
+	* Makefile.in (.NOTPARALLEL): Add fake tag.
+
+2002-03-07  H.J. Lu  (hjl@gnu.org)
+
+	* configure.in: Enable gprof for mips*-*-linux*.
+
 2002-02-28  Alexandre Oliva  <aoliva@redhat.com>
 
 	* configure.in (libstdcxx_flags): Don't add libstdc++-v3 flags for
@@ -26,8 +518,8 @@
 
 2002-02-04  Jeff Johnston  <jjohnstn@redhat.com>
 
-        * COPYING.NEWLIB: Remove advertising clause from
-        Berkeley and Red Hat licenses.
+	* COPYING.NEWLIB: Remove advertising clause from
+	Berkeley and Red Hat licenses.
 
 2002-02-01  Mo DeJong  <supermo@bayarea.net>
 
@@ -103,7 +595,7 @@
 2001-12-05  Laurent Guerby  <guerby@acm.org>
 
 	* MAINTAINERS: gcc adopts symlink-tree, refer more to
-        libiberty.
+	libiberty.
 
 	Import this patch from gcc:
 	
@@ -169,7 +661,7 @@
 
 2001-11-12  Hans-Peter Nilsson  <hp@bitrange.com>
 
-        * COPYING.NEWLIB: Add BSD-style license/copyright blurb for my work.
+	* COPYING.NEWLIB: Add BSD-style license/copyright blurb for my work.
 
 2001-11-08  Phil Edwards  <pedwards@disaster.jaj.com>
 
@@ -457,7 +949,7 @@
 
 2001-01-07  Andreas Jaeger  <aj@suse.de>
 
-        * config.sub, config.guess: Update from subversions.
+	* config.sub, config.guess: Update from subversions.
 
 2000-12-12  Alexandre Oliva  <aoliva@redhat.com>
 
@@ -501,8 +993,8 @@
 
 2000-10-30  Stephane Carrez  <stcarrez@worldnet.fr>
 
-        * configure.in (noconfigdirs): Don't compile some
-        of the libraries for 68HC11 & 68hc12 targets.
+	* configure.in (noconfigdirs): Don't compile some
+	of the libraries for 68HC11 & 68hc12 targets.
 
 2000-09-30  Alexandre Oliva  <aoliva@redhat.com>
 
@@ -665,7 +1157,7 @@
 
 2000-07-01  Koundinya K  <kk@ddeorg.soft.net>
 
-        * ltconfig: Add support for mips-dde-sysv4.2MP
+	* ltconfig: Add support for mips-dde-sysv4.2MP
 
 2000-06-28  Corinna Vinschen  <vinschen@cygnus.com>
 
@@ -693,12 +1185,12 @@
 
 20000-05-21  H.J. Lu  (hjl@gnu.org)
 
-        * Makefile.in (CC_FOR_TARGET): Make sure as/ld in the gcc
-        directory are used if they exist. Make sure
-        $(build_tooldir)/include is searched for header files,
-        $(build_tooldir)/lib/ for library files.
+	* Makefile.in (CC_FOR_TARGET): Make sure as/ld in the gcc
+	directory are used if they exist. Make sure
+	$(build_tooldir)/include is searched for header files,
+	$(build_tooldir)/lib/ for library files.
 	(GCC_FOR_TARGET): Likewise.
-        (CXX_FOR_TARGET): Likewise.
+	(CXX_FOR_TARGET): Likewise.
 
 2000-05-18  Jeffrey A Law  (law@cygnus.com)
 
@@ -746,7 +1238,7 @@
 2000-05-08  Eli Zaretskii  <eliz@is.elta.co.il>
 
 	* djunpack.bat: Change the Sed script to replace @V@ in fnchange.lst
-        with the version name.
+	with the version name.
 
 2000-05-01  Benjamin Kosnik  <bkoz@cygnus.com>
 
@@ -765,8 +1257,8 @@
 
 2000-04-16  Dave Pitts  <dpitts@cozx.com>
 
-        * config.sub (case $basic_machine): Change default for "ibm-*"
-        to "openedition".
+	* config.sub (case $basic_machine): Change default for "ibm-*"
+	to "openedition".
 
 2000-04-12  Andrew Cagney  <cagney@b1.cygnus.com>
 
@@ -787,13 +1279,13 @@
 	* configure (warn_cflags): Delete.
 
 2000-04-05  Benjamin Kosnik  <bkoz@cygnus.com>
-            Martin v. Loewis  <martin@loewis.home.cs.tu-berlin.de>
+	    Martin v. Loewis  <martin@loewis.home.cs.tu-berlin.de>
 
-        * configure.in (enable_libstdcxx_v3): Add.
-        (target_libs): Add bits here to switch between libstdc++-v2 and
-        libstdc++-v3.
-        * config.if: And this file too.
-        * Makefile.in: Add libstdc++-v3 targets.
+	* configure.in (enable_libstdcxx_v3): Add.
+	(target_libs): Add bits here to switch between libstdc++-v2 and
+	libstdc++-v3.
+	* config.if: And this file too.
+	* Makefile.in: Add libstdc++-v3 targets.
 
 2000-04-05  Michael Meissner  <meissner@redhat.com>
 
@@ -974,15 +1466,15 @@
 	(configure-target-boehm-gc): New target.
 	(configure-target-qthreads): New target.
 
-        * configure.in (target_libs): Added target-qthreads.
-        * Makefile.in (ALL_TARGET_MODULES): Added qthreads.
-        (CONFIGURE_TARGET_MODULES): Likewise.
-        (CHECK_TARGET_MODULES): Likewise.
-        (INSTALL_TARGET_MODULES): Likewise.
-        (CLEAN_TARGET_MODULES): Likewise.
-        (all-target-qthreads): New target.
-        (configure-target-libjava): Depend on configure-target-qthreads.
-        (all-target-libjava): Depend on all-target-qthreads.
+	* configure.in (target_libs): Added target-qthreads.
+	* Makefile.in (ALL_TARGET_MODULES): Added qthreads.
+	(CONFIGURE_TARGET_MODULES): Likewise.
+	(CHECK_TARGET_MODULES): Likewise.
+	(INSTALL_TARGET_MODULES): Likewise.
+	(CLEAN_TARGET_MODULES): Likewise.
+	(all-target-qthreads): New target.
+	(configure-target-libjava): Depend on configure-target-qthreads.
+	(all-target-libjava): Depend on all-target-qthreads.
 
 	* Makefile.in (ALL_TARGET_MODULES): Added libjava, boehm-gc.
 	(CONFIGURE_TARGET_MODULES): Likewise.
@@ -1070,7 +1562,7 @@
 	Bad merge removed these two changes.
 
 Tue Apr 13 22:50:54 1999  Donn Terry (donn@interix.com)
-                          Martin Heller (Ing.-Buero_Heller@t-online.de)
+	                  Martin Heller (Ing.-Buero_Heller@t-online.de)
 
 	* config.guess (interix Alpha): Add.
 
@@ -1127,7 +1619,7 @@
 
 1999-03-21  Ben Elliston  <bje@cygnus.com>
 
-        * config.guess: Correct typo for detecting ELF on FreeBSD.
+	* config.guess: Correct typo for detecting ELF on FreeBSD.
 
 Thu Mar 18 00:17:50 1999  Mark Elbrecht <snowball3@usa.net>
 
@@ -1237,8 +1729,8 @@
 
 1999-02-02  Catherine Moore  <clm@cygnus.com>
 
-        * config.sub (oabi):  Recognize.
-        * configure.in (arm-*-oabi):  Handle.
+	* config.sub (oabi):  Recognize.
+	* configure.in (arm-*-oabi):  Handle.
 
 1999-01-30  Robert Lipe  (robertlipe@usa.net)
 
@@ -1326,8 +1818,8 @@
 
 1998-11-17  Geoffrey Noer  <noer@cygnus.com>
 
-        * Makefile.in: modify CC_FOR_TARGET and CXX_FOR_TARGET so that
-        they include winsup/include when it's a cygwin target.
+	* Makefile.in: modify CC_FOR_TARGET and CXX_FOR_TARGET so that
+	they include winsup/include when it's a cygwin target.
 
 1998-11-12  Tom Tromey  <tromey@cygnus.com>
 
@@ -1353,7 +1845,7 @@
 
 1998-11-02  Geoffrey Noer  <noer@cygnus.com>
 
-        * configure.in: drop "32" from config/mh-cygwin32.  Check
+	* configure.in: drop "32" from config/mh-cygwin32.  Check
 	cygwin* instead of cygwin32*.
 	* config.sub: Check cygwin* instead of cygwin32*.
 
@@ -1950,7 +2442,7 @@
 
 Mon Feb 23 15:09:18 1998  Bruno Haible <bruno@linuix.mathematik.uni-karlsruhe.de
 
-        * config.sub (sco5): Fix typo.
+	* config.sub (sco5): Fix typo.
 
 Mon Feb 23 14:46:06 1998  Ian Lance Taylor  <ian@cygnus.com>
 
@@ -2262,10 +2754,10 @@
 
 Fri Nov  7 10:34:09 1997  Rob Savoye  <rob@darkstar.cygnus.com>
 
-        * include/libiberty.h: Add extern "C" { so it can be used with C++
-        progrms.
-        * include/remote-sim.h:  Add extern "C" { so it can be used with C++
-        programs.
+	* include/libiberty.h: Add extern "C" { so it can be used with C++
+	progrms.
+	* include/remote-sim.h:  Add extern "C" { so it can be used with C++
+	programs.
 
 Thu Oct 30 11:09:29 1997  Michael Meissner  <meissner@cygnus.com>
 
@@ -2389,7 +2881,7 @@
 
 Fri Sep  5 16:11:28 1997  Joel Sherrill  (joel@OARcorp.com)
 
-        * configure.in (*-*-rtems*): Do not build libgloss for rtems.
+	* configure.in (*-*-rtems*): Do not build libgloss for rtems.
 
 Fri Sep  5 12:27:17 1997  Jeffrey A Law  (law@cygnus.com)
 
@@ -2457,7 +2949,7 @@
 
 	* configure: When handling a Canadian Cross, handle YACC as well as
 	BISON.  Just set BISON to bison.  When setting YACC, prefer bison.
-        * Makefile.in (all-bison): Depend upon all-texinfo.
+	* Makefile.in (all-bison): Depend upon all-texinfo.
 
 Tue Aug 12 20:09:48 1997  Jason Merrill  <jason@yorick.cygnus.com>
 
@@ -2790,7 +3282,7 @@
 
 Mon Mar 31 16:26:55 1997  Joel Sherrill  <joel@oarcorp.com>
 
-        * configure.in (hppa1.1-*-rtems*): New target, like hppa-*-*elf*.
+	* configure.in (hppa1.1-*-rtems*): New target, like hppa-*-*elf*.
 
 Sun Mar 30 12:38:27 1997  Fred Fish  <fnf@cygnus.com>
 
@@ -3142,11 +3634,11 @@
 	* config.guess:  Merge from FSF.
 
 	1996-09-12  Richard Stallman  <rms@ethanol.gnu.ai.mit.edu>
-        * config.guess: Use pc instead of unknown, for pc clone systems.
-        Change linux to linux-gnu.
+	* config.guess: Use pc instead of unknown, for pc clone systems.
+	Change linux to linux-gnu.
 
 	Mon Jul 15 23:51:11 1996  Karl Heuer  <kwzh@gnu.ai.mit.edu>
-        * config.guess: Avoid non-portable tr syntax.
+	* config.guess: Avoid non-portable tr syntax.
 
 Wed Oct  9 06:06:46 1996  Jeffrey A Law  (law@cygnus.com)
 
@@ -3420,9 +3912,9 @@
 
 Sun Jun 23 22:41:54 1996  Geoffrey Noer  <noer@cygnus.com>
 
-        * configure.in: enable dosrel for cygwin32-hosted builds,
-                remove diff from the list of things not buildable
-                via Canadian Cross
+	* configure.in: enable dosrel for cygwin32-hosted builds,
+	        remove diff from the list of things not buildable
+	        via Canadian Cross
 
 Sat Jun 22 11:39:01 1996  Jason Merrill  <jason@yorick.cygnus.com>
 
@@ -3624,8 +4116,8 @@
 
 Tue Mar 26 21:18:50 1996  Andrew Cagney  <cagney@kremvax.highland.com.au>
 
-        * configure (--enable-*): Handle quoted option lists such as
-        --enable-sim-cflags='-g0 -O' better.
+	* configure (--enable-*): Handle quoted option lists such as
+	--enable-sim-cflags='-g0 -O' better.
 
 Thu Mar 21 11:53:08 1996  Michael Meissner  <meissner@tiktok.cygnus.com>
 
@@ -4626,7 +5118,7 @@
 Wed Apr 12 16:06:01 1995  Jason Merrill  <jason@phydeaux.cygnus.com>
 
 	* test-build.mk: Enable building of shared libraries on IRIX 5 and
-        OSF/1.  Fix compiler flags.
+	OSF/1.  Fix compiler flags.
 	* build-all.mk: Support Linux and OSF/1 3.0.  Fix compiler flags.
 
 Tue Apr 11 18:55:40 1995  Doug Evans  <dje@canuck.cygnus.com>
@@ -5060,21 +5552,21 @@
 	Thu Aug 25 20:28:51 1994  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
 	* config.guess (Pyramid*:OSx*:*:*): New case.
-        (PATH): Add /.attbin at end for finding uname.
-        (dummy.c): Handle i860-alliant-bsd.  Follow whitespace conventions.
+	(PATH): Add /.attbin at end for finding uname.
+	(dummy.c): Handle i860-alliant-bsd.  Follow whitespace conventions.
 
 	Wed Aug 17 18:21:02 1994  Tor Egge  (tegge@pvv.unit.no)
 
-        * config.guess (M88*:DolphinOS:*:*): New case.
+	* config.guess (M88*:DolphinOS:*:*): New case.
 
 	Thu Aug 11 17:00:13 1994  Stan Cox  (coxs@dg-rtp.dg.com)
 
-        * config.guess (AViiON:dgux:*:*): Use TARGET_BINARY_INTERFACE
-        to select whether to use ELF or COFF.
+	* config.guess (AViiON:dgux:*:*): Use TARGET_BINARY_INTERFACE
+	to select whether to use ELF or COFF.
 
 	Sun Jul 24 16:20:53 1994  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
-        * config.guess: Recognize i860-stardent-sysv and i860-unknown-sysv.
+	* config.guess: Recognize i860-stardent-sysv and i860-unknown-sysv.
 
 	Sun May  1 10:23:10 1994  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
@@ -5413,7 +5905,7 @@
 Wed Apr 13 15:14:52 1994  Bill Cox  (bill@cygnus.com)
 
 	* configure: Make file links cleanly even if Lynx fails on
-          an NFS symlink (at least fail cleanly).
+	  an NFS symlink (at least fail cleanly).
 
 Mon Apr 11 10:58:56 1994  Jim Wilson  (wilson@sphagnum.cygnus.com)
 
@@ -5566,7 +6058,7 @@
 
 Wed Feb  2 13:57:57 1994  Jeffrey A. Law  (law@snake.cs.utah.edu)
 
-        * Makefile.in:  Avoid bug in losing hpux sed.
+	* Makefile.in:  Avoid bug in losing hpux sed.
 
 Wed Feb  2 14:53:05 1994  Jim Kingdon  (kingdon@lioth.cygnus.com)
 
@@ -7001,8 +7493,8 @@
 	ranlib.
 
 	* configure: also define $(host_canonical) and
-        $(target_canonical), which are the full, canonical names for the
-        given host and target
+	$(target_canonical), which are the full, canonical names for the
+	given host and target
 
 Sun Nov  1 16:38:17 1992  Per Bothner  (bothner@cygnus.com)
 
@@ -7150,7 +7642,7 @@
 
 Tue Aug 11 23:13:17 1992  david d `zoo' zuhn  (zoo at cirdan.cygnus.com)
 
-        * COPYING: new file, GPL v2
+	* COPYING: new file, GPL v2
 
 Tue Aug  4 01:12:43 1992  david d `zoo' zuhn  (zoo at cirdan.cygnus.com)
 
diff --git a/MAINTAINERS b/MAINTAINERS
index 75f3240..104b815 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -33,9 +33,12 @@
 		gdb-patches@sources.redhat.com
 
 dejagnu/
-	Notify http://dejagnu.sourceforge.net/ of generic changes.
-	Generic patches to gdb-patches@sources.redhat.com;
-	Other dependents of dejagnu include sid@, binutils@, gcc@, etc.
+	Send all patches to:
+	http://www.gnu.org/software/dejagnu/
+	mail:bug-dejagnu@gnu.org
+	For changes to the local repostory, send them to
+	gdb-patches@sources.redhat.com when generic; and sid@,
+	binutils@, gcc@, etc. for sub-components.
 
 gdb/; mmalloc/; readline/; sim/; GDB's part of include/ & dejagnu/
 	gdb: http://sources.redhat.com/gdb/
diff --git a/Makefile.in b/Makefile.in
index 7bf5b5a..70bf102 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -18,6 +18,12 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 
+# Tell GNU make 3.79 not to run the top level in parallel.  This 
+# prevents contention for $builddir/$target/config.cache, as well
+# as minimizing scatter in file system caches.
+NOTPARALLEL = .NOTPARALLEL
+$(NOTPARALLEL):
+
 srcdir = .
 
 prefix = /usr/local
@@ -87,14 +93,13 @@
 
 LDFLAGS = 
 LIBCFLAGS = $(CFLAGS)
+CFLAGS_FOR_BUILD = $(CFLAGS)
 CFLAGS_FOR_TARGET = $(CFLAGS)
 LDFLAGS_FOR_TARGET = 
 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
 PICFLAG = 
 PICFLAG_FOR_TARGET = 
 
-CHILLFLAGS = $(CFLAGS)
-CHILL_LIB = -lchill
 CXX = c++
 
 # Use -O2 to stress test the compiler.
@@ -102,8 +107,6 @@
 CXXFLAGS_FOR_TARGET = $(CXXFLAGS)
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
 
-RANLIB = ranlib
-
 DLLTOOL = dlltool
 WINDRES = windres
 
@@ -173,7 +176,7 @@
 
 # This is set by the configure script to the list of directories which
 # should be built using the target tools.
-TARGET_CONFIGDIRS = libiberty libgloss $(SPECIAL_LIBS) newlib libio librx libstdc++ libg++ winsup opcodes bsp libstub cygmon libf2c libchill libobjc
+TARGET_CONFIGDIRS = libiberty libgloss $(SPECIAL_LIBS) newlib librx winsup opcodes bsp libstub cygmon libf2c libobjc
 
 # Target libraries are put under this directory:
 # Changed by configure to $(target_alias) if cross.
@@ -204,7 +207,7 @@
 
 # This is the list of directories that may be needed in RPATH_ENVVAR
 # so that prorgams built for the target machine work.
-TARGET_LIB_PATH = $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs:$$r/$(TARGET_SUBDIR)/libstdc++
+TARGET_LIB_PATH = $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs:
 
 # configure.in sets SET_LIB_PATH to this if --enable-shared was used.
 # Some platforms don't like blank entries, so we remove duplicate,
@@ -230,9 +233,9 @@
 # Should be substed by configure.in
 FLAGS_FOR_TARGET =
 CC_FOR_TARGET =
-CHILL_FOR_TARGET =
 CXX_FOR_TARGET =
 CXX_FOR_TARGET_FOR_RECURSIVE_MAKE =
+GCJ_FOR_TARGET =
 
 # If GCC_FOR_TARGET is not overriden on the command line, then this
 # variable is passed down to the gcc Makefile, where it is used to
@@ -353,9 +356,7 @@
 	"CC_FOR_TARGET=$(CC_FOR_TARGET)" \
 	"CFLAGS=$(CFLAGS)" \
 	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
-	"CHILLFLAGS=$(CHILLFLAGS)" \
-	"CHILL_FOR_TARGET=$(CHILL_FOR_TARGET)" \
-	"CHILL_LIB=$(CHILL_LIB)" \
+	"GCJ_FOR_TARGET=$(GCJ_FOR_TARGET)" \
 	"CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
 	"CXXFLAGS=$(CXXFLAGS)" \
 	"CXXFLAGS_FOR_TARGET=$(CXXFLAGS_FOR_TARGET)" \
@@ -393,6 +394,8 @@
 	"libdir=$(libdir)" \
 	"libexecdir=$(libexecdir)" \
 	"lispdir=$(lispdir)" \
+	"libstdcxx_incdir=$(libstdcxx_incdir)" \
+	"libsubdir=$(libsubdir)" \
 	"localstatedir=$(localstatedir)" \
 	"mandir=$(mandir)" \
 	"oldincludedir=$(oldincludedir)" \
@@ -405,8 +408,7 @@
 	"gxx_include_dir=$(gxx_include_dir)" \
 	"gcc_version=$(gcc_version)" \
 	"gcc_version_trigger=$(gcc_version_trigger)" \
-	"target_alias=$(target_alias)" \
-	"libsubdir=$(libsubdir)"
+	"target_alias=$(target_alias)" 
 
 # For any flags above that may contain shell code that varies from one
 # target library to another.  When doing recursive invocations of the
@@ -427,7 +429,7 @@
 	'DLLTOOL=$(DLLTOOL)' \
 	'LD=$(LD)' \
 	'NM=$(NM)' \
-	'RANLIB=$(RANLIB)' \
+	"`echo 'RANLIB=$(RANLIB)' | sed -e s/.*=$$/XFOO=/`" \
 	'WINDRES=$(WINDRES)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
@@ -481,9 +483,10 @@
 	'HOST_PREFIX=$(HOST_PREFIX)' \
 	'HOST_PREFIX_1=$(HOST_PREFIX_1)' \
 	'NM=$(NM)' \
-	'RANLIB=$(RANLIB)' \
+	"`echo 'RANLIB=$(RANLIB)' | sed -e s/.*=$$/XFOO=/`" \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
 	"GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
+	"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
 	"`echo 'LANGUAGES=$(LANGUAGES)' | sed -e s/.*=$$/XFOO=/`" \
 	"`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s/.*=$$/XFOO=/`" \
 	"`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s/.*=$$/XFOO=/`" \
@@ -492,6 +495,7 @@
 	"`echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)' | sed -e s/.*=$$/XFOO=/`" \
 	"`echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)' | sed -e s/.*=$$/XFOO=/`" \
 	"`echo 'ENQUIRE=$(ENQUIRE)' | sed -e s/.*=$$/XFOO=/`" \
+	"`echo 'STAGE1_CFLAGS=$(STAGE1_CFLAGS)' | sed -e s/.*=$$/XFOO=/`" \
 	"`echo 'BOOT_CFLAGS=$(BOOT_CFLAGS)' | sed -e s/.*=$$/XFOO=/`"
 
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS)
@@ -528,6 +532,7 @@
 	all-diff \
 	all-dosutils \
 	all-etc \
+	all-fastjar \
 	all-fileutils \
 	all-findutils \
 	all-find \
@@ -589,6 +594,7 @@
 NATIVE_CHECK_MODULES = \
 	check-bison \
 	check-byacc \
+	check-fastjar \
 	check-flex \
 	check-zip
 
@@ -681,6 +687,7 @@
 	install-diff \
 	install-dosutils \
 	install-etc \
+	install-fastjar \
 	install-fileutils \
 	install-findutils \
 	install-find \
@@ -736,7 +743,6 @@
 	all-emacs19 \
 	all-gdb \
 	all-expect \
-	all-gash \
 	all-guile \
 	all-tclX \
 	all-tk \
@@ -750,7 +756,6 @@
 	check-gdb \
 	check-guile \
 	check-expect \
-	check-gash \
 	check-tclX \
 	check-tk \
 	check-tix
@@ -763,7 +768,6 @@
 	install-gdb \
 	install-guile \
 	install-expect \
-	install-gash \
 	install-tclX \
 	install-tk \
 	install-tk8.1 \
@@ -772,14 +776,10 @@
 # This is a list of the targets for all of the modules which are compiled
 # using $(TARGET_FLAGS_TO_PASS).
 ALL_TARGET_MODULES = \
-	all-target-libio \
-	all-target-libstdc++ \
 	all-target-libstdc++-v3 \
 	all-target-librx \
-	all-target-libg++ \
 	all-target-newlib \
 	all-target-libf2c \
-	all-target-libchill \
 	all-target-libobjc \
 	all-target-libtermcap \
 	all-target-winsup \
@@ -799,14 +799,10 @@
 # This is a list of the configure targets for all of the modules which
 # are compiled using the target tools.
 CONFIGURE_TARGET_MODULES = \
-	configure-target-libio \
-	configure-target-libstdc++ \
 	configure-target-libstdc++-v3 \
 	configure-target-librx \
-	configure-target-libg++ \
 	configure-target-newlib \
 	configure-target-libf2c \
-	configure-target-libchill \
 	configure-target-libobjc \
 	configure-target-libtermcap \
 	configure-target-winsup \
@@ -826,13 +822,9 @@
 # This is a list of the check targets for all of the modules which are
 # compiled using $(TARGET_FLAGS_TO_PASS).
 CHECK_TARGET_MODULES = \
-	check-target-libio \
-	check-target-libstdc++ \
 	check-target-libstdc++-v3 \
-	check-target-libg++ \
 	check-target-newlib \
 	check-target-libf2c \
-	check-target-libchill \
 	check-target-libobjc \
 	check-target-winsup \
 	check-target-libiberty \
@@ -846,13 +838,9 @@
 # This is a list of the install targets for all of the modules which are
 # compiled using $(TARGET_FLAGS_TO_PASS).
 INSTALL_TARGET_MODULES = \
-	install-target-libio \
-	install-target-libstdc++ \
 	install-target-libstdc++-v3 \
-	install-target-libg++ \
 	install-target-newlib \
 	install-target-libf2c \
-	install-target-libchill \
 	install-target-libobjc \
 	install-target-libtermcap \
 	install-target-winsup \
@@ -884,6 +872,7 @@
 	clean-diff \
 	clean-dosutils \
 	clean-etc \
+	clean-fastjar \
 	clean-fileutils \
 	clean-findutils \
 	clean-find \
@@ -936,14 +925,10 @@
 
 # All of the target modules that can be cleaned
 CLEAN_TARGET_MODULES = \
-	clean-target-libio \
-	clean-target-libstdc++ \
 	clean-target-libstdc++-v3 \
 	clean-target-librx \
-	clean-target-libg++ \
 	clean-target-newlib \
 	clean-target-libf2c \
-	clean-target-libchill \
 	clean-target-libobjc \
 	clean-target-winsup \
 	clean-target-libgloss \
@@ -965,7 +950,6 @@
 	clean-emacs19 \
 	clean-gdb \
 	clean-expect \
-	clean-gash \
 	clean-guile \
 	clean-tclX \
 	clean-tk \
@@ -1020,7 +1004,7 @@
 	    if (cd ./$$i; \
 	        $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 			"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
-			"RANLIB=$${RANLIB}" \
+	                "`echo \"RANLIB=$${RANLIB}\" | sed -e 's/.*=$$/XFOO=/'`" \
 			"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
 			$${target}); \
 	    then true; else exit 1; fi; \
@@ -1038,7 +1022,7 @@
 	    if (cd $(TARGET_SUBDIR)/$$i; \
 	        $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 			"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
-			"RANLIB=$${RANLIB}" \
+	                "`echo \"RANLIB=$${RANLIB}\" | sed -e 's/.*=$$/XFOO=/'`" \
 			"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
 			$${target}); \
 	    then true; else exit 1; fi; \
@@ -1071,6 +1055,11 @@
 	-if [ "$(TARGET_SUBDIR)" != "." ]; then \
 	  rm -rf $(TARGET_SUBDIR); \
 	else true; fi
+	-rm -f texinfo/po/Makefile texinfo/po/Makefile.in texinfo/info/Makefile
+	-rm -f texinfo/doc/Makefile texinfo/po/POTFILES
+	-rmdir texinfo/doc texinfo/info texinfo/intl texinfo/lib 2>/dev/null
+	-rmdir texinfo/makeinfo texinfo/po texinfo/util 2>/dev/null
+	-rmdir fastjar gcc libiberty texinfo zlib 2>/dev/null
 
 local-maintainer-clean:
 	@echo "This command is intended for maintainers to use;"
@@ -1118,8 +1107,11 @@
 
 # Check target.
 
-.PHONY: check
-check: $(CHECK_MODULES) \
+.PHONY: check do-check
+check:
+	$(MAKE) do-check NOTPARALLEL=parallel-ok
+
+do-check: $(CHECK_MODULES) \
 	$(CHECK_TARGET_MODULES) \
 	$(CHECK_X11_MODULES) \
 	check-gcc
@@ -1416,6 +1408,7 @@
 	    CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
 	    CXX="$(CXX_FOR_TARGET)"; export CXX; \
 	    CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	    GCJ="$(GCJ_FOR_TARGET)"; export GCJ; \
 	    DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
 	    LD="$(LD_FOR_TARGET)"; export LD; \
             LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
@@ -1423,9 +1416,9 @@
 	    RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	    WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
 	    echo Configuring in $(TARGET_SUBDIR)/$${dir}; \
-	    cd $(TARGET_SUBDIR)/$${dir}; \
+	    cd "$(TARGET_SUBDIR)/$${dir}" || exit 1; \
 	    case $(srcdir) in \
-	    /*) \
+	    /* | [A-Za-z]:[\\/]*) \
 	      topdir=$(srcdir) ;; \
 	    *) \
 	      case "$(TARGET_SUBDIR)" in \
@@ -1467,7 +1460,7 @@
 	      CONFIG_SITE=no-such-file $(SHELL) $$s/configure \
 		$(TARGET_CONFIGARGS) $${srcdiroption} \
 		--with-target-subdir="$(TARGET_SUBDIR)"; \
-	    fi; \
+	    fi || exit 1; \
 	    if [ -f skip-this-dir ] ; then \
 	      sh skip-this-dir; \
 	      rm -f skip-this-dir; \
@@ -1649,6 +1642,18 @@
 	  true; \
 	fi
 
+.PHONY: check-c++
+check-c++:
+	@if [ -f ./gcc/Makefile ] ; then \
+	  r=`pwd`; export r; \
+	  s=`cd $(srcdir); pwd`; export s; \
+	  $(SET_LIB_PATH) \
+	  (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++); \
+	  $(MAKE) check-target-libstdc++-v3; \
+	else \
+	  true; \
+	fi 
+
 .PHONY: install-gcc
 install-gcc:
 	@if [ -f ./gcc/Makefile ] ; then \
@@ -1689,7 +1694,7 @@
 
 ALL_GCC = all-gcc
 ALL_GCC_C = $(ALL_GCC) all-target-newlib all-target-libgloss
-ALL_GCC_CXX = $(ALL_GCC_C) all-target-libstdc++ all-target-libstdc++-v3
+ALL_GCC_CXX = $(ALL_GCC_C) all-target-libstdc++-v3
 
 # This is a list of inter-dependencies among modules.
 all-apache:
@@ -1700,7 +1705,7 @@
 all-bfd: all-libiberty all-intl
 all-binutils: all-libiberty all-opcodes all-bfd all-flex all-bison all-byacc all-intl
 all-bison: all-texinfo
-configure-target-boehm-gc: $(ALL_GCC_CXX) configure-target-qthreads
+configure-target-boehm-gc: $(ALL_GCC_C) configure-target-qthreads
 all-target-boehm-gc: configure-target-boehm-gc
 configure-target-bsp: $(ALL_GCC_C)
 all-target-bsp: configure-target-bsp
@@ -1709,7 +1714,7 @@
 all-cgen: all-libiberty
 all-cvssrc:
 configure-target-cygmon: $(ALL_GCC_C)
-all-target-cygmon: configure-target-cygmon all-target-libiberty all-target-libio all-target-libstub all-target-bsp
+all-target-cygmon: configure-target-cygmon all-target-libiberty all-target-libstub all-target-bsp
 all-db:
 all-dejagnu: all-tcl all-expect all-tk
 all-diff: all-libiberty
@@ -1724,7 +1729,6 @@
 all-find:
 all-flex: all-libiberty all-bison all-byacc
 all-gas: all-libiberty all-opcodes all-bfd all-intl
-all-gash: all-tcl
 all-gawk:
 all-gcc: all-bison all-byacc all-binutils all-gas all-ld all-zlib
 all-bootstrap: all-libiberty all-texinfo all-bison all-byacc all-binutils all-gas all-ld all-zlib
@@ -1747,13 +1751,8 @@
 all-ispell: all-emacs19
 all-itcl: all-tcl all-tk all-tcl8.1 all-tk8.1
 all-ld: all-libiberty all-bfd all-opcodes all-bison all-byacc all-flex all-intl
-configure-target-libg++: $(ALL_GCC_CXX) configure-target-librx
-all-target-libg++: configure-target-libg++ all-target-libiberty all-target-librx
 configure-target-libgloss: $(ALL_GCC)
 all-target-libgloss: configure-target-libgloss configure-target-newlib
-configure-target-libio: $(ALL_GCC_C)
-all-target-libio: configure-target-libio all-gas all-ld all-gcc all-target-libiberty all-target-newlib
-check-target-libio: all-target-libstdc++
 all-libgui: all-tcl all-tk all-tcl8.1 all-tk8.1 all-itcl
 all-libiberty:
 
@@ -1761,12 +1760,10 @@
 
 configure-target-libffi: $(ALL_GCC_C) 
 all-target-libffi: configure-target-libffi
-configure-target-libjava: $(ALL_GCC_CXX) configure-target-zlib configure-target-boehm-gc configure-target-qthreads configure-target-libffi
-all-target-libjava: configure-target-libjava all-zip all-target-zlib all-target-boehm-gc all-target-qthreads all-target-libffi
+configure-target-libjava: $(ALL_GCC_C) configure-target-zlib configure-target-boehm-gc configure-target-qthreads configure-target-libffi
+all-target-libjava: configure-target-libjava all-fastjar all-target-zlib all-target-boehm-gc all-target-qthreads all-target-libffi
 configure-target-librx: $(ALL_GCC_C)
 all-target-librx: configure-target-librx
-configure-target-libstdc++: $(ALL_GCC_C)
-all-target-libstdc++: configure-target-libstdc++ all-target-libiberty all-target-libio
 configure-target-libstdc++-v3: $(ALL_GCC_C)
 all-target-libstdc++-v3: configure-target-libstdc++-v3 all-target-libiberty
 configure-target-libstub: $(ALL_GCC_C)
@@ -1774,8 +1771,6 @@
 all-libtool:
 configure-target-libf2c: $(ALL_GCC_C)
 all-target-libf2c: configure-target-libf2c all-target-libiberty
-configure-target-libchill: $(ALL_GCC_C)
-all-target-libchill: configure-target-libchill all-target-libiberty
 configure-target-libobjc: $(ALL_GCC_C)
 all-target-libobjc: configure-target-libobjc all-target-libiberty
 all-m4: all-libiberty all-texinfo
@@ -1819,6 +1814,9 @@
 all-zlib:
 configure-target-zlib: $(ALL_GCC_C)
 all-target-zlib: configure-target-zlib
+all-fastjar: all-zlib all-libiberty
+configure-target-fastjar: configure-target-zlib
+all-target-fastjar: configure-target-fastjar all-target-zlib all-target-libiberty
 configure-target-libiberty: $(ALL_GCC_C)
 all-target-libiberty: configure-target-libiberty
 all-target: $(ALL_TARGET_MODULES)
@@ -1910,13 +1908,17 @@
 		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(SUPPORT_FILES)"
-	$(MAKE) -f Makefile.in do-tar-bz2 \
+	$(MAKE) -f Makefile.in do-tar \
+		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(SUPPORT_FILES)"
+	$(MAKE) -f Makefile.in do-bz2 \
 		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(SUPPORT_FILES)"
 
-.PHONY: gdb-taz
-gdb-taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
+.PHONY: gdb-tar
+gdb-tar: $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
 	$(MAKE) -f Makefile.in do-proto-toplev \
 		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
 		MD5PROG="$(MD5PROG)" \
@@ -1929,7 +1931,18 @@
 		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(SUPPORT_FILES)"
-	$(MAKE) -f Makefile.in do-tar-bz2 \
+	$(MAKE) -f Makefile.in do-tar \
+		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(SUPPORT_FILES)"
+
+.PHONY: gdb-taz
+gdb-taz: gdb-tar $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
+	$(MAKE) -f Makefile.in gdb-tar \
+		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(SUPPORT_FILES)"
+	$(MAKE) -f Makefile.in do-bz2 \
 		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(SUPPORT_FILES)"
@@ -1996,12 +2009,17 @@
 	-rm -f $(PACKAGE)-$(VER)
 	ln -s proto-toplev $(PACKAGE)-$(VER)
 
-.PHONY: do-tar-bz2
-do-tar-bz2:
-	echo "==> Making $(PACKAGE)-$(VER).tar.bz2"
-	-rm -f $(PACKAGE)-$(VER).tar.bz2
+.PHONY: do-tar
+do-tar:
+	echo "==> Making $(PACKAGE)-$(VER).tar"
+	-rm -f $(PACKAGE)-$(VER).tar
 	find $(PACKAGE)-$(VER) -follow -name CVS -prune -o -type f -print \
 		| tar cTfh - $(PACKAGE)-$(VER).tar
+
+.PHONY: do-bz2
+do-bz2:
+	echo "==> Bzipping $(PACKAGE)-$(VER).tar.bz2"
+	-rm -f $(PACKAGE)-$(VER).tar.bz2
 	$(BZIPPROG) -v -9 $(PACKAGE)-$(VER).tar
 
 .PHONY: do-md5sum
@@ -2046,13 +2064,6 @@
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(GASB_SUPPORT_DIRS)"
 
-.PHONY: libg++.tar.bz2
-LIBGXX_SUPPORT_DIRS=include libstdc++ libio librx libiberty
-libg++.tar.bz2: $(DIST_SUPPORT) libg++
-	$(MAKE) -f Makefile.in taz TOOL=libg++ \
-		MD5PROG="$(MD5PROG)" \
-		SUPPORT_FILES="$(LIBGXX_SUPPORT_DIRS)"
-
 GNATS_SUPPORT_DIRS=include libiberty send-pr
 gnats.tar.bz2: $(DIST_SUPPORT) $(GNATS_SUPPORT_DIRS) gnats
 	$(MAKE) -f  Makefile.in taz TOOL=gnats \
@@ -2065,9 +2076,14 @@
 	$(MAKE) -f Makefile.in gdb-taz TOOL=gdb \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(GDB_SUPPORT_DIRS)"
+.PHONY: gdb.tar
+gdb.tar: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
+	$(MAKE) -f Makefile.in gdb-tar TOOL=gdb \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(GDB_SUPPORT_DIRS)"
 
-.PHONY: dejagnu.tar.bz2
 DEJAGNU_SUPPORT_DIRS=  tcl expect libiberty
+.PHONY: dejagnu.tar.bz2
 dejagnu.tar.bz2: $(DIST_SUPPORT) $(DEJAGNU_SUPPORT_DIRS) dejagnu
 	$(MAKE) -f Makefile.in taz TOOL=dejagnu \
 		MD5PROG="$(MD5PROG)" \
@@ -2079,6 +2095,11 @@
 	$(MAKE) -f Makefile.in gdb-taz TOOL=gdb PACKAGE=gdb+dejagnu \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(GDBD_SUPPORT_DIRS)"
+.PHONY: gdb+dejagnu.tar
+gdb+dejagnu.tar: $(DIST_SUPPORT) $(GDBD_SUPPORT_DIRS) gdb
+	$(MAKE) -f Makefile.in gdb-tar TOOL=gdb PACKAGE=gdb+dejagnu \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(GDBD_SUPPORT_DIRS)"
 
 .PHONY: insight.tar.bz2
 INSIGHT_SUPPORT_DIRS= $(GDB_SUPPORT_DIRS) tcl tk itcl tix libgui
@@ -2086,6 +2107,11 @@
 	$(MAKE) -f Makefile.in gdb-taz TOOL=gdb PACKAGE=insight \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(INSIGHT_SUPPORT_DIRS)"
+.PHONY: insight.tar
+insight.tar: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
+	$(MAKE) -f Makefile.in gdb-tar TOOL=gdb PACKAGE=insight \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(INSIGHT_SUPPORT_DIRS)"
 
 .PHONY: insight+dejagnu.tar.bz2
 INSIGHTD_SUPPORT_DIRS= $(INSIGHT_SUPPORT_DIRS) expect dejagnu
@@ -2093,6 +2119,11 @@
 	$(MAKE) -f Makefile.in gdb-taz TOOL=gdb PACKAGE="insight+dejagnu" \
 		MD5PROG="$(MD5PROG)" \
 		SUPPORT_FILES="$(INSIGHTD_SUPPORT_DIRS)"
+.PHONY: insight+dejagnu.tar
+insight+dejagnu.tar: $(DIST_SUPPORT) $(INSIGHTD_SUPPORT_DIRS) gdb
+	$(MAKE) -f Makefile.in gdb-tar TOOL=gdb PACKAGE="insight+dejagnu" \
+		MD5PROG="$(MD5PROG)" \
+		SUPPORT_FILES="$(INSIGHTD_SUPPORT_DIRS)"
 
 .PHONY: newlib.tar.bz2
 NEWLIB_SUPPORT_DIRS=libgloss
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a547dee..1f0e6d0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,7 +1,881 @@
+2002-05-06  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* elf32-arm.h (elf32_arm_final_link_relocate): Convert
+	'reloc_signed_max' and 'reloc_signed_min' into half-word offsets.
+
+2002-05-06  Alan Modra  <amodra@bigpond.net.au>
+
+	* elflink.h (elf_link_input_bfd <emit_relocs>): Adjust r_offset
+	when not relocatable.  Fix reloc_emitter call for K&R.
+
+2002-05-04  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf64-ppc.c (ppc64_elf_relocate_section): Reinstate code
+	reloading local sym addend mistakenly removed in 2002-05-01 change.
+
+	* dwarf2.c (struct line_head): Make prologue_length a bfd_vma.
+	(read_abbrevs): Change "offset" param to bfd_vma.
+	(parse_comp_unit): Change "version" and addr_size to unsigned ints.
+	Change "abbrev_offset" to bfd_vma.
+	(read_indirect_string): Use correct conversion chars in error
+	message format string, cast bfd_vma's to unsigned long.
+	(read_abbrevs): Likewise.
+	(read_attribute_value): Likewise.
+	(decode_line_info): Likewise.
+	(scan_unit_for_functions): Likewise.
+	(parse_comp_unit): Likewise.
+
+2002-05-04  Tom Rix  <trix@redhat.com>
+
+	* coffswap.h (coff_swap_reloc_in): Remove XCOFF support.
+	(coff_swap_reloc_out): Same.
+	* coff-rs6000.c: (xcoff_swap_reloc_in): Moved from coffswap.h.
+	(xcoff_swap_reloc_out): Same.
+	(xcoff_rtype2howto): Renamed from _bfd_xcoff_rtype2howto. Special
+	case some 16 bit relocs. Add reloc value to output.
+	(xcoff_howto_table): Remove 64 bit R_POS, add 16 bit
+	R_RBR. Improve names. 
+	(_bfd_xcoff_reloc_type_lookup): Adjust for removal of 64 bit R_POS.
+	(bfd_xcoff_backend_data): Update with new reloc swap names.
+	(bfd_pmac_xcoff_backend_data) : Same.
+	* coff64-rs6000.c: (xcoff64_swap_reloc_in): Moved from coffswap.h.
+	(xcoff64_swap_reloc_out): Same.
+	(xcoff64_rtype2howto): Special case some 16 bit relocs and 32 bit 
+	R_POS. Add reloc value to output.
+	(xcoff64_howto_table): Move 64 bit R_POS to first entry.  Add 16 
+	bit R_RBR. Improve names, masks. 
+	(xcoff64_reloc_type_lookup): Adjust for move of 64 bit R_POS.
+	(bfd_xcoff_backend_data): Update with new reloc swap names.
+	(bfd_xcoff_aix5_backend_data) : Same.
+
+2002-05-04  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf32-hppa.c (struct elf32_hppa_link_hash_table): Add
+	bfd_count top_index, input_list, all_local_syms.
+	(elf32_hppa_setup_section_lists): New function, split from
+	elf32_hppa_size_stubs.
+	(elf32_hppa_next_input_section): Likewise.
+	(group_sections): Likewise.
+	(get_local_syms): Likewise.
+	(elf32_hppa_size_stubs): Adjust for split out functions.  Look for
+	stubs on undefined syms too.
+	(elf32_hppa_set_gp): Use bfd_link_hash* instead of elf_link_hash*.
+	Only access htab elf fields when we have and elf hash table.
+	* elf32-hppa.h (elf32_hppa_setup_section_lists): Declare.
+	(elf32_hppa_next_input_section): Declare.
+
+2002-05-04  Bob Byrnes  <byrnes@curl.com>
+
+	* opncls.c (_bfd_new_bfd_contained_in): Check return value of
+	_bfd_new_bfd.
+
+2002-05-03  H.J. Lu  (hjl@gnu.org)
+
+	* elfxx-mips.c (mips_elf_link_hash_entry): Add forced_local.
+	(mips_elf_link_hash_newfunc): Initialize forced_local to false.
+	(mips_elf_record_global_got_symbol): Call _bfd_mips_elf_hide_symbol
+	to hide a global symbol.
+	(_bfd_mips_elf_hide_symbol): Return if forced_local is true. Set
+	forced_local to true. 
+
+2002-05-02  Richard Henderson  <rth@redhat.com>
+
+	* elf64-alpha.c (elf64_alpha_relocate_section): Force relative relocs
+	vs SHN_UNDEF to zero.
+
+2002-05-02  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_SECTOFF>): Change to a
+	16 bit reloc.
+	<R_PPC64_SECTOFF_DS>: Likewise.
+	(ppc64_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to
+	SECTOFF reloc.
+	* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_SECTOFF>): Correct.
+	(ppc_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to
+	SECTOFF reloc.
+
+	* elf64-ppc.c (ppc64_elf_addr16_ha_reloc): Delete.
+	(ppc64_elf_ha_reloc): New function.
+	(ppc64_elf_brtaken_reloc): New function.
+	(ppc64_elf_sectoff_reloc): New function.
+	(ppc64_elf_sectoff_ha_reloc): New function.
+	(ppc64_elf_toc_reloc): New function.
+	(ppc64_elf_toc_ha_reloc): New function.
+	(ppc64_elf_toc64_reloc): New function.
+	(ppc64_elf_unhandled_reloc): New function.
+	(ppc64_elf_howto_raw): Use the above.
+	<R_PPC64_RELATIVE>: Mark pc_relative, pcrel_offset.
+	<R_PPC64_SECTOFF>: Not pc_relative or pcrel_offset.  Fix dst_mask.
+	<R_PPC64_SECTOFF_DS>: Likewise.
+	(IS_ABSOLUTE_RELOC): Update.
+	(struct ppc_link_hash_table): Add have_undefweak.
+	(ppc64_elf_link_hash_table_create): Init.
+	(func_desc_adjust): Set have_undefweak.
+	(ppc64_elf_func_desc_adjust): Call func_desc_adjust earlier.  Only
+	add the .sfpr blr when have_undefweak.
+	(ppc64_elf_setup_section_lists): Check hash table flavour.
+	(ppc64_elf_next_input_section): Move output_section->owner test to
+	ppc64elf.em.
+	(ppc64_elf_set_toc): Rename to ppc64_elf_toc, remove info param
+	and relocatable test.  Return TOCstart and don't set elf_gp.
+	(ppc64_elf_relocate_section): Correct BRTAKEN/BRNTAKEN branch
+	offset calculation.  Add assert on weak sym branch tweaks.
+	* elf64-ppc.h (ppc64_elf_set_toc): Delete.
+	(ppc64_elf_toc): Declare.
+	(ppc64_elf_next_input_section): Update.
+	
+2002-05-01  Alan Modra  <amodra@bigpond.net.au>
+
+	* syms.c (_bfd_stab_section_find_nearest_line): Don't bomb on NULL
+	file_name.
+
+2002-05-01  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf64-ppc.c (CROR_151515, CROR_313131): Define.
+	(ppc64_elf_relocate_section): Use them.  Don't look for plt calls
+	on R_PPC64_ADDR24 relocs.  Require a nop or no link reg on plt
+	call branches.  Correct undefined weak destination.
+	(ppc64_elf_func_desc_adjust): Always create at least one blr in
+	.sfpr, and correct case where either only savef* or restf* is
+	needed.
+
+	Long branch stubs, multiple stub sections.
+	* elf64-ppc.h (ppc64_elf_setup_section_lists): Declare.
+	(ppc64_elf_next_input_section): Declare.
+	* elf64-ppc.c: Move linker-only prototypes.
+	(STUB_SUFFIX): Define.
+	(enum ppc_stub_type): New.
+	(struct ppc_stub_hash_entry): New.
+	(struct ppc_branch_hash_entry): New.
+	(struct ppc_link_hash_entry): Add stub_cache, oh.
+	(struct ppc_link_hash_table): Add stub_hash_table etc.  Remove
+	sstub.  Add sbrlt, srelbrlt, has_14bit_branch, stub_iteration.
+	Rename plt_overflow to stub_error.
+	(ppc_stub_hash_lookup): Define.
+	(ppc_branch_hash_lookup): Define.
+	(stub_hash_newfunc): New function.
+	(branch_hash_newfunc): New function.
+	(link_hash_newfunc): Init new fields.
+	(ppc64_elf_link_hash_table_create): Likewise.
+	(ppc64_elf_link_hash_table_free): New function.
+	(ppc_stub_name): New function.
+	(ppc_get_stub_entry): New function.
+	(ppc_add_stub): New function.
+	(create_linkage_sections): Use bfd_make_section_anyway.  Create
+	.branch_lt and .rela.branch_lt sections.  Don't create .stub.
+	(ppc64_elf_check_relocs): Set has_14bit_branch on R_PPC64_REL14*,
+	and set up for plt call stubs.  Link func and func desc syms.
+	(ppc64_elf_gc_sweep_hook): Handle REL14* as per REL24.
+	(func_desc_adjust): Avoid hash lookup when func desc sym available
+	via shortcut, and set links when processing.
+	(ppc64_elf_hide_symbol): Likewise.
+	(allocate_dynrelocs): Don't allocate stub section here.
+	(ppc64_elf_size_dynamic_sections): Handle sbrlt and srelbrlt.
+	Remove sstub code.
+	(ppc_type_of_stub): New function.
+	(build_one_stub): Delete.
+	(ppc_build_one_stub): New function.
+	(ppc_size_one_stub): New function.
+	(ppc64_elf_setup_section_lists): New function.
+	(ppc64_elf_next_input_section): New function.
+	(group_sections): New function.
+	(get_local_syms): New function.
+	(ppc64_elf_size_stubs): Rewrite.
+	(ppc64_elf_build_stubs): Rewrite.
+	(ppc64_elf_relocate_section): Look up stub entry for REL24
+	relocs.  Don't propagate REL14* to dynamic objects.  Look for long
+	branch stubs if REL14* or REL24 relocs won't reach.
+	(bfd_elf64_bfd_link_hash_table_free): Define.
+
+2002-04-30  Mark Mitchell  <mark@codesourcery.com>
+
+	* bfd/config.bfd: Add support for powerpc-*-windiss.
+
+2002-04-30  Tom Rix  <trix@redhat.com>
+
+	* xcofflink.c (xcoff_link_add_symbols): Always copy undef C_EXT
+	symbol names into the hash table.
+
+2002-04-28  Tom Rix  <trix@redhat.com>
+
+	* coff-rs6000.c (xcoff_calculate_relocation) : Function table for
+	calulating relocations. 
+	(xcoff_complain_overflow) : Function table for relocation errors.
+	(xcoff_ppc_relocate_section): Use relocation and complain function 
+	tables. 
+	(xcoff_complain_overflow_unsigned_func): New complain function. 
+	(xcoff_complain_overflow_signed_func): Same.
+	(xcoff_complain_overflow_bitfield_func): Same.
+	(xcoff_complain_overflow_dont_func): Same.
+	(xcoff_reloc_type_crel): New recot function.
+	(xcoff_reloc_type_br): Same.
+	(xcoff_reloc_type_ba): Same.
+	(xcoff_reloc_type_toc): Same.
+	(xcoff_reloc_type_rel): Same.
+	(xcoff_reloc_type_neg): Same.
+	(xcoff_reloc_type_pos): Same.
+	(xcoff_reloc_type_fail): Same.
+	(xcoff_reloc_type_noop): Same.
+	* libxcoff.h : Declare common parts for xcoff64.
+	* coff64-rs6000.c (xcoff64_ppc_relocate_section): Use relocation
+	and complain function tables. 
+
+2002-04-28  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf64-x86-64.c (struct elf64_x86_64_dyn_relocs): Comment typo.
+	* elf32-hppa.c (elf32_hppa_final_link): Formatting.
+
+2002-04-26  Alan Modra  <amodra@bigpond.net.au>
+
+	* opncls.c (bfd_make_readable): Call bfd_section_list_clear.
+	* xcofflink.c (xcoff_link_add_dynamic_symbols): Likewise.
+
+	* elflink.h (elf_bfd_final_link): Ensure input bfd class is the
+	same as the output before calling elf_link_input_bfd.
+
+	* coffcode.h (coff_compute_section_file_positions): Set
+	section_tail after shuffling section list.
+
+2002-04-24  Christian Groessler <chris@groessler.org>
+
+	* coff-z8k.c (extra_case): Fix R_IMM32 relocations: The
+	addresses are 23bit with a special layout, not plain 32bit
+	values.  Prevent relocation of immediate values.
+
+2002-04-24  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* elfxx-mips.c (_bfd_mips_elf_print_private_bfd_data): If MDMX or
+	MIPS-16 ASE flags are set, print something to indicate that.
+
+2002-04-23  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf32-hppa.c (hppa_type_of_stub): Correct and simplify condition
+	under which a plt call stub is used.
+	(final_link_relocate): Similarly.
+	(allocate_plt_static): Clear h-plabel except when plt entry is
+	exclusively used for a plabel.
+	(allocate_dynrelocs): Use the above to simplify plt sizing.
+	(struct elf32_hppa_link_hash_table): Add has_22bit_branch.
+	(elf32_hppa_link_hash_table_create): Init.
+	(BL22_RP): Define.
+	(hppa_build_one_stub): Use BL22_RP if has_22bit_branch.
+	(elf32_hppa_check_relocs): Set has_22bit_branch.
+
+	* elf32-hppa.c (elf32_hppa_check_relocs): Remove debug message.
+	(final_link_relocate): Likewise.
+
+2002-04-22  Jakub Jelinek  <jakub@redhat.com>
+
+	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't build
+	search table if some FDE is DW_EH_PE_aligned encoded either.
+	(_bfd_elf_write_section_eh_frame): Handle terminating FDE specially.
+
+2002-04-22  Richard Smith  <richard@ex-parrot.com>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	* elf-eh-frame.c (struct eh_cie_fde): Add per_encoding_relative.
+	(_bfd_elf_discard_section_eh_frame): Set it for CIEs with pcrel
+	encoded personality.
+	(_bfd_elf_write_section_eh_frame): Adjust pcrel encoded personality
+	for CIE/FDE removal.
+
+2002-04-20  Tom Rix  <trix@redhat.com>
+
+	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Fix C_FILE auxent.
+
+2002-04-20  Alan Modra  <amodra@bigpond.net.au>
+
+	* archures.c (bfd_lookup_arch): Move the list order comment..
+	(struct bfd_arch_info): ..to where it belongs.
+	* bfd-in2.h: Regenerate.
+
+	* archures.c (bfd_lookup_arch): Add comment on list order.
+	(bfd_default_set_arch_mach): Use bfd_lookup_arch.
+	* cpu-powerpc.c (bfd_powerpc_archs): Re-order so that the default
+	is always at head of list.
+
+2002-04-18  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* coff-arm.c (coff_thumb_pcrel_12, coff_thumb_pcrel_9,
+	insert_thumb_branch, record_thumb_to_arm_glue): Suppress
+	definition of these functions for ARM_WINCE builds as they are
+	not used.
+        (SWAP_IN_RELOC_OFFSET, SWAP_OUT_RELOC_OFFSET): Do not define
+	for ARM_WINCE builds.
+
+2002-04-18  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* coff-arm.c (bfd_arm_process_before_allocation): 
+
+2002-04-17  J"orn Rennecke <joern.rennecke@superh.com>
+
+	* cpu-sh.c (scan_mach): Delete.
+	(arch_info_struct): Replace scan_mach with bfd_default_scan.
+	(bfd_sh_arch): Likewise.
+
+2002-04-16  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* ihex.c (ihex_write_object_contents): Fix check for records
+	crossing 64K boundaries.
+
+2002-04-16  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf32-m32r.c (m32r_elf_add_symbol_hook): Check the hash table
+	type rather than just assuming entries are ELF.
+	* elf32-sh64.c (sh64_elf_add_symbol_hook): Likewise.
+	* elf64-sh64.c (sh64_elf64_add_symbol_hook): Likewise.
+	* elf64-sparc.c (sparc64_elf_add_symbol_hook): Likewise.
+	* elf64-mmix.c (mmix_elf_add_symbol_hook): Use bfd_link_hash_entry
+	rather than elf_link_hash_entry.
+
+2002-04-15  Richard Henderson  <rth@redhat.com>
+
+	* elf32-mips.c (mips_elf32_object_p): Revert 0404 fragment: allow
+	n32 binaries.
+
+2002-04-15  Michael Snyder  <msnyder@redhat.com>
+
+	* opncls.c (bfd_close): Write contents if writeable.
+	Minor formatting tidy-ups.
+
+2002-04-15  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf32-ppc.c (ppc_elf_add_symbol_hook): Check the hash table type.
+
+2002-04-12  Michael Snyder  <msnyder@redhat.com>
+
+	* bfd-in.h (bfd_get_section_lma): New access macro.
+	Minor white-space fix-up.
+
+2002-04-12  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf.c (prep_headers): Don't zero EI_OSABI, EI_ABIVERSION or
+	header pad.
+
+2002-04-09  DJ Delorie  <dj@redhat.com>
+
+	* elfarm-nabi.c (elf32_arm_howto_table): Fix ABS16 masks.
+
+2002-04-09  Casper S. Hornstrup <chorns@users.sourceforge.net>
+
+	* coffcode.h (coff_read_word): New.
+	(coff_compute_checksum): New.
+	(coff_apply_checksum): New.
+	(coff_write_object_contents): Call coff_apply_checksum () to
+	apply checksum to PE image.
+
+2002-04-08  Randolph Chung  <tausq@debian.org>
+
+	* elf32-hppa.c (hppa_unwind_entry_compare): Move to elf-hppa.h.
+	(elf32_hppa_final_link): Split out sorting logic to..
+	* elf-hppa.h (elf_hppa_sort_unwind): ..here.
+	(elf_hppa_final_link): Call elf_hppa_sort_unwind.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* configure.in: Add missing ``|'' to powerpc-*-aix4.[4-9]*
+	pattern.
+	* configure: Re-generate.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* configure.in: Only define AIX_CORE_DUMPX_CORE when AIX version
+	is greater or equal to 4.3.3.
+	* configure: Regenerate.
+	Fix PR gdb/344.
+
+2002-04-05  Hans-Peter Nilsson  <hp@axis.com>
+
+	* elf32-cris.c (cris_elf_howto_table) <R_CRIS_16_PCREL,
+	R_CRIS_32_PCREL>: Fix typo in name.
+	(cris_elf_check_relocs): Always create .rela.got here when
+	R_CRIS_16_GOTPLT or R_CRIS_32_GOTPLT is seen.
+	(elf_cris_adjust_gotplt_to_got): Don't create .rela.got here;
+	assume it's created.
+
+2002-04-04  Daniel Jacobowitz  <drow@mvista.com>
+
+	* aout-adobe.c (aout_32_bfd_link_hash_table_free): Define.
+	* aout-target.h (MY_bfd_link_hash_table_free): Conditionally
+	define.
+	* aout-tic30.c (MY_bfd_link_hash_table_free): Likewise.
+	* bfd.c (bfd_link_hash_table_free): Define.
+	* binary.c (binary_bfd_link_hash_table_free): Define.
+	* bout.c (b_out_bfd_link_hash_table_free): Define.
+	* coff-rs6000.c (rs6000coff_vec): Include
+	_bfd_generic_link_hash_table_free.
+	(pmac_xcoff_vec): Likewise.
+	* coff64-rs6000.c (rs6000coff64_vec): Likewise.
+	(aix5coff64_vec): Likewise.
+	* coffcode.h (coff_bfd_link_hash_table_free): Conditionally define.
+	* elf-m10300.c (elf32_mn10300_link_hash_table_free): New function.
+	(bfd_elf32_bfd_link_hash_table_free): Define.
+	* elf32-hppa.c (elf32_hppa_link_hash_table_free): New function.
+	(bfd_elf32_bfd_link_hash_table_free): Define.
+	* elfxx-target.h (bfd_elfNN_bfd_link_hash_table_free): Conditionally
+	define.
+	* i386msdos.c (msdos_bfd_link_hash_table_free): Define.
+	* i386os9k.c (os9k_bfd_link_hash_table_free): Define.
+	* ieee.c (ieee_bfd_link_hash_table_free): Define.
+	* ihex.c (ihex_bfd_link_hash_table_free): Define.
+	* libbfd-in.h (_bfd_nolink_bfd_link_hash_table_free): Define.
+	(_bfd_generic_link_hash_table_free): Add prototype.
+	* libcoff-in.h (_bfd_xcoff_bfd_link_hash_table_free): Add prototype.
+	* libecoff.h (_bfd_ecoff_bfd_link_hash_table_free): Define.
+	* linker.c (_bfd_generic_link_hash_table_free): New function.
+	* mmo.c (mmo_bfd_link_hash_table_free): Define.
+	* nlm-target.h (nlm_bfd_link_hash_table_free): Define.
+	* oasys.c (oasys_bfd_link_hash_table_free): Define.
+	* ppcboot.c (ppcboot_bfd_link_hash_table_free): Define.
+	* som.c (som_bfd_link_hash_table_free): Define.
+	* srec.c (srec_bfd_link_hash_table_free): Define.
+	* tekhex.c (tekhex_bfd_link_hash_table_free): Define.
+	* versados.c (versados_bfd_link_hash_table_free): Define.
+	* vms.c (vms_bfd_link_hash_table_free): New function.
+	* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_free): New function.
+
+	* coff-arm.c (coff_arm_link_hash_table_create): Use bfd_malloc
+	instead of bfd_alloc.
+	* coff-h8300.c (h8300_coff_link_hash_table_create): Likewise.
+	* coff-mcore.c (coff_mcore_link_hash_table_create): Likewise.
+	* coff-ppc.c (ppc_coff_link_hash_table_create): Likewise.
+	* cofflink.c (_bfd_coff_link_hash_table_create): Likewise.
+	* ecoff.c (_bfd_ecoff_bfd_link_hash_table_create): Likewise.
+	* elf-m10300.c (elf32_mn10300_link_hash_table_create): Likewise.
+	* elf.c (_bfd_elf_link_hash_table_create): Likewise.
+	* elf32-arm.h (elf32_arm_link_hash_table_create): Likewise.
+	* elf32-cris.c (elf_cris_link_hash_table_create): Likewise.
+	* elf32-hppa.c (elf32_hppa_link_hash_table_create): Likewise.
+	* elf32-i386.c (elf_i386_link_hash_table_create): Likewise.
+	* elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise.
+	* elf32-s390.c (elf_s390_link_hash_table_create): Likewise.
+	* elf32-sh.c (sh_elf_link_hash_table_create): Likewise.
+	* elf64-alpha.c (elf64_alpha_bfd_link_hash_table_create): Likewise.
+	* elf64-ppc.c (ppc64_elf_link_hash_table_create): Likewise.
+	* elf64-s390.c (elf_s390_link_hash_table_create): Likewise.
+	* elf64-sh64.c (sh64_elf64_link_hash_table_create): Likewise.
+	* elf64-sparc.c (sparc64_elf_bfd_link_hash_table_create): Likewise.
+	* elf64-x86-64.c (elf64_x86_64_link_hash_table_create): Likewise.
+	* elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise.
+	* linker.c (_bfd_generic_link_hash_table_create): Likewise.
+	* m68klinux.c (linux_link_hash_table_create): Likewise.
+	* sparclinux.c (linux_link_hash_table_create): Likewise.
+	* sunos.c (sunos_link_hash_table_create): Likewise.
+	* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Likewise.
+
+	* targets.c: Add _bfd_link_hash_table_free to xvec.
+
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+	* libcoff.h: Regenerate.
+
+2002-04-04  Alan Modra  <amodra@bigpond.net.au>
+
+	* dep-in.sed: Cope with absolute paths.
+	* Makefile.am (dep.sed): Subst TOPDIR, and not INCDIR.
+	Run "make dep-am".
+	* Makefile.in: Regenerate.
+	* coff-arm.c: Fix copyright date.
+	* cpu-h8300.c: Likewise.
+	* cpu-i370.c: Likewise.
+	* cpu-s390.c: Likewise.
+	* cpu-mips.c: Likewise.
+	* po/SRC-POTFILES.in: Regenerate.
+
+2002-04-04  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
+
+	* Makefile.am: Add elfxx-mips.c to the known backends.
+	(elf32-mips.lo): remove dependency to coff/external.h.
+	* Makefile.in: Regenerate.
+	* configure.in: Add elfxx-mips.lo to all vectors using elf32-mips.lo
+	Remove elf32-mips.lo from 64 bit vectors. Update dependencies
+	accordingly.
+	* configure: Regenerate.
+	* elf-bfd.h: Move all MIPS ELF specific prototypes to elfxx-mips.h.
+	(irix_compat_t): IRIX compatibility level, moved from elf32-mips.c.
+	(elf_backend_mips_irix_compat, elf_backend_mips_rtype_to_howto): New
+	MIPS specific backend functions.
+	* elf32-mips.c: Moved most code to elfxx-mips.c.
+	(mips_elf_hi16_reloc): Rename from _bfd_mips_elf_hi16_reloc and make
+	static.
+	(mips_elf_lo16_reloc): Likewise, was _bfd_mips_elf_lo16_reloc.
+	(mips_elf_got16_reloc): Likewise, was _bfd_mips_elf_got16_reloc.
+	(mips_elf_gprel32_reloc): Likewise, was _bfd_mips_elf_gprel32_reloc.
+	(mips_elf32_rtype_to_howto): Rename from mips_rtype_to_howto. Changed
+	interface to allow selection of the right REL or RELA howto table.
+	(mips_elf32_object_p): Rename from _bfd_mips_elf_object_p and made
+	static. Let it refuse n32 objects.
+	(elf32_mips_grok_prstatus): Rename from _bfd_elf32_mips_grok_prstatus.
+	(elf32_mips_grok_psinfo): Rename from _bfd_elf32_mips_grok_psinfo.
+	(elf32_mips_discard_info): Rename from _bfd_elf32_mips_discard_info.
+	(elf32_mips_ignore_discarded_relocs): Rename from
+	_bfd_elf32_mips_ignore_discarded_relocs.
+	(elf32_mips_write_section): Rename from _bfd_elf32_mips_write_section.
+	(elf32_mips_irix_compat): New function, replaces IRIX_COMPAT.
+	(elf_mips_howto_table_rela): Remove.
+	* elf64-mips.c: Moved most code to elfxx-mips.c.
+	(bfd_elf64_bfd_reloc_type_lookup): Make static.
+	(mips_elf64_rtype_to_howto): New function.
+	(mips_elf64_object_p): Likewise.
+	(elf64_mips_irix_compat): Likewise.
+	* elfxx-mips.c: New file containing common code merged together from
+	elf32-mips.c and elf64-mips.c.
+	* elfxx-mips.h: New file containing MIPS specific prototypes from
+	elf-bfd.h.
+	* elfxx-target.h: Add handling for elf_backend_mips_irix_compat and
+	elf_backend_mips_rtype_to_howto.
+
+2002-04-04  Alan Modra  <amodra@bigpond.net.au>
+
+	* srec.c (MAXCHUNK, Chunk): Revise comments.
+	(srec_write_record): Correct buffer size.
+	(srec_write_header): Do without intermediate buffer.
+	(srec_write_section): Validate Chunk.
+	(srec_write_terminator): Pass NULL instead of dummy buffer.
+	(srec_write_symbols): Pass file and symbol names directly to
+	bfd_bwrite so sprintf won't overflow buffer.
+
+2002-04-03  Jakub Jelinek  <jakub@redhat.com>
+
+	* elf32-sparc.c (elf32_sparc_relocate_section): Don't emit dynamic
+	PC relative relocs against hidden symbols.
+	* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+
+2002-04-03  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf.c (_bfd_elf_make_section_from_shdr): When setting section
+	LMAs, loop over segments until p_vaddr and p_memsz specify an
+	extent enclosing the section.
+
+2002-04-02  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* ihex.c (ihex_write_object_contents): Do not allow records to
+	cross a 64K boundary - wrap if necessary.
+
+2002-04-01  Nathan Williams  <nathanw@wasabisystems.com>
+
+	* elf.c (elfcore_netbsd_get_lwpid): Fix off-by-one error
+	which caused the returned LWP ID to always be 0.
+
+2002-04-01  Richard Henderson  <rth@redhat.com>
+
+	* elf32-sparc.c (WILL_CALL_FINISH_DYNAMIC_SYMBOL): New.
+	(elf32_sparc_relocate_section): Use it to figure out when to
+	initialize .got entries.
+	* elf64-sparc.c: Similarly.
+
+2002-03-28  Alan Modra  <amodra@bigpond.net.au>
+
+	* linker.c (link_action): Ignore duplicate warning syms.
+	(_bfd_generic_link_write_global_symbol): Follow warning symbol link.
+	* elflink.h (elf_adjust_dynstr_offsets): Likewise.
+	(elf_adjust_dynamic_symbol): Likewise.
+	(elf_export_symbol): Likewise.
+	(elf_link_find_version_dependencies): Likewise.
+	(elf_link_assign_sym_version): Likewise.
+	(elf_link_sec_merge_syms): Likewise.
+	(elf_link_output_extsym): Likewise.
+	(elf_gc_sweep_symbol): Likewise.
+	(elf_gc_propagate_vtable_entries_used): Likewise.
+	(elf_gc_smash_unused_vtentry_relocs): Likewise.
+	(elf_gc_allocate_got_offsets): Likewise.
+	(elf_collect_hash_codes): Likewise.
+	* elflink.c (elf_link_renumber_hash_table_dynsyms): Likewise.
+	* elf-hppa.h (elf_hppa_unmark_useless_dynamic_symbols): Likewise.
+	(elf_hppa_remark_useless_dynamic_symbols): Likewise.
+	* elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Likewise.
+	* elf32-arm.h (elf32_arm_discard_copies): Likewise.
+	* elf32-cris.c (elf_cris_adjust_gotplt_to_got): Likewise.
+	(elf_cris_discard_excess_dso_dynamics): Likewise.
+	* elf32-hppa.c (clobber_millicode_symbols): Likewise.
+	(mark_PIC_calls): Likewise.
+	(allocate_plt_static): Likewise.
+	(allocate_dynrelocs): Likewise.
+	(readonly_dynrelocs): Likewise.
+	* elf32-i386.c (allocate_dynrelocs): Likewise.
+	(readonly_dynrelocs): Likewise.
+	* elf32-i370.c (i370_elf_adjust_dynindx): Likewise.
+	* elf32-m68k.c (elf_m68k_discard_copies): Likewise.
+	* elf32-mips.c (mips_elf_output_extsym): Likewise.
+	(mips_elf_sort_hash_table_f): Likewise.
+	(mips_elf_check_mips16_stubs): Likewise.
+	* elf32-s390.c (allocate_dynrelocs): Likewise.
+	(readonly_dynrelocs): Likewise.
+	* elf32-sh.c (sh_elf_discard_copies): Likewise.
+	* elf32-xstormy16.c (xstormy16_relax_plt_check): Likewise.
+	(xstormy16_relax_plt_realloc): Likewise.
+	* elf64-alpha.c (elf64_alpha_calc_got_offsets_for_symbol): Likewise.
+	(elf64_alpha_output_extsym): Likewise.
+	* elf64-hppa.c (elf64_hppa_mark_exported_functions): Likewise.
+	* elf64-mips.c (mips_elf64_sort_hash_table_f): Likewise.
+	(mips_elf64_check_mips16_stubs): Likewise.
+	(mips_elf64_output_extsym): Likewise.
+	* elf64-ppc.c (func_desc_adjust): Likewise.
+	(allocate_dynrelocs): Likewise.
+	(readonly_dynrelocs): Likewise.
+	* elf64-s390.c (allocate_dynrelocs): Likewise.
+	(readonly_dynrelocs): Likewise.
+	* elf64-sh64.c (sh64_elf64_discard_copies): Likewise.
+	* elf64-x86-64.c (allocate_dynrelocs): Likewise.
+	(readonly_dynrelocs): Likewise.
+	* elfxx-ia64.c (elfNN_ia64_global_dyn_sym_thunk): Likewise.
+	* aoutx.h (aout_link_write_other_symbol): Likewise.
+	* cofflink.c (_bfd_coff_write_task_globals): Likewise.
+	(_bfd_coff_write_global_sym): Likewise.
+	* i386linux.c (linux_tally_symbols): Likewise.
+	* m68klinux.c (linux_tally_symbols): Likewise.
+	* sparclinux.c (linux_tally_symbols): Likewise.
+	* pdp11.c (aout_link_write_other_symbol): Likewise.
+	* sunos.c (sunos_scan_dynamic_symbol): Likewise.
+	* xcofflink.c (xcoff_build_ldsyms): Likewise.
+	(xcoff_write_global_symbol): Likewise.
+
+	* cofflink.c (_bfd_coff_final_link): Formatting.
+	* cpu-mips.c (mips_compatible): Make static, prototype.
+	* elf32-i386.c (elf_i386_check_relocs): Formatting.
+	* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
+	* elf64-alpha.c (elf64_alpha_output_extsym): Likewise.
+	* elf64-mips.c (mips_elf64_sort_hash_table): Likewise.
+	(mips_elf64_final_link): Likewise.
+	* elflink.h (elf_link_find_version_dependencies): Remove duplicate
+	prototype.
+
+2002-03-27  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* coff-arm.c (SWAP_IN_RELOC_OFFSET): Define.
+	(SWAP_OUT_RELOC_OFFSET): Define.
+
+2002-03-27  Gregory Steuck <greg@nest.cx>
+
+	* elf.c (_bfd_elf_get_symtab_upper_bound): Leave space for
+	terminating NULL if empty symbol table.
+	(_bfd_elf_get_dynamic_symtab_upper_bound): Likewise.
+
+2002-03-26  H.J. Lu  (hjl@gnu.org)
+
+	* elflink.h (elf_link_input_bfd): Revert the last change since
+	the gcc exception handling isn't fixed yet.
+
+2002-03-26  H.J. Lu  (hjl@gnu.org)
+
+	* elflink.h (elf_link_input_bfd): Complain about relocations
+	against local symbols in discarded sections.
+
+2002-03-26  Alan Modra  <amodra@bigpond.net.au>
+
+	* elflink.h (elf_gc_mark): Don't recurse into non-ELF sections.
+
+2002-03-23  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on
+	section file offset for !SEC_LOAD sections.
+
+2002-03-21  Richard Earnshaw  <rearnsha@arm.com>
+
+	* elf32-arm.h (elf32_arm_final_link_relocate <case R_ARM_GOTOFF>,
+	<case R_ARM_GOT>): Handle relocations to Thumb functions.
+
+2002-03-21  Alan Modra  <amodra@bigpond.net.au>
+
+	* coff64-rs6000.c (_bfd_xcoff64_put_symbol_name): Prototype.
+	Whitespace changes.
+	* archive.c: Update copyright date.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+	* Makefile.am: Run "make dep-am"
+	* Makefile.in: Regenerate.
+	* po/SRC-POTFILES.in: Regenerate.
+
+2002-03-20  Daniel Jacobowitz  <drow@mvista.com>
+
+	* dwarf2.c (struct funcinfo): Move up.
+	(lookup_address_in_function_table): New argument function_ptr.
+	Set it.
+	(lookup_address_in_line_table): New argument function.  If function
+	is non-NULL, use it to handle ``addr'' before the first line note of
+	the function.
+	(comp_unit_find_nearest_line): Update and swap calls to
+	lookup_address_in_function_table and lookup_address_in_line_table.
+	* syms.c (_bfd_stab_section_find_nearest_line): Use the first
+	N_SLINE encountered if we see an N_FUN before any N_SLINE.
+
+2002-03-20  Tom Rix  <trix@redhat.com>
+
+	* coff-rs6000.c (_bfd_xcoff_stat_arch_elt): Renamed from 
+	_bfd_xcoff_generic_stat_arch_elt.  Fix format check.
+	* coff64-rs6000.c :  Use _bfd_xcoff_stat_arch_elt. 
+
+2002-03-19  Tom Rix  <trix@redhat.com>
+
+	* xcofflink.c (_bfd_xcoff_bfd_link_add_symbols): Look through all 
+	dynamic objects in archives.
+
+2002-03-19  Hans-Peter Nilsson  <hp@bitrange.com>
+
+	* elflink.h (NAME(bfd_elf,record_link_assignment)): Don't set
+	STT_NOTYPE symbols to STT_OBJECT.
+
+2002-03-18  Jan Hubicka  <jh@suse.cz>
+
+	* cpu-i386.c (bfd_x86_64_arch): Rename to "i386:x86-64"
+
+2002-03-18  Tom Rix  <trix@redhat.com>
+
+	* aix5ppc.core.c : New file for AIX 5 64 bit core support.
+	* bfd-in.h : Add bfd_xcoff_ar_archive_set_magic declaration.
+	* coff-rs6000 (do_pad) : New function for archive padding.
+	(do_copy) : New function for object file copying in archives.
+	(do_shared_object_padding) : New function for padding shared
+	objects to their text section alignment in archives.
+	(bfd_xcoff_ar_achive_set_magic) : Stub.
+	(xcoff_write_armap_big) : Use do_copy and do_pad.
+	(xcoff_write_archive_contents_big) : Use do_shared_object_padding,
+	do_copy and do_pad.
+	* coff64-rs6000.c (xcoff64_write_ojbect_contents) : Use
+	bfd_xcoff_magic_number. 
+	(xcoff64_bad_format_hook) : New function for _bfd_bad_format_hook
+	fop.
+	(xcoff_backend_data_r) : Use xcoff64_bad_format_hook.
+	(bfd_xcoff_aix5_backend_data) : New Aix 5 backend data.
+	(aix5coff64_vec) : New Aix 5 target aix5coff64-rs6000.
+	* rs6000-core.c : Update copyright date.
+	* xcofflink.c (bfd_xcoff_size_dynamic_sections): Check for NULL 
+	csectpp.
+	* coffcode.h (coff_new_section_hook) : Use new accessor macros.
+	(coff_set_arch_mach_hook) : Add Aix 5 U64_TOCMAGIC magic #.
+	(coff_set_flags) : Use bfd_xcoff_magic_number.
+	* libxcoff.h (bfd_xcoff_is_xcoff64): Add U64_TOCMAGIC.
+	* configure.in : Add powerpc-*-aix5 and rs6000-*-aix5 support.
+	* Makefile.am : Same.
+	* config.bfd : Same.
+	* targets.c : Same.
+	* configure : Regnerate.
+	* Makefile.in : Same.
+	* bfd-in2.h : Same.
+
+2002-03-18  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* po/fr.po: Updated version.
+
+2002-03-18  Alan Modra  <amodra@bigpond.net.au>
+
+	* libbfd.c (bfd_write_bigendian_4byte_int): Return true iff success.
+	* libbfd.h: Regenerate.
+	* archive.c (coff_write_armap): Pass on failures from
+	bfd_write_bigendian_4byte_int.
+
+2002-03-14  H.J. Lu <hjl@gnu.org>
+
+	* elflink.h (NAME(bfd_elf,size_dynamic_sections)): Set the BFD
+	error to bfd_error_nonrepresentable_section for reinit_array
+	section in DSO.
+
+2002-03-14  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* coffcode.h (coff_slurp_symbol_table): When adding BSF_WEAK flag,
+	OR it in rather than replacing previously selected flags.
+
+	* elfxx-target.h (TARGET_BIG_SYM): Set ar_max_namelen to 15.
+	(TARGET_LITTLE_SYM): Set ar_max_namelen to 15.
+
+2002-03-14  Alan Modra  <amodra@bigpond.net.au>
+
+	* cpu-mips.c (mips_compatible): New.  Don't check bits_per_word.
+	(N): Use the above.
+	* elflink.h (elf_bfd_final_link): Revert last change.  Instead,
+	ensure reloc size matches before calling elf_link_input_bfd.
+	Add an assert to check reloc size when counting output relocs.
+
+2002-03-14  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* mmo.c (mmo_get_loc): Return NULL rather than false.
+
+2002-03-13  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* po/fr.po: Updated version.
+
+2002-03-13  Alan Modra  <amodra@bigpond.net.au>
+
+	* archures.c (bfd_default_compatible): Test bits_per_word.
+	* cpu-i386.c (i386_compatible): Remove.  Replace occurrences with
+	bfd_default_compatible.
+	* cpu-i370.c (i370_compatible): Likewise.
+	* cpu-sparc.c (sparc_compatible): Likewise.
+	* cpu-h8300.c (compatible): Test in->arch == out->arch.
+
+	* elflink.h: Formatting fixes.
+	(elf_link_output_extsym): Merge undefined and undef weak cases.
+
+	* elflink.h (elf_bfd_final_link): Only call elf_link_input_bfd
+	when word size of input matches output word size.
+
+2002-03-12  Andreas Jaeger  <aj@suse.de>
+
+	* cpu-i386.c (i386_compatible): New.  Use it instead of
+	bfd_default_compatible.
+
+2002-03-07  H.J. Lu  (hjl@gnu.org)
+
+	* coff-sh.c (shcoff_reloc_map): Use bfd_reloc_code_real_type
+	as the type for bfd_reloc_val.
+
+2002-03-05  John David Anglin  <dave@hiauly1.hia.nrc.ca>
+
+	* elf-hppa.h (elf_hppa_is_dynamic_loader_symbol): New function.
+	(elf_hppa_relocate_section): Ignore undefined dynamic loader symbols.
+	(elf_hppa_final_link_relocate): Correct relocations for indirect
+	references to local data through the DLT.  Fix .opd creation for
+	local symbols using R_PARISC_LTOFF_FPTR32 and R_PARISC_FPTR64
+	relocations.  Use e_lsel selector for R_PARISC_DLTIND21L,
+	R_PARISC_LTOFF_FPTR21L and R_PARISC_LTOFF_TP21L as per
+	"Processor-Specific ELF for PA_RISC, Version 1.43" document.
+	Similarly, use e_rsel for DLT and LTOFF 'R' relocations.
+	* elf32-hppa.c (final_link_relocate): Revise relocation selectors
+	as per "Processor-Specific ELF for PA_RISC, Version 1.43" document.
+
+2002-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+	* merge.c (_bfd_merge_sections): Don't segfault if there
+	is nothing to merge due to GC.
+
+2002-03-05  Alan Modra  <amodra@bigpond.net.au>
+
+	* elf32-hppa.c (clobber_millicode_symbols): Remove hack to keep
+	symbols that have been forced local.
+
+	* elflink.h (elf_bfd_final_link): Call elf_link_output_extsym
+	to output forced local syms for non-shared link.
+	(elf_link_output_extsym): Tweak condition for calling backend
+	adjust_dynamic_symbol so that previous behaviour is kept.
+	Whitespace changes throughout file.
+
+2002-03-04  H.J. Lu <hjl@gnu.org>
+
+	* elf.c (bfd_section_from_shdr): Handle special sections,
+	.init_array, .fini_array and .preinit_array.
+	(elf_fake_sections): Likewise.
+
+	* elflink.h (NAME(bfd_elf,size_dynamic_sections)): Create the
+	DT entry only if the section is in output for .init_array,
+	.fini_array and .preinit_array. Complain about .preinit_array
+	section in DSO.
+	(elf_bfd_final_link): Warn zero size for .init_array,
+	.fini_array and .preinit_array sections.
+
+	* elfxx-ia64.c (elfNN_ia64_section_from_shdr): Remove
+	SHT_INIT_ARRAY, SHT_FINI_ARRAY and SHT_PREINIT_ARRAY.
+	(elfNN_ia64_fake_sections): Remove .init_array, .fini_array and
+	.preinit_array.
+
+2002-03-04  Alan Modra  <amodra@bigpond.net.au>
+
+	* configure.in (WIN32LIBADD): Don't eval PICFLAG assignment.
+	* configure: Regenerate.
+
 2002-03-02  Tom Rix  <trix@redhat.com>
 
-	* coff64-rs6000.c (xcoff64_howto_table): Replace howto types with 
-	symbolic equiv. 
+	* coff64-rs6000.c (xcoff64_howto_table): Replace howto types with
+	symbolic equiv.
 	* coff-rs6000.c (xcoff_howto_table): Same.
 
 2002-03-01  David Mosberger  <davidm@hpl.hp.com>
diff --git a/bfd/ChangeLog-9495 b/bfd/ChangeLog-9495
index 4657d66..a208f42 100644
--- a/bfd/ChangeLog-9495
+++ b/bfd/ChangeLog-9495
@@ -6887,7 +6887,7 @@
 	* libelf.h (struct elf_obj_tdata): Add new field bad_symtab.
 	(elf_bad_symtab): Define new accessor macro.
 	(_bfd_elf_link_hash_newfunc): Declare.
-	(_bew_elf_link_hash_table_init): Declare.
+	(_bfd_elf_link_hash_table_init): Declare.
 	* elfcode.h (elf_object_p): Call backend object_p hook after
 	swapping in all the section headers.
 	(map_program_segments): Correct typo: Internal for External.
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index fdeb6e6..d6dd2e6 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -213,6 +213,7 @@
 	elf-m10200.lo \
 	elf-m10300.lo \
 	elf32-mcore.lo \
+	elfxx-mips.lo \
 	elf32-mips.lo \
 	elf32-openrisc.lo \
 	elf32-or32.lo \
@@ -360,6 +361,7 @@
 	elf-m10200.c \
 	elf-m10300.c \
 	elf32-mcore.c \
+	elfxx-mips.c \
 	elf32-mips.c \
 	elf32-openrisc.c \
 	elf32-or32.c \
@@ -441,6 +443,7 @@
 # target_vector in targets.c if configured with --enable-targets=all
 # and --enable-64-bit-bfd.
 BFD64_BACKENDS = \
+	aix5ppc-core.lo \
 	aout64.lo \
 	coff-alpha.lo \
 	coff64-rs6000.lo \
@@ -464,6 +467,7 @@
 	pepigen.lo
 
 BFD64_BACKENDS_CFILES = \
+	aix5ppc-core.c \
 	aout64.c \
 	coff-alpha.c \
 	coff64-rs6000.c \
@@ -700,8 +704,8 @@
 dep.sed: dep-in.sed config.status
 	sed <$(srcdir)/dep-in.sed >dep.sed	\
 		-e 's!@BFD_H@!$(BFD_H)!'	\
-		-e 's!@INCDIR@!$(INCDIR)!'	\
-		-e 's!@SRCDIR@!$(srcdir)!'
+		-e 's!@SRCDIR@!$(srcdir)!'	\
+		-e 's!@TOPDIR@!'`echo $(srcdir) | sed -e s,/bfd$$,,`'!'
 
 dep: DEP
 	sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
@@ -1116,12 +1120,17 @@
   $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/mcore.h \
   $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elfxx-mips.lo: elfxx-mips.c $(INCDIR)/filenames.h elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  $(INCDIR)/bfdlink.h elfxx-mips.h $(INCDIR)/elf/mips.h \
+  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
+  $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h
 elf32-mips.lo: elf32-mips.c $(INCDIR)/filenames.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)/elf/reloc-macros.h \
-  $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h \
-  ecoffswap.h elf32-target.h
+  $(INCDIR)/elf/external.h elfxx-mips.h $(INCDIR)/elf/mips.h \
+  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
+  $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h \
+  $(INCDIR)/coff/external.h ecoffswap.h elf32-target.h
 elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h \
@@ -1367,6 +1376,7 @@
 xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \
   libxcoff.h
+aix5ppc-core.lo: aix5ppc-core.c
 aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \
   $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
   $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
@@ -1387,8 +1397,8 @@
   $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
   $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.h
 elf64-x86-64.lo: elf64-x86-64.c $(INCDIR)/filenames.h \
-  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
-  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/x86-64.h \
+  $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/x86-64.h \
   $(INCDIR)/elf/reloc-macros.h elf64-target.h
 elf64-alpha.lo: elf64-alpha.c $(INCDIR)/filenames.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
@@ -1407,10 +1417,11 @@
   $(INCDIR)/bfdlink.h elf64-target.h
 elf64-mips.lo: elf64-mips.c $(INCDIR)/filenames.h $(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)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
-  $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h \
-  ecoffswap.h elf64-target.h
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfxx-mips.h \
+  $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h \
+  $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
+  $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \
+  elf64-target.h
 elf64-mmix.lo: elf64-mmix.c $(INCDIR)/filenames.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/elf/mmix.h $(INCDIR)/elf/reloc-macros.h \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 716b439..e3cc126 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -341,6 +341,7 @@
 	elf-m10200.lo \
 	elf-m10300.lo \
 	elf32-mcore.lo \
+	elfxx-mips.lo \
 	elf32-mips.lo \
 	elf32-openrisc.lo \
 	elf32-or32.lo \
@@ -489,6 +490,7 @@
 	elf-m10200.c \
 	elf-m10300.c \
 	elf32-mcore.c \
+	elfxx-mips.c \
 	elf32-mips.c \
 	elf32-openrisc.c \
 	elf32-or32.c \
@@ -571,6 +573,7 @@
 # target_vector in targets.c if configured with --enable-targets=all
 # and --enable-64-bit-bfd.
 BFD64_BACKENDS = \
+	aix5ppc-core.lo \
 	aout64.lo \
 	coff-alpha.lo \
 	coff64-rs6000.lo \
@@ -595,6 +598,7 @@
 
 
 BFD64_BACKENDS_CFILES = \
+	aix5ppc-core.c \
 	aout64.c \
 	coff-alpha.c \
 	coff64-rs6000.c \
@@ -1258,8 +1262,8 @@
 dep.sed: dep-in.sed config.status
 	sed <$(srcdir)/dep-in.sed >dep.sed	\
 		-e 's!@BFD_H@!$(BFD_H)!'	\
-		-e 's!@INCDIR@!$(INCDIR)!'	\
-		-e 's!@SRCDIR@!$(srcdir)!'
+		-e 's!@SRCDIR@!$(srcdir)!'	\
+		-e 's!@TOPDIR@!'`echo $(srcdir) | sed -e s,/bfd$$,,`'!'
 
 dep: DEP
 	sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
@@ -1660,12 +1664,17 @@
   $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/mcore.h \
   $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elfxx-mips.lo: elfxx-mips.c $(INCDIR)/filenames.h elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  $(INCDIR)/bfdlink.h elfxx-mips.h $(INCDIR)/elf/mips.h \
+  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
+  $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h
 elf32-mips.lo: elf32-mips.c $(INCDIR)/filenames.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)/elf/reloc-macros.h \
-  $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h \
-  ecoffswap.h elf32-target.h
+  $(INCDIR)/elf/external.h elfxx-mips.h $(INCDIR)/elf/mips.h \
+  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
+  $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h \
+  $(INCDIR)/coff/external.h ecoffswap.h elf32-target.h
 elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h \
@@ -1911,6 +1920,7 @@
 xcofflink.lo: xcofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/coff/internal.h $(INCDIR)/coff/xcoff.h libcoff.h \
   libxcoff.h
+aix5ppc-core.lo: aix5ppc-core.c
 aout64.lo: aout64.c aoutx.h $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \
   $(INCDIR)/bfdlink.h libaout.h $(INCDIR)/aout/aout64.h \
   $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
@@ -1931,8 +1941,8 @@
   $(INCDIR)/coff/internal.h $(INCDIR)/coff/pe.h libcoff.h \
   $(INCDIR)/bfdlink.h coffcode.h peicode.h libpei.h
 elf64-x86-64.lo: elf64-x86-64.c $(INCDIR)/filenames.h \
-  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
-  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/x86-64.h \
+  $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/x86-64.h \
   $(INCDIR)/elf/reloc-macros.h elf64-target.h
 elf64-alpha.lo: elf64-alpha.c $(INCDIR)/filenames.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
@@ -1951,10 +1961,11 @@
   $(INCDIR)/bfdlink.h elf64-target.h
 elf64-mips.lo: elf64-mips.c $(INCDIR)/filenames.h $(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)/elf/reloc-macros.h $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h \
-  $(INCDIR)/coff/internal.h $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h \
-  ecoffswap.h elf64-target.h
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfxx-mips.h \
+  $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h \
+  $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
+  $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/alpha.h ecoffswap.h \
+  elf64-target.h
 elf64-mmix.lo: elf64-mmix.c $(INCDIR)/filenames.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/elf/mmix.h $(INCDIR)/elf/reloc-macros.h \
diff --git a/bfd/aix5ppc-core.c b/bfd/aix5ppc-core.c
new file mode 100644
index 0000000..5ba182f
--- /dev/null
+++ b/bfd/aix5ppc-core.c
@@ -0,0 +1,359 @@
+/* IBM RS/6000 "XCOFF" back-end for BFD.
+   Copyright 2001, 2002
+   Free Software Foundation, Inc.
+   Written by Tom Rix
+   Contributed by Redhat.
+
+   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"
+
+#ifdef AIX_5_CORE
+
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_target * xcoff64_core_p PARAMS ((bfd *));
+boolean            xcoff64_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
+char *             xcoff64_core_file_failing_command PARAMS ((bfd *));
+int                xcoff64_core_file_failing_signal PARAMS ((bfd *));
+
+/* Aix 5.1 system include file.  */
+
+/* Need to define this macro so struct ld_info64 get included.  */
+#define __LDINFO_PTRACE64__
+#include <sys/ldr.h>
+#include <core.h>
+
+#define	core_hdr(abfd)		((struct core_dumpxx *) abfd->tdata.any)
+
+#define CHECK_FILE_OFFSET(s, v) \
+  ((bfd_signed_vma)(v) < 0 || (bfd_signed_vma)(v) > (bfd_signed_vma)(s).st_size)
+
+const bfd_target *
+xcoff64_core_p (abfd)
+     bfd *abfd;
+{
+  struct core_dumpxx core, *new_core_hdr;
+  struct stat statbuf;
+  asection *sec;
+  struct __ld_info64 ldinfo;
+  bfd_vma ld_offset;
+  bfd_size_type i;
+  struct vm_infox vminfo;
+  bfd_target *return_value = NULL;
+
+  /* Get the header.  */
+  if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+    goto xcoff64_core_p_error;
+
+  if (sizeof (struct core_dumpxx) 
+      != bfd_read (&core, sizeof (struct core_dumpxx), 1, abfd))
+    goto xcoff64_core_p_error;
+
+  if (bfd_stat (abfd, &statbuf) < 0) 
+    goto xcoff64_core_p_error;
+
+  /* Sanity checks
+     c_flag has CORE_VERSION_1, Aix 4+
+     c_entries = 0 for Aix 4.3+
+     IS_PROC64 is a macro defined in procinfo.h, test for 64 bit process.
+
+     We will still be confused if a Aix 4.3 64 bit core file is
+     copied over to a Aix 5 machine.
+
+     Check file header offsets
+
+     See rs6000-core.c for comment on size of core
+     If there isn't enough of a real core file, bail.  */
+
+  if ((CORE_VERSION_1 != (core.c_flag & CORE_VERSION_1)) 
+      || (0 != core.c_entries) 
+      || (! (IS_PROC64 (&core.c_u.U_proc))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_fdsinfox))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_loader))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_loader + core.c_lsize))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_thr))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_segregion))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_stack))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_stack + core.c_size))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_data))) 
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_data + core.c_datasize))) 
+      || (! (core.c_flag & UBLOCK_VALID)) 
+      || (! (core.c_flag & LE_VALID))) 
+    goto xcoff64_core_p_error;
+
+  /* Check for trucated stack or general truncating.  */
+  if ((! (core.c_flag & USTACK_VALID)) 
+      || (core.c_flag & CORE_TRUNC))
+    {
+      bfd_set_error (bfd_error_file_truncated);
+
+      return return_value;
+    }
+
+  new_core_hdr = (struct core_dumpxx *)
+    bfd_zalloc (abfd, sizeof (struct core_dumpxx));
+  if (NULL == new_core_hdr) 
+    return return_value;
+
+  memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
+  core_hdr(abfd) = (char *)new_core_hdr;
+
+  /* .stack section.  */
+  sec = bfd_make_section_anyway (abfd, ".stack");
+  if (NULL == sec) 
+    return return_value;
+
+  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  sec->_raw_size = core.c_size;
+  sec->vma = core.c_stackorg;
+  sec->filepos = core.c_stack;
+
+  /* .reg section for all registers.  */
+  sec = bfd_make_section_anyway (abfd, ".reg");
+  if (NULL == sec) 
+    return return_value;
+
+  sec->flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+  sec->_raw_size = sizeof (struct __context64);
+  sec->vma = 0;
+  sec->filepos = 0;
+  sec->contents = (bfd_byte *)&new_core_hdr->c_flt.r64;
+
+  /* .ldinfo section.
+     To actually find out how long this section is in this particular
+     core dump would require going down the whole list of struct 
+     ld_info's.   See if we can just fake it.  */
+  sec = bfd_make_section_anyway (abfd, ".ldinfo");
+  if (NULL == sec)
+    return return_value;
+
+  sec->flags = SEC_HAS_CONTENTS;
+  sec->_raw_size = core.c_lsize;
+  sec->vma = 0;
+  sec->filepos = core.c_loader;
+
+  /* AIX 4 adds data sections from loaded objects to the core file,
+     which can be found by examining ldinfo, and anonymously mmapped
+     regions.  */
+  
+  /* .data section from executable.  */
+  sec = bfd_make_section_anyway (abfd, ".data");
+  if (NULL == sec) 
+    return return_value;
+
+  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  sec->_raw_size = core.c_datasize;
+  sec->vma = core.c_dataorg;
+  sec->filepos = core.c_data;
+
+  /* .data sections from loaded objects.  */
+  ld_offset = core.c_loader;
+	
+  while (1) 
+    {
+      if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0) 
+	return return_value;
+
+      if (sizeof (struct __ld_info64) !=
+	  bfd_read (&ldinfo, sizeof (struct __ld_info64), 1, abfd)) 
+	return return_value;
+
+      if (ldinfo.ldinfo_core) 
+	{
+	  sec = bfd_make_section_anyway (abfd, ".data");
+	  if (NULL == sec) 
+	    return return_value;
+
+	  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+	  sec->_raw_size = ldinfo.ldinfo_datasize;
+	  sec->vma = ldinfo.ldinfo_dataorg;
+	  sec->filepos = ldinfo.ldinfo_core;
+	}
+
+      if (0 == ldinfo.ldinfo_next)
+	break;
+      ld_offset += ldinfo.ldinfo_next;
+    }
+
+  /* .vmdata sections from anonymously mmapped regions.  */
+  if (core.c_vmregions) 
+    {
+      if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0) 
+	return return_value;
+
+      for (i = 0; i < core.c_vmregions; i++) 
+	if (sizeof (struct vm_infox) !=
+	    bfd_read (&vminfo, sizeof (struct vm_infox), 1, abfd)) 
+	  return return_value;
+
+      if (vminfo.vminfo_offset) 
+	{
+	  sec = bfd_make_section_anyway (abfd, ".vmdata");
+	  if (NULL == sec) 
+	    return return_value;
+
+	  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+	  sec->_raw_size = vminfo.vminfo_size;
+	  sec->vma = vminfo.vminfo_addr;
+	  sec->filepos = vminfo.vminfo_offset;
+	}
+    }
+
+  return_value = abfd->xvec;	/* This is garbage for now.  */
+	
+ xcoff64_core_p_error:
+  if (bfd_get_error () != bfd_error_system_call) 
+    bfd_set_error (bfd_error_wrong_format);
+  
+  return return_value;
+}
+
+/* Return `true' if given core is from the given executable.  */
+
+boolean
+xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
+     bfd *core_bfd;
+     bfd *exec_bfd;
+{
+  struct core_dumpxx core;
+  char *path, *s;
+  size_t alloc;
+  const char *str1, *str2;
+  boolean return_value = false;
+
+  /* Get the header.  */
+  if (bfd_seek (core_bfd, 0, SEEK_SET) != 0) 
+    return return_value;
+	
+  if (sizeof (struct core_dumpxx) !=
+      bfd_read (&core, sizeof (struct core_dumpxx), 1, core_bfd)) 
+    return return_value;
+
+  if (bfd_seek (core_bfd, core.c_loader, SEEK_SET) != 0) 
+    return return_value;
+
+  alloc = 100;
+  path = bfd_malloc (alloc);
+  if (path == NULL) 
+    return return_value;
+
+  s = path;
+
+  while (1)
+    {
+      if (bfd_read (s, 1, 1, core_bfd) != 1)
+	goto xcoff64_core_file_matches_executable_p_end_1;
+
+      if (*s == '\0')
+	break;
+      ++s;
+      if (s == path + alloc) 
+	{
+	  char *n;
+
+	  alloc *= 2;
+	  n = bfd_realloc (path, alloc);
+	  if (n == NULL) 
+	    goto xcoff64_core_file_matches_executable_p_end_1;
+
+	  s = n + (path - s);
+	  path = n;
+	}
+    }
+
+  str1 = strrchr (path, '/');
+  str2 = strrchr (exec_bfd->filename, '/');
+
+  /* Step over character '/'.  */
+  str1 = str1 != NULL ? str1 + 1 : path;
+  str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
+
+  if (strcmp (str1, str2) == 0) 
+    return_value = true;
+
+ xcoff64_core_file_matches_executable_p_end_1:
+  free (path);
+  return return_value;
+}
+
+char *
+xcoff64_core_file_failing_command (abfd)
+     bfd *abfd;
+{
+  struct core_dumpxx *c = core_hdr (abfd);
+  char *return_value = 0;
+
+  if (NULL != c) 
+    return_value = c->c_u.U_proc.pi_comm;
+
+  return return_value;
+}
+
+int
+xcoff64_core_file_failing_signal (abfd)
+     bfd *abfd;
+{
+  struct core_dumpxx *c = core_hdr (abfd);
+  int return_value = 0;
+
+  if (NULL != c) 
+    return_value = c->c_signo;
+
+  return return_value;
+}
+
+#else /* AIX_5_CORE */
+
+const bfd_target * xcoff64_core_p PARAMS ((bfd *));
+boolean            xcoff64_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
+char *             xcoff64_core_file_failing_command PARAMS ((bfd *));
+int                xcoff64_core_file_failing_signal PARAMS ((bfd *));
+
+const bfd_target *
+xcoff64_core_p (abfd)
+     bfd *abfd;
+{
+  bfd_set_error (bfd_error_wrong_format);
+  return 0;
+}
+
+boolean
+xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
+     bfd *core_bfd;
+     bfd *exec_bfd;
+{
+  return false;
+}
+
+char *
+xcoff64_core_file_failing_command (abfd)
+     bfd *abfd;
+{
+  return 0;
+}
+
+int
+xcoff64_core_file_failing_signal (abfd)
+     bfd *abfd;
+{
+  return 0;
+}
+
+#endif /* AIX_5_CORE */
diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c
index 72fed35..01f2691 100644
--- a/bfd/aout-adobe.c
+++ b/bfd/aout-adobe.c
@@ -1,5 +1,6 @@
 /* BFD back-end for a.out.adobe binaries.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+   2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.  Based on bout.c.
 
@@ -511,6 +512,8 @@
 #define aout_32_bfd_merge_sections	bfd_generic_merge_sections
 #define aout_32_bfd_link_hash_table_create \
   _bfd_generic_link_hash_table_create
+#define aout_32_bfd_link_hash_table_free \
+  _bfd_generic_link_hash_table_free
 #define aout_32_bfd_link_add_symbols	_bfd_generic_link_add_symbols
 #define aout_32_bfd_final_link		_bfd_generic_final_link
 #define aout_32_bfd_link_split_section	_bfd_generic_link_split_section
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index ccedb93..30c735a 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -1,6 +1,6 @@
 /* Define a target vector and some small routines for a variant of a.out.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -528,6 +528,9 @@
 #ifndef MY_bfd_link_hash_table_create
 #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
 #endif
+#ifndef MY_bfd_link_hash_table_free
+#define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#endif
 #ifndef MY_bfd_link_add_symbols
 #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
 #endif
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index e3c74fa..58ef3ea 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -1,5 +1,5 @@
 /* BFD back-end for TMS320C30 a.out binaries.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -980,6 +980,9 @@
 #ifndef MY_bfd_link_hash_table_create
 #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
 #endif
+#ifndef MY_bfd_link_hash_table_free
+#define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#endif
 #ifndef MY_bfd_link_add_symbols
 #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
 #endif
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 0a3c05a..3c9cd4f 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1,6 +1,6 @@
 /* BFD semi-generic back-end for a.out binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001
+   2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -4577,6 +4577,13 @@
   bfd_size_type indx;
   bfd_size_type amt;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h = (struct aout_link_hash_entry *) h->root.u.i.link;
+      if (h->root.type == bfd_link_hash_new)
+	return true;
+    }
+
   output_bfd = finfo->output_bfd;
 
   if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
@@ -4605,6 +4612,7 @@
   switch (h->root.type)
     {
     default:
+    case bfd_link_hash_warning:
       abort ();
       /* Avoid variable not initialized warnings.  */
       return true;
@@ -4646,9 +4654,8 @@
       type = N_WEAKU;
       val = 0;
     case bfd_link_hash_indirect:
-    case bfd_link_hash_warning:
-      /* FIXME: Ignore these for now.  The circumstances under which
-	 they should be written out are not clear to me.  */
+      /* We ignore these symbols, since the indirected symbol is
+	 already in the hash table.  */
       return true;
     }
 
diff --git a/bfd/archive.c b/bfd/archive.c
index fc2ba45..e9e07c5 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1,6 +1,6 @@
 /* BFD back-end for archive files (libraries).
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
 
@@ -2190,7 +2190,8 @@
       != sizeof (struct ar_hdr))
     return false;
 
-  bfd_write_bigendian_4byte_int (arch, symbol_count);
+  if (!bfd_write_bigendian_4byte_int (arch, symbol_count))
+    return false;
 
   /* Two passes, first write the file offsets for each symbol -
      remembering that each offset is on a two byte boundary.  */
@@ -2207,7 +2208,8 @@
 
       while (count < symbol_count && map[count].u.abfd == current)
 	{
-	  bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
+	  if (!bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr))
+	    return false;
 	  count++;
 	}
       /* Add size of this archive entry.  */
diff --git a/bfd/archures.c b/bfd/archures.c
index fb2ba9b..40102e8 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -288,7 +288,9 @@
 .  const char *arch_name;
 .  const char *printable_name;
 .  unsigned int section_align_power;
-.  {* True if this is the default machine for the architecture.  *}
+.  {* True if this is the default machine for the architecture.
+.     The default arch should be the first entry for an arch so that
+.     all the entries for that arch can be accessed via <<next>>.  *}
 .  boolean the_default;
 .  const struct bfd_arch_info * (*compatible)
 .	PARAMS ((const struct bfd_arch_info *a,
@@ -604,21 +606,9 @@
      enum bfd_architecture arch;
      unsigned long mach;
 {
-  const bfd_arch_info_type * const *app, *ap;
-
-  for (app = bfd_archures_list; *app != NULL; app++)
-    {
-      for (ap = *app; ap != NULL; ap = ap->next)
-	{
-	  if (ap->arch == arch
-	      && (ap->mach == mach
-		  || (mach == 0 && ap->the_default)))
-	    {
-	      abfd->arch_info = ap;
-	      return true;
-	    }
-	}
-    }
+  abfd->arch_info = bfd_lookup_arch (arch, mach);
+  if (abfd->arch_info != NULL)
+    return true;
 
   abfd->arch_info = &bfd_default_arch_struct;
   bfd_set_error (bfd_error_bad_value);
@@ -722,6 +712,9 @@
   if (a->arch != b->arch)
     return NULL;
 
+  if (a->bits_per_word != b->bits_per_word)
+    return NULL;
+
   if (a->mach > b->mach)
     return a;
 
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 5c21e1d..8c36c67 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -334,6 +334,7 @@
 
 #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
 #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
+#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
 #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
 #define bfd_section_name(bfd, ptr) ((ptr)->name)
 #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
@@ -345,7 +346,7 @@
 
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
 
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
+#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = (boolean)true), true)
 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
 
@@ -749,6 +750,9 @@
 extern boolean bfd_xcoff_link_generate_rtinit
   PARAMS ((bfd *, const char *, const char *, boolean));
 
+/* XCOFF support routines for ar.  */
+extern boolean bfd_xcoff_ar_archive_set_magic PARAMS ((bfd *, char *));
+
 /* Externally visible COFF routines.  */
 
 #if defined(__STDC__) || defined(ALMOST_STDC)
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index a582806..774d439 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -340,6 +340,7 @@
 
 #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
 #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
+#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
 #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
 #define bfd_section_name(bfd, ptr) ((ptr)->name)
 #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
@@ -351,7 +352,7 @@
 
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
 
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
+#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = (boolean)true), true)
 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
 
@@ -755,6 +756,9 @@
 extern boolean bfd_xcoff_link_generate_rtinit
   PARAMS ((bfd *, const char *, const char *, boolean));
 
+/* XCOFF support routines for ar.  */
+extern boolean bfd_xcoff_ar_archive_set_magic PARAMS ((bfd *, char *));
+
 /* Externally visible COFF routines.  */
 
 #if defined(__STDC__) || defined(ALMOST_STDC)
@@ -1657,7 +1661,9 @@
   const char *arch_name;
   const char *printable_name;
   unsigned int section_align_power;
-  /* True if this is the default machine for the architecture.  */
+  /* True if this is the default machine for the architecture.
+     The default arch should be the first entry for an arch so that
+     all the entries for that arch can be accessed via <<next>>.  */
   boolean the_default;
   const struct bfd_arch_info * (*compatible)
        PARAMS ((const struct bfd_arch_info *a,
@@ -2194,55 +2200,6 @@
   BFD_RELOC_MIPS_REL16,
   BFD_RELOC_MIPS_RELGOT,
   BFD_RELOC_MIPS_JALR,
-  BFD_RELOC_SH_GOT_LOW16,
-  BFD_RELOC_SH_GOT_MEDLOW16,
-  BFD_RELOC_SH_GOT_MEDHI16,
-  BFD_RELOC_SH_GOT_HI16,
-  BFD_RELOC_SH_GOTPLT_LOW16,
-  BFD_RELOC_SH_GOTPLT_MEDLOW16,
-  BFD_RELOC_SH_GOTPLT_MEDHI16,
-  BFD_RELOC_SH_GOTPLT_HI16,
-  BFD_RELOC_SH_PLT_LOW16,
-  BFD_RELOC_SH_PLT_MEDLOW16,
-  BFD_RELOC_SH_PLT_MEDHI16,
-  BFD_RELOC_SH_PLT_HI16,
-  BFD_RELOC_SH_GOTOFF_LOW16,
-  BFD_RELOC_SH_GOTOFF_MEDLOW16,
-  BFD_RELOC_SH_GOTOFF_MEDHI16,
-  BFD_RELOC_SH_GOTOFF_HI16,
-  BFD_RELOC_SH_GOTPC_LOW16,
-  BFD_RELOC_SH_GOTPC_MEDLOW16,
-  BFD_RELOC_SH_GOTPC_MEDHI16,
-  BFD_RELOC_SH_GOTPC_HI16,
-  BFD_RELOC_SH_COPY64,
-  BFD_RELOC_SH_GLOB_DAT64,
-  BFD_RELOC_SH_JMP_SLOT64,
-  BFD_RELOC_SH_RELATIVE64,
-  BFD_RELOC_SH_GOT10BY4,
-  BFD_RELOC_SH_GOT10BY8,
-  BFD_RELOC_SH_GOTPLT10BY4,
-  BFD_RELOC_SH_GOTPLT10BY8,
-  BFD_RELOC_SH_GOTPLT32,
-  BFD_RELOC_SH_SHMEDIA_CODE,
-  BFD_RELOC_SH_IMMU5,
-  BFD_RELOC_SH_IMMS6,
-  BFD_RELOC_SH_IMMS6BY32,
-  BFD_RELOC_SH_IMMU6,
-  BFD_RELOC_SH_IMMS10,
-  BFD_RELOC_SH_IMMS10BY2,
-  BFD_RELOC_SH_IMMS10BY4,
-  BFD_RELOC_SH_IMMS10BY8,
-  BFD_RELOC_SH_IMMS16,
-  BFD_RELOC_SH_IMMU16,
-  BFD_RELOC_SH_IMM_LOW16,
-  BFD_RELOC_SH_IMM_LOW16_PCREL,
-  BFD_RELOC_SH_IMM_MEDLOW16,
-  BFD_RELOC_SH_IMM_MEDLOW16_PCREL,
-  BFD_RELOC_SH_IMM_MEDHI16,
-  BFD_RELOC_SH_IMM_MEDHI16_PCREL,
-  BFD_RELOC_SH_IMM_HI16,
-  BFD_RELOC_SH_IMM_HI16_PCREL,
-  BFD_RELOC_SH_PT_16,
 
 
 /* i386/elf relocations  */
@@ -2423,6 +2380,55 @@
   BFD_RELOC_SH_JMP_SLOT,
   BFD_RELOC_SH_RELATIVE,
   BFD_RELOC_SH_GOTPC,
+  BFD_RELOC_SH_GOT_LOW16,
+  BFD_RELOC_SH_GOT_MEDLOW16,
+  BFD_RELOC_SH_GOT_MEDHI16,
+  BFD_RELOC_SH_GOT_HI16,
+  BFD_RELOC_SH_GOTPLT_LOW16,
+  BFD_RELOC_SH_GOTPLT_MEDLOW16,
+  BFD_RELOC_SH_GOTPLT_MEDHI16,
+  BFD_RELOC_SH_GOTPLT_HI16,
+  BFD_RELOC_SH_PLT_LOW16,
+  BFD_RELOC_SH_PLT_MEDLOW16,
+  BFD_RELOC_SH_PLT_MEDHI16,
+  BFD_RELOC_SH_PLT_HI16,
+  BFD_RELOC_SH_GOTOFF_LOW16,
+  BFD_RELOC_SH_GOTOFF_MEDLOW16,
+  BFD_RELOC_SH_GOTOFF_MEDHI16,
+  BFD_RELOC_SH_GOTOFF_HI16,
+  BFD_RELOC_SH_GOTPC_LOW16,
+  BFD_RELOC_SH_GOTPC_MEDLOW16,
+  BFD_RELOC_SH_GOTPC_MEDHI16,
+  BFD_RELOC_SH_GOTPC_HI16,
+  BFD_RELOC_SH_COPY64,
+  BFD_RELOC_SH_GLOB_DAT64,
+  BFD_RELOC_SH_JMP_SLOT64,
+  BFD_RELOC_SH_RELATIVE64,
+  BFD_RELOC_SH_GOT10BY4,
+  BFD_RELOC_SH_GOT10BY8,
+  BFD_RELOC_SH_GOTPLT10BY4,
+  BFD_RELOC_SH_GOTPLT10BY8,
+  BFD_RELOC_SH_GOTPLT32,
+  BFD_RELOC_SH_SHMEDIA_CODE,
+  BFD_RELOC_SH_IMMU5,
+  BFD_RELOC_SH_IMMS6,
+  BFD_RELOC_SH_IMMS6BY32,
+  BFD_RELOC_SH_IMMU6,
+  BFD_RELOC_SH_IMMS10,
+  BFD_RELOC_SH_IMMS10BY2,
+  BFD_RELOC_SH_IMMS10BY4,
+  BFD_RELOC_SH_IMMS10BY8,
+  BFD_RELOC_SH_IMMS16,
+  BFD_RELOC_SH_IMMU16,
+  BFD_RELOC_SH_IMM_LOW16,
+  BFD_RELOC_SH_IMM_LOW16_PCREL,
+  BFD_RELOC_SH_IMM_MEDLOW16,
+  BFD_RELOC_SH_IMM_MEDLOW16_PCREL,
+  BFD_RELOC_SH_IMM_MEDHI16,
+  BFD_RELOC_SH_IMM_MEDHI16_PCREL,
+  BFD_RELOC_SH_IMM_HI16,
+  BFD_RELOC_SH_IMM_HI16_PCREL,
+  BFD_RELOC_SH_PT_16,
 
 /* Thumb 23-, 12- and 9-bit pc-relative branches.  The lowest bit must
 be zero and is not stored in the instruction.  */
@@ -3498,6 +3504,9 @@
 #define bfd_link_hash_table_create(abfd) \
        BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
 
+#define bfd_link_hash_table_free(abfd, hash) \
+       BFD_SEND (abfd, _bfd_link_hash_table_free, (hash))
+
 #define bfd_link_add_symbols(abfd, info) \
        BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
 
@@ -3823,6 +3832,7 @@
 CONCAT2 (NAME,_bfd_get_relocated_section_contents), \
 CONCAT2 (NAME,_bfd_relax_section), \
 CONCAT2 (NAME,_bfd_link_hash_table_create), \
+CONCAT2 (NAME,_bfd_link_hash_table_free), \
 CONCAT2 (NAME,_bfd_link_add_symbols), \
 CONCAT2 (NAME,_bfd_final_link), \
 CONCAT2 (NAME,_bfd_link_split_section), \
@@ -3840,6 +3850,9 @@
      different information in this table.  */
   struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
 
+  /* Release the memory associated with the linker hash table.  */
+  void (*_bfd_link_hash_table_free) PARAMS ((struct bfd_link_hash_table *));
+
   /* Add symbols from this object file into the hash table.  */
   boolean  (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
 
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 5795383..c1135c8 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1189,6 +1189,9 @@
 .#define bfd_link_hash_table_create(abfd) \
 .	BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
 .
+.#define bfd_link_hash_table_free(abfd, hash) \
+.	BFD_SEND (abfd, _bfd_link_hash_table_free, (hash))
+.
 .#define bfd_link_add_symbols(abfd, info) \
 .	BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
 .
diff --git a/bfd/binary.c b/bfd/binary.c
index 705ac8f..3207e89 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -1,5 +1,5 @@
 /* BFD back-end for binary objects.
-   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
 
@@ -338,6 +338,7 @@
 #define binary_bfd_gc_sections bfd_generic_gc_sections
 #define binary_bfd_merge_sections bfd_generic_merge_sections
 #define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define binary_bfd_final_link _bfd_generic_final_link
 #define binary_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/bout.c b/bfd/bout.c
index 13e4f04..0e070ad 100644
--- a/bfd/bout.c
+++ b/bfd/bout.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel 960 b.out binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -1449,6 +1449,7 @@
 #define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
 
 #define b_out_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define b_out_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define b_out_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define b_out_bfd_final_link _bfd_generic_final_link
 #define b_out_bfd_link_split_section  _bfd_generic_link_split_section
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
index ca08131..1619e67 100644
--- a/bfd/coff-arm.c
+++ b/bfd/coff-arm.c
@@ -1,6 +1,6 @@
 /* BFD back-end for ARM COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -87,12 +87,16 @@
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type aoutarm_fix_pcrel_26
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+#ifndef ARM_WINCE
 static bfd_reloc_status_type coff_thumb_pcrel_23
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type coff_thumb_pcrel_12
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type coff_thumb_pcrel_9
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static insn32 insert_thumb_branch
+  PARAMS ((insn32, int));
+#endif
+static bfd_reloc_status_type coff_thumb_pcrel_12
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type coff_arm_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static boolean coff_arm_adjust_symndx
@@ -109,8 +113,6 @@
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static struct bfd_link_hash_table * coff_arm_link_hash_table_create
   PARAMS ((bfd *));
-static insn32 insert_thumb_branch
-  PARAMS ((insn32, int));
 static struct coff_link_hash_entry * find_thumb_glue
   PARAMS ((struct bfd_link_info *, const char *, bfd *));
 static struct coff_link_hash_entry * find_arm_glue
@@ -118,9 +120,11 @@
 #ifndef COFF_IMAGE_WITH_PE
 static void record_arm_to_thumb_glue
   PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
+#ifndef ARM_WINCE
 static void record_thumb_to_arm_glue
   PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
 #endif
+#endif
 static boolean coff_arm_merge_private_bfd_data
   PARAMS ((bfd *, bfd *));
 static boolean coff_arm_print_private_bfd_data
@@ -801,6 +805,7 @@
   return flag;
 }
 
+#ifndef ARM_WINCE
 static bfd_reloc_status_type
 coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section,
 		     output_bfd, error_message)
@@ -818,22 +823,6 @@
 }
 
 static bfd_reloc_status_type
-coff_thumb_pcrel_12 (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;
-{
-  return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
-                                  input_section, output_bfd, error_message,
-				  b12);
-}
-
-static bfd_reloc_status_type
 coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section,
 		     output_bfd, error_message)
      bfd *abfd;
@@ -848,6 +837,23 @@
                                   input_section, output_bfd, error_message,
 				  b9);
 }
+#endif /* not ARM_WINCE */
+
+static bfd_reloc_status_type
+coff_thumb_pcrel_12 (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;
+{
+  return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
+                                  input_section, output_bfd, error_message,
+				  b12);
+}
 
 static const struct reloc_howto_struct *
 coff_arm_reloc_type_lookup (abfd, code)
@@ -900,6 +906,13 @@
 #define BADMAG(x) ARMBADMAG(x)
 #define ARM 1			/* Customize coffcode.h */
 
+#ifndef ARM_WINCE
+/* Make sure that the 'r_offset' field is copied properly
+   so that identical binaries will compare the same.  */
+#define SWAP_IN_RELOC_OFFSET	H_GET_32
+#define SWAP_OUT_RELOC_OFFSET	H_PUT_32
+#endif
+
 /* Extend the coff_link_hash_table structure with a few ARM specific fields.
    This allows us to store global data here without actually creating any
    global variables, which is a no-no in the BFD world.  */
@@ -934,14 +947,14 @@
   struct coff_arm_link_hash_table * ret;
   bfd_size_type amt = sizeof (struct coff_arm_link_hash_table);
 
-  ret = (struct coff_arm_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct coff_arm_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct coff_arm_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_coff_link_hash_table_init
       (& ret->root, abfd, _bfd_coff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
 
@@ -970,6 +983,7 @@
 
 }
 
+#ifndef ARM_WINCE
 /* The thumb form of a long branch is a bit finicky, because the offset
    encoding is split over two fields, each in it's own instruction. They
    can occur in any order. So given a thumb form of long branch, and an
@@ -1026,6 +1040,7 @@
 
   return br_insn;
 }
+
 
 static struct coff_link_hash_entry *
 find_thumb_glue (info, name, input_bfd)
@@ -1055,6 +1070,7 @@
 
   return myh;
 }
+#endif /* not ARM_WINCE */
 
 static struct coff_link_hash_entry *
 find_arm_glue (info, name, input_bfd)
@@ -1909,6 +1925,7 @@
   return;
 }
 
+#ifndef ARM_WINCE
 static void
 record_thumb_to_arm_glue (info, h)
      struct bfd_link_info *        info;
@@ -1982,6 +1999,7 @@
 
   return;
 }
+#endif /* not ARM_WINCE */
 
 /* Select a BFD to be used to hold the sections used by the glue code.
    This function is called from the linker scripts in ld/emultempl/
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c
index 7ce4208..82b7bca 100644
--- a/bfd/coff-h8300.c
+++ b/bfd/coff-h8300.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Hitachi H8/300 COFF binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Steve Chamberlain, <sac@cygnus.com>.
 
@@ -186,13 +186,13 @@
   struct h8300_coff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct h8300_coff_link_hash_table);
 
-  ret = (struct h8300_coff_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct h8300_coff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
   if (!_bfd_link_hash_table_init (&ret->root.root, abfd,
 				  _bfd_generic_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
index 9603e02..f15102d 100644
--- a/bfd/coff-mcore.c
+++ b/bfd/coff-mcore.c
@@ -1,5 +1,5 @@
 /* BFD back-end for Motorola MCore COFF/PE
-   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -229,14 +229,14 @@
 {
   mcore_hash_table * ret;
 
-  ret = (mcore_hash_table *) bfd_alloc (abfd, (bfd_size_type) sizeof (* ret));
+  ret = (mcore_hash_table *) bfd_malloc ((bfd_size_type) sizeof (* ret));
   if (ret == (mcore_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_coff_link_hash_table_init
       (& ret->root, abfd, _bfd_coff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
 
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index f2bdfe5..4f8b15e 100644
--- a/bfd/coff-ppc.c
+++ b/bfd/coff-ppc.c
@@ -1,6 +1,6 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila (krk@cygnus.com)
@@ -204,13 +204,13 @@
   struct ppc_coff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table);
 
-  ret = (struct ppc_coff_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
   if (! ppc_coff_link_hash_table_init (ret, abfd,
 					ppc_coff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
   return &ret->root.root;
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index c01c1b1..b1db78f 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -45,7 +45,7 @@
 extern const bfd_target *_bfd_xcoff_archive_p PARAMS ((bfd *));
 extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
 extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
-extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
+extern int _bfd_xcoff_stat_arch_elt PARAMS ((bfd *, struct stat *));
 extern boolean _bfd_xcoff_write_armap
   PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
 extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
@@ -54,9 +54,11 @@
 extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
 extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
 extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static void xcoff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int xcoff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
 
-/* Forward declare _bfd_xcoff_rtype2howto for coffcode.h macro.  */
-void _bfd_xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *));
+/* Forward declare xcoff_rtype2howto for coffcode.h macro.  */
+void xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *));
 
 /* coffcode.h needs these to be defined.  */
 #define RS6000COFF_C 1
@@ -74,7 +76,7 @@
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
 #define COFF_LONG_FILENAMES
 #define NO_COFF_SYMBOLS
-#define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
+#define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst)
 #define coff_mkobject _bfd_xcoff_mkobject
 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
@@ -105,6 +107,9 @@
 #define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
 #define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in
 #define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out
+#define coff_swap_reloc_in xcoff_swap_reloc_in
+#define coff_swap_reloc_out xcoff_swap_reloc_out
+#define NO_COFF_RELOCS
 
 #include "coffcode.h"
 
@@ -145,6 +150,71 @@
   PARAMS ((bfd *, struct internal_ldhdr *));
 static boolean xcoff_generate_rtinit 
   PARAMS((bfd *, const char *, const char *, boolean));
+static boolean do_pad PARAMS((bfd *, unsigned int));
+static boolean do_copy PARAMS((bfd *, bfd *));
+static boolean do_shared_object_padding PARAMS ((bfd *, bfd *, ufile_ptr *, int));
+
+/* Relocation functions */
+static boolean xcoff_reloc_type_noop PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_fail PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_pos PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_neg PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_rel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_toc PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_ba PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_br PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+static boolean xcoff_reloc_type_crel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+
+static boolean xcoff_complain_overflow_dont_func 
+  PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
+static boolean xcoff_complain_overflow_bitfield_func
+  PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
+static boolean xcoff_complain_overflow_signed_func
+  PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
+static boolean xcoff_complain_overflow_unsigned_func
+  PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
+
+boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
+     (XCOFF_RELOC_FUNCTION_ARGS) =
+{
+  xcoff_reloc_type_pos,  /* R_POS   (0x00) */
+  xcoff_reloc_type_neg,  /* R_NEG   (0x01) */
+  xcoff_reloc_type_rel,  /* R_REL   (0x02) */
+  xcoff_reloc_type_toc,  /* R_TOC   (0x03) */
+  xcoff_reloc_type_fail, /* R_RTB   (0x04) */
+  xcoff_reloc_type_toc,  /* R_GL    (0x05) */
+  xcoff_reloc_type_toc,  /* R_TCL   (0x06) */
+  xcoff_reloc_type_fail, /*         (0x07) */
+  xcoff_reloc_type_ba,   /* R_BA    (0x08) */
+  xcoff_reloc_type_fail, /*         (0x09) */
+  xcoff_reloc_type_br,   /* R_BR    (0x0a) */
+  xcoff_reloc_type_fail, /*         (0x0b) */
+  xcoff_reloc_type_pos,  /* R_RL    (0x0c) */
+  xcoff_reloc_type_pos,  /* R_RLA   (0x0d) */
+  xcoff_reloc_type_fail, /*         (0x0e) */
+  xcoff_reloc_type_noop, /* R_REF   (0x0f) */
+  xcoff_reloc_type_fail, /*         (0x10) */
+  xcoff_reloc_type_fail, /*         (0x11) */
+  xcoff_reloc_type_toc,  /* R_TRL   (0x12) */
+  xcoff_reloc_type_toc,  /* R_TRLA  (0x13) */
+  xcoff_reloc_type_fail, /* R_RRTBI (0x14) */
+  xcoff_reloc_type_fail, /* R_RRTBA (0x15) */
+  xcoff_reloc_type_ba,   /* R_CAI   (0x16) */
+  xcoff_reloc_type_crel, /* R_CREL  (0x17) */
+  xcoff_reloc_type_ba,   /* R_RBA   (0x18) */
+  xcoff_reloc_type_ba,   /* R_RBAC  (0x19) */
+  xcoff_reloc_type_br,   /* R_RBR   (0x1a) */
+  xcoff_reloc_type_ba,   /* R_RBRC  (0x1b) */
+};
+
+boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
+     (XCOFF_COMPLAIN_FUNCTION_ARGS) = 
+{
+  xcoff_complain_overflow_dont_func,
+  xcoff_complain_overflow_bitfield_func,
+  xcoff_complain_overflow_signed_func,
+  xcoff_complain_overflow_unsigned_func,
+};
 
 /* We use our own tdata type.  Its first field is the COFF tdata type,
    so the COFF routines are compatible.  */
@@ -631,7 +701,7 @@
 	 0,	                /* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 0,		        /* special_function */
-	 "R_BA",                /* name */
+	 "R_BA_26",             /* name */
 	 true,	                /* partial_inplace */
 	 0x3fffffc,	        /* src_mask */
 	 0x3fffffc,        	/* dst_mask */
@@ -835,7 +905,7 @@
 	 0,	                /* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
 	 0,		        /* special_function */
-	 "R_RBR",               /* name */
+	 "R_RBR_26",            /* name */
 	 true,	                /* partial_inplace */
 	 0xffff,	        /* src_mask */
 	 0xffff,        	/* dst_mask */
@@ -856,50 +926,58 @@
 	 0xffff,        	/* dst_mask */
 	 false),                /* pcrel_offset */
 
-  HOWTO (R_POS,                 /* type */
-         0,                     /* rightshift */
-         4,                     /* size (0 = byte, 1 = short, 2 = long) */
-         64,                    /* bitsize */
-         false,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield, /* complain_on_overflow */
-         0,                     /* special_function */
-         "R_POS",               /* name */
-         true,                  /* partial_inplace */
-         MINUS_ONE,             /* src_mask */
-	 MINUS_ONE,             /* dst_mask */
-	 false),                /* pcrel_offset */
-
   /* 16 bit Non modifiable absolute branch.  */
   HOWTO (R_BA,	                /* type */
 	 0,	                /* rightshift */
-	 2,	                /* size (0 = byte, 1 = short, 2 = long) */
+	 1,	                /* size (0 = byte, 1 = short, 2 = long) */
 	 16,	                /* bitsize */
 	 false,	                /* pc_relative */
 	 0,	                /* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 0,		        /* special_function */
-	 "R_BA",                /* name */
+	 "R_BA_16",             /* name */
 	 true,	                /* partial_inplace */
 	 0xfffc,	        /* src_mask */
 	 0xfffc,        	/* dst_mask */
 	 false),                /* pcrel_offset */
+
+  /* Modifiable branch relative.  */
+  HOWTO (R_RBR,	                /* type */
+	 0,	                /* rightshift */
+	 1,	                /* size (0 = byte, 1 = short, 2 = long) */
+	 16,	                /* bitsize */
+	 false,	                /* pc_relative */
+	 0,	                /* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 0,		        /* special_function */
+	 "R_RBR_16",            /* name */
+	 true,	                /* partial_inplace */
+	 0xffff,	        /* src_mask */
+	 0xffff,        	/* dst_mask */
+	 false),                /* pcrel_offset */
+
 };
 
 void
-_bfd_xcoff_rtype2howto (relent, internal)
+xcoff_rtype2howto (relent, internal)
      arelent *relent;
      struct internal_reloc *internal;
 {
-  relent->howto = xcoff_howto_table + internal->r_type;
-
-  /* Check for relocs we don't know of.  */
-  if (internal->r_type
-      >= sizeof (xcoff_howto_table) / sizeof (xcoff_howto_table[0]))
-    abort ();
-  if (internal->r_type != relent->howto->type)
+  if (internal->r_type > R_RBRC)
     abort ();
 
+  /* Default howto layout works most of the time */
+  relent->howto = &xcoff_howto_table[internal->r_type];
+  
+  /* Special case some 16 bit reoloc */
+  if (15 == (internal->r_size & 0x1f))
+    {
+      if (R_BA == internal->r_type) 
+	relent->howto = &xcoff_howto_table[0x1c];
+      else if (R_RBR == internal->r_type) 
+	relent->howto = &xcoff_howto_table[0x1d];
+    }
+  
   /* The r_size field of an XCOFF reloc encodes the bitsize of the
      relocation, as well as indicating whether it is signed or not.
      Doublecheck that the relocation information gathered from the
@@ -907,14 +985,12 @@
      for R_REF relocs.  */
   if (relent->howto->dst_mask != 0
       && (relent->howto->bitsize
-	  != ((unsigned int) internal->r_size & 0x3f) + 1))
+	  != ((unsigned int) internal->r_size & 0x1f) + 1))
     abort ();
-#if 0
-  if ((internal->r_size & 0x80) != 0
-      ? (relent->howto->complain_on_overflow != complain_overflow_signed)
-      : (relent->howto->complain_on_overflow != complain_overflow_bitfield))
-    abort ();
-#endif
+
+  /* Put a meaningful value in addend */
+  relent->addend = (internal->r_size & 0x80) ? - internal->r_vaddr 
+    : internal->r_vaddr;
 }
 
 reloc_howto_type *
@@ -927,7 +1003,7 @@
     case BFD_RELOC_PPC_B26:
       return &xcoff_howto_table[0xa];
     case BFD_RELOC_PPC_BA16:
-      return &xcoff_howto_table[0x1d];
+      return &xcoff_howto_table[0x1c];
     case BFD_RELOC_PPC_BA26:
       return &xcoff_howto_table[8];
     case BFD_RELOC_PPC_TOC16:
@@ -935,8 +1011,6 @@
     case BFD_RELOC_32:
     case BFD_RELOC_CTOR:
       return &xcoff_howto_table[0];
-    case BFD_RELOC_64:
-      return &xcoff_howto_table[0x1c];
     default:
       return NULL;
     }
@@ -988,7 +1062,17 @@
 /* XCOFF archives use this as a magic string.  Note that both strings
    have the same length.  */
 
+/* Set the magic for archive.  */
 
+boolean
+bfd_xcoff_ar_archive_set_magic (abfd, magic)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     char *magic ATTRIBUTE_UNUSED;
+{
+  /* Not supported yet.  */
+  return false;
+ /* bfd_xcoff_archive_set_magic (abfd, magic); */
+}
 
 /* Read in the armap of an XCOFF archive.  */
 
@@ -1404,7 +1488,7 @@
 /* Stat an element in an XCOFF archive.  */
 
 int
-_bfd_xcoff_generic_stat_arch_elt (abfd, s)
+_bfd_xcoff_stat_arch_elt (abfd, s)
      bfd *abfd;
      struct stat *s;
 {
@@ -1414,7 +1498,7 @@
       return -1;
     }
 
-  if (! xcoff_big_format_p (abfd))
+  if (! xcoff_big_format_p (abfd->my_archive))
     {
       struct xcoff_ar_hdr *hdrp = arch_xhdr (abfd);
 
@@ -1573,6 +1657,85 @@
   (v) = bfd_scan_vma (buff20, (const char **) NULL, 10)
 
 static boolean
+do_pad (abfd, number)
+     bfd *abfd;
+     unsigned int number;
+{
+  bfd_byte b = 0;
+
+  /* Limit pad to <= 4096.  */
+  if (number > 4096)
+    return false;
+
+  while (number--)
+    if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
+      return false;
+
+  return true;
+}
+
+static boolean
+do_copy (out_bfd, in_bfd)
+     bfd *out_bfd;
+     bfd *in_bfd;
+{
+  bfd_size_type remaining;
+  bfd_byte buffer[DEFAULT_BUFFERSIZE];
+
+  if (bfd_seek (in_bfd, (file_ptr) 0, SEEK_SET) != 0)
+    return false;
+
+  remaining = arelt_size (in_bfd);
+
+  while (remaining >= DEFAULT_BUFFERSIZE)
+    {
+      if (bfd_bread (buffer, DEFAULT_BUFFERSIZE, in_bfd) != DEFAULT_BUFFERSIZE
+	  || bfd_bwrite (buffer, DEFAULT_BUFFERSIZE, out_bfd) != DEFAULT_BUFFERSIZE)
+	return false;
+
+      remaining -= DEFAULT_BUFFERSIZE;
+    }
+
+  if (remaining)
+    {
+      if (bfd_bread (buffer, remaining, in_bfd) != remaining 
+	  || bfd_bwrite (buffer, remaining, out_bfd) != remaining)
+	return false;
+    }
+
+  return true;
+}
+
+static boolean 
+do_shared_object_padding (out_bfd, in_bfd, offset, ar_header_size)
+     bfd *out_bfd;
+     bfd *in_bfd;
+     ufile_ptr *offset;
+     int ar_header_size;
+{
+  if (bfd_check_format (in_bfd, bfd_object)
+      && bfd_get_flavour (in_bfd) == bfd_target_xcoff_flavour
+      && (in_bfd->flags & DYNAMIC) != 0)
+    {
+      bfd_size_type pad = 0;
+      int text_align_power;
+
+      text_align_power = bfd_xcoff_text_align_power (in_bfd);
+      BFD_ASSERT (2 < text_align_power);
+
+      pad = 1 << text_align_power;
+      pad -= (*offset + ar_header_size) & (pad - 1);
+
+      if (! do_pad (out_bfd, pad))
+	return false;
+
+      *offset += pad;
+    }
+
+  return true;
+}
+
+static boolean
 xcoff_write_armap_big (abfd, elength, map, orl_count, stridx)
      bfd *abfd;
      unsigned int elength ATTRIBUTE_UNUSED;
@@ -2001,28 +2164,12 @@
 
       if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
 	return false;
-      while (remaining != 0)
-	{
-	  bfd_size_type amt;
-	  bfd_byte buffer[DEFAULT_BUFFERSIZE];
 
-	  amt = sizeof buffer;
-	  if (amt > remaining)
-	    amt = remaining;
-	  if (bfd_bread (buffer, amt, sub) != amt
-	      || bfd_bwrite (buffer, amt, abfd) != amt)
-	    return false;
-	  remaining -= amt;
-	}
-
-      if ((size & 1) != 0)
-	{
-	  bfd_byte b;
-
-	  b = '\0';
-	  if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
-	    return false;
-	}
+      if (! do_copy (abfd, sub))
+	return false;
+      
+      if (! do_pad (abfd, size & 1))
+	return false;
     }
 
   sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
@@ -2089,14 +2236,9 @@
       if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1)
 	return false;
     }
-  if ((size & 1) != 0)
-    {
-      bfd_byte b;
 
-      b = '\0';
-      if (bfd_bwrite ((PTR) &b, (bfd_size_type) 1, abfd) != 1)
-	return false;
-    }
+  if (! do_pad (abfd, size & 1))
+    return false;
 
   /* Write out the armap, if appropriate.  */
   if (! makemap || ! hasobjects)
@@ -2143,15 +2285,26 @@
   bfd_byte *member_table, *mt;
   bfd_vma member_table_size;
 
+  memset (&fhdr, 0, SIZEOF_AR_FILE_HDR_BIG);
   memcpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG);
-  PRINT20 (fhdr.firstmemoff, SIZEOF_AR_FILE_HDR_BIG);
-  PRINT20 (fhdr.freeoff, 0);
 
-  /* Calculate count and total_namlen */
+  if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)
+    return false;
+  
+  /* Calculate count and total_namlen.  */
+  makemap = bfd_has_map (abfd);
+  hasobjects = false;
   for (current_bfd = abfd->archive_head, count = 0, total_namlen = 0; 
        current_bfd != NULL; 
        current_bfd = current_bfd->next, count++)
-    total_namlen += strlen (normalize_filename (current_bfd)) + 1;
+    {
+      total_namlen += strlen (normalize_filename (current_bfd)) + 1;
+
+      if (makemap
+	  && ! hasobjects
+	  && bfd_check_format (current_bfd, bfd_object))
+	hasobjects = true;
+    }
 
   offsets = NULL;
   if (count)
@@ -2160,11 +2313,7 @@
       if (offsets == NULL)
 	return false;
     }
-  if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)
-    return false;
 
-  makemap = bfd_has_map (abfd);
-  hasobjects = false;
   prevoff = 0;
   nextoff = SIZEOF_AR_FILE_HDR_BIG;
   for (current_bfd = abfd->archive_head, i = 0; 
@@ -2176,12 +2325,6 @@
       struct xcoff_ar_hdr_big *ahdrp;
       bfd_size_type remaining;
 
-      if (makemap && ! hasobjects)
-	{
-	  if (bfd_check_format (current_bfd, bfd_object))
-	    hasobjects = true;
-	}
-
       name = normalize_filename (current_bfd);
       namlen = strlen (name);
 
@@ -2236,6 +2379,14 @@
 
       BFD_ASSERT (nextoff == bfd_tell (abfd));
 
+      /* Check for xcoff shared objects.
+	 Their text section needs to be aligned wrt the archive file position.
+	 This requires extra padding before the archive header.  */
+      if (! do_shared_object_padding (abfd, current_bfd, & nextoff,
+				      SIZEOF_AR_HDR_BIG + namlen 
+				      + SXCOFFARFMAG))
+	return false;
+
       offsets[i] = nextoff;
 
       prevoff = nextoff;
@@ -2252,31 +2403,19 @@
 
       if (bfd_seek (current_bfd, (file_ptr) 0, SEEK_SET) != 0)
 	return false;
-      while (remaining != 0)
-	{
-	  bfd_size_type amt;
-	  bfd_byte buffer[DEFAULT_BUFFERSIZE];
 
-	  amt = sizeof buffer;
-	  if (amt > remaining)
-	    amt = remaining;
-	  if (bfd_bread (buffer, amt, current_bfd) != amt
-	      || bfd_bwrite (buffer, amt, abfd) != amt)
-	    return false;
-	  remaining -= amt;
-	}
-
-      if ((size & 1) != 0)
-	{
-	  bfd_byte b;
-
-	  b = '\0';
-	  if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
-	    return false;
-	}
+      if (! do_copy (abfd, current_bfd))
+  	return false;
+  
+      if (! do_pad (abfd, size & 1))
+	return false;
     }
 
-  PRINT20 (fhdr.lastmemoff, prevoff);
+  if (count)
+    {
+      PRINT20 (fhdr.firstmemoff, offsets[0]);
+      PRINT20 (fhdr.lastmemoff, prevoff);
+    }
 
   /* Write out the member table.  
      Layout : 
@@ -2520,6 +2659,40 @@
   bfd_put_32 (abfd, src->l_parm, dst->l_parm);
 }
 
+static void
+xcoff_swap_reloc_in (abfd, s, d)
+     bfd *abfd;
+     PTR s;
+     PTR d;
+{
+  struct external_reloc *src = (struct external_reloc *) s;
+  struct internal_reloc *dst = (struct internal_reloc *) d;
+
+  memset (dst, 0, sizeof (struct internal_reloc));
+
+  dst->r_vaddr = bfd_get_32 (abfd, src->r_vaddr);
+  dst->r_symndx = bfd_get_32 (abfd, src->r_symndx);
+  dst->r_size = bfd_get_8 (abfd, src->r_size);
+  dst->r_type = bfd_get_8 (abfd, src->r_type);
+}
+
+static unsigned int
+xcoff_swap_reloc_out (abfd, s, d)
+     bfd *abfd;
+     PTR s;
+     PTR d;
+{
+  struct internal_reloc *src = (struct internal_reloc *) s;
+  struct external_reloc *dst = (struct external_reloc *) d;
+
+  bfd_put_32 (abfd, src->r_vaddr, dst->r_vaddr);
+  bfd_put_32 (abfd, src->r_symndx, dst->r_symndx);
+  bfd_put_8 (abfd, src->r_type, dst->r_type);
+  bfd_put_8 (abfd, src->r_size, dst->r_size);
+
+  return bfd_coff_relsz (abfd);
+}
+
 /* Swap in the ldrel structure.  */
 
 static void
@@ -2553,12 +2726,575 @@
 }
 
 
+static boolean 
+xcoff_reloc_type_noop (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		       val, addend, relocation, contents)
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel ATTRIBUTE_UNUSED;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
+     bfd_vma val ATTRIBUTE_UNUSED;
+     bfd_vma addend ATTRIBUTE_UNUSED;
+     bfd_vma *relocation ATTRIBUTE_UNUSED;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  return true;
+}
+
+static boolean 
+xcoff_reloc_type_fail (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		       val, addend, relocation, contents)
+     bfd *input_bfd;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
+     bfd_vma val ATTRIBUTE_UNUSED;
+     bfd_vma addend ATTRIBUTE_UNUSED;
+     bfd_vma *relocation ATTRIBUTE_UNUSED;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  (*_bfd_error_handler)
+    (_("%s: unsupported relocation type 0x%02x"),
+     bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
+  bfd_set_error (bfd_error_bad_value);
+  return false;
+}
+
+static boolean 
+xcoff_reloc_type_pos (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		      val, addend, relocation, contents)
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel ATTRIBUTE_UNUSED;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
+     bfd_vma val;
+     bfd_vma addend;
+     bfd_vma *relocation;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  *relocation = val + addend;
+  return true;
+}
+
+static boolean 
+xcoff_reloc_type_neg (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		      val, addend, relocation, contents)
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel ATTRIBUTE_UNUSED;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
+     bfd_vma val;
+     bfd_vma addend;
+     bfd_vma *relocation;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  *relocation = addend - val;
+  return true;
+}
+
+static boolean 
+xcoff_reloc_type_rel (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		      val, addend, relocation, contents)
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     asection *input_section;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel ATTRIBUTE_UNUSED;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto;
+     bfd_vma val;
+     bfd_vma addend;
+     bfd_vma *relocation;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  howto->pc_relative = true;
+
+  /* A PC relative reloc includes the section address.  */
+  addend += input_section->vma;
+
+  *relocation = val + addend;
+  *relocation -= (input_section->output_section->vma + 
+		  input_section->output_offset);
+  return true;
+}
+static boolean 
+xcoff_reloc_type_toc (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		      val, addend, relocation, contents)
+     bfd *input_bfd;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
+     struct internal_reloc *rel;
+     struct internal_syment *sym;
+     struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
+     bfd_vma val;
+     bfd_vma addend ATTRIBUTE_UNUSED;
+     bfd_vma *relocation;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  struct xcoff_link_hash_entry *h;
+
+  if (0 > rel->r_symndx) 
+    return false;
+
+  h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
+
+  if (h != NULL && h->smclas != XMC_TD)
+    {
+      if (h->toc_section == NULL)
+	{
+	  (*_bfd_error_handler)
+	    (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
+	     bfd_get_filename (input_bfd), rel->r_vaddr,
+	     h->root.root.string);
+	  bfd_set_error (bfd_error_bad_value);
+	  return false;
+	}
+      
+      BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
+      val = (h->toc_section->output_section->vma
+	      + h->toc_section->output_offset);
+    }
+  
+  *relocation = ((val - xcoff_data (output_bfd)->toc) - 
+		 (sym->n_value - xcoff_data (input_bfd)->toc));
+  return true;
+}
+static boolean 
+xcoff_reloc_type_ba (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		     val, addend, relocation, contents)
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     asection *input_section ATTRIBUTE_UNUSED;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel ATTRIBUTE_UNUSED;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto;
+     bfd_vma val;
+     bfd_vma addend;
+     bfd_vma *relocation;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  howto->src_mask &= ~3;
+  howto->dst_mask = howto->src_mask;
+
+  *relocation = val + addend;
+
+  return true;
+}
+
+static boolean 
+xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		     val, addend, relocation, contents)
+     bfd *input_bfd;
+     asection *input_section;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto;
+     bfd_vma val;
+     bfd_vma addend;
+     bfd_vma *relocation;
+     bfd_byte *contents;
+{
+  struct xcoff_link_hash_entry *h;
+
+  if (0 > rel->r_symndx) 
+    return false;
+
+  h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
+
+  /* If we see an R_BR or R_RBR reloc which is jumping to global
+     linkage code, and it is followed by an appropriate cror nop
+     instruction, we replace the cror with lwz r2,20(r1).  This
+     restores the TOC after the glink code.  Contrariwise, if the
+     call is followed by a lwz r2,20(r1), but the call is not
+     going to global linkage code, we can replace the load with a
+     cror.  */
+  if (NULL != h 
+      && bfd_link_hash_defined == h->root.type 
+      && (rel->r_vaddr - input_section->vma + 8 <= 
+	  input_section->_cooked_size)) 
+    {
+      bfd_byte *pnext;
+      unsigned long next;
+      
+      pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
+      next = bfd_get_32 (input_bfd, pnext);
+      
+      /* The _ptrgl function is magic.  It is used by the AIX
+	 compiler to call a function through a pointer.  */
+      if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0)
+	{
+	  if (next == 0x4def7b82                        /* cror 15,15,15 */
+	      || next == 0x4ffffb82                     /* cror 31,31,31 */
+	      || next == 0x60000000)	                /* ori r0,r0,0 */
+	    bfd_put_32 (input_bfd, 0x80410014, pnext);  /* lwz r1,20(r1) */
+	  
+	} else 
+	  {
+	    if (next == 0x80410014)		         /* lwz r1,20(r1) */
+	      bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */
+	  }
+    } 
+  else if (NULL != h && bfd_link_hash_undefined == h->root.type) 
+    {
+      /* Normally, this relocation is against a defined symbol.  In the
+	 case where this is a partial link and the output section offset
+	 is greater than 2^25, the linker will return an invalid error 
+	 message that the relocation has been truncated.  Yes it has been
+	 truncated but no it not important.  For this case, disable the 
+	 overflow checking. */
+      
+      howto->complain_on_overflow = complain_overflow_dont;
+    }
+  
+  howto->pc_relative = true;
+  howto->src_mask &= ~3;
+  howto->dst_mask = howto->src_mask;
+
+  /* A PC relative reloc includes the section address.  */
+  addend += input_section->vma;
+  
+  *relocation = val + addend;
+  *relocation -= (input_section->output_section->vma + 
+		  input_section->output_offset);
+  return true;
+}
+
+static boolean 
+xcoff_reloc_type_crel (input_bfd, input_section, output_bfd, rel, sym, howto, 
+		       val, addend, relocation, contents)
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     asection *input_section;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
+     struct internal_reloc *rel ATTRIBUTE_UNUSED;
+     struct internal_syment *sym ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto;
+     bfd_vma val ATTRIBUTE_UNUSED;
+     bfd_vma addend;
+     bfd_vma *relocation;
+     bfd_byte *contents ATTRIBUTE_UNUSED;
+{
+  howto->pc_relative = true;
+  howto->src_mask &= ~3;
+  howto->dst_mask = howto->src_mask;
+
+  /* A PC relative reloc includes the section address.  */
+  addend += input_section->vma;
+
+  *relocation = val + addend;
+  *relocation -= (input_section->output_section->vma + 
+		  input_section->output_offset);
+  return true;
+}
+
+static boolean 
+xcoff_complain_overflow_dont_func (input_bfd, val, relocation, howto) 
+     bfd *input_bfd ATTRIBUTE_UNUSED;
+     bfd_vma val ATTRIBUTE_UNUSED;
+     bfd_vma relocation ATTRIBUTE_UNUSED;
+     struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
+{
+  return false;
+}
+
+static boolean 
+xcoff_complain_overflow_bitfield_func (input_bfd, val, relocation, howto) 
+     bfd *input_bfd;
+     bfd_vma val;
+     bfd_vma relocation;
+     struct reloc_howto_struct *howto; 
+{
+  bfd_vma addrmask, fieldmask, signmask, ss;
+  bfd_vma a, b, sum;
+  
+  /* Get the values to be added together.  For signed and unsigned
+     relocations, we assume that all values should be truncated to
+     the size of an address.  For bitfields, all the bits matter.
+     See also bfd_check_overflow.  */
+  fieldmask = N_ONES (howto->bitsize);
+  addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask;
+  a = relocation;
+  b = val & howto->src_mask;
+
+  /* Much like unsigned, except no trimming with addrmask.  In
+     addition, the sum overflows if there is a carry out of
+     the bfd_vma, i.e., the sum is less than either input
+     operand.  */
+  a >>= howto->rightshift;
+  b >>= howto->bitpos;
+  
+  /* Bitfields are sometimes used for signed numbers; for
+     example, a 13-bit field sometimes represents values in
+     0..8191 and sometimes represents values in -4096..4095.
+     If the field is signed and a is -4095 (0x1001) and b is
+     -1 (0x1fff), the sum is -4096 (0x1000), but (0x1001 +
+     0x1fff is 0x3000).  It's not clear how to handle this
+     everywhere, since there is not way to know how many bits
+     are significant in the relocation, but the original code
+     assumed that it was fully sign extended, and we will keep
+     that assumption.  */
+  signmask = (fieldmask >> 1) + 1;
+		  
+  if ((a & ~ fieldmask) != 0)
+    {
+      /* Some bits out of the field are set.  This might not
+	 be a problem: if this is a signed bitfield, it is OK
+	 iff all the high bits are set, including the sign
+	 bit.  We'll try setting all but the most significant
+	 bit in the original relocation value: if this is all
+	 ones, we are OK, assuming a signed bitfield.  */
+      ss = (signmask << howto->rightshift) - 1;
+      if ((ss | relocation) != ~ (bfd_vma) 0)
+	return true;
+      a &= fieldmask;
+    }
+  
+  /* We just assume (b & ~ fieldmask) == 0.  */
+  
+  /* We explicitly permit wrap around if this relocation
+     covers the high bit of an address.  The Linux kernel
+     relies on it, and it is the only way to write assembler
+     code which can run when loaded at a location 0x80000000
+     away from the location at which it is linked.  */
+  if (howto->bitsize + howto->rightshift
+      == bfd_arch_bits_per_address (input_bfd))
+    return false;
+  
+  sum = a + b;
+  if (sum < a || (sum & ~ fieldmask) != 0)
+    {
+      /* There was a carry out, or the field overflow.  Test
+	 for signed operands again.  Here is the overflow test
+	 is as for complain_overflow_signed.  */
+      if (((~ (a ^ b)) & (a ^ sum)) & signmask)
+	return true;
+    }
+  
+  return false;
+}
+
+static boolean 
+xcoff_complain_overflow_signed_func (input_bfd, val, relocation, howto) 
+     bfd *input_bfd;
+     bfd_vma val;
+     bfd_vma relocation;
+     struct reloc_howto_struct *howto;
+{
+  bfd_vma addrmask, fieldmask, signmask, ss;
+  bfd_vma a, b, sum;
+  
+  /* Get the values to be added together.  For signed and unsigned
+     relocations, we assume that all values should be truncated to
+     the size of an address.  For bitfields, all the bits matter.
+     See also bfd_check_overflow.  */
+  fieldmask = N_ONES (howto->bitsize);
+  addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask;
+  a = relocation;
+  b = val & howto->src_mask;
+
+  a = (a & addrmask) >> howto->rightshift;
+  
+  /* If any sign bits are set, all sign bits must be set.
+     That is, A must be a valid negative address after
+     shifting.  */
+  signmask = ~ (fieldmask >> 1);
+  ss = a & signmask;
+  if (ss != 0 && ss != ((addrmask >> howto->rightshift) & signmask))
+    return true;
+  
+  /* We only need this next bit of code if the sign bit of B
+     is below the sign bit of A.  This would only happen if
+     SRC_MASK had fewer bits than BITSIZE.  Note that if
+     SRC_MASK has more bits than BITSIZE, we can get into
+     trouble; we would need to verify that B is in range, as
+     we do for A above.  */
+  signmask = ((~ howto->src_mask) >> 1) & howto->src_mask;
+  if ((b & signmask) != 0)
+    {
+      /* Set all the bits above the sign bit.  */
+      b -= signmask <<= 1;
+    }
+  
+  b = (b & addrmask) >> howto->bitpos;
+  
+  /* Now we can do the addition.  */
+  sum = a + b;
+  
+  /* See if the result has the correct sign.  Bits above the
+     sign bit are junk now; ignore them.  If the sum is
+     positive, make sure we did not have all negative inputs;
+     if the sum is negative, make sure we did not have all
+     positive inputs.  The test below looks only at the sign
+     bits, and it really just
+     SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM)
+  */
+  signmask = (fieldmask >> 1) + 1;
+  if (((~ (a ^ b)) & (a ^ sum)) & signmask)
+    return true;
+  
+  return false;
+}
+
+static boolean 
+xcoff_complain_overflow_unsigned_func (input_bfd, val, relocation, howto) 
+     bfd *input_bfd;
+     bfd_vma val;
+     bfd_vma relocation;
+     struct reloc_howto_struct *howto; 
+{
+  bfd_vma addrmask, fieldmask;
+  bfd_vma a, b, sum;
+  
+  /* Get the values to be added together.  For signed and unsigned
+     relocations, we assume that all values should be truncated to
+     the size of an address.  For bitfields, all the bits matter.
+     See also bfd_check_overflow.  */
+  fieldmask = N_ONES (howto->bitsize);
+  addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask;
+  a = relocation;
+  b = val & howto->src_mask;
+
+  /* Checking for an unsigned overflow is relatively easy:
+     trim the addresses and add, and trim the result as well.
+     Overflow is normally indicated when the result does not
+     fit in the field.  However, we also need to consider the
+     case when, e.g., fieldmask is 0x7fffffff or smaller, an
+     input is 0x80000000, and bfd_vma is only 32 bits; then we
+     will get sum == 0, but there is an overflow, since the
+     inputs did not fit in the field.  Instead of doing a
+     separate test, we can check for this by or-ing in the
+     operands when testing for the sum overflowing its final
+     field.  */
+  a = (a & addrmask) >> howto->rightshift;
+  b = (b & addrmask) >> howto->bitpos;
+  sum = (a + b) & addrmask;
+  if ((a | b | sum) & ~ fieldmask)
+    return true;
+  
+  return false;
+}
 
 /* This is the relocation function for the RS/6000/POWER/PowerPC.
    This is currently the only processor which uses XCOFF; I hope that
-   will never change.  */
+   will never change.  
 
-static boolean
+   I took the relocation type definitions from two documents:
+   the PowerPC AIX Version 4 Application Binary Interface, First
+   Edition (April 1992), and the PowerOpen ABI, Big-Endian
+   32-Bit Hardware Implementation (June 30, 1994).  Differences
+   between the documents are noted below. 
+
+   Unsupported r_type's 
+
+   R_RTB:
+   R_RRTBI:
+   R_RRTBA:
+	
+   These relocs are defined by the PowerPC ABI to be
+   relative branches which use half of the difference
+   between the symbol and the program counter.  I can't
+   quite figure out when this is useful.  These relocs are
+   not defined by the PowerOpen ABI. 
+
+   Supported r_type's
+
+   R_POS:
+   Simple positive relocation.
+
+   R_NEG:
+   Simple negative relocation. 
+
+   R_REL:
+   Simple PC relative relocation.
+
+   R_TOC:
+   TOC relative relocation.  The value in the instruction in
+   the input file is the offset from the input file TOC to
+   the desired location.  We want the offset from the final
+   TOC to the desired location.  We have:
+   isym = iTOC + in
+   iinsn = in + o
+   osym = oTOC + on
+   oinsn = on + o
+   so we must change insn by on - in.
+
+   R_GL:
+   GL linkage relocation.  The value of this relocation
+   is the address of the entry in the TOC section. 
+
+   R_TCL:
+   Local object TOC address.  I can't figure out the
+   difference between this and case R_GL. 
+
+   R_TRL:
+   TOC relative relocation.  A TOC relative load instruction
+   which may be changed to a load address instruction.
+   FIXME: We don't currently implement this optimization. 
+
+   R_TRLA:
+   TOC relative relocation.  This is a TOC relative load
+   address instruction which may be changed to a load
+   instruction.  FIXME: I don't know if this is the correct
+   implementation.
+
+   R_BA:
+   Absolute branch.  We don't want to mess with the lower
+   two bits of the instruction. 
+
+   R_CAI:
+   The PowerPC ABI defines this as an absolute call which
+   may be modified to become a relative call.  The PowerOpen
+   ABI does not define this relocation type. 
+   
+   R_RBA:
+   Absolute branch which may be modified to become a
+   relative branch. 
+
+   R_RBAC:
+   The PowerPC ABI defines this as an absolute branch to a
+   fixed address which may be modified to an absolute branch
+   to a symbol.  The PowerOpen ABI does not define this
+   relocation type. 
+
+   R_RBRC:
+   The PowerPC ABI defines this as an absolute branch to a
+   fixed address which may be modified to a relative branch.
+   The PowerOpen ABI does not define this relocation type. 
+
+   R_BR:
+   Relative branch.  We don't want to mess with the lower
+   two bits of the instruction. 
+
+   R_CREL:
+   The PowerPC ABI defines this as a relative call which may
+   be modified to become an absolute call.  The PowerOpen
+   ABI does not define this relocation type. 
+
+   R_RBR:
+   A relative branch which may be modified to become an
+   absolute branch.  FIXME: We don't implement this,
+   although we should for symbols of storage mapping class
+   XMC_XO. 
+
+   R_RL:
+   The PowerPC AIX ABI describes this as a load which may be
+   changed to a load address.  The PowerOpen ABI says this
+   is the same as case R_POS. 
+
+   R_RLA:
+   The PowerPC AIX ABI describes this as a load address
+   which may be changed to a load.  The PowerOpen ABI says
+   this is the same as R_POS. 
+*/
+
+boolean
 xcoff_ppc_relocate_section (output_bfd, info, input_bfd,
 			    input_section, contents, relocs, syms,
 			    sections)
@@ -2576,7 +3312,6 @@
 
   rel = relocs;
   relend = rel + input_section->reloc_count;
-
   for (; rel < relend; rel++)
     {
       long symndx;
@@ -2585,7 +3320,10 @@
       bfd_vma addend;
       bfd_vma val;
       struct reloc_howto_struct howto;
-      bfd_reloc_status_type rstat;
+      bfd_vma relocation;
+      bfd_vma value_to_relocate;
+      bfd_vma address;
+      bfd_byte *location;
 
       /* Relocation type R_REF is a special relocation type which is
          merely used to prevent garbage collection from occurring for
@@ -2593,327 +3331,151 @@
       if (rel->r_type == R_REF)
 	continue;
 
-      symndx = rel->r_symndx;
-
-      if (symndx == -1)
-	{
-	  h = NULL;
-	  sym = NULL;
-	  addend = 0;
-	}
-      else
-	{
-	  h = obj_xcoff_sym_hashes (input_bfd)[symndx];
-	  sym = syms + symndx;
-	  addend = - sym->n_value;
-
-	}
-
-      /* We build the howto information on the fly.  */
-
+      /* howto */
       howto.type = rel->r_type;
       howto.rightshift = 0;
-      howto.size = 2;
       howto.bitsize = (rel->r_size & 0x1f) + 1;
+      howto.size = howto.bitsize > 16 ? 2 : 1;
       howto.pc_relative = false;
       howto.bitpos = 0;
-      if ((rel->r_size & 0x80) != 0)
-	howto.complain_on_overflow = complain_overflow_signed;
-      else
-	howto.complain_on_overflow = complain_overflow_bitfield;
+      howto.complain_on_overflow = rel->r_size & 0x80 ? 
+	complain_overflow_signed : complain_overflow_bitfield;
       howto.special_function = NULL;
       howto.name = "internal";
       howto.partial_inplace = true;
-      if (howto.bitsize == 32)
-	howto.src_mask = howto.dst_mask = 0xffffffff;
-      else
-	{
-	  howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1;
-	  if (howto.bitsize == 16)
-	    howto.size = 1;
-	}
+      howto.src_mask = howto.dst_mask = N_ONES(howto.bitsize);
       howto.pcrel_offset = false;
 
+      /* symbol */
       val = 0;
+      addend = 0;
+      h = NULL;
+      sym = NULL;
+      symndx = rel->r_symndx;      
 
-      if (h == NULL)
+      if (-1 != symndx)	
 	{
 	  asection *sec;
-
-	  if (symndx == -1)
-	    {
-	      sec = bfd_abs_section_ptr;
-	      val = 0;
-	    }
-	  else
+	  
+	  h = obj_xcoff_sym_hashes (input_bfd)[symndx];
+	  sym = syms + symndx;
+	  addend = - sym->n_value;
+	  
+	  if (NULL == h) 
 	    {
 	      sec = sections[symndx];
 	      /* Hack to make sure we use the right TOC anchor value
-                 if this reloc is against the TOC anchor.  */
-
+		 if this reloc is against the TOC anchor.  */
 	      if (sec->name[3] == '0'
-			  && strcmp (sec->name, ".tc0") == 0)
-		{
-		  val = xcoff_data (output_bfd)->toc;
-		}
+		  && strcmp (sec->name, ".tc0") == 0)
+		val = xcoff_data (output_bfd)->toc;
 	      else
+		val = (sec->output_section->vma
+		       + sec->output_offset
+		       + sym->n_value
+		       - sec->vma);
+	    } 
+	  else 
+	    {
+	      if (h->root.type == bfd_link_hash_defined 
+		  || h->root.type == bfd_link_hash_defweak) 
 		{
+		  sec = h->root.u.def.section;
+		  val = (h->root.u.def.value
+			 + sec->output_section->vma
+			 + sec->output_offset);
+		} 
+	      else if (h->root.type == bfd_link_hash_common) 
+		{
+		  sec = h->root.u.c.p->section;
 		  val = (sec->output_section->vma
-			 + sec->output_offset
-			 + sym->n_value
-			 - sec->vma);
-		}
-	    }
-	}
-      else
-	{
-	  if (h->root.type == bfd_link_hash_defined
-	      || h->root.type == bfd_link_hash_defweak)
-	    {
-	      asection *sec;
-
-	      sec = h->root.u.def.section;
-	      val = (h->root.u.def.value
-		     + sec->output_section->vma
-		     + sec->output_offset);
-	    }
-	  else if (h->root.type == bfd_link_hash_common)
-	    {
-	      asection *sec;
-
-	      sec = h->root.u.c.p->section;
-	      val = (sec->output_section->vma
-		     + sec->output_offset);
-	    }
-	  else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0
-		   || (h->flags & XCOFF_IMPORT) != 0)
-	    {
-	      /* Every symbol in a shared object is defined somewhere.  */
-	      val = 0;
-	    }
-	  else if (! info->relocateable)
-	    {
-	      if (! ((*info->callbacks->undefined_symbol)
-		     (info, h->root.root.string, input_bfd, input_section,
-		      rel->r_vaddr - input_section->vma, true)))
-		return false;
-
-	      /* Don't try to process the reloc.  It can't help, and
-                 it may generate another error.  */
-	      continue;
-	    }
-	}
-
-      /* I took the relocation type definitions from two documents:
-	 the PowerPC AIX Version 4 Application Binary Interface, First
-	 Edition (April 1992), and the PowerOpen ABI, Big-Endian
-	 32-Bit Hardware Implementation (June 30, 1994).  Differences
-	 between the documents are noted below.  */
-
-      switch (rel->r_type)
-	{
-	case R_RTB:
-	case R_RRTBI:
-	case R_RRTBA:
-	  /* These relocs are defined by the PowerPC ABI to be
-             relative branches which use half of the difference
-             between the symbol and the program counter.  I can't
-             quite figure out when this is useful.  These relocs are
-             not defined by the PowerOpen ABI.  */
-	default:
-	  (*_bfd_error_handler)
-	    (_("%s: unsupported relocation type 0x%02x"),
-	     bfd_archive_filename (input_bfd), (unsigned int) rel->r_type);
-	  bfd_set_error (bfd_error_bad_value);
-	  return false;
-	case R_POS:
-	  /* Simple positive relocation.  */
-	  break;
-	case R_NEG:
-	  /* Simple negative relocation.  */
-	  val = - val;
-	  break;
-	case R_REL:
-	  /* Simple PC relative relocation.  */
-	  howto.pc_relative = true;
-	  break;
-	case R_TOC:
-	  /* TOC relative relocation.  The value in the instruction in
-             the input file is the offset from the input file TOC to
-             the desired location.  We want the offset from the final
-             TOC to the desired location.  We have:
-	         isym = iTOC + in
-		 iinsn = in + o
-		 osym = oTOC + on
-		 oinsn = on + o
-	     so we must change insn by on - in.
-	     */
-	case R_GL:
-	  /* Global linkage relocation.  The value of this relocation
-             is the address of the entry in the TOC section.  */
-	case R_TCL:
-	  /* Local object TOC address.  I can't figure out the
-             difference between this and case R_GL.  */
-	case R_TRL:
-	  /* TOC relative relocation.  A TOC relative load instruction
-             which may be changed to a load address instruction.
-             FIXME: We don't currently implement this optimization.  */
-	case R_TRLA:
-	  /* TOC relative relocation.  This is a TOC relative load
-             address instruction which may be changed to a load
-             instruction.  FIXME: I don't know if this is the correct
-             implementation.  */
-	  if (h != NULL && h->smclas != XMC_TD)
-	    {
-	      if (h->toc_section == NULL)
+			 + sec->output_offset);
+		  
+		} 
+	      else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT))) 
+		       && ! info->relocateable) 
 		{
-		  (*_bfd_error_handler)
-		    (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
-		     bfd_archive_filename (input_bfd), rel->r_vaddr,
-		     h->root.root.string);
-		  bfd_set_error (bfd_error_bad_value);
-		  return false;
+		  if (! ((*info->callbacks->undefined_symbol)
+			 (info, h->root.root.string, input_bfd, input_section,
+			  rel->r_vaddr - input_section->vma, true)))
+		    return false;
+		  
+		  /* Don't try to process the reloc.  It can't help, and
+		     it may generate another error.  */
+		  continue;
 		}
-
-	      BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
-	      val = (h->toc_section->output_section->vma
-		     + h->toc_section->output_offset);
-	    }
-
-	  val = ((val - xcoff_data (output_bfd)->toc)
-		 - (sym->n_value - xcoff_data (input_bfd)->toc));
-	  addend = 0;
-	  break;
-	case R_BA:
-	  /* Absolute branch.  We don't want to mess with the lower
-             two bits of the instruction.  */
-	case R_CAI:
-	  /* The PowerPC ABI defines this as an absolute call which
-             may be modified to become a relative call.  The PowerOpen
-             ABI does not define this relocation type.  */
-	case R_RBA:
-	  /* Absolute branch which may be modified to become a
-             relative branch.  */
-	case R_RBAC:
-	  /* The PowerPC ABI defines this as an absolute branch to a
-             fixed address which may be modified to an absolute branch
-             to a symbol.  The PowerOpen ABI does not define this
-             relocation type.  */
-	case R_RBRC:
-	  /* The PowerPC ABI defines this as an absolute branch to a
-             fixed address which may be modified to a relative branch.
-             The PowerOpen ABI does not define this relocation type.  */
-	  howto.src_mask &= ~3;
-	  howto.dst_mask = howto.src_mask;
-	  break;
-	case R_BR:
-	  /* Relative branch.  We don't want to mess with the lower
-             two bits of the instruction.  */
-	case R_CREL:
-	  /* The PowerPC ABI defines this as a relative call which may
-             be modified to become an absolute call.  The PowerOpen
-             ABI does not define this relocation type.  */
-	case R_RBR:
-	  /* A relative branch which may be modified to become an
-             absolute branch.  FIXME: We don't implement this,
-             although we should for symbols of storage mapping class
-             XMC_XO.  */
-	  howto.pc_relative = true;
-	  howto.src_mask &= ~3;
-	  howto.dst_mask = howto.src_mask;
-	  break;
-	case R_RL:
-	  /* The PowerPC AIX ABI describes this as a load which may be
-             changed to a load address.  The PowerOpen ABI says this
-             is the same as case R_POS.  */
-	  break;
-	case R_RLA:
-	  /* The PowerPC AIX ABI describes this as a load address
-             which may be changed to a load.  The PowerOpen ABI says
-             this is the same as R_POS.  */
-	  break;
-	}
-
-      /* If we see an R_BR or R_RBR reloc which is jumping to global
-         linkage code, and it is followed by an appropriate cror nop
-         instruction, we replace the cror with lwz r2,20(r1).  This
-         restores the TOC after the glink code.  Contrariwise, if the
-         call is followed by a lwz r2,20(r1), but the call is not
-         going to global linkage code, we can replace the load with a
-         cror.  */
-      if ((rel->r_type == R_BR || rel->r_type == R_RBR)
-	  && h != NULL
-	  && h->root.type == bfd_link_hash_defined
-	  && (rel->r_vaddr - input_section->vma + 8
-	      <= input_section->_cooked_size))
-	{
-	  bfd_byte *pnext;
-	  unsigned long next;
-
-	  pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
-	  next = bfd_get_32 (input_bfd, pnext);
-
-	  /* The _ptrgl function is magic.  It is used by the AIX
-             compiler to call a function through a pointer.  */
-	  if (h->smclas == XMC_GL
-	      || strcmp (h->root.root.string, "._ptrgl") == 0)
-	    {
-	      if (next == 0x4def7b82		/* cror 15,15,15 */
-		  || next == 0x4ffffb82		/* cror 31,31,31 */
-		  || next == 0x60000000)	/* ori r0,r0,0 */
-		bfd_put_32 (input_bfd,
-			    (bfd_vma) 0x80410014, /* lwz r1,20(r1) */
-			    pnext);
-	    }
-	  else
-	    {
-	      if (next == 0x80410014)		/* lwz r1,20(r1) */
-		bfd_put_32 (input_bfd,
-			    (bfd_vma) 0x60000000, /* ori r0,r0,0 */
-			    pnext);
 	    }
 	}
 
-      /* A PC relative reloc includes the section address.  */
-      if (howto.pc_relative)
-	addend += input_section->vma;
+      if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION 
+	  || (false == xcoff_calculate_relocation[rel->r_type]
+	      (input_bfd, input_section, output_bfd, rel, sym, &howto, val, 
+	       addend, &relocation, contents))) 
+	return false;
+      
+      /* address */
+      address = rel->r_vaddr - input_section->vma;
+      location = contents + address;
+      
+      if (address > input_section->_raw_size)
+	abort();
 
-      rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section,
-					contents,
-					rel->r_vaddr - input_section->vma,
-					val, addend);
+      /* Get the value we are going to relocate.  */
+      if (1 == howto.size)
+	value_to_relocate = bfd_get_16 (input_bfd, location);
+      else 
+	value_to_relocate = bfd_get_32 (input_bfd, location);
+      
+      /* overflow.  
+	 
+	 FIXME: We may drop bits during the addition
+	 which we don't check for.  We must either check at every single
+	 operation, which would be tedious, or we must do the computations
+	 in a type larger than bfd_vma, which would be inefficient.  */
+      
+      if ((unsigned int) howto.complain_on_overflow >= 
+	  XCOFF_MAX_COMPLAIN_OVERFLOW)
+	abort();
 
-      switch (rstat)
+      if ((true == xcoff_complain_overflow[howto.complain_on_overflow]
+	   (input_bfd, value_to_relocate, relocation, &howto))) 
 	{
-	default:
-	  abort ();
-	case bfd_reloc_ok:
-	  break;
-	case bfd_reloc_overflow:
-	  {
-	    const char *name;
-	    char buf[SYMNMLEN + 1];
-	    char howto_name[10];
-
-	    if (symndx == -1)
+	  const char *name;
+	  char buf[SYMNMLEN + 1];
+	  char reloc_type_name[10];
+	  
+	  if (symndx == -1) 
+	    {
 	      name = "*ABS*";
-	    else if (h != NULL)
+	    } 
+	  else if (h != NULL) 
+	    {
 	      name = h->root.root.string;
-	    else
-	      {
-		name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
-
-		if (name == NULL)
-		  return false;
-	      }
-	    sprintf (howto_name, "0x%02x", rel->r_type);
-
-	    if (! ((*info->callbacks->reloc_overflow)
-		   (info, name, howto_name, (bfd_vma) 0, input_bfd,
-		    input_section, rel->r_vaddr - input_section->vma)))
-	      return false;
-	  }
+	    } 
+	  else 
+	    {
+	      name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+	      if (name == NULL)
+		name = "UNKNOWN";
+	    }
+	  sprintf (reloc_type_name, "0x%02x", rel->r_type);
+	  
+	  if (! ((*info->callbacks->reloc_overflow)
+		 (info, name, reloc_type_name, (bfd_vma) 0, input_bfd,
+		  input_section, rel->r_vaddr - input_section->vma)))
+	    return false;
 	}
+      
+      /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE.  */
+      value_to_relocate = ((value_to_relocate & ~howto.dst_mask) | 
+			   (((value_to_relocate & howto.src_mask) + 
+			     relocation) & howto.dst_mask));
+      
+      /* Put the value back in the object file.  */
+      if (1 == howto.size)
+	bfd_put_16 (input_bfd, value_to_relocate, location);
+      else 
+	bfd_put_32 (input_bfd, value_to_relocate, location);
     }
 
   return true;
@@ -3392,7 +3954,7 @@
       _bfd_xcoff_swap_aux_out,          /* _bfd_swap_aux_out */
       _bfd_xcoff_swap_sym_out,          /* _bfd_swap_sym_out */
       coff_swap_lineno_out,             /* _bfd_swap_lineno_out */
-      coff_swap_reloc_out,              /* _bfd_swap_reloc_out */
+      xcoff_swap_reloc_out,             /* _bfd_swap_reloc_out */
       coff_swap_filehdr_out,            /* _bfd_swap_filehdr_out */
       coff_swap_aouthdr_out,            /* _bfd_swap_aouthdr_out */
       coff_swap_scnhdr_out,             /* _bfd_swap_scnhdr_out */
@@ -3412,7 +3974,7 @@
       coff_swap_filehdr_in,             /* _bfd_coff_swap_filehdr_in */
       coff_swap_aouthdr_in,             /* _bfd_swap_aouthdr_in */
       coff_swap_scnhdr_in,              /* _bfd_swap_scnhdr_in */
-      coff_swap_reloc_in,               /* _bfd_reloc_in */
+      xcoff_swap_reloc_in,              /* _bfd_reloc_in */
       coff_bad_format_hook,             /* _bfd_bad_format_hook */
       coff_set_arch_mach_hook,          /* _bfd_set_arch_mach_hook */
       coff_mkobject_hook,               /* _bfd_mkobject_hook */
@@ -3455,14 +4017,11 @@
     SMALL_AOUTSZ,                       /* _xcoff_small_aout_header_size */
 
   /* Versions. */
-    1,                                    /* _xcoff_ldhdr_version */
+    1,                                   /* _xcoff_ldhdr_version */
 
-    /* Xcoff vs xcoff64 putting symbol names.  */
     _bfd_xcoff_put_symbol_name,          /* _xcoff_put_symbol_name */
-    _bfd_xcoff_put_ldsymbol_name,          /* _xcoff_put_ldsymbol_name */
-
-    & xcoff_dynamic_reloc,                  /* dynamic reloc howto */
-
+    _bfd_xcoff_put_ldsymbol_name,        /* _xcoff_put_ldsymbol_name */
+    & xcoff_dynamic_reloc,               /* dynamic reloc howto */
     xcoff_create_csect_from_smclas,      /* _xcoff_create_csect_from_smclas */
 
     /* Lineno and reloc count overflow.  */
@@ -3481,7 +4040,7 @@
     xcoff_generate_rtinit,  /* _xcoff_generate_rtinit */
 };
 
-/* The transfer vector that leads the outside world to all of the above. */
+/* The transfer vector that leads the outside world to all of the above.  */
 const bfd_target rs6000coff_vec =
 {
   "aixcoff-rs6000",
@@ -3579,7 +4138,7 @@
   _bfd_xcoff_read_ar_hdr,                  /* _read_ar_hdr */
   _bfd_xcoff_openr_next_archived_file,     /* _openr_next_archived_file */
   _bfd_generic_get_elt_at_index,           /* _get_elt_at_index */
-  _bfd_xcoff_generic_stat_arch_elt,        /* _generic_dtat_arch_elt */
+  _bfd_xcoff_stat_arch_elt,                /* _generic_stat_arch_elt */
                                            /* XCOFF archives do not have
 					      a timestamp.  */
   bfd_true,                                /* _update_armap_timestamp */
@@ -3612,6 +4171,7 @@
   bfd_generic_get_relocated_section_contents,
   bfd_generic_relax_section,               /* _bfd_relax_section */
   _bfd_xcoff_bfd_link_hash_table_create,   /* _bfd_link_hash_table_create */
+  _bfd_generic_link_hash_table_free,       /* _bfd_link_hash_table_free */
   _bfd_xcoff_bfd_link_add_symbols,         /* _bfd_link_add_symbols */
   _bfd_xcoff_bfd_final_link,               /* _bfd_filnal_link */
   _bfd_generic_link_split_section,         /* _bfd_link_split_section */
@@ -3651,7 +4211,7 @@
     _bfd_xcoff_swap_aux_out,          /* _bfd_swap_aux_out */
     _bfd_xcoff_swap_sym_out,          /* _bfd_swap_sym_out */
     coff_swap_lineno_out,             /* _bfd_swap_lineno_out */
-    coff_swap_reloc_out,              /* _bfd_swap_reloc_out */
+    xcoff_swap_reloc_out,             /* _bfd_swap_reloc_out */
     coff_swap_filehdr_out,            /* _bfd_swap_filehdr_out */
     coff_swap_aouthdr_out,            /* _bfd_swap_aouthdr_out */
     coff_swap_scnhdr_out,             /* _bfd_swap_scnhdr_out */
@@ -3671,7 +4231,7 @@
     coff_swap_filehdr_in,             /* _bfd_coff_swap_filehdr_in */
     coff_swap_aouthdr_in,             /* _bfd_swap_aouthdr_in */
     coff_swap_scnhdr_in,              /* _bfd_swap_scnhdr_in */
-    coff_swap_reloc_in,               /* _bfd_reloc_in */
+    xcoff_swap_reloc_in,              /* _bfd_reloc_in */
     coff_bad_format_hook,             /* _bfd_bad_format_hook */
     coff_set_arch_mach_hook,          /* _bfd_set_arch_mach_hook */
     coff_mkobject_hook,               /* _bfd_mkobject_hook */
@@ -3839,7 +4399,7 @@
   _bfd_xcoff_read_ar_hdr,                  /* _read_ar_hdr */
   _bfd_xcoff_openr_next_archived_file,     /* _openr_next_archived_file */
   _bfd_generic_get_elt_at_index,           /* _get_elt_at_index */
-  _bfd_xcoff_generic_stat_arch_elt,        /* _generic_dtat_arch_elt */
+  _bfd_xcoff_stat_arch_elt,                /* _generic_stat_arch_elt */
                                            /* XCOFF archives do not have
 					      a timestamp.  */
   bfd_true,                                /* _update_armap_timestamp */
@@ -3872,6 +4432,7 @@
   bfd_generic_get_relocated_section_contents,
   bfd_generic_relax_section,               /* _bfd_relax_section */
   _bfd_xcoff_bfd_link_hash_table_create,   /* _bfd_link_hash_table_create */
+  _bfd_generic_link_hash_table_free,       /* _bfd_link_hash_table_free */
   _bfd_xcoff_bfd_link_add_symbols,         /* _bfd_link_add_symbols */
   _bfd_xcoff_bfd_final_link,               /* _bfd_filnal_link */
   _bfd_generic_link_split_section,         /* _bfd_link_split_section */
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index 6213f6d..ae73996 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -469,7 +469,7 @@
 /* This structure is used to map BFD reloc codes to SH PE relocs.  */
 struct shcoff_reloc_map
 {
-  unsigned char bfd_reloc_val;
+  bfd_reloc_code_real_type bfd_reloc_val;
   unsigned char shcoff_reloc_val;
 };
 
diff --git a/bfd/coff-z8k.c b/bfd/coff-z8k.c
index c626cd7..c1d6a88 100644
--- a/bfd/coff-z8k.c
+++ b/bfd/coff-z8k.c
@@ -185,10 +185,25 @@
       break;
 
     case R_IMM32:
-      bfd_put_32 (in_abfd,
-		  /* 0x80000000 indicates a long segmented address.  */
-		  bfd_coff_reloc16_get_value (reloc, link_info, input_section) | 0x80000000,
-		  data + *dst_ptr);
+      /* If no flags are set, assume immediate value.  */
+      if (! (*reloc->sym_ptr_ptr)->section->flags)
+	{
+	  bfd_put_32 (in_abfd,
+		      bfd_coff_reloc16_get_value (reloc, link_info,
+						  input_section),
+		      data + *dst_ptr);
+	}
+      else
+	{
+	  bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
+						    input_section);
+	  /* Adresses are 23 bit, and the layout of those in a 32-bit
+	     value is as follows:
+	       1AAAAAAA xxxxxxxx AAAAAAAA AAAAAAAA
+	     (A - address bits,  x - ignore).  */
+	  dst = (dst & 0xffff) | ((dst & 0xff0000) << 8) | 0x80000000;
+	  bfd_put_32 (in_abfd, dst, data + *dst_ptr);
+	}
       (*dst_ptr) += 4;
       (*src_ptr) += 4;
       break;
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 9758afd..b1bc2f5 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -4,21 +4,21 @@
    Written Clinton Popetz.
    Contributed by Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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 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.
+   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.  */
+   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"
@@ -84,6 +84,9 @@
 
 static void _bfd_xcoff64_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
 static unsigned int _bfd_xcoff64_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
+static boolean _bfd_xcoff64_put_symbol_name
+  PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *,
+	   const char *));
 static boolean _bfd_xcoff64_put_ldsymbol_name
   PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
 	   const char *));
@@ -93,6 +96,8 @@
   PARAMS ((bfd *, PTR, int, int, int, int, PTR));
 static unsigned int _bfd_xcoff64_swap_aux_out
   PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static void xcoff64_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int xcoff64_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
 extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
 extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
 extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
@@ -103,7 +108,7 @@
 extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
 extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
 extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
-extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
+extern int _bfd_xcoff_stat_arch_elt PARAMS ((bfd *, struct stat *));
 extern boolean _bfd_xcoff_write_armap
   PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
 extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
@@ -129,8 +134,8 @@
 static boolean xcoff64_write_object_contents PARAMS ((bfd *));
 static boolean xcoff64_ppc_relocate_section
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	 struct internal_reloc *, struct internal_syment *,
-	 asection **sections));
+	   struct internal_reloc *, struct internal_syment *,
+	   asection **));
 static boolean xcoff64_slurp_armap PARAMS ((bfd *));
 static const bfd_target *xcoff64_archive_p PARAMS ((bfd *));
 static bfd *xcoff64_openr_next_archived_file PARAMS ((bfd *, bfd *));
@@ -143,10 +148,11 @@
   PARAMS ((bfd *, struct internal_ldhdr *));
 static bfd_vma xcoff64_loader_reloc_offset
   PARAMS ((bfd *, struct internal_ldhdr *));
-static boolean xcoff64_generate_rtinit 
-  PARAMS((bfd *, const char *, const char *, boolean));
+static boolean xcoff64_generate_rtinit
+  PARAMS ((bfd *, const char *, const char *, boolean));
+static boolean xcoff64_bad_format_hook PARAMS ((bfd *, PTR ));
 
-/* coffcode.h needs these to be defined */
+/* coffcode.h needs these to be defined.  */
 /* Internalcoff.h and coffcode.h modify themselves based on these flags.  */
 #define XCOFF64
 #define RS6000COFF_C 1
@@ -171,7 +177,7 @@
 #define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
 #ifdef AIX_CORE
 extern const bfd_target * rs6000coff_core_p PARAMS ((bfd *abfd));
-extern boolean rs6000coff_core_file_matches_executable_p 
+extern boolean rs6000coff_core_file_matches_executable_p
   PARAMS((bfd *cbfd, bfd *ebfd));
 extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
 extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
@@ -195,7 +201,9 @@
 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
 #define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
 #define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
-
+#define coff_swap_reloc_in xcoff64_swap_reloc_in
+#define coff_swap_reloc_out xcoff64_swap_reloc_out
+#define NO_COFF_RELOCS
 
 #include "coffcode.h"
 
@@ -289,7 +297,7 @@
   switch (class)
     {
     case C_FILE:
-      if (ext->x_file.x_n.x_zeroes == 0)
+      if (ext->x_file.x_n.x_zeroes[0] == 0)
 	{
 	  in->x_file.x_n.x_zeroes = 0;
 	  in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
@@ -453,9 +461,12 @@
 }
 
 static boolean
-_bfd_xcoff64_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
-			      struct internal_syment *sym,
-			      const char *name) {
+_bfd_xcoff64_put_symbol_name (abfd, strtab, sym, name)
+     bfd *abfd;
+     struct bfd_strtab_hash *strtab;
+     struct internal_syment *sym;
+     const char *name;
+{
   boolean hash;
   bfd_size_type indx;
 
@@ -482,7 +493,6 @@
      struct internal_ldsym *ldsym;
      const char *name;
 {
-
   size_t len;
   len = strlen (name);
 
@@ -608,6 +618,40 @@
   bfd_put_32 (abfd, src->l_parm, dst->l_parm);
 }
 
+static void
+xcoff64_swap_reloc_in (abfd, s, d)
+     bfd *abfd;
+     PTR s;
+     PTR d;
+{
+  struct external_reloc *src = (struct external_reloc *) s;
+  struct internal_reloc *dst = (struct internal_reloc *) d;
+
+  memset (dst, 0, sizeof (struct internal_reloc));
+
+  dst->r_vaddr = bfd_get_64 (abfd, src->r_vaddr);
+  dst->r_symndx = bfd_get_32 (abfd, src->r_symndx);
+  dst->r_size = bfd_get_8 (abfd, src->r_size);
+  dst->r_type = bfd_get_8 (abfd, src->r_type);
+}
+
+static unsigned int
+xcoff64_swap_reloc_out (abfd, s, d)
+     bfd *abfd;
+     PTR s;
+     PTR d;
+{
+  struct internal_reloc *src = (struct internal_reloc *) s;
+  struct external_reloc *dst = (struct external_reloc *) d;
+
+  bfd_put_64 (abfd, src->r_vaddr, dst->r_vaddr);
+  bfd_put_32 (abfd, src->r_symndx, dst->r_symndx);
+  bfd_put_8 (abfd, src->r_type, dst->r_type);
+  bfd_put_8 (abfd, src->r_size, dst->r_size);
+
+  return bfd_coff_relsz (abfd);
+}
+
 /* Swap in the ldrel structure.  */
 
 static void
@@ -668,7 +712,7 @@
 	return false;
     }
 
-  /* Work out the size of the reloc and linno areas */
+  /* Work out the size of the reloc and linno areas.  */
   reloc_base = obj_relocbase (abfd);
 
   for (current = abfd->sections; current != NULL; current = current->next)
@@ -677,12 +721,12 @@
   lineno_base = reloc_base + reloc_size;
 
   /* Make a pass through the symbol table to count line number entries and
-     put them into the correct asections */
+     put them into the correct asections.  */
   lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
 
   sym_base = lineno_base + lnno_size;
 
-  /* Indicate in each section->line_filepos its actual file address */
+  /* Indicate in each section->line_filepos its actual file address.  */
   for (current = abfd->sections; current != NULL; current =  current->next)
     {
       if (current->lineno_count)
@@ -792,7 +836,7 @@
   if (abfd->flags & EXEC_P)
     internal_f.f_flags |= F_EXEC;
 
-  /* FIXME: this is wrong for PPC_PE! */
+  /* FIXME: this is wrong for PPC_PE!  */
   if (bfd_little_endian (abfd))
     internal_f.f_flags |= F_AR32WR;
   else
@@ -805,11 +849,7 @@
 
   memset (&internal_a, 0, sizeof internal_a);
 
-
-  /* This can only be called from the xcoff64 backend so the magic #
-     must be for xcoff64.  */
-  internal_f.f_magic = 0757;
-
+  internal_f.f_magic = bfd_xcoff_magic_number (abfd);
   internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
     (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
     RS6K_AOUTHDR_OMAGIC;
@@ -817,7 +857,7 @@
   /* FIXME: Does anybody ever set this to another value?  */
   internal_a.vstamp = 0;
 
-  /* Now should write relocs, strings, syms */
+  /* Now should write relocs, strings, syms.  */
   obj_sym_filepos (abfd) = sym_base;
 
   internal_f.f_symptr = 0;
@@ -990,11 +1030,10 @@
   return true;
 }
 
-/* This is the relocation function for the RS/6000/POWER/PowerPC.
-   This is currently the only processor which uses XCOFF; I hope that
-   will never change.  */
+/* This is the relocation function for the PowerPC64.
+   See xcoff_ppc_relocation_section for more information. */
 
-static boolean
+boolean
 xcoff64_ppc_relocate_section (output_bfd, info, input_bfd,
 			      input_section, contents, relocs, syms,
 			      sections)
@@ -1020,7 +1059,10 @@
       bfd_vma addend;
       bfd_vma val;
       struct reloc_howto_struct howto;
-      bfd_reloc_status_type rstat;
+      bfd_vma relocation;
+      bfd_vma value_to_relocate;
+      bfd_vma address;
+      bfd_byte *location;
 
       /* Relocation type R_REF is a special relocation type which is
          merely used to prevent garbage collection from occurring for
@@ -1028,65 +1070,37 @@
       if (rel->r_type == R_REF)
 	continue;
 
-      symndx = rel->r_symndx;
-
-      if (symndx == -1)
-	{
-	  h = NULL;
-	  sym = NULL;
-	  addend = 0;
-	}
-      else
-	{
-	  h = obj_xcoff_sym_hashes (input_bfd)[symndx];
-	  sym = syms + symndx;
-	  addend = - sym->n_value;
-	}
-
-      /* We build the howto information on the fly.  */
-
+      /* howto */
       howto.type = rel->r_type;
       howto.rightshift = 0;
-      howto.size = 4;
       howto.bitsize = (rel->r_size & 0x3f) + 1;
+      howto.size = howto.bitsize > 16 ? (howto.bitsize > 32 ? 4 : 2) : 1;
       howto.pc_relative = false;
       howto.bitpos = 0;
-      if ((rel->r_size & 0x80) != 0)
-	howto.complain_on_overflow = complain_overflow_signed;
-      else
-	howto.complain_on_overflow = complain_overflow_bitfield;
+      howto.complain_on_overflow = rel->r_size & 0x80 ? 
+	complain_overflow_signed : complain_overflow_bitfield;
       howto.special_function = NULL;
       howto.name = "internal";
       howto.partial_inplace = true;
-
-      if (howto.bitsize == 64)
-	{
-	  howto.src_mask = howto.dst_mask = MINUS_ONE;
-	}
-      else if (howto.bitsize == 32)
-	{
-	  howto.src_mask = howto.dst_mask = 0xffffffff;
-	}
-      else
-	{
-	  howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1;
-	  if (howto.bitsize == 16)
-	    howto.size = 1;
-	}
+      howto.src_mask = howto.dst_mask = N_ONES(howto.bitsize);
       howto.pcrel_offset = false;
 
+      /* symbol */
       val = 0;
+      addend = 0;
+      h = NULL;
+      sym = NULL;
+      symndx = rel->r_symndx;      
 
-      if (h == NULL)
+      if (-1 != symndx)	
 	{
 	  asection *sec;
-
-	  if (symndx == -1)
-	    {
-	      sec = bfd_abs_section_ptr;
-	      val = 0;
-	    }
-	  else
+	  
+	  h = obj_xcoff_sym_hashes (input_bfd)[symndx];
+	  sym = syms + symndx;
+	  addend = - sym->n_value;
+	  
+	  if (NULL == h) 
 	    {
 	      sec = sections[symndx];
 	      /* Hack to make sure we use the right TOC anchor value
@@ -1099,270 +1113,116 @@
 		       + sec->output_offset
 		       + sym->n_value
 		       - sec->vma);
-	    }
-
-	}
-      else
-	{
-
-	  if (h->root.type == bfd_link_hash_defined
-	      || h->root.type == bfd_link_hash_defweak)
+	    } 
+	  else 
 	    {
-	      asection *sec;
-
-	      sec = h->root.u.def.section;
-	      val = (h->root.u.def.value
-		     + sec->output_section->vma
-		     + sec->output_offset);
-
-	    }
-	  else if (h->root.type == bfd_link_hash_common)
-	    {
-	      asection *sec;
-
-	      sec = h->root.u.c.p->section;
-	      val = (sec->output_section->vma
-		     + sec->output_offset);
-	    }
-	  else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0
-		   || (h->flags & XCOFF_IMPORT) != 0)
-	    {
-	      /* Every symbol in a shared object is defined somewhere.  */
-	      val = 0;
-	    }
-	  else if (! info->relocateable)
-	    {
-	      if (! ((*info->callbacks->undefined_symbol)
-		     (info, h->root.root.string, input_bfd, input_section,
-		      rel->r_vaddr - input_section->vma, true)))
-		return false;
-
-	      /* Don't try to process the reloc.  It can't help, and
-		 it may generate another error.  */
-	      continue;
-	    }
-	}
-
-      /* I took the relocation type definitions from two documents:
-	 the PowerPC AIX Version 4 Application Binary Interface, First
-	 Edition (April 1992), and the PowerOpen ABI, Big-Endian
-	 32-Bit Hardware Implementation (June 30, 1994).  Differences
-	 between the documents are noted below.  */
-
-      switch (rel->r_type)
-	{
-	case R_RTB:
-	case R_RRTBI:
-	case R_RRTBA:
-	  /* These relocs are defined by the PowerPC ABI to be
-	     relative branches which use half of the difference
-	     between the symbol and the program counter.  I can't
-	     quite figure out when this is useful.  These relocs are
-	     not defined by the PowerOpen ABI.  */
-	default:
-	  (*_bfd_error_handler)
-	    (_("%s: unsupported relocation type 0x%02x"),
-	     bfd_archive_filename (input_bfd), (unsigned int) rel->r_type);
-	  bfd_set_error (bfd_error_bad_value);
-	  return false;
-	case R_POS:
-	  /* Simple positive relocation.  */
-	  break;
-	case R_NEG:
-	  /* Simple negative relocation.  */
-	  val = - val;
-	  break;
-	case R_REL:
-	  /* Simple PC relative relocation.  */
-	  howto.pc_relative = true;
-	  break;
-	case R_TOC:
-	  /* TOC relative relocation.  The value in the instruction in
-	     the input file is the offset from the input file TOC to
-	     the desired location.  We want the offset from the final
-	     TOC to the desired location.  We have:
-	     isym = iTOC + in
-	     iinsn = in + o
-	     osym = oTOC + on
-	     oinsn = on + o
-	     so we must change insn by on - in.
-	  */
-	case R_GL:
-	  /* Global linkage relocation.  The value of this relocation
-	     is the address of the entry in the TOC section.  */
-	case R_TCL:
-	  /* Local object TOC address.  I can't figure out the
-	     difference between this and case R_GL.  */
-	case R_TRL:
-	  /* TOC relative relocation.  A TOC relative load instruction
-	     which may be changed to a load address instruction.
-	     FIXME: We don't currently implement this optimization.  */
-	case R_TRLA:
-	  /* TOC relative relocation.  This is a TOC relative load
-	     address instruction which may be changed to a load
-	     instruction.  FIXME: I don't know if this is the correct
-	     implementation.  */
-	  if (h != NULL && h->smclas != XMC_TD)
-	    {
-	      if (h->toc_section == NULL)
+	      if (h->root.type == bfd_link_hash_defined 
+		  || h->root.type == bfd_link_hash_defweak) 
 		{
-		  (*_bfd_error_handler)
-		    (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
-		     bfd_archive_filename (input_bfd), rel->r_vaddr,
-		     h->root.root.string);
-		  bfd_set_error (bfd_error_bad_value);
-		  return false;
+		  sec = h->root.u.def.section;
+		  val = (h->root.u.def.value
+			 + sec->output_section->vma
+			 + sec->output_offset);
+		} 
+	      else if (h->root.type == bfd_link_hash_common) 
+		{
+		  sec = h->root.u.c.p->section;
+		  val = (sec->output_section->vma
+			 + sec->output_offset);
+		} 
+	      else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT))) 
+		       && ! info->relocateable) 
+		{
+		  if (! ((*info->callbacks->undefined_symbol)
+			 (info, h->root.root.string, input_bfd, input_section,
+			  rel->r_vaddr - input_section->vma, true)))
+		    return false;
+		  
+		  /* Don't try to process the reloc.  It can't help, and
+		     it may generate another error.  */
+		  continue;
 		}
-
-	      BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
-	      val = (h->toc_section->output_section->vma
-		     + h->toc_section->output_offset);
-	    }
-
-	  val = ((val - xcoff_data (output_bfd)->toc)
-		 - (sym->n_value - xcoff_data (input_bfd)->toc));
-
-	  addend = 0;
-	  break;
-	case R_BA:
-	  /* Absolute branch.  We don't want to mess with the lower
-	     two bits of the instruction.  */
-	case R_CAI:
-	  /* The PowerPC ABI defines this as an absolute call which
-	     may be modified to become a relative call.  The PowerOpen
-	     ABI does not define this relocation type.  */
-	case R_RBA:
-	  /* Absolute branch which may be modified to become a
-	     relative branch.  */
-	case R_RBAC:
-	  /* The PowerPC ABI defines this as an absolute branch to a
-	     fixed address which may be modified to an absolute branch
-	     to a symbol.  The PowerOpen ABI does not define this
-	     relocation type.  */
-	case R_RBRC:
-	  /* The PowerPC ABI defines this as an absolute branch to a
-	     fixed address which may be modified to a relative branch.
-	     The PowerOpen ABI does not define this relocation type.  */
-	  howto.src_mask &= ~3;
-	  howto.dst_mask = howto.src_mask;
-	  break;
-	case R_BR:
-	  /* Relative branch.  We don't want to mess with the lower
-	     two bits of the instruction.  */
-	case R_CREL:
-	  /* The PowerPC ABI defines this as a relative call which may
-	     be modified to become an absolute call.  The PowerOpen
-	     ABI does not define this relocation type.  */
-	case R_RBR:
-	  /* A relative branch which may be modified to become an
-	     absolute branch.  FIXME: We don't implement this,
-	     although we should for symbols of storage mapping class
-	     XMC_XO.  */
-	  howto.pc_relative = true;
-	  howto.src_mask &= ~3;
-	  howto.dst_mask = howto.src_mask;
-	  howto.size = 2;
-	  howto.complain_on_overflow = complain_overflow_bitfield;
-	  break;
-	case R_RL:
-	  /* The PowerPC AIX ABI describes this as a load which may be
-	     changed to a load address.  The PowerOpen ABI says this
-	     is the same as case R_POS.  */
-	  break;
-	case R_RLA:
-	  /* The PowerPC AIX ABI describes this as a load address
-	     which may be changed to a load.  The PowerOpen ABI says
-	     this is the same as R_POS.  */
-	  break;
-	}
-
-      /* If we see an R_BR or R_RBR reloc which is jumping to global
-         linkage code, and it is followed by an appropriate cror nop
-         instruction, we replace the cror with ld r2,40(r1).  This
-         restores the TOC after the glink code.  Contrariwise, if the
-         call is followed by a ld r2,40(r1), but the call is not
-         going to global linkage code, we can replace the load with a
-         cror.  */
-      if ((rel->r_type == R_BR || rel->r_type == R_RBR)
-	  && h != NULL
-	  && h->root.type == bfd_link_hash_defined
-	  && (rel->r_vaddr - input_section->vma + 8
-	      <= input_section->_cooked_size))
-	{
-	  bfd_byte *pnext;
-	  unsigned long next;
-
-	  pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
-	  next = bfd_get_32 (input_bfd, pnext);
-
-
-	  /* The _ptrgl function is magic.  It is used by the AIX
-	   * compiler to call a function through a pointer.
-	   *
-	   * special case XMC_GL, global linkage
-	   */
-	  if (h->smclas == XMC_GL
-	      || strcmp (h->root.root.string, "._ptrgl") == 0)
-	    {
-	      if (next == 0x4def7b82 /* cror 15,15,15 */
-		  || next == 0x4ffffb82 /* cror 31,31,31 */
-		  || next == 0x60000000 /* ori r0,r0,0 */)
-		bfd_put_32 (input_bfd, (bfd_vma) 0xe8410028 /* ld r2,40(r1) */,
-			    pnext);
-	    }
-	  else
-	    {
-	      if (next == 0xe8410028 /* ld r2,40(r1) */)
-		bfd_put_32 (input_bfd, (bfd_vma) 0x60000000 /* ori r0,r0,0 */,
-			    pnext);
 	    }
 	}
-
-      /* A PC relative reloc includes the section address.  */
-      if (howto.pc_relative)
-	addend += input_section->vma;
-
-      rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section,
-					contents,
-					rel->r_vaddr - input_section->vma,
-					val, addend);
-
-      switch (rstat)
+      
+      if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION 
+	  || (false == xcoff_calculate_relocation[rel->r_type]
+	      (input_bfd, input_section, output_bfd, rel, sym, &howto, val, 
+	       addend, &relocation, contents))) 
+	return false;
+      
+      /* address */
+      address = rel->r_vaddr - input_section->vma;
+      location = contents + address;
+      
+      if (address > input_section->_raw_size)
+	abort();
+      
+      /* Get the value we are going to relocate.  */
+      if (1 == howto.size)
+	value_to_relocate = bfd_get_16 (input_bfd, location);
+      else if (2 == howto.size)
+	value_to_relocate = bfd_get_32 (input_bfd, location);
+      else 
+	value_to_relocate = bfd_get_64 (input_bfd, location);
+      
+      /* overflow.  
+	 
+	 FIXME: We may drop bits during the addition
+	 which we don't check for.  We must either check at every single
+	 operation, which would be tedious, or we must do the computations
+	 in a type larger than bfd_vma, which would be inefficient.  */
+      
+      if ((unsigned int) howto.complain_on_overflow >= 
+	  XCOFF_MAX_COMPLAIN_OVERFLOW)
+	abort();
+      
+      if ((true == xcoff_complain_overflow[howto.complain_on_overflow]
+	   (input_bfd, value_to_relocate, relocation, &howto))) 
 	{
-	default:
-	  abort ();
-	case bfd_reloc_ok:
-	  break;
-	case bfd_reloc_overflow:
-	  {
-	    const char *name;
-	    char buf[SYMNMLEN + 1];
-	    char howto_name[10];
-
-	    if (symndx == -1)
+	  const char *name;
+	  char buf[SYMNMLEN + 1];
+	  char reloc_type_name[10];
+	  
+	  if (symndx == -1) 
+	    {
 	      name = "*ABS*";
-	    else if (h != NULL)
+	    } 
+	  else if (h != NULL) 
+	    {
 	      name = h->root.root.string;
-	    else
-	      {
-		name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
-		if (name == NULL)
-		  return false;
-	      }
-	    sprintf (howto_name, "0x%02x", rel->r_type);
-
-	    if (! ((*info->callbacks->reloc_overflow)
-		   (info, name, howto_name, (bfd_vma) 0, input_bfd,
-		    input_section, rel->r_vaddr - input_section->vma)))
-	      return false;
-	  }
+	    } 
+	  else 
+	    {
+	      name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
+	      if (name == NULL)
+		name = "UNKNOWN";
+	    }
+	  sprintf (reloc_type_name, "0x%02x", rel->r_type);
+	  
+	  if (! ((*info->callbacks->reloc_overflow)
+		 (info, name, reloc_type_name, (bfd_vma) 0, input_bfd,
+		  input_section, rel->r_vaddr - input_section->vma)))
+	    return false;
 	}
-    }
 
+      /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE.  */
+      value_to_relocate = ((value_to_relocate & ~howto.dst_mask) | 
+			   (((value_to_relocate & howto.src_mask) + 
+			     relocation) & howto.dst_mask));
+      
+      /* Put the value back in the object file.  */
+      if (1 == howto.size)
+	bfd_put_16 (input_bfd, value_to_relocate, location);
+      else if (2 == howto.size)
+	bfd_put_32 (input_bfd, value_to_relocate, location);
+      else
+	bfd_put_64 (input_bfd, value_to_relocate, location);
+      
+    }
   return true;
 }
 
-
 
 /* The XCOFF reloc table.  Actually, XCOFF relocations specify the
    bitsize and whether they are signed or not, along with a
@@ -1370,7 +1230,6 @@
    different algorithms for putting in the reloc.  Many of these
    relocs need special_function entries, which I have not written.  */
 
-
 reloc_howto_type xcoff64_howto_table[] =
 {
   /* Standard 64 bit relocation.  */
@@ -1382,7 +1241,7 @@
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 0,			/* special_function */
-	 "R_POS",		/* name */
+	 "R_POS_64",		/* name */
 	 true,			/* partial_inplace */
 	 MINUS_ONE,		/* src_mask */
 	 MINUS_ONE,		/* dst_mask */
@@ -1433,7 +1292,7 @@
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
-  /* I don't really know what this is.	*/
+  /* I don't really know what this is.  */
   HOWTO (R_RTB,			/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1489,7 +1348,7 @@
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 0,			/* special_function */
-	 "R_BA",		/* name */
+	 "R_BA_26",		/* name */
 	 true,			/* partial_inplace */
 	 0x3fffffc,		/* src_mask */
 	 0x3fffffc,		/* dst_mask */
@@ -1546,7 +1405,7 @@
 
   EMPTY_HOWTO (0xe),
 
-  /* Non-relocating reference.	*/
+  /* Non-relocating reference.  */
   HOWTO (R_REF,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1639,7 +1498,7 @@
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
-  /* Modifiable call relative.	*/
+  /* Modifiable call relative.  */
   HOWTO (R_CREL,		/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1693,7 +1552,7 @@
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
 	 0,			/* special_function */
-	 "R_RBR",		/* name */
+	 "R_RBR_26",		/* name */
 	 true,			/* partial_inplace */
 	 0xffff,		/* src_mask */
 	 0xffff,		/* dst_mask */
@@ -1716,31 +1575,46 @@
 
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
-	 4,			/* size (0 = byte, 1 = short, 2 = long) */
-	 64,			/* bitsize */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 0,			/* special_function */
-	 "R_POS",		/* name */
+	 "R_POS_32",		/* name */
 	 true,			/* partial_inplace */
-	 MINUS_ONE,		/* src_mask */
-	 MINUS_ONE,		/* dst_mask */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
   /* 16 bit Non modifiable absolute branch.  */
-  HOWTO (R_BA,	                /* type */
+  HOWTO (R_BA,			/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 0,			/* special_function */
+	 "R_BA_16",		/* name */
+	 true,			/* partial_inplace */
+	 0xfffc,		/* src_mask */
+	 0xfffc,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* Modifiable branch relative.  */
+  HOWTO (R_RBR,	                /* type */
 	 0,	                /* rightshift */
-	 2,	                /* size (0 = byte, 1 = short, 2 = long) */
+	 1,	                /* size (0 = byte, 1 = short, 2 = long) */
 	 16,	                /* bitsize */
 	 false,	                /* pc_relative */
 	 0,	                /* bitpos */
-	 complain_overflow_bitfield, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 0,		        /* special_function */
-	 "R_BA",                /* name */
+	 "R_RBR_16",            /* name */
 	 true,	                /* partial_inplace */
-	 0xfffc,	        /* src_mask */
-	 0xfffc,        	/* dst_mask */
+	 0xffff,	        /* src_mask */
+	 0xffff,        	/* dst_mask */
 	 false),                /* pcrel_offset */
 };
 
@@ -1749,15 +1623,27 @@
      arelent *relent;
      struct internal_reloc *internal;
 {
-  relent->howto = xcoff64_howto_table + internal->r_type;
-
-  /* Check for relocs we don't know of.  */
-  if (internal->r_type
-      >= sizeof (xcoff64_howto_table) / sizeof (xcoff64_howto_table[0]))
-    abort ();
-  if (internal->r_type != relent->howto->type)
+  if (internal->r_type > R_RBRC)
     abort ();
 
+  /* Default howto layout works most of the time */
+  relent->howto = &xcoff64_howto_table[internal->r_type];
+  
+  /* Special case some 16 bit reoloc */
+  if (15 == (internal->r_size & 0x3f))
+    {
+      if (R_BA == internal->r_type) 
+	relent->howto = &xcoff64_howto_table[0x1d];
+      else if (R_RBR == internal->r_type) 
+	relent->howto = &xcoff64_howto_table[0x1e];
+    }
+  /* Special case 32 bit */
+  else if (31 == (internal->r_size & 0x3f))
+    {
+      if (R_POS == internal->r_type) 
+	relent->howto = &xcoff64_howto_table[0x1c];
+    }
+  
   /* The r_size field of an XCOFF reloc encodes the bitsize of the
      relocation, as well as indicating whether it is signed or not.
      Doublecheck that the relocation information gathered from the
@@ -1767,12 +1653,10 @@
       && (relent->howto->bitsize
 	  != ((unsigned int) internal->r_size & 0x3f) + 1))
     abort ();
-#if 0
-  if ((internal->r_size & 0x80) != 0
-      ? (relent->howto->complain_on_overflow != complain_overflow_signed)
-      : (relent->howto->complain_on_overflow != complain_overflow_bitfield))
-    abort ();
-#endif
+
+  /* Put a meaningful value in addend */
+  relent->addend = (internal->r_size & 0x80) ? - internal->r_vaddr 
+    : internal->r_vaddr;
 }
 
 reloc_howto_type *
@@ -1792,16 +1676,14 @@
       return &xcoff64_howto_table[3];
     case BFD_RELOC_32:
     case BFD_RELOC_CTOR:
-      return &xcoff64_howto_table[0];
-    case BFD_RELOC_64:
       return &xcoff64_howto_table[0x1c];
+    case BFD_RELOC_64:
+      return &xcoff64_howto_table[0];
     default:
       return NULL;
     }
 }
 
-
-
 /* Read in the armap of an XCOFF archive.  */
 
 static boolean
@@ -2114,7 +1996,24 @@
   return (ldhdr->l_rldoff);
 }
 
-static boolean 
+static boolean
+xcoff64_bad_format_hook (abfd, filehdr)
+     bfd * abfd;
+     PTR filehdr;
+{
+  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+  /* Check flavor first.  */
+  if (bfd_get_flavour (abfd) != bfd_target_xcoff_flavour)
+    return false;
+
+  if (bfd_xcoff_magic_number (abfd) != internal_f->f_magic)
+    return false;
+
+  return true;
+}
+
+static boolean
 xcoff64_generate_rtinit (abfd, init, fini, rtld)
      bfd *abfd;
      const char *init;
@@ -2138,34 +2037,34 @@
   struct internal_syment syment;
   union internal_auxent auxent;
   struct internal_reloc reloc;
-  
+
   char *text_name = ".text";
   char *data_name = ".data";
   char *bss_name = ".bss";
   char *rtinit_name = "__rtinit";
   char *rtld_name = "__rtld";
-  
+
   if (! bfd_xcoff_rtinit_size (abfd))
     return false;
 
   initsz = (init == NULL ? 0 : 1 + strlen (init));
   finisz = (fini == NULL ? 0 : 1 + strlen (fini));
 
-  /* file header */
+  /* File header.  */
   memset (filehdr_ext, 0, FILHSZ);
   memset (&filehdr, 0, sizeof (struct internal_filehdr));
   filehdr.f_magic = bfd_xcoff_magic_number (abfd);
-  filehdr.f_nscns = 3; 
+  filehdr.f_nscns = 3;
   filehdr.f_timdat = 0;
   filehdr.f_nsyms = 0;  /* at least 6, no more than 8 */
   filehdr.f_symptr = 0; /* set below */
   filehdr.f_opthdr = 0;
   filehdr.f_flags = 0;
 
-  /* section headers */
+  /* Section headers.  */
   memset (scnhdr_ext, 0, 3 * SCNHSZ);
 
-  /* text */
+  /* Text.  */
   memset (&text_scnhdr, 0, sizeof (struct internal_scnhdr));
   memcpy (text_scnhdr.s_name, text_name, strlen (text_name));
   text_scnhdr.s_paddr = 0;
@@ -2178,7 +2077,7 @@
   text_scnhdr.s_nlnno = 0;
   text_scnhdr.s_flags = STYP_TEXT;
 
-  /* data */
+  /* Data.  */
   memset (&data_scnhdr, 0, sizeof (struct internal_scnhdr));
   memcpy (data_scnhdr.s_name, data_name, strlen (data_name));
   data_scnhdr.s_paddr = 0;
@@ -2191,25 +2090,25 @@
   data_scnhdr.s_nlnno = 0;
   data_scnhdr.s_flags = STYP_DATA;
 
-  /* bss */
+  /* Bss.  */
   memset (&bss_scnhdr, 0, sizeof (struct internal_scnhdr));
   memcpy (bss_scnhdr.s_name, bss_name, strlen (bss_name));
   bss_scnhdr.s_paddr = 0; /* set below */
   bss_scnhdr.s_vaddr = 0; /* set below */
   bss_scnhdr.s_size = 0;  /* set below */
   bss_scnhdr.s_scnptr = 0;
-  bss_scnhdr.s_relptr = 0;  
+  bss_scnhdr.s_relptr = 0;
   bss_scnhdr.s_lnnoptr = 0;
   bss_scnhdr.s_nreloc = 0;
   bss_scnhdr.s_nlnno = 0;
   bss_scnhdr.s_flags = STYP_BSS;
 
-  /* .data 
+  /* .data
      0x0000           0x00000000 : rtl
      0x0004           0x00000000 :
      0x0008           0x00000018 : offset to init, or 0
      0x000C           0x00000038 : offset to fini, or 0
-     0x0010           0x00000010 : size of descriptor 
+     0x0010           0x00000010 : size of descriptor
      0x0014           0x00000000 : pad
      0x0018           0x00000000 : init, needs a reloc
      0x001C           0x00000000 :
@@ -2217,16 +2116,16 @@
      0x0024           0x00000000 : flags, padded to a word
      0x0028           0x00000000 : empty init
      0x002C           0x00000000 :
-     0x0030           0x00000000 : 
-     0x0034           0x00000000 : 
+     0x0030           0x00000000 :
+     0x0034           0x00000000 :
      0x0038           0x00000000 : fini, needs a reloc
      0x003C           0x00000000 :
      0x0040           0x00000??? : offset to fini name
      0x0044           0x00000000 : flags, padded to a word
      0x0048           0x00000000 : empty fini
      0x004C           0x00000000 :
-     0x0050           0x00000000 : 
-     0x0054           0x00000000 : 
+     0x0050           0x00000000 :
+     0x0054           0x00000000 :
      0x0058           init name
      0x0058 + initsz  fini name */
 
@@ -2236,10 +2135,10 @@
   data_buffer = (bfd_byte *)bfd_malloc (data_buffer_size);
   if (data_buffer == NULL)
     return false;
-  
+
   memset (data_buffer, 0, data_buffer_size);
 
-  if (initsz) 
+  if (initsz)
     {
       val = 0x18;
       bfd_put_32 (abfd, val, &data_buffer[0x08]);
@@ -2248,7 +2147,7 @@
       memcpy (&data_buffer[val], init, initsz);
     }
 
-  if (finisz) 
+  if (finisz)
     {
       val = 0x38;
       bfd_put_32 (abfd, val, &data_buffer[0x0C]);
@@ -2262,7 +2161,7 @@
   data_scnhdr.s_size = data_buffer_size;
   bss_scnhdr.s_paddr = bss_scnhdr.s_vaddr = data_scnhdr.s_size;
 
-  /* string table */
+  /* String table.  */
   string_table_size = 4;
   string_table_size += strlen (data_name) + 1;
   string_table_size += strlen (rtinit_name) + 1;
@@ -2276,12 +2175,12 @@
   val = string_table_size;
   bfd_put_32 (abfd, val, &string_table[0]);
   st_tmp = string_table + 4;
-  
-  /* symbols 
+
+  /* symbols
      0. .data csect
      2. __rtinit
-     4. init function 
-     6. fini function 
+     4. init function
+     6. fini function
      8. __rtld  */
   memset (syment_ext, 0, 10 * SYMESZ);
   memset (reloc_ext, 0, 3 * RELSZ);
@@ -2300,10 +2199,10 @@
   auxent.x_csect.x_scnlen.l = data_buffer_size;
   auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;
   auxent.x_csect.x_smclas = XMC_RW;
-  bfd_coff_swap_sym_out (abfd, &syment, 
+  bfd_coff_swap_sym_out (abfd, &syment,
 			 &syment_ext[filehdr.f_nsyms * SYMESZ]);
-  bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, 
-			 syment.n_numaux, 
+  bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
+			 syment.n_numaux,
 			 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
   filehdr.f_nsyms += 2;
 
@@ -2313,21 +2212,21 @@
   syment._n._n_n._n_offset = st_tmp - string_table;
   memcpy (st_tmp, rtinit_name, strlen (rtinit_name));
   st_tmp += strlen (rtinit_name) + 1;
-  
+
   syment.n_scnum = 2;
   syment.n_sclass = C_EXT;
   syment.n_numaux = 1;
   auxent.x_csect.x_smtyp = XTY_LD;
   auxent.x_csect.x_smclas = XMC_RW;
-  bfd_coff_swap_sym_out (abfd, &syment, 
+  bfd_coff_swap_sym_out (abfd, &syment,
 			 &syment_ext[filehdr.f_nsyms * SYMESZ]);
-  bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, 
-			 syment.n_numaux, 
+  bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
+			 syment.n_numaux,
 			 &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
   filehdr.f_nsyms += 2;
 
-  /* init */
-  if (initsz) 
+  /* Init.  */
+  if (initsz)
     {
       memset (&syment, 0, sizeof (struct internal_syment));
       memset (&auxent, 0, sizeof (union internal_auxent));
@@ -2338,12 +2237,12 @@
 
       syment.n_sclass = C_EXT;
       syment.n_numaux = 1;
-      bfd_coff_swap_sym_out (abfd, &syment, 
+      bfd_coff_swap_sym_out (abfd, &syment,
 			     &syment_ext[filehdr.f_nsyms * SYMESZ]);
-      bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, 
-			     syment.n_numaux, 
+      bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
+			     syment.n_numaux,
 			     &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
-      /* reloc */
+      /* Reloc.  */
       memset (&reloc, 0, sizeof (struct internal_reloc));
       reloc.r_vaddr = 0x0018;
       reloc.r_symndx = filehdr.f_nsyms;
@@ -2355,8 +2254,8 @@
       data_scnhdr.s_nreloc += 1;
     }
 
-  /* finit */
-  if (finisz) 
+  /* Finit.  */
+  if (finisz)
     {
       memset (&syment, 0, sizeof (struct internal_syment));
       memset (&auxent, 0, sizeof (union internal_auxent));
@@ -2367,19 +2266,19 @@
 
       syment.n_sclass = C_EXT;
       syment.n_numaux = 1;
-      bfd_coff_swap_sym_out (abfd, &syment, 
+      bfd_coff_swap_sym_out (abfd, &syment,
 			     &syment_ext[filehdr.f_nsyms * SYMESZ]);
-      bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, 
-			     syment.n_numaux, 
+      bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
+			     syment.n_numaux,
 			     &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
 
-      /* reloc */
+      /* Reloc.  */
       memset (&reloc, 0, sizeof (struct internal_reloc));
       reloc.r_vaddr = 0x0038;
       reloc.r_symndx = filehdr.f_nsyms;
       reloc.r_type = R_POS;
       reloc.r_size = 63;
-      bfd_coff_swap_reloc_out (abfd, &reloc, 
+      bfd_coff_swap_reloc_out (abfd, &reloc,
 			       &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
 
       filehdr.f_nsyms += 2;
@@ -2397,19 +2296,19 @@
 
       syment.n_sclass = C_EXT;
       syment.n_numaux = 1;
-      bfd_coff_swap_sym_out (abfd, &syment, 
+      bfd_coff_swap_sym_out (abfd, &syment,
 			     &syment_ext[filehdr.f_nsyms * SYMESZ]);
-      bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0, 
-			     syment.n_numaux, 
+      bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
+			     syment.n_numaux,
 			     &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
 
-      /* reloc */
+      /* Reloc.  */
       memset (&reloc, 0, sizeof (struct internal_reloc));
       reloc.r_vaddr = 0x0000;
       reloc.r_symndx = filehdr.f_nsyms;
       reloc.r_type = R_POS;
       reloc.r_size = 63;
-      bfd_coff_swap_reloc_out (abfd, &reloc, 
+      bfd_coff_swap_reloc_out (abfd, &reloc,
 			       &reloc_ext[data_scnhdr.s_nreloc * RELSZ]);
 
       filehdr.f_nsyms += 2;
@@ -2457,118 +2356,119 @@
 
 static unsigned long xcoff64_glink_code[10] =
 {
-  0xe9820000,   /* ld r12,0(r2) */
-  0xf8410028,   /* std r2,40(r1) */
-  0xe80c0000,   /* ld r0,0(r12) */
-  0xe84c0008,   /* ld r0,8(r12) */
-  0x7c0903a6,   /* mtctr r0 */
-  0x4e800420,   /* bctr */
-  0x00000000,   /* start of traceback table */
-  0x000ca000,   /* traceback table */
-  0x00000000,   /* traceback table */
-  0x00000018,   /* ??? */
+  0xe9820000,	/* ld r12,0(r2) */
+  0xf8410028,	/* std r2,40(r1) */
+  0xe80c0000,	/* ld r0,0(r12) */
+  0xe84c0008,	/* ld r0,8(r12) */
+  0x7c0903a6,	/* mtctr r0 */
+  0x4e800420,	/* bctr */
+  0x00000000,	/* start of traceback table */
+  0x000ca000,	/* traceback table */
+  0x00000000,	/* traceback table */
+  0x00000018,	/* ??? */
 };
 
 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
 {
-  { /* COFF backend, defined in libcoff.h */
-    _bfd_xcoff64_swap_aux_in,         /* _bfd_coff_swap_aux_in */
-    _bfd_xcoff64_swap_sym_in,         /* _bfd_coff_swap_sym_in */
-    _bfd_xcoff64_swap_lineno_in,      /* _bfd_coff_swap_lineno_in */
-    _bfd_xcoff64_swap_aux_out,        /* _bfd_swap_aux_out */
-    _bfd_xcoff64_swap_sym_out,        /* _bfd_swap_sym_out */
-    _bfd_xcoff64_swap_lineno_out,     /* _bfd_swap_lineno_out */
-    coff_swap_reloc_out,              /* _bfd_swap_reloc_out */
-    coff_swap_filehdr_out,            /* _bfd_swap_filehdr_out */
-    coff_swap_aouthdr_out,            /* _bfd_swap_aouthdr_out */
-    coff_swap_scnhdr_out,             /* _bfd_swap_scnhdr_out */
-    FILHSZ,                           /* _bfd_filhsz */
-    AOUTSZ,                           /* _bfd_aoutsz */
-    SCNHSZ,                           /* _bfd_scnhsz */
-    SYMESZ,                           /* _bfd_symesz */
-    AUXESZ,                           /* _bfd_auxesz */
-    RELSZ,                            /* _bfd_relsz */
-    LINESZ,                           /* _bfd_linesz */
-    FILNMLEN,                         /* _bfd_filnmlen */
-    true,                             /* _bfd_coff_long_filenames */
-    false,                            /* _bfd_coff_long_section_names */
-    (3),                        /* _bfd_coff_default_section_alignment_power */
-    true,                            /* _bfd_coff_force_symnames_in_strings */
-    4,                               /* _bfd_coff_debug_string_prefix_length */
-    coff_swap_filehdr_in,             /* _bfd_coff_swap_filehdr_in */
-    coff_swap_aouthdr_in,             /* _bfd_swap_aouthdr_in */
-    coff_swap_scnhdr_in,              /* _bfd_swap_scnhdr_in */
-    coff_swap_reloc_in,               /* _bfd_reloc_in */
-    coff_bad_format_hook,             /* _bfd_bad_format_hook */
-    coff_set_arch_mach_hook,          /* _bfd_set_arch_mach_hook */
-    coff_mkobject_hook,               /* _bfd_mkobject_hook */
-    styp_to_sec_flags,                /* _bfd_syp_to_sec_flags */
-    coff_set_alignment_hook,          /* _bfd_set_alignment_hook */
-    coff_slurp_symbol_table,     /* _bfd_coff_slurp_symbol_table */
-    symname_in_debug_hook,            /* _coff_symname_in_debug_hook */
-    coff_pointerize_aux_hook,         /* _bfd_coff_pointerize_aux_hook */
-    coff_print_aux,                   /* bfd_coff_print_aux */
-    dummy_reloc16_extra_cases,        /* _bfd_coff_reloc16_extra_cases */
-    dummy_reloc16_estimate,           /* _bfd_coff_reloc16_estimate */
-    NULL,                             /* bfd_coff_sym_is_global */
+  { /* COFF backend, defined in libcoff.h.  */
+    _bfd_xcoff64_swap_aux_in,		/* _bfd_coff_swap_aux_in */
+    _bfd_xcoff64_swap_sym_in,		/* _bfd_coff_swap_sym_in */
+    _bfd_xcoff64_swap_lineno_in,	/* _bfd_coff_swap_lineno_in */
+    _bfd_xcoff64_swap_aux_out,		/* _bfd_swap_aux_out */
+    _bfd_xcoff64_swap_sym_out,		/* _bfd_swap_sym_out */
+    _bfd_xcoff64_swap_lineno_out,	/* _bfd_swap_lineno_out */
+    xcoff64_swap_reloc_out,		/* _bfd_swap_reloc_out */
+    coff_swap_filehdr_out,		/* _bfd_swap_filehdr_out */
+    coff_swap_aouthdr_out,		/* _bfd_swap_aouthdr_out */
+    coff_swap_scnhdr_out,		/* _bfd_swap_scnhdr_out */
+    FILHSZ,				/* _bfd_filhsz */
+    AOUTSZ,				/* _bfd_aoutsz */
+    SCNHSZ,				/* _bfd_scnhsz */
+    SYMESZ,				/* _bfd_symesz */
+    AUXESZ,				/* _bfd_auxesz */
+    RELSZ,				/* _bfd_relsz */
+    LINESZ,				/* _bfd_linesz */
+    FILNMLEN,				/* _bfd_filnmlen */
+    true,				/* _bfd_coff_long_filenames */
+    false,				/* _bfd_coff_long_section_names */
+    (3),			/* _bfd_coff_default_section_alignment_power */
+    true,			/* _bfd_coff_force_symnames_in_strings */
+    4,				/* _bfd_coff_debug_string_prefix_length */
+    coff_swap_filehdr_in,		/* _bfd_coff_swap_filehdr_in */
+    coff_swap_aouthdr_in,		/* _bfd_swap_aouthdr_in */
+    coff_swap_scnhdr_in,		/* _bfd_swap_scnhdr_in */
+    xcoff64_swap_reloc_in,		/* _bfd_reloc_in */
+    xcoff64_bad_format_hook,		/* _bfd_bad_format_hook */
+    coff_set_arch_mach_hook,		/* _bfd_set_arch_mach_hook */
+    coff_mkobject_hook,			/* _bfd_mkobject_hook */
+    styp_to_sec_flags,			/* _bfd_syp_to_sec_flags */
+    coff_set_alignment_hook,		/* _bfd_set_alignment_hook */
+    coff_slurp_symbol_table,		/* _bfd_coff_slurp_symbol_table */
+    symname_in_debug_hook,		/* _coff_symname_in_debug_hook */
+    coff_pointerize_aux_hook,		/* _bfd_coff_pointerize_aux_hook */
+    coff_print_aux,			/* bfd_coff_print_aux */
+    dummy_reloc16_extra_cases,		/* _bfd_coff_reloc16_extra_cases */
+    dummy_reloc16_estimate,		/* _bfd_coff_reloc16_estimate */
+    NULL,				/* bfd_coff_sym_is_global */
     /* _bfd_coff_compute_section_file_positions */
     coff_compute_section_file_positions,
-    NULL ,                            /* _bfd_coff_start_final_link */
-    xcoff64_ppc_relocate_section,  /* _bfd_coff_relocate_section */
-    coff_rtype_to_howto,              /* _bfd_coff_rtype_to_howto */
-    NULL ,                            /* _bfd_coff_addust_symndx */
-    _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */
-    coff_link_output_has_begun,       /* _bfd_coff_link_output_has_begun */
-    coff_final_link_postscript        /* _bfd_coff_final_link_postscript */
+    NULL ,				/* _bfd_coff_start_final_link */
+    xcoff64_ppc_relocate_section,	/* _bfd_coff_relocate_section */
+    coff_rtype_to_howto,		/* _bfd_coff_rtype_to_howto */
+    NULL ,				/* _bfd_coff_addust_symndx */
+    _bfd_generic_link_add_one_symbol,	/* _bfd_coff_add_one_symbol */
+    coff_link_output_has_begun,		/* _bfd_coff_link_output_has_begun */
+    coff_final_link_postscript		/* _bfd_coff_final_link_postscript */
   },
 
-  0x01EF,                             /* magic number */
-  bfd_arch_powerpc,                   /* architecture */
-  bfd_mach_ppc_620,                   /* machine */
+  0x01EF,				/* magic number */
+  bfd_arch_powerpc,			/* architecture */
+  bfd_mach_ppc_620,			/* machine */
 
-  /* function pointers to xcoff specific swap routines */
-  xcoff64_swap_ldhdr_in,                /* _xcoff_swap_ldhdr_in */
-  xcoff64_swap_ldhdr_out,               /* _xcoff_swap_ldhdr_out */
-  xcoff64_swap_ldsym_in,                /* _xcoff_swap_ldsym_in */
-  xcoff64_swap_ldsym_out,               /* _xcoff_swap_ldsym_out */
-  xcoff64_swap_ldrel_in,                /* _xcoff_swap_ldrel_in */
-  xcoff64_swap_ldrel_out,               /* _xcoff_swap_ldrel_out */
+  /* Function pointers to xcoff specific swap routines.  */
+  xcoff64_swap_ldhdr_in,		/* _xcoff_swap_ldhdr_in */
+  xcoff64_swap_ldhdr_out,		/* _xcoff_swap_ldhdr_out */
+  xcoff64_swap_ldsym_in,		/* _xcoff_swap_ldsym_in */
+  xcoff64_swap_ldsym_out,		/* _xcoff_swap_ldsym_out */
+  xcoff64_swap_ldrel_in,		/* _xcoff_swap_ldrel_in */
+  xcoff64_swap_ldrel_out,		/* _xcoff_swap_ldrel_out */
 
-  /* sizes */
-  LDHDRSZ,                              /* _xcoff_ldhdrsz */
-  LDSYMSZ,                              /* _xcoff_ldsymsz */
-  LDRELSZ,                              /* _xcoff_ldrelsz */
-  24,                                   /* _xcoff_function_descriptor_size */
-  0,                                    /* _xcoff_small_aout_header_size */
-  /* versions */
-  2,                                    /* _xcoff_ldhdr_version */
+  /* Sizes.  */
+  LDHDRSZ,				/* _xcoff_ldhdrsz */
+  LDSYMSZ,				/* _xcoff_ldsymsz */
+  LDRELSZ,				/* _xcoff_ldrelsz */
+  24,					/* _xcoff_function_descriptor_size */
+  0,					/* _xcoff_small_aout_header_size */
 
-  /* xcoff vs xcoff64 putting symbol names */
-  _bfd_xcoff64_put_symbol_name,          /* _xcoff_put_symbol_name */
-  _bfd_xcoff64_put_ldsymbol_name,        /* _xcoff_put_ldsymbol_name */
+  /* Versions.  */
+  2,					/* _xcoff_ldhdr_version */
 
-  /* dynamic reloc howto */
+  /* xcoff vs xcoff64 putting symbol names.  */
+  _bfd_xcoff64_put_symbol_name,		/* _xcoff_put_symbol_name */
+  _bfd_xcoff64_put_ldsymbol_name,	/* _xcoff_put_ldsymbol_name */
+
+  /* Dynamic reloc howto.  */
   &xcoff64_dynamic_reloc,
 
   xcoff64_create_csect_from_smclas,
 
-  /* lineno and reloc count overflow */
+  /* Lineno and reloc count overflow.  */
   xcoff64_is_lineno_count_overflow,
   xcoff64_is_reloc_count_overflow,
 
   xcoff64_loader_symbol_offset,
   xcoff64_loader_reloc_offset,
 
-  /* glink */
+  /* glink.  */
   &xcoff64_glink_code[0],
-  40,           /* _xcoff_glink_size */
+  40,					/* _xcoff_glink_size */
 
-  /* rtinit */
-  88,           /* _xcoff_rtinit_size */
-  xcoff64_generate_rtinit,  /* _xcoff_generate_rtinit */
+  /* rtinit.  */
+  88,					/* _xcoff_rtinit_size */
+  xcoff64_generate_rtinit,		/* _xcoff_generate_rtinit */
 };
 
-/* The transfer vector that leads the outside world to all of the above. */
+/* The transfer vector that leads the outside world to all of the above.  */
 const bfd_target rs6000coff64_vec =
 {
   "aixcoff64-rs6000",
@@ -2586,26 +2486,26 @@
   15,				/* ar_max_namelen??? FIXMEmgo */
 
   /* data */
-  bfd_getb64,         /* bfd_getx64 */
-  bfd_getb_signed_64, /* bfd_getx_signed_64 */
-  bfd_putb64,         /* bfd_putx64 */
-  bfd_getb32,         /* bfd_getx32 */
-  bfd_getb_signed_32, /* bfd_getx_signed_32 */
-  bfd_putb32,         /* bfd_putx32 */
-  bfd_getb16,         /* bfd_getx16 */
-  bfd_getb_signed_16, /* bfd_getx_signed_16 */
-  bfd_putb16,         /* bfd_putx16 */
+  bfd_getb64,			/* bfd_getx64 */
+  bfd_getb_signed_64,		/* bfd_getx_signed_64 */
+  bfd_putb64,			/* bfd_putx64 */
+  bfd_getb32,			/* bfd_getx32 */
+  bfd_getb_signed_32,		/* bfd_getx_signed_32 */
+  bfd_putb32,			/* bfd_putx32 */
+  bfd_getb16,			/* bfd_getx16 */
+  bfd_getb_signed_16,		/* bfd_getx_signed_16 */
+  bfd_putb16,			/* bfd_putx16 */
 
   /* hdrs */
-  bfd_getb64,         /* bfd_h_getx64 */
-  bfd_getb_signed_64, /* bfd_h_getx_signed_64 */
-  bfd_putb64,         /* bfd_h_putx64 */
-  bfd_getb32,         /* bfd_h_getx32 */
-  bfd_getb_signed_32, /* bfd_h_getx_signed_32 */
-  bfd_putb32,         /* bfd_h_putx32 */
-  bfd_getb16,         /* bfd_h_getx16 */
-  bfd_getb_signed_16, /* bfd_h_getx_signed_16 */
-  bfd_putb16,         /* bfd_h_putx16 */
+  bfd_getb64,			/* bfd_h_getx64 */
+  bfd_getb_signed_64,		/* bfd_h_getx_signed_64 */
+  bfd_putb64,			/* bfd_h_putx64 */
+  bfd_getb32,			/* bfd_h_getx32 */
+  bfd_getb_signed_32,		/* bfd_h_getx_signed_32 */
+  bfd_putb32,			/* bfd_h_putx32 */
+  bfd_getb16,			/* bfd_h_getx16 */
+  bfd_getb_signed_16,		/* bfd_h_getx_signed_16 */
+  bfd_putb16,			/* bfd_h_putx16 */
 
   { /* bfd_check_format */
     _bfd_dummy_target,
@@ -2629,15 +2529,15 @@
   },
 
   /* Generic */
-  bfd_true,                          /* _close_and_cleanup */
-  bfd_true,                          /* _bfd_free_cached_info */
-  coff_new_section_hook,             /* _new_section_hook */
-  _bfd_generic_get_section_contents, /* _bfd_get_section_contents */
+  bfd_true,				/* _close_and_cleanup */
+  bfd_true,				/* _bfd_free_cached_info */
+  coff_new_section_hook,		/* _new_section_hook */
+  _bfd_generic_get_section_contents,	/* _bfd_get_section_contents */
   /* _bfd_get_section_contents_in_window */
   _bfd_generic_get_section_contents_in_window,
 
   /* Copy */
-  _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */
+  _bfd_xcoff_copy_private_bfd_data,	/* _bfd_copy_private_bfd */
   /* _bfd_merge_private_bfd_data */
   ((boolean (*) (bfd *, bfd *)) bfd_true),
   /* _bfd_copy_pivate_section_data */
@@ -2648,62 +2548,60 @@
   ((boolean (*) (bfd *, void * )) bfd_true),  /* _bfd_print_private_bfd_data */
 
   /* Core */
-  coff_core_file_failing_command,    /* _core_file_failing_command */
-  coff_core_file_failing_signal,     /* _core_file_failing_signal */
-  /* _core_file_matches_executable_p */
-  coff_core_file_matches_executable_p,
+  coff_core_file_failing_command,	/* _core_file_failing_command */
+  coff_core_file_failing_signal,	/* _core_file_failing_signal */
+  coff_core_file_matches_executable_p,	/* _core_file_matches_executable_p */
 
   /* Archive */
-  xcoff64_slurp_armap,                  /* _slurp_armap */
-  /* XCOFF archives do not have
-     anything which corresponds to
-     an extended name table.  */
-  bfd_false,                               /* _slurp_extended_name_table */
+  xcoff64_slurp_armap,			/* _slurp_armap */
+  /* XCOFF archives do not have anything which corresponds to an
+     extended name table.  */
+  bfd_false,				/* _slurp_extended_name_table */
   /* _construct_extended_name_table */
   ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
-  bfd_dont_truncate_arname,                /* _truncate_arname */
-  _bfd_xcoff_write_armap,                  /* _write_armap */
-  _bfd_xcoff_read_ar_hdr,                  /* _read_ar_hdr */
-  xcoff64_openr_next_archived_file,     /* _openr_next_archived_file */
-  _bfd_generic_get_elt_at_index,           /* _get_elt_at_index */
-  _bfd_xcoff_generic_stat_arch_elt,        /* _generic_dtat_arch_elt */
-  /* XCOFF archives do not have
-     a timestamp.  */
-  bfd_true,                                /* _update_armap_timestamp */
+  bfd_dont_truncate_arname,		/* _truncate_arname */
+  _bfd_xcoff_write_armap,		/* _write_armap */
+  _bfd_xcoff_read_ar_hdr,		/* _read_ar_hdr */
+  xcoff64_openr_next_archived_file,	/* _openr_next_archived_file */
+  _bfd_generic_get_elt_at_index,	/* _get_elt_at_index */
+  _bfd_xcoff_stat_arch_elt,		/* _generic_stat_arch_elt */
+  /* XCOFF archives do not have a timestamp.  */
+  bfd_true,				/* _update_armap_timestamp */
 
   /* Symbols */
-  coff_get_symtab_upper_bound,             /* _get_symtab_upper_bound */
-  coff_get_symtab,                         /* _get_symtab */
-  coff_make_empty_symbol,                  /* _make_empty_symbol */
-  coff_print_symbol,                       /* _print_symbol */
-  coff_get_symbol_info,                    /* _get_symbol_info */
-  _bfd_xcoff_is_local_label_name,          /* _bfd_is_local_label_name */
-  coff_get_lineno,                         /* _get_lineno */
-  coff_find_nearest_line,                  /* _find_nearest_line */
-  coff_bfd_make_debug_symbol,              /* _bfd_make_debug_symbol */
-  _bfd_generic_read_minisymbols,           /* _read_minisymbols */
-  _bfd_generic_minisymbol_to_symbol,       /* _minsymbol_to_symbol */
+  coff_get_symtab_upper_bound,		/* _get_symtab_upper_bound */
+  coff_get_symtab,			/* _get_symtab */
+  coff_make_empty_symbol,		/* _make_empty_symbol */
+  coff_print_symbol,			/* _print_symbol */
+  coff_get_symbol_info,			/* _get_symbol_info */
+  _bfd_xcoff_is_local_label_name,	/* _bfd_is_local_label_name */
+  coff_get_lineno,			/* _get_lineno */
+  coff_find_nearest_line,		/* _find_nearest_line */
+  coff_bfd_make_debug_symbol,		/* _bfd_make_debug_symbol */
+  _bfd_generic_read_minisymbols,	/* _read_minisymbols */
+  _bfd_generic_minisymbol_to_symbol,	/* _minsymbol_to_symbol */
 
   /* Reloc */
-  coff_get_reloc_upper_bound,              /* _get_reloc_upper_bound */
-  coff_canonicalize_reloc,           /* _cononicalize_reloc */
-  xcoff64_reloc_type_lookup,               /* _bfd_reloc_type_lookup */
+  coff_get_reloc_upper_bound,		/* _get_reloc_upper_bound */
+  coff_canonicalize_reloc,		/* _cononicalize_reloc */
+  xcoff64_reloc_type_lookup,		/* _bfd_reloc_type_lookup */
 
   /* Write */
-  coff_set_arch_mach,                      /* _set_arch_mach */
-  coff_set_section_contents,               /* _set_section_contents */
+  coff_set_arch_mach,			/* _set_arch_mach */
+  coff_set_section_contents,		/* _set_section_contents */
 
   /* Link */
-  xcoff64_sizeof_headers,               /* _sizeof_headers */
+  xcoff64_sizeof_headers,		/* _sizeof_headers */
   /* _bfd_get_relocated_section_contents */
   bfd_generic_get_relocated_section_contents,
-  bfd_generic_relax_section,               /* _bfd_relax_section */
-  _bfd_xcoff_bfd_link_hash_table_create,   /* _bfd_link_hash_table_create */
-  _bfd_xcoff_bfd_link_add_symbols,         /* _bfd_link_add_symbols */
-  _bfd_xcoff_bfd_final_link,               /* _bfd_filnal_link */
-  _bfd_generic_link_split_section,         /* _bfd_link_split_section */
-  bfd_generic_gc_sections,                 /* _bfd_gc_sections */
-  bfd_generic_merge_sections,               /* _bfd_merge_sections */
+  bfd_generic_relax_section,		/* _bfd_relax_section */
+  _bfd_xcoff_bfd_link_hash_table_create,/* _bfd_link_hash_table_create */
+  _bfd_generic_link_hash_table_free,    /* _bfd_link_hash_table_free */
+  _bfd_xcoff_bfd_link_add_symbols,	/* _bfd_link_add_symbols */
+  _bfd_xcoff_bfd_final_link,		/* _bfd_filnal_link */
+  _bfd_generic_link_split_section,	/* _bfd_link_split_section */
+  bfd_generic_gc_sections,		/* _bfd_gc_sections */
+  bfd_generic_merge_sections,		/* _bfd_merge_sections */
 
   /* Dynamic */
   /* _get_dynamic_symtab_upper_bound */
@@ -2718,3 +2616,255 @@
   /* back end data */
   (void *) &bfd_xcoff_backend_data,
 };
+
+extern const bfd_target *xcoff64_core_p PARAMS ((bfd *));
+extern boolean xcoff64_core_file_matches_executable_p PARAMS((bfd *, bfd *));
+extern char *xcoff64_core_file_failing_command PARAMS ((bfd *));
+extern int xcoff64_core_file_failing_signal PARAMS ((bfd *));
+
+/* AIX 5 */
+static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data =
+{
+  { /* COFF backend, defined in libcoff.h.  */
+    _bfd_xcoff64_swap_aux_in,		/* _bfd_coff_swap_aux_in */
+    _bfd_xcoff64_swap_sym_in,		/* _bfd_coff_swap_sym_in */
+    _bfd_xcoff64_swap_lineno_in,	/* _bfd_coff_swap_lineno_in */
+    _bfd_xcoff64_swap_aux_out,		/* _bfd_swap_aux_out */
+    _bfd_xcoff64_swap_sym_out,		/* _bfd_swap_sym_out */
+    _bfd_xcoff64_swap_lineno_out,	/* _bfd_swap_lineno_out */
+    xcoff64_swap_reloc_out,		/* _bfd_swap_reloc_out */
+    coff_swap_filehdr_out,		/* _bfd_swap_filehdr_out */
+    coff_swap_aouthdr_out,		/* _bfd_swap_aouthdr_out */
+    coff_swap_scnhdr_out,		/* _bfd_swap_scnhdr_out */
+    FILHSZ,				/* _bfd_filhsz */
+    AOUTSZ,				/* _bfd_aoutsz */
+    SCNHSZ,				/* _bfd_scnhsz */
+    SYMESZ,				/* _bfd_symesz */
+    AUXESZ,				/* _bfd_auxesz */
+    RELSZ,				/* _bfd_relsz */
+    LINESZ,				/* _bfd_linesz */
+    FILNMLEN,				/* _bfd_filnmlen */
+    true,				/* _bfd_coff_long_filenames */
+    false,				/* _bfd_coff_long_section_names */
+    (3),			/* _bfd_coff_default_section_alignment_power */
+    true,			/* _bfd_coff_force_symnames_in_strings */
+    4,				/* _bfd_coff_debug_string_prefix_length */
+    coff_swap_filehdr_in,		/* _bfd_coff_swap_filehdr_in */
+    coff_swap_aouthdr_in,		/* _bfd_swap_aouthdr_in */
+    coff_swap_scnhdr_in,		/* _bfd_swap_scnhdr_in */
+    xcoff64_swap_reloc_in,		/* _bfd_reloc_in */
+    xcoff64_bad_format_hook,		/* _bfd_bad_format_hook */
+    coff_set_arch_mach_hook,		/* _bfd_set_arch_mach_hook */
+    coff_mkobject_hook,			/* _bfd_mkobject_hook */
+    styp_to_sec_flags,			/* _bfd_syp_to_sec_flags */
+    coff_set_alignment_hook,		/* _bfd_set_alignment_hook */
+    coff_slurp_symbol_table,		/* _bfd_coff_slurp_symbol_table */
+    symname_in_debug_hook,		/* _coff_symname_in_debug_hook */
+    coff_pointerize_aux_hook,		/* _bfd_coff_pointerize_aux_hook */
+    coff_print_aux,			/* bfd_coff_print_aux */
+    dummy_reloc16_extra_cases,		/* _bfd_coff_reloc16_extra_cases */
+    dummy_reloc16_estimate,		/* _bfd_coff_reloc16_estimate */
+    NULL,				/* bfd_coff_sym_is_global */
+    /* _bfd_coff_compute_section_file_positions */
+    coff_compute_section_file_positions,
+    NULL ,				/* _bfd_coff_start_final_link */
+    xcoff64_ppc_relocate_section,	/* _bfd_coff_relocate_section */
+    coff_rtype_to_howto,		/* _bfd_coff_rtype_to_howto */
+    NULL ,				/* _bfd_coff_addust_symndx */
+    _bfd_generic_link_add_one_symbol,	/* _bfd_coff_add_one_symbol */
+    coff_link_output_has_begun,		/* _bfd_coff_link_output_has_begun */
+    coff_final_link_postscript		/* _bfd_coff_final_link_postscript */
+  },
+
+  U64_TOCMAGIC,				/* magic number */
+  bfd_arch_powerpc,			/* architecture */
+  bfd_mach_ppc_620,			/* machine */
+
+  /* Function pointers to xcoff specific swap routines.	 */
+  xcoff64_swap_ldhdr_in,		/* _xcoff_swap_ldhdr_in */
+  xcoff64_swap_ldhdr_out,		/* _xcoff_swap_ldhdr_out */
+  xcoff64_swap_ldsym_in,		/* _xcoff_swap_ldsym_in */
+  xcoff64_swap_ldsym_out,		/* _xcoff_swap_ldsym_out */
+  xcoff64_swap_ldrel_in,		/* _xcoff_swap_ldrel_in */
+  xcoff64_swap_ldrel_out,		/* _xcoff_swap_ldrel_out */
+
+  /* Sizes.  */
+  LDHDRSZ,				/* _xcoff_ldhdrsz */
+  LDSYMSZ,				/* _xcoff_ldsymsz */
+  LDRELSZ,				/* _xcoff_ldrelsz */
+  24,					/* _xcoff_function_descriptor_size */
+  0,					/* _xcoff_small_aout_header_size */
+  /* Versions.  */
+  2,					/* _xcoff_ldhdr_version */
+
+  _bfd_xcoff64_put_symbol_name,		/* _xcoff_put_symbol_name */
+  _bfd_xcoff64_put_ldsymbol_name,	/* _xcoff_put_ldsymbol_name */
+
+  /* Dynamic reloc howto.  */
+  &xcoff64_dynamic_reloc,
+  xcoff64_create_csect_from_smclas,
+
+  /* Lineno and reloc count overflow.  */
+  xcoff64_is_lineno_count_overflow,
+  xcoff64_is_reloc_count_overflow,
+
+  xcoff64_loader_symbol_offset,
+  xcoff64_loader_reloc_offset,
+
+  /* glink.  */
+  &xcoff64_glink_code[0],
+  40,					/* _xcoff_glink_size */
+
+  /* rtinit.  */
+  88,					/* _xcoff_rtinit_size */
+  xcoff64_generate_rtinit,		/* _xcoff_generate_rtinit */
+};
+
+/* The transfer vector that leads the outside world to all of the above.  */
+const bfd_target aix5coff64_vec =
+{
+  "aix5coff64-rs6000",
+  bfd_target_xcoff_flavour,
+  BFD_ENDIAN_BIG,		/* data byte order is big */
+  BFD_ENDIAN_BIG,		/* header byte order is big */
+
+  (HAS_RELOC | EXEC_P |		/* object flags */
+   HAS_LINENO | HAS_DEBUG | DYNAMIC |
+   HAS_SYMS | HAS_LOCALS | WP_TEXT),
+
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+  0,				/* leading char */
+  '/',				/* ar_pad_char */
+  15,				/* ar_max_namelen??? FIXMEmgo */
+
+  /* data */
+  bfd_getb64,			/* bfd_getx64 */
+  bfd_getb_signed_64,		/* bfd_getx_signed_64 */
+  bfd_putb64,			/* bfd_putx64 */
+  bfd_getb32,			/* bfd_getx32 */
+  bfd_getb_signed_32,		/* bfd_getx_signed_32 */
+  bfd_putb32,			/* bfd_putx32 */
+  bfd_getb16,			/* bfd_getx16 */
+  bfd_getb_signed_16,		/* bfd_getx_signed_16 */
+  bfd_putb16,			/* bfd_putx16 */
+
+  /* hdrs */
+  bfd_getb64,			/* bfd_h_getx64 */
+  bfd_getb_signed_64,		/* bfd_h_getx_signed_64 */
+  bfd_putb64,			/* bfd_h_putx64 */
+  bfd_getb32,			/* bfd_h_getx32 */
+  bfd_getb_signed_32,		/* bfd_h_getx_signed_32 */
+  bfd_putb32,			/* bfd_h_putx32 */
+  bfd_getb16,			/* bfd_h_getx16 */
+  bfd_getb_signed_16,		/* bfd_h_getx_signed_16 */
+  bfd_putb16,			/* bfd_h_putx16 */
+
+  { /* bfd_check_format */
+    _bfd_dummy_target,
+    coff_object_p,
+    xcoff64_archive_p,
+    xcoff64_core_p
+  },
+
+  { /* bfd_set_format */
+    bfd_false,
+    coff_mkobject,
+    _bfd_generic_mkarchive,
+    bfd_false
+  },
+
+  {/* bfd_write_contents */
+    bfd_false,
+    xcoff64_write_object_contents,
+    _bfd_xcoff_write_archive_contents,
+    bfd_false
+  },
+
+  /* Generic */
+  bfd_true,				/* _close_and_cleanup */
+  bfd_true,				/* _bfd_free_cached_info */
+  coff_new_section_hook,		/* _new_section_hook */
+  _bfd_generic_get_section_contents,	/* _bfd_get_section_contents */
+  /* _bfd_get_section_contents_in_window */
+  _bfd_generic_get_section_contents_in_window,
+
+  /* Copy */
+  _bfd_xcoff_copy_private_bfd_data,	/* _bfd_copy_private_bfd */
+  /* _bfd_merge_private_bfd_data */
+  ((boolean (*) (bfd *, bfd *)) bfd_true),
+  /* _bfd_copy_pivate_section_data */
+  ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
+  /* _bfd_copy_private_symbol_data */
+  ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
+  ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */
+  ((boolean (*) (bfd *, void * )) bfd_true),  /* _bfd_print_private_bfd_data */
+
+  /* Core */
+  xcoff64_core_file_failing_command,	/* _core_file_failing_command */
+  xcoff64_core_file_failing_signal,	/* _core_file_failing_signal */
+  xcoff64_core_file_matches_executable_p, /* _core_file_matches_executable_p */
+
+  /* Archive */
+  xcoff64_slurp_armap,			/* _slurp_armap */
+  /* XCOFF archives do not have anything which corresponds to an
+     extended name table.  */
+  bfd_false,				/* _slurp_extended_name_table */
+  /* _construct_extended_name_table */
+  ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
+  bfd_dont_truncate_arname,		/* _truncate_arname */
+  _bfd_xcoff_write_armap,		/* _write_armap */
+  _bfd_xcoff_read_ar_hdr,		/* _read_ar_hdr */
+  xcoff64_openr_next_archived_file,	/* _openr_next_archived_file */
+  _bfd_generic_get_elt_at_index,	/* _get_elt_at_index */
+  _bfd_xcoff_stat_arch_elt,		/* _generic_stat_arch_elt */
+  /* XCOFF archives do not have a timestamp.  */
+  bfd_true,				/* _update_armap_timestamp */
+
+  /* Symbols */
+  coff_get_symtab_upper_bound,		/* _get_symtab_upper_bound */
+  coff_get_symtab,			/* _get_symtab */
+  coff_make_empty_symbol,		/* _make_empty_symbol */
+  coff_print_symbol,			/* _print_symbol */
+  coff_get_symbol_info,			/* _get_symbol_info */
+  _bfd_xcoff_is_local_label_name,	/* _bfd_is_local_label_name */
+  coff_get_lineno,			/* _get_lineno */
+  coff_find_nearest_line,		/* _find_nearest_line */
+  coff_bfd_make_debug_symbol,		/* _bfd_make_debug_symbol */
+  _bfd_generic_read_minisymbols,	/* _read_minisymbols */
+  _bfd_generic_minisymbol_to_symbol,	/* _minsymbol_to_symbol */
+
+  /* Reloc */
+  coff_get_reloc_upper_bound,		/* _get_reloc_upper_bound */
+  coff_canonicalize_reloc,		/* _cononicalize_reloc */
+  xcoff64_reloc_type_lookup,		/* _bfd_reloc_type_lookup */
+
+  /* Write */
+  coff_set_arch_mach,			/* _set_arch_mach */
+  coff_set_section_contents,		/* _set_section_contents */
+
+  /* Link */
+  xcoff64_sizeof_headers,		/* _sizeof_headers */
+  /* _bfd_get_relocated_section_contents */
+  bfd_generic_get_relocated_section_contents,
+  bfd_generic_relax_section,		/* _bfd_relax_section */
+  _bfd_xcoff_bfd_link_hash_table_create,/* _bfd_link_hash_table_create */
+  _bfd_generic_link_hash_table_free,    /* _bfd_link_hash_table_free */
+  _bfd_xcoff_bfd_link_add_symbols,	/* _bfd_link_add_symbols */
+  _bfd_xcoff_bfd_final_link,		/* _bfd_filnal_link */
+  _bfd_generic_link_split_section,	/* _bfd_link_split_section */
+  bfd_generic_gc_sections,		/* _bfd_gc_sections */
+  bfd_generic_merge_sections,		/* _bfd_merge_sections */
+
+  /* Dynamic */
+  /* _get_dynamic_symtab_upper_bound */
+  _bfd_xcoff_get_dynamic_symtab_upper_bound,
+  _bfd_xcoff_canonicalize_dynamic_symtab,  /* _cononicalize_dynamic_symtab */
+  _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */
+  _bfd_xcoff_canonicalize_dynamic_reloc,   /* _cononicalize_dynamic_reloc */
+
+  /* Opposite endian version, none exists.  */
+  NULL,
+
+  /* back end data */
+  (void *) & bfd_xcoff_aix5_backend_data,
+};
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index f0a2c5e..eadb898 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -341,6 +341,11 @@
 #ifdef COFF_WITH_PE
 static flagword handle_COMDAT PARAMS ((bfd *, flagword, PTR, const char *, asection *));
 #endif
+#ifdef COFF_IMAGE_WITH_PE
+static boolean coff_read_word PARAMS ((bfd *, unsigned int *));
+static unsigned int coff_compute_checksum PARAMS ((bfd *));
+static boolean coff_apply_checksum PARAMS ((bfd *));
+#endif
 
 /* void warning(); */
 
@@ -1493,12 +1498,12 @@
   section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
 
 #ifdef RS6000COFF_C
-  if (xcoff_data (abfd)->text_align_power != 0
+  if (bfd_xcoff_text_align_power (abfd) != 0
       && strcmp (bfd_get_section_name (abfd, section), ".text") == 0)
-    section->alignment_power = xcoff_data (abfd)->text_align_power;
-  if (xcoff_data (abfd)->data_align_power != 0
+    section->alignment_power = bfd_xcoff_text_align_power (abfd);
+  if (bfd_xcoff_data_align_power (abfd) != 0
       && strcmp (bfd_get_section_name (abfd, section), ".data") == 0)
-    section->alignment_power = xcoff_data (abfd)->data_align_power;
+    section->alignment_power = bfd_xcoff_data_align_power (abfd);
 #endif
 
   /* Allocate aux records for section symbols, to store size and
@@ -1964,6 +1969,7 @@
 
 #ifdef RS6000COFF_C
 #ifdef XCOFF64
+    case U64_TOCMAGIC:
     case U803XTOCMAGIC:
 #else
     case U802ROMAGIC:
@@ -2768,14 +2774,8 @@
 #ifndef PPCMAGIC
     case bfd_arch_powerpc:
 #endif
-#ifdef XCOFF64
-      if (bfd_get_mach (abfd) == bfd_mach_ppc_620
-	  && !strncmp (abfd->xvec->name,"aix", 3))
-	*magicp = U803XTOCMAGIC;
-      else
-#else
-    	*magicp = U802TOCMAGIC;
-#endif
+      BFD_ASSERT (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
+      *magicp = bfd_xcoff_magic_number (abfd);
       return true;
       break;
 #endif
@@ -3014,6 +3014,7 @@
 	else
 	  current->target_index = target_index++;
       }
+    abfd->section_tail = &current->next;
 
     free (section_list);
   }
@@ -3275,6 +3276,100 @@
 
 #endif /* 0 */
 
+#ifdef COFF_IMAGE_WITH_PE
+
+static unsigned int pelength;
+static unsigned int peheader;
+
+static boolean
+coff_read_word (abfd, value)
+  bfd *abfd;
+  unsigned int *value;
+{
+  unsigned char b[2];
+  int status;
+
+  status = bfd_bread (b, (bfd_size_type) 2, abfd);
+  if (status < 1)
+    {
+      *value = 0;
+      return false;
+    }
+
+  if (status == 1)
+    *value = (unsigned int) b[0];
+  else
+    *value = (unsigned int) (b[0] + (b[1] << 8));
+
+  pelength += (unsigned int) status;
+
+  return true;
+}
+
+static unsigned int
+coff_compute_checksum (abfd)
+  bfd *abfd;
+{
+  boolean more_data;
+  file_ptr filepos;
+  unsigned int value;
+  unsigned int total;
+
+  total = 0;
+  pelength = 0;
+  filepos = (file_ptr) 0;
+
+  do
+    {
+      if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
+	return 0;
+
+      more_data = coff_read_word (abfd, &value);
+      total += value;
+      total = 0xffff & (total + (total >> 0x10));
+      filepos += 2;
+    }
+  while (more_data);
+
+  return (0xffff & (total + (total >> 0x10)));
+}
+
+static boolean
+coff_apply_checksum (abfd)
+  bfd *abfd;
+{
+  unsigned int computed;
+  unsigned int checksum = 0;
+
+  if (bfd_seek (abfd, 0x3c, SEEK_SET) != 0)
+    return false;
+
+  if (!coff_read_word (abfd, &peheader))
+    return false;
+
+  if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0)
+    return false;
+
+  checksum = 0;
+  bfd_bwrite (&checksum, (bfd_size_type) 4, abfd);
+
+  if (bfd_seek (abfd, peheader, SEEK_SET) != 0)
+    return false;
+
+  computed = coff_compute_checksum (abfd);
+
+  checksum = computed + pelength;
+
+  if (bfd_seek (abfd, peheader + 0x58, SEEK_SET) != 0)
+    return false;
+
+  bfd_bwrite (&checksum, (bfd_size_type) 4, abfd);
+
+  return true;
+}
+
+#endif /* COFF_IMAGE_WITH_PE */
+
 /* SUPPRESS 558 */
 /* SUPPRESS 529 */
 static boolean
@@ -4065,6 +4160,11 @@
 
       if (amount != bfd_coff_aoutsz (abfd))
 	return false;
+
+#ifdef COFF_IMAGE_WITH_PE
+      if (! coff_apply_checksum (abfd))
+	return false;
+#endif
     }
 #ifdef RS6000COFF_C
   else
@@ -4443,16 +4543,14 @@
 
 #ifdef COFF_WITH_PE
 	      if (src->u.syment.n_sclass == C_NT_WEAK)
-		dst->symbol.flags = BSF_WEAK;
+		dst->symbol.flags |= BSF_WEAK;
+
 	      if (src->u.syment.n_sclass == C_SECTION
 		  && src->u.syment.n_scnum > 0)
-		{
-		  dst->symbol.flags = BSF_LOCAL;
-		}
+		dst->symbol.flags = BSF_LOCAL;
 #endif
-
 	      if (src->u.syment.n_sclass == C_WEAKEXT)
-		dst->symbol.flags = BSF_WEAK;
+		dst->symbol.flags |= BSF_WEAK;
 
 	      break;
 
@@ -5050,6 +5148,10 @@
 }
 #endif
 
+#ifndef coff_bfd_link_hash_table_free
+#define coff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#endif
+
 /* If coff_relocate_section is defined, we can use the optimized COFF
    backend linker.  Otherwise we must continue to use the old linker.  */
 #ifdef coff_relocate_section
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 00a5289..1eac3c5 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -1,5 +1,5 @@
 /* COFF specific linker code.
-   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
@@ -119,13 +119,13 @@
   struct coff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct coff_link_hash_table);
 
-  ret = (struct coff_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct coff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
   if (! _bfd_coff_link_hash_table_init (ret, abfd,
 					_bfd_coff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
   return &ret->root;
@@ -1005,7 +1005,8 @@
   if (info->task_link)
     {
       finfo.failed = false;
-      coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_task_globals,
+      coff_link_hash_traverse (coff_hash_table (info),
+			       _bfd_coff_write_task_globals,
 			       (PTR) &finfo);
       if (finfo.failed)
 	goto error_return;
@@ -1013,7 +1014,8 @@
 
   /* Write out the global symbols.  */
   finfo.failed = false;
-  coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
+  coff_link_hash_traverse (coff_hash_table (info),
+			   _bfd_coff_write_global_sym,
 			   (PTR) &finfo);
   if (finfo.failed)
     goto error_return;
@@ -2497,6 +2499,13 @@
 
   output_bfd = finfo->output_bfd;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h = (struct coff_link_hash_entry *) h->root.u.i.link;
+      if (h->root.type == bfd_link_hash_new)
+	return true;
+    }
+
   if (h->indx >= 0)
     return true;
 
@@ -2512,6 +2521,7 @@
     {
     default:
     case bfd_link_hash_new:
+    case bfd_link_hash_warning:
       abort ();
       return false;
 
@@ -2544,7 +2554,6 @@
       break;
 
     case bfd_link_hash_indirect:
-    case bfd_link_hash_warning:
       /* Just ignore these.  They can't be handled anyhow.  */
       return true;
     }
@@ -2699,6 +2708,9 @@
   boolean rtnval = true;
   boolean save_global_to_static;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct coff_link_hash_entry *) h->root.u.i.link;
+
   if (h->indx < 0)
     {
       switch (h->root.type)
diff --git a/bfd/coffswap.h b/bfd/coffswap.h
index 454e686..cd147c5 100644
--- a/bfd/coffswap.h
+++ b/bfd/coffswap.h
@@ -244,13 +244,7 @@
 
   reloc_dst->r_vaddr = GET_RELOC_VADDR (abfd, reloc_src->r_vaddr);
   reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
-
-#ifdef RS6000COFF_C
-  reloc_dst->r_type = H_GET_8 (abfd, reloc_src->r_type);
-  reloc_dst->r_size = H_GET_8 (abfd, reloc_src->r_size);
-#else
   reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
-#endif
 
 #ifdef SWAP_IN_RELOC_OFFSET
   reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset);
@@ -267,13 +261,7 @@
   struct external_reloc *reloc_dst = (struct external_reloc *) dst;
   PUT_RELOC_VADDR (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
   H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
-
-#ifdef RS6000COFF_C
-  H_PUT_8 (abfd, reloc_src->r_type, reloc_dst->r_type);
-  H_PUT_8 (abfd, reloc_src->r_size, reloc_dst->r_size);
-#else
   H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
-#endif
 
 #ifdef SWAP_OUT_RELOC_OFFSET
   SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 58c7315..4cc1242 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -785,11 +785,22 @@
     targ_selvecs="bfd_elf32_pjl_vec bfd_elf32_pj_vec bfd_elf32_i386_vec"
     ;;
 
+  powerpc-*-aix5*)
+    targ_defvec=rs6000coff_vec
+    targ_selvecs="aix5coff64_vec"
+    want64=true
+    ;;
+  powerpc64-*-aix5*)
+    targ_defvec=aix5coff64_vec
+    targ_selvecs="rs6000coff_vec"
+    want64=true
+    ;;
+
   powerpc-*-aix* | powerpc-*-beos* | rs6000-*-*)
     targ_defvec=rs6000coff_vec
     targ64_selvecs=rs6000coff64_vec
     case "${targ}" in
-      *-*-aix4.[3456789]* | *-*-aix[56789]*)
+        *-*-aix4.[3456789]* | *-*-aix[56789]*)
 	want64=true;;
 	
 	*)
@@ -812,7 +823,7 @@
 #endif
   powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
   powerpc-*-solaris2* | powerpc-*-linux-gnu* | powerpc-*-rtems* | \
-  powerpc-*-chorus* | powerpc-*-vxworks*)
+  powerpc-*-chorus* | powerpc-*-vxworks* | powerpc-*-windiss*)
     targ_defvec=bfd_elf32_powerpc_vec
     targ_selvecs="rs6000coff_vec bfd_elf32_powerpcle_vec ppcboot_vec"
     targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec"
diff --git a/bfd/configure b/bfd/configure
index 022565d..47f3348 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -57,6 +57,7 @@
 program_transform_name=s,x,x,
 silent=
 site=
+sitefile=
 srcdir=
 target=NONE
 verbose=
@@ -171,6 +172,7 @@
   --help                  print this message
   --no-create             do not create output files
   --quiet, --silent       do not print \`checking...' messages
+  --site-file=FILE        use FILE as the site file
   --version               print the version of autoconf that created configure
 Directory and file names:
   --prefix=PREFIX         install architecture-independent files in PREFIX
@@ -341,6 +343,11 @@
   -site=* | --site=* | --sit=*)
     site="$ac_optarg" ;;
 
+  -site-file | --site-file | --site-fil | --site-fi | --site-f)
+    ac_prev=sitefile ;;
+  -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
+    sitefile="$ac_optarg" ;;
+
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
@@ -506,12 +513,16 @@
 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
 
 # Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+if test -z "$sitefile"; then
+  if test -z "$CONFIG_SITE"; then
+    if test "x$prefix" != xNONE; then
+      CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+    else
+      CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+    fi
   fi
+else
+  CONFIG_SITE="$sitefile"
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
@@ -550,12 +561,12 @@
 fi
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:554: checking for Cygwin environment" >&5
+echo "configure:565: checking for Cygwin environment" >&5
 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 559 "configure"
+#line 570 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -566,7 +577,7 @@
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:570: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -583,19 +594,19 @@
 CYGWIN=
 test "$ac_cv_cygwin" = yes && CYGWIN=yes
 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
-echo "configure:587: checking for mingw32 environment" >&5
+echo "configure:598: checking for mingw32 environment" >&5
 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 592 "configure"
+#line 603 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:599: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:610: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -660,7 +671,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:664: checking host system type" >&5
+echo "configure:675: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -681,7 +692,7 @@
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:685: checking target system type" >&5
+echo "configure:696: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -699,7 +710,7 @@
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:703: checking build system type" >&5
+echo "configure:714: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -724,7 +735,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:728: checking for $ac_word" >&5
+echo "configure:739: 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
@@ -754,7 +765,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:758: checking for $ac_word" >&5
+echo "configure:769: 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
@@ -805,7 +816,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:809: checking for $ac_word" >&5
+echo "configure:820: 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
@@ -837,7 +848,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:841: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:852: 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.
@@ -848,12 +859,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 852 "configure"
+#line 863 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; 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
@@ -879,12 +890,12 @@
   { 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:883: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:894: 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:888: checking whether we are using GNU C" >&5
+echo "configure:899: 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
@@ -893,7 +904,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:897: \"$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:908: \"$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
@@ -912,7 +923,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:916: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:927: 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
@@ -944,7 +955,7 @@
 fi
 
 echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:948: checking for POSIXized ISC" >&5
+echo "configure:959: 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
@@ -977,7 +988,7 @@
 # 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:981: checking for a BSD compatible install" >&5
+echo "configure:992: 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
@@ -1030,7 +1041,7 @@
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:1034: checking whether build environment is sane" >&5
+echo "configure:1045: checking whether build environment is sane" >&5
 # Just in case
 sleep 1
 echo timestamp > conftestfile
@@ -1087,7 +1098,7 @@
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1091: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1102: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1133,7 +1144,7 @@
 
 missing_dir=`cd $ac_aux_dir && pwd`
 echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
-echo "configure:1137: checking for working aclocal" >&5
+echo "configure:1148: checking for working aclocal" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1146,7 +1157,7 @@
 fi
 
 echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
-echo "configure:1150: checking for working autoconf" >&5
+echo "configure:1161: checking for working autoconf" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1159,7 +1170,7 @@
 fi
 
 echo $ac_n "checking for working automake""... $ac_c" 1>&6
-echo "configure:1163: checking for working automake" >&5
+echo "configure:1174: checking for working automake" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1172,7 +1183,7 @@
 fi
 
 echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
-echo "configure:1176: checking for working autoheader" >&5
+echo "configure:1187: checking for working autoheader" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1185,7 +1196,7 @@
 fi
 
 echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
-echo "configure:1189: checking for working makeinfo" >&5
+echo "configure:1200: checking for working makeinfo" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -1221,7 +1232,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:1225: checking for $ac_word" >&5
+echo "configure:1236: 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
@@ -1253,7 +1264,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:1257: checking for $ac_word" >&5
+echo "configure:1268: 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
@@ -1285,7 +1296,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:1289: checking for $ac_word" >&5
+echo "configure:1300: 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
@@ -1400,7 +1411,7 @@
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
   echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
-echo "configure:1404: checking for ld used by GCC" >&5
+echo "configure:1415: checking for ld used by GCC" >&5
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -1430,10 +1441,10 @@
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:1434: checking for GNU ld" >&5
+echo "configure:1445: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:1437: checking for non-GNU ld" >&5
+echo "configure:1448: checking for non-GNU ld" >&5
 fi
 if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1468,7 +1479,7 @@
 fi
 test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
 echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:1472: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:1483: checking if the linker ($LD) is GNU ld" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1485,7 +1496,7 @@
 
 
 echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6
-echo "configure:1489: checking for $LD option to reload object files" >&5
+echo "configure:1500: checking for $LD option to reload object files" >&5
 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1497,7 +1508,7 @@
 test -n "$reload_flag" && reload_flag=" $reload_flag"
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:1501: checking for BSD-compatible nm" >&5
+echo "configure:1512: checking for BSD-compatible nm" >&5
 if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1535,7 +1546,7 @@
 echo "$ac_t""$NM" 1>&6
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:1539: checking whether ln -s works" >&5
+echo "configure:1550: checking whether ln -s works" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1556,7 +1567,7 @@
 fi
 
 echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6
-echo "configure:1560: checking how to recognise dependant libraries" >&5
+echo "configure:1571: checking how to recognise dependant libraries" >&5
 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1729,13 +1740,13 @@
 deplibs_check_method=$lt_cv_deplibs_check_method
 
 echo $ac_n "checking for object suffix""... $ac_c" 1>&6
-echo "configure:1733: checking for object suffix" >&5
+echo "configure:1744: checking for object suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   rm -f conftest*
 echo 'int i = 1;' > conftest.$ac_ext
-if { (eval echo configure:1739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1750: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   for ac_file in conftest.*; do
     case $ac_file in
     *.c) ;;
@@ -1755,7 +1766,7 @@
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:1759: checking for executable suffix" >&5
+echo "configure:1770: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1765,10 +1776,10 @@
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:1769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:1780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
-      *.c | *.o | *.obj) ;;
+      *.c | *.o | *.obj | *.ilk | *.pdb) ;;
       *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
       esac
     done
@@ -1792,7 +1803,7 @@
 file_magic*)
   if test "$file_magic_cmd" = '$MAGIC_CMD'; then
     echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
-echo "configure:1796: checking for ${ac_tool_prefix}file" >&5
+echo "configure:1807: checking for ${ac_tool_prefix}file" >&5
 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1854,7 +1865,7 @@
 if test -z "$lt_cv_path_MAGIC_CMD"; then
   if test -n "$ac_tool_prefix"; then
     echo $ac_n "checking for file""... $ac_c" 1>&6
-echo "configure:1858: checking for file" >&5
+echo "configure:1869: checking for file" >&5
 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1925,7 +1936,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:1929: checking for $ac_word" >&5
+echo "configure:1940: 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
@@ -1957,7 +1968,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:1961: checking for $ac_word" >&5
+echo "configure:1972: 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
@@ -1992,7 +2003,7 @@
 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1996: checking for $ac_word" >&5
+echo "configure:2007: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2024,7 +2035,7 @@
   # Extract the first word of "strip", so it can be a program name with args.
 set dummy strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2028: checking for $ac_word" >&5
+echo "configure:2039: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2091,8 +2102,8 @@
 case $host in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 2095 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 2106 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:2107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case `/usr/bin/file conftest.$ac_objext` in
     *32-bit*)
       LD="${LD-ld} -32"
@@ -2111,7 +2122,7 @@
 ia64-*-hpux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:2115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:2126: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case "`/usr/bin/file conftest.o`" in
     *ELF-32*)
       HPUX_IA64_MODE="32"
@@ -2129,7 +2140,7 @@
   SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS -belf"
   echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:2133: checking whether the C compiler needs -belf" >&5
+echo "configure:2144: checking whether the C compiler needs -belf" >&5
 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2142,14 +2153,14 @@
 cross_compiling=$ac_cv_prog_cc_cross
 
      cat > conftest.$ac_ext <<EOF
-#line 2146 "configure"
+#line 2157 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_cc_needs_belf=yes
 else
@@ -2339,7 +2350,7 @@
 fi
 
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:2343: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:2354: checking whether to enable maintainer-specific portions of Makefiles" >&5
     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
@@ -2364,7 +2375,7 @@
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:2368: checking for executable suffix" >&5
+echo "configure:2379: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2374,10 +2385,10 @@
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:2378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:2389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
-      *.c | *.o | *.obj) ;;
+      *.c | *.o | *.obj | *.ilk | *.pdb) ;;
       *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
       esac
     done
@@ -2404,7 +2415,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:2408: checking for $ac_word" >&5
+echo "configure:2419: 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
@@ -2434,7 +2445,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:2438: checking for $ac_word" >&5
+echo "configure:2449: 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
@@ -2485,7 +2496,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2489: checking for $ac_word" >&5
+echo "configure:2500: 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
@@ -2517,7 +2528,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2521: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2532: 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.
@@ -2528,12 +2539,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 2532 "configure"
+#line 2543 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; 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
@@ -2559,12 +2570,12 @@
   { 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:2563: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2574: 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:2568: checking whether we are using GNU C" >&5
+echo "configure:2579: 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
@@ -2573,7 +2584,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2577: \"$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:2588: \"$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
@@ -2592,7 +2603,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:2596: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2607: 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
@@ -2626,7 +2637,7 @@
 
 ALL_LINGUAS="fr tr ja es sv"
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2630: checking how to run the C preprocessor" >&5
+echo "configure:2641: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2641,13 +2652,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 2645 "configure"
+#line 2656 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2658,13 +2669,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2662 "configure"
+#line 2673 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2668: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2679: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2675,13 +2686,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2679 "configure"
+#line 2690 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2685: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2696: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2708,7 +2719,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:2712: checking for $ac_word" >&5
+echo "configure:2723: 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
@@ -2736,12 +2747,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2740: checking for ANSI C header files" >&5
+echo "configure:2751: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2745 "configure"
+#line 2756 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2749,7 +2760,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2753: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2764: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2766,7 +2777,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2770 "configure"
+#line 2781 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2784,7 +2795,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2788 "configure"
+#line 2799 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2805,7 +2816,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 2809 "configure"
+#line 2820 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2816,7 +2827,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -2840,12 +2851,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2844: checking for working const" >&5
+echo "configure:2855: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2849 "configure"
+#line 2860 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2894,7 +2905,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2898: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2909: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -2915,21 +2926,21 @@
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:2919: checking for inline" >&5
+echo "configure:2930: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 2926 "configure"
+#line 2937 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:2933: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2944: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -2955,12 +2966,12 @@
 esac
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:2959: checking for off_t" >&5
+echo "configure:2970: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2964 "configure"
+#line 2975 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2988,12 +2999,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2992: checking for size_t" >&5
+echo "configure:3003: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2997 "configure"
+#line 3008 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3023,19 +3034,19 @@
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:3027: checking for working alloca.h" >&5
+echo "configure:3038: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3032 "configure"
+#line 3043 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:3039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -3056,12 +3067,12 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:3060: checking for alloca" >&5
+echo "configure:3071: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3065 "configure"
+#line 3076 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -3089,7 +3100,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:3093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -3121,12 +3132,12 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:3125: checking whether alloca needs Cray hooks" >&5
+echo "configure:3136: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3130 "configure"
+#line 3141 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -3151,12 +3162,12 @@
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3155: checking for $ac_func" >&5
+echo "configure:3166: 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 <<EOF
-#line 3160 "configure"
+#line 3171 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3179,7 +3190,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3206,7 +3217,7 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:3210: checking stack direction for C alloca" >&5
+echo "configure:3221: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3214,7 +3225,7 @@
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 3218 "configure"
+#line 3229 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -3233,7 +3244,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:3237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -3254,21 +3265,21 @@
 
 fi
 
-for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
+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:3262: checking for $ac_hdr" >&5
+echo "configure:3273: 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
-#line 3267 "configure"
+#line 3278 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3297,12 +3308,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3301: checking for $ac_func" >&5
+echo "configure:3312: 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 <<EOF
-#line 3306 "configure"
+#line 3317 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3325,7 +3336,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3350,7 +3361,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:3354: checking for working mmap" >&5
+echo "configure:3365: 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
@@ -3358,7 +3369,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 3362 "configure"
+#line 3373 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -3386,24 +3397,11 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
 
 /* Assume that all systems that can run configure have sys/param.h.  */
 # ifndef HAVE_SYS_PARAM_H
@@ -3511,7 +3509,7 @@
 }
 
 EOF
-if { (eval echo configure:3515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -3539,17 +3537,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3543: checking for $ac_hdr" >&5
+echo "configure:3541: 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
-#line 3548 "configure"
+#line 3546 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3553: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3579,12 +3577,12 @@
 __argz_count __argz_stringify __argz_next
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3583: checking for $ac_func" >&5
+echo "configure:3581: 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 <<EOF
-#line 3588 "configure"
+#line 3586 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3607,7 +3605,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3611: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3636,12 +3634,12 @@
      for ac_func in stpcpy
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3640: checking for $ac_func" >&5
+echo "configure:3638: 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 <<EOF
-#line 3645 "configure"
+#line 3643 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3664,7 +3662,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3698,19 +3696,19 @@
 
    if test $ac_cv_header_locale_h = yes; then
     echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
-echo "configure:3702: checking for LC_MESSAGES" >&5
+echo "configure:3700: checking for LC_MESSAGES" >&5
 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3707 "configure"
+#line 3705 "configure"
 #include "confdefs.h"
 #include <locale.h>
 int main() {
 return LC_MESSAGES
 ; return 0; }
 EOF
-if { (eval echo configure:3714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   am_cv_val_LC_MESSAGES=yes
 else
@@ -3731,7 +3729,7 @@
     fi
   fi
    echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6
-echo "configure:3735: checking whether NLS is requested" >&5
+echo "configure:3733: checking whether NLS is requested" >&5
         # Check whether --enable-nls or --disable-nls was given.
 if test "${enable_nls+set}" = set; then
   enableval="$enable_nls"
@@ -3751,7 +3749,7 @@
 EOF
 
       echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6
-echo "configure:3755: checking whether included gettext is requested" >&5
+echo "configure:3753: checking whether included gettext is requested" >&5
       # Check whether --with-included-gettext or --without-included-gettext was given.
 if test "${with_included_gettext+set}" = set; then
   withval="$with_included_gettext"
@@ -3770,17 +3768,17 @@
 
 	ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for libintl.h""... $ac_c" 1>&6
-echo "configure:3774: checking for libintl.h" >&5
+echo "configure:3772: checking for libintl.h" >&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
-#line 3779 "configure"
+#line 3777 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3782: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3797,19 +3795,19 @@
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6
-echo "configure:3801: checking for gettext in libc" >&5
+echo "configure:3799: checking for gettext in libc" >&5
 if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3806 "configure"
+#line 3804 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 int main() {
 return (int) gettext ("")
 ; return 0; }
 EOF
-if { (eval echo configure:3813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   gt_cv_func_gettext_libc=yes
 else
@@ -3825,7 +3823,7 @@
 
 	   if test "$gt_cv_func_gettext_libc" != "yes"; then
 	     echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
-echo "configure:3829: checking for bindtextdomain in -lintl" >&5
+echo "configure:3827: checking for bindtextdomain in -lintl" >&5
 ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3833,7 +3831,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lintl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3837 "configure"
+#line 3835 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3844,7 +3842,7 @@
 bindtextdomain()
 ; return 0; }
 EOF
-if { (eval echo configure:3848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3846: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3860,19 +3858,19 @@
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
-echo "configure:3864: checking for gettext in libintl" >&5
+echo "configure:3862: checking for gettext in libintl" >&5
 if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3869 "configure"
+#line 3867 "configure"
 #include "confdefs.h"
 
 int main() {
 return (int) gettext ("")
 ; return 0; }
 EOF
-if { (eval echo configure:3876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   gt_cv_func_gettext_libintl=yes
 else
@@ -3900,7 +3898,7 @@
 	      # Extract the first word of "msgfmt", so it can be a program name with args.
 set dummy msgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3904: checking for $ac_word" >&5
+echo "configure:3902: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3934,12 +3932,12 @@
 		for ac_func in dcgettext
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3938: checking for $ac_func" >&5
+echo "configure:3936: 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 <<EOF
-#line 3943 "configure"
+#line 3941 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3962,7 +3960,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3966: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3989,7 +3987,7 @@
 		# Extract the first word of "gmsgfmt", so it can be a program name with args.
 set dummy gmsgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3993: checking for $ac_word" >&5
+echo "configure:3991: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4025,7 +4023,7 @@
 		# Extract the first word of "xgettext", so it can be a program name with args.
 set dummy xgettext; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4029: checking for $ac_word" >&5
+echo "configure:4027: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4057,7 +4055,7 @@
 fi
 
 		cat > conftest.$ac_ext <<EOF
-#line 4061 "configure"
+#line 4059 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -4065,7 +4063,7 @@
 			       return _nl_msg_cat_cntr
 ; return 0; }
 EOF
-if { (eval echo configure:4069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   CATOBJEXT=.gmo
 		   DATADIRNAME=share
@@ -4097,7 +4095,7 @@
         # Extract the first word of "msgfmt", so it can be a program name with args.
 set dummy msgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4101: checking for $ac_word" >&5
+echo "configure:4099: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4131,7 +4129,7 @@
         # Extract the first word of "gmsgfmt", so it can be a program name with args.
 set dummy gmsgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4135: checking for $ac_word" >&5
+echo "configure:4133: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4167,7 +4165,7 @@
         # Extract the first word of "xgettext", so it can be a program name with args.
 set dummy xgettext; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4171: checking for $ac_word" >&5
+echo "configure:4169: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4257,7 +4255,7 @@
        LINGUAS=
      else
        echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
-echo "configure:4261: checking for catalogs to be installed" >&5
+echo "configure:4259: checking for catalogs to be installed" >&5
        NEW_LINGUAS=
        for lang in ${LINGUAS=$ALL_LINGUAS}; do
          case "$ALL_LINGUAS" in
@@ -4285,17 +4283,17 @@
       if test "$CATOBJEXT" = ".cat"; then
 	 ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
-echo "configure:4289: checking for linux/version.h" >&5
+echo "configure:4287: checking for linux/version.h" >&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
-#line 4294 "configure"
+#line 4292 "configure"
 #include "confdefs.h"
 #include <linux/version.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4299: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4373,7 +4371,7 @@
 # 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:4377: checking for a BSD compatible install" >&5
+echo "configure:4375: 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
@@ -4456,7 +4454,7 @@
   EXEEXT_FOR_BUILD='$(EXEEXT)'
 else
   echo $ac_n "checking for build system executable suffix""... $ac_c" 1>&6
-echo "configure:4460: checking for build system executable suffix" >&5
+echo "configure:4458: checking for build system executable suffix" >&5
 if eval "test \"`echo '$''{'bfd_cv_build_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4484,17 +4482,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4488: checking for $ac_hdr" >&5
+echo "configure:4486: 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
-#line 4493 "configure"
+#line 4491 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4496: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4524,17 +4522,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4528: checking for $ac_hdr" >&5
+echo "configure:4526: 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
-#line 4533 "configure"
+#line 4531 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4538: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4536: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4561,12 +4559,12 @@
 done
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:4565: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:4563: 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 <<EOF
-#line 4570 "configure"
+#line 4568 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -4575,7 +4573,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:4579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4577: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -4600,12 +4598,12 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:4604: checking for $ac_hdr that defines DIR" >&5
+echo "configure:4602: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4609 "configure"
+#line 4607 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -4613,7 +4611,7 @@
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:4617: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -4638,7 +4636,7 @@
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:4642: checking for opendir in -ldir" >&5
+echo "configure:4640: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4646,7 +4644,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4650 "configure"
+#line 4648 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4657,7 +4655,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:4661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4679,7 +4677,7 @@
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:4683: checking for opendir in -lx" >&5
+echo "configure:4681: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4687,7 +4685,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4691 "configure"
+#line 4689 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4698,7 +4696,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:4702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4723,12 +4721,12 @@
 for ac_func in fcntl getpagesize setitimer sysconf fdopen getuid getgid
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4727: checking for $ac_func" >&5
+echo "configure:4725: 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 <<EOF
-#line 4732 "configure"
+#line 4730 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4751,7 +4749,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4786,12 +4784,12 @@
 esac
 
 echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6
-echo "configure:4790: checking whether strstr must be declared" >&5
+echo "configure:4788: 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 <<EOF
-#line 4795 "configure"
+#line 4793 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4812,7 +4810,7 @@
 char *(*pfn) = (char *(*)) strstr
 ; return 0; }
 EOF
-if { (eval echo configure:4816: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4814: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_strstr=no
 else
@@ -4833,12 +4831,12 @@
 fi
 
 echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6
-echo "configure:4837: checking whether malloc must be declared" >&5
+echo "configure:4835: 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 <<EOF
-#line 4842 "configure"
+#line 4840 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4859,7 +4857,7 @@
 char *(*pfn) = (char *(*)) malloc
 ; return 0; }
 EOF
-if { (eval echo configure:4863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4861: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_malloc=no
 else
@@ -4880,12 +4878,12 @@
 fi
 
 echo $ac_n "checking whether realloc must be declared""... $ac_c" 1>&6
-echo "configure:4884: checking whether realloc must be declared" >&5
+echo "configure:4882: 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 <<EOF
-#line 4889 "configure"
+#line 4887 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4906,7 +4904,7 @@
 char *(*pfn) = (char *(*)) realloc
 ; return 0; }
 EOF
-if { (eval echo configure:4910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_realloc=no
 else
@@ -4927,12 +4925,12 @@
 fi
 
 echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6
-echo "configure:4931: checking whether free must be declared" >&5
+echo "configure:4929: 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 <<EOF
-#line 4936 "configure"
+#line 4934 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4953,7 +4951,7 @@
 char *(*pfn) = (char *(*)) free
 ; return 0; }
 EOF
-if { (eval echo configure:4957: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4955: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_free=no
 else
@@ -4974,12 +4972,12 @@
 fi
 
 echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6
-echo "configure:4978: checking whether getenv must be declared" >&5
+echo "configure:4976: 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 <<EOF
-#line 4983 "configure"
+#line 4981 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -5000,7 +4998,7 @@
 char *(*pfn) = (char *(*)) getenv
 ; return 0; }
 EOF
-if { (eval echo configure:5004: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5002: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_getenv=no
 else
@@ -5156,8 +5154,11 @@
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/m68kaux.h"'
 	;;
-  m88*-*-sysv4*)	;;
-  m88*-motorola-sysv*)	COREFILE=ptrace-core.lo ;;
+  m88*-*-sysv4*)
+	;;
+  m88*-motorola-sysv*)
+	COREFILE=ptrace-core.lo
+	;;
   m88*-*-mach3*)
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/m88kmach3.h"'
@@ -5169,8 +5170,15 @@
   ns32k-*-netbsd* | ns32k-*-openbsd*)
 	COREFILE=netbsd-core.lo
 	;;
-  rs6000-*-lynx*)	COREFILE=lynx-core.lo ;;
-  rs6000-*-aix4.[3-9]* | powerpc-*-aix4.[3-9]*)
+  rs6000-*-lynx*)
+  	COREFILE=lynx-core.lo
+	;;
+  rs6000-*-aix5.* | powerpc-*-aix5.*)
+        COREFILE=rs6000-core.lo
+	COREFLAG="$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE"
+	;;
+  rs6000-*-aix4.[4-9]* | powerpc-*-aix4.[4-9]* | \
+  rs6000-*-aix4.3.[3-9]* | powerpc-*-aix4.3.[3-9]*)
         COREFILE=rs6000-core.lo
 	COREFLAG="$COREFLAG -DAIX_CORE_DUMPX_CORE"
 	;;
@@ -5226,17 +5234,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5230: checking for $ac_hdr" >&5
+echo "configure:5238: 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
-#line 5235 "configure"
+#line 5243 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5264,12 +5272,12 @@
 
   if test "$ac_cv_header_sys_procfs_h" = yes; then
     echo $ac_n "checking for prstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5268: checking for prstatus_t in sys/procfs.h" >&5
+echo "configure:5276: checking for prstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5273 "configure"
+#line 5281 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5278,7 +5286,7 @@
 prstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5282: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5290: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prstatus_t=yes
 else
@@ -5300,12 +5308,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prstatus_t" 1>&6
 
     echo $ac_n "checking for prstatus32_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5304: checking for prstatus32_t in sys/procfs.h" >&5
+echo "configure:5312: checking for prstatus32_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prstatus32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5309 "configure"
+#line 5317 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5314,7 +5322,7 @@
 prstatus32_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5326: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prstatus32_t=yes
 else
@@ -5336,12 +5344,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prstatus32_t" 1>&6
 
     echo $ac_n "checking for prstatus_t.pr_who in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5340: checking for prstatus_t.pr_who in sys/procfs.h" >&5
+echo "configure:5348: checking for prstatus_t.pr_who in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5345 "configure"
+#line 5353 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5350,7 +5358,7 @@
 prstatus_t avar; void* aref = (void*) &avar.pr_who
 ; return 0; }
 EOF
-if { (eval echo configure:5354: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5362: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who=yes
 else
@@ -5372,12 +5380,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_prstatus_t_pr_who" 1>&6
 
     echo $ac_n "checking for prstatus32_t.pr_who in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5376: checking for prstatus32_t.pr_who in sys/procfs.h" >&5
+echo "configure:5384: checking for prstatus32_t.pr_who in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_prstatus32_t_pr_who'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5381 "configure"
+#line 5389 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5386,7 +5394,7 @@
 prstatus32_t avar; void* aref = (void*) &avar.pr_who
 ; return 0; }
 EOF
-if { (eval echo configure:5390: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5398: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_member_prstatus32_t_pr_who=yes
 else
@@ -5408,12 +5416,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_prstatus32_t_pr_who" 1>&6
 
     echo $ac_n "checking for pstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5412: checking for pstatus_t in sys/procfs.h" >&5
+echo "configure:5420: checking for pstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5417 "configure"
+#line 5425 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5422,7 +5430,7 @@
 pstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5434: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pstatus_t=yes
 else
@@ -5444,12 +5452,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_pstatus_t" 1>&6
 
     echo $ac_n "checking for pxstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5448: checking for pxstatus_t in sys/procfs.h" >&5
+echo "configure:5456: checking for pxstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pxstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5453 "configure"
+#line 5461 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5458,7 +5466,7 @@
 pxstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5462: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5470: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pxstatus_t=yes
 else
@@ -5480,12 +5488,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_pxstatus_t" 1>&6
 
     echo $ac_n "checking for pstatus32_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5484: checking for pstatus32_t in sys/procfs.h" >&5
+echo "configure:5492: checking for pstatus32_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pstatus32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5489 "configure"
+#line 5497 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5494,7 +5502,7 @@
 pstatus32_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5498: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pstatus32_t=yes
 else
@@ -5516,12 +5524,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_pstatus32_t" 1>&6
 
     echo $ac_n "checking for prpsinfo_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5520: checking for prpsinfo_t in sys/procfs.h" >&5
+echo "configure:5528: checking for prpsinfo_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prpsinfo_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5525 "configure"
+#line 5533 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5530,7 +5538,7 @@
 prpsinfo_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5542: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prpsinfo_t=yes
 else
@@ -5552,12 +5560,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prpsinfo_t" 1>&6
 
     echo $ac_n "checking for prpsinfo32_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5556: checking for prpsinfo32_t in sys/procfs.h" >&5
+echo "configure:5564: checking for prpsinfo32_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prpsinfo32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5561 "configure"
+#line 5569 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5566,7 +5574,7 @@
 prpsinfo32_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5570: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prpsinfo32_t=yes
 else
@@ -5588,12 +5596,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prpsinfo32_t" 1>&6
 
     echo $ac_n "checking for psinfo_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5592: checking for psinfo_t in sys/procfs.h" >&5
+echo "configure:5600: checking for psinfo_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psinfo_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5597 "configure"
+#line 5605 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5602,7 +5610,7 @@
 psinfo_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5606: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5614: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_psinfo_t=yes
 else
@@ -5624,12 +5632,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_psinfo_t" 1>&6
 
     echo $ac_n "checking for psinfo32_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5628: checking for psinfo32_t in sys/procfs.h" >&5
+echo "configure:5636: checking for psinfo32_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psinfo32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5633 "configure"
+#line 5641 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5638,7 +5646,7 @@
 psinfo32_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5642: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5650: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_psinfo32_t=yes
 else
@@ -5660,12 +5668,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_psinfo32_t" 1>&6
 
     echo $ac_n "checking for lwpstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5664: checking for lwpstatus_t in sys/procfs.h" >&5
+echo "configure:5672: checking for lwpstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5669 "configure"
+#line 5677 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5674,7 +5682,7 @@
 lwpstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5678: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_lwpstatus_t=yes
 else
@@ -5696,12 +5704,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpstatus_t" 1>&6
 
     echo $ac_n "checking for lwpxstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5700: checking for lwpxstatus_t in sys/procfs.h" >&5
+echo "configure:5708: checking for lwpxstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpxstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5705 "configure"
+#line 5713 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5710,7 +5718,7 @@
 lwpxstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5714: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_lwpxstatus_t=yes
 else
@@ -5732,12 +5740,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpxstatus_t" 1>&6
 
     echo $ac_n "checking for lwpstatus_t.pr_context in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5736: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5
+echo "configure:5744: checking for lwpstatus_t.pr_context in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5741 "configure"
+#line 5749 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5746,7 +5754,7 @@
 lwpstatus_t avar; void* aref = (void*) &avar.pr_context
 ; return 0; }
 EOF
-if { (eval echo configure:5750: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5758: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context=yes
 else
@@ -5768,12 +5776,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_context" 1>&6
 
     echo $ac_n "checking for lwpstatus_t.pr_reg in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5772: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5
+echo "configure:5780: checking for lwpstatus_t.pr_reg in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5777 "configure"
+#line 5785 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5782,7 +5790,7 @@
 lwpstatus_t avar; void* aref = (void*) &avar.pr_reg
 ; return 0; }
 EOF
-if { (eval echo configure:5786: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5794: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg=yes
 else
@@ -5804,12 +5812,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_member_lwpstatus_t_pr_reg" 1>&6
 
     echo $ac_n "checking for win32_pstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5808: checking for win32_pstatus_t in sys/procfs.h" >&5
+echo "configure:5816: checking for win32_pstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_win32_pstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5813 "configure"
+#line 5821 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5818,7 +5826,7 @@
 win32_pstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5822: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_win32_pstatus_t=yes
 else
@@ -5871,9 +5879,8 @@
     fi
     ;;
   *)
-    PICFLAG=
-        eval `grep "^[ 	]*PICFLAG[ 	]*=" ../libiberty/Makefile | sed -e "s/[ 	]*//g"`
-        if test -n "$PICFLAG"; then
+    x=`sed -n -e 's/^[ 	]*PICFLAG[ 	]*=[ 	]*//p' < ../libiberty/Makefile | tail -1`
+    if test -n "$x"; then
       WIN32LIBADD="-L../libiberty/pic -liberty"
     fi
   ;;
@@ -5960,17 +5967,6 @@
     # This list is alphabetized to make it easy to compare
     # with the two vector lists in targets.c.  For the same reason,
     # use one entry per line, even though this leads to long lines.
-    # FIXME: We include cofflink.lo not because it's needed for
-    # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
-    # which needs it but does not list it.  Should be fixed in right place.
-    bfd_elf32_sh64_vec)		tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo"
-				target_size=64 ;;
-    bfd_elf32_sh64l_vec)	tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo"
-				target_size=64 ;;
-    bfd_elf64_sh64_vec)		tb="$tb elf64-sh64.lo elf64.lo $elf"
-				target_size=64 ;;
-    bfd_elf64_sh64l_vec)	tb="$tb elf64-sh64.lo elf64.lo $elf"
-				target_size=64 ;;
     a29kcoff_big_vec)		tb="$tb coff-a29k.lo cofflink.lo" ;;
     a_out_adobe_vec)		tb="$tb aout-adobe.lo aout32.lo" ;;
     aout0_big_vec)		tb="$tb aout0.lo aout32.lo" ;;
@@ -5999,7 +5995,7 @@
     bfd_elf32_bigarc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
     bfd_elf32_bigarm_oabi_vec)	tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_bigarm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
-    bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_cris_vec)		tb="$tb elf32-cris.lo elf32.lo $elf" ;;
     bfd_elf32_d10v_vec)		tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
     bfd_elf32_d30v_vec)		tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
@@ -6018,7 +6014,7 @@
     bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
-    bfd_elf32_littlemips_vec) 	tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_littlemips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_m32r_vec)		tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
     bfd_elf32_m68hc11_vec)	tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
     bfd_elf32_m68hc12_vec)	tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;;
@@ -6041,15 +6037,22 @@
     bfd_elf32_shlin_vec)	tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
     bfd_elf32_shlnbsd_vec)	tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
     bfd_elf32_shnbsd_vec)	tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+    # FIXME: We include cofflink.lo not because it's needed for
+    # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
+    # which needs it but does not list it.  Should be fixed in right place.
+    bfd_elf32_sh64_vec)		tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
+    bfd_elf32_sh64l_vec)	tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
+    bfd_elf64_sh64_vec)		tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
+    bfd_elf64_sh64l_vec)	tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf32_sparc_vec)	tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
-    bfd_elf32_tradbigmips_vec)  tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
-    bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_tradbigmips_vec)  tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_us_cris_vec)	tb="$tb elf32-cris.lo elf32.lo $elf" ;;
     bfd_elf32_v850_vec)		tb="$tb elf32-v850.lo elf32.lo $elf" ;;
     bfd_elf32_xstormy16_vec)	tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
     bfd_elf64_alpha_vec)	tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_big_generic_vec) 	tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_bigmips_vec) 	tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_bigmips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_hppa_linux_vec)	tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_hppa_vec)		tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_aix_big_vec)	tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
@@ -6058,14 +6061,14 @@
     bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_little_vec)	tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_mmix_vec) 	tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_powerpc_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_powerpcle_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_s390_vec)		tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sparc_vec)	tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_tradbigmips_vec)	tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
-    bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_tradbigmips_vec)	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_mmo_vec)		tb="$tb mmo.lo" target_size=64 ;;
     bfd_powerpc_pe_vec)         tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
@@ -6133,7 +6136,8 @@
     pmac_xcoff_vec)		tb="$tb coff-rs6000.lo xcofflink.lo" ;;
     ppcboot_vec)		tb="$tb ppcboot.lo" ;;
     riscix_vec)			tb="$tb aout32.lo riscix.lo" ;;
-    rs6000coff64_vec)		tb="$tb coff64-rs6000.lo xcofflink.lo"; target_size=64 ;;
+    rs6000coff64_vec)		tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
+    aix5coff64_vec)		tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
     rs6000coff_vec)		tb="$tb coff-rs6000.lo xcofflink.lo" ;;
     shcoff_small_vec)		tb="$tb coff-sh.lo cofflink.lo" ;;
     shcoff_vec)			tb="$tb coff-sh.lo cofflink.lo" ;;
@@ -6236,10 +6240,10 @@
     if test -n "$GCC" ; then
        bad_64bit_gcc=no;
        echo $ac_n "checking for gcc version with buggy 64-bit support""... $ac_c" 1>&6
-echo "configure:6240: checking for gcc version with buggy 64-bit support" >&5
+echo "configure:6244: checking for gcc version with buggy 64-bit support" >&5
        # Add more tests for gcc versions with non-working 64-bit support here.
        cat > conftest.$ac_ext <<EOF
-#line 6243 "configure"
+#line 6247 "configure"
 #include "confdefs.h"
 :__GNUC__:__GNUC_MINOR__:__i386__:
 EOF
@@ -6280,21 +6284,21 @@
 test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
 
 
-for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
+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:6288: checking for $ac_hdr" >&5
+echo "configure:6292: 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
-#line 6293 "configure"
+#line 6297 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6298: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6323,12 +6327,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6327: checking for $ac_func" >&5
+echo "configure:6331: 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 <<EOF
-#line 6332 "configure"
+#line 6336 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6351,7 +6355,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6376,7 +6380,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6380: checking for working mmap" >&5
+echo "configure:6384: 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
@@ -6384,7 +6388,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 6388 "configure"
+#line 6392 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6412,24 +6416,11 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
 
 /* Assume that all systems that can run configure have sys/param.h.  */
 # ifndef HAVE_SYS_PARAM_H
@@ -6537,7 +6528,7 @@
 }
 
 EOF
-if { (eval echo configure:6541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -6562,12 +6553,12 @@
 for ac_func in madvise mprotect
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6566: checking for $ac_func" >&5
+echo "configure:6557: 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 <<EOF
-#line 6571 "configure"
+#line 6562 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6590,7 +6581,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
diff --git a/bfd/configure.in b/bfd/configure.in
index c8e633b..6659fd5 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -308,8 +308,11 @@
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/m68kaux.h"'
 	;;
-  m88*-*-sysv4*)	;;
-  m88*-motorola-sysv*)	COREFILE=ptrace-core.lo ;;
+  m88*-*-sysv4*)
+	;;
+  m88*-motorola-sysv*)
+	COREFILE=ptrace-core.lo
+	;;
   m88*-*-mach3*)
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/m88kmach3.h"'
@@ -321,9 +324,16 @@
   ns32k-*-netbsd* | ns32k-*-openbsd*)
 	COREFILE=netbsd-core.lo
 	;;
-  rs6000-*-lynx*)	COREFILE=lynx-core.lo ;;
+  rs6000-*-lynx*)
+  	COREFILE=lynx-core.lo
+	;;
+  rs6000-*-aix5.* | powerpc-*-aix5.*)
+        COREFILE=rs6000-core.lo
+	COREFLAG="$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE"
+	;;
 changequote(,)dnl
-  rs6000-*-aix4.[3-9]* | powerpc-*-aix4.[3-9]*)
+  rs6000-*-aix4.[4-9]* | powerpc-*-aix4.[4-9]* | \
+  rs6000-*-aix4.3.[3-9]* | powerpc-*-aix4.3.[3-9]*)
 changequote([,])dnl
         COREFILE=rs6000-core.lo
 	COREFLAG="$COREFLAG -DAIX_CORE_DUMPX_CORE"
@@ -424,11 +434,10 @@
     fi
     ;;
   *)
-    PICFLAG=
-    changequote(,)dnl
-    eval `grep "^[ 	]*PICFLAG[ 	]*=" ../libiberty/Makefile | sed -e "s/[ 	]*//g"`
-    changequote([,])dnl
-    if test -n "$PICFLAG"; then
+changequote(,)dnl
+    x=`sed -n -e 's/^[ 	]*PICFLAG[ 	]*=[ 	]*//p' < ../libiberty/Makefile | tail -1`
+changequote([,])dnl
+    if test -n "$x"; then
       WIN32LIBADD="-L../libiberty/pic -liberty"
     fi
   ;;
@@ -515,17 +524,6 @@
     # This list is alphabetized to make it easy to compare
     # with the two vector lists in targets.c.  For the same reason,
     # use one entry per line, even though this leads to long lines.
-    # FIXME: We include cofflink.lo not because it's needed for
-    # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
-    # which needs it but does not list it.  Should be fixed in right place.
-    bfd_elf32_sh64_vec)		tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo"
-				target_size=64 ;;
-    bfd_elf32_sh64l_vec)	tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo"
-				target_size=64 ;;
-    bfd_elf64_sh64_vec)		tb="$tb elf64-sh64.lo elf64.lo $elf"
-				target_size=64 ;;
-    bfd_elf64_sh64l_vec)	tb="$tb elf64-sh64.lo elf64.lo $elf"
-				target_size=64 ;;
     a29kcoff_big_vec)		tb="$tb coff-a29k.lo cofflink.lo" ;;
     a_out_adobe_vec)		tb="$tb aout-adobe.lo aout32.lo" ;;
     aout0_big_vec)		tb="$tb aout0.lo aout32.lo" ;;
@@ -554,7 +552,7 @@
     bfd_elf32_bigarc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
     bfd_elf32_bigarm_oabi_vec)	tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_bigarm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
-    bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_cris_vec)		tb="$tb elf32-cris.lo elf32.lo $elf" ;;
     bfd_elf32_d10v_vec)		tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
     bfd_elf32_d30v_vec)		tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
@@ -573,7 +571,7 @@
     bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
-    bfd_elf32_littlemips_vec) 	tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_littlemips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_m32r_vec)		tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
     bfd_elf32_m68hc11_vec)	tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
     bfd_elf32_m68hc12_vec)	tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;;
@@ -596,15 +594,22 @@
     bfd_elf32_shlin_vec)	tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
     bfd_elf32_shlnbsd_vec)	tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
     bfd_elf32_shnbsd_vec)	tb="$tb elf32-sh-nbsd.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
+    # FIXME: We include cofflink.lo not because it's needed for
+    # bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
+    # which needs it but does not list it.  Should be fixed in right place.
+    bfd_elf32_sh64_vec)		tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
+    bfd_elf32_sh64l_vec)	tb="$tb elf32-sh64.lo elf32.lo $elf cofflink.lo" target_size=64 ;;
+    bfd_elf64_sh64_vec)		tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
+    bfd_elf64_sh64l_vec)	tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf32_sparc_vec)	tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
-    bfd_elf32_tradbigmips_vec)  tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
-    bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_tradbigmips_vec)  tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_us_cris_vec)	tb="$tb elf32-cris.lo elf32.lo $elf" ;;
     bfd_elf32_v850_vec)		tb="$tb elf32-v850.lo elf32.lo $elf" ;;
     bfd_elf32_xstormy16_vec)	tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
     bfd_elf64_alpha_vec)	tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_big_generic_vec) 	tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_bigmips_vec) 	tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_bigmips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_hppa_linux_vec)	tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_hppa_vec)		tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_aix_big_vec)	tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
@@ -613,14 +618,14 @@
     bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_little_vec)	tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_mmix_vec) 	tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_powerpc_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_powerpcle_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_s390_vec)		tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sparc_vec)	tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_tradbigmips_vec)	tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
-    bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_tradbigmips_vec)	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+    bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_mmo_vec)		tb="$tb mmo.lo" target_size=64 ;;
     bfd_powerpc_pe_vec)         tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
@@ -688,7 +693,8 @@
     pmac_xcoff_vec)		tb="$tb coff-rs6000.lo xcofflink.lo" ;;
     ppcboot_vec)		tb="$tb ppcboot.lo" ;;
     riscix_vec)			tb="$tb aout32.lo riscix.lo" ;;
-    rs6000coff64_vec)		tb="$tb coff64-rs6000.lo xcofflink.lo"; target_size=64 ;;
+    rs6000coff64_vec)		tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
+    aix5coff64_vec)		tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;;
     rs6000coff_vec)		tb="$tb coff-rs6000.lo xcofflink.lo" ;;
     shcoff_small_vec)		tb="$tb coff-sh.lo cofflink.lo" ;;
     shcoff_vec)			tb="$tb coff-sh.lo cofflink.lo" ;;
diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c
index 929ebd1..07beae5 100644
--- a/bfd/cpu-h8300.c
+++ b/bfd/cpu-h8300.c
@@ -1,5 +1,5 @@
 /* BFD library support routines for the Hitachi H8/300 architecture.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Hacked by Steve Chamberlain of Cygnus Support.
 
@@ -91,7 +91,7 @@
      const bfd_arch_info_type *out;
 {
   /* It's really not a good idea to mix and match modes.  */
-  if (in->mach != out->mach)
+  if (in->arch != out->arch || in->mach != out->mach)
     return 0;
   else
     return in;
diff --git a/bfd/cpu-i370.c b/bfd/cpu-i370.c
index c6c599a..d682113 100644
--- a/bfd/cpu-i370.c
+++ b/bfd/cpu-i370.c
@@ -1,5 +1,5 @@
 /* BFD i370 CPU definition
-   Copyright 1994, 1995, 1996, 1998, 1999, 2000
+   Copyright 1994, 1995, 1996, 1998, 1999, 2000, 2002
    Free Software Foundation, Inc.
    Contributed by Ian Lance Taylor, Cygnus Support.
    Hacked by Linas Vepstas <linas@linas.org> in 1998, 1999
@@ -24,27 +24,6 @@
 #include "sysdep.h"
 #include "libbfd.h"
 
-/* The common i360/370 architecture comes in many forms  */
-
-static const bfd_arch_info_type *i370_compatible
-  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
-static const bfd_arch_info_type *
-i370_compatible (a, b)
-     const bfd_arch_info_type *a;
-     const bfd_arch_info_type *b;
-{
-  BFD_ASSERT (a->arch == bfd_arch_i370);
-  switch (b->arch)
-    {
-    default:
-      return NULL;
-    case bfd_arch_i370:
-      return bfd_default_compatible (a, b);
-    }
-  /*NOTREACHED*/
-}
-
 static const bfd_arch_info_type arch_info_struct[] =
 {
   /* hack alert: old old machines are really 16 and 24 bit arch ...  */
@@ -58,7 +37,7 @@
     "i370:360",
     3,
     false, /* not the default */
-    i370_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[1]
   },
@@ -72,7 +51,7 @@
     "i370:370",
     3,
     false, /* not the default */
-    i370_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     0
   },
@@ -89,7 +68,7 @@
     "i370:common",
     3,
     true, /* the default */
-    i370_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[0]
   };
diff --git a/bfd/cpu-i386.c b/bfd/cpu-i386.c
index 8619fbf..f492827 100644
--- a/bfd/cpu-i386.c
+++ b/bfd/cpu-i386.c
@@ -1,5 +1,5 @@
 /* BFD support for the Intel 386 architecture.
-   Copyright 1992, 1994, 1995, 1996, 1998, 2000, 2001
+   Copyright 1992, 1994, 1995, 1996, 1998, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -44,8 +44,8 @@
   8,  /* 8 bits in a byte */
   bfd_arch_i386,
   bfd_mach_x86_64_intel_syntax,
-  "x86-64:intel",
-  "x86-64:intel",
+  "i386:intel",
+  "i386:x86-64:intel",
   3,
   true,
   bfd_default_compatible,
@@ -75,8 +75,8 @@
   8,  /* 8 bits in a byte */
   bfd_arch_i386,
   bfd_mach_x86_64,
-  "x86-64",
-  "x86-64",
+  "i386",
+  "i386:x86-64",
   3,
   true,
   bfd_default_compatible,
diff --git a/bfd/cpu-mips.c b/bfd/cpu-mips.c
index 888d863..d54b0a5 100644
--- a/bfd/cpu-mips.c
+++ b/bfd/cpu-mips.c
@@ -1,5 +1,5 @@
 /* bfd back-end for mips support
-   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000
+   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002
    Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support.
 
@@ -23,6 +23,29 @@
 #include "sysdep.h"
 #include "libbfd.h"
 
+static const bfd_arch_info_type *mips_compatible
+  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+
+/* The default routine tests bits_per_word, which is wrong on mips as
+   mips word size doesn't correlate with reloc size.  */
+
+static const bfd_arch_info_type *
+mips_compatible (a, b)
+     const bfd_arch_info_type *a;
+     const bfd_arch_info_type *b;
+{
+  if (a->arch != b->arch)
+    return NULL;
+
+  if (a->mach > b->mach)
+    return a;
+
+  if (b->mach > a->mach)
+    return b;
+
+  return a;
+}
+
 #define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT)		\
   {							\
     BITS_WORD, /*  bits in a word */			\
@@ -34,7 +57,7 @@
     PRINT,						\
     3,							\
     DEFAULT,						\
-    bfd_default_compatible, 				\
+    mips_compatible,					\
     bfd_default_scan,					\
     NEXT,						\
   }
diff --git a/bfd/cpu-powerpc.c b/bfd/cpu-powerpc.c
index d812618..d77b426 100644
--- a/bfd/cpu-powerpc.c
+++ b/bfd/cpu-powerpc.c
@@ -50,6 +50,65 @@
 
 const bfd_arch_info_type bfd_powerpc_archs[] =
 {
+#if BFD_DEFAULT_TARGET_SIZE == 64 /* default arch must come first.  */
+  {
+    64,	/* 64 bits in a word */
+    64,	/* 64 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc64,
+    "powerpc",
+    "powerpc:common64",
+    3,
+    true, /* default for 64 bit target */
+    powerpc_compatible,
+    bfd_default_scan,
+    &bfd_powerpc_archs[1]
+  },
+  {
+    32,	/* 32 bits in a word */
+    32,	/* 32 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc, /* for the POWER/PowerPC common architecture */
+    "powerpc",
+    "powerpc:common",
+    3,
+    false,
+    powerpc_compatible,
+    bfd_default_scan,
+    &bfd_powerpc_archs[2],
+  },
+#else
+  {
+    32,	/* 32 bits in a word */
+    32,	/* 32 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc, /* for the POWER/PowerPC common architecture */
+    "powerpc",
+    "powerpc:common",
+    3,
+    true, /* default for 32 bit target */
+    powerpc_compatible,
+    bfd_default_scan,
+    &bfd_powerpc_archs[1],
+  },
+  {
+    64,	/* 64 bits in a word */
+    64,	/* 64 bits in an address */
+    8,	/* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc64,
+    "powerpc",
+    "powerpc:common64",
+    3,
+    false,
+    powerpc_compatible,
+    bfd_default_scan,
+    &bfd_powerpc_archs[2]
+  },
+#endif
   {
     32,	/* 32 bits in a word */
     32,	/* 32 bits in an address */
@@ -62,7 +121,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[1]
+    &bfd_powerpc_archs[3]
   },
   {
     32,	/* 32 bits in a word */
@@ -76,7 +135,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[2]
+    &bfd_powerpc_archs[4]
   },
   {
     32,	/* 32 bits in a word */
@@ -90,7 +149,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[3]
+    &bfd_powerpc_archs[5]
   },
   {
     32,	/* 32 bits in a word */
@@ -104,7 +163,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[4]
+    &bfd_powerpc_archs[6]
   },
   {
     32,	/* 32 bits in a word */
@@ -118,7 +177,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[5]
+    &bfd_powerpc_archs[7]
   },
   {
     64,	/* 64 bits in a word */
@@ -132,7 +191,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[6]
+    &bfd_powerpc_archs[8]
   },
   {
     64,	/* 64 bits in a word */
@@ -146,7 +205,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[7]
+    &bfd_powerpc_archs[9]
   },
   {
     64,	/* 64 bits in a word */
@@ -160,7 +219,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[8]
+    &bfd_powerpc_archs[10]
   },
   {
     64,	/* 64 bits in a word */
@@ -174,7 +233,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[9]
+    &bfd_powerpc_archs[11]
   },
   {
     64,	/* 64 bits in a word */
@@ -188,7 +247,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[10]
+    &bfd_powerpc_archs[12]
   },
   {
     32,	/* 32 bits in a word */
@@ -202,7 +261,7 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[11]
+    &bfd_powerpc_archs[13]
   },
   {
     32,       /* 32 bits in a word */
@@ -216,34 +275,6 @@
     false, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
-    &bfd_powerpc_archs[12]
-  },
-  {
-    64,	/* 64 bits in a word */
-    64,	/* 64 bits in an address */
-    8,	/* 8 bits in a byte */
-    bfd_arch_powerpc,
-    bfd_mach_ppc64,
-    "powerpc",
-    "powerpc:common64",
-    3,
-    BFD_DEFAULT_TARGET_SIZE == 64, /* default for 64 bit target */
-    powerpc_compatible,
-    bfd_default_scan,
-    &bfd_powerpc_archs[13]
-  },
-  {
-    32,	/* 32 bits in a word */
-    32,	/* 32 bits in an address */
-    8,	/* 8 bits in a byte */
-    bfd_arch_powerpc,
-    bfd_mach_ppc, /* for the POWER/PowerPC common architecture */
-    "powerpc",
-    "powerpc:common",
-    3,
-    BFD_DEFAULT_TARGET_SIZE != 64, /* default for 32 bit target */
-    powerpc_compatible,
-    bfd_default_scan,
     0
   }
 };
diff --git a/bfd/cpu-s390.c b/bfd/cpu-s390.c
index d537e12..ac0d45e 100644
--- a/bfd/cpu-s390.c
+++ b/bfd/cpu-s390.c
@@ -1,5 +1,5 @@
 /* BFD support for the s390 processor.
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Carl B. Pedersen and Martin Schwidefsky.
 
    This file is part of BFD, the Binary File Descriptor library.
diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c
index 30cd141..dff2f88 100644
--- a/bfd/cpu-sh.c
+++ b/bfd/cpu-sh.c
@@ -23,19 +23,6 @@
 #include "sysdep.h"
 #include "libbfd.h"
 
-static boolean scan_mach
-  PARAMS ((const struct bfd_arch_info *, const char *));
-
-static boolean
-scan_mach (info, string)
-     const struct bfd_arch_info *info;
-     const char *string;
-{
-  if (strcasecmp (info->printable_name, string) == 0)
-    return true;
-  return false;
-}
-
 #if 0
 /* This routine is provided two arch_infos and returns whether
    they'd be compatible */
@@ -75,7 +62,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH2_NEXT
   },
   {
@@ -89,7 +76,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH_DSP_NEXT
   },
   {
@@ -103,7 +90,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH3_NEXT
   },
   {
@@ -117,7 +104,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH3_DSP_NEXT
   },
   {
@@ -131,7 +118,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH3E_NEXT
   },
   {
@@ -145,7 +132,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH4_NEXT
   },
   {
@@ -159,7 +146,7 @@
     1,
     false,			/* not the default */
     bfd_default_compatible,
-    scan_mach,
+    bfd_default_scan,
     SH64_NEXT
   },
 };
@@ -176,6 +163,6 @@
   1,
   true,				/* the default machine */
   bfd_default_compatible,
-  scan_mach,
+  bfd_default_scan,
   SH_NEXT
 };
diff --git a/bfd/cpu-sparc.c b/bfd/cpu-sparc.c
index dbc83ba..e3b8ecb 100644
--- a/bfd/cpu-sparc.c
+++ b/bfd/cpu-sparc.c
@@ -1,5 +1,6 @@
 /* BFD support for the SPARC architecture.
-   Copyright 1992, 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
+   Copyright 1992, 1995, 1996, 1998, 2000, 2002
+   Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -21,22 +22,6 @@
 #include "sysdep.h"
 #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)
-     const bfd_arch_info_type *a;
-     const bfd_arch_info_type *b;
-{
-  if (a->bits_per_word != b->bits_per_word)
-    return NULL;
-
-  return bfd_default_compatible (a, b);
-}
-
 static const bfd_arch_info_type arch_info_struct[] =
 {
   {
@@ -49,7 +34,7 @@
     "sparc:sparclet",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[1],
   },
@@ -63,7 +48,7 @@
     "sparc:sparclite",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[2],
   },
@@ -77,7 +62,7 @@
     "sparc:v8plus",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[3],
   },
@@ -91,7 +76,7 @@
     "sparc:v8plusa",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[4],
   },
@@ -105,7 +90,7 @@
     "sparc:sparclite_le",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[5],
   },
@@ -119,7 +104,7 @@
     "sparc:v9",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[6],
   },
@@ -133,7 +118,7 @@
     "sparc:v9a",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[7],
   },
@@ -147,7 +132,7 @@
     "sparc:v8plusb",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[8],
   },
@@ -161,7 +146,7 @@
     "sparc:v9b",
     3,
     false,
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     0,
   }
@@ -178,7 +163,7 @@
     "sparc",
     3,
     true, /* the default */
-    sparc_compatible,
+    bfd_default_compatible,
     bfd_default_scan,
     &arch_info_struct[0],
   };
diff --git a/bfd/dep-in.sed b/bfd/dep-in.sed
index 4a706aa..ce8b79b 100644
--- a/bfd/dep-in.sed
+++ b/bfd/dep-in.sed
@@ -5,8 +5,10 @@
 
 s!\.o:!.lo:!
 s! @BFD_H@!!g
-s!@INCDIR@!$(INCDIR)!g
+s!@SRCDIR@/../include!$(INCDIR)!g
+s!@TOPDIR@/include!$(INCDIR)!g
 s!@SRCDIR@/../opcodes!$(srcdir)/../opcodes!g
+s!@TOPDIR@/opcodes!$(srcdir)/../opcodes!g
 s!@SRCDIR@/!!g
 s! hosts/[^ ]*\.h! !g
 s! sysdep.h!!g
diff --git a/bfd/doc/ChangeLog b/bfd/doc/ChangeLog
index 7330a3e..b71ad5a 100644
--- a/bfd/doc/ChangeLog
+++ b/bfd/doc/ChangeLog
@@ -1,3 +1,7 @@
+2002-04-20  Alan Modra  <amodra@bigpond.net.au>
+
+	* Makefile.in: Regenerate.
+
 2002-02-11  Alan Modra  <amodra@bigpond.net.au>
 
 	* Makefile.in: Regenerate.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 550f005..e3b8e27 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -42,7 +42,7 @@
 {
   bfd_vma total_length;
   unsigned short version;
-  unsigned int prologue_length;
+  bfd_vma prologue_length;
   unsigned char minimum_instruction_length;
   unsigned char default_is_stmt;
   int line_base;
@@ -225,7 +225,7 @@
 static struct abbrev_info *lookup_abbrev
   PARAMS ((unsigned int, struct abbrev_info **));
 static struct abbrev_info **read_abbrevs
-  PARAMS ((bfd *, unsigned int, struct dwarf2_debug *));
+  PARAMS ((bfd *, bfd_vma, struct dwarf2_debug *));
 static char *read_attribute
   PARAMS ((struct attribute *, struct attr_abbrev *,
 	   struct comp_unit *, char *));
@@ -240,9 +240,10 @@
 static struct line_info_table *decode_line_info
   PARAMS ((struct comp_unit *, struct dwarf2_debug *));
 static boolean lookup_address_in_line_info_table
-  PARAMS ((struct line_info_table *, bfd_vma, const char **, unsigned int *));
+  PARAMS ((struct line_info_table *, bfd_vma, struct funcinfo *,
+	   const char **, unsigned int *));
 static boolean lookup_address_in_function_table
-  PARAMS ((struct funcinfo *, bfd_vma, const char **));
+  PARAMS ((struct funcinfo *, bfd_vma, struct funcinfo **, const char **));
 static boolean scan_unit_for_functions PARAMS ((struct comp_unit *));
 static bfd_vma find_rela_addend
   PARAMS ((bfd *, asection *, bfd_size_type, asymbol**));
@@ -395,8 +396,8 @@
 
   if (offset >= stash->dwarf_str_size)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: DW_FORM_strp offset (%u) greater than or equal to .debug_str size (%u)."),
-			     offset, stash->dwarf_str_size);
+      (*_bfd_error_handler) (_("Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str size (%lu)."),
+			     (unsigned long) offset, stash->dwarf_str_size);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
     }
@@ -522,7 +523,7 @@
 static struct abbrev_info**
 read_abbrevs (abfd, offset, stash)
      bfd * abfd;
-     unsigned int offset;
+     bfd_vma offset;
      struct dwarf2_debug *stash;
 {
   struct abbrev_info **abbrevs;
@@ -556,8 +557,8 @@
 
   if (offset >= stash->dwarf_abbrev_size)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%u) greater than or equal to .debug_abbrev size (%u)."),
-			     offset, stash->dwarf_abbrev_size);
+      (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."),
+			     (unsigned long) offset, stash->dwarf_abbrev_size);
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
@@ -753,7 +754,7 @@
       info_ptr = read_attribute_value (attr, form, unit, info_ptr);
       break;
     default:
-      (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %d."),
+      (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %u."),
 			     form);
       bfd_set_error (bfd_error_bad_value);
     }
@@ -808,6 +809,14 @@
   struct line_info* last_line;
 };
 
+struct funcinfo
+{
+  struct funcinfo *prev_func;
+  char* name;
+  bfd_vma low;
+  bfd_vma high;
+};
+
 static void
 add_line_info (table, address, filename, line, column, end_sequence)
      struct line_info_table* table;
@@ -949,7 +958,7 @@
      below.  */
   if (unit->line_offset >= stash->dwarf_line_size)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: Line offset (%u) greater than or equal to .debug_line size (%u)."),
+      (*_bfd_error_handler) (_("Dwarf Error: Line offset (%lu) greater than or equal to .debug_line size (%lu)."),
 			     unit->line_offset, stash->dwarf_line_size);
       bfd_set_error (bfd_error_bad_value);
       return 0;
@@ -1215,10 +1224,12 @@
 static boolean
 lookup_address_in_line_info_table (table,
 				   addr,
+				   function,
 				   filename_ptr,
 				   linenumber_ptr)
      struct line_info_table* table;
      bfd_vma addr;
+     struct funcinfo *function;
      const char **filename_ptr;
      unsigned int *linenumber_ptr;
 {
@@ -1235,35 +1246,53 @@
       if (!each_line->end_sequence
 	  && addr >= each_line->address && addr < next_line->address)
 	{
-	  *filename_ptr = each_line->filename;
-	  *linenumber_ptr = each_line->line;
+	  /* If this line appears to span functions, and addr is in the
+	     later function, return the first line of that function instead
+	     of the last line of the earlier one.  This check is for GCC
+	     2.95, which emits the first line number for a function late.  */
+	  if (function != NULL
+	      && each_line->address < function->low
+	      && next_line->address > function->low)
+	    {
+	      *filename_ptr = next_line->filename;
+	      *linenumber_ptr = next_line->line;
+	    }
+	  else
+	    {
+	      *filename_ptr = each_line->filename;
+	      *linenumber_ptr = each_line->line;
+	    }
 	  return true;
 	}
       next_line = each_line;
       each_line = each_line->prev_line;
     }
 
+  /* At this point each_line is NULL but next_line is not.  If we found the
+     containing function in this compilation unit, return the first line we
+     have a number for.  This is also for compatibility with GCC 2.95.  */
+  if (function != NULL)
+    {
+      *filename_ptr = next_line->filename;
+      *linenumber_ptr = next_line->line;
+      return true;
+    }
+
   return false;
 }
 
 /* Function table functions.  */
 
-struct funcinfo
-{
-  struct funcinfo *prev_func;
-  char* name;
-  bfd_vma low;
-  bfd_vma high;
-};
-
 /* If ADDR is within TABLE, set FUNCTIONNAME_PTR, and return true.  */
 
 static boolean
 lookup_address_in_function_table (table,
 				  addr,
+				  function_ptr,
 				  functionname_ptr)
      struct funcinfo* table;
      bfd_vma addr;
+     struct funcinfo** function_ptr;
      const char **functionname_ptr;
 {
   struct funcinfo* each_func;
@@ -1275,6 +1304,7 @@
       if (addr >= each_func->low && addr < each_func->high)
 	{
 	  *functionname_ptr = each_func->name;
+	  *function_ptr = each_func;
 	  return true;
 	}
     }
@@ -1315,7 +1345,7 @@
       abbrev = lookup_abbrev (abbrev_number,unit->abbrevs);
       if (! abbrev)
 	{
-	  (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."),
+	  (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
 			     abbrev_number);
 	  bfd_set_error (bfd_error_bad_value);
 	  return false;
@@ -1456,9 +1486,9 @@
      unsigned int offset_size;
 {
   struct comp_unit* unit;
-  unsigned short version;
-  unsigned int abbrev_offset = 0;
-  unsigned char addr_size;
+  unsigned int version;
+  bfd_vma abbrev_offset = 0;
+  unsigned int addr_size;
   struct abbrev_info** abbrevs;
   unsigned int abbrev_number, bytes_read, i;
   struct abbrev_info *abbrev;
@@ -1487,7 +1517,7 @@
 
   if (version != 2)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%hu', this reader only handles version 2 information."), version);
+      (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%u', this reader only handles version 2 information."), version);
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
@@ -1496,7 +1526,7 @@
     {
       (*_bfd_error_handler) (_("Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."),
 			 addr_size,
-			 sizeof (bfd_vma));
+			 (unsigned int) sizeof (bfd_vma));
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
@@ -1517,7 +1547,7 @@
   info_ptr += bytes_read;
   if (! abbrev_number)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %d."),
+      (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %u."),
 			 abbrev_number);
       bfd_set_error (bfd_error_bad_value);
       return 0;
@@ -1526,7 +1556,7 @@
   abbrev = lookup_abbrev (abbrev_number, abbrevs);
   if (! abbrev)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."),
+      (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
 			 abbrev_number);
       bfd_set_error (bfd_error_bad_value);
       return 0;
@@ -1636,6 +1666,7 @@
 {
   boolean line_p;
   boolean func_p;
+  struct funcinfo *function;
 
   if (unit->error)
     return false;
@@ -1664,13 +1695,16 @@
 	}
     }
 
-  line_p = lookup_address_in_line_info_table (unit->line_table,
-					      addr,
-					      filename_ptr,
-					      linenumber_ptr);
+  function = NULL;
   func_p = lookup_address_in_function_table (unit->function_table,
 					     addr,
+					     &function,
 					     functionname_ptr);
+  line_p = lookup_address_in_line_info_table (unit->line_table,
+					      addr,
+					      function,
+					      filename_ptr,
+					      linenumber_ptr);
   return line_p || func_p;
 }
 
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 1e3b6a9..c7230f6 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -1,5 +1,5 @@
 /* Generic ECOFF (Extended-COFF) routines.
-   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
@@ -3452,7 +3452,7 @@
   struct ecoff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct ecoff_link_hash_table);
 
-  ret = (struct ecoff_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct ecoff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd,
@@ -4393,6 +4393,13 @@
   bfd *output_bfd = einfo->abfd;
   boolean strip;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h = (struct ecoff_link_hash_entry *) h->root.u.i.link;
+      if (h->root.type == bfd_link_hash_new)
+	return true;
+    }
+
   /* We need to check if this symbol is being stripped.  */
   if (h->root.type == bfd_link_hash_undefined
       || h->root.type == bfd_link_hash_undefweak)
@@ -4474,6 +4481,7 @@
   switch (h->root.type)
     {
     default:
+    case bfd_link_hash_warning:
     case bfd_link_hash_new:
       abort ();
     case bfd_link_hash_undefined:
@@ -4502,9 +4510,8 @@
       h->esym.asym.value = h->root.u.c.size;
       break;
     case bfd_link_hash_indirect:
-    case bfd_link_hash_warning:
-      /* FIXME: Ignore these for now.  The circumstances under which
-	 they should be written out are not clear to me.  */
+      /* We ignore these symbols, since the indirected symbol is
+	 already in the hash table.  */
       return true;
     }
 
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 4439daa..ef219e4 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -403,6 +403,14 @@
   boolean bad_symtab;
 };
 
+/* The level of IRIX compatibility we're striving for.  */
+
+typedef enum {
+  ict_none,
+  ict_irix5,
+  ict_irix6
+} irix_compat_t;
+
 struct elf_backend_data
 {
   /* The architecture for this backend.  */
@@ -740,6 +748,14 @@
   boolean (*elf_backend_write_section)
     PARAMS ((bfd *, asection *, bfd_byte *));
 
+  /* The level of IRIX compatibility we're striving for.
+     MIPS ELF specific function.  */
+  irix_compat_t (*elf_backend_mips_irix_compat)
+    PARAMS ((bfd *));
+
+  reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
+    PARAMS ((unsigned int, boolean));
+
   /* The swapping table to use when dealing with ECOFF information.
      Used for the MIPS ELF .mdebug section.  */
   const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
@@ -1534,85 +1550,6 @@
 extern char *elfcore_write_lwpstatus 
   PARAMS ((bfd*, char*, int*, long, int, void*));
 
-/* MIPS ELF specific routines.  */
-
-extern boolean _bfd_mips_elf_object_p
-  PARAMS ((bfd *));
-extern boolean _bfd_mips_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
-extern boolean _bfd_mips_elf_fake_sections
-  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
-extern boolean _bfd_mips_elf_section_from_bfd_section
-  PARAMS ((bfd *, asection *, int *));
-extern boolean _bfd_mips_elf_section_processing
-  PARAMS ((bfd *, Elf_Internal_Shdr *));
-extern void _bfd_mips_elf_symbol_processing
-  PARAMS ((bfd *, asymbol *));
-extern boolean _bfd_mips_elf_read_ecoff_info
-  PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
-extern void _bfd_mips_elf_final_write_processing
-  PARAMS ((bfd *, boolean));
-extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-extern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-extern boolean _bfd_mips_elf_set_private_flags
-  PARAMS ((bfd *, flagword));
-extern boolean _bfd_mips_elf_merge_private_bfd_data
-  PARAMS ((bfd *, bfd *));
-extern boolean _bfd_mips_elf_find_nearest_line
-  PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
-	   const char **, unsigned int *));
-extern boolean _bfd_mips_elf_set_section_contents
-  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-extern boolean _bfd_mips_elf_create_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_mips_elf_add_symbol_hook
-  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
-	   const char **, flagword *, asection **, bfd_vma *));
-extern boolean _bfd_mips_elf_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-extern boolean _bfd_mips_elf_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-extern boolean _bfd_mips_elf_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-extern asection * _bfd_mips_elf_gc_mark_hook
-  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-extern boolean _bfd_mips_elf_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-extern boolean _bfd_mips_elf_always_size_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_mips_elf_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_mips_elf_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
-  PARAMS ((bfd *));
-extern boolean _bfd_mips_elf_print_private_bfd_data
-  PARAMS ((bfd *, PTR));
-extern boolean _bfd_mips_elf_link_output_symbol_hook
-  PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
-	   asection *));
-extern boolean _bfd_mips_elf_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-extern int _bfd_mips_elf_additional_program_headers
-  PARAMS ((bfd *));
-extern boolean _bfd_mips_elf_modify_segment_map
-  PARAMS ((bfd *));
-extern boolean _bfd_mips_elf_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-
 /* SH ELF specific routine.  */
 
 extern boolean _sh_elf_set_mach_from_flags
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 20cbfb2..6a23edb 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -64,6 +64,7 @@
   unsigned char removed : 1;
   unsigned char make_relative : 1;
   unsigned char make_lsda_relative : 1;
+  unsigned char per_encoding_relative : 1;
 };
 
 struct eh_frame_sec_info
@@ -469,6 +470,8 @@
 		    = cie.make_relative;
 		  sec_info->entry[last_cie_ndx].make_lsda_relative
 		    = cie.make_lsda_relative;
+		  sec_info->entry[last_cie_ndx].per_encoding_relative
+		    = (cie.per_encoding & 0x70) == DW_EH_PE_pcrel;
 		}
 	    }
 
@@ -633,8 +636,9 @@
 	  else
 	    {
 	      if (info->shared
-		  && (cie.fde_encoding & 0xf0) == DW_EH_PE_absptr
-		  && cie.make_relative == 0)
+		  && (((cie.fde_encoding & 0xf0) == DW_EH_PE_absptr
+		       && cie.make_relative == 0)
+		      || (cie.fde_encoding & 0xf0) == DW_EH_PE_aligned))
 		{
 		  /* If shared library uses absolute pointers
 		     which we cannot turn into PC relative,
@@ -689,6 +693,7 @@
 	    {
 	      sec_info->entry[i].make_relative = make_relative;
 	      sec_info->entry[i].make_lsda_relative = make_lsda_relative;
+	      sec_info->entry[i].per_encoding_relative = 0;
 	    }
 	}
       else if (sec_info->entry[i].cie && sec_info->entry[i].sec == sec)
@@ -947,7 +952,8 @@
 	  /* CIE */
 	  cie_offset = sec_info->entry[i].new_offset;
 	  if (sec_info->entry[i].make_relative
-	      || sec_info->entry[i].make_lsda_relative)
+	      || sec_info->entry[i].make_lsda_relative
+	      || sec_info->entry[i].per_encoding_relative)
 	    {
 	      unsigned char *aug;
 	      unsigned int action;
@@ -956,7 +962,8 @@
 	      /* Need to find 'R' or 'L' augmentation's argument and modify
 		 DW_EH_PE_* value.  */
 	      action = (sec_info->entry[i].make_relative ? 1 : 0)
-		       | (sec_info->entry[i].make_lsda_relative ? 2 : 0);
+		       | (sec_info->entry[i].make_lsda_relative ? 2 : 0)
+		       | (sec_info->entry[i].per_encoding_relative ? 4 : 0);
 	      buf = contents + sec_info->entry[i].offset;
 	      /* Skip length, id and version.  */
 	      buf += 9;
@@ -988,10 +995,22 @@
                     per_width = get_DW_EH_PE_width (per_encoding,
 						    ptr_size);
 		    BFD_ASSERT (per_width != 0);
+		    BFD_ASSERT (((per_encoding & 0x70) == DW_EH_PE_pcrel)
+				== sec_info->entry[i].per_encoding_relative);
 		    if ((per_encoding & 0xf0) == DW_EH_PE_aligned)
 		      buf = (contents
 			     + ((buf - contents + per_width - 1)
 				& ~((bfd_size_type) per_width - 1)));
+		    if (action & 4)
+		      {
+			bfd_vma value;
+
+			value = read_value (abfd, buf, per_width);
+			value += (sec_info->entry[i].offset
+				  - sec_info->entry[i].new_offset);
+			write_value (abfd, buf, value, per_width);
+			action &= ~4;
+		      }
 		    buf += per_width;
 		    break;
 		  case 'R':
@@ -1008,7 +1027,7 @@
 		  }
 	    }
 	}
-      else
+      else if (sec_info->entry[i].size > 4)
 	{
 	  /* FDE */
 	  bfd_vma value = 0, address;
@@ -1081,6 +1100,9 @@
 		}
 	    }
 	}
+      else
+	/* Terminating FDE must be at the end of .eh_frame section only.  */
+	BFD_ASSERT (i == sec_info->count - 1);
 
       BFD_ASSERT (p == contents + sec_info->entry[i].new_offset);
       memmove (p, contents + sec_info->entry[i].offset,
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h
index a98c2b0..99a66f4 100644
--- a/bfd/elf-hppa.h
+++ b/bfd/elf-hppa.h
@@ -64,6 +64,12 @@
 static void elf_hppa_final_write_processing
   PARAMS ((bfd *, boolean));
 
+static int hppa_unwind_entry_compare
+  PARAMS ((const PTR, const PTR));
+
+static boolean elf_hppa_sort_unwind
+  PARAMS ((bfd *));
+
 #if ARCH_SIZE == 64
 static boolean elf_hppa_add_symbol_hook
   PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
@@ -75,6 +81,9 @@
 static boolean elf_hppa_remark_useless_dynamic_symbols
   PARAMS ((struct elf_link_hash_entry *, PTR));
 
+static boolean elf_hppa_is_dynamic_loader_symbol
+  PARAMS ((const char *));
+
 static void elf_hppa_record_segment_addrs
   PARAMS ((bfd *, asection *, PTR));
 
@@ -83,12 +92,12 @@
 
 static boolean elf_hppa_relocate_section
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
-           bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+	   bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
 
 static bfd_reloc_status_type elf_hppa_final_link_relocate
   PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *,
-           bfd_byte *, bfd_vma, struct bfd_link_info *,
-           asection *, struct elf_link_hash_entry *,
+	   bfd_byte *, bfd_vma, struct bfd_link_info *,
+	   asection *, struct elf_link_hash_entry *,
 	   struct elf64_hppa_dyn_hash_entry *));
 
 static int elf_hppa_relocate_insn
@@ -706,7 +715,7 @@
 		 be a section relative relocation.  Dwarf2 (for example)
 		 uses 32bit section relative relocations.  */
 	      if (bfd_get_arch_info (abfd)->bits_per_address != 32)
-	        final_type = R_PARISC_SECREL32;
+		final_type = R_PARISC_SECREL32;
 	      break;
 	    case e_psel:
 	      final_type = R_PARISC_PLABEL32;
@@ -1034,6 +1043,64 @@
 				      | EF_PARISC_TRAPNIL);
 }
 
+/* Comparison function for qsort to sort unwind section during a
+   final link.  */
+
+static int
+hppa_unwind_entry_compare (a, b)
+     const PTR a;
+     const PTR b;
+{
+  const bfd_byte *ap, *bp;
+  unsigned long av, bv;
+
+  ap = (const bfd_byte *) a;
+  av = (unsigned long) ap[0] << 24;
+  av |= (unsigned long) ap[1] << 16;
+  av |= (unsigned long) ap[2] << 8;
+  av |= (unsigned long) ap[3];
+
+  bp = (const bfd_byte *) b;
+  bv = (unsigned long) bp[0] << 24;
+  bv |= (unsigned long) bp[1] << 16;
+  bv |= (unsigned long) bp[2] << 8;
+  bv |= (unsigned long) bp[3];
+
+  return av < bv ? -1 : av > bv ? 1 : 0;
+}
+
+static boolean elf_hppa_sort_unwind (abfd)
+     bfd *abfd;
+{
+  asection *s;
+
+  /* Magic section names, but this is much safer than having
+     relocate_section remember where SEGREL32 relocs occurred.
+     Consider what happens if someone inept creates a linker script
+     that puts unwind information in .text.  */
+  s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
+  if (s != NULL)
+    {
+      bfd_size_type size;
+      char *contents;
+
+      size = s->_raw_size;
+      contents = bfd_malloc (size);
+      if (contents == NULL)
+	return false;
+
+      if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size))
+	return false;
+
+      qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
+
+      if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
+	return false;
+    }
+
+  return true;
+}
+
 #if ARCH_SIZE == 64
 /* Hook called by the linker routine which adds symbols from an object
    file.  HP's libraries define symbols with HP specific section
@@ -1076,6 +1143,9 @@
 {
   struct bfd_link_info *info = (struct bfd_link_info *)data;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* If we are not creating a shared library, and this symbol is
      referenced by a shared library but is not defined anywhere, then
      the generic code will warn that it is undefined.
@@ -1109,6 +1179,9 @@
 {
   struct bfd_link_info *info = (struct bfd_link_info *)data;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* If we are not creating a shared library, and this symbol is
      referenced by a shared library but is not defined anywhere, then
      the generic code will warn that it is undefined.
@@ -1136,6 +1209,23 @@
   return true;
 }
 
+static boolean
+elf_hppa_is_dynamic_loader_symbol (name)
+     const char * name;
+{
+  return (! strcmp (name, "__CPU_REVISION")
+	  || ! strcmp (name, "__CPU_KEYBITS_1")
+	  || ! strcmp (name, "__SYSTEM_ID_D")
+	  || ! strcmp (name, "__FPU_MODEL")
+	  || ! strcmp (name, "__FPU_REVISION")
+	  || ! strcmp (name, "__ARGC")
+	  || ! strcmp (name, "__ARGV")
+	  || ! strcmp (name, "__ENVP")
+	  || ! strcmp (name, "__TLS_SIZE_D")
+	  || ! strcmp (name, "__LOAD_INFO")
+	  || ! strcmp (name, "__systab"));
+}
+
 /* Record the lowest address for the data and text segments.  */
 static void
 elf_hppa_record_segment_addrs (abfd, section, data)
@@ -1258,6 +1348,11 @@
 			  elf_hppa_remark_useless_dynamic_symbols,
 			  info);
 
+  /* If we're producing a final executable, sort the contents of the
+     unwind section. */
+  if (retval)
+    retval = elf_hppa_sort_unwind (abfd);
+
   return retval;
 }
 
@@ -1390,7 +1485,7 @@
 		relocation = 0;
 	    }
 	  /* Allow undefined symbols in shared libraries.  */
-          else if (info->shared && !info->no_undefined
+	  else if (info->shared && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    {
 	      if (info->symbolic)
@@ -1419,11 +1514,17 @@
 	    relocation = 0;
 	  else
 	    {
-	      if (!((*info->callbacks->undefined_symbol)
-		    (info, h->root.root.string, input_bfd,
-		     input_section, rel->r_offset, true)))
-		return false;
-	      break;
+	      /* Ignore dynamic loader defined symbols.  */
+	      if (elf_hppa_is_dynamic_loader_symbol (h->root.root.string))
+		relocation = 0;
+	      else
+		{
+		  if (!((*info->callbacks->undefined_symbol)
+			(info, h->root.root.string, input_bfd,
+			 input_section, rel->r_offset, true)))
+		    return false;
+		  break;
+		}
 	    }
 	}
 
@@ -1620,11 +1721,7 @@
 	   a local function which had its address taken.  */
 	if (dyn_h->h == NULL)
 	  {
-	    bfd_put_64 (hppa_info->dlt_sec->owner,
-			value,
-			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
-
-	    /* Now handle .opd creation if needed.  */
+	    /* Now do .opd creation if needed.  */
 	    if (r_type == R_PARISC_LTOFF_FPTR14R
 		|| r_type == R_PARISC_LTOFF_FPTR14DR
 		|| r_type == R_PARISC_LTOFF_FPTR14WR
@@ -1638,7 +1735,7 @@
 			0, 16);
 
 		/* The next word is the address of the function.  */
-		bfd_put_64 (hppa_info->opd_sec->owner, value,
+		bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
 			    (hppa_info->opd_sec->contents
 			     + dyn_h->opd_offset + 16));
 
@@ -1648,7 +1745,17 @@
 		bfd_put_64 (hppa_info->opd_sec->owner, value,
 			    (hppa_info->opd_sec->contents
 			     + dyn_h->opd_offset + 24));
+
+		/* The DLT value is the address of the .opd entry.  */
+		value = (dyn_h->opd_offset
+			 + hppa_info->opd_sec->output_offset
+			 + hppa_info->opd_sec->output_section->vma);
+		addend = 0;
 	      }
+
+	    bfd_put_64 (hppa_info->dlt_sec->owner,
+			value + addend,
+			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
 	  }
 
 	/* We want the value of the DLT offset for this symbol, not
@@ -1666,7 +1773,7 @@
 	if (r_type == R_PARISC_DLTIND21L
 	    || r_type == R_PARISC_LTOFF_FPTR21L
 	    || r_type == R_PARISC_LTOFF_TP21L)
-	  value = hppa_field_adjust (value, addend, e_lrsel);
+	  value = hppa_field_adjust (value, 0, e_lsel);
 	else if (r_type == R_PARISC_DLTIND14F
 		 || r_type == R_PARISC_LTOFF_FPTR16F
 		 || r_type == R_PARISC_LTOFF_FPTR16WF
@@ -1677,9 +1784,9 @@
 		 || r_type == R_PARISC_LTOFF_TP16F
 		 || r_type == R_PARISC_LTOFF_TP16WF
 		 || r_type == R_PARISC_LTOFF_TP16DF)
-	  value = hppa_field_adjust (value, addend, e_fsel);
+	  value = hppa_field_adjust (value, 0, e_fsel);
 	else
-	  value = hppa_field_adjust (value, addend, e_rrsel);
+	  value = hppa_field_adjust (value, 0, e_rsel);
 
 	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
 	break;
@@ -1804,7 +1911,7 @@
 	    memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
 
 	    /* The next word is the address of the function.  */
-	    bfd_put_64 (hppa_info->opd_sec->owner, value,
+	    bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
 			(hppa_info->opd_sec->contents
 			 + dyn_h->opd_offset + 16));
 
@@ -1813,6 +1920,15 @@
 		      (hppa_info->opd_sec->output_section->owner);
 	    bfd_put_64 (hppa_info->opd_sec->owner, value,
 			hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
+
+	    /* The DLT value is the address of the .opd entry.  */
+	    value = (dyn_h->opd_offset
+		     + hppa_info->opd_sec->output_offset
+		     + hppa_info->opd_sec->output_section->vma);
+
+	    bfd_put_64 (hppa_info->dlt_sec->owner,
+			value,
+			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
 	  }
 
 	/* We want the value of the DLT offset for this symbol, not
@@ -1838,7 +1954,7 @@
 	    memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
 
 	    /* The next word is the address of the function.  */
-	    bfd_put_64 (hppa_info->opd_sec->owner, value,
+	    bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
 			(hppa_info->opd_sec->contents
 			 + dyn_h->opd_offset + 16));
 
@@ -1847,6 +1963,15 @@
 		      (hppa_info->opd_sec->output_section->owner);
 	    bfd_put_64 (hppa_info->opd_sec->owner, value,
 			hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
+
+	    /* The DLT value is the address of the .opd entry.  */
+	    value = (dyn_h->opd_offset
+		     + hppa_info->opd_sec->output_offset
+		     + hppa_info->opd_sec->output_section->vma);
+
+	    bfd_put_64 (hppa_info->dlt_sec->owner,
+			value,
+			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
 	  }
 
 	/* We want the value of the DLT offset for this symbol, not
@@ -1938,7 +2063,7 @@
 	    memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
 
 	    /* The next word is the address of the function.  */
-	    bfd_put_64 (hppa_info->opd_sec->owner, value,
+	    bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
 			(hppa_info->opd_sec->contents
 			 + dyn_h->opd_offset + 16));
 
@@ -1950,12 +2075,12 @@
 	  }
 
 	/* We want the value of the OPD offset for this symbol, not
-           the symbol's actual address.  */
+	   the symbol's actual address.  */
 	value = (dyn_h->opd_offset
 		 + hppa_info->opd_sec->output_offset
 		 + hppa_info->opd_sec->output_section->vma);
 
-	bfd_put_64 (input_bfd, value + addend, hit_data);
+	bfd_put_64 (input_bfd, value, hit_data);
 	return bfd_reloc_ok;
       }
 
@@ -1991,7 +2116,7 @@
 	  bfd_put_32 (input_bfd, value, hit_data);
 	else
 	  bfd_put_64 (input_bfd, value, hit_data);
-        return bfd_reloc_ok;
+	return bfd_reloc_ok;
       }
 
     /* Something we don't know how to handle.  */
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index e006ac2..ce68a16 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -111,6 +111,8 @@
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 static struct bfd_link_hash_table *elf32_mn10300_link_hash_table_create
   PARAMS ((bfd *));
+static void elf32_mn10300_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
 
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
@@ -709,6 +711,9 @@
 
   entry = (struct elf32_mn10300_link_hash_entry *) gen_entry;
 
+  if (entry->root.root.type == bfd_link_hash_warning)
+    entry = (struct elf32_mn10300_link_hash_entry *) entry->root.root.u.i.link;
+
   /* If we already know we want to convert "call" to "calls" for calls
      to this symbol, then return now.  */
   if (entry->flags == MN10300_CONVERT_CALL_TO_CALLS)
@@ -2966,37 +2971,52 @@
   struct elf32_mn10300_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf32_mn10300_link_hash_table);
 
-  ret = (struct elf32_mn10300_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf32_mn10300_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct elf32_mn10300_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       elf32_mn10300_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
   ret->flags = 0;
   amt = sizeof (struct elf_link_hash_table);
   ret->static_hash_table
-    = (struct elf32_mn10300_link_hash_table *) bfd_alloc (abfd, amt);
+    = (struct elf32_mn10300_link_hash_table *) bfd_malloc (amt);
   if (ret->static_hash_table == NULL)
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
   if (! _bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd,
 				       elf32_mn10300_link_hash_newfunc))
     {
-      bfd_release (abfd, ret->static_hash_table);
-      bfd_release (abfd, ret);
+      free (ret->static_hash_table);
+      free (ret);
       return NULL;
     }
   return &ret->root.root;
 }
 
+/* Free an mn10300 ELF linker hash table.  */
+
+static void
+elf32_mn10300_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash;
+{
+  struct elf32_mn10300_link_hash_table *ret
+    = (struct elf32_mn10300_link_hash_table *) hash;
+
+  _bfd_generic_link_hash_table_free
+    ((struct bfd_link_hash_table *) ret->static_hash_table);
+  _bfd_generic_link_hash_table_free
+    ((struct bfd_link_hash_table *) ret);
+}
+
 static unsigned long
 elf_mn10300_mach (flags)
      flagword flags;
@@ -3089,6 +3109,8 @@
 				mn10300_elf_get_relocated_section_contents
 #define bfd_elf32_bfd_link_hash_table_create \
 				elf32_mn10300_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_free \
+				elf32_mn10300_link_hash_table_free
 
 #define elf_symbol_leading_char '_'
 
diff --git a/bfd/elf.c b/bfd/elf.c
index 7f63b34..f8fdbd2 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -655,9 +655,9 @@
 
 		 Note - we used to check the p_paddr field as well, and
 		 refuse to set the LMA if it was 0.  This is wrong
-		 though as a perfectly valid, initialised segment can
+		 though, as a perfectly valid initialised segment can
 		 have a p_paddr of zero.  Some architectures, eg ARM,
-	         place special significance one the address 0 and
+	         place special significance on the address 0 and
 	         executables need to be able to have a segment which
 	         covers this address.  */
 	      if (phdr->p_type == PT_LOAD
@@ -665,19 +665,31 @@
 		  && (hdr->sh_offset + hdr->sh_size
 		      <= phdr->p_offset + phdr->p_memsz)
 		  && ((flags & SEC_LOAD) == 0
-		      || (phdr->p_offset + phdr->p_filesz
-			  >= hdr->sh_offset + hdr->sh_size)))
+		      || (hdr->sh_offset + hdr->sh_size
+			  <= phdr->p_offset + phdr->p_filesz)))
 		{
-		  /* We used to do a relative adjustment here, but
-		     that doesn't work if the segment is packed with
-		     code from multiple VMAs.  Instead we calculate
-		     the LMA absoultely, based on the LMA of the
-		     segment (it is assumed that the segment will
-		     contain sections with contiguous LMAs, even if
-		     the VMAs are not).  */
-		  newsect->lma = phdr->p_paddr
-		    + hdr->sh_offset - phdr->p_offset;
-		  break;
+		  if ((flags & SEC_LOAD) == 0)
+		    newsect->lma = (phdr->p_paddr
+				    + hdr->sh_addr - phdr->p_vaddr);
+		  else
+		    /* We used to use the same adjustment for SEC_LOAD
+		       sections, but that doesn't work if the segment
+		       is packed with code from multiple VMAs.
+		       Instead we calculate the section LMA based on
+		       the segment LMA.  It is assumed that the
+		       segment will contain sections with contiguous
+		       LMAs, even if the VMAs are not.  */
+		    newsect->lma = (phdr->p_paddr
+				    + hdr->sh_offset - phdr->p_offset);
+
+		  /* With contiguous segments, we can't tell from file
+		     offsets whether a section with zero size should
+		     be placed at the end of one segment or the
+		     beginning of the next.  Decide based on vaddr.  */
+		  if (hdr->sh_addr >= phdr->p_vaddr
+		      && (hdr->sh_addr + hdr->sh_size
+			  <= phdr->p_vaddr + phdr->p_memsz))
+		    break;
 		}
 	    }
 	}
@@ -1348,13 +1360,13 @@
   struct elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_link_hash_table);
 
-  ret = (struct elf_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct elf_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1563,6 +1575,9 @@
     case SHT_NOBITS:	/* .bss section.  */
     case SHT_HASH:	/* .hash section.  */
     case SHT_NOTE:	/* .note section.  */
+    case SHT_INIT_ARRAY:	/* .init_array section.  */
+    case SHT_FINI_ARRAY:	/* .fini_array section.  */
+    case SHT_PREINIT_ARRAY:	/* .preinit_array section.  */
       return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
 
     case SHT_SYMTAB:		/* A symbol table */
@@ -2177,6 +2192,12 @@
       this_hdr->sh_type = SHT_REL;
       this_hdr->sh_entsize = bed->s->sizeof_rel;
     }
+  else if (strcmp (asect->name, ".init_array") == 0)
+    this_hdr->sh_type = SHT_INIT_ARRAY;
+  else if (strcmp (asect->name, ".fini_array") == 0)
+    this_hdr->sh_type = SHT_FINI_ARRAY;
+  else if (strcmp (asect->name, ".preinit_array") == 0)
+    this_hdr->sh_type = SHT_PREINIT_ARRAY;
   else if (strncmp (asect->name, ".note", 5) == 0)
     this_hdr->sh_type = SHT_NOTE;
   else if (strncmp (asect->name, ".stab", 5) == 0
@@ -3860,7 +3881,6 @@
   Elf_Internal_Ehdr *i_ehdrp;	/* Elf file header, internal form */
   Elf_Internal_Phdr *i_phdrp = 0; /* Program header table, internal form */
   Elf_Internal_Shdr **i_shdrp;	/* Section header table, internal form */
-  int count;
   struct elf_strtab_hash *shstrtab;
   struct elf_backend_data *bed = get_elf_backend_data (abfd);
 
@@ -3883,12 +3903,6 @@
     bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
   i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
 
-  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_NONE;
-  i_ehdrp->e_ident[EI_ABIVERSION] = 0;
-
-  for (count = EI_PAD; count < EI_NIDENT; count++)
-    i_ehdrp->e_ident[count] = 0;
-
   if ((abfd->flags & DYNAMIC) != 0)
     i_ehdrp->e_type = ET_DYN;
   else if ((abfd->flags & EXEC_P) != 0)
@@ -5101,7 +5115,9 @@
   Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->symtab_hdr;
 
   symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
-  symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
+  symtab_size = (symcount + 1) * (sizeof (asymbol *));
+  if (symcount > 0)
+    symtab_size -= sizeof (asymbol *);
 
   return symtab_size;
 }
@@ -5121,7 +5137,9 @@
     }
 
   symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
-  symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
+  symtab_size = (symcount + 1) * (sizeof (asymbol *));
+  if (symcount > 0)
+    symtab_size -= sizeof (asymbol *);
 
   return symtab_size;
 }
@@ -6425,7 +6443,7 @@
   cp = strchr (note->namedata, '@');
   if (cp != NULL)
     {
-      *lwpidp = atoi(cp);
+      *lwpidp = atoi(cp + 1);
       return true;
     }
   return false;
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
index a452465..51c51a4 100644
--- a/bfd/elf32-arm.h
+++ b/bfd/elf32-arm.h
@@ -236,14 +236,14 @@
   struct elf32_arm_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
 
-  ret = (struct elf32_arm_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf32_arm_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct elf32_arm_link_hash_table *) NULL)
     return NULL;
 
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
 				      elf32_arm_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1390,7 +1390,7 @@
 	boolean        overflow = false;
 	bfd_vma        upper_insn = bfd_get_16 (input_bfd, hit_data);
 	bfd_vma        lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
-	bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
+	bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift;
 	bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
 	bfd_vma        check;
 	bfd_signed_vma signed_check;
@@ -1560,6 +1560,12 @@
       if (sgot == NULL)
         return bfd_reloc_notsupported;
 
+      /* If we are addressing a Thumb function, we need to adjust the 
+	 address by one, so that attempts to call the function pointer will
+	 correctly interpret it as Thumb code.  */
+      if (sym_flags == STT_ARM_TFUNC)
+	value += 1;
+
       /* Note that sgot->output_offset is not involved in this
          calculation.  We always want the start of .got.  If we
          define _GLOBAL_OFFSET_TABLE in a different way, as is
@@ -1612,6 +1618,13 @@
 		off &= ~1;
 	      else
 		{
+		  /* If we are addressing a Thumb function, we need to
+		     adjust the address by one, so that attempts to
+		     call the function pointer will correctly
+		     interpret it as Thumb code.  */
+		  if (sym_flags == STT_ARM_TFUNC)
+		    value |= 1;
+
 		  bfd_put_32 (output_bfd, value, sgot->contents + off);
 		  h->got.offset |= 1;
 		}
@@ -3275,6 +3288,9 @@
 {
   struct elf32_arm_pcrel_relocs_copied * s;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf32_arm_link_hash_entry *) h->root.root.u.i.link;
+
   /* 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;
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index ef8c951..ab72483 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -180,7 +180,7 @@
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_CRIS_16",		/* name */
+	 "R_CRIS_16_PCREL",	/* name */
 	 false,			/* partial_inplace */
 	 0x00000000,		/* src_mask */
 	 0x0000ffff,		/* dst_mask */
@@ -195,7 +195,7 @@
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
 	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_CRIS_32",		/* name */
+	 "R_CRIS_32_PCREL",	/* name */
 	 false,			/* partial_inplace */
 	 0x00000000,		/* src_mask */
 	 0xffffffff,		/* dst_mask */
@@ -710,14 +710,14 @@
   struct elf_cris_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
 
-  ret = ((struct elf_cris_link_hash_table *) bfd_alloc (abfd, amt));
+  ret = ((struct elf_cris_link_hash_table *) bfd_malloc (amt));
   if (ret == (struct elf_cris_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       elf_cris_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1930,6 +1930,9 @@
 
   BFD_ASSERT (dynobj != NULL);
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf_cris_link_hash_entry *) h->root.root.u.i.link;
+
   /* If nobody wanted a GOTPLT with this symbol, we're done.  */
   if (h->gotplt_refcount <= 0)
     return true;
@@ -1954,28 +1957,9 @@
 
       h->gotplt_refcount = -1;
 
-      /* We always have a .got section when there are dynamic
-	 relocs.  */
-      BFD_ASSERT (sgot != NULL /* Surely have .got section.  */);
-
-      /* We might have had a PLT but with no GOT entry and
-	 further no GOT reloc section at all needed before.
-	 Add it.  */
-      if (srelgot == NULL)
-	{
-	  srelgot = bfd_make_section (dynobj, ".rela.got");
-
-	  if (srelgot == NULL
-	      || !bfd_set_section_flags (dynobj, srelgot,
-					 (SEC_ALLOC
-					  | SEC_LOAD
-					  | SEC_HAS_CONTENTS
-					  | SEC_IN_MEMORY
-					  | SEC_LINKER_CREATED
-					  | SEC_READONLY))
-	      || !bfd_set_section_alignment (dynobj, srelgot, 2))
-	    return false;
-	}
+      /* We always have a .got and a .rela.got section if there were
+	 GOTPLT relocs in input.  */
+      BFD_ASSERT (sgot != NULL && srelgot != NULL);
 
       /* Allocate space in the .got section.  */
       sgot->_raw_size += 4;
@@ -2365,8 +2349,38 @@
 	 specific GOT entry).  */
       switch (r_type)
 	{
+	  /* For R_CRIS_16_GOTPLT and R_CRIS_32_GOTPLT, we need a GOT
+	     entry only for local symbols.  Unfortunately, we don't know
+	     until later on if there's a version script that forces the
+	     symbol local.  We must have the .rela.got section in place
+	     before we know if the symbol looks global now, so we need
+	     to treat the reloc just like for R_CRIS_16_GOT and
+	     R_CRIS_32_GOT.  */
+	case R_CRIS_16_GOTPLT:
+	case R_CRIS_32_GOTPLT:
 	case R_CRIS_16_GOT:
 	case R_CRIS_32_GOT:
+	  if (srelgot == NULL
+	      && (h != NULL || info->shared))
+	    {
+	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      if (srelgot == NULL)
+		{
+		  srelgot = bfd_make_section (dynobj, ".rela.got");
+		  if (srelgot == NULL
+		      || !bfd_set_section_flags (dynobj, srelgot,
+						 (SEC_ALLOC
+						  | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | SEC_LINKER_CREATED
+						  | SEC_READONLY))
+		      || !bfd_set_section_alignment (dynobj, srelgot, 2))
+		    return false;
+		}
+	    }
+	  /* Fall through.  */
+
 	case R_CRIS_32_GOTREL:
 	case R_CRIS_32_PLT_GOTREL:
 	  if (sgot == NULL)
@@ -2413,27 +2427,6 @@
 	case R_CRIS_16_GOT:
 	case R_CRIS_32_GOT:
 	  /* This symbol requires a global offset table entry.  */
-
-	  if (srelgot == NULL
-	      && (h != NULL || info->shared))
-	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-	      if (srelgot == NULL)
-		{
-		  srelgot = bfd_make_section (dynobj, ".rela.got");
-		  if (srelgot == NULL
-		      || !bfd_set_section_flags (dynobj, srelgot,
-						 (SEC_ALLOC
-						  | SEC_LOAD
-						  | SEC_HAS_CONTENTS
-						  | SEC_IN_MEMORY
-						  | SEC_LINKER_CREATED
-						  | SEC_READONLY))
-		      || !bfd_set_section_alignment (dynobj, srelgot, 2))
-		    return false;
-		}
-	    }
-
 	  if (h != NULL)
 	    {
 	      if (h->got.refcount == 0)
@@ -2881,6 +2874,9 @@
   struct elf_cris_pcrel_relocs_copied *s;
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf_cris_link_hash_entry *) h->root.root.u.i.link;
+
   /* If a symbol has been forced local or we have found a regular
      definition for the symbolic link case, then we won't be needing
      any relocs.  */
@@ -2906,6 +2902,9 @@
 {
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf_cris_link_hash_entry *) h->root.root.u.i.link;
+
   /* If we're not creating a shared library and have a symbol which is
      referred to by .got references, but the symbol is defined locally,
      (or rather, not referred to by a DSO and not defined by a DSO) then
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 5a65dcb..f0fd549 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -71,14 +71,14 @@
    (single sub-space version)
    :		addil LR'lt_ptr+ltoff,%dp	; get procedure entry point
    :		ldw RR'lt_ptr+ltoff(%r1),%r21
-   :            bv %r0(%r21)
+   :		bv %r0(%r21)
    :		ldw RR'lt_ptr+ltoff+4(%r1),%r19	; get new dlt value.
 
    Import stub to call shared library routine from shared library
    (single sub-space version)
    :		addil LR'ltoff,%r19		; get procedure entry point
    :		ldw RR'ltoff(%r1),%r21
-   :            bv %r0(%r21)
+   :		bv %r0(%r21)
    :		ldw RR'ltoff+4(%r1),%r19	; get new dlt value.
 
    Import stub to call shared library routine from normal object file
@@ -203,9 +203,6 @@
 #endif
   } *dyn_relocs;
 
-  /* Set during a static link if we detect a function is PIC.  */
-  unsigned int maybe_pic_call:1;
-
   /* Set if the only reason we need a .plt entry is for a non-PIC to
      PIC function call.  */
   unsigned int pic_call:1;
@@ -239,6 +236,12 @@
     asection *stub_sec;
   } *stub_group;
 
+  /* Assorted information used by elf32_hppa_size_stubs.  */
+  unsigned int bfd_count;
+  int top_index;
+  asection **input_list;
+  Elf_Internal_Sym **all_local_syms;
+
   /* Short-cuts to get to dynamic linker sections.  */
   asection *sgot;
   asection *srelgot;
@@ -255,10 +258,11 @@
   /* Whether we support multiple sub-spaces for shared libs.  */
   unsigned int multi_subspace:1;
 
-  /* Flags set when PCREL12F and PCREL17F branches detected.  Used to
+  /* Flags set when various size branches are detected.  Used to
      select suitable defaults for the stub group size.  */
   unsigned int has_12bit_branch:1;
   unsigned int has_17bit_branch:1;
+  unsigned int has_22bit_branch:1;
 
   /* Set if we need a .plt stub to support lazy dynamic linking.  */
   unsigned int need_plt_stub:1;
@@ -284,6 +288,9 @@
 static struct bfd_link_hash_table *elf32_hppa_link_hash_table_create
   PARAMS ((bfd *));
 
+static void elf32_hppa_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
+
 /* Stub handling functions.  */
 static char *hppa_stub_name
   PARAMS ((const asection *, const asection *,
@@ -358,6 +365,12 @@
 static boolean elf32_hppa_size_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 
+static void group_sections
+  PARAMS ((struct elf32_hppa_link_hash_table *, bfd_size_type, boolean));
+
+static int get_local_syms
+  PARAMS ((bfd *, bfd *, struct bfd_link_info *));
+
 static boolean elf32_hppa_final_link
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -373,9 +386,6 @@
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
 	   bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
 
-static int hppa_unwind_entry_compare
-  PARAMS ((const PTR, const PTR));
-
 static boolean elf32_hppa_finish_dynamic_symbol
   PARAMS ((bfd *, struct bfd_link_info *,
 	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
@@ -460,7 +470,6 @@
       eh = (struct elf32_hppa_link_hash_entry *) entry;
       eh->stub_cache = NULL;
       eh->dyn_relocs = NULL;
-      eh->maybe_pic_call = 0;
       eh->pic_call = 0;
       eh->plabel = 0;
     }
@@ -479,13 +488,13 @@
   struct elf32_hppa_link_hash_table *ret;
   bfd_size_type amt = sizeof (*ret);
 
-  ret = (struct elf32_hppa_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf32_hppa_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
   if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, hppa_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -508,12 +517,26 @@
   ret->multi_subspace = 0;
   ret->has_12bit_branch = 0;
   ret->has_17bit_branch = 0;
+  ret->has_22bit_branch = 0;
   ret->need_plt_stub = 0;
   ret->sym_sec.abfd = NULL;
 
   return &ret->elf.root;
 }
 
+/* Free the derived linker hash table.  */
+
+static void
+elf32_hppa_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash;
+{
+  struct elf32_hppa_link_hash_table *ret
+    = (struct elf32_hppa_link_hash_table *) hash;
+
+  bfd_hash_table_free (&ret->stub_hash_table);
+  _bfd_generic_link_hash_table_free (hash);
+}
+
 /* Build a name for an entry in the stub hash table.  */
 
 static char *
@@ -670,21 +693,12 @@
   unsigned int r_type;
 
   if (hash != NULL
-      && (((hash->elf.root.type == bfd_link_hash_defined
-	    || hash->elf.root.type == bfd_link_hash_defweak)
-	   && hash->elf.root.u.def.section->output_section == NULL)
-	  || (hash->elf.root.type == bfd_link_hash_defweak
-	      && hash->elf.dynindx != -1
-	      && hash->elf.plt.offset != (bfd_vma) -1)
-	  || hash->elf.root.type == bfd_link_hash_undefweak
-	  || hash->elf.root.type == bfd_link_hash_undefined
-	  || (hash->maybe_pic_call && !(input_sec->flags & SEC_HAS_GOT_REF))))
+      && hash->elf.plt.offset != (bfd_vma) -1
+      && (hash->elf.dynindx != -1 || hash->pic_call)
+      && !hash->plabel)
     {
-      /* If output_section is NULL, then it's a symbol defined in a
-	 shared library.  We will need an import stub.  Decide between
-	 hppa_stub_import and hppa_stub_import_shared later.  For
-	 shared links we need stubs for undefined or weak syms too;
-	 They will presumably be resolved by the dynamic linker.  */
+      /* We need an import stub.  Decide between hppa_stub_import
+	 and hppa_stub_import_shared later.  */
       return hppa_stub_import;
     }
 
@@ -742,6 +756,7 @@
 #define BE_SR0_R21	0xe2a00000	/* be    0(%sr0,%r21)		*/
 #define STW_RP		0x6bc23fd1	/* stw   %rp,-24(%sr0,%sp)	*/
 
+#define BL22_RP		0xe800a002	/* b,l,n XXX,%rp		*/
 #define BL_RP		0xe8400002	/* b,l,n XXX,%rp		*/
 #define NOP		0x08000240	/* nop				*/
 #define LDW_RP		0x4bc23fd1	/* ldw   -24(%sr0,%sp),%rp	*/
@@ -931,7 +946,9 @@
 		    + stub_sec->output_offset
 		    + stub_sec->output_section->vma);
 
-      if (sym_value - 8 + 0x40000 >= 0x80000)
+      if (sym_value - 8 + (1 << (17 + 1)) >= (1 << (17 + 2))
+	  && (!htab->has_22bit_branch
+	      || sym_value - 8 + (1 << (22 + 1)) >= (1 << (22 + 2))))
 	{
 	  (*_bfd_error_handler)
 	    (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
@@ -944,7 +961,10 @@
 	}
 
       val = hppa_field_adjust (sym_value, (bfd_signed_vma) -8, e_fsel) >> 2;
-      insn = hppa_rebuild_insn ((int) BL_RP, val, 17);
+      if (!htab->has_22bit_branch)
+	insn = hppa_rebuild_insn ((int) BL_RP, val, 17);
+      else
+	insn = hppa_rebuild_insn ((int) BL22_RP, val, 22);
       bfd_put_32 (stub_bfd, insn, loc);
 
       bfd_put_32 (stub_bfd, (bfd_vma) NOP,         loc + 4);
@@ -1263,12 +1283,16 @@
 
 	case R_PARISC_PCREL12F:
 	  htab->has_12bit_branch = 1;
-	  /* Fall thru.  */
+	  goto branch_common;
+
 	case R_PARISC_PCREL17C:
 	case R_PARISC_PCREL17F:
 	  htab->has_17bit_branch = 1;
-	  /* Fall thru.  */
+	  goto branch_common;
+
 	case R_PARISC_PCREL22F:
+	  htab->has_22bit_branch = 1;
+	branch_common:
 	  /* Function calls might need to go through the .plt, and
 	     might require long branch stubs.  */
 	  if (h == NULL)
@@ -1322,7 +1346,7 @@
 	case R_PARISC_DIR14F: /* Used for load/store from absolute locn.  */
 	case R_PARISC_DIR14R:
 	case R_PARISC_DIR21L: /* As above, and for ext branches too.  */
-#if 1
+#if 0
 	  /* Help debug shared library creation.  Any of the above
 	     relocs can be used in shared libs, but they may cause
 	     pages to become unshared.  */
@@ -1838,19 +1862,10 @@
   unsigned int power_of_two;
 
   /* If this is a function, put it in the procedure linkage table.  We
-     will fill in the contents of the procedure linkage table later,
-     when we know the address of the .got section.  */
+     will fill in the contents of the procedure linkage table later.  */
   if (h->type == STT_FUNC
       || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
     {
-      if (!info->shared
-	  && h->plt.refcount > 0
-	  && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
-	  && (h->root.u.def.section->flags & SEC_HAS_GOT_REF) != 0)
-	{
-	  ((struct elf32_hppa_link_hash_entry *) h)->maybe_pic_call = 1;
-	}
-
       if (h->plt.refcount <= 0
 	  || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
 	      && h->root.type != bfd_link_hash_defweak
@@ -1867,7 +1882,10 @@
 
 	  /* As a special sop to the hppa ABI, we keep a .plt entry
 	     for functions in sections containing PIC code.  */
-	  if (((struct elf32_hppa_link_hash_entry *) h)->maybe_pic_call)
+	  if (!info->shared
+	      && h->plt.refcount > 0
+	      && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+	      && (h->root.u.def.section->flags & SEC_HAS_GOT_REF) != 0)
 	    ((struct elf32_hppa_link_hash_entry *) h)->pic_call = 1;
 	  else
 	    {
@@ -1918,7 +1936,7 @@
     }
 
   /* If we didn't find any dynamic relocs in read-only sections, then
-     we'll be keeping the dynamic relocs and avoiding the copy reloc.  */ 
+     we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
   if (p == NULL)
     {
       h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
@@ -1982,6 +2000,9 @@
      struct elf_link_hash_entry *h;
      PTR inf ATTRIBUTE_UNUSED;
 {
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (! (h->plt.refcount > 0
 	 && (h->root.type == bfd_link_hash_defined
 	     || h->root.type == bfd_link_hash_defweak)
@@ -1993,7 +2014,6 @@
     }
 
   h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-  ((struct elf32_hppa_link_hash_entry *) h)->maybe_pic_call = 1;
   ((struct elf32_hppa_link_hash_entry *) h)->pic_call = 1;
 
   return true;
@@ -2011,16 +2031,19 @@
   struct elf32_hppa_link_hash_table *htab;
   asection *s;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = hppa_link_hash_table (info);
   if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
     {
       /* Make an entry in the .plt section for non-pic code that is
 	 calling pic code.  */
+      ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0;
       s = htab->splt;
       h->plt.offset = s->_raw_size;
       s->_raw_size += PLT_ENTRY_SIZE;
@@ -2040,7 +2063,11 @@
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
 	{
-	  /* Allocate these later.  */
+	  /* Allocate these later.  From this point on, h->plabel
+	     means that the plt entry is only used by a plabel.
+	     We'll be using a normal plt entry for this symbol, so
+	     clear the plabel indicator.  */
+	  ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0;
 	}
       else if (((struct elf32_hppa_link_hash_entry *) h)->plabel)
 	{
@@ -2080,16 +2107,18 @@
   struct elf32_hppa_link_hash_entry *eh;
   struct elf32_hppa_dyn_reloc_entry *p;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = hppa_link_hash_table (info);
   if (htab->elf.dynamic_sections_created
       && h->plt.offset != (bfd_vma) -1
       && !((struct elf32_hppa_link_hash_entry *) h)->pic_call
-      && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+      && !((struct elf32_hppa_link_hash_entry *) h)->plabel)
     {
       /* Make an entry in the .plt section.  */
       s = htab->splt;
@@ -2213,14 +2242,13 @@
      struct elf_link_hash_entry *h;
      struct bfd_link_info *info;
 {
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->type == STT_PARISC_MILLI
       && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
     {
       elf32_hppa_hide_symbol (info, h, true);
-
-      /* ?!? We only want to remove these from the dynamic symbol table.
-	 Therefore we do not leave ELF_LINK_FORCED_LOCAL set.  */
-      h->elf_link_hash_flags &= ~ELF_LINK_FORCED_LOCAL;
     }
   return true;
 }
@@ -2235,6 +2263,9 @@
   struct elf32_hppa_link_hash_entry *eh;
   struct elf32_hppa_dyn_reloc_entry *p;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   eh = (struct elf32_hppa_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
@@ -2525,57 +2556,25 @@
 
 /* External entry points for sizing and building linker stubs.  */
 
-/* Determine and set the size of the stub section for a final link.
+/* Set up various things so that we can make a list of input sections
+   for each output section included in the link.  Returns -1 on error,
+   0 when no stubs will be needed, and 1 on success. */
 
-   The basic idea here is to examine all the relocations looking for
-   PC-relative calls to a target that is unreachable with a "bl"
-   instruction.  */
-
-boolean
-elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
-		       add_stub_section, layout_sections_again)
+int
+elf32_hppa_setup_section_lists (output_bfd, info)
      bfd *output_bfd;
-     bfd *stub_bfd;
      struct bfd_link_info *info;
-     boolean multi_subspace;
-     bfd_signed_vma group_size;
-     asection * (*add_stub_section) PARAMS ((const char *, asection *));
-     void (*layout_sections_again) PARAMS ((void));
 {
   bfd *input_bfd;
+  unsigned int bfd_count;
+  int top_id, top_index;
   asection *section;
   asection **input_list, **list;
-  Elf_Internal_Sym *local_syms, **all_local_syms;
-  unsigned int bfd_indx, bfd_count;
-  int top_id, top_index;
-  struct elf32_hppa_link_hash_table *htab;
-  bfd_size_type stub_group_size;
-  boolean stubs_always_before_branch;
-  boolean stub_changed = 0;
-  boolean ret = 0;
   bfd_size_type amt;
+  struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
 
-  htab = hppa_link_hash_table (info);
-
-  /* Stash our params away.  */
-  htab->stub_bfd = stub_bfd;
-  htab->multi_subspace = multi_subspace;
-  htab->add_stub_section = add_stub_section;
-  htab->layout_sections_again = layout_sections_again;
-  stubs_always_before_branch = group_size < 0;
-  if (group_size < 0)
-    stub_group_size = -group_size;
-  else
-    stub_group_size = group_size;
-  if (stub_group_size == 1)
-    {
-      /* Default values.  */
-      stub_group_size = 7680000;
-      if (htab->has_17bit_branch || htab->multi_subspace)
-	stub_group_size = 240000;
-      if (htab->has_12bit_branch)
-	stub_group_size = 7500;
-    }
+  if (htab->elf.root.creator->flavour != bfd_target_elf_flavour)
+    return 0;
 
   /* Count the number of input BFDs and find the top input section id.  */
   for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
@@ -2591,16 +2590,14 @@
 	    top_id = section->id;
 	}
     }
+  htab->bfd_count = bfd_count;
 
   amt = sizeof (struct map_stub) * (top_id + 1);
   htab->stub_group = (struct map_stub *) bfd_zmalloc (amt);
   if (htab->stub_group == NULL)
-    return false;
+    return -1;
 
-  /* Make a list of input sections for each output section included in
-     the link.
-
-     We can't use output_bfd->section_count here to find the top output
+  /* We can't use output_bfd->section_count here to find the top output
      section index as some sections may have been removed, and
      _bfd_strip_section_from_output doesn't renumber the indices.  */
   for (section = output_bfd->sections, top_index = 0;
@@ -2611,10 +2608,12 @@
 	top_index = section->index;
     }
 
+  htab->top_index = top_index;
   amt = sizeof (asection *) * (top_index + 1);
   input_list = (asection **) bfd_malloc (amt);
+  htab->input_list = input_list;
   if (input_list == NULL)
-    return false;
+    return -1;
 
   /* For sections we aren't interested in, mark their entries with a
      value we can check later.  */
@@ -2631,40 +2630,50 @@
 	input_list[section->index] = NULL;
     }
 
-  /* Now actually build the lists.  */
-  for (input_bfd = info->input_bfds;
-       input_bfd != NULL;
-       input_bfd = input_bfd->link_next)
+  return 1;
+}
+
+/* The linker repeatedly calls this function for each input section,
+   in the order that input sections are linked into output sections.
+   Build lists of input sections to determine groupings between which
+   we may insert linker stubs.  */
+
+void
+elf32_hppa_next_input_section (info, isec)
+     struct bfd_link_info *info;
+     asection *isec;
+{
+  struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
+
+  if (isec->output_section->index <= htab->top_index)
     {
-      for (section = input_bfd->sections;
-	   section != NULL;
-	   section = section->next)
+      asection **list = htab->input_list + isec->output_section->index;
+      if (*list != bfd_abs_section_ptr)
 	{
-	  if (section->output_section != NULL
-	      && section->output_section->owner == output_bfd
-	      && section->output_section->index <= top_index)
-	    {
-	      list = input_list + section->output_section->index;
-	      if (*list != bfd_abs_section_ptr)
-		{
-		  /* Steal the link_sec pointer for our list.  */
+	  /* Steal the link_sec pointer for our list.  */
 #define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
-		  /* This happens to make the list in reverse order,
-		     which is what we want.  */
-		  PREV_SEC (section) = *list;
-		  *list = section;
-		}
-	    }
+	  /* This happens to make the list in reverse order,
+	     which is what we want.  */
+	  PREV_SEC (isec) = *list;
+	  *list = isec;
 	}
     }
+}
 
-  /* See whether we can group stub sections together.  Grouping stub
-     sections may result in fewer stubs.  More importantly, we need to
-     put all .init* and .fini* stubs at the beginning of the .init or
-     .fini output sections respectively, because glibc splits the
-     _init and _fini functions into multiple parts.  Putting a stub in
-     the middle of a function is not a good idea.  */
-  list = input_list + top_index;
+/* See whether we can group stub sections together.  Grouping stub
+   sections may result in fewer stubs.  More importantly, we need to
+   put all .init* and .fini* stubs at the beginning of the .init or
+   .fini output sections respectively, because glibc splits the
+   _init and _fini functions into multiple parts.  Putting a stub in
+   the middle of a function is not a good idea.  */
+
+static void
+group_sections (htab, stub_group_size, stubs_always_before_branch)
+     struct elf32_hppa_link_hash_table *htab;
+     bfd_size_type stub_group_size;
+     boolean stubs_always_before_branch;
+{
+  asection **list = htab->input_list + htab->top_index;
   do
     {
       asection *tail = *list;
@@ -2724,22 +2733,39 @@
 	  tail = prev;
 	}
     }
-  while (list-- != input_list);
-  free (input_list);
+  while (list-- != htab->input_list);
+  free (htab->input_list);
 #undef PREV_SEC
+}
+
+/* Read in all local syms for all input bfds, and create hash entries
+   for export stubs if we are building a multi-subspace shared lib.
+   Returns -1 on error, 1 if export stubs created, 0 otherwise.  */
+
+static int
+get_local_syms (output_bfd, input_bfd, info)
+     bfd *output_bfd;
+     bfd *input_bfd;
+     struct bfd_link_info *info;
+{
+  unsigned int bfd_indx;
+  Elf_Internal_Sym *local_syms, **all_local_syms;
+  int stub_changed = 0;
+  struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
 
   /* We want to read in symbol extension records only once.  To do this
      we need to read in the local symbols in parallel and save them for
      later use; so hold pointers to the local symbols in an array.  */
-  amt = sizeof (Elf_Internal_Sym *) * bfd_count;
+  bfd_size_type amt = sizeof (Elf_Internal_Sym *) * htab->bfd_count;
   all_local_syms = (Elf_Internal_Sym **) bfd_zmalloc (amt);
+  htab->all_local_syms = all_local_syms;
   if (all_local_syms == NULL)
-    return false;
+    return -1;
 
   /* Walk over all the input BFDs, swapping in local symbols.
      If we are creating a shared library, create hash entries for the
      export stubs.  */
-  for (input_bfd = info->input_bfds, bfd_indx = 0;
+  for (bfd_indx = 0;
        input_bfd != NULL;
        input_bfd = input_bfd->link_next, bfd_indx++)
     {
@@ -2761,21 +2787,21 @@
       sec_size *= sizeof (Elf_Internal_Sym);
       local_syms = (Elf_Internal_Sym *) bfd_malloc (sec_size);
       if (local_syms == NULL)
-	goto error_ret_free_local;
+	return -1;
 
       all_local_syms[bfd_indx] = local_syms;
       sec_size = symtab_hdr->sh_info;
       sec_size *= sizeof (Elf32_External_Sym);
       ext_syms = (Elf32_External_Sym *) bfd_malloc (sec_size);
       if (ext_syms == NULL)
-	goto error_ret_free_local;
+	return -1;
 
       if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
 	  || bfd_bread ((PTR) ext_syms, sec_size, input_bfd) != sec_size)
 	{
 	error_ret_free_ext_syms:
 	  free (ext_syms);
-	  goto error_ret_free_local;
+	  return -1;
 	}
 
       shndx_buf = NULL;
@@ -2858,7 +2884,7 @@
 		    {
 		      stub_entry = hppa_add_stub (stub_name, sec, htab);
 		      if (!stub_entry)
-			goto error_ret_free_local;
+			return -1;
 
 		      stub_entry->target_value = hash->elf.root.u.def.value;
 		      stub_entry->target_section = hash->elf.root.u.def.section;
@@ -2877,8 +2903,74 @@
 	}
     }
 
+  return stub_changed;
+}
+
+/* Determine and set the size of the stub section for a final link.
+
+   The basic idea here is to examine all the relocations looking for
+   PC-relative calls to a target that is unreachable with a "bl"
+   instruction.  */
+
+boolean
+elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
+		       add_stub_section, layout_sections_again)
+     bfd *output_bfd;
+     bfd *stub_bfd;
+     struct bfd_link_info *info;
+     boolean multi_subspace;
+     bfd_signed_vma group_size;
+     asection * (*add_stub_section) PARAMS ((const char *, asection *));
+     void (*layout_sections_again) PARAMS ((void));
+{
+  bfd_size_type stub_group_size;
+  boolean stubs_always_before_branch;
+  boolean stub_changed;
+  boolean ret = 0;
+  struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
+
+  /* Stash our params away.  */
+  htab->stub_bfd = stub_bfd;
+  htab->multi_subspace = multi_subspace;
+  htab->add_stub_section = add_stub_section;
+  htab->layout_sections_again = layout_sections_again;
+  stubs_always_before_branch = group_size < 0;
+  if (group_size < 0)
+    stub_group_size = -group_size;
+  else
+    stub_group_size = group_size;
+  if (stub_group_size == 1)
+    {
+      /* Default values.  */
+      stub_group_size = 7680000;
+      if (htab->has_17bit_branch || htab->multi_subspace)
+	stub_group_size = 240000;
+      if (htab->has_12bit_branch)
+	stub_group_size = 7500;
+    }
+
+  group_sections (htab, stub_group_size, stubs_always_before_branch);
+
+  switch (get_local_syms (output_bfd, info->input_bfds, info))
+    {
+    default:
+      if (htab->all_local_syms)
+	goto error_ret_free_local;
+      return false;
+
+    case 0:
+      stub_changed = false;
+      break;
+
+    case 1:
+      stub_changed = true;
+      break;
+    }
+
   while (1)
     {
+      bfd *input_bfd;
+      unsigned int bfd_indx;
       asection *stub_sec;
 
       for (input_bfd = info->input_bfds, bfd_indx = 0;
@@ -2886,13 +2978,15 @@
 	   input_bfd = input_bfd->link_next, bfd_indx++)
 	{
 	  Elf_Internal_Shdr *symtab_hdr;
+	  asection *section;
+	  Elf_Internal_Sym *local_syms;
 
 	  /* We'll need the symbol table in a second.  */
 	  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
 	  if (symtab_hdr->sh_info == 0)
 	    continue;
 
-	  local_syms = all_local_syms[bfd_indx];
+	  local_syms = htab->all_local_syms[bfd_indx];
 
 	  /* Walk over each section attached to the input bfd.  */
 	  for (section = input_bfd->sections;
@@ -2902,6 +2996,7 @@
 	      Elf_Internal_Shdr *input_rel_hdr;
 	      Elf32_External_Rela *external_relocs, *erelaend, *erela;
 	      Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
+	      bfd_size_type amt;
 
 	      /* If there aren't any relocs, then there's nothing more
 		 to do.  */
@@ -3033,19 +3128,9 @@
 					   + sym_sec->output_section->vma);
 			}
 		      else if (hash->elf.root.type == bfd_link_hash_undefweak)
-			{
-			  if (! info->shared)
-			    continue;
-			}
+			;
 		      else if (hash->elf.root.type == bfd_link_hash_undefined)
-			{
-			  if (! (info->shared
-				 && !info->no_undefined
-				 && (ELF_ST_VISIBILITY (hash->elf.other)
-				     == STV_DEFAULT)
-				 && hash->elf.type != STT_PARISC_MILLI))
-			    continue;
-			}
+			;
 		      else
 			{
 			  bfd_set_error (bfd_error_bad_value);
@@ -3095,7 +3180,7 @@
 			stub_entry->stub_type = hppa_stub_long_branch_shared;
 		    }
 		  stub_entry->h = hash;
-		  stub_changed = 1;
+		  stub_changed = true;
 		}
 
 	      /* We're done with the internal relocs, free them.  */
@@ -3120,16 +3205,16 @@
 
       /* Ask the linker to do its stuff.  */
       (*htab->layout_sections_again) ();
-      stub_changed = 0;
+      stub_changed = false;
     }
 
-  ret = 1;
+  ret = true;
 
  error_ret_free_local:
-  while (bfd_count-- > 0)
-    if (all_local_syms[bfd_count])
-      free (all_local_syms[bfd_count]);
-  free (all_local_syms);
+  while (htab->bfd_count-- > 0)
+    if (htab->all_local_syms[htab->bfd_count])
+      free (htab->all_local_syms[htab->bfd_count]);
+  free (htab->all_local_syms);
 
   return ret;
 }
@@ -3142,23 +3227,39 @@
      bfd *abfd;
      struct bfd_link_info *info;
 {
+  struct bfd_link_hash_entry *h;
+  asection *sec = NULL;
+  bfd_vma gp_val = 0;
   struct elf32_hppa_link_hash_table *htab;
-  struct elf_link_hash_entry *h;
-  asection *sec;
-  bfd_vma gp_val;
 
   htab = hppa_link_hash_table (info);
-  h = elf_link_hash_lookup (&htab->elf, "$global$", false, false, false);
+  h = bfd_link_hash_lookup (&htab->elf.root, "$global$", false, false, false);
 
   if (h != NULL
-      && (h->root.type == bfd_link_hash_defined
-	  || h->root.type == bfd_link_hash_defweak))
+      && (h->type == bfd_link_hash_defined
+	  || h->type == bfd_link_hash_defweak))
     {
-      gp_val = h->root.u.def.value;
-      sec = h->root.u.def.section;
+      gp_val = h->u.def.value;
+      sec = h->u.def.section;
     }
   else
     {
+      asection *splt;
+      asection *sgot;
+
+      if (htab->elf.root.creator->flavour == bfd_target_elf_flavour)
+	{
+	  splt = htab->splt;
+	  sgot = htab->sgot;
+	}
+      else
+	{
+	  /* If we're not elf, look up the output sections in the
+	     hope we may actually find them.  */
+	  splt = bfd_get_section_by_name (abfd, ".plt");
+	  sgot = bfd_get_section_by_name (abfd, ".got");
+	}
+
       /* Choose to point our LTP at, in this order, one of .plt, .got,
 	 or .data, if these sections exist.  In the case of choosing
 	 .plt try to make the LTP ideal for addressing anywhere in the
@@ -3167,21 +3268,18 @@
 	 if either the .plt or .got is larger than 0x2000.  If both
 	 the .plt and .got are smaller than 0x2000, choose the end of
 	 the .plt section.  */
-
-      sec = htab->splt;
+      sec = splt;
       if (sec != NULL)
 	{
 	  gp_val = sec->_raw_size;
-	  if (gp_val > 0x2000
-	      || (htab->sgot && htab->sgot->_raw_size > 0x2000))
+	  if (gp_val > 0x2000 || (sgot && sgot->_raw_size > 0x2000))
 	    {
 	      gp_val = 0x2000;
 	    }
 	}
       else
 	{
-	  gp_val = 0;
-	  sec = htab->sgot;
+	  sec = sgot;
 	  if (sec != NULL)
 	    {
 	      /* We know we don't have a .plt.  If .got is large,
@@ -3198,12 +3296,12 @@
 
       if (h != NULL)
 	{
-	  h->root.type = bfd_link_hash_defined;
-	  h->root.u.def.value = gp_val;
+	  h->type = bfd_link_hash_defined;
+	  h->u.def.value = gp_val;
 	  if (sec != NULL)
-	    h->root.u.def.section = sec;
+	    h->u.def.section = sec;
 	  else
-	    h->root.u.def.section = bfd_abs_section_ptr;
+	    h->u.def.section = bfd_abs_section_ptr;
 	}
     }
 
@@ -3258,37 +3356,13 @@
      bfd *abfd;
      struct bfd_link_info *info;
 {
-  asection *s;
-
   /* Invoke the regular ELF linker to do all the work.  */
   if (!bfd_elf32_bfd_final_link (abfd, info))
     return false;
 
   /* If we're producing a final executable, sort the contents of the
-     unwind section.  Magic section names, but this is much safer than
-     having elf32_hppa_relocate_section remember where SEGREL32 relocs
-     occurred.  Consider what happens if someone inept creates a
-     linker script that puts unwind information in .text.  */
-  s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
-  if (s != NULL)
-    {
-      bfd_size_type size;
-      char *contents;
-
-      size = s->_raw_size;
-      contents = bfd_malloc (size);
-      if (contents == NULL)
-	return false;
-
-      if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size))
-	return false;
-
-      qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
-
-      if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
-	return false;
-    }
-  return true;
+     unwind section.  */
+  return elf_hppa_sort_unwind (abfd);
 }
 
 /* Record the lowest address for the data and text segments.  */
@@ -3361,19 +3435,14 @@
     case R_PARISC_PCREL12F:
     case R_PARISC_PCREL17F:
     case R_PARISC_PCREL22F:
-      /* If this is a call to a function defined in another dynamic
-	 library, or if it is a call to a PIC function in the same
-	 object, or if this is a shared link and it is a call to a
-	 weak symbol which may or may not be in the same object, then
-	 find the import stub in the stub hash.  */
+      /* If this call should go via the plt, find the import stub in
+	 the stub hash.  */
       if (sym_sec == NULL
 	  || sym_sec->output_section == NULL
 	  || (h != NULL
-	      && ((h->maybe_pic_call
-		   && !(input_section->flags & SEC_HAS_GOT_REF))
-		  || (h->elf.root.type == bfd_link_hash_defweak
-		      && h->elf.dynindx != -1
-		      && h->elf.plt.offset != (bfd_vma) -1))))
+	      && h->elf.plt.offset != (bfd_vma) -1
+	      && (h->elf.dynindx != -1 || h->pic_call)
+	      && !h->plabel))
 	{
 	  stub_entry = hppa_get_stub_entry (input_section, sym_sec,
 					    h, rel, htab);
@@ -3428,7 +3497,7 @@
 	      == (((int) OP_ADDIL << 26) | (27 << 21)))
 	    {
 	      insn &= ~ (0x1f << 21);
-#if 1 /* debug them.  */
+#if 0 /* debug them.  */
 	      (*_bfd_error_handler)
 		(_("%s(%s+0x%lx): fixing %s"),
 		 bfd_archive_filename (input_bfd),
@@ -3475,21 +3544,27 @@
       r_field = e_fsel;
       break;
 
-    case R_PARISC_DIR21L:
-    case R_PARISC_PCREL21L:
-    case R_PARISC_DPREL21L:
-    case R_PARISC_PLABEL21L:
     case R_PARISC_DLTIND21L:
+    case R_PARISC_PCREL21L:
+    case R_PARISC_PLABEL21L:
+      r_field = e_lsel;
+      break;
+
+    case R_PARISC_DIR21L:
+    case R_PARISC_DPREL21L:
       r_field = e_lrsel;
       break;
 
-    case R_PARISC_DIR17R:
     case R_PARISC_PCREL17R:
-    case R_PARISC_DIR14R:
     case R_PARISC_PCREL14R:
-    case R_PARISC_DPREL14R:
     case R_PARISC_PLABEL14R:
     case R_PARISC_DLTIND14R:
+      r_field = e_rsel;
+      break;
+
+    case R_PARISC_DIR17R:
+    case R_PARISC_DIR14R:
+    case R_PARISC_DPREL14R:
       r_field = e_rrsel;
       break;
 
@@ -4093,32 +4168,6 @@
   return true;
 }
 
-/* Comparison function for qsort to sort unwind section during a
-   final link.  */
-
-static int
-hppa_unwind_entry_compare (a, b)
-     const PTR a;
-     const PTR b;
-{
-  const bfd_byte *ap, *bp;
-  unsigned long av, bv;
-
-  ap = (const bfd_byte *) a;
-  av = (unsigned long) ap[0] << 24;
-  av |= (unsigned long) ap[1] << 16;
-  av |= (unsigned long) ap[2] << 8;
-  av |= (unsigned long) ap[3];
-
-  bp = (const bfd_byte *) b;
-  bv = (unsigned long) bp[0] << 24;
-  bv |= (unsigned long) bp[1] << 16;
-  bv |= (unsigned long) bp[2] << 8;
-  bv |= (unsigned long) bp[3];
-
-  return av < bv ? -1 : av > bv ? 1 : 0;
-}
-
 /* Finish up dynamic symbol handling.  We set the contents of various
    dynamic sections here.  */
 
@@ -4462,6 +4511,7 @@
 /* Stuff for the BFD linker.  */
 #define bfd_elf32_bfd_final_link	     elf32_hppa_final_link
 #define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_free   elf32_hppa_link_hash_table_free
 #define elf_backend_add_symbol_hook	     elf32_hppa_add_symbol_hook
 #define elf_backend_adjust_dynamic_symbol    elf32_hppa_adjust_dynamic_symbol
 #define elf_backend_copy_indirect_symbol     elf32_hppa_copy_indirect_symbol
diff --git a/bfd/elf32-hppa.h b/bfd/elf32-hppa.h
index ea680c3..720cd08 100644
--- a/bfd/elf32-hppa.h
+++ b/bfd/elf32-hppa.h
@@ -36,6 +36,12 @@
 #include "libhppa.h"
 #include "elf/hppa.h"
 
+int elf32_hppa_setup_section_lists
+  PARAMS ((bfd *, struct bfd_link_info *));
+
+void elf32_hppa_next_input_section
+  PARAMS ((struct bfd_link_info *, asection *));
+
 boolean elf32_hppa_size_stubs
   PARAMS ((bfd *, bfd *, struct bfd_link_info *, boolean, bfd_signed_vma,
 	   asection * (*) PARAMS ((const char *, asection *)),
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index aa9cd39..07d5f9d 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -1,5 +1,5 @@
 /* i370-specific support for 32-bit ELF
-   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001
+   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
    Hacked by Linas Vepstas for i370 linas@linas.org
@@ -736,6 +736,9 @@
 	   h->dynindx, *cp);
 #endif
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->dynindx != -1)
     h->dynindx += *cp;
 
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7e6588c..7165e84 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1,5 +1,5 @@
 /* Intel 80386/80486-specific support for 32-bit ELF
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -547,13 +547,13 @@
   struct elf_i386_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_i386_link_hash_table);
 
-  ret = (struct elf_i386_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf_i386_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -847,11 +847,10 @@
 		{
 		  const char *name;
 		  bfd *dynobj;
+		  unsigned int strndx = elf_elfheader (abfd)->e_shstrndx;
+		  unsigned int shnam = elf_section_data (sec)->rel_hdr.sh_name;
 
-		  name = (bfd_elf_string_from_elf_section
-			  (abfd,
-			   elf_elfheader (abfd)->e_shstrndx,
-			   elf_section_data (sec)->rel_hdr.sh_name));
+		  name = bfd_elf_string_from_elf_section (abfd, strndx, shnam);
 		  if (name == NULL)
 		    return false;
 
@@ -1251,10 +1250,15 @@
   struct elf_i386_link_hash_entry *eh;
   struct elf_i386_dyn_relocs *p;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    /* When warning symbols are created, they **replace** the "real"
+       entry in the hash table, thus we never get to see the real
+       symbol in a hash traversal.  So look at it now.  */
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = elf_i386_hash_table (info);
 
@@ -1421,6 +1425,9 @@
   struct elf_i386_link_hash_entry *eh;
   struct elf_i386_dyn_relocs *p;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   eh = (struct elf_i386_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 1ce1827..b3b6220 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -838,7 +838,8 @@
 {
   if (! info->relocateable
       && (*namep)[0] == '_' && (*namep)[1] == 'S'
-      && strcmp (*namep, "_SDA_BASE_") == 0)
+      && strcmp (*namep, "_SDA_BASE_") == 0
+      && info->hash->creator->flavour == bfd_target_elf_flavour)
     {
       /* This is simpler than using _bfd_elf_create_linker_section
 	 (our needs are simpler than ppc's needs).  Also
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 1fb6844..9267e47 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -1,5 +1,5 @@
 /* Motorola 68k series support for 32-bit ELF
-   Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -340,14 +340,14 @@
   struct elf_m68k_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_m68k_link_hash_table);
 
-  ret = (struct elf_m68k_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf_m68k_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct elf_m68k_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       elf_m68k_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1271,6 +1271,9 @@
 {
   struct elf_m68k_pcrel_relocs_copied *s;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf_m68k_link_hash_entry *) h->root.root.u.i.link;
+
   /* 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;
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index d52e5d20..1e6cf6f 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -35,6 +35,7 @@
 #include "bfdlink.h"
 #include "genlink.h"
 #include "elf-bfd.h"
+#include "elfxx-mips.h"
 #include "elf/mips.h"
 
 /* Get the ECOFF swapping routines.  */
@@ -46,203 +47,50 @@
 #define ECOFF_SIGNED_32
 #include "ecoffswap.h"
 
-/* This structure is used to hold .got information when linking.  It
-   is stored in the tdata field of the bfd_elf_section_data structure.  */
-
-struct mips_got_info
-{
-  /* The global symbol in the GOT with the lowest index in the dynamic
-     symbol table.  */
-  struct elf_link_hash_entry *global_gotsym;
-  /* The number of global .got entries.  */
-  unsigned int global_gotno;
-  /* The number of local .got entries.  */
-  unsigned int local_gotno;
-  /* The number of local .got entries we have used.  */
-  unsigned int assigned_gotno;
-};
-
-/* The MIPS ELF linker needs additional information for each symbol in
-   the global hash table.  */
-
-struct mips_elf_link_hash_entry
-{
-  struct elf_link_hash_entry root;
-
-  /* External symbol information.  */
-  EXTR esym;
-
-  /* Number of R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 relocs against
-     this symbol.  */
-  unsigned int possibly_dynamic_relocs;
-
-  /* If the R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 reloc is against
-     a readonly section.  */
-  boolean readonly_reloc;
-
-  /* The index of the first dynamic relocation (in the .rel.dyn
-     section) against this symbol.  */
-  unsigned int min_dyn_reloc_index;
-
-  /* We must not create a stub for a symbol that has relocations
-     related to taking the function's address, i.e. any but
-     R_MIPS_CALL*16 ones -- see "MIPS ABI Supplement, 3rd Edition",
-     p. 4-20.  */
-  boolean no_fn_stub;
-
-  /* If there is a stub that 32 bit functions should use to call this
-     16 bit function, this points to the section containing the stub.  */
-  asection *fn_stub;
-
-  /* Whether we need the fn_stub; this is set if this symbol appears
-     in any relocs other than a 16 bit call.  */
-  boolean need_fn_stub;
-
-  /* If there is a stub that 16 bit functions should use to call this
-     32 bit function, this points to the section containing the stub.  */
-  asection *call_stub;
-
-  /* This is like the call_stub field, but it is used if the function
-     being called returns a floating point value.  */
-  asection *call_fp_stub;
-};
-
+static bfd_reloc_status_type mips_elf_hi16_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type mips_elf_lo16_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type mips_elf_got16_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type mips_elf_gprel32_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type mips32_64bit_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
-static reloc_howto_type *mips_rtype_to_howto
-  PARAMS ((unsigned int));
+static reloc_howto_type *mips_elf32_rtype_to_howto
+  PARAMS ((unsigned int, boolean));
 static void mips_info_to_howto_rel
   PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
 static void mips_info_to_howto_rela
   PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
-static void bfd_mips_elf32_swap_gptab_in
-  PARAMS ((bfd *, const Elf32_External_gptab *, Elf32_gptab *));
-static void bfd_mips_elf32_swap_gptab_out
-  PARAMS ((bfd *, const Elf32_gptab *, Elf32_External_gptab *));
-#if 0
-static void bfd_mips_elf_swap_msym_in
-  PARAMS ((bfd *, const Elf32_External_Msym *, Elf32_Internal_Msym *));
-#endif
-static void bfd_mips_elf_swap_msym_out
-  PARAMS ((bfd *, const Elf32_Internal_Msym *, Elf32_External_Msym *));
 static boolean mips_elf_sym_is_global PARAMS ((bfd *, asymbol *));
-static boolean mips_elf_create_procedure_table
-  PARAMS ((PTR, bfd *, struct bfd_link_info *, asection *,
-	   struct ecoff_debug_info *));
-static INLINE int elf_mips_isa PARAMS ((flagword));
-static INLINE unsigned long elf_mips_mach PARAMS ((flagword));
-static INLINE char* elf_mips_abi_name PARAMS ((bfd *));
+static boolean mips_elf32_object_p PARAMS ((bfd *));
 static boolean mips_elf_is_local_label_name
   PARAMS ((bfd *, const char *));
-static struct bfd_hash_entry *mips_elf_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static int gptab_compare PARAMS ((const void *, const void *));
 static bfd_reloc_status_type mips16_jump_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type mips16_gprel_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static boolean mips_elf_create_compact_rel_section
-  PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf_create_got_section
-  PARAMS ((bfd *, struct bfd_link_info *));
 static bfd_reloc_status_type mips_elf_final_gp
   PARAMS ((bfd *, asymbol *, boolean, char **, bfd_vma *));
-static bfd_byte *elf32_mips_get_relocated_section_contents
-  PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
-	   bfd_byte *, boolean, asymbol **));
-static asection *mips_elf_create_msym_section
-  PARAMS ((bfd *));
-static void mips_elf_irix6_finish_dynamic_symbol
-  PARAMS ((bfd *, const char *, Elf_Internal_Sym *));
-static bfd_vma mips_elf_sign_extend PARAMS ((bfd_vma, int));
-static boolean mips_elf_overflow_p PARAMS ((bfd_vma, int));
-static bfd_vma mips_elf_high PARAMS ((bfd_vma));
-static bfd_vma mips_elf_higher PARAMS ((bfd_vma));
-static bfd_vma mips_elf_highest PARAMS ((bfd_vma));
-static bfd_vma mips_elf_global_got_index
-  PARAMS ((bfd *, struct elf_link_hash_entry *));
-static bfd_vma mips_elf_local_got_index
-  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma));
-static bfd_vma mips_elf_got_offset_from_index
-  PARAMS ((bfd *, bfd *, bfd_vma));
-static boolean mips_elf_record_global_got_symbol
-  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *,
-	   struct mips_got_info *));
-static bfd_vma mips_elf_got_page
-  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, bfd_vma *));
-static const Elf_Internal_Rela *mips_elf_next_relocation
-  PARAMS ((unsigned int, const Elf_Internal_Rela *,
-	   const Elf_Internal_Rela *));
-static bfd_reloc_status_type mips_elf_calculate_relocation
-  PARAMS ((bfd *, bfd *, asection *, struct bfd_link_info *,
-	   const Elf_Internal_Rela *, bfd_vma, reloc_howto_type *,
-	   Elf_Internal_Sym *, asection **, bfd_vma *, const char **,
-	   boolean *));
-static bfd_vma mips_elf_obtain_contents
-  PARAMS ((reloc_howto_type *, const Elf_Internal_Rela *, bfd *, bfd_byte *));
-static boolean mips_elf_perform_relocation
-  PARAMS ((struct bfd_link_info *, reloc_howto_type *,
-	   const Elf_Internal_Rela *, bfd_vma,
-	   bfd *, asection *, bfd_byte *, boolean));
 static boolean mips_elf_assign_gp PARAMS ((bfd *, bfd_vma *));
-static boolean mips_elf_sort_hash_table_f
-  PARAMS ((struct mips_elf_link_hash_entry *, PTR));
-static boolean mips_elf_sort_hash_table
-  PARAMS ((struct bfd_link_info *, unsigned long));
-static asection * mips_elf_got_section PARAMS ((bfd *));
-static struct mips_got_info *mips_elf_got_info
-  PARAMS ((bfd *, asection **));
-static boolean mips_elf_local_relocation_p
-  PARAMS ((bfd *, const Elf_Internal_Rela *, asection **, boolean));
-static bfd_vma mips_elf_create_local_got_entry
-  PARAMS ((bfd *, struct mips_got_info *, asection *, bfd_vma));
-static bfd_vma mips_elf_got16_entry
-  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, boolean));
-static boolean mips_elf_create_dynamic_relocation
-  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Rela *,
-	   struct mips_elf_link_hash_entry *, asection *,
-	   bfd_vma, bfd_vma *, asection *));
-static void mips_elf_allocate_dynamic_relocations
-  PARAMS ((bfd *, unsigned int));
-static boolean mips_elf_stub_section_p
-  PARAMS ((bfd *, asection *));
-static int sort_dynamic_relocs
-  PARAMS ((const void *, const void *));
-static void _bfd_mips_elf_hide_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
-static void _bfd_mips_elf_copy_indirect_symbol
-  PARAMS ((struct elf_link_hash_entry *,
-	   struct elf_link_hash_entry *));
-static boolean _bfd_elf32_mips_grok_prstatus
+static boolean elf32_mips_grok_prstatus
   PARAMS ((bfd *, Elf_Internal_Note *));
-static boolean _bfd_elf32_mips_grok_psinfo
+static boolean elf32_mips_grok_psinfo
   PARAMS ((bfd *, Elf_Internal_Note *));
-static boolean _bfd_elf32_mips_discard_info
+static boolean elf32_mips_discard_info
   PARAMS ((bfd *, struct elf_reloc_cookie *, struct bfd_link_info *));
-static boolean _bfd_elf32_mips_ignore_discarded_relocs
+static boolean elf32_mips_ignore_discarded_relocs
   PARAMS ((asection *));
-static boolean _bfd_elf32_mips_write_section
+static boolean elf32_mips_write_section
   PARAMS ((bfd *, asection *, bfd_byte *));
+static irix_compat_t elf32_mips_irix_compat
+  PARAMS ((bfd *));
 
 extern const bfd_target bfd_elf32_tradbigmips_vec;
 extern const bfd_target bfd_elf32_tradlittlemips_vec;
-#ifdef BFD64
-extern const bfd_target bfd_elf64_tradbigmips_vec;
-extern const bfd_target bfd_elf64_tradlittlemips_vec;
-#endif
-
-/* The level of IRIX compatibility we're striving for.  */
-
-typedef enum {
-  ict_none,
-  ict_irix5,
-  ict_irix6
-} irix_compat_t;
-
-/* This will be used when we sort the dynamic relocation records.  */
-static bfd *reldyn_sorting_bfd;
 
 /* Nonzero if ABFD is using the N32 ABI.  */
 
@@ -253,107 +101,19 @@
 #define ABI_64_P(abfd) \
   ((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0)
 
-/* Depending on the target vector we generate some version of Irix
-   executables or "normal" MIPS ELF ABI executables.  */
-#ifdef BFD64
-#define IRIX_COMPAT(abfd) \
-  (((abfd->xvec == &bfd_elf64_tradbigmips_vec) || \
-    (abfd->xvec == &bfd_elf64_tradlittlemips_vec) || \
-    (abfd->xvec == &bfd_elf32_tradbigmips_vec) || \
-    (abfd->xvec == &bfd_elf32_tradlittlemips_vec)) ? ict_none : \
-  ((ABI_N32_P (abfd) || ABI_64_P (abfd)) ? ict_irix6 : ict_irix5))
-#else
-#define IRIX_COMPAT(abfd) \
-  (((abfd->xvec == &bfd_elf32_tradbigmips_vec) || \
-    (abfd->xvec == &bfd_elf32_tradlittlemips_vec)) ? ict_none : \
-  ((ABI_N32_P (abfd) || ABI_64_P (abfd)) ? ict_irix6 : ict_irix5))
-#endif
-
-#define NEWABI_P(abfd) (ABI_N32_P(abfd) || ABI_64_P(abfd))
+#define NEWABI_P(abfd) (ABI_N32_P (abfd) || ABI_64_P (abfd))
 
 /* Whether we are trying to be compatible with IRIX at all.  */
 #define SGI_COMPAT(abfd) \
-  (IRIX_COMPAT (abfd) != ict_none)
-
-/* The name of the msym section.  */
-#define MIPS_ELF_MSYM_SECTION_NAME(abfd) ".msym"
-
-/* The name of the srdata section.  */
-#define MIPS_ELF_SRDATA_SECTION_NAME(abfd) ".srdata"
-
-/* The name of the options section.  */
-#define MIPS_ELF_OPTIONS_SECTION_NAME(abfd) \
-  (IRIX_COMPAT (abfd) == ict_irix6 ? ".MIPS.options" : ".options")
-
-/* The name of the stub section.  */
-#define MIPS_ELF_STUB_SECTION_NAME(abfd) \
-  (IRIX_COMPAT (abfd) == ict_irix6 ? ".MIPS.stubs" : ".stub")
-
-/* The name of the dynamic relocation section.  */
-#define MIPS_ELF_REL_DYN_SECTION_NAME(abfd) ".rel.dyn"
+  (elf32_mips_irix_compat (abfd) != ict_none)
 
 /* The size of an external REL relocation.  */
 #define MIPS_ELF_REL_SIZE(abfd) \
   (get_elf_backend_data (abfd)->s->sizeof_rel)
 
-/* The size of an external dynamic table entry.  */
-#define MIPS_ELF_DYN_SIZE(abfd) \
-  (get_elf_backend_data (abfd)->s->sizeof_dyn)
-
-/* The size of a GOT entry.  */
-#define MIPS_ELF_GOT_SIZE(abfd) \
-  (get_elf_backend_data (abfd)->s->arch_size / 8)
-
-/* The size of a symbol-table entry.  */
-#define MIPS_ELF_SYM_SIZE(abfd) \
-  (get_elf_backend_data (abfd)->s->sizeof_sym)
-
-/* The default alignment for sections, as a power of two.  */
-#define MIPS_ELF_LOG_FILE_ALIGN(abfd)				\
-  (get_elf_backend_data (abfd)->s->file_align == 8 ? 3 : 2)
-
-/* Get word-sized data.  */
-#define MIPS_ELF_GET_WORD(abfd, ptr) \
-  (ABI_64_P (abfd) ? bfd_get_64 (abfd, ptr) : bfd_get_32 (abfd, ptr))
-
-/* Put out word-sized data.  */
-#define MIPS_ELF_PUT_WORD(abfd, val, ptr)	\
-  (ABI_64_P (abfd) 				\
-   ? bfd_put_64 (abfd, val, ptr) 		\
-   : bfd_put_32 (abfd, val, ptr))
-
-/* Add a dynamic symbol table-entry.  */
-#ifdef BFD64
-#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val)			\
-  (ABI_64_P (elf_hash_table (info)->dynobj)				\
-   ? bfd_elf64_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val)	\
-   : bfd_elf32_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
-#else
-#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val)			\
-  (ABI_64_P (elf_hash_table (info)->dynobj)				\
-   ? (boolean) (abort (), false)					\
-   : bfd_elf32_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
-#endif
-
 /* The number of local .got entries we reserve.  */
 #define MIPS_RESERVED_GOTNO (2)
 
-/* Instructions which appear in a stub.  For some reason the stub is
-   slightly different on an SGI system.  */
-#define ELF_MIPS_GP_OFFSET(abfd) (SGI_COMPAT (abfd) ? 0x7ff0 : 0x8000)
-#define STUB_LW(abfd)						\
-  (SGI_COMPAT (abfd)						\
-   ? (ABI_64_P (abfd)  						\
-      ? 0xdf998010		/* ld t9,0x8010(gp) */		\
-      : 0x8f998010)             /* lw t9,0x8010(gp) */		\
-   : 0x8f998010)		/* lw t9,0x8000(gp) */
-#define STUB_MOVE(abfd)                                         \
-  (SGI_COMPAT (abfd) ? 0x03e07825 : 0x03e07821)         /* move t7,ra */
-#define STUB_JALR 0x0320f809				/* jal t9 */
-#define STUB_LI16(abfd)                                         \
-  (SGI_COMPAT (abfd) ? 0x34180000 : 0x24180000)         /* ori t8,zero,0 */
-#define MIPS_FUNCTION_STUB_SIZE (16)
-
 #if 0
 /* We no longer try to identify particular sections for the .dynsym
    section.  When we do, we wind up crashing if there are other random
@@ -487,11 +247,6 @@
 #define mips_elf_set_cr_dist2to(x,v)		((x).dist2to = (v))
 #define mips_elf_set_cr_relvaddr(x,d)		((x).relvaddr = (d)<<2)
 
-static void bfd_elf32_swap_compact_rel_out
-  PARAMS ((bfd *, const Elf32_compact_rel *, Elf32_External_compact_rel *));
-static void bfd_elf32_swap_crinfo_out
-  PARAMS ((bfd *, const Elf32_crinfo *, Elf32_External_crinfo *));
-
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    from smaller values.  Start with zero, widen, *then* decrement.  */
 #define MINUS_ONE	(((bfd_vma)0) - 1)
@@ -586,7 +341,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_hi16_reloc,	/* special_function */
+	 mips_elf_hi16_reloc,	/* special_function */
 	 "R_MIPS_HI16",		/* name */
 	 true,			/* partial_inplace */
 	 0x0000ffff,		/* src_mask */
@@ -601,7 +356,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_lo16_reloc,	/* special_function */
+	 mips_elf_lo16_reloc,	/* special_function */
 	 "R_MIPS_LO16",		/* name */
 	 true,			/* partial_inplace */
 	 0x0000ffff,		/* src_mask */
@@ -616,7 +371,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_gprel16_reloc, /* special_function */
+	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
 	 "R_MIPS_GPREL16",	/* name */
 	 true,			/* partial_inplace */
 	 0x0000ffff,		/* src_mask */
@@ -631,7 +386,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_gprel16_reloc, /* special_function */
+	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
 	 "R_MIPS_LITERAL",	/* name */
 	 true,			/* partial_inplace */
 	 0x0000ffff,		/* src_mask */
@@ -646,7 +401,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_got16_reloc,	/* special_function */
+	 mips_elf_got16_reloc,	/* special_function */
 	 "R_MIPS_GOT16",	/* name */
 	 true,			/* partial_inplace */
 	 0x0000ffff,		/* src_mask */
@@ -691,7 +446,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_gprel32_reloc, /* special_function */
+	 mips_elf_gprel32_reloc, /* special_function */
 	 "R_MIPS_GPREL32",	/* name */
 	 true,			/* partial_inplace */
 	 0xffffffff,		/* src_mask */
@@ -943,535 +698,6 @@
 	 false),		/* pcrel_offset */
 };
 
-/* The relocation table used for SHT_RELA sections.  */
-
-static reloc_howto_type elf_mips_howto_table_rela[] =
-{
-  /* No relocation.  */
-  HOWTO (R_MIPS_NONE,		/* type */
-	 0,			/* rightshift */
-	 0,			/* size (0 = byte, 1 = short, 2 = long) */
-	 0,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_NONE",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 16 bit relocation.  */
-  HOWTO (R_MIPS_16,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_16",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 32 bit relocation.  */
-  HOWTO (R_MIPS_32,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_32",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 32 bit symbol relative relocation.  */
-  HOWTO (R_MIPS_REL32,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_REL32",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 26 bit jump address.  */
-  HOWTO (R_MIPS_26,		/* type */
-	 2,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 26,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-				/* This needs complex overflow
-				   detection, because the upper 36
-				   bits must match the PC + 4.  */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_26",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x03ffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for 64 bit REL.  */
-  /* High 16 bits of symbol value.  */
-  HOWTO (R_MIPS_HI16,		/* type */
-	 0,			/* rightshift */
-	 2,			/* 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_MIPS_HI16",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Low 16 bits of symbol value.  */
-  HOWTO (R_MIPS_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 */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_LO16",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* GP relative reference.  */
-  HOWTO (R_MIPS_GPREL16,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_gprel16_reloc, /* special_function */
-	 "R_MIPS_GPREL16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Reference to literal section.  */
-  HOWTO (R_MIPS_LITERAL,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_gprel16_reloc, /* special_function */
-	 "R_MIPS_LITERAL",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Reference to global offset table.  */
-  /* FIXME: This is not handled correctly.  */
-  HOWTO (R_MIPS_GOT16,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc, /* special_function */
-	 "R_MIPS_GOT16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 16 bit PC relative reference.  */
-  HOWTO (R_MIPS_PC16,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 true,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_PC16",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 true),			/* pcrel_offset */
-
-  /* 16 bit call through global offset table.  */
-  /* FIXME: This is not handled correctly.  */
-  HOWTO (R_MIPS_CALL16,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_CALL16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 32 bit GP relative reference.  */
-  HOWTO (R_MIPS_GPREL32,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_gprel32_reloc, /* special_function */
-	 "R_MIPS_GPREL32",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  EMPTY_HOWTO (13),
-  EMPTY_HOWTO (14),
-  EMPTY_HOWTO (15),
-
-  /* A 5 bit shift field.  */
-  HOWTO (R_MIPS_SHIFT5,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 5,			/* bitsize */
-	 false,			/* pc_relative */
-	 6,			/* bitpos */
-	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_SHIFT5",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x000007c0,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* A 6 bit shift field.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_SHIFT6,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 6,			/* bitsize */
-	 false,			/* pc_relative */
-	 6,			/* bitpos */
-	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc, /* special_function */
-	 "R_MIPS_SHIFT6",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x000007c4,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 64 bit relocation.  */
-  HOWTO (R_MIPS_64,		/* type */
-	 0,			/* rightshift */
-	 4,			/* size (0 = byte, 1 = short, 2 = long) */
-	 64,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_64",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 MINUS_ONE,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Displacement in the global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_GOT_DISP,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_GOT_DISP",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Displacement to page pointer in the global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_GOT_PAGE,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_GOT_PAGE",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Offset from page pointer in the global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_GOT_OFST,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_GOT_OFST",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* High 16 bits of displacement in global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_GOT_HI16,	/* type */
-	 0,			/* rightshift */
-	 2,			/* 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_MIPS_GOT_HI16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Low 16 bits of displacement in global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_GOT_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 */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_GOT_LO16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* 64 bit substraction.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_SUB,		/* type */
-	 0,			/* rightshift */
-	 4,			/* size (0 = byte, 1 = short, 2 = long) */
-	 64,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_SUB",		/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 MINUS_ONE,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Insert the addend as an instruction.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_INSERT_A,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_INSERT_A",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Insert the addend as an instruction, and change all relocations
-     to refer to the old instruction at the address.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_INSERT_B,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_INSERT_B",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Delete a 32 bit instruction.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_DELETE,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_DELETE",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Get the higher value of a 64 bit addend.  */
-  HOWTO (R_MIPS_HIGHER,		/* type */
-	 0,			/* rightshift */
-	 2,			/* 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_MIPS_HIGHER",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Get the highest value of a 64 bit addend.  */
-  HOWTO (R_MIPS_HIGHEST,	/* type */
-	 0,			/* rightshift */
-	 2,			/* 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_MIPS_HIGHEST",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* High 16 bits of displacement in global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_CALL_HI16,	/* type */
-	 0,			/* rightshift */
-	 2,			/* 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_MIPS_CALL_HI16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Low 16 bits of displacement in global offset table.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_CALL_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 */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_CALL_LO16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0x0000ffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Section displacement, used by an associated event location section.  */
-  /* FIXME: Not handled correctly.  */
-  HOWTO (R_MIPS_SCN_DISP,	/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_SCN_DISP",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  HOWTO (R_MIPS_REL16,		/* type */
-	 0,			/* rightshift */
-	 1,			/* size (0 = byte, 1 = short, 2 = long) */
-	 16,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_REL16",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* These two are obsolete.  */
-  EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
-  EMPTY_HOWTO (R_MIPS_PJUMP),
-
-  /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
-     It must be used for multigot GOT's (and only there).  */
-  HOWTO (R_MIPS_RELGOT,		/* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_RELGOT",	/* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-
-  /* Protected jump conversion.  This is an optimization hint.  No
-     relocation is required for correctness.  */
-  HOWTO (R_MIPS_JALR,	        /* type */
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 false,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MIPS_JALR",	        /* name */
-	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0xffffffff,		/* dst_mask */
-	 false),		/* pcrel_offset */
-};
-
 /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link.  This
    is a hack to make the linker think that we need 64 bit values.  */
 static reloc_howto_type elf_mips_ctor64_howto =
@@ -1534,7 +760,7 @@
 	 true,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_hi16_reloc,	/* special_function */
+	 mips_elf_hi16_reloc,	/* special_function */
 	 "R_MIPS_GNU_REL_HI16",	/* name */
 	 true,			/* partial_inplace */
 	 0xffff,		/* src_mask */
@@ -1550,7 +776,7 @@
 	 true,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_lo16_reloc,	/* special_function */
+	 mips_elf_lo16_reloc,	/* special_function */
 	 "R_MIPS_GNU_REL_LO16",	/* name */
 	 true,			/* partial_inplace */
 	 0xffff,		/* src_mask */
@@ -1663,14 +889,9 @@
 
 static struct mips_hi16 *mips_hi16_list;
 
-bfd_reloc_status_type
-_bfd_mips_elf_hi16_reloc (abfd,
-		     reloc_entry,
-		     symbol,
-		     data,
-		     input_section,
-		     output_bfd,
-		     error_message)
+static bfd_reloc_status_type
+mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data, input_section,
+		     output_bfd, error_message)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *reloc_entry;
      asymbol *symbol;
@@ -1756,14 +977,9 @@
    inplace relocation; this function exists in order to do the
    R_MIPS_HI16 relocation described above.  */
 
-bfd_reloc_status_type
-_bfd_mips_elf_lo16_reloc (abfd,
-		     reloc_entry,
-		     symbol,
-		     data,
-		     input_section,
-		     output_bfd,
-		     error_message)
+static bfd_reloc_status_type
+mips_elf_lo16_reloc (abfd, reloc_entry, symbol, data, input_section,
+		     output_bfd, error_message)
      bfd *abfd;
      arelent *reloc_entry;
      asymbol *symbol;
@@ -1872,14 +1088,9 @@
    This implementation suffices for the assembler, but the linker does
    not yet know how to create global offset tables.  */
 
-bfd_reloc_status_type
-_bfd_mips_elf_got16_reloc (abfd,
-		      reloc_entry,
-		      symbol,
-		      data,
-		      input_section,
-		      output_bfd,
-		      error_message)
+static bfd_reloc_status_type
+mips_elf_got16_reloc (abfd, reloc_entry, symbol, data, input_section,
+		      output_bfd, error_message)
      bfd *abfd;
      arelent *reloc_entry;
      asymbol *symbol;
@@ -1902,8 +1113,8 @@
      just like HI16.  */
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) != 0)
-    return _bfd_mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
-				     input_section, output_bfd, error_message);
+    return mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
+				input_section, output_bfd, error_message);
 
   abort ();
 }
@@ -2008,13 +1219,9 @@
    cleverly because the entries in the .lit8 and .lit4 sections can be
    merged.  */
 
-static bfd_reloc_status_type gprel16_with_gp PARAMS ((bfd *, asymbol *,
-						      arelent *, asection *,
-						      boolean, PTR, bfd_vma));
-
 bfd_reloc_status_type
-_bfd_mips_elf_gprel16_reloc (abfd, reloc_entry, symbol, data, input_section,
-			     output_bfd, error_message)
+_bfd_mips_elf32_gprel16_reloc (abfd, reloc_entry, symbol, data, input_section,
+			       output_bfd, error_message)
      bfd *abfd;
      arelent *reloc_entry;
      asymbol *symbol;
@@ -2052,69 +1259,9 @@
   if (ret != bfd_reloc_ok)
     return ret;
 
-  return gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
-			  relocateable, data, gp);
-}
-
-static bfd_reloc_status_type
-gprel16_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
-		 gp)
-     bfd *abfd;
-     asymbol *symbol;
-     arelent *reloc_entry;
-     asection *input_section;
-     boolean relocateable;
-     PTR data;
-     bfd_vma gp;
-{
-  bfd_vma relocation;
-  unsigned long insn;
-  unsigned long val;
-
-  if (bfd_is_com_section (symbol->section))
-    relocation = 0;
-  else
-    relocation = symbol->value;
-
-  relocation += symbol->section->output_section->vma;
-  relocation += symbol->section->output_offset;
-
-  if (reloc_entry->address > input_section->_cooked_size)
-    return bfd_reloc_outofrange;
-
-  insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
-
-  /* Set val to the offset into the section or symbol.  */
-  if (reloc_entry->howto->src_mask == 0)
-    {
-      /* This case occurs with the 64-bit MIPS ELF ABI.  */
-      val = reloc_entry->addend;
-    }
-  else
-    {
-      val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
-      if (val & 0x8000)
-	val -= 0x10000;
-    }
-
-  /* Adjust val for the final section location and GP value.  If we
-     are producing relocateable output, we don't want to do this for
-     an external symbol.  */
-  if (! relocateable
-      || (symbol->flags & BSF_SECTION_SYM) != 0)
-    val += relocation - gp;
-
-  insn = (insn & ~0xffff) | (val & 0xffff);
-  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
-
-  if (relocateable)
-    reloc_entry->address += input_section->output_offset;
-
-  /* Make sure it fit in 16 bits.  */
-  if ((long) val >= 0x8000 || (long) val < -0x8000)
-    return bfd_reloc_overflow;
-
-  return bfd_reloc_ok;
+  return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
+					input_section, relocateable,
+					data, gp);
 }
 
 /* Do a R_MIPS_GPREL32 relocation.  Is this 32 bit value the offset
@@ -2124,14 +1271,9 @@
 						      arelent *, asection *,
 						      boolean, PTR, bfd_vma));
 
-bfd_reloc_status_type
-_bfd_mips_elf_gprel32_reloc (abfd,
-			reloc_entry,
-			symbol,
-			data,
-			input_section,
-			output_bfd,
-			error_message)
+static bfd_reloc_status_type
+mips_elf_gprel32_reloc (abfd, reloc_entry, symbol, data, input_section,
+			output_bfd, error_message)
      bfd *abfd;
      arelent *reloc_entry;
      asymbol *symbol;
@@ -2369,8 +1511,8 @@
 			 | (insn & 0x1f)),
 	      (bfd_byte *) data + reloc_entry->address);
 
-  ret = gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
-			 relocateable, data, gp);
+  ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
+				       input_section, relocateable, data, gp);
 
   final = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
   bfd_put_16 (abfd,
@@ -2386,126 +1528,6 @@
   return ret;
 }
 
-/* Return the ISA for a MIPS e_flags value.  */
-
-static INLINE int
-elf_mips_isa (flags)
-     flagword flags;
-{
-  switch (flags & EF_MIPS_ARCH)
-    {
-    case E_MIPS_ARCH_1:
-      return 1;
-    case E_MIPS_ARCH_2:
-      return 2;
-    case E_MIPS_ARCH_3:
-      return 3;
-    case E_MIPS_ARCH_4:
-      return 4;
-    case E_MIPS_ARCH_5:
-      return 5;
-    case E_MIPS_ARCH_32:
-      return 32;
-    case E_MIPS_ARCH_64:
-      return 64;
-    }
-  return 4;
-}
-
-/* Return the MACH for a MIPS e_flags value.  */
-
-static INLINE unsigned long
-elf_mips_mach (flags)
-     flagword flags;
-{
-  switch (flags & EF_MIPS_MACH)
-    {
-    case E_MIPS_MACH_3900:
-      return bfd_mach_mips3900;
-
-    case E_MIPS_MACH_4010:
-      return bfd_mach_mips4010;
-
-    case E_MIPS_MACH_4100:
-      return bfd_mach_mips4100;
-
-    case E_MIPS_MACH_4111:
-      return bfd_mach_mips4111;
-
-    case E_MIPS_MACH_4650:
-      return bfd_mach_mips4650;
-
-    case E_MIPS_MACH_SB1:
-      return bfd_mach_mips_sb1;
-
-    default:
-      switch (flags & EF_MIPS_ARCH)
-	{
-	default:
-	case E_MIPS_ARCH_1:
-	  return bfd_mach_mips3000;
-	  break;
-
-	case E_MIPS_ARCH_2:
-	  return bfd_mach_mips6000;
-	  break;
-
-	case E_MIPS_ARCH_3:
-	  return bfd_mach_mips4000;
-	  break;
-
-	case E_MIPS_ARCH_4:
-	  return bfd_mach_mips8000;
-	  break;
-
-	case E_MIPS_ARCH_5:
-	  return bfd_mach_mips5;
-	  break;
-
-	case E_MIPS_ARCH_32:
-	  return bfd_mach_mipsisa32;
-	  break;
-
-	case E_MIPS_ARCH_64:
-	  return bfd_mach_mipsisa64;
-	  break;
-	}
-    }
-
-  return 0;
-}
-
-/* Return printable name for ABI.  */
-
-static INLINE char *
-elf_mips_abi_name (abfd)
-     bfd *abfd;
-{
-  flagword flags;
-
-  flags = elf_elfheader (abfd)->e_flags;
-  switch (flags & EF_MIPS_ABI)
-    {
-    case 0:
-      if (ABI_N32_P (abfd))
-	return "N32";
-      else if (ABI_64_P (abfd))
-	return "64";
-      else
-	return "none";
-    case E_MIPS_ABI_O32:
-      return "O32";
-    case E_MIPS_ABI_O64:
-      return "O64";
-    case E_MIPS_ABI_EABI32:
-      return "EABI32";
-    case E_MIPS_ABI_EABI64:
-      return "EABI64";
-    default:
-      return "unknown abi";
-    }
-}
-
 /* A mapping from BFD reloc types to MIPS ELF reloc types.  */
 
 struct elf_reloc_map {
@@ -2592,8 +1614,9 @@
 /* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure.  */
 
 static reloc_howto_type *
-mips_rtype_to_howto (r_type)
+mips_elf32_rtype_to_howto (r_type, rela_p)
      unsigned int r_type;
+     boolean rela_p ATTRIBUTE_UNUSED;
 {
   switch (r_type)
     {
@@ -2628,7 +1651,6 @@
     default:
       BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
       return &elf_mips_howto_table_rel[r_type];
-      break;
     }
 }
 
@@ -2643,7 +1665,7 @@
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  cache_ptr->howto = mips_rtype_to_howto (r_type);
+  cache_ptr->howto = mips_elf32_rtype_to_howto (r_type, false);
 
   /* The addend for a GPREL16 or LITERAL relocation comes from the GP
      value for the object file.  We get the addend now, rather than
@@ -2672,180 +1694,6 @@
      (the field omitted in an Elf32_Internal_Rel) we can do it here.  */
 }
 
-/* A .reginfo section holds a single Elf32_RegInfo structure.  These
-   routines swap this structure in and out.  They are used outside of
-   BFD, so they are globally visible.  */
-
-void
-bfd_mips_elf32_swap_reginfo_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf32_External_RegInfo *ex;
-     Elf32_RegInfo *in;
-{
-  in->ri_gprmask = H_GET_32 (abfd, ex->ri_gprmask);
-  in->ri_cprmask[0] = H_GET_32 (abfd, ex->ri_cprmask[0]);
-  in->ri_cprmask[1] = H_GET_32 (abfd, ex->ri_cprmask[1]);
-  in->ri_cprmask[2] = H_GET_32 (abfd, ex->ri_cprmask[2]);
-  in->ri_cprmask[3] = H_GET_32 (abfd, ex->ri_cprmask[3]);
-  in->ri_gp_value = H_GET_32 (abfd, ex->ri_gp_value);
-}
-
-void
-bfd_mips_elf32_swap_reginfo_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_RegInfo *in;
-     Elf32_External_RegInfo *ex;
-{
-  H_PUT_32 (abfd, in->ri_gprmask, ex->ri_gprmask);
-  H_PUT_32 (abfd, in->ri_cprmask[0], ex->ri_cprmask[0]);
-  H_PUT_32 (abfd, in->ri_cprmask[1], ex->ri_cprmask[1]);
-  H_PUT_32 (abfd, in->ri_cprmask[2], ex->ri_cprmask[2]);
-  H_PUT_32 (abfd, in->ri_cprmask[3], ex->ri_cprmask[3]);
-  H_PUT_32 (abfd, in->ri_gp_value, ex->ri_gp_value);
-}
-
-/* In the 64 bit ABI, the .MIPS.options section holds register
-   information in an Elf64_Reginfo structure.  These routines swap
-   them in and out.  They are globally visible because they are used
-   outside of BFD.  These routines are here so that gas can call them
-   without worrying about whether the 64 bit ABI has been included.  */
-
-void
-bfd_mips_elf64_swap_reginfo_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf64_External_RegInfo *ex;
-     Elf64_Internal_RegInfo *in;
-{
-  in->ri_gprmask = H_GET_32 (abfd, ex->ri_gprmask);
-  in->ri_pad = H_GET_32 (abfd, ex->ri_pad);
-  in->ri_cprmask[0] = H_GET_32 (abfd, ex->ri_cprmask[0]);
-  in->ri_cprmask[1] = H_GET_32 (abfd, ex->ri_cprmask[1]);
-  in->ri_cprmask[2] = H_GET_32 (abfd, ex->ri_cprmask[2]);
-  in->ri_cprmask[3] = H_GET_32 (abfd, ex->ri_cprmask[3]);
-  in->ri_gp_value = H_GET_64 (abfd, ex->ri_gp_value);
-}
-
-void
-bfd_mips_elf64_swap_reginfo_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf64_Internal_RegInfo *in;
-     Elf64_External_RegInfo *ex;
-{
-  H_PUT_32 (abfd, in->ri_gprmask, ex->ri_gprmask);
-  H_PUT_32 (abfd, in->ri_pad, ex->ri_pad);
-  H_PUT_32 (abfd, in->ri_cprmask[0], ex->ri_cprmask[0]);
-  H_PUT_32 (abfd, in->ri_cprmask[1], ex->ri_cprmask[1]);
-  H_PUT_32 (abfd, in->ri_cprmask[2], ex->ri_cprmask[2]);
-  H_PUT_32 (abfd, in->ri_cprmask[3], ex->ri_cprmask[3]);
-  H_PUT_64 (abfd, in->ri_gp_value, ex->ri_gp_value);
-}
-
-/* Swap an entry in a .gptab section.  Note that these routines rely
-   on the equivalence of the two elements of the union.  */
-
-static void
-bfd_mips_elf32_swap_gptab_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf32_External_gptab *ex;
-     Elf32_gptab *in;
-{
-  in->gt_entry.gt_g_value = H_GET_32 (abfd, ex->gt_entry.gt_g_value);
-  in->gt_entry.gt_bytes = H_GET_32 (abfd, ex->gt_entry.gt_bytes);
-}
-
-static void
-bfd_mips_elf32_swap_gptab_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_gptab *in;
-     Elf32_External_gptab *ex;
-{
-  H_PUT_32 (abfd, in->gt_entry.gt_g_value, ex->gt_entry.gt_g_value);
-  H_PUT_32 (abfd, in->gt_entry.gt_bytes, ex->gt_entry.gt_bytes);
-}
-
-static void
-bfd_elf32_swap_compact_rel_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_compact_rel *in;
-     Elf32_External_compact_rel *ex;
-{
-  H_PUT_32 (abfd, in->id1, ex->id1);
-  H_PUT_32 (abfd, in->num, ex->num);
-  H_PUT_32 (abfd, in->id2, ex->id2);
-  H_PUT_32 (abfd, in->offset, ex->offset);
-  H_PUT_32 (abfd, in->reserved0, ex->reserved0);
-  H_PUT_32 (abfd, in->reserved1, ex->reserved1);
-}
-
-static void
-bfd_elf32_swap_crinfo_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_crinfo *in;
-     Elf32_External_crinfo *ex;
-{
-  unsigned long l;
-
-  l = (((in->ctype & CRINFO_CTYPE) << CRINFO_CTYPE_SH)
-       | ((in->rtype & CRINFO_RTYPE) << CRINFO_RTYPE_SH)
-       | ((in->dist2to & CRINFO_DIST2TO) << CRINFO_DIST2TO_SH)
-       | ((in->relvaddr & CRINFO_RELVADDR) << CRINFO_RELVADDR_SH));
-  H_PUT_32 (abfd, l, ex->info);
-  H_PUT_32 (abfd, in->konst, ex->konst);
-  H_PUT_32 (abfd, in->vaddr, ex->vaddr);
-}
-
-/* Swap in an options header.  */
-
-void
-bfd_mips_elf_swap_options_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf_External_Options *ex;
-     Elf_Internal_Options *in;
-{
-  in->kind = H_GET_8 (abfd, ex->kind);
-  in->size = H_GET_8 (abfd, ex->size);
-  in->section = H_GET_16 (abfd, ex->section);
-  in->info = H_GET_32 (abfd, ex->info);
-}
-
-/* Swap out an options header.  */
-
-void
-bfd_mips_elf_swap_options_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf_Internal_Options *in;
-     Elf_External_Options *ex;
-{
-  H_PUT_8 (abfd, in->kind, ex->kind);
-  H_PUT_8 (abfd, in->size, ex->size);
-  H_PUT_16 (abfd, in->section, ex->section);
-  H_PUT_32 (abfd, in->info, ex->info);
-}
-#if 0
-/* Swap in an MSYM entry.  */
-
-static void
-bfd_mips_elf_swap_msym_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf32_External_Msym *ex;
-     Elf32_Internal_Msym *in;
-{
-  in->ms_hash_value = H_GET_32 (abfd, ex->ms_hash_value);
-  in->ms_info = H_GET_32 (abfd, ex->ms_info);
-}
-#endif
-/* Swap out an MSYM entry.  */
-
-static void
-bfd_mips_elf_swap_msym_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_Internal_Msym *in;
-     Elf32_External_Msym *ex;
-{
-  H_PUT_32 (abfd, in->ms_hash_value, ex->ms_hash_value);
-  H_PUT_32 (abfd, in->ms_info, ex->ms_info);
-}
-
 /* Determine whether a symbol is global for the purposes of splitting
    the symbol table into global symbols and local symbols.  At least
    on Irix 5, this split must be between section symbols and all other
@@ -2865,1416 +1713,26 @@
 	    || bfd_is_com_section (bfd_get_section (sym)));
 }
 
-/* Set the right machine number for a MIPS ELF file.  This is used for
-   both the 32-bit and the 64-bit ABI.  */
+/* Set the right machine number for a MIPS ELF file.  */
 
-boolean
-_bfd_mips_elf_object_p (abfd)
+static boolean
+mips_elf32_object_p (abfd)
      bfd *abfd;
 {
+  unsigned long mach;
+
   /* Irix 5 and 6 are broken.  Object file symbol tables are not always
      sorted correctly such that local symbols precede global symbols,
      and the sh_info field in the symbol table is not always right.  */
-  if (SGI_COMPAT(abfd))
+  if (SGI_COMPAT (abfd))
     elf_bad_symtab (abfd) = true;
 
-  bfd_default_set_arch_mach (abfd, bfd_arch_mips,
-			     elf_mips_mach (elf_elfheader (abfd)->e_flags));
-  return true;
-}
-
-/* The final processing done just before writing out a MIPS ELF object
-   file.  This gets the MIPS architecture right based on the machine
-   number.  This is used by both the 32-bit and the 64-bit ABI.  */
-
-void
-_bfd_mips_elf_final_write_processing (abfd, linker)
-     bfd *abfd;
-     boolean linker ATTRIBUTE_UNUSED;
-{
-  unsigned long val;
-  unsigned int i;
-  Elf_Internal_Shdr **hdrpp;
-  const char *name;
-  asection *sec;
-
-  switch (bfd_get_mach (abfd))
-    {
-    default:
-    case bfd_mach_mips3000:
-      val = E_MIPS_ARCH_1;
-      break;
-
-    case bfd_mach_mips3900:
-      val = E_MIPS_ARCH_1 | E_MIPS_MACH_3900;
-      break;
-
-    case bfd_mach_mips6000:
-      val = E_MIPS_ARCH_2;
-      break;
-
-    case bfd_mach_mips4000:
-    case bfd_mach_mips4300:
-    case bfd_mach_mips4400:
-    case bfd_mach_mips4600:
-      val = E_MIPS_ARCH_3;
-      break;
-
-    case bfd_mach_mips4010:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4010;
-      break;
-
-    case bfd_mach_mips4100:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4100;
-      break;
-
-    case bfd_mach_mips4111:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4111;
-      break;
-
-    case bfd_mach_mips4650:
-      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4650;
-      break;
-
-    case bfd_mach_mips5000:
-    case bfd_mach_mips8000:
-    case bfd_mach_mips10000:
-    case bfd_mach_mips12000:
-      val = E_MIPS_ARCH_4;
-      break;
-
-    case bfd_mach_mips5:
-      val = E_MIPS_ARCH_5;
-      break;
-
-    case bfd_mach_mips_sb1:
-      val = E_MIPS_ARCH_64 | E_MIPS_MACH_SB1;
-      break;
-
-    case bfd_mach_mipsisa32:
-      val = E_MIPS_ARCH_32;
-      break;
-
-    case bfd_mach_mipsisa64:
-      val = E_MIPS_ARCH_64;
-    }
-
-  elf_elfheader (abfd)->e_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
-  elf_elfheader (abfd)->e_flags |= val;
-
-  /* Set the sh_info field for .gptab sections and other appropriate
-     info for each special section.  */
-  for (i = 1, hdrpp = elf_elfsections (abfd) + 1;
-       i < elf_numsections (abfd);
-       i++, hdrpp++)
-    {
-      switch ((*hdrpp)->sh_type)
-	{
-	case SHT_MIPS_MSYM:
-	case SHT_MIPS_LIBLIST:
-	  sec = bfd_get_section_by_name (abfd, ".dynstr");
-	  if (sec != NULL)
-	    (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
-	  break;
-
-	case SHT_MIPS_GPTAB:
-	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
-	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
-	  BFD_ASSERT (name != NULL
-		      && strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0);
-	  sec = bfd_get_section_by_name (abfd, name + sizeof ".gptab" - 1);
-	  BFD_ASSERT (sec != NULL);
-	  (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
-	  break;
-
-	case SHT_MIPS_CONTENT:
-	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
-	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
-	  BFD_ASSERT (name != NULL
-		      && strncmp (name, ".MIPS.content",
-				  sizeof ".MIPS.content" - 1) == 0);
-	  sec = bfd_get_section_by_name (abfd,
-					 name + sizeof ".MIPS.content" - 1);
-	  BFD_ASSERT (sec != NULL);
-	  (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
-	  break;
-
-	case SHT_MIPS_SYMBOL_LIB:
-	  sec = bfd_get_section_by_name (abfd, ".dynsym");
-	  if (sec != NULL)
-	    (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
-	  sec = bfd_get_section_by_name (abfd, ".liblist");
-	  if (sec != NULL)
-	    (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
-	  break;
-
-	case SHT_MIPS_EVENTS:
-	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
-	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
-	  BFD_ASSERT (name != NULL);
-	  if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0)
-	    sec = bfd_get_section_by_name (abfd,
-					   name + sizeof ".MIPS.events" - 1);
-	  else
-	    {
-	      BFD_ASSERT (strncmp (name, ".MIPS.post_rel",
-				   sizeof ".MIPS.post_rel" - 1) == 0);
-	      sec = bfd_get_section_by_name (abfd,
-					     (name
-					      + sizeof ".MIPS.post_rel" - 1));
-	    }
-	  BFD_ASSERT (sec != NULL);
-	  (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
-	  break;
-
-	}
-    }
-}
-
-/* Function to keep MIPS specific file flags like as EF_MIPS_PIC.  */
-
-boolean
-_bfd_mips_elf_set_private_flags (abfd, flags)
-     bfd *abfd;
-     flagword flags;
-{
-  BFD_ASSERT (!elf_flags_init (abfd)
-	      || elf_elfheader (abfd)->e_flags == flags);
-
-  elf_elfheader (abfd)->e_flags = flags;
-  elf_flags_init (abfd) = true;
-  return true;
-}
-
-/* Merge backend specific data from an object file to the output
-   object file when linking.  */
-
-boolean
-_bfd_mips_elf_merge_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
-{
-  flagword old_flags;
-  flagword new_flags;
-  boolean ok;
-  boolean null_input_bfd = true;
-  asection *sec;
-
-  /* Check if we have the same endianess */
-  if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
-    return false;
-
-  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
-      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return true;
-
-  new_flags = elf_elfheader (ibfd)->e_flags;
-  elf_elfheader (obfd)->e_flags |= new_flags & EF_MIPS_NOREORDER;
-  old_flags = elf_elfheader (obfd)->e_flags;
-
-  if (! elf_flags_init (obfd))
-    {
-      elf_flags_init (obfd) = true;
-      elf_elfheader (obfd)->e_flags = new_flags;
-      elf_elfheader (obfd)->e_ident[EI_CLASS]
-	= elf_elfheader (ibfd)->e_ident[EI_CLASS];
-
-      if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
-	  && bfd_get_arch_info (obfd)->the_default)
-	{
-	  if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
-				   bfd_get_mach (ibfd)))
-	    return false;
-	}
-
-      return true;
-    }
-
-  /* Check flag compatibility.  */
-
-  new_flags &= ~EF_MIPS_NOREORDER;
-  old_flags &= ~EF_MIPS_NOREORDER;
-
-  if (new_flags == old_flags)
-    return true;
-
-  /* Check to see if the input BFD actually contains any sections.
-     If not, its flags may not have been initialised either, but it cannot
-     actually cause any incompatibility.  */
-  for (sec = ibfd->sections; sec != NULL; sec = sec->next)
-    {
-      /* Ignore synthetic sections and empty .text, .data and .bss sections
-	  which are automatically generated by gas.  */
-      if (strcmp (sec->name, ".reginfo")
-	  && strcmp (sec->name, ".mdebug")
-	  && ((!strcmp (sec->name, ".text")
-	       || !strcmp (sec->name, ".data")
-	       || !strcmp (sec->name, ".bss"))
-	      && sec->_raw_size != 0))
-	{
-	  null_input_bfd = false;
-	  break;
-	}
-    }
-  if (null_input_bfd)
-    return true;
-
-  ok = true;
-
-  if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC))
-    {
-      new_flags &= ~EF_MIPS_PIC;
-      old_flags &= ~EF_MIPS_PIC;
-      (*_bfd_error_handler)
-	(_("%s: linking PIC files with non-PIC files"),
-	 bfd_archive_filename (ibfd));
-      ok = false;
-    }
-
-  if ((new_flags & EF_MIPS_CPIC) != (old_flags & EF_MIPS_CPIC))
-    {
-      new_flags &= ~EF_MIPS_CPIC;
-      old_flags &= ~EF_MIPS_CPIC;
-      (*_bfd_error_handler)
-	(_("%s: linking abicalls files with non-abicalls files"),
-	 bfd_archive_filename (ibfd));
-      ok = false;
-    }
-
-  /* Compare the ISA's.  */
-  if ((new_flags & (EF_MIPS_ARCH | EF_MIPS_MACH))
-      != (old_flags & (EF_MIPS_ARCH | EF_MIPS_MACH)))
-    {
-      int new_mach = new_flags & EF_MIPS_MACH;
-      int old_mach = old_flags & EF_MIPS_MACH;
-      int new_isa = elf_mips_isa (new_flags);
-      int old_isa = elf_mips_isa (old_flags);
-
-      /* If either has no machine specified, just compare the general isa's.
-	 Some combinations of machines are ok, if the isa's match.  */
-      if (! new_mach
-	  || ! old_mach
-	  || new_mach == old_mach
-	  )
-	{
-	  /* Don't warn about mixing code using 32-bit ISAs, or mixing code
-	     using 64-bit ISAs.  They will normally use the same data sizes
-	     and calling conventions.  */
-
-	  if ((  (new_isa == 1 || new_isa == 2 || new_isa == 32)
-	       ^ (old_isa == 1 || old_isa == 2 || old_isa == 32)) != 0)
-	    {
-	      (*_bfd_error_handler)
-	       (_("%s: ISA mismatch (-mips%d) with previous modules (-mips%d)"),
-		bfd_archive_filename (ibfd), new_isa, old_isa);
-	      ok = false;
-	    }
-	  else
-	    {
-	      /* Do we need to update the mach field?  */
-	      if (old_mach == 0 && new_mach != 0) 
-		elf_elfheader (obfd)->e_flags |= new_mach;
-
-	      /* Do we need to update the ISA field?  */
-	      if (new_isa > old_isa)
-		{
-		  elf_elfheader (obfd)->e_flags &= ~EF_MIPS_ARCH;
-		  elf_elfheader (obfd)->e_flags
-		    |= new_flags & EF_MIPS_ARCH;
-		}
-	    }
-	}
-      else
-	{
-	  (*_bfd_error_handler)
-	    (_("%s: ISA mismatch (%d) with previous modules (%d)"),
-	     bfd_archive_filename (ibfd),
-	     elf_mips_mach (new_flags),
-	     elf_mips_mach (old_flags));
-	  ok = false;
-	}
-
-      new_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
-      old_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
-    }
-
-  /* Compare ABI's.  The 64-bit ABI does not use EF_MIPS_ABI.  But, it
-     does set EI_CLASS differently from any 32-bit ABI.  */
-  if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI)
-      || (elf_elfheader (ibfd)->e_ident[EI_CLASS]
-	  != elf_elfheader (obfd)->e_ident[EI_CLASS]))
-    {
-      /* Only error if both are set (to different values).  */
-      if (((new_flags & EF_MIPS_ABI) && (old_flags & EF_MIPS_ABI))
-	  || (elf_elfheader (ibfd)->e_ident[EI_CLASS]
-	      != elf_elfheader (obfd)->e_ident[EI_CLASS]))
-	{
-	  (*_bfd_error_handler)
-	    (_("%s: ABI mismatch: linking %s module with previous %s modules"),
-	     bfd_archive_filename (ibfd),
-	     elf_mips_abi_name (ibfd),
-	     elf_mips_abi_name (obfd));
-	  ok = false;
-	}
-      new_flags &= ~EF_MIPS_ABI;
-      old_flags &= ~EF_MIPS_ABI;
-    }
-
-  /* Warn about any other mismatches */
-  if (new_flags != old_flags)
-    {
-      (*_bfd_error_handler)
-	(_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
-	 bfd_archive_filename (ibfd), (unsigned long) new_flags,
-	 (unsigned long) old_flags);
-      ok = false;
-    }
-
-  if (! ok)
-    {
-      bfd_set_error (bfd_error_bad_value);
-      return false;
-    }
+  mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
+  bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
 
   return true;
 }
 
-boolean
-_bfd_mips_elf_print_private_bfd_data (abfd, ptr)
-     bfd *abfd;
-     PTR ptr;
-{
-  FILE *file = (FILE *) ptr;
-
-  BFD_ASSERT (abfd != NULL && ptr != NULL);
-
-  /* Print normal ELF private data.  */
-  _bfd_elf_print_private_bfd_data (abfd, ptr);
-
-  /* xgettext:c-format */
-  fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
-
-  if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_O32)
-    fprintf (file, _(" [abi=O32]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_O64)
-    fprintf (file, _(" [abi=O64]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI32)
-    fprintf (file, _(" [abi=EABI32]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI64)
-    fprintf (file, _(" [abi=EABI64]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI))
-    fprintf (file, _(" [abi unknown]"));
-  else if (ABI_N32_P (abfd))
-    fprintf (file, _(" [abi=N32]"));
-  else if (ABI_64_P (abfd))
-    fprintf (file, _(" [abi=64]"));
-  else
-    fprintf (file, _(" [no abi set]"));
-
-  if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_1)
-    fprintf (file, _(" [mips1]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_2)
-    fprintf (file, _(" [mips2]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_3)
-    fprintf (file, _(" [mips3]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_4)
-    fprintf (file, _(" [mips4]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_5)
-    fprintf (file, _(" [mips5]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_32)
-    fprintf (file, _(" [mips32]"));
-  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_64)
-    fprintf (file, _(" [mips64]"));
-  else
-    fprintf (file, _(" [unknown ISA]"));
-
-  if (elf_elfheader (abfd)->e_flags & EF_MIPS_32BITMODE)
-    fprintf (file, _(" [32bitmode]"));
-  else
-    fprintf (file, _(" [not 32bitmode]"));
-
-  fputc ('\n', file);
-
-  return true;
-}
-
-/* Handle a MIPS specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.
-   This routine supports both the 32-bit and 64-bit ELF ABI.
-
-   FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure
-   how to.  */
-
-boolean
-_bfd_mips_elf_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     char *name;
-{
-  flagword flags = 0;
-
-  /* There ought to be a place to keep ELF backend specific flags, but
-     at the moment there isn't one.  We just keep track of the
-     sections by their name, instead.  Fortunately, the ABI gives
-     suggested names for all the MIPS specific sections, so we will
-     probably get away with this.  */
-  switch (hdr->sh_type)
-    {
-    case SHT_MIPS_LIBLIST:
-      if (strcmp (name, ".liblist") != 0)
-	return false;
-      break;
-    case SHT_MIPS_MSYM:
-      if (strcmp (name, MIPS_ELF_MSYM_SECTION_NAME (abfd)) != 0)
-	return false;
-      break;
-    case SHT_MIPS_CONFLICT:
-      if (strcmp (name, ".conflict") != 0)
-	return false;
-      break;
-    case SHT_MIPS_GPTAB:
-      if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) != 0)
-	return false;
-      break;
-    case SHT_MIPS_UCODE:
-      if (strcmp (name, ".ucode") != 0)
-	return false;
-      break;
-    case SHT_MIPS_DEBUG:
-      if (strcmp (name, ".mdebug") != 0)
-	return false;
-      flags = SEC_DEBUGGING;
-      break;
-    case SHT_MIPS_REGINFO:
-      if (strcmp (name, ".reginfo") != 0
-	  || hdr->sh_size != sizeof (Elf32_External_RegInfo))
-	return false;
-      flags = (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_SAME_SIZE);
-      break;
-    case SHT_MIPS_IFACE:
-      if (strcmp (name, ".MIPS.interfaces") != 0)
-	return false;
-      break;
-    case SHT_MIPS_CONTENT:
-      if (strncmp (name, ".MIPS.content", sizeof ".MIPS.content" - 1) != 0)
-	return false;
-      break;
-    case SHT_MIPS_OPTIONS:
-      if (strcmp (name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) != 0)
-	return false;
-      break;
-    case SHT_MIPS_DWARF:
-      if (strncmp (name, ".debug_", sizeof ".debug_" - 1) != 0)
-	return false;
-      break;
-    case SHT_MIPS_SYMBOL_LIB:
-      if (strcmp (name, ".MIPS.symlib") != 0)
-	return false;
-      break;
-    case SHT_MIPS_EVENTS:
-      if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) != 0
-	  && strncmp (name, ".MIPS.post_rel",
-		      sizeof ".MIPS.post_rel" - 1) != 0)
-	return false;
-      break;
-    default:
-      return false;
-    }
-
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
-    return false;
-
-  if (flags)
-    {
-      if (! bfd_set_section_flags (abfd, hdr->bfd_section,
-				   (bfd_get_section_flags (abfd,
-							   hdr->bfd_section)
-				    | flags)))
-	return false;
-    }
-
-  /* FIXME: We should record sh_info for a .gptab section.  */
-
-  /* For a .reginfo section, set the gp value in the tdata information
-     from the contents of this section.  We need the gp value while
-     processing relocs, so we just get it now.  The .reginfo section
-     is not used in the 64-bit MIPS ELF ABI.  */
-  if (hdr->sh_type == SHT_MIPS_REGINFO)
-    {
-      Elf32_External_RegInfo ext;
-      Elf32_RegInfo s;
-
-      if (! bfd_get_section_contents (abfd, hdr->bfd_section, (PTR) &ext,
-				      (file_ptr) 0,
-				      (bfd_size_type) sizeof ext))
-	return false;
-      bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s);
-      elf_gp (abfd) = s.ri_gp_value;
-    }
-
-  /* For a SHT_MIPS_OPTIONS section, look for a ODK_REGINFO entry, and
-     set the gp value based on what we find.  We may see both
-     SHT_MIPS_REGINFO and SHT_MIPS_OPTIONS/ODK_REGINFO; in that case,
-     they should agree.  */
-  if (hdr->sh_type == SHT_MIPS_OPTIONS)
-    {
-      bfd_byte *contents, *l, *lend;
-
-      contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
-      if (contents == NULL)
-	return false;
-      if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents,
-				      (file_ptr) 0, hdr->sh_size))
-	{
-	  free (contents);
-	  return false;
-	}
-      l = contents;
-      lend = contents + hdr->sh_size;
-      while (l + sizeof (Elf_External_Options) <= lend)
-	{
-	  Elf_Internal_Options intopt;
-
-	  bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
-					&intopt);
-	  if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
-	    {
-	      Elf64_Internal_RegInfo intreg;
-
-	      bfd_mips_elf64_swap_reginfo_in
-		(abfd,
-		 ((Elf64_External_RegInfo *)
-		  (l + sizeof (Elf_External_Options))),
-		 &intreg);
-	      elf_gp (abfd) = intreg.ri_gp_value;
-	    }
-	  else if (intopt.kind == ODK_REGINFO)
-	    {
-	      Elf32_RegInfo intreg;
-
-	      bfd_mips_elf32_swap_reginfo_in
-		(abfd,
-		 ((Elf32_External_RegInfo *)
-		  (l + sizeof (Elf_External_Options))),
-		 &intreg);
-	      elf_gp (abfd) = intreg.ri_gp_value;
-	    }
-	  l += intopt.size;
-	}
-      free (contents);
-    }
-
-  return true;
-}
-
-/* Set the correct type for a MIPS ELF section.  We do this by the
-   section name, which is a hack, but ought to work.  This routine is
-   used by both the 32-bit and the 64-bit ABI.  */
-
-boolean
-_bfd_mips_elf_fake_sections (abfd, hdr, sec)
-     bfd *abfd;
-     Elf32_Internal_Shdr *hdr;
-     asection *sec;
-{
-  register const char *name;
-
-  name = bfd_get_section_name (abfd, sec);
-
-  if (strcmp (name, ".liblist") == 0)
-    {
-      hdr->sh_type = SHT_MIPS_LIBLIST;
-      hdr->sh_info = sec->_raw_size / sizeof (Elf32_Lib);
-      /* The sh_link field is set in final_write_processing.  */
-    }
-  else if (strcmp (name, ".conflict") == 0)
-    hdr->sh_type = SHT_MIPS_CONFLICT;
-  else if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0)
-    {
-      hdr->sh_type = SHT_MIPS_GPTAB;
-      hdr->sh_entsize = sizeof (Elf32_External_gptab);
-      /* The sh_info field is set in final_write_processing.  */
-    }
-  else if (strcmp (name, ".ucode") == 0)
-    hdr->sh_type = SHT_MIPS_UCODE;
-  else if (strcmp (name, ".mdebug") == 0)
-    {
-      hdr->sh_type = SHT_MIPS_DEBUG;
-      /* In a shared object on Irix 5.3, the .mdebug section has an
-         entsize of 0.  FIXME: Does this matter?  */
-      if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
-	hdr->sh_entsize = 0;
-      else
-	hdr->sh_entsize = 1;
-    }
-  else if (strcmp (name, ".reginfo") == 0)
-    {
-      hdr->sh_type = SHT_MIPS_REGINFO;
-      /* In a shared object on Irix 5.3, the .reginfo section has an
-         entsize of 0x18.  FIXME: Does this matter?  */
-      if (SGI_COMPAT (abfd))
-	{
-	  if ((abfd->flags & DYNAMIC) != 0)
-	    hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
-	  else
-	    hdr->sh_entsize = 1;
-	}
-      else
-	hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
-    }
-  else if (SGI_COMPAT (abfd)
-	   && (strcmp (name, ".hash") == 0
-	       || strcmp (name, ".dynamic") == 0
-	       || strcmp (name, ".dynstr") == 0))
-    {
-      if (SGI_COMPAT (abfd))
-	hdr->sh_entsize = 0;
-#if 0
-      /* This isn't how the Irix 6 linker behaves.  */
-      hdr->sh_info = SIZEOF_MIPS_DYNSYM_SECNAMES;
-#endif
-    }
-  else if (strcmp (name, ".got") == 0
-	   || strcmp (name, MIPS_ELF_SRDATA_SECTION_NAME (abfd)) == 0
-	   || strcmp (name, ".sdata") == 0
-	   || strcmp (name, ".sbss") == 0
-	   || strcmp (name, ".lit4") == 0
-	   || strcmp (name, ".lit8") == 0)
-    hdr->sh_flags |= SHF_MIPS_GPREL;
-  else if (strcmp (name, ".MIPS.interfaces") == 0)
-    {
-      hdr->sh_type = SHT_MIPS_IFACE;
-      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
-    }
-  else if (strncmp (name, ".MIPS.content", strlen (".MIPS.content")) == 0)
-    {
-      hdr->sh_type = SHT_MIPS_CONTENT;
-      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
-      /* The sh_info field is set in final_write_processing.  */
-    }
-  else if (strcmp (name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
-    {
-      hdr->sh_type = SHT_MIPS_OPTIONS;
-      hdr->sh_entsize = 1;
-      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
-    }
-  else if (strncmp (name, ".debug_", sizeof ".debug_" - 1) == 0)
-    hdr->sh_type = SHT_MIPS_DWARF;
-  else if (strcmp (name, ".MIPS.symlib") == 0)
-    {
-      hdr->sh_type = SHT_MIPS_SYMBOL_LIB;
-      /* The sh_link and sh_info fields are set in
-         final_write_processing.  */
-    }
-  else if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0
-	   || strncmp (name, ".MIPS.post_rel",
-		       sizeof ".MIPS.post_rel" - 1) == 0)
-    {
-      hdr->sh_type = SHT_MIPS_EVENTS;
-      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
-      /* The sh_link field is set in final_write_processing.  */
-    }
-  else if (strcmp (name, MIPS_ELF_MSYM_SECTION_NAME (abfd)) == 0)
-    {
-      hdr->sh_type = SHT_MIPS_MSYM;
-      hdr->sh_flags |= SHF_ALLOC;
-      hdr->sh_entsize = 8;
-    }
-
-  /* The generic elf_fake_sections will set up REL_HDR using the
-     default kind of relocations.  But, we may actually need both
-     kinds of relocations, so we set up the second header here.
-
-     This is not necessary for the O32 ABI since that only uses Elf32_Rel
-     relocations (cf. System V ABI, MIPS RISC Processor Supplement,
-     3rd Edition, p. 4-17).  It breaks the IRIX 5/6 32-bit ld, since one
-     of the resulting empty .rela.<section> sections starts with
-     sh_offset == object size, and ld doesn't allow that.  While the check
-     is arguably bogus for empty or SHT_NOBITS sections, it can easily be
-     avoided by not emitting those useless sections in the first place.  */
-  if (IRIX_COMPAT (abfd) != ict_irix5 && (sec->flags & SEC_RELOC) != 0)
-    {
-      struct bfd_elf_section_data *esd;
-      bfd_size_type amt = sizeof (Elf_Internal_Shdr);
-
-      esd = elf_section_data (sec);
-      BFD_ASSERT (esd->rel_hdr2 == NULL);
-      esd->rel_hdr2 = (Elf_Internal_Shdr *) bfd_zalloc (abfd, amt);
-      if (!esd->rel_hdr2)
-	return false;
-      _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec,
-				!elf_section_data (sec)->use_rela_p);
-    }
-
-  return true;
-}
-
-/* Given a BFD section, try to locate the corresponding ELF section
-   index.  This is used by both the 32-bit and the 64-bit ABI.
-   Actually, it's not clear to me that the 64-bit ABI supports these,
-   but for non-PIC objects we will certainly want support for at least
-   the .scommon section.  */
-
-boolean
-_bfd_mips_elf_section_from_bfd_section (abfd, sec, retval)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     int *retval;
-{
-  if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
-    {
-      *retval = SHN_MIPS_SCOMMON;
-      return true;
-    }
-  if (strcmp (bfd_get_section_name (abfd, sec), ".acommon") == 0)
-    {
-      *retval = SHN_MIPS_ACOMMON;
-      return true;
-    }
-  return false;
-}
-
-/* When are writing out the .options or .MIPS.options section,
-   remember the bytes we are writing out, so that we can install the
-   GP value in the section_processing routine.  */
-
-boolean
-_bfd_mips_elf_set_section_contents (abfd, section, location, offset, count)
-     bfd *abfd;
-     sec_ptr section;
-     PTR location;
-     file_ptr offset;
-     bfd_size_type count;
-{
-  if (strcmp (section->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
-    {
-      bfd_byte *c;
-
-      if (elf_section_data (section) == NULL)
-	{
-	  bfd_size_type amt = sizeof (struct bfd_elf_section_data);
-	  section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
-	  if (elf_section_data (section) == NULL)
-	    return false;
-	}
-      c = (bfd_byte *) elf_section_data (section)->tdata;
-      if (c == NULL)
-	{
-	  bfd_size_type size;
-
-	  if (section->_cooked_size != 0)
-	    size = section->_cooked_size;
-	  else
-	    size = section->_raw_size;
-	  c = (bfd_byte *) bfd_zalloc (abfd, size);
-	  if (c == NULL)
-	    return false;
-	  elf_section_data (section)->tdata = (PTR) c;
-	}
-
-      memcpy (c + offset, location, (size_t) count);
-    }
-
-  return _bfd_elf_set_section_contents (abfd, section, location, offset,
-					count);
-}
-
-/* Work over a section just before writing it out.  This routine is
-   used by both the 32-bit and the 64-bit ABI.  FIXME: We recognize
-   sections that need the SHF_MIPS_GPREL flag by name; there has to be
-   a better way.  */
-
-boolean
-_bfd_mips_elf_section_processing (abfd, hdr)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-{
-  if (hdr->sh_type == SHT_MIPS_REGINFO
-      && hdr->sh_size > 0)
-    {
-      bfd_byte buf[4];
-
-      BFD_ASSERT (hdr->sh_size == sizeof (Elf32_External_RegInfo));
-      BFD_ASSERT (hdr->contents == NULL);
-
-      if (bfd_seek (abfd,
-		    hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
-		    SEEK_SET) != 0)
-	return false;
-      H_PUT_32 (abfd, elf_gp (abfd), buf);
-      if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
-	return false;
-    }
-
-  if (hdr->sh_type == SHT_MIPS_OPTIONS
-      && hdr->bfd_section != NULL
-      && elf_section_data (hdr->bfd_section) != NULL
-      && elf_section_data (hdr->bfd_section)->tdata != NULL)
-    {
-      bfd_byte *contents, *l, *lend;
-
-      /* We stored the section contents in the elf_section_data tdata
-	 field in the set_section_contents routine.  We save the
-	 section contents so that we don't have to read them again.
-	 At this point we know that elf_gp is set, so we can look
-	 through the section contents to see if there is an
-	 ODK_REGINFO structure.  */
-
-      contents = (bfd_byte *) elf_section_data (hdr->bfd_section)->tdata;
-      l = contents;
-      lend = contents + hdr->sh_size;
-      while (l + sizeof (Elf_External_Options) <= lend)
-	{
-	  Elf_Internal_Options intopt;
-
-	  bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
-					&intopt);
-	  if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
-	    {
-	      bfd_byte buf[8];
-
-	      if (bfd_seek (abfd,
-			    (hdr->sh_offset
-			     + (l - contents)
-			     + sizeof (Elf_External_Options)
-			     + (sizeof (Elf64_External_RegInfo) - 8)),
-			     SEEK_SET) != 0)
-		return false;
-	      H_PUT_64 (abfd, elf_gp (abfd), buf);
-	      if (bfd_bwrite (buf, (bfd_size_type) 8, abfd) != 8)
-		return false;
-	    }
-	  else if (intopt.kind == ODK_REGINFO)
-	    {
-	      bfd_byte buf[4];
-
-	      if (bfd_seek (abfd,
-			    (hdr->sh_offset
-			     + (l - contents)
-			     + sizeof (Elf_External_Options)
-			     + (sizeof (Elf32_External_RegInfo) - 4)),
-			    SEEK_SET) != 0)
-		return false;
-	      H_PUT_32 (abfd, elf_gp (abfd), buf);
-	      if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
-		return false;
-	    }
-	  l += intopt.size;
-	}
-    }
-
-  if (hdr->bfd_section != NULL)
-    {
-      const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
-
-      if (strcmp (name, ".sdata") == 0
-	  || strcmp (name, ".lit8") == 0
-	  || strcmp (name, ".lit4") == 0)
-	{
-	  hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
-	  hdr->sh_type = SHT_PROGBITS;
-	}
-      else if (strcmp (name, ".sbss") == 0)
-	{
-	  hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
-	  hdr->sh_type = SHT_NOBITS;
-	}
-      else if (strcmp (name, MIPS_ELF_SRDATA_SECTION_NAME (abfd)) == 0)
-	{
-	  hdr->sh_flags |= SHF_ALLOC | SHF_MIPS_GPREL;
-	  hdr->sh_type = SHT_PROGBITS;
-	}
-      else if (strcmp (name, ".compact_rel") == 0)
-	{
-	  hdr->sh_flags = 0;
-	  hdr->sh_type = SHT_PROGBITS;
-	}
-      else if (strcmp (name, ".rtproc") == 0)
-	{
-	  if (hdr->sh_addralign != 0 && hdr->sh_entsize == 0)
-	    {
-	      unsigned int adjust;
-
-	      adjust = hdr->sh_size % hdr->sh_addralign;
-	      if (adjust != 0)
-		hdr->sh_size += hdr->sh_addralign - adjust;
-	    }
-	}
-    }
-
-  return true;
-}
-
-/* MIPS 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 the gp pointer, which yields
-   faster assembler code.  This is what we use for the small common
-   section.  This approach is copied from ecoff.c.  */
-static asection mips_elf_scom_section;
-static asymbol mips_elf_scom_symbol;
-static asymbol *mips_elf_scom_symbol_ptr;
-
-/* MIPS ELF also uses an acommon section, which represents an
-   allocated common symbol which may be overridden by a
-   definition in a shared library.  */
-static asection mips_elf_acom_section;
-static asymbol mips_elf_acom_symbol;
-static asymbol *mips_elf_acom_symbol_ptr;
-
-/* Handle the special MIPS section numbers that a symbol may use.
-   This is used for both the 32-bit and the 64-bit ABI.  */
-
-void
-_bfd_mips_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_MIPS_ACOMMON:
-      /* This section is used in a dynamically linked executable file.
-	 It is an allocated common section.  The dynamic linker can
-	 either resolve these symbols to something in a shared
-	 library, or it can just leave them here.  For our purposes,
-	 we can consider these symbols to be in a new section.  */
-      if (mips_elf_acom_section.name == NULL)
-	{
-	  /* Initialize the acommon section.  */
-	  mips_elf_acom_section.name = ".acommon";
-	  mips_elf_acom_section.flags = SEC_ALLOC;
-	  mips_elf_acom_section.output_section = &mips_elf_acom_section;
-	  mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
-	  mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
-	  mips_elf_acom_symbol.name = ".acommon";
-	  mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
-	  mips_elf_acom_symbol.section = &mips_elf_acom_section;
-	  mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
-	}
-      asym->section = &mips_elf_acom_section;
-      break;
-
-    case SHN_COMMON:
-      /* Common symbols less than the GP size are automatically
-	 treated as SHN_MIPS_SCOMMON symbols on IRIX5.  */
-      if (asym->value > elf_gp_size (abfd)
-	  || IRIX_COMPAT (abfd) == ict_irix6)
-	break;
-      /* Fall through.  */
-    case SHN_MIPS_SCOMMON:
-      if (mips_elf_scom_section.name == NULL)
-	{
-	  /* Initialize the small common section.  */
-	  mips_elf_scom_section.name = ".scommon";
-	  mips_elf_scom_section.flags = SEC_IS_COMMON;
-	  mips_elf_scom_section.output_section = &mips_elf_scom_section;
-	  mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
-	  mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
-	  mips_elf_scom_symbol.name = ".scommon";
-	  mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
-	  mips_elf_scom_symbol.section = &mips_elf_scom_section;
-	  mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
-	}
-      asym->section = &mips_elf_scom_section;
-      asym->value = elfsym->internal_elf_sym.st_size;
-      break;
-
-    case SHN_MIPS_SUNDEFINED:
-      asym->section = bfd_und_section_ptr;
-      break;
-
-#if 0 /* for SGI_COMPAT */
-    case SHN_MIPS_TEXT:
-      asym->section = mips_elf_text_section_ptr;
-      break;
-
-    case SHN_MIPS_DATA:
-      asym->section = mips_elf_data_section_ptr;
-      break;
-#endif
-    }
-}
-
-/* When creating an Irix 5 executable, we need REGINFO and RTPROC
-   segments.  */
-
-int
-_bfd_mips_elf_additional_program_headers (abfd)
-     bfd *abfd;
-{
-  asection *s;
-  int ret = 0;
-
-  /* See if we need a PT_MIPS_REGINFO segment.  */
-  s = bfd_get_section_by_name (abfd, ".reginfo");
-  if (s && (s->flags & SEC_LOAD))
-    ++ret;
-
-  /* See if we need a PT_MIPS_OPTIONS segment.  */
-  if (IRIX_COMPAT (abfd) == ict_irix6
-      && bfd_get_section_by_name (abfd,
-				  MIPS_ELF_OPTIONS_SECTION_NAME (abfd)))
-    ++ret;
-
-  /* See if we need a PT_MIPS_RTPROC segment.  */
-  if (IRIX_COMPAT (abfd) == ict_irix5
-      && bfd_get_section_by_name (abfd, ".dynamic")
-      && bfd_get_section_by_name (abfd, ".mdebug"))
-    ++ret;
-
-  return ret;
-}
-
-/* Modify the segment map for an Irix 5 executable.  */
-
-boolean
-_bfd_mips_elf_modify_segment_map (abfd)
-     bfd *abfd;
-{
-  asection *s;
-  struct elf_segment_map *m, **pm;
-  bfd_size_type amt;
-
-  /* If there is a .reginfo section, we need a PT_MIPS_REGINFO
-     segment.  */
-  s = bfd_get_section_by_name (abfd, ".reginfo");
-  if (s != NULL && (s->flags & SEC_LOAD) != 0)
-    {
-      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
-	if (m->p_type == PT_MIPS_REGINFO)
-	  break;
-      if (m == NULL)
-	{
-	  amt = sizeof *m;
-	  m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
-	  if (m == NULL)
-	    return false;
-
-	  m->p_type = PT_MIPS_REGINFO;
-	  m->count = 1;
-	  m->sections[0] = s;
-
-	  /* We want to put it after the PHDR and INTERP segments.  */
-	  pm = &elf_tdata (abfd)->segment_map;
-	  while (*pm != NULL
-		 && ((*pm)->p_type == PT_PHDR
-		     || (*pm)->p_type == PT_INTERP))
-	    pm = &(*pm)->next;
-
-	  m->next = *pm;
-	  *pm = m;
-	}
-    }
-
-  /* For IRIX 6, we don't have .mdebug sections, nor does anything but
-     .dynamic end up in PT_DYNAMIC.  However, we do have to insert a
-     PT_OPTIONS segement immediately following the program header
-     table.  */
-  if (IRIX_COMPAT (abfd) == ict_irix6)
-    {
-      for (s = abfd->sections; s; s = s->next)
-	if (elf_section_data (s)->this_hdr.sh_type == SHT_MIPS_OPTIONS)
-	  break;
-
-      if (s)
-	{
-	  struct elf_segment_map *options_segment;
-
-	  /* Usually, there's a program header table.  But, sometimes
-	     there's not (like when running the `ld' testsuite).  So,
-	     if there's no program header table, we just put the
-	     options segement at the end.  */
-	  for (pm = &elf_tdata (abfd)->segment_map;
-	       *pm != NULL;
-	       pm = &(*pm)->next)
-	    if ((*pm)->p_type == PT_PHDR)
-	      break;
-
-	  amt = sizeof (struct elf_segment_map);
-	  options_segment = bfd_zalloc (abfd, amt);
-	  options_segment->next = *pm;
-	  options_segment->p_type = PT_MIPS_OPTIONS;
-	  options_segment->p_flags = PF_R;
-	  options_segment->p_flags_valid = true;
-	  options_segment->count = 1;
-	  options_segment->sections[0] = s;
-	  *pm = options_segment;
-	}
-    }
-  else
-    {
-      if (IRIX_COMPAT (abfd) == ict_irix5)
-	{
-	  /* If there are .dynamic and .mdebug sections, we make a room
-	     for the RTPROC header.  FIXME: Rewrite without section names.  */
-	  if (bfd_get_section_by_name (abfd, ".interp") == NULL
-	      && bfd_get_section_by_name (abfd, ".dynamic") != NULL
-	      && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
-	    {
-	      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
-		if (m->p_type == PT_MIPS_RTPROC)
-		  break;
-	      if (m == NULL)
-		{
-		  amt = sizeof *m;
-		  m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
-		  if (m == NULL)
-		    return false;
-
-		  m->p_type = PT_MIPS_RTPROC;
-
-		  s = bfd_get_section_by_name (abfd, ".rtproc");
-		  if (s == NULL)
-		    {
-		      m->count = 0;
-		      m->p_flags = 0;
-		      m->p_flags_valid = 1;
-		    }
-		  else
-		    {
-		      m->count = 1;
-		      m->sections[0] = s;
-		    }
-
-		  /* We want to put it after the DYNAMIC segment.  */
-		  pm = &elf_tdata (abfd)->segment_map;
-		  while (*pm != NULL && (*pm)->p_type != PT_DYNAMIC)
-		    pm = &(*pm)->next;
-		  if (*pm != NULL)
-		    pm = &(*pm)->next;
-
-		  m->next = *pm;
-		  *pm = m;
-		}
-	    }
-	}
-      /* On Irix 5, the PT_DYNAMIC segment includes the .dynamic,
-	 .dynstr, .dynsym, and .hash sections, and everything in
-	 between.  */
-      for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL;
-	   pm = &(*pm)->next)
-	if ((*pm)->p_type == PT_DYNAMIC)
-	  break;
-      m = *pm;
-      if (m != NULL && IRIX_COMPAT (abfd) == ict_none)
-	{
-	  /* For a normal mips executable the permissions for the PT_DYNAMIC
-	     segment are read, write and execute. We do that here since
-	     the code in elf.c sets only the read permission. This matters
-	     sometimes for the dynamic linker.  */
-	  if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
-	    {
-	      m->p_flags = PF_R | PF_W | PF_X;
-	      m->p_flags_valid = 1;
-	    }
-	}
-      if (m != NULL
-	  && m->count == 1 && strcmp (m->sections[0]->name, ".dynamic") == 0)
-	{
-	  static const char *sec_names[] =
-	  {
-	    ".dynamic", ".dynstr", ".dynsym", ".hash"
-	  };
-	  bfd_vma low, high;
-	  unsigned int i, c;
-	  struct elf_segment_map *n;
-
-	  low = 0xffffffff;
-	  high = 0;
-	  for (i = 0; i < sizeof sec_names / sizeof sec_names[0]; i++)
-	    {
-	      s = bfd_get_section_by_name (abfd, sec_names[i]);
-	      if (s != NULL && (s->flags & SEC_LOAD) != 0)
-		{
-		  bfd_size_type sz;
-
-		  if (low > s->vma)
-		    low = s->vma;
-		  sz = s->_cooked_size;
-		  if (sz == 0)
-		    sz = s->_raw_size;
-		  if (high < s->vma + sz)
-		    high = s->vma + sz;
-		}
-	    }
-
-	  c = 0;
-	  for (s = abfd->sections; s != NULL; s = s->next)
-	    if ((s->flags & SEC_LOAD) != 0
-		&& s->vma >= low
-		&& ((s->vma
-		     + (s->_cooked_size !=
-			0 ? s->_cooked_size : s->_raw_size)) <= high))
-	      ++c;
-
-	  amt = sizeof *n + (bfd_size_type) (c - 1) * sizeof (asection *);
-	  n = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
-	  if (n == NULL)
-	    return false;
-	  *n = *m;
-	  n->count = c;
-
-	  i = 0;
-	  for (s = abfd->sections; s != NULL; s = s->next)
-	    {
-	      if ((s->flags & SEC_LOAD) != 0
-		  && s->vma >= low
-		  && ((s->vma
-		       + (s->_cooked_size != 0 ?
-			  s->_cooked_size : s->_raw_size)) <= high))
-		{
-		  n->sections[i] = s;
-		  ++i;
-		}
-	    }
-
-	  *pm = n;
-	}
-    }
-
-  return true;
-}
-
-/* The structure of the runtime procedure descriptor created by the
-   loader for use by the static exception system.  */
-
-typedef struct runtime_pdr {
-	bfd_vma	adr;		/* memory address of start of procedure */
-	long	regmask;	/* save register mask */
-	long	regoffset;	/* save register offset */
-	long	fregmask;	/* save floating point register mask */
-	long	fregoffset;	/* save floating point register offset */
-	long	frameoffset;	/* frame size */
-	short	framereg;	/* frame pointer register */
-	short	pcreg;		/* offset or reg of return pc */
-	long	irpss;		/* index into the runtime string table */
-	long	reserved;
-	struct exception_info *exception_info;/* pointer to exception array */
-} RPDR, *pRPDR;
-#define cbRPDR sizeof (RPDR)
-#define rpdNil ((pRPDR) 0)
-
-/* Swap RPDR (runtime procedure table entry) for output.  */
-
-static void ecoff_swap_rpdr_out
-  PARAMS ((bfd *, const RPDR *, struct rpdr_ext *));
-
-static void
-ecoff_swap_rpdr_out (abfd, in, ex)
-     bfd *abfd;
-     const RPDR *in;
-     struct rpdr_ext *ex;
-{
-  /* ECOFF_PUT_OFF was defined in ecoffswap.h.  */
-  ECOFF_PUT_OFF (abfd, in->adr, ex->p_adr);
-  H_PUT_32 (abfd, in->regmask, ex->p_regmask);
-  H_PUT_32 (abfd, in->regoffset, ex->p_regoffset);
-  H_PUT_32 (abfd, in->fregmask, ex->p_fregmask);
-  H_PUT_32 (abfd, in->fregoffset, ex->p_fregoffset);
-  H_PUT_32 (abfd, in->frameoffset, ex->p_frameoffset);
-
-  H_PUT_16 (abfd, in->framereg, ex->p_framereg);
-  H_PUT_16 (abfd, in->pcreg, ex->p_pcreg);
-
-  H_PUT_32 (abfd, in->irpss, ex->p_irpss);
-#if 0 /* FIXME */
-  ECOFF_PUT_OFF (abfd, in->exception_info, ex->p_exception_info);
-#endif
-}
-
-/* Read ECOFF debugging information from a .mdebug section into a
-   ecoff_debug_info structure.  */
-
-boolean
-_bfd_mips_elf_read_ecoff_info (abfd, section, debug)
-     bfd *abfd;
-     asection *section;
-     struct ecoff_debug_info *debug;
-{
-  HDRR *symhdr;
-  const struct ecoff_debug_swap *swap;
-  char *ext_hdr = NULL;
-
-  swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-  memset (debug, 0, sizeof (*debug));
-
-  ext_hdr = (char *) bfd_malloc (swap->external_hdr_size);
-  if (ext_hdr == NULL && swap->external_hdr_size != 0)
-    goto error_return;
-
-  if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
-				swap->external_hdr_size)
-      == false)
-    goto error_return;
-
-  symhdr = &debug->symbolic_header;
-  (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr);
-
-  /* The symbolic header contains absolute file offsets and sizes to
-     read.  */
-#define READ(ptr, offset, count, size, type)				\
-  if (symhdr->count == 0)						\
-    debug->ptr = NULL;							\
-  else									\
-    {									\
-      bfd_size_type amt = (bfd_size_type) size * symhdr->count;		\
-      debug->ptr = (type) bfd_malloc (amt);				\
-      if (debug->ptr == NULL)						\
-	goto error_return;						\
-      if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0	\
-	  || bfd_bread (debug->ptr, amt, abfd) != amt)			\
-	goto error_return;						\
-    }
-
-  READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
-  READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
-  READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
-  READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
-  READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
-  READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
-	union aux_ext *);
-  READ (ss, cbSsOffset, issMax, sizeof (char), char *);
-  READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
-  READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
-  READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
-  READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
-#undef READ
-
-  debug->fdr = NULL;
-  debug->adjust = NULL;
-
-  return true;
-
- error_return:
-  if (ext_hdr != NULL)
-    free (ext_hdr);
-  if (debug->line != NULL)
-    free (debug->line);
-  if (debug->external_dnr != NULL)
-    free (debug->external_dnr);
-  if (debug->external_pdr != NULL)
-    free (debug->external_pdr);
-  if (debug->external_sym != NULL)
-    free (debug->external_sym);
-  if (debug->external_opt != NULL)
-    free (debug->external_opt);
-  if (debug->external_aux != NULL)
-    free (debug->external_aux);
-  if (debug->ss != NULL)
-    free (debug->ss);
-  if (debug->ssext != NULL)
-    free (debug->ssext);
-  if (debug->external_fdr != NULL)
-    free (debug->external_fdr);
-  if (debug->external_rfd != NULL)
-    free (debug->external_rfd);
-  if (debug->external_ext != NULL)
-    free (debug->external_ext);
-  return false;
-}
-
 /* MIPS ELF local labels start with '$', not 'L'.  */
 
 static boolean
@@ -4289,5420 +1747,10 @@
      the generic ELF local label syntax as well.  */
   return _bfd_elf_is_local_label_name (abfd, name);
 }
-
-/* MIPS ELF uses a special find_nearest_line routine in order the
-   handle the ECOFF debugging information.  */
-
-struct mips_elf_find_line
-{
-  struct ecoff_debug_info d;
-  struct ecoff_find_line i;
-};
-
-boolean
-_bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
-				 functionname_ptr, line_ptr)
-     bfd *abfd;
-     asection *section;
-     asymbol **symbols;
-     bfd_vma offset;
-     const char **filename_ptr;
-     const char **functionname_ptr;
-     unsigned int *line_ptr;
-{
-  asection *msec;
-
-  if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
-				     filename_ptr, functionname_ptr,
-				     line_ptr))
-    return true;
-
-  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
-				     filename_ptr, functionname_ptr,
-				     line_ptr,
-				     (unsigned) (ABI_64_P (abfd) ? 8 : 0),
-				     &elf_tdata (abfd)->dwarf2_find_line_info))
-    return true;
-
-  msec = bfd_get_section_by_name (abfd, ".mdebug");
-  if (msec != NULL)
-    {
-      flagword origflags;
-      struct mips_elf_find_line *fi;
-      const struct ecoff_debug_swap * const swap =
-	get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-
-      /* If we are called during a link, mips_elf_final_link may have
-	 cleared the SEC_HAS_CONTENTS field.  We force it back on here
-	 if appropriate (which it normally will be).  */
-      origflags = msec->flags;
-      if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
-	msec->flags |= SEC_HAS_CONTENTS;
-
-      fi = elf_tdata (abfd)->find_line_info;
-      if (fi == NULL)
-	{
-	  bfd_size_type external_fdr_size;
-	  char *fraw_src;
-	  char *fraw_end;
-	  struct fdr *fdr_ptr;
-	  bfd_size_type amt = sizeof (struct mips_elf_find_line);
-
-	  fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
-	  if (fi == NULL)
-	    {
-	      msec->flags = origflags;
-	      return false;
-	    }
-
-	  if (! _bfd_mips_elf_read_ecoff_info (abfd, msec, &fi->d))
-	    {
-	      msec->flags = origflags;
-	      return false;
-	    }
-
-	  /* Swap in the FDR information.  */
-	  amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr);
-	  fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt);
-	  if (fi->d.fdr == NULL)
-	    {
-	      msec->flags = origflags;
-	      return false;
-	    }
-	  external_fdr_size = swap->external_fdr_size;
-	  fdr_ptr = fi->d.fdr;
-	  fraw_src = (char *) fi->d.external_fdr;
-	  fraw_end = (fraw_src
-		      + fi->d.symbolic_header.ifdMax * external_fdr_size);
-	  for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
-	    (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
-
-	  elf_tdata (abfd)->find_line_info = fi;
-
-	  /* Note that we don't bother to ever free this information.
-             find_nearest_line is either called all the time, as in
-             objdump -l, so the information should be saved, or it is
-             rarely called, as in ld error messages, so the memory
-             wasted is unimportant.  Still, it would probably be a
-             good idea for free_cached_info to throw it away.  */
-	}
-
-      if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap,
-				  &fi->i, filename_ptr, functionname_ptr,
-				  line_ptr))
-	{
-	  msec->flags = origflags;
-	  return true;
-	}
-
-      msec->flags = origflags;
-    }
-
-  /* Fall back on the generic ELF find_nearest_line routine.  */
-
-  return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
-				     filename_ptr, functionname_ptr,
-				     line_ptr);
-}
 
-  /* The mips16 compiler uses a couple of special sections to handle
-     floating point arguments.
-
-     Section names that look like .mips16.fn.FNNAME contain stubs that
-     copy floating point arguments from the fp regs to the gp regs and
-     then jump to FNNAME.  If any 32 bit function calls FNNAME, the
-     call should be redirected to the stub instead.  If no 32 bit
-     function calls FNNAME, the stub should be discarded.  We need to
-     consider any reference to the function, not just a call, because
-     if the address of the function is taken we will need the stub,
-     since the address might be passed to a 32 bit function.
-
-     Section names that look like .mips16.call.FNNAME contain stubs
-     that copy floating point arguments from the gp regs to the fp
-     regs and then jump to FNNAME.  If FNNAME is a 32 bit function,
-     then any 16 bit function that calls FNNAME should be redirected
-     to the stub instead.  If FNNAME is not a 32 bit function, the
-     stub should be discarded.
-
-     .mips16.call.fp.FNNAME sections are similar, but contain stubs
-     which call FNNAME and then copy the return value from the fp regs
-     to the gp regs.  These stubs store the return value in $18 while
-     calling FNNAME; any function which might call one of these stubs
-     must arrange to save $18 around the call.  (This case is not
-     needed for 32 bit functions that call 16 bit functions, because
-     16 bit functions always return floating point values in both
-     $f0/$f1 and $2/$3.)
-
-     Note that in all cases FNNAME might be defined statically.
-     Therefore, FNNAME is not used literally.  Instead, the relocation
-     information will indicate which symbol the section is for.
-
-     We record any stubs that we find in the symbol table.  */
-
-#define FN_STUB ".mips16.fn."
-#define CALL_STUB ".mips16.call."
-#define CALL_FP_STUB ".mips16.call.fp."
-
-/* MIPS ELF linker hash table.  */
-
-struct mips_elf_link_hash_table
-{
-  struct elf_link_hash_table root;
-#if 0
-  /* We no longer use this.  */
-  /* String section indices for the dynamic section symbols.  */
-  bfd_size_type dynsym_sec_strindex[SIZEOF_MIPS_DYNSYM_SECNAMES];
-#endif
-  /* The number of .rtproc entries.  */
-  bfd_size_type procedure_count;
-  /* The size of the .compact_rel section (if SGI_COMPAT).  */
-  bfd_size_type compact_rel_size;
-  /* This flag indicates that the value of DT_MIPS_RLD_MAP dynamic
-     entry is set to the address of __rld_obj_head as in Irix 5.  */
-  boolean use_rld_obj_head;
-  /* This is the value of the __rld_map or __rld_obj_head symbol.  */
-  bfd_vma rld_value;
-  /* This is set if we see any mips16 stub sections.  */
-  boolean mips16_stubs_seen;
-};
-
-/* Look up an entry in a MIPS ELF linker hash table.  */
-
-#define mips_elf_link_hash_lookup(table, string, create, copy, follow)	\
-  ((struct mips_elf_link_hash_entry *)					\
-   elf_link_hash_lookup (&(table)->root, (string), (create),		\
-			 (copy), (follow)))
-
-/* Traverse a MIPS ELF linker hash table.  */
-
-#define mips_elf_link_hash_traverse(table, func, info)			\
-  (elf_link_hash_traverse						\
-   (&(table)->root,							\
-    (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),	\
-    (info)))
-
-/* Get the MIPS ELF linker hash table from a link_info structure.  */
-
-#define mips_elf_hash_table(p) \
-  ((struct mips_elf_link_hash_table *) ((p)->hash))
-
-static boolean mips_elf_output_extsym
-  PARAMS ((struct mips_elf_link_hash_entry *, PTR));
-
-/* Create an entry in a MIPS ELF linker hash table.  */
-
-static struct bfd_hash_entry *
-mips_elf_link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
-{
-  struct mips_elf_link_hash_entry *ret =
-    (struct mips_elf_link_hash_entry *) entry;
-
-  /* Allocate the structure if it has not already been allocated by a
-     subclass.  */
-  if (ret == (struct mips_elf_link_hash_entry *) NULL)
-    ret = ((struct mips_elf_link_hash_entry *)
-	   bfd_hash_allocate (table,
-			      sizeof (struct mips_elf_link_hash_entry)));
-  if (ret == (struct mips_elf_link_hash_entry *) NULL)
-    return (struct bfd_hash_entry *) ret;
-
-  /* Call the allocation method of the superclass.  */
-  ret = ((struct mips_elf_link_hash_entry *)
-	 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
-				     table, string));
-  if (ret != (struct mips_elf_link_hash_entry *) NULL)
-    {
-      /* Set local fields.  */
-      memset (&ret->esym, 0, sizeof (EXTR));
-      /* We use -2 as a marker to indicate that the information has
-	 not been set.  -1 means there is no associated ifd.  */
-      ret->esym.ifd = -2;
-      ret->possibly_dynamic_relocs = 0;
-      ret->readonly_reloc = false;
-      ret->min_dyn_reloc_index = 0;
-      ret->no_fn_stub = false;
-      ret->fn_stub = NULL;
-      ret->need_fn_stub = false;
-      ret->call_stub = NULL;
-      ret->call_fp_stub = NULL;
-    }
-
-  return (struct bfd_hash_entry *) ret;
-}
-
-static void
-_bfd_mips_elf_hide_symbol (info, entry, force_local)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *entry;
-     boolean force_local;
-{
-  bfd *dynobj;
-  asection *got;
-  struct mips_got_info *g;
-  struct mips_elf_link_hash_entry *h;
-  h = (struct mips_elf_link_hash_entry *) entry;
-  dynobj = elf_hash_table (info)->dynobj;
-  got = bfd_get_section_by_name (dynobj, ".got");
-  g = (struct mips_got_info *) elf_section_data (got)->tdata;
-
-  _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
-
-  /* FIXME: Do we allocate too much GOT space here?  */
-  g->local_gotno++;
-  got->_raw_size += MIPS_ELF_GOT_SIZE (dynobj);
-}
-
-/* Create a MIPS ELF linker hash table.  */
-
-struct bfd_link_hash_table *
-_bfd_mips_elf_link_hash_table_create (abfd)
-     bfd *abfd;
-{
-  struct mips_elf_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct mips_elf_link_hash_table);
-
-  ret = (struct mips_elf_link_hash_table *) bfd_alloc (abfd, amt);
-  if (ret == (struct mips_elf_link_hash_table *) NULL)
-    return NULL;
-
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-				       mips_elf_link_hash_newfunc))
-    {
-      bfd_release (abfd, ret);
-      return NULL;
-    }
-
-#if 0
-  /* We no longer use this.  */
-  for (i = 0; i < SIZEOF_MIPS_DYNSYM_SECNAMES; i++)
-    ret->dynsym_sec_strindex[i] = (bfd_size_type) -1;
-#endif
-  ret->procedure_count = 0;
-  ret->compact_rel_size = 0;
-  ret->use_rld_obj_head = false;
-  ret->rld_value = 0;
-  ret->mips16_stubs_seen = false;
-
-  return &ret->root.root;
-}
-
-/* Hook called by the linker routine which adds symbols from an object
-   file.  We must handle the special MIPS section numbers here.  */
-
-boolean
-_bfd_mips_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 ATTRIBUTE_UNUSED;
-     asection **secp;
-     bfd_vma *valp;
-{
-  if (SGI_COMPAT (abfd)
-      && (abfd->flags & DYNAMIC) != 0
-      && strcmp (*namep, "_rld_new_interface") == 0)
-    {
-      /* Skip Irix 5 rld entry name.  */
-      *namep = NULL;
-      return true;
-    }
-
-  switch (sym->st_shndx)
-    {
-    case SHN_COMMON:
-      /* Common symbols less than the GP size are automatically
-	 treated as SHN_MIPS_SCOMMON symbols.  */
-      if (sym->st_size > elf_gp_size (abfd)
-	  || IRIX_COMPAT (abfd) == ict_irix6)
-	break;
-      /* Fall through.  */
-    case SHN_MIPS_SCOMMON:
-      *secp = bfd_make_section_old_way (abfd, ".scommon");
-      (*secp)->flags |= SEC_IS_COMMON;
-      *valp = sym->st_size;
-      break;
-
-    case SHN_MIPS_TEXT:
-      /* This section is used in a shared object.  */
-      if (elf_tdata (abfd)->elf_text_section == NULL)
-	{
-	  asymbol *elf_text_symbol;
-	  asection *elf_text_section;
-	  bfd_size_type amt = sizeof (asection);
-
-	  elf_text_section = bfd_zalloc (abfd, amt);
-	  if (elf_text_section == NULL)
-	    return false;
-
-	  amt = sizeof (asymbol);
-	  elf_text_symbol = bfd_zalloc (abfd, amt);
-	  if (elf_text_symbol == NULL)
-	    return false;
-
-	  /* Initialize the section.  */
-
-	  elf_tdata (abfd)->elf_text_section = elf_text_section;
-	  elf_tdata (abfd)->elf_text_symbol = elf_text_symbol;
-
-	  elf_text_section->symbol = elf_text_symbol;
-	  elf_text_section->symbol_ptr_ptr = &elf_tdata (abfd)->elf_text_symbol;
-
-	  elf_text_section->name = ".text";
-	  elf_text_section->flags = SEC_NO_FLAGS;
-	  elf_text_section->output_section = NULL;
-	  elf_text_section->owner = abfd;
-	  elf_text_symbol->name = ".text";
-	  elf_text_symbol->flags = BSF_SECTION_SYM | BSF_DYNAMIC;
-	  elf_text_symbol->section = elf_text_section;
-	}
-      /* This code used to do *secp = bfd_und_section_ptr if
-         info->shared.  I don't know why, and that doesn't make sense,
-         so I took it out.  */
-      *secp = elf_tdata (abfd)->elf_text_section;
-      break;
-
-    case SHN_MIPS_ACOMMON:
-      /* Fall through. XXX Can we treat this as allocated data?  */
-    case SHN_MIPS_DATA:
-      /* This section is used in a shared object.  */
-      if (elf_tdata (abfd)->elf_data_section == NULL)
-	{
-	  asymbol *elf_data_symbol;
-	  asection *elf_data_section;
-	  bfd_size_type amt = sizeof (asection);
-
-	  elf_data_section = bfd_zalloc (abfd, amt);
-	  if (elf_data_section == NULL)
-	    return false;
-
-	  amt = sizeof (asymbol);
-	  elf_data_symbol = bfd_zalloc (abfd, amt);
-	  if (elf_data_symbol == NULL)
-	    return false;
-
-	  /* Initialize the section.  */
-
-	  elf_tdata (abfd)->elf_data_section = elf_data_section;
-	  elf_tdata (abfd)->elf_data_symbol = elf_data_symbol;
-
-	  elf_data_section->symbol = elf_data_symbol;
-	  elf_data_section->symbol_ptr_ptr = &elf_tdata (abfd)->elf_data_symbol;
-
-	  elf_data_section->name = ".data";
-	  elf_data_section->flags = SEC_NO_FLAGS;
-	  elf_data_section->output_section = NULL;
-	  elf_data_section->owner = abfd;
-	  elf_data_symbol->name = ".data";
-	  elf_data_symbol->flags = BSF_SECTION_SYM | BSF_DYNAMIC;
-	  elf_data_symbol->section = elf_data_section;
-	}
-      /* This code used to do *secp = bfd_und_section_ptr if
-         info->shared.  I don't know why, and that doesn't make sense,
-         so I took it out.  */
-      *secp = elf_tdata (abfd)->elf_data_section;
-      break;
-
-    case SHN_MIPS_SUNDEFINED:
-      *secp = bfd_und_section_ptr;
-      break;
-    }
-
-  if (SGI_COMPAT (abfd)
-      && ! info->shared
-      && info->hash->creator == abfd->xvec
-      && strcmp (*namep, "__rld_obj_head") == 0)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Mark __rld_obj_head as dynamic.  */
-      h = NULL;
-      if (! (_bfd_generic_link_add_one_symbol
-	     (info, abfd, *namep, BSF_GLOBAL, *secp,
-	      (bfd_vma) *valp, (const char *) NULL, false,
-	      get_elf_backend_data (abfd)->collect,
-	      (struct bfd_link_hash_entry **) &h)))
-	return false;
-      h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
-      h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-      h->type = STT_OBJECT;
-
-      if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-	return false;
-
-      mips_elf_hash_table (info)->use_rld_obj_head = true;
-    }
-
-  /* If this is a mips16 text symbol, add 1 to the value to make it
-     odd.  This will cause something like .word SYM to come up with
-     the right value when it is loaded into the PC.  */
-  if (sym->st_other == STO_MIPS16)
-    ++*valp;
-
-  return true;
-}
-
-/* Structure used to pass information to mips_elf_output_extsym.  */
-
-struct extsym_info
-{
-  bfd *abfd;
-  struct bfd_link_info *info;
-  struct ecoff_debug_info *debug;
-  const struct ecoff_debug_swap *swap;
-  boolean failed;
-};
-
-/* This routine is used to write out ECOFF debugging external symbol
-   information.  It is called via mips_elf_link_hash_traverse.  The
-   ECOFF external symbol information must match the ELF external
-   symbol information.  Unfortunately, at this point we don't know
-   whether a symbol is required by reloc information, so the two
-   tables may wind up being different.  We must sort out the external
-   symbol information before we can set the final size of the .mdebug
-   section, and we must set the size of the .mdebug section before we
-   can relocate any sections, and we can't know which symbols are
-   required by relocation until we relocate the sections.
-   Fortunately, it is relatively unlikely that any symbol will be
-   stripped but required by a reloc.  In particular, it can not happen
-   when generating a final executable.  */
-
+/* Support for core dump NOTE sections.  */
 static boolean
-mips_elf_output_extsym (h, data)
-     struct mips_elf_link_hash_entry *h;
-     PTR data;
-{
-  struct extsym_info *einfo = (struct extsym_info *) data;
-  boolean strip;
-  asection *sec, *output_section;
-
-  if (h->root.indx == -2)
-    strip = false;
-  else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-	    || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
-	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
-	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
-    strip = true;
-  else if (einfo->info->strip == strip_all
-	   || (einfo->info->strip == strip_some
-	       && bfd_hash_lookup (einfo->info->keep_hash,
-				   h->root.root.root.string,
-				   false, false) == NULL))
-    strip = true;
-  else
-    strip = false;
-
-  if (strip)
-    return true;
-
-  if (h->esym.ifd == -2)
-    {
-      h->esym.jmptbl = 0;
-      h->esym.cobol_main = 0;
-      h->esym.weakext = 0;
-      h->esym.reserved = 0;
-      h->esym.ifd = ifdNil;
-      h->esym.asym.value = 0;
-      h->esym.asym.st = stGlobal;
-
-      if (h->root.root.type == bfd_link_hash_undefined
-	  || h->root.root.type == bfd_link_hash_undefweak)
-	{
-	  const char *name;
-
-	  /* Use undefined class.  Also, set class and type for some
-             special symbols.  */
-	  name = h->root.root.root.string;
-	  if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
-	      || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
-	    {
-	      h->esym.asym.sc = scData;
-	      h->esym.asym.st = stLabel;
-	      h->esym.asym.value = 0;
-	    }
-	  else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
-	    {
-	      h->esym.asym.sc = scAbs;
-	      h->esym.asym.st = stLabel;
-	      h->esym.asym.value =
-		mips_elf_hash_table (einfo->info)->procedure_count;
-	    }
-	  else if (strcmp (name, "_gp_disp") == 0)
-	    {
-	      h->esym.asym.sc = scAbs;
-	      h->esym.asym.st = stLabel;
-	      h->esym.asym.value = elf_gp (einfo->abfd);
-	    }
-	  else
-	    h->esym.asym.sc = scUndefined;
-	}
-      else if (h->root.root.type != bfd_link_hash_defined
-	  && h->root.root.type != bfd_link_hash_defweak)
-	h->esym.asym.sc = scAbs;
-      else
-	{
-	  const char *name;
-
-	  sec = h->root.root.u.def.section;
-	  output_section = sec->output_section;
-
-	  /* When making a shared library and symbol h is the one from
-	     the another shared library, OUTPUT_SECTION may be null.  */
-	  if (output_section == NULL)
-	    h->esym.asym.sc = scUndefined;
-	  else
-	    {
-	      name = bfd_section_name (output_section->owner, output_section);
-
-	      if (strcmp (name, ".text") == 0)
-		h->esym.asym.sc = scText;
-	      else if (strcmp (name, ".data") == 0)
-		h->esym.asym.sc = scData;
-	      else if (strcmp (name, ".sdata") == 0)
-		h->esym.asym.sc = scSData;
-	      else if (strcmp (name, ".rodata") == 0
-		       || strcmp (name, ".rdata") == 0)
-		h->esym.asym.sc = scRData;
-	      else if (strcmp (name, ".bss") == 0)
-		h->esym.asym.sc = scBss;
-	      else if (strcmp (name, ".sbss") == 0)
-		h->esym.asym.sc = scSBss;
-	      else if (strcmp (name, ".init") == 0)
-		h->esym.asym.sc = scInit;
-	      else if (strcmp (name, ".fini") == 0)
-		h->esym.asym.sc = scFini;
-	      else
-		h->esym.asym.sc = scAbs;
-	    }
-	}
-
-      h->esym.asym.reserved = 0;
-      h->esym.asym.index = indexNil;
-    }
-
-  if (h->root.root.type == bfd_link_hash_common)
-    h->esym.asym.value = h->root.root.u.c.size;
-  else if (h->root.root.type == bfd_link_hash_defined
-	   || h->root.root.type == bfd_link_hash_defweak)
-    {
-      if (h->esym.asym.sc == scCommon)
-	h->esym.asym.sc = scBss;
-      else if (h->esym.asym.sc == scSCommon)
-	h->esym.asym.sc = scSBss;
-
-      sec = h->root.root.u.def.section;
-      output_section = sec->output_section;
-      if (output_section != NULL)
-	h->esym.asym.value = (h->root.root.u.def.value
-			      + sec->output_offset
-			      + output_section->vma);
-      else
-	h->esym.asym.value = 0;
-    }
-  else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
-    {
-      struct mips_elf_link_hash_entry *hd = h;
-      boolean no_fn_stub = h->no_fn_stub;
-
-      while (hd->root.root.type == bfd_link_hash_indirect)
-	{
-	  hd = (struct mips_elf_link_hash_entry *)h->root.root.u.i.link;
-	  no_fn_stub = no_fn_stub || hd->no_fn_stub;
-	}
-
-      if (!no_fn_stub)
-	{
-	  /* Set type and value for a symbol with a function stub.  */
-	  h->esym.asym.st = stProc;
-	  sec = hd->root.root.u.def.section;
-	  if (sec == NULL)
-	    h->esym.asym.value = 0;
-	  else
-	    {
-	      output_section = sec->output_section;
-	      if (output_section != NULL)
-		h->esym.asym.value = (hd->root.plt.offset
-				      + sec->output_offset
-				      + output_section->vma);
-	      else
-		h->esym.asym.value = 0;
-	    }
-#if 0 /* FIXME?  */
-	  h->esym.ifd = 0;
-#endif
-	}
-    }
-
-  if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
-				      h->root.root.root.string,
-				      &h->esym))
-    {
-      einfo->failed = true;
-      return false;
-    }
-
-  return true;
-}
-
-/* Create a runtime procedure table from the .mdebug section.  */
-
-static boolean
-mips_elf_create_procedure_table (handle, abfd, info, s, debug)
-     PTR handle;
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *s;
-     struct ecoff_debug_info *debug;
-{
-  const struct ecoff_debug_swap *swap;
-  HDRR *hdr = &debug->symbolic_header;
-  RPDR *rpdr, *rp;
-  struct rpdr_ext *erp;
-  PTR rtproc;
-  struct pdr_ext *epdr;
-  struct sym_ext *esym;
-  char *ss, **sv;
-  char *str;
-  bfd_size_type size;
-  bfd_size_type count;
-  unsigned long sindex;
-  unsigned long i;
-  PDR pdr;
-  SYMR sym;
-  const char *no_name_func = _("static procedure (no name)");
-
-  epdr = NULL;
-  rpdr = NULL;
-  esym = NULL;
-  ss = NULL;
-  sv = NULL;
-
-  swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-
-  sindex = strlen (no_name_func) + 1;
-  count = hdr->ipdMax;
-  if (count > 0)
-    {
-      size = swap->external_pdr_size;
-
-      epdr = (struct pdr_ext *) bfd_malloc (size * count);
-      if (epdr == NULL)
-	goto error_return;
-
-      if (! _bfd_ecoff_get_accumulated_pdr (handle, (PTR) epdr))
-	goto error_return;
-
-      size = sizeof (RPDR);
-      rp = rpdr = (RPDR *) bfd_malloc (size * count);
-      if (rpdr == NULL)
-	goto error_return;
-
-      size = sizeof (char *);
-      sv = (char **) bfd_malloc (size * count);
-      if (sv == NULL)
-	goto error_return;
-
-      count = hdr->isymMax;
-      size = swap->external_sym_size;
-      esym = (struct sym_ext *) bfd_malloc (size * count);
-      if (esym == NULL)
-	goto error_return;
-
-      if (! _bfd_ecoff_get_accumulated_sym (handle, (PTR) esym))
-	goto error_return;
-
-      count = hdr->issMax;
-      ss = (char *) bfd_malloc (count);
-      if (ss == NULL)
-	goto error_return;
-      if (! _bfd_ecoff_get_accumulated_ss (handle, (PTR) ss))
-	goto error_return;
-
-      count = hdr->ipdMax;
-      for (i = 0; i < (unsigned long) count; i++, rp++)
-	{
-	  (*swap->swap_pdr_in) (abfd, (PTR) (epdr + i), &pdr);
-	  (*swap->swap_sym_in) (abfd, (PTR) &esym[pdr.isym], &sym);
-	  rp->adr = sym.value;
-	  rp->regmask = pdr.regmask;
-	  rp->regoffset = pdr.regoffset;
-	  rp->fregmask = pdr.fregmask;
-	  rp->fregoffset = pdr.fregoffset;
-	  rp->frameoffset = pdr.frameoffset;
-	  rp->framereg = pdr.framereg;
-	  rp->pcreg = pdr.pcreg;
-	  rp->irpss = sindex;
-	  sv[i] = ss + sym.iss;
-	  sindex += strlen (sv[i]) + 1;
-	}
-    }
-
-  size = sizeof (struct rpdr_ext) * (count + 2) + sindex;
-  size = BFD_ALIGN (size, 16);
-  rtproc = (PTR) bfd_alloc (abfd, size);
-  if (rtproc == NULL)
-    {
-      mips_elf_hash_table (info)->procedure_count = 0;
-      goto error_return;
-    }
-
-  mips_elf_hash_table (info)->procedure_count = count + 2;
-
-  erp = (struct rpdr_ext *) rtproc;
-  memset (erp, 0, sizeof (struct rpdr_ext));
-  erp++;
-  str = (char *) rtproc + sizeof (struct rpdr_ext) * (count + 2);
-  strcpy (str, no_name_func);
-  str += strlen (no_name_func) + 1;
-  for (i = 0; i < count; i++)
-    {
-      ecoff_swap_rpdr_out (abfd, rpdr + i, erp + i);
-      strcpy (str, sv[i]);
-      str += strlen (sv[i]) + 1;
-    }
-  ECOFF_PUT_OFF (abfd, -1, (erp + count)->p_adr);
-
-  /* Set the size and contents of .rtproc section.  */
-  s->_raw_size = size;
-  s->contents = (bfd_byte *) rtproc;
-
-  /* Skip this section later on (I don't think this currently
-     matters, but someday it might).  */
-  s->link_order_head = (struct bfd_link_order *) NULL;
-
-  if (epdr != NULL)
-    free (epdr);
-  if (rpdr != NULL)
-    free (rpdr);
-  if (esym != NULL)
-    free (esym);
-  if (ss != NULL)
-    free (ss);
-  if (sv != NULL)
-    free (sv);
-
-  return true;
-
- error_return:
-  if (epdr != NULL)
-    free (epdr);
-  if (rpdr != NULL)
-    free (rpdr);
-  if (esym != NULL)
-    free (esym);
-  if (ss != NULL)
-    free (ss);
-  if (sv != NULL)
-    free (sv);
-  return false;
-}
-
-/* A comparison routine used to sort .gptab entries.  */
-
-static int
-gptab_compare (p1, p2)
-     const PTR p1;
-     const PTR p2;
-{
-  const Elf32_gptab *a1 = (const Elf32_gptab *) p1;
-  const Elf32_gptab *a2 = (const Elf32_gptab *) p2;
-
-  return a1->gt_entry.gt_g_value - a2->gt_entry.gt_g_value;
-}
-
-/* We need to use a special link routine to handle the .reginfo and
-   the .mdebug sections.  We need to merge all instances of these
-   sections together, not write them all out sequentially.  */
-
-boolean
-_bfd_mips_elf_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
-{
-  asection **secpp;
-  asection *o;
-  struct bfd_link_order *p;
-  asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
-  asection *rtproc_sec;
-  Elf32_RegInfo reginfo;
-  struct ecoff_debug_info debug;
-  const struct ecoff_debug_swap *swap
-    = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-  HDRR *symhdr = &debug.symbolic_header;
-  PTR mdebug_handle = NULL;
-  asection *s;
-  EXTR esym;
-  unsigned int i;
-  bfd_size_type amt;
-
-  static const char * const secname[] =
-  {
-    ".text", ".init", ".fini", ".data",
-    ".rodata", ".sdata", ".sbss", ".bss"
-  };
-  static const int sc[] =
-  {
-    scText, scInit, scFini, scData,
-    scRData, scSData, scSBss, scBss
-  };
-
-  /* If all the things we linked together were PIC, but we're
-     producing an executable (rather than a shared object), then the
-     resulting file is CPIC (i.e., it calls PIC code.)  */
-  if (!info->shared
-      && !info->relocateable
-      && elf_elfheader (abfd)->e_flags & EF_MIPS_PIC)
-    {
-      elf_elfheader (abfd)->e_flags &= ~EF_MIPS_PIC;
-      elf_elfheader (abfd)->e_flags |= EF_MIPS_CPIC;
-    }
-
-  /* We'd carefully arranged the dynamic symbol indices, and then the
-     generic size_dynamic_sections renumbered them out from under us.
-     Rather than trying somehow to prevent the renumbering, just do
-     the sort again.  */
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      bfd *dynobj;
-      asection *got;
-      struct mips_got_info *g;
-
-      /* When we resort, we must tell mips_elf_sort_hash_table what
-	 the lowest index it may use is.  That's the number of section
-	 symbols we're going to add.  The generic ELF linker only
-	 adds these symbols when building a shared object.  Note that
-	 we count the sections after (possibly) removing the .options
-	 section above.  */
-      if (!mips_elf_sort_hash_table (info, (info->shared
-					    ? bfd_count_sections (abfd) + 1
-					    : 1)))
-	return false;
-
-      /* Make sure we didn't grow the global .got region.  */
-      dynobj = elf_hash_table (info)->dynobj;
-      got = bfd_get_section_by_name (dynobj, ".got");
-      g = (struct mips_got_info *) elf_section_data (got)->tdata;
-
-      if (g->global_gotsym != NULL)
-	BFD_ASSERT ((elf_hash_table (info)->dynsymcount
-		     - g->global_gotsym->dynindx)
-		    <= g->global_gotno);
-    }
-
-  /* On IRIX5, we omit the .options section.  On IRIX6, however, we
-     include it, even though we don't process it quite right.  (Some
-     entries are supposed to be merged.)  Empirically, we seem to be
-     better off including it then not.  */
-  if (IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
-    for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
-      {
-	if (strcmp ((*secpp)->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
-	  {
-	    for (p = (*secpp)->link_order_head; p != NULL; p = p->next)
-	      if (p->type == bfd_indirect_link_order)
-		p->u.indirect.section->flags &= ~SEC_HAS_CONTENTS;
-	    (*secpp)->link_order_head = NULL;
-	    bfd_section_list_remove (abfd, secpp);
-	    --abfd->section_count;
-
-	    break;
-	  }
-      }
-
-  /* Get a value for the GP register.  */
-  if (elf_gp (abfd) == 0)
-    {
-      struct bfd_link_hash_entry *h;
-
-      h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
-      if (h != (struct bfd_link_hash_entry *) NULL
-	  && h->type == bfd_link_hash_defined)
-	elf_gp (abfd) = (h->u.def.value
-			 + h->u.def.section->output_section->vma
-			 + h->u.def.section->output_offset);
-      else if (info->relocateable)
-	{
-	  bfd_vma lo;
-
-	  /* Find the GP-relative section with the lowest offset.  */
-	  lo = (bfd_vma) -1;
-	  for (o = abfd->sections; o != (asection *) NULL; o = o->next)
-	    if (o->vma < lo
-		&& (elf_section_data (o)->this_hdr.sh_flags & SHF_MIPS_GPREL))
-	      lo = o->vma;
-
-	  /* And calculate GP relative to that.  */
-	  elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (abfd);
-	}
-      else
-	{
-	  /* If the relocate_section function needs to do a reloc
-	     involving the GP value, it should make a reloc_dangerous
-	     callback to warn that GP is not defined.  */
-	}
-    }
-
-  /* Go through the sections and collect the .reginfo and .mdebug
-     information.  */
-  reginfo_sec = NULL;
-  mdebug_sec = NULL;
-  gptab_data_sec = NULL;
-  gptab_bss_sec = NULL;
-  for (o = abfd->sections; o != (asection *) NULL; o = o->next)
-    {
-      if (strcmp (o->name, ".reginfo") == 0)
-	{
-	  memset (&reginfo, 0, sizeof reginfo);
-
-	  /* We have found the .reginfo section in the output file.
-	     Look through all the link_orders comprising it and merge
-	     the information together.  */
-	  for (p = o->link_order_head;
-	       p != (struct bfd_link_order *) NULL;
-	       p = p->next)
-	    {
-	      asection *input_section;
-	      bfd *input_bfd;
-	      Elf32_External_RegInfo ext;
-	      Elf32_RegInfo sub;
-
-	      if (p->type != bfd_indirect_link_order)
-		{
-		  if (p->type == bfd_data_link_order)
-		    continue;
-		  abort ();
-		}
-
-	      input_section = p->u.indirect.section;
-	      input_bfd = input_section->owner;
-
-	      /* The linker emulation code has probably clobbered the
-                 size to be zero bytes.  */
-	      if (input_section->_raw_size == 0)
-		input_section->_raw_size = sizeof (Elf32_External_RegInfo);
-
-	      if (! bfd_get_section_contents (input_bfd, input_section,
-					      (PTR) &ext,
-					      (file_ptr) 0,
-					      (bfd_size_type) sizeof ext))
-		return false;
-
-	      bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);
-
-	      reginfo.ri_gprmask |= sub.ri_gprmask;
-	      reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
-	      reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
-	      reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
-	      reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
-
-	      /* ri_gp_value is set by the function
-		 mips_elf32_section_processing when the section is
-		 finally written out.  */
-
-	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		 elf_link_input_bfd ignores this section.  */
-	      input_section->flags &= ~SEC_HAS_CONTENTS;
-	    }
-
-	  /* Size has been set in mips_elf_always_size_sections  */
-	  BFD_ASSERT(o->_raw_size == sizeof (Elf32_External_RegInfo));
-
-	  /* Skip this section later on (I don't think this currently
-	     matters, but someday it might).  */
-	  o->link_order_head = (struct bfd_link_order *) NULL;
-
-	  reginfo_sec = o;
-	}
-
-      if (strcmp (o->name, ".mdebug") == 0)
-	{
-	  struct extsym_info einfo;
-	  bfd_vma last;
-
-	  /* We have found the .mdebug section in the output file.
-	     Look through all the link_orders comprising it and merge
-	     the information together.  */
-	  symhdr->magic = swap->sym_magic;
-	  /* FIXME: What should the version stamp be?  */
-	  symhdr->vstamp = 0;
-	  symhdr->ilineMax = 0;
-	  symhdr->cbLine = 0;
-	  symhdr->idnMax = 0;
-	  symhdr->ipdMax = 0;
-	  symhdr->isymMax = 0;
-	  symhdr->ioptMax = 0;
-	  symhdr->iauxMax = 0;
-	  symhdr->issMax = 0;
-	  symhdr->issExtMax = 0;
-	  symhdr->ifdMax = 0;
-	  symhdr->crfd = 0;
-	  symhdr->iextMax = 0;
-
-	  /* We accumulate the debugging information itself in the
-	     debug_info structure.  */
-	  debug.line = NULL;
-	  debug.external_dnr = NULL;
-	  debug.external_pdr = NULL;
-	  debug.external_sym = NULL;
-	  debug.external_opt = NULL;
-	  debug.external_aux = NULL;
-	  debug.ss = NULL;
-	  debug.ssext = debug.ssext_end = NULL;
-	  debug.external_fdr = NULL;
-	  debug.external_rfd = NULL;
-	  debug.external_ext = debug.external_ext_end = NULL;
-
-	  mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
-	  if (mdebug_handle == (PTR) NULL)
-	    return false;
-
-	  esym.jmptbl = 0;
-	  esym.cobol_main = 0;
-	  esym.weakext = 0;
-	  esym.reserved = 0;
-	  esym.ifd = ifdNil;
-	  esym.asym.iss = issNil;
-	  esym.asym.st = stLocal;
-	  esym.asym.reserved = 0;
-	  esym.asym.index = indexNil;
-	  last = 0;
-	  for (i = 0; i < sizeof (secname) / sizeof (secname[0]); i++)
-	    {
-	      esym.asym.sc = sc[i];
-	      s = bfd_get_section_by_name (abfd, secname[i]);
-	      if (s != NULL)
-		{
-		  esym.asym.value = s->vma;
-		  last = s->vma + s->_raw_size;
-		}
-	      else
-		esym.asym.value = last;
-	      if (!bfd_ecoff_debug_one_external (abfd, &debug, swap,
-						 secname[i], &esym))
-		return false;
-	    }
-
-	  for (p = o->link_order_head;
-	       p != (struct bfd_link_order *) NULL;
-	       p = p->next)
-	    {
-	      asection *input_section;
-	      bfd *input_bfd;
-	      const struct ecoff_debug_swap *input_swap;
-	      struct ecoff_debug_info input_debug;
-	      char *eraw_src;
-	      char *eraw_end;
-
-	      if (p->type != bfd_indirect_link_order)
-		{
-		  if (p->type == bfd_data_link_order)
-		    continue;
-		  abort ();
-		}
-
-	      input_section = p->u.indirect.section;
-	      input_bfd = input_section->owner;
-
-	      if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
-		  || (get_elf_backend_data (input_bfd)
-		      ->elf_backend_ecoff_debug_swap) == NULL)
-		{
-		  /* I don't know what a non MIPS ELF bfd would be
-		     doing with a .mdebug section, but I don't really
-		     want to deal with it.  */
-		  continue;
-		}
-
-	      input_swap = (get_elf_backend_data (input_bfd)
-			    ->elf_backend_ecoff_debug_swap);
-
-	      BFD_ASSERT (p->size == input_section->_raw_size);
-
-	      /* The ECOFF linking code expects that we have already
-		 read in the debugging information and set up an
-		 ecoff_debug_info structure, so we do that now.  */
-	      if (! _bfd_mips_elf_read_ecoff_info (input_bfd, input_section,
-						   &input_debug))
-		return false;
-
-	      if (! (bfd_ecoff_debug_accumulate
-		     (mdebug_handle, abfd, &debug, swap, input_bfd,
-		      &input_debug, input_swap, info)))
-		return false;
-
-	      /* Loop through the external symbols.  For each one with
-		 interesting information, try to find the symbol in
-		 the linker global hash table and save the information
-		 for the output external symbols.  */
-	      eraw_src = input_debug.external_ext;
-	      eraw_end = (eraw_src
-			  + (input_debug.symbolic_header.iextMax
-			     * input_swap->external_ext_size));
-	      for (;
-		   eraw_src < eraw_end;
-		   eraw_src += input_swap->external_ext_size)
-		{
-		  EXTR ext;
-		  const char *name;
-		  struct mips_elf_link_hash_entry *h;
-
-		  (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
-		  if (ext.asym.sc == scNil
-		      || ext.asym.sc == scUndefined
-		      || ext.asym.sc == scSUndefined)
-		    continue;
-
-		  name = input_debug.ssext + ext.asym.iss;
-		  h = mips_elf_link_hash_lookup (mips_elf_hash_table (info),
-						 name, false, false, true);
-		  if (h == NULL || h->esym.ifd != -2)
-		    continue;
-
-		  if (ext.ifd != -1)
-		    {
-		      BFD_ASSERT (ext.ifd
-				  < input_debug.symbolic_header.ifdMax);
-		      ext.ifd = input_debug.ifdmap[ext.ifd];
-		    }
-
-		  h->esym = ext;
-		}
-
-	      /* Free up the information we just read.  */
-	      free (input_debug.line);
-	      free (input_debug.external_dnr);
-	      free (input_debug.external_pdr);
-	      free (input_debug.external_sym);
-	      free (input_debug.external_opt);
-	      free (input_debug.external_aux);
-	      free (input_debug.ss);
-	      free (input_debug.ssext);
-	      free (input_debug.external_fdr);
-	      free (input_debug.external_rfd);
-	      free (input_debug.external_ext);
-
-	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		 elf_link_input_bfd ignores this section.  */
-	      input_section->flags &= ~SEC_HAS_CONTENTS;
-	    }
-
-	  if (SGI_COMPAT (abfd) && info->shared)
-	    {
-	      /* Create .rtproc section.  */
-	      rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
-	      if (rtproc_sec == NULL)
-		{
-		  flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
-				    | SEC_LINKER_CREATED | SEC_READONLY);
-
-		  rtproc_sec = bfd_make_section (abfd, ".rtproc");
-		  if (rtproc_sec == NULL
-		      || ! bfd_set_section_flags (abfd, rtproc_sec, flags)
-		      || ! bfd_set_section_alignment (abfd, rtproc_sec, 4))
-		    return false;
-		}
-
-	      if (! mips_elf_create_procedure_table (mdebug_handle, abfd,
-						     info, rtproc_sec, &debug))
-		return false;
-	    }
-
-	  /* Build the external symbol information.  */
-	  einfo.abfd = abfd;
-	  einfo.info = info;
-	  einfo.debug = &debug;
-	  einfo.swap = swap;
-	  einfo.failed = false;
-	  mips_elf_link_hash_traverse (mips_elf_hash_table (info),
-				       mips_elf_output_extsym,
-				       (PTR) &einfo);
-	  if (einfo.failed)
-	    return false;
-
-	  /* Set the size of the .mdebug section.  */
-	  o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
-
-	  /* Skip this section later on (I don't think this currently
-	     matters, but someday it might).  */
-	  o->link_order_head = (struct bfd_link_order *) NULL;
-
-	  mdebug_sec = o;
-	}
-
-      if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
-	{
-	  const char *subname;
-	  unsigned int c;
-	  Elf32_gptab *tab;
-	  Elf32_External_gptab *ext_tab;
-	  unsigned int j;
-
-	  /* The .gptab.sdata and .gptab.sbss sections hold
-	     information describing how the small data area would
-	     change depending upon the -G switch.  These sections
-	     not used in executables files.  */
-	  if (! info->relocateable)
-	    {
-	      for (p = o->link_order_head;
-		   p != (struct bfd_link_order *) NULL;
-		   p = p->next)
-		{
-		  asection *input_section;
-
-		  if (p->type != bfd_indirect_link_order)
-		    {
-		      if (p->type == bfd_data_link_order)
-			continue;
-		      abort ();
-		    }
-
-		  input_section = p->u.indirect.section;
-
-		  /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		     elf_link_input_bfd ignores this section.  */
-		  input_section->flags &= ~SEC_HAS_CONTENTS;
-		}
-
-	      /* Skip this section later on (I don't think this
-		 currently matters, but someday it might).  */
-	      o->link_order_head = (struct bfd_link_order *) NULL;
-
-	      /* Really remove the section.  */
-	      for (secpp = &abfd->sections;
-		   *secpp != o;
-		   secpp = &(*secpp)->next)
-		;
-	      bfd_section_list_remove (abfd, secpp);
-	      --abfd->section_count;
-
-	      continue;
-	    }
-
-	  /* There is one gptab for initialized data, and one for
-	     uninitialized data.  */
-	  if (strcmp (o->name, ".gptab.sdata") == 0)
-	    gptab_data_sec = o;
-	  else if (strcmp (o->name, ".gptab.sbss") == 0)
-	    gptab_bss_sec = o;
-	  else
-	    {
-	      (*_bfd_error_handler)
-		(_("%s: illegal section name `%s'"),
-		 bfd_get_filename (abfd), o->name);
-	      bfd_set_error (bfd_error_nonrepresentable_section);
-	      return false;
-	    }
-
-	  /* The linker script always combines .gptab.data and
-	     .gptab.sdata into .gptab.sdata, and likewise for
-	     .gptab.bss and .gptab.sbss.  It is possible that there is
-	     no .sdata or .sbss section in the output file, in which
-	     case we must change the name of the output section.  */
-	  subname = o->name + sizeof ".gptab" - 1;
-	  if (bfd_get_section_by_name (abfd, subname) == NULL)
-	    {
-	      if (o == gptab_data_sec)
-		o->name = ".gptab.data";
-	      else
-		o->name = ".gptab.bss";
-	      subname = o->name + sizeof ".gptab" - 1;
-	      BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
-	    }
-
-	  /* Set up the first entry.  */
-	  c = 1;
-	  amt = c * sizeof (Elf32_gptab);
-	  tab = (Elf32_gptab *) bfd_malloc (amt);
-	  if (tab == NULL)
-	    return false;
-	  tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
-	  tab[0].gt_header.gt_unused = 0;
-
-	  /* Combine the input sections.  */
-	  for (p = o->link_order_head;
-	       p != (struct bfd_link_order *) NULL;
-	       p = p->next)
-	    {
-	      asection *input_section;
-	      bfd *input_bfd;
-	      bfd_size_type size;
-	      unsigned long last;
-	      bfd_size_type gpentry;
-
-	      if (p->type != bfd_indirect_link_order)
-		{
-		  if (p->type == bfd_data_link_order)
-		    continue;
-		  abort ();
-		}
-
-	      input_section = p->u.indirect.section;
-	      input_bfd = input_section->owner;
-
-	      /* Combine the gptab entries for this input section one
-		 by one.  We know that the input gptab entries are
-		 sorted by ascending -G value.  */
-	      size = bfd_section_size (input_bfd, input_section);
-	      last = 0;
-	      for (gpentry = sizeof (Elf32_External_gptab);
-		   gpentry < size;
-		   gpentry += sizeof (Elf32_External_gptab))
-		{
-		  Elf32_External_gptab ext_gptab;
-		  Elf32_gptab int_gptab;
-		  unsigned long val;
-		  unsigned long add;
-		  boolean exact;
-		  unsigned int look;
-
-		  if (! (bfd_get_section_contents
-			 (input_bfd, input_section, (PTR) &ext_gptab,
-			  (file_ptr) gpentry,
-			  (bfd_size_type) sizeof (Elf32_External_gptab))))
-		    {
-		      free (tab);
-		      return false;
-		    }
-
-		  bfd_mips_elf32_swap_gptab_in (input_bfd, &ext_gptab,
-						&int_gptab);
-		  val = int_gptab.gt_entry.gt_g_value;
-		  add = int_gptab.gt_entry.gt_bytes - last;
-
-		  exact = false;
-		  for (look = 1; look < c; look++)
-		    {
-		      if (tab[look].gt_entry.gt_g_value >= val)
-			tab[look].gt_entry.gt_bytes += add;
-
-		      if (tab[look].gt_entry.gt_g_value == val)
-			exact = true;
-		    }
-
-		  if (! exact)
-		    {
-		      Elf32_gptab *new_tab;
-		      unsigned int max;
-
-		      /* We need a new table entry.  */
-		      amt = (bfd_size_type) (c + 1) * sizeof (Elf32_gptab);
-		      new_tab = (Elf32_gptab *) bfd_realloc ((PTR) tab, amt);
-		      if (new_tab == NULL)
-			{
-			  free (tab);
-			  return false;
-			}
-		      tab = new_tab;
-		      tab[c].gt_entry.gt_g_value = val;
-		      tab[c].gt_entry.gt_bytes = add;
-
-		      /* Merge in the size for the next smallest -G
-			 value, since that will be implied by this new
-			 value.  */
-		      max = 0;
-		      for (look = 1; look < c; look++)
-			{
-			  if (tab[look].gt_entry.gt_g_value < val
-			      && (max == 0
-				  || (tab[look].gt_entry.gt_g_value
-				      > tab[max].gt_entry.gt_g_value)))
-			    max = look;
-			}
-		      if (max != 0)
-			tab[c].gt_entry.gt_bytes +=
-			  tab[max].gt_entry.gt_bytes;
-
-		      ++c;
-		    }
-
-		  last = int_gptab.gt_entry.gt_bytes;
-		}
-
-	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		 elf_link_input_bfd ignores this section.  */
-	      input_section->flags &= ~SEC_HAS_CONTENTS;
-	    }
-
-	  /* The table must be sorted by -G value.  */
-	  if (c > 2)
-	    qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
-
-	  /* Swap out the table.  */
-	  amt = (bfd_size_type) c * sizeof (Elf32_External_gptab);
-	  ext_tab = (Elf32_External_gptab *) bfd_alloc (abfd, amt);
-	  if (ext_tab == NULL)
-	    {
-	      free (tab);
-	      return false;
-	    }
-
-	  for (j = 0; j < c; j++)
-	    bfd_mips_elf32_swap_gptab_out (abfd, tab + j, ext_tab + j);
-	  free (tab);
-
-	  o->_raw_size = c * sizeof (Elf32_External_gptab);
-	  o->contents = (bfd_byte *) ext_tab;
-
-	  /* Skip this section later on (I don't think this currently
-	     matters, but someday it might).  */
-	  o->link_order_head = (struct bfd_link_order *) NULL;
-	}
-    }
-
-  /* Invoke the regular ELF backend linker to do all the work.  */
-  if (ABI_64_P (abfd))
-    {
-#ifdef BFD64
-      if (!bfd_elf64_bfd_final_link (abfd, info))
-	return false;
-#else
-      abort ();
-      return false;
-#endif /* BFD64 */
-    }
-  else if (!bfd_elf32_bfd_final_link (abfd, info))
-    return false;
-
-  /* Now write out the computed sections.  */
-
-  if (reginfo_sec != (asection *) NULL)
-    {
-      Elf32_External_RegInfo ext;
-
-      bfd_mips_elf32_swap_reginfo_out (abfd, &reginfo, &ext);
-      if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
-				      (file_ptr) 0, (bfd_size_type) sizeof ext))
-	return false;
-    }
-
-  if (mdebug_sec != (asection *) NULL)
-    {
-      BFD_ASSERT (abfd->output_has_begun);
-      if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
-					       swap, info,
-					       mdebug_sec->filepos))
-	return false;
-
-      bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
-    }
-
-  if (gptab_data_sec != (asection *) NULL)
-    {
-      if (! bfd_set_section_contents (abfd, gptab_data_sec,
-				      gptab_data_sec->contents,
-				      (file_ptr) 0,
-				      gptab_data_sec->_raw_size))
-	return false;
-    }
-
-  if (gptab_bss_sec != (asection *) NULL)
-    {
-      if (! bfd_set_section_contents (abfd, gptab_bss_sec,
-				      gptab_bss_sec->contents,
-				      (file_ptr) 0,
-				      gptab_bss_sec->_raw_size))
-	return false;
-    }
-
-  if (SGI_COMPAT (abfd))
-    {
-      rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
-      if (rtproc_sec != NULL)
-	{
-	  if (! bfd_set_section_contents (abfd, rtproc_sec,
-					  rtproc_sec->contents,
-					  (file_ptr) 0,
-					  rtproc_sec->_raw_size))
-	    return false;
-	}
-    }
-
-  return true;
-}
-
-/* This function is called via qsort() to sort the dynamic relocation
-   entries by increasing r_symndx value.  */
-
-static int
-sort_dynamic_relocs (arg1, arg2)
-     const PTR arg1;
-     const PTR arg2;
-{
-  const Elf32_External_Rel *ext_reloc1 = (const Elf32_External_Rel *) arg1;
-  const Elf32_External_Rel *ext_reloc2 = (const Elf32_External_Rel *) arg2;
-
-  Elf_Internal_Rel int_reloc1;
-  Elf_Internal_Rel int_reloc2;
-
-  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, ext_reloc1, &int_reloc1);
-  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, ext_reloc2, &int_reloc2);
-
-  return (ELF32_R_SYM (int_reloc1.r_info) - ELF32_R_SYM (int_reloc2.r_info));
-}
-
-/* Returns the GOT section for ABFD.  */
-
-static asection *
-mips_elf_got_section (abfd)
-     bfd *abfd;
-{
-  return bfd_get_section_by_name (abfd, ".got");
-}
-
-/* Returns the GOT information associated with the link indicated by
-   INFO.  If SGOTP is non-NULL, it is filled in with the GOT
-   section.  */
-
-static struct mips_got_info *
-mips_elf_got_info (abfd, sgotp)
-     bfd *abfd;
-     asection **sgotp;
-{
-  asection *sgot;
-  struct mips_got_info *g;
-
-  sgot = mips_elf_got_section (abfd);
-  BFD_ASSERT (sgot != NULL);
-  BFD_ASSERT (elf_section_data (sgot) != NULL);
-  g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
-  BFD_ASSERT (g != NULL);
-
-  if (sgotp)
-    *sgotp = sgot;
-  return g;
-}
-
-/* Return whether a relocation is against a local symbol.  */
-
-static boolean
-mips_elf_local_relocation_p (input_bfd, relocation, local_sections,
-			     check_forced)
-     bfd *input_bfd;
-     const Elf_Internal_Rela *relocation;
-     asection **local_sections;
-     boolean check_forced;
-{
-  unsigned long r_symndx;
-  Elf_Internal_Shdr *symtab_hdr;
-  struct mips_elf_link_hash_entry *h;
-  size_t extsymoff;
-
-  r_symndx = ELF32_R_SYM (relocation->r_info);
-  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
-  extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
-
-  if (r_symndx < extsymoff)
-    return true;
-  if (elf_bad_symtab (input_bfd) && local_sections[r_symndx] != NULL)
-    return true;
-
-  if (check_forced)
-    {
-      /* Look up the hash table to check whether the symbol
- 	 was forced local.  */
-      h = (struct mips_elf_link_hash_entry *)
-	elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
-      /* Find the real hash-table entry for this symbol.  */
-      while (h->root.root.type == bfd_link_hash_indirect
- 	     || h->root.root.type == bfd_link_hash_warning)
-	h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
-      if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
-	return true;
-    }
-
-  return false;
-}
-
-/* Sign-extend VALUE, which has the indicated number of BITS.  */
-
-static bfd_vma
-mips_elf_sign_extend (value, bits)
-     bfd_vma value;
-     int bits;
-{
-  if (value & ((bfd_vma) 1 << (bits - 1)))
-    /* VALUE is negative.  */
-    value |= ((bfd_vma) - 1) << bits;
-
-  return value;
-}
-
-/* Return non-zero if the indicated VALUE has overflowed the maximum
-   range expressable by a signed number with the indicated number of
-   BITS.  */
-
-static boolean
-mips_elf_overflow_p (value, bits)
-     bfd_vma value;
-     int bits;
-{
-  bfd_signed_vma svalue = (bfd_signed_vma) value;
-
-  if (svalue > (1 << (bits - 1)) - 1)
-    /* The value is too big.  */
-    return true;
-  else if (svalue < -(1 << (bits - 1)))
-    /* The value is too small.  */
-    return true;
-
-  /* All is well.  */
-  return false;
-}
-
-/* Calculate the %high function.  */
-
-static bfd_vma
-mips_elf_high (value)
-     bfd_vma value;
-{
-  return ((value + (bfd_vma) 0x8000) >> 16) & 0xffff;
-}
-
-/* Calculate the %higher function.  */
-
-static bfd_vma
-mips_elf_higher (value)
-     bfd_vma value ATTRIBUTE_UNUSED;
-{
-#ifdef BFD64
-  return ((value + (bfd_vma) 0x80008000) >> 32) & 0xffff;
-#else
-  abort ();
-  return (bfd_vma) -1;
-#endif
-}
-
-/* Calculate the %highest function.  */
-
-static bfd_vma
-mips_elf_highest (value)
-     bfd_vma value ATTRIBUTE_UNUSED;
-{
-#ifdef BFD64
-  return ((value + (bfd_vma) 0x800080008000) >> 48) & 0xffff;
-#else
-  abort ();
-  return (bfd_vma) -1;
-#endif
-}
-
-/* Returns the GOT index for the global symbol indicated by H.  */
-
-static bfd_vma
-mips_elf_global_got_index (abfd, h)
-     bfd *abfd;
-     struct elf_link_hash_entry *h;
-{
-  bfd_vma index;
-  asection *sgot;
-  struct mips_got_info *g;
-
-  g = mips_elf_got_info (abfd, &sgot);
-
-  /* Once we determine the global GOT entry with the lowest dynamic
-     symbol table index, we must put all dynamic symbols with greater
-     indices into the GOT.  That makes it easy to calculate the GOT
-     offset.  */
-  BFD_ASSERT (h->dynindx >= g->global_gotsym->dynindx);
-  index = ((h->dynindx - g->global_gotsym->dynindx + g->local_gotno)
-	   * MIPS_ELF_GOT_SIZE (abfd));
-  BFD_ASSERT (index < sgot->_raw_size);
-
-  return index;
-}
-
-/* Returns the offset for the entry at the INDEXth position
-   in the GOT.  */
-
-static bfd_vma
-mips_elf_got_offset_from_index (dynobj, output_bfd, index)
-     bfd *dynobj;
-     bfd *output_bfd;
-     bfd_vma index;
-{
-  asection *sgot;
-  bfd_vma gp;
-
-  sgot = mips_elf_got_section (dynobj);
-  gp = _bfd_get_gp_value (output_bfd);
-  return (sgot->output_section->vma + sgot->output_offset + index -
-	  gp);
-}
-
-/* If H is a symbol that needs a global GOT entry, but has a dynamic
-   symbol table index lower than any we've seen to date, record it for
-   posterity.  */
-
-static boolean
-mips_elf_record_global_got_symbol (h, info, g)
-     struct elf_link_hash_entry *h;
-     struct bfd_link_info *info;
-     struct mips_got_info *g ATTRIBUTE_UNUSED;
-{
-  /* A global symbol in the GOT must also be in the dynamic symbol
-     table.  */
-  if (h->dynindx == -1
-      && !bfd_elf32_link_record_dynamic_symbol (info, h))
-    return false;
-
-  /* If we've already marked this entry as needing GOT space, we don't
-     need to do it again.  */
-  if (h->got.offset != (bfd_vma) -1)
-    return true;
-
-  /* By setting this to a value other than -1, we are indicating that
-     there needs to be a GOT entry for H.  Avoid using zero, as the
-     generic ELF copy_indirect_symbol tests for <= 0.  */
-  h->got.offset = 1;
-
-  return true;
-}
-
-/* This structure is passed to mips_elf_sort_hash_table_f when sorting
-   the dynamic symbols.  */
-
-struct mips_elf_hash_sort_data
-{
-  /* The symbol in the global GOT with the lowest dynamic symbol table
-     index.  */
-  struct elf_link_hash_entry *low;
-  /* The least dynamic symbol table index corresponding to a symbol
-     with a GOT entry.  */
-  long min_got_dynindx;
-  /* The greatest dynamic symbol table index not corresponding to a
-     symbol without a GOT entry.  */
-  long max_non_got_dynindx;
-};
-
-/* If H needs a GOT entry, assign it the highest available dynamic
-   index.  Otherwise, assign it the lowest available dynamic
-   index.  */
-
-static boolean
-mips_elf_sort_hash_table_f (h, data)
-     struct mips_elf_link_hash_entry *h;
-     PTR data;
-{
-  struct mips_elf_hash_sort_data *hsd
-    = (struct mips_elf_hash_sort_data *) data;
-
-  /* Symbols without dynamic symbol table entries aren't interesting
-     at all.  */
-  if (h->root.dynindx == -1)
-    return true;
-
-  if (h->root.got.offset != 1)
-    h->root.dynindx = hsd->max_non_got_dynindx++;
-  else
-    {
-      h->root.dynindx = --hsd->min_got_dynindx;
-      hsd->low = (struct elf_link_hash_entry *) h;
-    }
-
-  return true;
-}
-
-/* Sort the dynamic symbol table so that symbols that need GOT entries
-   appear towards the end.  This reduces the amount of GOT space
-   required.  MAX_LOCAL is used to set the number of local symbols
-   known to be in the dynamic symbol table.  During
-   mips_elf_size_dynamic_sections, this value is 1.  Afterward, the
-   section symbols are added and the count is higher.  */
-
-static boolean
-mips_elf_sort_hash_table (info, max_local)
-     struct bfd_link_info *info;
-     unsigned long max_local;
-{
-  struct mips_elf_hash_sort_data hsd;
-  struct mips_got_info *g;
-  bfd *dynobj;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
-  hsd.low = NULL;
-  hsd.min_got_dynindx = elf_hash_table (info)->dynsymcount;
-  hsd.max_non_got_dynindx = max_local;
-  mips_elf_link_hash_traverse (((struct mips_elf_link_hash_table *)
-				elf_hash_table (info)),
-			       mips_elf_sort_hash_table_f,
-			       &hsd);
-
-  /* There should have been enough room in the symbol table to
-     accomodate both the GOT and non-GOT symbols.  */
-  BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
-
-  /* Now we know which dynamic symbol has the lowest dynamic symbol
-     table index in the GOT.  */
-  g = mips_elf_got_info (dynobj, NULL);
-  g->global_gotsym = hsd.low;
-
-  return true;
-}
-
-/* Create a local GOT entry for VALUE.  Return the index of the entry,
-   or -1 if it could not be created.  */
-
-static bfd_vma
-mips_elf_create_local_got_entry (abfd, g, sgot, value)
-     bfd *abfd;
-     struct mips_got_info *g;
-     asection *sgot;
-     bfd_vma value;
-{
-  if (g->assigned_gotno >= g->local_gotno)
-    {
-      /* We didn't allocate enough space in the GOT.  */
-      (*_bfd_error_handler)
-	(_("not enough GOT space for local GOT entries"));
-      bfd_set_error (bfd_error_bad_value);
-      return (bfd_vma) -1;
-    }
-
-  MIPS_ELF_PUT_WORD (abfd, value,
-		     (sgot->contents
-		      + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno));
-  return MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
-}
-
-/* Returns the GOT offset at which the indicated address can be found.
-   If there is not yet a GOT entry for this value, create one.  Returns
-   -1 if no satisfactory GOT offset can be found.  */
-
-static bfd_vma
-mips_elf_local_got_index (abfd, info, value)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     bfd_vma value;
-{
-  asection *sgot;
-  struct mips_got_info *g;
-  bfd_byte *entry;
-
-  g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
-
-  /* Look to see if we already have an appropriate entry.  */
-  for (entry = (sgot->contents
-		+ MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO);
-       entry != sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno;
-       entry += MIPS_ELF_GOT_SIZE (abfd))
-    {
-      bfd_vma address = MIPS_ELF_GET_WORD (abfd, entry);
-      if (address == value)
-	return entry - sgot->contents;
-    }
-
-  return mips_elf_create_local_got_entry (abfd, g, sgot, value);
-}
-
-/* Find a GOT entry that is within 32KB of the VALUE.  These entries
-   are supposed to be placed at small offsets in the GOT, i.e.,
-   within 32KB of GP.  Return the index into the GOT for this page,
-   and store the offset from this entry to the desired address in
-   OFFSETP, if it is non-NULL.  */
-
-static bfd_vma
-mips_elf_got_page (abfd, info, value, offsetp)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     bfd_vma value;
-     bfd_vma *offsetp;
-{
-  asection *sgot;
-  struct mips_got_info *g;
-  bfd_byte *entry;
-  bfd_byte *last_entry;
-  bfd_vma index = 0;
-  bfd_vma address;
-
-  g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
-
-  /* Look to see if we aleady have an appropriate entry.  */
-  last_entry = sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno;
-  for (entry = (sgot->contents
-		+ MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO);
-       entry != last_entry;
-       entry += MIPS_ELF_GOT_SIZE (abfd))
-    {
-      address = MIPS_ELF_GET_WORD (abfd, entry);
-
-      if (!mips_elf_overflow_p (value - address, 16))
-	{
-	  /* This entry will serve as the page pointer.  We can add a
-	     16-bit number to it to get the actual address.  */
-	  index = entry - sgot->contents;
-	  break;
-	}
-    }
-
-  /* If we didn't have an appropriate entry, we create one now.  */
-  if (entry == last_entry)
-    index = mips_elf_create_local_got_entry (abfd, g, sgot, value);
-
-  if (offsetp)
-    {
-      address = MIPS_ELF_GET_WORD (abfd, entry);
-      *offsetp = value - address;
-    }
-
-  return index;
-}
-
-/* Find a GOT entry whose higher-order 16 bits are the same as those
-   for value.  Return the index into the GOT for this entry.  */
-
-static bfd_vma
-mips_elf_got16_entry (abfd, info, value, external)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     bfd_vma value;
-     boolean external;
-{
-  asection *sgot;
-  struct mips_got_info *g;
-  bfd_byte *entry;
-  bfd_byte *last_entry;
-  bfd_vma index = 0;
-  bfd_vma address;
-
-  if (! external)
-    {
-      /* Although the ABI says that it is "the high-order 16 bits" that we
-	 want, it is really the %high value.  The complete value is
-	 calculated with a `addiu' of a LO16 relocation, just as with a
-	 HI16/LO16 pair.  */
-      value = mips_elf_high (value) << 16;
-    }
-
-  g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
-
-  /* Look to see if we already have an appropriate entry.  */
-  last_entry = sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno;
-  for (entry = (sgot->contents
-		+ MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO);
-       entry != last_entry;
-       entry += MIPS_ELF_GOT_SIZE (abfd))
-    {
-      address = MIPS_ELF_GET_WORD (abfd, entry);
-      if (address == value)
-	{
-	  /* This entry has the right high-order 16 bits, and the low-order
-	     16 bits are set to zero.  */
-	  index = entry - sgot->contents;
-	  break;
-	}
-    }
-
-  /* If we didn't have an appropriate entry, we create one now.  */
-  if (entry == last_entry)
-    index = mips_elf_create_local_got_entry (abfd, g, sgot, value);
-
-  return index;
-}
-
-/* Returns the first relocation of type r_type found, beginning with
-   RELOCATION.  RELEND is one-past-the-end of the relocation table.  */
-
-static const Elf_Internal_Rela *
-mips_elf_next_relocation (r_type, relocation, relend)
-     unsigned int r_type;
-     const Elf_Internal_Rela *relocation;
-     const Elf_Internal_Rela *relend;
-{
-  /* According to the MIPS ELF ABI, the R_MIPS_LO16 relocation must be
-     immediately following.  However, for the IRIX6 ABI, the next
-     relocation may be a composed relocation consisting of several
-     relocations for the same address.  In that case, the R_MIPS_LO16
-     relocation may occur as one of these.  We permit a similar
-     extension in general, as that is useful for GCC.  */
-  while (relocation < relend)
-    {
-      if (ELF32_R_TYPE (relocation->r_info) == r_type)
-	return relocation;
-
-      ++relocation;
-    }
-
-  /* We didn't find it.  */
-  bfd_set_error (bfd_error_bad_value);
-  return NULL;
-}
-
-/* Create a rel.dyn relocation for the dynamic linker to resolve.  REL
-   is the original relocation, which is now being transformed into a
-   dynamic relocation.  The ADDENDP is adjusted if necessary; the
-   caller should store the result in place of the original addend.  */
-
-static boolean
-mips_elf_create_dynamic_relocation (output_bfd, info, rel, h, sec,
-				    symbol, addendp, input_section)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     const Elf_Internal_Rela *rel;
-     struct mips_elf_link_hash_entry *h;
-     asection *sec;
-     bfd_vma symbol;
-     bfd_vma *addendp;
-     asection *input_section;
-{
-  Elf_Internal_Rel outrel;
-  boolean skip;
-  asection *sreloc;
-  bfd *dynobj;
-  int r_type;
-
-  r_type = ELF32_R_TYPE (rel->r_info);
-  dynobj = elf_hash_table (info)->dynobj;
-  sreloc
-    = bfd_get_section_by_name (dynobj,
-			       MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd));
-  BFD_ASSERT (sreloc != NULL);
-  BFD_ASSERT (sreloc->contents != NULL);
-  BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd)
-	      < sreloc->_raw_size);
-
-  skip = false;
-  outrel.r_offset =
-    _bfd_elf_section_offset (output_bfd, info, input_section, rel->r_offset);
-  if (outrel.r_offset == (bfd_vma) -1)
-    skip = true;
-  /* FIXME: For -2 runtime relocation needs to be skipped, but
-     properly resolved statically and installed.  */
-  BFD_ASSERT (outrel.r_offset != (bfd_vma) -2);
-
-  /* If we've decided to skip this relocation, just output an empty
-     record.  Note that R_MIPS_NONE == 0, so that this call to memset
-     is a way of setting R_TYPE to R_MIPS_NONE.  */
-  if (skip)
-    memset (&outrel, 0, sizeof (outrel));
-  else
-    {
-      long indx;
-      bfd_vma section_offset;
-
-      /* We must now calculate the dynamic symbol table index to use
-	 in the relocation.  */
-      if (h != NULL
-	  && (! info->symbolic || (h->root.elf_link_hash_flags
-				   & ELF_LINK_HASH_DEF_REGULAR) == 0))
-	{
-	  indx = h->root.dynindx;
-	  /* h->root.dynindx may be -1 if this symbol was marked to
-	     become local.  */
-	  if (indx == -1)
-	    indx = 0;
-	}
-      else
-	{
-	  if (sec != NULL && bfd_is_abs_section (sec))
-	    indx = 0;
-	  else if (sec == NULL || sec->owner == NULL)
-	    {
-	      bfd_set_error (bfd_error_bad_value);
-	      return false;
-	    }
-	  else
-	    {
-	      indx = elf_section_data (sec->output_section)->dynindx;
-	      if (indx == 0)
-		abort ();
-	    }
-
-	  /* Figure out how far the target of the relocation is from
-	     the beginning of its section.  */
-	  section_offset = symbol - sec->output_section->vma;
-	  /* The relocation we're building is section-relative.
-	     Therefore, the original addend must be adjusted by the
-	     section offset.  */
-	  *addendp += section_offset;
-	  /* Now, the relocation is just against the section.  */
-	  symbol = sec->output_section->vma;
-	}
-
-      /* If the relocation was previously an absolute relocation and
-	 this symbol will not be referred to by the relocation, we must
-	 adjust it by the value we give it in the dynamic symbol table.
-	 Otherwise leave the job up to the dynamic linker.  */
-      if (!indx && r_type != R_MIPS_REL32)
-	*addendp += symbol;
-
-      /* The relocation is always an REL32 relocation because we don't
-	 know where the shared library will wind up at load-time.  */
-      outrel.r_info = ELF32_R_INFO (indx, R_MIPS_REL32);
-
-      /* Adjust the output offset of the relocation to reference the
-	 correct location in the output file.  */
-      outrel.r_offset += (input_section->output_section->vma
-			  + input_section->output_offset);
-    }
-
-  /* Put the relocation back out.  We have to use the special
-     relocation outputter in the 64-bit case since the 64-bit
-     relocation format is non-standard.  */
-  if (ABI_64_P (output_bfd))
-    {
-      (*get_elf_backend_data (output_bfd)->s->swap_reloc_out)
-	(output_bfd, &outrel,
-	 (sreloc->contents
-	  + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel)));
-    }
-  else
-    bfd_elf32_swap_reloc_out (output_bfd, &outrel,
-			      (((Elf32_External_Rel *)
-				sreloc->contents)
-			       + sreloc->reloc_count));
-
-  /* Record the index of the first relocation referencing H.  This
-     information is later emitted in the .msym section.  */
-  if (h != NULL
-      && (h->min_dyn_reloc_index == 0
-	  || sreloc->reloc_count < h->min_dyn_reloc_index))
-    h->min_dyn_reloc_index = sreloc->reloc_count;
-
-  /* We've now added another relocation.  */
-  ++sreloc->reloc_count;
-
-  /* Make sure the output section is writable.  The dynamic linker
-     will be writing to it.  */
-  elf_section_data (input_section->output_section)->this_hdr.sh_flags
-    |= SHF_WRITE;
-
-  /* On IRIX5, make an entry of compact relocation info.  */
-  if (! skip && IRIX_COMPAT (output_bfd) == ict_irix5)
-    {
-      asection *scpt = bfd_get_section_by_name (dynobj, ".compact_rel");
-      bfd_byte *cr;
-
-      if (scpt)
-	{
-	  Elf32_crinfo cptrel;
-
-	  mips_elf_set_cr_format (cptrel, CRF_MIPS_LONG);
-	  cptrel.vaddr = (rel->r_offset
-			  + input_section->output_section->vma
-			  + input_section->output_offset);
-	  if (r_type == R_MIPS_REL32)
-	    mips_elf_set_cr_type (cptrel, CRT_MIPS_REL32);
-	  else
-	    mips_elf_set_cr_type (cptrel, CRT_MIPS_WORD);
-	  mips_elf_set_cr_dist2to (cptrel, 0);
-	  cptrel.konst = *addendp;
-
-	  cr = (scpt->contents
-		+ sizeof (Elf32_External_compact_rel));
-	  bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
-				     ((Elf32_External_crinfo *) cr
-				      + scpt->reloc_count));
-	  ++scpt->reloc_count;
-	}
-    }
-
-  return true;
-}
-
-/* Calculate the value produced by the RELOCATION (which comes from
-   the INPUT_BFD).  The ADDEND is the addend to use for this
-   RELOCATION; RELOCATION->R_ADDEND is ignored.
-
-   The result of the relocation calculation is stored in VALUEP.
-   REQUIRE_JALXP indicates whether or not the opcode used with this
-   relocation must be JALX.
-
-   This function returns bfd_reloc_continue if the caller need take no
-   further action regarding this relocation, bfd_reloc_notsupported if
-   something goes dramatically wrong, bfd_reloc_overflow if an
-   overflow occurs, and bfd_reloc_ok to indicate success.  */
-
-static bfd_reloc_status_type
-mips_elf_calculate_relocation (abfd,
-			       input_bfd,
-			       input_section,
-			       info,
-			       relocation,
-			       addend,
-			       howto,
-			       local_syms,
-			       local_sections,
-			       valuep,
-			       namep,
-			       require_jalxp)
-     bfd *abfd;
-     bfd *input_bfd;
-     asection *input_section;
-     struct bfd_link_info *info;
-     const Elf_Internal_Rela *relocation;
-     bfd_vma addend;
-     reloc_howto_type *howto;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
-     bfd_vma *valuep;
-     const char **namep;
-     boolean *require_jalxp;
-{
-  /* The eventual value we will return.  */
-  bfd_vma value;
-  /* The address of the symbol against which the relocation is
-     occurring.  */
-  bfd_vma symbol = 0;
-  /* The final GP value to be used for the relocatable, executable, or
-     shared object file being produced.  */
-  bfd_vma gp = (bfd_vma) - 1;
-  /* The place (section offset or address) of the storage unit being
-     relocated.  */
-  bfd_vma p;
-  /* The value of GP used to create the relocatable object.  */
-  bfd_vma gp0 = (bfd_vma) - 1;
-  /* The offset into the global offset table at which the address of
-     the relocation entry symbol, adjusted by the addend, resides
-     during execution.  */
-  bfd_vma g = (bfd_vma) - 1;
-  /* The section in which the symbol referenced by the relocation is
-     located.  */
-  asection *sec = NULL;
-  struct mips_elf_link_hash_entry *h = NULL;
-  /* True if the symbol referred to by this relocation is a local
-     symbol.  */
-  boolean local_p;
-  /* True if the symbol referred to by this relocation is "_gp_disp".  */
-  boolean gp_disp_p = false;
-  Elf_Internal_Shdr *symtab_hdr;
-  size_t extsymoff;
-  unsigned long r_symndx;
-  int r_type;
-  /* True if overflow occurred during the calculation of the
-     relocation value.  */
-  boolean overflowed_p;
-  /* True if this relocation refers to a MIPS16 function.  */
-  boolean target_is_16_bit_code_p = false;
-
-  /* Parse the relocation.  */
-  r_symndx = ELF32_R_SYM (relocation->r_info);
-  r_type = ELF32_R_TYPE (relocation->r_info);
-  p = (input_section->output_section->vma
-       + input_section->output_offset
-       + relocation->r_offset);
-
-  /* Assume that there will be no overflow.  */
-  overflowed_p = false;
-
-  /* Figure out whether or not the symbol is local, and get the offset
-     used in the array of hash table entries.  */
-  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
-  local_p = mips_elf_local_relocation_p (input_bfd, relocation,
-					 local_sections, false);
-  if (! elf_bad_symtab (input_bfd))
-    extsymoff = symtab_hdr->sh_info;
-  else
-    {
-      /* The symbol table does not follow the rule that local symbols
-	 must come before globals.  */
-      extsymoff = 0;
-    }
-
-  /* Figure out the value of the symbol.  */
-  if (local_p)
-    {
-      Elf_Internal_Sym *sym;
-
-      sym = local_syms + r_symndx;
-      sec = local_sections[r_symndx];
-
-      symbol = sec->output_section->vma + sec->output_offset;
-      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
-	symbol += sym->st_value;
-
-      /* MIPS16 text labels should be treated as odd.  */
-      if (sym->st_other == STO_MIPS16)
-	++symbol;
-
-      /* Record the name of this symbol, for our caller.  */
-      *namep = bfd_elf_string_from_elf_section (input_bfd,
-						symtab_hdr->sh_link,
-						sym->st_name);
-      if (*namep == '\0')
-	*namep = bfd_section_name (input_bfd, sec);
-
-      target_is_16_bit_code_p = (sym->st_other == STO_MIPS16);
-    }
-  else
-    {
-      /* For global symbols we look up the symbol in the hash-table.  */
-      h = ((struct mips_elf_link_hash_entry *)
-	   elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
-      /* Find the real hash-table entry for this symbol.  */
-      while (h->root.root.type == bfd_link_hash_indirect
-	     || h->root.root.type == bfd_link_hash_warning)
-	h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
-
-      /* Record the name of this symbol, for our caller.  */
-      *namep = h->root.root.root.string;
-
-      /* See if this is the special _gp_disp symbol.  Note that such a
-	 symbol must always be a global symbol.  */
-      if (strcmp (h->root.root.root.string, "_gp_disp") == 0)
-	{
-	  /* Relocations against _gp_disp are permitted only with
-	     R_MIPS_HI16 and R_MIPS_LO16 relocations.  */
-	  if (r_type != R_MIPS_HI16 && r_type != R_MIPS_LO16)
-	    return bfd_reloc_notsupported;
-
-	  gp_disp_p = true;
-	}
-      /* If this symbol is defined, calculate its address.  Note that
-	 _gp_disp is a magic symbol, always implicitly defined by the
-	 linker, so it's inappropriate to check to see whether or not
-	 its defined.  */
-      else if ((h->root.root.type == bfd_link_hash_defined
-		|| h->root.root.type == bfd_link_hash_defweak)
-	       && h->root.root.u.def.section)
-	{
-	  sec = h->root.root.u.def.section;
-	  if (sec->output_section)
-	    symbol = (h->root.root.u.def.value
-		      + sec->output_section->vma
-		      + sec->output_offset);
-	  else
-	    symbol = h->root.root.u.def.value;
-	}
-      else if (h->root.root.type == bfd_link_hash_undefweak)
-	/* We allow relocations against undefined weak symbols, giving
-	   it the value zero, so that you can undefined weak functions
-	   and check to see if they exist by looking at their
-	   addresses.  */
-	symbol = 0;
-      else if (info->shared
-	       && (!info->symbolic || info->allow_shlib_undefined)
-	       && !info->no_undefined
-	       && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
-	symbol = 0;
-      else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0 ||
-              strcmp (h->root.root.root.string, "_DYNAMIC_LINKING") == 0)
-	{
-	  /* If this is a dynamic link, we should have created a
-	     _DYNAMIC_LINK symbol or _DYNAMIC_LINKING(for normal mips) symbol
-	     in in mips_elf_create_dynamic_sections.
-	     Otherwise, we should define the symbol with a value of 0.
-	     FIXME: It should probably get into the symbol table
-	     somehow as well.  */
-	  BFD_ASSERT (! info->shared);
-	  BFD_ASSERT (bfd_get_section_by_name (abfd, ".dynamic") == NULL);
-	  symbol = 0;
-	}
-      else
-	{
-	  if (! ((*info->callbacks->undefined_symbol)
-		 (info, h->root.root.root.string, input_bfd,
-		  input_section, relocation->r_offset,
-		  (!info->shared || info->no_undefined
-		   || ELF_ST_VISIBILITY (h->root.other)))))
-	    return bfd_reloc_undefined;
-	  symbol = 0;
-	}
-
-      target_is_16_bit_code_p = (h->root.other == STO_MIPS16);
-    }
-
-  /* If this is a 32-bit call to a 16-bit function with a stub, we
-     need to redirect the call to the stub, unless we're already *in*
-     a stub.  */
-  if (r_type != R_MIPS16_26 && !info->relocateable
-      && ((h != NULL && h->fn_stub != NULL)
-	  || (local_p && elf_tdata (input_bfd)->local_stubs != NULL
-	      && elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL))
-      && !mips_elf_stub_section_p (input_bfd, input_section))
-    {
-      /* This is a 32-bit call to a 16-bit function.  We should
-	 have already noticed that we were going to need the
-	 stub.  */
-      if (local_p)
-	sec = elf_tdata (input_bfd)->local_stubs[r_symndx];
-      else
-	{
-	  BFD_ASSERT (h->need_fn_stub);
-	  sec = h->fn_stub;
-	}
-
-      symbol = sec->output_section->vma + sec->output_offset;
-    }
-  /* If this is a 16-bit call to a 32-bit function with a stub, we
-     need to redirect the call to the stub.  */
-  else if (r_type == R_MIPS16_26 && !info->relocateable
-	   && h != NULL
-	   && (h->call_stub != NULL || h->call_fp_stub != NULL)
-	   && !target_is_16_bit_code_p)
-    {
-      /* If both call_stub and call_fp_stub are defined, we can figure
-	 out which one to use by seeing which one appears in the input
-	 file.  */
-      if (h->call_stub != NULL && h->call_fp_stub != NULL)
-	{
-	  asection *o;
-
-	  sec = NULL;
-	  for (o = input_bfd->sections; o != NULL; o = o->next)
-	    {
-	      if (strncmp (bfd_get_section_name (input_bfd, o),
-			   CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
-		{
-		  sec = h->call_fp_stub;
-		  break;
-		}
-	    }
-	  if (sec == NULL)
-	    sec = h->call_stub;
-	}
-      else if (h->call_stub != NULL)
-	sec = h->call_stub;
-      else
-	sec = h->call_fp_stub;
-
-      BFD_ASSERT (sec->_raw_size > 0);
-      symbol = sec->output_section->vma + sec->output_offset;
-    }
-
-  /* Calls from 16-bit code to 32-bit code and vice versa require the
-     special jalx instruction.  */
-  *require_jalxp = (!info->relocateable
-                    && (((r_type == R_MIPS16_26) && !target_is_16_bit_code_p)
-                        || ((r_type == R_MIPS_26) && target_is_16_bit_code_p)));
-
-  local_p = mips_elf_local_relocation_p (input_bfd, relocation,
-					 local_sections, true);
-
-  /* If we haven't already determined the GOT offset, or the GP value,
-     and we're going to need it, get it now.  */
-  switch (r_type)
-    {
-    case R_MIPS_CALL16:
-    case R_MIPS_GOT16:
-    case R_MIPS_GOT_DISP:
-    case R_MIPS_GOT_HI16:
-    case R_MIPS_CALL_HI16:
-    case R_MIPS_GOT_LO16:
-    case R_MIPS_CALL_LO16:
-      /* Find the index into the GOT where this value is located.  */
-      if (!local_p)
-	{
-	  BFD_ASSERT (addend == 0);
-	  g = mips_elf_global_got_index
-	    (elf_hash_table (info)->dynobj,
-	     (struct elf_link_hash_entry *) h);
-	  if (! elf_hash_table(info)->dynamic_sections_created
-	      || (info->shared
-		  && (info->symbolic || h->root.dynindx == -1)
-		  && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
-	    {
-	      /* This is a static link or a -Bsymbolic link.  The
-		 symbol is defined locally, or was forced to be local.
-		 We must initialize this entry in the GOT.  */
-	      asection *sgot = mips_elf_got_section(elf_hash_table
-						    (info)->dynobj);
-	      MIPS_ELF_PUT_WORD (elf_hash_table (info)->dynobj,
-				 symbol + addend, sgot->contents + g);
-	    }
-	}
-      else if (r_type == R_MIPS_GOT16 || r_type == R_MIPS_CALL16)
-	/* There's no need to create a local GOT entry here; the
-	   calculation for a local GOT16 entry does not involve G.  */
-	break;
-      else
-	{
-	  g = mips_elf_local_got_index (abfd, info, symbol + addend);
-	  if (g == (bfd_vma) -1)
-	    return bfd_reloc_outofrange;
-	}
-
-      /* Convert GOT indices to actual offsets.  */
-      g = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
-					  abfd, g);
-      break;
-
-    case R_MIPS_HI16:
-    case R_MIPS_LO16:
-    case R_MIPS16_GPREL:
-    case R_MIPS_GPREL16:
-    case R_MIPS_GPREL32:
-    case R_MIPS_LITERAL:
-      gp0 = _bfd_get_gp_value (input_bfd);
-      gp = _bfd_get_gp_value (abfd);
-      break;
-
-    default:
-      break;
-    }
-
-  /* Figure out what kind of relocation is being performed.  */
-  switch (r_type)
-    {
-    case R_MIPS_NONE:
-      return bfd_reloc_continue;
-
-    case R_MIPS_16:
-      value = symbol + mips_elf_sign_extend (addend, 16);
-      overflowed_p = mips_elf_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_32:
-    case R_MIPS_REL32:
-    case R_MIPS_64:
-      if ((info->shared
-	   || (elf_hash_table (info)->dynamic_sections_created
-	       && h != NULL
-	       && ((h->root.elf_link_hash_flags
-		    & ELF_LINK_HASH_DEF_DYNAMIC) != 0)
-	       && ((h->root.elf_link_hash_flags
-		    & ELF_LINK_HASH_DEF_REGULAR) == 0)))
-	  && r_symndx != 0
-	  && (input_section->flags & SEC_ALLOC) != 0)
-	{
-	  /* If we're creating a shared library, or this relocation is
-	     against a symbol in a shared library, then we can't know
-	     where the symbol will end up.  So, we create a relocation
-	     record in the output, and leave the job up to the dynamic
-	     linker.  */
-	  value = addend;
-	  if (!mips_elf_create_dynamic_relocation (abfd,
-						   info,
-						   relocation,
-						   h,
-						   sec,
-						   symbol,
-						   &value,
-						   input_section))
-	    return bfd_reloc_undefined;
-	}
-      else
-	{
-	  if (r_type != R_MIPS_REL32)
-	    value = symbol + addend;
-	  else
-	    value = addend;
-	}
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_PC32:
-    case R_MIPS_PC64:
-    case R_MIPS_GNU_REL_LO16:
-      value = symbol + addend - p;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_GNU_REL16_S2:
-      value = symbol + mips_elf_sign_extend (addend << 2, 18) - p;
-      overflowed_p = mips_elf_overflow_p (value, 18);
-      value = (value >> 2) & howto->dst_mask;
-      break;
-
-    case R_MIPS_GNU_REL_HI16:
-      /* Instead of subtracting 'p' here, we should be subtracting the
-	 equivalent value for the LO part of the reloc, since the value
-	 here is relative to that address.  Because that's not easy to do,
-	 we adjust 'addend' in _bfd_mips_elf_relocate_section().  See also
-	 the comment there for more information.  */
-      value = mips_elf_high (addend + symbol - p);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS16_26:
-      /* The calculation for R_MIPS16_26 is just the same as for an
-	 R_MIPS_26.  It's only the storage of the relocated field into
-	 the output file that's different.  That's handled in
-	 mips_elf_perform_relocation.  So, we just fall through to the
-	 R_MIPS_26 case here.  */
-    case R_MIPS_26:
-      if (local_p)
-	value = (((addend << 2) | ((p + 4) & 0xf0000000)) + symbol) >> 2;
-      else
-	value = (mips_elf_sign_extend (addend << 2, 28) + symbol) >> 2;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_HI16:
-      if (!gp_disp_p)
-	{
-	  value = mips_elf_high (addend + symbol);
-	  value &= howto->dst_mask;
-	}
-      else
-	{
-	  value = mips_elf_high (addend + gp - p);
-	  overflowed_p = mips_elf_overflow_p (value, 16);
-	}
-      break;
-
-    case R_MIPS_LO16:
-      if (!gp_disp_p)
-	value = (symbol + addend) & howto->dst_mask;
-      else
-	{
-	  value = addend + gp - p + 4;
-	  /* The MIPS ABI requires checking the R_MIPS_LO16 relocation
-	     for overflow.  But, on, say, Irix 5, relocations against
-	     _gp_disp are normally generated from the .cpload
-	     pseudo-op.  It generates code that normally looks like
-	     this:
-
-	       lui    $gp,%hi(_gp_disp)
-	       addiu  $gp,$gp,%lo(_gp_disp)
-	       addu   $gp,$gp,$t9
-
-	     Here $t9 holds the address of the function being called,
-	     as required by the MIPS ELF ABI.  The R_MIPS_LO16
-	     relocation can easily overflow in this situation, but the
-	     R_MIPS_HI16 relocation will handle the overflow.
-	     Therefore, we consider this a bug in the MIPS ABI, and do
-	     not check for overflow here.  */
-	}
-      break;
-
-    case R_MIPS_LITERAL:
-      /* Because we don't merge literal sections, we can handle this
-	 just like R_MIPS_GPREL16.  In the long run, we should merge
-	 shared literals, and then we will need to additional work
-	 here.  */
-
-      /* Fall through.  */
-
-    case R_MIPS16_GPREL:
-      /* The R_MIPS16_GPREL performs the same calculation as
-	 R_MIPS_GPREL16, but stores the relocated bits in a different
-	 order.  We don't need to do anything special here; the
-	 differences are handled in mips_elf_perform_relocation.  */
-    case R_MIPS_GPREL16:
-      if (local_p)
-	value = mips_elf_sign_extend (addend, 16) + symbol + gp0 - gp;
-      else
-	value = mips_elf_sign_extend (addend, 16) + symbol - gp;
-      overflowed_p = mips_elf_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_GOT16:
-    case R_MIPS_CALL16:
-      if (local_p)
-	{
-	  boolean forced;
-
-	  /* The special case is when the symbol is forced to be local.  We
-	     need the full address in the GOT since no R_MIPS_LO16 relocation
-	     follows.  */
-	  forced = ! mips_elf_local_relocation_p (input_bfd, relocation,
-						  local_sections, false);
-	  value = mips_elf_got16_entry (abfd, info, symbol + addend, forced);
-	  if (value == (bfd_vma) -1)
-	    return bfd_reloc_outofrange;
-	  value
-	    = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
-					      abfd,
-					      value);
-	  overflowed_p = mips_elf_overflow_p (value, 16);
-	  break;
-	}
-
-      /* Fall through.  */
-
-    case R_MIPS_GOT_DISP:
-      value = g;
-      overflowed_p = mips_elf_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_GPREL32:
-      value = (addend + symbol + gp0 - gp) & howto->dst_mask;
-      break;
-
-    case R_MIPS_PC16:
-      value = mips_elf_sign_extend (addend, 16) + symbol - p;
-      overflowed_p = mips_elf_overflow_p (value, 16);
-      value = (bfd_vma) ((bfd_signed_vma) value / 4);
-      break;
-
-    case R_MIPS_GOT_HI16:
-    case R_MIPS_CALL_HI16:
-      /* We're allowed to handle these two relocations identically.
-	 The dynamic linker is allowed to handle the CALL relocations
-	 differently by creating a lazy evaluation stub.  */
-      value = g;
-      value = mips_elf_high (value);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_GOT_LO16:
-    case R_MIPS_CALL_LO16:
-      value = g & howto->dst_mask;
-      break;
-
-    case R_MIPS_GOT_PAGE:
-      value = mips_elf_got_page (abfd, info, symbol + addend, NULL);
-      if (value == (bfd_vma) -1)
-	return bfd_reloc_outofrange;
-      value = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
-					      abfd,
-					      value);
-      overflowed_p = mips_elf_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_GOT_OFST:
-      mips_elf_got_page (abfd, info, symbol + addend, &value);
-      overflowed_p = mips_elf_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_SUB:
-      value = symbol - addend;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_HIGHER:
-      value = mips_elf_higher (addend + symbol);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_HIGHEST:
-      value = mips_elf_highest (addend + symbol);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_SCN_DISP:
-      value = symbol + addend - sec->output_offset;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_PJUMP:
-    case R_MIPS_JALR:
-      /* Both of these may be ignored.  R_MIPS_JALR is an optimization
-	 hint; we could improve performance by honoring that hint.  */
-      return bfd_reloc_continue;
-
-    case R_MIPS_GNU_VTINHERIT:
-    case R_MIPS_GNU_VTENTRY:
-      /* We don't do anything with these at present.  */
-      return bfd_reloc_continue;
-
-    default:
-      /* An unrecognized relocation type.  */
-      return bfd_reloc_notsupported;
-    }
-
-  /* Store the VALUE for our caller.  */
-  *valuep = value;
-  return overflowed_p ? bfd_reloc_overflow : bfd_reloc_ok;
-}
-
-/* Obtain the field relocated by RELOCATION.  */
-
-static bfd_vma
-mips_elf_obtain_contents (howto, relocation, input_bfd, contents)
-     reloc_howto_type *howto;
-     const Elf_Internal_Rela *relocation;
-     bfd *input_bfd;
-     bfd_byte *contents;
-{
-  bfd_vma x;
-  bfd_byte *location = contents + relocation->r_offset;
-
-  /* Obtain the bytes.  */
-  x = bfd_get (((bfd_vma)(8 * bfd_get_reloc_size (howto))), input_bfd, location);
-
-  if ((ELF32_R_TYPE (relocation->r_info) == R_MIPS16_26
-       || ELF32_R_TYPE (relocation->r_info) == R_MIPS16_GPREL)
-      && bfd_little_endian (input_bfd))
-    /* The two 16-bit words will be reversed on a little-endian
-       system.  See mips_elf_perform_relocation for more details.  */
-    x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
-
-  return x;
-}
-
-/* It has been determined that the result of the RELOCATION is the
-   VALUE.  Use HOWTO to place VALUE into the output file at the
-   appropriate position.  The SECTION is the section to which the
-   relocation applies.  If REQUIRE_JALX is true, then the opcode used
-   for the relocation must be either JAL or JALX, and it is
-   unconditionally converted to JALX.
-
-   Returns false if anything goes wrong.  */
-
-static boolean
-mips_elf_perform_relocation (info, howto, relocation, value,
-			     input_bfd, input_section,
-			     contents, require_jalx)
-     struct bfd_link_info *info;
-     reloc_howto_type *howto;
-     const Elf_Internal_Rela *relocation;
-     bfd_vma value;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     boolean require_jalx;
-{
-  bfd_vma x;
-  bfd_byte *location;
-  int r_type = ELF32_R_TYPE (relocation->r_info);
-
-  /* Figure out where the relocation is occurring.  */
-  location = contents + relocation->r_offset;
-
-  /* Obtain the current value.  */
-  x = mips_elf_obtain_contents (howto, relocation, input_bfd, contents);
-
-  /* Clear the field we are setting.  */
-  x &= ~howto->dst_mask;
-
-  /* If this is the R_MIPS16_26 relocation, we must store the
-     value in a funny way.  */
-  if (r_type == R_MIPS16_26)
-    {
-      /* R_MIPS16_26 is used for the mips16 jal and jalx instructions.
-	 Most mips16 instructions are 16 bits, but these instructions
-	 are 32 bits.
-
-	 The format of these instructions is:
-
-	 +--------------+--------------------------------+
-	 !     JALX     ! X!   Imm 20:16  !   Imm 25:21  !
-	 +--------------+--------------------------------+
-	 !	  	  Immediate  15:0		    !
-	 +-----------------------------------------------+
-
-	 JALX is the 5-bit value 00011.  X is 0 for jal, 1 for jalx.
-	 Note that the immediate value in the first word is swapped.
-
-	 When producing a relocateable object file, R_MIPS16_26 is
-	 handled mostly like R_MIPS_26.  In particular, the addend is
-	 stored as a straight 26-bit value in a 32-bit instruction.
-	 (gas makes life simpler for itself by never adjusting a
-	 R_MIPS16_26 reloc to be against a section, so the addend is
-	 always zero).  However, the 32 bit instruction is stored as 2
-	 16-bit values, rather than a single 32-bit value.  In a
-	 big-endian file, the result is the same; in a little-endian
-	 file, the two 16-bit halves of the 32 bit value are swapped.
-	 This is so that a disassembler can recognize the jal
-	 instruction.
-
-	 When doing a final link, R_MIPS16_26 is treated as a 32 bit
-	 instruction stored as two 16-bit values.  The addend A is the
-	 contents of the targ26 field.  The calculation is the same as
-	 R_MIPS_26.  When storing the calculated value, reorder the
-	 immediate value as shown above, and don't forget to store the
-	 value as two 16-bit values.
-
-	 To put it in MIPS ABI terms, the relocation field is T-targ26-16,
-	 defined as
-
-	 big-endian:
-	 +--------+----------------------+
-	 |        |                      |
-	 |        |    targ26-16         |
-	 |31    26|25                   0|
-	 +--------+----------------------+
-
-	 little-endian:
-	 +----------+------+-------------+
-	 |          |      |             |
-	 |  sub1    |      |     sub2    |
-	 |0        9|10  15|16         31|
-	 +----------+--------------------+
-	 where targ26-16 is sub1 followed by sub2 (i.e., the addend field A is
-	 ((sub1 << 16) | sub2)).
-
-	 When producing a relocateable object file, the calculation is
-	 (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2)
-	 When producing a fully linked file, the calculation is
-	 let R = (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2)
-	 ((R & 0x1f0000) << 5) | ((R & 0x3e00000) >> 5) | (R & 0xffff)  */
-
-      if (!info->relocateable)
-	/* Shuffle the bits according to the formula above.  */
-	value = (((value & 0x1f0000) << 5)
-		 | ((value & 0x3e00000) >> 5)
-		 | (value & 0xffff));
-    }
-  else if (r_type == R_MIPS16_GPREL)
-    {
-      /* R_MIPS16_GPREL is used for GP-relative addressing in mips16
-	 mode.  A typical instruction will have a format like this:
-
-	 +--------------+--------------------------------+
-	 !    EXTEND    !     Imm 10:5    !   Imm 15:11  !
-	 +--------------+--------------------------------+
-	 !    Major     !   rx   !   ry   !   Imm  4:0   !
-	 +--------------+--------------------------------+
-
-	 EXTEND is the five bit value 11110.  Major is the instruction
-	 opcode.
-
-	 This is handled exactly like R_MIPS_GPREL16, except that the
-	 addend is retrieved and stored as shown in this diagram; that
-	 is, the Imm fields above replace the V-rel16 field.
-
-         All we need to do here is shuffle the bits appropriately.  As
-	 above, the two 16-bit halves must be swapped on a
-	 little-endian system.  */
-      value = (((value & 0x7e0) << 16)
-	       | ((value & 0xf800) << 5)
-	       | (value & 0x1f));
-    }
-
-  /* Set the field.  */
-  x |= (value & howto->dst_mask);
-
-  /* If required, turn JAL into JALX.  */
-  if (require_jalx)
-    {
-      boolean ok;
-      bfd_vma opcode = x >> 26;
-      bfd_vma jalx_opcode;
-
-      /* Check to see if the opcode is already JAL or JALX.  */
-      if (r_type == R_MIPS16_26)
-	{
-	  ok = ((opcode == 0x6) || (opcode == 0x7));
-	  jalx_opcode = 0x7;
-	}
-      else
-	{
-	  ok = ((opcode == 0x3) || (opcode == 0x1d));
-	  jalx_opcode = 0x1d;
-	}
-
-      /* If the opcode is not JAL or JALX, there's a problem.  */
-      if (!ok)
-	{
-	  (*_bfd_error_handler)
-	    (_("%s: %s+0x%lx: jump to stub routine which is not jal"),
-	     bfd_archive_filename (input_bfd),
-	     input_section->name,
-	     (unsigned long) relocation->r_offset);
-	  bfd_set_error (bfd_error_bad_value);
-	  return false;
-	}
-
-      /* Make this the JALX opcode.  */
-      x = (x & ~(0x3f << 26)) | (jalx_opcode << 26);
-    }
-
-  /* Swap the high- and low-order 16 bits on little-endian systems
-     when doing a MIPS16 relocation.  */
-  if ((r_type == R_MIPS16_GPREL || r_type == R_MIPS16_26)
-      && bfd_little_endian (input_bfd))
-    x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
-
-  /* Put the value into the output.  */
-  bfd_put (8 * bfd_get_reloc_size (howto), input_bfd, x, location);
-  return true;
-}
-
-/* Returns true if SECTION is a MIPS16 stub section.  */
-
-static boolean
-mips_elf_stub_section_p (abfd, section)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *section;
-{
-  const char *name = bfd_get_section_name (abfd, section);
-
-  return (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0
-	  || strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
-	  || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0);
-}
-
-/* Relocate a MIPS ELF section.  */
-
-boolean
-_bfd_mips_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_Rela *rel;
-  const Elf_Internal_Rela *relend;
-  bfd_vma addend = 0;
-  boolean use_saved_addend_p = false;
-  struct elf_backend_data *bed;
-
-  bed = get_elf_backend_data (output_bfd);
-  relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
-  for (rel = relocs; rel < relend; ++rel)
-    {
-      const char *name;
-      bfd_vma value;
-      reloc_howto_type *howto;
-      boolean require_jalx;
-      /* True if the relocation is a RELA relocation, rather than a
-         REL relocation.  */
-      boolean rela_relocation_p = true;
-      unsigned int r_type = ELF32_R_TYPE (rel->r_info);
-      const char * msg = (const char *) NULL;
-
-      /* Find the relocation howto for this relocation.  */
-      if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
-	{
-	  /* Some 32-bit code uses R_MIPS_64.  In particular, people use
-	     64-bit code, but make sure all their addresses are in the
-	     lowermost or uppermost 32-bit section of the 64-bit address
-	     space.  Thus, when they use an R_MIPS_64 they mean what is
-	     usually meant by R_MIPS_32, with the exception that the
-	     stored value is sign-extended to 64 bits.  */
-	  howto = elf_mips_howto_table_rel + R_MIPS_32;
-
-	  /* On big-endian systems, we need to lie about the position
-	     of the reloc.  */
-	  if (bfd_big_endian (input_bfd))
-	    rel->r_offset += 4;
-	}
-      else
-	howto = mips_rtype_to_howto (r_type);
-
-      if (!use_saved_addend_p)
-	{
-	  Elf_Internal_Shdr *rel_hdr;
-
-	  /* If these relocations were originally of the REL variety,
-	     we must pull the addend out of the field that will be
-	     relocated.  Otherwise, we simply use the contents of the
-	     RELA relocation.  To determine which flavor or relocation
-	     this is, we depend on the fact that the INPUT_SECTION's
-	     REL_HDR is read before its REL_HDR2.  */
-	  rel_hdr = &elf_section_data (input_section)->rel_hdr;
-	  if ((size_t) (rel - relocs)
-	      >= (NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel))
-	    rel_hdr = elf_section_data (input_section)->rel_hdr2;
-	  if (rel_hdr->sh_entsize == MIPS_ELF_REL_SIZE (input_bfd))
-	    {
-	      /* Note that this is a REL relocation.  */
-	      rela_relocation_p = false;
-
-	      /* Get the addend, which is stored in the input file.  */
-	      addend = mips_elf_obtain_contents (howto,
-						 rel,
-						 input_bfd,
-						 contents);
-	      addend &= howto->src_mask;
-
-	      /* For some kinds of relocations, the ADDEND is a
-		 combination of the addend stored in two different
-		 relocations.   */
-	      if (r_type == R_MIPS_HI16
-		  || r_type == R_MIPS_GNU_REL_HI16
-		  || (r_type == R_MIPS_GOT16
-		      && mips_elf_local_relocation_p (input_bfd, rel,
-						      local_sections, false)))
-		{
-		  bfd_vma l;
-		  const Elf_Internal_Rela *lo16_relocation;
-		  reloc_howto_type *lo16_howto;
-		  unsigned int lo;
-
-		  /* The combined value is the sum of the HI16 addend,
-		     left-shifted by sixteen bits, and the LO16
-		     addend, sign extended.  (Usually, the code does
-		     a `lui' of the HI16 value, and then an `addiu' of
-		     the LO16 value.)
-
-		     Scan ahead to find a matching LO16 relocation.  */
-		  if (r_type == R_MIPS_GNU_REL_HI16)
-		    lo = R_MIPS_GNU_REL_LO16;
-		  else
-		    lo = R_MIPS_LO16;
-		  lo16_relocation
-		    = mips_elf_next_relocation (lo, rel, relend);
-		  if (lo16_relocation == NULL)
-		    return false;
-
-		  /* Obtain the addend kept there.  */
-		  lo16_howto = mips_rtype_to_howto (lo);
-		  l = mips_elf_obtain_contents (lo16_howto,
-						lo16_relocation,
-						input_bfd, contents);
-		  l &= lo16_howto->src_mask;
-		  l = mips_elf_sign_extend (l, 16);
-
-		  addend <<= 16;
-
-		  /* Compute the combined addend.  */
-		  addend += l;
-
-		  /* If PC-relative, subtract the difference between the
-		     address of the LO part of the reloc and the address of
-		     the HI part.  The relocation is relative to the LO
-		     part, but mips_elf_calculate_relocation() doesn't know
-		     it address or the difference from the HI part, so
-		     we subtract that difference here.  See also the
-		     comment in mips_elf_calculate_relocation().  */
-		  if (r_type == R_MIPS_GNU_REL_HI16)
-		    addend -= (lo16_relocation->r_offset - rel->r_offset);
-		}
-	      else if (r_type == R_MIPS16_GPREL)
-		{
-		  /* The addend is scrambled in the object file.  See
-		     mips_elf_perform_relocation for details on the
-		     format.  */
-		  addend = (((addend & 0x1f0000) >> 5)
-			    | ((addend & 0x7e00000) >> 16)
-			    | (addend & 0x1f));
-		}
-	    }
-	  else
-	    addend = rel->r_addend;
-	}
-
-      if (info->relocateable)
-	{
-	  Elf_Internal_Sym *sym;
-	  unsigned long r_symndx;
-
-	  if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd)
-	      && bfd_big_endian (input_bfd))
-	    rel->r_offset -= 4;
-
-	  /* Since we're just relocating, all we need to do is copy
-	     the relocations back out to the object file, unless
-	     they're against a section symbol, in which case we need
-	     to adjust by the section offset, or unless they're GP
-	     relative in which case we need to adjust by the amount
-	     that we're adjusting GP in this relocateable object.  */
-
-	  if (!mips_elf_local_relocation_p (input_bfd, rel, local_sections,
-					    false))
-	    /* There's nothing to do for non-local relocations.  */
-	    continue;
-
-	  if (r_type == R_MIPS16_GPREL
-	      || r_type == R_MIPS_GPREL16
-	      || r_type == R_MIPS_GPREL32
-	      || r_type == R_MIPS_LITERAL)
-	    addend -= (_bfd_get_gp_value (output_bfd)
-		       - _bfd_get_gp_value (input_bfd));
-	  else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26
-		   || r_type == R_MIPS_GNU_REL16_S2)
-	    /* The addend is stored without its two least
-	       significant bits (which are always zero.)  In a
-	       non-relocateable link, calculate_relocation will do
-	       this shift; here, we must do it ourselves.  */
-	    addend <<= 2;
-
-	  r_symndx = ELF32_R_SYM (rel->r_info);
-	  sym = local_syms + r_symndx;
-	  if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
-	    /* Adjust the addend appropriately.  */
-	    addend += local_sections[r_symndx]->output_offset;
-
-	  /* If the relocation is for a R_MIPS_HI16 or R_MIPS_GOT16,
-	     then we only want to write out the high-order 16 bits.
-	     The subsequent R_MIPS_LO16 will handle the low-order bits.  */
-	  if (r_type == R_MIPS_HI16 || r_type == R_MIPS_GOT16
-	      || r_type == R_MIPS_GNU_REL_HI16)
-	    addend = mips_elf_high (addend);
-	  /* If the relocation is for an R_MIPS_26 relocation, then
-	     the two low-order bits are not stored in the object file;
-	     they are implicitly zero.  */
-	  else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26
-		   || r_type == R_MIPS_GNU_REL16_S2)
-	    addend >>= 2;
-
-	  if (rela_relocation_p)
-	    /* If this is a RELA relocation, just update the addend.
-	       We have to cast away constness for REL.  */
-	    rel->r_addend = addend;
-	  else
-	    {
-	      /* Otherwise, we have to write the value back out.  Note
-		 that we use the source mask, rather than the
-		 destination mask because the place to which we are
-		 writing will be source of the addend in the final
-		 link.  */
-	      addend &= howto->src_mask;
-
-	      if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
-		/* See the comment above about using R_MIPS_64 in the 32-bit
-		   ABI.  Here, we need to update the addend.  It would be
-		   possible to get away with just using the R_MIPS_32 reloc
-		   but for endianness.  */
-		{
-		  bfd_vma sign_bits;
-		  bfd_vma low_bits;
-		  bfd_vma high_bits;
-
-		  if (addend & ((bfd_vma) 1 << 31))
-#ifdef BFD64
-		    sign_bits = ((bfd_vma) 1 << 32) - 1;
-#else
-		    sign_bits = -1;
-#endif
-		  else
-		    sign_bits = 0;
-
-		  /* If we don't know that we have a 64-bit type,
-		     do two separate stores.  */
-		  if (bfd_big_endian (input_bfd))
-		    {
-		      /* Store the sign-bits (which are most significant)
-			 first.  */
-		      low_bits = sign_bits;
-		      high_bits = addend;
-		    }
-		  else
-		    {
-		      low_bits = addend;
-		      high_bits = sign_bits;
-		    }
-		  bfd_put_32 (input_bfd, low_bits,
-			      contents + rel->r_offset);
-		  bfd_put_32 (input_bfd, high_bits,
-			      contents + rel->r_offset + 4);
-		  continue;
-		}
-
-	      if (!mips_elf_perform_relocation (info, howto, rel, addend,
-						input_bfd, input_section,
-						contents, false))
-		return false;
-	    }
-
-	  /* Go on to the next relocation.  */
-	  continue;
-	}
-
-      /* In the N32 and 64-bit ABIs there may be multiple consecutive
-	 relocations for the same offset.  In that case we are
-	 supposed to treat the output of each relocation as the addend
-	 for the next.  */
-      if (rel + 1 < relend
-	  && rel->r_offset == rel[1].r_offset
-	  && ELF32_R_TYPE (rel[1].r_info) != R_MIPS_NONE)
-	use_saved_addend_p = true;
-      else
-	use_saved_addend_p = false;
-
-      /* Figure out what value we are supposed to relocate.  */
-      switch (mips_elf_calculate_relocation (output_bfd,
-					     input_bfd,
-					     input_section,
-					     info,
-					     rel,
-					     addend,
-					     howto,
-					     local_syms,
-					     local_sections,
-					     &value,
-					     &name,
-					     &require_jalx))
-	{
-	case bfd_reloc_continue:
-	  /* There's nothing to do.  */
-	  continue;
-
-	case bfd_reloc_undefined:
-	  /* mips_elf_calculate_relocation already called the
-	     undefined_symbol callback.  There's no real point in
-	     trying to perform the relocation at this point, so we
-	     just skip ahead to the next relocation.  */
-	  continue;
-
-	case bfd_reloc_notsupported:
-	  msg = _("internal error: unsupported relocation error");
-	  info->callbacks->warning
-	    (info, msg, name, input_bfd, input_section, rel->r_offset);
-	  return false;
-
-	case bfd_reloc_overflow:
-	  if (use_saved_addend_p)
-	    /* Ignore overflow until we reach the last relocation for
-	       a given location.  */
-	    ;
-	  else
-	    {
-	      BFD_ASSERT (name != NULL);
-	      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_ok:
-	  break;
-
-	default:
-	  abort ();
-	  break;
-	}
-
-      /* If we've got another relocation for the address, keep going
-	 until we reach the last one.  */
-      if (use_saved_addend_p)
-	{
-	  addend = value;
-	  continue;
-	}
-
-      if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
-	/* See the comment above about using R_MIPS_64 in the 32-bit
-	   ABI.  Until now, we've been using the HOWTO for R_MIPS_32;
-	   that calculated the right value.  Now, however, we
-	   sign-extend the 32-bit result to 64-bits, and store it as a
-	   64-bit value.  We are especially generous here in that we
-	   go to extreme lengths to support this usage on systems with
-	   only a 32-bit VMA.  */
-	{
-	  bfd_vma sign_bits;
-	  bfd_vma low_bits;
-	  bfd_vma high_bits;
-
-	  if (value & ((bfd_vma) 1 << 31))
-#ifdef BFD64
-	    sign_bits = ((bfd_vma) 1 << 32) - 1;
-#else
-	    sign_bits = -1;
-#endif
-	  else
-	    sign_bits = 0;
-
-	  /* If we don't know that we have a 64-bit type,
-	     do two separate stores.  */
-	  if (bfd_big_endian (input_bfd))
-	    {
-	      /* Undo what we did above.  */
-	      rel->r_offset -= 4;
-	      /* Store the sign-bits (which are most significant)
-		 first.  */
-	      low_bits = sign_bits;
-	      high_bits = value;
-	    }
-	  else
-	    {
-	      low_bits = value;
-	      high_bits = sign_bits;
-	    }
-	  bfd_put_32 (input_bfd, low_bits,
-		      contents + rel->r_offset);
-	  bfd_put_32 (input_bfd, high_bits,
-		      contents + rel->r_offset + 4);
-	  continue;
-	}
-
-      /* Actually perform the relocation.  */
-      if (!mips_elf_perform_relocation (info, howto, rel, value, input_bfd,
-					input_section, contents,
-					require_jalx))
-	return false;
-    }
-
-  return true;
-}
-
-/* This hook function is called before the linker writes out a global
-   symbol.  We mark symbols as small common if appropriate.  This is
-   also where we undo the increment of the value for a mips16 symbol.  */
-
-boolean
-_bfd_mips_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     const char *name ATTRIBUTE_UNUSED;
-     Elf_Internal_Sym *sym;
-     asection *input_sec;
-{
-  /* If we see a common symbol, which implies a relocatable link, then
-     if a symbol was small common in an input file, mark it as small
-     common in the output file.  */
-  if (sym->st_shndx == SHN_COMMON
-      && strcmp (input_sec->name, ".scommon") == 0)
-    sym->st_shndx = SHN_MIPS_SCOMMON;
-
-  if (sym->st_other == STO_MIPS16
-      && (sym->st_value & 1) != 0)
-    --sym->st_value;
-
-  return true;
-}
-
-/* Functions for the dynamic linker.  */
-
-/* The name of the dynamic interpreter.  This is put in the .interp
-   section.  */
-
-#define ELF_DYNAMIC_INTERPRETER(abfd) 		\
-   (ABI_N32_P (abfd) ? "/usr/lib32/libc.so.1" 	\
-    : ABI_64_P (abfd) ? "/usr/lib64/libc.so.1" 	\
-    : "/usr/lib/libc.so.1")
-
-/* Create dynamic sections when linking against a dynamic object.  */
-
-boolean
-_bfd_mips_elf_create_dynamic_sections (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
-{
-  struct elf_link_hash_entry *h;
-  flagword flags;
-  register asection *s;
-  const char * const *namep;
-
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
-	   | SEC_LINKER_CREATED | SEC_READONLY);
-
-  /* Mips ABI requests the .dynamic section to be read only.  */
-  s = bfd_get_section_by_name (abfd, ".dynamic");
-  if (s != NULL)
-    {
-      if (! bfd_set_section_flags (abfd, s, flags))
-	return false;
-    }
-
-  /* We need to create .got section.  */
-  if (! mips_elf_create_got_section (abfd, info))
-    return false;
-
-  /* Create the .msym section on IRIX6.  It is used by the dynamic
-     linker to speed up dynamic relocations, and to avoid computing
-     the ELF hash for symbols.  */
-  if (IRIX_COMPAT (abfd) == ict_irix6
-      && !mips_elf_create_msym_section (abfd))
-    return false;
-
-  /* Create .stub section.  */
-  if (bfd_get_section_by_name (abfd,
-			       MIPS_ELF_STUB_SECTION_NAME (abfd)) == NULL)
-    {
-      s = bfd_make_section (abfd, MIPS_ELF_STUB_SECTION_NAME (abfd));
-      if (s == NULL
-	  || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
-	  || ! bfd_set_section_alignment (abfd, s,
-					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
-	return false;
-    }
-
-  if ((IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
-      && !info->shared
-      && bfd_get_section_by_name (abfd, ".rld_map") == NULL)
-    {
-      s = bfd_make_section (abfd, ".rld_map");
-      if (s == NULL
-	  || ! bfd_set_section_flags (abfd, s, flags &~ (flagword) SEC_READONLY)
-	  || ! bfd_set_section_alignment (abfd, s,
-					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
-	return false;
-    }
-
-  /* On IRIX5, we adjust add some additional symbols and change the
-     alignments of several sections.  There is no ABI documentation
-     indicating that this is necessary on IRIX6, nor any evidence that
-     the linker takes such action.  */
-  if (IRIX_COMPAT (abfd) == ict_irix5)
-    {
-      for (namep = mips_elf_dynsym_rtproc_names; *namep != NULL; namep++)
-	{
-	  h = NULL;
-	  if (! (_bfd_generic_link_add_one_symbol
-		 (info, abfd, *namep, BSF_GLOBAL, bfd_und_section_ptr,
-		  (bfd_vma) 0, (const char *) NULL, false,
-		  get_elf_backend_data (abfd)->collect,
-		  (struct bfd_link_hash_entry **) &h)))
-	    return false;
-	  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
-	  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-	  h->type = STT_SECTION;
-
-	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-	    return false;
-	}
-
-      /* We need to create a .compact_rel section.  */
-      if (SGI_COMPAT (abfd))
-	{
-	  if (!mips_elf_create_compact_rel_section (abfd, info))
-	    return false;
-	}
-
-      /* Change aligments of some sections.  */
-      s = bfd_get_section_by_name (abfd, ".hash");
-      if (s != NULL)
-	bfd_set_section_alignment (abfd, s, 4);
-      s = bfd_get_section_by_name (abfd, ".dynsym");
-      if (s != NULL)
-	bfd_set_section_alignment (abfd, s, 4);
-      s = bfd_get_section_by_name (abfd, ".dynstr");
-      if (s != NULL)
-	bfd_set_section_alignment (abfd, s, 4);
-      s = bfd_get_section_by_name (abfd, ".reginfo");
-      if (s != NULL)
-	bfd_set_section_alignment (abfd, s, 4);
-      s = bfd_get_section_by_name (abfd, ".dynamic");
-      if (s != NULL)
-	bfd_set_section_alignment (abfd, s, 4);
-    }
-
-  if (!info->shared)
-    {
-      h = NULL;
-      if (SGI_COMPAT (abfd))
-	{
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, abfd, "_DYNAMIC_LINK", BSF_GLOBAL, bfd_abs_section_ptr,
-		 (bfd_vma) 0, (const char *) NULL, false,
-		 get_elf_backend_data (abfd)->collect,
-		 (struct bfd_link_hash_entry **) &h)))
-	    return false;
-	}
-      else
-	{
-	  /* For normal mips it is _DYNAMIC_LINKING.  */
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, abfd, "_DYNAMIC_LINKING", BSF_GLOBAL,
-		 bfd_abs_section_ptr, (bfd_vma) 0, (const char *) NULL, false,
-		 get_elf_backend_data (abfd)->collect,
-		 (struct bfd_link_hash_entry **) &h)))
-	    return false;
-	}
-      h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
-      h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-      h->type = STT_SECTION;
-
-      if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-	return false;
-
-      if (! mips_elf_hash_table (info)->use_rld_obj_head)
-	{
-	  /* __rld_map is a four byte word located in the .data section
-	     and is filled in by the rtld to contain a pointer to
-	     the _r_debug structure. Its symbol value will be set in
-	     mips_elf_finish_dynamic_symbol.  */
-	  s = bfd_get_section_by_name (abfd, ".rld_map");
-	  BFD_ASSERT (s != NULL);
-
-	  h = NULL;
-	  if (SGI_COMPAT (abfd))
-	    {
-	      if (!(_bfd_generic_link_add_one_symbol
-		    (info, abfd, "__rld_map", BSF_GLOBAL, s,
-		     (bfd_vma) 0, (const char *) NULL, false,
-		     get_elf_backend_data (abfd)->collect,
-		     (struct bfd_link_hash_entry **) &h)))
-		return false;
-	    }
-	  else
-	    {
-	      /* For normal mips the symbol is __RLD_MAP.  */
-	      if (!(_bfd_generic_link_add_one_symbol
-		    (info, abfd, "__RLD_MAP", BSF_GLOBAL, s,
-		     (bfd_vma) 0, (const char *) NULL, false,
-		     get_elf_backend_data (abfd)->collect,
-		     (struct bfd_link_hash_entry **) &h)))
-		return false;
-	    }
-	  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
-	  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-	  h->type = STT_OBJECT;
-
-	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-	    return false;
-	}
-    }
-
-  return true;
-}
-
-/* Create the .compact_rel section.  */
-
-static boolean
-mips_elf_create_compact_rel_section (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-{
-  flagword flags;
-  register asection *s;
-
-  if (bfd_get_section_by_name (abfd, ".compact_rel") == NULL)
-    {
-      flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED
-	       | SEC_READONLY);
-
-      s = bfd_make_section (abfd, ".compact_rel");
-      if (s == NULL
-	  || ! bfd_set_section_flags (abfd, s, flags)
-	  || ! bfd_set_section_alignment (abfd, s,
-					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
-	return false;
-
-      s->_raw_size = sizeof (Elf32_External_compact_rel);
-    }
-
-  return true;
-}
-
-/* Create the .got section to hold the global offset table.  */
-
-static boolean
-mips_elf_create_got_section (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
-{
-  flagword flags;
-  register asection *s;
-  struct elf_link_hash_entry *h;
-  struct mips_got_info *g;
-  bfd_size_type amt;
-
-  /* This function may be called more than once.  */
-  if (mips_elf_got_section (abfd))
-    return true;
-
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
-	   | SEC_LINKER_CREATED);
-
-  s = bfd_make_section (abfd, ".got");
-  if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags)
-      || ! bfd_set_section_alignment (abfd, s, 4))
-    return false;
-
-  /* Define the symbol _GLOBAL_OFFSET_TABLE_.  We don't do this in the
-     linker script because we don't want to define the symbol if we
-     are not creating a global offset table.  */
-  h = NULL;
-  if (! (_bfd_generic_link_add_one_symbol
-	 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
-	  (bfd_vma) 0, (const char *) NULL, false,
-	  get_elf_backend_data (abfd)->collect,
-	  (struct bfd_link_hash_entry **) &h)))
-    return false;
-  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
-  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-  h->type = STT_OBJECT;
-
-  if (info->shared
-      && ! bfd_elf32_link_record_dynamic_symbol (info, h))
-    return false;
-
-  /* The first several global offset table entries are reserved.  */
-  s->_raw_size = MIPS_RESERVED_GOTNO * MIPS_ELF_GOT_SIZE (abfd);
-
-  amt = sizeof (struct mips_got_info);
-  g = (struct mips_got_info *) bfd_alloc (abfd, amt);
-  if (g == NULL)
-    return false;
-  g->global_gotsym = NULL;
-  g->local_gotno = MIPS_RESERVED_GOTNO;
-  g->assigned_gotno = MIPS_RESERVED_GOTNO;
-  if (elf_section_data (s) == NULL)
-    {
-      amt = sizeof (struct bfd_elf_section_data);
-      s->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
-      if (elf_section_data (s) == NULL)
-	return false;
-    }
-  elf_section_data (s)->tdata = (PTR) g;
-  elf_section_data (s)->this_hdr.sh_flags
-    |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
-
-  return true;
-}
-
-/* Returns the .msym section for ABFD, creating it if it does not
-   already exist.  Returns NULL to indicate error.  */
-
-static asection *
-mips_elf_create_msym_section (abfd)
-     bfd *abfd;
-{
-  asection *s;
-
-  s = bfd_get_section_by_name (abfd, MIPS_ELF_MSYM_SECTION_NAME (abfd));
-  if (!s)
-    {
-      s = bfd_make_section (abfd, MIPS_ELF_MSYM_SECTION_NAME (abfd));
-      if (!s
-	  || !bfd_set_section_flags (abfd, s,
-				     SEC_ALLOC
-				     | SEC_LOAD
-				     | SEC_HAS_CONTENTS
-				     | SEC_LINKER_CREATED
-				     | SEC_READONLY)
-	  || !bfd_set_section_alignment (abfd, s,
-					 MIPS_ELF_LOG_FILE_ALIGN (abfd)))
-	return NULL;
-    }
-
-  return s;
-}
-
-/* Add room for N relocations to the .rel.dyn section in ABFD.  */
-
-static void
-mips_elf_allocate_dynamic_relocations (abfd, n)
-     bfd *abfd;
-     unsigned int n;
-{
-  asection *s;
-
-  s = bfd_get_section_by_name (abfd, MIPS_ELF_REL_DYN_SECTION_NAME (abfd));
-  BFD_ASSERT (s != NULL);
-
-  if (s->_raw_size == 0)
-    {
-      /* Make room for a null element.  */
-      s->_raw_size += MIPS_ELF_REL_SIZE (abfd);
-      ++s->reloc_count;
-    }
-  s->_raw_size += n * MIPS_ELF_REL_SIZE (abfd);
-}
-
-/* Look through the relocs for a section during the first phase, and
-   allocate space in the global offset table.  */
-
-boolean
-_bfd_mips_elf_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
-{
-  const char *name;
-  bfd *dynobj;
-  Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes;
-  struct mips_got_info *g;
-  size_t extsymoff;
-  const Elf_Internal_Rela *rel;
-  const Elf_Internal_Rela *rel_end;
-  asection *sgot;
-  asection *sreloc;
-  struct elf_backend_data *bed;
-
-  if (info->relocateable)
-    return true;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
-  extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
-
-  /* Check for the mips16 stub sections.  */
-
-  name = bfd_get_section_name (abfd, sec);
-  if (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0)
-    {
-      unsigned long r_symndx;
-
-      /* Look at the relocation information to figure out which symbol
-         this is for.  */
-
-      r_symndx = ELF32_R_SYM (relocs->r_info);
-
-      if (r_symndx < extsymoff
-	  || sym_hashes[r_symndx - extsymoff] == NULL)
-	{
-	  asection *o;
-
-	  /* This stub is for a local symbol.  This stub will only be
-             needed if there is some relocation in this BFD, other
-             than a 16 bit function call, which refers to this symbol.  */
-	  for (o = abfd->sections; o != NULL; o = o->next)
-	    {
-	      Elf_Internal_Rela *sec_relocs;
-	      const Elf_Internal_Rela *r, *rend;
-
-	      /* We can ignore stub sections when looking for relocs.  */
-	      if ((o->flags & SEC_RELOC) == 0
-		  || o->reloc_count == 0
-		  || strncmp (bfd_get_section_name (abfd, o), FN_STUB,
-			      sizeof FN_STUB - 1) == 0
-		  || strncmp (bfd_get_section_name (abfd, o), CALL_STUB,
-			      sizeof CALL_STUB - 1) == 0
-		  || strncmp (bfd_get_section_name (abfd, o), CALL_FP_STUB,
-			      sizeof CALL_FP_STUB - 1) == 0)
-		continue;
-
-	      sec_relocs = (_bfd_elf32_link_read_relocs
-			    (abfd, o, (PTR) NULL,
-			     (Elf_Internal_Rela *) NULL,
-			     info->keep_memory));
-	      if (sec_relocs == NULL)
-		return false;
-
-	      rend = sec_relocs + o->reloc_count;
-	      for (r = sec_relocs; r < rend; r++)
-		if (ELF32_R_SYM (r->r_info) == r_symndx
-		    && ELF32_R_TYPE (r->r_info) != R_MIPS16_26)
-		  break;
-
-	      if (! info->keep_memory)
-		free (sec_relocs);
-
-	      if (r < rend)
-		break;
-	    }
-
-	  if (o == NULL)
-	    {
-	      /* There is no non-call reloc for this stub, so we do
-                 not need it.  Since this function is called before
-                 the linker maps input sections to output sections, we
-                 can easily discard it by setting the SEC_EXCLUDE
-                 flag.  */
-	      sec->flags |= SEC_EXCLUDE;
-	      return true;
-	    }
-
-	  /* Record this stub in an array of local symbol stubs for
-             this BFD.  */
-	  if (elf_tdata (abfd)->local_stubs == NULL)
-	    {
-	      unsigned long symcount;
-	      asection **n;
-	      bfd_size_type amt;
-
-	      if (elf_bad_symtab (abfd))
-		symcount = NUM_SHDR_ENTRIES (symtab_hdr);
-	      else
-		symcount = symtab_hdr->sh_info;
-	      amt = symcount * sizeof (asection *);
-	      n = (asection **) bfd_zalloc (abfd, amt);
-	      if (n == NULL)
-		return false;
-	      elf_tdata (abfd)->local_stubs = n;
-	    }
-
-	  elf_tdata (abfd)->local_stubs[r_symndx] = sec;
-
-	  /* We don't need to set mips16_stubs_seen in this case.
-             That flag is used to see whether we need to look through
-             the global symbol table for stubs.  We don't need to set
-             it here, because we just have a local stub.  */
-	}
-      else
-	{
-	  struct mips_elf_link_hash_entry *h;
-
-	  h = ((struct mips_elf_link_hash_entry *)
-	       sym_hashes[r_symndx - extsymoff]);
-
-	  /* H is the symbol this stub is for.  */
-
-	  h->fn_stub = sec;
-	  mips_elf_hash_table (info)->mips16_stubs_seen = true;
-	}
-    }
-  else if (strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
-	   || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
-    {
-      unsigned long r_symndx;
-      struct mips_elf_link_hash_entry *h;
-      asection **loc;
-
-      /* Look at the relocation information to figure out which symbol
-         this is for.  */
-
-      r_symndx = ELF32_R_SYM (relocs->r_info);
-
-      if (r_symndx < extsymoff
-	  || sym_hashes[r_symndx - extsymoff] == NULL)
-	{
-	  /* This stub was actually built for a static symbol defined
-	     in the same file.  We assume that all static symbols in
-	     mips16 code are themselves mips16, so we can simply
-	     discard this stub.  Since this function is called before
-	     the linker maps input sections to output sections, we can
-	     easily discard it by setting the SEC_EXCLUDE flag.  */
-	  sec->flags |= SEC_EXCLUDE;
-	  return true;
-	}
-
-      h = ((struct mips_elf_link_hash_entry *)
-	   sym_hashes[r_symndx - extsymoff]);
-
-      /* H is the symbol this stub is for.  */
-
-      if (strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
-	loc = &h->call_fp_stub;
-      else
-	loc = &h->call_stub;
-
-      /* If we already have an appropriate stub for this function, we
-	 don't need another one, so we can discard this one.  Since
-	 this function is called before the linker maps input sections
-	 to output sections, we can easily discard it by setting the
-	 SEC_EXCLUDE flag.  We can also discard this section if we
-	 happen to already know that this is a mips16 function; it is
-	 not necessary to check this here, as it is checked later, but
-	 it is slightly faster to check now.  */
-      if (*loc != NULL || h->root.other == STO_MIPS16)
-	{
-	  sec->flags |= SEC_EXCLUDE;
-	  return true;
-	}
-
-      *loc = sec;
-      mips_elf_hash_table (info)->mips16_stubs_seen = true;
-    }
-
-  if (dynobj == NULL)
-    {
-      sgot = NULL;
-      g = NULL;
-    }
-  else
-    {
-      sgot = mips_elf_got_section (dynobj);
-      if (sgot == NULL)
-	g = NULL;
-      else
-	{
-	  BFD_ASSERT (elf_section_data (sgot) != NULL);
-	  g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
-	  BFD_ASSERT (g != NULL);
-	}
-    }
-
-  sreloc = NULL;
-  bed = get_elf_backend_data (abfd);
-  rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
-  for (rel = relocs; rel < rel_end; ++rel)
-    {
-      unsigned long r_symndx;
-      unsigned int r_type;
-      struct elf_link_hash_entry *h;
-
-      r_symndx = ELF32_R_SYM (rel->r_info);
-      r_type = ELF32_R_TYPE (rel->r_info);
-
-      if (r_symndx < extsymoff)
-	h = NULL;
-      else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
-	{
-	  (*_bfd_error_handler)
-	    (_("%s: Malformed reloc detected for section %s"),
-	     bfd_archive_filename (abfd), name);
-	  bfd_set_error (bfd_error_bad_value);
-	  return false;
-	}
-      else
-	{
-	  h = sym_hashes[r_symndx - extsymoff];
-
-	  /* This may be an indirect symbol created because of a version.  */
-	  if (h != NULL)
-	    {
-	      while (h->root.type == bfd_link_hash_indirect)
-		h = (struct elf_link_hash_entry *) h->root.u.i.link;
-	    }
-	}
-
-      /* Some relocs require a global offset table.  */
-      if (dynobj == NULL || sgot == NULL)
-	{
-	  switch (r_type)
-	    {
-	    case R_MIPS_GOT16:
-	    case R_MIPS_CALL16:
-	    case R_MIPS_CALL_HI16:
-	    case R_MIPS_CALL_LO16:
-	    case R_MIPS_GOT_HI16:
-	    case R_MIPS_GOT_LO16:
-	    case R_MIPS_GOT_PAGE:
-	    case R_MIPS_GOT_OFST:
-	    case R_MIPS_GOT_DISP:
-	      if (dynobj == NULL)
-		elf_hash_table (info)->dynobj = dynobj = abfd;
-	      if (! mips_elf_create_got_section (dynobj, info))
-		return false;
-	      g = mips_elf_got_info (dynobj, &sgot);
-	      break;
-
-	    case R_MIPS_32:
-	    case R_MIPS_REL32:
-	    case R_MIPS_64:
-	      if (dynobj == NULL
-		  && (info->shared || h != NULL)
-		  && (sec->flags & SEC_ALLOC) != 0)
-		elf_hash_table (info)->dynobj = dynobj = abfd;
-	      break;
-
-	    default:
-	      break;
-	    }
-	}
-
-      if (!h && (r_type == R_MIPS_CALL_LO16
-		 || r_type == R_MIPS_GOT_LO16
-		 || r_type == R_MIPS_GOT_DISP))
-	{
-	  /* We may need a local GOT entry for this relocation.  We
-	     don't count R_MIPS_GOT_PAGE because we can estimate the
-	     maximum number of pages needed by looking at the size of
-	     the segment.  Similar comments apply to R_MIPS_GOT16 and
-	     R_MIPS_CALL16.  We don't count R_MIPS_GOT_HI16, or
-	     R_MIPS_CALL_HI16 because these are always followed by an
-	     R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16.
-
-	     This estimation is very conservative since we can merge
-	     duplicate entries in the GOT.  In order to be less
-	     conservative, we could actually build the GOT here,
-	     rather than in relocate_section.  */
-	  g->local_gotno++;
-	  sgot->_raw_size += MIPS_ELF_GOT_SIZE (dynobj);
-	}
-
-      switch (r_type)
-	{
-	case R_MIPS_CALL16:
-	  if (h == NULL)
-	    {
-	      (*_bfd_error_handler)
-		(_("%s: CALL16 reloc at 0x%lx not against global symbol"),
-		 bfd_archive_filename (abfd), (unsigned long) rel->r_offset);
-	      bfd_set_error (bfd_error_bad_value);
-	      return false;
-	    }
-	  /* Fall through.  */
-
-	case R_MIPS_CALL_HI16:
-	case R_MIPS_CALL_LO16:
-	  if (h != NULL)
-	    {
-	      /* This symbol requires a global offset table entry.  */
-	      if (!mips_elf_record_global_got_symbol (h, info, g))
-		return false;
-
-	      /* We need a stub, not a plt entry for the undefined
-		 function.  But we record it as if it needs plt.  See
-		 elf_adjust_dynamic_symbol in elflink.h.  */
-	      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-	      h->type = STT_FUNC;
-	    }
-	  break;
-
-	case R_MIPS_GOT16:
-	case R_MIPS_GOT_HI16:
-	case R_MIPS_GOT_LO16:
-	case R_MIPS_GOT_DISP:
-	  /* This symbol requires a global offset table entry.  */
-	  if (h && !mips_elf_record_global_got_symbol (h, info, g))
-	    return false;
-	  break;
-
-	case R_MIPS_32:
-	case R_MIPS_REL32:
-	case R_MIPS_64:
-	  if ((info->shared || h != NULL)
-	      && (sec->flags & SEC_ALLOC) != 0)
-	    {
-	      if (sreloc == NULL)
-		{
-		  const char *dname = MIPS_ELF_REL_DYN_SECTION_NAME (dynobj);
-
-		  sreloc = bfd_get_section_by_name (dynobj, dname);
-		  if (sreloc == NULL)
-		    {
-		      sreloc = bfd_make_section (dynobj, dname);
-		      if (sreloc == NULL
-			  || ! bfd_set_section_flags (dynobj, sreloc,
-						      (SEC_ALLOC
-						       | SEC_LOAD
-						       | SEC_HAS_CONTENTS
-						       | SEC_IN_MEMORY
-						       | SEC_LINKER_CREATED
-						       | SEC_READONLY))
-			  || ! bfd_set_section_alignment (dynobj, sreloc,
-							  4))
-			return false;
-		    }
-		}
-#define MIPS_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
-	      if (info->shared)
-		{
-		  /* When creating a shared object, we must copy these
-		     reloc types into the output file as R_MIPS_REL32
-		     relocs.  We make room for this reloc in the
-		     .rel.dyn reloc section.  */
-		  mips_elf_allocate_dynamic_relocations (dynobj, 1);
-		  if ((sec->flags & MIPS_READONLY_SECTION)
-		      == MIPS_READONLY_SECTION)
-		    /* We tell the dynamic linker that there are
-		       relocations against the text segment.  */
-		    info->flags |= DF_TEXTREL;
-		}
-	      else
-		{
-		  struct mips_elf_link_hash_entry *hmips;
-
-		  /* We only need to copy this reloc if the symbol is
-                     defined in a dynamic object.  */
-		  hmips = (struct mips_elf_link_hash_entry *) h;
-		  ++hmips->possibly_dynamic_relocs;
-		  if ((sec->flags & MIPS_READONLY_SECTION)
-		      == MIPS_READONLY_SECTION)
-		    /* We need it to tell the dynamic linker if there
-		       are relocations against the text segment.  */
-		    hmips->readonly_reloc = true;
-		}
-
-	      /* Even though we don't directly need a GOT entry for
-		 this symbol, a symbol must have a dynamic symbol
-		 table index greater that DT_MIPS_GOTSYM if there are
-		 dynamic relocations against it.  */
-	      if (h != NULL
-		  && !mips_elf_record_global_got_symbol (h, info, g))
-		return false;
-	    }
-
-	  if (SGI_COMPAT (abfd))
-	    mips_elf_hash_table (info)->compact_rel_size +=
-	      sizeof (Elf32_External_crinfo);
-	  break;
-
-	case R_MIPS_26:
-	case R_MIPS_GPREL16:
-	case R_MIPS_LITERAL:
-	case R_MIPS_GPREL32:
-	  if (SGI_COMPAT (abfd))
-	    mips_elf_hash_table (info)->compact_rel_size +=
-	      sizeof (Elf32_External_crinfo);
-	  break;
-
-	  /* This relocation describes the C++ object vtable hierarchy.
-	     Reconstruct it for later use during GC.  */
-	case R_MIPS_GNU_VTINHERIT:
-	  if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
-	    return false;
-	  break;
-
-	  /* This relocation describes which C++ vtable entries are actually
-	     used.  Record for later use during GC.  */
-	case R_MIPS_GNU_VTENTRY:
-	  if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
-	    return false;
-	  break;
-
-	default:
-	  break;
-	}
-
-      /* We must not create a stub for a symbol that has relocations
-         related to taking the function's address.  */
-      switch (r_type)
-	{
-	default:
-	  if (h != NULL)
-	    {
-	      struct mips_elf_link_hash_entry *mh;
-
-	      mh = (struct mips_elf_link_hash_entry *) h;
-	      mh->no_fn_stub = true;
-	    }
-	  break;
-	case R_MIPS_CALL16:
-	case R_MIPS_CALL_HI16:
-	case R_MIPS_CALL_LO16:
-	  break;
-	}
-
-      /* If this reloc is not a 16 bit call, and it has a global
-         symbol, then we will need the fn_stub if there is one.
-         References from a stub section do not count.  */
-      if (h != NULL
-	  && r_type != R_MIPS16_26
-	  && strncmp (bfd_get_section_name (abfd, sec), FN_STUB,
-		      sizeof FN_STUB - 1) != 0
-	  && strncmp (bfd_get_section_name (abfd, sec), CALL_STUB,
-		      sizeof CALL_STUB - 1) != 0
-	  && strncmp (bfd_get_section_name (abfd, sec), CALL_FP_STUB,
-		      sizeof CALL_FP_STUB - 1) != 0)
-	{
-	  struct mips_elf_link_hash_entry *mh;
-
-	  mh = (struct mips_elf_link_hash_entry *) h;
-	  mh->need_fn_stub = true;
-	}
-    }
-
-  return true;
-}
-
-/* Return the section that should be marked against GC for a given
-   relocation.  */
-
-asection *
-_bfd_mips_elf_gc_mark_hook (abfd, info, rel, h, sym)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
-{
-  /* ??? Do mips16 stub sections need to be handled special?  */
-
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-	case R_MIPS_GNU_VTINHERIT:
-	case R_MIPS_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    case bfd_link_hash_defined:
-	    case bfd_link_hash_defweak:
-	      return h->root.u.def.section;
-
-	    case bfd_link_hash_common:
-	      return h->root.u.c.p->section;
-
-	    default:
-	      break;
-	    }
-	}
-    }
-  else
-    {
-      return bfd_section_from_elf_index (abfd, sym->st_shndx);
-    }
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
-
-boolean
-_bfd_mips_elf_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
-{
-#if 0
-  Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes;
-  bfd_signed_vma *local_got_refcounts;
-  const Elf_Internal_Rela *rel, *relend;
-  unsigned long r_symndx;
-  struct elf_link_hash_entry *h;
-
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
-  local_got_refcounts = elf_local_got_refcounts (abfd);
-
-  relend = relocs + sec->reloc_count;
-  for (rel = relocs; rel < relend; rel++)
-    switch (ELF32_R_TYPE (rel->r_info))
-      {
-      case R_MIPS_GOT16:
-      case R_MIPS_CALL16:
-      case R_MIPS_CALL_HI16:
-      case R_MIPS_CALL_LO16:
-      case R_MIPS_GOT_HI16:
-      case R_MIPS_GOT_LO16:
-	/* ??? It would seem that the existing MIPS code does no sort
-	   of reference counting or whatnot on its GOT and PLT entries,
-	   so it is not possible to garbage collect them at this time.  */
-	break;
-
-      default:
-	break;
-      }
-#endif
-
-  return true;
-}
-
-/* Copy data from a MIPS ELF indirect symbol to its direct symbol,
-   hiding the old indirect symbol.  Process additional relocation
-   information.  Also called for weakdefs, in which case we just let
-   _bfd_elf_link_hash_copy_indirect copy the flags for us.  */
-
-static void
-_bfd_mips_elf_copy_indirect_symbol (dir, ind)
-     struct elf_link_hash_entry *dir, *ind;
-{
-  struct mips_elf_link_hash_entry *dirmips, *indmips;
-
-  _bfd_elf_link_hash_copy_indirect (dir, ind);
-
-  if (ind->root.type != bfd_link_hash_indirect)
-    return;
-
-  dirmips = (struct mips_elf_link_hash_entry *) dir;
-  indmips = (struct mips_elf_link_hash_entry *) ind;
-  dirmips->possibly_dynamic_relocs += indmips->possibly_dynamic_relocs;
-  if (indmips->readonly_reloc)
-    dirmips->readonly_reloc = true;
-  if (dirmips->min_dyn_reloc_index == 0
-      || (indmips->min_dyn_reloc_index != 0
-	  && indmips->min_dyn_reloc_index < dirmips->min_dyn_reloc_index))
-    dirmips->min_dyn_reloc_index = indmips->min_dyn_reloc_index;
-  if (indmips->no_fn_stub)
-    dirmips->no_fn_stub = true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
-   regular object.  The current definition is in some section of the
-   dynamic object, but we're not including those sections.  We have to
-   change the definition to something the rest of the link can
-   understand.  */
-
-boolean
-_bfd_mips_elf_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-{
-  bfd *dynobj;
-  struct mips_elf_link_hash_entry *hmips;
-  asection *s;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
-  /* Make sure we know what is going on here.  */
-  BFD_ASSERT (dynobj != NULL
-	      && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
-		  || h->weakdef != NULL
-		  || ((h->elf_link_hash_flags
-		       & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-		      && (h->elf_link_hash_flags
-			  & ELF_LINK_HASH_REF_REGULAR) != 0
-		      && (h->elf_link_hash_flags
-			  & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
-  /* If this symbol is defined in a dynamic object, we need to copy
-     any R_MIPS_32 or R_MIPS_REL32 relocs against it into the output
-     file.  */
-  hmips = (struct mips_elf_link_hash_entry *) h;
-  if (! info->relocateable
-      && hmips->possibly_dynamic_relocs != 0
-      && (h->root.type == bfd_link_hash_defweak
-	  || (h->elf_link_hash_flags
-	      & ELF_LINK_HASH_DEF_REGULAR) == 0))
-    {
-      mips_elf_allocate_dynamic_relocations (dynobj,
-					     hmips->possibly_dynamic_relocs);
-      if (hmips->readonly_reloc)
-	/* We tell the dynamic linker that there are relocations
-	   against the text segment.  */
-	info->flags |= DF_TEXTREL;
-    }
-
-  /* For a function, create a stub, if allowed.  */
-  if (! hmips->no_fn_stub
-      && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
-    {
-      if (! elf_hash_table (info)->dynamic_sections_created)
-	return true;
-
-      /* If this symbol is not defined in a regular file, then set
-	 the symbol to the stub location.  This is required to make
-	 function pointers compare as equal between the normal
-	 executable and the shared library.  */
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
-	{
-	  /* We need .stub section.  */
-	  s = bfd_get_section_by_name (dynobj,
-				       MIPS_ELF_STUB_SECTION_NAME (dynobj));
-	  BFD_ASSERT (s != NULL);
-
-	  h->root.u.def.section = s;
-	  h->root.u.def.value = s->_raw_size;
-
-	  /* XXX Write this stub address somewhere.  */
-	  h->plt.offset = s->_raw_size;
-
-	  /* Make room for this stub code.  */
-	  s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
-
-	  /* The last half word of the stub will be filled with the index
-	     of this symbol in .dynsym section.  */
-	  return true;
-	}
-    }
-  else if ((h->type == STT_FUNC)
-	   && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
-    {
-      /* This will set the entry for this symbol in the GOT to 0, and
-         the dynamic linker will take care of this.  */
-      h->root.u.def.value = 0;
-      return true;
-    }
-
-  /* If this is a weak symbol, and there is a real definition, the
-     processor independent code will have arranged for us to see the
-     real definition first, and we can just use the same value.  */
-  if (h->weakdef != NULL)
-    {
-      BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
-		  || h->weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->weakdef->root.u.def.section;
-      h->root.u.def.value = h->weakdef->root.u.def.value;
-      return true;
-    }
-
-  /* This is a reference to a symbol defined by a dynamic object which
-     is not a function.  */
-
-  return true;
-}
-
-/* This function is called after all the input files have been read,
-   and the input sections have been assigned to output sections.  We
-   check for any mips16 stub sections that we can discard.  */
-
-static boolean mips_elf_check_mips16_stubs
-  PARAMS ((struct mips_elf_link_hash_entry *, PTR));
-
-boolean
-_bfd_mips_elf_always_size_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-{
-  asection *ri;
-
-  /* The .reginfo section has a fixed size.  */
-  ri = bfd_get_section_by_name (output_bfd, ".reginfo");
-  if (ri != NULL)
-    bfd_set_section_size (output_bfd, ri,
-			  (bfd_size_type) sizeof (Elf32_External_RegInfo));
-
-  if (info->relocateable
-      || ! mips_elf_hash_table (info)->mips16_stubs_seen)
-    return true;
-
-  mips_elf_link_hash_traverse (mips_elf_hash_table (info),
-			       mips_elf_check_mips16_stubs,
-			       (PTR) NULL);
-
-  return true;
-}
-
-/* Check the mips16 stubs for a particular symbol, and see if we can
-   discard them.  */
-
-static boolean
-mips_elf_check_mips16_stubs (h, data)
-     struct mips_elf_link_hash_entry *h;
-     PTR data ATTRIBUTE_UNUSED;
-{
-  if (h->fn_stub != NULL
-      && ! h->need_fn_stub)
-    {
-      /* We don't need the fn_stub; the only references to this symbol
-         are 16 bit calls.  Clobber the size to 0 to prevent it from
-         being included in the link.  */
-      h->fn_stub->_raw_size = 0;
-      h->fn_stub->_cooked_size = 0;
-      h->fn_stub->flags &= ~SEC_RELOC;
-      h->fn_stub->reloc_count = 0;
-      h->fn_stub->flags |= SEC_EXCLUDE;
-    }
-
-  if (h->call_stub != NULL
-      && h->root.other == STO_MIPS16)
-    {
-      /* We don't need the call_stub; this is a 16 bit function, so
-         calls from other 16 bit functions are OK.  Clobber the size
-         to 0 to prevent it from being included in the link.  */
-      h->call_stub->_raw_size = 0;
-      h->call_stub->_cooked_size = 0;
-      h->call_stub->flags &= ~SEC_RELOC;
-      h->call_stub->reloc_count = 0;
-      h->call_stub->flags |= SEC_EXCLUDE;
-    }
-
-  if (h->call_fp_stub != NULL
-      && h->root.other == STO_MIPS16)
-    {
-      /* We don't need the call_stub; this is a 16 bit function, so
-         calls from other 16 bit functions are OK.  Clobber the size
-         to 0 to prevent it from being included in the link.  */
-      h->call_fp_stub->_raw_size = 0;
-      h->call_fp_stub->_cooked_size = 0;
-      h->call_fp_stub->flags &= ~SEC_RELOC;
-      h->call_fp_stub->reloc_count = 0;
-      h->call_fp_stub->flags |= SEC_EXCLUDE;
-    }
-
-  return true;
-}
-
-/* Set the sizes of the dynamic sections.  */
-
-boolean
-_bfd_mips_elf_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-{
-  bfd *dynobj;
-  asection *s;
-  boolean reltext;
-  struct mips_got_info *g = NULL;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  BFD_ASSERT (dynobj != NULL);
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
-	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
-	  BFD_ASSERT (s != NULL);
-	  s->_raw_size
-	    = strlen (ELF_DYNAMIC_INTERPRETER (output_bfd)) + 1;
-	  s->contents
-	    = (bfd_byte *) ELF_DYNAMIC_INTERPRETER (output_bfd);
-	}
-    }
-
-  /* The check_relocs and adjust_dynamic_symbol entry points have
-     determined the sizes of the various dynamic sections.  Allocate
-     memory for them.  */
-  reltext = false;
-  for (s = dynobj->sections; s != NULL; s = s->next)
-    {
-      const char *name;
-      boolean strip;
-
-      /* It's OK to base decisions on the section name, because none
-	 of the dynobj section names depend upon the input files.  */
-      name = bfd_get_section_name (dynobj, s);
-
-      if ((s->flags & SEC_LINKER_CREATED) == 0)
-	continue;
-
-      strip = false;
-
-      if (strncmp (name, ".rel", 4) == 0)
-	{
-	  if (s->_raw_size == 0)
-	    {
-	      /* We only strip the section if the output section name
-                 has the same name.  Otherwise, there might be several
-                 input sections for this output section.  FIXME: This
-                 code is probably not needed these days anyhow, since
-                 the linker now does not create empty output sections.  */
-	      if (s->output_section != NULL
-		  && strcmp (name,
-			     bfd_get_section_name (s->output_section->owner,
-						   s->output_section)) == 0)
-		strip = true;
-	    }
-	  else
-	    {
-	      const char *outname;
-	      asection *target;
-
-	      /* If this relocation section applies to a read only
-                 section, then we probably need a DT_TEXTREL entry.
-                 If the relocation section is .rel.dyn, we always
-                 assert a DT_TEXTREL entry rather than testing whether
-                 there exists a relocation to a read only section or
-                 not.  */
-	      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
-		   && (target->flags & SEC_ALLOC) != 0)
-		  || strcmp (outname,
-			     MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd)) == 0)
-		reltext = true;
-
-	      /* We use the reloc_count field as a counter if we need
-		 to copy relocs into the output file.  */
-	      if (strcmp (name,
-			  MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd)) != 0)
-		s->reloc_count = 0;
-	    }
-	}
-      else if (strncmp (name, ".got", 4) == 0)
-	{
-	  int i;
-	  bfd_size_type loadable_size = 0;
-	  bfd_size_type local_gotno;
-	  bfd *sub;
-
-	  BFD_ASSERT (elf_section_data (s) != NULL);
-	  g = (struct mips_got_info *) elf_section_data (s)->tdata;
-	  BFD_ASSERT (g != NULL);
-
-	  /* Calculate the total loadable size of the output.  That
-	     will give us the maximum number of GOT_PAGE entries
-	     required.  */
-	  for (sub = info->input_bfds; sub; sub = sub->link_next)
-	    {
-	      asection *subsection;
-
-	      for (subsection = sub->sections;
-		   subsection;
-		   subsection = subsection->next)
-		{
-		  if ((subsection->flags & SEC_ALLOC) == 0)
-		    continue;
-		  loadable_size += ((subsection->_raw_size + 0xf)
-				    &~ (bfd_size_type) 0xf);
-		}
-	    }
-	  loadable_size += MIPS_FUNCTION_STUB_SIZE;
-
-	  /* Assume there are two loadable segments consisting of
-	     contiguous sections.  Is 5 enough?  */
-	  local_gotno = (loadable_size >> 16) + 5;
-	  if (IRIX_COMPAT (output_bfd) == ict_irix6)
-	    /* It's possible we will need GOT_PAGE entries as well as
-	       GOT16 entries.  Often, these will be able to share GOT
-	       entries, but not always.  */
-	    local_gotno *= 2;
-
-	  g->local_gotno += local_gotno;
-	  s->_raw_size += local_gotno * MIPS_ELF_GOT_SIZE (dynobj);
-
-	  /* There has to be a global GOT entry for every symbol with
-	     a dynamic symbol table index of DT_MIPS_GOTSYM or
-	     higher.  Therefore, it make sense to put those symbols
-	     that need GOT entries at the end of the symbol table.  We
-	     do that here.  */
- 	  if (!mips_elf_sort_hash_table (info, 1))
- 	    return false;
-
-	  if (g->global_gotsym != NULL)
-	    i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx;
-	  else
-	    /* If there are no global symbols, or none requiring
-	       relocations, then GLOBAL_GOTSYM will be NULL.  */
-	    i = 0;
-	  g->global_gotno = i;
-	  s->_raw_size += i * MIPS_ELF_GOT_SIZE (dynobj);
-	}
-      else if (strcmp (name, MIPS_ELF_STUB_SECTION_NAME (output_bfd)) == 0)
-	{
-	  /* Irix rld assumes that the function stub isn't at the end
-	     of .text section. So put a dummy. XXX  */
-	  s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
-	}
-      else if (! info->shared
-	       && ! mips_elf_hash_table (info)->use_rld_obj_head
-	       && strncmp (name, ".rld_map", 8) == 0)
-	{
-	  /* We add a room for __rld_map. It will be filled in by the
-	     rtld to contain a pointer to the _r_debug structure.  */
-	  s->_raw_size += 4;
-	}
-      else if (SGI_COMPAT (output_bfd)
-	       && strncmp (name, ".compact_rel", 12) == 0)
-	s->_raw_size += mips_elf_hash_table (info)->compact_rel_size;
-      else if (strcmp (name, MIPS_ELF_MSYM_SECTION_NAME (output_bfd))
-	       == 0)
-	s->_raw_size = (sizeof (Elf32_External_Msym)
-			* (elf_hash_table (info)->dynsymcount
-			   + bfd_count_sections (output_bfd)));
-      else if (strncmp (name, ".init", 5) != 0)
-	{
-	  /* It's not one of our sections, so don't allocate space.  */
-	  continue;
-	}
-
-      if (strip)
-	{
-	  _bfd_strip_section_from_output (info, s);
-	  continue;
-	}
-
-      /* Allocate memory for the section contents.  */
-      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
-      if (s->contents == NULL && s->_raw_size != 0)
-	{
-	  bfd_set_error (bfd_error_no_memory);
-	  return false;
-	}
-    }
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-	 values later, in elf_mips_finish_dynamic_sections, but we
-	 must add the entries now so that we get the correct size for
-	 the .dynamic section.  The DT_DEBUG entry is filled in by the
-	 dynamic linker and used by the debugger.  */
-      if (! info->shared)
-	{
-	  /* SGI object has the equivalence of DT_DEBUG in the
-	     DT_MIPS_RLD_MAP entry.  */
-	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
-	    return false;
-	  if (!SGI_COMPAT (output_bfd))
-	    {
-	      if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
-		return false;
-	    }
-	}
-      else
-	{
-	  /* Shared libraries on traditional mips have DT_DEBUG.  */
-	  if (!SGI_COMPAT (output_bfd))
-	    {
-	      if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
-		return false;
-	    }
-	}
-
-      if (reltext && SGI_COMPAT (output_bfd))
-	info->flags |= DF_TEXTREL;
-
-      if ((info->flags & DF_TEXTREL) != 0)
-	{
-	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0))
-	    return false;
-	}
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTGOT, 0))
-	return false;
-
-      if (bfd_get_section_by_name (dynobj,
-				   MIPS_ELF_REL_DYN_SECTION_NAME (dynobj)))
-	{
-	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0))
-	    return false;
-
-	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0))
-	    return false;
-
-	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0))
-	    return false;
-	}
-
-      if (SGI_COMPAT (output_bfd))
-	{
-	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICTNO, 0))
-	    return false;
-	}
-
-      if (SGI_COMPAT (output_bfd))
-	{
-	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLISTNO, 0))
-	    return false;
-	}
-
-      if (bfd_get_section_by_name (dynobj, ".conflict") != NULL)
-	{
-	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICT, 0))
-	    return false;
-
-	  s = bfd_get_section_by_name (dynobj, ".liblist");
-	  BFD_ASSERT (s != NULL);
-
-	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLIST, 0))
-	    return false;
-	}
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_VERSION, 0))
-	return false;
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_FLAGS, 0))
-	return false;
-
-#if 0
-      /* Time stamps in executable files are a bad idea.  */
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_TIME_STAMP, 0))
-	return false;
-#endif
-
-#if 0 /* FIXME  */
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_ICHECKSUM, 0))
-	return false;
-#endif
-
-#if 0 /* FIXME  */
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_IVERSION, 0))
-	return false;
-#endif
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_BASE_ADDRESS, 0))
-	return false;
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LOCAL_GOTNO, 0))
-	return false;
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_SYMTABNO, 0))
-	return false;
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_UNREFEXTNO, 0))
-	return false;
-
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_GOTSYM, 0))
-	return false;
-
-      if (IRIX_COMPAT (dynobj) == ict_irix5
-	  && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0))
-	return false;
-
-      if (IRIX_COMPAT (dynobj) == ict_irix6
-	  && (bfd_get_section_by_name
-	      (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
-	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
-	return false;
-
-      if (bfd_get_section_by_name (dynobj,
-				   MIPS_ELF_MSYM_SECTION_NAME (dynobj))
-	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_MSYM, 0))
-	return false;
-    }
-
-  return true;
-}
-
-/* If NAME is one of the special IRIX6 symbols defined by the linker,
-   adjust it appropriately now.  */
-
-static void
-mips_elf_irix6_finish_dynamic_symbol (abfd, name, sym)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     const char *name;
-     Elf_Internal_Sym *sym;
-{
-  /* The linker script takes care of providing names and values for
-     these, but we must place them into the right sections.  */
-  static const char* const text_section_symbols[] = {
-    "_ftext",
-    "_etext",
-    "__dso_displacement",
-    "__elf_header",
-    "__program_header_table",
-    NULL
-  };
-
-  static const char* const data_section_symbols[] = {
-    "_fdata",
-    "_edata",
-    "_end",
-    "_fbss",
-    NULL
-  };
-
-  const char* const *p;
-  int i;
-
-  for (i = 0; i < 2; ++i)
-    for (p = (i == 0) ? text_section_symbols : data_section_symbols;
-	 *p;
-	 ++p)
-      if (strcmp (*p, name) == 0)
-	{
-	  /* All of these symbols are given type STT_SECTION by the
-	     IRIX6 linker.  */
-	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-
-	  /* The IRIX linker puts these symbols in special sections.  */
-	  if (i == 0)
-	    sym->st_shndx = SHN_MIPS_TEXT;
-	  else
-	    sym->st_shndx = SHN_MIPS_DATA;
-
-	  break;
-	}
-}
-
-/* Finish up dynamic symbol handling.  We set the contents of various
-   dynamic sections here.  */
-
-boolean
-_bfd_mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
-{
-  bfd *dynobj;
-  bfd_vma gval;
-  asection *sgot;
-  asection *smsym;
-  struct mips_got_info *g;
-  const char *name;
-  struct mips_elf_link_hash_entry *mh;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  gval = sym->st_value;
-  mh = (struct mips_elf_link_hash_entry *) h;
-
-  if (h->plt.offset != (bfd_vma) -1)
-    {
-      asection *s;
-      bfd_byte *p;
-      bfd_byte stub[MIPS_FUNCTION_STUB_SIZE];
-
-      /* This symbol has a stub.  Set it up.  */
-
-      BFD_ASSERT (h->dynindx != -1);
-
-      s = bfd_get_section_by_name (dynobj,
-				   MIPS_ELF_STUB_SECTION_NAME (dynobj));
-      BFD_ASSERT (s != NULL);
-
-      /* Fill the stub.  */
-      p = stub;
-      bfd_put_32 (output_bfd, (bfd_vma) STUB_LW (output_bfd), p);
-      p += 4;
-      bfd_put_32 (output_bfd, (bfd_vma) STUB_MOVE (output_bfd), p);
-      p += 4;
-
-      /* FIXME: Can h->dynindex be more than 64K?  */
-      if (h->dynindx & 0xffff0000)
-	return false;
-
-      bfd_put_32 (output_bfd, (bfd_vma) STUB_JALR, p);
-      p += 4;
-      bfd_put_32 (output_bfd, (bfd_vma) STUB_LI16 (output_bfd) + h->dynindx, p);
-
-      BFD_ASSERT (h->plt.offset <= s->_raw_size);
-      memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
-
-      /* Mark the symbol as undefined.  plt.offset != -1 occurs
-	 only for the referenced symbol.  */
-      sym->st_shndx = SHN_UNDEF;
-
-      /* The run-time linker uses the st_value field of the symbol
-	 to reset the global offset table entry for this external
-	 to its stub address when unlinking a shared object.  */
-      gval = s->output_section->vma + s->output_offset + h->plt.offset;
-      sym->st_value = gval;
-    }
-
-  BFD_ASSERT (h->dynindx != -1
-	      || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0);
-
-  sgot = mips_elf_got_section (dynobj);
-  BFD_ASSERT (sgot != NULL);
-  BFD_ASSERT (elf_section_data (sgot) != NULL);
-  g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
-  BFD_ASSERT (g != NULL);
-
-  /* Run through the global symbol table, creating GOT entries for all
-     the symbols that need them.  */
-  if (g->global_gotsym != NULL
-      && h->dynindx >= g->global_gotsym->dynindx)
-    {
-      bfd_vma offset;
-      bfd_vma value;
-
-      if (sym->st_value)
-	value = sym->st_value;
-      else
-	{
-	  /* For an entity defined in a shared object, this will be
-	     NULL.  (For functions in shared objects for
-	     which we have created stubs, ST_VALUE will be non-NULL.
-	     That's because such the functions are now no longer defined
-	     in a shared object.)  */
-
-	  if (info->shared && h->root.type == bfd_link_hash_undefined)
-	    value = 0;
-	  else
-	    value = h->root.u.def.value;
-	}
-      offset = mips_elf_global_got_index (dynobj, h);
-      MIPS_ELF_PUT_WORD (output_bfd, value, sgot->contents + offset);
-    }
-
-  /* Create a .msym entry, if appropriate.  */
-  smsym = bfd_get_section_by_name (dynobj,
-				   MIPS_ELF_MSYM_SECTION_NAME (dynobj));
-  if (smsym)
-    {
-      Elf32_Internal_Msym msym;
-
-      msym.ms_hash_value = bfd_elf_hash (h->root.root.string);
-      /* It is undocumented what the `1' indicates, but IRIX6 uses
-	 this value.  */
-      msym.ms_info = ELF32_MS_INFO (mh->min_dyn_reloc_index, 1);
-      bfd_mips_elf_swap_msym_out
-	(dynobj, &msym,
-	 ((Elf32_External_Msym *) smsym->contents) + h->dynindx);
-    }
-
-  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  name = h->root.root.string;
-  if (strcmp (name, "_DYNAMIC") == 0
-      || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
-    sym->st_shndx = SHN_ABS;
-  else if (strcmp (name, "_DYNAMIC_LINK") == 0
-	   || strcmp (name, "_DYNAMIC_LINKING") == 0)
-    {
-      sym->st_shndx = SHN_ABS;
-      sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-      sym->st_value = 1;
-    }
-  else if (strcmp (name, "_gp_disp") == 0)
-    {
-      sym->st_shndx = SHN_ABS;
-      sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-      sym->st_value = elf_gp (output_bfd);
-    }
-  else if (SGI_COMPAT (output_bfd))
-    {
-      if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
-	  || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
-	{
-	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-	  sym->st_other = STO_PROTECTED;
-	  sym->st_value = 0;
-	  sym->st_shndx = SHN_MIPS_DATA;
-	}
-      else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
-	{
-	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-	  sym->st_other = STO_PROTECTED;
-	  sym->st_value = mips_elf_hash_table (info)->procedure_count;
-	  sym->st_shndx = SHN_ABS;
-	}
-      else if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS)
-	{
-	  if (h->type == STT_FUNC)
-	    sym->st_shndx = SHN_MIPS_TEXT;
-	  else if (h->type == STT_OBJECT)
-	    sym->st_shndx = SHN_MIPS_DATA;
-	}
-    }
-
-  /* Handle the IRIX6-specific symbols.  */
-  if (IRIX_COMPAT (output_bfd) == ict_irix6)
-    mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym);
-
-  if (! info->shared)
-    {
-      if (! mips_elf_hash_table (info)->use_rld_obj_head
-	  && (strcmp (name, "__rld_map") == 0
-	      || strcmp (name, "__RLD_MAP") == 0))
-	{
-	  asection *s = bfd_get_section_by_name (dynobj, ".rld_map");
-	  BFD_ASSERT (s != NULL);
-	  sym->st_value = s->output_section->vma + s->output_offset;
-	  bfd_put_32 (output_bfd, (bfd_vma) 0, s->contents);
-	  if (mips_elf_hash_table (info)->rld_value == 0)
-	    mips_elf_hash_table (info)->rld_value = sym->st_value;
-	}
-      else if (mips_elf_hash_table (info)->use_rld_obj_head
-	       && strcmp (name, "__rld_obj_head") == 0)
-	{
-	  /* IRIX6 does not use a .rld_map section.  */
-	  if (IRIX_COMPAT (output_bfd) == ict_irix5
-              || IRIX_COMPAT (output_bfd) == ict_none)
-	    BFD_ASSERT (bfd_get_section_by_name (dynobj, ".rld_map")
-			!= NULL);
-	  mips_elf_hash_table (info)->rld_value = sym->st_value;
-	}
-    }
-
-  /* If this is a mips16 symbol, force the value to be even.  */
-  if (sym->st_other == STO_MIPS16
-      && (sym->st_value & 1) != 0)
-    --sym->st_value;
-
-  return true;
-}
-
-/* Finish up the dynamic sections.  */
-
-boolean
-_bfd_mips_elf_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-{
-  bfd *dynobj;
-  asection *sdyn;
-  asection *sgot;
-  struct mips_got_info *g;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
-  sgot = mips_elf_got_section (dynobj);
-  if (sgot == NULL)
-    g = NULL;
-  else
-    {
-      BFD_ASSERT (elf_section_data (sgot) != NULL);
-      g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
-      BFD_ASSERT (g != NULL);
-    }
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      bfd_byte *b;
-
-      BFD_ASSERT (sdyn != NULL);
-      BFD_ASSERT (g != NULL);
-
-      for (b = sdyn->contents;
-	   b < sdyn->contents + sdyn->_raw_size;
-	   b += MIPS_ELF_DYN_SIZE (dynobj))
-	{
-	  Elf_Internal_Dyn dyn;
-	  const char *name;
-	  size_t elemsize;
-	  asection *s;
-	  boolean swap_out_p;
-
-	  /* Read in the current dynamic entry.  */
-	  (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
-
-	  /* Assume that we're going to modify it and write it out.  */
-	  swap_out_p = true;
-
-	  switch (dyn.d_tag)
-	    {
-	    case DT_RELENT:
-	      s = (bfd_get_section_by_name
-		   (dynobj,
-		    MIPS_ELF_REL_DYN_SECTION_NAME (dynobj)));
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_val = MIPS_ELF_REL_SIZE (dynobj);
-	      break;
-
-	    case DT_STRSZ:
-	      /* Rewrite DT_STRSZ.  */
-	      dyn.d_un.d_val =
-		_bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
-	      break;
-
-	    case DT_PLTGOT:
-	      name = ".got";
-	      goto get_vma;
-	    case DT_MIPS_CONFLICT:
-	      name = ".conflict";
-	      goto get_vma;
-	    case DT_MIPS_LIBLIST:
-	      name = ".liblist";
-	    get_vma:
-	      s = bfd_get_section_by_name (output_bfd, name);
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_ptr = s->vma;
-	      break;
-
-	    case DT_MIPS_RLD_VERSION:
-	      dyn.d_un.d_val = 1; /* XXX */
-	      break;
-
-	    case DT_MIPS_FLAGS:
-	      dyn.d_un.d_val = RHF_NOTPOT; /* XXX */
-	      break;
-
-	    case DT_MIPS_CONFLICTNO:
-	      name = ".conflict";
-	      elemsize = sizeof (Elf32_Conflict);
-	      goto set_elemno;
-
-	    case DT_MIPS_LIBLISTNO:
-	      name = ".liblist";
-	      elemsize = sizeof (Elf32_Lib);
-	    set_elemno:
-	      s = bfd_get_section_by_name (output_bfd, name);
-	      if (s != NULL)
-		{
-		  if (s->_cooked_size != 0)
-		    dyn.d_un.d_val = s->_cooked_size / elemsize;
-		  else
-		    dyn.d_un.d_val = s->_raw_size / elemsize;
-		}
-	      else
-		dyn.d_un.d_val = 0;
-	      break;
-
-	    case DT_MIPS_TIME_STAMP:
-	      time ((time_t *) &dyn.d_un.d_val);
-	      break;
-
-	    case DT_MIPS_ICHECKSUM:
-	      /* XXX FIXME: */
-	      swap_out_p = false;
-	      break;
-
-	    case DT_MIPS_IVERSION:
-	      /* XXX FIXME: */
-	      swap_out_p = false;
-	      break;
-
-	    case DT_MIPS_BASE_ADDRESS:
-	      s = output_bfd->sections;
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
-	      break;
-
-	    case DT_MIPS_LOCAL_GOTNO:
-	      dyn.d_un.d_val = g->local_gotno;
-	      break;
-
-	    case DT_MIPS_UNREFEXTNO:
-	      /* The index into the dynamic symbol table which is the
-		 entry of the first external symbol that is not
-		 referenced within the same object.  */
-	      dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
-	      break;
-
-	    case DT_MIPS_GOTSYM:
-	      if (g->global_gotsym)
-		{
-		  dyn.d_un.d_val = g->global_gotsym->dynindx;
-		  break;
-		}
-	      /* In case if we don't have global got symbols we default
-		 to setting DT_MIPS_GOTSYM to the same value as
-		 DT_MIPS_SYMTABNO, so we just fall through.  */
-
-	    case DT_MIPS_SYMTABNO:
-	      name = ".dynsym";
-	      elemsize = MIPS_ELF_SYM_SIZE (output_bfd);
-	      s = bfd_get_section_by_name (output_bfd, name);
-	      BFD_ASSERT (s != NULL);
-
-	      if (s->_cooked_size != 0)
-		dyn.d_un.d_val = s->_cooked_size / elemsize;
-	      else
-		dyn.d_un.d_val = s->_raw_size / elemsize;
-	      break;
-
-	    case DT_MIPS_HIPAGENO:
-	      dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO;
-	      break;
-
-	    case DT_MIPS_RLD_MAP:
-	      dyn.d_un.d_ptr = mips_elf_hash_table (info)->rld_value;
-	      break;
-
-	    case DT_MIPS_OPTIONS:
-	      s = (bfd_get_section_by_name
-		   (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (output_bfd)));
-	      dyn.d_un.d_ptr = s->vma;
-	      break;
-
-	    case DT_MIPS_MSYM:
-	      s = (bfd_get_section_by_name
-		   (output_bfd, MIPS_ELF_MSYM_SECTION_NAME (output_bfd)));
-	      dyn.d_un.d_ptr = s->vma;
-	      break;
-
-	    default:
-	      swap_out_p = false;
-	      break;
-	    }
-
-	  if (swap_out_p)
-	    (*get_elf_backend_data (dynobj)->s->swap_dyn_out)
-	      (dynobj, &dyn, b);
-	}
-    }
-
-  /* The first entry of the global offset table will be filled at
-     runtime. The second entry will be used by some runtime loaders.
-     This isn't the case of Irix rld.  */
-  if (sgot != NULL && sgot->_raw_size > 0)
-    {
-      MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0, sgot->contents);
-      MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0x80000000,
-			 sgot->contents + MIPS_ELF_GOT_SIZE (output_bfd));
-    }
-
-  if (sgot != NULL)
-    elf_section_data (sgot->output_section)->this_hdr.sh_entsize
-      = MIPS_ELF_GOT_SIZE (output_bfd);
-
-  {
-    asection *smsym;
-    asection *s;
-    Elf32_compact_rel cpt;
-
-    /* ??? The section symbols for the output sections were set up in
-       _bfd_elf_final_link.  SGI sets the STT_NOTYPE attribute for these
-       symbols.  Should we do so?  */
-
-    smsym = bfd_get_section_by_name (dynobj,
-				     MIPS_ELF_MSYM_SECTION_NAME (dynobj));
-    if (smsym != NULL)
-      {
-	Elf32_Internal_Msym msym;
-
-	msym.ms_hash_value = 0;
-	msym.ms_info = ELF32_MS_INFO (0, 1);
-
-	for (s = output_bfd->sections; s != NULL; s = s->next)
-	  {
-	    long dynindx = elf_section_data (s)->dynindx;
-
-	    bfd_mips_elf_swap_msym_out
-	      (output_bfd, &msym,
-	       (((Elf32_External_Msym *) smsym->contents)
-		+ dynindx));
-	  }
-      }
-
-    if (SGI_COMPAT (output_bfd))
-      {
-	/* Write .compact_rel section out.  */
-	s = bfd_get_section_by_name (dynobj, ".compact_rel");
-	if (s != NULL)
-	  {
-	    cpt.id1 = 1;
-	    cpt.num = s->reloc_count;
-	    cpt.id2 = 2;
-	    cpt.offset = (s->output_section->filepos
-			  + sizeof (Elf32_External_compact_rel));
-	    cpt.reserved0 = 0;
-	    cpt.reserved1 = 0;
-	    bfd_elf32_swap_compact_rel_out (output_bfd, &cpt,
-					    ((Elf32_External_compact_rel *)
-					     s->contents));
-
-	    /* Clean up a dummy stub function entry in .text.  */
-	    s = bfd_get_section_by_name (dynobj,
-					 MIPS_ELF_STUB_SECTION_NAME (dynobj));
-	    if (s != NULL)
-	      {
-		file_ptr dummy_offset;
-
-		BFD_ASSERT (s->_raw_size >= MIPS_FUNCTION_STUB_SIZE);
-		dummy_offset = s->_raw_size - MIPS_FUNCTION_STUB_SIZE;
-		memset (s->contents + dummy_offset, 0,
-			MIPS_FUNCTION_STUB_SIZE);
-	      }
-	  }
-      }
-
-    /* We need to sort the entries of the dynamic relocation section.  */
-
-    if (!ABI_64_P (output_bfd))
-      {
-	asection *reldyn;
-
-	reldyn = bfd_get_section_by_name (dynobj,
-					  MIPS_ELF_REL_DYN_SECTION_NAME (dynobj));
-	if (reldyn != NULL && reldyn->reloc_count > 2)
-	  {
-	    reldyn_sorting_bfd = output_bfd;
-	    qsort ((Elf32_External_Rel *) reldyn->contents + 1,
-		   (size_t) reldyn->reloc_count - 1,
-		   sizeof (Elf32_External_Rel), sort_dynamic_relocs);
-	  }
-      }
-
-    /* Clean up a first relocation in .rel.dyn.  */
-    s = bfd_get_section_by_name (dynobj,
-				 MIPS_ELF_REL_DYN_SECTION_NAME (dynobj));
-    if (s != NULL && s->_raw_size > 0)
-      memset (s->contents, 0, MIPS_ELF_REL_SIZE (dynobj));
-  }
-
-  return true;
-}
-
-/* Support for core dump NOTE sections */
-static boolean
-_bfd_elf32_mips_grok_prstatus (abfd, note)
+elf32_mips_grok_prstatus (abfd, note)
      bfd *abfd;
      Elf_Internal_Note *note;
 {
@@ -9734,7 +1782,7 @@
 }
 
 static boolean
-_bfd_elf32_mips_grok_psinfo (abfd, note)
+elf32_mips_grok_psinfo (abfd, note)
      bfd *abfd;
      Elf_Internal_Note *note;
 {
@@ -9768,7 +1816,7 @@
 #define PDR_SIZE 32
 
 static boolean
-_bfd_elf32_mips_discard_info (abfd, cookie, info)
+elf32_mips_discard_info (abfd, cookie, info)
      bfd *abfd;
      struct elf_reloc_cookie *cookie;
      struct bfd_link_info *info;
@@ -9832,7 +1880,7 @@
 }
 
 static boolean
-_bfd_elf32_mips_ignore_discarded_relocs (sec)
+elf32_mips_ignore_discarded_relocs (sec)
      asection *sec;
 {
   if (strcmp (sec->name, ".pdr") == 0)
@@ -9841,7 +1889,7 @@
 }
 
 static boolean
-_bfd_elf32_mips_write_section (output_bfd, sec, contents)
+elf32_mips_write_section (output_bfd, sec, contents)
      bfd *output_bfd;
      asection *sec;
      bfd_byte *contents;
@@ -9872,6 +1920,19 @@
 			    sec->_cooked_size);
   return true;
 }
+
+/* Depending on the target vector we generate some version of Irix
+   executables or "normal" MIPS ELF ABI executables.  */
+static irix_compat_t
+elf32_mips_irix_compat (abfd)
+     bfd *abfd;
+{
+  if ((abfd->xvec == &bfd_elf32_tradbigmips_vec)
+      || (abfd->xvec == &bfd_elf32_tradlittlemips_vec))
+    return ict_none;
+  else
+    return ict_irix5;
+}
 
 /* Given a data section and an in-memory embedded reloc section, store
    relocation information into the embedded reloc section which can be
@@ -9966,10 +2027,10 @@
       asection *targetsec;
 
       /* We are going to write a four byte longword into the runtime
-       reloc section.  The longword will be the address in the data
-       section which must be relocated.  It is followed by the name
-       of the target section NUL-padded or truncated to 8
-       characters.  */
+	 reloc section.  The longword will be the address in the data
+	 section which must be relocated.  It is followed by the name
+	 of the target section NUL-padded or truncated to 8
+	 characters.  */
 
       /* We can only relocate absolute longword relocs at run time.  */
       if ((ELF32_R_TYPE (irel->r_info) != (int) R_MIPS_32) &&
@@ -10003,13 +2064,12 @@
 	  h = elf_sym_hashes (abfd)[indx];
 	  targetsec = NULL;
 	  /*
-	   * For some reason, in certain programs, the symbol will
-	   * not be in the hash table.  It seems to happen when you
-	   * declare a static table of pointers to const external structures.
-	   * In this case, the relocs are relative to data, not
-	   * text, so just treating it like an undefined link
-	   * should be sufficient.
-	   */
+	     For some reason, in certain programs, the symbol will
+	     not be in the hash table.  It seems to happen when you
+	     declare a static table of pointers to const external structures.
+	     In this case, the relocs are relative to data, not
+	     text, so just treating it like an undefined link
+	     should be sufficient.  */
 	  BFD_ASSERT(h != NULL);
 	  if (h->root.type == bfd_link_hash_defined
 	      || h->root.type == bfd_link_hash_defweak)
@@ -10018,9 +2078,8 @@
 
 
       /*
-       * Set the low bit of the relocation offset if it's a MIPS64 reloc.
-       * Relocations will always be on (at least) 32-bit boundaries.
-       */
+         Set the low bit of the relocation offset if it's a MIPS64 reloc.
+         Relocations will always be on (at least) 32-bit boundaries.  */
 
       bfd_put_32 (abfd, ((irel->r_offset + datasec->output_offset) +
 		  ((ELF32_R_TYPE (irel->r_info) == (int) R_MIPS_64) ? 1 : 0)),
@@ -10048,193 +2107,6 @@
   return false;
 }
 
-/* This is almost identical to bfd_generic_get_... except that some
-   MIPS relocations need to be handled specially.  Sigh.  */
-
-static bfd_byte *
-elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data,
-					   relocateable, symbols)
-     bfd *abfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     bfd_byte *data;
-     boolean relocateable;
-     asymbol **symbols;
-{
-  /* Get enough memory to hold the stuff */
-  bfd *input_bfd = link_order->u.indirect.section->owner;
-  asection *input_section = link_order->u.indirect.section;
-
-  long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
-  arelent **reloc_vector = NULL;
-  long reloc_count;
-
-  if (reloc_size < 0)
-    goto error_return;
-
-  reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
-  if (reloc_vector == NULL && reloc_size != 0)
-    goto error_return;
-
-  /* read in the section */
-  if (!bfd_get_section_contents (input_bfd,
-				 input_section,
-				 (PTR) data,
-				 (file_ptr) 0,
-				 input_section->_raw_size))
-    goto error_return;
-
-  /* We're not relaxing the section, so just copy the size info */
-  input_section->_cooked_size = input_section->_raw_size;
-  input_section->reloc_done = true;
-
-  reloc_count = bfd_canonicalize_reloc (input_bfd,
-					input_section,
-					reloc_vector,
-					symbols);
-  if (reloc_count < 0)
-    goto error_return;
-
-  if (reloc_count > 0)
-    {
-      arelent **parent;
-      /* for mips */
-      int gp_found;
-      bfd_vma gp = 0x12345678;	/* initialize just to shut gcc up */
-
-      {
-	struct bfd_hash_entry *h;
-	struct bfd_link_hash_entry *lh;
-	/* Skip all this stuff if we aren't mixing formats.  */
-	if (abfd && input_bfd
-	    && abfd->xvec == input_bfd->xvec)
-	  lh = 0;
-	else
-	  {
-	    h = bfd_hash_lookup (&link_info->hash->table, "_gp", false, false);
-	    lh = (struct bfd_link_hash_entry *) h;
-	  }
-      lookup:
-	if (lh)
-	  {
-	    switch (lh->type)
-	      {
-	      case bfd_link_hash_undefined:
-	      case bfd_link_hash_undefweak:
-	      case bfd_link_hash_common:
-		gp_found = 0;
-		break;
-	      case bfd_link_hash_defined:
-	      case bfd_link_hash_defweak:
-		gp_found = 1;
-		gp = lh->u.def.value;
-		break;
-	      case bfd_link_hash_indirect:
-	      case bfd_link_hash_warning:
-		lh = lh->u.i.link;
-		/* @@FIXME  ignoring warning for now */
-		goto lookup;
-	      case bfd_link_hash_new:
-	      default:
-		abort ();
-	      }
-	  }
-	else
-	  gp_found = 0;
-      }
-      /* end mips */
-      for (parent = reloc_vector; *parent != (arelent *) NULL;
-	   parent++)
-	{
-	  char *error_message = (char *) NULL;
-	  bfd_reloc_status_type r;
-
-	  /* Specific to MIPS: Deal with relocation types that require
-	     knowing the gp of the output bfd.  */
-	  asymbol *sym = *(*parent)->sym_ptr_ptr;
-	  if (bfd_is_abs_section (sym->section) && abfd)
-	    {
-	      /* The special_function wouldn't get called anyways.  */
-	    }
-	  else if (!gp_found)
-	    {
-	      /* The gp isn't there; let the special function code
-		 fall over on its own.  */
-	    }
-	  else if ((*parent)->howto->special_function
-		   == _bfd_mips_elf_gprel16_reloc)
-	    {
-	      /* bypass special_function call */
-	      r = gprel16_with_gp (input_bfd, sym, *parent, input_section,
-				   relocateable, (PTR) data, gp);
-	      goto skip_bfd_perform_relocation;
-	    }
-	  /* end mips specific stuff */
-
-	  r = bfd_perform_relocation (input_bfd,
-				      *parent,
-				      (PTR) data,
-				      input_section,
-				      relocateable ? abfd : (bfd *) NULL,
-				      &error_message);
-	skip_bfd_perform_relocation:
-
-	  if (relocateable)
-	    {
-	      asection *os = input_section->output_section;
-
-	      /* A partial link, so keep the relocs */
-	      os->orelocation[os->reloc_count] = *parent;
-	      os->reloc_count++;
-	    }
-
-	  if (r != bfd_reloc_ok)
-	    {
-	      switch (r)
-		{
-		case bfd_reloc_undefined:
-		  if (!((*link_info->callbacks->undefined_symbol)
-			(link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
-			 input_bfd, input_section, (*parent)->address,
-			 true)))
-		    goto error_return;
-		  break;
-		case bfd_reloc_dangerous:
-		  BFD_ASSERT (error_message != (char *) NULL);
-		  if (!((*link_info->callbacks->reloc_dangerous)
-			(link_info, error_message, input_bfd, input_section,
-			 (*parent)->address)))
-		    goto error_return;
-		  break;
-		case bfd_reloc_overflow:
-		  if (!((*link_info->callbacks->reloc_overflow)
-			(link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
-			 (*parent)->howto->name, (*parent)->addend,
-			 input_bfd, input_section, (*parent)->address)))
-		    goto error_return;
-		  break;
-		case bfd_reloc_outofrange:
-		default:
-		  abort ();
-		  break;
-		}
-
-	    }
-	}
-    }
-  if (reloc_vector != NULL)
-    free (reloc_vector);
-  return data;
-
-error_return:
-  if (reloc_vector != NULL)
-    free (reloc_vector);
-  return NULL;
-}
-
-#define bfd_elf32_bfd_get_relocated_section_contents \
-  elf32_mips_get_relocated_section_contents
-
 /* ECOFF swapping routines.  These are used when dealing with the
    .mdebug section, which is in the ECOFF debugging format.  */
 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
@@ -10290,7 +2162,7 @@
 #define elf_info_to_howto		mips_info_to_howto_rela
 #define elf_info_to_howto_rel		mips_info_to_howto_rel
 #define elf_backend_sym_is_global	mips_elf_sym_is_global
-#define elf_backend_object_p		_bfd_mips_elf_object_p
+#define elf_backend_object_p		mips_elf32_object_p
 #define elf_backend_symbol_processing	_bfd_mips_elf_symbol_processing
 #define elf_backend_section_processing	_bfd_mips_elf_section_processing
 #define elf_backend_section_from_shdr	_bfd_mips_elf_section_from_shdr
@@ -10324,8 +2196,8 @@
 #define elf_backend_copy_indirect_symbol \
 					_bfd_mips_elf_copy_indirect_symbol
 #define elf_backend_hide_symbol		_bfd_mips_elf_hide_symbol
-#define elf_backend_grok_prstatus	_bfd_elf32_mips_grok_prstatus
-#define elf_backend_grok_psinfo		_bfd_elf32_mips_grok_psinfo
+#define elf_backend_grok_prstatus	elf32_mips_grok_prstatus
+#define elf_backend_grok_psinfo		elf32_mips_grok_psinfo
 #define elf_backend_ecoff_debug_swap	&mips_elf32_ecoff_debug_swap
 
 #define elf_backend_got_header_size	(4 * MIPS_RESERVED_GOTNO)
@@ -10335,15 +2207,18 @@
 #define elf_backend_default_use_rela_p	0
 #define elf_backend_sign_extend_vma	true
 
-#define elf_backend_discard_info	_bfd_elf32_mips_discard_info
+#define elf_backend_discard_info	elf32_mips_discard_info
 #define elf_backend_ignore_discarded_relocs \
-					_bfd_elf32_mips_ignore_discarded_relocs
-#define elf_backend_write_section	_bfd_elf32_mips_write_section
-
+					elf32_mips_ignore_discarded_relocs
+#define elf_backend_write_section	elf32_mips_write_section
+#define elf_backend_mips_irix_compat	elf32_mips_irix_compat
+#define elf_backend_mips_rtype_to_howto	mips_elf32_rtype_to_howto
 #define bfd_elf32_bfd_is_local_label_name \
 					mips_elf_is_local_label_name
 #define bfd_elf32_find_nearest_line	_bfd_mips_elf_find_nearest_line
 #define bfd_elf32_set_section_contents	_bfd_mips_elf_set_section_contents
+#define bfd_elf32_bfd_get_relocated_section_contents \
+				_bfd_elf_mips_get_relocated_section_contents
 #define bfd_elf32_bfd_link_hash_table_create \
 					_bfd_mips_elf_link_hash_table_create
 #define bfd_elf32_bfd_final_link	_bfd_mips_elf_final_link
@@ -10374,5 +2249,5 @@
 #define TARGET_BIG_SYM                  bfd_elf32_tradbigmips_vec
 #define TARGET_BIG_NAME                 "elf32-tradbigmips"
 
-/* Include the target file again for this target */
+/* Include the target file again for this target.  */
 #include "elf32-target.h"
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index be6cfab..f68d914 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -679,20 +679,20 @@
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
-  /* 32-bit section relative relocation.  */
+  /* 16-bit section relative relocation.  */
   HOWTO (R_PPC_SECTOFF,		/* type */
 	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 true,			/* pc_relative */
+	 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_PPC_SECTOFF",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 true),			/* pcrel_offset */
+	 0xffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
 
   /* 16-bit lower half section relative relocation.  */
   HOWTO (R_PPC_SECTOFF_LO,	  /* type */
@@ -1295,7 +1295,7 @@
     case BFD_RELOC_HI16_PLTOFF:		ppc_reloc = R_PPC_PLT16_HI;		break;
     case BFD_RELOC_HI16_S_PLTOFF:	ppc_reloc = R_PPC_PLT16_HA;		break;
     case BFD_RELOC_GPREL16:		ppc_reloc = R_PPC_SDAREL16;		break;
-    case BFD_RELOC_32_BASEREL:		ppc_reloc = R_PPC_SECTOFF;		break;
+    case BFD_RELOC_16_BASEREL:		ppc_reloc = R_PPC_SECTOFF;		break;
     case BFD_RELOC_LO16_BASEREL:	ppc_reloc = R_PPC_SECTOFF_LO;		break;
     case BFD_RELOC_HI16_BASEREL:	ppc_reloc = R_PPC_SECTOFF_HI;		break;
     case BFD_RELOC_HI16_S_BASEREL:	ppc_reloc = R_PPC_SECTOFF_HA;		break;
@@ -2542,7 +2542,8 @@
 {
   if (sym->st_shndx == SHN_COMMON
       && !info->relocateable
-      && sym->st_size <= elf_gp_size (abfd))
+      && sym->st_size <= elf_gp_size (abfd)
+      && info->hash->creator->flavour == bfd_target_elf_flavour)
     {
       /* Common symbols less than or equal to -G nn bytes are automatically
 	 put into .sdata.  */
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 1f197b5..8c6f546 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1,5 +1,5 @@
 /* IBM S/390-specific support for 32-bit ELF
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Carl B. Pedersen and Martin Schwidefsky.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -478,13 +478,13 @@
   struct elf_s390_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
 
-  ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1214,10 +1214,12 @@
   struct elf_s390_link_hash_entry *eh;
   struct elf_s390_dyn_relocs *p;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = elf_s390_hash_table (info);
 
@@ -1384,6 +1386,9 @@
   struct elf_s390_link_hash_entry *eh;
   struct elf_s390_dyn_relocs *p;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   eh = (struct elf_s390_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index d8d4a6a..ef737b5 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -3529,14 +3529,14 @@
   struct elf_sh_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_sh_link_hash_table);
 
-  ret = (struct elf_sh_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf_sh_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct elf_sh_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       sh_elf_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -3899,8 +3899,8 @@
      will not fill them in in the relocate_section routine.  */
   if (info->shared && info->symbolic)
     sh_elf_link_hash_traverse (sh_elf_hash_table (info),
-				 sh_elf_discard_copies,
-				 (PTR) NULL);
+			       sh_elf_discard_copies,
+			       (PTR) NULL);
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
@@ -4038,6 +4038,9 @@
 {
   struct elf_sh_pcrel_relocs_copied *s;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf_sh_link_hash_entry *) h->root.root.u.i.link;
+
   /* 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;
diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c
index 5c85d36..5e7ccdd 100644
--- a/bfd/elf32-sh64.c
+++ b/bfd/elf32-sh64.c
@@ -389,7 +389,8 @@
      bfd_vma *valp;
 {
   /* We want to do this for relocatable as well as final linking.  */
-  if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL)
+  if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL
+      && info->hash->creator->flavour == bfd_target_elf_flavour)
     {
       struct elf_link_hash_entry *h;
 
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index e944f00..a11db81 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -1084,6 +1084,17 @@
   return true;
 }
 
+/* This is the condition under which finish_dynamic_symbol will be called
+   from elflink.h.  If elflink.h doesn't call our finish_dynamic_symbol
+   routine, we'll need to do something about initializing any .plt and .got
+   entries in relocate_section.  */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H)			\
+  ((DYN)								\
+   && ((INFO)->shared							\
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)	\
+   && ((H)->dynindx != -1						\
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
 /* Relocate a SPARC ELF section.  */
 
 static boolean
@@ -1133,9 +1144,10 @@
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *sym;
       asection *sec;
-      bfd_vma relocation;
+      bfd_vma relocation, off;
       bfd_reloc_status_type r;
       boolean is_plt = false;
+      boolean unresolved_reloc;
 
       r_type = ELF32_R_TYPE (rel->r_info);
 
@@ -1175,6 +1187,7 @@
       h = NULL;
       sym = NULL;
       sec = NULL;
+      unresolved_reloc = false;
       if (r_symndx < symtab_hdr->sh_info)
 	{
 	  sym = local_syms + r_symndx;
@@ -1187,71 +1200,30 @@
 	  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;
+
+	  relocation = 0;
 	  if (h->root.type == bfd_link_hash_defined
 	      || h->root.type == bfd_link_hash_defweak)
 	    {
 	      sec = h->root.u.def.section;
-	      if (((r_type == R_SPARC_WPLT30
-		    || r_type == R_SPARC_PLT32)
-		   && h->plt.offset != (bfd_vma) -1)
-		  || ((r_type == R_SPARC_GOT10
-		       || r_type == R_SPARC_GOT13
-		       || r_type == R_SPARC_GOT22)
-		      && elf_hash_table (info)->dynamic_sections_created
-		      && (! info->shared
-			  || (! info->symbolic && h->dynindx != -1)
-			  || (h->elf_link_hash_flags
-			      & ELF_LINK_HASH_DEF_REGULAR) == 0))
-		  || (info->shared
-		      && ((! info->symbolic && h->dynindx != -1)
-			  || (h->elf_link_hash_flags
-			      & ELF_LINK_HASH_DEF_REGULAR) == 0)
-		      && (r_type == R_SPARC_8
-			  || r_type == R_SPARC_16
-			  || r_type == R_SPARC_32
-			  || r_type == R_SPARC_DISP8
-			  || r_type == R_SPARC_DISP16
-			  || r_type == R_SPARC_DISP32
-			  || r_type == R_SPARC_WDISP30
-			  || r_type == R_SPARC_WDISP22
-			  || r_type == R_SPARC_WDISP19
-			  || r_type == R_SPARC_WDISP16
-			  || r_type == R_SPARC_HI22
-			  || r_type == R_SPARC_22
-			  || r_type == R_SPARC_13
-			  || r_type == R_SPARC_LO10
-			  || r_type == R_SPARC_UA16
-			  || r_type == R_SPARC_UA32
-			  || ((r_type == R_SPARC_PC10
-			       || r_type == R_SPARC_PC22)
-			      && strcmp (h->root.root.string,
-					 "_GLOBAL_OFFSET_TABLE_") != 0))
-		      && ((input_section->flags & SEC_ALLOC) != 0
-			  /* DWARF will emit R_SPARC_32 relocations in its
-			     sections against symbols defined externally
-			     in shared libraries.  We can't do anything
-			     with them here.  */
-			  || ((input_section->flags & SEC_DEBUGGING) != 0
-			      && (h->elf_link_hash_flags
-				  & ELF_LINK_HASH_DEF_DYNAMIC) != 0))))
-		{
-		  /* 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;
-		}
+	      if (sec->output_section == NULL)
+		 /* Set a flag that will be cleared later if we find a
+		   relocation value for this symbol.  output_section
+		   is typically NULL for symbols satisfied by a shared
+		   library.  */
+		unresolved_reloc = true;
 	      else
 		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->shared
 		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
-	    relocation = 0;
+	    ;
 	  else
 	    {
 	      if (! ((*info->callbacks->undefined_symbol)
@@ -1260,7 +1232,6 @@
 		      (!info->shared || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return false;
-	      relocation = 0;
 	    }
 	}
 
@@ -1279,14 +1250,17 @@
 
 	  if (h != NULL)
 	    {
-	      bfd_vma off;
+	      boolean dyn;
 
 	      off = h->got.offset;
 	      BFD_ASSERT (off != (bfd_vma) -1);
+	      dyn = elf_hash_table (info)->dynamic_sections_created;
 
-	      if (! elf_hash_table (info)->dynamic_sections_created
+	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
 		  || (info->shared
-		      && (info->symbolic || h->dynindx == -1)
+		      && (info->symbolic
+			  || h->dynindx == -1
+			  || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
 		      && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
 		{
 		  /* This is actually a static link, or it is a
@@ -1310,13 +1284,11 @@
 		      h->got.offset |= 1;
 		    }
 		}
-
-	      relocation = sgot->output_offset + off - got_base;
+	      else
+		unresolved_reloc = false;
 	    }
 	  else
 	    {
-	      bfd_vma off;
-
 	      BFD_ASSERT (local_got_offsets != NULL
 			  && local_got_offsets[r_symndx] != (bfd_vma) -1);
 
@@ -1355,10 +1327,8 @@
 
 		  local_got_offsets[r_symndx] |= 1;
 		}
-
-	      relocation = sgot->output_offset + off - got_base;
 	    }
-
+	  relocation = sgot->output_offset + off - got_base;
 	  break;
 
 	case R_SPARC_PLT32:
@@ -1396,6 +1366,7 @@
 	  relocation = (splt->output_section->vma
 			+ splt->output_offset
 			+ h->plt.offset);
+	  unresolved_reloc = false;
 	  if (r_type == R_SPARC_PLT32)
 	    {
 	      r_type = R_SPARC_32;
@@ -1496,6 +1467,17 @@
 		  if (!(outrel.r_offset & 3))
 		    r_type = R_SPARC_32;
 		  break;
+	  	case R_SPARC_DISP8:
+		case R_SPARC_DISP16:
+	  	case R_SPARC_DISP32:
+		  /* If the symbol is not dynamic, we should not keep
+		     a dynamic relocation.  But an .rela.* slot has been
+		     allocated for it, output R_SPARC_NONE.
+		     FIXME: Add code tracking needed dynamic relocs as
+		     e.g. i386 has.  */
+		  if (h->dynindx == -1)
+		    skip = true, relocate = true;
+		  break;
 		}
 
 	      if (skip)
@@ -1582,6 +1564,18 @@
 	  break;
 	}
 
+      /* ??? Copied from elf32-i386.c, debugging section check and all.  */
+      if (unresolved_reloc
+	  && !(info->shared
+	       && (input_section->flags & SEC_DEBUGGING) != 0
+	       && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+	(*_bfd_error_handler)
+	  (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
+	   bfd_archive_filename (input_bfd),
+	   bfd_get_section_name (input_bfd, input_section),
+	   (long) rel->r_offset,
+	   h->root.root.string);
+
       r = bfd_reloc_continue;
       if (r_type == R_SPARC_WDISP16)
 	{
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index bdb0279..484acdd 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -500,6 +500,9 @@
 {
   struct relax_plt_data *data = (struct relax_plt_data *) xdata;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->plt.offset != (bfd_vma) -1)
     {
       bfd_vma address;
@@ -533,6 +536,9 @@
 {
   bfd_vma *entry = (bfd_vma *) xdata;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->plt.offset != (bfd_vma) -1)
     {
       h->plt.offset = *entry;
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 2c380d6..94b4ebe 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -324,14 +324,14 @@
   struct alpha_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct alpha_elf_link_hash_table);
 
-  ret = (struct alpha_elf_link_hash_table *) bfd_zalloc (abfd, amt);
+  ret = (struct alpha_elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct alpha_elf_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       elf64_alpha_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -2120,18 +2120,21 @@
   boolean strip;
   asection *sec, *output_section;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
+
   if (h->root.indx == -2)
     strip = false;
   else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-           || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
-          && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
-          && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
+	    || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
+	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
     strip = true;
   else if (einfo->info->strip == strip_all
-          || (einfo->info->strip == strip_some
-              && bfd_hash_lookup (einfo->info->keep_hash,
-                                  h->root.root.root.string,
-                                  false, false) == NULL))
+	   || (einfo->info->strip == strip_some
+	       && bfd_hash_lookup (einfo->info->keep_hash,
+				   h->root.root.root.string,
+				   false, false) == NULL))
     strip = true;
   else
     strip = false;
@@ -2150,44 +2153,44 @@
       h->esym.asym.st = stGlobal;
 
       if (h->root.root.type != bfd_link_hash_defined
-         && h->root.root.type != bfd_link_hash_defweak)
-       h->esym.asym.sc = scAbs;
+	  && h->root.root.type != bfd_link_hash_defweak)
+	h->esym.asym.sc = scAbs;
       else
-       {
-         const char *name;
+	{
+	  const char *name;
 
-         sec = h->root.root.u.def.section;
-         output_section = sec->output_section;
+	  sec = h->root.root.u.def.section;
+	  output_section = sec->output_section;
 
-         /* When making a shared library and symbol h is the one from
-            the another shared library, OUTPUT_SECTION may be null.  */
-         if (output_section == NULL)
-           h->esym.asym.sc = scUndefined;
-         else
-           {
-             name = bfd_section_name (output_section->owner, output_section);
+	  /* When making a shared library and symbol h is the one from
+	     the another shared library, OUTPUT_SECTION may be null.  */
+	  if (output_section == NULL)
+	    h->esym.asym.sc = scUndefined;
+	  else
+	    {
+	      name = bfd_section_name (output_section->owner, output_section);
 
-             if (strcmp (name, ".text") == 0)
-               h->esym.asym.sc = scText;
-             else if (strcmp (name, ".data") == 0)
-               h->esym.asym.sc = scData;
-             else if (strcmp (name, ".sdata") == 0)
-               h->esym.asym.sc = scSData;
-             else if (strcmp (name, ".rodata") == 0
-                      || strcmp (name, ".rdata") == 0)
-               h->esym.asym.sc = scRData;
-             else if (strcmp (name, ".bss") == 0)
-               h->esym.asym.sc = scBss;
-             else if (strcmp (name, ".sbss") == 0)
-               h->esym.asym.sc = scSBss;
-             else if (strcmp (name, ".init") == 0)
-               h->esym.asym.sc = scInit;
-             else if (strcmp (name, ".fini") == 0)
-               h->esym.asym.sc = scFini;
-             else
-               h->esym.asym.sc = scAbs;
-           }
-       }
+	      if (strcmp (name, ".text") == 0)
+		h->esym.asym.sc = scText;
+	      else if (strcmp (name, ".data") == 0)
+		h->esym.asym.sc = scData;
+	      else if (strcmp (name, ".sdata") == 0)
+		h->esym.asym.sc = scSData;
+	      else if (strcmp (name, ".rodata") == 0
+		       || strcmp (name, ".rdata") == 0)
+		h->esym.asym.sc = scRData;
+	      else if (strcmp (name, ".bss") == 0)
+		h->esym.asym.sc = scBss;
+	      else if (strcmp (name, ".sbss") == 0)
+		h->esym.asym.sc = scSBss;
+	      else if (strcmp (name, ".init") == 0)
+		h->esym.asym.sc = scInit;
+	      else if (strcmp (name, ".fini") == 0)
+		h->esym.asym.sc = scFini;
+	      else
+		h->esym.asym.sc = scAbs;
+	    }
+	}
 
       h->esym.asym.reserved = 0;
       h->esym.asym.index = indexNil;
@@ -2199,18 +2202,18 @@
 	   || h->root.root.type == bfd_link_hash_defweak)
     {
       if (h->esym.asym.sc == scCommon)
-       h->esym.asym.sc = scBss;
+	h->esym.asym.sc = scBss;
       else if (h->esym.asym.sc == scSCommon)
-       h->esym.asym.sc = scSBss;
+	h->esym.asym.sc = scSBss;
 
       sec = h->root.root.u.def.section;
       output_section = sec->output_section;
       if (output_section != NULL)
-       h->esym.asym.value = (h->root.root.u.def.value
-                             + sec->output_offset
-                             + output_section->vma);
+	h->esym.asym.value = (h->root.root.u.def.value
+			      + sec->output_offset
+			      + output_section->vma);
       else
-       h->esym.asym.value = 0;
+	h->esym.asym.value = 0;
     }
   else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
     {
@@ -2232,8 +2235,8 @@
     }
 
   if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
-                                     h->root.root.root.string,
-                                     &h->esym))
+				      h->root.root.root.string,
+				      &h->esym))
     {
       einfo->failed = true;
       return false;
@@ -2861,6 +2864,9 @@
 {
   struct alpha_elf_got_entry *gotent;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
+
   for (gotent = h->got_entries; gotent; gotent = gotent->next)
     if (gotent->use_count > 0)
       {
@@ -3038,6 +3044,9 @@
      struct alpha_elf_link_hash_entry *h;
      struct bfd_link_info *info;
 {
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
+
   /* If the symbol was defined as a common symbol in a regular object
      file, and there was no definition in any dynamic object, then the
      linker will have allocated space for the symbol in a common
@@ -3686,6 +3695,16 @@
 	  }
 	  goto default_reloc;
 
+	case R_ALPHA_SREL32:
+	case R_ALPHA_SREL64:
+	  /* ??? .eh_frame references to discarded sections will be smashed
+	     to relocations against SHN_UNDEF.  The .eh_frame format allows
+	     NULL to be encoded as 0 in any format, so this works here.  */
+	  if (r_symndx == 0)
+	    howto = (elf64_alpha_howto_table
+		     + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
+	  goto default_reloc;
+
 	default:
 	default_reloc:
 	  r = _bfd_final_link_relocate (howto, input_bfd, input_section,
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index defd72d..c6ea4f4 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -1,5 +1,5 @@
 /* Support for HPPA 64-bit ELF
-   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -1023,6 +1023,9 @@
 
   hppa_info = elf64_hppa_hash_table (info);
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h
       && (h->root.type == bfd_link_hash_defined
 	  || h->root.type == bfd_link_hash_defweak)
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 084e08a..508c0ee 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -38,7 +38,7 @@
  .   - Embedded PIC  is only partially implemented (is it needed?).
  .   - Combined relocs with RSS_* entries are unsupported.
  .   - The whole GOT handling for NewABI is missing, some parts of
- .     the OldABI version is still lying around and shold be removed.
+ .     the OldABI version is still lying around and should be removed.
  */
 
 #include "bfd.h"
@@ -48,6 +48,7 @@
 #include "bfdlink.h"
 #include "genlink.h"
 #include "elf-bfd.h"
+#include "elfxx-mips.h"
 #include "elf/mips.h"
 
 /* Get the ECOFF swapping routines.  The 64-bit ABI is not supposed to
@@ -61,8 +62,6 @@
 #define ECOFF_SIGNED_64
 #include "ecoffswap.h"
 
-struct mips_elf64_link_hash_entry;
-
 static void mips_elf64_swap_reloc_in
   PARAMS ((bfd *, const Elf64_Mips_External_Rel *,
 	   Elf64_Mips_Internal_Rel *));
@@ -83,11 +82,10 @@
   PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 static void mips_elf64_be_swap_reloca_out
   PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
-static bfd_vma mips_elf64_high PARAMS ((bfd_vma));
-static bfd_vma mips_elf64_higher PARAMS ((bfd_vma));
-static bfd_vma mips_elf64_highest PARAMS ((bfd_vma));
-static reloc_howto_type *mips_elf64_reloc_type_lookup
+static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
+static reloc_howto_type *mips_elf64_rtype_to_howto
+  PARAMS ((unsigned int, boolean));
 static void mips_elf64_info_to_howto_rel
   PARAMS ((bfd *, arelent *, Elf64_Internal_Rel *));
 static void mips_elf64_info_to_howto_rela
@@ -102,8 +100,6 @@
   PARAMS((bfd *, asection *, Elf_Internal_Shdr *, int *, PTR));
 static void mips_elf64_write_rela
   PARAMS((bfd *, asection *, Elf_Internal_Shdr *, int *, PTR));
-static struct bfd_hash_entry *mips_elf64_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 static bfd_reloc_status_type mips_elf64_hi16_reloc
   PARAMS ((bfd *, arelent *, asymbol *,	PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type mips_elf64_higher_reloc
@@ -125,101 +121,11 @@
 static boolean mips_elf64_assign_gp PARAMS ((bfd *, bfd_vma *));
 static bfd_reloc_status_type mips_elf64_final_gp
   PARAMS ((bfd *, asymbol *, boolean, char **, bfd_vma *));
-static bfd_reloc_status_type gprel16_with_gp
-  PARAMS ((bfd *, asymbol *, arelent *, asection *, boolean, PTR, bfd_vma));
-static int mips_elf64_additional_program_headers PARAMS ((bfd *));
-static struct bfd_link_hash_table *mips_elf64_link_hash_table_create
-  PARAMS((bfd *));
-static bfd_vma mips_elf64_got_offset_from_index
-  PARAMS ((bfd *, bfd *, bfd_vma));
-static struct mips_elf64_got_info *_mips_elf64_got_info
-  PARAMS ((bfd *, asection **));
-static bfd_vma mips_elf64_sign_extend PARAMS ((bfd_vma, int));
-static boolean mips_elf64_overflow_p PARAMS ((bfd_vma, int));
-static bfd_vma mips_elf64_global_got_index
-  PARAMS ((bfd *, struct elf_link_hash_entry *));
-static boolean mips_elf64_sort_hash_table_f
-  PARAMS ((struct mips_elf64_link_hash_entry *, PTR));
-static boolean mips_elf64_sort_hash_table
-  PARAMS ((struct bfd_link_info *, unsigned long));
-static void mips_elf64_swap_msym_out
-  PARAMS ((bfd *, const Elf32_Internal_Msym *, Elf32_External_Msym *));
-static bfd_vma mips_elf64_create_local_got_entry
-  PARAMS ((bfd *abfd, struct mips_elf64_got_info *, asection *,
-	   bfd_vma value));
-static bfd_vma mips_elf64_local_got_index
-  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma));
-static bfd_vma mips_elf64_got_page
-  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, bfd_vma *));
-static bfd_vma mips_elf64_got16_entry
-  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, boolean));
-static boolean mips_elf64_local_relocation_p
-  PARAMS ((bfd *, const Elf_Internal_Rela *, asection **, boolean));
-static const Elf_Internal_Rela *mips_elf64_next_relocation
-  PARAMS ((unsigned int, const Elf_Internal_Rela *,
-	   const Elf_Internal_Rela *));
-static boolean mips_elf64_create_dynamic_relocation
-  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Rela *,
-	   struct mips_elf64_link_hash_entry *, asection *, bfd_vma,
-	   bfd_vma *, asection *));
-static bfd_reloc_status_type mips_elf64_calculate_relocation
-  PARAMS ((bfd *, bfd *, asection *, struct bfd_link_info *,
-	   const Elf_Internal_Rela *, bfd_vma, reloc_howto_type *,
-	   Elf_Internal_Sym *, asection **, bfd_vma *, const char **,
-	   boolean *));
-static bfd_vma mips_elf64_obtain_contents
-  PARAMS ((reloc_howto_type *, const Elf_Internal_Rela *, bfd *, bfd_byte *));
-static boolean mips_elf64_perform_relocation
-  PARAMS ((struct bfd_link_info *, reloc_howto_type *,
-	   const Elf_Internal_Rela *, bfd_vma,
-	   bfd *, asection *, bfd_byte *, boolean));
-static boolean mips_elf64_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-boolean mips_elf64_create_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-boolean mips_elf64_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *h));
-boolean mips_elf64_always_size_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf64_check_mips16_stubs
-  PARAMS ((struct mips_elf64_link_hash_entry *, PTR));
-boolean mips_elf64_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-boolean mips_elf64_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-boolean mips_elf64_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *info));
-asection *mips_elf64_gc_mark_hook
-  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-boolean mips_elf64_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-static boolean mips_elf64_create_got_section
-  PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf64_record_global_got_symbol
-  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *,
-	   struct mips_elf64_got_info *));
-static asection *mips_elf64_create_msym_section PARAMS((bfd *));
-static void mips_elf64_allocate_dynamic_relocations
-  PARAMS ((bfd *, unsigned int));
-static boolean mips_elf64_stub_section_p PARAMS ((bfd *, asection *));
-boolean mips_elf64_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-static boolean mips_elf64_output_extsym
-	PARAMS ((struct mips_elf64_link_hash_entry *, PTR));
-static void mips_elf64_swap_gptab_in
-  PARAMS ((bfd *, const Elf32_External_gptab *, Elf32_gptab *));
-static void mips_elf64_swap_gptab_out
-  PARAMS ((bfd *, const Elf32_gptab *, Elf32_External_gptab *));
-static int gptab_compare PARAMS ((const PTR, const PTR));
-boolean mips_elf64_final_link PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf64_object_p PARAMS ((bfd *));
+static irix_compat_t elf64_mips_irix_compat PARAMS ((bfd *));
 
-extern const bfd_target bfd_elf64_bigmips_vec;
-extern const bfd_target bfd_elf64_littlemips_vec;
+extern const bfd_target bfd_elf64_tradbigmips_vec;
+extern const bfd_target bfd_elf64_tradlittlemips_vec;
 
 static bfd_vma prev_reloc_addend = 0;
 static bfd_size_type prev_reloc_address = 0;
@@ -227,8 +133,7 @@
 /* Whether we are trying to be compatible with IRIX6 (or little endianers
    which are otherwise IRIX-ABI compliant).  */
 #define SGI_COMPAT(abfd) \
-  ((abfd->xvec == &bfd_elf64_bigmips_vec) \
-   || (abfd->xvec == &bfd_elf64_littlemips_vec) ? true : false)
+  (elf64_mips_irix_compat (abfd) != ict_none)
 
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    from smaller values.  Start with zero, widen, *then* decrement.  */
@@ -236,15 +141,7 @@
 
 /* The number of local .got entries we reserve.  */
 #define MIPS_RESERVED_GOTNO (2)
-
-/* Instructions which appear in a stub.  */
-#define ELF_MIPS_GP_OFFSET(abfd) 0x7ff0
-#define STUB_LW    0xdf998010   /* ld t9,0x8010(gp) */
-#define STUB_MOVE  0x03e07825   /* move t7,ra */
-#define STUB_JALR  0x0320f809   /* jal t9 */
-#define STUB_LI16  0x34180000   /* ori t8,zero,0 */
-#define MIPS_FUNCTION_STUB_SIZE (16)
-
+
 /* The relocation table used for SHT_REL sections.  */
 
 #define UNUSED_RELOC(num) { num, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
@@ -1300,7 +1197,7 @@
 	 0x00000000,		/* dst_mask */
 	 false),		/* pcrel_offset */
 };
-
+
 /* Swap in a MIPS 64-bit Rel reloc.  */
 
 static void
@@ -1465,34 +1362,7 @@
   mips_elf64_swap_reloca_out (abfd, &mirela,
 			      (Elf64_Mips_External_Rela *) dst);
 }
-
-/* Calculate the %high function.  */
-
-static bfd_vma
-mips_elf64_high (value)
-     bfd_vma value;
-{
-  return ((value + (bfd_vma) 0x8000) >> 16) & 0xffff;
-}
-
-/* Calculate the %higher function.  */
-
-static bfd_vma
-mips_elf64_higher (value)
-     bfd_vma value;
-{
-  return ((value + (bfd_vma) 0x80008000) >> 32) & 0xffff;
-}
-
-/* Calculate the %highest function.  */
-
-static bfd_vma 
-mips_elf64_highest (value)
-     bfd_vma value;
-{
-  return ((value + (bfd_vma) 0x800080008000) >> 48) & 0xffff;
-}
-
+
 /* Do a R_MIPS_HI16 relocation.  */
 
 bfd_reloc_status_type
@@ -1787,68 +1657,9 @@
   if (ret != bfd_reloc_ok)
     return ret;
 
-  return gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
-			  relocateable, data, gp);
-}
-
-static bfd_reloc_status_type
-gprel16_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
-		 gp)
-     bfd *abfd;
-     asymbol *symbol;
-     arelent *reloc_entry;
-     asection *input_section;
-     boolean relocateable;
-     PTR data;
-     bfd_vma gp;
-{
-  bfd_vma relocation;
-  unsigned long insn;
-  unsigned long val;
-
-  if (bfd_is_com_section (symbol->section))
-    relocation = 0;
-  else
-    relocation = symbol->value;
-
-  relocation += symbol->section->output_section->vma;
-  relocation += symbol->section->output_offset;
-
-  if (reloc_entry->address > input_section->_cooked_size)
-    return bfd_reloc_outofrange;
-
-  insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
-
-  /* Set val to the offset into the section or symbol.  */
-  if (reloc_entry->howto->src_mask == 0)
-    {
-      /* This case occurs with the 64-bit MIPS ELF ABI.  */
-      val = reloc_entry->addend;
-    }
-  else
-    {
-      val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
-      if (val & 0x8000)
-	val -= 0x10000;
-    }
-
-  /* Adjust val for the final section location and GP value.  If we
-     are producing relocateable output, we don't want to do this for
-     an external symbol.  */
-  if (! relocateable
-      || (symbol->flags & BSF_SECTION_SYM) != 0)
-    val += relocation - gp;
-
-  insn = (insn & ~0xffff) | (val & 0xffff);
-  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
-
-  if (relocateable)
-    reloc_entry->address += input_section->output_offset;
-
-  else if ((long) val >= 0x8000 || (long) val < -0x8000)
-    return bfd_reloc_overflow;
-
-  return bfd_reloc_ok;
+  return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
+					input_section, relocateable,
+					data, gp);
 }
 
 /* Do a R_MIPS_GPREL16 RELA relocation.  */
@@ -2057,23 +1868,10 @@
   return bfd_reloc_continue;
 }
 
-static int
-mips_elf64_additional_program_headers (abfd)
-     bfd *abfd;
-{
-  int ret = 0;
-
-  /* See if we need a PT_MIPS_OPTIONS segment.  */
-  if (bfd_get_section_by_name (abfd, ".MIPS.options"))
-    ++ret;
-
-  return ret;
-}
-
 /* Given a BFD reloc type, return a howto structure.  */
 
 static reloc_howto_type *
-mips_elf64_reloc_type_lookup (abfd, code)
+bfd_elf64_bfd_reloc_type_lookup (abfd, code)
      bfd *abfd ATTRIBUTE_UNUSED;
      bfd_reloc_code_real_type code;
 {
@@ -2091,14 +1889,7 @@
       return &howto_table[R_MIPS_32];
     case BFD_RELOC_64:
     case BFD_RELOC_CTOR:
-      /* We need to handle these specially.  Select the right
-	 relocation (R_MIPS_32 or R_MIPS_64) based on the
-	 size of addresses on this architecture.  */
-      if (bfd_arch_bits_per_address (abfd) == 32)
-	return &howto_table[R_MIPS_32];
-      else
-	return &howto_table[R_MIPS_64];
-
+      return &howto_table[R_MIPS_64];
     case BFD_RELOC_16_PCREL:
       return &howto_table[R_MIPS_PC16];
     case BFD_RELOC_HI16_S:
@@ -2182,6 +1973,55 @@
     }
 }
 
+/* Given a MIPS Elf64_Internal_Rel, fill in an arelent structure.  */
+
+static reloc_howto_type *
+mips_elf64_rtype_to_howto (r_type, rela_p)
+     unsigned int r_type;
+     boolean rela_p;
+{
+  switch (r_type)
+    {
+/*
+    case R_MIPS16_26:
+      return &elf_mips16_jump_howto;
+      break;
+    case R_MIPS16_GPREL:
+      return &elf_mips16_gprel_howto;
+      break;
+    case R_MIPS_GNU_VTINHERIT:
+      return &elf_mips_gnu_vtinherit_howto;
+      break;
+    case R_MIPS_GNU_VTENTRY:
+      return &elf_mips_gnu_vtentry_howto;
+      break;
+    case R_MIPS_GNU_REL_HI16:
+      return &elf_mips_gnu_rel_hi16;
+      break;
+    case R_MIPS_GNU_REL_LO16:
+      return &elf_mips_gnu_rel_lo16;
+      break;
+    case R_MIPS_GNU_REL16_S2:
+      return &elf_mips_gnu_rel16_s2;
+      break;
+    case R_MIPS_PC64:
+      return &elf_mips_gnu_pcrel64;
+      break;
+    case R_MIPS_PC32:
+      return &elf_mips_gnu_pcrel32;
+      break;
+*/
+
+    default:
+      BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
+      if (rela_p)
+	return &mips_elf64_howto_table_rela[r_type];
+      else
+	return &mips_elf64_howto_table_rel[r_type];
+      break;
+    }
+}
+
 /* Prevent relocation handling by bfd for MIPS ELF64.  */
 
 static void
@@ -2728,4167 +2568,36 @@
 	      == *count);
 }
 
-/* This structure is used to hold .got information when linking.  It
-   is stored in the tdata field of the bfd_elf_section_data structure.  */
-
-struct mips_elf64_got_info
-{
-  /* The global symbol in the GOT with the lowest index in the dynamic
-     symbol table.  */
-  struct elf_link_hash_entry *global_gotsym;
-  /* The number of global .got entries.  */
-  unsigned int global_gotno;
-  /* The number of local .got entries.  */
-  unsigned int local_gotno;
-  /* The number of local .got entries we have used.  */
-  unsigned int assigned_gotno;
-};
-
-/* The MIPS ELF64 linker needs additional information for each symbol in
-   the global hash table.  */
-
-struct mips_elf64_link_hash_entry
-{
-  struct elf_link_hash_entry root;
-
-  /* External symbol information.  */
-  EXTR esym;
-
-  /* Number of R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 relocs against
-     this symbol.  */ 
-  unsigned int possibly_dynamic_relocs;
-
-  /* If the R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 reloc is against
-     a readonly section.  */
-  boolean readonly_reloc;
-
-  /* The index of the first dynamic relocation (in the .rel.dyn
-     section) against this symbol.  */
-  unsigned int min_dyn_reloc_index;
-
-  /* We must not create a stub for a symbol that has relocations
-     related to taking the function's address, i.e. any but
-     R_MIPS_CALL*16 ones -- see "MIPS ABI Supplement, 3rd Edition",
-     p. 4-20.  */
-  boolean no_fn_stub;
-
-  /* If there is a stub that 32 bit functions should use to call this
-     16 bit function, this points to the section containing the stub.  */
-  asection *fn_stub;
-
-  /* Whether we need the fn_stub; this is set if this symbol appears
-     in any relocs other than a 16 bit call.  */
-  boolean need_fn_stub;
-
-  /* If there is a stub that 16 bit functions should use to call this
-     32 bit function, this points to the section containing the stub.  */
-  asection *call_stub;
-
-  /* This is like the call_stub field, but it is used if the function
-     being called returns a floating point value.  */
-  asection *call_fp_stub;
-};
-
-  /* The mips16 compiler uses a couple of special sections to handle
-     floating point arguments.
-
-     Section names that look like .mips16.fn.FNNAME contain stubs that
-     copy floating point arguments from the fp regs to the gp regs and
-     then jump to FNNAME.  If any 32 bit function calls FNNAME, the
-     call should be redirected to the stub instead.  If no 32 bit
-     function calls FNNAME, the stub should be discarded.  We need to
-     consider any reference to the function, not just a call, because
-     if the address of the function is taken we will need the stub,
-     since the address might be passed to a 32 bit function.
-
-     Section names that look like .mips16.call.FNNAME contain stubs
-     that copy floating point arguments from the gp regs to the fp
-     regs and then jump to FNNAME.  If FNNAME is a 32 bit function,
-     then any 16 bit function that calls FNNAME should be redirected
-     to the stub instead.  If FNNAME is not a 32 bit function, the
-     stub should be discarded.
-
-     .mips16.call.fp.FNNAME sections are similar, but contain stubs
-     which call FNNAME and then copy the return value from the fp regs
-     to the gp regs.  These stubs store the return value in $18 while
-     calling FNNAME; any function which might call one of these stubs
-     must arrange to save $18 around the call.  (This case is not
-     needed for 32 bit functions that call 16 bit functions, because
-     16 bit functions always return floating point values in both
-     $f0/$f1 and $2/$3.)
-
-     Note that in all cases FNNAME might be defined statically.
-     Therefore, FNNAME is not used literally.  Instead, the relocation
-     information will indicate which symbol the section is for.
-
-     We record any stubs that we find in the symbol table.  */
-
-#define FN_STUB ".mips16.fn."
-#define CALL_STUB ".mips16.call."
-#define CALL_FP_STUB ".mips16.call.fp."
-
-/* MIPS ELF64 linker hash table.  */
-
-struct mips_elf64_link_hash_table
-{
-  struct elf_link_hash_table root;
-  /* This is set if we see any mips16 stub sections.  */
-  boolean mips16_stubs_seen;
-};
-
-/* Look up an entry in a MIPS ELF64 linker hash table.  */
-
-#define mips_elf64_link_hash_lookup(table, string, create, copy, follow) \
-  ((struct mips_elf64_link_hash_entry *)				\
-   elf_link_hash_lookup (&(table)->root, (string), (create),		\
-			 (copy), (follow)))
-
-/* Traverse a MIPS ELF linker hash table.  */
-
-#define mips_elf64_link_hash_traverse(table, func, info)		\
-  (elf_link_hash_traverse						\
-   (&(table)->root,							\
-    (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),	\
-    (info)))
-
-/* Get the MIPS ELF64 linker hash table from a link_info structure.  */
-
-#define mips_elf64_hash_table(p) \
-  ((struct mips_elf64_link_hash_table *) ((p)->hash))
-
-/* Create an entry in a MIPS ELF64 linker hash table.  */
-
-static struct bfd_hash_entry *
-mips_elf64_link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
-{
-  struct mips_elf64_link_hash_entry *ret =
-    (struct mips_elf64_link_hash_entry *) entry;
-
-  /* Allocate the structure if it has not already been allocated by a
-     subclass.  */
-  if (ret == (struct mips_elf64_link_hash_entry *) NULL)
-    ret = ((struct mips_elf64_link_hash_entry *)
-	   bfd_hash_allocate (table,
-			      sizeof (struct mips_elf64_link_hash_entry)));
-  if (ret == (struct mips_elf64_link_hash_entry *) NULL)
-    return (struct bfd_hash_entry *) ret;
-
-  /* Call the allocation method of the superclass.  */
-  ret = ((struct mips_elf64_link_hash_entry *)
-	 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
-				     table, string));
-  if (ret != (struct mips_elf64_link_hash_entry *) NULL)
-    {
-      /* Set local fields.  */
-      memset (&ret->esym, 0, sizeof (EXTR));
-      /* We use -2 as a marker to indicate that the information has
-	 not been set.  -1 means there is no associated ifd.  */
-      ret->esym.ifd = -2;
-      ret->possibly_dynamic_relocs = 0;
-      ret->readonly_reloc = false;
-      ret->min_dyn_reloc_index = 0;
-      ret->no_fn_stub = false;
-      ret->fn_stub = NULL;
-      ret->need_fn_stub = false;
-      ret->call_stub = NULL;
-      ret->call_fp_stub = NULL;
-    }
-
-  return (struct bfd_hash_entry *) ret;
-}
-
-/* Create a MIPS ELF64 linker hash table.  */
-
-struct bfd_link_hash_table *
-mips_elf64_link_hash_table_create (abfd)
-     bfd *abfd;
-{
-  struct mips_elf64_link_hash_table *ret;
-
-  ret = ((struct mips_elf64_link_hash_table *)
-	 bfd_alloc (abfd, sizeof (struct mips_elf64_link_hash_table)));
-  if (ret == (struct mips_elf64_link_hash_table *) NULL)
-    return NULL;
-
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-				       mips_elf64_link_hash_newfunc))
-    {
-      bfd_release (abfd, ret);
-      return NULL;
-    }
-
-  ret->mips16_stubs_seen = false;
-
-  return &ret->root.root;
-}
-
-/* Returns the offset for the entry at the INDEXth position
-   in the GOT.  */
-
-static bfd_vma
-mips_elf64_got_offset_from_index (dynobj, output_bfd, index)
-     bfd *dynobj;
-     bfd *output_bfd;
-     bfd_vma index;
-{
-  asection *sgot;
-  bfd_vma gp;
-
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  gp = _bfd_get_gp_value (output_bfd);
-  return (sgot->output_section->vma + sgot->output_offset + index - 
-	  gp);
-}
-
-/* Returns the GOT information associated with the link indicated by
-   INFO.  If SGOTP is non-NULL, it is filled in with the GOT 
-   section.  */
-
-static struct mips_elf64_got_info *
-_mips_elf64_got_info (abfd, sgotp)
-     bfd *abfd;
-     asection **sgotp;
-{
-  asection *sgot;
-  struct mips_elf64_got_info *g;
-
-  sgot = bfd_get_section_by_name (abfd, ".got");
-  BFD_ASSERT (sgot != NULL);
-  BFD_ASSERT (elf_section_data (sgot) != NULL);
-  g = (struct mips_elf64_got_info *) elf_section_data (sgot)->tdata;
-  BFD_ASSERT (g != NULL);
-
-  if (sgotp)
-    *sgotp = sgot;
-  return g;
-}
-
-/* Sign-extend VALUE, which has the indicated number of BITS.  */
-
-static bfd_vma
-mips_elf64_sign_extend (value, bits)
-     bfd_vma value;
-     int bits;
-{
-  if (value & ((bfd_vma)1 << (bits - 1)))
-    /* VALUE is negative.  */
-    value |= ((bfd_vma) - 1) << bits;      
-  
-  return value;
-}
-
-/* Return non-zero if the indicated VALUE has overflowed the maximum
-   range expressable by a signed number with the indicated number of
-   BITS.  */
+/* Set the right machine number for a MIPS ELF file.  */
 
 static boolean
-mips_elf64_overflow_p (value, bits)
-     bfd_vma value;
-     int bits;
-{
-  bfd_signed_vma svalue = (bfd_signed_vma) value;
-
-  if (svalue > (1 << (bits - 1)) - 1)
-    /* The value is too big.  */
-    return true;
-  else if (svalue < -(1 << (bits - 1)))
-    /* The value is too small.  */
-    return true;
-    
-  /* All is well.  */
-  return false;
-}
-
-/* Returns the GOT index for the global symbol indicated by H.  */
-
-static bfd_vma 
-mips_elf64_global_got_index (abfd, h)
+mips_elf64_object_p (abfd)
      bfd *abfd;
-     struct elf_link_hash_entry *h;
 {
-  bfd_vma index;
-  asection *sgot;
-  struct mips_elf64_got_info *g;
+  unsigned long mach;
 
-  g = _mips_elf64_got_info (abfd, &sgot);
+  /* Irix 6 is broken.  Object file symbol tables are not always
+     sorted correctly such that local symbols precede global symbols,
+     and the sh_info field in the symbol table is not always right.  */
+  if (SGI_COMPAT(abfd))
+    elf_bad_symtab (abfd) = true;
 
-  /* Once we determine the global GOT entry with the lowest dynamic
-     symbol table index, we must put all dynamic symbols with greater
-     indices into the GOT.  That makes it easy to calculate the GOT
-     offset.  */
-  BFD_ASSERT (h->dynindx >= g->global_gotsym->dynindx);
-  index = ((h->dynindx - g->global_gotsym->dynindx + g->local_gotno) 
-	   * (get_elf_backend_data (abfd)->s->arch_size / 8));
-  BFD_ASSERT (index < sgot->_raw_size);
-
-  return index;
+  mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
+  bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
+  return true;
 }
 
-struct mips_elf64_hash_sort_data
+/* Depending on the target vector we generate some version of Irix
+   executables or "normal" MIPS ELF ABI executables.  */
+static irix_compat_t
+elf64_mips_irix_compat (abfd)
+     bfd *abfd;
 {
-  /* The symbol in the global GOT with the lowest dynamic symbol table
-     index.  */
-  struct elf_link_hash_entry *low;
-  /* The least dynamic symbol table index corresponding to a symbol
-     with a GOT entry.  */
-  long min_got_dynindx;
-  /* The greatest dynamic symbol table index not corresponding to a
-     symbol without a GOT entry.  */
-  long max_non_got_dynindx;
-};
-
-/* If H needs a GOT entry, assign it the highest available dynamic
-   index.  Otherwise, assign it the lowest available dynamic 
-   index.  */
-
-static boolean
-mips_elf64_sort_hash_table_f (h, data)
-     struct mips_elf64_link_hash_entry *h;
-     PTR data;
-{
-  struct mips_elf64_hash_sort_data *hsd 
-    = (struct mips_elf64_hash_sort_data *) data;
-
-  /* Symbols without dynamic symbol table entries aren't interesting
-     at all.  */
-  if (h->root.dynindx == -1)
-    return true;
-
-  if (h->root.got.offset != 1)
-    h->root.dynindx = hsd->max_non_got_dynindx++;
+  if ((abfd->xvec == &bfd_elf64_tradbigmips_vec)
+      || (abfd->xvec == &bfd_elf64_tradlittlemips_vec))
+    return ict_none;
   else
-    {
-      h->root.dynindx = --hsd->min_got_dynindx;
-      hsd->low = (struct elf_link_hash_entry *) h;
-    }
-
-  return true;
-}
-
-/* Sort the dynamic symbol table so that symbols that need GOT entries
-   appear towards the end.  This reduces the amount of GOT space
-   required.  MAX_LOCAL is used to set the number of local symbols
-   known to be in the dynamic symbol table.  During
-   mips_elf64_size_dynamic_sections, this value is 1.  Afterward, the
-   section symbols are added and the count is higher.  */
-
-static boolean
-mips_elf64_sort_hash_table (info, max_local)
-     struct bfd_link_info *info;
-     unsigned long max_local;
-{
-  struct mips_elf64_hash_sort_data hsd;
-  struct mips_elf64_got_info *g;
-  bfd *dynobj;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
-  hsd.low = NULL;
-  hsd.min_got_dynindx = elf_hash_table (info)->dynsymcount;
-  hsd.max_non_got_dynindx = max_local;
-  mips_elf64_link_hash_traverse (((struct mips_elf64_link_hash_table *) 
-				elf_hash_table (info)), 
-			       mips_elf64_sort_hash_table_f, 
-			       &hsd);
-
-  /* There shoud have been enough room in the symbol table to
-     accomodate both the GOT and non-GOT symbols.  */
-  BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
-
-  /* Now we know which dynamic symbol has the lowest dynamic symbol
-     table index in the GOT.  */
-  g = _mips_elf64_got_info (dynobj, NULL);
-  g->global_gotsym = hsd.low;
-
-  return true;
-}
-
-#if 0
-/* Swap in an MSYM entry.  */
-
-static void
-mips_elf64_swap_msym_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf32_External_Msym *ex;
-     Elf32_Internal_Msym *in;
-{
-  in->ms_hash_value = H_GET_32 (abfd, ex->ms_hash_value);
-  in->ms_info = H_GET_32 (abfd, ex->ms_info);
-}
-#endif
-/* Swap out an MSYM entry.  */
-
-static void
-mips_elf64_swap_msym_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_Internal_Msym *in;
-     Elf32_External_Msym *ex;
-{
-  H_PUT_32 (abfd, in->ms_hash_value, ex->ms_hash_value);
-  H_PUT_32 (abfd, in->ms_info, ex->ms_info);
-}
-
-/* Create a local GOT entry for VALUE.  Return the index of the entry,
-   or -1 if it could not be created.  */
-
-static bfd_vma
-mips_elf64_create_local_got_entry (abfd, g, sgot, value)
-     bfd *abfd;
-     struct mips_elf64_got_info *g;
-     asection *sgot;
-     bfd_vma value;
-{
-  CONST bfd_vma got_size = get_elf_backend_data (abfd)->s->arch_size / 8;
-  
-  if (g->assigned_gotno >= g->local_gotno)
-    {
-      /* We didn't allocate enough space in the GOT.  */
-      (*_bfd_error_handler)
-	(_("not enough GOT space for local GOT entries"));
-      bfd_set_error (bfd_error_bad_value);
-      return (bfd_vma) -1;
-    }
-
-  bfd_put_64 (abfd, value, (sgot->contents + got_size * g->assigned_gotno));
-  return got_size * g->assigned_gotno++;
-}
-
-/* Returns the GOT offset at which the indicated address can be found.
-   If there is not yet a GOT entry for this value, create one.  Returns
-   -1 if no satisfactory GOT offset can be found.  */
-
-static bfd_vma
-mips_elf64_local_got_index (abfd, info, value)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     bfd_vma value;
-{
-  CONST bfd_vma got_size = get_elf_backend_data (abfd)->s->arch_size / 8;
-  asection *sgot;
-  struct mips_elf64_got_info *g;
-  bfd_byte *entry;
-
-  g = _mips_elf64_got_info (elf_hash_table (info)->dynobj, &sgot);
-
-  /* Look to see if we already have an appropriate entry.  */
-  for (entry = (sgot->contents + got_size * MIPS_RESERVED_GOTNO); 
-       entry != sgot->contents + got_size * g->assigned_gotno;
-       entry += got_size)
-    {
-      bfd_vma address = bfd_get_64 (abfd, entry);
-      if (address == value)
-	return entry - sgot->contents;
-    }
-
-  return mips_elf64_create_local_got_entry (abfd, g, sgot, value);
-}
-
-/* Find a GOT entry that is within 32KB of the VALUE.  These entries
-   are supposed to be placed at small offsets in the GOT, i.e.,
-   within 32KB of GP.  Return the index into the GOT for this page,
-   and store the offset from this entry to the desired address in
-   OFFSETP, if it is non-NULL.  */
-
-static bfd_vma
-mips_elf64_got_page (abfd, info, value, offsetp)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     bfd_vma value;
-     bfd_vma *offsetp;
-{
-  CONST bfd_vma got_size = get_elf_backend_data (abfd)->s->arch_size / 8;
-  asection *sgot;
-  struct mips_elf64_got_info *g;
-  bfd_byte *entry;
-  bfd_byte *last_entry;
-  bfd_vma index = 0;
-  bfd_vma address;
-
-  g = _mips_elf64_got_info (elf_hash_table (info)->dynobj, &sgot);
-
-  /* Look to see if we aleady have an appropriate entry.  */
-  last_entry = sgot->contents + got_size * g->assigned_gotno;
-  for (entry = (sgot->contents + got_size * MIPS_RESERVED_GOTNO);
-       entry != last_entry;
-       entry += got_size)
-    {
-      address = bfd_get_64 (abfd, entry);
-
-      if (!mips_elf64_overflow_p (value - address, 16))
-	{
-	  /* This entry will serve as the page pointer.  We can add a
-	     16-bit number to it to get the actual address.  */
-	  index = entry - sgot->contents;
-	  break;
-	}
-    }
-
-  /* If we didn't have an appropriate entry, we create one now.  */
-  if (entry == last_entry)
-    index = mips_elf64_create_local_got_entry (abfd, g, sgot, value);
-
-  if (offsetp)
-    {
-      address = bfd_get_64 (abfd, entry);
-      *offsetp = value - address;
-    }
-
-  return index;
-}
-
-/* Find a GOT entry whose higher-order 16 bits are the same as those
-   for value.  Return the index into the GOT for this entry.  */
-
-static bfd_vma
-mips_elf64_got16_entry (abfd, info, value, external)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     bfd_vma value;
-     boolean external;
-{
-  CONST bfd_vma got_size = get_elf_backend_data (abfd)->s->arch_size / 8;
-  asection *sgot;
-  struct mips_elf64_got_info *g;
-  bfd_byte *entry;
-  bfd_byte *last_entry;
-  bfd_vma index = 0;
-  bfd_vma address;
-
-  if (! external)
-    {
-      /* Although the ABI says that it is "the high-order 16 bits" that we
-	 want, it is really the %high value.  The complete value is
-	 calculated with a `addiu' of a LO16 relocation, just as with a
-	 HI16/LO16 pair.  */
-      value = mips_elf64_high (value) << 16;
-    }
-
-  g = _mips_elf64_got_info (elf_hash_table (info)->dynobj, &sgot);
-
-  /* Look to see if we already have an appropriate entry.  */
-  last_entry = sgot->contents + got_size * g->assigned_gotno;
-  for (entry = (sgot->contents + got_size * MIPS_RESERVED_GOTNO);
-       entry != last_entry;
-       entry += got_size)
-    {
-      address = bfd_get_64 (abfd, entry);
-      if (address == value)
-	{
-	  /* This entry has the right high-order 16 bits, and the low-order
-	     16 bits are set to zero.  */
-	  index = entry - sgot->contents;
-	  break;
-	}
-    }
-
-  /* If we didn't have an appropriate entry, we create one now.  */
-  if (entry == last_entry)
-    index = mips_elf64_create_local_got_entry (abfd, g, sgot, value);
-
-  return index;
-}
-
-/* Return whether a relocation is against a local symbol.  */
-
-static boolean
-mips_elf64_local_relocation_p (input_bfd, relocation, local_sections,
-			     check_forced)
-     bfd *input_bfd;
-     const Elf_Internal_Rela *relocation;
-     asection **local_sections;
-     boolean check_forced;
-{
-  unsigned long r_symndx;
-  Elf_Internal_Shdr *symtab_hdr;
-  struct mips_elf64_link_hash_entry* h;
-  size_t extsymoff;
-
-  r_symndx = ELF64_R_SYM (relocation->r_info);
-  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
-  extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
-
-  if (r_symndx < extsymoff)
-    return true;
-  if (elf_bad_symtab (input_bfd) && local_sections[r_symndx] != NULL)
-    return true;
-
-  if (check_forced)
-    {
-       /* Look up the hash table to check whether the symbol
- 	 was forced local.  */
-       h = (struct mips_elf64_link_hash_entry *)
- 	  elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
-       /* Find the real hash-table entry for this symbol.  */
-       while (h->root.root.type == bfd_link_hash_indirect
- 	     || h->root.root.type == bfd_link_hash_warning)
-         h = (struct mips_elf64_link_hash_entry *) h->root.root.u.i.link;
-       if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
-         return true;
-    }
-
-  return false;
-}
-
-/* Returns the first relocation of type r_type found, beginning with
-   RELOCATION.  RELEND is one-past-the-end of the relocation table.  */
-
-static const Elf_Internal_Rela *
-mips_elf64_next_relocation (r_type, relocation, relend)
-     unsigned int r_type;
-     const Elf_Internal_Rela *relocation;
-     const Elf_Internal_Rela *relend;
-{
-  /* According to the MIPS ELF ABI, the R_MIPS_LO16 relocation must be
-     immediately following.  However, for the IRIX6 ABI, the next
-     relocation may be a composed relocation consisting of several
-     relocations for the same address.  In that case, the R_MIPS_LO16
-     relocation may occur as one of these.  We permit a similar
-     extension in general, as that is useful for GCC.  */
-  while (relocation < relend)
-    {
-      if (ELF64_MIPS_R_TYPE (relocation->r_info) == r_type)
-	return relocation;
-
-      ++relocation;
-    }
-
-  /* We didn't find it.  */
-  bfd_set_error (bfd_error_bad_value);
-  return NULL;
-}
-
-/* Create a rel.dyn relocation for the dynamic linker to resolve.  REL
-   is the original relocation, which is now being transformed into a
-   dynamic relocation.  The ADDENDP is adjusted if necessary; the
-   caller should store the result in place of the original addend.  */
-
-static boolean
-mips_elf64_create_dynamic_relocation (output_bfd, info, rel, h, sec,
-				    symbol, addendp, input_section)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     const Elf_Internal_Rela *rel;
-     struct mips_elf64_link_hash_entry *h;
-     asection *sec;
-     bfd_vma symbol;
-     bfd_vma *addendp;
-     asection *input_section;
-{
-  Elf_Internal_Rel outrel[3];
-  boolean skip;
-  asection *sreloc;
-  bfd *dynobj;
-  int r_type;
-
-  r_type = ELF64_MIPS_R_TYPE (rel->r_info);
-  dynobj = elf_hash_table (info)->dynobj;
-  sreloc = bfd_get_section_by_name (dynobj, ".rel.dyn");
-  BFD_ASSERT (sreloc != NULL);
-  BFD_ASSERT (sreloc->contents != NULL);
-  BFD_ASSERT ((sreloc->reloc_count
-	       * get_elf_backend_data (output_bfd)->s->sizeof_rel)
-	      < sreloc->_raw_size);
-
-  skip = false;
-  outrel[0].r_offset = _bfd_elf_section_offset (output_bfd, info,
-						input_section,
-						rel[0].r_offset);
-  /* FIXME: For -2 runtime relocation needs to be skipped, but
-     properly resolved statically and installed.  */
-  BFD_ASSERT (outrel[0].r_offset != (bfd_vma) -2);
-
-  /* We begin by assuming that the offset for the dynamic relocation
-     is the same as for the original relocation.  We'll adjust this
-     later to reflect the correct output offsets.  */
-  if (elf_section_data (input_section)->sec_info_type != ELF_INFO_TYPE_STABS)
-    {
-      outrel[1].r_offset = rel[1].r_offset;
-      outrel[2].r_offset = rel[2].r_offset;
-    }
-  else
-    {
-      /* Except that in a stab section things are more complex.
-	 Because we compress stab information, the offset given in the
-	 relocation may not be the one we want; we must let the stabs
-	 machinery tell us the offset.  */
-      outrel[1].r_offset = outrel[0].r_offset;
-      outrel[2].r_offset = outrel[0].r_offset;
-      /* If we didn't need the relocation at all, this value will be
-	 -1.  */
-      if (outrel[0].r_offset == (bfd_vma) -1)
-	skip = true;
-    }
-
-  /* If we've decided to skip this relocation, just output an empty
-     record.  Note that R_MIPS_NONE == 0, so that this call to memset
-     is a way of setting R_TYPE to R_MIPS_NONE.  */
-  if (skip)
-    memset (outrel, 0, sizeof (Elf_Internal_Rel) * 3);
-  else
-    {
-      long indx;
-      bfd_vma section_offset;
-
-      /* We must now calculate the dynamic symbol table index to use
-	 in the relocation.  */
-      if (h != NULL
-	  && (! info->symbolic || (h->root.elf_link_hash_flags
-				   & ELF_LINK_HASH_DEF_REGULAR) == 0))
-	{
-	  indx = h->root.dynindx;
-	  /* h->root.dynindx may be -1 if this symbol was marked to
-	     become local.  */
-	  if (indx == -1)
-		indx = 0;
-	}
-      else
-	{
-	  if (sec != NULL && bfd_is_abs_section (sec))
-	    indx = 0;
-	  else if (sec == NULL || sec->owner == NULL)
-	    {
-	      bfd_set_error (bfd_error_bad_value);
-	      return false;
-	    }
-	  else
-	    {
-	      indx = elf_section_data (sec->output_section)->dynindx;
-	      if (indx == 0)
-		abort ();
-	    }
-
-	  /* Figure out how far the target of the relocation is from
-	     the beginning of its section.  */
-	  section_offset = symbol - sec->output_section->vma;
-	  /* The relocation we're building is section-relative.
-	     Therefore, the original addend must be adjusted by the
-	     section offset.  */
-	  *addendp += section_offset;
-	  /* Now, the relocation is just against the section.  */
-	  symbol = sec->output_section->vma;
-	}
-      
-      /* If the relocation was previously an absolute relocation and
-	 this symbol will not be referred to by the relocation, we must
-	 adjust it by the value we give it in the dynamic symbol table.
-	 Otherwise leave the job up to the dynamic linker.  */
-      if (!indx && r_type != R_MIPS_REL32)
-	*addendp += symbol;
-
-      /* The relocation is always an REL32 relocation because we don't
-	 know where the shared library will wind up at load-time.  */
-      outrel[0].r_info = ELF64_R_INFO (indx, R_MIPS_REL32);
-
-      /* Adjust the output offset of the relocation to reference the
-	 correct location in the output file.  */
-      outrel[0].r_offset += (input_section->output_section->vma
-			     + input_section->output_offset);
-      outrel[1].r_offset += (input_section->output_section->vma
-			     + input_section->output_offset);
-      outrel[2].r_offset += (input_section->output_section->vma
-			     + input_section->output_offset);
-    }
-
-  /* Put the relocation back out.  */
-  mips_elf64_be_swap_reloc_out (output_bfd, outrel,
-				(sreloc->contents 
-				 + sreloc->reloc_count
-				   * sizeof (Elf64_Mips_External_Rel)));
-
-  /* Record the index of the first relocation referencing H.  This
-     information is later emitted in the .msym section.  */
-  if (h != NULL
-      && (h->min_dyn_reloc_index == 0 
-	  || sreloc->reloc_count < h->min_dyn_reloc_index))
-    h->min_dyn_reloc_index = sreloc->reloc_count;
-
-  /* We've now added another relocation.  */
-  ++sreloc->reloc_count;
-
-  /* Make sure the output section is writable.  The dynamic linker
-     will be writing to it.  */
-  elf_section_data (input_section->output_section)->this_hdr.sh_flags
-    |= SHF_WRITE;
-
-  return true;
-}
-
-/* Calculate the value produced by the RELOCATION (which comes from
-   the INPUT_BFD).  The ADDEND is the addend to use for this
-   RELOCATION; RELOCATION->R_ADDEND is ignored.
-
-   The result of the relocation calculation is stored in VALUEP.
-   REQUIRE_JALXP indicates whether or not the opcode used with this
-   relocation must be JALX.
-
-   This function returns bfd_reloc_continue if the caller need take no
-   further action regarding this relocation, bfd_reloc_notsupported if
-   something goes dramatically wrong, bfd_reloc_overflow if an
-   overflow occurs, and bfd_reloc_ok to indicate success.  */
-
-static bfd_reloc_status_type
-mips_elf64_calculate_relocation (abfd, input_bfd, input_section, info,
-				 relocation, addend, howto, local_syms,
-				 local_sections, valuep, namep, require_jalxp)
-     bfd *abfd;
-     bfd *input_bfd;
-     asection *input_section;
-     struct bfd_link_info *info;
-     const Elf_Internal_Rela *relocation;
-     bfd_vma addend;
-     reloc_howto_type *howto;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
-     bfd_vma *valuep;
-     const char **namep;
-     boolean *require_jalxp;
-{
-  /* The eventual value we will return.  */
-  bfd_vma value;
-  /* The address of the symbol against which the relocation is
-     occurring.  */
-  bfd_vma symbol = 0;
-  /* The final GP value to be used for the relocatable, executable, or
-     shared object file being produced.  */
-  bfd_vma gp = (bfd_vma) - 1;
-  /* The place (section offset or address) of the storage unit being
-     relocated.  */
-  bfd_vma p;
-  /* The value of GP used to create the relocatable object.  */
-  bfd_vma gp0 = (bfd_vma) - 1;
-  /* The offset into the global offset table at which the address of
-     the relocation entry symbol, adjusted by the addend, resides
-     during execution.  */
-  bfd_vma g = (bfd_vma) - 1;
-  /* The section in which the symbol referenced by the relocation is
-     located.  */
-  asection *sec = NULL;
-  struct mips_elf64_link_hash_entry* h = NULL;
-  /* True if the symbol referred to by this relocation is a local
-     symbol.  */
-  boolean local_p;
-  Elf_Internal_Shdr *symtab_hdr;
-  size_t extsymoff;
-  unsigned long r_symndx;
-  int r_type;
-  /* True if overflow occurred during the calculation of the
-     relocation value.  */
-  boolean overflowed_p;
-  /* True if this relocation refers to a MIPS16 function.  */
-  boolean target_is_16_bit_code_p = false;
-
-  /* Parse the relocation.  */
-  r_symndx = ELF64_R_SYM (relocation->r_info);
-  r_type = ELF64_MIPS_R_TYPE (relocation->r_info);
-  p = (input_section->output_section->vma 
-       + input_section->output_offset
-       + relocation->r_offset);
-
-  /* Assume that there will be no overflow.  */
-  overflowed_p = false;
-
-  /* Figure out whether or not the symbol is local, and get the offset
-     used in the array of hash table entries.  */
-  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
-  local_p = mips_elf64_local_relocation_p (input_bfd, relocation,
-					 local_sections, false);
-  if (! elf_bad_symtab (input_bfd))
-    extsymoff = symtab_hdr->sh_info;
-  else
-    {
-      /* The symbol table does not follow the rule that local symbols
-	 must come before globals.  */
-      extsymoff = 0;
-    }
-
-  /* Figure out the value of the symbol.  */
-  if (local_p)
-    {
-      Elf_Internal_Sym *sym;
-
-      sym = local_syms + r_symndx;
-      sec = local_sections[r_symndx];
-
-      symbol = sec->output_section->vma + sec->output_offset;
-      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
-	symbol += sym->st_value;
-
-      /* MIPS16 text labels should be treated as odd.  */
-      if (sym->st_other == STO_MIPS16)
-	++symbol;
-
-      /* Record the name of this symbol, for our caller.  */
-      *namep = bfd_elf_string_from_elf_section (input_bfd,
-						symtab_hdr->sh_link,
-						sym->st_name);
-      if (*namep == '\0')
-	*namep = bfd_section_name (input_bfd, sec);
-
-      target_is_16_bit_code_p = (sym->st_other == STO_MIPS16);
-    }
-  else
-    {
-      /* For global symbols we look up the symbol in the hash-table.  */
-      h = ((struct mips_elf64_link_hash_entry *) 
-	   elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
-      /* Find the real hash-table entry for this symbol.  */
-      while (h->root.root.type == bfd_link_hash_indirect
-	     || h->root.root.type == bfd_link_hash_warning)
-	h = (struct mips_elf64_link_hash_entry *) h->root.root.u.i.link;
-      
-      /* Record the name of this symbol, for our caller.  */
-      *namep = h->root.root.root.string;
-
-      /* If this symbol is defined, calculate its address.  */
-      if ((h->root.root.type == bfd_link_hash_defined
-	   || h->root.root.type == bfd_link_hash_defweak)
-	  && h->root.root.u.def.section)
-	{
-	  sec = h->root.root.u.def.section;
-	  if (sec->output_section)
-	    symbol = (h->root.root.u.def.value 
-		      + sec->output_section->vma
-		      + sec->output_offset);
-	  else
-	    symbol = h->root.root.u.def.value;
-	}
-      else if (h->root.root.type == bfd_link_hash_undefweak)
-	/* We allow relocations against undefined weak symbols, giving
-	   it the value zero, so that you can undefined weak functions
-	   and check to see if they exist by looking at their
-	   addresses.  */
-	symbol = 0;
-      else if (info->shared
-	       && (!info->symbolic || info->allow_shlib_undefined)
-	       && !info->no_undefined
-	       && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
-	symbol = 0;
-      else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0 ||
-              strcmp (h->root.root.root.string, "_DYNAMIC_LINKING") == 0)
-	{
-	  /* If this is a dynamic link, we should have created a
-	     _DYNAMIC_LINK symbol or _DYNAMIC_LINKING(for normal mips) symbol 
-	     in in mips_elf64_create_dynamic_sections.
-	     Otherwise, we should define the symbol with a value of 0.
-	     FIXME: It should probably get into the symbol table
-	     somehow as well.  */
-	  BFD_ASSERT (! info->shared);
-	  BFD_ASSERT (bfd_get_section_by_name (abfd, ".dynamic") == NULL);
-	  symbol = 0;
-	}
-      else
-	{
-	  if (! ((*info->callbacks->undefined_symbol)
-		 (info, h->root.root.root.string, input_bfd,
-		  input_section, relocation->r_offset,
-		  (!info->shared || info->no_undefined
-		   || ELF_ST_VISIBILITY (h->root.other)))))
-	    return bfd_reloc_undefined;
-	  symbol = 0;
-	}
-
-      target_is_16_bit_code_p = (h->root.other == STO_MIPS16);
-    }
-
-  /* If this is a 64-bit call to a 16-bit function with a stub, we
-     need to redirect the call to the stub, unless we're already *in*
-     a stub.  */
-  if (r_type != R_MIPS16_26 && !info->relocateable
-      && ((h != NULL && h->fn_stub != NULL)
-	  || (local_p && elf_tdata (input_bfd)->local_stubs != NULL
-	      && elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL))
-      && !mips_elf64_stub_section_p (input_bfd, input_section))
-    {
-      /* This is a 64-bit call to a 16-bit function.  We should
-	 have already noticed that we were going to need the
-	 stub.  */
-      if (local_p)
-	sec = elf_tdata (input_bfd)->local_stubs[r_symndx];
-      else
-	{
-	  BFD_ASSERT (h->need_fn_stub);
-	  sec = h->fn_stub;
-	}
-
-      symbol = sec->output_section->vma + sec->output_offset;
-    }
-  /* If this is a 16-bit call to a 64-bit function with a stub, we
-     need to redirect the call to the stub.  */
-  else if (r_type == R_MIPS16_26 && !info->relocateable
-	   && h != NULL
-	   && (h->call_stub != NULL || h->call_fp_stub != NULL)
-	   && !target_is_16_bit_code_p)
-    {
-      /* If both call_stub and call_fp_stub are defined, we can figure
-	 out which one to use by seeing which one appears in the input
-	 file.  */
-      if (h->call_stub != NULL && h->call_fp_stub != NULL)
-	{
-	  asection *o;
-
-	  sec = NULL;
-	  for (o = input_bfd->sections; o != NULL; o = o->next)
-	    {
-	      if (strncmp (bfd_get_section_name (input_bfd, o),
-			   CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
-		{
-		  sec = h->call_fp_stub;
-		  break;
-		}
-	    }
-	  if (sec == NULL)
-	    sec = h->call_stub;
-	}
-      else if (h->call_stub != NULL)
-	sec = h->call_stub;
-      else
-	sec = h->call_fp_stub;
-
-      BFD_ASSERT (sec->_raw_size > 0);
-      symbol = sec->output_section->vma + sec->output_offset;
-    }
-
-  /* Calls from 16-bit code to 32-bit code and vice versa require the
-     special jalx instruction.  */
-  *require_jalxp = (!info->relocateable
-		    && ((r_type == R_MIPS16_26) != target_is_16_bit_code_p));
-
-  local_p = mips_elf64_local_relocation_p (input_bfd, relocation,
-					   local_sections, true);
-
-  /* If we haven't already determined the GOT offset, or the GP value,
-     and we're going to need it, get it now.  */
-  switch (r_type)
-    {
-    case R_MIPS_CALL16:
-    case R_MIPS_GOT16:
-    case R_MIPS_GOT_DISP:
-    case R_MIPS_GOT_HI16:
-    case R_MIPS_CALL_HI16:
-    case R_MIPS_GOT_LO16:
-    case R_MIPS_CALL_LO16:
-      /* Find the index into the GOT where this value is located.  */
-      if (!local_p)
-	{
-	  BFD_ASSERT (addend == 0);
-	  g = mips_elf64_global_got_index (elf_hash_table (info)->dynobj,
-					 (struct elf_link_hash_entry*) h);
-	  if (! elf_hash_table(info)->dynamic_sections_created
-	      || (info->shared
-		  && (info->symbolic || h->root.dynindx == -1)
-		  && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
-	    {
-	      /* This is a static link or a -Bsymbolic link.  The
-		 symbol is defined locally, or was forced to be local.
-		 We must initialize this entry in the GOT.  */
-	      bfd *tmpbfd = elf_hash_table (info)->dynobj;
-
-	      asection *sgot = bfd_get_section_by_name (tmpbfd, ".got");
-	      bfd_put_64 (tmpbfd, symbol + addend, sgot->contents + g);
-	    }
-	}
-      else if (r_type == R_MIPS_GOT16 || r_type == R_MIPS_CALL16)
-	/* There's no need to create a local GOT entry here; the
-	   calculation for a local GOT16 entry does not involve G.  */
-	break;
-      else
-	{
-	  g = mips_elf64_local_got_index (abfd, info, symbol + addend);
-	  if (g == (bfd_vma) -1)
-	    return false;
-	}
-
-      /* Convert GOT indices to actual offsets.  */
-      g = mips_elf64_got_offset_from_index (elf_hash_table (info)->dynobj,
-					    abfd, g);
-      break;
-      
-    case R_MIPS_HI16:
-    case R_MIPS_LO16:
-    case R_MIPS_GPREL16:
-    case R_MIPS_GPREL32:
-    case R_MIPS_LITERAL:
-      gp0 = _bfd_get_gp_value (input_bfd);
-      gp = _bfd_get_gp_value (abfd);
-      break;
-
-    default:
-      break;
-    }
-
-  /* Figure out what kind of relocation is being performed.  */
-  switch (r_type)
-    {
-    case R_MIPS_NONE:
-      return bfd_reloc_continue;
-
-    case R_MIPS_16:
-      value = symbol + mips_elf64_sign_extend (addend, 16);
-      overflowed_p = mips_elf64_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_32:
-    case R_MIPS_REL32:
-    case R_MIPS_64:
-      if ((info->shared
-	   || (elf_hash_table (info)->dynamic_sections_created
-	       && h != NULL
-	       && ((h->root.elf_link_hash_flags
-		    & ELF_LINK_HASH_DEF_DYNAMIC) != 0)
-	       && ((h->root.elf_link_hash_flags
-		    & ELF_LINK_HASH_DEF_REGULAR) == 0)))
-	  && r_symndx != 0
-	  && (input_section->flags & SEC_ALLOC) != 0)
-	{
-	  /* If we're creating a shared library, or this relocation is
-	     against a symbol in a shared library, then we can't know
-	     where the symbol will end up.  So, we create a relocation
-	     record in the output, and leave the job up to the dynamic
-	     linker.  */
-	  value = addend;
-	  if (!mips_elf64_create_dynamic_relocation (abfd, info, relocation,
-						     h, sec, symbol, &value,
-						     input_section))
-	    return false;
-	}
-      else
-	{
-	  if (r_type != R_MIPS_REL32)
-	    value = symbol + addend;
-	  else
-	    value = addend;
-	}
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_PC32:
-    case R_MIPS_PC64:
-    case R_MIPS_GNU_REL_LO16:
-      value = symbol + addend - p;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_GNU_REL16_S2:
-      value = symbol + mips_elf64_sign_extend (addend << 2, 18) - p;
-      overflowed_p = mips_elf64_overflow_p (value, 18);
-      value = (value >> 2) & howto->dst_mask;
-      break;
-
-    case R_MIPS_GNU_REL_HI16:
-      value = mips_elf64_high (addend + symbol - p);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS16_26:
-      /* The calculation for R_MIPS16_26 is just the same as for an
-	 R_MIPS_26.  It's only the storage of the relocated field into
-	 the output file that's different.  That's handled in
-	 mips_elf_perform_relocation.  So, we just fall through to the
-	 R_MIPS_26 case here.  */
-    case R_MIPS_26:
-      if (local_p)
-	value = (((addend << 2) | ((p + 4) & 0xf0000000)) + symbol) >> 2;
-      else
-	value = (mips_elf64_sign_extend (addend << 2, 28) + symbol) >> 2;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_HI16:
-      value = mips_elf64_high (addend + symbol);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_LO16:
-	value = (addend + symbol) & 0xffff;
-	value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_LITERAL:
-      /* Because we don't merge literal sections, we can handle this
-	 just like R_MIPS_GPREL16.  In the long run, we should merge
-	 shared literals, and then we will need to additional work
-	 here.  */
-
-      /* Fall through.  */
-
-    case R_MIPS_GPREL16:
-      if (local_p)
-	value = mips_elf64_sign_extend (addend, 16) + symbol + gp0 - gp;
-      else
-	value = mips_elf64_sign_extend (addend, 16) + symbol - gp;
-      overflowed_p = mips_elf64_overflow_p (value, 16);
-      break;
-      
-    case R_MIPS_PC16:
-      value = mips_elf64_sign_extend (addend, 16) + symbol - p;
-      overflowed_p = mips_elf64_overflow_p (value, 16);
-      value = (bfd_vma) ((bfd_signed_vma) value / 4);
-      break;
-
-    case R_MIPS_GOT16:
-    case R_MIPS_CALL16:
-      if (local_p)
-	{
-	  boolean forced;
-	  
-	  /* The special case is when the symbol is forced to be local.  We
-	     need the full address in the GOT since no R_MIPS_LO16 relocation
-	     follows.  */
-	  forced = ! mips_elf64_local_relocation_p (input_bfd, relocation,
-						  local_sections, false);
-	  value = mips_elf64_got16_entry (abfd, info, symbol + addend, forced);
-	  if (value == (bfd_vma) -1)
-	    return false;
-	  value 
-	    = mips_elf64_got_offset_from_index (elf_hash_table (info)->dynobj,
-					      abfd,
-					      value);
-	  overflowed_p = mips_elf64_overflow_p (value, 16);
-	  break;
-	}
-
-      /* Fall through.  */
-
-    case R_MIPS_GOT_DISP:
-      value = g;
-      overflowed_p = mips_elf64_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_GPREL32:
-      value = (addend + symbol + gp0 - gp) & howto->dst_mask;
-      break;
-
-    case R_MIPS_GOT_HI16:
-    case R_MIPS_CALL_HI16:
-      /* We're allowed to handle these two relocations identically.
-	 The dynamic linker is allowed to handle the CALL relocations
-	 differently by creating a lazy evaluation stub.  */
-      value = g;
-      value = mips_elf64_high (value);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_GOT_LO16:
-    case R_MIPS_CALL_LO16:
-      value = g & howto->dst_mask;
-      break;
-
-    case R_MIPS_GOT_PAGE:
-      value = mips_elf64_got_page (abfd, info, symbol + addend, NULL);
-      if (value == (bfd_vma) -1)
-	return false;
-      value = mips_elf64_got_offset_from_index (elf_hash_table (info)->dynobj,
-					      abfd,
-					      value);
-      overflowed_p = mips_elf64_overflow_p (value, 16);
-      break;
-      
-    case R_MIPS_GOT_OFST:
-      mips_elf64_got_page (abfd, info, symbol + addend, &value);
-      overflowed_p = mips_elf64_overflow_p (value, 16);
-      break;
-
-    case R_MIPS_SUB:
-      value = symbol - addend;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_HIGHER:
-      value = mips_elf64_higher (addend + symbol);
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_HIGHEST:
-      value = mips_elf64_highest (addend + symbol);
-      value &= howto->dst_mask;
-      break;
-      
-    case R_MIPS_SCN_DISP:
-      value = symbol + addend - sec->output_offset;
-      value &= howto->dst_mask;
-      break;
-
-    case R_MIPS_PJUMP:
-    case R_MIPS_JALR:
-      /* Both of these may be ignored.  R_MIPS_JALR is an optimization
-	 hint; we could improve performance by honoring that hint.  */
-      return bfd_reloc_continue;
-
-    case R_MIPS_GNU_VTINHERIT:
-    case R_MIPS_GNU_VTENTRY:
-      /* We don't do anything with these at present.  */
-      return bfd_reloc_continue;
-
-    default:
-      /* An unrecognized relocation type.  */
-      return bfd_reloc_notsupported;
-    }
-
-  /* Store the VALUE for our caller.  */
-  *valuep = value;
-  return overflowed_p ? bfd_reloc_overflow : bfd_reloc_ok;
-}
-
-/* Obtain the field relocated by RELOCATION.  */
-
-static bfd_vma
-mips_elf64_obtain_contents (howto, relocation, input_bfd, contents)
-     reloc_howto_type *howto;
-     const Elf_Internal_Rela *relocation;
-     bfd *input_bfd;
-     bfd_byte *contents;
-{
-  bfd_byte *location = contents + relocation->r_offset;
-
-  /* Obtain the bytes.  */
-  return bfd_get (8 * bfd_get_reloc_size (howto), input_bfd, location);
-}
-
-/* It has been determined that the result of the RELOCATION is the
-   VALUE.  Use HOWTO to place VALUE into the output file at the
-   appropriate position.  The SECTION is the section to which the
-   relocation applies.  If REQUIRE_JALX is true, then the opcode used
-   for the relocation must be either JAL or JALX, and it is
-   unconditionally converted to JALX.
-
-   Returns false if anything goes wrong.  */
-
-static boolean
-mips_elf64_perform_relocation (info, howto, relocation, value,
-			     input_bfd, input_section,
-			     contents, require_jalx)
-     struct bfd_link_info *info;
-     reloc_howto_type *howto;
-     const Elf_Internal_Rela *relocation;
-     bfd_vma value;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     boolean require_jalx;
-{
-  bfd_vma x;
-  bfd_byte *location;
-  int r_type = ELF32_R_TYPE (relocation->r_info);
-
-  /* Figure out where the relocation is occurring.  */
-  location = contents + relocation->r_offset;
-
-  /* Obtain the current value.  */
-  x = mips_elf64_obtain_contents (howto, relocation, input_bfd, contents);
-
-  /* Clear the field we are setting.  */
-  x &= ~howto->dst_mask;
-
-  /* If this is the R_MIPS16_26 relocation, we must store the
-     value in a funny way.  */
-  if (r_type == R_MIPS16_26)
-    {
-      /* R_MIPS16_26 is used for the mips16 jal and jalx instructions.
-	 Most mips16 instructions are 16 bits, but these instructions
-	 are 32 bits.
-
-	 The format of these instructions is:
-
-	 +--------------+--------------------------------+
-	 !     JALX     ! X!   Imm 20:16  !   Imm 25:21  !
-	 +--------------+--------------------------------+
-	 !	  	  Immediate  15:0		    !
-	 +-----------------------------------------------+
-
-	 JALX is the 5-bit value 00011.  X is 0 for jal, 1 for jalx.
-	 Note that the immediate value in the first word is swapped.
-
-	 When producing a relocateable object file, R_MIPS16_26 is
-	 handled mostly like R_MIPS_26.  In particular, the addend is
-	 stored as a straight 26-bit value in a 32-bit instruction.
-	 (gas makes life simpler for itself by never adjusting a
-	 R_MIPS16_26 reloc to be against a section, so the addend is
-	 always zero).  However, the 32 bit instruction is stored as 2
-	 16-bit values, rather than a single 32-bit value.  In a
-	 big-endian file, the result is the same; in a little-endian
-	 file, the two 16-bit halves of the 32 bit value are swapped.
-	 This is so that a disassembler can recognize the jal
-	 instruction.
-
-	 When doing a final link, R_MIPS16_26 is treated as a 32 bit
-	 instruction stored as two 16-bit values.  The addend A is the
-	 contents of the targ26 field.  The calculation is the same as
-	 R_MIPS_26.  When storing the calculated value, reorder the
-	 immediate value as shown above, and don't forget to store the
-	 value as two 16-bit values.
-
-	 To put it in MIPS ABI terms, the relocation field is T-targ26-16,
-	 defined as
-
-	 big-endian:
-	 +--------+----------------------+
-	 |        |                      |
-	 |        |    targ26-16         |
-	 |31    26|25                   0|
-	 +--------+----------------------+
-
-	 little-endian:
-	 +----------+------+-------------+
-	 |          |      |             |
-	 |  sub1    |      |     sub2    |
-	 |0        9|10  15|16         31|
-	 +----------+--------------------+
-	 where targ26-16 is sub1 followed by sub2 (i.e., the addend field A is
-	 ((sub1 << 16) | sub2)).
-
-	 When producing a relocateable object file, the calculation is
-	 (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2)
-	 When producing a fully linked file, the calculation is
-	 let R = (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2)
-	 ((R & 0x1f0000) << 5) | ((R & 0x3e00000) >> 5) | (R & 0xffff)  */
-
-      if (!info->relocateable)
-	/* Shuffle the bits according to the formula above.  */
-	value = (((value & 0x1f0000) << 5)
-		 | ((value & 0x3e00000) >> 5)
-		 | (value & 0xffff));
-    }
-  else if (r_type == R_MIPS16_GPREL)
-    {
-      /* R_MIPS16_GPREL is used for GP-relative addressing in mips16
-	 mode.  A typical instruction will have a format like this:
-
-	 +--------------+--------------------------------+
-	 !    EXTEND    !     Imm 10:5    !   Imm 15:11  !
-	 +--------------+--------------------------------+
-	 !    Major     !   rx   !   ry   !   Imm  4:0   !
-	 +--------------+--------------------------------+
-
-	 EXTEND is the five bit value 11110.  Major is the instruction
-	 opcode.
-
-	 This is handled exactly like R_MIPS_GPREL16, except that the
-	 addend is retrieved and stored as shown in this diagram; that
-	 is, the Imm fields above replace the V-rel16 field.
-
-         All we need to do here is shuffle the bits appropriately.  As
-	 above, the two 16-bit halves must be swapped on a
-	 little-endian system.  */
-      value = (((value & 0x7e0) << 16)
-	       | ((value & 0xf800) << 5)
-	       | (value & 0x1f));
-    }
-
-  /* Set the field.  */
-  x |= (value & howto->dst_mask);
-
-  /* If required, turn JAL into JALX.  */
-  if (require_jalx)
-    {
-      boolean ok;
-      bfd_vma opcode = x >> 26;
-      bfd_vma jalx_opcode;
-
-      /* Check to see if the opcode is already JAL or JALX.  */
-      if (r_type == R_MIPS16_26)
-	{
-	  ok = ((opcode == 0x6) || (opcode == 0x7));
-	  jalx_opcode = 0x7;
-	}
-      else
-	{
-	  ok = ((opcode == 0x3) || (opcode == 0x1d));
-	  jalx_opcode = 0x1d;
-	}
-
-      /* If the opcode is not JAL or JALX, there's a problem.  */
-      if (!ok)
-	{
-	  (*_bfd_error_handler)
-	    (_("%s: %s+0x%lx: jump to stub routine which is not jal"),
-	     bfd_archive_filename (input_bfd),
-	     input_section->name,
-	     (unsigned long) relocation->r_offset);
-	  bfd_set_error (bfd_error_bad_value);
-	  return false;
-	}
-
-      /* Make this the JALX opcode.  */
-      x = (x & ~(0x3f << 26)) | (jalx_opcode << 26);
-    }
-
-  /* Swap the high- and low-order 16 bits on little-endian systems
-     when doing a MIPS16 relocation.  */
-  if ((r_type == R_MIPS16_GPREL || r_type == R_MIPS16_26)
-      && bfd_little_endian (input_bfd))
-    x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
-
-  /* Put the value into the output.  */
-  bfd_put (8 * bfd_get_reloc_size (howto), input_bfd, x, location);
-  return true;
-}
-
-/* Returns true if SECTION is a MIPS16 stub section.  */
-
-static boolean
-mips_elf64_stub_section_p (abfd, section)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *section;
-{
-  const char *name = bfd_get_section_name (abfd, section);
-
-  return (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0
-	  || strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
-	  || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0);
-}
-
-/* Relocate a MIPS ELF64 section.  */
-
-static boolean
-mips_elf64_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_Rela *rel;
-  const Elf_Internal_Rela *relend;
-  bfd_vma addend = 0;
-  boolean use_saved_addend_p = false;
-  struct elf_backend_data *bed;
-
-  bed = get_elf_backend_data (output_bfd);
-  relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
-  for (rel = relocs; rel < relend; ++rel)
-    {
-      const char *name;
-      bfd_vma value;
-      reloc_howto_type *howto;
-      boolean require_jalx;
-      /* True if the relocation is a RELA relocation, rather than a
-         REL relocation.  */
-      boolean rela_relocation_p = true;
-      int r_type = ELF64_MIPS_R_TYPE (rel->r_info);
-      const char *msg = (const char *) NULL;
-
-      /* Find the relocation howto for this relocation.  */
-      howto = &mips_elf64_howto_table_rela[r_type];
-
-      if (!use_saved_addend_p)
-	{
-	  Elf_Internal_Shdr *rel_hdr;
-
-	  /* If these relocations were originally of the REL variety,
-	     we must pull the addend out of the field that will be
-	     relocated.  Otherwise, we simply use the contents of the
-	     RELA relocation.  To determine which flavor or relocation
-	     this is, we depend on the fact that the INPUT_SECTION's
-	     REL_HDR is read before its REL_HDR2.  */
-	  rel_hdr = &elf_section_data (input_section)->rel_hdr;
-	  if ((size_t) (rel - relocs)
-	      >= (NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel))
-	    rel_hdr = elf_section_data (input_section)->rel_hdr2;
-	  if (rel_hdr->sh_entsize
-	      == (get_elf_backend_data (input_bfd)->s->sizeof_rel))
-	    {
-	      /* Note that this is a REL relocation.  */
-	      rela_relocation_p = false;
-
-	      /* Find the relocation howto for this relocation.  */
-	      howto = &mips_elf64_howto_table_rel[r_type];
-
-	      /* Get the addend, which is stored in the input file.  */
-	      addend = mips_elf64_obtain_contents (howto, 
-						   rel,
-						   input_bfd,
-						   contents);
-	      addend &= howto->src_mask;
-
-	      /* For some kinds of relocations, the ADDEND is a
-		 combination of the addend stored in two different
-		 relocations.   */
-	      if (r_type == R_MIPS_HI16
-		  || r_type == R_MIPS_GNU_REL_HI16
-		  || (r_type == R_MIPS_GOT16
-		      && mips_elf64_local_relocation_p (input_bfd, rel,
-						      local_sections, false)))
-		{
-		  bfd_vma l;
-		  const Elf_Internal_Rela *lo16_relocation;
-		  reloc_howto_type *lo16_howto;
-		  int lo;
-
-		  /* The combined value is the sum of the HI16 addend,
-		     left-shifted by sixteen bits, and the LO16
-		     addend, sign extended.  (Usually, the code does
-		     a `lui' of the HI16 value, and then an `addiu' of
-		     the LO16 value.)  
-
-		     Scan ahead to find a matching LO16 relocation.  */
-		  if (r_type == R_MIPS_GNU_REL_HI16)
-		    lo = R_MIPS_GNU_REL_LO16;
-		  else
-		    lo = R_MIPS_LO16;
-		  lo16_relocation 
-		    = mips_elf64_next_relocation (lo, rel, relend); 
-		  if (lo16_relocation == NULL)
-		    return false;
-
-		  /* Obtain the addend kept there.  */
-		  if (rela_relocation_p == false)
-		    lo16_howto = &mips_elf64_howto_table_rel[lo];
-		  else
-		    lo16_howto = &mips_elf64_howto_table_rela[lo];
-		  l = mips_elf64_obtain_contents (lo16_howto,
-						lo16_relocation,
-						input_bfd, contents);
-		  l &= lo16_howto->src_mask;
-		  l = mips_elf64_sign_extend (l, 16);
-
-		  addend <<= 16;
-
-		  /* Compute the combined addend.  */
-		  addend += l;
-		}
-	    }
-	  else
-	    addend = rel->r_addend;
-	}
-
-      if (info->relocateable)
-	{
-	  Elf_Internal_Sym *sym;
-	  unsigned long r_symndx;
-
-	  /* Since we're just relocating, all we need to do is copy
-	     the relocations back out to the object file, unless
-	     they're against a section symbol, in which case we need
-	     to adjust by the section offset, or unless they're GP
-	     relative in which case we need to adjust by the amount
-	     that we're adjusting GP in this relocateable object.  */
-
-	  if (!mips_elf64_local_relocation_p (input_bfd, rel, local_sections,
-					    false))
-	    /* There's nothing to do for non-local relocations.  */
-	    continue;
-
-	  if (r_type == R_MIPS_GPREL16
-	      || r_type == R_MIPS_GPREL32
-	      || r_type == R_MIPS_LITERAL)
-	    addend -= (_bfd_get_gp_value (output_bfd)
-		       - _bfd_get_gp_value (input_bfd));
-	  else if (r_type == R_MIPS_26 || r_type == R_MIPS_GNU_REL16_S2)
-	    /* The addend is stored without its two least
-	       significant bits (which are always zero.)  In a
-	       non-relocateable link, calculate_relocation will do
-	       this shift; here, we must do it ourselves.  */
-	    addend <<= 2;
-
-	  r_symndx = ELF64_R_SYM (rel->r_info);
-	  sym = local_syms + r_symndx;
-	  if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
-	    /* Adjust the addend appropriately.  */
-	    addend += local_sections[r_symndx]->output_offset;
-
-#if 0
-	  /* If the relocation is for a R_MIPS_HI16 or R_MIPS_GOT16,
-	     then we only want to write out the high-order 16 bits.
-	     The subsequent R_MIPS_LO16 will handle the low-order bits.  */
-	  if (r_type == R_MIPS_HI16 || r_type == R_MIPS_GOT16
-	      || r_type == R_MIPS_GNU_REL_HI16)
-	    addend = mips_elf64_high (addend);
-	  else if (r_type == R_MIPS_HIGHER)
-	    addend = mips_elf64_higher (addend);
-	  else if (r_type == R_MIPS_HIGHEST)
-	    addend = mips_elf64_highest (addend);
-#endif
-	  /* If the relocation is for an R_MIPS_26 relocation, then
-	     the two low-order bits are not stored in the object file;
-	     they are implicitly zero.  */
-	  if (r_type == R_MIPS_26 || r_type == R_MIPS_GNU_REL16_S2)
-	    addend >>= 2;
-
-	  if (rela_relocation_p)
-	    /* If this is a RELA relocation, just update the addend.
-	       We have to cast away constness for REL.  */
-	    rel->r_addend = addend;
-	  else
-	    {
-	      /* Otherwise, we have to write the value back out.  Note
-		 that we use the source mask, rather than the
-		 destination mask because the place to which we are
-		 writing will be source of the addend in the final
-		 link.  */
-	      addend &= howto->src_mask;
-
-	      if (!mips_elf64_perform_relocation (info, howto, rel, addend,
-						  input_bfd, input_section,
-						  contents, false))
-		return false;
-	    }
-
-	  /* Go on to the next relocation.  */
-	  continue;
-	}
-
-      /* In the N32 and 64-bit ABIs there may be multiple consecutive
-	 relocations for the same offset.  In that case we are
-	 supposed to treat the output of each relocation as the addend
-	 for the next.  */
-      if (rel + 1 < relend 
-	  && rel->r_offset == rel[1].r_offset
-	  && ELF64_MIPS_R_TYPE (rel[1].r_info) != R_MIPS_NONE)
-	use_saved_addend_p = true;
-      else
-	use_saved_addend_p = false;
-
-      /* Figure out what value we are supposed to relocate.  */
-      switch (mips_elf64_calculate_relocation (output_bfd, input_bfd,
-					       input_section, info, rel,
-					       addend, howto, local_syms,
-					       local_sections, &value, &name,
-					       &require_jalx))
-	{
-	case bfd_reloc_continue:
-	  /* There's nothing to do.  */
-	  continue;
-
-	case bfd_reloc_undefined:
-	  /* mips_elf64_calculate_relocation already called the
-	     undefined_symbol callback.  There's no real point in
-	     trying to perform the relocation at this point, so we
-	     just skip ahead to the next relocation.  */
-	  continue;
-
-	case bfd_reloc_notsupported:
-	  msg = _("internal error: unsupported relocation error");
-	  info->callbacks->warning
-	    (info, msg, name, input_bfd, input_section, rel->r_offset);
-	  return false;
-
-	case bfd_reloc_overflow:
-	  if (use_saved_addend_p)
-	    /* Ignore overflow until we reach the last relocation for
-	       a given location.  */
-	    ;
-	  else
-	    {
-	      BFD_ASSERT (name != NULL);
-	      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_ok:
-	  break;
-
-	default:
-	  abort ();
-	  break;
-	}
-
-      /* If we've got another relocation for the address, keep going
-	 until we reach the last one.  */
-      if (use_saved_addend_p)
-	{
-	  addend = value;
-	  continue;
-	}
-
-      /* Actually perform the relocation.  */
-      if (!mips_elf64_perform_relocation (info, howto, rel, value, input_bfd,
-					  input_section, contents,
-					  require_jalx))
-	return false;
-    }
-
-  return true;
-}
-
-/* Create dynamic sections when linking against a dynamic object.  */
-
-boolean
-mips_elf64_create_dynamic_sections (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
-{
-  flagword flags;
-  register asection *s;
-
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
-	   | SEC_LINKER_CREATED | SEC_READONLY);
-
-  /* Mips ABI requests the .dynamic section to be read only.  */
-  s = bfd_get_section_by_name (abfd, ".dynamic");
-  if (s != NULL)
-    {
-      if (! bfd_set_section_flags (abfd, s, flags))
-	return false;
-    }
-
-  /* We need to create .got section.  */
-  if (! mips_elf64_create_got_section (abfd, info))
-    return false;
-
-  /* Create the .msym section on IRIX6.  It is used by the dynamic
-     linker to speed up dynamic relocations, and to avoid computing
-     the ELF hash for symbols.  */
-  if (!mips_elf64_create_msym_section (abfd))
-    return false;
-
-  /* Create .stub section.  */
-  if (bfd_get_section_by_name (abfd, ".MIPS.stubs") == NULL)
-    {
-      s = bfd_make_section (abfd, ".MIPS.stubs");
-      if (s == NULL
-	  || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
-	  || ! bfd_set_section_alignment (abfd, s, 3))
-	return false;
-    }
-
-  return true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
-   regular object.  The current definition is in some section of the
-   dynamic object, but we're not including those sections.  We have to
-   change the definition to something the rest of the link can
-   understand.  */
-
-boolean
-mips_elf64_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-{
-  bfd *dynobj;
-  struct mips_elf64_link_hash_entry *hmips;
-  asection *s;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
-  /* Make sure we know what is going on here.  */
-  BFD_ASSERT (dynobj != NULL
-	      && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
-		  || h->weakdef != NULL
-		  || ((h->elf_link_hash_flags
-		       & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-		      && (h->elf_link_hash_flags
-			  & ELF_LINK_HASH_REF_REGULAR) != 0
-		      && (h->elf_link_hash_flags
-			  & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
-  /* If this symbol is defined in a dynamic object, we need to copy
-     any R_MIPS_32 or R_MIPS_REL32 relocs against it into the output
-     file.  */
-  hmips = (struct mips_elf64_link_hash_entry *) h;
-  if (! info->relocateable
-      && hmips->possibly_dynamic_relocs != 0
-      && (h->root.type == bfd_link_hash_defweak
-	  || (h->elf_link_hash_flags
-	      & ELF_LINK_HASH_DEF_REGULAR) == 0))
-    {
-      mips_elf64_allocate_dynamic_relocations (dynobj,
-					       hmips->possibly_dynamic_relocs);
-      if (hmips->readonly_reloc)
-	/* We tell the dynamic linker that there are relocations
-	   against the text segment.  */
-	info->flags |= DF_TEXTREL;
-    }
-
-  /* For a function, create a stub, if allowed.  */
-  if (! hmips->no_fn_stub
-      && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
-    {
-      if (! elf_hash_table (info)->dynamic_sections_created)
-	return true;
-
-      /* If this symbol is not defined in a regular file, then set
-	 the symbol to the stub location.  This is required to make
-	 function pointers compare as equal between the normal
-	 executable and the shared library.  */
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
-	{
-	  /* We need .stub section.  */
-	  s = bfd_get_section_by_name (dynobj, ".MIPS.stubs");
-	  BFD_ASSERT (s != NULL);
-
-	  h->root.u.def.section = s;
-	  h->root.u.def.value = s->_raw_size;
-
-	  /* XXX Write this stub address somewhere.  */
-	  h->plt.offset = s->_raw_size;
-
-	  /* Make room for this stub code.  */
-	  s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
-
-	  /* The last half word of the stub will be filled with the index
-	     of this symbol in .dynsym section.  */
-	  return true;
-	}
-    }
-  else if ((h->type == STT_FUNC)
-	   && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
-    {
-      /* This will set the entry for this symbol in the GOT to 0, and
-         the dynamic linker will take care of this.  */
-      h->root.u.def.value = 0;
-      return true;
-    }
-
-  /* If this is a weak symbol, and there is a real definition, the
-     processor independent code will have arranged for us to see the
-     real definition first, and we can just use the same value.  */
-  if (h->weakdef != NULL)
-    {
-      BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
-		  || h->weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->weakdef->root.u.def.section;
-      h->root.u.def.value = h->weakdef->root.u.def.value;
-      return true;
-    }
-
-  /* This is a reference to a symbol defined by a dynamic object which
-     is not a function.  */
-
-  return true;
-}
-
-/* This function is called after all the input files have been read,
-   and the input sections have been assigned to output sections.  */
-
-boolean
-mips_elf64_always_size_sections (output_bfd, info)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-{
-  if (info->relocateable
-      || ! mips_elf64_hash_table (info)->mips16_stubs_seen)
-    return true;
-
-  mips_elf64_link_hash_traverse (mips_elf64_hash_table (info),
-				 mips_elf64_check_mips16_stubs,
-				 (PTR) NULL);
-
-  return true;
-}
-
-/* Check the mips16 stubs for a particular symbol, and see if we can
-   discard them.  */
-
-static boolean
-mips_elf64_check_mips16_stubs (h, data)
-     struct mips_elf64_link_hash_entry *h;
-     PTR data ATTRIBUTE_UNUSED;
-{
-  if (h->fn_stub != NULL
-      && ! h->need_fn_stub)
-    {
-      /* We don't need the fn_stub; the only references to this symbol
-         are 16 bit calls.  Clobber the size to 0 to prevent it from
-         being included in the link.  */
-      h->fn_stub->_raw_size = 0;
-      h->fn_stub->_cooked_size = 0;
-      h->fn_stub->flags &= ~SEC_RELOC;
-      h->fn_stub->reloc_count = 0;
-      h->fn_stub->flags |= SEC_EXCLUDE;
-    }
-
-  if (h->call_stub != NULL
-      && h->root.other == STO_MIPS16)
-    {
-      /* We don't need the call_stub; this is a 16 bit function, so
-         calls from other 16 bit functions are OK.  Clobber the size
-         to 0 to prevent it from being included in the link.  */
-      h->call_stub->_raw_size = 0;
-      h->call_stub->_cooked_size = 0;
-      h->call_stub->flags &= ~SEC_RELOC;
-      h->call_stub->reloc_count = 0;
-      h->call_stub->flags |= SEC_EXCLUDE;
-    }
-
-  if (h->call_fp_stub != NULL
-      && h->root.other == STO_MIPS16)
-    {
-      /* We don't need the call_stub; this is a 16 bit function, so
-         calls from other 16 bit functions are OK.  Clobber the size
-         to 0 to prevent it from being included in the link.  */
-      h->call_fp_stub->_raw_size = 0;
-      h->call_fp_stub->_cooked_size = 0;
-      h->call_fp_stub->flags &= ~SEC_RELOC;
-      h->call_fp_stub->reloc_count = 0;
-      h->call_fp_stub->flags |= SEC_EXCLUDE;
-    }
-
-  return true;
-}
-
-/* Set the sizes of the dynamic sections.  */
-
-boolean
-mips_elf64_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-{
-  bfd *dynobj;
-  asection *s;
-  boolean reltext;
-  struct mips_elf64_got_info *g = NULL;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  BFD_ASSERT (dynobj != NULL);
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
-	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
-	  BFD_ASSERT (s != NULL);
-	  s->_raw_size = strlen ("/usr/lib64/libc.so.1") + 1;
-	  s->contents = (bfd_byte *) "/usr/lib64/libc.so.1";
-	}
-    }
-
-  /* The check_relocs and adjust_dynamic_symbol entry points have
-     determined the sizes of the various dynamic sections.  Allocate
-     memory for them.  */
-  reltext = false;
-  for (s = dynobj->sections; s != NULL; s = s->next)
-    {
-      const char *name;
-      boolean strip;
-
-      /* It's OK to base decisions on the section name, because none
-	 of the dynobj section names depend upon the input files.  */
-      name = bfd_get_section_name (dynobj, s);
-
-      if ((s->flags & SEC_LINKER_CREATED) == 0)
-	continue;
-
-      strip = false;
-
-      if (strncmp (name, ".rel", 4) == 0)
-	{
-	  if (s->_raw_size == 0)
-	    {
-	      /* We only strip the section if the output section name
-                 has the same name.  Otherwise, there might be several
-                 input sections for this output section.  FIXME: This
-                 code is probably not needed these days anyhow, since
-                 the linker now does not create empty output sections.  */
-	      if (s->output_section != NULL
-		  && strcmp (name,
-			     bfd_get_section_name (s->output_section->owner,
-						   s->output_section)) == 0)
-		strip = true;
-	    }
-	  else
-	    {
-	      const char *outname;
-	      asection *target;
-
-	      /* If this relocation section applies to a read only
-                 section, then we probably need a DT_TEXTREL entry.
-                 If the relocation section is .rel.dyn, we always
-                 assert a DT_TEXTREL entry rather than testing whether
-                 there exists a relocation to a read only section or
-                 not.  */
-	      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
-		   && (target->flags & SEC_ALLOC) != 0)
-		  || strcmp (outname, "rel.dyn") == 0)
-		reltext = true;
-
-	      /* We use the reloc_count field as a counter if we need
-		 to copy relocs into the output file.  */
-	      if (strcmp (name, "rel.dyn") != 0)
-		s->reloc_count = 0;
-	    }
-	}
-      else if (strncmp (name, ".got", 4) == 0)
-	{
-	  int i;
-	  bfd_size_type loadable_size = 0;
-	  bfd_size_type local_gotno;
-	  bfd *sub;
-
-	  BFD_ASSERT (elf_section_data (s) != NULL);
-	  g = (struct mips_elf64_got_info *) elf_section_data (s)->tdata;
-	  BFD_ASSERT (g != NULL);
-
-	  /* Calculate the total loadable size of the output.  That
-	     will give us the maximum number of GOT_PAGE entries
-	     required.  */
-	  for (sub = info->input_bfds; sub; sub = sub->link_next)
-	    {
-	      asection *subsection;
-
-	      for (subsection = sub->sections;
-		   subsection;
-		   subsection = subsection->next)
-		{
-		  if ((subsection->flags & SEC_ALLOC) == 0)
-		    continue;
-		  loadable_size += (subsection->_raw_size + 0xf) & ~0xf;
-		}
-	    }
-	  loadable_size += MIPS_FUNCTION_STUB_SIZE;
-
-	  /* Assume there are two loadable segments consisting of
-	     contiguous sections.  Is 5 enough?  */
-	  local_gotno = (loadable_size >> 16) + 5;
-	    /* It's possible we will need GOT_PAGE entries as well as
-	       GOT16 entries.  Often, these will be able to share GOT
-	       entries, but not always.  */
-	    local_gotno *= 2;
-
-	  g->local_gotno += local_gotno;
-	  s->_raw_size += local_gotno * 8;
-
-	  /* There has to be a global GOT entry for every symbol with
-	     a dynamic symbol table index of DT_MIPS_GOTSYM or
-	     higher.  Therefore, it make sense to put those symbols
-	     that need GOT entries at the end of the symbol table.  We
-	     do that here.  */
- 	  if (!mips_elf64_sort_hash_table (info, 1))
- 	    return false;
-
-	  if (g->global_gotsym != NULL)
-	    i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx;
-	  else
-	    /* If there are no global symbols, or none requiring
-	       relocations, then GLOBAL_GOTSYM will be NULL.  */
-	    i = 0;
-	  g->global_gotno = i;
-	  s->_raw_size += i * 8;
-	}
-      else if (strcmp (name, ".MIPS.stubs") == 0)
-	{
-	  /* Irix rld assumes that the function stub isn't at the end
-	     of .text section. So put a dummy. XXX  */
-	  s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
-	}
-      else if (strcmp (name, ".msym")
-	       == 0)
-	s->_raw_size = (sizeof (Elf32_External_Msym)
-			* (elf_hash_table (info)->dynsymcount
-			   + bfd_count_sections (output_bfd)));
-      else if (strncmp (name, ".init", 5) != 0)
-	{
-	  /* It's not one of our sections, so don't allocate space.  */
-	  continue;
-	}
-
-      if (strip)
-	{
-	  _bfd_strip_section_from_output (info, s);
-	  continue;
-	}
-
-      /* Allocate memory for the section contents.  */
-      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
-      if (s->contents == NULL && s->_raw_size != 0)
-	{
-	  bfd_set_error (bfd_error_no_memory);
-	  return false;
-	}
-    }
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-	 values later, in elf_mips_finish_dynamic_sections, but we
-	 must add the entries now so that we get the correct size for
-	 the .dynamic section.  The DT_DEBUG entry is filled in by the
-	 dynamic linker and used by the debugger.  */
-      if (! info->shared)
-	{
-	  /* SGI object has the equivalence of DT_DEBUG in the
-	     DT_MIPS_RLD_MAP entry.  */
-	  if (!bfd_elf64_add_dynamic_entry (info, DT_MIPS_RLD_MAP, 0))
-	    return false;
-	  if (!SGI_COMPAT (output_bfd))
-	    {
-	      if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
-		return false;
-	    }
-	}
-      else
-	{
-	  /* Shared libraries on traditional mips have DT_DEBUG.  */
-	  if (!SGI_COMPAT (output_bfd))
-	    {
-	      if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
-		return false;
-	    }
-	}
-
-      if (reltext && SGI_COMPAT (output_bfd))
-	info->flags |= DF_TEXTREL;
-
-      if ((info->flags & DF_TEXTREL) != 0)
-	{
-	  if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
-	    return false;
-	}
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0))
-	return false;
-
-      if (bfd_get_section_by_name (dynobj, "rel.dyn"))
-	{
-	  if (! bfd_elf64_add_dynamic_entry (info, DT_REL, 0))
-	    return false;
-
-	  if (! bfd_elf64_add_dynamic_entry (info, DT_RELSZ, 0))
-	    return false;
-
-	  if (! bfd_elf64_add_dynamic_entry (info, DT_RELENT, 0))
-	    return false;
-	}
-
-      if (SGI_COMPAT (output_bfd))
-	{
-	  if (!bfd_elf64_add_dynamic_entry (info, DT_MIPS_CONFLICTNO, 0))
-	    return false;
-	}
-
-      if (SGI_COMPAT (output_bfd))
-	{
-	  if (!bfd_elf64_add_dynamic_entry (info, DT_MIPS_LIBLISTNO, 0))
-	    return false;
-	}
-
-      if (bfd_get_section_by_name (dynobj, ".conflict") != NULL)
-	{
-	  if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_CONFLICT, 0))
-	    return false;
-
-	  s = bfd_get_section_by_name (dynobj, ".liblist");
-	  BFD_ASSERT (s != NULL);
-
-	  if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_LIBLIST, 0))
-	    return false;
-	}
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_RLD_VERSION, 0))
-	return false;
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_FLAGS, 0))
-	return false;
-
-#if 0
-      /* Time stamps in executable files are a bad idea.  */
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_TIME_STAMP, 0))
-	return false;
-#endif
-
-#if 0 /* FIXME  */
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_ICHECKSUM, 0))
-	return false;
-#endif
-
-#if 0 /* FIXME  */
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_IVERSION, 0))
-	return false;
-#endif
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_BASE_ADDRESS, 0))
-	return false;
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_LOCAL_GOTNO, 0))
-	return false;
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_SYMTABNO, 0))
-	return false;
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_UNREFEXTNO, 0))
-	return false;
-
-      if (! bfd_elf64_add_dynamic_entry (info, DT_MIPS_GOTSYM, 0))
-	return false;
-
-      if ((bfd_get_section_by_name(dynobj, ".MIPS.options"))
-	  && !bfd_elf64_add_dynamic_entry (info, DT_MIPS_OPTIONS, 0))
-	return false;
-
-      if (bfd_get_section_by_name (dynobj, ".msym")
-	  && !bfd_elf64_add_dynamic_entry (info, DT_MIPS_MSYM, 0))
-	return false;
-    }
-
-  return true;
-}
-
-/* Finish up dynamic symbol handling.  We set the contents of various
-   dynamic sections here.  */
-
-boolean
-mips_elf64_finish_dynamic_symbol (output_bfd, info, h, sym)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
-{
-  bfd *dynobj;
-  bfd_vma gval;
-  asection *sgot;
-  asection *smsym;
-  struct mips_elf64_got_info *g;
-  const char *name;
-  struct mips_elf64_link_hash_entry *mh;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  gval = sym->st_value;
-  mh = (struct mips_elf64_link_hash_entry *) h;
-
-  if (h->plt.offset != (bfd_vma) -1)
-    {
-      asection *s;
-      bfd_byte stub[MIPS_FUNCTION_STUB_SIZE];
-
-      /* This symbol has a stub.  Set it up.  */
-
-      BFD_ASSERT (h->dynindx != -1);
-
-      s = bfd_get_section_by_name (dynobj, ".MIPS.stubs");
-      BFD_ASSERT (s != NULL);
-
-      /* FIXME: Can h->dynindex be more than 64K?  */
-      if (h->dynindx & 0xffff0000)
-	return false;
-
-      /* Fill the stub.  */
-      bfd_put_32 (output_bfd, STUB_LW, stub);
-      bfd_put_32 (output_bfd, STUB_MOVE, stub + 4);
-      bfd_put_32 (output_bfd, STUB_JALR, stub + 8);
-      bfd_put_32 (output_bfd, STUB_LI16 + h->dynindx, stub + 12);
-
-      BFD_ASSERT (h->plt.offset <= s->_raw_size);
-      memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
-
-      /* Mark the symbol as undefined.  plt.offset != -1 occurs
-	 only for the referenced symbol.  */
-      sym->st_shndx = SHN_UNDEF;
-
-      /* The run-time linker uses the st_value field of the symbol
-	 to reset the global offset table entry for this external
-	 to its stub address when unlinking a shared object.  */
-      gval = s->output_section->vma + s->output_offset + h->plt.offset;
-      sym->st_value = gval;
-    }
-
-  BFD_ASSERT (h->dynindx != -1
-	      || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0);
-
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  BFD_ASSERT (sgot != NULL);
-  BFD_ASSERT (elf_section_data (sgot) != NULL);
-  g = (struct mips_elf64_got_info *) elf_section_data (sgot)->tdata;
-  BFD_ASSERT (g != NULL);
-
-  /* Run through the global symbol table, creating GOT entries for all
-     the symbols that need them.  */
-  if (g->global_gotsym != NULL
-      && h->dynindx >= g->global_gotsym->dynindx)
-    {
-      bfd_vma offset;
-      bfd_vma value;
-
-      if (sym->st_value)
-	value = sym->st_value;
-      else
-	{
-	  /* For an entity defined in a shared object, this will be
-	     NULL.  (For functions in shared objects for
-	     which we have created stubs, ST_VALUE will be non-NULL.
-	     That's because such the functions are now no longer defined
-	     in a shared object.)  */
-
-	  if (info->shared && h->root.type == bfd_link_hash_undefined)
-	    value = 0;
-	  else
-	    value = h->root.u.def.value;
-	}
-      offset = mips_elf64_global_got_index (dynobj, h);
-      bfd_put_64 (output_bfd, value, sgot->contents + offset);
-    }
-
-  /* Create a .msym entry, if appropriate.  */
-  smsym = bfd_get_section_by_name (dynobj, ".msym");
-  if (smsym)
-    {
-      Elf32_Internal_Msym msym;
-
-      msym.ms_hash_value = bfd_elf_hash (h->root.root.string);
-      /* It is undocumented what the `1' indicates, but IRIX6 uses
-	 this value.  */
-      msym.ms_info = ELF32_MS_INFO (mh->min_dyn_reloc_index, 1);
-      mips_elf64_swap_msym_out
-	(dynobj, &msym,
-	 ((Elf32_External_Msym *) smsym->contents) + h->dynindx);
-    }
-
-  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  name = h->root.root.string;
-  if (strcmp (name, "_DYNAMIC") == 0
-      || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
-    sym->st_shndx = SHN_ABS;
-  else if (strcmp (name, "_DYNAMIC_LINK") == 0
-	   || strcmp (name, "_DYNAMIC_LINKING") == 0)
-    {
-      sym->st_shndx = SHN_ABS;
-      sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-      sym->st_value = 1;
-    }
-  else if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS)
-    {
-      if (h->type == STT_FUNC)
-	sym->st_shndx = SHN_MIPS_TEXT;
-      else if (h->type == STT_OBJECT)
-	sym->st_shndx = SHN_MIPS_DATA;
-    }
-
-  /* Handle the IRIX6-specific symbols.  */
-
-    {
-  /* The linker script takes care of providing names and values for
-     these, but we must place them into the right sections.  */
-  static const char* const text_section_symbols[] = {
-    "_ftext",
-    "_etext",
-    "__dso_displacement",
-    "__elf_header",
-    "__program_header_table",
-    NULL
-  };
-
-  static const char* const data_section_symbols[] = {
-    "_fdata",
-    "_edata",
-    "_end",
-    "_fbss",
-    NULL
-  };
-
-  const char* const *p;
-  int i;
-
-  for (i = 0; i < 2; ++i)
-    for (p = (i == 0) ? text_section_symbols : data_section_symbols;
-	 *p;
-	 ++p)
-      if (strcmp (*p, name) == 0)
-	{
-	  /* All of these symbols are given type STT_SECTION by the
-	     IRIX6 linker.  */
-	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
-
-	  /* The IRIX linker puts these symbols in special sections.  */
-	  if (i == 0)
-	    sym->st_shndx = SHN_MIPS_TEXT;
-	  else
-	    sym->st_shndx = SHN_MIPS_DATA;
-
-	  break;
-	}
-    }
-
-  return true;
-}
-
-/* Finish up the dynamic sections.  */
-
-boolean
-mips_elf64_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-{
-  bfd *dynobj;
-  asection *sdyn;
-  asection *sgot;
-  struct mips_elf64_got_info *g;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  if (sgot == NULL)
-    g = NULL;
-  else
-    {
-      BFD_ASSERT (elf_section_data (sgot) != NULL);
-      g = (struct mips_elf64_got_info *) elf_section_data (sgot)->tdata;
-      BFD_ASSERT (g != NULL);
-    }
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      bfd_byte *b;
-
-      BFD_ASSERT (sdyn != NULL);
-      BFD_ASSERT (g != NULL);
-
-      for (b = sdyn->contents;
-	   b < sdyn->contents + sdyn->_raw_size;
-	   b += get_elf_backend_data (dynobj)->s->sizeof_dyn)
-	{
-	  Elf_Internal_Dyn dyn;
-	  const char *name;
-	  size_t elemsize;
-	  asection *s;
-	  boolean swap_out_p;
-
-	  /* Read in the current dynamic entry.  */
-	  (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
-
-	  /* Assume that we're going to modify it and write it out.  */
-	  swap_out_p = true;
-
-	  switch (dyn.d_tag)
-	    {
-	    case DT_RELENT:
-	      s = bfd_get_section_by_name(dynobj, "rel.dyn");
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_val = get_elf_backend_data (dynobj)->s->sizeof_rel;
-	      break;
-
-	    case DT_STRSZ:
-	      /* Rewrite DT_STRSZ.  */
-	      dyn.d_un.d_val =
-		_bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
-	      break;
-
-	    case DT_PLTGOT:
-	      name = ".got";
-	      goto get_vma;
-	    case DT_MIPS_CONFLICT:
-	      name = ".conflict";
-	      goto get_vma;
-	    case DT_MIPS_LIBLIST:
-	      name = ".liblist";
-	    get_vma:
-	      s = bfd_get_section_by_name (output_bfd, name);
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_ptr = s->vma;
-	      break;
-
-	    case DT_MIPS_RLD_VERSION:
-	      dyn.d_un.d_val = 1; /* XXX */
-	      break;
-
-	    case DT_MIPS_FLAGS:
-	      dyn.d_un.d_val = RHF_NOTPOT; /* XXX */
-	      break;
-
-	    case DT_MIPS_CONFLICTNO:
-	      name = ".conflict";
-	      elemsize = sizeof (Elf32_Conflict);
-	      goto set_elemno;
-
-	    case DT_MIPS_LIBLISTNO:
-	      name = ".liblist";
-	      elemsize = sizeof (Elf32_Lib);
-	    set_elemno:
-	      s = bfd_get_section_by_name (output_bfd, name);
-	      if (s != NULL)
-		{
-		  if (s->_cooked_size != 0)
-		    dyn.d_un.d_val = s->_cooked_size / elemsize;
-		  else
-		    dyn.d_un.d_val = s->_raw_size / elemsize;
-		}
-	      else
-		dyn.d_un.d_val = 0;
-	      break;
-
-	    case DT_MIPS_TIME_STAMP:
-	      time ((time_t *) &dyn.d_un.d_val);
-	      break;
-
-	    case DT_MIPS_ICHECKSUM:
-	      /* XXX FIXME: */
-	      swap_out_p = false;
-	      break;
-
-	    case DT_MIPS_IVERSION:
-	      /* XXX FIXME: */
-	      swap_out_p = false;
-	      break;
-
-	    case DT_MIPS_BASE_ADDRESS:
-	      s = output_bfd->sections;
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_ptr = s->vma & ~(0xffff);
-	      break;
-
-	    case DT_MIPS_LOCAL_GOTNO:
-	      dyn.d_un.d_val = g->local_gotno;
-	      break;
-
-	    case DT_MIPS_UNREFEXTNO:
-	      /* The index into the dynamic symbol table which is the
-		 entry of the first external symbol that is not
-		 referenced within the same object.  */
-	      dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
-	      break;
-
-	    case DT_MIPS_GOTSYM:
-	      if (g->global_gotsym)
-		{
-		  dyn.d_un.d_val = g->global_gotsym->dynindx;
-		  break;
-		}
-	      /* In case if we don't have global got symbols we default
-		 to setting DT_MIPS_GOTSYM to the same value as
-		 DT_MIPS_SYMTABNO, so we just fall through.  */
-
-	    case DT_MIPS_SYMTABNO:
-	      name = ".dynsym";
-	      elemsize = get_elf_backend_data (output_bfd)->s->sizeof_sym;
-	      s = bfd_get_section_by_name (output_bfd, name);
-	      BFD_ASSERT (s != NULL);
-
-	      if (s->_cooked_size != 0)
-		dyn.d_un.d_val = s->_cooked_size / elemsize;
-	      else
-		dyn.d_un.d_val = s->_raw_size / elemsize;
-	      break;
-
-	    case DT_MIPS_HIPAGENO:
-	      dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO;
-	      break;
-
-	    case DT_MIPS_OPTIONS:
-	      s = bfd_get_section_by_name(output_bfd, ".MIPS.options");
-	      dyn.d_un.d_ptr = s->vma;
-	      break;
-
-	    case DT_MIPS_MSYM:
-	      s = bfd_get_section_by_name(output_bfd, ".msym");
-	      dyn.d_un.d_ptr = s->vma;
-	      break;
-
-	    default:
-	      swap_out_p = false;
-	      break;
-	    }
-
-	  if (swap_out_p)
-	    (*get_elf_backend_data (dynobj)->s->swap_dyn_out)
-	      (dynobj, &dyn, b);
-	}
-    }
-
-  /* The first entry of the global offset table will be filled at
-     runtime. The second entry will be used by some runtime loaders.
-     This isn't the case of Irix rld.  */
-  if (sgot != NULL && sgot->_raw_size > 0)
-    {
-      bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
-      bfd_put_64 (output_bfd, (bfd_vma) 0x80000000, sgot->contents + 8);
-    }
-
-  if (sgot != NULL)
-    elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8;
-
-  {
-    asection *smsym;
-    asection *s;
-
-    /* ??? The section symbols for the output sections were set up in
-       _bfd_elf_final_link.  SGI sets the STT_NOTYPE attribute for these
-       symbols.  Should we do so?  */
-
-    smsym = bfd_get_section_by_name (dynobj, ".msym");
-    if (smsym != NULL)
-      {
-	Elf32_Internal_Msym msym;
-
-	msym.ms_hash_value = 0;
-	msym.ms_info = ELF32_MS_INFO (0, 1);
-
-	for (s = output_bfd->sections; s != NULL; s = s->next)
-	  {
-	    long dynindx = elf_section_data (s)->dynindx;
-
-	    mips_elf64_swap_msym_out
-	      (output_bfd, &msym,
-	       (((Elf32_External_Msym *) smsym->contents)
-		+ dynindx));
-	  }
-      }
-
-    /* Clean up a first relocation in .rel.dyn.  */
-    s = bfd_get_section_by_name (dynobj, "rel.dyn");
-    if (s != NULL && s->_raw_size > 0)
-      memset (s->contents, 0, get_elf_backend_data (dynobj)->s->sizeof_rel);
-  }
-
-  return true;
-}
-
-/* Return the section that should be marked against GC for a given
-   relocation.  */
-
-asection *
-mips_elf64_gc_mark_hook (abfd, info, rel, h, sym)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
-{
-  if (h != NULL)
-    {
-      switch (ELF64_R_TYPE (rel->r_info))
-	{
-	case R_MIPS_GNU_VTINHERIT:
-	case R_MIPS_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    case bfd_link_hash_defined:
-	    case bfd_link_hash_defweak:
-	      return h->root.u.def.section;
-
-	    case bfd_link_hash_common:
-	      return h->root.u.c.p->section;
-
-	    default:
-	      break;
-	    }
-	}
-    }
-  else
-    {
-      return bfd_section_from_elf_index (abfd, sym->st_shndx);
-    }
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
-
-boolean
-mips_elf64_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
-{
-#if 0
-  Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes;
-  bfd_signed_vma *local_got_refcounts;
-  const Elf_Internal_Rela *rel, *relend;
-  unsigned long r_symndx;
-  struct elf_link_hash_entry *h;
-
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
-  local_got_refcounts = elf_local_got_refcounts (abfd);
-
-  relend = relocs + sec->reloc_count;
-  for (rel = relocs; rel < relend; rel++)
-    switch (ELF64_R_TYPE (rel->r_info))
-      {
-      case R_MIPS_GOT16:
-      case R_MIPS_CALL16:
-      case R_MIPS_CALL_HI16:
-      case R_MIPS_CALL_LO16:
-      case R_MIPS_GOT_HI16:
-      case R_MIPS_GOT_LO16:
-	/* ??? It would seem that the existing MIPS code does no sort
-	   of reference counting or whatnot on its GOT and PLT entries,
-	   so it is not possible to garbage collect them at this time.  */
-	break;
-
-      default:
-	break;
-      }
-#endif
-
-  return true;
-}
-
-/* Create the .got section to hold the global offset table. */
-
-static boolean
-mips_elf64_create_got_section (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
-{
-  flagword flags;
-  register asection *s;
-  struct elf_link_hash_entry *h;
-  struct mips_elf64_got_info *g;
-
-  /* This function may be called more than once.  */
-  if (bfd_get_section_by_name (abfd, ".got"))
-    return true;
-
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
-	   | SEC_LINKER_CREATED);
-
-  s = bfd_make_section (abfd, ".got");
-  if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags)
-      || ! bfd_set_section_alignment (abfd, s, 4))
-    return false;
-
-  /* Define the symbol _GLOBAL_OFFSET_TABLE_.  We don't do this in the
-     linker script because we don't want to define the symbol if we
-     are not creating a global offset table.  */
-  h = NULL;
-  if (! (_bfd_generic_link_add_one_symbol
-	 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
-	  (bfd_vma) 0, (const char *) NULL, false,
-	  get_elf_backend_data (abfd)->collect,
-	  (struct bfd_link_hash_entry **) &h)))
-    return false;
-  h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
-  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
-  h->type = STT_OBJECT;
-
-  if (info->shared
-      && ! bfd_elf64_link_record_dynamic_symbol (info, h))
-    return false;
-
-  /* The first several global offset table entries are reserved.  */
-  s->_raw_size = MIPS_RESERVED_GOTNO * (get_elf_backend_data (abfd)->s->arch_size / 8);
-
-  g = (struct mips_elf64_got_info *) bfd_alloc (abfd,
-					  sizeof (struct mips_elf64_got_info));
-  if (g == NULL)
-    return false;
-  g->global_gotsym = NULL;
-  g->local_gotno = MIPS_RESERVED_GOTNO;
-  g->assigned_gotno = MIPS_RESERVED_GOTNO;
-  if (elf_section_data (s) == NULL)
-    {
-      s->used_by_bfd =
-	(PTR) bfd_zalloc (abfd, sizeof (struct bfd_elf_section_data));
-      if (elf_section_data (s) == NULL)
-	return false;
-    }
-  elf_section_data (s)->tdata = (PTR) g;
-  elf_section_data (s)->this_hdr.sh_flags 
-    |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
-
-  return true;
-}
-
-/* If H is a symbol that needs a global GOT entry, but has a dynamic
-   symbol table index lower than any we've seen to date, record it for
-   posterity.  */
-
-static boolean
-mips_elf64_record_global_got_symbol (h, info, g)
-     struct elf_link_hash_entry *h;
-     struct bfd_link_info *info;
-     struct mips_elf64_got_info *g ATTRIBUTE_UNUSED;
-{
-  /* A global symbol in the GOT must also be in the dynamic symbol
-     table.  */
-  if (h->dynindx == -1
-      && !bfd_elf64_link_record_dynamic_symbol (info, h))
-    return false;
-  
-  /* If we've already marked this entry as needing GOT space, we don't
-     need to do it again.  */
-  if (h->got.offset != (bfd_vma) - 1)
-    return true;
-
-  /* By setting this to a value other than -1, we are indicating that
-     there needs to be a GOT entry for H.  Avoid using zero, as the
-     generic ELF copy_indirect_symbol tests for <= 0.  */
-  h->got.offset = 1;
-
-  return true;
-}
-
-/* Returns the .msym section for ABFD, creating it if it does not
-   already exist.  Returns NULL to indicate error.  */
-
-static asection *
-mips_elf64_create_msym_section (abfd)
-     bfd *abfd;
-{
-  asection *s;
-
-  s = bfd_get_section_by_name (abfd, ".msym");
-  if (!s)
-    {
-      s = bfd_make_section (abfd, ".msym");
-      if (!s
-	  || !bfd_set_section_flags (abfd, s,
-				     SEC_ALLOC
-				     | SEC_LOAD
-				     | SEC_HAS_CONTENTS
-				     | SEC_LINKER_CREATED
-				     | SEC_READONLY)
-	  || !bfd_set_section_alignment (abfd, s, 3))
-	return NULL;
-    }
-
-  return s;
-}
-
-/* Add room for N relocations to the .rel.dyn section in ABFD.  */
-
-static void
-mips_elf64_allocate_dynamic_relocations (abfd, n)
-     bfd *abfd;
-     unsigned int n;
-{
-  asection *s;
-
-  s = bfd_get_section_by_name (abfd, ".rel.dyn");
-  BFD_ASSERT (s != NULL);
-  
-  if (s->_raw_size == 0)
-    {
-      /* Make room for a null element. */
-      s->_raw_size += get_elf_backend_data (abfd)->s->sizeof_rel;
-      ++s->reloc_count;
-    }
-  s->_raw_size += n * get_elf_backend_data (abfd)->s->sizeof_rel;
-}
-
-/* Look through the relocs for a section during the first phase, and
-   allocate space in the global offset table.  */
-
-boolean
-mips_elf64_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
-{
-  const char *name;
-  bfd *dynobj;
-  Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes;
-  struct mips_elf64_got_info *g;
-  size_t extsymoff;
-  const Elf_Internal_Rela *rel;
-  const Elf_Internal_Rela *rel_end;
-  asection *sgot;
-  asection *sreloc;
-  struct elf_backend_data *bed;
-
-  if (info->relocateable)
-    return true;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
-  extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
-
-  /* Check for the mips16 stub sections.  */
-
-  name = bfd_get_section_name (abfd, sec);
-  if (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0)
-    {
-      unsigned long r_symndx;
-
-      /* Look at the relocation information to figure out which symbol
-         this is for.  */
-
-      r_symndx = ELF64_R_SYM (relocs->r_info);
-
-      if (r_symndx < extsymoff
-	  || sym_hashes[r_symndx - extsymoff] == NULL)
-	{
-	  asection *o;
-
-	  /* This stub is for a local symbol.  This stub will only be
-             needed if there is some relocation in this BFD, other
-             than a 16 bit function call, which refers to this symbol.  */
-	  for (o = abfd->sections; o != NULL; o = o->next)
-	    {
-	      Elf_Internal_Rela *sec_relocs;
-	      const Elf_Internal_Rela *r, *rend;
-
-	      /* We can ignore stub sections when looking for relocs.  */
-	      if ((o->flags & SEC_RELOC) == 0
-		  || o->reloc_count == 0
-		  || strncmp (bfd_get_section_name (abfd, o), FN_STUB,
-			      sizeof FN_STUB - 1) == 0
-		  || strncmp (bfd_get_section_name (abfd, o), CALL_STUB,
-			      sizeof CALL_STUB - 1) == 0
-		  || strncmp (bfd_get_section_name (abfd, o), CALL_FP_STUB,
-			      sizeof CALL_FP_STUB - 1) == 0)
-		continue;
-
-	      sec_relocs = (_bfd_elf64_link_read_relocs
-			    (abfd, o, (PTR) NULL,
-			     (Elf_Internal_Rela *) NULL,
-			     info->keep_memory));
-	      if (sec_relocs == NULL)
-		return false;
-
-	      rend = sec_relocs + o->reloc_count;
-	      for (r = sec_relocs; r < rend; r++)
-		if (ELF64_R_SYM (r->r_info) == r_symndx
-		    && ELF64_R_TYPE (r->r_info) != R_MIPS16_26)
-		  break;
-
-	      if (! info->keep_memory)
-		free (sec_relocs);
-
-	      if (r < rend)
-		break;
-	    }
-
-	  if (o == NULL)
-	    {
-	      /* There is no non-call reloc for this stub, so we do
-                 not need it.  Since this function is called before
-                 the linker maps input sections to output sections, we
-                 can easily discard it by setting the SEC_EXCLUDE
-                 flag.  */
-	      sec->flags |= SEC_EXCLUDE;
-	      return true;
-	    }
-
-	  /* Record this stub in an array of local symbol stubs for
-             this BFD.  */
-	  if (elf_tdata (abfd)->local_stubs == NULL)
-	    {
-	      unsigned long symcount;
-	      asection **n;
-	      bfd_size_type amt;
-
-	      if (elf_bad_symtab (abfd))
-		symcount = NUM_SHDR_ENTRIES (symtab_hdr);
-	      else
-		symcount = symtab_hdr->sh_info;
-	      amt = symcount * sizeof (asection *);
-	      n = (asection **) bfd_zalloc (abfd, amt);
-	      if (n == NULL)
-		return false;
-	      elf_tdata (abfd)->local_stubs = n;
-	    }
-
-	  elf_tdata (abfd)->local_stubs[r_symndx] = sec;
-
-	  /* We don't need to set mips16_stubs_seen in this case.
-             That flag is used to see whether we need to look through
-             the global symbol table for stubs.  We don't need to set
-             it here, because we just have a local stub.  */
-	}
-      else
-	{
-	  struct mips_elf64_link_hash_entry *h;
-
-	  h = ((struct mips_elf64_link_hash_entry *)
-	       sym_hashes[r_symndx - extsymoff]);
-
-	  /* H is the symbol this stub is for.  */
-
-	  h->fn_stub = sec;
-	  mips_elf64_hash_table (info)->mips16_stubs_seen = true;
-	}
-    }
-  else if (strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
-	   || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
-    {
-      unsigned long r_symndx;
-      struct mips_elf64_link_hash_entry *h;
-      asection **loc;
-
-      /* Look at the relocation information to figure out which symbol
-         this is for.  */
-
-      r_symndx = ELF64_R_SYM (relocs->r_info);
-
-      if (r_symndx < extsymoff
-	  || sym_hashes[r_symndx - extsymoff] == NULL)
-	{
-	  /* This stub was actually built for a static symbol defined
-	     in the same file.  We assume that all static symbols in
-	     mips16 code are themselves mips16, so we can simply
-	     discard this stub.  Since this function is called before
-	     the linker maps input sections to output sections, we can
-	     easily discard it by setting the SEC_EXCLUDE flag.  */
-	  sec->flags |= SEC_EXCLUDE;
-	  return true;
-	}
-
-      h = ((struct mips_elf64_link_hash_entry *)
-	   sym_hashes[r_symndx - extsymoff]);
-
-      /* H is the symbol this stub is for.  */
-
-      if (strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
-	loc = &h->call_fp_stub;
-      else
-	loc = &h->call_stub;
-
-      /* If we already have an appropriate stub for this function, we
-	 don't need another one, so we can discard this one.  Since
-	 this function is called before the linker maps input sections
-	 to output sections, we can easily discard it by setting the
-	 SEC_EXCLUDE flag.  We can also discard this section if we
-	 happen to already know that this is a mips16 function; it is
-	 not necessary to check this here, as it is checked later, but
-	 it is slightly faster to check now.  */
-      if (*loc != NULL || h->root.other == STO_MIPS16)
-	{
-	  sec->flags |= SEC_EXCLUDE;
-	  return true;
-	}
-
-      *loc = sec;
-      mips_elf64_hash_table (info)->mips16_stubs_seen = true;
-    }
-
-  if (dynobj == NULL)
-    {
-      sgot = NULL;
-      g = NULL;
-    }
-  else
-    {
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      if (sgot == NULL)
-	g = NULL;
-      else
-	{
-	  BFD_ASSERT (elf_section_data (sgot) != NULL);
-	  g = (struct mips_elf64_got_info *) elf_section_data (sgot)->tdata;
-	  BFD_ASSERT (g != NULL);
-	}
-    }
-
-  sreloc = NULL;
-  bed = get_elf_backend_data (abfd);
-  rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
-  for (rel = relocs; rel < rel_end; ++rel)
-    {
-      unsigned long r_symndx;
-      int r_type;
-      struct elf_link_hash_entry *h;
-
-      r_symndx = ELF64_R_SYM (rel->r_info);
-      r_type = ELF64_MIPS_R_TYPE (rel->r_info);
-
-      if (r_symndx < extsymoff)
-	h = NULL;
-      else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
-	{
-	  (*_bfd_error_handler)
-	    (_("%s: Malformed reloc detected for section %s"),
-	     bfd_archive_filename (abfd), name);
-	  bfd_set_error (bfd_error_bad_value);
-	  return false;
-	}
-      else
-	{
-	  h = sym_hashes[r_symndx - extsymoff];
-
-	  /* This may be an indirect symbol created because of a version.  */
-	  if (h != NULL)
-	    {
-	      while (h->root.type == bfd_link_hash_indirect)
-		h = (struct elf_link_hash_entry *) h->root.u.i.link;
-	    }
-	}
-
-      /* Some relocs require a global offset table.  */
-      if (dynobj == NULL || sgot == NULL)
-	{
-	  switch (r_type)
-	    {
-	    case R_MIPS_GOT16:
-	    case R_MIPS_CALL16:
-	    case R_MIPS_CALL_HI16:
-	    case R_MIPS_CALL_LO16:
-	    case R_MIPS_GOT_HI16:
-	    case R_MIPS_GOT_LO16:
-	    case R_MIPS_GOT_PAGE:
-	    case R_MIPS_GOT_OFST:
-	    case R_MIPS_GOT_DISP:
-	      if (dynobj == NULL)
-		elf_hash_table (info)->dynobj = dynobj = abfd;
-	      if (! mips_elf64_create_got_section (dynobj, info))
-		return false;
-	      g = _mips_elf64_got_info (dynobj, &sgot);
-	      break;
-
-	    case R_MIPS_32:
-	    case R_MIPS_REL32:
-	    case R_MIPS_64:
-	      if (dynobj == NULL
-		  && (info->shared || h != NULL)
-		  && (sec->flags & SEC_ALLOC) != 0)
-		elf_hash_table (info)->dynobj = dynobj = abfd;
-	      break;
-
-	    default:
-	      break;
-	    }
-	}
-
-      if (!h && (r_type == R_MIPS_CALL_LO16
-		 || r_type == R_MIPS_GOT_LO16
-		 || r_type == R_MIPS_GOT_DISP))
-	{
-	  /* We may need a local GOT entry for this relocation.  We
-	     don't count R_MIPS_GOT_PAGE because we can estimate the
-	     maximum number of pages needed by looking at the size of
-	     the segment.  Similar comments apply to R_MIPS_GOT16 and
-	     R_MIPS_CALL16.  We don't count R_MIPS_GOT_HI16, or
-	     R_MIPS_CALL_HI16 because these are always followed by an
-	     R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16.
-
-	     This estimation is very conservative since we can merge
-	     duplicate entries in the GOT.  In order to be less
-	     conservative, we could actually build the GOT here,
-	     rather than in relocate_section.  */
-	  g->local_gotno++;
-	  sgot->_raw_size += get_elf_backend_data (dynobj)->s->arch_size / 8;
-	}
-
-      switch (r_type)
-	{
-	case R_MIPS_CALL16:
-	  if (h == NULL)
-	    {
-	      (*_bfd_error_handler)
-		(_("%s: CALL16 reloc at 0x%lx not against global symbol"),
-		 bfd_archive_filename (abfd), (unsigned long) rel->r_offset);
-	      bfd_set_error (bfd_error_bad_value);
-	      return false;
-	    }
-	  /* Fall through.  */
-
-	case R_MIPS_CALL_HI16:
-	case R_MIPS_CALL_LO16:
-	  if (h != NULL)
-	    {
-	      /* This symbol requires a global offset table entry.  */
-	      if (!mips_elf64_record_global_got_symbol (h, info, g))
-		return false;
-
-	      /* We need a stub, not a plt entry for the undefined
-		 function.  But we record it as if it needs plt.  See
-		 elf_adjust_dynamic_symbol in elflink.h.  */
-	      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-	      h->type = STT_FUNC;
-	    }
-	  break;
-
-	case R_MIPS_GOT16:
-	case R_MIPS_GOT_HI16:
-	case R_MIPS_GOT_LO16:
-	case R_MIPS_GOT_DISP:
-	  /* This symbol requires a global offset table entry.  */
-	  if (h && !mips_elf64_record_global_got_symbol (h, info, g))
-	    return false;
-	  break;
-
-	case R_MIPS_32:
-	case R_MIPS_REL32:
-	case R_MIPS_64:
-	  if ((info->shared || h != NULL)
-	      && (sec->flags & SEC_ALLOC) != 0)
-	    {
-	      if (sreloc == NULL)
-		{
-		  const char *name = ".rel.dyn";
-
-		  sreloc = bfd_get_section_by_name (dynobj, name);
-		  if (sreloc == NULL)
-		    {
-		      sreloc = bfd_make_section (dynobj, name);
-		      if (sreloc == NULL
-			  || ! bfd_set_section_flags (dynobj, sreloc,
-						      (SEC_ALLOC
-						       | SEC_LOAD
-						       | SEC_HAS_CONTENTS
-						       | SEC_IN_MEMORY
-						       | SEC_LINKER_CREATED
-						       | SEC_READONLY))
-			  || ! bfd_set_section_alignment (dynobj, sreloc,
-							  4))
-			return false;
-		    }
-		}
-#define MIPS_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
-	      if (info->shared)
-		{
-		  /* When creating a shared object, we must copy these
-		     reloc types into the output file as R_MIPS_REL32
-		     relocs.  We make room for this reloc in the
-		     .rel.dyn reloc section.  */
-		  mips_elf64_allocate_dynamic_relocations (dynobj, 1);
-		  if ((sec->flags & MIPS_READONLY_SECTION)
-		      == MIPS_READONLY_SECTION)
-		    /* We tell the dynamic linker that there are
-		       relocations against the text segment.  */
-		    info->flags |= DF_TEXTREL;
-		}
-	      else
-		{
-		  struct mips_elf64_link_hash_entry *hmips;
-
-		  /* We only need to copy this reloc if the symbol is
-                     defined in a dynamic object.  */
-		  hmips = (struct mips_elf64_link_hash_entry *) h;
-		  ++hmips->possibly_dynamic_relocs;
-		  if ((sec->flags & MIPS_READONLY_SECTION)
-		      == MIPS_READONLY_SECTION)
-		    /* We need it to tell the dynamic linker if there
-		       are relocations against the text segment.  */
-		    hmips->readonly_reloc = true;
-		}
-	     
-	      /* Even though we don't directly need a GOT entry for
-		 this symbol, a symbol must have a dynamic symbol
-		 table index greater that DT_MIPS_GOTSYM if there are
-		 dynamic relocations against it.  */
-	      if (h != NULL
-		  && !mips_elf64_record_global_got_symbol (h, info, g))
-		return false;
-	    }
-	  break;
-
-	case R_MIPS_26:
-	case R_MIPS_GPREL16:
-	case R_MIPS_LITERAL:
-	case R_MIPS_GPREL32:
-	  break;
-
-	  /* This relocation describes the C++ object vtable hierarchy.
-	     Reconstruct it for later use during GC.  */
-	case R_MIPS_GNU_VTINHERIT:
-	  if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
-	    return false;
-	  break;
-
-	  /* This relocation describes which C++ vtable entries are actually
-	     used.  Record for later use during GC.  */
-	case R_MIPS_GNU_VTENTRY:
-	  if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_offset))
-	    return false;
-	  break;
-
-	default:
-	  break;
-	}
-    }
-
-  return true;
-}
-
-/* Structure used to pass information to mips_elf64_output_extsym.  */
-
-struct extsym_info
-{
-  bfd *abfd;
-  struct bfd_link_info *info;
-  struct ecoff_debug_info *debug;
-  const struct ecoff_debug_swap *swap;
-  boolean failed;
-};
-
-/* This routine is used to write out ECOFF debugging external symbol
-   information.  It is called via mips_elf64_link_hash_traverse.  The
-   ECOFF external symbol information must match the ELF external
-   symbol information.  Unfortunately, at this point we don't know
-   whether a symbol is required by reloc information, so the two
-   tables may wind up being different.  We must sort out the external
-   symbol information before we can set the final size of the .mdebug
-   section, and we must set the size of the .mdebug section before we
-   can relocate any sections, and we can't know which symbols are
-   required by relocation until we relocate the sections.
-   Fortunately, it is relatively unlikely that any symbol will be
-   stripped but required by a reloc.  In particular, it can not happen
-   when generating a final executable.  */
-
-static boolean
-mips_elf64_output_extsym (h, data)
-     struct mips_elf64_link_hash_entry *h;
-     PTR data;
-{
-  struct extsym_info *einfo = (struct extsym_info *) data;
-  boolean strip;
-  asection *sec, *output_section;
-
-  if (h->root.indx == -2)
-    strip = false;
-  else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-	    || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
-	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
-	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
-    strip = true;
-  else if (einfo->info->strip == strip_all
-	   || (einfo->info->strip == strip_some
-	       && bfd_hash_lookup (einfo->info->keep_hash,
-				   h->root.root.root.string,
-				   false, false) == NULL))
-    strip = true;
-  else
-    strip = false;
-
-  if (strip)
-    return true;
-
-  if (h->esym.ifd == -2)
-    {
-      h->esym.jmptbl = 0;
-      h->esym.cobol_main = 0;
-      h->esym.weakext = 0;
-      h->esym.reserved = 0;
-      h->esym.ifd = ifdNil;
-      h->esym.asym.value = 0;
-      h->esym.asym.st = stGlobal;
-
-      if (h->root.root.type == bfd_link_hash_undefined
-	      || h->root.root.type == bfd_link_hash_undefweak)
-	{
-	  const char *name;
-
-	  /* Use undefined class.  Also, set class and type for some
-             special symbols.  */
-	  name = h->root.root.root.string;
-	  h->esym.asym.sc = scUndefined;
-	}
-      else if (h->root.root.type != bfd_link_hash_defined
-	  && h->root.root.type != bfd_link_hash_defweak)
-	h->esym.asym.sc = scAbs;
-      else
-	{
-	  const char *name;
-
-	  sec = h->root.root.u.def.section;
-	  output_section = sec->output_section;
-
-	  /* When making a shared library and symbol h is the one from
-	     the another shared library, OUTPUT_SECTION may be null.  */
-	  if (output_section == NULL)
-	    h->esym.asym.sc = scUndefined;
-	  else
-	    {
-	      name = bfd_section_name (output_section->owner, output_section);
-
-	      if (strcmp (name, ".text") == 0)
-		h->esym.asym.sc = scText;
-	      else if (strcmp (name, ".data") == 0)
-		h->esym.asym.sc = scData;
-	      else if (strcmp (name, ".sdata") == 0)
-		h->esym.asym.sc = scSData;
-	      else if (strcmp (name, ".rodata") == 0
-		       || strcmp (name, ".rdata") == 0)
-		h->esym.asym.sc = scRData;
-	      else if (strcmp (name, ".bss") == 0)
-		h->esym.asym.sc = scBss;
-	      else if (strcmp (name, ".sbss") == 0)
-		h->esym.asym.sc = scSBss;
-	      else if (strcmp (name, ".init") == 0)
-		h->esym.asym.sc = scInit;
-	      else if (strcmp (name, ".fini") == 0)
-		h->esym.asym.sc = scFini;
-	      else
-		h->esym.asym.sc = scAbs;
-	    }
-	}
-
-      h->esym.asym.reserved = 0;
-      h->esym.asym.index = indexNil;
-    }
-
-  if (h->root.root.type == bfd_link_hash_common)
-    h->esym.asym.value = h->root.root.u.c.size;
-  else if (h->root.root.type == bfd_link_hash_defined
-	   || h->root.root.type == bfd_link_hash_defweak)
-    {
-      if (h->esym.asym.sc == scCommon)
-	h->esym.asym.sc = scBss;
-      else if (h->esym.asym.sc == scSCommon)
-	h->esym.asym.sc = scSBss;
-
-      sec = h->root.root.u.def.section;
-      output_section = sec->output_section;
-      if (output_section != NULL)
-	h->esym.asym.value = (h->root.root.u.def.value
-			      + sec->output_offset
-			      + output_section->vma);
-      else
-	h->esym.asym.value = 0;
-    }
-  else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
-    {
-      struct mips_elf64_link_hash_entry *hd = h;
-      boolean no_fn_stub = h->no_fn_stub;
-
-      while (hd->root.root.type == bfd_link_hash_indirect)
-	{
-	  hd = (struct mips_elf64_link_hash_entry *)h->root.root.u.i.link;
-	  no_fn_stub = no_fn_stub || hd->no_fn_stub;
-	}
-
-      if (!no_fn_stub)
-	{
-	  /* Set type and value for a symbol with a function stub.  */
-	  h->esym.asym.st = stProc;
-	  sec = hd->root.root.u.def.section;
-	  if (sec == NULL)
-	    h->esym.asym.value = 0;
-	  else
-	    {
-	      output_section = sec->output_section;
-	      if (output_section != NULL)
-		h->esym.asym.value = (hd->root.plt.offset
-				      + sec->output_offset
-				      + output_section->vma);
-	      else
-		h->esym.asym.value = 0;
-	    }
-#if 0 /* FIXME?  */
-	  h->esym.ifd = 0;
-#endif
-	}
-    }
-
-  if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
-				      h->root.root.root.string,
-				      &h->esym))
-    {
-      einfo->failed = true;
-      return false;
-    }
-
-  return true;
-}
-
-/* Swap an entry in a .gptab section.  Note that these routines rely
-   on the equivalence of the two elements of the union.  */
-
-static void
-mips_elf64_swap_gptab_in (abfd, ex, in)
-     bfd *abfd;
-     const Elf32_External_gptab *ex;
-     Elf32_gptab *in;
-{
-  in->gt_entry.gt_g_value = H_GET_32 (abfd, ex->gt_entry.gt_g_value);
-  in->gt_entry.gt_bytes = H_GET_32 (abfd, ex->gt_entry.gt_bytes);
-}
-
-static void
-mips_elf64_swap_gptab_out (abfd, in, ex)
-     bfd *abfd;
-     const Elf32_gptab *in;
-     Elf32_External_gptab *ex;
-{
-  H_PUT_32 (abfd, (bfd_vma) in->gt_entry.gt_g_value,
-		ex->gt_entry.gt_g_value);
-  H_PUT_32 (abfd, (bfd_vma) in->gt_entry.gt_bytes,
-		ex->gt_entry.gt_bytes);
-}
-
-/* A comparison routine used to sort .gptab entries.  */
-
-static int
-gptab_compare (p1, p2)
-     const PTR p1;
-     const PTR p2;
-{
-  const Elf32_gptab *a1 = (const Elf32_gptab *) p1;
-  const Elf32_gptab *a2 = (const Elf32_gptab *) p2;
-
-  return a1->gt_entry.gt_g_value - a2->gt_entry.gt_g_value;
-}
-
-/* We need to use a special link routine to handle the .mdebug section.
-   We need to merge all instances of this section together, not write
-   them all out sequentially.  */
-
-boolean
-mips_elf64_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
-{
-  asection **secpp;
-  asection *o;
-  struct bfd_link_order *p;
-  asection *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
-  struct ecoff_debug_info debug;
-  const struct ecoff_debug_swap *swap
-    = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-  HDRR *symhdr = &debug.symbolic_header;
-  PTR mdebug_handle = NULL;
-  asection *s;
-  EXTR esym;
-  unsigned int i;
-  static const char * const secname[] =
-      { ".text", ".init", ".fini", ".data",
-          ".rodata", ".sdata", ".sbss", ".bss" };
-  static const int sc[] = { scText, scInit, scFini, scData,
-                          scRData, scSData, scSBss, scBss };
-
-  /* If all the things we linked together were PIC, but we're
-     producing an executable (rather than a shared object), then the
-     resulting file is CPIC (i.e., it calls PIC code.)  */
-  if (!info->shared
-      && !info->relocateable
-      && elf_elfheader (abfd)->e_flags & EF_MIPS_PIC)
-    {
-      elf_elfheader (abfd)->e_flags &= ~EF_MIPS_PIC;
-      elf_elfheader (abfd)->e_flags |= EF_MIPS_CPIC;
-    }
-
-  /* We'd carefully arranged the dynamic symbol indices, and then the
-     generic size_dynamic_sections renumbered them out from under us.
-     Rather than trying somehow to prevent the renumbering, just do
-     the sort again.  */
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      bfd *dynobj;
-      asection *got;
-      struct mips_elf64_got_info *g;
-
-      /* When we resort, we must tell mips_elf64_sort_hash_table what
-	 the lowest index it may use is.  That's the number of section
-	 symbols we're going to add.  The generic ELF linker only
-	 adds these symbols when building a shared object.  Note that
-	 we count the sections after (possibly) removing the .options
-	 section above.  */
-      if (!mips_elf64_sort_hash_table (info, (info->shared 
-					    ? bfd_count_sections (abfd) + 1
-					    : 1)))
-        return false;
-
-      /* Make sure we didn't grow the global .got region.  */
-      dynobj = elf_hash_table (info)->dynobj;
-      got = bfd_get_section_by_name (dynobj, ".got");
-      g = (struct mips_elf64_got_info *) elf_section_data (got)->tdata;
-
-      if (g->global_gotsym != NULL)
-	BFD_ASSERT ((elf_hash_table (info)->dynsymcount
-		     - g->global_gotsym->dynindx)
-		    <= g->global_gotno);
-    }
-
-  /* We include .MIPS.options, even though we don't process it quite right.
-     (Some entries are supposed to be merged.)  At IRIX6 empirically we seem
-     to be better off including it than not.  */
-  for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
-    {
-      if (strcmp ((*secpp)->name, ".MIPS.options") == 0)
-	{
-	  for (p = (*secpp)->link_order_head; p != NULL; p = p->next)
-	    if (p->type == bfd_indirect_link_order)
-	      p->u.indirect.section->flags &=~ SEC_HAS_CONTENTS;
-	  (*secpp)->link_order_head = NULL;
-	  bfd_section_list_remove (abfd, secpp);
-	  --abfd->section_count;
-	    
-	  break;
-	}
-    }
-
-  /* Get a value for the GP register.  */
-  if (elf_gp (abfd) == 0)
-    {
-      struct bfd_link_hash_entry *h;
-
-      h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
-      if (h != (struct bfd_link_hash_entry *) NULL
-	  && h->type == bfd_link_hash_defined)
-	elf_gp (abfd) = (h->u.def.value
-			 + h->u.def.section->output_section->vma
-			 + h->u.def.section->output_offset);
-      else if (info->relocateable)
-	{
-	  bfd_vma lo = MINUS_ONE;
-
-	  /* Find the GP-relative section with the lowest offset.  */
-	  for (o = abfd->sections; o != NULL; o = o->next)
-	    if (o->vma < lo 
-		&& (elf_section_data (o)->this_hdr.sh_flags & SHF_MIPS_GPREL))
-	      lo = o->vma;
-
-	  /* And calculate GP relative to that.  */
-	  elf_gp (abfd) = (lo + 0x7ff0);
-	}
-      else
-	{
-	  /* If the relocate_section function needs to do a reloc
-	     involving the GP value, it should make a reloc_dangerous
-	     callback to warn that GP is not defined.  */
-	}
-    }
-
-  /* Go through the sections and collect the .mdebug information.  */
-  mdebug_sec = NULL;
-  gptab_data_sec = NULL;
-  gptab_bss_sec = NULL;
-  for (o = abfd->sections; o != (asection *) NULL; o = o->next)
-    {
-      if (strcmp (o->name, ".mdebug") == 0)
-	{
-	  struct extsym_info einfo;
-	  bfd_vma last;
-
-	  /* We have found the .mdebug section in the output file.
-	     Look through all the link_orders comprising it and merge
-	     the information together.  */
-	  symhdr->magic = swap->sym_magic;
-	  /* FIXME: What should the version stamp be?  */
-	  symhdr->vstamp = 0;
-	  symhdr->ilineMax = 0;
-	  symhdr->cbLine = 0;
-	  symhdr->idnMax = 0;
-	  symhdr->ipdMax = 0;
-	  symhdr->isymMax = 0;
-	  symhdr->ioptMax = 0;
-	  symhdr->iauxMax = 0;
-	  symhdr->issMax = 0;
-	  symhdr->issExtMax = 0;
-	  symhdr->ifdMax = 0;
-	  symhdr->crfd = 0;
-	  symhdr->iextMax = 0;
-
-	  /* We accumulate the debugging information itself in the
-	     debug_info structure.  */
-	  debug.line = NULL;
-	  debug.external_dnr = NULL;
-	  debug.external_pdr = NULL;
-	  debug.external_sym = NULL;
-	  debug.external_opt = NULL;
-	  debug.external_aux = NULL;
-	  debug.ss = NULL;
-	  debug.ssext = debug.ssext_end = NULL;
-	  debug.external_fdr = NULL;
-	  debug.external_rfd = NULL;
-	  debug.external_ext = debug.external_ext_end = NULL;
-
-	  mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
-	  if (mdebug_handle == (PTR) NULL)
-	    return false;
-
-          esym.jmptbl = 0;
-          esym.cobol_main = 0;
-          esym.weakext = 0;
-          esym.reserved = 0;
-          esym.ifd = ifdNil;
-          esym.asym.iss = issNil;
-          esym.asym.st = stLocal;
-          esym.asym.reserved = 0;
-          esym.asym.index = indexNil;
-          last = 0;
-	  for (i = 0; i < sizeof (secname) / sizeof (secname[0]); i++)
-            {
-              esym.asym.sc = sc[i];
-              s = bfd_get_section_by_name (abfd, secname[i]);
-              if (s != NULL)
-                {
-                  esym.asym.value = s->vma;
-                  last = s->vma + s->_raw_size;
-                }
-              else
-                esym.asym.value = last;
-              if (!bfd_ecoff_debug_one_external (abfd, &debug, swap,
-                                                 secname[i], &esym))
-                return false;
-            }
-
-	  for (p = o->link_order_head;
-	       p != (struct bfd_link_order *) NULL;
-	       p = p->next)
-	    {
-	      asection *input_section;
-	      bfd *input_bfd;
-	      const struct ecoff_debug_swap *input_swap;
-	      struct ecoff_debug_info input_debug;
-	      char *eraw_src;
-	      char *eraw_end;
-
-	      if (p->type != bfd_indirect_link_order)
-		{
-		  if (p->type == bfd_data_link_order)
-		    continue;
-		  abort ();
-		}
-
-	      input_section = p->u.indirect.section;
-	      input_bfd = input_section->owner;
-
-	      if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
-		  || (get_elf_backend_data (input_bfd)
-		      ->elf_backend_ecoff_debug_swap) == NULL)
-		{
-		  /* I don't know what a non MIPS ELF bfd would be
-		     doing with a .mdebug section, but I don't really
-		     want to deal with it.  */
-		  continue;
-		}
-
-	      input_swap = (get_elf_backend_data (input_bfd)
-			    ->elf_backend_ecoff_debug_swap);
-
-	      BFD_ASSERT (p->size == input_section->_raw_size);
-
-	      /* The ECOFF linking code expects that we have already
-		 read in the debugging information and set up an
-		 ecoff_debug_info structure, so we do that now.  */
-	      if (! _bfd_mips_elf_read_ecoff_info (input_bfd, input_section,
-						   &input_debug))
-		return false;
-
-	      if (! (bfd_ecoff_debug_accumulate
-		     (mdebug_handle, abfd, &debug, swap, input_bfd,
-		      &input_debug, input_swap, info)))
-		return false;
-
-	      /* Loop through the external symbols.  For each one with
-		 interesting information, try to find the symbol in
-		 the linker global hash table and save the information
-		 for the output external symbols.  */
-	      eraw_src = input_debug.external_ext;
-	      eraw_end = (eraw_src
-			  + (input_debug.symbolic_header.iextMax
-			     * input_swap->external_ext_size));
-	      for (;
-		   eraw_src < eraw_end;
-		   eraw_src += input_swap->external_ext_size)
-		{
-		  EXTR ext;
-		  const char *name;
-		  struct mips_elf64_link_hash_entry *h;
-
-		  (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
-		  if (ext.asym.sc == scNil
-		      || ext.asym.sc == scUndefined
-		      || ext.asym.sc == scSUndefined)
-		    continue;
-
-		  name = input_debug.ssext + ext.asym.iss;
-		  h = mips_elf64_link_hash_lookup (mips_elf64_hash_table (info),
-						 name, false, false, true);
-		  if (h == NULL || h->esym.ifd != -2)
-		    continue;
-
-		  if (ext.ifd != -1)
-		    {
-		      BFD_ASSERT (ext.ifd
-				  < input_debug.symbolic_header.ifdMax);
-		      ext.ifd = input_debug.ifdmap[ext.ifd];
-		    }
-
-		  h->esym = ext;
-		}
-
-	      /* Free up the information we just read.  */
-	      free (input_debug.line);
-	      free (input_debug.external_dnr);
-	      free (input_debug.external_pdr);
-	      free (input_debug.external_sym);
-	      free (input_debug.external_opt);
-	      free (input_debug.external_aux);
-	      free (input_debug.ss);
-	      free (input_debug.ssext);
-	      free (input_debug.external_fdr);
-	      free (input_debug.external_rfd);
-	      free (input_debug.external_ext);
-
-	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		 elf_link_input_bfd ignores this section.  */
-	      input_section->flags &=~ SEC_HAS_CONTENTS;
-	    }
-
-	  /* Build the external symbol information.  */
-	  einfo.abfd = abfd;
-	  einfo.info = info;
-	  einfo.debug = &debug;
-	  einfo.swap = swap;
-	  einfo.failed = false;
-	  mips_elf64_link_hash_traverse (mips_elf64_hash_table (info),
-				       mips_elf64_output_extsym,
-				       (PTR) &einfo);
-	  if (einfo.failed)
-	    return false;
-
-	  /* Set the size of the .mdebug section.  */
-	  o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
-
-	  /* Skip this section later on (I don't think this currently
-	     matters, but someday it might).  */
-	  o->link_order_head = (struct bfd_link_order *) NULL;
-
-	  mdebug_sec = o;
-	}
-
-      if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
-	{
-	  const char *subname;
-	  unsigned int c;
-	  Elf32_gptab *tab;
-	  Elf32_External_gptab *ext_tab;
-	  unsigned int i;
-
-	  /* The .gptab.sdata and .gptab.sbss sections hold
-	     information describing how the small data area would
-	     change depending upon the -G switch.  These sections
-	     not used in executables files.  */
-	  if (! info->relocateable)
-	    {
-	      asection **secpp;
-
-	      for (p = o->link_order_head;
-		   p != (struct bfd_link_order *) NULL;
-		   p = p->next)
-		{
-		  asection *input_section;
-
-		  if (p->type != bfd_indirect_link_order)
-		    {
-		      if (p->type == bfd_data_link_order)
-			continue;
-		      abort ();
-		    }
-
-		  input_section = p->u.indirect.section;
-
-		  /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		     elf_link_input_bfd ignores this section.  */
-		  input_section->flags &=~ SEC_HAS_CONTENTS;
-		}
-
-	      /* Skip this section later on (I don't think this
-		 currently matters, but someday it might).  */
-	      o->link_order_head = (struct bfd_link_order *) NULL;
-
-	      /* Really remove the section.  */
-	      for (secpp = &abfd->sections;
-		   *secpp != o;
-		   secpp = &(*secpp)->next)
-		;
-	      bfd_section_list_remove (abfd, secpp);
-	      --abfd->section_count;
-
-	      continue;
-	    }
-
-	  /* There is one gptab for initialized data, and one for
-	     uninitialized data.  */
-	  if (strcmp (o->name, ".gptab.sdata") == 0)
-	    gptab_data_sec = o;
-	  else if (strcmp (o->name, ".gptab.sbss") == 0)
-	    gptab_bss_sec = o;
-	  else
-	    {
-	      (*_bfd_error_handler)
-		(_("%s: illegal section name `%s'"),
-		 bfd_archive_filename (abfd), o->name);
-	      bfd_set_error (bfd_error_nonrepresentable_section);
-	      return false;
-	    }
-
-	  /* The linker script always combines .gptab.data and
-	     .gptab.sdata into .gptab.sdata, and likewise for
-	     .gptab.bss and .gptab.sbss.  It is possible that there is
-	     no .sdata or .sbss section in the output file, in which
-	     case we must change the name of the output section.  */
-	  subname = o->name + sizeof ".gptab" - 1;
-	  if (bfd_get_section_by_name (abfd, subname) == NULL)
-	    {
-	      if (o == gptab_data_sec)
-		o->name = ".gptab.data";
-	      else
-		o->name = ".gptab.bss";
-	      subname = o->name + sizeof ".gptab" - 1;
-	      BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
-	    }
-
-	  /* Set up the first entry.  */
-	  c = 1;
-	  tab = (Elf32_gptab *) bfd_malloc (c * sizeof (Elf32_gptab));
-	  if (tab == NULL)
-	    return false;
-	  tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
-	  tab[0].gt_header.gt_unused = 0;
-
-	  /* Combine the input sections.  */
-	  for (p = o->link_order_head;
-	       p != (struct bfd_link_order *) NULL;
-	       p = p->next)
-	    {
-	      asection *input_section;
-	      bfd *input_bfd;
-	      bfd_size_type size;
-	      unsigned long last;
-	      bfd_size_type gpentry;
-
-	      if (p->type != bfd_indirect_link_order)
-		{
-		  if (p->type == bfd_data_link_order)
-		    continue;
-		  abort ();
-		}
-
-	      input_section = p->u.indirect.section;
-	      input_bfd = input_section->owner;
-
-	      /* Combine the gptab entries for this input section one
-		 by one.  We know that the input gptab entries are
-		 sorted by ascending -G value.  */
-	      size = bfd_section_size (input_bfd, input_section);
-	      last = 0;
-	      for (gpentry = sizeof (Elf32_External_gptab);
-		   gpentry < size;
-		   gpentry += sizeof (Elf32_External_gptab))
-		{
-		  Elf32_External_gptab ext_gptab;
-		  Elf32_gptab int_gptab;
-		  unsigned long val;
-		  unsigned long add;
-		  boolean exact;
-		  unsigned int look;
-
-		  if (! (bfd_get_section_contents
-			 (input_bfd, input_section, (PTR) &ext_gptab,
-			  gpentry, sizeof (Elf32_External_gptab))))
-		    {
-		      free (tab);
-		      return false;
-		    }
-
-		  mips_elf64_swap_gptab_in (input_bfd, &ext_gptab,
-						&int_gptab);
-		  val = int_gptab.gt_entry.gt_g_value;
-		  add = int_gptab.gt_entry.gt_bytes - last;
-
-		  exact = false;
-		  for (look = 1; look < c; look++)
-		    {
-		      if (tab[look].gt_entry.gt_g_value >= val)
-			tab[look].gt_entry.gt_bytes += add;
-
-		      if (tab[look].gt_entry.gt_g_value == val)
-			exact = true;
-		    }
-
-		  if (! exact)
-		    {
-		      Elf32_gptab *new_tab;
-		      unsigned int max;
-
-		      /* We need a new table entry.  */
-		      new_tab = ((Elf32_gptab *)
-				 bfd_realloc ((PTR) tab,
-					      (c + 1) * sizeof (Elf32_gptab)));
-		      if (new_tab == NULL)
-			{
-			  free (tab);
-			  return false;
-			}
-		      tab = new_tab;
-		      tab[c].gt_entry.gt_g_value = val;
-		      tab[c].gt_entry.gt_bytes = add;
-
-		      /* Merge in the size for the next smallest -G
-			 value, since that will be implied by this new
-			 value.  */
-		      max = 0;
-		      for (look = 1; look < c; look++)
-			{
-			  if (tab[look].gt_entry.gt_g_value < val
-			      && (max == 0
-				  || (tab[look].gt_entry.gt_g_value
-				      > tab[max].gt_entry.gt_g_value)))
-			    max = look;
-			}
-		      if (max != 0)
-			tab[c].gt_entry.gt_bytes +=
-			  tab[max].gt_entry.gt_bytes;
-
-		      ++c;
-		    }
-
-		  last = int_gptab.gt_entry.gt_bytes;
-		}
-
-	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
-		 elf_link_input_bfd ignores this section.  */
-	      input_section->flags &=~ SEC_HAS_CONTENTS;
-	    }
-
-	  /* The table must be sorted by -G value.  */
-	  if (c > 2)
-	    qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
-
-	  /* Swap out the table.  */
-	  ext_tab = ((Elf32_External_gptab *)
-		     bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
-	  if (ext_tab == NULL)
-	    {
-	      free (tab);
-	      return false;
-	    }
-
-	  for (i = 0; i < c; i++)
-	    mips_elf64_swap_gptab_out (abfd, tab + i, ext_tab + i);
-	  free (tab);
-
-	  o->_raw_size = c * sizeof (Elf32_External_gptab);
-	  o->contents = (bfd_byte *) ext_tab;
-
-	  /* Skip this section later on (I don't think this currently
-	     matters, but someday it might).  */
-	  o->link_order_head = (struct bfd_link_order *) NULL;
-	}
-    }
-
-  /* Invoke the regular ELF backend linker to do all the work.  */
-  if (!bfd_elf64_bfd_final_link (abfd, info))
-     return false;
-
-  /* Now write out the computed sections.  */
-  if (mdebug_sec != (asection *) NULL)
-    {
-      BFD_ASSERT (abfd->output_has_begun);
-      if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
-					       swap, info,
-					       mdebug_sec->filepos))
-	return false;
-
-      bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
-    }
-  if (gptab_data_sec != (asection *) NULL)
-    {
-      if (! bfd_set_section_contents (abfd, gptab_data_sec,
-				      gptab_data_sec->contents,
-				      (file_ptr) 0,
-				      gptab_data_sec->_raw_size))
-	return false;
-    }
-
-  if (gptab_bss_sec != (asection *) NULL)
-    {
-      if (! bfd_set_section_contents (abfd, gptab_bss_sec,
-				      gptab_bss_sec->contents,
-				      (file_ptr) 0,
-				      gptab_bss_sec->_raw_size))
-	return false;
-    }
-
-  return true;
+    return ict_irix6;
 }
 
 /* ECOFF swapping routines.  These are used when dealing with the
@@ -6978,37 +2687,40 @@
 #define elf_backend_can_gc_sections	true
 #define elf_info_to_howto		mips_elf64_info_to_howto_rela
 #define elf_info_to_howto_rel		mips_elf64_info_to_howto_rel
-#define elf_backend_object_p		_bfd_mips_elf_object_p
+#define elf_backend_object_p		mips_elf64_object_p
 #define elf_backend_symbol_processing	_bfd_mips_elf_symbol_processing
 #define elf_backend_section_processing	_bfd_mips_elf_section_processing
 #define elf_backend_section_from_shdr	_bfd_mips_elf_section_from_shdr
 #define elf_backend_fake_sections	_bfd_mips_elf_fake_sections
 #define elf_backend_section_from_bfd_section \
-					_bfd_mips_elf_section_from_bfd_section
+				_bfd_mips_elf_section_from_bfd_section
 #define elf_backend_add_symbol_hook	_bfd_mips_elf_add_symbol_hook
 #define elf_backend_link_output_symbol_hook \
-					_bfd_mips_elf_link_output_symbol_hook
+				_bfd_mips_elf_link_output_symbol_hook
 #define elf_backend_create_dynamic_sections \
-					mips_elf64_create_dynamic_sections
-#define elf_backend_check_relocs	mips_elf64_check_relocs
+				_bfd_mips_elf_create_dynamic_sections
+#define elf_backend_check_relocs	_bfd_mips_elf_check_relocs
 #define elf_backend_adjust_dynamic_symbol \
-					mips_elf64_adjust_dynamic_symbol
+				_bfd_mips_elf_adjust_dynamic_symbol
 #define elf_backend_always_size_sections \
-					mips_elf64_always_size_sections
+				_bfd_mips_elf_always_size_sections
 #define elf_backend_size_dynamic_sections \
-					mips_elf64_size_dynamic_sections
-#define elf_backend_relocate_section    mips_elf64_relocate_section
+				_bfd_mips_elf_size_dynamic_sections
+#define elf_backend_relocate_section    _bfd_mips_elf_relocate_section
 #define elf_backend_finish_dynamic_symbol \
-					mips_elf64_finish_dynamic_symbol
+				_bfd_mips_elf_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
-					mips_elf64_finish_dynamic_sections
+				_bfd_mips_elf_finish_dynamic_sections
 #define elf_backend_final_write_processing \
-					_bfd_mips_elf_final_write_processing
+				_bfd_mips_elf_final_write_processing
 #define elf_backend_additional_program_headers \
-					mips_elf64_additional_program_headers
+				_bfd_mips_elf_additional_program_headers
 #define elf_backend_modify_segment_map	_bfd_mips_elf_modify_segment_map
-#define elf_backend_gc_mark_hook	mips_elf64_gc_mark_hook
-#define elf_backend_gc_sweep_hook	mips_elf64_gc_sweep_hook
+#define elf_backend_gc_mark_hook	_bfd_mips_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook	_bfd_mips_elf_gc_sweep_hook
+#define elf_backend_hide_symbol		_bfd_mips_elf_hide_symbol
+#define elf_backend_mips_irix_compat	elf64_mips_irix_compat
+#define elf_backend_mips_rtype_to_howto	mips_elf64_rtype_to_howto
 #define elf_backend_ecoff_debug_swap	&mips_elf64_ecoff_debug_swap
 #define elf_backend_size_info		mips_elf64_size_info
 
@@ -7016,7 +2728,7 @@
 #define elf_backend_plt_header_size	0
 
 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
- * work better/work only in RELA, so we default to this.  */
+   work better/work only in RELA, so we default to this.  */
 #define elf_backend_may_use_rel_p	1
 #define elf_backend_may_use_rela_p	1
 #define elf_backend_default_use_rela_p	1
@@ -7026,37 +2738,40 @@
    ABI.  */
 #define bfd_elf64_find_nearest_line	_bfd_mips_elf_find_nearest_line
 #define bfd_elf64_set_section_contents	_bfd_mips_elf_set_section_contents
+#define bfd_elf64_bfd_get_relocated_section_contents \
+				_bfd_elf_mips_get_relocated_section_contents
 #define bfd_elf64_bfd_link_hash_table_create \
-					mips_elf64_link_hash_table_create
-#define bfd_elf64_bfd_final_link	mips_elf64_final_link
+				_bfd_mips_elf_link_hash_table_create
+#define bfd_elf64_bfd_final_link	_bfd_mips_elf_final_link
 #define bfd_elf64_bfd_merge_private_bfd_data \
-					_bfd_mips_elf_merge_private_bfd_data
+				_bfd_mips_elf_merge_private_bfd_data
 #define bfd_elf64_bfd_set_private_flags	_bfd_mips_elf_set_private_flags
 #define bfd_elf64_bfd_print_private_bfd_data \
-					_bfd_mips_elf_print_private_bfd_data
+				_bfd_mips_elf_print_private_bfd_data
 
 #define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
-#define bfd_elf64_bfd_reloc_type_lookup	mips_elf64_reloc_type_lookup
+
+/* MIPS ELF64 archive functions.  */
 #define bfd_elf64_archive_functions
 extern boolean bfd_elf64_archive_slurp_armap
   PARAMS((bfd *));
 extern boolean bfd_elf64_archive_write_armap
   PARAMS((bfd *, unsigned int, struct orl *, unsigned int, int));
 #define bfd_elf64_archive_slurp_extended_name_table \
-				_bfd_archive_coff_slurp_extended_name_table
+			_bfd_archive_coff_slurp_extended_name_table
 #define bfd_elf64_archive_construct_extended_name_table \
-				_bfd_archive_coff_construct_extended_name_table
+			_bfd_archive_coff_construct_extended_name_table
 #define bfd_elf64_archive_truncate_arname \
-					_bfd_archive_coff_truncate_arname
+			_bfd_archive_coff_truncate_arname
 #define bfd_elf64_archive_read_ar_hdr	_bfd_archive_coff_read_ar_hdr
 #define bfd_elf64_archive_openr_next_archived_file \
-				_bfd_archive_coff_openr_next_archived_file
+			_bfd_archive_coff_openr_next_archived_file
 #define bfd_elf64_archive_get_elt_at_index \
-					_bfd_archive_coff_get_elt_at_index
+			_bfd_archive_coff_get_elt_at_index
 #define bfd_elf64_archive_generic_stat_arch_elt \
-					_bfd_archive_coff_generic_stat_arch_elt
+			_bfd_archive_coff_generic_stat_arch_elt
 #define bfd_elf64_archive_update_armap_timestamp \
-				_bfd_archive_coff_update_armap_timestamp
+			_bfd_archive_coff_update_armap_timestamp
 
 /* The SGI style (n)64 NewABI.  */
 #define TARGET_LITTLE_SYM		bfd_elf64_littlemips_vec
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index 3bda435..96146ed 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -1953,16 +1953,16 @@
 		       strlen (MMIX_LOC_SECTION_START_SYMBOL_PREFIX)) == 0)
     {
       /* See if we have another one.  */
-      struct elf_link_hash_entry *h
-	= (struct elf_link_hash_entry *) bfd_link_hash_lookup (info->hash,
-							       *namep,
-							       false,
-							       false, false);
+      struct bfd_link_hash_entry *h = bfd_link_hash_lookup (info->hash,
+							    *namep,
+							    false,
+							    false,
+							    false);
 
-      if (h != NULL && h->root.type != bfd_link_hash_undefined)
+      if (h != NULL && h->type != bfd_link_hash_undefined)
 	{
 	  /* How do we get the asymbol (or really: the filename) from h?
-	     h->root.u.def.section->owner is NULL.  */
+	     h->u.def.section->owner is NULL.  */
 	  ((*_bfd_error_handler)
 	   (_("%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"),
 	    bfd_get_filename (abfd), *namep,
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 2e5933a..6cff281 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -39,7 +39,21 @@
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void ppc64_elf_info_to_howto
   PARAMS ((bfd *abfd, arelent *cache_ptr, Elf64_Internal_Rela *dst));
-static bfd_reloc_status_type ppc64_elf_addr16_ha_reloc
+static bfd_reloc_status_type ppc64_elf_ha_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_brtaken_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_sectoff_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_toc_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_toc_ha_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_toc64_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type ppc64_elf_unhandled_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static boolean ppc64_elf_set_private_flags
   PARAMS ((bfd *, flagword));
@@ -47,58 +61,6 @@
   PARAMS ((bfd *, bfd *));
 static boolean ppc64_elf_section_from_shdr
   PARAMS ((bfd *, Elf64_Internal_Shdr *, char *));
-static struct bfd_hash_entry *link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *ppc64_elf_link_hash_table_create
-  PARAMS ((bfd *));
-static boolean create_linkage_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static boolean create_got_section
-  PARAMS ((bfd *, struct bfd_link_info *));
-static boolean ppc64_elf_create_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static void ppc64_elf_copy_indirect_symbol
-  PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
-static boolean ppc64_elf_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-static asection * ppc64_elf_gc_mark_hook
-  PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Rela *rel,
-	   struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
-static boolean ppc64_elf_gc_sweep_hook
-  PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec,
-	   const Elf_Internal_Rela *relocs));
-static boolean func_desc_adjust
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean ppc64_elf_func_desc_adjust
-  PARAMS ((bfd *, struct bfd_link_info *));
-static boolean ppc64_elf_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static void ppc64_elf_hide_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
-static boolean allocate_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean readonly_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static enum elf_reloc_type_class ppc64_elf_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-static boolean ppc64_elf_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_byte *build_plt_stub
-  PARAMS ((bfd *, bfd_byte *, int, int));
-static boolean build_one_stub
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean ppc64_elf_fake_sections
-  PARAMS ((bfd *, Elf64_Internal_Shdr *, asection *));
-static boolean ppc64_elf_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
-	   asection **));
-static boolean ppc64_elf_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-static boolean ppc64_elf_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
 
 
 /* Mask to set RA in memory instructions.  */
@@ -146,6 +108,10 @@
 /* Pad with this.  */
 #define NOP		0x60000000
 
+/* Some other nops.  */
+#define CROR_151515	0x4def7b82
+#define CROR_313131	0x4ffffb82
+
 /* .glink entries for the first 32k functions are two instructions. */
 #define LI_R0_0		0x38000000	/* li    %r0,0		*/
 #define B_DOT		0x48000000	/* b     .		*/
@@ -273,7 +239,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_ha_reloc,	/* special_function */
 	 "R_PPC64_ADDR16_HA",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -306,7 +272,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_brtaken_reloc, /* special_function */
 	 "R_PPC64_ADDR14_BRTAKEN",/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -323,7 +289,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_brtaken_reloc, /* special_function */
 	 "R_PPC64_ADDR14_BRNTAKEN",/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -370,7 +336,7 @@
 	 true,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_brtaken_reloc, /* special_function */
 	 "R_PPC64_REL14_BRTAKEN", /* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -387,7 +353,7 @@
 	 true,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_brtaken_reloc, /* special_function */
 	 "R_PPC64_REL14_BRNTAKEN",/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -403,7 +369,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -419,7 +385,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_LO",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -435,7 +401,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont,/* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_HI",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -451,7 +417,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont,/* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_HA",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -470,7 +436,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	 /* special_function */
+	 ppc64_elf_unhandled_reloc,  /* special_function */
 	 "R_PPC64_COPY",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -486,7 +452,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	 /* special_function */
+	 ppc64_elf_unhandled_reloc,  /* special_function */
 	 "R_PPC64_GLOB_DAT",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -502,7 +468,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_JMP_SLOT",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -516,7 +482,7 @@
 	 0,			/* rightshift */
 	 4,			/* size (0=byte, 1=short, 2=long, 4=64 bits) */
 	 64,			/* bitsize */
-	 false,			/* pc_relative */
+	 true,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
 	 bfd_elf_generic_reloc,	/* special_function */
@@ -524,7 +490,7 @@
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
 	 0xffffffffffffffff,	/* dst_mask */
-	 false),		/* pcrel_offset */
+	 true),			/* pcrel_offset */
 
   /* Like R_PPC64_ADDR32, but may be unaligned.  */
   HOWTO (R_PPC64_UADDR32,	/* type */
@@ -580,7 +546,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT32",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -612,7 +578,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT16_LO",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -628,7 +594,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT16_HI",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -644,31 +610,29 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT16_HA",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
-  /* 32-bit section relative relocation.  */
-  /* FIXME: Verify R_PPC64_SECTOFF.  Seems strange with size=2 and
-     dst_mask=0.  */
+  /* 16-bit section relative relocation.  */
   HOWTO (R_PPC64_SECTOFF,	/* type */
 	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 true,			/* pc_relative */
+	 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 */
+	 ppc64_elf_sectoff_reloc, /* special_function */
 	 "R_PPC64_SECTOFF",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 true),			/* pcrel_offset */
+	 0xffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
 
-  /* 16-bit lower half section relative relocation.  */
+  /* Like R_PPC64_SECTOFF, but no overflow warning.  */
   HOWTO (R_PPC64_SECTOFF_LO,	/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -676,7 +640,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_sectoff_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_LO",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -691,7 +655,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_sectoff_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_HI",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -706,7 +670,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_sectoff_ha_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_HA",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -714,8 +678,7 @@
 	 false),		/* pcrel_offset */
 
   /* Like R_PPC64_REL24 without touching the two least significant
-     bits.  */
-  /* FIXME: Verify R_PPC64_ADDR30.  */
+     bits.  Should have been named R_PPC64_REL30!  */
   HOWTO (R_PPC64_ADDR30,	/* type */
 	 2,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -771,7 +734,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_ha_reloc,	/* special_function */
 	 "R_PPC64_ADDR16_HIGHERA", /* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -802,7 +765,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_ha_reloc,	/* special_function */
 	 "R_PPC64_ADDR16_HIGHESTA", /* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -847,7 +810,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT64",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -864,7 +827,7 @@
 	 true,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTREL64",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -881,7 +844,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_toc_reloc,	/* special_function */
 	 "R_PPC64_TOC16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -898,7 +861,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_toc_reloc,	/* special_function */
 	 "R_PPC64_TOC16_LO",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -915,7 +878,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_toc_reloc,	/* special_function */
 	 "R_PPC64_TOC16_HI",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -934,7 +897,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_toc_ha_reloc, /* special_function */
 	 "R_PPC64_TOC16_HA",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -951,7 +914,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_toc64_reloc,	/* special_function */
 	 "R_PPC64_TOC",		/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -974,7 +937,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -990,7 +953,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_LO",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1006,7 +969,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_HI",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1024,7 +987,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont,/* complain_on_overflow */
-	 ppc64_elf_addr16_ha_reloc, /* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_HA",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1069,7 +1032,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1084,7 +1047,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_LO_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1099,7 +1062,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT16_LO_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1107,21 +1070,19 @@
 	 false),		/* pcrel_offset */
 
   /* Like R_PPC64_SECTOFF, but for instructions with a DS field.  */
-  /* FIXME: Verify R_PPC64_SECTOFF.  Seems strange with size=2 and
-     dst_mask=0.  */
   HOWTO (R_PPC64_SECTOFF_DS,	/* type */
 	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 true,			/* pc_relative */
+	 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 */
+	 ppc64_elf_sectoff_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 true),			/* pcrel_offset */
+	 0xfffc,		/* dst_mask */
+	 false),		/* pcrel_offset */
 
   /* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field.  */
   HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */
@@ -1131,7 +1092,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_sectoff_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_LO_DS",/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1146,7 +1107,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_toc_reloc,	/* special_function */
 	 "R_PPC64_TOC16_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1161,7 +1122,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_toc_reloc,	/* special_function */
 	 "R_PPC64_TOC16_LO_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1177,7 +1138,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_DS",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1193,7 +1154,7 @@
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_LO_DS",/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -1319,7 +1280,7 @@
       break;
     case BFD_RELOC_HI16_S_PLTOFF:	 ppc_reloc = R_PPC64_PLT16_HA;
       break;
-    case BFD_RELOC_32_BASEREL:		 ppc_reloc = R_PPC64_SECTOFF;
+    case BFD_RELOC_16_BASEREL:		 ppc_reloc = R_PPC64_SECTOFF;
       break;
     case BFD_RELOC_LO16_BASEREL:	 ppc_reloc = R_PPC64_SECTOFF_LO;
       break;
@@ -1417,41 +1378,265 @@
 /* Handle the R_PPC_ADDR16_HA and similar relocs.  */
 
 static bfd_reloc_status_type
-ppc64_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
-			   output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
+ppc64_elf_ha_reloc (abfd, reloc_entry, symbol, data,
+		    input_section, output_bfd, error_message)
+     bfd *abfd;
      arelent *reloc_entry;
      asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
+     PTR data;
      asection *input_section;
      bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+     char **error_message;
 {
-  bfd_vma relocation;
-
+  /* If this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
   if (output_bfd != NULL)
-    {
-      reloc_entry->address += input_section->output_offset;
-      return bfd_reloc_ok;
-    }
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
 
-  if (reloc_entry->address > input_section->_cooked_size)
-    return bfd_reloc_outofrange;
-
-  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;
-
-  reloc_entry->addend += (relocation & 0x8000) << 1;
-
+  /* Adjust the addend for sign extension of the low 16 bits.
+     We won't actually be using the low 16 bits, so trashing them
+     doesn't matter.  */
+  reloc_entry->addend += 0x8000;
   return bfd_reloc_continue;
 }
 
+static bfd_reloc_status_type
+ppc64_elf_brtaken_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;
+{
+  long insn;
+  enum elf_ppc_reloc_type r_type;
+  bfd_size_type octets;
+  /* Disabled until we sort out how ld should choose 'y' vs 'at'.  */
+  boolean is_power4 = false;
+
+  /* If this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  octets = reloc_entry->address * bfd_octets_per_byte (abfd);
+  insn = bfd_get_32 (abfd, (bfd_byte *) data + octets);
+  insn &= ~(0x01 << 21);
+  r_type = (enum elf_ppc_reloc_type) reloc_entry->howto->type;
+  if (r_type == R_PPC64_ADDR14_BRTAKEN
+      || r_type == R_PPC64_REL14_BRTAKEN)
+    insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */
+
+  if (is_power4)
+    {
+      /* Set 'a' bit.  This is 0b00010 in BO field for branch
+	 on CR(BI) insns (BO == 001at or 011at), and 0b01000
+	 for branch on CTR insns (BO == 1a00t or 1a01t).  */
+      if ((insn & (0x14 << 21)) == (0x04 << 21))
+	insn |= 0x02 << 21;
+      else if ((insn & (0x14 << 21)) == (0x10 << 21))
+	insn |= 0x08 << 21;
+      else
+	return bfd_reloc_continue;
+    }
+  else
+    {
+      bfd_vma target = 0;
+      bfd_vma from;
+
+      if (!bfd_is_com_section (symbol->section))
+	target = symbol->value;
+      target += symbol->section->output_section->vma;
+      target += symbol->section->output_offset;
+      target += reloc_entry->addend;
+
+      from = (reloc_entry->address
+	      + input_section->output_offset
+	      + input_section->output_section->vma);
+
+      /* Invert 'y' bit if not the default.  */
+      if ((bfd_signed_vma) (target - from) < 0)
+	insn ^= 0x01 << 21;
+    }
+  bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + octets);
+  return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_sectoff_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 this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  /* Subtract the symbol section base address.  */
+  reloc_entry->addend -= symbol->section->output_section->vma;
+  return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_sectoff_ha_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 this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  /* Subtract the symbol section base address.  */
+  reloc_entry->addend -= symbol->section->output_section->vma;
+
+  /* Adjust the addend for sign extension of the low 16 bits.  */
+  reloc_entry->addend += 0x8000;
+  return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_toc_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 TOCstart;
+
+  /* If this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
+  if (TOCstart == 0)
+    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+
+  /* Subtract the TOC base address.  */
+  reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
+  return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_toc_ha_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 TOCstart;
+
+  /* If this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
+  if (TOCstart == 0)
+    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+
+  /* Subtract the TOC base address.  */
+  reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
+
+  /* Adjust the addend for sign extension of the low 16 bits.  */
+  reloc_entry->addend += 0x8000;
+  return bfd_reloc_continue;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_toc64_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 TOCstart;
+  bfd_size_type octets;
+
+  /* If this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
+  if (TOCstart == 0)
+    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+
+  octets = reloc_entry->address * bfd_octets_per_byte (abfd);
+  bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets);
+  return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+ppc64_elf_unhandled_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 this is a relocatable link (output_bfd test tells us), just
+     call the generic function.  Any adjustment will be done at final
+     link time.  */
+  if (output_bfd != NULL)
+    return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,	
+				  input_section, output_bfd, error_message);
+
+  if (error_message != NULL)
+    {
+      static char buf[60];
+      sprintf (buf, "generic linker can't handle %s",
+	       reloc_entry->howto->name);
+      *error_message = buf;
+    }
+  return bfd_reloc_dangerous;
+}
+
 /* Function to set whether a module needs the -mrelocatable bit set.  */
 
 static boolean
@@ -1690,22 +1875,98 @@
    selects between relative and absolute types.  */
 
 #define IS_ABSOLUTE_RELOC(RTYPE)		\
-  ((RTYPE) != R_PPC64_REL14			\
-   && (RTYPE) != R_PPC64_REL14_BRNTAKEN		\
-   && (RTYPE) != R_PPC64_REL14_BRTAKEN		\
-   && (RTYPE) != R_PPC64_REL24			\
-   && (RTYPE) != R_PPC64_REL32			\
-   && (RTYPE) != R_PPC64_REL64)
+  ((RTYPE) != R_PPC64_REL32			\
+   && (RTYPE) != R_PPC64_REL64			\
+   && (RTYPE) != R_PPC64_ADDR30)
 
-/* ppc64 ELF linker hash entry.  */
+/* Section name for stubs is the associated section name plus this
+   string.  */
+#define STUB_SUFFIX ".stub"
+
+/* Linker stubs.
+   ppc_stub_long_branch:
+   Used when a 14 bit branch (or even a 24 bit branch) can't reach its
+   destination, but a 24 bit branch in a stub section will reach.
+   .	b	dest
+
+   ppc_stub_plt_branch:
+   Similar to the above, but a 24 bit branch in the stub section won't
+   reach its destination.
+   .	addis	%r12,%r2,xxx@ha
+   .	ld	%r11,xxx@l(%r12)
+   .	mtctr	%r11
+   .	bctr
+
+   ppc_stub_plt_call:
+   Used to call a function in a shared library.
+   .	addis	%r12,%r2,xxx@ha
+   .	std	%r2,40(%r1)
+   .	ld	%r11,xxx+0@l(%r12)
+   .	ld	%r2,xxx+8@l(%r12)
+   .	mtctr	%r11
+   .	ld	%r11,xxx+16@l(%r12)
+   .	bctr
+*/
+
+enum ppc_stub_type {
+  ppc_stub_none,
+  ppc_stub_long_branch,
+  ppc_stub_plt_branch,
+  ppc_stub_plt_call
+};
+
+struct ppc_stub_hash_entry {
+
+  /* Base hash table entry structure.  */
+  struct bfd_hash_entry root;
+
+  /* The stub section.  */
+  asection *stub_sec;
+
+  /* Offset within stub_sec of the beginning of this stub.  */
+  bfd_vma stub_offset;
+
+  /* Given the symbol's value and its section we can determine its final
+     value when building the stubs (so the stub knows where to jump.  */
+  bfd_vma target_value;
+  asection *target_section;
+
+  enum ppc_stub_type stub_type;
+
+  /* The symbol table entry, if any, that this was derived from.  */
+  struct ppc_link_hash_entry *h;
+
+  /* Where this stub is being called from, or, in the case of combined
+     stub sections, the first input section in the group.  */
+  asection *id_sec;
+};
+
+struct ppc_branch_hash_entry {
+
+  /* Base hash table entry structure.  */
+  struct bfd_hash_entry root;
+
+  /* Offset within .branch_lt.  */
+  unsigned int offset;
+
+  /* Generation marker.  */
+  unsigned int iter;
+};
 
 struct ppc_link_hash_entry
 {
   struct elf_link_hash_entry elf;
 
+  /* A pointer to the most recently used stub hash entry against this
+     symbol.  */
+  struct ppc_stub_hash_entry *stub_cache;
+
   /* Track dynamic relocs copied for this symbol.  */
   struct ppc_dyn_relocs *dyn_relocs;
 
+  /* Link between function code and descriptor symbols.  */
+  struct elf_link_hash_entry *oh;
+
   /* Flag function code and descriptor symbols.  */
   unsigned int is_func:1;
   unsigned int is_func_descriptor:1;
@@ -1717,6 +1978,34 @@
 {
   struct elf_link_hash_table elf;
 
+  /* The stub hash table.  */
+  struct bfd_hash_table stub_hash_table;
+
+  /* Another hash table for plt_branch stubs.  */
+  struct bfd_hash_table branch_hash_table;
+
+  /* Linker stub bfd.  */
+  bfd *stub_bfd;
+
+  /* Linker call-backs.  */
+  asection * (*add_stub_section) PARAMS ((const char *, asection *));
+  void (*layout_sections_again) PARAMS ((void));
+
+  /* Array to keep track of which stub sections have been created, and
+     information on stub grouping.  */
+  struct map_stub {
+    /* This is the section to which stubs in the group will be attached.  */
+    asection *link_sec;
+    /* The stub section.  */
+    asection *stub_sec;
+  } *stub_group;
+
+  /* Assorted information used by ppc64_elf_size_stubs.  */
+  unsigned int bfd_count;
+  int top_index;
+  asection **input_list;
+  Elf_Internal_Sym **all_local_syms;
+
   /* Short-cuts to get to dynamic linker sections.  */
   asection *sgot;
   asection *srelgot;
@@ -1724,22 +2013,186 @@
   asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
-  asection *sstub;
   asection *sglink;
   asection *sfpr;
+  asection *sbrlt;
+  asection *srelbrlt;
 
   /* Set on error.  */
-  int plt_overflow;
+  unsigned int stub_error;
+
+  /* Flag set when small branches are detected.  Used to
+     select suitable defaults for the stub group size.  */
+  unsigned int has_14bit_branch;
+
+  /* Set if we detect a reference undefined weak symbol.  */
+  unsigned int have_undefweak;
+
+  /* Incremented every time we size stubs.  */
+  unsigned int stub_iteration;
 
   /* Small local sym to section mapping cache.  */
   struct sym_sec_cache sym_sec;
 };
 
+static struct bfd_hash_entry *stub_hash_newfunc
+  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_hash_entry *branch_hash_newfunc
+  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_hash_entry *link_hash_newfunc
+  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static struct bfd_link_hash_table *ppc64_elf_link_hash_table_create
+  PARAMS ((bfd *));
+static void ppc64_elf_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
+static char *ppc_stub_name
+  PARAMS ((const asection *, const asection *,
+	   const struct ppc_link_hash_entry *, const Elf_Internal_Rela *));
+static struct ppc_stub_hash_entry *ppc_get_stub_entry
+  PARAMS ((const asection *, const asection *, struct elf_link_hash_entry *,
+	   const Elf_Internal_Rela *, struct ppc_link_hash_table *));
+static struct ppc_stub_hash_entry *ppc_add_stub
+  PARAMS ((const char *, asection *, struct ppc_link_hash_table *));
+static boolean create_linkage_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+static boolean create_got_section
+  PARAMS ((bfd *, struct bfd_link_info *));
+static boolean ppc64_elf_create_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+static void ppc64_elf_copy_indirect_symbol
+  PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
+static boolean ppc64_elf_check_relocs
+  PARAMS ((bfd *, struct bfd_link_info *, asection *,
+	   const Elf_Internal_Rela *));
+static asection * ppc64_elf_gc_mark_hook
+  PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Rela *rel,
+	   struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
+static boolean ppc64_elf_gc_sweep_hook
+  PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec,
+	   const Elf_Internal_Rela *relocs));
+static boolean func_desc_adjust
+  PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean ppc64_elf_func_desc_adjust
+  PARAMS ((bfd *, struct bfd_link_info *));
+static boolean ppc64_elf_adjust_dynamic_symbol
+  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static void ppc64_elf_hide_symbol
+  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
+static boolean allocate_dynrelocs
+  PARAMS ((struct elf_link_hash_entry *, PTR));
+static boolean readonly_dynrelocs
+  PARAMS ((struct elf_link_hash_entry *, PTR));
+static enum elf_reloc_type_class ppc64_elf_reloc_type_class
+  PARAMS ((const Elf_Internal_Rela *));
+static boolean ppc64_elf_size_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+static INLINE enum ppc_stub_type ppc_type_of_stub
+  PARAMS ((asection *, const Elf_Internal_Rela *,
+	   struct ppc_link_hash_entry **, bfd_vma));
+static bfd_byte *build_plt_stub
+  PARAMS ((bfd *, bfd_byte *, int, int));
+static boolean ppc_build_one_stub
+  PARAMS ((struct bfd_hash_entry *, PTR));
+static boolean ppc_size_one_stub
+  PARAMS ((struct bfd_hash_entry *, PTR));
+static void group_sections
+  PARAMS ((struct ppc_link_hash_table *, bfd_size_type, boolean));
+static boolean get_local_syms
+  PARAMS ((bfd *, struct ppc_link_hash_table *));
+static boolean ppc64_elf_fake_sections
+  PARAMS ((bfd *, Elf64_Internal_Shdr *, asection *));
+static boolean ppc64_elf_relocate_section
+  PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *,
+	   Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
+	   asection **));
+static boolean ppc64_elf_finish_dynamic_symbol
+  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+	   Elf_Internal_Sym *));
+static boolean ppc64_elf_finish_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+
 /* Get the ppc64 ELF linker hash table from a link_info structure.  */
 
 #define ppc_hash_table(p) \
   ((struct ppc_link_hash_table *) ((p)->hash))
 
+#define ppc_stub_hash_lookup(table, string, create, copy) \
+  ((struct ppc_stub_hash_entry *) \
+   bfd_hash_lookup ((table), (string), (create), (copy)))
+
+#define ppc_branch_hash_lookup(table, string, create, copy) \
+  ((struct ppc_branch_hash_entry *) \
+   bfd_hash_lookup ((table), (string), (create), (copy)))
+
+/* Create an entry in the stub hash table.  */
+
+static struct bfd_hash_entry *
+stub_hash_newfunc (entry, table, string)
+     struct bfd_hash_entry *entry;
+     struct bfd_hash_table *table;
+     const char *string;
+{
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (entry == NULL)
+    {
+      entry = bfd_hash_allocate (table, sizeof (struct ppc_stub_hash_entry));
+      if (entry == NULL)
+	return entry;
+    }
+
+  /* Call the allocation method of the superclass.  */
+  entry = bfd_hash_newfunc (entry, table, string);
+  if (entry != NULL)
+    {
+      struct ppc_stub_hash_entry *eh;
+
+      /* Initialize the local fields.  */
+      eh = (struct ppc_stub_hash_entry *) entry;
+      eh->stub_sec = NULL;
+      eh->stub_offset = 0;
+      eh->target_value = 0;
+      eh->target_section = NULL;
+      eh->stub_type = ppc_stub_none;
+      eh->h = NULL;
+      eh->id_sec = NULL;
+    }
+
+  return entry;
+}
+
+/* Create an entry in the branch hash table.  */
+
+static struct bfd_hash_entry *
+branch_hash_newfunc (entry, table, string)
+     struct bfd_hash_entry *entry;
+     struct bfd_hash_table *table;
+     const char *string;
+{
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (entry == NULL)
+    {
+      entry = bfd_hash_allocate (table, sizeof (struct ppc_branch_hash_entry));
+      if (entry == NULL)
+	return entry;
+    }
+
+  /* Call the allocation method of the superclass.  */
+  entry = bfd_hash_newfunc (entry, table, string);
+  if (entry != NULL)
+    {
+      struct ppc_branch_hash_entry *eh;
+
+      /* Initialize the local fields.  */
+      eh = (struct ppc_branch_hash_entry *) entry;
+      eh->offset = 0;
+      eh->iter = 0;
+    }
+
+  return entry;
+}
+
 /* Create an entry in a ppc64 ELF linker hash table.  */
 
 static struct bfd_hash_entry *
@@ -1763,7 +2216,9 @@
     {
       struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) entry;
 
+      eh->stub_cache = NULL;
       eh->dyn_relocs = NULL;
+      eh->oh = NULL;
       eh->is_func = 0;
       eh->is_func_descriptor = 0;
     }
@@ -1780,31 +2235,207 @@
   struct ppc_link_hash_table *htab;
   bfd_size_type amt = sizeof (struct ppc_link_hash_table);
 
-  htab = (struct ppc_link_hash_table *) bfd_alloc (abfd, amt);
+  htab = (struct ppc_link_hash_table *) bfd_malloc (amt);
   if (htab == NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc))
     {
-      bfd_release (abfd, htab);
+      free (htab);
       return NULL;
     }
 
+  /* Init the stub hash table too.  */
+  if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc))
+    return NULL;
+
+  /* And the branch hash table.  */
+  if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc))
+    return NULL;
+
+  htab->stub_bfd = NULL;
+  htab->add_stub_section = NULL;
+  htab->layout_sections_again = NULL;
+  htab->stub_group = NULL;
   htab->sgot = NULL;
   htab->srelgot = NULL;
   htab->splt = NULL;
   htab->srelplt = NULL;
   htab->sdynbss = NULL;
   htab->srelbss = NULL;
-  htab->sstub = NULL;
   htab->sglink = NULL;
   htab->sfpr = NULL;
-  htab->plt_overflow = 0;
+  htab->sbrlt = NULL;
+  htab->srelbrlt = NULL;
+  htab->stub_error = 0;
+  htab->has_14bit_branch = 0;
+  htab->have_undefweak = 0;
+  htab->stub_iteration = 0;
   htab->sym_sec.abfd = NULL;
 
   return &htab->elf.root;
 }
 
+/* Free the derived linker hash table.  */
+
+static void
+ppc64_elf_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash;
+{
+  struct ppc_link_hash_table *ret = (struct ppc_link_hash_table *) hash;
+
+  bfd_hash_table_free (&ret->stub_hash_table);
+  bfd_hash_table_free (&ret->branch_hash_table);
+  _bfd_generic_link_hash_table_free (hash);
+}
+
+/* Build a name for an entry in the stub hash table.  */
+
+static char *
+ppc_stub_name (input_section, sym_sec, h, rel)
+     const asection *input_section;
+     const asection *sym_sec;
+     const struct ppc_link_hash_entry *h;
+     const Elf_Internal_Rela *rel;
+{
+  char *stub_name;
+  bfd_size_type len;
+
+  /* rel->r_addend is actually 64 bit, but who uses more than +/- 2^31
+     offsets from a sym as a branch target?  In fact, we could
+     probably assume the addend is always zero.  */
+  BFD_ASSERT (((int) rel->r_addend & 0xffffffff) == rel->r_addend);
+
+  if (h)
+    {
+      len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1;
+      stub_name = bfd_malloc (len);
+      if (stub_name != NULL)
+	{
+	  sprintf (stub_name, "%08x_%s+%x",
+		   input_section->id & 0xffffffff,
+		   h->elf.root.root.string,
+		   (int) rel->r_addend & 0xffffffff);
+	}
+    }
+  else
+    {
+      len = 8 + 1 + 8 + 1 + 8 + 1 + 16 + 1;
+      stub_name = bfd_malloc (len);
+      if (stub_name != NULL)
+	{
+	  sprintf (stub_name, "%08x_%x:%x+%x",
+		   input_section->id & 0xffffffff,
+		   sym_sec->id & 0xffffffff,
+		   (int) ELF64_R_SYM (rel->r_info) & 0xffffffff,
+		   (int) rel->r_addend & 0xffffffff);
+	}
+    }
+  return stub_name;
+}
+
+/* Look up an entry in the stub hash.  Stub entries are cached because
+   creating the stub name takes a bit of time.  */
+
+static struct ppc_stub_hash_entry *
+ppc_get_stub_entry (input_section, sym_sec, hash, rel, htab)
+     const asection *input_section;
+     const asection *sym_sec;
+     struct elf_link_hash_entry *hash;
+     const Elf_Internal_Rela *rel;
+     struct ppc_link_hash_table *htab;
+{
+  struct ppc_stub_hash_entry *stub_entry;
+  struct ppc_link_hash_entry *h = (struct ppc_link_hash_entry *) hash;
+  const asection *id_sec;
+
+  /* If this input section is part of a group of sections sharing one
+     stub section, then use the id of the first section in the group.
+     Stub names need to include a section id, as there may well be
+     more than one stub used to reach say, printf, and we need to
+     distinguish between them.  */
+  id_sec = htab->stub_group[input_section->id].link_sec;
+
+  if (h != NULL && h->stub_cache != NULL
+      && h->stub_cache->h == h
+      && h->stub_cache->id_sec == id_sec)
+    {
+      stub_entry = h->stub_cache;
+    }
+  else
+    {
+      char *stub_name;
+
+      stub_name = ppc_stub_name (id_sec, sym_sec, h, rel);
+      if (stub_name == NULL)
+	return NULL;
+
+      stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table,
+					 stub_name, false, false);
+      if (h != NULL)
+	h->stub_cache = stub_entry;
+
+      free (stub_name);
+    }
+
+  return stub_entry;
+}
+
+/* Add a new stub entry to the stub hash.  Not all fields of the new
+   stub entry are initialised.  */
+
+static struct ppc_stub_hash_entry *
+ppc_add_stub (stub_name, section, htab)
+     const char *stub_name;
+     asection *section;
+     struct ppc_link_hash_table *htab;
+{
+  asection *link_sec;
+  asection *stub_sec;
+  struct ppc_stub_hash_entry *stub_entry;
+
+  link_sec = htab->stub_group[section->id].link_sec;
+  stub_sec = htab->stub_group[section->id].stub_sec;
+  if (stub_sec == NULL)
+    {
+      stub_sec = htab->stub_group[link_sec->id].stub_sec;
+      if (stub_sec == NULL)
+	{
+	  bfd_size_type len;
+	  char *s_name;
+
+	  len = strlen (link_sec->name) + sizeof (STUB_SUFFIX);
+	  s_name = bfd_alloc (htab->stub_bfd, len);
+	  if (s_name == NULL)
+	    return NULL;
+
+	  strcpy (s_name, link_sec->name);
+	  strcpy (s_name + len - sizeof (STUB_SUFFIX), STUB_SUFFIX);
+	  stub_sec = (*htab->add_stub_section) (s_name, link_sec);
+	  if (stub_sec == NULL)
+	    return NULL;
+	  htab->stub_group[link_sec->id].stub_sec = stub_sec;
+	}
+      htab->stub_group[section->id].stub_sec = stub_sec;
+    }
+
+  /* Enter this entry into the linker stub hash table.  */
+  stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table, stub_name,
+				     true, false);
+  if (stub_entry == NULL)
+    {
+      (*_bfd_error_handler) (_("%s: cannot create stub entry %s"),
+			     bfd_archive_filename (section->owner),
+			     stub_name);
+      return NULL;
+    }
+
+  stub_entry->stub_sec = stub_sec;
+  stub_entry->stub_offset = 0;
+  stub_entry->id_sec = link_sec;
+  return stub_entry;
+}
+
 /* Create sections for linker generated code.  */
 
 static boolean
@@ -1820,24 +2451,38 @@
   /* Create .sfpr for code to save and restore fp regs.  */
   flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
 	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-  htab->sfpr = bfd_make_section (dynobj, ".sfpr");
+  htab->sfpr = bfd_make_section_anyway (dynobj, ".sfpr");
   if (htab->sfpr == NULL
       || ! bfd_set_section_flags (dynobj, htab->sfpr, flags)
       || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2))
     return false;
 
-  /* Create .stub and .glink for global linkage functions.  */
-  htab->sstub = bfd_make_section (dynobj, ".stub");
-  if (htab->sstub == NULL
-      || ! bfd_set_section_flags (dynobj, htab->sstub, flags)
-      || ! bfd_set_section_alignment (dynobj, htab->sstub, 2))
-    return false;
-  htab->sglink = bfd_make_section (dynobj, ".glink");
+  /* Create .glink for lazy dynamic linking support.  */
+  htab->sglink = bfd_make_section_anyway (dynobj, ".glink");
   if (htab->sglink == NULL
       || ! bfd_set_section_flags (dynobj, htab->sglink, flags)
       || ! bfd_set_section_alignment (dynobj, htab->sglink, 2))
     return false;
 
+  /* Create .branch_lt for plt_branch stubs.  */
+  flags = (SEC_ALLOC | SEC_LOAD
+	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+  htab->sbrlt = bfd_make_section_anyway (dynobj, ".branch_lt");
+  if (htab->sbrlt == NULL
+      || ! bfd_set_section_flags (dynobj, htab->sbrlt, flags)
+      || ! bfd_set_section_alignment (dynobj, htab->sbrlt, 3))
+    return false;
+
+  if (info->shared)
+    {
+      flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+	       | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+      htab->srelbrlt = bfd_make_section (dynobj, ".rela.branch_lt");
+      if (!htab->srelbrlt
+	  || ! bfd_set_section_flags (dynobj, htab->srelbrlt, flags)
+	  || ! bfd_set_section_alignment (dynobj, htab->srelbrlt, 3))
+	return false;
+    }
   return true;
 }
 
@@ -2099,6 +2744,12 @@
 	    return false;
 	  break;
 
+	case R_PPC64_REL14:
+	case R_PPC64_REL14_BRTAKEN:
+	case R_PPC64_REL14_BRNTAKEN:
+	  htab->has_14bit_branch = 1;
+	  /* Fall through.  */
+
 	case R_PPC64_REL24:
 	  if (h != NULL
 	      && h->root.root.string[0] == '.'
@@ -2130,16 +2781,15 @@
 		     in ppc64_elf_hide_symbol.  */
 		  fdh->root.root.string = h->root.root.string + 1;
 		  ((struct ppc_link_hash_entry *) fdh)->is_func_descriptor = 1;
+		  ((struct ppc_link_hash_entry *) fdh)->oh = h;
 		  ((struct ppc_link_hash_entry *) h)->is_func = 1;
+		  ((struct ppc_link_hash_entry *) h)->oh = fdh;
 		}
 	    }
 	  /* Fall through.  */
 
 	case R_PPC64_REL64:
 	case R_PPC64_REL32:
-	case R_PPC64_REL14:
-	case R_PPC64_REL14_BRTAKEN:
-	case R_PPC64_REL14_BRNTAKEN:
 	case R_PPC64_ADDR14:
 	case R_PPC64_ADDR14_BRNTAKEN:
 	case R_PPC64_ADDR14_BRTAKEN:
@@ -2407,6 +3057,9 @@
 	    }
 	  break;
 
+	case R_PPC64_REL14:
+	case R_PPC64_REL14_BRNTAKEN:
+	case R_PPC64_REL14_BRTAKEN:
 	case R_PPC64_REL24:
 	  if (r_symndx >= symtab_hdr->sh_info)
 	    {
@@ -2416,9 +3069,6 @@
 	    }
 	  break;
 
-	case R_PPC64_REL14:
-	case R_PPC64_REL14_BRNTAKEN:
-	case R_PPC64_REL14_BRTAKEN:
 	case R_PPC64_REL32:
 	case R_PPC64_REL64:
 	  if (r_symndx >= symtab_hdr->sh_info)
@@ -2501,10 +3151,12 @@
   struct bfd_link_info *info;
   struct ppc_link_hash_table *htab;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = ppc_hash_table (info);
 
@@ -2513,18 +3165,23 @@
   if (!((struct ppc_link_hash_entry *) h)->is_func)
     return true;
 
+  if (h->root.type == bfd_link_hash_undefweak
+      && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR))
+    htab->have_undefweak = true;
+
   if (h->plt.refcount > 0
       && h->root.root.string[0] == '.'
       && h->root.root.string[1] != '\0')
     {
-      struct elf_link_hash_entry *fdh;
+      struct elf_link_hash_entry *fdh = ((struct ppc_link_hash_entry *) h)->oh;
       boolean force_local;
 
       /* Find the corresponding function descriptor symbol.  Create it
 	 as undefined if necessary.  */
 
-      fdh = elf_link_hash_lookup (&htab->elf, h->root.root.string + 1,
-				  false, false, true);
+      if (fdh == NULL)
+	fdh = elf_link_hash_lookup (&htab->elf, h->root.root.string + 1,
+				    false, false, true);
 
       if (fdh == NULL
 	  && info->shared
@@ -2573,7 +3230,9 @@
 	      fdh->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
 	    }
 	  ((struct ppc_link_hash_entry *) fdh)->is_func_descriptor = 1;
+	  ((struct ppc_link_hash_entry *) fdh)->oh = h;
 	  fdh->root.root.string = h->root.root.string + 1;
+	  ((struct ppc_link_hash_entry *) h)->oh = fdh;
 	}
 
       /* Now that the info is on the function descriptor, clear the
@@ -2608,6 +3267,7 @@
   unsigned int lowest_restf = MAX_SAVE_FPR + 2;
   unsigned int i;
   struct elf_link_hash_entry *h;
+  bfd_byte *p;
   char sym[10];
 
   htab = ppc_hash_table (info);
@@ -2658,43 +3318,53 @@
 	}
     }
 
+  elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info);
+
   htab->sfpr->_raw_size = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4
 			   + (MAX_SAVE_FPR + 2 - lowest_restf) * 4);
 
   if (htab->sfpr->_raw_size == 0)
     {
-      _bfd_strip_section_from_output (info, htab->sfpr);
+      if (!htab->have_undefweak)
+	{
+	  _bfd_strip_section_from_output (info, htab->sfpr);
+	  return true;
+	}
+
+      htab->sfpr->_raw_size = 4;
     }
-  else
+
+  p = (bfd_byte *) bfd_alloc (htab->elf.dynobj, htab->sfpr->_raw_size);
+  if (p == NULL)
+    return false;
+  htab->sfpr->contents = p;
+
+  for (i = lowest_savef; i <= MAX_SAVE_FPR; i++)
     {
-      bfd_byte *p = (bfd_byte *) bfd_alloc (htab->elf.dynobj,
-					    htab->sfpr->_raw_size);
-      if (p == NULL)
-	return false;
-      htab->sfpr->contents = p;
-
-      for (i = lowest_savef; i <= MAX_SAVE_FPR; i++)
-	{
-	  unsigned int fpr = i << 21;
-	  unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
-	  bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p);
-	  p += 4;
-	}
-      bfd_put_32 (htab->elf.dynobj, BLR, p);
+      unsigned int fpr = i << 21;
+      unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
+      bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p);
       p += 4;
-
-      for (i = lowest_restf; i <= MAX_SAVE_FPR; i++)
-	{
-	  unsigned int fpr = i << 21;
-	  unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
-	  bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p);
-	  p += 4;
-	}
+    }
+  if (lowest_savef <= MAX_SAVE_FPR)
+    {
       bfd_put_32 (htab->elf.dynobj, BLR, p);
       p += 4;
     }
 
-  elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info);
+  for (i = lowest_restf; i <= MAX_SAVE_FPR; i++)
+    {
+      unsigned int fpr = i << 21;
+      unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8;
+      bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p);
+      p += 4;
+    }
+  if (lowest_restf <= MAX_SAVE_FPR
+      || htab->sfpr->_raw_size == 4)
+    {
+      bfd_put_32 (htab->elf.dynobj, BLR, p);
+    }
+
   return true;
 }
 
@@ -2839,12 +3509,13 @@
   if (((struct ppc_link_hash_entry *) h)->is_func_descriptor)
     {
       const char *name;
-      struct elf_link_hash_entry *fh;
+      struct elf_link_hash_entry *fh = ((struct ppc_link_hash_entry *) h)->oh;
       struct ppc_link_hash_table *htab;
 
       name = h->root.root.string - 1;
       htab = ppc_hash_table (info);
-      fh = elf_link_hash_lookup (&htab->elf, name, false, false, false);
+      if (fh == NULL)
+	fh = elf_link_hash_lookup (&htab->elf, name, false, false, false);
       if (fh != NULL)
 	_bfd_elf_link_hash_hide_symbol (info, fh, force_local);
     }
@@ -2875,10 +3546,12 @@
   struct ppc_link_hash_entry *eh;
   struct ppc_dyn_relocs *p;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = ppc_hash_table (info);
 
@@ -2901,10 +3574,7 @@
 	  /* Make room for this entry.  */
 	  s->_raw_size += PLT_ENTRY_SIZE;
 
-	  /* Make room for the .stub and .glink code.  */
-	  s = htab->sstub;
-	  s->_raw_size += PLT_CALL_STUB_SIZE;
-
+	  /* Make room for the .glink code.  */
 	  s = htab->sglink;
 	  if (s->_raw_size == 0)
 	    s->_raw_size += GLINK_CALL_STUB_SIZE;
@@ -3034,6 +3704,9 @@
   struct ppc_link_hash_entry *eh;
   struct ppc_dyn_relocs *p;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   eh = (struct ppc_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
@@ -3155,15 +3828,15 @@
   relocs = false;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
-      bfd_vma size;
-
       if ((s->flags & SEC_LINKER_CREATED) == 0)
 	continue;
 
-      if (s == htab->splt
-	  || s == htab->sgot
-	  || s == htab->sstub
-	  || s == htab->sglink)
+      if (s == htab->sbrlt || s == htab->srelbrlt)
+	/* These haven't been allocated yet;  don't strip.  */
+	continue;
+      else if (s == htab->splt
+	       || s == htab->sgot
+	       || s == htab->sglink)
 	{
 	  /* Strip this section if we don't need it; see the
 	     comment below.  */
@@ -3209,13 +3882,7 @@
 	 section's contents are written out.  This should not happen,
 	 but this way if it does, we get a R_PPC64_NONE reloc instead
 	 of garbage.  */
-      size = s->_raw_size;
-      if (s == htab->sstub)
-	{
-	  /* .stub may grow.  Allocate enough for the maximum growth.  */
-	  size += (size + 65536 + 65535) / 65536 * 4;
-	}
-      s->contents = (bfd_byte *) bfd_zalloc (dynobj, size);
+      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
       if (s->contents == NULL)
 	return false;
     }
@@ -3278,124 +3945,55 @@
   return true;
 }
 
-/* Called after we have seen all the input files/sections, but before
-   final symbol resolution and section placement has been determined.
+/* Determine the type of stub needed, if any, for a call.  */
 
-   We use this hook to provide a value for TOCstart, which we store in
-   the output bfd elf_gp.  */
-
-boolean
-ppc64_elf_set_toc (obfd, info)
-     bfd *obfd;
-     struct bfd_link_info *info;
+static INLINE enum ppc_stub_type
+ppc_type_of_stub (input_sec, rel, hash, destination)
+     asection *input_sec;
+     const Elf_Internal_Rela *rel;
+     struct ppc_link_hash_entry **hash;
+     bfd_vma destination;
 {
-  if (!info->relocateable)
+  struct ppc_link_hash_entry *h = *hash;
+  bfd_vma location;
+  bfd_vma branch_offset;
+  bfd_vma max_branch_offset;
+  unsigned int r_type;
+
+  if (h != NULL)
     {
-      asection *s;
-      bfd_vma TOCstart;
-
-      /* The TOC consists of sections .got, .toc, .tocbss, .plt in that
-	 order.  The TOC starts where the first of these sections starts.  */
-      s = bfd_get_section_by_name (obfd, ".got");
-      if (s == NULL)
-	s = bfd_get_section_by_name (obfd, ".toc");
-      if (s == NULL)
-	s = bfd_get_section_by_name (obfd, ".tocbss");
-      if (s == NULL)
-	s = bfd_get_section_by_name (obfd, ".plt");
-      if (s == NULL)
+      if (h->oh != NULL
+	  && h->oh->plt.offset != (bfd_vma) -1
+	  && h->oh->dynindx != -1)
 	{
-	  /* This may happen for
-	     o  references to TOC base (SYM@toc / TOC[tc0]) without a
-	     .toc directive
-	     o  bad linker script
-	     o --gc-sections and empty TOC sections
-
-	     FIXME: Warn user?  */
-
-	  /* Look for a likely section.  We probably won't even be
-	     using TOCstart.  */
-	  for (s = obfd->sections; s != NULL; s = s->next)
-	    if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY))
-		== (SEC_ALLOC | SEC_SMALL_DATA))
-	      break;
-	  if (s == NULL)
-	    for (s = obfd->sections; s != NULL; s = s->next)
-	      if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA))
-		  == (SEC_ALLOC | SEC_SMALL_DATA))
-		break;
-	  if (s == NULL)
-	    for (s = obfd->sections; s != NULL; s = s->next)
-	      if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
-		break;
-	  if (s == NULL)
-	    for (s = obfd->sections; s != NULL; s = s->next)
-	      if ((s->flags & SEC_ALLOC) == SEC_ALLOC)
-		break;
+	  *hash = (struct ppc_link_hash_entry *) h->oh;
+	  return ppc_stub_plt_call;
 	}
 
-      TOCstart = 0;
-      if (s != NULL)
-	TOCstart = s->output_section->vma + s->output_offset;
-
-      elf_gp (obfd) = TOCstart;
+      if (h->elf.root.type == bfd_link_hash_undefweak
+	  || h->elf.root.type == bfd_link_hash_undefined)
+	return ppc_stub_none;
     }
-  return true;
-}
 
-/* PowerPC64 .plt entries are 24 bytes long, which doesn't divide
-   evenly into 64k.  Sometimes with a large enough .plt, we'll need to
-   use offsets differing in the high 16 bits when accessing a .plt
-   entry from a .plt call stub.  This function adjusts the size of
-   .stub to accommodate the extra stub instruction needed in such
-   cases.  */
+  /* Determine where the call point is.  */
+  location = (input_sec->output_offset
+	      + input_sec->output_section->vma
+	      + rel->r_offset);
 
-boolean
-ppc64_elf_size_stubs (obfd, info, changed)
-     bfd *obfd;
-     struct bfd_link_info *info;
-     int *changed;
-{
-  struct ppc_link_hash_table *htab = ppc_hash_table (info);
-  bfd_vma plt_offset, next_64k;
-  long base, num, extra;
+  branch_offset = destination - location;
+  r_type = ELF64_R_TYPE (rel->r_info);
 
-  /* .plt and .stub should be both present, or both absent.  */
-  if ((htab->splt == NULL || htab->splt->_raw_size == 0)
-      != (htab->sstub == NULL || htab->sstub->_raw_size == 0))
-    abort ();
+  /* Determine if a long branch stub is needed.  */
+  max_branch_offset = 1 << 25;
+  if (r_type != (unsigned int) R_PPC64_REL24)
+    max_branch_offset = 1 << 15;
 
-  /* If no .plt, then nothing to do.  */
-  if (htab->splt == NULL || htab->splt->_raw_size == 0)
-    return true;
+  if (branch_offset + max_branch_offset >= 2 * max_branch_offset)
+    /* We need a stub.  Figure out whether a long_branch or plt_branch
+       is needed later.  */
+    return ppc_stub_long_branch;
 
-  plt_offset = (htab->splt->output_section->vma
-		+ htab->splt->output_offset
-		- elf_gp (obfd));
-  next_64k = (plt_offset + 65535) & -65536;
-
-  /* If the .plt doesn't have any entries crossing a 64k boundary,
-     then there is no need for bigger stubs.  */
-  if (plt_offset + htab->splt->_raw_size <= next_64k)
-    return true;
-
-  /* OK, so we have at least one transition.  Since .plt entries are
-     24 bytes long, we'll strike it lucky every 3*64k, with the 64k
-     boundary between .plt entries.  */
-  base = next_64k / 65536;
-  num = (plt_offset + htab->splt->_raw_size - next_64k) / 65536;
-  extra = (base % 3 + num + 1) * 2 / 3;
-
-  /* Allow one extra instruction for each EXTRA.  The change in .stub
-     may change the location of .toc and .plt.  .toc and .plt ought to
-     move as a group, but someone might be playing with eg. .plt
-     alignment, so don't allow .stub size to decrease.  */
-  if (htab->sstub->_cooked_size < htab->sstub->_raw_size + extra * 4)
-    {
-      htab->sstub->_cooked_size = htab->sstub->_raw_size + extra * 4;
-      *changed = true;
-    }
-  return true;
+  return ppc_stub_none;
 }
 
 /* Build a .plt call stub.  */
@@ -3430,139 +4028,957 @@
   return p;
 }
 
-/* Build the stubs for one function call.  */
-
 static boolean
-build_one_stub (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+ppc_build_one_stub (gen_entry, in_arg)
+     struct bfd_hash_entry *gen_entry;
+     PTR in_arg;
 {
+  struct ppc_stub_hash_entry *stub_entry;
+  struct ppc_branch_hash_entry *br_entry;
   struct bfd_link_info *info;
   struct ppc_link_hash_table *htab;
+  asection *stub_sec;
+  bfd *stub_bfd;
+  bfd_byte *loc;
+  bfd_byte *p;
+  unsigned int indx;
+  bfd_vma off;
+  int size;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
-    return true;
+  /* Massage our args to the form they really have.  */
+  stub_entry = (struct ppc_stub_hash_entry *) gen_entry;
+  info = (struct bfd_link_info *) in_arg;
 
-  info = (struct bfd_link_info *) inf;
   htab = ppc_hash_table (info);
+  stub_sec = stub_entry->stub_sec;
 
-  if (htab->elf.dynamic_sections_created
-      && h->plt.offset != (bfd_vma) -1
-      && ((struct ppc_link_hash_entry *) h)->is_func_descriptor)
+  /* Make a note of the offset within the stubs for this entry.  */
+  stub_entry->stub_offset = stub_sec->_cooked_size;
+  loc = stub_sec->contents + stub_entry->stub_offset;
+
+  stub_bfd = stub_sec->owner;
+
+  switch (stub_entry->stub_type)
     {
-      struct elf_link_hash_entry *fh;
-      asection *s;
-      bfd_vma plt_r2;
-      bfd_byte *p;
-      unsigned int indx;
+    case ppc_stub_long_branch:
+      /* Branches are relative.  This is where we are going to.  */
+      off = (stub_entry->target_value
+	     + stub_entry->target_section->output_offset
+	     + stub_entry->target_section->output_section->vma);
 
-      fh = elf_link_hash_lookup (&htab->elf, h->root.root.string - 1,
-				 false, false, true);
+      /* And this is where we are coming from.  */
+      off -= (stub_entry->stub_offset
+	      + stub_sec->output_offset
+	      + stub_sec->output_section->vma);
 
-      if (fh == NULL)
-	abort ();
+      BFD_ASSERT (off + (1 << 25) < (bfd_vma) (1 << 26));
 
-      BFD_ASSERT (((struct ppc_link_hash_entry *) fh)->is_func);
+      bfd_put_32 (stub_bfd, (bfd_vma) B_DOT | (off & 0x3fffffc), loc);
+      size = 4;
+      break;
 
-      /* Build the .plt call stub.  */
-      plt_r2 = (htab->splt->output_section->vma
-		+ htab->splt->output_offset
-		+ h->plt.offset
-		- elf_gp (htab->splt->output_section->owner)
-		- TOC_BASE_OFF);
-
-      if (plt_r2 + 0x80000000 > 0xffffffff
-	  || (plt_r2 & 3) != 0)
+    case ppc_stub_plt_branch:
+      br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
+					 stub_entry->root.string + 9,
+					 false, false);
+      if (br_entry == NULL)
 	{
-	  (*_bfd_error_handler)
-	    (_("linkage table error against `%s'"),
-	     h->root.root.string);
-	  bfd_set_error (bfd_error_bad_value);
-	  htab->plt_overflow = true;
+	  (*_bfd_error_handler) (_("can't find branch stub `%s'"),
+				 stub_entry->root.string + 9);
+	  htab->stub_error = true;
 	  return false;
 	}
 
-      s = htab->sstub;
-      /* Steal plt.offset to store the stub offset.  */
-      fh->plt.offset = s->_cooked_size;
-      p = s->contents + s->_cooked_size;
-      p = build_plt_stub (s->owner, p, (int) plt_r2, 0);
-      s->_cooked_size = p - s->contents;
+      off = (stub_entry->target_value
+	     + stub_entry->target_section->output_offset
+	     + stub_entry->target_section->output_section->vma);
 
+      bfd_put_64 (htab->sbrlt->owner, off,
+		  htab->sbrlt->contents + br_entry->offset);
+
+      if (info->shared)
+	{
+	  /* Create a reloc for the branch lookup table entry.  */
+	  Elf_Internal_Rela rela;
+	  Elf64_External_Rela *r;
+
+	  rela.r_offset = (br_entry->offset
+			   + htab->sbrlt->output_offset
+			   + htab->sbrlt->output_section->vma);
+	  rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
+	  rela.r_addend = off;
+
+	  r = (Elf64_External_Rela *) htab->srelbrlt->contents;
+	  r += htab->srelbrlt->reloc_count++;
+	  bfd_elf64_swap_reloca_out (htab->srelbrlt->owner, &rela, r);
+	}
+
+      off = (br_entry->offset
+	     + htab->sbrlt->output_offset
+	     + htab->sbrlt->output_section->vma
+	     - elf_gp (htab->sbrlt->output_section->owner)
+	     - TOC_BASE_OFF);
+
+      if (off + 0x80000000 > 0xffffffff || (off & 7) != 0)
+	{
+	  (*_bfd_error_handler)
+	    (_("linkage table error against `%s'"),
+	     stub_entry->root.string);
+	  bfd_set_error (bfd_error_bad_value);
+	  htab->stub_error = true;
+	  return false;
+	}
+
+      indx = off;
+      bfd_put_32 (stub_bfd, (bfd_vma) ADDIS_R12_R2 | PPC_HA (indx), loc);
+      bfd_put_32 (stub_bfd, (bfd_vma) LD_R11_0R12 | PPC_LO (indx), loc + 4);
+      bfd_put_32 (stub_bfd, (bfd_vma) MTCTR_R11, loc + 8);
+      bfd_put_32 (stub_bfd, (bfd_vma) BCTR, loc + 12);
+      size = 16;
+      break;
+
+    case ppc_stub_plt_call:
       /* Build the .glink lazy link call stub.  */
-      s = htab->sglink;
-      p = s->contents + s->_cooked_size;
-      indx = s->reloc_count;
+      p = htab->sglink->contents + htab->sglink->_cooked_size;
+      indx = htab->sglink->reloc_count;
       if (indx < 0x8000)
 	{
-	  bfd_put_32 (s->owner, LI_R0_0 | indx, p);
+	  bfd_put_32 (htab->sglink->owner, LI_R0_0 | indx, p);
 	  p += 4;
 	}
       else
 	{
-	  bfd_put_32 (s->owner, LIS_R0_0 | PPC_HI (indx), p);
+	  bfd_put_32 (htab->sglink->owner, LIS_R0_0 | PPC_HI (indx), p);
 	  p += 4;
-	  bfd_put_32 (s->owner, ORI_R0_R0_0 | PPC_LO (indx), p);
+	  bfd_put_32 (htab->sglink->owner, ORI_R0_R0_0 | PPC_LO (indx), p);
 	  p += 4;
 	}
-      bfd_put_32 (s->owner, B_DOT | ((s->contents - p) & 0x3fffffc), p);
+      bfd_put_32 (htab->sglink->owner,
+		  B_DOT | ((htab->sglink->contents - p) & 0x3fffffc), p);
       p += 4;
-      s->_cooked_size = p - s->contents;
-      s->reloc_count += 1;
+      htab->sglink->_cooked_size = p - htab->sglink->contents;
+      htab->sglink->reloc_count += 1;
+
+      /* Now build the stub.  */
+      off = stub_entry->h->elf.plt.offset;
+      if (off >= (bfd_vma) -2)
+	abort ();
+
+      off &= ~ (bfd_vma) 1;
+      off += (htab->splt->output_offset
+	      + htab->splt->output_section->vma
+	      - elf_gp (htab->splt->output_section->owner)
+	      - TOC_BASE_OFF);
+
+      if (off + 0x80000000 > 0xffffffff || (off & 7) != 0)
+	{
+	  (*_bfd_error_handler)
+	    (_("linkage table error against `%s'"),
+	     stub_entry->h->elf.root.root.string);
+	  bfd_set_error (bfd_error_bad_value);
+	  htab->stub_error = true;
+	  return false;
+	}
+
+      p = build_plt_stub (stub_bfd, loc, (int) off, 0);
+      size = p - loc;
+      break;
+
+    default:
+      BFD_FAIL ();
+      return false;
     }
+
+  stub_sec->_cooked_size += size;
   return true;
 }
 
+/* As above, but don't actually build the stub.  Just bump offset so
+   we know stub section sizes, and select plt_branch stubs where
+   long_branch stubs won't do.  */
+
+static boolean
+ppc_size_one_stub (gen_entry, in_arg)
+     struct bfd_hash_entry *gen_entry;
+     PTR in_arg;
+{
+  struct ppc_stub_hash_entry *stub_entry;
+  struct ppc_link_hash_table *htab;
+  bfd_vma off;
+  int size;
+
+  /* Massage our args to the form they really have.  */
+  stub_entry = (struct ppc_stub_hash_entry *) gen_entry;
+  htab = (struct ppc_link_hash_table *) in_arg;
+
+  if (stub_entry->stub_type == ppc_stub_plt_call)
+    {
+      off = stub_entry->h->elf.plt.offset & ~(bfd_vma) 1;
+      off += (htab->splt->output_offset
+	      + htab->splt->output_section->vma
+	      - elf_gp (htab->splt->output_section->owner)
+	      - TOC_BASE_OFF);
+
+      size = 28;
+      if (PPC_HA ((int) off + 16) != PPC_HA ((int) off))
+	size += 4;
+    }
+  else
+    {
+      /* ppc_stub_long_branch or ppc_stub_plt_branch.  */
+      stub_entry->stub_type = ppc_stub_long_branch;
+      size = 4;
+
+      off = (stub_entry->target_value
+	     + stub_entry->target_section->output_offset
+	     + stub_entry->target_section->output_section->vma);
+      off -= (stub_entry->stub_sec->_raw_size
+	      + stub_entry->stub_sec->output_offset
+	      + stub_entry->stub_sec->output_section->vma);
+
+      if (off + (1 << 25) >= (bfd_vma) (1 << 26))
+	{
+	  struct ppc_branch_hash_entry *br_entry;
+
+	  br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
+					     stub_entry->root.string + 9,
+					     true, false);
+	  if (br_entry == NULL)
+	    {
+	      (*_bfd_error_handler) (_("can't build branch stub `%s'"),
+				     stub_entry->root.string + 9);
+	      htab->stub_error = true;
+	      return false;
+	    }
+
+	  if (br_entry->iter != htab->stub_iteration)
+	    {
+	      br_entry->iter = htab->stub_iteration;
+	      br_entry->offset = htab->sbrlt->_raw_size;
+	      htab->sbrlt->_raw_size += 8;
+	    }
+	  stub_entry->stub_type = ppc_stub_plt_branch;
+	  size = 16;
+	}
+    }
+
+  stub_entry->stub_sec->_raw_size += size;
+  return true;
+}
+
+/* Set up various things so that we can make a list of input sections
+   for each output section included in the link.  Returns -1 on error,
+   0 when no stubs will be needed, and 1 on success. */
+
+int
+ppc64_elf_setup_section_lists (output_bfd, info)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+{
+  bfd *input_bfd;
+  unsigned int bfd_count;
+  int top_id, top_index;
+  asection *section;
+  asection **input_list, **list;
+  bfd_size_type amt;
+  struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+  if (htab->elf.root.creator->flavour != bfd_target_elf_flavour
+      || htab->sbrlt == NULL)
+    return 0;
+
+  /* Count the number of input BFDs and find the top input section id.  */
+  for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
+       input_bfd != NULL;
+       input_bfd = input_bfd->link_next)
+    {
+      bfd_count += 1;
+      for (section = input_bfd->sections;
+	   section != NULL;
+	   section = section->next)
+	{
+	  if (top_id < section->id)
+	    top_id = section->id;
+	}
+    }
+  htab->bfd_count = bfd_count;
+
+  amt = sizeof (struct map_stub) * (top_id + 1);
+  htab->stub_group = (struct map_stub *) bfd_zmalloc (amt);
+  if (htab->stub_group == NULL)
+    return -1;
+
+  /* We can't use output_bfd->section_count here to find the top output
+     section index as some sections may have been removed, and
+     _bfd_strip_section_from_output doesn't renumber the indices.  */
+  for (section = output_bfd->sections, top_index = 0;
+       section != NULL;
+       section = section->next)
+    {
+      if (top_index < section->index)
+	top_index = section->index;
+    }
+
+  htab->top_index = top_index;
+  amt = sizeof (asection *) * (top_index + 1);
+  input_list = (asection **) bfd_malloc (amt);
+  htab->input_list = input_list;
+  if (input_list == NULL)
+    return -1;
+
+  /* For sections we aren't interested in, mark their entries with a
+     value we can check later.  */
+  list = input_list + top_index;
+  do
+    *list = bfd_abs_section_ptr;
+  while (list-- != input_list);
+
+  for (section = output_bfd->sections;
+       section != NULL;
+       section = section->next)
+    {
+      if ((section->flags & SEC_CODE) != 0)
+	input_list[section->index] = NULL;
+    }
+
+  return 1;
+}
+
+/* The linker repeatedly calls this function for each input section,
+   in the order that input sections are linked into output sections.
+   Build lists of input sections to determine groupings between which
+   we may insert linker stubs.  */
+
+void
+ppc64_elf_next_input_section (info, isec)
+     struct bfd_link_info *info;
+     asection *isec;
+{
+  struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+  if (isec->output_section->index <= htab->top_index)
+    {
+      asection **list = htab->input_list + isec->output_section->index;
+      if (*list != bfd_abs_section_ptr)
+	{
+	  /* Steal the link_sec pointer for our list.  */
+#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
+	  /* This happens to make the list in reverse order,
+	     which is what we want.  */
+	  PREV_SEC (isec) = *list;
+	  *list = isec;
+	}
+    }
+}
+
+/* See whether we can group stub sections together.  Grouping stub
+   sections may result in fewer stubs.  More importantly, we need to
+   put all .init* and .fini* stubs at the beginning of the .init or
+   .fini output sections respectively, because glibc splits the
+   _init and _fini functions into multiple parts.  Putting a stub in
+   the middle of a function is not a good idea.  */
+
+static void
+group_sections (htab, stub_group_size, stubs_always_before_branch)
+     struct ppc_link_hash_table *htab;
+     bfd_size_type stub_group_size;
+     boolean stubs_always_before_branch;
+{
+  asection **list = htab->input_list + htab->top_index;
+  do
+    {
+      asection *tail = *list;
+      if (tail == bfd_abs_section_ptr)
+	continue;
+      while (tail != NULL)
+	{
+	  asection *curr;
+	  asection *prev;
+	  bfd_size_type total;
+
+	  curr = tail;
+	  if (tail->_cooked_size)
+	    total = tail->_cooked_size;
+	  else
+	    total = tail->_raw_size;
+	  while ((prev = PREV_SEC (curr)) != NULL
+		 && ((total += curr->output_offset - prev->output_offset)
+		     < stub_group_size))
+	    curr = prev;
+
+	  /* OK, the size from the start of CURR to the end is less
+	     than stub_group_size and thus can be handled by one stub
+	     section.  (or the tail section is itself larger than
+	     stub_group_size, in which case we may be toast.)  We
+	     should really be keeping track of the total size of stubs
+	     added here, as stubs contribute to the final output
+	     section size.  That's a little tricky, and this way will
+	     only break if stubs added make the total size more than
+	     2^25, ie. for the default stub_group_size, if stubs total
+	     more than 2834432 bytes, or over 100000 plt call stubs.  */
+	  do
+	    {
+	      prev = PREV_SEC (tail);
+	      /* Set up this stub group.  */
+	      htab->stub_group[tail->id].link_sec = curr;
+	    }
+	  while (tail != curr && (tail = prev) != NULL);
+
+	  /* But wait, there's more!  Input sections up to stub_group_size
+	     bytes before the stub section can be handled by it too.  */
+	  if (!stubs_always_before_branch)
+	    {
+	      total = 0;
+	      while (prev != NULL
+		     && ((total += tail->output_offset - prev->output_offset)
+			 < stub_group_size))
+		{
+		  tail = prev;
+		  prev = PREV_SEC (tail);
+		  htab->stub_group[tail->id].link_sec = curr;
+		}
+	    }
+	  tail = prev;
+	}
+    }
+  while (list-- != htab->input_list);
+  free (htab->input_list);
+#undef PREV_SEC
+}
+
+/* Read in all local syms for all input bfds.  */
+
+static boolean
+get_local_syms (input_bfd, htab)
+     bfd *input_bfd;
+     struct ppc_link_hash_table *htab;
+{
+  unsigned int bfd_indx;
+  Elf_Internal_Sym *local_syms, **all_local_syms;
+
+  /* We want to read in symbol extension records only once.  To do this
+     we need to read in the local symbols in parallel and save them for
+     later use; so hold pointers to the local symbols in an array.  */
+  bfd_size_type amt = sizeof (Elf_Internal_Sym *) * htab->bfd_count;
+  all_local_syms = (Elf_Internal_Sym **) bfd_zmalloc (amt);
+  htab->all_local_syms = all_local_syms;
+  if (all_local_syms == NULL)
+    return false;
+
+  /* Walk over all the input BFDs, swapping in local symbols.
+     If we are creating a shared library, create hash entries for the
+     export stubs.  */
+  for (bfd_indx = 0;
+       input_bfd != NULL;
+       input_bfd = input_bfd->link_next, bfd_indx++)
+    {
+      Elf_Internal_Shdr *symtab_hdr;
+      Elf_Internal_Shdr *shndx_hdr;
+      Elf_Internal_Sym *isym;
+      Elf64_External_Sym *ext_syms, *esym, *end_sy;
+      Elf_External_Sym_Shndx *shndx_buf, *shndx;
+      bfd_size_type sec_size;
+
+      /* We'll need the symbol table in a second.  */
+      symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+      if (symtab_hdr->sh_info == 0)
+	continue;
+
+      /* We need an array of the local symbols attached to the input bfd.
+	 Unfortunately, we're going to have to read & swap them in.  */
+      sec_size = symtab_hdr->sh_info;
+      sec_size *= sizeof (Elf_Internal_Sym);
+      local_syms = (Elf_Internal_Sym *) bfd_malloc (sec_size);
+      if (local_syms == NULL)
+	return false;
+
+      all_local_syms[bfd_indx] = local_syms;
+      sec_size = symtab_hdr->sh_info;
+      sec_size *= sizeof (Elf64_External_Sym);
+      ext_syms = (Elf64_External_Sym *) bfd_malloc (sec_size);
+      if (ext_syms == NULL)
+	return false;
+
+      if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
+	  || bfd_bread ((PTR) ext_syms, sec_size, input_bfd) != sec_size)
+	{
+	error_ret_free_ext_syms:
+	  free (ext_syms);
+	  return false;
+	}
+
+      shndx_buf = NULL;
+      shndx_hdr = &elf_tdata (input_bfd)->symtab_shndx_hdr;
+      if (shndx_hdr->sh_size != 0)
+	{
+	  sec_size = symtab_hdr->sh_info;
+	  sec_size *= sizeof (Elf_External_Sym_Shndx);
+	  shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (sec_size);
+	  if (shndx_buf == NULL)
+	    goto error_ret_free_ext_syms;
+
+	  if (bfd_seek (input_bfd, shndx_hdr->sh_offset, SEEK_SET) != 0
+	      || bfd_bread ((PTR) shndx_buf, sec_size, input_bfd) != sec_size)
+	    {
+	      free (shndx_buf);
+	      goto error_ret_free_ext_syms;
+	    }
+	}
+
+      /* Swap the local symbols in.  */
+      for (esym = ext_syms, end_sy = esym + symtab_hdr->sh_info,
+	     isym = local_syms, shndx = shndx_buf;
+	   esym < end_sy;
+	   esym++, isym++, shndx = (shndx ? shndx + 1 : NULL))
+	bfd_elf64_swap_symbol_in (input_bfd, esym, shndx, isym);
+
+      /* Now we can free the external symbols.  */
+      free (shndx_buf);
+      free (ext_syms);
+    }
+
+  return true;
+}
+
+/* Determine and set the size of the stub section for a final link.
+
+   The basic idea here is to examine all the relocations looking for
+   PC-relative calls to a target that is unreachable with a "bl"
+   instruction.  */
+
 boolean
-ppc64_elf_build_stubs (obfd, info)
+ppc64_elf_size_stubs (output_bfd, stub_bfd, info, group_size,
+		      add_stub_section, layout_sections_again)
+     bfd *output_bfd;
+     bfd *stub_bfd;
+     struct bfd_link_info *info;
+     bfd_signed_vma group_size;
+     asection * (*add_stub_section) PARAMS ((const char *, asection *));
+     void (*layout_sections_again) PARAMS ((void));
+{
+  bfd_size_type stub_group_size;
+  boolean stubs_always_before_branch;
+  boolean ret = false;
+  struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+  /* Stash our params away.  */
+  htab->stub_bfd = stub_bfd;
+  htab->add_stub_section = add_stub_section;
+  htab->layout_sections_again = layout_sections_again;
+  stubs_always_before_branch = group_size < 0;
+  if (group_size < 0)
+    stub_group_size = -group_size;
+  else
+    stub_group_size = group_size;
+  if (stub_group_size == 1)
+    {
+      /* Default values.  */
+      stub_group_size = 30720000;
+      if (htab->has_14bit_branch)
+	stub_group_size = 30000;
+    }
+
+  group_sections (htab, stub_group_size, stubs_always_before_branch);
+
+  if (! get_local_syms (info->input_bfds, htab))
+    {
+      if (htab->all_local_syms)
+	goto error_ret_free_local;
+      return false;
+    }
+
+  while (1)
+    {
+      bfd *input_bfd;
+      unsigned int bfd_indx;
+      asection *stub_sec;
+      boolean stub_changed;
+
+      htab->stub_iteration += 1;
+      stub_changed = false;
+
+      for (input_bfd = info->input_bfds, bfd_indx = 0;
+	   input_bfd != NULL;
+	   input_bfd = input_bfd->link_next, bfd_indx++)
+	{
+	  Elf_Internal_Shdr *symtab_hdr;
+	  asection *section;
+	  Elf_Internal_Sym *local_syms;
+
+	  /* We'll need the symbol table in a second.  */
+	  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+	  if (symtab_hdr->sh_info == 0)
+	    continue;
+
+	  local_syms = htab->all_local_syms[bfd_indx];
+
+	  /* Walk over each section attached to the input bfd.  */
+	  for (section = input_bfd->sections;
+	       section != NULL;
+	       section = section->next)
+	    {
+	      Elf_Internal_Shdr *input_rel_hdr;
+	      Elf64_External_Rela *external_relocs, *erelaend, *erela;
+	      Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
+	      bfd_size_type amt;
+
+	      /* If there aren't any relocs, then there's nothing more
+		 to do.  */
+	      if ((section->flags & SEC_RELOC) == 0
+		  || section->reloc_count == 0)
+		continue;
+
+	      /* If this section is a link-once section that will be
+		 discarded, then don't create any stubs.  */
+	      if (section->output_section == NULL
+		  || section->output_section->owner != output_bfd)
+		continue;
+
+	      /* Allocate space for the external relocations.  */
+	      amt = section->reloc_count;
+	      amt *= sizeof (Elf64_External_Rela);
+	      external_relocs = (Elf64_External_Rela *) bfd_malloc (amt);
+	      if (external_relocs == NULL)
+		{
+		  goto error_ret_free_local;
+		}
+
+	      /* Likewise for the internal relocations.  */
+	      amt = section->reloc_count;
+	      amt *= sizeof (Elf_Internal_Rela);
+	      internal_relocs = (Elf_Internal_Rela *) bfd_malloc (amt);
+	      if (internal_relocs == NULL)
+		{
+		  free (external_relocs);
+		  goto error_ret_free_local;
+		}
+
+	      /* Read in the external relocs.  */
+	      input_rel_hdr = &elf_section_data (section)->rel_hdr;
+	      if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0
+		  || bfd_bread ((PTR) external_relocs,
+				input_rel_hdr->sh_size,
+				input_bfd) != input_rel_hdr->sh_size)
+		{
+		  free (external_relocs);
+		error_ret_free_internal:
+		  free (internal_relocs);
+		  goto error_ret_free_local;
+		}
+
+	      /* Swap in the relocs.  */
+	      erela = external_relocs;
+	      erelaend = erela + section->reloc_count;
+	      irela = internal_relocs;
+	      for (; erela < erelaend; erela++, irela++)
+		bfd_elf64_swap_reloca_in (input_bfd, erela, irela);
+
+	      /* We're done with the external relocs, free them.  */
+	      free (external_relocs);
+
+	      /* Now examine each relocation.  */
+	      irela = internal_relocs;
+	      irelaend = irela + section->reloc_count;
+	      for (; irela < irelaend; irela++)
+		{
+		  unsigned int r_type, r_indx;
+		  enum ppc_stub_type stub_type;
+		  struct ppc_stub_hash_entry *stub_entry;
+		  asection *sym_sec;
+		  bfd_vma sym_value;
+		  bfd_vma destination;
+		  struct ppc_link_hash_entry *hash;
+		  char *stub_name;
+		  const asection *id_sec;
+
+		  r_type = ELF64_R_TYPE (irela->r_info);
+		  r_indx = ELF64_R_SYM (irela->r_info);
+
+		  if (r_type >= (unsigned int) R_PPC_max)
+		    {
+		      bfd_set_error (bfd_error_bad_value);
+		      goto error_ret_free_internal;
+		    }
+
+		  /* Only look for stubs on branch instructions.  */
+		  if (r_type != (unsigned int) R_PPC64_REL24
+		      && r_type != (unsigned int) R_PPC64_REL14
+		      && r_type != (unsigned int) R_PPC64_REL14_BRTAKEN
+		      && r_type != (unsigned int) R_PPC64_REL14_BRNTAKEN)
+		    continue;
+
+		  /* Now determine the call target, its name, value,
+		     section.  */
+		  sym_sec = NULL;
+		  sym_value = 0;
+		  destination = 0;
+		  hash = NULL;
+		  if (r_indx < symtab_hdr->sh_info)
+		    {
+		      /* It's a local symbol.  */
+		      Elf_Internal_Sym *sym;
+		      Elf_Internal_Shdr *hdr;
+
+		      sym = local_syms + r_indx;
+		      hdr = elf_elfsections (input_bfd)[sym->st_shndx];
+		      sym_sec = hdr->bfd_section;
+		      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+			sym_value = sym->st_value;
+		      destination = (sym_value + irela->r_addend
+				     + sym_sec->output_offset
+				     + sym_sec->output_section->vma);
+		    }
+		  else
+		    {
+		      /* It's an external symbol.  */
+		      int e_indx;
+
+		      e_indx = r_indx - symtab_hdr->sh_info;
+		      hash = ((struct ppc_link_hash_entry *)
+			      elf_sym_hashes (input_bfd)[e_indx]);
+
+		      while (hash->elf.root.type == bfd_link_hash_indirect
+			     || hash->elf.root.type == bfd_link_hash_warning)
+			hash = ((struct ppc_link_hash_entry *)
+				hash->elf.root.u.i.link);
+
+		      if (hash->elf.root.type == bfd_link_hash_defined
+			  || hash->elf.root.type == bfd_link_hash_defweak)
+			{
+			  sym_sec = hash->elf.root.u.def.section;
+			  sym_value = hash->elf.root.u.def.value;
+			  if (sym_sec->output_section != NULL)
+			    destination = (sym_value + irela->r_addend
+					   + sym_sec->output_offset
+					   + sym_sec->output_section->vma);
+			}
+		      else if (hash->elf.root.type == bfd_link_hash_undefweak)
+			;
+		      else if (hash->elf.root.type == bfd_link_hash_undefined)
+			;
+		      else
+			{
+			  bfd_set_error (bfd_error_bad_value);
+			  goto error_ret_free_internal;
+			}
+		    }
+
+		  /* Determine what (if any) linker stub is needed.  */
+		  stub_type = ppc_type_of_stub (section, irela, &hash,
+						destination);
+		  if (stub_type == ppc_stub_none)
+		    continue;
+
+		  /* Support for grouping stub sections.  */
+		  id_sec = htab->stub_group[section->id].link_sec;
+
+		  /* Get the name of this stub.  */
+		  stub_name = ppc_stub_name (id_sec, sym_sec, hash, irela);
+		  if (!stub_name)
+		    goto error_ret_free_internal;
+
+		  stub_entry = ppc_stub_hash_lookup (&htab->stub_hash_table,
+						     stub_name, false, false);
+		  if (stub_entry != NULL)
+		    {
+		      /* The proper stub has already been created.  */
+		      free (stub_name);
+		      continue;
+		    }
+
+		  stub_entry = ppc_add_stub (stub_name, section, htab);
+		  if (stub_entry == NULL)
+		    {
+		      free (stub_name);
+		      goto error_ret_free_local;
+		    }
+
+		  stub_entry->target_value = sym_value;
+		  stub_entry->target_section = sym_sec;
+		  stub_entry->stub_type = stub_type;
+		  stub_entry->h = hash;
+		  stub_changed = true;
+		}
+
+	      /* We're done with the internal relocs, free them.  */
+	      free (internal_relocs);
+	    }
+	}
+
+      if (!stub_changed)
+	break;
+
+      /* OK, we've added some stubs.  Find out the new size of the
+	 stub sections.  */
+      for (stub_sec = htab->stub_bfd->sections;
+	   stub_sec != NULL;
+	   stub_sec = stub_sec->next)
+	{
+	  stub_sec->_raw_size = 0;
+	  stub_sec->_cooked_size = 0;
+	}
+      htab->sbrlt->_raw_size = 0;
+      htab->sbrlt->_cooked_size = 0;
+
+      bfd_hash_traverse (&htab->stub_hash_table, ppc_size_one_stub, htab);
+
+      /* Ask the linker to do its stuff.  */
+      (*htab->layout_sections_again) ();
+    }
+
+  if (htab->sbrlt->_raw_size == 0)
+    {
+      _bfd_strip_section_from_output (info, htab->sbrlt);
+      if (htab->srelbrlt != NULL)
+	_bfd_strip_section_from_output (info, htab->srelbrlt);
+    }
+
+  ret = true;
+
+ error_ret_free_local:
+  while (htab->bfd_count-- > 0)
+    if (htab->all_local_syms[htab->bfd_count])
+      free (htab->all_local_syms[htab->bfd_count]);
+  free (htab->all_local_syms);
+
+  return ret;
+}
+
+/* Called after we have determined section placement.  If sections
+   move, we'll be called again.  Provide a value for TOCstart.  */
+
+bfd_vma
+ppc64_elf_toc (obfd)
      bfd *obfd;
+{
+  asection *s;
+  bfd_vma TOCstart;
+
+  /* The TOC consists of sections .got, .toc, .tocbss, .plt in that
+     order.  The TOC starts where the first of these sections starts.  */
+  s = bfd_get_section_by_name (obfd, ".got");
+  if (s == NULL)
+    s = bfd_get_section_by_name (obfd, ".toc");
+  if (s == NULL)
+    s = bfd_get_section_by_name (obfd, ".tocbss");
+  if (s == NULL)
+    s = bfd_get_section_by_name (obfd, ".plt");
+  if (s == NULL)
+    {
+      /* This may happen for
+	 o  references to TOC base (SYM@toc / TOC[tc0]) without a
+	 .toc directive
+	 o  bad linker script
+	 o --gc-sections and empty TOC sections
+
+	 FIXME: Warn user?  */
+
+      /* Look for a likely section.  We probably won't even be
+	 using TOCstart.  */
+      for (s = obfd->sections; s != NULL; s = s->next)
+	if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY))
+	    == (SEC_ALLOC | SEC_SMALL_DATA))
+	  break;
+      if (s == NULL)
+	for (s = obfd->sections; s != NULL; s = s->next)
+	  if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA))
+	      == (SEC_ALLOC | SEC_SMALL_DATA))
+	    break;
+      if (s == NULL)
+	for (s = obfd->sections; s != NULL; s = s->next)
+	  if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
+	    break;
+      if (s == NULL)
+	for (s = obfd->sections; s != NULL; s = s->next)
+	  if ((s->flags & SEC_ALLOC) == SEC_ALLOC)
+	    break;
+    }
+
+  TOCstart = 0;
+  if (s != NULL)
+    TOCstart = s->output_section->vma + s->output_offset;
+
+  return TOCstart;
+}
+
+/* Build all the stubs associated with the current output file.
+   The stubs are kept in a hash table attached to the main linker
+   hash table.  This function is called via gldelf64ppc_finish.  */
+
+boolean
+ppc64_elf_build_stubs (info)
      struct bfd_link_info *info;
 {
   struct ppc_link_hash_table *htab = ppc_hash_table (info);
-  bfd_vma old_stub_size;
+  asection *stub_sec;
   bfd_vma plt_r2;
   bfd_byte *p;
 
-  /* If no .plt stubs, then nothing to do.  */
-  if (htab->sstub == NULL || htab->sstub->_raw_size == 0)
-    return true;
-
-  old_stub_size = htab->sstub->_cooked_size;
-  htab->sstub->_cooked_size = 0;
-
-  /* Build the .glink plt call stub.  */
-  plt_r2 = (htab->splt->output_section->vma
-	    + htab->splt->output_offset
-	    - elf_gp (obfd)
-	    - TOC_BASE_OFF);
-  p = htab->sglink->contents;
-  p = build_plt_stub (htab->sglink->owner, p, (int) plt_r2, 1);
-  while (p - htab->sglink->contents < GLINK_CALL_STUB_SIZE)
+  for (stub_sec = htab->stub_bfd->sections;
+       stub_sec != NULL;
+       stub_sec = stub_sec->next)
     {
-      bfd_put_32 (htab->sglink->owner, NOP, p);
-      p += 4;
+      bfd_size_type size;
+
+      /* Allocate memory to hold the linker stubs.  */
+      size = stub_sec->_raw_size;
+      if (size != 0)
+	{
+	  stub_sec->contents = (bfd_byte *) bfd_zalloc (htab->stub_bfd, size);
+	  if (stub_sec->contents == NULL)
+	    return false;
+	}
+      stub_sec->_cooked_size = 0;
     }
-  htab->sglink->_cooked_size = p - htab->sglink->contents;
 
-  /* Use reloc_count to count entries.  */
+  if (htab->splt != NULL)
+    {
+      /* Build the .glink plt call stub.  */
+      plt_r2 = (htab->splt->output_offset
+		+ htab->splt->output_section->vma
+		- elf_gp (htab->splt->output_section->owner)
+		- TOC_BASE_OFF);
+      p = htab->sglink->contents;
+      p = build_plt_stub (htab->sglink->owner, p, (int) plt_r2, 1);
+      while (p - htab->sglink->contents < GLINK_CALL_STUB_SIZE)
+	{
+	  bfd_put_32 (htab->sglink->owner, NOP, p);
+	  p += 4;
+	}
+      htab->sglink->_cooked_size = p - htab->sglink->contents;
+
+      /* Use reloc_count to count entries.  */
+      htab->sglink->reloc_count = 0;
+    }
+
+  if (htab->sbrlt->_raw_size != 0)
+    {
+      htab->sbrlt->contents = (bfd_byte *) bfd_zalloc (htab->sbrlt->owner,
+						       htab->sbrlt->_raw_size);
+      if (htab->sbrlt->contents == NULL)
+	return false;
+    }
+
+  /* Build the stubs as directed by the stub hash table.  */
+  bfd_hash_traverse (&htab->stub_hash_table, ppc_build_one_stub, info);
   htab->sglink->reloc_count = 0;
 
-  elf_link_hash_traverse (&htab->elf, build_one_stub, (PTR) info);
-  htab->sglink->reloc_count = 0;
+  for (stub_sec = htab->stub_bfd->sections;
+       stub_sec != NULL;
+       stub_sec = stub_sec->next)
+    {
+      if (stub_sec->_raw_size != stub_sec->_cooked_size)
+	break;
+    }
 
-  if (htab->plt_overflow)
-    return false;
-
-  if (old_stub_size != htab->sstub->_cooked_size
+  if (stub_sec != NULL
       || htab->sglink->_raw_size != htab->sglink->_cooked_size)
     {
-      (*_bfd_error_handler)
-	(_("stub section size doesn't match calculated size"));
-      bfd_set_error (bfd_error_bad_value);
-      return false;
+      htab->stub_error = true;
+      (*_bfd_error_handler) (_("stubs don't match calculated size"));
     }
-  return true;
+
+  return !htab->stub_error;
 }
 
 /* Set up any other section flags and such that may be necessary.  */
@@ -3657,12 +5073,15 @@
       Elf_Internal_Sym *sym;
       asection *sec;
       struct elf_link_hash_entry *h;
+      struct elf_link_hash_entry *fdh;
       const char *sym_name;
       unsigned long r_symndx;
       bfd_vma relocation;
       boolean unresolved_reloc;
-      boolean has_nop;
       long insn;
+      struct ppc_stub_hash_entry *stub_entry;
+      bfd_vma max_br_offset;
+      bfd_vma from;
 
       r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
       r_symndx = ELF64_R_SYM (rel->r_info);
@@ -3709,6 +5128,7 @@
 	  sym_name = "<local symbol>";
 
 	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+	  /* rel may have changed, update our copy of addend.  */
 	  addend = rel->r_addend;
 	}
       else
@@ -3784,8 +5204,12 @@
 	    }
 	  else
 	    {
+	      from = (offset
+		      + input_section->output_offset
+		      + input_section->output_section->vma);
+
 	      /* Invert 'y' bit if not the default.  */
-	      if ((bfd_signed_vma) (relocation - offset) < 0)
+	      if ((bfd_signed_vma) (relocation + addend - from) < 0)
 		insn ^= 0x01 << 21;
 	    }
 
@@ -3793,57 +5217,72 @@
 	  break;
 
 	case R_PPC64_REL24:
-	case R_PPC64_ADDR24:
-	  /* An ADDR24 or REL24 branching to a linkage function may be
-	     followed by a nop that we have to replace with a ld in
-	     order to restore the TOC base pointer.  Only calls to
-	     shared objects need to alter the TOC base.  These are
-	     recognized by their need for a PLT entry.  */
-	  has_nop = 0;
+	  /* A REL24 branching to a linkage function is followed by a
+	     nop.  We replace the nop with a ld in order to restore
+	     the TOC base pointer.  Only calls to shared objects need
+	     to alter the TOC base.  These are recognized by their
+	     need for a PLT entry.  */
 	  if (h != NULL
-	      && h->plt.offset != (bfd_vma) -1
-	      && htab->sstub != NULL)
+	      && (fdh = ((struct ppc_link_hash_entry *) h)->oh) != NULL
+	      && fdh->plt.offset != (bfd_vma) -1
+	      && (stub_entry = ppc_get_stub_entry (input_section, sec, fdh,
+						   rel, htab)) != NULL)
 	    {
-	      /* plt.offset here is the offset into the stub section.  */
-	      relocation = (htab->sstub->output_section->vma
-			    + htab->sstub->output_offset
-			    + h->plt.offset);
-	      unresolved_reloc = false;
+	      boolean can_plt_call = 0;
 
-	      /* Make sure that there really is an instruction after
-                 the branch that we can decode.  */
 	      if (offset + 8 <= input_section->_cooked_size)
 		{
-		  bfd_byte *pnext;
-
-		  pnext = contents + offset + 4;
-		  insn = bfd_get_32 (input_bfd, pnext);
-
-		  if (insn == 0x60000000	 /* nop (ori  r0,r0,0) */
-		      || insn == 0x4def7b82	 /* cror 15,15,15 */
-		      || insn == 0x4ffffb82) /* cror 31,31,31 */
+		  insn = bfd_get_32 (input_bfd, contents + offset + 4);
+		  if (insn == NOP
+		      || insn == CROR_151515 || insn == CROR_313131)
 		    {
-		      bfd_put_32 (input_bfd,
-				  (bfd_vma) 0xe8410028, /* ld r2,40(r1) */
-				  pnext);
-		      has_nop = 1;
+		      bfd_put_32 (input_bfd, (bfd_vma) LD_R2_40R1,
+				  contents + offset + 4);
+		      can_plt_call = 1;
 		    }
 		}
+
+	      if (!can_plt_call)
+		{
+		  /* If this is a plain branch rather than a branch
+		     and link, don't require a nop.  */
+		  insn = bfd_get_32 (input_bfd, contents + offset);
+		  if ((insn & 1) == 0)
+		    can_plt_call = 1;
+		}
+
+	      if (can_plt_call)
+		{
+		  relocation = (stub_entry->stub_offset
+				+ stub_entry->stub_sec->output_offset
+				+ stub_entry->stub_sec->output_section->vma);
+		  addend = 0;
+		  unresolved_reloc = false;
+		}
 	    }
 
 	  if (h != NULL
 	      && h->root.type == bfd_link_hash_undefweak
-	      && r_type == R_PPC64_REL24
-	      && addend == 0
-	      && relocation == 0)
+	      && relocation == 0
+	      && addend == 0)
 	    {
-	      /* Tweak calls to undefined weak functions to behave as
-		 if the "called" function immediately returns.  We can
-		 thus call to a weak function without first checking
-		 whether the function is defined.  */
-	      relocation = 4;
-	      if (has_nop)
-		relocation = 8;
+	      /* Tweak calls to undefined weak functions to point at a
+		 blr.  We can thus call a weak function without first
+		 checking whether the function is defined.  We have a
+		 blr at the end of .sfpr.  */
+	      BFD_ASSERT (htab->sfpr->_raw_size != 0);
+	      relocation = (htab->sfpr->_raw_size - 4
+			    + htab->sfpr->output_offset
+			    + htab->sfpr->output_section->vma);
+	      from = (offset
+		      + input_section->output_offset
+		      + input_section->output_section->vma);
+
+	      /* But let's not be silly about it.  If the blr isn't in
+		 reach, just go to the next instruction.  */
+	      if (relocation - from + (1 << 25) >= (1 << 26)
+		  || htab->sfpr->_raw_size == 0)
+		relocation = from + 4;
 	    }
 	  break;
 	}
@@ -4022,14 +5461,14 @@
 	    addend -= sec->output_section->vma;
 	  break;
 
+	case R_PPC64_REL14:
+	case R_PPC64_REL14_BRNTAKEN:
+	case R_PPC64_REL14_BRTAKEN:
 	case R_PPC64_REL24:
 	  break;
 
 	  /* Relocations that may need to be propagated if this is a
 	     dynamic object.  */
-	case R_PPC64_REL14:
-	case R_PPC64_REL14_BRNTAKEN:
-	case R_PPC64_REL14_BRTAKEN:
 	case R_PPC64_REL32:
 	case R_PPC64_REL64:
 	case R_PPC64_ADDR14:
@@ -4246,6 +5685,34 @@
 	      continue;
 	    }
 	  break;
+
+	case R_PPC64_REL14:
+	case R_PPC64_REL14_BRNTAKEN:
+	case R_PPC64_REL14_BRTAKEN:
+	  max_br_offset = 1 << 15;
+	  goto branch_check;
+
+	case R_PPC64_REL24:
+	  max_br_offset = 1 << 25;
+
+	branch_check:
+	  /* If the branch is out of reach, then redirect the
+	     call to the local stub for this function.  */
+	  from = (offset
+		  + input_section->output_offset
+		  + input_section->output_section->vma);
+	  if (relocation + addend - from + max_br_offset >= 2 * max_br_offset
+	      && (stub_entry = ppc_get_stub_entry (input_section, sec, h,
+						   rel, htab)) != NULL)
+	    {
+	      /* Munge up the value and addend so that we call the stub
+		 rather than the procedure directly.  */
+	      relocation = (stub_entry->stub_offset
+			    + stub_entry->stub_sec->output_offset
+			    + stub_entry->stub_sec->output_section->vma);
+	      addend = 0;
+	    }
+	  break;
 	}
 
       /* FIXME: Why do we allow debugging sections to escape this error?
@@ -4591,6 +6058,7 @@
 #define bfd_elf64_bfd_set_private_flags	      ppc64_elf_set_private_flags
 #define bfd_elf64_bfd_merge_private_bfd_data  ppc64_elf_merge_private_bfd_data
 #define bfd_elf64_bfd_link_hash_table_create  ppc64_elf_link_hash_table_create
+#define bfd_elf64_bfd_link_hash_table_free    ppc64_elf_link_hash_table_free
 
 #define elf_backend_section_from_shdr	      ppc64_elf_section_from_shdr
 #define elf_backend_create_dynamic_sections   ppc64_elf_create_dynamic_sections
diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h
index b261a58..86f687e 100644
--- a/bfd/elf64-ppc.h
+++ b/bfd/elf64-ppc.h
@@ -17,6 +17,14 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-boolean ppc64_elf_set_toc PARAMS ((bfd *, struct bfd_link_info *));
-boolean ppc64_elf_size_stubs PARAMS ((bfd *, struct bfd_link_info *, int *));
-boolean ppc64_elf_build_stubs PARAMS ((bfd *, struct bfd_link_info *));
+bfd_vma ppc64_elf_toc
+  PARAMS ((bfd *));
+int ppc64_elf_setup_section_lists
+  PARAMS ((bfd *, struct bfd_link_info *));
+void ppc64_elf_next_input_section
+  PARAMS ((struct bfd_link_info *, asection *));
+boolean ppc64_elf_size_stubs
+  PARAMS ((bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
+	   asection *(*) (const char *, asection *), void (*) (void)));
+boolean ppc64_elf_build_stubs
+  PARAMS ((struct bfd_link_info *));
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 5be7928..c4c3c1d 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1,5 +1,5 @@
 /* IBM S/390-specific support for 64-bit ELF
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed Martin Schwidefsky (schwidefsky@de.ibm.com).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -424,13 +424,13 @@
   struct elf_s390_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
 
-  ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1169,10 +1169,12 @@
   struct elf_s390_link_hash_entry *eh;
   struct elf_s390_dyn_relocs *p;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = elf_s390_hash_table (info);
 
@@ -1339,6 +1341,9 @@
   struct elf_s390_link_hash_entry *eh;
   struct elf_s390_dyn_relocs *p;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   eh = (struct elf_s390_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index 5b11aa8..b168934 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -2929,7 +2929,8 @@
      bfd_vma *valp;
 {
   /* We want to do this for relocatable as well as final linking.  */
-  if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL)
+  if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL
+      && info->hash->creator->flavour == bfd_target_elf_flavour)
     {
       struct elf_link_hash_entry *h;
 
@@ -3227,14 +3228,14 @@
   struct elf_sh64_link_hash_table *ret;
 
   ret = ((struct elf_sh64_link_hash_table *)
-	 bfd_alloc (abfd, sizeof (struct elf_sh64_link_hash_table)));
+	 bfd_malloc (sizeof (struct elf_sh64_link_hash_table)));
   if (ret == (struct elf_sh64_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       sh64_elf64_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -3607,6 +3608,9 @@
 {
   struct elf_sh64_pcrel_relocs_copied *s;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct elf_sh64_link_hash_entry *) h->root.root.u.i.link;
+
   /* 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;
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 0f81fa2..4933f8d 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -1,5 +1,5 @@
 /* SPARC-specific support for 64-bit ELF
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -659,14 +659,14 @@
   struct sparc64_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct sparc64_elf_link_hash_table);
 
-  ret = (struct sparc64_elf_link_hash_table *) bfd_zalloc (abfd, amt);
+  ret = (struct sparc64_elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct sparc64_elf_link_hash_table *) NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
 				       _bfd_elf_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1385,9 +1385,8 @@
       *namep = NULL;
       return true;
     }
-  else if (! *namep || ! **namep)
-    return true;
-  else
+  else if (*namep && **namep
+	   && info->hash->creator->flavour == bfd_target_elf_flavour)
     {
       int i;
       struct sparc64_elf_app_reg *p;
@@ -1881,6 +1880,17 @@
   return true;
 }
 
+/* This is the condition under which finish_dynamic_symbol will be called
+   from elflink.h.  If elflink.h doesn't call our finish_dynamic_symbol
+   routine, we'll need to do something about initializing any .plt and
+   .got entries in relocate_section.  */
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H)			\
+  ((DYN)								\
+   && ((INFO)->shared							\
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)	\
+   && ((H)->dynindx != -1						\
+       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
+
 /* Relocate a SPARC64 ELF section.  */
 
 static boolean
@@ -1928,9 +1938,10 @@
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *sym;
       asection *sec;
-      bfd_vma relocation;
+      bfd_vma relocation, off;
       bfd_reloc_status_type r;
       boolean is_plt = false;
+      boolean unresolved_reloc;
 
       r_type = ELF64_R_TYPE_ID (rel->r_info);
       if (r_type < 0 || r_type >= (int) R_SPARC_max_std)
@@ -1965,6 +1976,7 @@
       h = NULL;
       sym = NULL;
       sec = NULL;
+      unresolved_reloc = false;
       if (r_symndx < symtab_hdr->sh_info)
 	{
 	  sym = local_syms + r_symndx;
@@ -1977,116 +1989,30 @@
 	  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;
+
+	  relocation = 0;
 	  if (h->root.type == bfd_link_hash_defined
 	      || h->root.type == bfd_link_hash_defweak)
 	    {
-	      boolean skip_it = false;
 	      sec = h->root.u.def.section;
-
-	      switch (r_type)
-		{
-		case R_SPARC_WPLT30:
-		case R_SPARC_PLT32:
-		case R_SPARC_HIPLT22:
-		case R_SPARC_LOPLT10:
-		case R_SPARC_PCPLT32:
-		case R_SPARC_PCPLT22:
-		case R_SPARC_PCPLT10:
-		case R_SPARC_PLT64:
-		  if (h->plt.offset != (bfd_vma) -1)
-		    skip_it = true;
-		  break;
-
-		case R_SPARC_GOT10:
-		case R_SPARC_GOT13:
-		case R_SPARC_GOT22:
-		  if (elf_hash_table(info)->dynamic_sections_created
-		      && (!info->shared
-			  || (!info->symbolic && h->dynindx != -1)
-			  || !(h->elf_link_hash_flags
-			       & ELF_LINK_HASH_DEF_REGULAR)))
-		    skip_it = true;
-		  break;
-
-		case R_SPARC_PC10:
-		case R_SPARC_PC22:
-		case R_SPARC_PC_HH22:
-		case R_SPARC_PC_HM10:
-		case R_SPARC_PC_LM22:
-		  if (!strcmp(h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
-		    break;
-		  /* FALLTHRU */
-
-		case R_SPARC_8:
-		case R_SPARC_16:
-		case R_SPARC_32:
-		case R_SPARC_DISP8:
-		case R_SPARC_DISP16:
-		case R_SPARC_DISP32:
-		case R_SPARC_WDISP30:
-		case R_SPARC_WDISP22:
-		case R_SPARC_HI22:
-		case R_SPARC_22:
-		case R_SPARC_13:
-		case R_SPARC_LO10:
-		case R_SPARC_UA32:
-		case R_SPARC_10:
-		case R_SPARC_11:
-		case R_SPARC_64:
-		case R_SPARC_OLO10:
-		case R_SPARC_HH22:
-		case R_SPARC_HM10:
-		case R_SPARC_LM22:
-		case R_SPARC_WDISP19:
-		case R_SPARC_WDISP16:
-		case R_SPARC_7:
-		case R_SPARC_5:
-		case R_SPARC_6:
-		case R_SPARC_DISP64:
-		case R_SPARC_HIX22:
-		case R_SPARC_LOX10:
-		case R_SPARC_H44:
-		case R_SPARC_M44:
-		case R_SPARC_L44:
-		case R_SPARC_UA64:
-		case R_SPARC_UA16:
-		  if (info->shared
-		      && ((!info->symbolic && h->dynindx != -1)
-			  || !(h->elf_link_hash_flags
-			       & ELF_LINK_HASH_DEF_REGULAR))
-		      && ((input_section->flags & SEC_ALLOC) != 0
-			  /* DWARF will emit R_SPARC_{32,64} relocations in
-			     its sections against symbols defined externally
-			     in shared libraries.  We can't do anything
-			     with them here.  */
-			  || ((input_section->flags & SEC_DEBUGGING) != 0
-			      && (h->elf_link_hash_flags
-				  & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
-		    skip_it = true;
-		  break;
-		}
-
-	      if (skip_it)
-		{
-		  /* 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;
-		}
+	      if (sec->output_section == NULL)
+		/* Set a flag that will be cleared later if we find a
+		   relocation value for this symbol.  output_section
+		   is typically NULL for symbols satisfied by a shared
+		   library.  */
+		unresolved_reloc = true;
 	      else
-		{
-		  relocation = (h->root.u.def.value
-				+ sec->output_section->vma
-				+ sec->output_offset);
-		}
+		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->shared
 		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
-	    relocation = 0;
+	    ;
 	  else
 	    {
 	      if (! ((*info->callbacks->undefined_symbol)
@@ -2107,7 +2033,7 @@
 	    }
 	}
 
-do_dynreloc:
+ do_dynreloc:
       /* When generating a shared object, these relocations are copied
 	 into the output file to be resolved at run time.  */
       if (info->shared && r_symndx != 0 && (input_section->flags & SEC_ALLOC))
@@ -2126,11 +2052,11 @@
 	    case R_SPARC_DISP8:
 	    case R_SPARC_DISP16:
 	    case R_SPARC_DISP32:
+	    case R_SPARC_DISP64:
 	    case R_SPARC_WDISP30:
 	    case R_SPARC_WDISP22:
 	    case R_SPARC_WDISP19:
 	    case R_SPARC_WDISP16:
-	    case R_SPARC_DISP64:
 	      if (h == NULL)
 		break;
 	      /* Fall through.  */
@@ -2219,6 +2145,18 @@
 		  case R_SPARC_UA64:
 		    if (!(outrel.r_offset & 7)) r_type = R_SPARC_64;
 		    break;
+		  case R_SPARC_DISP8:
+		  case R_SPARC_DISP16:
+		  case R_SPARC_DISP32:
+		  case R_SPARC_DISP64:
+		    /* If the symbol is not dynamic, we should not keep
+		       a dynamic relocation.  But an .rela.* slot has been
+		       allocated for it, output R_SPARC_NONE.
+		       FIXME: Add code tracking needed dynamic relocs as
+		       e.g. i386 has.  */
+		    if (h->dynindx == -1)
+		      skip = true, relocate = true;
+		    break;
 		  }
 
 		if (skip)
@@ -2326,14 +2264,18 @@
 
 	  if (h != NULL)
 	    {
-	      bfd_vma off = h->got.offset;
-	      BFD_ASSERT (off != (bfd_vma) -1);
+	      boolean dyn;
 
-	      if (! elf_hash_table (info)->dynamic_sections_created
+	      off = h->got.offset;
+	      BFD_ASSERT (off != (bfd_vma) -1);
+	      dyn = elf_hash_table (info)->dynamic_sections_created;
+
+	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
 		  || (info->shared
-		      && (info->symbolic || h->dynindx == -1)
-		      && (h->elf_link_hash_flags
-			  & ELF_LINK_HASH_DEF_REGULAR)))
+		      && (info->symbolic
+			  || h->dynindx == -1
+			  || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+		      && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
 		{
 		  /* This is actually a static link, or it is a -Bsymbolic
 		     link and the symbol is defined locally, or the symbol
@@ -2356,12 +2298,11 @@
 		      h->got.offset |= 1;
 		    }
 		}
-	      relocation = sgot->output_offset + off - got_base;
+	      else
+		unresolved_reloc = false;
 	    }
 	  else
 	    {
-	      bfd_vma off;
-
 	      BFD_ASSERT (local_got_offsets != NULL);
 	      off = local_got_offsets[r_symndx];
 	      BFD_ASSERT (off != (bfd_vma) -1);
@@ -2407,8 +2348,8 @@
 		  else
 		    bfd_put_64 (output_bfd, relocation, sgot->contents + off);
 		}
-	      relocation = sgot->output_offset + off - got_base;
 	    }
+	  relocation = sgot->output_offset + off - got_base;
 	  goto do_default;
 
 	case R_SPARC_WPLT30:
@@ -2440,6 +2381,7 @@
 	  relocation = (splt->output_section->vma
 			+ splt->output_offset
 			+ sparc64_elf_plt_entry_offset (h->plt.offset));
+	  unresolved_reloc = false;
 	  if (r_type == R_SPARC_WPLT30)
 	    goto do_wplt30;
 	  if (r_type == R_SPARC_PLT32 || r_type == R_SPARC_PLT64)
@@ -2623,6 +2565,17 @@
 	  break;
 	}
 
+      if (unresolved_reloc
+	  && !(info->shared
+	       && (input_section->flags & SEC_DEBUGGING) != 0
+	       && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+	(*_bfd_error_handler)
+	  (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
+	   bfd_archive_filename (input_bfd),
+	   bfd_get_section_name (input_bfd, input_section),
+	   (long) rel->r_offset,
+	   h->root.root.string);
+
       switch (r)
 	{
 	case bfd_reloc_ok:
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index f2d2e64..5d77e7b 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -246,7 +246,7 @@
 };
 
 /* The x86-64 linker needs to keep track of the number of relocs that
-   decides to copy as dynamic relocs in check_relocs for each symbol.
+   it decides to copy as dynamic relocs in check_relocs for each symbol.
    This is so that it can later discard them if they are found to be
    unnecessary.  We store the information in a field extending the
    regular ELF linker hash table.  */
@@ -340,13 +340,13 @@
   struct elf64_x86_64_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table);
 
-  ret = (struct elf64_x86_64_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct elf64_x86_64_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return NULL;
     }
 
@@ -1075,10 +1075,12 @@
   struct elf64_x86_64_link_hash_entry *eh;
   struct elf64_x86_64_dyn_relocs *p;
 
-  if (h->root.type == bfd_link_hash_indirect
-      || h->root.type == bfd_link_hash_warning)
+  if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   info = (struct bfd_link_info *) inf;
   htab = elf64_x86_64_hash_table (info);
 
@@ -1245,6 +1247,9 @@
   struct elf64_x86_64_link_hash_entry *eh;
   struct elf64_x86_64_dyn_relocs *p;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   eh = (struct elf64_x86_64_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c
index 7ced680..2d791de 100644
--- a/bfd/elfarm-nabi.c
+++ b/bfd/elfarm-nabi.c
@@ -138,8 +138,8 @@
 	 bfd_elf_generic_reloc,	/* special_function */
 	 "R_ARM_ABS16",		/* name */
 	 false,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0,			/* dst_mask */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
 	 false),		/* pcrel_offset */
 
   /* 12 bit absolute */
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 2032efa..e74fae9 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1,5 +1,5 @@
 /* ELF linking support for BFD.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -330,6 +330,9 @@
 {
   size_t *count = (size_t *) data;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->dynindx != -1)
     h->dynindx = ++(*count);
 
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 7fd8b53..37b2150 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -57,8 +57,6 @@
   PARAMS ((struct elf_link_hash_entry *, PTR));
 static boolean elf_link_find_version_dependencies
   PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean elf_link_find_version_dependencies
-  PARAMS ((struct elf_link_hash_entry *, PTR));
 static boolean elf_link_assign_sym_version
   PARAMS ((struct elf_link_hash_entry *, PTR));
 static boolean elf_collect_hash_codes
@@ -592,7 +590,7 @@
       asection *hsec;
 
       /* This code handles the special SHN_MIPS_{TEXT,DATA} section
-         indices used by MIPS ELF.  */
+	 indices used by MIPS ELF.  */
       switch (h->root.type)
 	{
 	default:
@@ -702,10 +700,10 @@
       && sym->st_size != h->size)
     {
       /* Since we think we have two common symbols, issue a multiple
-         common warning if desired.  Note that we only warn if the
-         size is different.  If the size is the same, we simply let
-         the old symbol override the new one as normally happens with
-         symbols defined in dynamic objects.  */
+	 common warning if desired.  Note that we only warn if the
+	 size is different.  If the size is the same, we simply let
+	 the old symbol override the new one as normally happens with
+	 symbols defined in dynamic objects.  */
 
       if (! ((*info->callbacks->multiple_common)
 	     (info, h->root.root.string, oldbfd, bfd_link_hash_common,
@@ -755,10 +753,10 @@
       *size_change_ok = true;
 
       /* If we get here when the old symbol is a common symbol, then
-         we are explicitly letting it override a weak symbol or
-         function in a dynamic object, and we don't want to warn about
-         a type change.  If the old symbol is a defined symbol, a type
-         change warning may still be appropriate.  */
+	 we are explicitly letting it override a weak symbol or
+	 function in a dynamic object, and we don't want to warn about
+	 a type change.  If the old symbol is a defined symbol, a type
+	 change warning may still be appropriate.  */
 
       if (h->root.type == bfd_link_hash_common)
 	*type_change_ok = true;
@@ -817,7 +815,7 @@
       olddyncommon = false;
 
       /* We again permit a type change when a common symbol may be
-         overriding a function.  */
+	 overriding a function.  */
 
       if (bfd_is_com_section (sec))
 	*type_change_ok = true;
@@ -829,11 +827,11 @@
       h->verinfo.vertree = NULL;
 
       /* In this special case, if H is the target of an indirection,
-         we want the caller to frob with H rather than with the
-         indirect symbol.  That will permit the caller to redefine the
-         target of the indirection, rather than the indirect symbol
-         itself.  FIXME: This will break the -y option if we store a
-         symbol with a different name.  */
+	 we want the caller to frob with H rather than with the
+	 indirect symbol.  That will permit the caller to redefine the
+	 target of the indirection, rather than the indirect symbol
+	 itself.  FIXME: This will break the -y option if we store a
+	 symbol with a different name.  */
       *sym_hash = h;
     }
 
@@ -856,7 +854,7 @@
 	return false;
 
       /* If the predumed common symbol in the dynamic object is
-         larger, pretend that the new symbol has its size.  */
+	 larger, pretend that the new symbol has its size.  */
 
       if (h->size > *pvalue)
 	*pvalue = h->size;
@@ -890,8 +888,8 @@
       && bind != STB_WEAK)
     {
       /* To make this work we have to frob the flags so that the rest
-         of the code does not think we are using the regular
-         definition.  */
+	 of the code does not think we are using the regular
+	 definition.  */
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
 	h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
       else if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)
@@ -900,9 +898,9 @@
 				   | ELF_LINK_HASH_DEF_DYNAMIC);
 
       /* If H is the target of an indirection, we want the caller to
-         use H rather than the indirect symbol.  Otherwise if we are
-         defining a new indirect symbol we will wind up attaching it
-         to the entry we are overriding.  */
+	 use H rather than the indirect symbol.  Otherwise if we are
+	 defining a new indirect symbol we will wind up attaching it
+	 to the entry we are overriding.  */
       *sym_hash = h;
     }
 
@@ -1047,7 +1045,7 @@
 	}
 
       /* Now set HI to H, so that the following code will set the
-         other fields correctly.  */
+	 other fields correctly.  */
       hi = h;
     }
 
@@ -1133,7 +1131,7 @@
 		       & (ELF_LINK_HASH_DEF_DYNAMIC
 			  | ELF_LINK_HASH_DEF_REGULAR)) == 0);
 
-          (*bed->elf_backend_copy_indirect_symbol) (h, hi);
+	  (*bed->elf_backend_copy_indirect_symbol) (h, hi);
 
 	  /* See if the new flags lead us to realize that the symbol
 	     must be dynamic.  */
@@ -1259,8 +1257,8 @@
 			  || h->root.type == bfd_link_hash_defweak))
 		    {
 		      /* We don't want to issue this warning.  Clobber
-                         the section size so that the warning does not
-                         get copied into the output file.  */
+			 the section size so that the warning does not
+			 get copied into the output file.  */
 		      s->_raw_size = 0;
 		      continue;
 		    }
@@ -1284,7 +1282,7 @@
 	      if (! info->relocateable)
 		{
 		  /* Clobber the section size so that the warning does
-                     not get copied into the output file.  */
+		     not get copied into the output file.  */
 		  s->_raw_size = 0;
 		}
 	    }
@@ -1315,7 +1313,7 @@
 	goto error_return;
 
       /* Read in the symbol versions, but don't bother to convert them
-         to internal format.  */
+	 to internal format.  */
       if (elf_dynversym (abfd) != 0)
 	{
 	  Elf_Internal_Shdr *versymhdr;
@@ -1373,10 +1371,10 @@
   if (! dynamic)
     {
       /* If we are creating a shared library, create all the dynamic
-         sections immediately.  We need to attach them to something,
-         so we attach them to this BFD, provided it is the right
-         format.  FIXME: If there are no input BFD's of the same
-         format as the output, we can't make a shared library.  */
+	 sections immediately.  We need to attach them to something,
+	 so we attach them to this BFD, provided it is the right
+	 format.  FIXME: If there are no input BFD's of the same
+	 format as the output, we can't make a shared library.  */
       if (info->shared
 	  && is_elf_hash_table (info)
 	  && ! hash_table->dynamic_sections_created
@@ -1411,7 +1409,7 @@
 	  if (*name == '\0')
 	    {
 	      if (elf_dt_soname (abfd) != NULL)
-	        dt_needed = true;
+		dt_needed = true;
 
 	      add_needed = false;
 	    }
@@ -1531,7 +1529,7 @@
 		}
 	      /* Ignore DT_RPATH if we have seen DT_RUNPATH.  */
 	      if (!runpath && dyn.d_tag == DT_RPATH)
-	        {
+		{
 		  struct bfd_link_needed_list *n, **pn;
 		  char *fnm, *anm;
 		  unsigned int tagv = dyn.d_un.d_val;
@@ -1623,7 +1621,7 @@
 	}
 
       /* Save the SONAME, if there is one, because sometimes the
-         linker emulation code will need to know it.  */
+	 linker emulation code will need to know it.  */
       if (*name == '\0')
 	name = basename (bfd_get_filename (abfd));
       elf_dt_name (abfd) = name;
@@ -1764,10 +1762,10 @@
 	      vernum = iver.vs_vers & VERSYM_VERSION;
 
 	      /* If this is a hidden symbol, or if it is not version
-                 1, we append the version name to the symbol name.
-                 However, we do not modify a non-hidden absolute
-                 symbol, because it might be the version symbol
-                 itself.  FIXME: What if it isn't?  */
+		 1, we append the version name to the symbol name.
+		 However, we do not modify a non-hidden absolute
+		 symbol, because it might be the version symbol
+		 itself.  FIXME: What if it isn't?  */
 	      if ((iver.vs_vers & VERSYM_HIDDEN) != 0
 		  || (vernum > 1 && ! bfd_is_abs_section (sec)))
 		{
@@ -1866,10 +1864,10 @@
 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
 	  /* Remember the old alignment if this is a common symbol, so
-             that we don't reduce the alignment later on.  We can't
-             check later, because _bfd_generic_link_add_one_symbol
-             will set a default for the alignment which we want to
-             override.  */
+	     that we don't reduce the alignment later on.  We can't
+	     check later, because _bfd_generic_link_add_one_symbol
+	     will set a default for the alignment which we want to
+	     override.  */
 	  if (h->root.type == bfd_link_hash_common)
 	    old_alignment = h->root.u.c.p->alignment_power;
 
@@ -1950,10 +1948,10 @@
 	    }
 
 	  /* If this is a common symbol, then we always want H->SIZE
-             to be the size of the common symbol.  The code just above
-             won't fix the size if a common symbol becomes larger.  We
-             don't warn about a size change here, because that is
-             covered by --warn-common.  */
+	     to be the size of the common symbol.  The code just above
+	     won't fix the size if a common symbol becomes larger.  We
+	     don't warn about a size change here, because that is
+	     covered by --warn-common.  */
 	  if (h->root.type == bfd_link_hash_common)
 	    h->size = h->root.u.c.size;
 
@@ -1983,8 +1981,8 @@
 		h->other = sym.st_other;
 
 	      /* If neither has visibility, use the st_other of the
-	         definition.  This is an arbitrary choice, since the
-	         other bits have no general meaning.  */
+		 definition.  This is an arbitrary choice, since the
+		 other bits have no general meaning.  */
 	      if (!symvis && !hvis
 		  && (definition || h->other == 0))
 		h->other = sym.st_other;
@@ -2071,7 +2069,7 @@
 		goto error_return;
 
 	      /* The symbol from a DT_NEEDED object is referenced from
-	         the regular object to create a dynamic executable. We
+		 the regular object to create a dynamic executable. We
 		 have to make sure there is a DT_NEEDED entry for it.  */
 
 	      dt_needed = false;
@@ -2167,10 +2165,10 @@
 		}
 
 	      /* If the real definition is in the list of dynamic
-                 symbols, make sure the weak definition is put there
-                 as well.  If we don't do this, then the dynamic
-                 loader might not merge the entries for the real
-                 definition and the weak definition.  */
+		 symbols, make sure the weak definition is put there
+		 as well.  If we don't do this, then the dynamic
+		 loader might not merge the entries for the real
+		 definition and the weak definition.  */
 	      if (h->dynindx != -1
 		  && hlook->dynindx == -1)
 		{
@@ -2795,10 +2793,6 @@
 
   h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
 
-  /* When possible, keep the original type of the symbol.  */
-  if (h->type == STT_NOTYPE)
-    h->type = STT_OBJECT;
-
   if (((h->elf_link_hash_flags & (ELF_LINK_HASH_DEF_DYNAMIC
 				  | ELF_LINK_HASH_REF_DYNAMIC)) != 0
        || info->shared)
@@ -3029,9 +3023,7 @@
      struct bfd_elf_version_tree *verdefs;
 {
   bfd_size_type soname_indx;
-  bfd *dynobj, *sub;
-  asection *o;
-  int need_preinit_array = 0, need_init_array = 0, need_fini_array = 0;
+  bfd *dynobj;
   struct elf_backend_data *bed;
   struct elf_assign_sym_version_info asvinfo;
 
@@ -3142,11 +3134,11 @@
       eif.failed = false;
 
       /* If we are supposed to export all symbols into the dynamic symbol
-         table (this is not the normal case), then do so.  */
+	 table (this is not the normal case), then do so.  */
       if (info->export_dynamic)
 	{
 	  elf_link_hash_traverse (elf_hash_table (info), elf_export_symbol,
-			          (PTR) &eif);
+				  (PTR) &eif);
 	  if (eif.failed)
 	    return false;
 	}
@@ -3202,27 +3194,37 @@
 	    return false;
 	}
 
-      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
-	for (o = sub->sections; o != NULL; o = o->next)
-	  {
-	    /* yuck, more matching by name... */
-
-	    if (strcmp (bfd_section_name (sub, o), ".preinit_array") == 0)
-	      need_preinit_array = 1;
-	    if (strcmp (bfd_section_name (sub, o), ".init_array") == 0)
-	      need_init_array = 1;
-	    if (strcmp (bfd_section_name (sub, o), ".fini_array") == 0)
-	      need_fini_array = 1;
-	  }
-      if (need_preinit_array)
+      if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL)
 	{
+	  /* DT_PREINIT_ARRAY is not allowed in shared library.  */
+	  if (info->shared)
+	    {
+	      bfd *sub;
+	      asection *o;
+
+	      for (sub = info->input_bfds; sub != NULL;
+		   sub = sub->link_next)
+		for (o = sub->sections; o != NULL; o = o->next)
+		  if (elf_section_data (o)->this_hdr.sh_type
+		      == SHT_PREINIT_ARRAY)
+		    {
+		      (*_bfd_error_handler)
+			(_("%s: .preinit_array section is not allowed in DSO"),
+			  bfd_archive_filename (sub));
+		      break;
+		    }
+
+	      bfd_set_error (bfd_error_nonrepresentable_section);
+	      return false;
+	    }
+
 	  if (!elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAY,
 				      (bfd_vma) 0)
 	      || !elf_add_dynamic_entry (info, (bfd_vma) DT_PREINIT_ARRAYSZ,
 					 (bfd_vma) 0))
 	    return false;
 	}
-      if (need_init_array)
+      if (bfd_get_section_by_name (output_bfd, ".init_array") != NULL)
 	{
 	  if (!elf_add_dynamic_entry (info, (bfd_vma) DT_INIT_ARRAY,
 				      (bfd_vma) 0)
@@ -3230,7 +3232,7 @@
 					 (bfd_vma) 0))
 	    return false;
 	}
-      if (need_fini_array)
+      if (bfd_get_section_by_name (output_bfd, ".fini_array") != NULL)
 	{
 	  if (!elf_add_dynamic_entry (info, (bfd_vma) DT_FINI_ARRAY,
 				      (bfd_vma) 0)
@@ -3278,7 +3280,7 @@
       BFD_ASSERT (s != NULL);
 
       /* We may have created additional version definitions if we are
-         just linking a regular application.  */
+	 just linking a regular application.  */
       verdefs = asvinfo.verdefs;
 
       /* Skip anonymous version tag.  */
@@ -3672,10 +3674,10 @@
 
 /* This function is used to adjust offsets into .dynstr for
    dynamic symbols.  This is called via elf_link_hash_traverse.  */
-      
+
 static boolean elf_adjust_dynstr_offsets
 PARAMS ((struct elf_link_hash_entry *, PTR));
-        
+
 static boolean
 elf_adjust_dynstr_offsets (h, data)
      struct elf_link_hash_entry *h;
@@ -3683,6 +3685,9 @@
 {
   struct elf_strtab_hash *dynstr = (struct elf_strtab_hash *) data;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->dynindx != -1)
     h->dynstr_index = _bfd_elf_strtab_offset (dynstr, h->dynstr_index);
   return true;
@@ -3755,7 +3760,7 @@
       bfd_size_type i;
       Elf_Internal_Verdef def;
       Elf_Internal_Verdaux defaux;
-                    
+
       s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
       p = (bfd_byte *) s->contents;
       do
@@ -3785,7 +3790,7 @@
       bfd_size_type i;
       Elf_Internal_Verneed need;
       Elf_Internal_Vernaux needaux;
-                    
+
       s = bfd_get_section_by_name (dynobj, ".gnu.version_r");
       p = (bfd_byte *) s->contents;
       do
@@ -3863,11 +3868,11 @@
   else
     {
       /* Unfortunately, ELF_LINK_NON_ELF is only correct if the symbol
-         was first seen in a non-ELF file.  Fortunately, if the symbol
-         was first seen in an ELF file, we're probably OK unless the
-         symbol was defined in a non-ELF file.  Catch that case here.
-         FIXME: We're still in trouble if the symbol was first seen in
-         a dynamic object, and then later in a non-ELF regular object.  */
+	 was first seen in a non-ELF file.  Fortunately, if the symbol
+	 was first seen in an ELF file, we're probably OK unless the
+	 symbol was defined in a non-ELF file.  Catch that case here.
+	 FIXME: We're still in trouble if the symbol was first seen in
+	 a dynamic object, and then later in a non-ELF regular object.  */
       if ((h->root.type == bfd_link_hash_defined
 	   || h->root.type == bfd_link_hash_defweak)
 	  && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
@@ -3962,6 +3967,17 @@
   bfd *dynobj;
   struct elf_backend_data *bed;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h->plt.offset = (bfd_vma) -1;
+      h->got.offset = (bfd_vma) -1;
+
+      /* When warning symbols are created, they **replace** the "real"
+	 entry in the hash table, thus we never get to see the real
+	 symbol in a hash traversal.  So look at it now.  */
+      h = (struct elf_link_hash_entry *) h->root.u.i.link;
+    }
+
   /* Ignore indirect symbols.  These are added by the versioning code.  */
   if (h->root.type == bfd_link_hash_indirect)
     return true;
@@ -4078,6 +4094,9 @@
   if (h->root.type == bfd_link_hash_indirect)
     return true;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->dynindx == -1
       && (h->elf_link_hash_flags
 	  & (ELF_LINK_HASH_DEF_REGULAR | ELF_LINK_HASH_REF_REGULAR)) != 0)
@@ -4107,14 +4126,14 @@
 	}
 
       if (!eif->verdefs)
-        {
+	{
 doit:
 	  if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
 	    {
 	      eif->failed = true;
 	      return false;
 	    }
-        }
+	}
     }
 
   return true;
@@ -4135,6 +4154,9 @@
   Elf_Internal_Vernaux *a;
   bfd_size_type amt;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* We only care about symbols defined in shared objects with version
      information.  */
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
@@ -4215,6 +4237,9 @@
   sinfo = (struct elf_assign_sym_version_info *) data;
   info = sinfo->info;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* Fix the symbol flags.  */
   eif.failed = false;
   eif.info = info;
@@ -4240,7 +4265,7 @@
       hidden = true;
 
       /* There are two consecutive ELF_VER_CHR characters if this is
-         not a hidden symbol.  */
+	 not a hidden symbol.  */
       ++p;
       if (*p == ELF_VER_CHR)
 	{
@@ -4268,11 +4293,11 @@
 	      len = p - h->root.root.string;
 	      alc = bfd_malloc ((bfd_size_type) len);
 	      if (alc == NULL)
-	        return false;
+		return false;
 	      strncpy (alc, h->root.root.string, len - 1);
 	      alc[len - 1] = '\0';
 	      if (alc[len - 2] == ELF_VER_CHR)
-	        alc[len - 2] = '\0';
+		alc[len - 2] = '\0';
 
 	      h->verinfo.vertree = t;
 	      t->used = true;
@@ -4286,7 +4311,7 @@
 		}
 
 	      /* See if there is anything to force this symbol to
-                 local scope.  */
+		 local scope.  */
 	      if (d == NULL && t->locals != NULL)
 		{
 		  for (d = t->locals; d != NULL; d = d->next)
@@ -4311,14 +4336,14 @@
 	}
 
       /* If we are building an application, we need to create a
-         version node for this version.  */
+	 version node for this version.  */
       if (t == NULL && ! info->shared)
 	{
 	  struct bfd_elf_version_tree **pp;
 	  int version_index;
 
 	  /* If we aren't going to export this symbol, we don't need
-             to worry about it.  */
+	     to worry about it.  */
 	  if (h->dynindx == -1)
 	    return true;
 
@@ -4354,7 +4379,7 @@
       else if (t == NULL)
 	{
 	  /* We could not find the version for a symbol when
-             generating a shared archive.  Return an error.  */
+	     generating a shared archive.  Return an error.  */
 	  (*_bfd_error_handler)
 	    (_("%s: undefined versioned symbol name %s"),
 	     bfd_get_filename (sinfo->output_bfd), h->root.root.string);
@@ -4376,8 +4401,8 @@
       struct bfd_elf_version_expr *d;
 
       /* See if can find what version this symbol is in.  If the
-         symbol is supposed to be local, then don't actually register
-         it.  */
+	 symbol is supposed to be local, then don't actually register
+	 it.  */
       deflt = NULL;
       for (t = sinfo->verdefs; t != NULL; t = t->next)
 	{
@@ -4897,8 +4922,8 @@
   dynobj = elf_hash_table (info)->dynobj;
 
   emit_relocs = (info->relocateable
-                 || info->emitrelocations
-                 || bed->elf_backend_emit_relocs);
+		 || info->emitrelocations
+		 || bed->elf_backend_emit_relocs);
 
   finfo.info = info;
   finfo.output_bfd = abfd;
@@ -4968,7 +4993,7 @@
 
 	      if (info->relocateable || info->emitrelocations)
 		o->reloc_count += sec->reloc_count;
-              else if (bed->elf_backend_count_relocs)
+	      else if (bed->elf_backend_count_relocs)
 		{
 		  Elf_Internal_Rela * relocs;
 
@@ -4976,8 +5001,8 @@
 			    (abfd, sec, (PTR) NULL,
 			     (Elf_Internal_Rela *) NULL, info->keep_memory));
 
-		  o->reloc_count += (*bed->elf_backend_count_relocs)
-		                      (sec, relocs);
+		  o->reloc_count
+		    += (*bed->elf_backend_count_relocs) (sec, relocs);
 
 		  if (!info->keep_memory)
 		    free (relocs);
@@ -5079,10 +5104,20 @@
 		= elf_section_data (output_section);
 	      unsigned int *rel_count;
 	      unsigned int *rel_count2;
+	      bfd_size_type entsize;
+	      bfd_size_type entsize2;
 
-	      /* We must be careful to add the relocation froms the
+	      /* We must be careful to add the relocations from the
 		 input section to the right output count.  */
-	      if (esdi->rel_hdr.sh_entsize == esdo->rel_hdr.sh_entsize)
+	      entsize = esdi->rel_hdr.sh_entsize;
+	      entsize2 = esdi->rel_hdr2 ? esdi->rel_hdr2->sh_entsize : 0;
+	      BFD_ASSERT ((entsize == sizeof (Elf_External_Rel)
+			   || entsize == sizeof (Elf_External_Rela))
+			  && entsize2 != entsize
+			  && (entsize2 == 0
+			      || entsize2 == sizeof (Elf_External_Rel)
+			      || entsize2 == sizeof (Elf_External_Rela)));
+	      if (entsize == esdo->rel_hdr.sh_entsize)
 		{
 		  rel_count = &esdo->rel_count;
 		  rel_count2 = &esdo->rel_count2;
@@ -5313,10 +5348,10 @@
       for (p = o->link_order_head; p != NULL; p = p->next)
 	{
 	  if (p->type == bfd_indirect_link_order
-	      && (bfd_get_flavour (p->u.indirect.section->owner)
-		  == bfd_target_elf_flavour))
+	      && (bfd_get_flavour ((sub = p->u.indirect.section->owner))
+		  == bfd_target_elf_flavour)
+	      && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass)
 	    {
-	      sub = p->u.indirect.section->owner;
 	      if (! sub->output_has_begun)
 		{
 		  if (! elf_link_input_bfd (&finfo, sub))
@@ -5338,28 +5373,25 @@
 	}
     }
 
+  /* Output any global symbols that got converted to local in a
+     version script or due to symbol visibility.  We do this in a
+     separate step since ELF requires all local symbols to appear
+     prior to any global symbols.  FIXME: We should only do this if
+     some global symbols were, in fact, converted to become local.
+     FIXME: Will this work correctly with the Irix 5 linker?  */
+  eoinfo.failed = false;
+  eoinfo.finfo = &finfo;
+  eoinfo.localsyms = true;
+  elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
+			  (PTR) &eoinfo);
+  if (eoinfo.failed)
+    return false;
+
   /* That wrote out all the local symbols.  Finish up the symbol table
      with the global symbols. Even if we want to strip everything we
      can, we still need to deal with those global symbols that got
      converted to local in a version script.  */
 
-  if (info->shared)
-    {
-      /* Output any global symbols that got converted to local in a
-         version script.  We do this in a separate step since ELF
-         requires all local symbols to appear prior to any global
-         symbols.  FIXME: We should only do this if some global
-         symbols were, in fact, converted to become local.  FIXME:
-         Will this work correctly with the Irix 5 linker?  */
-      eoinfo.failed = false;
-      eoinfo.finfo = &finfo;
-      eoinfo.localsyms = true;
-      elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
-			      (PTR) &eoinfo);
-      if (eoinfo.failed)
-	return false;
-    }
-
   /* The sh_info field records the index of the first non local symbol.  */
   symtab_hdr->sh_info = bfd_get_symcount (abfd);
 
@@ -5411,8 +5443,8 @@
 
 	      /* Copy the internal symbol as is.
 		 Note that we saved a word of storage and overwrote
-                 the original st_name with the dynstr_index.  */
-              sym = e->isym;
+		 the original st_name with the dynstr_index.  */
+	      sym = e->isym;
 
 	      if (e->isym.st_shndx != SHN_UNDEF
 		   && (e->isym.st_shndx < SHN_LORESERVE
@@ -5600,6 +5632,9 @@
 	    get_size:
 	      o = bfd_get_section_by_name (abfd, name);
 	      BFD_ASSERT (o != NULL);
+	      if (o->_raw_size == 0)
+		(*_bfd_error_handler)
+		  (_("warning: %s section has zero size"), name);
 	      dyn.d_un.d_val = o->_raw_size;
 	      elf_swap_dyn_out (dynobj, &dyn, dyncon);
 	      break;
@@ -5686,7 +5721,7 @@
 	  if ((o->flags & SEC_LINKER_CREATED) == 0)
 	    {
 	      /* At this point, we are only interested in sections
-                 created by elf_link_create_dynamic_sections.  */
+		 created by elf_link_create_dynamic_sections.  */
 	      continue;
 	    }
 	  if ((elf_section_data (o->output_section)->this_hdr.sh_type
@@ -5702,7 +5737,7 @@
 	  else
 	    {
 	      /* The contents of the .dynstr section are actually in a
-                 stringtab.  */
+		 stringtab.  */
 	      off = elf_section_data (o->output_section)->this_hdr.sh_offset;
 	      if (bfd_seek (abfd, off, SEEK_SET) != 0
 		  || ! _bfd_elf_strtab_emit (abfd,
@@ -5758,7 +5793,7 @@
     {
       if ((o->flags & SEC_RELOC) != 0
 	  && elf_section_data (o)->rel_hashes != NULL)
-        free (elf_section_data (o)->rel_hashes);
+	free (elf_section_data (o)->rel_hashes);
     }
 
   elf_tdata (abfd)->linker = true;
@@ -5809,7 +5844,7 @@
 {
   Elf_External_Sym *dest;
   Elf_External_Sym_Shndx *destshndx;
-  
+
   boolean (*output_symbol_hook) PARAMS ((bfd *,
 					 struct bfd_link_info *info,
 					 const char *,
@@ -5905,6 +5940,9 @@
 {
   asection *sec;
 
+  if (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)->flags & SEC_MERGE)
@@ -5940,6 +5978,13 @@
   Elf_Internal_Sym sym;
   asection *input_sec;
 
+  if (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_new)
+	return true;
+    }
+
   /* Decide whether to output this symbol in this pass.  */
   if (eoinfo->localsyms)
     {
@@ -6017,14 +6062,11 @@
     {
     default:
     case bfd_link_hash_new:
+    case bfd_link_hash_warning:
       abort ();
       return false;
 
     case bfd_link_hash_undefined:
-      input_sec = bfd_und_section_ptr;
-      sym.st_shndx = SHN_UNDEF;
-      break;
-
     case bfd_link_hash_undefweak:
       input_sec = bfd_und_section_ptr;
       sym.st_shndx = SHN_UNDEF;
@@ -6075,29 +6117,22 @@
 
     case bfd_link_hash_indirect:
       /* These symbols are created by symbol versioning.  They point
-         to the decorated version of the name.  For example, if the
-         symbol foo@@GNU_1.2 is the default, which should be used when
-         foo is used with no version, then we add an indirect symbol
-         foo which points to foo@@GNU_1.2.  We ignore these symbols,
-         since the indirected symbol is already in the hash table.  */
+	 to the decorated version of the name.  For example, if the
+	 symbol foo@@GNU_1.2 is the default, which should be used when
+	 foo is used with no version, then we add an indirect symbol
+	 foo which points to foo@@GNU_1.2.  We ignore these symbols,
+	 since the indirected symbol is already in the hash table.  */
       return true;
-
-    case bfd_link_hash_warning:
-      /* We can't represent these symbols in ELF, although a warning
-         symbol may have come from a .gnu.warning.SYMBOL section.  We
-         just put the target symbol in the hash table.  If the target
-         symbol does not really exist, don't do anything.  */
-      if (h->root.u.i.link->type == bfd_link_hash_new)
-	return true;
-      return (elf_link_output_extsym
-	      ((struct elf_link_hash_entry *) h->root.u.i.link, data));
     }
 
   /* Give the processor backend a chance to tweak the symbol value,
      and also to finish up anything that needs to be done for this
-     symbol.  */
+     symbol.  FIXME: Not calling elf_backend_finish_dynamic_symbol for
+     forced local syms when non-shared is due to a historical quirk.  */
   if ((h->dynindx != -1
        || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+      && (finfo->info->shared
+	  || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
       && elf_hash_table (finfo->info)->dynamic_sections_created)
     {
       struct elf_backend_data *bed;
@@ -6351,8 +6386,8 @@
     return true;
 
   emit_relocs = (finfo->info->relocateable
-                 || finfo->info->emitrelocations
-                 || bed->elf_backend_emit_relocs);
+		 || finfo->info->emitrelocations
+		 || bed->elf_backend_emit_relocs);
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   if (elf_bad_symtab (input_bfd))
@@ -6468,10 +6503,10 @@
 	continue;
 
       /* If this symbol is defined in a section which we are
-         discarding, we don't need to keep it, but note that
-         linker_mark is only reliable for sections that have contents.
-         For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
-         as well as linker_mark.  */
+	 discarding, we don't need to keep it, but note that
+	 linker_mark is only reliable for sections that have contents.
+	 For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
+	 as well as linker_mark.  */
       if ((isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
 	  && isec != NULL
 	  && ((! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
@@ -6546,9 +6581,9 @@
 	}
 
       /* Get the contents of the section.  They have been cached by a
-         relaxation routine.  Note that o is a section in an input
-         file, so the contents field will not have been set by any of
-         the routines which work on output files.  */
+	 relaxation routine.  Note that o is a section in an input
+	 file, so the contents field will not have been set by any of
+	 the routines which work on output files.  */
       if (elf_section_data (o)->this_hdr.contents != NULL)
 	contents = elf_section_data (o)->this_hdr.contents;
       else
@@ -6741,7 +6776,7 @@
 		  irela->r_offset += o->output_offset;
 
 		  /* Relocs in an executable have to be virtual addresses.  */
-		  if (finfo->info->emitrelocations)
+		  if (!finfo->info->relocateable)
 		    irela->r_offset += o->output_section->vma;
 
 		  r_symndx = ELF_R_SYM (irela->r_info);
@@ -6858,23 +6893,24 @@
 		}
 
 	      /* Swap out the relocs.  */
-              if (bed->elf_backend_emit_relocs
-                  && !(finfo->info->relocateable
+	      if (bed->elf_backend_emit_relocs
+		  && !(finfo->info->relocateable
 		       || finfo->info->emitrelocations))
-                reloc_emitter = bed->elf_backend_emit_relocs;
-              else
-                reloc_emitter = elf_link_output_relocs;
+		reloc_emitter = bed->elf_backend_emit_relocs;
+	      else
+		reloc_emitter = elf_link_output_relocs;
 
 	      input_rel_hdr = &elf_section_data (o)->rel_hdr;
-              (*reloc_emitter) (output_bfd, o, input_rel_hdr, internal_relocs);
+	      (*reloc_emitter) (output_bfd, o, input_rel_hdr, internal_relocs);
 
 	      input_rel_hdr = elf_section_data (o)->rel_hdr2;
-              if (input_rel_hdr)
-                {
-                  internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr)
+	      if (input_rel_hdr)
+		{
+		  internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr)
 				      * bed->s->int_rels_per_ext_rel);
-                  reloc_emitter (output_bfd, o, input_rel_hdr, internal_relocs);
-                }
+		  (*reloc_emitter) (output_bfd, o, input_rel_hdr,
+				    internal_relocs);
+		}
 
 	    }
 	}
@@ -6974,7 +7010,7 @@
       struct elf_link_hash_entry *h;
 
       /* Treat a reloc against a defined symbol as though it were
-         actually against the section.  */
+	 actually against the section.  */
       h = ((struct elf_link_hash_entry *)
 	   bfd_wrapped_link_hash_lookup (output_bfd, info,
 					 link_order->u.reloc.p->u.name,
@@ -6989,8 +7025,8 @@
 	  indx = section->output_section->target_index;
 	  *rel_hash_ptr = NULL;
 	  /* It seems that we ought to add the symbol value to the
-             addend here, but in practice it has already been added
-             because it was passed to constructor_callback.  */
+	     addend here, but in practice it has already been added
+	     because it was passed to constructor_callback.  */
 	  addend += section->output_section->vma + section->output_offset;
 	}
       else if (h != NULL)
@@ -7463,7 +7499,7 @@
       if (elf_bad_symtab (input_bfd))
 	{
 	  nlocsyms = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
-          extsymoff = 0;
+	  extsymoff = 0;
 	}
       else
 	extsymoff = nlocsyms = symtab_hdr->sh_info;
@@ -7525,11 +7561,11 @@
 				  locsym_shndx + (locsym_shndx ? r_symndx : 0),
 				  &s);
 	      if (ELF_ST_BIND (s.st_info) == STB_LOCAL)
-	        rsec = (*gc_mark_hook) (sec->owner, info, rel, NULL, &s);
+		rsec = (*gc_mark_hook) (sec->owner, info, rel, NULL, &s);
 	      else
 		{
-	          h = sym_hashes[r_symndx - extsymoff];
-	          rsec = (*gc_mark_hook) (sec->owner, info, rel, h, NULL);
+		  h = sym_hashes[r_symndx - extsymoff];
+		  rsec = (*gc_mark_hook) (sec->owner, info, rel, h, NULL);
 		}
 	    }
 	  else if (r_symndx >= nlocsyms)
@@ -7547,11 +7583,15 @@
 	    }
 
 	  if (rsec && !rsec->gc_mark)
-	    if (!elf_gc_mark (info, rsec, gc_mark_hook))
-	      {
-		ret = false;
-		goto out2;
-	      }
+	    {
+	      if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour)
+		rsec->gc_mark = 1;
+	      else if (!elf_gc_mark (info, rsec, gc_mark_hook))
+		{
+		  ret = false;
+		  goto out2;
+		}
+	    }
 	}
 
     out2:
@@ -7650,6 +7690,9 @@
 {
   int *idx = (int *) idxptr;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->dynindx != -1
       && ((h->root.type != bfd_link_hash_defined
 	   && h->root.type != bfd_link_hash_defweak)
@@ -7667,6 +7710,9 @@
      struct elf_link_hash_entry *h;
      PTR okp;
 {
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* Those that are not vtables.  */
   if (h->vtable_parent == NULL)
     return true;
@@ -7700,9 +7746,9 @@
       pu = h->vtable_parent->vtable_entries_used;
       if (pu != NULL)
 	{
-          asection *sec = h->root.u.def.section;
-          struct elf_backend_data *bed = get_elf_backend_data (sec->owner);
-          int file_align = bed->s->file_align;
+	  asection *sec = h->root.u.def.section;
+	  struct elf_backend_data *bed = get_elf_backend_data (sec->owner);
+	  int file_align = bed->s->file_align;
 
 	  n = h->vtable_parent->vtable_entries_size / file_align;
 	  while (n--)
@@ -7729,6 +7775,9 @@
   struct elf_backend_data *bed;
   int file_align;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* Take care of both those symbols that do not describe vtables as
      well as those that are not loaded.  */
   if (h->vtable_parent == NULL)
@@ -7779,7 +7828,7 @@
   bfd *sub;
   asection * (*gc_mark_hook)
     PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
-             struct elf_link_hash_entry *h, Elf_Internal_Sym *));
+	     struct elf_link_hash_entry *h, Elf_Internal_Sym *));
 
   if (!get_elf_backend_data (abfd)->can_gc_sections
       || info->relocateable || info->emitrelocations
@@ -7813,7 +7862,7 @@
       for (o = sub->sections; o != NULL; o = o->next)
 	{
 	  if (o->flags & SEC_KEEP)
-  	    if (!elf_gc_mark (info, o, gc_mark_hook))
+	    if (!elf_gc_mark (info, o, gc_mark_hook))
 	      return false;
 	}
     }
@@ -8016,6 +8065,9 @@
 {
   bfd_vma *off = (bfd_vma *) offarg;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   if (h->got.refcount > 0)
     {
       h->got.offset = off[0];
@@ -8056,6 +8108,9 @@
   unsigned long ha;
   char *alc = NULL;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   /* Ignore indirect symbols.  These are added by the versioning code.  */
   if (h->dynindx == -1)
     return true;
@@ -8208,7 +8263,8 @@
 	}
 
       stab = strip ? NULL : bfd_get_section_by_name (abfd, ".stab");
-      if ((! stab || elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS)
+      if ((! stab
+	   || elf_section_data(stab)->sec_info_type != ELF_INFO_TYPE_STABS)
 	  && ! eh
 	  && (strip || ! bed->elf_backend_discard_info))
 	continue;
@@ -8233,24 +8289,24 @@
 
       freesyms = NULL;
       if (symtab_hdr->contents)
-        cookie.locsyms = (void *) symtab_hdr->contents;
+	cookie.locsyms = (void *) symtab_hdr->contents;
       else if (cookie.locsymcount == 0)
-        cookie.locsyms = NULL;
+	cookie.locsyms = NULL;
       else
-        {
-          bfd_size_type amt = cookie.locsymcount * sizeof (Elf_External_Sym);
-          cookie.locsyms = bfd_malloc (amt);
-          if (cookie.locsyms == NULL)
+	{
+	  bfd_size_type amt = cookie.locsymcount * sizeof (Elf_External_Sym);
+	  cookie.locsyms = bfd_malloc (amt);
+	  if (cookie.locsyms == NULL)
 	    return false;
 	  freesyms = cookie.locsyms;
 	  if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
-              || bfd_bread (cookie.locsyms, amt, abfd) != amt)
+	      || bfd_bread (cookie.locsyms, amt, abfd) != amt)
 	    {
 	    error_ret_free_loc:
 	      free (cookie.locsyms);
 	      return false;
-            }
-        }
+	    }
+	}
 
       cookie.locsym_shndx = NULL;
       if (shndx_hdr->sh_size != 0 && cookie.locsymcount != 0)
@@ -8296,8 +8352,7 @@
 	  cookie.relend = NULL;
 	  if (eh->reloc_count)
 	    cookie.rels = (NAME(_bfd_elf,link_read_relocs)
-			   (abfd, eh, (PTR) NULL,
-			    (Elf_Internal_Rela *) NULL,
+			   (abfd, eh, (PTR) NULL, (Elf_Internal_Rela *) NULL,
 			    info->keep_memory));
 	  if (cookie.rels)
 	    {
@@ -8326,9 +8381,7 @@
 	free (freesyms);
     }
 
-  if (ehdr
-      && _bfd_elf_discard_section_eh_frame_hdr (output_bfd,
-						info, ehdr))
+  if (ehdr && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info, ehdr))
     ret = true;
   return ret;
 }
@@ -8337,6 +8390,8 @@
 elf_section_ignore_discarded_relocs (sec)
      asection *sec;
 {
+  struct elf_backend_data *bed;
+
   switch (elf_section_data (sec)->sec_info_type)
     {
     case ELF_INFO_TYPE_STABS:
@@ -8345,10 +8400,10 @@
     default:
       break;
     }
-  if ((get_elf_backend_data (sec->owner)->elf_backend_ignore_discarded_relocs
-       != NULL)
-      && (*get_elf_backend_data (sec->owner)
-	   ->elf_backend_ignore_discarded_relocs) (sec))
+
+  bed = get_elf_backend_data (sec->owner);
+  if (bed->elf_backend_ignore_discarded_relocs != NULL
+      && (*bed->elf_backend_ignore_discarded_relocs) (sec))
     return true;
 
   return false;
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index e458477..aadb963 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -1016,9 +1016,6 @@
   switch (hdr->sh_type)
     {
     case SHT_IA_64_UNWIND:
-    case SHT_INIT_ARRAY:
-    case SHT_FINI_ARRAY:
-    case SHT_PREINIT_ARRAY:
     case SHT_IA_64_HP_OPT_ANOT:
       break;
 
@@ -1076,12 +1073,6 @@
     }
   else if (strcmp (name, ELF_STRING_ia64_archext) == 0)
     hdr->sh_type = SHT_IA_64_EXT;
-  else if (strcmp (name, ".init_array") == 0)
-    hdr->sh_type = SHT_INIT_ARRAY;
-  else if (strcmp (name, ".fini_array") == 0)
-    hdr->sh_type = SHT_FINI_ARRAY;
-  else if (strcmp (name, ".preinit_array") == 0)
-    hdr->sh_type = SHT_PREINIT_ARRAY;
   else if (strcmp (name, ".HP.opt_annot") == 0)
     hdr->sh_type = SHT_IA_64_HP_OPT_ANOT;
   else if (strcmp (name, ".reloc") == 0)
@@ -1719,6 +1710,9 @@
     = (struct elfNN_ia64_dyn_sym_traverse_data *) xdata;
   struct elfNN_ia64_dyn_sym_info *dyn_i;
 
+  if (entry->root.root.type == bfd_link_hash_warning)
+    entry = (struct elfNN_ia64_link_hash_entry *) entry->root.root.u.i.link;
+
   for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next)
     if (! (*data->func) (dyn_i, data->data))
       return false;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
new file mode 100644
index 0000000..8ec22b9
--- /dev/null
+++ b/bfd/elfxx-mips.c
@@ -0,0 +1,7796 @@
+/* MIPS-specific support for ELF
+   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+   Free Software Foundation, Inc.
+
+   Most of the information added by Ian Lance Taylor, Cygnus Support,
+   <ian@cygnus.com>.
+   N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
+   <mark@codesourcery.com>
+   Traditional MIPS targets support added by Koundinya.K, Dansk Data
+   Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
+
+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.  */
+
+/* This file handles functionality common to the different MIPS ABI's.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elfxx-mips.h"
+#include "elf/mips.h"
+
+/* Get the ECOFF swapping routines.  */
+#include "coff/sym.h"
+#include "coff/symconst.h"
+#include "coff/ecoff.h"
+#include "coff/mips.h"
+
+/* This structure is used to hold .got information when linking.  It
+   is stored in the tdata field of the bfd_elf_section_data structure.  */
+
+struct mips_got_info
+{
+  /* The global symbol in the GOT with the lowest index in the dynamic
+     symbol table.  */
+  struct elf_link_hash_entry *global_gotsym;
+  /* The number of global .got entries.  */
+  unsigned int global_gotno;
+  /* The number of local .got entries.  */
+  unsigned int local_gotno;
+  /* The number of local .got entries we have used.  */
+  unsigned int assigned_gotno;
+};
+
+/* This structure is passed to mips_elf_sort_hash_table_f when sorting
+   the dynamic symbols.  */
+
+struct mips_elf_hash_sort_data
+{
+  /* The symbol in the global GOT with the lowest dynamic symbol table
+     index.  */
+  struct elf_link_hash_entry *low;
+  /* The least dynamic symbol table index corresponding to a symbol
+     with a GOT entry.  */
+  long min_got_dynindx;
+  /* The greatest dynamic symbol table index not corresponding to a
+     symbol without a GOT entry.  */
+  long max_non_got_dynindx;
+};
+
+/* The MIPS ELF linker needs additional information for each symbol in
+   the global hash table.  */
+
+struct mips_elf_link_hash_entry
+{
+  struct elf_link_hash_entry root;
+
+  /* External symbol information.  */
+  EXTR esym;
+
+  /* Number of R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 relocs against
+     this symbol.  */
+  unsigned int possibly_dynamic_relocs;
+
+  /* If the R_MIPS_32, R_MIPS_REL32, or R_MIPS_64 reloc is against
+     a readonly section.  */
+  boolean readonly_reloc;
+
+  /* The index of the first dynamic relocation (in the .rel.dyn
+     section) against this symbol.  */
+  unsigned int min_dyn_reloc_index;
+
+  /* We must not create a stub for a symbol that has relocations
+     related to taking the function's address, i.e. any but
+     R_MIPS_CALL*16 ones -- see "MIPS ABI Supplement, 3rd Edition",
+     p. 4-20.  */
+  boolean no_fn_stub;
+
+  /* If there is a stub that 32 bit functions should use to call this
+     16 bit function, this points to the section containing the stub.  */
+  asection *fn_stub;
+
+  /* Whether we need the fn_stub; this is set if this symbol appears
+     in any relocs other than a 16 bit call.  */
+  boolean need_fn_stub;
+
+  /* If there is a stub that 16 bit functions should use to call this
+     32 bit function, this points to the section containing the stub.  */
+  asection *call_stub;
+
+  /* This is like the call_stub field, but it is used if the function
+     being called returns a floating point value.  */
+  asection *call_fp_stub;
+
+  /* Are we forced local?  .*/
+  boolean forced_local;
+};
+
+/* MIPS ELF linker hash table.  */
+
+struct mips_elf_link_hash_table
+{
+  struct elf_link_hash_table root;
+#if 0
+  /* We no longer use this.  */
+  /* String section indices for the dynamic section symbols.  */
+  bfd_size_type dynsym_sec_strindex[SIZEOF_MIPS_DYNSYM_SECNAMES];
+#endif
+  /* The number of .rtproc entries.  */
+  bfd_size_type procedure_count;
+  /* The size of the .compact_rel section (if SGI_COMPAT).  */
+  bfd_size_type compact_rel_size;
+  /* This flag indicates that the value of DT_MIPS_RLD_MAP dynamic
+     entry is set to the address of __rld_obj_head as in Irix 5.  */
+  boolean use_rld_obj_head;
+  /* This is the value of the __rld_map or __rld_obj_head symbol.  */
+  bfd_vma rld_value;
+  /* This is set if we see any mips16 stub sections.  */
+  boolean mips16_stubs_seen;
+};
+
+/* Structure used to pass information to mips_elf_output_extsym.  */
+
+struct extsym_info
+{
+  bfd *abfd;
+  struct bfd_link_info *info;
+  struct ecoff_debug_info *debug;
+  const struct ecoff_debug_swap *swap;
+  boolean failed;
+};
+
+/* The names of the runtime procedure table symbols used on Irix 5.  */
+
+static const char * const mips_elf_dynsym_rtproc_names[] =
+{
+  "_procedure_table",
+  "_procedure_string_table",
+  "_procedure_table_size",
+  NULL
+};
+
+/* These structures are used to generate the .compact_rel section on
+   Irix 5.  */
+
+typedef struct
+{
+  unsigned long id1;		/* Always one?  */
+  unsigned long num;		/* Number of compact relocation entries.  */
+  unsigned long id2;		/* Always two?  */
+  unsigned long offset;		/* The file offset of the first relocation.  */
+  unsigned long reserved0;	/* Zero?  */
+  unsigned long reserved1;	/* Zero?  */
+} Elf32_compact_rel;
+
+typedef struct
+{
+  bfd_byte id1[4];
+  bfd_byte num[4];
+  bfd_byte id2[4];
+  bfd_byte offset[4];
+  bfd_byte reserved0[4];
+  bfd_byte reserved1[4];
+} Elf32_External_compact_rel;
+
+typedef struct
+{
+  unsigned int ctype : 1;	/* 1: long 0: short format. See below.  */
+  unsigned int rtype : 4;	/* Relocation types. See below.  */
+  unsigned int dist2to : 8;
+  unsigned int relvaddr : 19;	/* (VADDR - vaddr of the previous entry)/ 4 */
+  unsigned long konst;		/* KONST field. See below.  */
+  unsigned long vaddr;		/* VADDR to be relocated.  */
+} Elf32_crinfo;
+
+typedef struct
+{
+  unsigned int ctype : 1;	/* 1: long 0: short format. See below.  */
+  unsigned int rtype : 4;	/* Relocation types. See below.  */
+  unsigned int dist2to : 8;
+  unsigned int relvaddr : 19;	/* (VADDR - vaddr of the previous entry)/ 4 */
+  unsigned long konst;		/* KONST field. See below.  */
+} Elf32_crinfo2;
+
+typedef struct
+{
+  bfd_byte info[4];
+  bfd_byte konst[4];
+  bfd_byte vaddr[4];
+} Elf32_External_crinfo;
+
+typedef struct
+{
+  bfd_byte info[4];
+  bfd_byte konst[4];
+} Elf32_External_crinfo2;
+
+/* These are the constants used to swap the bitfields in a crinfo.  */
+
+#define CRINFO_CTYPE (0x1)
+#define CRINFO_CTYPE_SH (31)
+#define CRINFO_RTYPE (0xf)
+#define CRINFO_RTYPE_SH (27)
+#define CRINFO_DIST2TO (0xff)
+#define CRINFO_DIST2TO_SH (19)
+#define CRINFO_RELVADDR (0x7ffff)
+#define CRINFO_RELVADDR_SH (0)
+
+/* A compact relocation info has long (3 words) or short (2 words)
+   formats.  A short format doesn't have VADDR field and relvaddr
+   fields contains ((VADDR - vaddr of the previous entry) >> 2).  */
+#define CRF_MIPS_LONG			1
+#define CRF_MIPS_SHORT			0
+
+/* There are 4 types of compact relocation at least. The value KONST
+   has different meaning for each type:
+
+   (type)		(konst)
+   CT_MIPS_REL32	Address in data
+   CT_MIPS_WORD		Address in word (XXX)
+   CT_MIPS_GPHI_LO	GP - vaddr
+   CT_MIPS_JMPAD	Address to jump
+   */
+
+#define CRT_MIPS_REL32			0xa
+#define CRT_MIPS_WORD			0xb
+#define CRT_MIPS_GPHI_LO		0xc
+#define CRT_MIPS_JMPAD			0xd
+
+#define mips_elf_set_cr_format(x,format)	((x).ctype = (format))
+#define mips_elf_set_cr_type(x,type)		((x).rtype = (type))
+#define mips_elf_set_cr_dist2to(x,v)		((x).dist2to = (v))
+#define mips_elf_set_cr_relvaddr(x,d)		((x).relvaddr = (d)<<2)
+
+/* The structure of the runtime procedure descriptor created by the
+   loader for use by the static exception system.  */
+
+typedef struct runtime_pdr {
+	bfd_vma	adr;		/* memory address of start of procedure */
+	long	regmask;	/* save register mask */
+	long	regoffset;	/* save register offset */
+	long	fregmask;	/* save floating point register mask */
+	long	fregoffset;	/* save floating point register offset */
+	long	frameoffset;	/* frame size */
+	short	framereg;	/* frame pointer register */
+	short	pcreg;		/* offset or reg of return pc */
+	long	irpss;		/* index into the runtime string table */
+	long	reserved;
+	struct exception_info *exception_info;/* pointer to exception array */
+} RPDR, *pRPDR;
+#define cbRPDR sizeof (RPDR)
+#define rpdNil ((pRPDR) 0)
+
+static struct bfd_hash_entry *mips_elf_link_hash_newfunc
+  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+static void ecoff_swap_rpdr_out
+  PARAMS ((bfd *, const RPDR *, struct rpdr_ext *));
+static boolean mips_elf_create_procedure_table
+  PARAMS ((PTR, bfd *, struct bfd_link_info *, asection *,
+	   struct ecoff_debug_info *));
+static boolean mips_elf_check_mips16_stubs
+  PARAMS ((struct mips_elf_link_hash_entry *, PTR));
+static void bfd_mips_elf32_swap_gptab_in
+  PARAMS ((bfd *, const Elf32_External_gptab *, Elf32_gptab *));
+static void bfd_mips_elf32_swap_gptab_out
+  PARAMS ((bfd *, const Elf32_gptab *, Elf32_External_gptab *));
+static void bfd_elf32_swap_compact_rel_out
+  PARAMS ((bfd *, const Elf32_compact_rel *, Elf32_External_compact_rel *));
+static void bfd_elf32_swap_crinfo_out
+  PARAMS ((bfd *, const Elf32_crinfo *, Elf32_External_crinfo *));
+#if 0
+static void bfd_mips_elf_swap_msym_in
+  PARAMS ((bfd *, const Elf32_External_Msym *, Elf32_Internal_Msym *));
+#endif
+static void bfd_mips_elf_swap_msym_out
+  PARAMS ((bfd *, const Elf32_Internal_Msym *, Elf32_External_Msym *));
+static int sort_dynamic_relocs
+  PARAMS ((const void *, const void *));
+static boolean mips_elf_output_extsym
+  PARAMS ((struct mips_elf_link_hash_entry *, PTR));
+static int gptab_compare PARAMS ((const void *, const void *));
+static asection * mips_elf_got_section PARAMS ((bfd *));
+static struct mips_got_info *mips_elf_got_info
+  PARAMS ((bfd *, asection **));
+static bfd_vma mips_elf_local_got_index
+  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma));
+static bfd_vma mips_elf_global_got_index
+  PARAMS ((bfd *, struct elf_link_hash_entry *));
+static bfd_vma mips_elf_got_page
+  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, bfd_vma *));
+static bfd_vma mips_elf_got16_entry
+  PARAMS ((bfd *, struct bfd_link_info *, bfd_vma, boolean));
+static bfd_vma mips_elf_got_offset_from_index
+  PARAMS ((bfd *, bfd *, bfd_vma));
+static bfd_vma mips_elf_create_local_got_entry
+  PARAMS ((bfd *, struct mips_got_info *, asection *, bfd_vma));
+static boolean mips_elf_sort_hash_table
+  PARAMS ((struct bfd_link_info *, unsigned long));
+static boolean mips_elf_sort_hash_table_f
+  PARAMS ((struct mips_elf_link_hash_entry *, PTR));
+static boolean mips_elf_record_global_got_symbol
+  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *,
+	   struct mips_got_info *));
+static const Elf_Internal_Rela *mips_elf_next_relocation
+  PARAMS ((bfd *, unsigned int, const Elf_Internal_Rela *,
+	   const Elf_Internal_Rela *));
+static boolean mips_elf_local_relocation_p
+  PARAMS ((bfd *, const Elf_Internal_Rela *, asection **, boolean));
+static bfd_vma mips_elf_sign_extend PARAMS ((bfd_vma, int));
+static boolean mips_elf_overflow_p PARAMS ((bfd_vma, int));
+static bfd_vma mips_elf_high PARAMS ((bfd_vma));
+static bfd_vma mips_elf_higher PARAMS ((bfd_vma));
+static bfd_vma mips_elf_highest PARAMS ((bfd_vma));
+static boolean mips_elf_create_compact_rel_section
+  PARAMS ((bfd *, struct bfd_link_info *));
+static boolean mips_elf_create_got_section
+  PARAMS ((bfd *, struct bfd_link_info *));
+static asection *mips_elf_create_msym_section
+  PARAMS ((bfd *));
+static bfd_reloc_status_type mips_elf_calculate_relocation
+  PARAMS ((bfd *, bfd *, asection *, struct bfd_link_info *,
+	   const Elf_Internal_Rela *, bfd_vma, reloc_howto_type *,
+	   Elf_Internal_Sym *, asection **, bfd_vma *, const char **,
+	   boolean *));
+static bfd_vma mips_elf_obtain_contents
+  PARAMS ((reloc_howto_type *, const Elf_Internal_Rela *, bfd *, bfd_byte *));
+static boolean mips_elf_perform_relocation
+  PARAMS ((struct bfd_link_info *, reloc_howto_type *,
+	   const Elf_Internal_Rela *, bfd_vma, bfd *, asection *, bfd_byte *,
+	   boolean));
+static boolean mips_elf_stub_section_p
+  PARAMS ((bfd *, asection *));
+static void mips_elf_allocate_dynamic_relocations
+  PARAMS ((bfd *, unsigned int));
+static boolean mips_elf_create_dynamic_relocation
+  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Rela *,
+	   struct mips_elf_link_hash_entry *, asection *,
+	   bfd_vma, bfd_vma *, asection *));
+static INLINE int elf_mips_isa PARAMS ((flagword));
+static INLINE char* elf_mips_abi_name PARAMS ((bfd *));
+static void mips_elf_irix6_finish_dynamic_symbol
+  PARAMS ((bfd *, const char *, Elf_Internal_Sym *));
+
+/* This will be used when we sort the dynamic relocation records.  */
+static bfd *reldyn_sorting_bfd;
+
+/* Nonzero if ABFD is using the N32 ABI.  */
+
+#define ABI_N32_P(abfd) \
+  ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
+
+/* Nonzero if ABFD is using the 64-bit ABI. */
+#define ABI_64_P(abfd) \
+  ((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0)
+
+#define IRIX_COMPAT(abfd) \
+  (get_elf_backend_data (abfd)->elf_backend_mips_irix_compat (abfd))
+
+#define NEWABI_P(abfd) (ABI_N32_P(abfd) || ABI_64_P(abfd))
+
+/* Whether we are trying to be compatible with IRIX at all.  */
+#define SGI_COMPAT(abfd) \
+  (IRIX_COMPAT (abfd) != ict_none)
+
+/* The name of the options section.  */
+#define MIPS_ELF_OPTIONS_SECTION_NAME(abfd) \
+  (IRIX_COMPAT (abfd) == ict_irix6 ? ".MIPS.options" : ".options")
+
+/* The name of the stub section.  */
+#define MIPS_ELF_STUB_SECTION_NAME(abfd) \
+  (IRIX_COMPAT (abfd) == ict_irix6 ? ".MIPS.stubs" : ".stub")
+
+/* The size of an external REL relocation.  */
+#define MIPS_ELF_REL_SIZE(abfd) \
+  (get_elf_backend_data (abfd)->s->sizeof_rel)
+
+/* The size of an external dynamic table entry.  */
+#define MIPS_ELF_DYN_SIZE(abfd) \
+  (get_elf_backend_data (abfd)->s->sizeof_dyn)
+
+/* The size of a GOT entry.  */
+#define MIPS_ELF_GOT_SIZE(abfd) \
+  (get_elf_backend_data (abfd)->s->arch_size / 8)
+
+/* The size of a symbol-table entry.  */
+#define MIPS_ELF_SYM_SIZE(abfd) \
+  (get_elf_backend_data (abfd)->s->sizeof_sym)
+
+/* The default alignment for sections, as a power of two.  */
+#define MIPS_ELF_LOG_FILE_ALIGN(abfd)				\
+  (get_elf_backend_data (abfd)->s->file_align == 8 ? 3 : 2)
+
+/* Get word-sized data.  */
+#define MIPS_ELF_GET_WORD(abfd, ptr) \
+  (ABI_64_P (abfd) ? bfd_get_64 (abfd, ptr) : bfd_get_32 (abfd, ptr))
+
+/* Put out word-sized data.  */
+#define MIPS_ELF_PUT_WORD(abfd, val, ptr)	\
+  (ABI_64_P (abfd) 				\
+   ? bfd_put_64 (abfd, val, ptr) 		\
+   : bfd_put_32 (abfd, val, ptr))
+
+/* Add a dynamic symbol table-entry.  */
+#ifdef BFD64
+#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val)			\
+  (ABI_64_P (elf_hash_table (info)->dynobj)				\
+   ? bfd_elf64_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val)	\
+   : bfd_elf32_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
+#else
+#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val)			\
+  (ABI_64_P (elf_hash_table (info)->dynobj)				\
+   ? (boolean) (abort (), false)					\
+   : bfd_elf32_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
+#endif
+
+#define MIPS_ELF_RTYPE_TO_HOWTO(abfd, rtype, rela)			\
+  (get_elf_backend_data (abfd)->elf_backend_mips_rtype_to_howto (rtype, rela))
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+   from smaller values.  Start with zero, widen, *then* decrement.  */
+#define MINUS_ONE	(((bfd_vma)0) - 1)
+
+/* The number of local .got entries we reserve.  */
+#define MIPS_RESERVED_GOTNO (2)
+
+/* Instructions which appear in a stub.  For some reason the stub is
+   slightly different on an SGI system.  */
+#define ELF_MIPS_GP_OFFSET(abfd) (SGI_COMPAT (abfd) ? 0x7ff0 : 0x8000)
+#define STUB_LW(abfd)						\
+  (SGI_COMPAT (abfd)						\
+   ? (ABI_64_P (abfd)  						\
+      ? 0xdf998010		/* ld t9,0x8010(gp) */		\
+      : 0x8f998010)             /* lw t9,0x8010(gp) */		\
+   : 0x8f998010)		/* lw t9,0x8000(gp) */
+#define STUB_MOVE(abfd)                                         \
+  (SGI_COMPAT (abfd) ? 0x03e07825 : 0x03e07821)         /* move t7,ra */
+#define STUB_JALR 0x0320f809				/* jal t9 */
+#define STUB_LI16(abfd)                                         \
+  (SGI_COMPAT (abfd) ? 0x34180000 : 0x24180000)         /* ori t8,zero,0 */
+#define MIPS_FUNCTION_STUB_SIZE (16)
+
+/* The name of the dynamic interpreter.  This is put in the .interp
+   section.  */
+
+#define ELF_DYNAMIC_INTERPRETER(abfd) 		\
+   (ABI_N32_P (abfd) ? "/usr/lib32/libc.so.1" 	\
+    : ABI_64_P (abfd) ? "/usr/lib64/libc.so.1" 	\
+    : "/usr/lib/libc.so.1")
+
+#ifdef BFD64
+#define ELF_R_SYM(bfd, i)					\
+  (ABI_64_P (bfd) ? ELF64_R_SYM (i) : ELF32_R_SYM (i))
+#define ELF_R_TYPE(bfd, i)					\
+  (ABI_64_P (bfd) ? ELF64_MIPS_R_TYPE (i) : ELF32_R_TYPE (i))
+#define ELF_R_INFO(bfd, s, t)					\
+  (ABI_64_P (bfd) ? ELF64_R_INFO (s, t) : ELF32_R_INFO (s, t))
+#else
+#define ELF_R_SYM(bfd, i)					\
+  (ELF32_R_SYM (i))
+#define ELF_R_TYPE(bfd, i)					\
+  (ELF32_R_TYPE (i))
+#define ELF_R_INFO(bfd, s, t)					\
+  (ELF32_R_INFO (s, t))
+#endif
+
+  /* The mips16 compiler uses a couple of special sections to handle
+     floating point arguments.
+
+     Section names that look like .mips16.fn.FNNAME contain stubs that
+     copy floating point arguments from the fp regs to the gp regs and
+     then jump to FNNAME.  If any 32 bit function calls FNNAME, the
+     call should be redirected to the stub instead.  If no 32 bit
+     function calls FNNAME, the stub should be discarded.  We need to
+     consider any reference to the function, not just a call, because
+     if the address of the function is taken we will need the stub,
+     since the address might be passed to a 32 bit function.
+
+     Section names that look like .mips16.call.FNNAME contain stubs
+     that copy floating point arguments from the gp regs to the fp
+     regs and then jump to FNNAME.  If FNNAME is a 32 bit function,
+     then any 16 bit function that calls FNNAME should be redirected
+     to the stub instead.  If FNNAME is not a 32 bit function, the
+     stub should be discarded.
+
+     .mips16.call.fp.FNNAME sections are similar, but contain stubs
+     which call FNNAME and then copy the return value from the fp regs
+     to the gp regs.  These stubs store the return value in $18 while
+     calling FNNAME; any function which might call one of these stubs
+     must arrange to save $18 around the call.  (This case is not
+     needed for 32 bit functions that call 16 bit functions, because
+     16 bit functions always return floating point values in both
+     $f0/$f1 and $2/$3.)
+
+     Note that in all cases FNNAME might be defined statically.
+     Therefore, FNNAME is not used literally.  Instead, the relocation
+     information will indicate which symbol the section is for.
+
+     We record any stubs that we find in the symbol table.  */
+
+#define FN_STUB ".mips16.fn."
+#define CALL_STUB ".mips16.call."
+#define CALL_FP_STUB ".mips16.call.fp."
+
+/* Look up an entry in a MIPS ELF linker hash table.  */
+
+#define mips_elf_link_hash_lookup(table, string, create, copy, follow)	\
+  ((struct mips_elf_link_hash_entry *)					\
+   elf_link_hash_lookup (&(table)->root, (string), (create),		\
+			 (copy), (follow)))
+
+/* Traverse a MIPS ELF linker hash table.  */
+
+#define mips_elf_link_hash_traverse(table, func, info)			\
+  (elf_link_hash_traverse						\
+   (&(table)->root,							\
+    (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),	\
+    (info)))
+
+/* Get the MIPS ELF linker hash table from a link_info structure.  */
+
+#define mips_elf_hash_table(p) \
+  ((struct mips_elf_link_hash_table *) ((p)->hash))
+
+/* Create an entry in a MIPS ELF linker hash table.  */
+
+static struct bfd_hash_entry *
+mips_elf_link_hash_newfunc (entry, table, string)
+     struct bfd_hash_entry *entry;
+     struct bfd_hash_table *table;
+     const char *string;
+{
+  struct mips_elf_link_hash_entry *ret =
+    (struct mips_elf_link_hash_entry *) entry;
+
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (ret == (struct mips_elf_link_hash_entry *) NULL)
+    ret = ((struct mips_elf_link_hash_entry *)
+	   bfd_hash_allocate (table,
+			      sizeof (struct mips_elf_link_hash_entry)));
+  if (ret == (struct mips_elf_link_hash_entry *) NULL)
+    return (struct bfd_hash_entry *) ret;
+
+  /* Call the allocation method of the superclass.  */
+  ret = ((struct mips_elf_link_hash_entry *)
+	 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+				     table, string));
+  if (ret != (struct mips_elf_link_hash_entry *) NULL)
+    {
+      /* Set local fields.  */
+      memset (&ret->esym, 0, sizeof (EXTR));
+      /* We use -2 as a marker to indicate that the information has
+	 not been set.  -1 means there is no associated ifd.  */
+      ret->esym.ifd = -2;
+      ret->possibly_dynamic_relocs = 0;
+      ret->readonly_reloc = false;
+      ret->min_dyn_reloc_index = 0;
+      ret->no_fn_stub = false;
+      ret->fn_stub = NULL;
+      ret->need_fn_stub = false;
+      ret->call_stub = NULL;
+      ret->call_fp_stub = NULL;
+      ret->forced_local = false;
+    }
+
+  return (struct bfd_hash_entry *) ret;
+}
+
+/* Read ECOFF debugging information from a .mdebug section into a
+   ecoff_debug_info structure.  */
+
+boolean
+_bfd_mips_elf_read_ecoff_info (abfd, section, debug)
+     bfd *abfd;
+     asection *section;
+     struct ecoff_debug_info *debug;
+{
+  HDRR *symhdr;
+  const struct ecoff_debug_swap *swap;
+  char *ext_hdr = NULL;
+
+  swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+  memset (debug, 0, sizeof (*debug));
+
+  ext_hdr = (char *) bfd_malloc (swap->external_hdr_size);
+  if (ext_hdr == NULL && swap->external_hdr_size != 0)
+    goto error_return;
+
+  if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
+				swap->external_hdr_size)
+      == false)
+    goto error_return;
+
+  symhdr = &debug->symbolic_header;
+  (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr);
+
+  /* The symbolic header contains absolute file offsets and sizes to
+     read.  */
+#define READ(ptr, offset, count, size, type)				\
+  if (symhdr->count == 0)						\
+    debug->ptr = NULL;							\
+  else									\
+    {									\
+      bfd_size_type amt = (bfd_size_type) size * symhdr->count;		\
+      debug->ptr = (type) bfd_malloc (amt);				\
+      if (debug->ptr == NULL)						\
+	goto error_return;						\
+      if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0	\
+	  || bfd_bread (debug->ptr, amt, abfd) != amt)			\
+	goto error_return;						\
+    }
+
+  READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
+  READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
+  READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
+  READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
+  READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
+  READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
+	union aux_ext *);
+  READ (ss, cbSsOffset, issMax, sizeof (char), char *);
+  READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
+  READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
+  READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
+  READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
+#undef READ
+
+  debug->fdr = NULL;
+  debug->adjust = NULL;
+
+  return true;
+
+ error_return:
+  if (ext_hdr != NULL)
+    free (ext_hdr);
+  if (debug->line != NULL)
+    free (debug->line);
+  if (debug->external_dnr != NULL)
+    free (debug->external_dnr);
+  if (debug->external_pdr != NULL)
+    free (debug->external_pdr);
+  if (debug->external_sym != NULL)
+    free (debug->external_sym);
+  if (debug->external_opt != NULL)
+    free (debug->external_opt);
+  if (debug->external_aux != NULL)
+    free (debug->external_aux);
+  if (debug->ss != NULL)
+    free (debug->ss);
+  if (debug->ssext != NULL)
+    free (debug->ssext);
+  if (debug->external_fdr != NULL)
+    free (debug->external_fdr);
+  if (debug->external_rfd != NULL)
+    free (debug->external_rfd);
+  if (debug->external_ext != NULL)
+    free (debug->external_ext);
+  return false;
+}
+
+/* Swap RPDR (runtime procedure table entry) for output.  */
+
+static void
+ecoff_swap_rpdr_out (abfd, in, ex)
+     bfd *abfd;
+     const RPDR *in;
+     struct rpdr_ext *ex;
+{
+  H_PUT_S32 (abfd, in->adr, ex->p_adr);
+  H_PUT_32 (abfd, in->regmask, ex->p_regmask);
+  H_PUT_32 (abfd, in->regoffset, ex->p_regoffset);
+  H_PUT_32 (abfd, in->fregmask, ex->p_fregmask);
+  H_PUT_32 (abfd, in->fregoffset, ex->p_fregoffset);
+  H_PUT_32 (abfd, in->frameoffset, ex->p_frameoffset);
+
+  H_PUT_16 (abfd, in->framereg, ex->p_framereg);
+  H_PUT_16 (abfd, in->pcreg, ex->p_pcreg);
+
+  H_PUT_32 (abfd, in->irpss, ex->p_irpss);
+#if 0 /* FIXME */
+  H_PUT_S32 (abfd, in->exception_info, ex->p_exception_info);
+#endif
+}
+
+/* Create a runtime procedure table from the .mdebug section.  */
+
+static boolean
+mips_elf_create_procedure_table (handle, abfd, info, s, debug)
+     PTR handle;
+     bfd *abfd;
+     struct bfd_link_info *info;
+     asection *s;
+     struct ecoff_debug_info *debug;
+{
+  const struct ecoff_debug_swap *swap;
+  HDRR *hdr = &debug->symbolic_header;
+  RPDR *rpdr, *rp;
+  struct rpdr_ext *erp;
+  PTR rtproc;
+  struct pdr_ext *epdr;
+  struct sym_ext *esym;
+  char *ss, **sv;
+  char *str;
+  bfd_size_type size;
+  bfd_size_type count;
+  unsigned long sindex;
+  unsigned long i;
+  PDR pdr;
+  SYMR sym;
+  const char *no_name_func = _("static procedure (no name)");
+
+  epdr = NULL;
+  rpdr = NULL;
+  esym = NULL;
+  ss = NULL;
+  sv = NULL;
+
+  swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+
+  sindex = strlen (no_name_func) + 1;
+  count = hdr->ipdMax;
+  if (count > 0)
+    {
+      size = swap->external_pdr_size;
+
+      epdr = (struct pdr_ext *) bfd_malloc (size * count);
+      if (epdr == NULL)
+	goto error_return;
+
+      if (! _bfd_ecoff_get_accumulated_pdr (handle, (PTR) epdr))
+	goto error_return;
+
+      size = sizeof (RPDR);
+      rp = rpdr = (RPDR *) bfd_malloc (size * count);
+      if (rpdr == NULL)
+	goto error_return;
+
+      size = sizeof (char *);
+      sv = (char **) bfd_malloc (size * count);
+      if (sv == NULL)
+	goto error_return;
+
+      count = hdr->isymMax;
+      size = swap->external_sym_size;
+      esym = (struct sym_ext *) bfd_malloc (size * count);
+      if (esym == NULL)
+	goto error_return;
+
+      if (! _bfd_ecoff_get_accumulated_sym (handle, (PTR) esym))
+	goto error_return;
+
+      count = hdr->issMax;
+      ss = (char *) bfd_malloc (count);
+      if (ss == NULL)
+	goto error_return;
+      if (! _bfd_ecoff_get_accumulated_ss (handle, (PTR) ss))
+	goto error_return;
+
+      count = hdr->ipdMax;
+      for (i = 0; i < (unsigned long) count; i++, rp++)
+	{
+	  (*swap->swap_pdr_in) (abfd, (PTR) (epdr + i), &pdr);
+	  (*swap->swap_sym_in) (abfd, (PTR) &esym[pdr.isym], &sym);
+	  rp->adr = sym.value;
+	  rp->regmask = pdr.regmask;
+	  rp->regoffset = pdr.regoffset;
+	  rp->fregmask = pdr.fregmask;
+	  rp->fregoffset = pdr.fregoffset;
+	  rp->frameoffset = pdr.frameoffset;
+	  rp->framereg = pdr.framereg;
+	  rp->pcreg = pdr.pcreg;
+	  rp->irpss = sindex;
+	  sv[i] = ss + sym.iss;
+	  sindex += strlen (sv[i]) + 1;
+	}
+    }
+
+  size = sizeof (struct rpdr_ext) * (count + 2) + sindex;
+  size = BFD_ALIGN (size, 16);
+  rtproc = (PTR) bfd_alloc (abfd, size);
+  if (rtproc == NULL)
+    {
+      mips_elf_hash_table (info)->procedure_count = 0;
+      goto error_return;
+    }
+
+  mips_elf_hash_table (info)->procedure_count = count + 2;
+
+  erp = (struct rpdr_ext *) rtproc;
+  memset (erp, 0, sizeof (struct rpdr_ext));
+  erp++;
+  str = (char *) rtproc + sizeof (struct rpdr_ext) * (count + 2);
+  strcpy (str, no_name_func);
+  str += strlen (no_name_func) + 1;
+  for (i = 0; i < count; i++)
+    {
+      ecoff_swap_rpdr_out (abfd, rpdr + i, erp + i);
+      strcpy (str, sv[i]);
+      str += strlen (sv[i]) + 1;
+    }
+  H_PUT_S32 (abfd, -1, (erp + count)->p_adr);
+
+  /* Set the size and contents of .rtproc section.  */
+  s->_raw_size = size;
+  s->contents = (bfd_byte *) rtproc;
+
+  /* Skip this section later on (I don't think this currently
+     matters, but someday it might).  */
+  s->link_order_head = (struct bfd_link_order *) NULL;
+
+  if (epdr != NULL)
+    free (epdr);
+  if (rpdr != NULL)
+    free (rpdr);
+  if (esym != NULL)
+    free (esym);
+  if (ss != NULL)
+    free (ss);
+  if (sv != NULL)
+    free (sv);
+
+  return true;
+
+ error_return:
+  if (epdr != NULL)
+    free (epdr);
+  if (rpdr != NULL)
+    free (rpdr);
+  if (esym != NULL)
+    free (esym);
+  if (ss != NULL)
+    free (ss);
+  if (sv != NULL)
+    free (sv);
+  return false;
+}
+
+/* Check the mips16 stubs for a particular symbol, and see if we can
+   discard them.  */
+
+static boolean
+mips_elf_check_mips16_stubs (h, data)
+     struct mips_elf_link_hash_entry *h;
+     PTR data ATTRIBUTE_UNUSED;
+{
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+
+  if (h->fn_stub != NULL
+      && ! h->need_fn_stub)
+    {
+      /* We don't need the fn_stub; the only references to this symbol
+         are 16 bit calls.  Clobber the size to 0 to prevent it from
+         being included in the link.  */
+      h->fn_stub->_raw_size = 0;
+      h->fn_stub->_cooked_size = 0;
+      h->fn_stub->flags &= ~SEC_RELOC;
+      h->fn_stub->reloc_count = 0;
+      h->fn_stub->flags |= SEC_EXCLUDE;
+    }
+
+  if (h->call_stub != NULL
+      && h->root.other == STO_MIPS16)
+    {
+      /* We don't need the call_stub; this is a 16 bit function, so
+         calls from other 16 bit functions are OK.  Clobber the size
+         to 0 to prevent it from being included in the link.  */
+      h->call_stub->_raw_size = 0;
+      h->call_stub->_cooked_size = 0;
+      h->call_stub->flags &= ~SEC_RELOC;
+      h->call_stub->reloc_count = 0;
+      h->call_stub->flags |= SEC_EXCLUDE;
+    }
+
+  if (h->call_fp_stub != NULL
+      && h->root.other == STO_MIPS16)
+    {
+      /* We don't need the call_stub; this is a 16 bit function, so
+         calls from other 16 bit functions are OK.  Clobber the size
+         to 0 to prevent it from being included in the link.  */
+      h->call_fp_stub->_raw_size = 0;
+      h->call_fp_stub->_cooked_size = 0;
+      h->call_fp_stub->flags &= ~SEC_RELOC;
+      h->call_fp_stub->reloc_count = 0;
+      h->call_fp_stub->flags |= SEC_EXCLUDE;
+    }
+
+  return true;
+}
+
+bfd_reloc_status_type
+_bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
+			       relocateable, data, gp)
+     bfd *abfd;
+     asymbol *symbol;
+     arelent *reloc_entry;
+     asection *input_section;
+     boolean relocateable;
+     PTR data;
+     bfd_vma gp;
+{
+  bfd_vma relocation;
+  unsigned long insn;
+  unsigned long val;
+
+  if (bfd_is_com_section (symbol->section))
+    relocation = 0;
+  else
+    relocation = symbol->value;
+
+  relocation += symbol->section->output_section->vma;
+  relocation += symbol->section->output_offset;
+
+  if (reloc_entry->address > input_section->_cooked_size)
+    return bfd_reloc_outofrange;
+
+  insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+
+  /* Set val to the offset into the section or symbol.  */
+  if (reloc_entry->howto->src_mask == 0)
+    {
+      /* This case occurs with the 64-bit MIPS ELF ABI.  */
+      val = reloc_entry->addend;
+    }
+  else
+    {
+      val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
+      if (val & 0x8000)
+	val -= 0x10000;
+    }
+
+  /* Adjust val for the final section location and GP value.  If we
+     are producing relocateable output, we don't want to do this for
+     an external symbol.  */
+  if (! relocateable
+      || (symbol->flags & BSF_SECTION_SYM) != 0)
+    val += relocation - gp;
+
+  insn = (insn & ~0xffff) | (val & 0xffff);
+  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+  if (relocateable)
+    reloc_entry->address += input_section->output_offset;
+
+  else if ((long) val >= 0x8000 || (long) val < -0x8000)
+    return bfd_reloc_overflow;
+
+  return bfd_reloc_ok;
+}
+
+/* Swap an entry in a .gptab section.  Note that these routines rely
+   on the equivalence of the two elements of the union.  */
+
+static void
+bfd_mips_elf32_swap_gptab_in (abfd, ex, in)
+     bfd *abfd;
+     const Elf32_External_gptab *ex;
+     Elf32_gptab *in;
+{
+  in->gt_entry.gt_g_value = H_GET_32 (abfd, ex->gt_entry.gt_g_value);
+  in->gt_entry.gt_bytes = H_GET_32 (abfd, ex->gt_entry.gt_bytes);
+}
+
+static void
+bfd_mips_elf32_swap_gptab_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf32_gptab *in;
+     Elf32_External_gptab *ex;
+{
+  H_PUT_32 (abfd, in->gt_entry.gt_g_value, ex->gt_entry.gt_g_value);
+  H_PUT_32 (abfd, in->gt_entry.gt_bytes, ex->gt_entry.gt_bytes);
+}
+
+static void
+bfd_elf32_swap_compact_rel_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf32_compact_rel *in;
+     Elf32_External_compact_rel *ex;
+{
+  H_PUT_32 (abfd, in->id1, ex->id1);
+  H_PUT_32 (abfd, in->num, ex->num);
+  H_PUT_32 (abfd, in->id2, ex->id2);
+  H_PUT_32 (abfd, in->offset, ex->offset);
+  H_PUT_32 (abfd, in->reserved0, ex->reserved0);
+  H_PUT_32 (abfd, in->reserved1, ex->reserved1);
+}
+
+static void
+bfd_elf32_swap_crinfo_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf32_crinfo *in;
+     Elf32_External_crinfo *ex;
+{
+  unsigned long l;
+
+  l = (((in->ctype & CRINFO_CTYPE) << CRINFO_CTYPE_SH)
+       | ((in->rtype & CRINFO_RTYPE) << CRINFO_RTYPE_SH)
+       | ((in->dist2to & CRINFO_DIST2TO) << CRINFO_DIST2TO_SH)
+       | ((in->relvaddr & CRINFO_RELVADDR) << CRINFO_RELVADDR_SH));
+  H_PUT_32 (abfd, l, ex->info);
+  H_PUT_32 (abfd, in->konst, ex->konst);
+  H_PUT_32 (abfd, in->vaddr, ex->vaddr);
+}
+
+#if 0
+/* Swap in an MSYM entry.  */
+
+static void
+bfd_mips_elf_swap_msym_in (abfd, ex, in)
+     bfd *abfd;
+     const Elf32_External_Msym *ex;
+     Elf32_Internal_Msym *in;
+{
+  in->ms_hash_value = H_GET_32 (abfd, ex->ms_hash_value);
+  in->ms_info = H_GET_32 (abfd, ex->ms_info);
+}
+#endif
+/* Swap out an MSYM entry.  */
+
+static void
+bfd_mips_elf_swap_msym_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf32_Internal_Msym *in;
+     Elf32_External_Msym *ex;
+{
+  H_PUT_32 (abfd, in->ms_hash_value, ex->ms_hash_value);
+  H_PUT_32 (abfd, in->ms_info, ex->ms_info);
+}
+
+/* A .reginfo section holds a single Elf32_RegInfo structure.  These
+   routines swap this structure in and out.  They are used outside of
+   BFD, so they are globally visible.  */
+
+void
+bfd_mips_elf32_swap_reginfo_in (abfd, ex, in)
+     bfd *abfd;
+     const Elf32_External_RegInfo *ex;
+     Elf32_RegInfo *in;
+{
+  in->ri_gprmask = H_GET_32 (abfd, ex->ri_gprmask);
+  in->ri_cprmask[0] = H_GET_32 (abfd, ex->ri_cprmask[0]);
+  in->ri_cprmask[1] = H_GET_32 (abfd, ex->ri_cprmask[1]);
+  in->ri_cprmask[2] = H_GET_32 (abfd, ex->ri_cprmask[2]);
+  in->ri_cprmask[3] = H_GET_32 (abfd, ex->ri_cprmask[3]);
+  in->ri_gp_value = H_GET_32 (abfd, ex->ri_gp_value);
+}
+
+void
+bfd_mips_elf32_swap_reginfo_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf32_RegInfo *in;
+     Elf32_External_RegInfo *ex;
+{
+  H_PUT_32 (abfd, in->ri_gprmask, ex->ri_gprmask);
+  H_PUT_32 (abfd, in->ri_cprmask[0], ex->ri_cprmask[0]);
+  H_PUT_32 (abfd, in->ri_cprmask[1], ex->ri_cprmask[1]);
+  H_PUT_32 (abfd, in->ri_cprmask[2], ex->ri_cprmask[2]);
+  H_PUT_32 (abfd, in->ri_cprmask[3], ex->ri_cprmask[3]);
+  H_PUT_32 (abfd, in->ri_gp_value, ex->ri_gp_value);
+}
+
+/* In the 64 bit ABI, the .MIPS.options section holds register
+   information in an Elf64_Reginfo structure.  These routines swap
+   them in and out.  They are globally visible because they are used
+   outside of BFD.  These routines are here so that gas can call them
+   without worrying about whether the 64 bit ABI has been included.  */
+
+void
+bfd_mips_elf64_swap_reginfo_in (abfd, ex, in)
+     bfd *abfd;
+     const Elf64_External_RegInfo *ex;
+     Elf64_Internal_RegInfo *in;
+{
+  in->ri_gprmask = H_GET_32 (abfd, ex->ri_gprmask);
+  in->ri_pad = H_GET_32 (abfd, ex->ri_pad);
+  in->ri_cprmask[0] = H_GET_32 (abfd, ex->ri_cprmask[0]);
+  in->ri_cprmask[1] = H_GET_32 (abfd, ex->ri_cprmask[1]);
+  in->ri_cprmask[2] = H_GET_32 (abfd, ex->ri_cprmask[2]);
+  in->ri_cprmask[3] = H_GET_32 (abfd, ex->ri_cprmask[3]);
+  in->ri_gp_value = H_GET_64 (abfd, ex->ri_gp_value);
+}
+
+void
+bfd_mips_elf64_swap_reginfo_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf64_Internal_RegInfo *in;
+     Elf64_External_RegInfo *ex;
+{
+  H_PUT_32 (abfd, in->ri_gprmask, ex->ri_gprmask);
+  H_PUT_32 (abfd, in->ri_pad, ex->ri_pad);
+  H_PUT_32 (abfd, in->ri_cprmask[0], ex->ri_cprmask[0]);
+  H_PUT_32 (abfd, in->ri_cprmask[1], ex->ri_cprmask[1]);
+  H_PUT_32 (abfd, in->ri_cprmask[2], ex->ri_cprmask[2]);
+  H_PUT_32 (abfd, in->ri_cprmask[3], ex->ri_cprmask[3]);
+  H_PUT_64 (abfd, in->ri_gp_value, ex->ri_gp_value);
+}
+
+/* Swap in an options header.  */
+
+void
+bfd_mips_elf_swap_options_in (abfd, ex, in)
+     bfd *abfd;
+     const Elf_External_Options *ex;
+     Elf_Internal_Options *in;
+{
+  in->kind = H_GET_8 (abfd, ex->kind);
+  in->size = H_GET_8 (abfd, ex->size);
+  in->section = H_GET_16 (abfd, ex->section);
+  in->info = H_GET_32 (abfd, ex->info);
+}
+
+/* Swap out an options header.  */
+
+void
+bfd_mips_elf_swap_options_out (abfd, in, ex)
+     bfd *abfd;
+     const Elf_Internal_Options *in;
+     Elf_External_Options *ex;
+{
+  H_PUT_8 (abfd, in->kind, ex->kind);
+  H_PUT_8 (abfd, in->size, ex->size);
+  H_PUT_16 (abfd, in->section, ex->section);
+  H_PUT_32 (abfd, in->info, ex->info);
+}
+
+/* This function is called via qsort() to sort the dynamic relocation
+   entries by increasing r_symndx value.  */
+
+static int
+sort_dynamic_relocs (arg1, arg2)
+     const PTR arg1;
+     const PTR arg2;
+{
+  const Elf32_External_Rel *ext_reloc1 = (const Elf32_External_Rel *) arg1;
+  const Elf32_External_Rel *ext_reloc2 = (const Elf32_External_Rel *) arg2;
+
+  Elf_Internal_Rel int_reloc1;
+  Elf_Internal_Rel int_reloc2;
+
+  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, ext_reloc1, &int_reloc1);
+  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, ext_reloc2, &int_reloc2);
+
+  return (ELF32_R_SYM (int_reloc1.r_info) - ELF32_R_SYM (int_reloc2.r_info));
+}
+
+/* This routine is used to write out ECOFF debugging external symbol
+   information.  It is called via mips_elf_link_hash_traverse.  The
+   ECOFF external symbol information must match the ELF external
+   symbol information.  Unfortunately, at this point we don't know
+   whether a symbol is required by reloc information, so the two
+   tables may wind up being different.  We must sort out the external
+   symbol information before we can set the final size of the .mdebug
+   section, and we must set the size of the .mdebug section before we
+   can relocate any sections, and we can't know which symbols are
+   required by relocation until we relocate the sections.
+   Fortunately, it is relatively unlikely that any symbol will be
+   stripped but required by a reloc.  In particular, it can not happen
+   when generating a final executable.  */
+
+static boolean
+mips_elf_output_extsym (h, data)
+     struct mips_elf_link_hash_entry *h;
+     PTR data;
+{
+  struct extsym_info *einfo = (struct extsym_info *) data;
+  boolean strip;
+  asection *sec, *output_section;
+
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+
+  if (h->root.indx == -2)
+    strip = false;
+  else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+	    || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
+	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+	   && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
+    strip = true;
+  else if (einfo->info->strip == strip_all
+	   || (einfo->info->strip == strip_some
+	       && bfd_hash_lookup (einfo->info->keep_hash,
+				   h->root.root.root.string,
+				   false, false) == NULL))
+    strip = true;
+  else
+    strip = false;
+
+  if (strip)
+    return true;
+
+  if (h->esym.ifd == -2)
+    {
+      h->esym.jmptbl = 0;
+      h->esym.cobol_main = 0;
+      h->esym.weakext = 0;
+      h->esym.reserved = 0;
+      h->esym.ifd = ifdNil;
+      h->esym.asym.value = 0;
+      h->esym.asym.st = stGlobal;
+
+      if (h->root.root.type == bfd_link_hash_undefined
+	  || h->root.root.type == bfd_link_hash_undefweak)
+	{
+	  const char *name;
+
+	  /* Use undefined class.  Also, set class and type for some
+             special symbols.  */
+	  name = h->root.root.root.string;
+	  if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
+	      || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
+	    {
+	      h->esym.asym.sc = scData;
+	      h->esym.asym.st = stLabel;
+	      h->esym.asym.value = 0;
+	    }
+	  else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
+	    {
+	      h->esym.asym.sc = scAbs;
+	      h->esym.asym.st = stLabel;
+	      h->esym.asym.value =
+		mips_elf_hash_table (einfo->info)->procedure_count;
+	    }
+	  else if (strcmp (name, "_gp_disp") == 0)
+	    {
+	      h->esym.asym.sc = scAbs;
+	      h->esym.asym.st = stLabel;
+	      h->esym.asym.value = elf_gp (einfo->abfd);
+	    }
+	  else
+	    h->esym.asym.sc = scUndefined;
+	}
+      else if (h->root.root.type != bfd_link_hash_defined
+	  && h->root.root.type != bfd_link_hash_defweak)
+	h->esym.asym.sc = scAbs;
+      else
+	{
+	  const char *name;
+
+	  sec = h->root.root.u.def.section;
+	  output_section = sec->output_section;
+
+	  /* When making a shared library and symbol h is the one from
+	     the another shared library, OUTPUT_SECTION may be null.  */
+	  if (output_section == NULL)
+	    h->esym.asym.sc = scUndefined;
+	  else
+	    {
+	      name = bfd_section_name (output_section->owner, output_section);
+
+	      if (strcmp (name, ".text") == 0)
+		h->esym.asym.sc = scText;
+	      else if (strcmp (name, ".data") == 0)
+		h->esym.asym.sc = scData;
+	      else if (strcmp (name, ".sdata") == 0)
+		h->esym.asym.sc = scSData;
+	      else if (strcmp (name, ".rodata") == 0
+		       || strcmp (name, ".rdata") == 0)
+		h->esym.asym.sc = scRData;
+	      else if (strcmp (name, ".bss") == 0)
+		h->esym.asym.sc = scBss;
+	      else if (strcmp (name, ".sbss") == 0)
+		h->esym.asym.sc = scSBss;
+	      else if (strcmp (name, ".init") == 0)
+		h->esym.asym.sc = scInit;
+	      else if (strcmp (name, ".fini") == 0)
+		h->esym.asym.sc = scFini;
+	      else
+		h->esym.asym.sc = scAbs;
+	    }
+	}
+
+      h->esym.asym.reserved = 0;
+      h->esym.asym.index = indexNil;
+    }
+
+  if (h->root.root.type == bfd_link_hash_common)
+    h->esym.asym.value = h->root.root.u.c.size;
+  else if (h->root.root.type == bfd_link_hash_defined
+	   || h->root.root.type == bfd_link_hash_defweak)
+    {
+      if (h->esym.asym.sc == scCommon)
+	h->esym.asym.sc = scBss;
+      else if (h->esym.asym.sc == scSCommon)
+	h->esym.asym.sc = scSBss;
+
+      sec = h->root.root.u.def.section;
+      output_section = sec->output_section;
+      if (output_section != NULL)
+	h->esym.asym.value = (h->root.root.u.def.value
+			      + sec->output_offset
+			      + output_section->vma);
+      else
+	h->esym.asym.value = 0;
+    }
+  else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+    {
+      struct mips_elf_link_hash_entry *hd = h;
+      boolean no_fn_stub = h->no_fn_stub;
+
+      while (hd->root.root.type == bfd_link_hash_indirect)
+	{
+	  hd = (struct mips_elf_link_hash_entry *)h->root.root.u.i.link;
+	  no_fn_stub = no_fn_stub || hd->no_fn_stub;
+	}
+
+      if (!no_fn_stub)
+	{
+	  /* Set type and value for a symbol with a function stub.  */
+	  h->esym.asym.st = stProc;
+	  sec = hd->root.root.u.def.section;
+	  if (sec == NULL)
+	    h->esym.asym.value = 0;
+	  else
+	    {
+	      output_section = sec->output_section;
+	      if (output_section != NULL)
+		h->esym.asym.value = (hd->root.plt.offset
+				      + sec->output_offset
+				      + output_section->vma);
+	      else
+		h->esym.asym.value = 0;
+	    }
+#if 0 /* FIXME?  */
+	  h->esym.ifd = 0;
+#endif
+	}
+    }
+
+  if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
+				      h->root.root.root.string,
+				      &h->esym))
+    {
+      einfo->failed = true;
+      return false;
+    }
+
+  return true;
+}
+
+/* A comparison routine used to sort .gptab entries.  */
+
+static int
+gptab_compare (p1, p2)
+     const PTR p1;
+     const PTR p2;
+{
+  const Elf32_gptab *a1 = (const Elf32_gptab *) p1;
+  const Elf32_gptab *a2 = (const Elf32_gptab *) p2;
+
+  return a1->gt_entry.gt_g_value - a2->gt_entry.gt_g_value;
+}
+
+/* Returns the GOT section for ABFD.  */
+
+static asection *
+mips_elf_got_section (abfd)
+     bfd *abfd;
+{
+  return bfd_get_section_by_name (abfd, ".got");
+}
+
+/* Returns the GOT information associated with the link indicated by
+   INFO.  If SGOTP is non-NULL, it is filled in with the GOT
+   section.  */
+
+static struct mips_got_info *
+mips_elf_got_info (abfd, sgotp)
+     bfd *abfd;
+     asection **sgotp;
+{
+  asection *sgot;
+  struct mips_got_info *g;
+
+  sgot = mips_elf_got_section (abfd);
+  BFD_ASSERT (sgot != NULL);
+  BFD_ASSERT (elf_section_data (sgot) != NULL);
+  g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+  BFD_ASSERT (g != NULL);
+
+  if (sgotp)
+    *sgotp = sgot;
+  return g;
+}
+
+/* Returns the GOT offset at which the indicated address can be found.
+   If there is not yet a GOT entry for this value, create one.  Returns
+   -1 if no satisfactory GOT offset can be found.  */
+
+static bfd_vma
+mips_elf_local_got_index (abfd, info, value)
+     bfd *abfd;
+     struct bfd_link_info *info;
+     bfd_vma value;
+{
+  asection *sgot;
+  struct mips_got_info *g;
+  bfd_byte *entry;
+
+  g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
+
+  /* Look to see if we already have an appropriate entry.  */
+  for (entry = (sgot->contents
+		+ MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO);
+       entry != sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno;
+       entry += MIPS_ELF_GOT_SIZE (abfd))
+    {
+      bfd_vma address = MIPS_ELF_GET_WORD (abfd, entry);
+      if (address == value)
+	return entry - sgot->contents;
+    }
+
+  return mips_elf_create_local_got_entry (abfd, g, sgot, value);
+}
+
+/* Returns the GOT index for the global symbol indicated by H.  */
+
+static bfd_vma
+mips_elf_global_got_index (abfd, h)
+     bfd *abfd;
+     struct elf_link_hash_entry *h;
+{
+  bfd_vma index;
+  asection *sgot;
+  struct mips_got_info *g;
+
+  g = mips_elf_got_info (abfd, &sgot);
+
+  /* Once we determine the global GOT entry with the lowest dynamic
+     symbol table index, we must put all dynamic symbols with greater
+     indices into the GOT.  That makes it easy to calculate the GOT
+     offset.  */
+  BFD_ASSERT (h->dynindx >= g->global_gotsym->dynindx);
+  index = ((h->dynindx - g->global_gotsym->dynindx + g->local_gotno)
+	   * MIPS_ELF_GOT_SIZE (abfd));
+  BFD_ASSERT (index < sgot->_raw_size);
+
+  return index;
+}
+
+/* Find a GOT entry that is within 32KB of the VALUE.  These entries
+   are supposed to be placed at small offsets in the GOT, i.e.,
+   within 32KB of GP.  Return the index into the GOT for this page,
+   and store the offset from this entry to the desired address in
+   OFFSETP, if it is non-NULL.  */
+
+static bfd_vma
+mips_elf_got_page (abfd, info, value, offsetp)
+     bfd *abfd;
+     struct bfd_link_info *info;
+     bfd_vma value;
+     bfd_vma *offsetp;
+{
+  asection *sgot;
+  struct mips_got_info *g;
+  bfd_byte *entry;
+  bfd_byte *last_entry;
+  bfd_vma index = 0;
+  bfd_vma address;
+
+  g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
+
+  /* Look to see if we aleady have an appropriate entry.  */
+  last_entry = sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno;
+  for (entry = (sgot->contents
+		+ MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO);
+       entry != last_entry;
+       entry += MIPS_ELF_GOT_SIZE (abfd))
+    {
+      address = MIPS_ELF_GET_WORD (abfd, entry);
+
+      if (!mips_elf_overflow_p (value - address, 16))
+	{
+	  /* This entry will serve as the page pointer.  We can add a
+	     16-bit number to it to get the actual address.  */
+	  index = entry - sgot->contents;
+	  break;
+	}
+    }
+
+  /* If we didn't have an appropriate entry, we create one now.  */
+  if (entry == last_entry)
+    index = mips_elf_create_local_got_entry (abfd, g, sgot, value);
+
+  if (offsetp)
+    {
+      address = MIPS_ELF_GET_WORD (abfd, entry);
+      *offsetp = value - address;
+    }
+
+  return index;
+}
+
+/* Find a GOT entry whose higher-order 16 bits are the same as those
+   for value.  Return the index into the GOT for this entry.  */
+
+static bfd_vma
+mips_elf_got16_entry (abfd, info, value, external)
+     bfd *abfd;
+     struct bfd_link_info *info;
+     bfd_vma value;
+     boolean external;
+{
+  asection *sgot;
+  struct mips_got_info *g;
+  bfd_byte *entry;
+  bfd_byte *last_entry;
+  bfd_vma index = 0;
+  bfd_vma address;
+
+  if (! external)
+    {
+      /* Although the ABI says that it is "the high-order 16 bits" that we
+	 want, it is really the %high value.  The complete value is
+	 calculated with a `addiu' of a LO16 relocation, just as with a
+	 HI16/LO16 pair.  */
+      value = mips_elf_high (value) << 16;
+    }
+
+  g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
+
+  /* Look to see if we already have an appropriate entry.  */
+  last_entry = sgot->contents + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno;
+  for (entry = (sgot->contents
+		+ MIPS_ELF_GOT_SIZE (abfd) * MIPS_RESERVED_GOTNO);
+       entry != last_entry;
+       entry += MIPS_ELF_GOT_SIZE (abfd))
+    {
+      address = MIPS_ELF_GET_WORD (abfd, entry);
+      if (address == value)
+	{
+	  /* This entry has the right high-order 16 bits, and the low-order
+	     16 bits are set to zero.  */
+	  index = entry - sgot->contents;
+	  break;
+	}
+    }
+
+  /* If we didn't have an appropriate entry, we create one now.  */
+  if (entry == last_entry)
+    index = mips_elf_create_local_got_entry (abfd, g, sgot, value);
+
+  return index;
+}
+
+/* Returns the offset for the entry at the INDEXth position
+   in the GOT.  */
+
+static bfd_vma
+mips_elf_got_offset_from_index (dynobj, output_bfd, index)
+     bfd *dynobj;
+     bfd *output_bfd;
+     bfd_vma index;
+{
+  asection *sgot;
+  bfd_vma gp;
+
+  sgot = mips_elf_got_section (dynobj);
+  gp = _bfd_get_gp_value (output_bfd);
+  return (sgot->output_section->vma + sgot->output_offset + index -
+	  gp);
+}
+
+/* Create a local GOT entry for VALUE.  Return the index of the entry,
+   or -1 if it could not be created.  */
+
+static bfd_vma
+mips_elf_create_local_got_entry (abfd, g, sgot, value)
+     bfd *abfd;
+     struct mips_got_info *g;
+     asection *sgot;
+     bfd_vma value;
+{
+  if (g->assigned_gotno >= g->local_gotno)
+    {
+      /* We didn't allocate enough space in the GOT.  */
+      (*_bfd_error_handler)
+	(_("not enough GOT space for local GOT entries"));
+      bfd_set_error (bfd_error_bad_value);
+      return (bfd_vma) -1;
+    }
+
+  MIPS_ELF_PUT_WORD (abfd, value,
+		     (sgot->contents
+		      + MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno));
+  return MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
+}
+
+/* Sort the dynamic symbol table so that symbols that need GOT entries
+   appear towards the end.  This reduces the amount of GOT space
+   required.  MAX_LOCAL is used to set the number of local symbols
+   known to be in the dynamic symbol table.  During
+   _bfd_mips_elf_size_dynamic_sections, this value is 1.  Afterward, the
+   section symbols are added and the count is higher.  */
+
+static boolean
+mips_elf_sort_hash_table (info, max_local)
+     struct bfd_link_info *info;
+     unsigned long max_local;
+{
+  struct mips_elf_hash_sort_data hsd;
+  struct mips_got_info *g;
+  bfd *dynobj;
+
+  dynobj = elf_hash_table (info)->dynobj;
+
+  hsd.low = NULL;
+  hsd.min_got_dynindx = elf_hash_table (info)->dynsymcount;
+  hsd.max_non_got_dynindx = max_local;
+  mips_elf_link_hash_traverse (((struct mips_elf_link_hash_table *)
+				elf_hash_table (info)),
+			       mips_elf_sort_hash_table_f,
+			       &hsd);
+
+  /* There should have been enough room in the symbol table to
+     accomodate both the GOT and non-GOT symbols.  */
+  BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
+
+  /* Now we know which dynamic symbol has the lowest dynamic symbol
+     table index in the GOT.  */
+  g = mips_elf_got_info (dynobj, NULL);
+  g->global_gotsym = hsd.low;
+
+  return true;
+}
+
+/* If H needs a GOT entry, assign it the highest available dynamic
+   index.  Otherwise, assign it the lowest available dynamic
+   index.  */
+
+static boolean
+mips_elf_sort_hash_table_f (h, data)
+     struct mips_elf_link_hash_entry *h;
+     PTR data;
+{
+  struct mips_elf_hash_sort_data *hsd
+    = (struct mips_elf_hash_sort_data *) data;
+
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+
+  /* Symbols without dynamic symbol table entries aren't interesting
+     at all.  */
+  if (h->root.dynindx == -1)
+    return true;
+
+  if (h->root.got.offset != 1)
+    h->root.dynindx = hsd->max_non_got_dynindx++;
+  else
+    {
+      h->root.dynindx = --hsd->min_got_dynindx;
+      hsd->low = (struct elf_link_hash_entry *) h;
+    }
+
+  return true;
+}
+
+/* If H is a symbol that needs a global GOT entry, but has a dynamic
+   symbol table index lower than any we've seen to date, record it for
+   posterity.  */
+
+static boolean
+mips_elf_record_global_got_symbol (h, info, g)
+     struct elf_link_hash_entry *h;
+     struct bfd_link_info *info;
+     struct mips_got_info *g ATTRIBUTE_UNUSED;
+{
+  /* A global symbol in the GOT must also be in the dynamic symbol
+     table.  */
+  if (h->dynindx == -1)
+    {
+      switch (ELF_ST_VISIBILITY (h->other))
+	{
+	case STV_INTERNAL:
+	case STV_HIDDEN:
+	  _bfd_mips_elf_hide_symbol (info, h, true);
+	  break;
+	}
+      if (!bfd_elf32_link_record_dynamic_symbol (info, h))
+	return false;
+    }
+
+  /* If we've already marked this entry as needing GOT space, we don't
+     need to do it again.  */
+  if (h->got.offset != MINUS_ONE)
+    return true;
+
+  /* By setting this to a value other than -1, we are indicating that
+     there needs to be a GOT entry for H.  Avoid using zero, as the
+     generic ELF copy_indirect_symbol tests for <= 0.  */
+  h->got.offset = 1;
+
+  return true;
+}
+
+/* Returns the first relocation of type r_type found, beginning with
+   RELOCATION.  RELEND is one-past-the-end of the relocation table.  */
+
+static const Elf_Internal_Rela *
+mips_elf_next_relocation (abfd, r_type, relocation, relend)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     unsigned int r_type;
+     const Elf_Internal_Rela *relocation;
+     const Elf_Internal_Rela *relend;
+{
+  /* According to the MIPS ELF ABI, the R_MIPS_LO16 relocation must be
+     immediately following.  However, for the IRIX6 ABI, the next
+     relocation may be a composed relocation consisting of several
+     relocations for the same address.  In that case, the R_MIPS_LO16
+     relocation may occur as one of these.  We permit a similar
+     extension in general, as that is useful for GCC.  */
+  while (relocation < relend)
+    {
+      if (ELF_R_TYPE (abfd, relocation->r_info) == r_type)
+	return relocation;
+
+      ++relocation;
+    }
+
+  /* We didn't find it.  */
+  bfd_set_error (bfd_error_bad_value);
+  return NULL;
+}
+
+/* Return whether a relocation is against a local symbol.  */
+
+static boolean
+mips_elf_local_relocation_p (input_bfd, relocation, local_sections,
+			     check_forced)
+     bfd *input_bfd;
+     const Elf_Internal_Rela *relocation;
+     asection **local_sections;
+     boolean check_forced;
+{
+  unsigned long r_symndx;
+  Elf_Internal_Shdr *symtab_hdr;
+  struct mips_elf_link_hash_entry *h;
+  size_t extsymoff;
+
+  r_symndx = ELF_R_SYM (input_bfd, relocation->r_info);
+  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
+
+  if (r_symndx < extsymoff)
+    return true;
+  if (elf_bad_symtab (input_bfd) && local_sections[r_symndx] != NULL)
+    return true;
+
+  if (check_forced)
+    {
+      /* Look up the hash table to check whether the symbol
+ 	 was forced local.  */
+      h = (struct mips_elf_link_hash_entry *)
+	elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
+      /* Find the real hash-table entry for this symbol.  */
+      while (h->root.root.type == bfd_link_hash_indirect
+ 	     || h->root.root.type == bfd_link_hash_warning)
+	h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+      if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+	return true;
+    }
+
+  return false;
+}
+
+/* Sign-extend VALUE, which has the indicated number of BITS.  */
+
+static bfd_vma
+mips_elf_sign_extend (value, bits)
+     bfd_vma value;
+     int bits;
+{
+  if (value & ((bfd_vma) 1 << (bits - 1)))
+    /* VALUE is negative.  */
+    value |= ((bfd_vma) - 1) << bits;
+
+  return value;
+}
+
+/* Return non-zero if the indicated VALUE has overflowed the maximum
+   range expressable by a signed number with the indicated number of
+   BITS.  */
+
+static boolean
+mips_elf_overflow_p (value, bits)
+     bfd_vma value;
+     int bits;
+{
+  bfd_signed_vma svalue = (bfd_signed_vma) value;
+
+  if (svalue > (1 << (bits - 1)) - 1)
+    /* The value is too big.  */
+    return true;
+  else if (svalue < -(1 << (bits - 1)))
+    /* The value is too small.  */
+    return true;
+
+  /* All is well.  */
+  return false;
+}
+
+/* Calculate the %high function.  */
+
+static bfd_vma
+mips_elf_high (value)
+     bfd_vma value;
+{
+  return ((value + (bfd_vma) 0x8000) >> 16) & 0xffff;
+}
+
+/* Calculate the %higher function.  */
+
+static bfd_vma
+mips_elf_higher (value)
+     bfd_vma value ATTRIBUTE_UNUSED;
+{
+#ifdef BFD64
+  return ((value + (bfd_vma) 0x80008000) >> 32) & 0xffff;
+#else
+  abort ();
+  return (bfd_vma) -1;
+#endif
+}
+
+/* Calculate the %highest function.  */
+
+static bfd_vma
+mips_elf_highest (value)
+     bfd_vma value ATTRIBUTE_UNUSED;
+{
+#ifdef BFD64
+  return ((value + (bfd_vma) 0x800080008000) >> 48) & 0xffff;
+#else
+  abort ();
+  return (bfd_vma) -1;
+#endif
+}
+
+/* Create the .compact_rel section.  */
+
+static boolean
+mips_elf_create_compact_rel_section (abfd, info)
+     bfd *abfd;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+{
+  flagword flags;
+  register asection *s;
+
+  if (bfd_get_section_by_name (abfd, ".compact_rel") == NULL)
+    {
+      flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED
+	       | SEC_READONLY);
+
+      s = bfd_make_section (abfd, ".compact_rel");
+      if (s == NULL
+	  || ! bfd_set_section_flags (abfd, s, flags)
+	  || ! bfd_set_section_alignment (abfd, s,
+					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
+	return false;
+
+      s->_raw_size = sizeof (Elf32_External_compact_rel);
+    }
+
+  return true;
+}
+
+/* Create the .got section to hold the global offset table.  */
+
+static boolean
+mips_elf_create_got_section (abfd, info)
+     bfd *abfd;
+     struct bfd_link_info *info;
+{
+  flagword flags;
+  register asection *s;
+  struct elf_link_hash_entry *h;
+  struct mips_got_info *g;
+  bfd_size_type amt;
+
+  /* This function may be called more than once.  */
+  if (mips_elf_got_section (abfd))
+    return true;
+
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+	   | SEC_LINKER_CREATED);
+
+  s = bfd_make_section (abfd, ".got");
+  if (s == NULL
+      || ! bfd_set_section_flags (abfd, s, flags)
+      || ! bfd_set_section_alignment (abfd, s, 4))
+    return false;
+
+  /* Define the symbol _GLOBAL_OFFSET_TABLE_.  We don't do this in the
+     linker script because we don't want to define the symbol if we
+     are not creating a global offset table.  */
+  h = NULL;
+  if (! (_bfd_generic_link_add_one_symbol
+	 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
+	  (bfd_vma) 0, (const char *) NULL, false,
+	  get_elf_backend_data (abfd)->collect,
+	  (struct bfd_link_hash_entry **) &h)))
+    return false;
+  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
+  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+  h->type = STT_OBJECT;
+
+  if (info->shared
+      && ! bfd_elf32_link_record_dynamic_symbol (info, h))
+    return false;
+
+  /* The first several global offset table entries are reserved.  */
+  s->_raw_size = MIPS_RESERVED_GOTNO * MIPS_ELF_GOT_SIZE (abfd);
+
+  amt = sizeof (struct mips_got_info);
+  g = (struct mips_got_info *) bfd_alloc (abfd, amt);
+  if (g == NULL)
+    return false;
+  g->global_gotsym = NULL;
+  g->local_gotno = MIPS_RESERVED_GOTNO;
+  g->assigned_gotno = MIPS_RESERVED_GOTNO;
+  if (elf_section_data (s) == NULL)
+    {
+      amt = sizeof (struct bfd_elf_section_data);
+      s->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
+      if (elf_section_data (s) == NULL)
+	return false;
+    }
+  elf_section_data (s)->tdata = (PTR) g;
+  elf_section_data (s)->this_hdr.sh_flags
+    |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+
+  return true;
+}
+
+/* Returns the .msym section for ABFD, creating it if it does not
+   already exist.  Returns NULL to indicate error.  */
+
+static asection *
+mips_elf_create_msym_section (abfd)
+     bfd *abfd;
+{
+  asection *s;
+
+  s = bfd_get_section_by_name (abfd, ".msym");
+  if (!s)
+    {
+      s = bfd_make_section (abfd, ".msym");
+      if (!s
+	  || !bfd_set_section_flags (abfd, s,
+				     SEC_ALLOC
+				     | SEC_LOAD
+				     | SEC_HAS_CONTENTS
+				     | SEC_LINKER_CREATED
+				     | SEC_READONLY)
+	  || !bfd_set_section_alignment (abfd, s,
+					 MIPS_ELF_LOG_FILE_ALIGN (abfd)))
+	return NULL;
+    }
+
+  return s;
+}
+
+/* Calculate the value produced by the RELOCATION (which comes from
+   the INPUT_BFD).  The ADDEND is the addend to use for this
+   RELOCATION; RELOCATION->R_ADDEND is ignored.
+
+   The result of the relocation calculation is stored in VALUEP.
+   REQUIRE_JALXP indicates whether or not the opcode used with this
+   relocation must be JALX.
+
+   This function returns bfd_reloc_continue if the caller need take no
+   further action regarding this relocation, bfd_reloc_notsupported if
+   something goes dramatically wrong, bfd_reloc_overflow if an
+   overflow occurs, and bfd_reloc_ok to indicate success.  */
+
+static bfd_reloc_status_type
+mips_elf_calculate_relocation (abfd, input_bfd, input_section, info,
+			       relocation, addend, howto, local_syms,
+			       local_sections, valuep, namep,
+			       require_jalxp)
+     bfd *abfd;
+     bfd *input_bfd;
+     asection *input_section;
+     struct bfd_link_info *info;
+     const Elf_Internal_Rela *relocation;
+     bfd_vma addend;
+     reloc_howto_type *howto;
+     Elf_Internal_Sym *local_syms;
+     asection **local_sections;
+     bfd_vma *valuep;
+     const char **namep;
+     boolean *require_jalxp;
+{
+  /* The eventual value we will return.  */
+  bfd_vma value;
+  /* The address of the symbol against which the relocation is
+     occurring.  */
+  bfd_vma symbol = 0;
+  /* The final GP value to be used for the relocatable, executable, or
+     shared object file being produced.  */
+  bfd_vma gp = MINUS_ONE;
+  /* The place (section offset or address) of the storage unit being
+     relocated.  */
+  bfd_vma p;
+  /* The value of GP used to create the relocatable object.  */
+  bfd_vma gp0 = MINUS_ONE;
+  /* The offset into the global offset table at which the address of
+     the relocation entry symbol, adjusted by the addend, resides
+     during execution.  */
+  bfd_vma g = MINUS_ONE;
+  /* The section in which the symbol referenced by the relocation is
+     located.  */
+  asection *sec = NULL;
+  struct mips_elf_link_hash_entry *h = NULL;
+  /* True if the symbol referred to by this relocation is a local
+     symbol.  */
+  boolean local_p;
+  /* True if the symbol referred to by this relocation is "_gp_disp".  */
+  boolean gp_disp_p = false;
+  Elf_Internal_Shdr *symtab_hdr;
+  size_t extsymoff;
+  unsigned long r_symndx;
+  int r_type;
+  /* True if overflow occurred during the calculation of the
+     relocation value.  */
+  boolean overflowed_p;
+  /* True if this relocation refers to a MIPS16 function.  */
+  boolean target_is_16_bit_code_p = false;
+
+  /* Parse the relocation.  */
+  r_symndx = ELF_R_SYM (input_bfd, relocation->r_info);
+  r_type = ELF_R_TYPE (input_bfd, relocation->r_info);
+  p = (input_section->output_section->vma
+       + input_section->output_offset
+       + relocation->r_offset);
+
+  /* Assume that there will be no overflow.  */
+  overflowed_p = false;
+
+  /* Figure out whether or not the symbol is local, and get the offset
+     used in the array of hash table entries.  */
+  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  local_p = mips_elf_local_relocation_p (input_bfd, relocation,
+					 local_sections, false);
+  if (! elf_bad_symtab (input_bfd))
+    extsymoff = symtab_hdr->sh_info;
+  else
+    {
+      /* The symbol table does not follow the rule that local symbols
+	 must come before globals.  */
+      extsymoff = 0;
+    }
+
+  /* Figure out the value of the symbol.  */
+  if (local_p)
+    {
+      Elf_Internal_Sym *sym;
+
+      sym = local_syms + r_symndx;
+      sec = local_sections[r_symndx];
+
+      symbol = sec->output_section->vma + sec->output_offset;
+      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+	symbol += sym->st_value;
+
+      /* MIPS16 text labels should be treated as odd.  */
+      if (sym->st_other == STO_MIPS16)
+	++symbol;
+
+      /* Record the name of this symbol, for our caller.  */
+      *namep = bfd_elf_string_from_elf_section (input_bfd,
+						symtab_hdr->sh_link,
+						sym->st_name);
+      if (*namep == '\0')
+	*namep = bfd_section_name (input_bfd, sec);
+
+      target_is_16_bit_code_p = (sym->st_other == STO_MIPS16);
+    }
+  else
+    {
+      /* For global symbols we look up the symbol in the hash-table.  */
+      h = ((struct mips_elf_link_hash_entry *)
+	   elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
+      /* Find the real hash-table entry for this symbol.  */
+      while (h->root.root.type == bfd_link_hash_indirect
+	     || h->root.root.type == bfd_link_hash_warning)
+	h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+
+      /* Record the name of this symbol, for our caller.  */
+      *namep = h->root.root.root.string;
+
+      /* See if this is the special _gp_disp symbol.  Note that such a
+	 symbol must always be a global symbol.  */
+      if (strcmp (h->root.root.root.string, "_gp_disp") == 0
+	  && ! NEWABI_P (input_bfd))
+	{
+	  /* Relocations against _gp_disp are permitted only with
+	     R_MIPS_HI16 and R_MIPS_LO16 relocations.  */
+	  if (r_type != R_MIPS_HI16 && r_type != R_MIPS_LO16)
+	    return bfd_reloc_notsupported;
+
+	  gp_disp_p = true;
+	}
+      /* If this symbol is defined, calculate its address.  Note that
+	 _gp_disp is a magic symbol, always implicitly defined by the
+	 linker, so it's inappropriate to check to see whether or not
+	 its defined.  */
+      else if ((h->root.root.type == bfd_link_hash_defined
+		|| h->root.root.type == bfd_link_hash_defweak)
+	       && h->root.root.u.def.section)
+	{
+	  sec = h->root.root.u.def.section;
+	  if (sec->output_section)
+	    symbol = (h->root.root.u.def.value
+		      + sec->output_section->vma
+		      + sec->output_offset);
+	  else
+	    symbol = h->root.root.u.def.value;
+	}
+      else if (h->root.root.type == bfd_link_hash_undefweak)
+	/* We allow relocations against undefined weak symbols, giving
+	   it the value zero, so that you can undefined weak functions
+	   and check to see if they exist by looking at their
+	   addresses.  */
+	symbol = 0;
+      else if (info->shared
+	       && (!info->symbolic || info->allow_shlib_undefined)
+	       && !info->no_undefined
+	       && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
+	symbol = 0;
+      else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0 ||
+              strcmp (h->root.root.root.string, "_DYNAMIC_LINKING") == 0)
+	{
+	  /* If this is a dynamic link, we should have created a
+	     _DYNAMIC_LINK symbol or _DYNAMIC_LINKING(for normal mips) symbol
+	     in in _bfd_mips_elf_create_dynamic_sections.
+	     Otherwise, we should define the symbol with a value of 0.
+	     FIXME: It should probably get into the symbol table
+	     somehow as well.  */
+	  BFD_ASSERT (! info->shared);
+	  BFD_ASSERT (bfd_get_section_by_name (abfd, ".dynamic") == NULL);
+	  symbol = 0;
+	}
+      else
+	{
+	  if (! ((*info->callbacks->undefined_symbol)
+		 (info, h->root.root.root.string, input_bfd,
+		  input_section, relocation->r_offset,
+		  (!info->shared || info->no_undefined
+		   || ELF_ST_VISIBILITY (h->root.other)))))
+	    return bfd_reloc_undefined;
+	  symbol = 0;
+	}
+
+      target_is_16_bit_code_p = (h->root.other == STO_MIPS16);
+    }
+
+  /* If this is a 32- or 64-bit call to a 16-bit function with a stub, we
+     need to redirect the call to the stub, unless we're already *in*
+     a stub.  */
+  if (r_type != R_MIPS16_26 && !info->relocateable
+      && ((h != NULL && h->fn_stub != NULL)
+	  || (local_p && elf_tdata (input_bfd)->local_stubs != NULL
+	      && elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL))
+      && !mips_elf_stub_section_p (input_bfd, input_section))
+    {
+      /* This is a 32- or 64-bit call to a 16-bit function.  We should
+	 have already noticed that we were going to need the
+	 stub.  */
+      if (local_p)
+	sec = elf_tdata (input_bfd)->local_stubs[r_symndx];
+      else
+	{
+	  BFD_ASSERT (h->need_fn_stub);
+	  sec = h->fn_stub;
+	}
+
+      symbol = sec->output_section->vma + sec->output_offset;
+    }
+  /* If this is a 16-bit call to a 32- or 64-bit function with a stub, we
+     need to redirect the call to the stub.  */
+  else if (r_type == R_MIPS16_26 && !info->relocateable
+	   && h != NULL
+	   && (h->call_stub != NULL || h->call_fp_stub != NULL)
+	   && !target_is_16_bit_code_p)
+    {
+      /* If both call_stub and call_fp_stub are defined, we can figure
+	 out which one to use by seeing which one appears in the input
+	 file.  */
+      if (h->call_stub != NULL && h->call_fp_stub != NULL)
+	{
+	  asection *o;
+
+	  sec = NULL;
+	  for (o = input_bfd->sections; o != NULL; o = o->next)
+	    {
+	      if (strncmp (bfd_get_section_name (input_bfd, o),
+			   CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
+		{
+		  sec = h->call_fp_stub;
+		  break;
+		}
+	    }
+	  if (sec == NULL)
+	    sec = h->call_stub;
+	}
+      else if (h->call_stub != NULL)
+	sec = h->call_stub;
+      else
+	sec = h->call_fp_stub;
+
+      BFD_ASSERT (sec->_raw_size > 0);
+      symbol = sec->output_section->vma + sec->output_offset;
+    }
+
+  /* Calls from 16-bit code to 32-bit code and vice versa require the
+     special jalx instruction.  */
+  *require_jalxp = (!info->relocateable
+                    && (((r_type == R_MIPS16_26) && !target_is_16_bit_code_p)
+                        || ((r_type == R_MIPS_26) && target_is_16_bit_code_p)));
+
+  local_p = mips_elf_local_relocation_p (input_bfd, relocation,
+					 local_sections, true);
+
+  /* If we haven't already determined the GOT offset, or the GP value,
+     and we're going to need it, get it now.  */
+  switch (r_type)
+    {
+    case R_MIPS_CALL16:
+    case R_MIPS_GOT16:
+    case R_MIPS_GOT_DISP:
+    case R_MIPS_GOT_HI16:
+    case R_MIPS_CALL_HI16:
+    case R_MIPS_GOT_LO16:
+    case R_MIPS_CALL_LO16:
+      /* Find the index into the GOT where this value is located.  */
+      if (!local_p)
+	{
+	  BFD_ASSERT (addend == 0);
+	  g = mips_elf_global_got_index (elf_hash_table (info)->dynobj,
+					 (struct elf_link_hash_entry *) h);
+	  if (! elf_hash_table(info)->dynamic_sections_created
+	      || (info->shared
+		  && (info->symbolic || h->root.dynindx == -1)
+		  && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+	    {
+	      /* This is a static link or a -Bsymbolic link.  The
+		 symbol is defined locally, or was forced to be local.
+		 We must initialize this entry in the GOT.  */
+	      bfd *tmpbfd = elf_hash_table (info)->dynobj;
+	      asection *sgot = mips_elf_got_section(tmpbfd);
+	      MIPS_ELF_PUT_WORD (tmpbfd, symbol + addend, sgot->contents + g);
+	    }
+	}
+      else if (r_type == R_MIPS_GOT16 || r_type == R_MIPS_CALL16)
+	/* There's no need to create a local GOT entry here; the
+	   calculation for a local GOT16 entry does not involve G.  */
+	break;
+      else
+	{
+	  g = mips_elf_local_got_index (abfd, info, symbol + addend);
+	  if (g == MINUS_ONE)
+	    return bfd_reloc_outofrange;
+	}
+
+      /* Convert GOT indices to actual offsets.  */
+      g = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
+					  abfd, g);
+      break;
+
+    case R_MIPS_HI16:
+    case R_MIPS_LO16:
+    case R_MIPS16_GPREL:
+    case R_MIPS_GPREL16:
+    case R_MIPS_GPREL32:
+    case R_MIPS_LITERAL:
+      gp0 = _bfd_get_gp_value (input_bfd);
+      gp = _bfd_get_gp_value (abfd);
+      break;
+
+    default:
+      break;
+    }
+
+  /* Figure out what kind of relocation is being performed.  */
+  switch (r_type)
+    {
+    case R_MIPS_NONE:
+      return bfd_reloc_continue;
+
+    case R_MIPS_16:
+      value = symbol + mips_elf_sign_extend (addend, 16);
+      overflowed_p = mips_elf_overflow_p (value, 16);
+      break;
+
+    case R_MIPS_32:
+    case R_MIPS_REL32:
+    case R_MIPS_64:
+      if ((info->shared
+	   || (elf_hash_table (info)->dynamic_sections_created
+	       && h != NULL
+	       && ((h->root.elf_link_hash_flags
+		    & ELF_LINK_HASH_DEF_DYNAMIC) != 0)
+	       && ((h->root.elf_link_hash_flags
+		    & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+	  && r_symndx != 0
+	  && (input_section->flags & SEC_ALLOC) != 0)
+	{
+	  /* If we're creating a shared library, or this relocation is
+	     against a symbol in a shared library, then we can't know
+	     where the symbol will end up.  So, we create a relocation
+	     record in the output, and leave the job up to the dynamic
+	     linker.  */
+	  value = addend;
+	  if (!mips_elf_create_dynamic_relocation (abfd,
+						   info,
+						   relocation,
+						   h,
+						   sec,
+						   symbol,
+						   &value,
+						   input_section))
+	    return bfd_reloc_undefined;
+	}
+      else
+	{
+	  if (r_type != R_MIPS_REL32)
+	    value = symbol + addend;
+	  else
+	    value = addend;
+	}
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_PC32:
+    case R_MIPS_PC64:
+    case R_MIPS_GNU_REL_LO16:
+      value = symbol + addend - p;
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_GNU_REL16_S2:
+      value = symbol + mips_elf_sign_extend (addend << 2, 18) - p;
+      overflowed_p = mips_elf_overflow_p (value, 18);
+      value = (value >> 2) & howto->dst_mask;
+      break;
+
+    case R_MIPS_GNU_REL_HI16:
+      /* Instead of subtracting 'p' here, we should be subtracting the
+	 equivalent value for the LO part of the reloc, since the value
+	 here is relative to that address.  Because that's not easy to do,
+	 we adjust 'addend' in _bfd_mips_elf_relocate_section().  See also
+	 the comment there for more information.  */
+      value = mips_elf_high (addend + symbol - p);
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS16_26:
+      /* The calculation for R_MIPS16_26 is just the same as for an
+	 R_MIPS_26.  It's only the storage of the relocated field into
+	 the output file that's different.  That's handled in
+	 mips_elf_perform_relocation.  So, we just fall through to the
+	 R_MIPS_26 case here.  */
+    case R_MIPS_26:
+      if (local_p)
+	value = (((addend << 2) | ((p + 4) & 0xf0000000)) + symbol) >> 2;
+      else
+	value = (mips_elf_sign_extend (addend << 2, 28) + symbol) >> 2;
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_HI16:
+      if (!gp_disp_p)
+	{
+	  value = mips_elf_high (addend + symbol);
+	  value &= howto->dst_mask;
+	}
+      else
+	{
+	  value = mips_elf_high (addend + gp - p);
+	  overflowed_p = mips_elf_overflow_p (value, 16);
+	}
+      break;
+
+    case R_MIPS_LO16:
+      if (!gp_disp_p)
+	value = (symbol + addend) & howto->dst_mask;
+      else
+	{
+	  value = addend + gp - p + 4;
+	  /* The MIPS ABI requires checking the R_MIPS_LO16 relocation
+	     for overflow.  But, on, say, Irix 5, relocations against
+	     _gp_disp are normally generated from the .cpload
+	     pseudo-op.  It generates code that normally looks like
+	     this:
+
+	       lui    $gp,%hi(_gp_disp)
+	       addiu  $gp,$gp,%lo(_gp_disp)
+	       addu   $gp,$gp,$t9
+
+	     Here $t9 holds the address of the function being called,
+	     as required by the MIPS ELF ABI.  The R_MIPS_LO16
+	     relocation can easily overflow in this situation, but the
+	     R_MIPS_HI16 relocation will handle the overflow.
+	     Therefore, we consider this a bug in the MIPS ABI, and do
+	     not check for overflow here.  */
+	}
+      break;
+
+    case R_MIPS_LITERAL:
+      /* Because we don't merge literal sections, we can handle this
+	 just like R_MIPS_GPREL16.  In the long run, we should merge
+	 shared literals, and then we will need to additional work
+	 here.  */
+
+      /* Fall through.  */
+
+    case R_MIPS16_GPREL:
+      /* The R_MIPS16_GPREL performs the same calculation as
+	 R_MIPS_GPREL16, but stores the relocated bits in a different
+	 order.  We don't need to do anything special here; the
+	 differences are handled in mips_elf_perform_relocation.  */
+    case R_MIPS_GPREL16:
+      if (local_p)
+	value = mips_elf_sign_extend (addend, 16) + symbol + gp0 - gp;
+      else
+	value = mips_elf_sign_extend (addend, 16) + symbol - gp;
+      overflowed_p = mips_elf_overflow_p (value, 16);
+      break;
+
+    case R_MIPS_GOT16:
+    case R_MIPS_CALL16:
+      if (local_p)
+	{
+	  boolean forced;
+
+	  /* The special case is when the symbol is forced to be local.  We
+	     need the full address in the GOT since no R_MIPS_LO16 relocation
+	     follows.  */
+	  forced = ! mips_elf_local_relocation_p (input_bfd, relocation,
+						  local_sections, false);
+	  value = mips_elf_got16_entry (abfd, info, symbol + addend, forced);
+	  if (value == MINUS_ONE)
+	    return bfd_reloc_outofrange;
+	  value
+	    = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
+					      abfd,
+					      value);
+	  overflowed_p = mips_elf_overflow_p (value, 16);
+	  break;
+	}
+
+      /* Fall through.  */
+
+    case R_MIPS_GOT_DISP:
+      value = g;
+      overflowed_p = mips_elf_overflow_p (value, 16);
+      break;
+
+    case R_MIPS_GPREL32:
+      value = (addend + symbol + gp0 - gp) & howto->dst_mask;
+      break;
+
+    case R_MIPS_PC16:
+      value = mips_elf_sign_extend (addend, 16) + symbol - p;
+      overflowed_p = mips_elf_overflow_p (value, 16);
+      value = (bfd_vma) ((bfd_signed_vma) value / 4);
+      break;
+
+    case R_MIPS_GOT_HI16:
+    case R_MIPS_CALL_HI16:
+      /* We're allowed to handle these two relocations identically.
+	 The dynamic linker is allowed to handle the CALL relocations
+	 differently by creating a lazy evaluation stub.  */
+      value = g;
+      value = mips_elf_high (value);
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_GOT_LO16:
+    case R_MIPS_CALL_LO16:
+      value = g & howto->dst_mask;
+      break;
+
+    case R_MIPS_GOT_PAGE:
+      value = mips_elf_got_page (abfd, info, symbol + addend, NULL);
+      if (value == MINUS_ONE)
+	return bfd_reloc_outofrange;
+      value = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
+					      abfd,
+					      value);
+      overflowed_p = mips_elf_overflow_p (value, 16);
+      break;
+
+    case R_MIPS_GOT_OFST:
+      mips_elf_got_page (abfd, info, symbol + addend, &value);
+      overflowed_p = mips_elf_overflow_p (value, 16);
+      break;
+
+    case R_MIPS_SUB:
+      value = symbol - addend;
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_HIGHER:
+      value = mips_elf_higher (addend + symbol);
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_HIGHEST:
+      value = mips_elf_highest (addend + symbol);
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_SCN_DISP:
+      value = symbol + addend - sec->output_offset;
+      value &= howto->dst_mask;
+      break;
+
+    case R_MIPS_PJUMP:
+    case R_MIPS_JALR:
+      /* Both of these may be ignored.  R_MIPS_JALR is an optimization
+	 hint; we could improve performance by honoring that hint.  */
+      return bfd_reloc_continue;
+
+    case R_MIPS_GNU_VTINHERIT:
+    case R_MIPS_GNU_VTENTRY:
+      /* We don't do anything with these at present.  */
+      return bfd_reloc_continue;
+
+    default:
+      /* An unrecognized relocation type.  */
+      return bfd_reloc_notsupported;
+    }
+
+  /* Store the VALUE for our caller.  */
+  *valuep = value;
+  return overflowed_p ? bfd_reloc_overflow : bfd_reloc_ok;
+}
+
+/* Obtain the field relocated by RELOCATION.  */
+
+static bfd_vma
+mips_elf_obtain_contents (howto, relocation, input_bfd, contents)
+     reloc_howto_type *howto;
+     const Elf_Internal_Rela *relocation;
+     bfd *input_bfd;
+     bfd_byte *contents;
+{
+  bfd_vma x;
+  bfd_byte *location = contents + relocation->r_offset;
+
+  /* Obtain the bytes.  */
+  x = bfd_get ((8 * bfd_get_reloc_size (howto)), input_bfd, location);
+
+  if ((ELF_R_TYPE (input_bfd, relocation->r_info) == R_MIPS16_26
+       || ELF_R_TYPE (input_bfd, relocation->r_info) == R_MIPS16_GPREL)
+      && bfd_little_endian (input_bfd))
+    /* The two 16-bit words will be reversed on a little-endian system.
+       See mips_elf_perform_relocation for more details.  */
+    x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
+
+  return x;
+}
+
+/* It has been determined that the result of the RELOCATION is the
+   VALUE.  Use HOWTO to place VALUE into the output file at the
+   appropriate position.  The SECTION is the section to which the
+   relocation applies.  If REQUIRE_JALX is true, then the opcode used
+   for the relocation must be either JAL or JALX, and it is
+   unconditionally converted to JALX.
+
+   Returns false if anything goes wrong.  */
+
+static boolean
+mips_elf_perform_relocation (info, howto, relocation, value, input_bfd,
+			     input_section, contents, require_jalx)
+     struct bfd_link_info *info;
+     reloc_howto_type *howto;
+     const Elf_Internal_Rela *relocation;
+     bfd_vma value;
+     bfd *input_bfd;
+     asection *input_section;
+     bfd_byte *contents;
+     boolean require_jalx;
+{
+  bfd_vma x;
+  bfd_byte *location;
+  int r_type = ELF_R_TYPE (input_bfd, relocation->r_info);
+
+  /* Figure out where the relocation is occurring.  */
+  location = contents + relocation->r_offset;
+
+  /* Obtain the current value.  */
+  x = mips_elf_obtain_contents (howto, relocation, input_bfd, contents);
+
+  /* Clear the field we are setting.  */
+  x &= ~howto->dst_mask;
+
+  /* If this is the R_MIPS16_26 relocation, we must store the
+     value in a funny way.  */
+  if (r_type == R_MIPS16_26)
+    {
+      /* R_MIPS16_26 is used for the mips16 jal and jalx instructions.
+	 Most mips16 instructions are 16 bits, but these instructions
+	 are 32 bits.
+
+	 The format of these instructions is:
+
+	 +--------------+--------------------------------+
+	 !     JALX     ! X!   Imm 20:16  !   Imm 25:21  !
+	 +--------------+--------------------------------+
+	 !	  	  Immediate  15:0		    !
+	 +-----------------------------------------------+
+
+	 JALX is the 5-bit value 00011.  X is 0 for jal, 1 for jalx.
+	 Note that the immediate value in the first word is swapped.
+
+	 When producing a relocateable object file, R_MIPS16_26 is
+	 handled mostly like R_MIPS_26.  In particular, the addend is
+	 stored as a straight 26-bit value in a 32-bit instruction.
+	 (gas makes life simpler for itself by never adjusting a
+	 R_MIPS16_26 reloc to be against a section, so the addend is
+	 always zero).  However, the 32 bit instruction is stored as 2
+	 16-bit values, rather than a single 32-bit value.  In a
+	 big-endian file, the result is the same; in a little-endian
+	 file, the two 16-bit halves of the 32 bit value are swapped.
+	 This is so that a disassembler can recognize the jal
+	 instruction.
+
+	 When doing a final link, R_MIPS16_26 is treated as a 32 bit
+	 instruction stored as two 16-bit values.  The addend A is the
+	 contents of the targ26 field.  The calculation is the same as
+	 R_MIPS_26.  When storing the calculated value, reorder the
+	 immediate value as shown above, and don't forget to store the
+	 value as two 16-bit values.
+
+	 To put it in MIPS ABI terms, the relocation field is T-targ26-16,
+	 defined as
+
+	 big-endian:
+	 +--------+----------------------+
+	 |        |                      |
+	 |        |    targ26-16         |
+	 |31    26|25                   0|
+	 +--------+----------------------+
+
+	 little-endian:
+	 +----------+------+-------------+
+	 |          |      |             |
+	 |  sub1    |      |     sub2    |
+	 |0        9|10  15|16         31|
+	 +----------+--------------------+
+	 where targ26-16 is sub1 followed by sub2 (i.e., the addend field A is
+	 ((sub1 << 16) | sub2)).
+
+	 When producing a relocateable object file, the calculation is
+	 (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2)
+	 When producing a fully linked file, the calculation is
+	 let R = (((A < 2) | ((P + 4) & 0xf0000000) + S) >> 2)
+	 ((R & 0x1f0000) << 5) | ((R & 0x3e00000) >> 5) | (R & 0xffff)  */
+
+      if (!info->relocateable)
+	/* Shuffle the bits according to the formula above.  */
+	value = (((value & 0x1f0000) << 5)
+		 | ((value & 0x3e00000) >> 5)
+		 | (value & 0xffff));
+    }
+  else if (r_type == R_MIPS16_GPREL)
+    {
+      /* R_MIPS16_GPREL is used for GP-relative addressing in mips16
+	 mode.  A typical instruction will have a format like this:
+
+	 +--------------+--------------------------------+
+	 !    EXTEND    !     Imm 10:5    !   Imm 15:11  !
+	 +--------------+--------------------------------+
+	 !    Major     !   rx   !   ry   !   Imm  4:0   !
+	 +--------------+--------------------------------+
+
+	 EXTEND is the five bit value 11110.  Major is the instruction
+	 opcode.
+
+	 This is handled exactly like R_MIPS_GPREL16, except that the
+	 addend is retrieved and stored as shown in this diagram; that
+	 is, the Imm fields above replace the V-rel16 field.
+
+         All we need to do here is shuffle the bits appropriately.  As
+	 above, the two 16-bit halves must be swapped on a
+	 little-endian system.  */
+      value = (((value & 0x7e0) << 16)
+	       | ((value & 0xf800) << 5)
+	       | (value & 0x1f));
+    }
+
+  /* Set the field.  */
+  x |= (value & howto->dst_mask);
+
+  /* If required, turn JAL into JALX.  */
+  if (require_jalx)
+    {
+      boolean ok;
+      bfd_vma opcode = x >> 26;
+      bfd_vma jalx_opcode;
+
+      /* Check to see if the opcode is already JAL or JALX.  */
+      if (r_type == R_MIPS16_26)
+	{
+	  ok = ((opcode == 0x6) || (opcode == 0x7));
+	  jalx_opcode = 0x7;
+	}
+      else
+	{
+	  ok = ((opcode == 0x3) || (opcode == 0x1d));
+	  jalx_opcode = 0x1d;
+	}
+
+      /* If the opcode is not JAL or JALX, there's a problem.  */
+      if (!ok)
+	{
+	  (*_bfd_error_handler)
+	    (_("%s: %s+0x%lx: jump to stub routine which is not jal"),
+	     bfd_archive_filename (input_bfd),
+	     input_section->name,
+	     (unsigned long) relocation->r_offset);
+	  bfd_set_error (bfd_error_bad_value);
+	  return false;
+	}
+
+      /* Make this the JALX opcode.  */
+      x = (x & ~(0x3f << 26)) | (jalx_opcode << 26);
+    }
+
+  /* Swap the high- and low-order 16 bits on little-endian systems
+     when doing a MIPS16 relocation.  */
+  if ((r_type == R_MIPS16_GPREL || r_type == R_MIPS16_26)
+      && bfd_little_endian (input_bfd))
+    x = (((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16));
+
+  /* Put the value into the output.  */
+  bfd_put (8 * bfd_get_reloc_size (howto), input_bfd, x, location);
+  return true;
+}
+
+/* Returns true if SECTION is a MIPS16 stub section.  */
+
+static boolean
+mips_elf_stub_section_p (abfd, section)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     asection *section;
+{
+  const char *name = bfd_get_section_name (abfd, section);
+
+  return (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0
+	  || strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
+	  || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0);
+}
+
+/* Add room for N relocations to the .rel.dyn section in ABFD.  */
+
+static void
+mips_elf_allocate_dynamic_relocations (abfd, n)
+     bfd *abfd;
+     unsigned int n;
+{
+  asection *s;
+
+  s = bfd_get_section_by_name (abfd, ".rel.dyn");
+  BFD_ASSERT (s != NULL);
+
+  if (s->_raw_size == 0)
+    {
+      /* Make room for a null element.  */
+      s->_raw_size += MIPS_ELF_REL_SIZE (abfd);
+      ++s->reloc_count;
+    }
+  s->_raw_size += n * MIPS_ELF_REL_SIZE (abfd);
+}
+
+/* Create a rel.dyn relocation for the dynamic linker to resolve.  REL
+   is the original relocation, which is now being transformed into a
+   dynamic relocation.  The ADDENDP is adjusted if necessary; the
+   caller should store the result in place of the original addend.  */
+
+static boolean
+mips_elf_create_dynamic_relocation (output_bfd, info, rel, h, sec,
+				    symbol, addendp, input_section)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+     const Elf_Internal_Rela *rel;
+     struct mips_elf_link_hash_entry *h;
+     asection *sec;
+     bfd_vma symbol;
+     bfd_vma *addendp;
+     asection *input_section;
+{
+  Elf_Internal_Rel outrel[3];
+  boolean skip;
+  asection *sreloc;
+  bfd *dynobj;
+  int r_type;
+
+  r_type = ELF_R_TYPE (output_bfd, rel->r_info);
+  dynobj = elf_hash_table (info)->dynobj;
+  sreloc
+    = bfd_get_section_by_name (dynobj, ".rel.dyn");
+  BFD_ASSERT (sreloc != NULL);
+  BFD_ASSERT (sreloc->contents != NULL);
+  BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd)
+	      < sreloc->_raw_size);
+
+  skip = false;
+  outrel[0].r_offset =
+    _bfd_elf_section_offset (output_bfd, info, input_section, rel[0].r_offset);
+  outrel[1].r_offset =
+    _bfd_elf_section_offset (output_bfd, info, input_section, rel[1].r_offset);
+  outrel[2].r_offset =
+    _bfd_elf_section_offset (output_bfd, info, input_section, rel[2].r_offset);
+
+#if 0
+  /* We begin by assuming that the offset for the dynamic relocation
+     is the same as for the original relocation.  We'll adjust this
+     later to reflect the correct output offsets.  */
+  if (elf_section_data (input_section)->sec_info_type != ELF_INFO_TYPE_STABS)
+    {
+      outrel[1].r_offset = rel[1].r_offset;
+      outrel[2].r_offset = rel[2].r_offset;
+    }
+  else
+    {
+      /* Except that in a stab section things are more complex.
+	 Because we compress stab information, the offset given in the
+	 relocation may not be the one we want; we must let the stabs
+	 machinery tell us the offset.  */
+      outrel[1].r_offset = outrel[0].r_offset;
+      outrel[2].r_offset = outrel[0].r_offset;
+      /* If we didn't need the relocation at all, this value will be
+	 -1.  */
+      if (outrel[0].r_offset == (bfd_vma) -1)
+	skip = true;
+    }
+#endif
+
+  if (outrel[0].r_offset == (bfd_vma) -1)
+    skip = true;
+  /* FIXME: For -2 runtime relocation needs to be skipped, but
+     properly resolved statically and installed.  */
+  BFD_ASSERT (outrel[0].r_offset != (bfd_vma) -2);
+
+  /* If we've decided to skip this relocation, just output an empty
+     record.  Note that R_MIPS_NONE == 0, so that this call to memset
+     is a way of setting R_TYPE to R_MIPS_NONE.  */
+  if (skip)
+    memset (outrel, 0, sizeof (Elf_Internal_Rel) * 3);
+  else
+    {
+      long indx;
+      bfd_vma section_offset;
+
+      /* We must now calculate the dynamic symbol table index to use
+	 in the relocation.  */
+      if (h != NULL
+	  && (! info->symbolic || (h->root.elf_link_hash_flags
+				   & ELF_LINK_HASH_DEF_REGULAR) == 0))
+	{
+	  indx = h->root.dynindx;
+	  /* h->root.dynindx may be -1 if this symbol was marked to
+	     become local.  */
+	  if (indx == -1)
+	    indx = 0;
+	}
+      else
+	{
+	  if (sec != NULL && bfd_is_abs_section (sec))
+	    indx = 0;
+	  else if (sec == NULL || sec->owner == NULL)
+	    {
+	      bfd_set_error (bfd_error_bad_value);
+	      return false;
+	    }
+	  else
+	    {
+	      indx = elf_section_data (sec->output_section)->dynindx;
+	      if (indx == 0)
+		abort ();
+	    }
+
+	  /* Figure out how far the target of the relocation is from
+	     the beginning of its section.  */
+	  section_offset = symbol - sec->output_section->vma;
+	  /* The relocation we're building is section-relative.
+	     Therefore, the original addend must be adjusted by the
+	     section offset.  */
+	  *addendp += section_offset;
+	  /* Now, the relocation is just against the section.  */
+	  symbol = sec->output_section->vma;
+	}
+
+      /* If the relocation was previously an absolute relocation and
+	 this symbol will not be referred to by the relocation, we must
+	 adjust it by the value we give it in the dynamic symbol table.
+	 Otherwise leave the job up to the dynamic linker.  */
+      if (!indx && r_type != R_MIPS_REL32)
+	*addendp += symbol;
+
+      /* The relocation is always an REL32 relocation because we don't
+	 know where the shared library will wind up at load-time.  */
+      outrel[0].r_info = ELF_R_INFO (output_bfd, indx, R_MIPS_REL32);
+
+      /* Adjust the output offset of the relocation to reference the
+	 correct location in the output file.  */
+      outrel[0].r_offset += (input_section->output_section->vma
+			     + input_section->output_offset);
+      outrel[1].r_offset += (input_section->output_section->vma
+			     + input_section->output_offset);
+      outrel[2].r_offset += (input_section->output_section->vma
+			     + input_section->output_offset);
+    }
+
+  /* Put the relocation back out.  We have to use the special
+     relocation outputter in the 64-bit case since the 64-bit
+     relocation format is non-standard.  */
+  if (ABI_64_P (output_bfd))
+    {
+      (*get_elf_backend_data (output_bfd)->s->swap_reloc_out)
+	(output_bfd, &outrel[0],
+	 (sreloc->contents
+	  + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel)));
+    }
+  else
+    bfd_elf32_swap_reloc_out (output_bfd, &outrel[0],
+			      (((Elf32_External_Rel *)
+				sreloc->contents)
+			       + sreloc->reloc_count));
+
+  /* Record the index of the first relocation referencing H.  This
+     information is later emitted in the .msym section.  */
+  if (h != NULL
+      && (h->min_dyn_reloc_index == 0
+	  || sreloc->reloc_count < h->min_dyn_reloc_index))
+    h->min_dyn_reloc_index = sreloc->reloc_count;
+
+  /* We've now added another relocation.  */
+  ++sreloc->reloc_count;
+
+  /* Make sure the output section is writable.  The dynamic linker
+     will be writing to it.  */
+  elf_section_data (input_section->output_section)->this_hdr.sh_flags
+    |= SHF_WRITE;
+
+  /* On IRIX5, make an entry of compact relocation info.  */
+  if (! skip && IRIX_COMPAT (output_bfd) == ict_irix5)
+    {
+      asection *scpt = bfd_get_section_by_name (dynobj, ".compact_rel");
+      bfd_byte *cr;
+
+      if (scpt)
+	{
+	  Elf32_crinfo cptrel;
+
+	  mips_elf_set_cr_format (cptrel, CRF_MIPS_LONG);
+	  cptrel.vaddr = (rel->r_offset
+			  + input_section->output_section->vma
+			  + input_section->output_offset);
+	  if (r_type == R_MIPS_REL32)
+	    mips_elf_set_cr_type (cptrel, CRT_MIPS_REL32);
+	  else
+	    mips_elf_set_cr_type (cptrel, CRT_MIPS_WORD);
+	  mips_elf_set_cr_dist2to (cptrel, 0);
+	  cptrel.konst = *addendp;
+
+	  cr = (scpt->contents
+		+ sizeof (Elf32_External_compact_rel));
+	  bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
+				     ((Elf32_External_crinfo *) cr
+				      + scpt->reloc_count));
+	  ++scpt->reloc_count;
+	}
+    }
+
+  return true;
+}
+
+/* Return the ISA for a MIPS e_flags value.  */
+
+static INLINE int
+elf_mips_isa (flags)
+     flagword flags;
+{
+  switch (flags & EF_MIPS_ARCH)
+    {
+    case E_MIPS_ARCH_1:
+      return 1;
+    case E_MIPS_ARCH_2:
+      return 2;
+    case E_MIPS_ARCH_3:
+      return 3;
+    case E_MIPS_ARCH_4:
+      return 4;
+    case E_MIPS_ARCH_5:
+      return 5;
+    case E_MIPS_ARCH_32:
+      return 32;
+    case E_MIPS_ARCH_64:
+      return 64;
+    }
+  return 4;
+}
+
+/* Return the MACH for a MIPS e_flags value.  */
+
+unsigned long
+_bfd_elf_mips_mach (flags)
+     flagword flags;
+{
+  switch (flags & EF_MIPS_MACH)
+    {
+    case E_MIPS_MACH_3900:
+      return bfd_mach_mips3900;
+
+    case E_MIPS_MACH_4010:
+      return bfd_mach_mips4010;
+
+    case E_MIPS_MACH_4100:
+      return bfd_mach_mips4100;
+
+    case E_MIPS_MACH_4111:
+      return bfd_mach_mips4111;
+
+    case E_MIPS_MACH_4650:
+      return bfd_mach_mips4650;
+
+    case E_MIPS_MACH_SB1:
+      return bfd_mach_mips_sb1;
+
+    default:
+      switch (flags & EF_MIPS_ARCH)
+	{
+	default:
+	case E_MIPS_ARCH_1:
+	  return bfd_mach_mips3000;
+	  break;
+
+	case E_MIPS_ARCH_2:
+	  return bfd_mach_mips6000;
+	  break;
+
+	case E_MIPS_ARCH_3:
+	  return bfd_mach_mips4000;
+	  break;
+
+	case E_MIPS_ARCH_4:
+	  return bfd_mach_mips8000;
+	  break;
+
+	case E_MIPS_ARCH_5:
+	  return bfd_mach_mips5;
+	  break;
+
+	case E_MIPS_ARCH_32:
+	  return bfd_mach_mipsisa32;
+	  break;
+
+	case E_MIPS_ARCH_64:
+	  return bfd_mach_mipsisa64;
+	  break;
+	}
+    }
+
+  return 0;
+}
+
+/* Return printable name for ABI.  */
+
+static INLINE char *
+elf_mips_abi_name (abfd)
+     bfd *abfd;
+{
+  flagword flags;
+
+  flags = elf_elfheader (abfd)->e_flags;
+  switch (flags & EF_MIPS_ABI)
+    {
+    case 0:
+      if (ABI_N32_P (abfd))
+	return "N32";
+      else if (ABI_64_P (abfd))
+	return "64";
+      else
+	return "none";
+    case E_MIPS_ABI_O32:
+      return "O32";
+    case E_MIPS_ABI_O64:
+      return "O64";
+    case E_MIPS_ABI_EABI32:
+      return "EABI32";
+    case E_MIPS_ABI_EABI64:
+      return "EABI64";
+    default:
+      return "unknown abi";
+    }
+}
+
+/* MIPS 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 the gp pointer, which yields
+   faster assembler code.  This is what we use for the small common
+   section.  This approach is copied from ecoff.c.  */
+static asection mips_elf_scom_section;
+static asymbol mips_elf_scom_symbol;
+static asymbol *mips_elf_scom_symbol_ptr;
+
+/* MIPS ELF also uses an acommon section, which represents an
+   allocated common symbol which may be overridden by a
+   definition in a shared library.  */
+static asection mips_elf_acom_section;
+static asymbol mips_elf_acom_symbol;
+static asymbol *mips_elf_acom_symbol_ptr;
+
+/* Handle the special MIPS section numbers that a symbol may use.
+   This is used for both the 32-bit and the 64-bit ABI.  */
+
+void
+_bfd_mips_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_MIPS_ACOMMON:
+      /* This section is used in a dynamically linked executable file.
+	 It is an allocated common section.  The dynamic linker can
+	 either resolve these symbols to something in a shared
+	 library, or it can just leave them here.  For our purposes,
+	 we can consider these symbols to be in a new section.  */
+      if (mips_elf_acom_section.name == NULL)
+	{
+	  /* Initialize the acommon section.  */
+	  mips_elf_acom_section.name = ".acommon";
+	  mips_elf_acom_section.flags = SEC_ALLOC;
+	  mips_elf_acom_section.output_section = &mips_elf_acom_section;
+	  mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
+	  mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
+	  mips_elf_acom_symbol.name = ".acommon";
+	  mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
+	  mips_elf_acom_symbol.section = &mips_elf_acom_section;
+	  mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
+	}
+      asym->section = &mips_elf_acom_section;
+      break;
+
+    case SHN_COMMON:
+      /* Common symbols less than the GP size are automatically
+	 treated as SHN_MIPS_SCOMMON symbols on IRIX5.  */
+      if (asym->value > elf_gp_size (abfd)
+	  || IRIX_COMPAT (abfd) == ict_irix6)
+	break;
+      /* Fall through.  */
+    case SHN_MIPS_SCOMMON:
+      if (mips_elf_scom_section.name == NULL)
+	{
+	  /* Initialize the small common section.  */
+	  mips_elf_scom_section.name = ".scommon";
+	  mips_elf_scom_section.flags = SEC_IS_COMMON;
+	  mips_elf_scom_section.output_section = &mips_elf_scom_section;
+	  mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
+	  mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
+	  mips_elf_scom_symbol.name = ".scommon";
+	  mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
+	  mips_elf_scom_symbol.section = &mips_elf_scom_section;
+	  mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
+	}
+      asym->section = &mips_elf_scom_section;
+      asym->value = elfsym->internal_elf_sym.st_size;
+      break;
+
+    case SHN_MIPS_SUNDEFINED:
+      asym->section = bfd_und_section_ptr;
+      break;
+
+#if 0 /* for SGI_COMPAT */
+    case SHN_MIPS_TEXT:
+      asym->section = mips_elf_text_section_ptr;
+      break;
+
+    case SHN_MIPS_DATA:
+      asym->section = mips_elf_data_section_ptr;
+      break;
+#endif
+    }
+}
+
+/* Work over a section just before writing it out.  This routine is
+   used by both the 32-bit and the 64-bit ABI.  FIXME: We recognize
+   sections that need the SHF_MIPS_GPREL flag by name; there has to be
+   a better way.  */
+
+boolean
+_bfd_mips_elf_section_processing (abfd, hdr)
+     bfd *abfd;
+     Elf_Internal_Shdr *hdr;
+{
+  if (hdr->sh_type == SHT_MIPS_REGINFO
+      && hdr->sh_size > 0)
+    {
+      bfd_byte buf[4];
+
+      BFD_ASSERT (hdr->sh_size == sizeof (Elf32_External_RegInfo));
+      BFD_ASSERT (hdr->contents == NULL);
+
+      if (bfd_seek (abfd,
+		    hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
+		    SEEK_SET) != 0)
+	return false;
+      H_PUT_32 (abfd, elf_gp (abfd), buf);
+      if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
+	return false;
+    }
+
+  if (hdr->sh_type == SHT_MIPS_OPTIONS
+      && hdr->bfd_section != NULL
+      && elf_section_data (hdr->bfd_section) != NULL
+      && elf_section_data (hdr->bfd_section)->tdata != NULL)
+    {
+      bfd_byte *contents, *l, *lend;
+
+      /* We stored the section contents in the elf_section_data tdata
+	 field in the set_section_contents routine.  We save the
+	 section contents so that we don't have to read them again.
+	 At this point we know that elf_gp is set, so we can look
+	 through the section contents to see if there is an
+	 ODK_REGINFO structure.  */
+
+      contents = (bfd_byte *) elf_section_data (hdr->bfd_section)->tdata;
+      l = contents;
+      lend = contents + hdr->sh_size;
+      while (l + sizeof (Elf_External_Options) <= lend)
+	{
+	  Elf_Internal_Options intopt;
+
+	  bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
+					&intopt);
+	  if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
+	    {
+	      bfd_byte buf[8];
+
+	      if (bfd_seek (abfd,
+			    (hdr->sh_offset
+			     + (l - contents)
+			     + sizeof (Elf_External_Options)
+			     + (sizeof (Elf64_External_RegInfo) - 8)),
+			     SEEK_SET) != 0)
+		return false;
+	      H_PUT_64 (abfd, elf_gp (abfd), buf);
+	      if (bfd_bwrite (buf, (bfd_size_type) 8, abfd) != 8)
+		return false;
+	    }
+	  else if (intopt.kind == ODK_REGINFO)
+	    {
+	      bfd_byte buf[4];
+
+	      if (bfd_seek (abfd,
+			    (hdr->sh_offset
+			     + (l - contents)
+			     + sizeof (Elf_External_Options)
+			     + (sizeof (Elf32_External_RegInfo) - 4)),
+			    SEEK_SET) != 0)
+		return false;
+	      H_PUT_32 (abfd, elf_gp (abfd), buf);
+	      if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
+		return false;
+	    }
+	  l += intopt.size;
+	}
+    }
+
+  if (hdr->bfd_section != NULL)
+    {
+      const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+
+      if (strcmp (name, ".sdata") == 0
+	  || strcmp (name, ".lit8") == 0
+	  || strcmp (name, ".lit4") == 0)
+	{
+	  hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+	  hdr->sh_type = SHT_PROGBITS;
+	}
+      else if (strcmp (name, ".sbss") == 0)
+	{
+	  hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
+	  hdr->sh_type = SHT_NOBITS;
+	}
+      else if (strcmp (name, ".srdata") == 0)
+	{
+	  hdr->sh_flags |= SHF_ALLOC | SHF_MIPS_GPREL;
+	  hdr->sh_type = SHT_PROGBITS;
+	}
+      else if (strcmp (name, ".compact_rel") == 0)
+	{
+	  hdr->sh_flags = 0;
+	  hdr->sh_type = SHT_PROGBITS;
+	}
+      else if (strcmp (name, ".rtproc") == 0)
+	{
+	  if (hdr->sh_addralign != 0 && hdr->sh_entsize == 0)
+	    {
+	      unsigned int adjust;
+
+	      adjust = hdr->sh_size % hdr->sh_addralign;
+	      if (adjust != 0)
+		hdr->sh_size += hdr->sh_addralign - adjust;
+	    }
+	}
+    }
+
+  return true;
+}
+
+/* Handle a MIPS specific section when reading an object file.  This
+   is called when elfcode.h finds a section with an unknown type.
+   This routine supports both the 32-bit and 64-bit ELF ABI.
+
+   FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure
+   how to.  */
+
+boolean
+_bfd_mips_elf_section_from_shdr (abfd, hdr, name)
+     bfd *abfd;
+     Elf_Internal_Shdr *hdr;
+     char *name;
+{
+  flagword flags = 0;
+
+  /* There ought to be a place to keep ELF backend specific flags, but
+     at the moment there isn't one.  We just keep track of the
+     sections by their name, instead.  Fortunately, the ABI gives
+     suggested names for all the MIPS specific sections, so we will
+     probably get away with this.  */
+  switch (hdr->sh_type)
+    {
+    case SHT_MIPS_LIBLIST:
+      if (strcmp (name, ".liblist") != 0)
+	return false;
+      break;
+    case SHT_MIPS_MSYM:
+      if (strcmp (name, ".msym") != 0)
+	return false;
+      break;
+    case SHT_MIPS_CONFLICT:
+      if (strcmp (name, ".conflict") != 0)
+	return false;
+      break;
+    case SHT_MIPS_GPTAB:
+      if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) != 0)
+	return false;
+      break;
+    case SHT_MIPS_UCODE:
+      if (strcmp (name, ".ucode") != 0)
+	return false;
+      break;
+    case SHT_MIPS_DEBUG:
+      if (strcmp (name, ".mdebug") != 0)
+	return false;
+      flags = SEC_DEBUGGING;
+      break;
+    case SHT_MIPS_REGINFO:
+      if (strcmp (name, ".reginfo") != 0
+	  || hdr->sh_size != sizeof (Elf32_External_RegInfo))
+	return false;
+      flags = (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_SAME_SIZE);
+      break;
+    case SHT_MIPS_IFACE:
+      if (strcmp (name, ".MIPS.interfaces") != 0)
+	return false;
+      break;
+    case SHT_MIPS_CONTENT:
+      if (strncmp (name, ".MIPS.content", sizeof ".MIPS.content" - 1) != 0)
+	return false;
+      break;
+    case SHT_MIPS_OPTIONS:
+      if (strcmp (name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) != 0)
+	return false;
+      break;
+    case SHT_MIPS_DWARF:
+      if (strncmp (name, ".debug_", sizeof ".debug_" - 1) != 0)
+	return false;
+      break;
+    case SHT_MIPS_SYMBOL_LIB:
+      if (strcmp (name, ".MIPS.symlib") != 0)
+	return false;
+      break;
+    case SHT_MIPS_EVENTS:
+      if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) != 0
+	  && strncmp (name, ".MIPS.post_rel",
+		      sizeof ".MIPS.post_rel" - 1) != 0)
+	return false;
+      break;
+    default:
+      return false;
+    }
+
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+    return false;
+
+  if (flags)
+    {
+      if (! bfd_set_section_flags (abfd, hdr->bfd_section,
+				   (bfd_get_section_flags (abfd,
+							   hdr->bfd_section)
+				    | flags)))
+	return false;
+    }
+
+  /* FIXME: We should record sh_info for a .gptab section.  */
+
+  /* For a .reginfo section, set the gp value in the tdata information
+     from the contents of this section.  We need the gp value while
+     processing relocs, so we just get it now.  The .reginfo section
+     is not used in the 64-bit MIPS ELF ABI.  */
+  if (hdr->sh_type == SHT_MIPS_REGINFO)
+    {
+      Elf32_External_RegInfo ext;
+      Elf32_RegInfo s;
+
+      if (! bfd_get_section_contents (abfd, hdr->bfd_section, (PTR) &ext,
+				      (file_ptr) 0,
+				      (bfd_size_type) sizeof ext))
+	return false;
+      bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s);
+      elf_gp (abfd) = s.ri_gp_value;
+    }
+
+  /* For a SHT_MIPS_OPTIONS section, look for a ODK_REGINFO entry, and
+     set the gp value based on what we find.  We may see both
+     SHT_MIPS_REGINFO and SHT_MIPS_OPTIONS/ODK_REGINFO; in that case,
+     they should agree.  */
+  if (hdr->sh_type == SHT_MIPS_OPTIONS)
+    {
+      bfd_byte *contents, *l, *lend;
+
+      contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
+      if (contents == NULL)
+	return false;
+      if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents,
+				      (file_ptr) 0, hdr->sh_size))
+	{
+	  free (contents);
+	  return false;
+	}
+      l = contents;
+      lend = contents + hdr->sh_size;
+      while (l + sizeof (Elf_External_Options) <= lend)
+	{
+	  Elf_Internal_Options intopt;
+
+	  bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
+					&intopt);
+	  if (ABI_64_P (abfd) && intopt.kind == ODK_REGINFO)
+	    {
+	      Elf64_Internal_RegInfo intreg;
+
+	      bfd_mips_elf64_swap_reginfo_in
+		(abfd,
+		 ((Elf64_External_RegInfo *)
+		  (l + sizeof (Elf_External_Options))),
+		 &intreg);
+	      elf_gp (abfd) = intreg.ri_gp_value;
+	    }
+	  else if (intopt.kind == ODK_REGINFO)
+	    {
+	      Elf32_RegInfo intreg;
+
+	      bfd_mips_elf32_swap_reginfo_in
+		(abfd,
+		 ((Elf32_External_RegInfo *)
+		  (l + sizeof (Elf_External_Options))),
+		 &intreg);
+	      elf_gp (abfd) = intreg.ri_gp_value;
+	    }
+	  l += intopt.size;
+	}
+      free (contents);
+    }
+
+  return true;
+}
+
+/* Set the correct type for a MIPS ELF section.  We do this by the
+   section name, which is a hack, but ought to work.  This routine is
+   used by both the 32-bit and the 64-bit ABI.  */
+
+boolean
+_bfd_mips_elf_fake_sections (abfd, hdr, sec)
+     bfd *abfd;
+     Elf32_Internal_Shdr *hdr;
+     asection *sec;
+{
+  register const char *name;
+
+  name = bfd_get_section_name (abfd, sec);
+
+  if (strcmp (name, ".liblist") == 0)
+    {
+      hdr->sh_type = SHT_MIPS_LIBLIST;
+      hdr->sh_info = sec->_raw_size / sizeof (Elf32_Lib);
+      /* The sh_link field is set in final_write_processing.  */
+    }
+  else if (strcmp (name, ".conflict") == 0)
+    hdr->sh_type = SHT_MIPS_CONFLICT;
+  else if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0)
+    {
+      hdr->sh_type = SHT_MIPS_GPTAB;
+      hdr->sh_entsize = sizeof (Elf32_External_gptab);
+      /* The sh_info field is set in final_write_processing.  */
+    }
+  else if (strcmp (name, ".ucode") == 0)
+    hdr->sh_type = SHT_MIPS_UCODE;
+  else if (strcmp (name, ".mdebug") == 0)
+    {
+      hdr->sh_type = SHT_MIPS_DEBUG;
+      /* In a shared object on Irix 5.3, the .mdebug section has an
+         entsize of 0.  FIXME: Does this matter?  */
+      if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
+	hdr->sh_entsize = 0;
+      else
+	hdr->sh_entsize = 1;
+    }
+  else if (strcmp (name, ".reginfo") == 0)
+    {
+      hdr->sh_type = SHT_MIPS_REGINFO;
+      /* In a shared object on Irix 5.3, the .reginfo section has an
+         entsize of 0x18.  FIXME: Does this matter?  */
+      if (SGI_COMPAT (abfd))
+	{
+	  if ((abfd->flags & DYNAMIC) != 0)
+	    hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
+	  else
+	    hdr->sh_entsize = 1;
+	}
+      else
+	hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
+    }
+  else if (SGI_COMPAT (abfd)
+	   && (strcmp (name, ".hash") == 0
+	       || strcmp (name, ".dynamic") == 0
+	       || strcmp (name, ".dynstr") == 0))
+    {
+      if (SGI_COMPAT (abfd))
+	hdr->sh_entsize = 0;
+#if 0
+      /* This isn't how the Irix 6 linker behaves.  */
+      hdr->sh_info = SIZEOF_MIPS_DYNSYM_SECNAMES;
+#endif
+    }
+  else if (strcmp (name, ".got") == 0
+	   || strcmp (name, ".srdata") == 0
+	   || strcmp (name, ".sdata") == 0
+	   || strcmp (name, ".sbss") == 0
+	   || strcmp (name, ".lit4") == 0
+	   || strcmp (name, ".lit8") == 0)
+    hdr->sh_flags |= SHF_MIPS_GPREL;
+  else if (strcmp (name, ".MIPS.interfaces") == 0)
+    {
+      hdr->sh_type = SHT_MIPS_IFACE;
+      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+    }
+  else if (strncmp (name, ".MIPS.content", strlen (".MIPS.content")) == 0)
+    {
+      hdr->sh_type = SHT_MIPS_CONTENT;
+      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+      /* The sh_info field is set in final_write_processing.  */
+    }
+  else if (strcmp (name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
+    {
+      hdr->sh_type = SHT_MIPS_OPTIONS;
+      hdr->sh_entsize = 1;
+      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+    }
+  else if (strncmp (name, ".debug_", sizeof ".debug_" - 1) == 0)
+    hdr->sh_type = SHT_MIPS_DWARF;
+  else if (strcmp (name, ".MIPS.symlib") == 0)
+    {
+      hdr->sh_type = SHT_MIPS_SYMBOL_LIB;
+      /* The sh_link and sh_info fields are set in
+         final_write_processing.  */
+    }
+  else if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0
+	   || strncmp (name, ".MIPS.post_rel",
+		       sizeof ".MIPS.post_rel" - 1) == 0)
+    {
+      hdr->sh_type = SHT_MIPS_EVENTS;
+      hdr->sh_flags |= SHF_MIPS_NOSTRIP;
+      /* The sh_link field is set in final_write_processing.  */
+    }
+  else if (strcmp (name, ".msym") == 0)
+    {
+      hdr->sh_type = SHT_MIPS_MSYM;
+      hdr->sh_flags |= SHF_ALLOC;
+      hdr->sh_entsize = 8;
+    }
+
+  /* The generic elf_fake_sections will set up REL_HDR using the
+     default kind of relocations.  But, we may actually need both
+     kinds of relocations, so we set up the second header here.
+
+     This is not necessary for the O32 ABI since that only uses Elf32_Rel
+     relocations (cf. System V ABI, MIPS RISC Processor Supplement,
+     3rd Edition, p. 4-17).  It breaks the IRIX 5/6 32-bit ld, since one
+     of the resulting empty .rela.<section> sections starts with
+     sh_offset == object size, and ld doesn't allow that.  While the check
+     is arguably bogus for empty or SHT_NOBITS sections, it can easily be
+     avoided by not emitting those useless sections in the first place.  */
+  if (IRIX_COMPAT (abfd) != ict_irix5 && (sec->flags & SEC_RELOC) != 0)
+    {
+      struct bfd_elf_section_data *esd;
+      bfd_size_type amt = sizeof (Elf_Internal_Shdr);
+
+      esd = elf_section_data (sec);
+      BFD_ASSERT (esd->rel_hdr2 == NULL);
+      esd->rel_hdr2 = (Elf_Internal_Shdr *) bfd_zalloc (abfd, amt);
+      if (!esd->rel_hdr2)
+	return false;
+      _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec,
+				!elf_section_data (sec)->use_rela_p);
+    }
+
+  return true;
+}
+
+/* Given a BFD section, try to locate the corresponding ELF section
+   index.  This is used by both the 32-bit and the 64-bit ABI.
+   Actually, it's not clear to me that the 64-bit ABI supports these,
+   but for non-PIC objects we will certainly want support for at least
+   the .scommon section.  */
+
+boolean
+_bfd_mips_elf_section_from_bfd_section (abfd, sec, retval)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     asection *sec;
+     int *retval;
+{
+  if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+    {
+      *retval = SHN_MIPS_SCOMMON;
+      return true;
+    }
+  if (strcmp (bfd_get_section_name (abfd, sec), ".acommon") == 0)
+    {
+      *retval = SHN_MIPS_ACOMMON;
+      return true;
+    }
+  return false;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+   file.  We must handle the special MIPS section numbers here.  */
+
+boolean
+_bfd_mips_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 ATTRIBUTE_UNUSED;
+     asection **secp;
+     bfd_vma *valp;
+{
+  if (SGI_COMPAT (abfd)
+      && (abfd->flags & DYNAMIC) != 0
+      && strcmp (*namep, "_rld_new_interface") == 0)
+    {
+      /* Skip Irix 5 rld entry name.  */
+      *namep = NULL;
+      return true;
+    }
+
+  switch (sym->st_shndx)
+    {
+    case SHN_COMMON:
+      /* Common symbols less than the GP size are automatically
+	 treated as SHN_MIPS_SCOMMON symbols.  */
+      if (sym->st_size > elf_gp_size (abfd)
+	  || IRIX_COMPAT (abfd) == ict_irix6)
+	break;
+      /* Fall through.  */
+    case SHN_MIPS_SCOMMON:
+      *secp = bfd_make_section_old_way (abfd, ".scommon");
+      (*secp)->flags |= SEC_IS_COMMON;
+      *valp = sym->st_size;
+      break;
+
+    case SHN_MIPS_TEXT:
+      /* This section is used in a shared object.  */
+      if (elf_tdata (abfd)->elf_text_section == NULL)
+	{
+	  asymbol *elf_text_symbol;
+	  asection *elf_text_section;
+	  bfd_size_type amt = sizeof (asection);
+
+	  elf_text_section = bfd_zalloc (abfd, amt);
+	  if (elf_text_section == NULL)
+	    return false;
+
+	  amt = sizeof (asymbol);
+	  elf_text_symbol = bfd_zalloc (abfd, amt);
+	  if (elf_text_symbol == NULL)
+	    return false;
+
+	  /* Initialize the section.  */
+
+	  elf_tdata (abfd)->elf_text_section = elf_text_section;
+	  elf_tdata (abfd)->elf_text_symbol = elf_text_symbol;
+
+	  elf_text_section->symbol = elf_text_symbol;
+	  elf_text_section->symbol_ptr_ptr = &elf_tdata (abfd)->elf_text_symbol;
+
+	  elf_text_section->name = ".text";
+	  elf_text_section->flags = SEC_NO_FLAGS;
+	  elf_text_section->output_section = NULL;
+	  elf_text_section->owner = abfd;
+	  elf_text_symbol->name = ".text";
+	  elf_text_symbol->flags = BSF_SECTION_SYM | BSF_DYNAMIC;
+	  elf_text_symbol->section = elf_text_section;
+	}
+      /* This code used to do *secp = bfd_und_section_ptr if
+         info->shared.  I don't know why, and that doesn't make sense,
+         so I took it out.  */
+      *secp = elf_tdata (abfd)->elf_text_section;
+      break;
+
+    case SHN_MIPS_ACOMMON:
+      /* Fall through. XXX Can we treat this as allocated data?  */
+    case SHN_MIPS_DATA:
+      /* This section is used in a shared object.  */
+      if (elf_tdata (abfd)->elf_data_section == NULL)
+	{
+	  asymbol *elf_data_symbol;
+	  asection *elf_data_section;
+	  bfd_size_type amt = sizeof (asection);
+
+	  elf_data_section = bfd_zalloc (abfd, amt);
+	  if (elf_data_section == NULL)
+	    return false;
+
+	  amt = sizeof (asymbol);
+	  elf_data_symbol = bfd_zalloc (abfd, amt);
+	  if (elf_data_symbol == NULL)
+	    return false;
+
+	  /* Initialize the section.  */
+
+	  elf_tdata (abfd)->elf_data_section = elf_data_section;
+	  elf_tdata (abfd)->elf_data_symbol = elf_data_symbol;
+
+	  elf_data_section->symbol = elf_data_symbol;
+	  elf_data_section->symbol_ptr_ptr = &elf_tdata (abfd)->elf_data_symbol;
+
+	  elf_data_section->name = ".data";
+	  elf_data_section->flags = SEC_NO_FLAGS;
+	  elf_data_section->output_section = NULL;
+	  elf_data_section->owner = abfd;
+	  elf_data_symbol->name = ".data";
+	  elf_data_symbol->flags = BSF_SECTION_SYM | BSF_DYNAMIC;
+	  elf_data_symbol->section = elf_data_section;
+	}
+      /* This code used to do *secp = bfd_und_section_ptr if
+         info->shared.  I don't know why, and that doesn't make sense,
+         so I took it out.  */
+      *secp = elf_tdata (abfd)->elf_data_section;
+      break;
+
+    case SHN_MIPS_SUNDEFINED:
+      *secp = bfd_und_section_ptr;
+      break;
+    }
+
+  if (SGI_COMPAT (abfd)
+      && ! info->shared
+      && info->hash->creator == abfd->xvec
+      && strcmp (*namep, "__rld_obj_head") == 0)
+    {
+      struct elf_link_hash_entry *h;
+
+      /* Mark __rld_obj_head as dynamic.  */
+      h = NULL;
+      if (! (_bfd_generic_link_add_one_symbol
+	     (info, abfd, *namep, BSF_GLOBAL, *secp,
+	      (bfd_vma) *valp, (const char *) NULL, false,
+	      get_elf_backend_data (abfd)->collect,
+	      (struct bfd_link_hash_entry **) &h)))
+	return false;
+      h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
+      h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+      h->type = STT_OBJECT;
+
+      if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+	return false;
+
+      mips_elf_hash_table (info)->use_rld_obj_head = true;
+    }
+
+  /* If this is a mips16 text symbol, add 1 to the value to make it
+     odd.  This will cause something like .word SYM to come up with
+     the right value when it is loaded into the PC.  */
+  if (sym->st_other == STO_MIPS16)
+    ++*valp;
+
+  return true;
+}
+
+/* This hook function is called before the linker writes out a global
+   symbol.  We mark symbols as small common if appropriate.  This is
+   also where we undo the increment of the value for a mips16 symbol.  */
+
+boolean
+_bfd_mips_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+     const char *name ATTRIBUTE_UNUSED;
+     Elf_Internal_Sym *sym;
+     asection *input_sec;
+{
+  /* If we see a common symbol, which implies a relocatable link, then
+     if a symbol was small common in an input file, mark it as small
+     common in the output file.  */
+  if (sym->st_shndx == SHN_COMMON
+      && strcmp (input_sec->name, ".scommon") == 0)
+    sym->st_shndx = SHN_MIPS_SCOMMON;
+
+  if (sym->st_other == STO_MIPS16
+      && (sym->st_value & 1) != 0)
+    --sym->st_value;
+
+  return true;
+}
+
+/* Functions for the dynamic linker.  */
+
+/* Create dynamic sections when linking against a dynamic object.  */
+
+boolean
+_bfd_mips_elf_create_dynamic_sections (abfd, info)
+     bfd *abfd;
+     struct bfd_link_info *info;
+{
+  struct elf_link_hash_entry *h;
+  flagword flags;
+  register asection *s;
+  const char * const *namep;
+
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+	   | SEC_LINKER_CREATED | SEC_READONLY);
+
+  /* Mips ABI requests the .dynamic section to be read only.  */
+  s = bfd_get_section_by_name (abfd, ".dynamic");
+  if (s != NULL)
+    {
+      if (! bfd_set_section_flags (abfd, s, flags))
+	return false;
+    }
+
+  /* We need to create .got section.  */
+  if (! mips_elf_create_got_section (abfd, info))
+    return false;
+
+  /* Create the .msym section on IRIX6.  It is used by the dynamic
+     linker to speed up dynamic relocations, and to avoid computing
+     the ELF hash for symbols.  */
+  if (IRIX_COMPAT (abfd) == ict_irix6
+      && !mips_elf_create_msym_section (abfd))
+    return false;
+
+  /* Create .stub section.  */
+  if (bfd_get_section_by_name (abfd,
+			       MIPS_ELF_STUB_SECTION_NAME (abfd)) == NULL)
+    {
+      s = bfd_make_section (abfd, MIPS_ELF_STUB_SECTION_NAME (abfd));
+      if (s == NULL
+	  || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
+	  || ! bfd_set_section_alignment (abfd, s,
+					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
+	return false;
+    }
+
+  if ((IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
+      && !info->shared
+      && bfd_get_section_by_name (abfd, ".rld_map") == NULL)
+    {
+      s = bfd_make_section (abfd, ".rld_map");
+      if (s == NULL
+	  || ! bfd_set_section_flags (abfd, s, flags &~ (flagword) SEC_READONLY)
+	  || ! bfd_set_section_alignment (abfd, s,
+					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
+	return false;
+    }
+
+  /* On IRIX5, we adjust add some additional symbols and change the
+     alignments of several sections.  There is no ABI documentation
+     indicating that this is necessary on IRIX6, nor any evidence that
+     the linker takes such action.  */
+  if (IRIX_COMPAT (abfd) == ict_irix5)
+    {
+      for (namep = mips_elf_dynsym_rtproc_names; *namep != NULL; namep++)
+	{
+	  h = NULL;
+	  if (! (_bfd_generic_link_add_one_symbol
+		 (info, abfd, *namep, BSF_GLOBAL, bfd_und_section_ptr,
+		  (bfd_vma) 0, (const char *) NULL, false,
+		  get_elf_backend_data (abfd)->collect,
+		  (struct bfd_link_hash_entry **) &h)))
+	    return false;
+	  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
+	  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+	  h->type = STT_SECTION;
+
+	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+	    return false;
+	}
+
+      /* We need to create a .compact_rel section.  */
+      if (SGI_COMPAT (abfd))
+	{
+	  if (!mips_elf_create_compact_rel_section (abfd, info))
+	    return false;
+	}
+
+      /* Change aligments of some sections.  */
+      s = bfd_get_section_by_name (abfd, ".hash");
+      if (s != NULL)
+	bfd_set_section_alignment (abfd, s, 4);
+      s = bfd_get_section_by_name (abfd, ".dynsym");
+      if (s != NULL)
+	bfd_set_section_alignment (abfd, s, 4);
+      s = bfd_get_section_by_name (abfd, ".dynstr");
+      if (s != NULL)
+	bfd_set_section_alignment (abfd, s, 4);
+      s = bfd_get_section_by_name (abfd, ".reginfo");
+      if (s != NULL)
+	bfd_set_section_alignment (abfd, s, 4);
+      s = bfd_get_section_by_name (abfd, ".dynamic");
+      if (s != NULL)
+	bfd_set_section_alignment (abfd, s, 4);
+    }
+
+  if (!info->shared)
+    {
+      h = NULL;
+      if (SGI_COMPAT (abfd))
+	{
+	  if (!(_bfd_generic_link_add_one_symbol
+		(info, abfd, "_DYNAMIC_LINK", BSF_GLOBAL, bfd_abs_section_ptr,
+		 (bfd_vma) 0, (const char *) NULL, false,
+		 get_elf_backend_data (abfd)->collect,
+		 (struct bfd_link_hash_entry **) &h)))
+	    return false;
+	}
+      else
+	{
+	  /* For normal mips it is _DYNAMIC_LINKING.  */
+	  if (!(_bfd_generic_link_add_one_symbol
+		(info, abfd, "_DYNAMIC_LINKING", BSF_GLOBAL,
+		 bfd_abs_section_ptr, (bfd_vma) 0, (const char *) NULL, false,
+		 get_elf_backend_data (abfd)->collect,
+		 (struct bfd_link_hash_entry **) &h)))
+	    return false;
+	}
+      h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
+      h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+      h->type = STT_SECTION;
+
+      if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+	return false;
+
+      if (! mips_elf_hash_table (info)->use_rld_obj_head)
+	{
+	  /* __rld_map is a four byte word located in the .data section
+	     and is filled in by the rtld to contain a pointer to
+	     the _r_debug structure. Its symbol value will be set in
+	     _bfd_mips_elf_finish_dynamic_symbol.  */
+	  s = bfd_get_section_by_name (abfd, ".rld_map");
+	  BFD_ASSERT (s != NULL);
+
+	  h = NULL;
+	  if (SGI_COMPAT (abfd))
+	    {
+	      if (!(_bfd_generic_link_add_one_symbol
+		    (info, abfd, "__rld_map", BSF_GLOBAL, s,
+		     (bfd_vma) 0, (const char *) NULL, false,
+		     get_elf_backend_data (abfd)->collect,
+		     (struct bfd_link_hash_entry **) &h)))
+		return false;
+	    }
+	  else
+	    {
+	      /* For normal mips the symbol is __RLD_MAP.  */
+	      if (!(_bfd_generic_link_add_one_symbol
+		    (info, abfd, "__RLD_MAP", BSF_GLOBAL, s,
+		     (bfd_vma) 0, (const char *) NULL, false,
+		     get_elf_backend_data (abfd)->collect,
+		     (struct bfd_link_hash_entry **) &h)))
+		return false;
+	    }
+	  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
+	  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+	  h->type = STT_OBJECT;
+
+	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+	    return false;
+	}
+    }
+
+  return true;
+}
+
+/* Look through the relocs for a section during the first phase, and
+   allocate space in the global offset table.  */
+
+boolean
+_bfd_mips_elf_check_relocs (abfd, info, sec, relocs)
+     bfd *abfd;
+     struct bfd_link_info *info;
+     asection *sec;
+     const Elf_Internal_Rela *relocs;
+{
+  const char *name;
+  bfd *dynobj;
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  struct mips_got_info *g;
+  size_t extsymoff;
+  const Elf_Internal_Rela *rel;
+  const Elf_Internal_Rela *rel_end;
+  asection *sgot;
+  asection *sreloc;
+  struct elf_backend_data *bed;
+
+  if (info->relocateable)
+    return true;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (abfd);
+  extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
+
+  /* Check for the mips16 stub sections.  */
+
+  name = bfd_get_section_name (abfd, sec);
+  if (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0)
+    {
+      unsigned long r_symndx;
+
+      /* Look at the relocation information to figure out which symbol
+         this is for.  */
+
+      r_symndx = ELF_R_SYM (abfd, relocs->r_info);
+
+      if (r_symndx < extsymoff
+	  || sym_hashes[r_symndx - extsymoff] == NULL)
+	{
+	  asection *o;
+
+	  /* This stub is for a local symbol.  This stub will only be
+             needed if there is some relocation in this BFD, other
+             than a 16 bit function call, which refers to this symbol.  */
+	  for (o = abfd->sections; o != NULL; o = o->next)
+	    {
+	      Elf_Internal_Rela *sec_relocs;
+	      const Elf_Internal_Rela *r, *rend;
+
+	      /* We can ignore stub sections when looking for relocs.  */
+	      if ((o->flags & SEC_RELOC) == 0
+		  || o->reloc_count == 0
+		  || strncmp (bfd_get_section_name (abfd, o), FN_STUB,
+			      sizeof FN_STUB - 1) == 0
+		  || strncmp (bfd_get_section_name (abfd, o), CALL_STUB,
+			      sizeof CALL_STUB - 1) == 0
+		  || strncmp (bfd_get_section_name (abfd, o), CALL_FP_STUB,
+			      sizeof CALL_FP_STUB - 1) == 0)
+		continue;
+
+	      sec_relocs = (_bfd_elf32_link_read_relocs
+			    (abfd, o, (PTR) NULL,
+			     (Elf_Internal_Rela *) NULL,
+			     info->keep_memory));
+	      if (sec_relocs == NULL)
+		return false;
+
+	      rend = sec_relocs + o->reloc_count;
+	      for (r = sec_relocs; r < rend; r++)
+		if (ELF_R_SYM (abfd, r->r_info) == r_symndx
+		    && ELF_R_TYPE (abfd, r->r_info) != R_MIPS16_26)
+		  break;
+
+	      if (! info->keep_memory)
+		free (sec_relocs);
+
+	      if (r < rend)
+		break;
+	    }
+
+	  if (o == NULL)
+	    {
+	      /* There is no non-call reloc for this stub, so we do
+                 not need it.  Since this function is called before
+                 the linker maps input sections to output sections, we
+                 can easily discard it by setting the SEC_EXCLUDE
+                 flag.  */
+	      sec->flags |= SEC_EXCLUDE;
+	      return true;
+	    }
+
+	  /* Record this stub in an array of local symbol stubs for
+             this BFD.  */
+	  if (elf_tdata (abfd)->local_stubs == NULL)
+	    {
+	      unsigned long symcount;
+	      asection **n;
+	      bfd_size_type amt;
+
+	      if (elf_bad_symtab (abfd))
+		symcount = NUM_SHDR_ENTRIES (symtab_hdr);
+	      else
+		symcount = symtab_hdr->sh_info;
+	      amt = symcount * sizeof (asection *);
+	      n = (asection **) bfd_zalloc (abfd, amt);
+	      if (n == NULL)
+		return false;
+	      elf_tdata (abfd)->local_stubs = n;
+	    }
+
+	  elf_tdata (abfd)->local_stubs[r_symndx] = sec;
+
+	  /* We don't need to set mips16_stubs_seen in this case.
+             That flag is used to see whether we need to look through
+             the global symbol table for stubs.  We don't need to set
+             it here, because we just have a local stub.  */
+	}
+      else
+	{
+	  struct mips_elf_link_hash_entry *h;
+
+	  h = ((struct mips_elf_link_hash_entry *)
+	       sym_hashes[r_symndx - extsymoff]);
+
+	  /* H is the symbol this stub is for.  */
+
+	  h->fn_stub = sec;
+	  mips_elf_hash_table (info)->mips16_stubs_seen = true;
+	}
+    }
+  else if (strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0
+	   || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
+    {
+      unsigned long r_symndx;
+      struct mips_elf_link_hash_entry *h;
+      asection **loc;
+
+      /* Look at the relocation information to figure out which symbol
+         this is for.  */
+
+      r_symndx = ELF_R_SYM (abfd, relocs->r_info);
+
+      if (r_symndx < extsymoff
+	  || sym_hashes[r_symndx - extsymoff] == NULL)
+	{
+	  /* This stub was actually built for a static symbol defined
+	     in the same file.  We assume that all static symbols in
+	     mips16 code are themselves mips16, so we can simply
+	     discard this stub.  Since this function is called before
+	     the linker maps input sections to output sections, we can
+	     easily discard it by setting the SEC_EXCLUDE flag.  */
+	  sec->flags |= SEC_EXCLUDE;
+	  return true;
+	}
+
+      h = ((struct mips_elf_link_hash_entry *)
+	   sym_hashes[r_symndx - extsymoff]);
+
+      /* H is the symbol this stub is for.  */
+
+      if (strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0)
+	loc = &h->call_fp_stub;
+      else
+	loc = &h->call_stub;
+
+      /* If we already have an appropriate stub for this function, we
+	 don't need another one, so we can discard this one.  Since
+	 this function is called before the linker maps input sections
+	 to output sections, we can easily discard it by setting the
+	 SEC_EXCLUDE flag.  We can also discard this section if we
+	 happen to already know that this is a mips16 function; it is
+	 not necessary to check this here, as it is checked later, but
+	 it is slightly faster to check now.  */
+      if (*loc != NULL || h->root.other == STO_MIPS16)
+	{
+	  sec->flags |= SEC_EXCLUDE;
+	  return true;
+	}
+
+      *loc = sec;
+      mips_elf_hash_table (info)->mips16_stubs_seen = true;
+    }
+
+  if (dynobj == NULL)
+    {
+      sgot = NULL;
+      g = NULL;
+    }
+  else
+    {
+      sgot = mips_elf_got_section (dynobj);
+      if (sgot == NULL)
+	g = NULL;
+      else
+	{
+	  BFD_ASSERT (elf_section_data (sgot) != NULL);
+	  g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+	  BFD_ASSERT (g != NULL);
+	}
+    }
+
+  sreloc = NULL;
+  bed = get_elf_backend_data (abfd);
+  rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
+  for (rel = relocs; rel < rel_end; ++rel)
+    {
+      unsigned long r_symndx;
+      unsigned int r_type;
+      struct elf_link_hash_entry *h;
+
+      r_symndx = ELF_R_SYM (abfd, rel->r_info);
+      r_type = ELF_R_TYPE (abfd, rel->r_info);
+
+      if (r_symndx < extsymoff)
+	h = NULL;
+      else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
+	{
+	  (*_bfd_error_handler)
+	    (_("%s: Malformed reloc detected for section %s"),
+	     bfd_archive_filename (abfd), name);
+	  bfd_set_error (bfd_error_bad_value);
+	  return false;
+	}
+      else
+	{
+	  h = sym_hashes[r_symndx - extsymoff];
+
+	  /* This may be an indirect symbol created because of a version.  */
+	  if (h != NULL)
+	    {
+	      while (h->root.type == bfd_link_hash_indirect)
+		h = (struct elf_link_hash_entry *) h->root.u.i.link;
+	    }
+	}
+
+      /* Some relocs require a global offset table.  */
+      if (dynobj == NULL || sgot == NULL)
+	{
+	  switch (r_type)
+	    {
+	    case R_MIPS_GOT16:
+	    case R_MIPS_CALL16:
+	    case R_MIPS_CALL_HI16:
+	    case R_MIPS_CALL_LO16:
+	    case R_MIPS_GOT_HI16:
+	    case R_MIPS_GOT_LO16:
+	    case R_MIPS_GOT_PAGE:
+	    case R_MIPS_GOT_OFST:
+	    case R_MIPS_GOT_DISP:
+	      if (dynobj == NULL)
+		elf_hash_table (info)->dynobj = dynobj = abfd;
+	      if (! mips_elf_create_got_section (dynobj, info))
+		return false;
+	      g = mips_elf_got_info (dynobj, &sgot);
+	      break;
+
+	    case R_MIPS_32:
+	    case R_MIPS_REL32:
+	    case R_MIPS_64:
+	      if (dynobj == NULL
+		  && (info->shared || h != NULL)
+		  && (sec->flags & SEC_ALLOC) != 0)
+		elf_hash_table (info)->dynobj = dynobj = abfd;
+	      break;
+
+	    default:
+	      break;
+	    }
+	}
+
+      if (!h && (r_type == R_MIPS_CALL_LO16
+		 || r_type == R_MIPS_GOT_LO16
+		 || r_type == R_MIPS_GOT_DISP))
+	{
+	  /* We may need a local GOT entry for this relocation.  We
+	     don't count R_MIPS_GOT_PAGE because we can estimate the
+	     maximum number of pages needed by looking at the size of
+	     the segment.  Similar comments apply to R_MIPS_GOT16 and
+	     R_MIPS_CALL16.  We don't count R_MIPS_GOT_HI16, or
+	     R_MIPS_CALL_HI16 because these are always followed by an
+	     R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16.
+
+	     This estimation is very conservative since we can merge
+	     duplicate entries in the GOT.  In order to be less
+	     conservative, we could actually build the GOT here,
+	     rather than in relocate_section.  */
+	  g->local_gotno++;
+	  sgot->_raw_size += MIPS_ELF_GOT_SIZE (dynobj);
+	}
+
+      switch (r_type)
+	{
+	case R_MIPS_CALL16:
+	  if (h == NULL)
+	    {
+	      (*_bfd_error_handler)
+		(_("%s: CALL16 reloc at 0x%lx not against global symbol"),
+		 bfd_archive_filename (abfd), (unsigned long) rel->r_offset);
+	      bfd_set_error (bfd_error_bad_value);
+	      return false;
+	    }
+	  /* Fall through.  */
+
+	case R_MIPS_CALL_HI16:
+	case R_MIPS_CALL_LO16:
+	  if (h != NULL)
+	    {
+	      /* This symbol requires a global offset table entry.  */
+	      if (! mips_elf_record_global_got_symbol (h, info, g))
+		return false;
+
+	      /* We need a stub, not a plt entry for the undefined
+		 function.  But we record it as if it needs plt.  See
+		 elf_adjust_dynamic_symbol in elflink.h.  */
+	      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+	      h->type = STT_FUNC;
+	    }
+	  break;
+
+	case R_MIPS_GOT16:
+	case R_MIPS_GOT_HI16:
+	case R_MIPS_GOT_LO16:
+	case R_MIPS_GOT_DISP:
+	  /* This symbol requires a global offset table entry.  */
+	  if (h && ! mips_elf_record_global_got_symbol (h, info, g))
+	    return false;
+	  break;
+
+	case R_MIPS_32:
+	case R_MIPS_REL32:
+	case R_MIPS_64:
+	  if ((info->shared || h != NULL)
+	      && (sec->flags & SEC_ALLOC) != 0)
+	    {
+	      if (sreloc == NULL)
+		{
+		  const char *dname = ".rel.dyn";
+
+		  sreloc = bfd_get_section_by_name (dynobj, dname);
+		  if (sreloc == NULL)
+		    {
+		      sreloc = bfd_make_section (dynobj, dname);
+		      if (sreloc == NULL
+			  || ! bfd_set_section_flags (dynobj, sreloc,
+						      (SEC_ALLOC
+						       | SEC_LOAD
+						       | SEC_HAS_CONTENTS
+						       | SEC_IN_MEMORY
+						       | SEC_LINKER_CREATED
+						       | SEC_READONLY))
+			  || ! bfd_set_section_alignment (dynobj, sreloc,
+							  4))
+			return false;
+		    }
+		}
+#define MIPS_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
+	      if (info->shared)
+		{
+		  /* When creating a shared object, we must copy these
+		     reloc types into the output file as R_MIPS_REL32
+		     relocs.  We make room for this reloc in the
+		     .rel.dyn reloc section.  */
+		  mips_elf_allocate_dynamic_relocations (dynobj, 1);
+		  if ((sec->flags & MIPS_READONLY_SECTION)
+		      == MIPS_READONLY_SECTION)
+		    /* We tell the dynamic linker that there are
+		       relocations against the text segment.  */
+		    info->flags |= DF_TEXTREL;
+		}
+	      else
+		{
+		  struct mips_elf_link_hash_entry *hmips;
+
+		  /* We only need to copy this reloc if the symbol is
+                     defined in a dynamic object.  */
+		  hmips = (struct mips_elf_link_hash_entry *) h;
+		  ++hmips->possibly_dynamic_relocs;
+		  if ((sec->flags & MIPS_READONLY_SECTION)
+		      == MIPS_READONLY_SECTION)
+		    /* We need it to tell the dynamic linker if there
+		       are relocations against the text segment.  */
+		    hmips->readonly_reloc = true;
+		}
+
+	      /* Even though we don't directly need a GOT entry for
+		 this symbol, a symbol must have a dynamic symbol
+		 table index greater that DT_MIPS_GOTSYM if there are
+		 dynamic relocations against it.  */
+	      if (h != NULL
+		  && ! mips_elf_record_global_got_symbol (h, info, g))
+		return false;
+	    }
+
+	  if (SGI_COMPAT (abfd))
+	    mips_elf_hash_table (info)->compact_rel_size +=
+	      sizeof (Elf32_External_crinfo);
+	  break;
+
+	case R_MIPS_26:
+	case R_MIPS_GPREL16:
+	case R_MIPS_LITERAL:
+	case R_MIPS_GPREL32:
+	  if (SGI_COMPAT (abfd))
+	    mips_elf_hash_table (info)->compact_rel_size +=
+	      sizeof (Elf32_External_crinfo);
+	  break;
+
+	  /* This relocation describes the C++ object vtable hierarchy.
+	     Reconstruct it for later use during GC.  */
+	case R_MIPS_GNU_VTINHERIT:
+	  if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+	    return false;
+	  break;
+
+	  /* This relocation describes which C++ vtable entries are actually
+	     used.  Record for later use during GC.  */
+	case R_MIPS_GNU_VTENTRY:
+	  if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+	    return false;
+	  break;
+
+	default:
+	  break;
+	}
+
+      /* We must not create a stub for a symbol that has relocations
+         related to taking the function's address.  */
+      switch (r_type)
+	{
+	default:
+	  if (h != NULL)
+	    {
+	      struct mips_elf_link_hash_entry *mh;
+
+	      mh = (struct mips_elf_link_hash_entry *) h;
+	      mh->no_fn_stub = true;
+	    }
+	  break;
+	case R_MIPS_CALL16:
+	case R_MIPS_CALL_HI16:
+	case R_MIPS_CALL_LO16:
+	  break;
+	}
+
+      /* If this reloc is not a 16 bit call, and it has a global
+         symbol, then we will need the fn_stub if there is one.
+         References from a stub section do not count.  */
+      if (h != NULL
+	  && r_type != R_MIPS16_26
+	  && strncmp (bfd_get_section_name (abfd, sec), FN_STUB,
+		      sizeof FN_STUB - 1) != 0
+	  && strncmp (bfd_get_section_name (abfd, sec), CALL_STUB,
+		      sizeof CALL_STUB - 1) != 0
+	  && strncmp (bfd_get_section_name (abfd, sec), CALL_FP_STUB,
+		      sizeof CALL_FP_STUB - 1) != 0)
+	{
+	  struct mips_elf_link_hash_entry *mh;
+
+	  mh = (struct mips_elf_link_hash_entry *) h;
+	  mh->need_fn_stub = true;
+	}
+    }
+
+  return true;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+   regular object.  The current definition is in some section of the
+   dynamic object, but we're not including those sections.  We have to
+   change the definition to something the rest of the link can
+   understand.  */
+
+boolean
+_bfd_mips_elf_adjust_dynamic_symbol (info, h)
+     struct bfd_link_info *info;
+     struct elf_link_hash_entry *h;
+{
+  bfd *dynobj;
+  struct mips_elf_link_hash_entry *hmips;
+  asection *s;
+
+  dynobj = elf_hash_table (info)->dynobj;
+
+  /* Make sure we know what is going on here.  */
+  BFD_ASSERT (dynobj != NULL
+	      && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+		  || h->weakdef != NULL
+		  || ((h->elf_link_hash_flags
+		       & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+		      && (h->elf_link_hash_flags
+			  & ELF_LINK_HASH_REF_REGULAR) != 0
+		      && (h->elf_link_hash_flags
+			  & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+
+  /* If this symbol is defined in a dynamic object, we need to copy
+     any R_MIPS_32 or R_MIPS_REL32 relocs against it into the output
+     file.  */
+  hmips = (struct mips_elf_link_hash_entry *) h;
+  if (! info->relocateable
+      && hmips->possibly_dynamic_relocs != 0
+      && (h->root.type == bfd_link_hash_defweak
+	  || (h->elf_link_hash_flags
+	      & ELF_LINK_HASH_DEF_REGULAR) == 0))
+    {
+      mips_elf_allocate_dynamic_relocations (dynobj,
+					     hmips->possibly_dynamic_relocs);
+      if (hmips->readonly_reloc)
+	/* We tell the dynamic linker that there are relocations
+	   against the text segment.  */
+	info->flags |= DF_TEXTREL;
+    }
+
+  /* For a function, create a stub, if allowed.  */
+  if (! hmips->no_fn_stub
+      && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+    {
+      if (! elf_hash_table (info)->dynamic_sections_created)
+	return true;
+
+      /* If this symbol is not defined in a regular file, then set
+	 the symbol to the stub location.  This is required to make
+	 function pointers compare as equal between the normal
+	 executable and the shared library.  */
+      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+	{
+	  /* We need .stub section.  */
+	  s = bfd_get_section_by_name (dynobj,
+				       MIPS_ELF_STUB_SECTION_NAME (dynobj));
+	  BFD_ASSERT (s != NULL);
+
+	  h->root.u.def.section = s;
+	  h->root.u.def.value = s->_raw_size;
+
+	  /* XXX Write this stub address somewhere.  */
+	  h->plt.offset = s->_raw_size;
+
+	  /* Make room for this stub code.  */
+	  s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
+
+	  /* The last half word of the stub will be filled with the index
+	     of this symbol in .dynsym section.  */
+	  return true;
+	}
+    }
+  else if ((h->type == STT_FUNC)
+	   && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
+    {
+      /* This will set the entry for this symbol in the GOT to 0, and
+         the dynamic linker will take care of this.  */
+      h->root.u.def.value = 0;
+      return true;
+    }
+
+  /* If this is a weak symbol, and there is a real definition, the
+     processor independent code will have arranged for us to see the
+     real definition first, and we can just use the same value.  */
+  if (h->weakdef != NULL)
+    {
+      BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+		  || h->weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->weakdef->root.u.def.section;
+      h->root.u.def.value = h->weakdef->root.u.def.value;
+      return true;
+    }
+
+  /* This is a reference to a symbol defined by a dynamic object which
+     is not a function.  */
+
+  return true;
+}
+
+/* This function is called after all the input files have been read,
+   and the input sections have been assigned to output sections.  We
+   check for any mips16 stub sections that we can discard.  */
+
+boolean
+_bfd_mips_elf_always_size_sections (output_bfd, info)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+{
+  asection *ri;
+
+  /* The .reginfo section has a fixed size.  */
+  ri = bfd_get_section_by_name (output_bfd, ".reginfo");
+  if (ri != NULL)
+    bfd_set_section_size (output_bfd, ri,
+			  (bfd_size_type) sizeof (Elf32_External_RegInfo));
+
+  if (info->relocateable
+      || ! mips_elf_hash_table (info)->mips16_stubs_seen)
+    return true;
+
+  mips_elf_link_hash_traverse (mips_elf_hash_table (info),
+			       mips_elf_check_mips16_stubs,
+			       (PTR) NULL);
+
+  return true;
+}
+
+/* Set the sizes of the dynamic sections.  */
+
+boolean
+_bfd_mips_elf_size_dynamic_sections (output_bfd, info)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+{
+  bfd *dynobj;
+  asection *s;
+  boolean reltext;
+  struct mips_got_info *g = NULL;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  BFD_ASSERT (dynobj != NULL);
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      /* Set the contents of the .interp section to the interpreter.  */
+      if (! info->shared)
+	{
+	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  BFD_ASSERT (s != NULL);
+	  s->_raw_size
+	    = strlen (ELF_DYNAMIC_INTERPRETER (output_bfd)) + 1;
+	  s->contents
+	    = (bfd_byte *) ELF_DYNAMIC_INTERPRETER (output_bfd);
+	}
+    }
+
+  /* The check_relocs and adjust_dynamic_symbol entry points have
+     determined the sizes of the various dynamic sections.  Allocate
+     memory for them.  */
+  reltext = false;
+  for (s = dynobj->sections; s != NULL; s = s->next)
+    {
+      const char *name;
+      boolean strip;
+
+      /* It's OK to base decisions on the section name, because none
+	 of the dynobj section names depend upon the input files.  */
+      name = bfd_get_section_name (dynobj, s);
+
+      if ((s->flags & SEC_LINKER_CREATED) == 0)
+	continue;
+
+      strip = false;
+
+      if (strncmp (name, ".rel", 4) == 0)
+	{
+	  if (s->_raw_size == 0)
+	    {
+	      /* We only strip the section if the output section name
+                 has the same name.  Otherwise, there might be several
+                 input sections for this output section.  FIXME: This
+                 code is probably not needed these days anyhow, since
+                 the linker now does not create empty output sections.  */
+	      if (s->output_section != NULL
+		  && strcmp (name,
+			     bfd_get_section_name (s->output_section->owner,
+						   s->output_section)) == 0)
+		strip = true;
+	    }
+	  else
+	    {
+	      const char *outname;
+	      asection *target;
+
+	      /* If this relocation section applies to a read only
+                 section, then we probably need a DT_TEXTREL entry.
+                 If the relocation section is .rel.dyn, we always
+                 assert a DT_TEXTREL entry rather than testing whether
+                 there exists a relocation to a read only section or
+                 not.  */
+	      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
+		   && (target->flags & SEC_ALLOC) != 0)
+		  || strcmp (outname, ".rel.dyn") == 0)
+		reltext = true;
+
+	      /* We use the reloc_count field as a counter if we need
+		 to copy relocs into the output file.  */
+	      if (strcmp (name, ".rel.dyn") != 0)
+		s->reloc_count = 0;
+	    }
+	}
+      else if (strncmp (name, ".got", 4) == 0)
+	{
+	  int i;
+	  bfd_size_type loadable_size = 0;
+	  bfd_size_type local_gotno;
+	  bfd *sub;
+
+	  BFD_ASSERT (elf_section_data (s) != NULL);
+	  g = (struct mips_got_info *) elf_section_data (s)->tdata;
+	  BFD_ASSERT (g != NULL);
+
+	  /* Calculate the total loadable size of the output.  That
+	     will give us the maximum number of GOT_PAGE entries
+	     required.  */
+	  for (sub = info->input_bfds; sub; sub = sub->link_next)
+	    {
+	      asection *subsection;
+
+	      for (subsection = sub->sections;
+		   subsection;
+		   subsection = subsection->next)
+		{
+		  if ((subsection->flags & SEC_ALLOC) == 0)
+		    continue;
+		  loadable_size += ((subsection->_raw_size + 0xf)
+				    &~ (bfd_size_type) 0xf);
+		}
+	    }
+	  loadable_size += MIPS_FUNCTION_STUB_SIZE;
+
+	  /* Assume there are two loadable segments consisting of
+	     contiguous sections.  Is 5 enough?  */
+	  local_gotno = (loadable_size >> 16) + 5;
+	  if (IRIX_COMPAT (output_bfd) == ict_irix6)
+	    /* It's possible we will need GOT_PAGE entries as well as
+	       GOT16 entries.  Often, these will be able to share GOT
+	       entries, but not always.  */
+	    local_gotno *= 2;
+
+	  g->local_gotno += local_gotno;
+	  s->_raw_size += local_gotno * MIPS_ELF_GOT_SIZE (dynobj);
+
+	  /* There has to be a global GOT entry for every symbol with
+	     a dynamic symbol table index of DT_MIPS_GOTSYM or
+	     higher.  Therefore, it make sense to put those symbols
+	     that need GOT entries at the end of the symbol table.  We
+	     do that here.  */
+ 	  if (! mips_elf_sort_hash_table (info, 1))
+ 	    return false;
+
+	  if (g->global_gotsym != NULL)
+	    i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx;
+	  else
+	    /* If there are no global symbols, or none requiring
+	       relocations, then GLOBAL_GOTSYM will be NULL.  */
+	    i = 0;
+	  g->global_gotno = i;
+	  s->_raw_size += i * MIPS_ELF_GOT_SIZE (dynobj);
+	}
+      else if (strcmp (name, MIPS_ELF_STUB_SECTION_NAME (output_bfd)) == 0)
+	{
+	  /* Irix rld assumes that the function stub isn't at the end
+	     of .text section. So put a dummy. XXX  */
+	  s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
+	}
+      else if (! info->shared
+	       && ! mips_elf_hash_table (info)->use_rld_obj_head
+	       && strncmp (name, ".rld_map", 8) == 0)
+	{
+	  /* We add a room for __rld_map. It will be filled in by the
+	     rtld to contain a pointer to the _r_debug structure.  */
+	  s->_raw_size += 4;
+	}
+      else if (SGI_COMPAT (output_bfd)
+	       && strncmp (name, ".compact_rel", 12) == 0)
+	s->_raw_size += mips_elf_hash_table (info)->compact_rel_size;
+      else if (strcmp (name, ".msym") == 0)
+	s->_raw_size = (sizeof (Elf32_External_Msym)
+			* (elf_hash_table (info)->dynsymcount
+			   + bfd_count_sections (output_bfd)));
+      else if (strncmp (name, ".init", 5) != 0)
+	{
+	  /* It's not one of our sections, so don't allocate space.  */
+	  continue;
+	}
+
+      if (strip)
+	{
+	  _bfd_strip_section_from_output (info, s);
+	  continue;
+	}
+
+      /* Allocate memory for the section contents.  */
+      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
+      if (s->contents == NULL && s->_raw_size != 0)
+	{
+	  bfd_set_error (bfd_error_no_memory);
+	  return false;
+	}
+    }
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      /* Add some entries to the .dynamic section.  We fill in the
+	 values later, in _bfd_mips_elf_finish_dynamic_sections, but we
+	 must add the entries now so that we get the correct size for
+	 the .dynamic section.  The DT_DEBUG entry is filled in by the
+	 dynamic linker and used by the debugger.  */
+      if (! info->shared)
+	{
+	  /* SGI object has the equivalence of DT_DEBUG in the
+	     DT_MIPS_RLD_MAP entry.  */
+	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
+	    return false;
+	  if (!SGI_COMPAT (output_bfd))
+	    {
+	      if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
+		return false;
+	    }
+	}
+      else
+	{
+	  /* Shared libraries on traditional mips have DT_DEBUG.  */
+	  if (!SGI_COMPAT (output_bfd))
+	    {
+	      if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
+		return false;
+	    }
+	}
+
+      if (reltext && SGI_COMPAT (output_bfd))
+	info->flags |= DF_TEXTREL;
+
+      if ((info->flags & DF_TEXTREL) != 0)
+	{
+	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0))
+	    return false;
+	}
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTGOT, 0))
+	return false;
+
+      if (bfd_get_section_by_name (dynobj, ".rel.dyn"))
+	{
+	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0))
+	    return false;
+
+	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0))
+	    return false;
+
+	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0))
+	    return false;
+	}
+
+      if (SGI_COMPAT (output_bfd))
+	{
+	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICTNO, 0))
+	    return false;
+	}
+
+      if (SGI_COMPAT (output_bfd))
+	{
+	  if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLISTNO, 0))
+	    return false;
+	}
+
+      if (bfd_get_section_by_name (dynobj, ".conflict") != NULL)
+	{
+	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICT, 0))
+	    return false;
+
+	  s = bfd_get_section_by_name (dynobj, ".liblist");
+	  BFD_ASSERT (s != NULL);
+
+	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLIST, 0))
+	    return false;
+	}
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_VERSION, 0))
+	return false;
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_FLAGS, 0))
+	return false;
+
+#if 0
+      /* Time stamps in executable files are a bad idea.  */
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_TIME_STAMP, 0))
+	return false;
+#endif
+
+#if 0 /* FIXME  */
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_ICHECKSUM, 0))
+	return false;
+#endif
+
+#if 0 /* FIXME  */
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_IVERSION, 0))
+	return false;
+#endif
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_BASE_ADDRESS, 0))
+	return false;
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LOCAL_GOTNO, 0))
+	return false;
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_SYMTABNO, 0))
+	return false;
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_UNREFEXTNO, 0))
+	return false;
+
+      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_GOTSYM, 0))
+	return false;
+
+      if (IRIX_COMPAT (dynobj) == ict_irix5
+	  && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0))
+	return false;
+
+      if (IRIX_COMPAT (dynobj) == ict_irix6
+	  && (bfd_get_section_by_name
+	      (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
+	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
+	return false;
+
+      if (bfd_get_section_by_name (dynobj, ".msym")
+	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_MSYM, 0))
+	return false;
+    }
+
+  return true;
+}
+
+/* Relocate a MIPS ELF section.  */
+
+boolean
+_bfd_mips_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_Rela *rel;
+  const Elf_Internal_Rela *relend;
+  bfd_vma addend = 0;
+  boolean use_saved_addend_p = false;
+  struct elf_backend_data *bed;
+
+  bed = get_elf_backend_data (output_bfd);
+  relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+  for (rel = relocs; rel < relend; ++rel)
+    {
+      const char *name;
+      bfd_vma value;
+      reloc_howto_type *howto;
+      boolean require_jalx;
+      /* True if the relocation is a RELA relocation, rather than a
+         REL relocation.  */
+      boolean rela_relocation_p = true;
+      unsigned int r_type = ELF_R_TYPE (output_bfd, rel->r_info);
+      const char * msg = (const char *) NULL;
+
+      /* Find the relocation howto for this relocation.  */
+      if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
+	{
+	  /* Some 32-bit code uses R_MIPS_64.  In particular, people use
+	     64-bit code, but make sure all their addresses are in the
+	     lowermost or uppermost 32-bit section of the 64-bit address
+	     space.  Thus, when they use an R_MIPS_64 they mean what is
+	     usually meant by R_MIPS_32, with the exception that the
+	     stored value is sign-extended to 64 bits.  */
+	  howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, R_MIPS_32,
+					   NEWABI_P (input_bfd));
+
+	  /* On big-endian systems, we need to lie about the position
+	     of the reloc.  */
+	  if (bfd_big_endian (input_bfd))
+	    rel->r_offset += 4;
+	}
+      else
+	/* NewABI defaults to RELA relocations.  */
+	howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, r_type,
+					 NEWABI_P (input_bfd));
+
+      if (!use_saved_addend_p)
+	{
+	  Elf_Internal_Shdr *rel_hdr;
+
+	  /* If these relocations were originally of the REL variety,
+	     we must pull the addend out of the field that will be
+	     relocated.  Otherwise, we simply use the contents of the
+	     RELA relocation.  To determine which flavor or relocation
+	     this is, we depend on the fact that the INPUT_SECTION's
+	     REL_HDR is read before its REL_HDR2.  */
+	  rel_hdr = &elf_section_data (input_section)->rel_hdr;
+	  if ((size_t) (rel - relocs)
+	      >= (NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel))
+	    rel_hdr = elf_section_data (input_section)->rel_hdr2;
+	  if (rel_hdr->sh_entsize == MIPS_ELF_REL_SIZE (input_bfd))
+	    {
+	      /* Note that this is a REL relocation.  */
+	      rela_relocation_p = false;
+
+	      /* Get the addend, which is stored in the input file.  */
+	      addend = mips_elf_obtain_contents (howto, rel, input_bfd,
+						 contents);
+	      addend &= howto->src_mask;
+
+	      /* For some kinds of relocations, the ADDEND is a
+		 combination of the addend stored in two different
+		 relocations.   */
+	      if (r_type == R_MIPS_HI16
+		  || r_type == R_MIPS_GNU_REL_HI16
+		  || (r_type == R_MIPS_GOT16
+		      && mips_elf_local_relocation_p (input_bfd, rel,
+						      local_sections, false)))
+		{
+		  bfd_vma l;
+		  const Elf_Internal_Rela *lo16_relocation;
+		  reloc_howto_type *lo16_howto;
+		  unsigned int lo;
+
+		  /* The combined value is the sum of the HI16 addend,
+		     left-shifted by sixteen bits, and the LO16
+		     addend, sign extended.  (Usually, the code does
+		     a `lui' of the HI16 value, and then an `addiu' of
+		     the LO16 value.)
+
+		     Scan ahead to find a matching LO16 relocation.  */
+		  if (r_type == R_MIPS_GNU_REL_HI16)
+		    lo = R_MIPS_GNU_REL_LO16;
+		  else
+		    lo = R_MIPS_LO16;
+		  lo16_relocation = mips_elf_next_relocation (input_bfd, lo,
+							      rel, relend);
+		  if (lo16_relocation == NULL)
+		    return false;
+
+		  /* Obtain the addend kept there.  */
+		  lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, lo,
+							rela_relocation_p);
+		  l = mips_elf_obtain_contents (lo16_howto, lo16_relocation,
+						input_bfd, contents);
+		  l &= lo16_howto->src_mask;
+		  l = mips_elf_sign_extend (l, 16);
+
+		  addend <<= 16;
+
+		  /* Compute the combined addend.  */
+		  addend += l;
+
+		  /* If PC-relative, subtract the difference between the
+		     address of the LO part of the reloc and the address of
+		     the HI part.  The relocation is relative to the LO
+		     part, but mips_elf_calculate_relocation() doesn't
+		     know its address or the difference from the HI part, so
+		     we subtract that difference here.  See also the
+		     comment in mips_elf_calculate_relocation().  */
+		  if (r_type == R_MIPS_GNU_REL_HI16)
+		    addend -= (lo16_relocation->r_offset - rel->r_offset);
+		}
+	      else if (r_type == R_MIPS16_GPREL)
+		{
+		  /* The addend is scrambled in the object file.  See
+		     mips_elf_perform_relocation for details on the
+		     format.  */
+		  addend = (((addend & 0x1f0000) >> 5)
+			    | ((addend & 0x7e00000) >> 16)
+			    | (addend & 0x1f));
+		}
+	    }
+	  else
+	    addend = rel->r_addend;
+	}
+
+      if (info->relocateable)
+	{
+	  Elf_Internal_Sym *sym;
+	  unsigned long r_symndx;
+
+	  if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd)
+	      && bfd_big_endian (input_bfd))
+	    rel->r_offset -= 4;
+
+	  /* Since we're just relocating, all we need to do is copy
+	     the relocations back out to the object file, unless
+	     they're against a section symbol, in which case we need
+	     to adjust by the section offset, or unless they're GP
+	     relative in which case we need to adjust by the amount
+	     that we're adjusting GP in this relocateable object.  */
+
+	  if (! mips_elf_local_relocation_p (input_bfd, rel, local_sections,
+					     false))
+	    /* There's nothing to do for non-local relocations.  */
+	    continue;
+
+	  if (r_type == R_MIPS16_GPREL
+	      || r_type == R_MIPS_GPREL16
+	      || r_type == R_MIPS_GPREL32
+	      || r_type == R_MIPS_LITERAL)
+	    addend -= (_bfd_get_gp_value (output_bfd)
+		       - _bfd_get_gp_value (input_bfd));
+	  else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26
+		   || r_type == R_MIPS_GNU_REL16_S2)
+	    /* The addend is stored without its two least
+	       significant bits (which are always zero.)  In a
+	       non-relocateable link, calculate_relocation will do
+	       this shift; here, we must do it ourselves.  */
+	    addend <<= 2;
+
+	  r_symndx = ELF_R_SYM (output_bfd, rel->r_info);
+	  sym = local_syms + r_symndx;
+	  if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	    /* Adjust the addend appropriately.  */
+	    addend += local_sections[r_symndx]->output_offset;
+
+	  /* If the relocation is for a R_MIPS_HI16 or R_MIPS_GOT16,
+	     then we only want to write out the high-order 16 bits.
+	     The subsequent R_MIPS_LO16 will handle the low-order bits.  */
+	  if (r_type == R_MIPS_HI16 || r_type == R_MIPS_GOT16
+	      || r_type == R_MIPS_GNU_REL_HI16)
+	    addend = mips_elf_high (addend);
+	  else if (r_type == R_MIPS_HIGHER)
+	    addend = mips_elf_higher (addend);
+	  else if (r_type == R_MIPS_HIGHEST)
+	    addend = mips_elf_highest (addend);
+
+	  /* If the relocation is for an R_MIPS_26 relocation, then
+	     the two low-order bits are not stored in the object file;
+	     they are implicitly zero.  */
+	  else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26
+		   || r_type == R_MIPS_GNU_REL16_S2)
+	    addend >>= 2;
+
+	  if (rela_relocation_p)
+	    /* If this is a RELA relocation, just update the addend.
+	       We have to cast away constness for REL.  */
+	    rel->r_addend = addend;
+	  else
+	    {
+	      /* Otherwise, we have to write the value back out.  Note
+		 that we use the source mask, rather than the
+		 destination mask because the place to which we are
+		 writing will be source of the addend in the final
+		 link.  */
+	      addend &= howto->src_mask;
+
+	      if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
+		/* See the comment above about using R_MIPS_64 in the 32-bit
+		   ABI.  Here, we need to update the addend.  It would be
+		   possible to get away with just using the R_MIPS_32 reloc
+		   but for endianness.  */
+		{
+		  bfd_vma sign_bits;
+		  bfd_vma low_bits;
+		  bfd_vma high_bits;
+
+		  if (addend & ((bfd_vma) 1 << 31))
+#ifdef BFD64
+		    sign_bits = ((bfd_vma) 1 << 32) - 1;
+#else
+		    sign_bits = -1;
+#endif
+		  else
+		    sign_bits = 0;
+
+		  /* If we don't know that we have a 64-bit type,
+		     do two separate stores.  */
+		  if (bfd_big_endian (input_bfd))
+		    {
+		      /* Store the sign-bits (which are most significant)
+			 first.  */
+		      low_bits = sign_bits;
+		      high_bits = addend;
+		    }
+		  else
+		    {
+		      low_bits = addend;
+		      high_bits = sign_bits;
+		    }
+		  bfd_put_32 (input_bfd, low_bits,
+			      contents + rel->r_offset);
+		  bfd_put_32 (input_bfd, high_bits,
+			      contents + rel->r_offset + 4);
+		  continue;
+		}
+
+	      if (! mips_elf_perform_relocation (info, howto, rel, addend,
+						 input_bfd, input_section,
+						 contents, false))
+		return false;
+	    }
+
+	  /* Go on to the next relocation.  */
+	  continue;
+	}
+
+      /* In the N32 and 64-bit ABIs there may be multiple consecutive
+	 relocations for the same offset.  In that case we are
+	 supposed to treat the output of each relocation as the addend
+	 for the next.  */
+      if (rel + 1 < relend
+	  && rel->r_offset == rel[1].r_offset
+	  && ELF_R_TYPE (input_bfd, rel[1].r_info) != R_MIPS_NONE)
+	use_saved_addend_p = true;
+      else
+	use_saved_addend_p = false;
+
+      /* Figure out what value we are supposed to relocate.  */
+      switch (mips_elf_calculate_relocation (output_bfd, input_bfd,
+					     input_section, info, rel,
+					     addend, howto, local_syms,
+					     local_sections, &value,
+					     &name, &require_jalx))
+	{
+	case bfd_reloc_continue:
+	  /* There's nothing to do.  */
+	  continue;
+
+	case bfd_reloc_undefined:
+	  /* mips_elf_calculate_relocation already called the
+	     undefined_symbol callback.  There's no real point in
+	     trying to perform the relocation at this point, so we
+	     just skip ahead to the next relocation.  */
+	  continue;
+
+	case bfd_reloc_notsupported:
+	  msg = _("internal error: unsupported relocation error");
+	  info->callbacks->warning
+	    (info, msg, name, input_bfd, input_section, rel->r_offset);
+	  return false;
+
+	case bfd_reloc_overflow:
+	  if (use_saved_addend_p)
+	    /* Ignore overflow until we reach the last relocation for
+	       a given location.  */
+	    ;
+	  else
+	    {
+	      BFD_ASSERT (name != NULL);
+	      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_ok:
+	  break;
+
+	default:
+	  abort ();
+	  break;
+	}
+
+      /* If we've got another relocation for the address, keep going
+	 until we reach the last one.  */
+      if (use_saved_addend_p)
+	{
+	  addend = value;
+	  continue;
+	}
+
+      if (r_type == R_MIPS_64 && !ABI_64_P (output_bfd))
+	/* See the comment above about using R_MIPS_64 in the 32-bit
+	   ABI.  Until now, we've been using the HOWTO for R_MIPS_32;
+	   that calculated the right value.  Now, however, we
+	   sign-extend the 32-bit result to 64-bits, and store it as a
+	   64-bit value.  We are especially generous here in that we
+	   go to extreme lengths to support this usage on systems with
+	   only a 32-bit VMA.  */
+	{
+	  bfd_vma sign_bits;
+	  bfd_vma low_bits;
+	  bfd_vma high_bits;
+
+	  if (value & ((bfd_vma) 1 << 31))
+#ifdef BFD64
+	    sign_bits = ((bfd_vma) 1 << 32) - 1;
+#else
+	    sign_bits = -1;
+#endif
+	  else
+	    sign_bits = 0;
+
+	  /* If we don't know that we have a 64-bit type,
+	     do two separate stores.  */
+	  if (bfd_big_endian (input_bfd))
+	    {
+	      /* Undo what we did above.  */
+	      rel->r_offset -= 4;
+	      /* Store the sign-bits (which are most significant)
+		 first.  */
+	      low_bits = sign_bits;
+	      high_bits = value;
+	    }
+	  else
+	    {
+	      low_bits = value;
+	      high_bits = sign_bits;
+	    }
+	  bfd_put_32 (input_bfd, low_bits,
+		      contents + rel->r_offset);
+	  bfd_put_32 (input_bfd, high_bits,
+		      contents + rel->r_offset + 4);
+	  continue;
+	}
+
+      /* Actually perform the relocation.  */
+      if (! mips_elf_perform_relocation (info, howto, rel, value,
+					 input_bfd, input_section,
+					 contents, require_jalx))
+	return false;
+    }
+
+  return true;
+}
+
+/* If NAME is one of the special IRIX6 symbols defined by the linker,
+   adjust it appropriately now.  */
+
+static void
+mips_elf_irix6_finish_dynamic_symbol (abfd, name, sym)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     const char *name;
+     Elf_Internal_Sym *sym;
+{
+  /* The linker script takes care of providing names and values for
+     these, but we must place them into the right sections.  */
+  static const char* const text_section_symbols[] = {
+    "_ftext",
+    "_etext",
+    "__dso_displacement",
+    "__elf_header",
+    "__program_header_table",
+    NULL
+  };
+
+  static const char* const data_section_symbols[] = {
+    "_fdata",
+    "_edata",
+    "_end",
+    "_fbss",
+    NULL
+  };
+
+  const char* const *p;
+  int i;
+
+  for (i = 0; i < 2; ++i)
+    for (p = (i == 0) ? text_section_symbols : data_section_symbols;
+	 *p;
+	 ++p)
+      if (strcmp (*p, name) == 0)
+	{
+	  /* All of these symbols are given type STT_SECTION by the
+	     IRIX6 linker.  */
+	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+
+	  /* The IRIX linker puts these symbols in special sections.  */
+	  if (i == 0)
+	    sym->st_shndx = SHN_MIPS_TEXT;
+	  else
+	    sym->st_shndx = SHN_MIPS_DATA;
+
+	  break;
+	}
+}
+
+/* Finish up dynamic symbol handling.  We set the contents of various
+   dynamic sections here.  */
+
+boolean
+_bfd_mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+     struct elf_link_hash_entry *h;
+     Elf_Internal_Sym *sym;
+{
+  bfd *dynobj;
+  bfd_vma gval;
+  asection *sgot;
+  asection *smsym;
+  struct mips_got_info *g;
+  const char *name;
+  struct mips_elf_link_hash_entry *mh;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  gval = sym->st_value;
+  mh = (struct mips_elf_link_hash_entry *) h;
+
+  if (h->plt.offset != (bfd_vma) -1)
+    {
+      asection *s;
+      bfd_byte stub[MIPS_FUNCTION_STUB_SIZE];
+
+      /* This symbol has a stub.  Set it up.  */
+
+      BFD_ASSERT (h->dynindx != -1);
+
+      s = bfd_get_section_by_name (dynobj,
+				   MIPS_ELF_STUB_SECTION_NAME (dynobj));
+      BFD_ASSERT (s != NULL);
+
+      /* FIXME: Can h->dynindex be more than 64K?  */
+      if (h->dynindx & 0xffff0000)
+	return false;
+
+      /* Fill the stub.  */
+      bfd_put_32 (output_bfd, STUB_LW (output_bfd), stub);
+      bfd_put_32 (output_bfd, STUB_MOVE (output_bfd), stub + 4);
+      bfd_put_32 (output_bfd, STUB_JALR, stub + 8);
+      bfd_put_32 (output_bfd, STUB_LI16 (output_bfd) + h->dynindx, stub + 12);
+
+      BFD_ASSERT (h->plt.offset <= s->_raw_size);
+      memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
+
+      /* Mark the symbol as undefined.  plt.offset != -1 occurs
+	 only for the referenced symbol.  */
+      sym->st_shndx = SHN_UNDEF;
+
+      /* The run-time linker uses the st_value field of the symbol
+	 to reset the global offset table entry for this external
+	 to its stub address when unlinking a shared object.  */
+      gval = s->output_section->vma + s->output_offset + h->plt.offset;
+      sym->st_value = gval;
+    }
+
+  BFD_ASSERT (h->dynindx != -1
+	      || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0);
+
+  sgot = mips_elf_got_section (dynobj);
+  BFD_ASSERT (sgot != NULL);
+  BFD_ASSERT (elf_section_data (sgot) != NULL);
+  g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+  BFD_ASSERT (g != NULL);
+
+  /* Run through the global symbol table, creating GOT entries for all
+     the symbols that need them.  */
+  if (g->global_gotsym != NULL
+      && h->dynindx >= g->global_gotsym->dynindx)
+    {
+      bfd_vma offset;
+      bfd_vma value;
+
+      if (sym->st_value)
+	value = sym->st_value;
+      else
+	{
+	  /* For an entity defined in a shared object, this will be
+	     NULL.  (For functions in shared objects for
+	     which we have created stubs, ST_VALUE will be non-NULL.
+	     That's because such the functions are now no longer defined
+	     in a shared object.)  */
+
+	  if (info->shared && h->root.type == bfd_link_hash_undefined)
+	    value = 0;
+	  else
+	    value = h->root.u.def.value;
+	}
+      offset = mips_elf_global_got_index (dynobj, h);
+      MIPS_ELF_PUT_WORD (output_bfd, value, sgot->contents + offset);
+    }
+
+  /* Create a .msym entry, if appropriate.  */
+  smsym = bfd_get_section_by_name (dynobj, ".msym");
+  if (smsym)
+    {
+      Elf32_Internal_Msym msym;
+
+      msym.ms_hash_value = bfd_elf_hash (h->root.root.string);
+      /* It is undocumented what the `1' indicates, but IRIX6 uses
+	 this value.  */
+      msym.ms_info = ELF32_MS_INFO (mh->min_dyn_reloc_index, 1);
+      bfd_mips_elf_swap_msym_out
+	(dynobj, &msym,
+	 ((Elf32_External_Msym *) smsym->contents) + h->dynindx);
+    }
+
+  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
+  name = h->root.root.string;
+  if (strcmp (name, "_DYNAMIC") == 0
+      || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+    sym->st_shndx = SHN_ABS;
+  else if (strcmp (name, "_DYNAMIC_LINK") == 0
+	   || strcmp (name, "_DYNAMIC_LINKING") == 0)
+    {
+      sym->st_shndx = SHN_ABS;
+      sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+      sym->st_value = 1;
+    }
+  else if (strcmp (name, "_gp_disp") == 0)
+    {
+      sym->st_shndx = SHN_ABS;
+      sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+      sym->st_value = elf_gp (output_bfd);
+    }
+  else if (SGI_COMPAT (output_bfd))
+    {
+      if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
+	  || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
+	{
+	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+	  sym->st_other = STO_PROTECTED;
+	  sym->st_value = 0;
+	  sym->st_shndx = SHN_MIPS_DATA;
+	}
+      else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
+	{
+	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+	  sym->st_other = STO_PROTECTED;
+	  sym->st_value = mips_elf_hash_table (info)->procedure_count;
+	  sym->st_shndx = SHN_ABS;
+	}
+      else if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS)
+	{
+	  if (h->type == STT_FUNC)
+	    sym->st_shndx = SHN_MIPS_TEXT;
+	  else if (h->type == STT_OBJECT)
+	    sym->st_shndx = SHN_MIPS_DATA;
+	}
+    }
+
+  /* Handle the IRIX6-specific symbols.  */
+  if (IRIX_COMPAT (output_bfd) == ict_irix6)
+    mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym);
+
+  if (! info->shared)
+    {
+      if (! mips_elf_hash_table (info)->use_rld_obj_head
+	  && (strcmp (name, "__rld_map") == 0
+	      || strcmp (name, "__RLD_MAP") == 0))
+	{
+	  asection *s = bfd_get_section_by_name (dynobj, ".rld_map");
+	  BFD_ASSERT (s != NULL);
+	  sym->st_value = s->output_section->vma + s->output_offset;
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, s->contents);
+	  if (mips_elf_hash_table (info)->rld_value == 0)
+	    mips_elf_hash_table (info)->rld_value = sym->st_value;
+	}
+      else if (mips_elf_hash_table (info)->use_rld_obj_head
+	       && strcmp (name, "__rld_obj_head") == 0)
+	{
+	  /* IRIX6 does not use a .rld_map section.  */
+	  if (IRIX_COMPAT (output_bfd) == ict_irix5
+              || IRIX_COMPAT (output_bfd) == ict_none)
+	    BFD_ASSERT (bfd_get_section_by_name (dynobj, ".rld_map")
+			!= NULL);
+	  mips_elf_hash_table (info)->rld_value = sym->st_value;
+	}
+    }
+
+  /* If this is a mips16 symbol, force the value to be even.  */
+  if (sym->st_other == STO_MIPS16
+      && (sym->st_value & 1) != 0)
+    --sym->st_value;
+
+  return true;
+}
+
+/* Finish up the dynamic sections.  */
+
+boolean
+_bfd_mips_elf_finish_dynamic_sections (output_bfd, info)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+{
+  bfd *dynobj;
+  asection *sdyn;
+  asection *sgot;
+  struct mips_got_info *g;
+
+  dynobj = elf_hash_table (info)->dynobj;
+
+  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+  sgot = bfd_get_section_by_name (dynobj, ".got");
+  if (sgot == NULL)
+    g = NULL;
+  else
+    {
+      BFD_ASSERT (elf_section_data (sgot) != NULL);
+      g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
+      BFD_ASSERT (g != NULL);
+    }
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      bfd_byte *b;
+
+      BFD_ASSERT (sdyn != NULL);
+      BFD_ASSERT (g != NULL);
+
+      for (b = sdyn->contents;
+	   b < sdyn->contents + sdyn->_raw_size;
+	   b += MIPS_ELF_DYN_SIZE (dynobj))
+	{
+	  Elf_Internal_Dyn dyn;
+	  const char *name;
+	  size_t elemsize;
+	  asection *s;
+	  boolean swap_out_p;
+
+	  /* Read in the current dynamic entry.  */
+	  (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
+
+	  /* Assume that we're going to modify it and write it out.  */
+	  swap_out_p = true;
+
+	  switch (dyn.d_tag)
+	    {
+	    case DT_RELENT:
+	      s = (bfd_get_section_by_name (dynobj, ".rel.dyn"));
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_val = MIPS_ELF_REL_SIZE (dynobj);
+	      break;
+
+	    case DT_STRSZ:
+	      /* Rewrite DT_STRSZ.  */
+	      dyn.d_un.d_val =
+		_bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
+	      break;
+
+	    case DT_PLTGOT:
+	      name = ".got";
+	      goto get_vma;
+	    case DT_MIPS_CONFLICT:
+	      name = ".conflict";
+	      goto get_vma;
+	    case DT_MIPS_LIBLIST:
+	      name = ".liblist";
+	    get_vma:
+	      s = bfd_get_section_by_name (output_bfd, name);
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->vma;
+	      break;
+
+	    case DT_MIPS_RLD_VERSION:
+	      dyn.d_un.d_val = 1; /* XXX */
+	      break;
+
+	    case DT_MIPS_FLAGS:
+	      dyn.d_un.d_val = RHF_NOTPOT; /* XXX */
+	      break;
+
+	    case DT_MIPS_CONFLICTNO:
+	      name = ".conflict";
+	      elemsize = sizeof (Elf32_Conflict);
+	      goto set_elemno;
+
+	    case DT_MIPS_LIBLISTNO:
+	      name = ".liblist";
+	      elemsize = sizeof (Elf32_Lib);
+	    set_elemno:
+	      s = bfd_get_section_by_name (output_bfd, name);
+	      if (s != NULL)
+		{
+		  if (s->_cooked_size != 0)
+		    dyn.d_un.d_val = s->_cooked_size / elemsize;
+		  else
+		    dyn.d_un.d_val = s->_raw_size / elemsize;
+		}
+	      else
+		dyn.d_un.d_val = 0;
+	      break;
+
+	    case DT_MIPS_TIME_STAMP:
+	      time ((time_t *) &dyn.d_un.d_val);
+	      break;
+
+	    case DT_MIPS_ICHECKSUM:
+	      /* XXX FIXME: */
+	      swap_out_p = false;
+	      break;
+
+	    case DT_MIPS_IVERSION:
+	      /* XXX FIXME: */
+	      swap_out_p = false;
+	      break;
+
+	    case DT_MIPS_BASE_ADDRESS:
+	      s = output_bfd->sections;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
+	      break;
+
+	    case DT_MIPS_LOCAL_GOTNO:
+	      dyn.d_un.d_val = g->local_gotno;
+	      break;
+
+	    case DT_MIPS_UNREFEXTNO:
+	      /* The index into the dynamic symbol table which is the
+		 entry of the first external symbol that is not
+		 referenced within the same object.  */
+	      dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
+	      break;
+
+	    case DT_MIPS_GOTSYM:
+	      if (g->global_gotsym)
+		{
+		  dyn.d_un.d_val = g->global_gotsym->dynindx;
+		  break;
+		}
+	      /* In case if we don't have global got symbols we default
+		 to setting DT_MIPS_GOTSYM to the same value as
+		 DT_MIPS_SYMTABNO, so we just fall through.  */
+
+	    case DT_MIPS_SYMTABNO:
+	      name = ".dynsym";
+	      elemsize = MIPS_ELF_SYM_SIZE (output_bfd);
+	      s = bfd_get_section_by_name (output_bfd, name);
+	      BFD_ASSERT (s != NULL);
+
+	      if (s->_cooked_size != 0)
+		dyn.d_un.d_val = s->_cooked_size / elemsize;
+	      else
+		dyn.d_un.d_val = s->_raw_size / elemsize;
+	      break;
+
+	    case DT_MIPS_HIPAGENO:
+	      dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO;
+	      break;
+
+	    case DT_MIPS_RLD_MAP:
+	      dyn.d_un.d_ptr = mips_elf_hash_table (info)->rld_value;
+	      break;
+
+	    case DT_MIPS_OPTIONS:
+	      s = (bfd_get_section_by_name
+		   (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (output_bfd)));
+	      dyn.d_un.d_ptr = s->vma;
+	      break;
+
+	    case DT_MIPS_MSYM:
+	      s = (bfd_get_section_by_name (output_bfd, ".msym"));
+	      dyn.d_un.d_ptr = s->vma;
+	      break;
+
+	    default:
+	      swap_out_p = false;
+	      break;
+	    }
+
+	  if (swap_out_p)
+	    (*get_elf_backend_data (dynobj)->s->swap_dyn_out)
+	      (dynobj, &dyn, b);
+	}
+    }
+
+  /* The first entry of the global offset table will be filled at
+     runtime. The second entry will be used by some runtime loaders.
+     This isn't the case of Irix rld.  */
+  if (sgot != NULL && sgot->_raw_size > 0)
+    {
+      MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0, sgot->contents);
+      MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0x80000000,
+			 sgot->contents + MIPS_ELF_GOT_SIZE (output_bfd));
+    }
+
+  if (sgot != NULL)
+    elf_section_data (sgot->output_section)->this_hdr.sh_entsize
+      = MIPS_ELF_GOT_SIZE (output_bfd);
+
+  {
+    asection *smsym;
+    asection *s;
+    Elf32_compact_rel cpt;
+
+    /* ??? The section symbols for the output sections were set up in
+       _bfd_elf_final_link.  SGI sets the STT_NOTYPE attribute for these
+       symbols.  Should we do so?  */
+
+    smsym = bfd_get_section_by_name (dynobj, ".msym");
+    if (smsym != NULL)
+      {
+	Elf32_Internal_Msym msym;
+
+	msym.ms_hash_value = 0;
+	msym.ms_info = ELF32_MS_INFO (0, 1);
+
+	for (s = output_bfd->sections; s != NULL; s = s->next)
+	  {
+	    long dynindx = elf_section_data (s)->dynindx;
+
+	    bfd_mips_elf_swap_msym_out
+	      (output_bfd, &msym,
+	       (((Elf32_External_Msym *) smsym->contents)
+		+ dynindx));
+	  }
+      }
+
+    if (SGI_COMPAT (output_bfd))
+      {
+	/* Write .compact_rel section out.  */
+	s = bfd_get_section_by_name (dynobj, ".compact_rel");
+	if (s != NULL)
+	  {
+	    cpt.id1 = 1;
+	    cpt.num = s->reloc_count;
+	    cpt.id2 = 2;
+	    cpt.offset = (s->output_section->filepos
+			  + sizeof (Elf32_External_compact_rel));
+	    cpt.reserved0 = 0;
+	    cpt.reserved1 = 0;
+	    bfd_elf32_swap_compact_rel_out (output_bfd, &cpt,
+					    ((Elf32_External_compact_rel *)
+					     s->contents));
+
+	    /* Clean up a dummy stub function entry in .text.  */
+	    s = bfd_get_section_by_name (dynobj,
+					 MIPS_ELF_STUB_SECTION_NAME (dynobj));
+	    if (s != NULL)
+	      {
+		file_ptr dummy_offset;
+
+		BFD_ASSERT (s->_raw_size >= MIPS_FUNCTION_STUB_SIZE);
+		dummy_offset = s->_raw_size - MIPS_FUNCTION_STUB_SIZE;
+		memset (s->contents + dummy_offset, 0,
+			MIPS_FUNCTION_STUB_SIZE);
+	      }
+	  }
+      }
+
+    /* We need to sort the entries of the dynamic relocation section.  */
+
+    if (!ABI_64_P (output_bfd))
+      {
+	asection *reldyn;
+
+	reldyn = bfd_get_section_by_name (dynobj, ".rel.dyn");
+	if (reldyn != NULL && reldyn->reloc_count > 2)
+	  {
+	    reldyn_sorting_bfd = output_bfd;
+	    qsort ((Elf32_External_Rel *) reldyn->contents + 1,
+		   (size_t) reldyn->reloc_count - 1,
+		   sizeof (Elf32_External_Rel), sort_dynamic_relocs);
+	  }
+      }
+
+    /* Clean up a first relocation in .rel.dyn.  */
+    s = bfd_get_section_by_name (dynobj, ".rel.dyn");
+    if (s != NULL && s->_raw_size > 0)
+      memset (s->contents, 0, MIPS_ELF_REL_SIZE (dynobj));
+  }
+
+  return true;
+}
+
+/* The final processing done just before writing out a MIPS ELF object
+   file.  This gets the MIPS architecture right based on the machine
+   number.  This is used by both the 32-bit and the 64-bit ABI.  */
+
+void
+_bfd_mips_elf_final_write_processing (abfd, linker)
+     bfd *abfd;
+     boolean linker ATTRIBUTE_UNUSED;
+{
+  unsigned long val;
+  unsigned int i;
+  Elf_Internal_Shdr **hdrpp;
+  const char *name;
+  asection *sec;
+
+  switch (bfd_get_mach (abfd))
+    {
+    default:
+    case bfd_mach_mips3000:
+      val = E_MIPS_ARCH_1;
+      break;
+
+    case bfd_mach_mips3900:
+      val = E_MIPS_ARCH_1 | E_MIPS_MACH_3900;
+      break;
+
+    case bfd_mach_mips6000:
+      val = E_MIPS_ARCH_2;
+      break;
+
+    case bfd_mach_mips4000:
+    case bfd_mach_mips4300:
+    case bfd_mach_mips4400:
+    case bfd_mach_mips4600:
+      val = E_MIPS_ARCH_3;
+      break;
+
+    case bfd_mach_mips4010:
+      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4010;
+      break;
+
+    case bfd_mach_mips4100:
+      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4100;
+      break;
+
+    case bfd_mach_mips4111:
+      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4111;
+      break;
+
+    case bfd_mach_mips4650:
+      val = E_MIPS_ARCH_3 | E_MIPS_MACH_4650;
+      break;
+
+    case bfd_mach_mips5000:
+    case bfd_mach_mips8000:
+    case bfd_mach_mips10000:
+    case bfd_mach_mips12000:
+      val = E_MIPS_ARCH_4;
+      break;
+
+    case bfd_mach_mips5:
+      val = E_MIPS_ARCH_5;
+      break;
+
+    case bfd_mach_mips_sb1:
+      val = E_MIPS_ARCH_64 | E_MIPS_MACH_SB1;
+      break;
+
+    case bfd_mach_mipsisa32:
+      val = E_MIPS_ARCH_32;
+      break;
+
+    case bfd_mach_mipsisa64:
+      val = E_MIPS_ARCH_64;
+    }
+
+  elf_elfheader (abfd)->e_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
+  elf_elfheader (abfd)->e_flags |= val;
+
+  /* Set the sh_info field for .gptab sections and other appropriate
+     info for each special section.  */
+  for (i = 1, hdrpp = elf_elfsections (abfd) + 1;
+       i < elf_numsections (abfd);
+       i++, hdrpp++)
+    {
+      switch ((*hdrpp)->sh_type)
+	{
+	case SHT_MIPS_MSYM:
+	case SHT_MIPS_LIBLIST:
+	  sec = bfd_get_section_by_name (abfd, ".dynstr");
+	  if (sec != NULL)
+	    (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+	  break;
+
+	case SHT_MIPS_GPTAB:
+	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
+	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
+	  BFD_ASSERT (name != NULL
+		      && strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0);
+	  sec = bfd_get_section_by_name (abfd, name + sizeof ".gptab" - 1);
+	  BFD_ASSERT (sec != NULL);
+	  (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
+	  break;
+
+	case SHT_MIPS_CONTENT:
+	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
+	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
+	  BFD_ASSERT (name != NULL
+		      && strncmp (name, ".MIPS.content",
+				  sizeof ".MIPS.content" - 1) == 0);
+	  sec = bfd_get_section_by_name (abfd,
+					 name + sizeof ".MIPS.content" - 1);
+	  BFD_ASSERT (sec != NULL);
+	  (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+	  break;
+
+	case SHT_MIPS_SYMBOL_LIB:
+	  sec = bfd_get_section_by_name (abfd, ".dynsym");
+	  if (sec != NULL)
+	    (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+	  sec = bfd_get_section_by_name (abfd, ".liblist");
+	  if (sec != NULL)
+	    (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
+	  break;
+
+	case SHT_MIPS_EVENTS:
+	  BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
+	  name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
+	  BFD_ASSERT (name != NULL);
+	  if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0)
+	    sec = bfd_get_section_by_name (abfd,
+					   name + sizeof ".MIPS.events" - 1);
+	  else
+	    {
+	      BFD_ASSERT (strncmp (name, ".MIPS.post_rel",
+				   sizeof ".MIPS.post_rel" - 1) == 0);
+	      sec = bfd_get_section_by_name (abfd,
+					     (name
+					      + sizeof ".MIPS.post_rel" - 1));
+	    }
+	  BFD_ASSERT (sec != NULL);
+	  (*hdrpp)->sh_link = elf_section_data (sec)->this_idx;
+	  break;
+
+	}
+    }
+}
+
+/* When creating an Irix 5 executable, we need REGINFO and RTPROC
+   segments.  */
+
+int
+_bfd_mips_elf_additional_program_headers (abfd)
+     bfd *abfd;
+{
+  asection *s;
+  int ret = 0;
+
+  /* See if we need a PT_MIPS_REGINFO segment.  */
+  s = bfd_get_section_by_name (abfd, ".reginfo");
+  if (s && (s->flags & SEC_LOAD))
+    ++ret;
+
+  /* See if we need a PT_MIPS_OPTIONS segment.  */
+  if (IRIX_COMPAT (abfd) == ict_irix6
+      && bfd_get_section_by_name (abfd,
+				  MIPS_ELF_OPTIONS_SECTION_NAME (abfd)))
+    ++ret;
+
+  /* See if we need a PT_MIPS_RTPROC segment.  */
+  if (IRIX_COMPAT (abfd) == ict_irix5
+      && bfd_get_section_by_name (abfd, ".dynamic")
+      && bfd_get_section_by_name (abfd, ".mdebug"))
+    ++ret;
+
+  return ret;
+}
+
+/* Modify the segment map for an Irix 5 executable.  */
+
+boolean
+_bfd_mips_elf_modify_segment_map (abfd)
+     bfd *abfd;
+{
+  asection *s;
+  struct elf_segment_map *m, **pm;
+  bfd_size_type amt;
+
+  /* If there is a .reginfo section, we need a PT_MIPS_REGINFO
+     segment.  */
+  s = bfd_get_section_by_name (abfd, ".reginfo");
+  if (s != NULL && (s->flags & SEC_LOAD) != 0)
+    {
+      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+	if (m->p_type == PT_MIPS_REGINFO)
+	  break;
+      if (m == NULL)
+	{
+	  amt = sizeof *m;
+	  m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
+	  if (m == NULL)
+	    return false;
+
+	  m->p_type = PT_MIPS_REGINFO;
+	  m->count = 1;
+	  m->sections[0] = s;
+
+	  /* We want to put it after the PHDR and INTERP segments.  */
+	  pm = &elf_tdata (abfd)->segment_map;
+	  while (*pm != NULL
+		 && ((*pm)->p_type == PT_PHDR
+		     || (*pm)->p_type == PT_INTERP))
+	    pm = &(*pm)->next;
+
+	  m->next = *pm;
+	  *pm = m;
+	}
+    }
+
+  /* For IRIX 6, we don't have .mdebug sections, nor does anything but
+     .dynamic end up in PT_DYNAMIC.  However, we do have to insert a
+     PT_OPTIONS segement immediately following the program header
+     table.  */
+  if (IRIX_COMPAT (abfd) == ict_irix6)
+    {
+      for (s = abfd->sections; s; s = s->next)
+	if (elf_section_data (s)->this_hdr.sh_type == SHT_MIPS_OPTIONS)
+	  break;
+
+      if (s)
+	{
+	  struct elf_segment_map *options_segment;
+
+	  /* Usually, there's a program header table.  But, sometimes
+	     there's not (like when running the `ld' testsuite).  So,
+	     if there's no program header table, we just put the
+	     options segement at the end.  */
+	  for (pm = &elf_tdata (abfd)->segment_map;
+	       *pm != NULL;
+	       pm = &(*pm)->next)
+	    if ((*pm)->p_type == PT_PHDR)
+	      break;
+
+	  amt = sizeof (struct elf_segment_map);
+	  options_segment = bfd_zalloc (abfd, amt);
+	  options_segment->next = *pm;
+	  options_segment->p_type = PT_MIPS_OPTIONS;
+	  options_segment->p_flags = PF_R;
+	  options_segment->p_flags_valid = true;
+	  options_segment->count = 1;
+	  options_segment->sections[0] = s;
+	  *pm = options_segment;
+	}
+    }
+  else
+    {
+      if (IRIX_COMPAT (abfd) == ict_irix5)
+	{
+	  /* If there are .dynamic and .mdebug sections, we make a room
+	     for the RTPROC header.  FIXME: Rewrite without section names.  */
+	  if (bfd_get_section_by_name (abfd, ".interp") == NULL
+	      && bfd_get_section_by_name (abfd, ".dynamic") != NULL
+	      && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
+	    {
+	      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+		if (m->p_type == PT_MIPS_RTPROC)
+		  break;
+	      if (m == NULL)
+		{
+		  amt = sizeof *m;
+		  m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
+		  if (m == NULL)
+		    return false;
+
+		  m->p_type = PT_MIPS_RTPROC;
+
+		  s = bfd_get_section_by_name (abfd, ".rtproc");
+		  if (s == NULL)
+		    {
+		      m->count = 0;
+		      m->p_flags = 0;
+		      m->p_flags_valid = 1;
+		    }
+		  else
+		    {
+		      m->count = 1;
+		      m->sections[0] = s;
+		    }
+
+		  /* We want to put it after the DYNAMIC segment.  */
+		  pm = &elf_tdata (abfd)->segment_map;
+		  while (*pm != NULL && (*pm)->p_type != PT_DYNAMIC)
+		    pm = &(*pm)->next;
+		  if (*pm != NULL)
+		    pm = &(*pm)->next;
+
+		  m->next = *pm;
+		  *pm = m;
+		}
+	    }
+	}
+      /* On Irix 5, the PT_DYNAMIC segment includes the .dynamic,
+	 .dynstr, .dynsym, and .hash sections, and everything in
+	 between.  */
+      for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL;
+	   pm = &(*pm)->next)
+	if ((*pm)->p_type == PT_DYNAMIC)
+	  break;
+      m = *pm;
+      if (m != NULL && IRIX_COMPAT (abfd) == ict_none)
+	{
+	  /* For a normal mips executable the permissions for the PT_DYNAMIC
+	     segment are read, write and execute. We do that here since
+	     the code in elf.c sets only the read permission. This matters
+	     sometimes for the dynamic linker.  */
+	  if (bfd_get_section_by_name (abfd, ".dynamic") != NULL)
+	    {
+	      m->p_flags = PF_R | PF_W | PF_X;
+	      m->p_flags_valid = 1;
+	    }
+	}
+      if (m != NULL
+	  && m->count == 1 && strcmp (m->sections[0]->name, ".dynamic") == 0)
+	{
+	  static const char *sec_names[] =
+	  {
+	    ".dynamic", ".dynstr", ".dynsym", ".hash"
+	  };
+	  bfd_vma low, high;
+	  unsigned int i, c;
+	  struct elf_segment_map *n;
+
+	  low = 0xffffffff;
+	  high = 0;
+	  for (i = 0; i < sizeof sec_names / sizeof sec_names[0]; i++)
+	    {
+	      s = bfd_get_section_by_name (abfd, sec_names[i]);
+	      if (s != NULL && (s->flags & SEC_LOAD) != 0)
+		{
+		  bfd_size_type sz;
+
+		  if (low > s->vma)
+		    low = s->vma;
+		  sz = s->_cooked_size;
+		  if (sz == 0)
+		    sz = s->_raw_size;
+		  if (high < s->vma + sz)
+		    high = s->vma + sz;
+		}
+	    }
+
+	  c = 0;
+	  for (s = abfd->sections; s != NULL; s = s->next)
+	    if ((s->flags & SEC_LOAD) != 0
+		&& s->vma >= low
+		&& ((s->vma
+		     + (s->_cooked_size !=
+			0 ? s->_cooked_size : s->_raw_size)) <= high))
+	      ++c;
+
+	  amt = sizeof *n + (bfd_size_type) (c - 1) * sizeof (asection *);
+	  n = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
+	  if (n == NULL)
+	    return false;
+	  *n = *m;
+	  n->count = c;
+
+	  i = 0;
+	  for (s = abfd->sections; s != NULL; s = s->next)
+	    {
+	      if ((s->flags & SEC_LOAD) != 0
+		  && s->vma >= low
+		  && ((s->vma
+		       + (s->_cooked_size != 0 ?
+			  s->_cooked_size : s->_raw_size)) <= high))
+		{
+		  n->sections[i] = s;
+		  ++i;
+		}
+	    }
+
+	  *pm = n;
+	}
+    }
+
+  return true;
+}
+
+/* Return the section that should be marked against GC for a given
+   relocation.  */
+
+asection *
+_bfd_mips_elf_gc_mark_hook (abfd, info, rel, h, sym)
+     bfd *abfd;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *rel;
+     struct elf_link_hash_entry *h;
+     Elf_Internal_Sym *sym;
+{
+  /* ??? Do mips16 stub sections need to be handled special?  */
+
+  if (h != NULL)
+    {
+      switch (ELF_R_TYPE (abfd, rel->r_info))
+	{
+	case R_MIPS_GNU_VTINHERIT:
+	case R_MIPS_GNU_VTENTRY:
+	  break;
+
+	default:
+	  switch (h->root.type)
+	    {
+	    case bfd_link_hash_defined:
+	    case bfd_link_hash_defweak:
+	      return h->root.u.def.section;
+
+	    case bfd_link_hash_common:
+	      return h->root.u.c.p->section;
+
+	    default:
+	      break;
+	    }
+	}
+    }
+  else
+    {
+      return bfd_section_from_elf_index (abfd, sym->st_shndx);
+    }
+
+  return NULL;
+}
+
+/* Update the got entry reference counts for the section being removed.  */
+
+boolean
+_bfd_mips_elf_gc_sweep_hook (abfd, info, sec, relocs)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+     asection *sec ATTRIBUTE_UNUSED;
+     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
+{
+#if 0
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  bfd_signed_vma *local_got_refcounts;
+  const Elf_Internal_Rela *rel, *relend;
+  unsigned long r_symndx;
+  struct elf_link_hash_entry *h;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (abfd);
+  local_got_refcounts = elf_local_got_refcounts (abfd);
+
+  relend = relocs + sec->reloc_count;
+  for (rel = relocs; rel < relend; rel++)
+    switch (ELF_R_TYPE (abfd, rel->r_info))
+      {
+      case R_MIPS_GOT16:
+      case R_MIPS_CALL16:
+      case R_MIPS_CALL_HI16:
+      case R_MIPS_CALL_LO16:
+      case R_MIPS_GOT_HI16:
+      case R_MIPS_GOT_LO16:
+	/* ??? It would seem that the existing MIPS code does no sort
+	   of reference counting or whatnot on its GOT and PLT entries,
+	   so it is not possible to garbage collect them at this time.  */
+	break;
+
+      default:
+	break;
+      }
+#endif
+
+  return true;
+}
+
+/* Copy data from a MIPS ELF indirect symbol to its direct symbol,
+   hiding the old indirect symbol.  Process additional relocation
+   information.  Also called for weakdefs, in which case we just let
+   _bfd_elf_link_hash_copy_indirect copy the flags for us.  */
+
+void
+_bfd_mips_elf_copy_indirect_symbol (dir, ind)
+     struct elf_link_hash_entry *dir, *ind;
+{
+  struct mips_elf_link_hash_entry *dirmips, *indmips;
+
+  _bfd_elf_link_hash_copy_indirect (dir, ind);
+
+  if (ind->root.type != bfd_link_hash_indirect)
+    return;
+
+  dirmips = (struct mips_elf_link_hash_entry *) dir;
+  indmips = (struct mips_elf_link_hash_entry *) ind;
+  dirmips->possibly_dynamic_relocs += indmips->possibly_dynamic_relocs;
+  if (indmips->readonly_reloc)
+    dirmips->readonly_reloc = true;
+  if (dirmips->min_dyn_reloc_index == 0
+      || (indmips->min_dyn_reloc_index != 0
+	  && indmips->min_dyn_reloc_index < dirmips->min_dyn_reloc_index))
+    dirmips->min_dyn_reloc_index = indmips->min_dyn_reloc_index;
+  if (indmips->no_fn_stub)
+    dirmips->no_fn_stub = true;
+}
+
+void
+_bfd_mips_elf_hide_symbol (info, entry, force_local)
+     struct bfd_link_info *info;
+     struct elf_link_hash_entry *entry;
+     boolean force_local;
+{
+  bfd *dynobj;
+  asection *got;
+  struct mips_got_info *g;
+  struct mips_elf_link_hash_entry *h;
+
+  h = (struct mips_elf_link_hash_entry *) entry;
+  if (h->forced_local)
+    return;
+  h->forced_local = true;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  got = bfd_get_section_by_name (dynobj, ".got");
+  g = (struct mips_got_info *) elf_section_data (got)->tdata;
+
+  _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
+
+  /* FIXME: Do we allocate too much GOT space here?  */
+  g->local_gotno++;
+  got->_raw_size += MIPS_ELF_GOT_SIZE (dynobj);
+}
+
+/* MIPS ELF uses a special find_nearest_line routine in order the
+   handle the ECOFF debugging information.  */
+
+struct mips_elf_find_line
+{
+  struct ecoff_debug_info d;
+  struct ecoff_find_line i;
+};
+
+boolean
+_bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
+				 functionname_ptr, line_ptr)
+     bfd *abfd;
+     asection *section;
+     asymbol **symbols;
+     bfd_vma offset;
+     const char **filename_ptr;
+     const char **functionname_ptr;
+     unsigned int *line_ptr;
+{
+  asection *msec;
+
+  if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
+				     filename_ptr, functionname_ptr,
+				     line_ptr))
+    return true;
+
+  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+				     filename_ptr, functionname_ptr,
+				     line_ptr,
+				     (unsigned) (ABI_64_P (abfd) ? 8 : 0),
+				     &elf_tdata (abfd)->dwarf2_find_line_info))
+    return true;
+
+  msec = bfd_get_section_by_name (abfd, ".mdebug");
+  if (msec != NULL)
+    {
+      flagword origflags;
+      struct mips_elf_find_line *fi;
+      const struct ecoff_debug_swap * const swap =
+	get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+
+      /* If we are called during a link, mips_elf_final_link may have
+	 cleared the SEC_HAS_CONTENTS field.  We force it back on here
+	 if appropriate (which it normally will be).  */
+      origflags = msec->flags;
+      if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
+	msec->flags |= SEC_HAS_CONTENTS;
+
+      fi = elf_tdata (abfd)->find_line_info;
+      if (fi == NULL)
+	{
+	  bfd_size_type external_fdr_size;
+	  char *fraw_src;
+	  char *fraw_end;
+	  struct fdr *fdr_ptr;
+	  bfd_size_type amt = sizeof (struct mips_elf_find_line);
+
+	  fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
+	  if (fi == NULL)
+	    {
+	      msec->flags = origflags;
+	      return false;
+	    }
+
+	  if (! _bfd_mips_elf_read_ecoff_info (abfd, msec, &fi->d))
+	    {
+	      msec->flags = origflags;
+	      return false;
+	    }
+
+	  /* Swap in the FDR information.  */
+	  amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr);
+	  fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt);
+	  if (fi->d.fdr == NULL)
+	    {
+	      msec->flags = origflags;
+	      return false;
+	    }
+	  external_fdr_size = swap->external_fdr_size;
+	  fdr_ptr = fi->d.fdr;
+	  fraw_src = (char *) fi->d.external_fdr;
+	  fraw_end = (fraw_src
+		      + fi->d.symbolic_header.ifdMax * external_fdr_size);
+	  for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
+	    (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
+
+	  elf_tdata (abfd)->find_line_info = fi;
+
+	  /* Note that we don't bother to ever free this information.
+             find_nearest_line is either called all the time, as in
+             objdump -l, so the information should be saved, or it is
+             rarely called, as in ld error messages, so the memory
+             wasted is unimportant.  Still, it would probably be a
+             good idea for free_cached_info to throw it away.  */
+	}
+
+      if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap,
+				  &fi->i, filename_ptr, functionname_ptr,
+				  line_ptr))
+	{
+	  msec->flags = origflags;
+	  return true;
+	}
+
+      msec->flags = origflags;
+    }
+
+  /* Fall back on the generic ELF find_nearest_line routine.  */
+
+  return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
+				     filename_ptr, functionname_ptr,
+				     line_ptr);
+}
+
+/* When are writing out the .options or .MIPS.options section,
+   remember the bytes we are writing out, so that we can install the
+   GP value in the section_processing routine.  */
+
+boolean
+_bfd_mips_elf_set_section_contents (abfd, section, location, offset, count)
+     bfd *abfd;
+     sec_ptr section;
+     PTR location;
+     file_ptr offset;
+     bfd_size_type count;
+{
+  if (strcmp (section->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
+    {
+      bfd_byte *c;
+
+      if (elf_section_data (section) == NULL)
+	{
+	  bfd_size_type amt = sizeof (struct bfd_elf_section_data);
+	  section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
+	  if (elf_section_data (section) == NULL)
+	    return false;
+	}
+      c = (bfd_byte *) elf_section_data (section)->tdata;
+      if (c == NULL)
+	{
+	  bfd_size_type size;
+
+	  if (section->_cooked_size != 0)
+	    size = section->_cooked_size;
+	  else
+	    size = section->_raw_size;
+	  c = (bfd_byte *) bfd_zalloc (abfd, size);
+	  if (c == NULL)
+	    return false;
+	  elf_section_data (section)->tdata = (PTR) c;
+	}
+
+      memcpy (c + offset, location, (size_t) count);
+    }
+
+  return _bfd_elf_set_section_contents (abfd, section, location, offset,
+					count);
+}
+
+/* This is almost identical to bfd_generic_get_... except that some
+   MIPS relocations need to be handled specially.  Sigh.  */
+
+bfd_byte *
+_bfd_elf_mips_get_relocated_section_contents (abfd, link_info, link_order,
+					      data, relocateable, symbols)
+     bfd *abfd;
+     struct bfd_link_info *link_info;
+     struct bfd_link_order *link_order;
+     bfd_byte *data;
+     boolean relocateable;
+     asymbol **symbols;
+{
+  /* Get enough memory to hold the stuff */
+  bfd *input_bfd = link_order->u.indirect.section->owner;
+  asection *input_section = link_order->u.indirect.section;
+
+  long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
+  arelent **reloc_vector = NULL;
+  long reloc_count;
+
+  if (reloc_size < 0)
+    goto error_return;
+
+  reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
+  if (reloc_vector == NULL && reloc_size != 0)
+    goto error_return;
+
+  /* read in the section */
+  if (!bfd_get_section_contents (input_bfd,
+				 input_section,
+				 (PTR) data,
+				 (file_ptr) 0,
+				 input_section->_raw_size))
+    goto error_return;
+
+  /* We're not relaxing the section, so just copy the size info */
+  input_section->_cooked_size = input_section->_raw_size;
+  input_section->reloc_done = true;
+
+  reloc_count = bfd_canonicalize_reloc (input_bfd,
+					input_section,
+					reloc_vector,
+					symbols);
+  if (reloc_count < 0)
+    goto error_return;
+
+  if (reloc_count > 0)
+    {
+      arelent **parent;
+      /* for mips */
+      int gp_found;
+      bfd_vma gp = 0x12345678;	/* initialize just to shut gcc up */
+
+      {
+	struct bfd_hash_entry *h;
+	struct bfd_link_hash_entry *lh;
+	/* Skip all this stuff if we aren't mixing formats.  */
+	if (abfd && input_bfd
+	    && abfd->xvec == input_bfd->xvec)
+	  lh = 0;
+	else
+	  {
+	    h = bfd_hash_lookup (&link_info->hash->table, "_gp", false, false);
+	    lh = (struct bfd_link_hash_entry *) h;
+	  }
+      lookup:
+	if (lh)
+	  {
+	    switch (lh->type)
+	      {
+	      case bfd_link_hash_undefined:
+	      case bfd_link_hash_undefweak:
+	      case bfd_link_hash_common:
+		gp_found = 0;
+		break;
+	      case bfd_link_hash_defined:
+	      case bfd_link_hash_defweak:
+		gp_found = 1;
+		gp = lh->u.def.value;
+		break;
+	      case bfd_link_hash_indirect:
+	      case bfd_link_hash_warning:
+		lh = lh->u.i.link;
+		/* @@FIXME  ignoring warning for now */
+		goto lookup;
+	      case bfd_link_hash_new:
+	      default:
+		abort ();
+	      }
+	  }
+	else
+	  gp_found = 0;
+      }
+      /* end mips */
+      for (parent = reloc_vector; *parent != (arelent *) NULL;
+	   parent++)
+	{
+	  char *error_message = (char *) NULL;
+	  bfd_reloc_status_type r;
+
+	  /* Specific to MIPS: Deal with relocation types that require
+	     knowing the gp of the output bfd.  */
+	  asymbol *sym = *(*parent)->sym_ptr_ptr;
+	  if (bfd_is_abs_section (sym->section) && abfd)
+	    {
+	      /* The special_function wouldn't get called anyways.  */
+	    }
+	  else if (!gp_found)
+	    {
+	      /* The gp isn't there; let the special function code
+		 fall over on its own.  */
+	    }
+	  else if ((*parent)->howto->special_function
+		   == _bfd_mips_elf32_gprel16_reloc)
+	    {
+	      /* bypass special_function call */
+	      r = _bfd_mips_elf_gprel16_with_gp (input_bfd, sym, *parent,
+						 input_section, relocateable,
+						 (PTR) data, gp);
+	      goto skip_bfd_perform_relocation;
+	    }
+	  /* end mips specific stuff */
+
+	  r = bfd_perform_relocation (input_bfd,
+				      *parent,
+				      (PTR) data,
+				      input_section,
+				      relocateable ? abfd : (bfd *) NULL,
+				      &error_message);
+	skip_bfd_perform_relocation:
+
+	  if (relocateable)
+	    {
+	      asection *os = input_section->output_section;
+
+	      /* A partial link, so keep the relocs */
+	      os->orelocation[os->reloc_count] = *parent;
+	      os->reloc_count++;
+	    }
+
+	  if (r != bfd_reloc_ok)
+	    {
+	      switch (r)
+		{
+		case bfd_reloc_undefined:
+		  if (!((*link_info->callbacks->undefined_symbol)
+			(link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
+			 input_bfd, input_section, (*parent)->address,
+			 true)))
+		    goto error_return;
+		  break;
+		case bfd_reloc_dangerous:
+		  BFD_ASSERT (error_message != (char *) NULL);
+		  if (!((*link_info->callbacks->reloc_dangerous)
+			(link_info, error_message, input_bfd, input_section,
+			 (*parent)->address)))
+		    goto error_return;
+		  break;
+		case bfd_reloc_overflow:
+		  if (!((*link_info->callbacks->reloc_overflow)
+			(link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
+			 (*parent)->howto->name, (*parent)->addend,
+			 input_bfd, input_section, (*parent)->address)))
+		    goto error_return;
+		  break;
+		case bfd_reloc_outofrange:
+		default:
+		  abort ();
+		  break;
+		}
+
+	    }
+	}
+    }
+  if (reloc_vector != NULL)
+    free (reloc_vector);
+  return data;
+
+error_return:
+  if (reloc_vector != NULL)
+    free (reloc_vector);
+  return NULL;
+}
+
+/* Create a MIPS ELF linker hash table.  */
+
+struct bfd_link_hash_table *
+_bfd_mips_elf_link_hash_table_create (abfd)
+     bfd *abfd;
+{
+  struct mips_elf_link_hash_table *ret;
+  bfd_size_type amt = sizeof (struct mips_elf_link_hash_table);
+
+  ret = (struct mips_elf_link_hash_table *) bfd_malloc (amt);
+  if (ret == (struct mips_elf_link_hash_table *) NULL)
+    return NULL;
+
+  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
+				       mips_elf_link_hash_newfunc))
+    {
+      free (ret);
+      return NULL;
+    }
+
+#if 0
+  /* We no longer use this.  */
+  for (i = 0; i < SIZEOF_MIPS_DYNSYM_SECNAMES; i++)
+    ret->dynsym_sec_strindex[i] = (bfd_size_type) -1;
+#endif
+  ret->procedure_count = 0;
+  ret->compact_rel_size = 0;
+  ret->use_rld_obj_head = false;
+  ret->rld_value = 0;
+  ret->mips16_stubs_seen = false;
+
+  return &ret->root.root;
+}
+
+/* We need to use a special link routine to handle the .reginfo and
+   the .mdebug sections.  We need to merge all instances of these
+   sections together, not write them all out sequentially.  */
+
+boolean
+_bfd_mips_elf_final_link (abfd, info)
+     bfd *abfd;
+     struct bfd_link_info *info;
+{
+  asection **secpp;
+  asection *o;
+  struct bfd_link_order *p;
+  asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
+  asection *rtproc_sec;
+  Elf32_RegInfo reginfo;
+  struct ecoff_debug_info debug;
+  const struct ecoff_debug_swap *swap
+    = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+  HDRR *symhdr = &debug.symbolic_header;
+  PTR mdebug_handle = NULL;
+  asection *s;
+  EXTR esym;
+  unsigned int i;
+  bfd_size_type amt;
+
+  static const char * const secname[] =
+  {
+    ".text", ".init", ".fini", ".data",
+    ".rodata", ".sdata", ".sbss", ".bss"
+  };
+  static const int sc[] =
+  {
+    scText, scInit, scFini, scData,
+    scRData, scSData, scSBss, scBss
+  };
+
+  /* If all the things we linked together were PIC, but we're
+     producing an executable (rather than a shared object), then the
+     resulting file is CPIC (i.e., it calls PIC code.)  */
+  if (!info->shared
+      && !info->relocateable
+      && elf_elfheader (abfd)->e_flags & EF_MIPS_PIC)
+    {
+      elf_elfheader (abfd)->e_flags &= ~EF_MIPS_PIC;
+      elf_elfheader (abfd)->e_flags |= EF_MIPS_CPIC;
+    }
+
+  /* We'd carefully arranged the dynamic symbol indices, and then the
+     generic size_dynamic_sections renumbered them out from under us.
+     Rather than trying somehow to prevent the renumbering, just do
+     the sort again.  */
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      bfd *dynobj;
+      asection *got;
+      struct mips_got_info *g;
+
+      /* When we resort, we must tell mips_elf_sort_hash_table what
+	 the lowest index it may use is.  That's the number of section
+	 symbols we're going to add.  The generic ELF linker only
+	 adds these symbols when building a shared object.  Note that
+	 we count the sections after (possibly) removing the .options
+	 section above.  */
+      if (! mips_elf_sort_hash_table (info, (info->shared
+					     ? bfd_count_sections (abfd) + 1
+					     : 1)))
+	return false;
+
+      /* Make sure we didn't grow the global .got region.  */
+      dynobj = elf_hash_table (info)->dynobj;
+      got = bfd_get_section_by_name (dynobj, ".got");
+      g = (struct mips_got_info *) elf_section_data (got)->tdata;
+
+      if (g->global_gotsym != NULL)
+	BFD_ASSERT ((elf_hash_table (info)->dynsymcount
+		     - g->global_gotsym->dynindx)
+		    <= g->global_gotno);
+    }
+
+  /* On IRIX5, we omit the .options section.  On IRIX6, however, we
+     include it, even though we don't process it quite right.  (Some
+     entries are supposed to be merged.)  Empirically, we seem to be
+     better off including it then not.  */
+  if (IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
+    for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
+      {
+	if (strcmp ((*secpp)->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
+	  {
+	    for (p = (*secpp)->link_order_head; p != NULL; p = p->next)
+	      if (p->type == bfd_indirect_link_order)
+		p->u.indirect.section->flags &= ~SEC_HAS_CONTENTS;
+	    (*secpp)->link_order_head = NULL;
+	    bfd_section_list_remove (abfd, secpp);
+	    --abfd->section_count;
+
+	    break;
+	  }
+      }
+
+  /* We include .MIPS.options, even though we don't process it quite right.
+     (Some entries are supposed to be merged.)  At IRIX6 empirically we seem
+     to be better off including it than not.  */
+  for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
+    {
+      if (strcmp ((*secpp)->name, ".MIPS.options") == 0)
+	{
+	  for (p = (*secpp)->link_order_head; p != NULL; p = p->next)
+	    if (p->type == bfd_indirect_link_order)
+	      p->u.indirect.section->flags &=~ SEC_HAS_CONTENTS;
+	  (*secpp)->link_order_head = NULL;
+	  bfd_section_list_remove (abfd, secpp);
+	  --abfd->section_count;
+	    
+	  break;
+	}
+    }
+
+  /* Get a value for the GP register.  */
+  if (elf_gp (abfd) == 0)
+    {
+      struct bfd_link_hash_entry *h;
+
+      h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
+      if (h != (struct bfd_link_hash_entry *) NULL
+	  && h->type == bfd_link_hash_defined)
+	elf_gp (abfd) = (h->u.def.value
+			 + h->u.def.section->output_section->vma
+			 + h->u.def.section->output_offset);
+      else if (info->relocateable)
+	{
+	  bfd_vma lo = MINUS_ONE;
+
+	  /* Find the GP-relative section with the lowest offset.  */
+	  for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+	    if (o->vma < lo
+		&& (elf_section_data (o)->this_hdr.sh_flags & SHF_MIPS_GPREL))
+	      lo = o->vma;
+
+	  /* And calculate GP relative to that.  */
+	  elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (abfd);
+	}
+      else
+	{
+	  /* If the relocate_section function needs to do a reloc
+	     involving the GP value, it should make a reloc_dangerous
+	     callback to warn that GP is not defined.  */
+	}
+    }
+
+  /* Go through the sections and collect the .reginfo and .mdebug
+     information.  */
+  reginfo_sec = NULL;
+  mdebug_sec = NULL;
+  gptab_data_sec = NULL;
+  gptab_bss_sec = NULL;
+  for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+    {
+      if (strcmp (o->name, ".reginfo") == 0)
+	{
+	  memset (&reginfo, 0, sizeof reginfo);
+
+	  /* We have found the .reginfo section in the output file.
+	     Look through all the link_orders comprising it and merge
+	     the information together.  */
+	  for (p = o->link_order_head;
+	       p != (struct bfd_link_order *) NULL;
+	       p = p->next)
+	    {
+	      asection *input_section;
+	      bfd *input_bfd;
+	      Elf32_External_RegInfo ext;
+	      Elf32_RegInfo sub;
+
+	      if (p->type != bfd_indirect_link_order)
+		{
+		  if (p->type == bfd_data_link_order)
+		    continue;
+		  abort ();
+		}
+
+	      input_section = p->u.indirect.section;
+	      input_bfd = input_section->owner;
+
+	      /* The linker emulation code has probably clobbered the
+                 size to be zero bytes.  */
+	      if (input_section->_raw_size == 0)
+		input_section->_raw_size = sizeof (Elf32_External_RegInfo);
+
+	      if (! bfd_get_section_contents (input_bfd, input_section,
+					      (PTR) &ext,
+					      (file_ptr) 0,
+					      (bfd_size_type) sizeof ext))
+		return false;
+
+	      bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);
+
+	      reginfo.ri_gprmask |= sub.ri_gprmask;
+	      reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
+	      reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
+	      reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
+	      reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
+
+	      /* ri_gp_value is set by the function
+		 mips_elf32_section_processing when the section is
+		 finally written out.  */
+
+	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
+		 elf_link_input_bfd ignores this section.  */
+	      input_section->flags &= ~SEC_HAS_CONTENTS;
+	    }
+
+	  /* Size has been set in _bfd_mips_elf_always_size_sections.  */
+	  BFD_ASSERT(o->_raw_size == sizeof (Elf32_External_RegInfo));
+
+	  /* Skip this section later on (I don't think this currently
+	     matters, but someday it might).  */
+	  o->link_order_head = (struct bfd_link_order *) NULL;
+
+	  reginfo_sec = o;
+	}
+
+      if (strcmp (o->name, ".mdebug") == 0)
+	{
+	  struct extsym_info einfo;
+	  bfd_vma last;
+
+	  /* We have found the .mdebug section in the output file.
+	     Look through all the link_orders comprising it and merge
+	     the information together.  */
+	  symhdr->magic = swap->sym_magic;
+	  /* FIXME: What should the version stamp be?  */
+	  symhdr->vstamp = 0;
+	  symhdr->ilineMax = 0;
+	  symhdr->cbLine = 0;
+	  symhdr->idnMax = 0;
+	  symhdr->ipdMax = 0;
+	  symhdr->isymMax = 0;
+	  symhdr->ioptMax = 0;
+	  symhdr->iauxMax = 0;
+	  symhdr->issMax = 0;
+	  symhdr->issExtMax = 0;
+	  symhdr->ifdMax = 0;
+	  symhdr->crfd = 0;
+	  symhdr->iextMax = 0;
+
+	  /* We accumulate the debugging information itself in the
+	     debug_info structure.  */
+	  debug.line = NULL;
+	  debug.external_dnr = NULL;
+	  debug.external_pdr = NULL;
+	  debug.external_sym = NULL;
+	  debug.external_opt = NULL;
+	  debug.external_aux = NULL;
+	  debug.ss = NULL;
+	  debug.ssext = debug.ssext_end = NULL;
+	  debug.external_fdr = NULL;
+	  debug.external_rfd = NULL;
+	  debug.external_ext = debug.external_ext_end = NULL;
+
+	  mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
+	  if (mdebug_handle == (PTR) NULL)
+	    return false;
+
+	  esym.jmptbl = 0;
+	  esym.cobol_main = 0;
+	  esym.weakext = 0;
+	  esym.reserved = 0;
+	  esym.ifd = ifdNil;
+	  esym.asym.iss = issNil;
+	  esym.asym.st = stLocal;
+	  esym.asym.reserved = 0;
+	  esym.asym.index = indexNil;
+	  last = 0;
+	  for (i = 0; i < sizeof (secname) / sizeof (secname[0]); i++)
+	    {
+	      esym.asym.sc = sc[i];
+	      s = bfd_get_section_by_name (abfd, secname[i]);
+	      if (s != NULL)
+		{
+		  esym.asym.value = s->vma;
+		  last = s->vma + s->_raw_size;
+		}
+	      else
+		esym.asym.value = last;
+	      if (!bfd_ecoff_debug_one_external (abfd, &debug, swap,
+						 secname[i], &esym))
+		return false;
+	    }
+
+	  for (p = o->link_order_head;
+	       p != (struct bfd_link_order *) NULL;
+	       p = p->next)
+	    {
+	      asection *input_section;
+	      bfd *input_bfd;
+	      const struct ecoff_debug_swap *input_swap;
+	      struct ecoff_debug_info input_debug;
+	      char *eraw_src;
+	      char *eraw_end;
+
+	      if (p->type != bfd_indirect_link_order)
+		{
+		  if (p->type == bfd_data_link_order)
+		    continue;
+		  abort ();
+		}
+
+	      input_section = p->u.indirect.section;
+	      input_bfd = input_section->owner;
+
+	      if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
+		  || (get_elf_backend_data (input_bfd)
+		      ->elf_backend_ecoff_debug_swap) == NULL)
+		{
+		  /* I don't know what a non MIPS ELF bfd would be
+		     doing with a .mdebug section, but I don't really
+		     want to deal with it.  */
+		  continue;
+		}
+
+	      input_swap = (get_elf_backend_data (input_bfd)
+			    ->elf_backend_ecoff_debug_swap);
+
+	      BFD_ASSERT (p->size == input_section->_raw_size);
+
+	      /* The ECOFF linking code expects that we have already
+		 read in the debugging information and set up an
+		 ecoff_debug_info structure, so we do that now.  */
+	      if (! _bfd_mips_elf_read_ecoff_info (input_bfd, input_section,
+						   &input_debug))
+		return false;
+
+	      if (! (bfd_ecoff_debug_accumulate
+		     (mdebug_handle, abfd, &debug, swap, input_bfd,
+		      &input_debug, input_swap, info)))
+		return false;
+
+	      /* Loop through the external symbols.  For each one with
+		 interesting information, try to find the symbol in
+		 the linker global hash table and save the information
+		 for the output external symbols.  */
+	      eraw_src = input_debug.external_ext;
+	      eraw_end = (eraw_src
+			  + (input_debug.symbolic_header.iextMax
+			     * input_swap->external_ext_size));
+	      for (;
+		   eraw_src < eraw_end;
+		   eraw_src += input_swap->external_ext_size)
+		{
+		  EXTR ext;
+		  const char *name;
+		  struct mips_elf_link_hash_entry *h;
+
+		  (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
+		  if (ext.asym.sc == scNil
+		      || ext.asym.sc == scUndefined
+		      || ext.asym.sc == scSUndefined)
+		    continue;
+
+		  name = input_debug.ssext + ext.asym.iss;
+		  h = mips_elf_link_hash_lookup (mips_elf_hash_table (info),
+						 name, false, false, true);
+		  if (h == NULL || h->esym.ifd != -2)
+		    continue;
+
+		  if (ext.ifd != -1)
+		    {
+		      BFD_ASSERT (ext.ifd
+				  < input_debug.symbolic_header.ifdMax);
+		      ext.ifd = input_debug.ifdmap[ext.ifd];
+		    }
+
+		  h->esym = ext;
+		}
+
+	      /* Free up the information we just read.  */
+	      free (input_debug.line);
+	      free (input_debug.external_dnr);
+	      free (input_debug.external_pdr);
+	      free (input_debug.external_sym);
+	      free (input_debug.external_opt);
+	      free (input_debug.external_aux);
+	      free (input_debug.ss);
+	      free (input_debug.ssext);
+	      free (input_debug.external_fdr);
+	      free (input_debug.external_rfd);
+	      free (input_debug.external_ext);
+
+	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
+		 elf_link_input_bfd ignores this section.  */
+	      input_section->flags &= ~SEC_HAS_CONTENTS;
+	    }
+
+	  if (SGI_COMPAT (abfd) && info->shared)
+	    {
+	      /* Create .rtproc section.  */
+	      rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
+	      if (rtproc_sec == NULL)
+		{
+		  flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
+				    | SEC_LINKER_CREATED | SEC_READONLY);
+
+		  rtproc_sec = bfd_make_section (abfd, ".rtproc");
+		  if (rtproc_sec == NULL
+		      || ! bfd_set_section_flags (abfd, rtproc_sec, flags)
+		      || ! bfd_set_section_alignment (abfd, rtproc_sec, 4))
+		    return false;
+		}
+
+	      if (! mips_elf_create_procedure_table (mdebug_handle, abfd,
+						     info, rtproc_sec,
+						     &debug))
+		return false;
+	    }
+
+	  /* Build the external symbol information.  */
+	  einfo.abfd = abfd;
+	  einfo.info = info;
+	  einfo.debug = &debug;
+	  einfo.swap = swap;
+	  einfo.failed = false;
+	  mips_elf_link_hash_traverse (mips_elf_hash_table (info),
+				       mips_elf_output_extsym,
+				       (PTR) &einfo);
+	  if (einfo.failed)
+	    return false;
+
+	  /* Set the size of the .mdebug section.  */
+	  o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
+
+	  /* Skip this section later on (I don't think this currently
+	     matters, but someday it might).  */
+	  o->link_order_head = (struct bfd_link_order *) NULL;
+
+	  mdebug_sec = o;
+	}
+
+      if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
+	{
+	  const char *subname;
+	  unsigned int c;
+	  Elf32_gptab *tab;
+	  Elf32_External_gptab *ext_tab;
+	  unsigned int j;
+
+	  /* The .gptab.sdata and .gptab.sbss sections hold
+	     information describing how the small data area would
+	     change depending upon the -G switch.  These sections
+	     not used in executables files.  */
+	  if (! info->relocateable)
+	    {
+	      for (p = o->link_order_head;
+		   p != (struct bfd_link_order *) NULL;
+		   p = p->next)
+		{
+		  asection *input_section;
+
+		  if (p->type != bfd_indirect_link_order)
+		    {
+		      if (p->type == bfd_data_link_order)
+			continue;
+		      abort ();
+		    }
+
+		  input_section = p->u.indirect.section;
+
+		  /* Hack: reset the SEC_HAS_CONTENTS flag so that
+		     elf_link_input_bfd ignores this section.  */
+		  input_section->flags &= ~SEC_HAS_CONTENTS;
+		}
+
+	      /* Skip this section later on (I don't think this
+		 currently matters, but someday it might).  */
+	      o->link_order_head = (struct bfd_link_order *) NULL;
+
+	      /* Really remove the section.  */
+	      for (secpp = &abfd->sections;
+		   *secpp != o;
+		   secpp = &(*secpp)->next)
+		;
+	      bfd_section_list_remove (abfd, secpp);
+	      --abfd->section_count;
+
+	      continue;
+	    }
+
+	  /* There is one gptab for initialized data, and one for
+	     uninitialized data.  */
+	  if (strcmp (o->name, ".gptab.sdata") == 0)
+	    gptab_data_sec = o;
+	  else if (strcmp (o->name, ".gptab.sbss") == 0)
+	    gptab_bss_sec = o;
+	  else
+	    {
+	      (*_bfd_error_handler)
+		(_("%s: illegal section name `%s'"),
+		 bfd_get_filename (abfd), o->name);
+	      bfd_set_error (bfd_error_nonrepresentable_section);
+	      return false;
+	    }
+
+	  /* The linker script always combines .gptab.data and
+	     .gptab.sdata into .gptab.sdata, and likewise for
+	     .gptab.bss and .gptab.sbss.  It is possible that there is
+	     no .sdata or .sbss section in the output file, in which
+	     case we must change the name of the output section.  */
+	  subname = o->name + sizeof ".gptab" - 1;
+	  if (bfd_get_section_by_name (abfd, subname) == NULL)
+	    {
+	      if (o == gptab_data_sec)
+		o->name = ".gptab.data";
+	      else
+		o->name = ".gptab.bss";
+	      subname = o->name + sizeof ".gptab" - 1;
+	      BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
+	    }
+
+	  /* Set up the first entry.  */
+	  c = 1;
+	  amt = c * sizeof (Elf32_gptab);
+	  tab = (Elf32_gptab *) bfd_malloc (amt);
+	  if (tab == NULL)
+	    return false;
+	  tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
+	  tab[0].gt_header.gt_unused = 0;
+
+	  /* Combine the input sections.  */
+	  for (p = o->link_order_head;
+	       p != (struct bfd_link_order *) NULL;
+	       p = p->next)
+	    {
+	      asection *input_section;
+	      bfd *input_bfd;
+	      bfd_size_type size;
+	      unsigned long last;
+	      bfd_size_type gpentry;
+
+	      if (p->type != bfd_indirect_link_order)
+		{
+		  if (p->type == bfd_data_link_order)
+		    continue;
+		  abort ();
+		}
+
+	      input_section = p->u.indirect.section;
+	      input_bfd = input_section->owner;
+
+	      /* Combine the gptab entries for this input section one
+		 by one.  We know that the input gptab entries are
+		 sorted by ascending -G value.  */
+	      size = bfd_section_size (input_bfd, input_section);
+	      last = 0;
+	      for (gpentry = sizeof (Elf32_External_gptab);
+		   gpentry < size;
+		   gpentry += sizeof (Elf32_External_gptab))
+		{
+		  Elf32_External_gptab ext_gptab;
+		  Elf32_gptab int_gptab;
+		  unsigned long val;
+		  unsigned long add;
+		  boolean exact;
+		  unsigned int look;
+
+		  if (! (bfd_get_section_contents
+			 (input_bfd, input_section, (PTR) &ext_gptab,
+			  (file_ptr) gpentry,
+			  (bfd_size_type) sizeof (Elf32_External_gptab))))
+		    {
+		      free (tab);
+		      return false;
+		    }
+
+		  bfd_mips_elf32_swap_gptab_in (input_bfd, &ext_gptab,
+						&int_gptab);
+		  val = int_gptab.gt_entry.gt_g_value;
+		  add = int_gptab.gt_entry.gt_bytes - last;
+
+		  exact = false;
+		  for (look = 1; look < c; look++)
+		    {
+		      if (tab[look].gt_entry.gt_g_value >= val)
+			tab[look].gt_entry.gt_bytes += add;
+
+		      if (tab[look].gt_entry.gt_g_value == val)
+			exact = true;
+		    }
+
+		  if (! exact)
+		    {
+		      Elf32_gptab *new_tab;
+		      unsigned int max;
+
+		      /* We need a new table entry.  */
+		      amt = (bfd_size_type) (c + 1) * sizeof (Elf32_gptab);
+		      new_tab = (Elf32_gptab *) bfd_realloc ((PTR) tab, amt);
+		      if (new_tab == NULL)
+			{
+			  free (tab);
+			  return false;
+			}
+		      tab = new_tab;
+		      tab[c].gt_entry.gt_g_value = val;
+		      tab[c].gt_entry.gt_bytes = add;
+
+		      /* Merge in the size for the next smallest -G
+			 value, since that will be implied by this new
+			 value.  */
+		      max = 0;
+		      for (look = 1; look < c; look++)
+			{
+			  if (tab[look].gt_entry.gt_g_value < val
+			      && (max == 0
+				  || (tab[look].gt_entry.gt_g_value
+				      > tab[max].gt_entry.gt_g_value)))
+			    max = look;
+			}
+		      if (max != 0)
+			tab[c].gt_entry.gt_bytes +=
+			  tab[max].gt_entry.gt_bytes;
+
+		      ++c;
+		    }
+
+		  last = int_gptab.gt_entry.gt_bytes;
+		}
+
+	      /* Hack: reset the SEC_HAS_CONTENTS flag so that
+		 elf_link_input_bfd ignores this section.  */
+	      input_section->flags &= ~SEC_HAS_CONTENTS;
+	    }
+
+	  /* The table must be sorted by -G value.  */
+	  if (c > 2)
+	    qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
+
+	  /* Swap out the table.  */
+	  amt = (bfd_size_type) c * sizeof (Elf32_External_gptab);
+	  ext_tab = (Elf32_External_gptab *) bfd_alloc (abfd, amt);
+	  if (ext_tab == NULL)
+	    {
+	      free (tab);
+	      return false;
+	    }
+
+	  for (j = 0; j < c; j++)
+	    bfd_mips_elf32_swap_gptab_out (abfd, tab + j, ext_tab + j);
+	  free (tab);
+
+	  o->_raw_size = c * sizeof (Elf32_External_gptab);
+	  o->contents = (bfd_byte *) ext_tab;
+
+	  /* Skip this section later on (I don't think this currently
+	     matters, but someday it might).  */
+	  o->link_order_head = (struct bfd_link_order *) NULL;
+	}
+    }
+
+  /* Invoke the regular ELF backend linker to do all the work.  */
+  if (ABI_64_P (abfd))
+    {
+#ifdef BFD64
+      if (!bfd_elf64_bfd_final_link (abfd, info))
+	return false;
+#else
+      abort ();
+      return false;
+#endif /* BFD64 */
+    }
+  else if (!bfd_elf32_bfd_final_link (abfd, info))
+    return false;
+
+  /* Now write out the computed sections.  */
+
+  if (reginfo_sec != (asection *) NULL)
+    {
+      Elf32_External_RegInfo ext;
+
+      bfd_mips_elf32_swap_reginfo_out (abfd, &reginfo, &ext);
+      if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
+				      (file_ptr) 0,
+				      (bfd_size_type) sizeof ext))
+	return false;
+    }
+
+  if (mdebug_sec != (asection *) NULL)
+    {
+      BFD_ASSERT (abfd->output_has_begun);
+      if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
+					       swap, info,
+					       mdebug_sec->filepos))
+	return false;
+
+      bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
+    }
+
+  if (gptab_data_sec != (asection *) NULL)
+    {
+      if (! bfd_set_section_contents (abfd, gptab_data_sec,
+				      gptab_data_sec->contents,
+				      (file_ptr) 0,
+				      gptab_data_sec->_raw_size))
+	return false;
+    }
+
+  if (gptab_bss_sec != (asection *) NULL)
+    {
+      if (! bfd_set_section_contents (abfd, gptab_bss_sec,
+				      gptab_bss_sec->contents,
+				      (file_ptr) 0,
+				      gptab_bss_sec->_raw_size))
+	return false;
+    }
+
+  if (SGI_COMPAT (abfd))
+    {
+      rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
+      if (rtproc_sec != NULL)
+	{
+	  if (! bfd_set_section_contents (abfd, rtproc_sec,
+					  rtproc_sec->contents,
+					  (file_ptr) 0,
+					  rtproc_sec->_raw_size))
+	    return false;
+	}
+    }
+
+  return true;
+}
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+boolean
+_bfd_mips_elf_merge_private_bfd_data (ibfd, obfd)
+     bfd *ibfd;
+     bfd *obfd;
+{
+  flagword old_flags;
+  flagword new_flags;
+  boolean ok;
+  boolean null_input_bfd = true;
+  asection *sec;
+
+  /* Check if we have the same endianess */
+  if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
+    return false;
+
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return true;
+
+  new_flags = elf_elfheader (ibfd)->e_flags;
+  elf_elfheader (obfd)->e_flags |= new_flags & EF_MIPS_NOREORDER;
+  old_flags = elf_elfheader (obfd)->e_flags;
+
+  if (! elf_flags_init (obfd))
+    {
+      elf_flags_init (obfd) = true;
+      elf_elfheader (obfd)->e_flags = new_flags;
+      elf_elfheader (obfd)->e_ident[EI_CLASS]
+	= elf_elfheader (ibfd)->e_ident[EI_CLASS];
+
+      if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+	  && bfd_get_arch_info (obfd)->the_default)
+	{
+	  if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
+				   bfd_get_mach (ibfd)))
+	    return false;
+	}
+
+      return true;
+    }
+
+  /* Check flag compatibility.  */
+
+  new_flags &= ~EF_MIPS_NOREORDER;
+  old_flags &= ~EF_MIPS_NOREORDER;
+
+  if (new_flags == old_flags)
+    return true;
+
+  /* Check to see if the input BFD actually contains any sections.
+     If not, its flags may not have been initialised either, but it cannot
+     actually cause any incompatibility.  */
+  for (sec = ibfd->sections; sec != NULL; sec = sec->next)
+    {
+      /* Ignore synthetic sections and empty .text, .data and .bss sections
+	  which are automatically generated by gas.  */
+      if (strcmp (sec->name, ".reginfo")
+	  && strcmp (sec->name, ".mdebug")
+	  && ((!strcmp (sec->name, ".text")
+	       || !strcmp (sec->name, ".data")
+	       || !strcmp (sec->name, ".bss"))
+	      && sec->_raw_size != 0))
+	{
+	  null_input_bfd = false;
+	  break;
+	}
+    }
+  if (null_input_bfd)
+    return true;
+
+  ok = true;
+
+  if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC))
+    {
+      new_flags &= ~EF_MIPS_PIC;
+      old_flags &= ~EF_MIPS_PIC;
+      (*_bfd_error_handler)
+	(_("%s: linking PIC files with non-PIC files"),
+	 bfd_archive_filename (ibfd));
+      ok = false;
+    }
+
+  if ((new_flags & EF_MIPS_CPIC) != (old_flags & EF_MIPS_CPIC))
+    {
+      new_flags &= ~EF_MIPS_CPIC;
+      old_flags &= ~EF_MIPS_CPIC;
+      (*_bfd_error_handler)
+	(_("%s: linking abicalls files with non-abicalls files"),
+	 bfd_archive_filename (ibfd));
+      ok = false;
+    }
+
+  /* Compare the ISA's.  */
+  if ((new_flags & (EF_MIPS_ARCH | EF_MIPS_MACH))
+      != (old_flags & (EF_MIPS_ARCH | EF_MIPS_MACH)))
+    {
+      int new_mach = new_flags & EF_MIPS_MACH;
+      int old_mach = old_flags & EF_MIPS_MACH;
+      int new_isa = elf_mips_isa (new_flags);
+      int old_isa = elf_mips_isa (old_flags);
+
+      /* If either has no machine specified, just compare the general isa's.
+	 Some combinations of machines are ok, if the isa's match.  */
+      if (! new_mach
+	  || ! old_mach
+	  || new_mach == old_mach
+	  )
+	{
+	  /* Don't warn about mixing code using 32-bit ISAs, or mixing code
+	     using 64-bit ISAs.  They will normally use the same data sizes
+	     and calling conventions.  */
+
+	  if ((  (new_isa == 1 || new_isa == 2 || new_isa == 32)
+	       ^ (old_isa == 1 || old_isa == 2 || old_isa == 32)) != 0)
+	    {
+	      (*_bfd_error_handler)
+	       (_("%s: ISA mismatch (-mips%d) with previous modules (-mips%d)"),
+		bfd_archive_filename (ibfd), new_isa, old_isa);
+	      ok = false;
+	    }
+	  else
+	    {
+	      /* Do we need to update the mach field?  */
+	      if (old_mach == 0 && new_mach != 0) 
+		elf_elfheader (obfd)->e_flags |= new_mach;
+
+	      /* Do we need to update the ISA field?  */
+	      if (new_isa > old_isa)
+		{
+		  elf_elfheader (obfd)->e_flags &= ~EF_MIPS_ARCH;
+		  elf_elfheader (obfd)->e_flags
+		    |= new_flags & EF_MIPS_ARCH;
+		}
+	    }
+	}
+      else
+	{
+	  (*_bfd_error_handler)
+	    (_("%s: ISA mismatch (%d) with previous modules (%d)"),
+	     bfd_archive_filename (ibfd),
+	     _bfd_elf_mips_mach (new_flags),
+	     _bfd_elf_mips_mach (old_flags));
+	  ok = false;
+	}
+
+      new_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
+      old_flags &= ~(EF_MIPS_ARCH | EF_MIPS_MACH);
+    }
+
+  /* Compare ABI's.  The 64-bit ABI does not use EF_MIPS_ABI.  But, it
+     does set EI_CLASS differently from any 32-bit ABI.  */
+  if ((new_flags & EF_MIPS_ABI) != (old_flags & EF_MIPS_ABI)
+      || (elf_elfheader (ibfd)->e_ident[EI_CLASS]
+	  != elf_elfheader (obfd)->e_ident[EI_CLASS]))
+    {
+      /* Only error if both are set (to different values).  */
+      if (((new_flags & EF_MIPS_ABI) && (old_flags & EF_MIPS_ABI))
+	  || (elf_elfheader (ibfd)->e_ident[EI_CLASS]
+	      != elf_elfheader (obfd)->e_ident[EI_CLASS]))
+	{
+	  (*_bfd_error_handler)
+	    (_("%s: ABI mismatch: linking %s module with previous %s modules"),
+	     bfd_archive_filename (ibfd),
+	     elf_mips_abi_name (ibfd),
+	     elf_mips_abi_name (obfd));
+	  ok = false;
+	}
+      new_flags &= ~EF_MIPS_ABI;
+      old_flags &= ~EF_MIPS_ABI;
+    }
+
+  /* Warn about any other mismatches */
+  if (new_flags != old_flags)
+    {
+      (*_bfd_error_handler)
+	(_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
+	 bfd_archive_filename (ibfd), (unsigned long) new_flags,
+	 (unsigned long) old_flags);
+      ok = false;
+    }
+
+  if (! ok)
+    {
+      bfd_set_error (bfd_error_bad_value);
+      return false;
+    }
+
+  return true;
+}
+
+/* Function to keep MIPS specific file flags like as EF_MIPS_PIC.  */
+
+boolean
+_bfd_mips_elf_set_private_flags (abfd, flags)
+     bfd *abfd;
+     flagword flags;
+{
+  BFD_ASSERT (!elf_flags_init (abfd)
+	      || elf_elfheader (abfd)->e_flags == flags);
+
+  elf_elfheader (abfd)->e_flags = flags;
+  elf_flags_init (abfd) = true;
+  return true;
+}
+
+boolean
+_bfd_mips_elf_print_private_bfd_data (abfd, ptr)
+     bfd *abfd;
+     PTR ptr;
+{
+  FILE *file = (FILE *) ptr;
+
+  BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+  /* Print normal ELF private data.  */
+  _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+  /* xgettext:c-format */
+  fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+
+  if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_O32)
+    fprintf (file, _(" [abi=O32]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_O64)
+    fprintf (file, _(" [abi=O64]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI32)
+    fprintf (file, _(" [abi=EABI32]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI64)
+    fprintf (file, _(" [abi=EABI64]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI))
+    fprintf (file, _(" [abi unknown]"));
+  else if (ABI_N32_P (abfd))
+    fprintf (file, _(" [abi=N32]"));
+  else if (ABI_64_P (abfd))
+    fprintf (file, _(" [abi=64]"));
+  else
+    fprintf (file, _(" [no abi set]"));
+
+  if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_1)
+    fprintf (file, _(" [mips1]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_2)
+    fprintf (file, _(" [mips2]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_3)
+    fprintf (file, _(" [mips3]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_4)
+    fprintf (file, _(" [mips4]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_5)
+    fprintf (file, _(" [mips5]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_32)
+    fprintf (file, _(" [mips32]"));
+  else if ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) == E_MIPS_ARCH_64)
+    fprintf (file, _(" [mips64]"));
+  else
+    fprintf (file, _(" [unknown ISA]"));
+
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_MDMX)
+    fprintf (file, _(" [mdmx]"));
+
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_M16)
+    fprintf (file, _(" [mips16]"));
+
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_32BITMODE)
+    fprintf (file, _(" [32bitmode]"));
+  else
+    fprintf (file, _(" [not 32bitmode]"));
+
+  fputc ('\n', file);
+
+  return true;
+}
diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h
new file mode 100644
index 0000000..959bfa6
--- /dev/null
+++ b/bfd/elfxx-mips.h
@@ -0,0 +1,100 @@
+/* MIPS ELF specific backend routines.
+   Copyright 2002 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 "elf/common.h"
+#include "elf/internal.h"
+
+extern void _bfd_mips_elf_symbol_processing
+  PARAMS ((bfd *, asymbol *));
+extern boolean _bfd_mips_elf_section_processing
+  PARAMS ((bfd *, Elf_Internal_Shdr *));
+extern boolean _bfd_mips_elf_section_from_shdr
+  PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
+extern boolean _bfd_mips_elf_fake_sections
+  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
+extern boolean _bfd_mips_elf_section_from_bfd_section
+  PARAMS ((bfd *, asection *, int *));
+extern boolean _bfd_mips_elf_add_symbol_hook
+  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+	   const char **, flagword *, asection **, bfd_vma *));
+extern boolean _bfd_mips_elf_link_output_symbol_hook
+  PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
+	   asection *));
+extern boolean _bfd_mips_elf_create_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_mips_elf_check_relocs
+  PARAMS ((bfd *, struct bfd_link_info *, asection *,
+	   const Elf_Internal_Rela *));
+extern boolean _bfd_mips_elf_adjust_dynamic_symbol
+  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+extern boolean _bfd_mips_elf_always_size_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_mips_elf_size_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_mips_elf_relocate_section
+  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+extern boolean _bfd_mips_elf_finish_dynamic_symbol
+  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
+	   Elf_Internal_Sym *));
+extern boolean _bfd_mips_elf_finish_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+extern void _bfd_mips_elf_final_write_processing
+  PARAMS ((bfd *, boolean));
+extern int _bfd_mips_elf_additional_program_headers
+  PARAMS ((bfd *));
+extern boolean _bfd_mips_elf_modify_segment_map
+  PARAMS ((bfd *));
+extern asection * _bfd_mips_elf_gc_mark_hook
+  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
+extern boolean _bfd_mips_elf_gc_sweep_hook
+  PARAMS ((bfd *, struct bfd_link_info *, asection *,
+	   const Elf_Internal_Rela *));
+extern void _bfd_mips_elf_copy_indirect_symbol
+  PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
+extern void _bfd_mips_elf_hide_symbol
+  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
+extern boolean _bfd_mips_elf_find_nearest_line
+  PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+	   const char **, unsigned int *));
+extern boolean _bfd_mips_elf_set_section_contents
+  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents
+  PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+	   bfd_byte *, boolean, asymbol **));
+extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
+  PARAMS ((bfd *));
+extern boolean _bfd_mips_elf_final_link
+  PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_mips_elf_merge_private_bfd_data
+  PARAMS ((bfd *, bfd *));
+extern boolean _bfd_mips_elf_set_private_flags
+  PARAMS ((bfd *, flagword));
+extern boolean _bfd_mips_elf_print_private_bfd_data
+  PARAMS ((bfd *, PTR));
+
+extern boolean _bfd_mips_elf_read_ecoff_info
+  PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
+extern bfd_reloc_status_type _bfd_mips_elf_gprel16_with_gp
+  PARAMS ((bfd *, asymbol *, arelent *, asection *, boolean, PTR, bfd_vma));
+extern bfd_reloc_status_type _bfd_mips_elf32_gprel16_reloc
+  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern unsigned long _bfd_elf_mips_mach
+  PARAMS ((flagword));
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index fda0f0d..c1c106f 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -1,5 +1,5 @@
 /* Target definitions for NN-bit ELF
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -169,6 +169,10 @@
   _bfd_elf_canonicalize_dynamic_reloc
 #endif
 
+#ifndef bfd_elfNN_bfd_link_hash_table_free
+#define bfd_elfNN_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#endif
+
 #ifdef elf_backend_relocate_section
 #ifndef bfd_elfNN_bfd_link_hash_table_create
 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
@@ -367,6 +371,12 @@
 #ifndef elf_backend_write_section
 #define elf_backend_write_section		NULL
 #endif
+#ifndef elf_backend_mips_irix_compat
+#define elf_backend_mips_irix_compat		NULL
+#endif
+#ifndef elf_backend_mips_rtype_to_howto
+#define elf_backend_mips_rtype_to_howto		NULL
+#endif
 
 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
    sections, but not both.  They defined USE_REL to indicate SHT_REL
@@ -458,6 +468,8 @@
   elf_backend_discard_info,
   elf_backend_ignore_discarded_relocs,
   elf_backend_write_section,
+  elf_backend_mips_irix_compat,
+  elf_backend_mips_rtype_to_howto,
   elf_backend_ecoff_debug_swap,
   ELF_MACHINE_ALT1,
   ELF_MACHINE_ALT2,
@@ -523,9 +535,9 @@
 
   /* ar_max_namelen: maximum number of characters in an archive header
      FIXME:  this really has nothing to do with ELF, this is a characteristic
-     of the archiver and should be independently tunable.  This value is
-     a WAG (wild a** guess) */
-  14,
+     of the archiver and should be independently tunable.  The System V ABI,
+     Chapter 7 (Formats & Protocols), Archive section sets this as 15.  */
+  15,
 
   /* Routines to byte-swap various sized integers from the data sections */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
@@ -619,9 +631,9 @@
 
   /* ar_max_namelen: maximum number of characters in an archive header
      FIXME:  this really has nothing to do with ELF, this is a characteristic
-     of the archiver and should be independently tunable.  This value is
-     a WAG (wild a** guess) */
-  14,
+     of the archiver and should be independently tunable.  The System V ABI,
+     Chapter 7 (Formats & Protocols), Archive section sets this as 15.  */
+  15,
 
   /* Routines to byte-swap various sized integers from the data sections */
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
diff --git a/bfd/i386linux.c b/bfd/i386linux.c
index bb93650..755b456 100644
--- a/bfd/i386linux.c
+++ b/bfd/i386linux.c
@@ -1,5 +1,5 @@
 /* BFD back-end for linux flavored i386 a.out binaries.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2001
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -438,6 +438,9 @@
   struct linux_link_hash_entry *h1, *h2;
   boolean exists;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct linux_link_hash_entry *) h->root.root.u.i.link;
+
   if (h->root.root.type == bfd_link_hash_undefined
       && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
 		  sizeof NEEDS_SHRLIB - 1) == 0)
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index f192b22..655ecfd 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -1,5 +1,5 @@
 /* BFD back-end for MS-DOS executables.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002
    Free Software Foundation, Inc.
    Written by Bryan Ford of the University of Utah.
 
@@ -174,6 +174,7 @@
 #define msdos_bfd_gc_sections bfd_generic_gc_sections
 #define msdos_bfd_merge_sections bfd_generic_merge_sections
 #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define msdos_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define msdos_bfd_final_link _bfd_generic_final_link
 #define msdos_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c
index 626fc77..099a714 100644
--- a/bfd/i386os9k.c
+++ b/bfd/i386os9k.c
@@ -1,5 +1,5 @@
 /* BFD back-end for os9000 i386 binaries.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -330,6 +330,7 @@
 #define os9k_bfd_gc_sections bfd_generic_gc_sections
 #define os9k_bfd_merge_sections bfd_generic_merge_sections
 #define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define os9k_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define os9k_bfd_final_link _bfd_generic_final_link
 #define os9k_bfd_link_split_section  _bfd_generic_link_split_section
diff --git a/bfd/ieee.c b/bfd/ieee.c
index df7cfd6..cd56101 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -4011,6 +4011,7 @@
 #define ieee_bfd_gc_sections bfd_generic_gc_sections
 #define ieee_bfd_merge_sections bfd_generic_merge_sections
 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define ieee_bfd_final_link _bfd_generic_final_link
 #define ieee_bfd_link_split_section  _bfd_generic_link_split_section
@@ -4084,6 +4085,7 @@
 
   /* ieee_sizeof_headers, ieee_bfd_get_relocated_section_contents,
      ieee_bfd_relax_section, ieee_bfd_link_hash_table_create,
+     _bfd_generic_link_hash_table_free,
      ieee_bfd_link_add_symbols, ieee_bfd_final_link,
      ieee_bfd_link_split_section, ieee_bfd_gc_sections,
      ieee_bfd_merge_sections  */
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 0b02e6d..0aad164 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -3,21 +3,21 @@
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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 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.
+   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.  */
+   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.  */
 
 /* This is what Intel Hex files look like:
 
@@ -147,12 +147,12 @@
 
 #define CHUNK 16
 
-/* Macros for converting between hex and binary. */
+/* Macros for converting between hex and binary.  */
 
-#define NIBBLE(x) (hex_value (x))
+#define NIBBLE(x)    (hex_value (x))
 #define HEX2(buffer) ((NIBBLE ((buffer)[0]) << 4) + NIBBLE ((buffer)[1]))
 #define HEX4(buffer) ((HEX2 (buffer) << 8) + HEX2 ((buffer) + 2))
-#define ISHEX(x) (hex_p (x))
+#define ISHEX(x)     (hex_p (x))
 
 /* When we write out an ihex value, the values can not be output as
    they are seen.  Instead, we hold them in memory in this structure.  */
@@ -288,6 +288,7 @@
   lineno = 1;
   error = false;
   bufsize = 0;
+
   while ((c = ihex_get_byte (abfd, &error)) != EOF)
     {
       if (c == '\r')
@@ -314,11 +315,9 @@
 	  unsigned int chksum;
 
 	  /* This is a data record.  */
-
 	  pos = bfd_tell (abfd) - 1;
 
 	  /* Read the header bytes.  */
-
 	  if (bfd_bread (hdr, (bfd_size_type) 8, abfd) != 8)
 	    goto error_return;
 
@@ -336,7 +335,6 @@
 	  type = HEX2 (hdr + 6);
 
 	  /* Read the data bytes.  */
-
 	  chars = len * 2 + 2;
 	  if (chars >= bufsize)
 	    {
@@ -553,7 +551,6 @@
     }
 
   /* OK, it looks like it really is an Intel Hex file.  */
-
   if (! ihex_mkobject (abfd)
       || ! ihex_scan (abfd))
     return NULL;
@@ -873,6 +870,11 @@
 	    }
 
 	  rec_addr = where - (extbase + segbase);
+
+          /* Output records shouldn't cross 64K boundaries.  */
+          if (rec_addr + now > 0xffff)
+            now = 0x10000 - rec_addr;
+
 	  if (! ihex_write_record (abfd, now, rec_addr, 0, p))
 	    return false;
 
@@ -976,6 +978,7 @@
 #define ihex_bfd_gc_sections bfd_generic_gc_sections
 #define ihex_bfd_merge_sections bfd_generic_merge_sections
 #define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define ihex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define ihex_bfd_final_link _bfd_generic_final_link
 #define ihex_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index ed417ca..68006fa 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -1,7 +1,7 @@
 /* libbfd.h -- Declarations used by bfd library *implementation*.
    (This include file is not for users of the library.)
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -324,6 +324,8 @@
    bfd_false)
 #define _bfd_nolink_bfd_link_hash_table_create \
   ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define _bfd_nolink_bfd_link_hash_table_free \
+  ((void (*) PARAMS ((struct bfd_link_hash_table *))) bfd_void)
 #define _bfd_nolink_bfd_link_add_symbols \
   ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
 #define _bfd_nolink_bfd_final_link \
@@ -389,6 +391,10 @@
 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
   PARAMS ((bfd *));
 
+/* Generic link hash table destruction routine.  */
+extern void _bfd_generic_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
+
 /* Generic add symbol routine.  */
 extern boolean _bfd_generic_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 8560d2f..a397d82 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -593,7 +593,7 @@
 	bfd_write_bigendian_4byte_int
 
 SYNOPSIS
-	void bfd_write_bigendian_4byte_int (bfd *, unsigned int);
+	boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
 
 DESCRIPTION
 	Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
@@ -601,15 +601,14 @@
 	archives.
 
 */
-void
+boolean
 bfd_write_bigendian_4byte_int (abfd, i)
      bfd *abfd;
      unsigned int i;
 {
   bfd_byte buffer[4];
   bfd_putb32 ((bfd_vma) i, buffer);
-  if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 4, abfd) != 4)
-    abort ();
+  return bfd_bwrite ((PTR) buffer, (bfd_size_type) 4, abfd) == 4;
 }
 
 bfd_vma
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index d864b22..cbe4973 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -6,7 +6,7 @@
 /* libbfd.h -- Declarations used by bfd library *implementation*.
    (This include file is not for users of the library.)
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -329,6 +329,8 @@
    bfd_false)
 #define _bfd_nolink_bfd_link_hash_table_create \
   ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define _bfd_nolink_bfd_link_hash_table_free \
+  ((void (*) PARAMS ((struct bfd_link_hash_table *))) bfd_void)
 #define _bfd_nolink_bfd_link_add_symbols \
   ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
 #define _bfd_nolink_bfd_final_link \
@@ -394,6 +396,10 @@
 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
   PARAMS ((bfd *));
 
+/* Generic link hash table destruction routine.  */
+extern void _bfd_generic_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
+
 /* Generic add symbol routine.  */
 extern boolean _bfd_generic_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
@@ -586,7 +592,7 @@
 
 /* And more follows */
 
-void
+boolean
 bfd_write_bigendian_4byte_int PARAMS ((bfd *, unsigned int));
 
 unsigned int
@@ -752,55 +758,6 @@
   "BFD_RELOC_MIPS_REL16",
   "BFD_RELOC_MIPS_RELGOT",
   "BFD_RELOC_MIPS_JALR",
-  "BFD_RELOC_SH_GOT_LOW16",
-  "BFD_RELOC_SH_GOT_MEDLOW16",
-  "BFD_RELOC_SH_GOT_MEDHI16",
-  "BFD_RELOC_SH_GOT_HI16",
-  "BFD_RELOC_SH_GOTPLT_LOW16",
-  "BFD_RELOC_SH_GOTPLT_MEDLOW16",
-  "BFD_RELOC_SH_GOTPLT_MEDHI16",
-  "BFD_RELOC_SH_GOTPLT_HI16",
-  "BFD_RELOC_SH_PLT_LOW16",
-  "BFD_RELOC_SH_PLT_MEDLOW16",
-  "BFD_RELOC_SH_PLT_MEDHI16",
-  "BFD_RELOC_SH_PLT_HI16",
-  "BFD_RELOC_SH_GOTOFF_LOW16",
-  "BFD_RELOC_SH_GOTOFF_MEDLOW16",
-  "BFD_RELOC_SH_GOTOFF_MEDHI16",
-  "BFD_RELOC_SH_GOTOFF_HI16",
-  "BFD_RELOC_SH_GOTPC_LOW16",
-  "BFD_RELOC_SH_GOTPC_MEDLOW16",
-  "BFD_RELOC_SH_GOTPC_MEDHI16",
-  "BFD_RELOC_SH_GOTPC_HI16",
-  "BFD_RELOC_SH_COPY64",
-  "BFD_RELOC_SH_GLOB_DAT64",
-  "BFD_RELOC_SH_JMP_SLOT64",
-  "BFD_RELOC_SH_RELATIVE64",
-  "BFD_RELOC_SH_GOT10BY4",
-  "BFD_RELOC_SH_GOT10BY8",
-  "BFD_RELOC_SH_GOTPLT10BY4",
-  "BFD_RELOC_SH_GOTPLT10BY8",
-  "BFD_RELOC_SH_GOTPLT32",
-  "BFD_RELOC_SH_SHMEDIA_CODE",
-  "BFD_RELOC_SH_IMMU5",
-  "BFD_RELOC_SH_IMMS6",
-  "BFD_RELOC_SH_IMMS6BY32",
-  "BFD_RELOC_SH_IMMU6",
-  "BFD_RELOC_SH_IMMS10",
-  "BFD_RELOC_SH_IMMS10BY2",
-  "BFD_RELOC_SH_IMMS10BY4",
-  "BFD_RELOC_SH_IMMS10BY8",
-  "BFD_RELOC_SH_IMMS16",
-  "BFD_RELOC_SH_IMMU16",
-  "BFD_RELOC_SH_IMM_LOW16",
-  "BFD_RELOC_SH_IMM_LOW16_PCREL",
-  "BFD_RELOC_SH_IMM_MEDLOW16",
-  "BFD_RELOC_SH_IMM_MEDLOW16_PCREL",
-  "BFD_RELOC_SH_IMM_MEDHI16",
-  "BFD_RELOC_SH_IMM_MEDHI16_PCREL",
-  "BFD_RELOC_SH_IMM_HI16",
-  "BFD_RELOC_SH_IMM_HI16_PCREL",
-  "BFD_RELOC_SH_PT_16",
 
   "BFD_RELOC_386_GOT32",
   "BFD_RELOC_386_PLT32",
@@ -947,6 +904,55 @@
   "BFD_RELOC_SH_JMP_SLOT",
   "BFD_RELOC_SH_RELATIVE",
   "BFD_RELOC_SH_GOTPC",
+  "BFD_RELOC_SH_GOT_LOW16",
+  "BFD_RELOC_SH_GOT_MEDLOW16",
+  "BFD_RELOC_SH_GOT_MEDHI16",
+  "BFD_RELOC_SH_GOT_HI16",
+  "BFD_RELOC_SH_GOTPLT_LOW16",
+  "BFD_RELOC_SH_GOTPLT_MEDLOW16",
+  "BFD_RELOC_SH_GOTPLT_MEDHI16",
+  "BFD_RELOC_SH_GOTPLT_HI16",
+  "BFD_RELOC_SH_PLT_LOW16",
+  "BFD_RELOC_SH_PLT_MEDLOW16",
+  "BFD_RELOC_SH_PLT_MEDHI16",
+  "BFD_RELOC_SH_PLT_HI16",
+  "BFD_RELOC_SH_GOTOFF_LOW16",
+  "BFD_RELOC_SH_GOTOFF_MEDLOW16",
+  "BFD_RELOC_SH_GOTOFF_MEDHI16",
+  "BFD_RELOC_SH_GOTOFF_HI16",
+  "BFD_RELOC_SH_GOTPC_LOW16",
+  "BFD_RELOC_SH_GOTPC_MEDLOW16",
+  "BFD_RELOC_SH_GOTPC_MEDHI16",
+  "BFD_RELOC_SH_GOTPC_HI16",
+  "BFD_RELOC_SH_COPY64",
+  "BFD_RELOC_SH_GLOB_DAT64",
+  "BFD_RELOC_SH_JMP_SLOT64",
+  "BFD_RELOC_SH_RELATIVE64",
+  "BFD_RELOC_SH_GOT10BY4",
+  "BFD_RELOC_SH_GOT10BY8",
+  "BFD_RELOC_SH_GOTPLT10BY4",
+  "BFD_RELOC_SH_GOTPLT10BY8",
+  "BFD_RELOC_SH_GOTPLT32",
+  "BFD_RELOC_SH_SHMEDIA_CODE",
+  "BFD_RELOC_SH_IMMU5",
+  "BFD_RELOC_SH_IMMS6",
+  "BFD_RELOC_SH_IMMS6BY32",
+  "BFD_RELOC_SH_IMMU6",
+  "BFD_RELOC_SH_IMMS10",
+  "BFD_RELOC_SH_IMMS10BY2",
+  "BFD_RELOC_SH_IMMS10BY4",
+  "BFD_RELOC_SH_IMMS10BY8",
+  "BFD_RELOC_SH_IMMS16",
+  "BFD_RELOC_SH_IMMU16",
+  "BFD_RELOC_SH_IMM_LOW16",
+  "BFD_RELOC_SH_IMM_LOW16_PCREL",
+  "BFD_RELOC_SH_IMM_MEDLOW16",
+  "BFD_RELOC_SH_IMM_MEDLOW16_PCREL",
+  "BFD_RELOC_SH_IMM_MEDHI16",
+  "BFD_RELOC_SH_IMM_MEDHI16_PCREL",
+  "BFD_RELOC_SH_IMM_HI16",
+  "BFD_RELOC_SH_IMM_HI16_PCREL",
+  "BFD_RELOC_SH_PT_16",
   "BFD_RELOC_THUMB_PCREL_BRANCH9",
   "BFD_RELOC_THUMB_PCREL_BRANCH12",
   "BFD_RELOC_THUMB_PCREL_BRANCH23",
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index bbccbba..618ddda 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -1,6 +1,6 @@
 /* BFD COFF object file private structure.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -580,6 +580,8 @@
   PARAMS ((bfd *, arelent **, asymbol **));
 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
   PARAMS ((bfd *));
+extern void _bfd_xcoff_bfd_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
 extern boolean _bfd_xcoff_bfd_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
 extern boolean _bfd_xcoff_bfd_final_link
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index f26a692..2e9a7d8 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -4,7 +4,7 @@
 
 /* BFD COFF object file private structure.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -584,6 +584,8 @@
   PARAMS ((bfd *, arelent **, asymbol **));
 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
   PARAMS ((bfd *));
+extern void _bfd_xcoff_bfd_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *));
 extern boolean _bfd_xcoff_bfd_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
 extern boolean _bfd_xcoff_bfd_final_link
diff --git a/bfd/libecoff.h b/bfd/libecoff.h
index 5f9e016..c900ee8 100644
--- a/bfd/libecoff.h
+++ b/bfd/libecoff.h
@@ -1,5 +1,5 @@
 /* BFD ECOFF object file private structure.
-   Copyright 1993, 1994, 1995, 1996, 1999, 2001
+   Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
@@ -330,6 +330,7 @@
 /* ecoff_bfd_relax_section defined by backend.  */
 extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
   PARAMS ((bfd *));
+#define _bfd_ecoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 extern boolean _bfd_ecoff_bfd_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
 extern boolean _bfd_ecoff_bfd_final_link
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h
index 20c3c4a..5e16fb2 100644
--- a/bfd/libxcoff.h
+++ b/bfd/libxcoff.h
@@ -1,22 +1,22 @@
 /* BFD XCOFF object file private structure.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
    Written by Tom Rix, Redhat.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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 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.
+   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.  */
+   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.  */
 
 #ifndef LIBXCOFF_H
 #define LIBXCOFF_H
@@ -31,14 +31,14 @@
   /* COFF backend information.  */
   bfd_coff_backend_data coff;
 
-  /* Magic number */
+  /* Magic number.  */
   unsigned short _xcoff_magic_number;
 
-  /* Architecture and machine for coff_set_arch_mach_hook */
+  /* Architecture and machine for coff_set_arch_mach_hook.  */
   enum bfd_architecture _xcoff_architecture;
   long _xcoff_machine;
 
-  /* function pointers to xcoff specific swap routines */
+  /* Function pointers to xcoff specific swap routines.  */
   void (* _xcoff_swap_ldhdr_in)(bfd *, const PTR, struct internal_ldhdr *);
   void (* _xcoff_swap_ldhdr_out)(bfd *, const struct internal_ldhdr *, PTR);
   void (* _xcoff_swap_ldsym_in)(bfd *, const PTR, struct internal_ldsym *);
@@ -46,33 +46,34 @@
   void (* _xcoff_swap_ldrel_in)(bfd *, const PTR, struct internal_ldrel *);
   void (* _xcoff_swap_ldrel_out)(bfd *, const struct internal_ldrel *, PTR);
 
-  /* size of the external struct */
+  /* Size of the external struct.  */
   unsigned int _xcoff_ldhdrsz;
   unsigned int _xcoff_ldsymsz;
   unsigned int _xcoff_ldrelsz;
 
-  /* size an entry in a descriptor section */
+  /* Size an entry in a descriptor section.  */
   unsigned int _xcoff_function_descriptor_size;
 
-  /* size of the small aout file header */
+  /* Size of the small aout file header.  */
   unsigned int _xcoff_small_aout_header_size;
 
   /* Loader version
      1 : XCOFF32
-     2 : XCOFF64 */
+     2 : XCOFF64.  */
   unsigned long _xcoff_ldhdr_version;
 
-  boolean (* _xcoff_put_symbol_name)(bfd *, struct bfd_strtab_hash *,
-				     struct internal_syment *,
-				     const char *);
+  boolean (* _xcoff_put_symbol_name)
+       PARAMS ((bfd *, struct bfd_strtab_hash *, struct internal_syment *,
+		const char *));
 
-  boolean (* _xcoff_put_ldsymbol_name)(bfd *, struct xcoff_loader_info *,
-				       struct internal_ldsym *,
-				       const char *);
+  boolean (* _xcoff_put_ldsymbol_name)
+       PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
+		const char *));
 
   reloc_howto_type *_xcoff_dynamic_reloc;
 
-  asection * (* _xcoff_create_csect_from_smclas) (bfd *, union internal_auxent *, const char *);
+  asection * (* _xcoff_create_csect_from_smclas)
+       PARAMS ((bfd *, union internal_auxent *, const char *));
 
   /* Line number and relocation overflow.
      XCOFF32 overflows to another section when the line number or the 
@@ -82,7 +83,7 @@
 
   /* Loader section symbol and relocation table offset
      XCOFF32 is after the .loader header
-     XCOFF64 is offset in .loader header  */
+     XCOFF64 is offset in .loader header.  */
   bfd_vma (*_xcoff_loader_symbol_offset)(bfd *, struct internal_ldhdr *);
   bfd_vma (*_xcoff_loader_reloc_offset)(bfd *, struct internal_ldhdr *);
   
@@ -93,21 +94,19 @@
   /* Size of the global link code in bytes of the xcoff_glink_code table.  */
   unsigned long _xcoff_glink_size;
 
-  /* rtinit */
+  /* rtinit.  */
   unsigned int _xcoff_rtinit_size;
   boolean (*_xcoff_generate_rtinit)(bfd *, const char *, const char *, 
 				    boolean);
 };
 
 /* Look up an entry in an XCOFF link hash table.  */
-
 #define xcoff_link_hash_lookup(table, string, create, copy, follow) \
   ((struct xcoff_link_hash_entry *) \
    bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
 			 (follow)))
 
 /* Traverse an XCOFF link hash table.  */
-
 #define xcoff_link_hash_traverse(table, func, info)			\
   (bfd_link_hash_traverse						\
    (&(table)->root,							\
@@ -116,7 +115,6 @@
 
 /* Get the XCOFF link hash table from the info structure.  This is
    just a cast.  */
-
 #define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
 
 
@@ -186,8 +184,11 @@
 #define bfd_xcoff_glink_code(a, b) ((xcoff_backend(a)->_xcoff_glink_code[(b)]))
 #define bfd_xcoff_glink_code_size(a) ((xcoff_backend(a)->_xcoff_glink_size))
 
-/* Check for the magic number U803XTOCMAGIC for 64 bit targets.  */
-#define bfd_xcoff_is_xcoff64(a) (0x01EF == (bfd_xcoff_magic_number(a)))
+/* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit 
+   targets.  */
+#define bfd_xcoff_is_xcoff64(a) \
+  (   (0x01EF == (bfd_xcoff_magic_number(a))) \
+   || (0x01F7 == (bfd_xcoff_magic_number(a))))
 
 /* Check for the magic number U802TOMAGIC for 32 bit targets.  */
 #define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number(a)))
@@ -195,4 +196,30 @@
 #define bfd_xcoff_rtinit_size(a) ((xcoff_backend(a)->_xcoff_rtinit_size))
 #define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend(a)->_xcoff_generate_rtinit ((a), (b), (c), (d))))
 
+/* Accessor macros for tdata.  */
+#define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power))
+#define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power))
+
+/* xcoff*_ppc_relocate_section macros  */
+#define XCOFF_MAX_CALCULATE_RELOCATION (0x1c)
+#define XCOFF_MAX_COMPLAIN_OVERFLOW (4)
+/* N_ONES produces N one bits, without overflowing machine arithmetic.  */
+#ifdef N_ONES
+#undef N_ONES
+#endif
+#define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
+
+#define XCOFF_RELOC_FUNCTION_ARGS \
+  bfd *, asection *, bfd *, struct internal_reloc *, \
+  struct internal_syment *, struct reloc_howto_struct *, bfd_vma, bfd_vma, \
+  bfd_vma *relocation, bfd_byte *contents
+
+#define XCOFF_COMPLAIN_FUNCTION_ARGS \
+  bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *howto
+
+extern boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
+     (XCOFF_RELOC_FUNCTION_ARGS);
+extern boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
+     (XCOFF_COMPLAIN_FUNCTION_ARGS);
+
 #endif /* LIBXCOFF_H */
diff --git a/bfd/linker.c b/bfd/linker.c
index 727be33..b4b9f29 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -675,7 +675,7 @@
   struct generic_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct generic_link_hash_table);
 
-  ret = (struct generic_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct generic_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return (struct bfd_link_hash_table *) NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd,
@@ -687,6 +687,17 @@
   return &ret->root;
 }
 
+void
+_bfd_generic_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash;
+{
+  struct generic_link_hash_table *ret
+    = (struct generic_link_hash_table *) hash;
+
+  bfd_hash_table_free (&ret->root.table);
+  free (ret);
+}
+
 /* Grab the symbols for an object file when doing a generic link.  We
    store the symbols in the outsymbols field.  We need to keep them
    around for the entire link to ensure that we only read them once.
@@ -1419,7 +1430,7 @@
   /* DEFW_ROW 	*/  {DEFW,  DEFW,  DEFW,  NOACT, NOACT, NOACT, NOACT, CYCLE },
   /* COMMON_ROW	*/  {COM,   COM,   COM,   CREF,  COM,   BIG,   REFC,  WARNC },
   /* INDR_ROW	*/  {IND,   IND,   IND,   MDEF,  IND,   CIND,  MIND,  CYCLE },
-  /* WARN_ROW   */  {MWARN, WARN,  WARN,  CWARN, CWARN, WARN,  CWARN, MWARN },
+  /* WARN_ROW   */  {MWARN, WARN,  WARN,  CWARN, CWARN, WARN,  CWARN, NOACT },
   /* SET_ROW	*/  {SET,   SET,   SET,   SET,   SET,   SET,   CYCLE, CYCLE }
 };
 
@@ -2456,6 +2467,9 @@
     (struct generic_write_global_symbol_info *) data;
   asymbol *sym;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct generic_link_hash_entry *) h->root.u.i.link;
+
   if (h->written)
     return true;
 
diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c
index 931282c..7dd0428 100644
--- a/bfd/m68klinux.c
+++ b/bfd/m68klinux.c
@@ -1,5 +1,5 @@
 /* BFD back-end for linux flavored m68k a.out binaries.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -230,7 +230,7 @@
   struct linux_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct linux_link_hash_table);
 
-  ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct linux_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct linux_link_hash_table *) NULL)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -442,6 +442,9 @@
   struct linux_link_hash_entry *h1, *h2;
   boolean exists;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct linux_link_hash_entry *) h->root.root.u.i.link;
+
   if (h->root.root.type == bfd_link_hash_undefined
       && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
 		  sizeof NEEDS_SHRLIB - 1) == 0)
diff --git a/bfd/merge.c b/bfd/merge.c
index 7b06c10..e175efd 100644
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -804,6 +804,9 @@
       if (secinfo)
 	continue;
 
+      if (sinfo->htab->first == NULL)
+	continue;
+
       if (sinfo->htab->strings)
 	merge_strings (sinfo);
       else
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 31ba035..fe70a18 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -1523,7 +1523,7 @@
   entry = (mmo_data_list_type *)
     bfd_zalloc (sec->owner, sizeof (mmo_data_list_type) + allocated_size);
   if (entry == NULL)
-    return false;
+    return NULL;
   entry->where = vma;
   entry->size = size;
   entry->allocated_size = allocated_size;
@@ -3245,6 +3245,7 @@
   bfd_generic_get_relocated_section_contents
 #define mmo_bfd_gc_sections bfd_generic_gc_sections
 #define mmo_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define mmo_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define mmo_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define mmo_bfd_final_link _bfd_generic_final_link
 #define mmo_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h
index c1b086b..79877fe 100644
--- a/bfd/nlm-target.h
+++ b/bfd/nlm-target.h
@@ -1,5 +1,6 @@
 /* Target definitions for 32/64-bit NLM (NetWare Loadable Module)
-   Copyright 1993, 1994, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1998, 1999, 2000, 2001, 2002
+   Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -44,6 +45,7 @@
 #define nlm_bfd_gc_sections bfd_generic_gc_sections
 #define nlm_bfd_merge_sections bfd_generic_merge_sections
 #define nlm_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define nlm_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define nlm_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define nlm_bfd_final_link _bfd_generic_final_link
 #define nlm_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/oasys.c b/bfd/oasys.c
index d8dc957..4cadb69 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -1,5 +1,5 @@
 /* BFD back-end for oasys objects.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002
    Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
 
@@ -1491,6 +1491,7 @@
 #define oasys_bfd_gc_sections bfd_generic_gc_sections
 #define oasys_bfd_merge_sections bfd_generic_merge_sections
 #define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define oasys_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define oasys_bfd_final_link _bfd_generic_final_link
 #define oasys_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 0b285d4..f110259 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -1,25 +1,25 @@
 /* opncls.c -- open and close a BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001
+   2001, 2002
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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 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.
+   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.  */
+   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"
@@ -39,9 +39,6 @@
 /* fdopen is a loser -- we should use stdio exclusively.  Unfortunately
    if we do that we can't use fcntl.  */
 
-/* FIXME: This is no longer used.  */
-long _bfd_chunksize = -1;
-
 /* Return a new BFD.  All BFD's are allocated through this routine.  */
 
 bfd *
@@ -96,6 +93,8 @@
   bfd *nbfd;
 
   nbfd = _bfd_new_bfd ();
+  if (nbfd == NULL)
+    return NULL;
   nbfd->xvec = obfd->xvec;
   nbfd->my_archive = obfd;
   nbfd->direction = read_direction;
@@ -163,7 +162,7 @@
 
   if (bfd_open_file (nbfd) == NULL)
     {
-      /* File didn't exist, or some such */
+      /* File didn't exist, or some such.  */
       bfd_set_error (bfd_error_system_call);
       _bfd_delete_bfd (nbfd);
       return NULL;
@@ -178,8 +177,7 @@
        won't cause a storage leak.
    o - We open the file stream last, since we don't want to have to
        close it if anything goes wrong.  Closing the stream means closing
-       the file descriptor too, even though we didn't open it.
- */
+       the file descriptor too, even though we didn't open it.  */
 /*
 FUNCTION
          bfd_fdopenr
@@ -218,7 +216,7 @@
 
   bfd_set_error (bfd_error_system_call);
 #if ! defined(HAVE_FCNTL) || ! defined(F_GETFL)
-  fdflags = O_RDWR;			/* Assume full access */
+  fdflags = O_RDWR;			/* Assume full access.  */
 #else
   fdflags = fcntl (fd, F_GETFL, NULL);
 #endif
@@ -239,7 +237,7 @@
 #ifndef HAVE_FDOPEN
   nbfd->iostream = (PTR) fopen (filename, FOPEN_RB);
 #else
-  /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
+  /* (O_ACCMODE) parens are to avoid Ultrix header file bug.  */
   switch (fdflags & (O_ACCMODE))
     {
     case O_RDONLY: nbfd->iostream = (PTR) fdopen (fd, FOPEN_RB);   break;
@@ -255,14 +253,13 @@
       return NULL;
     }
 
-  /* OK, put everything where it belongs */
-
+  /* OK, put everything where it belongs.  */
   nbfd->filename = filename;
 
   /* As a special case we allow a FD open for read/write to
      be written through, although doing so requires that we end
      the previous clause with a preposition.  */
-  /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
+  /* (O_ACCMODE) parens are to avoid Ultrix header file bug.  */
   switch (fdflags & (O_ACCMODE))
     {
     case O_RDONLY: nbfd->direction = read_direction; break;
@@ -329,10 +326,10 @@
   return nbfd;
 }
 
-/** bfd_openw -- open for writing.
-  Returns a pointer to a freshly-allocated BFD on success, or NULL.
+/* bfd_openw -- open for writing.
+   Returns a pointer to a freshly-allocated BFD on success, or NULL.
 
-  See comment by bfd_fdopenr before you try to modify this function. */
+   See comment by bfd_fdopenr before you try to modify this function.  */
 
 /*
 FUNCTION
@@ -360,8 +357,7 @@
   bfd_set_error (bfd_error_system_call);
 
   /* nbfd has to point to head of malloc'ed block so that bfd_close may
-     reclaim it correctly. */
-
+     reclaim it correctly.  */
   nbfd = _bfd_new_bfd ();
   if (nbfd == NULL)
     return NULL;
@@ -378,7 +374,8 @@
 
   if (bfd_open_file (nbfd) == NULL)
     {
-      bfd_set_error (bfd_error_system_call);	/* File not writeable, etc */
+      /* File not writeable, etc.  */
+      bfd_set_error (bfd_error_system_call);
       _bfd_delete_bfd (nbfd);
       return NULL;
   }
@@ -417,7 +414,7 @@
 {
   boolean ret;
 
-  if (!bfd_read_p (abfd))
+  if (bfd_write_p (abfd))
     {
       if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
 	return false;
@@ -429,7 +426,7 @@
   ret = bfd_cache_close (abfd);
 
   /* If the file was open for writing and is now executable,
-     make it so */
+     make it so.  */
   if (ret
       && abfd->direction == write_direction
       && abfd->flags & EXEC_P)
@@ -439,6 +436,7 @@
       if (stat (abfd->filename, &buf) == 0)
 	{
  	  unsigned int mask = umask (0);
+
 	  umask (mask);
 	  chmod (abfd->filename,
 		 (0777
@@ -471,7 +469,6 @@
 
 RETURNS
 	<<true>> is returned if all is ok, otherwise <<false>>.
-
 */
 
 boolean
@@ -483,7 +480,7 @@
   ret = bfd_cache_close (abfd);
 
   /* If the file was open for writing and is now executable,
-     make it so */
+     make it so.  */
   if (ret
       && abfd->direction == write_direction
       && abfd->flags & EXEC_P)
@@ -493,6 +490,7 @@
       if (stat (abfd->filename, &buf) == 0)
 	{
 	  unsigned int mask = umask (0);
+
 	  umask (mask);
 	  chmod (abfd->filename,
 		 (0777
@@ -517,7 +515,6 @@
 	<<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 <<bfd_object>>.
-
 */
 
 bfd *
@@ -535,6 +532,7 @@
     nbfd->xvec = templ->xvec;
   nbfd->direction = no_direction;
   bfd_set_format (nbfd, bfd_object);
+
   return nbfd;
 }
 
@@ -570,7 +568,7 @@
   bim = ((struct bfd_in_memory *)
 	 bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
   abfd->iostream = (PTR) bim;
-  /* bfd_bwrite will grow these as needed */
+  /* bfd_bwrite will grow these as needed.  */
   bim->size = 0;
   bim->buffer = 0;
 
@@ -618,7 +616,6 @@
   abfd->arch_info = &bfd_default_arch_struct;
 
   abfd->where = 0;
-  abfd->sections = (asection *) NULL;
   abfd->format = bfd_unknown;
   abfd->my_archive = (bfd *) NULL;
   abfd->origin = 0;
@@ -637,7 +634,8 @@
   abfd->outsymbols = 0;
   abfd->tdata.any = 0;
 
-  bfd_check_format(abfd, bfd_object);
+  bfd_section_list_clear (abfd);
+  bfd_check_format (abfd, bfd_object);
 
   return true;
 }
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index 2c08497..d4fe79e 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -1,5 +1,5 @@
 /* BFD back-end for PDP-11 a.out binaries.
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -4305,6 +4305,13 @@
   bfd_size_type indx;
   bfd_size_type amt;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h = (struct aout_link_hash_entry *) h->root.u.i.link;
+      if (h->root.type == bfd_link_hash_new)
+	return true;
+    }
+
   output_bfd = finfo->output_bfd;
 
   if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in
index f3f1d26..8f0199d 100644
--- a/bfd/po/SRC-POTFILES.in
+++ b/bfd/po/SRC-POTFILES.in
@@ -1,4 +1,5 @@
 aix386-core.c
+aix5ppc-core.c
 aout-adobe.c
 aout-arm.c
 aout-cris.c
@@ -170,6 +171,7 @@
 elfcore.h
 elflink.c
 elflink.h
+elfxx-mips.c
 epoc-pe-arm.c
 epoc-pei-arm.c
 format.c
diff --git a/bfd/po/fr.po b/bfd/po/fr.po
index 1ecda2a..8662d31 100644
--- a/bfd/po/fr.po
+++ b/bfd/po/fr.po
@@ -5,8 +5,8 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: GNU bfd 2.12-pre020121\n"
-"POT-Creation-Date: 2002-01-31 17:07+0000\n"
-"PO-Revision-Date: 2002-01-24 08:00-0500\n"
+"POT-Creation-Date: 2002-01-17 12:55+0000\n"
+"PO-Revision-Date: 2002-03-17 20:00-0500\n"
 "Last-Translator: Michel Robitaille <robitail@IRO.UMontreal.CA>\n"
 "Language-Team: French <traduc@traduc.org>\n"
 "MIME-Version: 1.0\n"
@@ -36,16 +36,12 @@
 #: aoutx.h:1282 aoutx.h:1699
 #, c-format
 msgid "%s: can not represent section `%s' in a.out object file format"
-msgstr ""
-"%s: ne peut représenter la section `%s' dans le fichier format objet a.out"
+msgstr "%s: ne peut représenter la section « %s » dans le fichier format objet a.out"
 
 #: aoutx.h:1669
 #, c-format
-msgid ""
-"%s: can not represent section for symbol `%s' in a.out object file format"
-msgstr ""
-"%s: ne peut représenter la section pour le symbole `%s' dans le fichier "
-"format objet a.out"
+msgid "%s: can not represent section for symbol `%s' in a.out object file format"
+msgstr "%s: ne peut représenter la section pour le symbole « %s » dans le fichier format objet a.out"
 
 #: aoutx.h:1671
 msgid "*unknown*"
@@ -58,9 +54,7 @@
 
 #: archive.c:1826
 msgid "Warning: writing archive was slow: rewriting timestamp\n"
-msgstr ""
-"AVERTISSEMENT: l'écriture de l'archive était lente: réécriture du cachet de "
-"date-heure\n"
+msgstr "AVERTISSEMENT: l'écriture de l'archive était lente: réécriture du cachet de date-heure\n"
 
 #: archive.c:2093
 msgid "Reading archive file mod timestamp"
@@ -71,111 +65,109 @@
 msgid "Writing updated armap timestamp"
 msgstr "Écriture du cachet date-heure armap mise à jour"
 
-#: bfd.c:274
+#: bfd.c:281
 msgid "No error"
 msgstr "Pas d'erreur"
 
-#: bfd.c:275
+#: bfd.c:282
 msgid "System call error"
 msgstr "Erreur d'appel système"
 
-#: bfd.c:276
+#: bfd.c:283
 msgid "Invalid bfd target"
 msgstr "cible bfd invalide"
 
-#: bfd.c:277
+#: bfd.c:284
 msgid "File in wrong format"
 msgstr "Fichier dans un mauvais format"
 
-#: bfd.c:278
+#: bfd.c:285
 msgid "Archive object file in wrong format"
 msgstr "Fichier objet d'archive dans un mauvais format"
 
-#: bfd.c:279
+#: bfd.c:286
 msgid "Invalid operation"
 msgstr "Opération invalide"
 
-#: bfd.c:280
+#: bfd.c:287
 msgid "Memory exhausted"
 msgstr "Mémoire épuisée"
 
-#: bfd.c:281
+#: bfd.c:288
 msgid "No symbols"
 msgstr "Aucun symbole"
 
-#: bfd.c:282
+#: bfd.c:289
 msgid "Archive has no index; run ranlib to add one"
 msgstr "L'archive n'a pas d'index; exécuter ranlib pour en ajouter un"
 
-#: bfd.c:283
+#: bfd.c:290
 msgid "No more archived files"
 msgstr "Aucun autre fichier d'archive"
 
-#: bfd.c:284
+#: bfd.c:291
 msgid "Malformed archive"
 msgstr "Archive mal formé"
 
-#: bfd.c:285
+#: bfd.c:292
 msgid "File format not recognized"
 msgstr "Format de fichier non reconnu"
 
-#: bfd.c:286
+#: bfd.c:293
 msgid "File format is ambiguous"
 msgstr "Format de fichier ambiguë"
 
-#: bfd.c:287
+#: bfd.c:294
 msgid "Section has no contents"
 msgstr "Section sans contenu"
 
-#: bfd.c:288
+#: bfd.c:295
 msgid "Nonrepresentable section on output"
 msgstr "Section non-représentable pour la sortie"
 
-#: bfd.c:289
+#: bfd.c:296
 msgid "Symbol needs debug section which does not exist"
 msgstr "Symboles ont besoin de la section de débug qui est inexistente"
 
-#: bfd.c:290
+#: bfd.c:297
 msgid "Bad value"
 msgstr "Mauvaise valeur"
 
-#: bfd.c:291
+#: bfd.c:298
 msgid "File truncated"
 msgstr "Fichier tronqué"
 
-#: bfd.c:292
+#: bfd.c:299
 msgid "File too big"
 msgstr "Fichier trop gros"
 
-#: bfd.c:293
+#: bfd.c:300
 msgid "#<Invalid error code>"
 msgstr "#<Code d'erreur invalide>"
 
-#: bfd.c:700
+#: bfd.c:707
 #, c-format
 msgid "BFD %s assertion fail %s:%d"
 msgstr "BFD assertion %s a échoué %s:%d"
 
-#: bfd.c:719
+#: bfd.c:726
 #, c-format
 msgid "BFD %s internal error, aborting at %s line %d in %s\n"
 msgstr "BFD erreur interne %s, abandon à %s, ligne %d dans %s\n"
 
-#: bfd.c:723
-#, fuzzy, c-format
-msgid "BFD %s internal error, aborting at %s line %d\n"
+#: bfd.c:730
+#, c-format
+msgid "BFD %sinternal error, aborting at %s line %d\n"
 msgstr "BFD erreur interne %s, abandon à %s, ligne %d\n"
 
-#: bfd.c:725
+#: bfd.c:732
 msgid "Please report this bug.\n"
 msgstr "SVP rapporter cette anomalie.\n"
 
 #: binary.c:306
 #, c-format
 msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."
-msgstr ""
-"AVERTISSEMENT: écriture de la section `%s' vers un énorme décalage (ie "
-"négatif) dans le fichier 0x%lx."
+msgstr "AVERTISSEMENT: écriture de la section « %s » vers un énorme décalage (ie négatif) dans le fichier 0x%lx."
 
 #: coff-a29k.c:119
 msgid "Missing IHCONST"
@@ -185,7 +177,7 @@
 msgid "Missing IHIHALF"
 msgstr "IHIHALF manquant"
 
-#: coff-a29k.c:212 coff-or32.c:228
+#: coff-a29k.c:212
 msgid "Unrecognized reloc"
 msgstr "Relocalisation non reconnue"
 
@@ -197,7 +189,7 @@
 msgid "missing IHIHALF reloc"
 msgstr "IHIHALF de relocalisation manquant"
 
-#: coff-alpha.c:881 coff-alpha.c:918 coff-alpha.c:1989 coff-mips.c:1433
+#: coff-alpha.c:881 coff-alpha.c:918
 msgid "GP relative relocation used when GP not defined"
 msgstr "Relocalisation relative GP utilisé alors que GP n'est pas défini"
 
@@ -205,15 +197,19 @@
 msgid "using multiple gp values"
 msgstr "utilisation de valeurs multiples gp"
 
+#: coff-alpha.c:1989 coff-mips.c:1433
+msgid "GP relative relocation when GP not defined"
+msgstr "GP relocalisation relative alors que GP n'est pas défini"
+
 #: coff-arm.c:1051 elf32-arm.h:285
 #, c-format
 msgid "%s: unable to find THUMB glue '%s' for `%s'"
-msgstr "%s: incapable de repérer le REPÈRE de liant '%s' pour `%s'"
+msgstr "%s: incapable de repérer le REPÈRE de liant « %s » pour « %s »"
 
 #: coff-arm.c:1080 elf32-arm.h:320
 #, c-format
 msgid "%s: unable to find ARM glue '%s' for `%s'"
-msgstr "%s: incapable de repérer le liant ARM '%s' pour `%s'"
+msgstr "%s: incapable de repérer le liant ARM « %s » pour « %s »"
 
 #: coff-arm.c:1375 coff-arm.c:1470 elf32-arm.h:886 elf32-arm.h:990
 #, c-format
@@ -237,7 +233,7 @@
 #: coff-arm.c:1767 coff-tic80.c:686 cofflink.c:3017
 #, c-format
 msgid "%s: bad reloc address 0x%lx in section `%s'"
-msgstr "%s: mausvaise adresse de relocalisation 0x%lx dans la section `%s'"
+msgstr "%s: mauvaise adresse de relocalisation 0x%lx dans la section « %s »"
 
 #: coff-arm.c:2107
 #, c-format
@@ -251,52 +247,33 @@
 
 #: coff-arm.c:2250
 #, c-format
-msgid ""
-"%s: ERROR: passes floats in float registers whereas target %s uses integer "
-"registers"
-msgstr ""
-"%s: ERREUR: passage de valeurs en virgule flottante dans des registreen "
-"virgule flottance alors que la cible %s utilise des registres de "
-"valeursentières"
+msgid "%s: ERROR: passes floats in float registers whereas target %s uses integer registers"
+msgstr "%s: ERREUR: passage de valeurs en virgule flottante dans des registreen virgule flottance alors que la cible %s utilise des registres de valeursentières"
 
 #: coff-arm.c:2253
 #, c-format
-msgid ""
-"%s: ERROR: passes floats in integer registers whereas target %s uses float "
-"registers"
-msgstr ""
-"%s: ERREUR: passage de valeurs en virgule flottante dans des registreen "
-"valeur entière alors que la cible %s utilise des registres de valeursen "
-"virgule flottante"
+msgid "%s: ERROR: passes floats in integer registers whereas target %s uses float registers"
+msgstr "%s: ERREUR: passage de valeurs en virgule flottante dans des registreen valeur entière alors que la cible %s utilise des registres de valeursen virgule flottante"
 
 #: coff-arm.c:2268
 #, c-format
-msgid ""
-"%s: ERROR: compiled as position independent code, whereas target %s is "
-"absolute position"
-msgstr ""
-"%s: ERREUR: compilé en code indépendant de la position, alors que la cible %"
-"s esten position absolue"
+msgid "%s: ERROR: compiled as position independent code, whereas target %s is absolute position"
+msgstr "%s: ERREUR: compilé en code indépendant de la position, alors que la cible %s esten position absolue"
 
 #: coff-arm.c:2271
 #, c-format
-msgid ""
-"%s: ERROR: compiled as absolute position code, whereas target %s is position "
-"independent"
-msgstr ""
-"%s: ERREUR: compilé en code à position abolsu, alors que la cible %s "
-"estindépendant de la position"
+msgid "%s: ERROR: compiled as absolute position code, whereas target %s is position independent"
+msgstr "%s: ERREUR: compilé en code à position abolsu, alors que la cible %s estindépendant de la position"
 
 #: coff-arm.c:2300
-#, fuzzy, c-format
-msgid "Warning: %s supports interworking, whereas %s does not."
-msgstr "AVERTISSEMENT: %s supporte l'inter-réseautage, contrairement à %s."
+#, c-format
+msgid "Warning: input file %s supports interworking, whereas %s does not."
+msgstr "AVERTISSEMENT: file d'entrée %s supporte l'inter-réseautage, contrairement à %s."
 
 #: coff-arm.c:2303
-#, fuzzy, c-format
-msgid "Warning: %s does not support interworking, whereas %s does."
-msgstr ""
-"AVERTISSEMENT: %s ne supporte pas l'inter-réseautage, contrairement à %s."
+#, c-format
+msgid "Warning: input file %s does not support interworking, whereas %s does."
+msgstr "AVERTISSEMENT: fichier d'entrée %s ne supporte pas l'inter-réseautage, contrairement à %s."
 
 #: coff-arm.c:2330
 #, c-format
@@ -305,15 +282,11 @@
 
 #: coff-arm.c:2338 elf32-arm.h:2408
 msgid " [floats passed in float registers]"
-msgstr ""
-" [valeurs en virgule flottante passées dans des registres de valeurs en "
-"virgule flottante]"
+msgstr " [valeurs en virgule flottante passées dans des registres de valeurs en virgule flottante]"
 
 #: coff-arm.c:2340
 msgid " [floats passed in integer registers]"
-msgstr ""
-" [valeurs en virgule flottante passées dans des registres de valeurs "
-"entières]"
+msgstr " [valeurs en virgule flottante passées dans des registres de valeurs entières]"
 
 #: coff-arm.c:2343 elf32-arm.h:2411
 msgid " [position independent]"
@@ -335,31 +308,25 @@
 msgid " [interworking not supported]"
 msgstr " [inter-réseautage non supporté]"
 
-#: coff-arm.c:2401 elf32-arm.h:2114
-#, fuzzy, c-format
-msgid ""
-"Warning: Not setting interworking flag of %s since it has already been "
-"specified as non-interworking"
-msgstr ""
-"AVERTISSEMENT: pas d'initialisation du fanion d'inter-réseautage %s, "
-"puisqu'il a déjà été spécifié comme sans inter-réseautage"
+#: coff-arm.c:2401
+#, c-format
+msgid "Warning: Not setting interworking flag of %s, since it has already been specified as non-interworking"
+msgstr "AVERTISSEMENT: pas d'initialisation du fanion d'inter-réseautage %s, puisqu'il a déjà été spécifié comme sans inter-réseautage"
 
-#: coff-arm.c:2405 elf32-arm.h:2118
+#: coff-arm.c:2405
 #, c-format
 msgid "Warning: Clearing the interworking flag of %s due to outside request"
-msgstr ""
-"AVERTISSEMENT: mise à zéro du fanion d'inter-réseautage %s en raison d'une "
-"requête externe"
+msgstr "AVERTISSEMENT: mise à zéro du fanion d'inter-réseautage %s en raison d'une requête externe"
 
 #: coff-i960.c:136 coff-i960.c:485
 msgid "uncertain calling convention for non-COFF symbol"
 msgstr "convention d'appel incertaine pour un symbole non COFF"
 
-#: coff-m68k.c:481 coff-mips.c:2431 elf32-m68k.c:2212 elf32-mips.c:9954
+#: coff-m68k.c:481 coff-mips.c:2431 elf32-m68k.c:2212
 msgid "unsupported reloc type"
 msgstr "type de relocalisation non supporté"
 
-#: coff-mips.c:875 elf32-mips.c:1997 elf64-mips.c:1739
+#: coff-mips.c:875 elf32-mips.c:1987 elf64-mips.c:1739
 msgid "GP relative relocation when _gp not defined"
 msgstr "relocalisation relative GP sans que _gp ne soit défini"
 
@@ -381,21 +348,19 @@
 #: coff-rs6000.c:2756 coff64-rs6000.c:1210
 #, c-format
 msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"
-msgstr ""
-"%s: table des matières des relocalisation à 0x%x pour les symboles `%s' sans "
-"aucune entrée dans la table des matières"
+msgstr "%s: table des matières des relocalisation à 0x%x pour les symboles « %s » sans aucune entrée"
 
 #: coff-rs6000.c:3006 coff64-rs6000.c:2060
 #, c-format
 msgid "%s: symbol `%s' has unrecognized smclas %d"
-msgstr "%s: symbole `%s' a une classe smclas non reconnue %d"
+msgstr "%s: symbole « %s » a une classe smclas non reconnue %d"
 
 #: coff-tic54x.c:279 coff-tic80.c:449
 #, c-format
 msgid "Unrecognized reloc type 0x%x"
 msgstr "Type de relocalisation non reconnu 0x%x"
 
-#: coff-tic54x.c:390 coffcode.h:4868
+#: coff-tic54x.c:390 coffcode.h:4847
 #, c-format
 msgid "%s: warning: illegal symbol index %ld in relocs"
 msgstr "%s: AVERTISSEMENT: symbole index illégal %ld dans les relocalisations"
@@ -410,32 +375,32 @@
 msgid "%s (%s): Section flag %s (0x%x) ignored"
 msgstr "%s (%s): fanion de section %s (0x%x) ignoré"
 
-#: coffcode.h:2132
+#: coffcode.h:2125
 #, c-format
 msgid "Unrecognized TI COFF target id '0x%x'"
 msgstr "cible TI COFF non reconnue identificateur '0x%x'"
 
-#: coffcode.h:4257
+#: coffcode.h:4236
 #, c-format
 msgid "%s: warning: illegal symbol index %ld in line numbers"
 msgstr "%s: AVERTISSEMENT: symbole d'index illégal %ld dans le numéro de ligne"
 
-#: coffcode.h:4271
+#: coffcode.h:4250
 #, c-format
 msgid "%s: warning: duplicate line number information for `%s'"
-msgstr "%s: AVERTISSEMENT: information de numéro de ligne dédoublée pour `%s'"
+msgstr "%s: AVERTISSEMENT: information de numéro de ligne dédoublée pour « %s »"
 
-#: coffcode.h:4630
+#: coffcode.h:4609
 #, c-format
 msgid "%s: Unrecognized storage class %d for %s symbol `%s'"
-msgstr "%s: classe de stockage non reconnue %d pour %s symbole `%s'"
+msgstr "%s: classe de stockage non reconnue %d pour %s symbole « %s »"
 
-#: coffcode.h:4761
+#: coffcode.h:4740
 #, c-format
 msgid "warning: %s: local symbol `%s' has no section"
-msgstr "AVERTISSEMENT: %s: symbole local `%s' n'a pas de section"
+msgstr "AVERTISSEMENT: %s: symbole local « %s » n'a pas de section"
 
-#: coffcode.h:4906
+#: coffcode.h:4885
 #, c-format
 msgid "%s: illegal relocation type %d at address 0x%lx"
 msgstr "%s: type de relocalisation illégal %d à l'adresse 0x%lx"
@@ -445,15 +410,20 @@
 msgid "%s: bad string table size %lu"
 msgstr "%s: chaîne erronée de la taille de table %lu"
 
+#: coffgen.c:2138
+#, c-format
+msgid "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"
+msgstr "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld prochain %ld"
+
 #: cofflink.c:536 elflink.h:1967
 #, c-format
 msgid "Warning: type of symbol `%s' changed from %d to %d in %s"
-msgstr "AVERTISSEMENT: type de symbole `%s' a changé de %d à %d dans %s"
+msgstr "AVERTISSEMENT: type de symbole « %s » a changé de %d à %d dans %s"
 
 #: cofflink.c:2317
 #, c-format
 msgid "%s: relocs in section `%s', but it has no contents"
-msgstr "%s: relocalisations dans la section `%s', mais n,a aucun contenu"
+msgstr "%s: relocalisations dans la section « %s », mais n'a aucun contenu"
 
 #: cofflink.c:2653 coffswap.h:889
 #, c-format
@@ -463,9 +433,7 @@
 #: cofflink.c:2662 coffswap.h:876
 #, c-format
 msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff"
-msgstr ""
-"%s: AVERTISSEMENT: %s: débordement du compteur de numéro de ligne: 0x%lx > "
-"0xffff"
+msgstr "%s: AVERTISSEMENT: %s: débordement du compteur de numéro de ligne: 0x%lx > 0xffff"
 
 #: dwarf2.c:381
 msgid "Dwarf Error: Can't find .debug_str section."
@@ -473,22 +441,16 @@
 
 #: dwarf2.c:398
 #, c-format
-msgid ""
-"Dwarf Error: DW_FORM_strp offset (%u) greater than or equal to .debug_str "
-"size (%u)."
-msgstr ""
-"Erreur DWARF: décalage DW_FORM_strp (%u) est > ou = à la taille de ."
-"debug_str (%u)."
+msgid "Dwarf Error: DW_FORM_strp offset (%u) greater than or equal to .debug_str size (%u)."
+msgstr "Erreur DWARF: décalage DW_FORM_strp (%u) est > ou = à la taille de .debug_str (%u)."
 
 #: dwarf2.c:542
 msgid "Dwarf Error: Can't find .debug_abbrev section."
 msgstr "Erreur DWARF: ne peut repérer la section .debug_abbrev"
 
 #: dwarf2.c:559
-#, fuzzy, c-format
-msgid ""
-"Dwarf Error: Abbrev offset (%u) greater than or equal to .debug_abbrev size "
-"(%u)."
+#, c-format
+msgid "Dwarf Error: Abbrev offset (%u) greater than or equal to abbrev size (%u)."
 msgstr "Erreur DWARF: décalage Abbrev (%u) est > ou = à la taille abbrev (%u)."
 
 #: dwarf2.c:756
@@ -498,48 +460,37 @@
 
 #: dwarf2.c:843
 msgid "Dwarf Error: mangled line number section (bad file number)."
-msgstr ""
-"Erreur DWARF: numéro mutilé de ligne de section (mauvais no. de fichier)"
+msgstr "Erreur DWARF: numéro mutilé de ligne de section (mauvais no. de fichier)"
 
 #: dwarf2.c:929
 msgid "Dwarf Error: Can't find .debug_line section."
 msgstr "Erreur DWARF: ne peut repérer la section .debug_line"
 
 #: dwarf2.c:952
-#, fuzzy, c-format
-msgid ""
-"Dwarf Error: Line offset (%u) greater than or equal to .debug_line size (%u)."
-msgstr ""
-"Erreur DWARF: décalage de ligne (%u) est > ou = à la taille de ligne (%u)"
+#, c-format
+msgid "Dwarf Error: Line offset (%u) greater than or equal to line size (%u)."
+msgstr "Erreur DWARF: décalage de ligne (%u) est > ou = à la taille de ligne (%u)"
 
 #: dwarf2.c:1143
 msgid "Dwarf Error: mangled line number section."
 msgstr "Erreur DWARF: numéro mutilé de ligne de section"
 
-#: dwarf2.c:1318 dwarf2.c:1529
+#: dwarf2.c:1318 dwarf2.c:1532
 #, c-format
 msgid "Dwarf Error: Could not find abbrev number %d."
 msgstr "Erreur DWARF: ne peut repérer le numéro abrégé %d"
 
-#: dwarf2.c:1490
+#: dwarf2.c:1493
 #, c-format
-msgid ""
-"Dwarf Error: found dwarf version '%hu', this reader only handles version 2 "
-"information."
-msgstr ""
-"Erreur DWARF: version DWARF retrouvée '%hu', ce lecteur ne supporte que les "
-"informations de la version 2."
+msgid "Dwarf Error: found dwarf version '%hu', this reader only handles version 2 information."
+msgstr "Erreur DWARF: version DWARF retrouvée « %hu », ce lecteur ne supporte que les informations de la version 2."
 
-#: dwarf2.c:1497
+#: dwarf2.c:1500
 #, c-format
-msgid ""
-"Dwarf Error: found address size '%u', this reader can not handle sizes "
-"greater than '%u'."
-msgstr ""
-"Erreur DWARF: taille d'adresse obtenue '%u', ce lecteur ne peut traiter des "
-"tailles plus grandes que '%u'."
+msgid "Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."
+msgstr "Erreur DWARF: taille d'adresse obtenue « %u », ce lecteur ne peut traiter des tailles plus grandes que « %u »."
 
-#: dwarf2.c:1520
+#: dwarf2.c:1523
 #, c-format
 msgid "Dwarf Error: Bad abbrev number: %d."
 msgstr "Erreur DWARF: mauvais numéro abrégé: %d"
@@ -621,57 +572,43 @@
 "\n"
 "      Type: %s"
 
-#: elf-hppa.h:1366 elf-hppa.h:1399 elf32-ppc.c:3062 elf32-sh.c:3201
-#: elf64-x86-64.c:1275
+#: elf-hppa.h:1366 elf-hppa.h:1399 elf32-ppc.c:3062 elf32-sh.c:3201 elf64-x86-64.c:1275
 #, c-format
-msgid ""
-"%s: warning: unresolvable relocation against symbol `%s' from %s section"
-msgstr ""
-"%s: AVERTISSEMENT: relocalisation sans solution vers le symbole `%s' de la "
-"section %s"
+msgid "%s: warning: unresolvable relocation against symbol `%s' from %s section"
+msgstr "%s: AVERTISSEMENT: relocalisation sans solution vers le symbole « %s » de la section %s"
 
-#: elf-m10200.c:463 elf-m10300.c:673 elf32-arm.h:2074 elf32-avr.c:835
-#: elf32-cris.c:1406 elf32-d10v.c:482 elf32-fr30.c:653 elf32-h8300.c:547
-#: elf32-i860.c:1048 elf32-m32r.c:1280 elf32-openrisc.c:455 elf32-v850.c:1691
-#: elf32-xstormy16.c:976 elf64-mmix.c:1164
+#: elf-m10200.c:463 elf-m10300.c:673 elf32-arm.h:2074 elf32-avr.c:835 elf32-cris.c:1392 elf32-d10v.c:482 elf32-fr30.c:653 elf32-h8300.c:547 elf32-i860.c:1048 elf32-m32r.c:1281 elf32-openrisc.c:455 elf32-v850.c:1691 elf64-mmix.c:1164
 msgid "internal error: out of range error"
 msgstr "erreur interne: hors gamme"
 
-#: elf-m10200.c:467 elf-m10300.c:677 elf32-arm.h:2078 elf32-avr.c:839
-#: elf32-cris.c:1410 elf32-d10v.c:486 elf32-fr30.c:657 elf32-h8300.c:551
-#: elf32-i860.c:1052 elf32-m32r.c:1284 elf32-mips.c:7587 elf32-openrisc.c:459
-#: elf32-v850.c:1695 elf32-xstormy16.c:980 elf64-mips.c:4464 elf64-mmix.c:1168
+#: elf-m10200.c:467 elf-m10300.c:677 elf32-arm.h:2078 elf32-avr.c:839 elf32-cris.c:1396 elf32-d10v.c:486 elf32-fr30.c:657 elf32-h8300.c:551 elf32-i860.c:1052 elf32-m32r.c:1285 elf32-mips.c:7565 elf32-openrisc.c:459 elf32-v850.c:1695 elf64-mips.c:4464 elf64-mmix.c:1168
 msgid "internal error: unsupported relocation error"
 msgstr "erreur interne: erreur de relocalisation non supportée"
 
-#: elf-m10200.c:471 elf-m10300.c:681 elf32-arm.h:2082 elf32-d10v.c:490
-#: elf32-h8300.c:555 elf32-m32r.c:1288
+#: elf-m10200.c:471 elf-m10300.c:681 elf32-arm.h:2082 elf32-d10v.c:490 elf32-h8300.c:555 elf32-m32r.c:1289
 msgid "internal error: dangerous error"
 msgstr "erreur interne: erreur dangereuse"
 
-#: elf-m10200.c:475 elf-m10300.c:685 elf32-arm.h:2086 elf32-avr.c:847
-#: elf32-cris.c:1418 elf32-d10v.c:494 elf32-fr30.c:665 elf32-h8300.c:559
-#: elf32-i860.c:1060 elf32-m32r.c:1292 elf32-openrisc.c:467 elf32-v850.c:1715
-#: elf32-xstormy16.c:988 elf64-mmix.c:1176
+#: elf-m10200.c:475 elf-m10300.c:685 elf32-arm.h:2086 elf32-avr.c:847 elf32-cris.c:1404 elf32-d10v.c:494 elf32-fr30.c:665 elf32-h8300.c:559 elf32-i860.c:1060 elf32-m32r.c:1293 elf32-openrisc.c:467 elf32-v850.c:1715 elf64-mmix.c:1176
 msgid "internal error: unknown error"
 msgstr "erreur interne: erreur inconnue"
 
-#: elf.c:343
+#: elf.c:345
 #, c-format
 msgid "%s: invalid string offset %u >= %lu for section `%s'"
-msgstr "%s: chaîne de décalage invalide %u >= %lu pour la section `%s'"
+msgstr "%s: chaîne de décalage invalide %u >= %lu pour la section « %s »"
 
-#: elf.c:448
+#: elf.c:450
 #, c-format
 msgid "%s: invalid SHT_GROUP entry"
 msgstr "%s: entrée SHT_GROUP invalide"
 
-#: elf.c:529
+#: elf.c:531
 #, c-format
 msgid "%s: no group info for section %s"
 msgstr "%s: aucune info de groupe pour la section %s"
 
-#: elf.c:840
+#: elf.c:842
 msgid ""
 "\n"
 "Program Header:\n"
@@ -679,7 +616,7 @@
 "\n"
 "En-tête de programme:\n"
 
-#: elf.c:889
+#: elf.c:891
 msgid ""
 "\n"
 "Dynamic Section:\n"
@@ -687,7 +624,7 @@
 "\n"
 "Section dynamique:\n"
 
-#: elf.c:1018
+#: elf.c:1020
 msgid ""
 "\n"
 "Version definitions:\n"
@@ -695,7 +632,7 @@
 "\n"
 "Définitions des versions:\n"
 
-#: elf.c:1041
+#: elf.c:1043
 msgid ""
 "\n"
 "Version References:\n"
@@ -703,55 +640,52 @@
 "\n"
 "Références de version:\n"
 
-#: elf.c:1046
+#: elf.c:1048
 #, c-format
 msgid "  required from %s:\n"
 msgstr " requis par %s:\n"
 
-#: elf.c:1682
+#: elf.c:1675
 #, c-format
 msgid "%s: invalid link %lu for reloc section %s (index %u)"
 msgstr "%s: lien invalide %lu pour la section de relocalisation %s (index %u)"
 
-#: elf.c:3296
+#: elf.c:3289
 #, c-format
 msgid "%s: Not enough room for program headers (allocated %u, need %u)"
-msgstr ""
-"%s: pas suffisamment d'espace pour les en-têtes du programme (alloué %u, "
-"besoin de %u)"
+msgstr "%s: pas suffisamment d'espace pour les en-têtes du programme (alloué %u, besoin de %u)"
 
-#: elf.c:3400
+#: elf.c:3393
 #, c-format
 msgid "%s: Not enough room for program headers, try linking with -N"
-msgstr ""
-"%s: pas suffisamment d'espace pour les en-têtes du programme, essayer "
-"l'option -N"
+msgstr "%s: pas suffisamment d'espace pour les en-têtes du programme, essayer l'option -N"
 
-#: elf.c:3525
+#: elf.c:3518
 #, c-format
-msgid ""
-"Error: First section in segment (%s) starts at 0x%x whereas the segment "
-"starts at 0x%x"
-msgstr ""
-"Erreur: première section dans le segment (%s) débute à 0x%x alors que le "
-"segment débute à 0x%x"
+msgid "Error: First section in segment (%s) starts at 0x%x whereas the segment starts at 0x%x"
+msgstr "Erreur: première section dans le segment (%s) débute à 0x%x alors que le segment débute à 0x%x"
 
-#: elf.c:3811
+#: elf.c:3804
 #, c-format
 msgid "%s: warning: allocated section `%s' not in segment"
-msgstr "%s: AVERTISSEMENT: section allouée `%s' n'est pas dans le segment"
+msgstr "%s: AVERTISSEMENT: section allouée « %s » n'est pas dans le segment"
 
-#: elf.c:4142
+#: elf.c:4138
 #, c-format
 msgid "%s: symbol `%s' required but not present"
-msgstr "%s: symbole `%s' requis mais absent"
+msgstr "%s: symbole « %s » requis mais absent"
 
-#: elf.c:4395
+#: elf.c:4147
+#, c-format
+msgid "elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x%.8lx%s\n"
+msgstr "elf_symbol_from_bfd_symbol 0x%.8lx, nom = %s, no. de symbole = %d, fanions = 0x%.8lx%s\n"
+
+#: elf.c:4391
 #, c-format
 msgid "%s: warning: Empty loadable segment detected\n"
 msgstr "%s: AVERTISSEMENT: segment chargeable vide détecté\n"
 
-#: elf.c:5808
+#: elf.c:5804
 #, c-format
 msgid "%s: unsupported relocation type %s"
 msgstr "%s: type de relocalisation non supporté %s"
@@ -759,96 +693,77 @@
 #: elf32-arm.h:1224
 #, c-format
 msgid "%s: Warning: Arm BLX instruction targets Arm function '%s'."
-msgstr "%s: AVERTISSEMENT: instruction Arm BLX vise la fonction Arm '%s'."
+msgstr "%s: AVERTISSEMENT: instruction Arm BLX vise la fonction Arm « %s »."
 
 #: elf32-arm.h:1420
 #, c-format
 msgid "%s: Warning: Thumb BLX instruction targets thumb function '%s'."
-msgstr ""
-"%s: AVERTISSEMENT: instruction de repérage BLX vise la function de repérage "
-"'%s'."
+msgstr "%s: AVERTISSEMENT: instruction de repérage BLX vise la function de repérage « %s »."
 
-#: elf32-arm.h:1904 elf32-i386.c:1778 elf32-sh.c:3133
+#: elf32-arm.h:1904 elf32-i386.c:1776 elf32-sh.c:3133
 #, c-format
 msgid "%s(%s+0x%lx): %s relocation against SEC_MERGE section"
 msgstr "%s(%s+0x%lx): %s relocation vers une section SEC_MERGE"
 
 #: elf32-arm.h:1998
 #, c-format
-msgid ""
-"%s: warning: unresolvable relocation %d against symbol `%s' from %s section"
-msgstr ""
-"%s: AVERTISSEMENT: relocalisation sans solution %d vers le symbole `%s' de "
-"la section %s"
+msgid "%s: warning: unresolvable relocation %d against symbol `%s' from %s section"
+msgstr "%s: AVERTISSEMENT: relocalisation sans solution %d vers le symbole « %s » de la section %s"
+
+#: elf32-arm.h:2114
+#, c-format
+msgid "Warning: Not setting interwork flag of %s since it has already been specified as non-interworking"
+msgstr "AVERTISSEMENT: pas d'initialisation du fanion d'inter-réseautage %s alors qu'il a déjè été spécifié sans inter-réseautage"
+
+#: elf32-arm.h:2118
+#, c-format
+msgid "Warning: Clearing the interwork flag of %s due to outside request"
+msgstr "AVERTISSEMENT: mise à zéro du fanion d'inter-réseautage %s en raison d'une requête externe"
 
 #: elf32-arm.h:2166
-#, fuzzy, c-format
-msgid ""
-"Warning: Clearing the interworking flag of %s because non-interworking code "
-"in %s has been linked with it"
-msgstr ""
-"AVERTISSEMENT: mise à zéro du fanion d'inter-réseautage %s en raison du code "
-"sans inter-réseautage dans %s qui a été lié avec lui"
+#, c-format
+msgid "Warning: Clearing the interwork flag in %s because non-interworking code in %s has been linked with it"
+msgstr "AVERTISSEMENT: mise à zéro du fanion d'inter-réseautage %s en raison du code sans inter-réseautage dans %s qui a été lié avec lui"
 
 #: elf32-arm.h:2261
 #, c-format
-msgid ""
-"Error: %s compiled for EABI version %d, whereas %s is compiled for version %d"
-msgstr ""
-"Erreur: %s compilé pour une version EABI %d, alors que %s a été compilé pour "
-"la version %d"
+msgid "Error: %s compiled for EABI version %d, whereas %s is compiled for version %d"
+msgstr "Erreur: %s compilé pour une version EABI %d, alors que %s a été compilé pour la version %d"
 
 #: elf32-arm.h:2275
 #, c-format
 msgid "Error: %s compiled for APCS-%d, whereas %s is compiled for APCS-%d"
-msgstr ""
-"Erreur: %s compilé pour APCS-%d, alors que %s a été compilé pour APCS-%d"
+msgstr "Erreur: %s compilé pour APCS-%d, alors que %s a été compilé pour APCS-%d"
 
 #: elf32-arm.h:2287
 #, c-format
-msgid ""
-"Error: %s passes floats in FP registers, whereas %s passes them in integer "
-"registers"
-msgstr ""
-"Erreur: %s passage de valeurs en virgule flottante dans les registres FP, "
-"alors que %s les passe dans les registres entiers"
+msgid "Error: %s passes floats in FP registers, whereas %s passes them in integer registers"
+msgstr "Erreur: %s passage de valeurs en virgule flottante dans les registres FP, alors que %s les passe dans les registres entiers"
 
 #: elf32-arm.h:2292
 #, c-format
-msgid ""
-"Error: %s passes floats in integer registers, whereas %s passes them in FP "
-"registers"
-msgstr ""
-"Erreur: %s passage de valeurs en virgule flottante dans les registres "
-"entiers, alors que %s les passe dans les registres FP"
+msgid "Error: %s passes floats in integer registers, whereas %s passes them in FP registers"
+msgstr "Erreur: %s passage de valeurs en virgule flottante dans les registres entiers, alors que %s les passe dans les registres FP"
 
 #: elf32-arm.h:2303
-#, fuzzy, c-format
-msgid "Error: %s uses VFP instructions, whereas %s uses FPA instructions"
-msgstr ""
-"Erreur: %s utilise les instructions VFP, alors que %s utilise les "
-"instructions FPA"
+#, c-format
+msgid "Error: %s uses VFP instructions, whereas %s FPA instructions"
+msgstr "Erreur: %s utilise les instructions VFP, alors que %s utilise les instructions FPA"
 
 #: elf32-arm.h:2308
-#, fuzzy, c-format
-msgid "Error: %s uses FPA instructions, whereas %s uses VFP instructions"
-msgstr ""
-"Erreur: %s utilise les instructions FPA, alors que %s utilise les "
-"instructions VFP"
+#, c-format
+msgid "Error: %s uses FPA instructions, whereas %s VFP instructions"
+msgstr "Erreur: %s utilise les instructions FPA, alors que %s utilise les instructions VFP"
 
 #: elf32-arm.h:2328
 #, c-format
 msgid "Error: %s uses software FP, whereas %s uses hardware FP"
-msgstr ""
-"Erreur: %s utilise le logiciel pour virgule flottante, alors que %s utilise "
-"le matériel pour virgule flottante"
+msgstr "Erreur: %s utilise le logiciel pour virgule flottante, alors que %s utilise le matériel pour virgule flottante"
 
 #: elf32-arm.h:2333
 #, c-format
 msgid "Error: %s uses hardware FP, whereas %s uses software FP"
-msgstr ""
-"Erreur: %s utilise le matériel pour virgule flottante, alors que %s utilise "
-"le logiciel pour virgule flottante"
+msgstr "Erreur: %s utilise le matériel pour virgule flottante, alors que %s utilise le logiciel pour virgule flottante"
 
 #: elf32-arm.h:2348
 #, c-format
@@ -858,12 +773,11 @@
 #: elf32-arm.h:2355
 #, c-format
 msgid "Warning: %s does not support interworking, whereas %s does"
-msgstr ""
-"AVERTISSEMENT: %s ne supporte pas l'inter-réseautage, contrairement à %s."
+msgstr "AVERTISSEMENT: %s ne supporte pas l'inter-réseautage, contrairement à %s."
 
 #. Ignore init flag - it may not be set, despite the flags field
 #. containing valid data.
-#: elf32-arm.h:2386 elf32-cris.c:2991 elf32-m68k.c:410 elf32-mips.c:3242
+#: elf32-arm.h:2386 elf32-cris.c:2970 elf32-m68k.c:410 elf32-mips.c:3232
 #, c-format
 msgid "private flags = %lx:"
 msgstr "fanions privés = %lx"
@@ -940,26 +854,19 @@
 msgid "<Unrecognised flag bits set>"
 msgstr "<Bits de fanions non reconnus>"
 
-#: elf32-avr.c:843 elf32-cris.c:1414 elf32-fr30.c:661 elf32-i860.c:1056
-#: elf32-openrisc.c:463 elf32-v850.c:1699 elf32-xstormy16.c:984
-#: elf64-mmix.c:1172
+#: elf32-avr.c:843 elf32-cris.c:1400 elf32-fr30.c:661 elf32-i860.c:1056 elf32-openrisc.c:463 elf32-v850.c:1699 elf64-mmix.c:1172
 msgid "internal error: dangerous relocation"
 msgstr "erreur interne: relocalisation dangereuse"
 
 #: elf32-cris.c:949
 #, c-format
 msgid "%s: unresolvable relocation %s against symbol `%s' from %s section"
-msgstr ""
-"%s: relocalisation %s sans solution vers le symbole `%s' à partir de la "
-"section %s"
+msgstr "%s: relocalisation %s sans solution vers le symbole « %s » à partir de la section %s"
 
 #: elf32-cris.c:1012
 #, c-format
-msgid ""
-"%s: No PLT nor GOT for relocation %s against symbol `%s' from %s section"
-msgstr ""
-"%s: pas de relocalisation %s PLT ni GOT vers le symbole `%s' à partir de la "
-"section %s"
+msgid "%s: No PLT nor GOT for relocation %s against symbol `%s' from %s section"
+msgstr "%s: pas de relocalisation %s PLT ni GOT vers le symbole « %s » à partir de la section %s"
 
 #: elf32-cris.c:1015 elf32-cris.c:1142
 msgid "[whose name is lost]"
@@ -967,66 +874,46 @@
 
 #: elf32-cris.c:1131
 #, c-format
-msgid ""
-"%s: relocation %s with non-zero addend %d against local symbol from %s "
-"section"
-msgstr ""
-"%s: relocalisation %s sans zéro ajoute %d vers le symbole local à partir de "
-"la section %s"
+msgid "%s: relocation %s with non-zero addend %d against local symbol from %s section"
+msgstr "%s: relocalisation %s sans zéro ajoute %d vers le symbole local à partir de la section %s"
 
 #: elf32-cris.c:1138
 #, c-format
-msgid ""
-"%s: relocation %s with non-zero addend %d against symbol `%s' from %s section"
-msgstr ""
-"%s: relocalisation %s sans zéro ajoute %d vers le symbole `%s' à partir de "
-"la section %s"
+msgid "%s: relocation %s with non-zero addend %d against symbol `%s' from %s section"
+msgstr "%s: relocalisation %s sans zéro ajoute %d vers le symbole « %s » à partir de la section %s"
 
 #: elf32-cris.c:1156
 #, c-format
-msgid ""
-"%s: relocation %s is not allowed for global symbol: `%s' from %s section"
-msgstr ""
-"%s: relocalisation %s n'est pas permise pour le symbole global: `%s' de la "
-"section %s."
+msgid "%s: relocation %s is not allowed for global symbol: `%s' from %s section"
+msgstr "%s: relocalisation %s n'est pas permise pour le symbole global: « %s » de la section %s."
 
-#: elf32-cris.c:1171
-#, fuzzy, c-format
-msgid "%s: relocation %s in section %s with no GOT created"
-msgstr "%s: relocalisations dans la section `%s', mais n,a aucun contenu"
-
-#: elf32-cris.c:1289
+#: elf32-cris.c:1275
 #, c-format
 msgid "%s: Internal inconsistency; no relocation section %s"
 msgstr "%s: inconsistence interne; pas de section de relocalisation %s"
 
-#: elf32-cris.c:2523
+#: elf32-cris.c:2508
 #, c-format
 msgid ""
 "%s, section %s:\n"
 "  relocation %s should not be used in a shared object; recompile with -fPIC"
 msgstr ""
 "%s, section %s:\n"
-" relocalisation %s devrait être utilisée dans un objet partagé; recompiler "
-"avec -fPIC"
+" relocalisation %s devrait être utilisée dans un objet partagé; recompiler avec -fPIC"
 
-#: elf32-cris.c:2994
+#: elf32-cris.c:2973
 msgid " [symbols have a _ prefix]"
-msgstr " [symboles sont préfixés par `_']"
+msgstr " [symboles sont préfixés par « _ »]"
 
-#: elf32-cris.c:3033
+#: elf32-cris.c:3012
 #, c-format
 msgid "%s: uses _-prefixed symbols, but writing file with non-prefixed symbols"
-msgstr ""
-"%s: utilise  _-prefixed symbols, mais avec écriture au fichier avec des "
-"symboles sans préfixes"
+msgstr "%s: utilise  _-prefixed symbols, mais avec écriture au fichier avec des symboles sans préfixes"
 
-#: elf32-cris.c:3034
+#: elf32-cris.c:3013
 #, c-format
 msgid "%s: uses non-prefixed symbols, but writing file with _-prefixed symbols"
-msgstr ""
-"%s: utilise des symboles sans préfixes, mais avec écriture au fichier avec "
-"des symboles ayant des préfixes_-prefixed"
+msgstr "%s: utilise des symboles sans préfixes, mais avec écriture au fichier avec des symboles ayant des préfixes_-prefixed"
 
 #: elf32-gen.c:82 elf64-gen.c:82
 #, c-format
@@ -1038,51 +925,42 @@
 msgid "%s: cannot create stub entry %s"
 msgstr "%s: ne peut créer l'entrée du talon %s"
 
-#: elf32-hppa.c:937 elf32-hppa.c:3545
+#: elf32-hppa.c:937 elf32-hppa.c:3540
 #, c-format
 msgid "%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"
-msgstr ""
-"%s(%s+0x%lx): ne peut atteindre %s, recompiler avec -ffunction-sections"
+msgstr "%s(%s+0x%lx): ne peut atteindre %s, recompiler avec -ffunction-sections"
 
 #: elf32-hppa.c:1312
 #, c-format
-msgid ""
-"%s: relocation %s can not be used when making a shared object; recompile "
-"with -fPIC"
-msgstr ""
-"%s: relocalisation de %s ne peut être utilisée lors de la création d'un "
-"objet partagé; recompiler avec -fPIC"
+msgid "%s: relocation %s can not be used when making a shared object; recompile with -fPIC"
+msgstr "%s: relocalisation de %s ne peut être utilisée lors de la création d'un objet partagé; recompiler avec -fPIC"
 
 #: elf32-hppa.c:1332
 #, c-format
-msgid ""
-"%s: relocation %s should not be used when making a shared object; recompile "
-"with -fPIC"
-msgstr ""
-"%s: relocalisation %s ne doit pas être utilisée lors de la création d'un "
-"objet partagé; recompiler avec -fPIC"
+msgid "%s: relocation %s should not be used when making a shared object; recompile with -fPIC"
+msgstr "%s: relocalisation %s ne doit pas être utilisée lors de la création d'un objet partagé; recompiler avec -fPIC"
 
 #: elf32-hppa.c:1525
 #, c-format
 msgid "Could not find relocation section for %s"
 msgstr "Ne peut repérer la section de relocalisation pour %s"
 
-#: elf32-hppa.c:2867
+#: elf32-hppa.c:2862
 #, c-format
 msgid "%s: duplicate export stub %s"
 msgstr "%s: talon d'exportation en double %s"
 
-#: elf32-hppa.c:3429
+#: elf32-hppa.c:3424
 #, c-format
 msgid "%s(%s+0x%lx): fixing %s"
 msgstr "%s(%s+0x%lx): corrigeant %s"
 
-#: elf32-hppa.c:4069
+#: elf32-hppa.c:4064
 #, c-format
 msgid "%s(%s+0x%lx): cannot handle %s for %s"
 msgstr "%s(%s+0x%lx): ne traiter %s pour %s"
 
-#: elf32-hppa.c:4408
+#: elf32-hppa.c:4403
 msgid ".got section not immediately after .plt section"
 msgstr "section .got pas immédiatement après la section .plt"
 
@@ -1096,51 +974,50 @@
 msgid "%s: bad symbol index: %d"
 msgstr "%s: symbole index erroné: %d"
 
-#: elf32-i386.c:863 elf32-s390.c:790 elf64-ppc.c:2198 elf64-s390.c:759
+#: elf32-i386.c:863 elf32-s390.c:790 elf64-ppc.c:2085 elf64-s390.c:759
 #, c-format
 msgid "%s: bad relocation section name `%s'"
-msgstr "%s: nom de section de relocalisation erroné `%s'"
+msgstr "%s: nom de section de relocalisation erroné « %s »"
 
-#: elf32-i386.c:2069 elf32-s390.c:1951 elf64-ppc.c:4124 elf64-s390.c:1955
+#: elf32-i386.c:2067 elf32-s390.c:1949 elf64-ppc.c:3908 elf64-s390.c:1953
 #, c-format
 msgid "%s(%s+0x%lx): unresolvable relocation against symbol `%s'"
-msgstr "%s(%s+0x%lx): relocalisation sans solution vers le symbole `%s'"
+msgstr "%s(%s+0x%lx): relocalisation sans solution vers le symbole « %s »"
 
-#: elf32-i386.c:2107 elf32-s390.c:1989 elf64-s390.c:1993
+#: elf32-i386.c:2105 elf32-s390.c:1987 elf64-s390.c:1991
 #, c-format
 msgid "%s(%s+0x%lx): reloc against `%s': error %d"
-msgstr "%s(%s+0x%lx): relocalisation vers `%s': erreur %d"
+msgstr "%s(%s+0x%lx): relocalisation vers « %s »: erreur %d"
 
-#: elf32-m32r.c:923
+#: elf32-m32r.c:924
 msgid "SDA relocation when _SDA_BASE_ not defined"
 msgstr "relocalisation SDA alors que _SDA_BASE_ n'est pas définie"
 
-#: elf32-ia64.c:3537 elf32-m32r.c:1007 elf32-ppc.c:2930 elf64-ia64.c:3537
+#: elf32-ia64.c:3538 elf32-m32r.c:1008 elf32-ppc.c:2930 elf64-ia64.c:3538
 #, c-format
 msgid "%s: unknown relocation type %d"
 msgstr "%s: type de relocalisation inconnu %d"
 
-#: elf32-m32r.c:1223
+#: elf32-m32r.c:1224
 #, c-format
 msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)"
-msgstr ""
-"%s: la cible (%s) de la relocalisation %s est dans la mauvaise section (%s)"
+msgstr "%s: la cible (%s) de la relocalisation %s est dans la mauvaise section (%s)"
 
-#: elf32-m32r.c:2000
+#: elf32-m32r.c:2001
 #, c-format
 msgid "%s: Instruction set mismatch with previous modules"
 msgstr "%s: jeu d'instructions ne concorde par avec les modules précédents"
 
-#: elf32-m32r.c:2023
+#: elf32-m32r.c:2024
 #, c-format
 msgid "private flags = %lx"
 msgstr "fanions privés = %lx"
 
-#: elf32-m32r.c:2028
+#: elf32-m32r.c:2029
 msgid ": m32r instructions"
 msgstr ": instructions m32r"
 
-#: elf32-m32r.c:2029
+#: elf32-m32r.c:2030
 msgid ": m32rx instructions"
 msgstr ": instruction m32rx"
 
@@ -1158,170 +1035,154 @@
 msgid "%s: Unknown relocation type %d\n"
 msgstr "%s: type de relocalisation inconnue %d\n"
 
-#: elf32-mips.c:2156 elf64-mips.c:1972
+#: elf32-mips.c:2146 elf64-mips.c:1972
 msgid "32bits gp relative relocation occurs for an external symbol"
 msgstr "relocalisation relative gp 32bits est survenue pour un symbole externe"
 
-#: elf32-mips.c:2305
+#: elf32-mips.c:2295
 #, c-format
 msgid "Linking mips16 objects into %s format is not supported"
 msgstr "Édition de liens d'objets mips16 dans le format %s n'est pas supporté"
 
-#: elf32-mips.c:3129
+#: elf32-mips.c:3119
 #, c-format
 msgid "%s: linking PIC files with non-PIC files"
 msgstr "%s: édition de liens des fichiers PIC avec des fichiers non PIC"
 
-#: elf32-mips.c:3139
+#: elf32-mips.c:3129
 #, c-format
 msgid "%s: linking abicalls files with non-abicalls files"
-msgstr ""
-"%s: édition de liens des fichier abicalls avec des fichiers non abicalls"
+msgstr "%s: édition de liens des fichier abicalls avec des fichiers non abicalls"
 
-#: elf32-mips.c:3168
+#: elf32-mips.c:3158
 #, c-format
 msgid "%s: ISA mismatch (-mips%d) with previous modules (-mips%d)"
-msgstr ""
-"%s: ISA ne concorde pas (-mips%d) avec les modules précédents (-mips%d)"
+msgstr "%s: ISA ne concorde pas (-mips%d) avec les modules précédents (-mips%d)"
 
-#: elf32-mips.c:3177
+#: elf32-mips.c:3167
 #, c-format
 msgid "%s: ISA mismatch (%d) with previous modules (%d)"
 msgstr "%s: ISA ne concorde pas (%d) avec les modules précédents (%d)"
 
-#: elf32-mips.c:3200
+#: elf32-mips.c:3190
 #, c-format
 msgid "%s: ABI mismatch: linking %s module with previous %s modules"
-msgstr ""
-"%s: ABI ne concorde pas: édition de lien du module %s avec les modules "
-"précédents %s"
+msgstr "%s: ABI ne concorde pas: édition de lien du module %s avec les modules précédents %s"
 
-#: elf32-mips.c:3214 elf32-ppc.c:1470 elf64-ppc.c:1556 elf64-sparc.c:3027
+#: elf32-mips.c:3204 elf32-ppc.c:1470 elf64-ppc.c:1538 elf64-sparc.c:3033
 #, c-format
 msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
-msgstr ""
-"%s: utilise differents champs e_flags (0x%lx) que les modules précédents (0x%"
-"lx)"
+msgstr "%s: utilise differents champs e_flags (0x%lx) que les modules précédents (0x%lx)"
 
-#: elf32-mips.c:3245
+#: elf32-mips.c:3235
 msgid " [abi=O32]"
 msgstr " [abi=O32]"
 
-#: elf32-mips.c:3247
+#: elf32-mips.c:3237
 msgid " [abi=O64]"
 msgstr " [abi=O64]"
 
-#: elf32-mips.c:3249
+#: elf32-mips.c:3239
 msgid " [abi=EABI32]"
 msgstr " [abi=EABI32]"
 
-#: elf32-mips.c:3251
+#: elf32-mips.c:3241
 msgid " [abi=EABI64]"
 msgstr " [abi=EABI64]"
 
-#: elf32-mips.c:3253
+#: elf32-mips.c:3243
 msgid " [abi unknown]"
 msgstr " [abi inconnu]"
 
-#: elf32-mips.c:3255
+#: elf32-mips.c:3245
 msgid " [abi=N32]"
 msgstr " [abi=N32]"
 
-#: elf32-mips.c:3257
+#: elf32-mips.c:3247
 msgid " [abi=64]"
 msgstr " [abi=64]"
 
-#: elf32-mips.c:3259
+#: elf32-mips.c:3249
 msgid " [no abi set]"
 msgstr " [aucun jeu abi]"
 
-#: elf32-mips.c:3262
+#: elf32-mips.c:3252
 msgid " [mips1]"
 msgstr " [mips1]"
 
-#: elf32-mips.c:3264
+#: elf32-mips.c:3254
 msgid " [mips2]"
 msgstr " [mips2]"
 
-#: elf32-mips.c:3266
+#: elf32-mips.c:3256
 msgid " [mips3]"
 msgstr " [mips3]"
 
-#: elf32-mips.c:3268
+#: elf32-mips.c:3258
 msgid " [mips4]"
 msgstr " [mips4]"
 
-#: elf32-mips.c:3270
+#: elf32-mips.c:3260
 msgid " [mips5]"
 msgstr " [mips5]"
 
-#: elf32-mips.c:3272
+#: elf32-mips.c:3262
 msgid " [mips32]"
 msgstr " [mips32]"
 
-#: elf32-mips.c:3274
+#: elf32-mips.c:3264
 msgid " [mips64]"
 msgstr " [mips64]"
 
-#: elf32-mips.c:3276
+#: elf32-mips.c:3266
 msgid " [unknown ISA]"
 msgstr " [ISA inconnu]"
 
-#: elf32-mips.c:3279
+#: elf32-mips.c:3269
 msgid " [32bitmode]"
 msgstr " [mode 32 bits]"
 
-#: elf32-mips.c:3281
+#: elf32-mips.c:3271
 msgid " [not 32bitmode]"
 msgstr " [aucun mode 32 bits]"
 
-#: elf32-mips.c:4954
+#: elf32-mips.c:4947
 msgid "static procedure (no name)"
 msgstr "procédure statique (sans name)"
 
-#: elf32-mips.c:5572 elf64-mips.c:6694
+#: elf32-mips.c:5565 elf64-mips.c:6694
 #, c-format
 msgid "%s: illegal section name `%s'"
-msgstr "%s: nom illégal de section `%s'"
+msgstr "%s: nom illégal de section « %s »"
 
-#: elf32-mips.c:6139 elf64-mips.c:3150
+#: elf32-mips.c:6132 elf64-mips.c:3150
 msgid "not enough GOT space for local GOT entries"
 msgstr "pas suffisamment d'espace GOT pour les entrées locales GOT"
 
-#: elf32-mips.c:7250 elf64-mips.c:4203
+#: elf32-mips.c:7238 elf64-mips.c:4203
 #, c-format
 msgid "%s: %s+0x%lx: jump to stub routine which is not jal"
-msgstr ""
-"%s: %s+0x%lx: saut vers la routine dans la partie du talon (stub) qui n'est "
-"pas jal"
+msgstr "%s: %s+0x%lx: saut vers la routine dans la partie du talon (stub) qui n'est pas jal"
 
-#: elf32-mips.c:8259 elf64-mips.c:5891
+#: elf32-mips.c:8237 elf64-mips.c:5891
 #, c-format
 msgid "%s: Malformed reloc detected for section %s"
 msgstr "%s: relocalisation mal composée détectée dans la section %s"
 
-#: elf32-mips.c:8337 elf64-mips.c:5969
+#: elf32-mips.c:8315 elf64-mips.c:5969
 #, c-format
 msgid "%s: CALL16 reloc at 0x%lx not against global symbol"
-msgstr ""
-"%s: appel CALL16 de relocalisation à 0x%lx qui n'est pas pourun symbole "
-"global"
+msgstr "%s: appel CALL16 de relocalisation à 0x%lx qui n'est pas pourun symbole global"
 
-#: elf32-ppc.c:1436 elf64-ppc.c:1521
+#: elf32-ppc.c:1436 elf64-ppc.c:1503
 #, c-format
-msgid ""
-"%s: compiled with -mrelocatable and linked with modules compiled normally"
-msgstr ""
-"%s: compilé avec -mrelocatable et fait l'édition de lien avec les modules "
-"compilés normalement"
+msgid "%s: compiled with -mrelocatable and linked with modules compiled normally"
+msgstr "%s: compilé avec -mrelocatable et fait l'édition de lien avec les modules compilés normalement"
 
-#: elf32-ppc.c:1444 elf64-ppc.c:1529
+#: elf32-ppc.c:1444 elf64-ppc.c:1511
 #, c-format
-msgid ""
-"%s: compiled normally and linked with modules compiled with -mrelocatable"
-msgstr ""
-"%s: compilé normalement et fait l'édition de lien avec les modules compilés "
-"avec -mrelocatable"
+msgid "%s: compiled normally and linked with modules compiled with -mrelocatable"
+msgstr "%s: compilé normalement et fait l'édition de lien avec les modules compilés avec -mrelocatable"
 
 #: elf32-ppc.c:1568
 #, c-format
@@ -1331,22 +1192,17 @@
 #: elf32-ppc.c:2218 elf32-ppc.c:2252 elf32-ppc.c:2287
 #, c-format
 msgid "%s: relocation %s cannot be used when making a shared object"
-msgstr ""
-"%s: relocalisation %s ne peut être utilisée lors de la création d'un objet "
-"partagé"
+msgstr "%s: relocalisation %s ne peut être utilisée lors de la création d'un objet partagé"
 
-#: elf32-ppc.c:3097 elf64-ppc.c:3716
+#: elf32-ppc.c:3097 elf64-ppc.c:3500
 #, c-format
 msgid "%s: unknown relocation type %d for symbol %s"
 msgstr "%s: type de relocalisation inconnue %d pour le symbole %s"
 
 #: elf32-ppc.c:3452 elf32-ppc.c:3473 elf32-ppc.c:3523
 #, c-format
-msgid ""
-"%s: The target (%s) of a %s relocation is in the wrong output section (%s)"
-msgstr ""
-"%s: la cible (%s) d'une relocalisation %s est dans la mauvaise section de "
-"sortie (%s)"
+msgid "%s: The target (%s) of a %s relocation is in the wrong output section (%s)"
+msgstr "%s: la cible (%s) d'une relocalisation %s est dans la mauvaise section de sortie (%s)"
 
 #: elf32-ppc.c:3589
 #, c-format
@@ -1381,9 +1237,7 @@
 #: elf32-sh.c:1323
 #, c-format
 msgid "%s: 0x%lx: warning: could not find expected COUNT reloc"
-msgstr ""
-"%s: 0x%lx: AVERTISSEMENT: ne peut repérer le compteur de relocalisation "
-"attendu"
+msgstr "%s: 0x%lx: AVERTISSEMENT: ne peut repérer le compteur de relocalisation attendu"
 
 #: elf32-sh.c:1332
 #, c-format
@@ -1393,17 +1247,14 @@
 #: elf32-sh.c:1741 elf32-sh.c:2132
 #, c-format
 msgid "%s: 0x%lx: fatal: reloc overflow while relaxing"
-msgstr ""
-"%s: 0x%lx: erreur fatale: débordement de relocalisation lors de relâches"
+msgstr "%s: 0x%lx: erreur fatale: débordement de relocalisation lors de relâches"
 
 #: elf32-sh.c:3267
 #, c-format
 msgid "%s: 0x%lx: fatal: unaligned branch target for relax-support relocation"
-msgstr ""
-"%s: 0x%lx: fatal: cible de branchement non aligné pour une relocalisatin de "
-"type relax-support"
+msgstr "%s: 0x%lx: fatal: cible de branchement non aligné pour une relocalisatin de type relax-support"
 
-#: elf32-sparc.c:1554 elf64-sparc.c:2280
+#: elf32-sparc.c:1554 elf64-sparc.c:2286
 #, c-format
 msgid "%s: probably compiled without -fPIC?"
 msgstr "%s: probablement compilé sans -fPIC?"
@@ -1423,39 +1274,27 @@
 #: elf32-v850.c:682
 #, c-format
 msgid "Variable `%s' cannot occupy in multiple small data regions"
-msgstr "Variable `%s' ne peut occuper de multiples petites régions de données"
+msgstr "Variable « %s » ne peut occuper de multiples petites régions de données"
 
 #: elf32-v850.c:685
 #, c-format
-msgid ""
-"Variable `%s' can only be in one of the small, zero, and tiny data regions"
-msgstr ""
-"Variable `%s' peut seulement être dans une région de données petite, zéro ou "
-"minuscule"
+msgid "Variable `%s' can only be in one of the small, zero, and tiny data regions"
+msgstr "Variable « %s » peut seulement être dans une région de données petite, zéro ou minuscule"
 
 #: elf32-v850.c:688
 #, c-format
-msgid ""
-"Variable `%s' cannot be in both small and zero data regions simultaneously"
-msgstr ""
-"Variable `%s' ne peut être dans une région de données petite et zéro à la "
-"fois"
+msgid "Variable `%s' cannot be in both small and zero data regions simultaneously"
+msgstr "Variable « %s » ne peut être dans une région de données petite et zéro à la fois"
 
 #: elf32-v850.c:691
 #, c-format
-msgid ""
-"Variable `%s' cannot be in both small and tiny data regions simultaneously"
-msgstr ""
-"Variable `%s' ne peut être dans une région de données petite et minuscule "
-"zéro à la fois"
+msgid "Variable `%s' cannot be in both small and tiny data regions simultaneously"
+msgstr "Variable « %s » ne peut être dans une région de données petite et minuscule zéro à la fois"
 
 #: elf32-v850.c:694
 #, c-format
-msgid ""
-"Variable `%s' cannot be in both zero and tiny data regions simultaneously"
-msgstr ""
-"Variable `%s' ne peut être dans une région de données zéro et minuscule zéro "
-"à la fois"
+msgid "Variable `%s' cannot be in both zero and tiny data regions simultaneously"
+msgstr "Variable « %s » ne peut être dans une région de données zéro et minuscule zéro à la fois"
 
 #: elf32-v850.c:1072
 msgid "FAILED to find previous HI16 reloc\n"
@@ -1495,10 +1334,6 @@
 msgid "v850ea architecture"
 msgstr "architecture v850ea"
 
-#: elf32-ia64.c:2247 elf32-xstormy16.c:414 elf64-ia64.c:2247
-msgid "non-zero addend in @fptr reloc"
-msgstr "ajout non null dans la relocalisation @fptr"
-
 #: elf64-alpha.c:858
 msgid "GPDISP relocation did not find ldah and lda instructions"
 msgstr "la relocalisation GPDISP n'a pas repéré les instructions ldah et lda"
@@ -1518,75 +1353,63 @@
 msgid "stub entry for %s cannot load .plt, dp offset = %ld"
 msgstr "entrée du talon pour %s ne peut charger .plt, décalage dp = %ld"
 
-#: elf64-mmix.c:1271
-#, fuzzy, c-format
-msgid "%s: register relocation against non-register symbol: (unknown) in %s"
-msgstr ""
-"%s: relocalisation de registre vers le symbole non-registre: %s dans %s"
-
-#: elf64-mmix.c:1276
+#: elf64-mmix.c:1268
 #, c-format
 msgid "%s: register relocation against non-register symbol: %s in %s"
-msgstr ""
-"%s: relocalisation de registre vers le symbole non-registre: %s dans %s"
+msgstr "%s: relocalisation de registre vers le symbole non-registre: %s dans %s"
 
-#: elf64-mmix.c:1312
+#: elf64-mmix.c:1270
+msgid "(unknown)"
+msgstr "(inconnu)"
+
+#: elf64-mmix.c:1305
 #, c-format
 msgid "%s: directive LOCAL valid only with a register or absolute value"
-msgstr ""
-"%s: directive LOCAL valide seulement avec un registre ou une valeur absolue"
+msgstr "%s: directive LOCAL valide seulement avec un registre ou une valeur absolue"
 
-#: elf64-mmix.c:1340
+#: elf64-mmix.c:1333
 #, c-format
-msgid ""
-"%s: LOCAL directive: Register $%ld is not a local register.  First global "
-"register is $%ld."
-msgstr ""
-"%s: directive LOCAL: registre $%ld n'est pas un registre local.  Premier "
-"registre global est $%ld."
+msgid "%s: LOCAL directive: Register $%ld is not a local register.  First global register is $%ld."
+msgstr "%s: directive LOCAL: registre $%ld n'est pas un registre local.  Premier registre global est $%ld."
 
-#: elf64-mmix.c:1615
+#: elf64-mmix.c:1609
 #, c-format
-msgid ""
-"%s: Error: multiple definition of `%s'; start of %s is set in a earlier "
-"linked file\n"
-msgstr ""
-"%s: erreur: multiple définitions de `%s'; début de %s est initialisé dans un "
-"précédent fichier lié\n"
+msgid "%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"
+msgstr "%s: erreur: multiple définitions de « %s »; début de %s est initialisé dans un précédent fichier lié\n"
 
-#: elf64-mmix.c:1674
+#: elf64-mmix.c:1668
 msgid "Register section has contents\n"
 msgstr "Registre de section contient\n"
 
-#: elf64-ppc.c:1484 libbfd.c:1436
+#: elf64-ppc.c:1466 libbfd.c:1436
 #, c-format
 msgid "%s: compiled for a big endian system and target is little endian"
 msgstr ""
 "%s: compilé pour un système à octets de poids fort alors que la cible\n"
 "est un système à octets de poids faible"
 
-#: elf64-ppc.c:1486 libbfd.c:1438
+#: elf64-ppc.c:1468 libbfd.c:1438
 #, c-format
 msgid "%s: compiled for a little endian system and target is big endian"
 msgstr ""
 "%s: compilé pour un système à octets de poids faible alors que la cible\n"
 "est un système à octets de poids fort"
 
-#: elf64-ppc.c:3350
-#, fuzzy, c-format
-msgid "linkage table error against `%s'"
-msgstr "débordement de la table de liaison vers `%s'"
+#: elf64-ppc.c:3166
+#, c-format
+msgid "linkage table overflow against `%s'"
+msgstr "débordement de la table de liaison vers « %s »"
 
-#: elf64-ppc.c:3432
+#: elf64-ppc.c:3244
 msgid "stub section size doesn't match calculated size"
 msgstr "taille de la section du talon ne concorde pas avec la taille calculée"
 
-#: elf64-ppc.c:4061
+#: elf64-ppc.c:3845
 #, c-format
 msgid "%s: Relocation %s is not supported for symbol %s."
 msgstr "%s: relocalisation %s n'est pas supportée pour le symbole %s."
 
-#: elf64-ppc.c:4105
+#: elf64-ppc.c:3889
 #, c-format
 msgid "%s: error: relocation %s not a multiple of 4"
 msgstr "%s: erreur: relocalisation %s n'est pas un multiple de 4"
@@ -1599,39 +1422,32 @@
 #: elf64-sparc.c:1314
 #, c-format
 msgid "%s: Only registers %%g[2367] can be declared using STT_REGISTER"
-msgstr ""
-"%s: seuls les registres %%g[2367] peuvent être déclarés en utilisant les "
-"registres STT_REGISTER"
+msgstr "%s: seuls les registres %%g[2367] peuvent être déclarés en utilisant les registres STT_REGISTER"
 
 #: elf64-sparc.c:1334
-#, fuzzy, c-format
-msgid "Register %%g%d used incompatibly: %s in %s, previously %s in %s"
+#, c-format
+msgid "Register %%g%d used incompatibly: %s in %s"
 msgstr "Registre %%g%d utilisé de manière incompatible: %s dans %s"
 
-#: elf64-sparc.c:1357
-#, fuzzy, c-format
-msgid "Symbol `%s' has differing types: REGISTER in %s, previously %s in %s"
-msgstr ""
-"Symbole `%s' a des types qui diffèrent: précédemment %s, ENREGISTRÉ dans %s"
+#: elf64-sparc.c:1338 elf64-sparc.c:1362 elf64-sparc.c:1411
+#, c-format
+msgid "  previously %s in %s"
+msgstr " précédemment %s dans %s"
 
-#: elf64-sparc.c:1404
-#, fuzzy, c-format
-msgid "Symbol `%s' has differing types: %s in %s, previously REGISTER in %s"
-msgstr ""
-"Symbole `%s' a des types qui diffèrent: précédemment %s, ENREGISTRÉ dans %s"
+#: elf64-sparc.c:1359 elf64-sparc.c:1408
+#, c-format
+msgid "Symbol `%s' has differing types: %s in %s"
+msgstr "Symbole « %s » a des types qui diffèrent: %s dans %s"
 
-#: elf64-sparc.c:3008
+#: elf64-sparc.c:3014
 #, c-format
 msgid "%s: linking UltraSPARC specific with HAL specific code"
-msgstr ""
-"%s: édition de liens spécifiques pour UltraSPARC avec du code spécifique HAL"
+msgstr "%s: édition de liens spécifiques pour UltraSPARC avec du code spécifique HAL"
 
 #: elfcode.h:1218
 #, c-format
 msgid "%s: version count (%ld) does not match symbol count (%ld)"
-msgstr ""
-"%s: compteur de version (%ld) ne concorde pas avec le symbole du compteur (%"
-"ld)"
+msgstr "%s: compteur de version (%ld) ne concorde pas avec le symbole du compteur (%ld)"
 
 #: elflink.c:434
 #, c-format
@@ -1641,7 +1457,7 @@
 #: elflink.h:1113
 #, c-format
 msgid "%s: warning: unexpected redefinition of `%s'"
-msgstr "%s: AVERTISSEMENT: redéfinition inattendue de `%s'"
+msgstr "%s: AVERTISSEMENT: redéfinition inattendue de « %s »"
 
 #: elflink.h:1784
 #, c-format
@@ -1656,43 +1472,40 @@
 #: elflink.h:1945
 #, c-format
 msgid "Warning: size of symbol `%s' changed from %lu to %lu in %s"
-msgstr "AVERTISSEMENT: taille du symbole `%s' a changé de %lu à %lu dans %s"
+msgstr "AVERTISSEMENT: taille du symbole « %s » a changé de %lu à %lu dans %s"
 
-#: elflink.h:4014
+#: elflink.h:4020
 #, c-format
 msgid "warning: type and size of dynamic symbol `%s' are not defined"
-msgstr ""
-"AVERTISSEMENT: type et taille du symbole dynamique `%s' ne sont pas définis"
+msgstr "AVERTISSEMENT: type et taille du symbole dynamique « %s » ne sont pas définis"
 
-#: elflink.h:4320
+#: elflink.h:4329
 #, c-format
 msgid "%s: undefined versioned symbol name %s"
 msgstr "%s: nom symbole avec version indéfinie %s"
 
-#: elflink.h:4544 elflink.h:4552 elflink.h:6203 elflink.h:7280
+#: elflink.h:4559 elflink.h:4567 elflink.h:6218 elflink.h:7295
 msgid "Error: out of memory"
 msgstr "Erreur: mémoire épuisée"
 
-#: elflink.h:4714
+#: elflink.h:4729
 msgid "Not enough memory to sort relocations"
 msgstr "Pas assez de mémoire pour effectuer le trie des relocalisations"
 
-#: elflink.h:5980
+#: elflink.h:5995
 #, c-format
 msgid "%s: could not find output section %s for input section %s"
-msgstr ""
-"%s: ne peut repérer la section de sortie %s pour la section d'entrée %s"
+msgstr "%s: ne peut repérer la section de sortie %s pour la section d'entrée %s"
 
-#: elflink.h:6553
+#: elflink.h:6568
 msgid "warning: relocation against removed section; zeroing"
-msgstr ""
-"AVERTISSEMENT: relocalisation vers une section qui a été enlevée; mise à zéro"
+msgstr "AVERTISSEMENT: relocalisation vers une section qui a été enlevée; mise à zéro"
 
-#: elflink.h:6583
+#: elflink.h:6598
 msgid "warning: relocation against removed section"
 msgstr "AVERTISSEMENT: relocalisation vers une section enlevée"
 
-#: elflink.h:6596
+#: elflink.h:6611
 #, c-format
 msgid "local symbols in discarded section %s"
 msgstr "symboles locaux de la section mise à l'écart %s"
@@ -1700,15 +1513,14 @@
 #: i386linux.c:455 m68klinux.c:459 sparclinux.c:456
 #, c-format
 msgid "Output file requires shared library `%s'\n"
-msgstr "La sortie requiert une ilbrairie partagée `%s'\n"
+msgstr "La sortie requiert une ilbrairie partagée « %s »\n"
 
 #: i386linux.c:463 m68klinux.c:467 sparclinux.c:464
 #, c-format
 msgid "Output file requires shared library `%s.so.%s'\n"
-msgstr "Le fichier de sortie requiert une librairie partagée `%s.so.%s'\n"
+msgstr "Le fichier de sortie requiert une librairie partagée « %s.so.%s »\n"
 
-#: i386linux.c:653 i386linux.c:703 m68klinux.c:660 m68klinux.c:708
-#: sparclinux.c:655 sparclinux.c:705
+#: i386linux.c:653 i386linux.c:703 m68klinux.c:660 m68klinux.c:708 sparclinux.c:655 sparclinux.c:705
 #, c-format
 msgid "Symbol %s not defined for fixups\n"
 msgstr "Symbole %s n'est pas défini pour les corrections\n"
@@ -1725,11 +1537,11 @@
 #: ieee.c:365
 #, c-format
 msgid "%s: unrecognized symbol `%s' flags 0x%x"
-msgstr "%s: symbole non reconnue `%s' fanions 0x%x"
+msgstr "%s: symbole non reconnue « %s » fanions 0x%x"
 
 #: ieee.c:877
-#, fuzzy, c-format
-msgid "%s: unimplemented ATI record %u for symbol %u"
+#, c-format
+msgid "%s: unimplemented ATI record  %u for symbol %u"
 msgstr "%s: enregistrement ATI non implanté %u pour le symbole %u"
 
 #: ieee.c:902
@@ -1745,42 +1557,32 @@
 #: ihex.c:258
 #, c-format
 msgid "%s:%d: unexpected character `%s' in Intel Hex file\n"
-msgstr "%s:%d: caractères inattendue `%s' dans le fichier Intel hexadécimal\n"
+msgstr "%s:%d: caractères inattendue « %s » dans le fichier Intel hexadécimal\n"
 
 #: ihex.c:368
 #, c-format
 msgid "%s:%u: bad checksum in Intel Hex file (expected %u, found %u)"
-msgstr ""
-"%s:%u: somme de contrôle erronée dans le fichier Intel hexadécimal (attendu %"
-"u, obtenu %u)"
+msgstr "%s:%u: somme de contrôle erronée dans le fichier Intel hexadécimal (attendu %u, obtenu %u)"
 
 #: ihex.c:422
 #, c-format
 msgid "%s:%u: bad extended address record length in Intel Hex file"
-msgstr ""
-"%s:%u: longueur erronée de l'enregistrement d'adresse étendue dans le "
-"fichier Intel hexadécimal"
+msgstr "%s:%u: longueur erronée de l'enregistrement d'adresse étendue dans le fichier Intel hexadécimal"
 
 #: ihex.c:439
 #, c-format
 msgid "%s:%u: bad extended start address length in Intel Hex file"
-msgstr ""
-"%s:%u: longueur erronée d'adresse étendue de début dans le fichier Intel "
-"hexadécimal"
+msgstr "%s:%u: longueur erronée d'adresse étendue de début dans le fichier Intel hexadécimal"
 
 #: ihex.c:456
 #, c-format
 msgid "%s:%u: bad extended linear address record length in Intel Hex file"
-msgstr ""
-"%s:%u: longueur erronée de l'enregistrement d'adresse étendue linéaire dans "
-"le fichier Intel hexadécimal"
+msgstr "%s:%u: longueur erronée de l'enregistrement d'adresse étendue linéaire dans le fichier Intel hexadécimal"
 
 #: ihex.c:473
 #, c-format
 msgid "%s:%u: bad extended linear start address length in Intel Hex file"
-msgstr ""
-"%s:%u: longueur erronée d'adresse étendue linéraire de début dans le fichier "
-"Intel hexadécimal"
+msgstr "%s:%u: longueur erronée d'adresse étendue linéraire de début dans le fichier Intel hexadécimal"
 
 #: ihex.c:490
 #, c-format
@@ -1798,8 +1600,8 @@
 msgstr "%s: longuer erronée de section dans ihex_read_section"
 
 #: ihex.c:863
-#, fuzzy, c-format
-msgid "%s: address 0x%s out of range for Intel Hex file"
+#, c-format
+msgid "%s: address 0x%s out of range for Intex Hex file"
 msgstr "%s: adresse 0x%s hors gamme pour le fichier Intel hexadécimal"
 
 #: libbfd.c:492
@@ -1811,26 +1613,25 @@
 msgid "not mapping: env var not set\n"
 msgstr "pas de table de projection: variable d'environnement pas initialisée\n"
 
-#: libbfd.c:1467
-#, fuzzy, c-format
-msgid "Deprecated %s called at %s line %d in %s\n"
-msgstr " à %s ligne %d dans %s\n"
-
-#: libbfd.c:1470
-#, fuzzy, c-format
-msgid "Deprecated %s called\n"
+#: libbfd.c:1463
+#, c-format
+msgid "Deprecated %s called"
 msgstr "%s appel déprécié"
 
+#: libbfd.c:1465
+#, c-format
+msgid " at %s line %d in %s\n"
+msgstr " à %s ligne %d dans %s\n"
+
 #: linker.c:1849
 #, c-format
 msgid "%s: indirect symbol `%s' to `%s' is a loop"
-msgstr "%s: symbole indirect `%s' vers `%s' est une boucle"
+msgstr "%s: symbole indirect « %s » vers « %s » est une boucle"
 
 #: linker.c:2745
 #, c-format
 msgid "Attempt to do relocateable link with %s input and %s output"
-msgstr ""
-"Tentative de relocalisation d'un lien avec %s à l'entrée et %s à la sortie"
+msgstr "Tentative de relocalisation d'un lien avec %s à l'entrée et %s à la sortie"
 
 #: merge.c:897
 #, c-format
@@ -1850,140 +1651,97 @@
 #: mmo.c:1190
 #, c-format
 msgid "%s: invalid mmo file: initialization value for $255 is not `Main'\n"
-msgstr ""
-"%s: fichier mmo invalide: valeur d'initialisation pour $255 n'est pas "
-"`Main'\n"
+msgstr "%s: fichier mmo invalide: valeur d'initialisation pour $255 n'est pas « Main »\n"
 
 #: mmo.c:1336
 #, c-format
-msgid ""
-"%s: unsupported wide character sequence 0x%02X 0x%02X after symbol name "
-"starting with `%s'\n"
-msgstr ""
-"%s: séquence de caractères large 0x%02X 0x%02X non supportée après le nom de "
-"symbole débutant avec `%s'\n"
+msgid "%s: unsupported wide character sequence 0x%02X 0x%02X after symbol name starting with `%s'\n"
+msgstr "%s: séquence de caractères large 0x%02X 0x%02X non supportée après le nom de symbole débutant avec « %s »\n"
 
 #: mmo.c:1571
 #, c-format
 msgid "%s: invalid mmo file: unsupported lopcode `%d'\n"
-msgstr "%s: fichier mmo invalide: lopcode non supporté `%d'\n"
+msgstr "%s: fichier mmo invalide: lopcode non supporté « %d »\n"
 
 #: mmo.c:1581
 #, c-format
 msgid "%s: invalid mmo file: expected YZ = 1 got YZ = %d for lop_quote\n"
-msgstr ""
-"%s: fichier mmo invalide: attendu YZ = 1 obtenu YZ = %d pour lop_quote\n"
+msgstr "%s: fichier mmo invalide: attendu YZ = 1 obtenu YZ = %d pour lop_quote\n"
 
 #: mmo.c:1617
 #, c-format
 msgid "%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_loc\n"
-msgstr ""
-"%s: fichier mmo invalide: attendu z = 1 ou z = 2, obtenu z = %d pour "
-"lop_loc\n"
+msgstr "%s: fichier mmo invalide: attendu z = 1 ou z = 2, obtenu z = %d pour lop_loc\n"
 
 #: mmo.c:1663
 #, c-format
-msgid ""
-"%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_fixo\n"
-msgstr ""
-"%s: fichier mmo invalide: attendu z = 1 ou z = 2, obtenu z = %d pour "
-"lop_fixo\n"
+msgid "%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_fixo\n"
+msgstr "%s: fichier mmo invalide: attendu z = 1 ou z = 2, obtenu z = %d pour lop_fixo\n"
 
 #: mmo.c:1702
 #, c-format
 msgid "%s: invalid mmo file: expected y = 0, got y = %d for lop_fixrx\n"
-msgstr ""
-"%s: fichier mmo invalide: attendu y = 0, obtenu y = %d pour lop_fixrx\n"
+msgstr "%s: fichier mmo invalide: attendu y = 0, obtenu y = %d pour lop_fixrx\n"
 
 #: mmo.c:1711
 #, c-format
-msgid ""
-"%s: invalid mmo file: expected z = 16 or z = 24, got z = %d for lop_fixrx\n"
-msgstr ""
-"%s: fichier mmo invalide: attendu z = 16 ou z = 24, obtenu z = %d pour "
-"lop_fixrx\n"
+msgid "%s: invalid mmo file: expected z = 16 or z = 24, got z = %d for lop_fixrx\n"
+msgstr "%s: fichier mmo invalide: attendu z = 16 ou z = 24, obtenu z = %d pour lop_fixrx\n"
 
 #: mmo.c:1734
 #, c-format
-msgid ""
-"%s: invalid mmo file: leading byte of operand word must be 0 or 1, got %d "
-"for lop_fixrx\n"
-msgstr ""
-"%s: fichier mmo invalide: octet de tête du mot de l'opérande doit être 0 ou "
-"1, obtenu %d pour lop_fixrx\n"
+msgid "%s: invalid mmo file: leading byte of operand word must be 0 or 1, got %d for lop_fixrx\n"
+msgstr "%s: fichier mmo invalide: octet de tête du mot de l'opérande doit être 0 ou 1, obtenu %d pour lop_fixrx\n"
 
 #: mmo.c:1757
 #, c-format
 msgid "%s: cannot allocate file name for file number %d, %d bytes\n"
-msgstr ""
-"%s: ne allouer un nom de ficheir pour le no. de fichier %d, %d octets\n"
+msgstr "%s: ne allouer un nom de ficheir pour le no. de fichier %d, %d octets\n"
 
 #: mmo.c:1777
 #, c-format
-msgid ""
-"%s: invalid mmo file: file number %d `%s', was already entered as `%s'\n"
-msgstr ""
-"%s: fichier mmo invalide: no. de fichier %d `%s', a déjà été entré comme `%"
-"s'\n"
+msgid "%s: invalid mmo file: file number %d `%s', was already entered as `%s'\n"
+msgstr "%s: fichier mmo invalide: no. de fichier %d « %s », a déjà été entré comme « %s »\n"
 
 #: mmo.c:1790
 #, c-format
-msgid ""
-"%s: invalid mmo file: file name for number %d was not specified before use\n"
-msgstr ""
-"%s: fichier mmo invalide: nom de fichier %d n'a pas été spécifié avant son "
-"utilisation\n"
+msgid "%s: invalid mmo file: file name for number %d was not specified before use\n"
+msgstr "%s: fichier mmo invalide: nom de fichier %d n'a pas été spécifié avant son utilisation\n"
 
 #: mmo.c:1896
 #, c-format
-msgid ""
-"%s: invalid mmo file: fields y and z of lop_stab non-zero, y: %d, z: %d\n"
-msgstr ""
-"%s: fichier mmo invalide: champs y et z de lop_stab non null, y: %d, z: %d\n"
+msgid "%s: invalid mmo file: fields y and z of lop_stab non-zero, y: %d, z: %d\n"
+msgstr "%s: fichier mmo invalide: champs y et z de lop_stab non null, y: %d, z: %d\n"
 
 #: mmo.c:1932
 #, c-format
 msgid "%s: invalid mmo file: lop_end not last item in file\n"
-msgstr ""
-"%s: fichier mmo invalide: lop_end N,est pas le dernier item dans le fichier\n"
+msgstr "%s: fichier mmo invalide: lop_end N,est pas le dernier item dans le fichier\n"
 
 #: mmo.c:1945
 #, c-format
-msgid ""
-"%s: invalid mmo file: YZ of lop_end (%ld) not equal to the number of tetras "
-"to the preceding lop_stab (%ld)\n"
-msgstr ""
-"%s: fichier mmo invalide: YZ de lop_end (%ld) n'est pas égal au nombre de "
-"teras du lop_stab précédent (%ld)\n"
+msgid "%s: invalid mmo file: YZ of lop_end (%ld) not equal to the number of tetras to the preceding lop_stab (%ld)\n"
+msgstr "%s: fichier mmo invalide: YZ de lop_end (%ld) n'est pas égal au nombre de teras du lop_stab précédent (%ld)\n"
 
 #: mmo.c:2610
 #, c-format
 msgid "%s: invalid symbol table: duplicate symbol `%s'\n"
-msgstr "%s: table de symboles invalides: duplication du symbole `%s'\n"
+msgstr "%s: table de symboles invalides: duplication du symbole « %s »\n"
 
 #: mmo.c:2898
 #, c-format
-msgid ""
-"%s: Bad symbol definition: `Main' set to %s rather than the start address %"
-"s\n"
-msgstr ""
-"%s: définition de symbole erronée: `Main' initialisé à %s au lieu de "
-"l'adresse de départ %s\n"
+msgid "%s: Bad symbol definition: `Main' set to %s rather than the start address %s\n"
+msgstr "%s: définition de symbole erronée: « Main » initialisé à %s au lieu de l'adresse de départ %s\n"
 
 #: mmo.c:2932
 #, c-format
-msgid ""
-"%s: warning: symbol table too large for mmo, larger than 65535 32-bit words: "
-"%d.  Only `Main' will be emitted.\n"
-msgstr ""
-"%s: avertissement: table de symboles trop grande pour mmo, plus grande que "
-"65535 mots de 32 bits: %d. Seul `Main' sera produit.\n"
+msgid "%s: warning: symbol table too large for mmo, larger than 65535 32-bit words: %d.  Only `Main' will be emitted.\n"
+msgstr "%s: avertissement: table de symboles trop grande pour mmo, plus grande que 65535 mots de 32 bits: %d. Seul « Main » sera produit.\n"
 
 #: mmo.c:2977
 #, c-format
 msgid "%s: internal error, symbol table changed size from %d to %d words\n"
-msgstr ""
-"%s: erreur interne, table de symbole a changé de taille de %d à %d mots\n"
+msgstr "%s: erreur interne, table de symbole a changé de taille de %d à %d mots\n"
 
 #: mmo.c:3032
 #, c-format
@@ -2002,17 +1760,13 @@
 
 #: mmo.c:3095
 #, c-format
-msgid ""
-"%s: invalid start address for initialized registers of length %ld: 0x%lx%"
-"08lx\n"
-msgstr ""
-"%s: adresse de départ invalide pour des registres initialisés de longueur %"
-"ld: 0x%lx%08lx\n"
+msgid "%s: invalid start address for initialized registers of length %ld: 0x%lx%08lx\n"
+msgstr "%s: adresse de départ invalide pour des registres initialisés de longueur %ld: 0x%lx%08lx\n"
 
 #: oasys.c:1036
 #, c-format
 msgid "%s: can not represent section `%s' in oasys"
-msgstr "%s: ne peut représenter la section `%s' dans oasis"
+msgstr "%s: ne peut représenter la section « %s » dans oasis"
 
 #: osf-core.c:132
 #, c-format
@@ -2022,7 +1776,7 @@
 #: pe-mips.c:658
 #, c-format
 msgid "%s: `ld -r' not supported with PE MIPS objects\n"
-msgstr "%s: `ld -r' non supporté avec les objets PE MIPS\n"
+msgstr "%s: « ld -r » non supporté avec les objets PE MIPS\n"
 
 #. OK, at this point the following variables are set up:
 #. src = VMA of the memory we're fixing up
@@ -2063,25 +1817,17 @@
 #: peicode.h:1162
 #, c-format
 msgid "%s: Unrecognised machine type (0x%x) in Import Library Format archive"
-msgstr ""
-"%s: type de machine non reconnue (0x%x) dans l'archive de librairie "
-"d'importation"
+msgstr "%s: type de machine non reconnue (0x%x) dans l'archive de librairie d'importation"
 
 #: peicode.h:1174
 #, c-format
-msgid ""
-"%s: Recognised but unhandled machine type (0x%x) in Import Library Format "
-"archive"
-msgstr ""
-"%s: type de machine reconnue mais non traitée (0x%x) dans l'archive da la "
-"librairie de formats d'importation"
+msgid "%s: Recognised but unhandled machine type (0x%x) in Import Library Format archive"
+msgstr "%s: type de machine reconnue mais non traitée (0x%x) dans l'archive da la librairie de formats d'importation"
 
 #: peicode.h:1191
 #, c-format
 msgid "%s: size field is zero in Import Library Format header"
-msgstr ""
-"%s: taille du champ est zéro dans l'en-tête de la librairie de formats "
-"d'importation"
+msgstr "%s: taille du champ est zéro dans l'en-tête de la librairie de formats d'importation"
 
 #: peicode.h:1219
 #, c-format
@@ -2114,7 +1860,7 @@
 #: ppcboot.c:427
 #, c-format
 msgid "Partition name      = \"%s\"\n"
-msgstr "Nom de partition    = \"%s\"\n"
+msgstr "Nom de partition    = « %s »\n"
 
 #: ppcboot.c:446
 #, c-format
@@ -2147,9 +1893,9 @@
 #: srec.c:301
 #, c-format
 msgid "%s:%d: Unexpected character `%s' in S-record file\n"
-msgstr "%s:%d: caractère inattendue `%s' dans le fichier S-record\n"
+msgstr "%s:%d: caractère inattendue « %s » dans le fichier S-record\n"
 
-#: syms.c:998
+#: syms.c:996
 msgid "Unsupported .stab relocation"
 msgstr "Relocalisation du .stab non supporté"
 
@@ -2204,115 +1950,193 @@
 msgid "failed to enter %s"
 msgstr "échec d'insertion de %s"
 
-#: vms-tir.c:81
+#: vms-tir.c:78
 msgid "No Mem !"
 msgstr "Mémoire épuisée!"
 
-#: vms-tir.c:362
-#, fuzzy, c-format
-msgid "bad section index in %s"
+#: vms-tir.c:313
+msgid "Bad section index in ETIR_S_C_STA_PQ"
 msgstr "Index de section erronée dans ETIR_S_C_STA_PQ"
 
-#: vms-tir.c:375
-#, fuzzy, c-format
-msgid "unsupported STA cmd %s"
+#: vms-tir.c:328
+#, c-format
+msgid "Unsupported STA cmd %d"
 msgstr "Commande STA non supportée %d"
 
-#: vms-tir.c:380 vms-tir.c:1240
-#, fuzzy, c-format
-msgid "reserved STA cmd %d"
+#: vms-tir.c:333 vms-tir.c:1301
+#, c-format
+msgid "Reserved STA cmd %d"
 msgstr "Commande STA réservée %d"
 
-#: vms-tir.c:491 vms-tir.c:514
-#, fuzzy, c-format
-msgid "%s: no symbol \"%s\""
-msgstr "%s: pas de tel symbole"
+#: vms-tir.c:443
+#, c-format
+msgid "ETIR_S_C_STO_GBL: no symbol \"%s\""
+msgstr "ETIR_S_C_STO_GBL: pas de symbole « %s »"
 
-#. unsigned shift
-#. rotate
-#. Redefine symbol to current location.
-#. Define a literal.
-#: vms-tir.c:581 vms-tir.c:693 vms-tir.c:803 vms-tir.c:821 vms-tir.c:829
-#: vms-tir.c:838 vms-tir.c:1563
-#, fuzzy, c-format
-msgid "%s: not supported"
-msgstr "n'est pas supportée"
+#: vms-tir.c:465
+#, c-format
+msgid "ETIR_S_C_STO_CA: no symbol \"%s\""
+msgstr "ETIR_S_C_STO_CA: pas de symbole « %s »"
 
-#: vms-tir.c:586 vms-tir.c:1418
-#, fuzzy, c-format
-msgid "%s: not implemented"
-msgstr "%s: non implanté %s\n"
+#: vms-tir.c:478
+msgid "ETIR_S_C_STO_RB/AB: Not supported"
+msgstr "ETIR_S_C_STO_RB/AB: non supporté"
 
-#: vms-tir.c:590 vms-tir.c:1422
-#, fuzzy, c-format
-msgid "reserved STO cmd %d"
+#: vms-tir.c:538
+msgid "ETIR_S_C_STO_LP_PSB: Not supported"
+msgstr "ETIR_S_C_STO_LP_PSB: non supporté"
+
+#: vms-tir.c:544
+msgid "ETIR_S_C_STO_HINT_GBL: not implemented"
+msgstr "ETIR_S_C_STO_HINT_GBL: pas implanté"
+
+#: vms-tir.c:550
+msgid "ETIR_S_C_STO_HINT_PS: not implemented"
+msgstr "ETIR_S_C_STO_HINT_PS: pas implanté"
+
+#: vms-tir.c:554 vms-tir.c:1473
+#, c-format
+msgid "Reserved STO cmd %d"
 msgstr "Commande STO réservée %d"
 
-#: vms-tir.c:708 vms-tir.c:1568
-#, fuzzy, c-format
-msgid "reserved OPR cmd %d"
+#: vms-tir.c:667
+msgid "ETIR_S_C_OPR_INSV: Not supported"
+msgstr "ETIR_S_C_OPR_INSV: non supporté"
+
+#: vms-tir.c:685
+msgid "ETIR_S_C_OPR_USH: Not supported"
+msgstr "ETIR_S_C_OPR_USH: non supporté"
+
+#: vms-tir.c:691
+msgid "ETIR_S_C_OPR_ROT: Not supported"
+msgstr "ETIR_S_C_OPR_ROT: non supporté"
+
+#: vms-tir.c:710
+msgid "ETIR_S_C_OPR_REDEF: Not supported"
+msgstr "ETIR_S_C_OPR_REDEF: non supporté"
+
+#: vms-tir.c:716
+msgid "ETIR_S_C_OPR_DFLIT: Not supported"
+msgstr "ETIR_S_C_OPR_DFLIT: non supporté"
+
+#: vms-tir.c:720 vms-tir.c:1668
+#, c-format
+msgid "Reserved OPR cmd %d"
 msgstr "Commande OPR réservée %d"
 
-#: vms-tir.c:776 vms-tir.c:1632
-#, fuzzy, c-format
-msgid "reserved CTL cmd %d"
+#: vms-tir.c:788 vms-tir.c:1737
+#, c-format
+msgid "Reserved CTL cmd %d"
 msgstr "Commande CTL réservée %d"
 
-#. stack byte from image
-#. arg: none.
-#: vms-tir.c:1148
-#, fuzzy
-msgid "stack-from-image not implemented"
+#: vms-tir.c:816
+msgid "ETIR_S_C_STC_LP: not supported"
+msgstr "ETIR_S_C_STC_LP: non supporté"
+
+#: vms-tir.c:834
+msgid "ETIR_S_C_STC_GBL: not supported"
+msgstr "ETIR_S_C_STC_GBL: non supporté"
+
+#: vms-tir.c:842
+msgid "ETIR_S_C_STC_GCA: not supported"
+msgstr "ETIR_S_C_STC_GCA: non supporté"
+
+#: vms-tir.c:851
+msgid "ETIR_S_C_STC_PS: not supported"
+msgstr "ETIR_S_C_STC_PS: non supporté"
+
+#.
+#. * stack byte from image
+#. * arg: -
+#. *
+#.
+#: vms-tir.c:1199
+msgid "Stack-from-image not implemented"
 msgstr "Stack-from-image non implanté"
 
-#: vms-tir.c:1166
-#, fuzzy
-msgid "stack-entry-mask not fully implemented"
+#: vms-tir.c:1219
+msgid "Stack-entry-mask not fully implemented"
 msgstr "Stack-entry-mask pas complètement implanté"
 
-#. compare procedure argument
-#. arg: cs	symbol name
-#. by	argument index
-#. da	argument descriptor
 #.
-#. compare argument descriptor with symbol argument (ARG$V_PASSMECH)
-#. and stack TRUE (args match) or FALSE (args dont match) value.
-#: vms-tir.c:1180
+#. * compare procedure argument
+#. * arg: cs	symbol name
+#. *	by	argument index
+#. *	da	argument descriptor
+#. *
+#. * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
+#. * and stack TRUE (args match) or FALSE (args dont match) value
+#.
+#: vms-tir.c:1235
 msgid "PASSMECH not fully implemented"
 msgstr "PASSMECH pas complètement implanté"
 
-#: vms-tir.c:1199
-#, fuzzy
-msgid "stack-local-symbol not fully implemented"
+#: vms-tir.c:1256
+msgid "Stack-local-symbol not fully implemented"
 msgstr "Stack-local-symbol pas complètement implanté"
 
-#: vms-tir.c:1212
-#, fuzzy
-msgid "stack-literal not fully implemented"
+#: vms-tir.c:1271
+msgid "Stack-literal not fully implemented"
 msgstr "Stack-literal pas complètement implanté"
 
-#: vms-tir.c:1233
-#, fuzzy
-msgid "stack-local-symbol-entry-point-mask not fully implemented"
+#: vms-tir.c:1294
+msgid "Stack-local-symbol-entry-point-mask not fully implemented"
 msgstr "Stack-local-symbol-entry-point-mask pas complètement implanté"
 
-#: vms-tir.c:1510 vms-tir.c:1522 vms-tir.c:1534 vms-tir.c:1546 vms-tir.c:1611
-#: vms-tir.c:1619 vms-tir.c:1627
-#, fuzzy, c-format
-msgid "%s: not fully implemented"
-msgstr "PASSMECH pas complètement implanté"
+#: vms-tir.c:1469
+#, c-format
+msgid "Unimplemented STO cmd %d"
+msgstr "Commande STO non implantée %d"
 
-#: vms-tir.c:1684
-#, fuzzy, c-format
-msgid "obj code %d not found"
+#: vms-tir.c:1608
+msgid "TIR_S_C_OPR_ASH incomplete"
+msgstr "TIR_S_C_OPR_ASH incomplète"
+
+#: vms-tir.c:1622
+msgid "TIR_S_C_OPR_USH incomplete"
+msgstr "TIR_S_C_OPR_USH incomplète"
+
+#: vms-tir.c:1636
+msgid "TIR_S_C_OPR_ROT incomplete"
+msgstr "TIR_S_C_OPR_ROT incomplète"
+
+#.
+#. * redefine symbol to current location
+#.
+#: vms-tir.c:1657
+msgid "TIR_S_C_OPR_REDEF not supported"
+msgstr "TIR_S_C_OPR_REDEF non supporté"
+
+#.
+#. * define a literal
+#.
+#: vms-tir.c:1664
+msgid "TIR_S_C_OPR_DFLIT not supported"
+msgstr "TIR_S_C_OPR_DFLIT non supporté"
+
+#: vms-tir.c:1718
+msgid "TIR_S_C_CTL_DFLOC not fully implemented"
+msgstr "TIR_S_C_CTL_DFLOC pas complètement implanté"
+
+#: vms-tir.c:1726
+msgid "TIR_S_C_CTL_STLOC not fully implemented"
+msgstr "TIR_S_C_CTL_STLOC pas complètement implanté"
+
+#: vms-tir.c:1734
+msgid "TIR_S_C_CTL_STKDL not fully implemented"
+msgstr "TIR_S_C_CTL_STKDL n'est pas complètement implanté"
+
+#: vms-tir.c:1791
+#, c-format
+msgid "Obj code %d not found"
 msgstr "Code objet %d non repéré"
 
-#: vms-tir.c:2019
+#: vms-tir.c:2137
 #, c-format
 msgid "SEC_RELOC with no relocs in section %s"
 msgstr "SEC_RELOC sans relocalisation dans la section %s"
 
-#: vms-tir.c:2307
+#: vms-tir.c:2424
 #, c-format
 msgid "Unhandled relocation %s"
 msgstr "Relocalisation non traitée: %s"
@@ -2320,37 +2144,37 @@
 #: xcofflink.c:1241
 #, c-format
 msgid "%s: `%s' has line numbers but no enclosing section"
-msgstr "%s: `%s' contient des numéros de lignes mais de section de fermeture"
+msgstr "%s: « %s » contient des numéros de lignes mais de section de fermeture"
 
 #: xcofflink.c:1294
 #, c-format
 msgid "%s: class %d symbol `%s' has no aux entries"
-msgstr "%s: classe %d symbole `%s' n'a pas d'entrée auxiliaire"
+msgstr "%s: classe %d symbole « %s » n'a pas d'entrée auxiliaire"
 
 #: xcofflink.c:1317
 #, c-format
 msgid "%s: symbol `%s' has unrecognized csect type %d"
-msgstr "%s: symbole `%s' a un type csect non reconnu %d"
+msgstr "%s: symbole « %s » a un type csect non reconnu %d"
 
 #: xcofflink.c:1329
 #, c-format
 msgid "%s: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"
-msgstr "%s: symbole XTY_ER erroné `%s': classe %d scnum %d scnlen %d"
+msgstr "%s: symbole XTY_ER erroné « %s »: classe %d scnum %d scnlen %d"
 
 #: xcofflink.c:1365
 #, c-format
 msgid "%s: XMC_TC0 symbol `%s' is class %d scnlen %d"
-msgstr "%s: XMC_TC0 symbol `%s' est la classe %d scnlen %d"
+msgstr "%s: XMC_TC0 symbol « %s » est la classe %d scnlen %d"
 
 #: xcofflink.c:1517
 #, c-format
 msgid "%s: csect `%s' not in enclosing section"
-msgstr "%s: csect `%s' n'est pas dans un section fermée"
+msgstr "%s: csect « %s » n'est pas dans un section fermée"
 
 #: xcofflink.c:1624
 #, c-format
 msgid "%s: misplaced XTY_LD `%s'"
-msgstr "%s: XTY_LD mal placé `%s'"
+msgstr "%s: XTY_LD mal placé « %s »"
 
 #: xcofflink.c:1948
 #, c-format
@@ -2379,181 +2203,176 @@
 #: xcofflink.c:3458
 #, c-format
 msgid "warning: attempt to export undefined symbol `%s'"
-msgstr "AVERTISSEMENT: tentative d'exportation d'un symbole indéfini `%s'"
+msgstr "AVERTISSEMENT: tentative d'exportation d'un symbole indéfini « %s »"
 
 #: xcofflink.c:4452
 #, c-format
 msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling"
-msgstr ""
-"Débordement de la table des entrées: 0x%lx > 0x10000; essayer l'option -"
-"mminimal-toc"
+msgstr "Débordement de la table des entrées: 0x%lx > 0x10000; essayer l'option -mminimal-toc"
 
 #: xcofflink.c:5292 xcofflink.c:5754 xcofflink.c:5816 xcofflink.c:6117
 #, c-format
 msgid "%s: loader reloc in unrecognized section `%s'"
-msgstr "%s: chargeur de relocalisation dans une section non reconnnue `%s'"
+msgstr "%s: chargeur de relocalisation dans une section non reconnnue « %s »"
 
 #: xcofflink.c:5314 xcofflink.c:6128
 #, c-format
 msgid "%s: `%s' in loader reloc but not loader sym"
-msgstr ""
-"%s: `%s' est dans le chargeur de relocalisation mais pas dans celui des "
-"symboles"
+msgstr "%s: « %s » est dans le chargeur de relocalisation mais pas dans celui des symboles"
 
 #: xcofflink.c:5329
 #, c-format
 msgid "%s: loader reloc in read-only section %s"
 msgstr "%s: chargeur de relocalisation dans un section en lecture seulement %s"
 
-#: elf32-ia64.c:2189 elf64-ia64.c:2189
+#: elf32-ia64.c:2190 elf64-ia64.c:2190
 msgid "@pltoff reloc against local symbol"
 msgstr "relocalisation @pltoff vers un symbole local"
 
-#: elf32-ia64.c:3413 elf64-ia64.c:3413
+#: elf32-ia64.c:2248 elf64-ia64.c:2248
+msgid "non-zero addend in @fptr reloc"
+msgstr "ajout non null dans la relocalisation @fptr"
+
+#: elf32-ia64.c:3414 elf64-ia64.c:3414
 #, c-format
 msgid "%s: short data segment overflowed (0x%lx >= 0x400000)"
 msgstr "%s: débordement du segment de données court (0x%lx >= 0x400000)"
 
-#: elf32-ia64.c:3424 elf64-ia64.c:3424
+#: elf32-ia64.c:3425 elf64-ia64.c:3425
 #, c-format
 msgid "%s: __gp does not cover short data segment"
 msgstr "%s: __gp ne couvre pas ce segment de données court"
 
-#: elf32-ia64.c:3728 elf64-ia64.c:3728
+#: elf32-ia64.c:3729 elf64-ia64.c:3729
 #, c-format
 msgid "%s: linking non-pic code in a shared library"
 msgstr "%s: liaison de code non-pic dans une librairie partagée"
 
-#: elf32-ia64.c:3761 elf64-ia64.c:3761
+#: elf32-ia64.c:3762 elf64-ia64.c:3762
 #, c-format
 msgid "%s: @gprel relocation against dynamic symbol %s"
 msgstr "%s: relocalisation @gprel vers le symbole dynamique %s"
 
-#: elf32-ia64.c:3900 elf64-ia64.c:3900
+#: elf32-ia64.c:3901 elf64-ia64.c:3901
 #, c-format
 msgid "%s: dynamic relocation against speculation fixup"
 msgstr "%s: relocalisation dynamique vers un correctif spéculé"
 
-#: elf32-ia64.c:3908 elf64-ia64.c:3908
+#: elf32-ia64.c:3909 elf64-ia64.c:3909
 #, c-format
 msgid "%s: speculation fixup against undefined weak symbol"
 msgstr "%s: correctif spéculé vers un symbole faible indéfini"
 
-#: elf32-ia64.c:4092 elf64-ia64.c:4092
+#: elf32-ia64.c:4093 elf64-ia64.c:4093
 msgid "unsupported reloc"
 msgstr "relocalisation non supporté"
 
-#: elf32-ia64.c:4372 elf64-ia64.c:4372
+#: elf32-ia64.c:4373 elf64-ia64.c:4373
 #, c-format
 msgid "%s: linking trap-on-NULL-dereference with non-trapping files"
-msgstr ""
-"%s: édition de liens trap-on-NULL-dereference avec des fichiers non-trapping"
+msgstr "%s: édition de liens trap-on-NULL-dereference avec des fichiers non-trapping"
 
-#: elf32-ia64.c:4381 elf64-ia64.c:4381
+#: elf32-ia64.c:4382 elf64-ia64.c:4382
 #, c-format
 msgid "%s: linking big-endian files with little-endian files"
 msgstr ""
 "%s: édition de liens pour des fichiers en système à octets de poids fort\n"
 "avec des fichiers pour des systèmes à octets de poids faible"
 
-#: elf32-ia64.c:4390 elf64-ia64.c:4390
+#: elf32-ia64.c:4391 elf64-ia64.c:4391
 #, c-format
 msgid "%s: linking 64-bit files with 32-bit files"
-msgstr ""
-"%s: édition de liens de fichiers de 64 bits avec des fichiers de 32 bits"
+msgstr "%s: édition de liens de fichiers de 64 bits avec des fichiers de 32 bits"
 
-#: elf32-ia64.c:4399 elf64-ia64.c:4399
+#: elf32-ia64.c:4400 elf64-ia64.c:4400
 #, c-format
 msgid "%s: linking constant-gp files with non-constant-gp files"
-msgstr ""
-"%s: édition de liens de fichiers constant-gp avec des fichier non-constant-gp"
+msgstr "%s: édition de liens de fichiers constant-gp avec des fichier non-constant-gp"
 
-#: elf32-ia64.c:4409 elf64-ia64.c:4409
+#: elf32-ia64.c:4410 elf64-ia64.c:4410
 #, c-format
 msgid "%s: linking auto-pic files with non-auto-pic files"
-msgstr ""
-"%s: édition de liens de fichiers auto-pic avec des fichiers non-auto-pic"
+msgstr "%s: édition de liens de fichiers auto-pic avec des fichiers non-auto-pic"
 
-#: peigen.c:962 pepigen.c:962
+#: peigen.c:964 pepigen.c:964
 #, c-format
 msgid "%s: line number overflow: 0x%lx > 0xffff"
 msgstr "%s: débordement du nombre de lignes: 0x%lx > 0xffff"
 
-#: peigen.c:979 pepigen.c:979
+#: peigen.c:981 pepigen.c:981
 #, c-format
 msgid "%s: reloc overflow 1: 0x%lx > 0xffff"
 msgstr "%s: débordement de la relocalisation 1: 0x%lx > 0xffff"
 
-#: peigen.c:993 pepigen.c:993
+#: peigen.c:995 pepigen.c:995
 msgid "Export Directory [.edata (or where ever we found it)]"
 msgstr "Répertoire d'exportation [.edata (ou là où il a été repéré)]"
 
-#: peigen.c:994 pepigen.c:994
+#: peigen.c:996 pepigen.c:996
 msgid "Import Directory [parts of .idata]"
 msgstr "Répertoire d'importation [faisant partie de .idata]"
 
-#: peigen.c:995 pepigen.c:995
+#: peigen.c:997 pepigen.c:997
 msgid "Resource Directory [.rsrc]"
 msgstr "Répertoire des resources [.rsrc]"
 
-#: peigen.c:996 pepigen.c:996
+#: peigen.c:998 pepigen.c:998
 msgid "Exception Directory [.pdata]"
 msgstr "Répertoire des exceptions [.pdata]"
 
-#: peigen.c:997 pepigen.c:997
+#: peigen.c:999 pepigen.c:999
 msgid "Security Directory"
 msgstr "Répertoire de la sécurité"
 
-#: peigen.c:998 pepigen.c:998
+#: peigen.c:1000 pepigen.c:1000
 msgid "Base Relocation Directory [.reloc]"
 msgstr "Répertoire de base de relocalisation [.reloc]"
 
-#: peigen.c:999 pepigen.c:999
+#: peigen.c:1001 pepigen.c:1001
 msgid "Debug Directory"
 msgstr "Répertoire de débug"
 
-#: peigen.c:1000 pepigen.c:1000
+#: peigen.c:1002 pepigen.c:1002
 msgid "Description Directory"
 msgstr "Répertoire de description"
 
-#: peigen.c:1001 pepigen.c:1001
+#: peigen.c:1003 pepigen.c:1003
 msgid "Special Directory"
 msgstr "Répertoire spécial"
 
-#: peigen.c:1002 pepigen.c:1002
+#: peigen.c:1004 pepigen.c:1004
 msgid "Thread Storage Directory [.tls]"
 msgstr "Répertoire des files de stockage [.tls]"
 
-#: peigen.c:1003 pepigen.c:1003
+#: peigen.c:1005 pepigen.c:1005
 msgid "Load Configuration Directory"
 msgstr "Répertoire de chargement de configuration"
 
-#: peigen.c:1004 pepigen.c:1004
+#: peigen.c:1006 pepigen.c:1006
 msgid "Bound Import Directory"
 msgstr "Répertoire des importations limitées"
 
-#: peigen.c:1005 pepigen.c:1005
+#: peigen.c:1007 pepigen.c:1007
 msgid "Import Address Table Directory"
 msgstr "Répertoire de la table d'adresse d'importation"
 
-#: peigen.c:1006 pepigen.c:1006
+#: peigen.c:1008 pepigen.c:1008
 msgid "Delay Import Directory"
 msgstr "Répertoire des délais d'importation"
 
-#: peigen.c:1007 peigen.c:1008 pepigen.c:1007 pepigen.c:1008
+#: peigen.c:1009 peigen.c:1010 pepigen.c:1009 pepigen.c:1010
 msgid "Reserved"
 msgstr "Réservé"
 
-#: peigen.c:1071 pepigen.c:1071
+#: peigen.c:1073 pepigen.c:1073
 msgid ""
 "\n"
 "There is an import table, but the section containing it could not be found\n"
 msgstr ""
 "\n"
-"Il y a une table d'importation, mais la section la contenant ne peut être "
-"repérée\n"
+"Il y a une table d'importation, mais la section la contenant ne peut être repérée\n"
 
-#: peigen.c:1076 pepigen.c:1076
+#: peigen.c:1078 pepigen.c:1078
 #, c-format
 msgid ""
 "\n"
@@ -2562,7 +2381,7 @@
 "\n"
 "Il y a une table d'importation dans %s à 0x%lx\n"
 
-#: peigen.c:1113 pepigen.c:1113
+#: peigen.c:1115 pepigen.c:1115
 #, c-format
 msgid ""
 "\n"
@@ -2571,12 +2390,12 @@
 "\n"
 "Descripteur de fonction localisé à l'adresse de départ: %04lx\n"
 
-#: peigen.c:1116 pepigen.c:1116
+#: peigen.c:1118 pepigen.c:1118
 #, c-format
 msgid "\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"
 msgstr "\tcode-base %08lx tab. des entrées (chargeable/actuel) %08lx/%08lx\n"
 
-#: peigen.c:1122 pepigen.c:1122
+#: peigen.c:1124 pepigen.c:1124
 msgid ""
 "\n"
 "No reldata section! Function descriptor not decoded.\n"
@@ -2584,7 +2403,7 @@
 "\n"
 "Pas de section reldata! Descripteur de fonction n'a pas été décodé.\n"
 
-#: peigen.c:1127 pepigen.c:1127
+#: peigen.c:1129 pepigen.c:1129
 #, c-format
 msgid ""
 "\n"
@@ -2593,14 +2412,15 @@
 "\n"
 "Les tables d'importation (contenus interprétés de la section %s)\n"
 
-#: peigen.c:1130 pepigen.c:1130
-#, fuzzy
-msgid ""
-" vma:            Hint    Time      Forward  DLL       First\n"
-"                 Table   Stamp     Chain    Name      Thunk\n"
+#: peigen.c:1132 pepigen.c:1132
+msgid " vma:            Hint    Time      Forward  DLL       First\n"
+msgstr " vma:            Hint    Heure     Forward  DLL       Premier\n"
+
+#: peigen.c:1134 pepigen.c:1134
+msgid "                 Table   Stamp     Chain    Name      Thunk\n"
 msgstr "                 Table   Tampon    Chaîne   Nom       Thunk\n"
 
-#: peigen.c:1180 pepigen.c:1180
+#: peigen.c:1182 pepigen.c:1182
 #, c-format
 msgid ""
 "\n"
@@ -2609,32 +2429,31 @@
 "\n"
 "\tNom DLL: %s\n"
 
-#: peigen.c:1184 peigen.c:1247 pepigen.c:1184 pepigen.c:1247
+#: peigen.c:1186 peigen.c:1249 pepigen.c:1186 pepigen.c:1249
 msgid "\tvma:  Hint/Ord Member-Name\n"
 msgstr "\tvma:  Hint/Nom-de-membre nombre ordinal\n"
 
-#: peigen.c:1246 pepigen.c:1246
+#: peigen.c:1248 pepigen.c:1248
 msgid "\tThe Import Address Table (difference found)\n"
 msgstr "\tL'adresse de la table d'importation (différence détectée)\n"
 
-#: peigen.c:1253 pepigen.c:1253
+#: peigen.c:1255 pepigen.c:1255
 msgid "\t>>> Ran out of IAT members!\n"
 msgstr "\t>>> membres IAT tous utilisés!\n"
 
-#: peigen.c:1271 pepigen.c:1271
+#: peigen.c:1273 pepigen.c:1273
 msgid "\tThe Import Address Table is identical\n"
 msgstr "\tL'adresse de la table d'importation est identique\n"
 
-#: peigen.c:1343 pepigen.c:1343
+#: peigen.c:1345 pepigen.c:1345
 msgid ""
 "\n"
 "There is an export table, but the section containing it could not be found\n"
 msgstr ""
 "\n"
-"Il y a une table d'exportation, mais la section la contenant n'a pu être "
-"repérée\n"
+"Il y a une table d'exportation, mais la section la contenant n'a pu être repérée\n"
 
-#: peigen.c:1348 pepigen.c:1348
+#: peigen.c:1350 pepigen.c:1350
 #, c-format
 msgid ""
 "\n"
@@ -2643,7 +2462,7 @@
 "\n"
 "Il y a une table d'exportation dans %s à 0x%lx\n"
 
-#: peigen.c:1379 pepigen.c:1379
+#: peigen.c:1381 pepigen.c:1381
 #, c-format
 msgid ""
 "\n"
@@ -2654,61 +2473,61 @@
 "Les tables d'exportation (contenus interprétés de la section %s)\n"
 "\n"
 
-#: peigen.c:1383 pepigen.c:1383
+#: peigen.c:1385 pepigen.c:1385
 #, c-format
 msgid "Export Flags \t\t\t%lx\n"
 msgstr "Fanion d'exportation \t\t\t%lx\n"
 
-#: peigen.c:1386 pepigen.c:1386
+#: peigen.c:1388 pepigen.c:1388
 #, c-format
 msgid "Time/Date stamp \t\t%lx\n"
 msgstr "Tampon Heure/Date \t\t%lx\n"
 
-#: peigen.c:1389 pepigen.c:1389
+#: peigen.c:1391 pepigen.c:1391
 #, c-format
 msgid "Major/Minor \t\t\t%d/%d\n"
 msgstr "Majeur/Mineur \t\t\t%d/%d\n"
 
-#: peigen.c:1392 pepigen.c:1392
+#: peigen.c:1394 pepigen.c:1394
 msgid "Name \t\t\t\t"
 msgstr "Nom \t\t\t\t"
 
-#: peigen.c:1398 pepigen.c:1398
+#: peigen.c:1400 pepigen.c:1400
 #, c-format
 msgid "Ordinal Base \t\t\t%ld\n"
 msgstr "base de nombre ordinal \t\t\t%ld\n"
 
-#: peigen.c:1401 pepigen.c:1401
+#: peigen.c:1403 pepigen.c:1403
 msgid "Number in:\n"
 msgstr "Numéro dans:\n"
 
-#: peigen.c:1404 pepigen.c:1404
+#: peigen.c:1406 pepigen.c:1406
 #, c-format
 msgid "\tExport Address Table \t\t%08lx\n"
 msgstr "\tTable d'adresses d'exportation \t\t%08lx\n"
 
-#: peigen.c:1408 pepigen.c:1408
+#: peigen.c:1410 pepigen.c:1410
 #, c-format
 msgid "\t[Name Pointer/Ordinal] Table\t%08lx\n"
 msgstr "\tTable de noms [Pointeur/Nombre ordinal]\t%08lx\n"
 
-#: peigen.c:1411 pepigen.c:1411
+#: peigen.c:1413 pepigen.c:1413
 msgid "Table Addresses\n"
 msgstr "Table d'adresses\n"
 
-#: peigen.c:1414 pepigen.c:1414
+#: peigen.c:1416 pepigen.c:1416
 msgid "\tExport Address Table \t\t"
 msgstr "\tTable d'adresse d'exportation \t\t"
 
-#: peigen.c:1419 pepigen.c:1419
+#: peigen.c:1421 pepigen.c:1421
 msgid "\tName Pointer Table \t\t"
 msgstr "\tTable des noms de pointeurs \t\t"
 
-#: peigen.c:1424 pepigen.c:1424
+#: peigen.c:1426 pepigen.c:1426
 msgid "\tOrdinal Table \t\t\t"
 msgstr "\tTable des ordinals \t\t\t"
 
-#: peigen.c:1439 pepigen.c:1439
+#: peigen.c:1441 pepigen.c:1441
 #, c-format
 msgid ""
 "\n"
@@ -2717,15 +2536,15 @@
 "\n"
 "Table d'adresses d'exportation -- base de nombre ordinal %ld\n"
 
-#: peigen.c:1458 pepigen.c:1458
+#: peigen.c:1460 pepigen.c:1460
 msgid "Forwarder RVA"
 msgstr "Adresseur RVA"
 
-#: peigen.c:1469 pepigen.c:1469
+#: peigen.c:1471 pepigen.c:1471
 msgid "Export RVA"
 msgstr "Exportation RVA"
 
-#: peigen.c:1476 pepigen.c:1476
+#: peigen.c:1478 pepigen.c:1478
 msgid ""
 "\n"
 "[Ordinal/Name Pointer] Table\n"
@@ -2733,14 +2552,12 @@
 "\n"
 "Table [Ordinal/Nom de pointeurs]\n"
 
-#: peigen.c:1531 pepigen.c:1531
+#: peigen.c:1533 pepigen.c:1533
 #, c-format
 msgid "Warning, .pdata section size (%ld) is not a multiple of %d\n"
-msgstr ""
-"AVERTISSEMENT, taille de la section .pdata (%ld) n'est pas un multiple de %"
-"d\n"
+msgstr "AVERTISSEMENT, taille de la section .pdata (%ld) n'est pas un multiple de %d\n"
 
-#: peigen.c:1535 pepigen.c:1535
+#: peigen.c:1537 pepigen.c:1537
 msgid ""
 "\n"
 "The Function Table (interpreted .pdata section contents)\n"
@@ -2748,30 +2565,31 @@
 "\n"
 "La table de fonctions (interprétation du contenu de la section .pdata)\n"
 
-#: peigen.c:1538 pepigen.c:1538
+#: peigen.c:1540 pepigen.c:1540
 msgid " vma:\t\t\tBegin Address    End Address      Unwind Info\n"
 msgstr " vma:\t\t\tDébut Adresse    Fin Adresse      Unwind Info\n"
 
-#: peigen.c:1540 pepigen.c:1540
-#, fuzzy
-msgid ""
-" vma:\t\tBegin    End      EH       EH       PrologEnd  Exception\n"
-"     \t\tAddress  Address  Handler  Data     Address    Mask\n"
+#: peigen.c:1543 pepigen.c:1543
+msgid " vma:\t\tBegin    End      EH       EH       PrologEnd  Exception\n"
 msgstr " vma:\t\tDébut    Fin      EH       EH       FinProlog  Exception\n"
 
-#: peigen.c:1610 pepigen.c:1610
+#: peigen.c:1545 pepigen.c:1545
+msgid "     \t\tAddress  Address  Handler  Data     Address    Mask\n"
+msgstr "     \t\tAdresse  Adresse  Routine  Données  Adresse    Masque\n"
+
+#: peigen.c:1613 pepigen.c:1613
 msgid " Register save millicode"
 msgstr " Registre a préservé le millicode"
 
-#: peigen.c:1613 pepigen.c:1613
+#: peigen.c:1616 pepigen.c:1616
 msgid " Register restore millicode"
 msgstr " Registre a restauré le millicode"
 
-#: peigen.c:1616 pepigen.c:1616
+#: peigen.c:1619 pepigen.c:1619
 msgid " Glue code sequence"
 msgstr " Séquence du code de liants"
 
-#: peigen.c:1668 pepigen.c:1668
+#: peigen.c:1671 pepigen.c:1671
 msgid ""
 "\n"
 "\n"
@@ -2779,20 +2597,18 @@
 msgstr ""
 "\n"
 "\n"
-"Fichier de base des relocalisation PE (contenus interprétés de la section ."
-"reloc)\n"
+"Fichier de base des relocalisation PE (contenus interprétés de la section .reloc)\n"
 
-#: peigen.c:1698 pepigen.c:1698
+#: peigen.c:1701 pepigen.c:1701
 #, c-format
 msgid ""
 "\n"
 "Virtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"
 msgstr ""
 "\n"
-"Adresse virtuelle: %08lx taille des morceaux %ld (0x%lx) nombre de "
-"correctifs %ld\n"
+"Adresse virtuelle: %08lx taille des morceaux %ld (0x%lx) nombre de correctifs %ld\n"
 
-#: peigen.c:1711 pepigen.c:1711
+#: peigen.c:1714 pepigen.c:1714
 #, c-format
 msgid "\treloc %4d offset %4x [%4lx] %s"
 msgstr "\trelocalisation %4d décalage %4x [%4lx] %s"
@@ -2800,7 +2616,7 @@
 #. The MS dumpbin program reportedly ands with 0xff0f before
 #. printing the characteristics field.  Not sure why.  No reason to
 #. emulate it here.
-#: peigen.c:1751 pepigen.c:1751
+#: peigen.c:1754 pepigen.c:1754
 #, c-format
 msgid ""
 "\n"
@@ -2809,129 +2625,6 @@
 "\n"
 "Caractéristiques 0x%x\n"
 
-#~ msgid "GP relative relocation when GP not defined"
-#~ msgstr "GP relocalisation relative alors que GP n'est pas défini"
-
-#~ msgid "Warning: input file %s supports interworking, whereas %s does not."
-#~ msgstr ""
-#~ "AVERTISSEMENT: file d'entrée %s supporte l'inter-réseautage, "
-#~ "contrairement à %s."
-
-#~ msgid ""
-#~ "Warning: input file %s does not support interworking, whereas %s does."
-#~ msgstr ""
-#~ "AVERTISSEMENT: fichier d'entrée %s ne supporte pas l'inter-réseautage, "
-#~ "contrairement à %s."
-
-#~ msgid "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"
-#~ msgstr "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld prochain %ld"
-
-#~ msgid ""
-#~ "elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x"
-#~ "%.8lx%s\n"
-#~ msgstr ""
-#~ "elf_symbol_from_bfd_symbol 0x%.8lx, nom = %s, no. de symbole = %d, "
-#~ "fanions = 0x%.8lx%s\n"
-
-#~ msgid ""
-#~ "Warning: Not setting interwork flag of %s since it has already been "
-#~ "specified as non-interworking"
-#~ msgstr ""
-#~ "AVERTISSEMENT: pas d'initialisation du fanion d'inter-réseautage %s alors "
-#~ "qu'il a déjè été spécifié sans inter-réseautage"
-
-#~ msgid "Warning: Clearing the interwork flag of %s due to outside request"
-#~ msgstr ""
-#~ "AVERTISSEMENT: mise à zéro du fanion d'inter-réseautage %s en raison "
-#~ "d'une requête externe"
-
-#~ msgid "(unknown)"
-#~ msgstr "(inconnu)"
-
-#~ msgid "  previously %s in %s"
-#~ msgstr " précédemment %s dans %s"
-
-#~ msgid "Symbol `%s' has differing types: %s in %s"
-#~ msgstr "Symbole `%s' a des types qui diffèrent: %s dans %s"
-
-#~ msgid "ETIR_S_C_STO_GBL: no symbol \"%s\""
-#~ msgstr "ETIR_S_C_STO_GBL: pas de symbole \"%s\""
-
-#~ msgid "ETIR_S_C_STO_CA: no symbol \"%s\""
-#~ msgstr "ETIR_S_C_STO_CA: pas de symbole \"%s\""
-
-#~ msgid "ETIR_S_C_STO_RB/AB: Not supported"
-#~ msgstr "ETIR_S_C_STO_RB/AB: non supporté"
-
-#~ msgid "ETIR_S_C_STO_LP_PSB: Not supported"
-#~ msgstr "ETIR_S_C_STO_LP_PSB: non supporté"
-
-#~ msgid "ETIR_S_C_STO_HINT_GBL: not implemented"
-#~ msgstr "ETIR_S_C_STO_HINT_GBL: pas implanté"
-
-#~ msgid "ETIR_S_C_STO_HINT_PS: not implemented"
-#~ msgstr "ETIR_S_C_STO_HINT_PS: pas implanté"
-
-#~ msgid "ETIR_S_C_OPR_INSV: Not supported"
-#~ msgstr "ETIR_S_C_OPR_INSV: non supporté"
-
-#~ msgid "ETIR_S_C_OPR_USH: Not supported"
-#~ msgstr "ETIR_S_C_OPR_USH: non supporté"
-
-#~ msgid "ETIR_S_C_OPR_ROT: Not supported"
-#~ msgstr "ETIR_S_C_OPR_ROT: non supporté"
-
-#~ msgid "ETIR_S_C_OPR_REDEF: Not supported"
-#~ msgstr "ETIR_S_C_OPR_REDEF: non supporté"
-
-#~ msgid "ETIR_S_C_OPR_DFLIT: Not supported"
-#~ msgstr "ETIR_S_C_OPR_DFLIT: non supporté"
-
-#~ msgid "ETIR_S_C_STC_LP: not supported"
-#~ msgstr "ETIR_S_C_STC_LP: non supporté"
-
-#~ msgid "ETIR_S_C_STC_GBL: not supported"
-#~ msgstr "ETIR_S_C_STC_GBL: non supporté"
-
-#~ msgid "ETIR_S_C_STC_GCA: not supported"
-#~ msgstr "ETIR_S_C_STC_GCA: non supporté"
-
-#~ msgid "ETIR_S_C_STC_PS: not supported"
-#~ msgstr "ETIR_S_C_STC_PS: non supporté"
-
-#~ msgid "Unimplemented STO cmd %d"
-#~ msgstr "Commande STO non implantée %d"
-
-#~ msgid "TIR_S_C_OPR_ASH incomplete"
-#~ msgstr "TIR_S_C_OPR_ASH incomplète"
-
-#~ msgid "TIR_S_C_OPR_USH incomplete"
-#~ msgstr "TIR_S_C_OPR_USH incomplète"
-
-#~ msgid "TIR_S_C_OPR_ROT incomplete"
-#~ msgstr "TIR_S_C_OPR_ROT incomplète"
-
-#~ msgid "TIR_S_C_OPR_REDEF not supported"
-#~ msgstr "TIR_S_C_OPR_REDEF non supporté"
-
-#~ msgid "TIR_S_C_OPR_DFLIT not supported"
-#~ msgstr "TIR_S_C_OPR_DFLIT non supporté"
-
-#~ msgid "TIR_S_C_CTL_DFLOC not fully implemented"
-#~ msgstr "TIR_S_C_CTL_DFLOC pas complètement implanté"
-
-#~ msgid "TIR_S_C_CTL_STLOC not fully implemented"
-#~ msgstr "TIR_S_C_CTL_STLOC pas complètement implanté"
-
-#~ msgid "TIR_S_C_CTL_STKDL not fully implemented"
-#~ msgstr "TIR_S_C_CTL_STKDL n'est pas complètement implanté"
-
-#~ msgid " vma:            Hint    Time      Forward  DLL       First\n"
-#~ msgstr " vma:            Hint    Heure     Forward  DLL       Premier\n"
-
-#~ msgid "     \t\tAddress  Address  Handler  Data     Address    Mask\n"
-#~ msgstr "     \t\tAdresse  Adresse  Routine  Données  Adresse    Masque\n"
-
 #~ msgid "float"
 #~ msgstr "flottant"
 
@@ -2950,6 +2643,9 @@
 #~ msgid "supports"
 #~ msgstr "supporte"
 
+#~ msgid "does not support"
+#~ msgstr "n'est pas supportée"
+
 #~ msgid "does not"
 #~ msgstr "n'est pas"
 
@@ -2960,15 +2656,13 @@
 #~ msgstr "%s(%s+0x%lx): ne peut repérer l'entrée du talon %s"
 
 #~ msgid "%s(%s+0x%lx): cannot relocate %s, recompile with -ffunction-sections"
-#~ msgstr ""
-#~ "%s(%s+0x%lx): ne peut relocaliser %s, recompiler avec -ffunction-sections"
+#~ msgstr "%s(%s+0x%lx): ne peut relocaliser %s, recompiler avec -ffunction-sections"
 
-#~ msgid ""
-#~ "creating section symbol, name = %s, value = 0x%.8lx, index = %d, section "
-#~ "= 0x%.8lx\n"
-#~ msgstr ""
-#~ "création de la section des symboles, nom = %s, valeur = 0x%.8lx, index = %"
-#~ "d, section = 0x%.8lx\n"
+#~ msgid "Symbol `%s' has differing types: previously %s, REGISTER in %s"
+#~ msgstr "Symbole `%s' a des types qui diffèrent: précédemment %s, ENREGISTRÉ dans %s"
+
+#~ msgid "creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = 0x%.8lx\n"
+#~ msgstr "création de la section des symboles, nom = %s, valeur = 0x%.8lx, index = %d, section = 0x%.8lx\n"
 
 #~ msgid "       whereas segment starts at 0x%x"
 #~ msgstr "       alors que le segment débute à 0x%x"
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index 9ac3f31..d40590f7 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -470,6 +470,7 @@
 #define ppcboot_bfd_gc_sections bfd_generic_gc_sections
 #define ppcboot_bfd_merge_sections bfd_generic_merge_sections
 #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define ppcboot_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define ppcboot_bfd_final_link _bfd_generic_final_link
 #define ppcboot_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 559a351..c701fe0 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -2051,106 +2051,6 @@
   BFD_RELOC_MIPS_JALR
 COMMENT
 COMMENT
-ENUMX
-  BFD_RELOC_SH_GOT_LOW16
-ENUMX
-  BFD_RELOC_SH_GOT_MEDLOW16
-ENUMX
-  BFD_RELOC_SH_GOT_MEDHI16
-ENUMX
-  BFD_RELOC_SH_GOT_HI16
-ENUMX
-  BFD_RELOC_SH_GOTPLT_LOW16
-ENUMX
-  BFD_RELOC_SH_GOTPLT_MEDLOW16
-ENUMX
-  BFD_RELOC_SH_GOTPLT_MEDHI16
-ENUMX
-  BFD_RELOC_SH_GOTPLT_HI16
-ENUMX
-  BFD_RELOC_SH_PLT_LOW16
-ENUMX
-  BFD_RELOC_SH_PLT_MEDLOW16
-ENUMX
-  BFD_RELOC_SH_PLT_MEDHI16
-ENUMX
-  BFD_RELOC_SH_PLT_HI16
-ENUMX
-  BFD_RELOC_SH_GOTOFF_LOW16
-ENUMX
-  BFD_RELOC_SH_GOTOFF_MEDLOW16
-ENUMX
-  BFD_RELOC_SH_GOTOFF_MEDHI16
-ENUMX
-  BFD_RELOC_SH_GOTOFF_HI16
-ENUMX
-  BFD_RELOC_SH_GOTPC_LOW16
-ENUMX
-  BFD_RELOC_SH_GOTPC_MEDLOW16
-ENUMX
-  BFD_RELOC_SH_GOTPC_MEDHI16
-ENUMX
-  BFD_RELOC_SH_GOTPC_HI16
-ENUMX
-  BFD_RELOC_SH_COPY64
-ENUMX
-  BFD_RELOC_SH_GLOB_DAT64
-ENUMX
-  BFD_RELOC_SH_JMP_SLOT64
-ENUMX
-  BFD_RELOC_SH_RELATIVE64
-ENUMX
-  BFD_RELOC_SH_GOT10BY4
-ENUMX
-  BFD_RELOC_SH_GOT10BY8
-ENUMX
-  BFD_RELOC_SH_GOTPLT10BY4
-ENUMX
-  BFD_RELOC_SH_GOTPLT10BY8
-ENUMX
-  BFD_RELOC_SH_GOTPLT32
-COMMENT
-ENUMX
-  BFD_RELOC_SH_SHMEDIA_CODE
-ENUMX
-  BFD_RELOC_SH_IMMU5
-ENUMX
-  BFD_RELOC_SH_IMMS6
-ENUMX
-  BFD_RELOC_SH_IMMS6BY32
-ENUMX
-  BFD_RELOC_SH_IMMU6
-ENUMX
-  BFD_RELOC_SH_IMMS10
-ENUMX
-  BFD_RELOC_SH_IMMS10BY2
-ENUMX
-  BFD_RELOC_SH_IMMS10BY4
-ENUMX
-  BFD_RELOC_SH_IMMS10BY8
-ENUMX
-  BFD_RELOC_SH_IMMS16
-ENUMX
-  BFD_RELOC_SH_IMMU16
-ENUMX
-  BFD_RELOC_SH_IMM_LOW16
-ENUMX
-  BFD_RELOC_SH_IMM_LOW16_PCREL
-ENUMX
-  BFD_RELOC_SH_IMM_MEDLOW16
-ENUMX
-  BFD_RELOC_SH_IMM_MEDLOW16_PCREL
-ENUMX
-  BFD_RELOC_SH_IMM_MEDHI16
-ENUMX
-  BFD_RELOC_SH_IMM_MEDHI16_PCREL
-ENUMX
-  BFD_RELOC_SH_IMM_HI16
-ENUMX
-  BFD_RELOC_SH_IMM_HI16_PCREL
-ENUMX
-  BFD_RELOC_SH_PT_16
-COMMENT
 ENUMDOC
   MIPS ELF relocations.
 
@@ -2487,6 +2387,104 @@
   BFD_RELOC_SH_RELATIVE
 ENUMX
   BFD_RELOC_SH_GOTPC
+ENUMX
+  BFD_RELOC_SH_GOT_LOW16
+ENUMX
+  BFD_RELOC_SH_GOT_MEDLOW16
+ENUMX
+  BFD_RELOC_SH_GOT_MEDHI16
+ENUMX
+  BFD_RELOC_SH_GOT_HI16
+ENUMX
+  BFD_RELOC_SH_GOTPLT_LOW16
+ENUMX
+  BFD_RELOC_SH_GOTPLT_MEDLOW16
+ENUMX
+  BFD_RELOC_SH_GOTPLT_MEDHI16
+ENUMX
+  BFD_RELOC_SH_GOTPLT_HI16
+ENUMX
+  BFD_RELOC_SH_PLT_LOW16
+ENUMX
+  BFD_RELOC_SH_PLT_MEDLOW16
+ENUMX
+  BFD_RELOC_SH_PLT_MEDHI16
+ENUMX
+  BFD_RELOC_SH_PLT_HI16
+ENUMX
+  BFD_RELOC_SH_GOTOFF_LOW16
+ENUMX
+  BFD_RELOC_SH_GOTOFF_MEDLOW16
+ENUMX
+  BFD_RELOC_SH_GOTOFF_MEDHI16
+ENUMX
+  BFD_RELOC_SH_GOTOFF_HI16
+ENUMX
+  BFD_RELOC_SH_GOTPC_LOW16
+ENUMX
+  BFD_RELOC_SH_GOTPC_MEDLOW16
+ENUMX
+  BFD_RELOC_SH_GOTPC_MEDHI16
+ENUMX
+  BFD_RELOC_SH_GOTPC_HI16
+ENUMX
+  BFD_RELOC_SH_COPY64
+ENUMX
+  BFD_RELOC_SH_GLOB_DAT64
+ENUMX
+  BFD_RELOC_SH_JMP_SLOT64
+ENUMX
+  BFD_RELOC_SH_RELATIVE64
+ENUMX
+  BFD_RELOC_SH_GOT10BY4
+ENUMX
+  BFD_RELOC_SH_GOT10BY8
+ENUMX
+  BFD_RELOC_SH_GOTPLT10BY4
+ENUMX
+  BFD_RELOC_SH_GOTPLT10BY8
+ENUMX
+  BFD_RELOC_SH_GOTPLT32
+ENUMX
+  BFD_RELOC_SH_SHMEDIA_CODE
+ENUMX
+  BFD_RELOC_SH_IMMU5
+ENUMX
+  BFD_RELOC_SH_IMMS6
+ENUMX
+  BFD_RELOC_SH_IMMS6BY32
+ENUMX
+  BFD_RELOC_SH_IMMU6
+ENUMX
+  BFD_RELOC_SH_IMMS10
+ENUMX
+  BFD_RELOC_SH_IMMS10BY2
+ENUMX
+  BFD_RELOC_SH_IMMS10BY4
+ENUMX
+  BFD_RELOC_SH_IMMS10BY8
+ENUMX
+  BFD_RELOC_SH_IMMS16
+ENUMX
+  BFD_RELOC_SH_IMMU16
+ENUMX
+  BFD_RELOC_SH_IMM_LOW16
+ENUMX
+  BFD_RELOC_SH_IMM_LOW16_PCREL
+ENUMX
+  BFD_RELOC_SH_IMM_MEDLOW16
+ENUMX
+  BFD_RELOC_SH_IMM_MEDLOW16_PCREL
+ENUMX
+  BFD_RELOC_SH_IMM_MEDHI16
+ENUMX
+  BFD_RELOC_SH_IMM_MEDHI16_PCREL
+ENUMX
+  BFD_RELOC_SH_IMM_HI16
+ENUMX
+  BFD_RELOC_SH_IMM_HI16_PCREL
+ENUMX
+  BFD_RELOC_SH_PT_16
 ENUMDOC
   Hitachi SH relocs.  Not all of these appear in object files.
 
diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c
index 19ff4a4..0edcdc4 100644
--- a/bfd/rs6000-core.c
+++ b/bfd/rs6000-core.c
@@ -11,21 +11,21 @@
    Archive support from Damon A. Permezel.
    Contributed by IBM Corporation and Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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 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.
+   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.  */
+   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.  */
 
 /* This port currently only handles reading object files, except when
    compiled on an RS/6000 host.  -- no archive support, no core files.
diff --git a/bfd/som.c b/bfd/som.c
index be190d8..4672379 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6333,6 +6333,7 @@
  bfd_generic_get_relocated_section_contents
 #define som_bfd_relax_section bfd_generic_relax_section
 #define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define som_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define som_bfd_final_link _bfd_generic_final_link
 
diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c
index 28ff8c8..7f1d270 100644
--- a/bfd/sparclinux.c
+++ b/bfd/sparclinux.c
@@ -1,5 +1,5 @@
 /* BFD back-end for linux flavored sparc a.out binaries.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -230,7 +230,7 @@
   struct linux_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct linux_link_hash_table);
 
-  ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct linux_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct linux_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
   if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
@@ -439,6 +439,9 @@
   struct linux_link_hash_entry *h1, *h2;
   boolean exists;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct linux_link_hash_entry *) h->root.root.u.i.link;
+
   if (h->root.root.type == bfd_link_hash_undefined
       && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
                  sizeof NEEDS_SHRLIB - 1) == 0)
diff --git a/bfd/srec.c b/bfd/srec.c
index 5dfad88..f40af69 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -167,13 +167,13 @@
     }
 }
 
-/* The maximum number of bytes on a line is FF.  */
+/* The maximum number of address+data+crc bytes on a line is FF.  */
 #define MAXCHUNK 0xff
 
 /* Default size for a CHUNK.  */
 #define DEFAULT_CHUNK 16
 
-/* The number of bytes we actually fit onto a line on output.
+/* The number of data bytes we actually fit onto a line on output.
    This variable can be modified by objcopy's --srec-len parameter.
    For a 0x75 byte record you should set --srec-len=0x70.  */
 unsigned int Chunk = DEFAULT_CHUNK;
@@ -936,7 +936,7 @@
      const bfd_byte *data;
      const bfd_byte *end;
 {
-  char buffer[MAXCHUNK];
+  char buffer[2 * MAXCHUNK + 6];
   unsigned int check_sum = 0;
   const bfd_byte *src = data;
   char *dst = buffer;
@@ -994,15 +994,14 @@
 srec_write_header (abfd)
      bfd *abfd;
 {
-  bfd_byte buffer[MAXCHUNK];
-  bfd_byte *dst = buffer;
-  unsigned int i;
+  unsigned int len = strlen (abfd->filename);
 
   /* I'll put an arbitary 40 char limit on header size.  */
-  for (i = 0; i < 40 && abfd->filename[i]; i++)
-    *dst++ = abfd->filename[i];
+  if (len > 40)
+    len = 40;
 
-  return srec_write_record (abfd, 0, (bfd_vma) 0, buffer, dst);
+  return srec_write_record (abfd, 0, (bfd_vma) 0,
+			    abfd->filename, abfd->filename + len);
 }
 
 static boolean
@@ -1014,6 +1013,17 @@
   unsigned int octets_written = 0;
   bfd_byte *location = list->data;
 
+  /* Validate number of data bytes to write.  The srec length byte
+     counts the address, data and crc bytes.  S1 (tdata->type == 1)
+     records have two address bytes, S2 (tdata->type == 2) records
+     have three, and S3 (tdata->type == 3) records have four.
+     The total length can't exceed 255, and a zero data length will
+     spin for a long time.  */
+  if (Chunk == 0)
+    Chunk = 1;
+  else if (Chunk > MAXCHUNK - tdata->type - 2)
+    Chunk = MAXCHUNK - tdata->type - 2;
+
   while (octets_written < list->size)
     {
       bfd_vma address;
@@ -1043,17 +1053,14 @@
      bfd *abfd;
      tdata_type *tdata;
 {
-  bfd_byte buffer[2];
-
   return srec_write_record (abfd, 10 - tdata->type,
-			    abfd->start_address, buffer, buffer);
+			    abfd->start_address, NULL, NULL);
 }
 
 static boolean
 srec_write_symbols (abfd)
      bfd *abfd;
 {
-  char buffer[MAXCHUNK];
   /* Dump out the symbols of a bfd.  */
   int i;
   int count = bfd_get_symcount (abfd);
@@ -1062,10 +1069,10 @@
     {
       bfd_size_type len;
       asymbol **table = bfd_get_outsymbols (abfd);
-      sprintf (buffer, "$$ %s\r\n", abfd->filename);
-
-      len = strlen (buffer);
-      if (bfd_bwrite (buffer, len, abfd) != len)
+      len = strlen (abfd->filename);
+      if (bfd_bwrite ("$$ ", (bfd_size_type) 3, abfd) != 3
+	  || bfd_bwrite (abfd->filename, len, abfd) != len
+	  || bfd_bwrite ("\r\n", (bfd_size_type) 2, abfd) != 2)
 	return false;
 
       for (i = 0; i < count; i++)
@@ -1075,23 +1082,29 @@
 	      && (s->flags & BSF_DEBUGGING) == 0)
 	    {
 	      /* Just dump out non debug symbols.  */
-	      char buf2[40], *p;
+	      char buf[42], *p;
 
-	      sprintf_vma (buf2,
-			   s->value + s->section->output_section->lma
-			   + s->section->output_offset);
-	      p = buf2;
+	      len = strlen (s->name);
+	      if (bfd_bwrite ("  ", (bfd_size_type) 2, abfd) != 2
+		  || bfd_bwrite (s->name, len, abfd) != len)
+		return false;
+
+	      sprintf_vma (buf + 1, (s->value
+				     + s->section->output_section->lma
+				     + s->section->output_offset));
+	      p = buf + 1;
 	      while (p[0] == '0' && p[1] != 0)
 		p++;
-	      sprintf (buffer, "  %s $%s\r\n", s->name, p);
-	      len = strlen (buffer);
-	      if (bfd_bwrite (buffer, len, abfd) != len)
+	      len = strlen (p);
+	      p[len] = '\r';
+	      p[len + 1] = '\n';
+	      *--p = ' ';
+	      len += 3;
+	      if (bfd_bwrite (p, len, abfd) != len)
 		return false;
 	    }
 	}
-      sprintf (buffer, "$$ \r\n");
-      len = strlen (buffer);
-      if (bfd_bwrite (buffer, len, abfd) != len)
+      if (bfd_bwrite ("$$ \r\n", (bfd_size_type) 5, abfd) != 5)
 	return false;
     }
 
@@ -1258,6 +1271,7 @@
 #define srec_bfd_gc_sections bfd_generic_gc_sections
 #define srec_bfd_merge_sections bfd_generic_merge_sections
 #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define srec_bfd_final_link _bfd_generic_final_link
 #define srec_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/sunos.c b/bfd/sunos.c
index 30fd019..7825a82 100644
--- a/bfd/sunos.c
+++ b/bfd/sunos.c
@@ -717,13 +717,13 @@
   struct sunos_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct sunos_link_hash_table);
 
-  ret = (struct sunos_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct sunos_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct sunos_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
   if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
 					 sunos_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
 
@@ -2052,6 +2052,9 @@
 {
   struct bfd_link_info *info = (struct bfd_link_info *) data;
 
+  if (h->root.root.type == bfd_link_hash_warning)
+    h = (struct sunos_link_hash_entry *) h->root.root.u.i.link;
+
   /* Set the written flag for symbols we do not want to write out as
      part of the regular symbol table.  This is all symbols which are
      not defined in a regular object file.  For some reason symbols
diff --git a/bfd/syms.c b/bfd/syms.c
index f0ffaa5..01f7eee 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -1238,9 +1238,11 @@
 
   for (; stab < (indexentry+1)->stab; stab += STABSIZE)
     {
-      boolean done;
+      boolean done, saw_line, saw_func;
       bfd_vma val;
 
+      saw_line = false;
+      saw_func = false;
       done = false;
 
       switch (stab[TYPEOFF])
@@ -1261,7 +1263,11 @@
 	  /* A line number.  The value is relative to the start of the
              current function.  */
 	  val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF);
-	  if (val <= offset)
+	  /* If this line starts before our desired offset, or if it's
+	     the first line we've been able to find, use it.  The
+	     !saw_line check works around a bug in GCC 2.95.3, which emits
+	     the first N_SLINE late.  */
+	  if (!saw_line || val <= offset)
 	    {
 	      *pline = bfd_get_16 (abfd, stab + DESCOFF);
 
@@ -1274,11 +1280,14 @@
 	    }
 	  if (val > offset)
 	    done = true;
+	  saw_line = true;
 	  break;
 
 	case N_FUN:
 	case N_SO:
-	  done = true;
+	  if (saw_func || saw_line)
+	    done = true;
+	  saw_func = true;
 	  break;
 	}
 
@@ -1288,7 +1297,8 @@
 
   *pfound = true;
 
-  if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL)
+  if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
+      || directory_name == NULL)
     *pfilename = file_name;
   else
     {
diff --git a/bfd/targets.c b/bfd/targets.c
index 78b4bbb..b9d3a93 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -394,6 +394,7 @@
 .CONCAT2 (NAME,_bfd_get_relocated_section_contents), \
 .CONCAT2 (NAME,_bfd_relax_section), \
 .CONCAT2 (NAME,_bfd_link_hash_table_create), \
+.CONCAT2 (NAME,_bfd_link_hash_table_free), \
 .CONCAT2 (NAME,_bfd_link_add_symbols), \
 .CONCAT2 (NAME,_bfd_final_link), \
 .CONCAT2 (NAME,_bfd_link_split_section), \
@@ -411,6 +412,9 @@
 .     different information in this table.  *}
 .  struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
 .
+.  {* Release the memory associated with the linker hash table.  *}
+.  void (*_bfd_link_hash_table_free) PARAMS ((struct bfd_link_hash_table *));
+.
 .  {* Add symbols from this object file into the hash table.  *}
 .  boolean  (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
 .
@@ -631,6 +635,7 @@
 extern const bfd_target riscix_vec;
 extern const bfd_target rs6000coff64_vec;
 extern const bfd_target rs6000coff_vec;
+extern const bfd_target aix5coff64_vec;
 extern const bfd_target shcoff_small_vec;
 extern const bfd_target shcoff_vec;
 extern const bfd_target shlcoff_small_vec;
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index f5d5160..565568a 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -1,5 +1,5 @@
 /* BFD backend for Extended Tektronix Hex Format  objects.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
@@ -1006,6 +1006,7 @@
 #define tekhex_bfd_gc_sections bfd_generic_gc_sections
 #define tekhex_bfd_merge_sections bfd_generic_merge_sections
 #define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define tekhex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define tekhex_bfd_final_link _bfd_generic_final_link
 #define tekhex_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/versados.c b/bfd/versados.c
index 37eb94c..9a7bcc7 100644
--- a/bfd/versados.c
+++ b/bfd/versados.c
@@ -868,6 +868,7 @@
 #define versados_bfd_gc_sections bfd_generic_gc_sections
 #define versados_bfd_merge_sections bfd_generic_merge_sections
 #define versados_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define versados_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define versados_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define versados_bfd_final_link _bfd_generic_final_link
 #define versados_bfd_link_split_section _bfd_generic_link_split_section
diff --git a/bfd/version.h b/bfd/version.h
index e7469a7..952767f 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1 +1 @@
-#define BFD_VERSION_DATE 20020303
+#define BFD_VERSION_DATE 20020506
diff --git a/bfd/vms.c b/bfd/vms.c
index 388b727..7ca7459 100644
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -114,6 +114,8 @@
   PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
 static struct bfd_link_hash_table *vms_bfd_link_hash_table_create
   PARAMS ((bfd *abfd));
+static void vms_bfd_link_hash_table_free
+  PARAMS ((struct bfd_link_hash_table *hash));
 static boolean vms_bfd_link_add_symbols
   PARAMS ((bfd *abfd, struct bfd_link_info *link_info));
 static boolean vms_bfd_final_link
@@ -1789,6 +1791,17 @@
   return 0;
 }
 
+/* Free a linker hash table.  */
+
+static void
+vms_bfd_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED;
+{
+#if VMS_DEBUG
+  vms_debug (1, "vms_bfd_link_hash_table_free(%p)\n", abfd);
+#endif
+}
+
 /* Add symbols from this object file into the hash table.  */
 
 static boolean
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 5b1ddcc..9d66243 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -3,21 +3,21 @@
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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 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.
+   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.  */
+   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"
@@ -482,12 +482,12 @@
   struct xcoff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct xcoff_link_hash_table);
 
-  ret = (struct xcoff_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct xcoff_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct xcoff_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
 
@@ -513,6 +513,18 @@
   return &ret->root;
 }
 
+/* Free a XCOFF link hash table.  */
+
+void
+_bfd_xcoff_bfd_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash;
+{
+  struct xcoff_link_hash_table *ret = (struct xcoff_link_hash_table *) hash;
+
+  _bfd_stringtab_free (ret->debug_strtab);
+  bfd_hash_table_free (&ret->root.table);
+  free (ret);
+}
 
 /* Read internal relocs for an XCOFF csect.  This is a wrapper around
    _bfd_coff_read_internal_relocs which tries to take advantage of any
@@ -588,11 +600,11 @@
 
     case bfd_archive:
       /* If the archive has a map, do the usual search.  We then need
-         to check the archive for stripped dynamic objects, because
-         they will not appear in the archive map even though they
-         should, perhaps, be included.  If the archive has no map, we
-         just consider each object file in turn, since that apparently
-         is what the AIX native linker does.  */
+         to check the archive for dynamic objects, because they may not 
+	 appear in the archive map even though they should, perhaps, be 
+	 included.  If the archive has no map, we just consider each object 
+	 file in turn, since that apparently is what the AIX native linker 
+	 does.  */
       if (bfd_has_map (abfd))
 	{
 	  if (! (_bfd_generic_link_add_archive_symbols
@@ -602,18 +614,18 @@
 
       {
 	bfd *member;
-
+	
 	member = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
 	while (member != NULL)
 	  {
 	    if (bfd_check_format (member, bfd_object)
-		&& (! bfd_has_map (abfd)
-		    || ((member->flags & DYNAMIC) != 0
-			&& (member->flags & HAS_SYMS) == 0)))
+		&& (info->hash->creator == member->xvec)
+		&& (! bfd_has_map (abfd) || (member->flags & DYNAMIC) != 0))
 	      {
 		boolean needed;
-
-		if (! xcoff_link_check_archive_element (member, info, &needed))
+		
+		if (! xcoff_link_check_archive_element (member, info, 
+							&needed))
 		  return false;
 		if (needed)
 		  member->archive_pass = -1;
@@ -1766,12 +1778,19 @@
  	  if (info->hash->creator == abfd->xvec)
 	    {
 	      if (! bfd_is_und_section (section))
-		*sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
-						    name, true, copy, false);
+		{
+		  *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
+						      name, true, copy, false);
+		}
 	      else
-		*sym_hash = ((struct xcoff_link_hash_entry *)
-			     bfd_wrapped_link_hash_lookup (abfd, info, name,
-							   true, copy, false));
+		{
+		  /* Make a copy of the symbol name to prevent problems with
+		     merging symbols.  */
+		  *sym_hash = ((struct xcoff_link_hash_entry *)
+			       bfd_wrapped_link_hash_lookup (abfd, info, name,
+							     true, true, 
+							     false));
+		}
 	      if (*sym_hash == NULL)
 		goto error_return;
 	      if (((*sym_hash)->root.type == bfd_link_hash_defined
@@ -2109,7 +2128,7 @@
 
   /* Remove the sections from this object, so that they do not get
      included in the link.  */
-  abfd->sections = NULL;
+  bfd_section_list_clear (abfd);
 
   bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
 
@@ -3141,37 +3160,42 @@
 
       csectpp = xcoff_data (sub)->csects;
 
-      symesz = bfd_coff_symesz (sub);
-      esym = (bfd_byte *) obj_coff_external_syms (sub);
-      esymend = esym + symcount * symesz;
-      while (esym < esymend)
+      /* Dynamic object do not have csectpp's.  */
+      if (NULL != csectpp) 
 	{
-	  struct internal_syment sym;
+	  symesz = bfd_coff_symesz (sub);
+	  esym = (bfd_byte *) obj_coff_external_syms (sub);
+	  esymend = esym + symcount * symesz;
 
-	  bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym);
-
-	  *debug_index = (unsigned long) -1;
-
-	  if (sym._n._n_n._n_zeroes == 0
-	      && *csectpp != NULL
-	      && (! gc
-		  || ((*csectpp)->flags & SEC_MARK) != 0
-		  || *csectpp == bfd_abs_section_ptr)
-	      && bfd_coff_symname_in_debug (sub, &sym))
+	  while (esym < esymend)
 	    {
-	      char *name;
-	      bfd_size_type indx;
+	      struct internal_syment sym;
 
-	      name = (char *) debug_contents + sym._n._n_n._n_offset;
-	      indx = _bfd_stringtab_add (debug_strtab, name, true, true);
-	      if (indx == (bfd_size_type) -1)
-		goto error_return;
-	      *debug_index = indx;
+	      bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym);
+
+	      *debug_index = (unsigned long) -1;
+
+	      if (sym._n._n_n._n_zeroes == 0
+		  && *csectpp != NULL
+		  && (! gc
+		      || ((*csectpp)->flags & SEC_MARK) != 0
+		      || *csectpp == bfd_abs_section_ptr)
+		  && bfd_coff_symname_in_debug (sub, &sym))
+		{
+		  char *name;
+		  bfd_size_type indx;
+
+		  name = (char *) debug_contents + sym._n._n_n._n_offset;
+		  indx = _bfd_stringtab_add (debug_strtab, name, true, true);
+		  if (indx == (bfd_size_type) -1)
+		    goto error_return;
+		  *debug_index = indx;
+		}
+
+	      esym += (sym.n_numaux + 1) * symesz;
+	      csectpp += sym.n_numaux + 1;
+	      debug_index += sym.n_numaux + 1;
 	    }
-
-	  esym += (sym.n_numaux + 1) * symesz;
-	  csectpp += sym.n_numaux + 1;
-	  debug_index += sym.n_numaux + 1;
 	}
 
       free (debug_contents);
@@ -3248,6 +3272,9 @@
   struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p;
   bfd_size_type amt;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct xcoff_link_hash_entry *) h->root.u.i.link;
+
   /* __rtinit, this symbol has special handling. */
   if (h->flags & XCOFF_RTINIT)
       return true;
@@ -5369,6 +5396,13 @@
   output_bfd = finfo->output_bfd;
   outsym = finfo->outsyms;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h = (struct xcoff_link_hash_entry *) h->root.u.i.link;
+      if (h->root.type == bfd_link_hash_new)
+	return true;
+    }
+
   /* If this symbol was garbage collected, just skip it.  */
   if (xcoff_hash_table (finfo->info)->gc
       && (h->flags & XCOFF_MARK) == 0)
diff --git a/config.guess b/config.guess
index db494f8..ed2e03b 100755
--- a/config.guess
+++ b/config.guess
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002 Free Software Foundation, Inc.
 
-timestamp='2002-02-19'
+timestamp='2002-03-20'
 
 # 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
@@ -98,7 +98,7 @@
 
 set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
  ,,)    echo "int dummy(){}" > $dummy.c ;
-	for c in cc gcc c89 ; do
+	for c in cc gcc c89 c99 ; do
 	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
 	  if test $? = 0 ; then
 	     CC_FOR_BUILD="$c"; break ;
@@ -138,8 +138,9 @@
 	#
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
-	UNAME_MACHINE_ARCH=`(uname -p) 2>/dev/null` || \
-	    UNAME_MACHINE_ARCH=unknown
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
 	case "${UNAME_MACHINE_ARCH}" in
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
@@ -759,7 +760,7 @@
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
     ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
     m68*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -770,15 +771,15 @@
 	#undef CPU
 	#undef mips
 	#undef mipsel
-	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) 
-	CPU=mipsel 
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mipsel
 	#else
-	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
 	CPU=mips
 	#else
 	CPU=
 	#endif
-	#endif 
+	#endif
 EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
 	rm -f $dummy.c
@@ -1058,12 +1059,12 @@
 	echo `uname -p`-apple-darwin${UNAME_RELEASE}
 	exit 0 ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
-	if test "${UNAME_MACHINE}" = "x86pc"; then
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
 		UNAME_MACHINE=pc
-		echo i386-${UNAME_MACHINE}-nto-qnx
-	else
-		echo `uname -p`-${UNAME_MACHINE}-nto-qnx
 	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
 	exit 0 ;;
     *:QNX:*:4*)
 	echo i386-pc-qnx
diff --git a/config.sub b/config.sub
index 4ac7ab2..299f3f4 100755
--- a/config.sub
+++ b/config.sub
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002 Free Software Foundation, Inc.
 
-timestamp='2002-02-22'
+timestamp='2002-04-26'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -239,7 +239,7 @@
 	| mips64vr4100 | mips64vr4100el | mips64vr4300 \
 	| mips64vr4300el | mips64vr5000 | mips64vr5000el \
 	| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
-	| mipsisa32 \
+	| mipsisa32 | mipsisa64 \
 	| mn10200 | mn10300 \
 	| ns16k | ns32k \
 	| openrisc | or32 \
@@ -247,7 +247,7 @@
 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| pyramid \
 	| sh | sh[34] | sh[34]eb | shbe | shle | sh64 \
-	| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
+	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
 	| strongarm \
 	| tahoe | thumb | tic80 | tron \
 	| v850 | v850e \
@@ -306,7 +306,7 @@
 	| pyramid-* \
 	| romp-* | rs6000-* \
 	| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \
-	| sparc-* | sparc64-* | sparc86x-* | sparclite-* \
+	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
 	| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
 	| tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
 	| v850-* | v850e-* | vax-* \
@@ -1090,7 +1090,7 @@
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-	      | -morphos* | -superux* | -rtmk* | -rtmk-nova*)
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* )
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1409,7 +1409,7 @@
 			-ptx*)
 				vendor=sequent
 				;;
-			-vxsim* | -vxworks*)
+			-vxsim* | -vxworks* | -windiss*)
 				vendor=wrs
 				;;
 			-aux*)
diff --git a/config/ChangeLog b/config/ChangeLog
index 5a398ec..06f7605 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,91 @@
+2002-04-29  Nathanael Nerode  <neroden@twcny.rr.com>
+
+	* config/mh-cxux: remove dead code
+	* config/mh-dgux386: remove dead code
+	* config/mh-hp300: remove dead code
+	* config/mh-hpux: remove dead code
+	* config/mh-hpux8: remove dead code
+	* config/mh-irix5: remove dead code
+	* config/mh-irix6: remove dead code
+	* config/mh-ncr3000: remove dead code
+	* config/mh-ncrsvr43: remove dead code
+	* config/mh-necv4: remove dead code
+	* config/mh-sco: remove dead code
+	* config/mh-solaris: remove dead code
+	* config/mh-sysv: remove dead code
+	* config/mh-sysv4: remove dead code
+	* config/mh-sysv5: remove dead code
+	* config/mh-irix4: remove, contains only dead code
+
+	* config/mt-armpic: Delete.
+	* config/mt-elfalphapic: Delete.
+	* config/mt-i370pic: Delete.
+	* config/mt-ia64pic: Delete.
+	* config/mt-m68kpic: Delete.
+	* config/mt-papic: Delete.
+	* config/mt-ppcpic: Delete.
+	* config/mt-s390pic: Delete.
+	* config/mt-sparcpic: Delete.
+	* config/mt-x86pic: Delete.
+
+2002-04-19  Nathanael Nerode  <neroden@twcny.rr.com>
+
+	* mh-a68bsd: clean out dead code
+	* mh-apollo68: clean out dead code
+	* mh-cxux: clean out dead code
+	* mh-decstation: clean out dead code
+	* mh-dgux: clean out dead code
+	* mh-dgux386: clean out dead code
+	* mh-hp300: clean out dead code
+	* mh-hpux: clean out dead code
+	* mh-hpux8: clean out dead code
+	* mh-interix: clean out dead code
+	* mh-irix4: clean out dead code
+	* mh-lynxrs6k: clean out dead code
+	* mh-mingw32: clean out dead code
+	* mh-ncr3000: clean out dead code
+	* mh-ncrsvr43: clean out dead code
+	* mh-necv4: clean out dead code
+	* mh-openedition: clean out dead code
+	* mh-riscos: clean out dead code
+	* mh-sco: clean out dead code
+	* mh-sysv4: clean out dead code
+	* mh-lynxos: removed, contained only dead code
+	* mh-vaxult2: removed, contained only dead code
+	* mh-sun3: removed, contained only dead code
+
+2002-04-15  Keith Seitz  <keiths@redhat.com>
+
+	* acinclude.m4 (CYG_AC_PATH_TCLCONFIG): Search the win/ directory,
+	too.
+	(CYG_AC_PATH_TKCONFIG): Likewise.
+
+2001-10-07  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+	* acinclude.m4: Fix spelling error of "separate" as "seperate".
+
+2001-05-22  Jason Merrill  <jason_merrill@redhat.com>
+
+	* mt-linux (CXXFLAGS_FOR_TARGET): Lose -fvtable-thunks.
+
+2001-01-27  Richard Henderson  <rth@redhat.com>
+
+	* mt-alphaieee: New file.
+
+2001-01-02  Laurynas Biveinis  <lauras@softhome.net>
+
+	* mh-djgpp: do not set CFLAGS.
+
+2000-08-04  Mark Elbrecht  <snowball3@bigfoot.com>
+
+	* mh-djgpp: Conditionally set 'target_alias' to djgpp. Conditionally
+	modify 'gcc_version'.
+
+2000-07-21  Andrew Haley  <aph@cygnus.com>
+
+	* mh-ia64pic: New file.
+	* mt-ia64pic: New file.	
+
 2001-02-09  Martin Schwidefsky  <schwidefsky@de.ibm.com>
 
 	* mh-s390pic: New file.
diff --git a/config/acinclude.m4 b/config/acinclude.m4
index 6187b5a..9be62cb 100755
--- a/config/acinclude.m4
+++ b/config/acinclude.m4
@@ -959,10 +959,17 @@
     dnl next check if it came with Tcl configuration file in the source tree
     if test x"${ac_cv_c_tclconfig}" = x ; then
         for i in $dirlist; do
+            dnl need to test both unix and win directories, since 
+            dnl cygwin's tkConfig.sh could be in either directory depending
+            dnl on the cygwin port of tcl.
             if test -f $srcdir/$i/unix/tclConfig.sh ; then
                 ac_cv_c_tclconfig=`(cd $srcdir/$i/unix; pwd)`
 	        break
             fi
+            if test -f $srcdir/$i/win/tclConfig.sh ; then
+                ac_cv_c_tclconfig=`(cd $srcdir/$i/win; pwd)`
+	        break
+            fi
         done
     fi
     dnl check in a few other locations
@@ -978,10 +985,17 @@
         dnl find the exact Tcl dir. We do it this way, cause there
         dnl might be multiple version of Tcl, and we want the most recent one.
         for i in `ls -dr $tclconfpath/tcl* 2>/dev/null ` ; do
+            dnl need to test both unix and win directories, since 
+            dnl cygwin's tclConfig.sh could be in either directory depending
+            dnl on the cygwin port of tcl.
             if test -f $i/unix/tclConfig.sh ; then
                 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
                 break
             fi
+            if test -f $i/win/tclConfig.sh ; then
+                ac_cv_c_tclconfig=`(cd $i/win; pwd)`
+                break
+            fi
         done
     fi
 
@@ -1071,7 +1085,7 @@
 # Note the gross little conversion here of srcdir by cd'ing to the found
 # directory. This converts the path from a relative to an absolute, so
 # recursive cache variables for the path will work right. We check all
-# the possible paths in one loop rather than many seperate loops to speed
+# the possible paths in one loop rather than many separate loops to speed
 # things up.
 # the alternative search directory is involked by --with-tkinclude
 #
@@ -1178,10 +1192,17 @@
     dnl next check if it came with Tk configuration file in the source tree
     if test x"${ac_cv_c_tkconfig}" = x ; then
         for i in $dirlist; do
+            dnl need to test both unix and win directories, since 
+            dnl cygwin's tkConfig.sh could be in either directory depending
+            dnl on the cygwin port of tk.
             if test -f $srcdir/$i/unix/tkConfig.sh ; then
                 ac_cv_c_tkconfig=`(cd $srcdir/$i/unix; pwd)`
 	        break
             fi
+            if test -f $srcdir/$i/win/tkConfig.sh ; then
+                ac_cv_c_tkconfig=`(cd $srcdir/$i/unix; pwd)`
+	        break
+            fi
         done
     fi
     dnl check in a few other locations
@@ -1197,10 +1218,17 @@
         dnl find the exact Tk dir. We do it this way, cause there
         dnl might be multiple version of Tk, and we want the most recent one.
         for i in `ls -dr $tkconfpath/tk* 2>/dev/null ` ; do
+            dnl need to test both unix and win directories, since 
+            dnl cygwin's tkConfig.sh could be in either directory depending
+            dnl on the cygwin port of tk.
             if test -f $i/unix/tkConfig.sh ; then
                 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
                 break
             fi
+            if test -f $i/win/tkConfig.sh ; then
+                ac_cv_c_tkconfig=`(cd $i/win; pwd)`
+                break
+            fi
         done
     fi
 
diff --git a/config/mh-a68bsd b/config/mh-a68bsd
index c991289..2fe28d0 100644
--- a/config/mh-a68bsd
+++ b/config/mh-a68bsd
@@ -1,12 +1,2 @@
 RANLIB=true
-
-#None of the Apollo compilers can compile gas or binutils.  The preprocessor
-# chokes on bfd, the compiler won't let you assign integers to enums, and
-# other problems.  Defining CC to gcc is a questionable way to say "don't use
-# the apollo compiler" (the preferred version of GCC could be called cc,
-# or whatever), but I'm not sure leaving CC as cc is any better...
-
-#CC=cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DNO_STDARG
-CC=gcc
-
 BISON=yacc
diff --git a/config/mh-apollo68 b/config/mh-apollo68
index 4497ed9..4b4ffa5 100644
--- a/config/mh-apollo68
+++ b/config/mh-apollo68
@@ -1,3 +1,2 @@
 HDEFINES = -DUSG
 RANLIB=true
-CC= cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DUSG
diff --git a/config/mh-cxux b/config/mh-cxux
index 54b2a16..0a98f11 100644
--- a/config/mh-cxux
+++ b/config/mh-cxux
@@ -1,14 +1,7 @@
 # Configuration for Harris CX/UX 7 (and maybe 6), based on sysv4 configuration.
 
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4
 RANLIB = true
 
-# C++ debugging is not yet supported under SVR4 (DWARF)
-CXXFLAGS=-O
-
 # The l flag generates a warning from the SVR4 archiver, remove it.
 AR_FLAGS = cq
 
-# Under CX/UX, we want to tell the compiler to use ANSI mode.
-CC=cc -Xa
diff --git a/config/mh-decstation b/config/mh-decstation
index 3720192..320927c 100644
--- a/config/mh-decstation
+++ b/config/mh-decstation
@@ -1,5 +1,3 @@
-CC = cc -Wf,-XNg1000
-
 # for X11, since the native DECwindows include files are really broken when
 # it comes to function prototypes.  
 X11_EXTRA_CFLAGS = "-DNeedFunctionPrototypes=0"
diff --git a/config/mh-dgux b/config/mh-dgux
index e7d85d6..746ffdb 100644
--- a/config/mh-dgux
+++ b/config/mh-dgux
@@ -1,4 +1,3 @@
 HDEFINES=-DHOST_SYS=DGUX_SYS
-CC=gcc -Wall -ansi -D__using_DGUX
 RANLIB=true
 
diff --git a/config/mh-dgux386 b/config/mh-dgux386
index 15885c3..f1e533a 100644
--- a/config/mh-dgux386
+++ b/config/mh-dgux386
@@ -1,22 +1,12 @@
 # from mh-dgux
 HDEFINES=-DHOST_SYS=DGUX_SYS
-CC=gcc -Wall -ansi -D__using_DGUX
 RANLIB = true
 
 # from mh-sysv4
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4
 RANLIB = true
 
-# C++ debugging is not yet supported under SVR4 (DWARF)
-CXXFLAGS=-O
-
 # The l flag generates a warning from the SVR4 archiver, remove it.
 AR_FLAGS = cr
 
 X11_EXTRA_LIBS = -lnsl
 
-# from angela
-# no debugging due to broken compiler, use BSD style timeofday
-CFLAGS=-O -D_BSD_TIMEOFDAY_FLAVOR
-
diff --git a/config/mh-djgpp b/config/mh-djgpp
index f12007b..88d250a 100644
--- a/config/mh-djgpp
+++ b/config/mh-djgpp
@@ -1,4 +1,14 @@
-# We don't want to use debugging information on DOS.  Unfortunately,
-# this requires that we set CFLAGS.
-# This used to set -fno-omit-frame-pointer.
-CFLAGS=-O2
+# Shorten the target alias so when it is used to set 'libsubdir'
+# the name will work in both short and long filename environments.
+ifeq ($(findstring -pc-msdosdjgpp,$(target_alias)),-pc-msdosdjgpp)
+target_alias=djgpp
+endif
+
+# The version string must be modified to contain just one dot
+# because DOS filenames can only have one dot when long filenames
+# are not available.
+__version:=$(gcc_version)
+__version:=$(subst ., ,$(__version))
+ifeq ($(words $(__version)),3)
+gcc_version=$(word 1,$(__version)).$(word 2,$(__version))$(word 3,$(__version))
+endif
diff --git a/config/mh-hp300 b/config/mh-hp300
index 761724d..17a69a6 100644
--- a/config/mh-hp300
+++ b/config/mh-hp300
@@ -1,13 +1,3 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV
-# Avoid "too much defining" errors from HPUX compiler.
-CC = cc -Wp,-H256000
 # If "ar" in $PATH is GNU ar, the symbol table may need rebuilding.
 # If it's HP/UX ar, this should be harmless.
 RANLIB = ar ts
-
-# Native cc can't bootstrap gcc with -g.  Defining CFLAGS here loses (a)
-# for non-gcc directories, (b) if we are compiling with gcc, not
-# native cc.  Neither (a) nor (b) has a trivial fix though.
-
-CFLAGS =
diff --git a/config/mh-hpux b/config/mh-hpux
index 4d71c9d..4003002 100644
--- a/config/mh-hpux
+++ b/config/mh-hpux
@@ -1,4 +1 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-CC = cc -Wp,-H256000
-SYSV = -DSYSV
 RANLIB = true
diff --git a/config/mh-hpux8 b/config/mh-hpux8
index 4d71c9d..4003002 100644
--- a/config/mh-hpux8
+++ b/config/mh-hpux8
@@ -1,4 +1 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-CC = cc -Wp,-H256000
-SYSV = -DSYSV
 RANLIB = true
diff --git a/config/mh-interix b/config/mh-interix
index 19b8ecf..1693006 100644
--- a/config/mh-interix
+++ b/config/mh-interix
@@ -2,12 +2,6 @@
 SHELL = sh
 RANLIB = true
 
-# We don't want debugging info in Interix-hosted toolchains.
-# Accomplish this by overriding CFLAGS. This is also a workaround
-# for LD crash when building shared libstdc++.
-CFLAGS=-O2
-CXXFLAGS=-O2
-
 # We also need to override LIBGCC2_DEBUG_CFLAGS so libgcc2 will be
 # built without debugging information
 
diff --git a/config/mh-irix4 b/config/mh-irix4
deleted file mode 100644
index 6872145..0000000
--- a/config/mh-irix4
+++ /dev/null
@@ -1,7 +0,0 @@
-# Makefile changes for SGI's running IRIX-4.x.
-# Tell compiler to use K&R C.  We can't compile under the SGI Ansi
-# environment.  Also bump switch table size so that cp-parse will
-# compile.  Bump string length limit so linker builds.
-
-CC = cc -cckr -Wf,-XNg1500 -Wf,-XNk1000 -Wf,-XNh2000 -Wf,-XNl8192
-SYSV = -DSYSV
diff --git a/config/mh-irix5 b/config/mh-irix5
index 8bd7c99..0019ee4 100644
--- a/config/mh-irix5
+++ b/config/mh-irix5
@@ -1,3 +1,2 @@
 # Makefile changes for SGI's running IRIX-5.x.
-SYSV = -DSYSV
 RANLIB = true
diff --git a/config/mh-irix6 b/config/mh-irix6
index e792678..bf6d8dc 100644
--- a/config/mh-irix6
+++ b/config/mh-irix6
@@ -1,3 +1,2 @@
 # Makefile changes for SGI's running IRIX-6.x.
-SYSV = -DSYSV
 RANLIB = true
diff --git a/config/mh-lynxos b/config/mh-lynxos
deleted file mode 100644
index 9afcb79..0000000
--- a/config/mh-lynxos
+++ /dev/null
@@ -1,2 +0,0 @@
-# /bin/cc is less than useful for our purposes.  Always use GCC
-CC = /bin/gcc
diff --git a/config/mh-lynxrs6k b/config/mh-lynxrs6k
index b279399..3ee7639 100644
--- a/config/mh-lynxrs6k
+++ b/config/mh-lynxrs6k
@@ -1,8 +1,5 @@
 # LynxOS running on the rs6000 doesn't have ranlib
 RANLIB = true
 
-# /bin/cc is less than useful for our purposes.  Always use GCC
-CC = /usr/cygnus/progressive/bin/gcc
-
 # /bin/sh is too buggy, so use /bin/bash instead.
 SHELL = /bin/bash
diff --git a/config/mh-mingw32 b/config/mh-mingw32
index 8c4839d..f622c8b 100644
--- a/config/mh-mingw32
+++ b/config/mh-mingw32
@@ -1,8 +1,3 @@
-# We don't want debugging info in Win32-hosted toolchains.
-# Accomplish this by overriding CFLAGS.
-CFLAGS=-O2
-CXXFLAGS=-O2
-
 # We also need to override LIBGCC2_DEBUG_CFLAGS so libgcc2 will be
 # built without debugging information
 
diff --git a/config/mh-ncr3000 b/config/mh-ncr3000
index 5bbd803..ead6cce 100644
--- a/config/mh-ncr3000
+++ b/config/mh-ncr3000
@@ -1,16 +1,5 @@
 # Host configuration file for an NCR 3000 (i486/SVR4) system.
 
-# The NCR 3000 ships with a MetaWare compiler installed as /bin/cc.
-# This compiler not only emits obnoxious copyright messages every time
-# you run it, but it chokes and dies on a whole bunch of GNU source
-# files.  Default to using the AT&T compiler installed in /usr/ccs/ATT/cc.
-# Unfortunately though, the AT&T compiler sometimes generates code that
-# the assembler barfs on if -g is used, so disable it by default as well.
-CC = /usr/ccs/ATT/cc
-CFLAGS =
-
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4
 RANLIB = true
 
 # The l flag generates a warning from the SVR4 archiver, remove it.
diff --git a/config/mh-ncrsvr43 b/config/mh-ncrsvr43
index 43b0991..5446d77 100644
--- a/config/mh-ncrsvr43
+++ b/config/mh-ncrsvr43
@@ -1,9 +1,3 @@
 # Host configuration file for an NCR 3000 (i486/SVR43) system.
 
-# The MetaWare compiler will generate a copyright message unless you
-# turn it off by adding the -Hnocopyr flag.
-CC = cc -Hnocopyr
-
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4
 RANLIB = true
diff --git a/config/mh-necv4 b/config/mh-necv4
index e887736..6845f3c 100644
--- a/config/mh-necv4
+++ b/config/mh-necv4
@@ -1,10 +1,5 @@
 # Host Makefile fragment for NEC MIPS SVR4.
 
-# The C compiler on NEC MIPS SVR4 needs bigger tables.
-CC = cc -ZXNd=5000 -ZXNg=1000
-
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4
 RANLIB = true
 
 # NEC -lX11 needs some other libraries.
diff --git a/config/mh-openedition b/config/mh-openedition
index e99ef15..4003002 100644
--- a/config/mh-openedition
+++ b/config/mh-openedition
@@ -1,2 +1 @@
 RANLIB = true
-CC = c89
diff --git a/config/mh-riscos b/config/mh-riscos
index e586b30..07588c7 100644
--- a/config/mh-riscos
+++ b/config/mh-riscos
@@ -1,15 +1,3 @@
 # This is for a MIPS running RISC/os 4.52C.
 
-# This is needed for GDB, but needs to be in the top-level make because
-# if a library is compiled with the bsd headers and gets linked with the
-# sysv system libraries all hell can break loose (e.g. a jmp_buf might be
-# a different size).
-# ptrace(2) apparently has problems in the BSD environment.  No workaround is
-# known except to select the sysv environment.  Could we use /proc instead?
-# These "sysv environments" and "bsd environments" often end up being a pain.
-#
-# This is not part of CFLAGS because perhaps not all C compilers have this
-# option.
-CC= cc -systype sysv
-
 RANLIB = true
diff --git a/config/mh-sco b/config/mh-sco
index cc337c9..574b92a 100644
--- a/config/mh-sco
+++ b/config/mh-sco
@@ -1,10 +1,5 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV
 RANLIB = true
 # You may need this if you don't have bison.
 # BISON = yacc -Sm10400
-# The native C compiler botches some simple uses of const.  Unfortunately,
-# it doesn't defined anything like "__sco__" for us to test for in ansidecl.h.
-CC = cc -Dconst=
 
 X11_EXTRA_LIBS = -lsocket -lm -lintl -lmalloc
diff --git a/config/mh-solaris b/config/mh-solaris
index ddbea54..16553c5 100644
--- a/config/mh-solaris
+++ b/config/mh-solaris
@@ -1,6 +1,5 @@
 # Makefile changes for Suns running Solaris 2
 
-SYSV = -DSYSV
 RANLIB = true
 
 X11_EXTRA_LIBS = -lnsl -lsocket
diff --git a/config/mh-sun3 b/config/mh-sun3
deleted file mode 100644
index dcd5155..0000000
--- a/config/mh-sun3
+++ /dev/null
@@ -1,3 +0,0 @@
-# Sun's C compiler needs the -J flag to be able to compile cp-parse.c
-# without overflowing the jump tables (-J says to use a 32 bit table)
-CC = cc -J
diff --git a/config/mh-sysv b/config/mh-sysv
index 16b1187..4003002 100644
--- a/config/mh-sysv
+++ b/config/mh-sysv
@@ -1,3 +1 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV
 RANLIB = true
diff --git a/config/mh-sysv4 b/config/mh-sysv4
index 8106651..3634950 100644
--- a/config/mh-sysv4
+++ b/config/mh-sysv4
@@ -1,10 +1,5 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4
 RANLIB = true
 
-# C++ debugging is not yet supported under SVR4 (DWARF)
-CXXFLAGS=-O
-
 # The l flag generates a warning from the SVR4 archiver, remove it.
 AR_FLAGS = cr
 
diff --git a/config/mh-sysv5 b/config/mh-sysv5
index 1fa38e5..3634950 100644
--- a/config/mh-sysv5
+++ b/config/mh-sysv5
@@ -1,5 +1,3 @@
-# Define SYSV as -DSYSV if you are using a System V operating system.
-SYSV = -DSYSV -DSVR4 -DSVR5
 RANLIB = true
 
 # The l flag generates a warning from the SVR4 archiver, remove it.
diff --git a/config/mh-vaxult2 b/config/mh-vaxult2
deleted file mode 100644
index 3de2dc8..0000000
--- a/config/mh-vaxult2
+++ /dev/null
@@ -1,2 +0,0 @@
-# The old BSD pcc isn't up to compiling parts of gdb so use gcc
-CC = gcc
diff --git a/config/mt-aix43 b/config/mt-aix43
index 9eb750c..0c6627f 100644
--- a/config/mt-aix43
+++ b/config/mt-aix43
@@ -1,4 +1,4 @@
 # AIX 4.3 and above requires -X32_64 flag to all ar and nm commands
 # to handle both 32-bit and 64-bit objects.
 AR_FOR_TARGET=ar -X32_64
-NM_FOR_TARGET=nm -X32_64
+NM_FOR_TARGET=nm -B -X32_64
diff --git a/config/mt-alphaieee b/config/mt-alphaieee
new file mode 100644
index 0000000..9c20531
--- /dev/null
+++ b/config/mt-alphaieee
@@ -0,0 +1,2 @@
+CFLAGS_FOR_TARGET += -mieee
+CXXFLAGS_FOR_TARGET += -mieee
diff --git a/config/mt-armpic b/config/mt-armpic
deleted file mode 100644
index 35b8c9e..0000000
--- a/config/mt-armpic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-elfalphapic b/config/mt-elfalphapic
deleted file mode 100644
index 35b8c9e..0000000
--- a/config/mt-elfalphapic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-i370pic b/config/mt-i370pic
deleted file mode 100644
index 35b8c9e..0000000
--- a/config/mt-i370pic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-ia64pic b/config/mt-ia64pic
deleted file mode 100644
index ff98727..0000000
--- a/config/mt-ia64pic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fpic
diff --git a/config/mt-linux b/config/mt-linux
index a09e6f1..15bf417 100644
--- a/config/mt-linux
+++ b/config/mt-linux
@@ -1,2 +1 @@
-# When using glibc 2 on Linux we must always use vtable thunks.
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -fvtable-thunks -D_GNU_SOURCE
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -D_GNU_SOURCE
diff --git a/config/mt-m68kpic b/config/mt-m68kpic
deleted file mode 100644
index ff98727..0000000
--- a/config/mt-m68kpic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fpic
diff --git a/config/mt-papic b/config/mt-papic
deleted file mode 100644
index 35b8c9e..0000000
--- a/config/mt-papic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-ppcpic b/config/mt-ppcpic
deleted file mode 100644
index 35b8c9e..0000000
--- a/config/mt-ppcpic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fPIC
diff --git a/config/mt-s390pic b/config/mt-s390pic
deleted file mode 100644
index ff98727..0000000
--- a/config/mt-s390pic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fpic
diff --git a/config/mt-sparcpic b/config/mt-sparcpic
deleted file mode 100644
index a62b38b..0000000
--- a/config/mt-sparcpic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=`case '${LIBCFLAGS} ${LIBCXXFLAGS}' in *-fpic* ) echo -fpic ;; * ) echo -fPIC ;; esac`
diff --git a/config/mt-x86pic b/config/mt-x86pic
deleted file mode 100644
index ff98727..0000000
--- a/config/mt-x86pic
+++ /dev/null
@@ -1 +0,0 @@
-PICFLAG_FOR_TARGET=-fpic
diff --git a/configure b/configure
index 9a8b197..30446a2 100755
--- a/configure
+++ b/configure
@@ -3,7 +3,7 @@
 ### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
 
 # Configuration script
-# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -53,6 +53,9 @@
 configdirs=
 extraconfigdirs=
 diroptions=
+enable_threads=no
+enable_shared=no
+enable_libstdcxx_v3=yes
 exec_prefix=
 exec_prefixoption=
 fatal=
@@ -152,13 +155,17 @@
 if [ -n "$PWD" ]; then PWD=`pwd`; fi
 
 case "${progname}" in
-/*) ;;
+/* | [A-Za-z]:[\\/]* ) ;;
 */*) ;;
 *)
         PATH=$PATH:${PWD=`pwd`} ; export PATH
         ;;
 esac
 
+# Export original configure arguments for use by sub-configures.
+TOPLEVEL_CONFIGURE_ARGUMENTS="$progname $@"
+export TOPLEVEL_CONFIGURE_ARGUMENTS
+
 # Loop over all args
 
 while :
@@ -656,13 +663,15 @@
 esac
 
 # keep this filename short for &%*%$*# 14 char file names and 8+3 file names
-tmpfile=${TMPDIR}/cNf$$
+tmpdir=${TMPDIR}/cNf$$
+mkdir ${tmpdir} || exit 1
+tmpfile=${tmpdir}/cNf$$
 # Note that under many versions of sh a trap handler for 0 will *override* any
 # exit status you explicitly specify!  At this point, the only non-error exit
 # is at the end of the script; these actions are duplicated there, minus
 # the "exit 1".  Don't use "exit 0" anywhere after this without resetting the
 # trap handler, or you'll lose.
-trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
+trap "rm -rf Makefile.tem ${tmpdir}; exit 1" 0 1 2 15
 
 # split ${srcdir}/configure.in into common, per-host, per-target,
 # and post-target parts.  Post-target is optional.
@@ -689,7 +698,7 @@
 	# Perform the same cleanup as the trap handler, minus the "exit 1" of course,
 	# and reset the trap handler.
 	trap 0
-	rm -f Makefile* ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
+	rm -rf Makefile* ${tmpdir}
 	# Execute the final clean-up actions
 	${config_shell} skip-this-dir
 	# and stop configuring this directory.
@@ -907,7 +916,7 @@
   # are not the same, we set reasonable default values for the tools.
 
   tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
-  tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET"
+  tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET GCJ_FOR_TARGET"
   tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET GCC_FOR_TARGET HOST_PREFIX"
   tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
   tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
@@ -942,6 +951,7 @@
   CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
   CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
   CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-c++}
+  GCJ_FOR_TARGET=${GCJ_FOR_TARGET-${target_alias}-gcj}
   DLLTOOL=${DLLTOOL-${host_alias}-dlltool}
   DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool}
   GCC_FOR_TARGET=${GCC_FOR_TARGET-${CC_FOR_TARGET-${target_alias}-gcc}}
@@ -1095,7 +1105,7 @@
     case "${srcdir}" in
         ".")  # no -srcdir option.  We're building in place.
                 makesrcdir=. ;;
-        /*) # absolute path
+        /* | [A-Za-z]:[\\/]* ) # absolute path
                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
                 ;;
         *) # otherwise relative
@@ -1291,7 +1301,7 @@
             esac
             # real copy now in ${subdir}/Makefile.tem
 
-            # prepend warning about editting, and a bunch of variables.
+            # prepend warning about editing, and a bunch of variables.
             rm -f ${Makefile}
             cat > ${Makefile} <<EOF
 # ${NO_EDIT}
@@ -1321,19 +1331,19 @@
 
             case "${package_makefile_frag}" in
               "") ;;
-              /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
+              /* | [A-Za-z]:[\\/]* ) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
             esac
 
             case "${target_makefile_frag}" in
               "") ;;
-              /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
+              /* | [A-Za-z]:[\\/]* ) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
             esac
 
             case "${host_makefile_frag}" in
               "") ;;
-              /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
+              /* | [A-Za-z]:[\\/]* ) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
             esac
 
@@ -1341,12 +1351,8 @@
                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
             fi 
 
-	    # record if we want to build shared libs.
-	    if test -z "${enable_shared}"; then
-	        echo enable_shared = no >> ${Makefile}
-	    else
-	        echo enable_shared = ${enable_shared} >> ${Makefile}
-	    fi
+	    echo enable_shared = ${enable_shared} >> ${Makefile}
+	    echo enable_threads = ${enable_threads} >> ${Makefile}
 	    # record if we want to rumtime library stuff installed in libsubdir.
 	    if test -z "${enable_version_specific_runtime_libs}"; then
 	        echo enable_version_specific_runtime_libs = no >> ${Makefile}
@@ -1364,9 +1370,14 @@
             # remove any form feeds.
             if [ -z "${subdirs}" ]; then
                 rm -f ${subdir}/Makefile.tm2
-                sed -e "s:^SUBDIRS[ 	]*=.*$:SUBDIRS = ${configdirs}:" \
-                    -e "s:^NONSUBDIRS[ 	]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
+                sedtemp=sed.$$
+                cat >$sedtemp <<EOF
+s:^SUBDIRS[ 	]*=.*$:SUBDIRS = ${configdirs}:
+s:^NONSUBDIRS[ 	]*=.*$:NONSUBDIRS = ${noconfigdirs}:
+EOF
+                sed -f $sedtemp \
                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tm2
+                rm -f $sedtemp
                 rm -f ${subdir}/Makefile.tem
                 mv ${subdir}/Makefile.tm2 ${subdir}/Makefile.tem
 	    fi
@@ -1549,11 +1560,7 @@
 ### figure out what to do with srcdir
                         case "${srcdir}" in
                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
-                        /*) # absolute path
-                                newsrcdir=${srcdir}/${cfg_dir}
-                                srcdiroption="--srcdir=${newsrcdir}"
-                                ;;
-                        ?:*) # absolute path on win32
+                        /* | [A-Za-z]:[\\/]* ) # absolute path
                                 newsrcdir=${srcdir}/${cfg_dir}
                                 srcdiroption="--srcdir=${newsrcdir}"
                                 ;;
@@ -1567,10 +1574,7 @@
 			case "${cache_file}" in
 			"") # empty
 				;;
-			/*) # absolute path
-				cache_file_option="--cache-file=${cache_file}"
-				;;
-			?:*) # absolute path on win32
+			/* | [A-Za-z]:[\\/]* ) # absolute path
 				cache_file_option="--cache-file=${cache_file}"
 				;;
 			*) # relative path
@@ -1583,9 +1587,8 @@
                                 recprog=${newsrcdir}/configure
                         elif [ -f ${newsrcdir}/configure.in ] ; then
                                 case "${progname}" in
-                                /*)     recprog=${progname} ;;
-                                ?:*)    recprog=${progname} ;;
-                                *)      recprog=../${progname} ;;
+                                /* | [A-Za-z]:[\\/]* )  recprog=${progname} ;;
+                                *)                      recprog=../${progname} ;;
                                 esac
 			else
 				eval echo No configuration information in ${cfg_dir} ${redirect}
@@ -1611,7 +1614,7 @@
 
 # Perform the same cleanup as the trap handler, minus the "exit 1" of course,
 # and reset the trap handler.
-rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
+rm -rf ${tmpdir}
 trap 0
 
 exit 0
diff --git a/configure.in b/configure.in
index baf9d73..2569cc2 100644
--- a/configure.in
+++ b/configure.in
@@ -14,7 +14,8 @@
 ## For more information on these two systems, check out the documentation
 ## for 'Autoconf' (autoconf.texi) and 'Configure' (configure.texi).  
 
-#   Copyright (C) 1992-99, 2000, 2001 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+#   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 #
 # 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
@@ -41,11 +42,7 @@
 
 # these libraries are used by various programs built for the host environment
 #
-host_libs="intl mmalloc libiberty opcodes bfd readline gash db tcl tk tcl8.1 tk8.1 tclX itcl tix libgui"
-
-if [ "${enable_gdbgui}" = "yes" ] ; then
-	host_libs="${host_libs} libgui"
-fi
+host_libs="intl mmalloc libiberty opcodes bfd readline db tcl tk tcl8.1 tk8.1 tclX itcl tix libgui zlib"
 
 libstdcxx_version="target-libstdc++-v3"
 # Don't use libstdc++-v3's flags to configure/build itself.
@@ -54,7 +51,14 @@
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
 # know that we are building the simulator.
-host_tools="texinfo byacc flex bison binutils ld gas gcc cgen sid sim gdb make patch prms send-pr gprof gdbtest tgas etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool ispell grep diff rcs cvssrc fileutils shellutils time textutils wdiff find emacs emacs19 uudecode hello tar gzip indent recode release sed utils guile perl apache inet gawk findutils snavigator libtool gettext zip"
+host_tools="texinfo byacc flex bison binutils ld gas gcc cgen sid sim gdb make patch prms send-pr gprof gdbtest tgas etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool ispell grep diff rcs cvssrc fileutils shellutils time textutils wdiff find emacs emacs19 uudecode hello tar gzip indent recode release sed utils guile perl apache inet gawk findutils snavigator libtool gettext zip fastjar"
+
+# libgcj represents the runtime libraries only used by gcj.
+libgcj="target-libffi \
+	target-boehm-gc \
+	target-zlib \
+	target-qthreads \
+	target-libjava"
 
 # these libraries are built for the target environment, and are built after
 # the host libraries and the host tools (which may be a cross compiler)
@@ -62,14 +66,10 @@
 target_libs="target-libiberty \
 		target-libgloss \
 		target-newlib \
+		target-librx \
 		${libstdcxx_version} \
 		target-libf2c \
-		target-libchill \
-		target-libffi \
-		target-libjava \
-		target-zlib \
-		target-boehm-gc \
-		target-qthreads \
+		${libgcj}
 		target-libobjc"
 
 # these tools are built using the target libs, and are intended to run only
@@ -93,7 +93,7 @@
 #
 # This must be a single line because of the way it is searched by grep in
 # the code below.
-native_only="autoconf automake libtool cvssrc emacs emacs19 fileutils find gawk gettext grep gzip hello indent ispell m4 rcs recode sed shellutils tar textutils gash uudecode wdiff gprof target-groff guile perl apache inet time ash bash bzip2 prms snavigator gnuserv target-gperf"
+native_only="autoconf automake libtool cvssrc emacs emacs19 fileutils find gawk gettext grep gzip hello indent ispell m4 rcs recode sed shellutils tar textutils uudecode wdiff gprof target-groff guile perl apache inet time ash bash bzip2 prms snavigator gnuserv target-gperf"
 
 # directories to be built in a cross environment only
 #
@@ -119,30 +119,47 @@
 # per-host:
 
 # Work in distributions that contain no compiler tools, like Autoconf.
-if [ -d ${srcdir}/config ]; then
+tentative_cc=""
+if test -d ${srcdir}/config ; then
 case "${host}" in
   m68k-hp-hpux*)
+    # Avoid "too much defining" errors from HPUX compiler.
+    tentative_cc="cc -Wp,-H256000"
     host_makefile_frag="${host_makefile_frag} config/mh-hp300"
     ;;
   m68k-apollo-sysv*)
+    tentative_cc="cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DUSG"
     host_makefile_frag="${host_makefile_frag} config/mh-apollo68"
     ;;
   m68k-apollo-bsd*)
+    #None of the Apollo compilers can compile gas or binutils.  The preprocessor
+    # chokes on bfd, the compiler won't let you assign integers to enums, and
+    # other problems.  Defining CC to gcc is a questionable way to say "don't use
+    # the apollo compiler" (the preferred version of GCC could be called cc,
+    # or whatever), but I'm not sure leaving CC as cc is any better...
+    #CC=cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DNO_STDARG
+    tentative_cc=gcc
     host_makefile_frag="${host_makefile_frag} config/mh-a68bsd"
     ;;
   m88k-dg-dgux*)
+    tentative_cc="gcc -Wall -ansi -D__using_DGUX"
     host_makefile_frag="${host_makefile_frag} config/mh-dgux"
     ;;
   m88k-harris-cxux*)
+    # Under CX/UX, we want to tell the compiler to use ANSI mode.
+    tentative_cc="cc -Xa"
     host_makefile_frag="${host_makefile_frag} config/mh-cxux"
     ;;
   m88k-motorola-sysv*)
     host_makefile_frag="${host_makefile_frag} config/mh-delta88"
     ;;
   mips*-dec-ultrix*)
+    tentative_cc="cc -Wf,-XNg1000"
     host_makefile_frag="${host_makefile_frag} config/mh-decstation"
     ;;
   mips*-nec-sysv4*)
+    # The C compiler on NEC MIPS SVR4 needs bigger tables.
+    tentative_cc="cc -ZXNd=5000 -ZXNg=1000"
     host_makefile_frag="${host_makefile_frag} config/mh-necv4"
     ;;
   mips*-sgi-irix6*)
@@ -152,7 +169,10 @@
     host_makefile_frag="${host_makefile_frag} config/mh-irix5"
     ;;
   mips*-sgi-irix4*)
-    host_makefile_frag="${host_makefile_frag} config/mh-irix4"
+    # Tell compiler to use K&R C.  We can't compile under the SGI Ansi
+    # environment.  Also bump switch table size so that cp-parse will
+    # compile.  Bump string length limit so linker builds.
+    tentative_cc="cc -cckr -Wf,-XNg1500 -Wf,-XNk1000 -Wf,-XNh2000 -Wf,-XNl8192"
     ;;
   mips*-sgi-irix3*)
     host_makefile_frag="${host_makefile_frag} config/mh-sysv"
@@ -161,27 +181,54 @@
     host_makefile_frag="${host_makefile_frag} config/mh-sysv4"
     ;;
   mips*-*-sysv*)
+    # This is for a MIPS running RISC/os 4.52C.
+
+    # This is needed for GDB, but needs to be in the top-level make because
+    # if a library is compiled with the bsd headers and gets linked with the
+    # sysv system libraries all hell can break loose (e.g. a jmp_buf might be
+    # a different size).
+    # ptrace(2) apparently has problems in the BSD environment.  No workaround is
+    # known except to select the sysv environment.  Could we use /proc instead?
+    # These "sysv environments" and "bsd environments" often end up being a pain.
+    #
+    # This is not part of CFLAGS because perhaps not all C compilers have this
+    # option.
+    tentative_cc="cc -systype sysv"
     host_makefile_frag="${host_makefile_frag} config/mh-riscos"
     ;;
   i370-ibm-opened*)
+    tentative_cc="c89"
     host_makefile_frag="${host_makefile_frag} config/mh-openedition"
     ;;
   i[3456]86-*-sysv5*)
     host_makefile_frag="${host_makefile_frag} config/mh-sysv5"
     ;;
   i[3456]86-*-dgux*)
+    tentative_cc="gcc -Wall -ansi -D__using_DGUX"
     host_makefile_frag="${host_makefile_frag} config/mh-dgux386"
     ;;
   i[3456]86-ncr-sysv4.3*)
+    # The MetaWare compiler will generate a copyright message unless you
+    # turn it off by adding the -Hnocopyr flag.
+    tentative_cc="cc -Hnocopyr"
     host_makefile_frag="${host_makefile_frag} config/mh-ncrsvr43"
     ;;
   i[3456]86-ncr-sysv4*)
+    # for an NCR 3000 (i486/SVR4) system.
+    # The NCR 3000 ships with a MetaWare compiler installed as /bin/cc.
+    # This compiler not only emits obnoxious copyright messages every time
+    # you run it, but it chokes and dies on a whole bunch of GNU source
+    # files.  Default to using the AT&T compiler installed in /usr/ccs/ATT/cc.
+    tentative_cc="/usr/ccs/ATT/cc"
     host_makefile_frag="${host_makefile_frag} config/mh-ncr3000"
     ;;
   i[3456]86-*-sco3.2v5*)
     host_makefile_frag="${host_makefile_frag} config/mh-sysv"
     ;;
   i[3456]86-*-sco*)
+    # The native C compiler botches some simple uses of const.  Unfortunately,
+    # it doesn't defined anything like "__sco__" for us to test for in ansidecl.h.
+    tentative_cc="cc -Dconst="
     host_makefile_frag="${host_makefile_frag} config/mh-sco"
     ;;
   i[3456]86-*-udk*)
@@ -208,32 +255,38 @@
   *-interix*)
     host_makefile_frag="${host_makefile_frag} config/mh-interix"
     ;;
-  *-windows*)
-    host_makefile_frag="${host_makefile_frag} config/mh-windows"
-    ;;
   vax-*-ultrix2*)
-    host_makefile_frag="${host_makefile_frag} config/mh-vaxult2"
+    # The old BSD pcc isn't up to compiling parts of gdb so use gcc
+    tentative_cc=gcc
     ;;
   *-*-solaris2*)
     host_makefile_frag="${host_makefile_frag} config/mh-solaris"
     ;;
   m68k-sun-sunos*)
-    host_makefile_frag="${host_makefile_frag} config/mh-sun3"
+    # Sun's C compiler needs the -J flag to be able to compile cp-parse.c
+    # without overflowing the jump tables (-J says to use a 32 bit table)
+    tentative_cc="cc -J"
     ;;
   *-hp-hpux[78]*)
+    tentative_cc="cc -Wp,-H256000"
     host_makefile_frag="${host_makefile_frag} config/mh-hpux8"
     ;;
   *-hp-hpux*)
+    tentative_cc="cc -Wp,-H256000"
     host_makefile_frag="${host_makefile_frag} config/mh-hpux"
     ;;
   *-*-hiux*)
+    tentative_cc="cc -Wp,-H256000"
     host_makefile_frag="${host_makefile_frag} config/mh-hpux"
     ;;
   rs6000-*-lynxos*)
+    # /bin/cc is less than useful for our purposes.  Always use GCC
+    tentative_cc="/usr/cygnus/progressive/bin/gcc"
     host_makefile_frag="${host_makefile_frag} config/mh-lynxrs6k"
     ;;
   *-*-lynxos*)
-    host_makefile_frag="${host_makefile_frag} config/mh-lynxos"
+    # /bin/cc is less than useful for our purposes.  Always use GCC
+    tentative_cc="/bin/gcc"
     ;;
   *-*-sysv4*)
     host_makefile_frag="${host_makefile_frag} config/mh-sysv4"
@@ -246,7 +299,8 @@
 
 # If we aren't going to be using gcc, see if we can extract a definition
 # of CC from the fragment.
-if [ -z "${CC}" ] && [ "${build}" = "${host}" ]; then
+# Actually, use the 'pre-extracted' version above.
+if test -z "${CC}" && test "${build}" = "${host}" ; then
   IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
   found=
   for dir in $PATH; do
@@ -257,17 +311,14 @@
     fi
   done
   IFS="$save_ifs"
-  if [ -z "${found}" ] && [ -n "${host_makefile_frag}" ] && [ -f "${srcdir}/${host_makefile_frag}" ]; then
-    xx=`sed -n -e 's/^[ 	]*CC[ 	]*=[ 	]*\(.*\)$/\1/p' < ${srcdir}/${host_makefile_frag}`
-    if [ -n "${xx}" ] ; then
-      CC=$xx
-    fi
+  if test -z "${found}" && test -n "${tentative_cc}" ; then
+    CC=$tentative_cc
   fi
 fi
 
 # We default to --with-shared on platforms where -fpic is meaningless.
 # Well, we don't yet, but we will.
-if false && [ "${host}" = "${target}" ] && [ x${enable_shared} = x ]; then
+if false && test "${host}" = "${target}" && test x${enable_shared} = x ; then
   case "${target}" in
     alpha*-dec-osf*)	enable_shared=yes ;;
     alpha*-*-linux*)	enable_shared=yes ;;
@@ -276,6 +327,14 @@
   esac
 fi
 
+# hpux11 in 64bit mode has libraries in a weird place.  Arrange to find
+# them automatically.
+case "${host}" in
+  hppa*64*-*-hpux11*)	
+    withoptions="$withoptions -x-libraries=/usr/lib/pa20_64 -x-includes=/usr/X11R6/include"
+    ;;
+esac
+
 case "${enable_shared}" in
   yes) shared=yes ;;
   no) shared=no ;;
@@ -283,51 +342,8 @@
   *) shared=yes ;;
 esac
 
-if [ x${shared} = xyes ]; then
-  case "${host}" in
-    alpha*-*-linux*)
-      host_makefile_frag="${host_makefile_frag} config/mh-elfalphapic"
-      ;;
-    arm*-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-armpic"
-      ;;
-    hppa*-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-papic"
-      ;;
-    i[3456]86-*-cygwin*)
-      # We don't want -fPIC on Cygwin.
-      ;;
-    i[3456]86-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-x86pic"
-      ;;
-    i370-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-i370pic"
-      ;;
-    ia64-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-ia64pic"
-      ;;
-    sparc64-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-sparcpic"
-      ;;
-    powerpc*-*-aix*)
-      # We don't want -fPIC on AIX.
-      ;;
-    powerpc*-*-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-ppcpic"
-      ;;
-    s390-* | s390x-*)
-      host_makefile_frag="${host_makefile_frag} config/mh-s390pic"
-      ;;
-    *-*-*)
-      if test -f ${srcdir}/config/mh-${host_cpu}pic; then
-        host_makefile_frag="${host_makefile_frag} config/mh-${host_cpu}pic"
-      fi
-      ;;
-  esac
-fi
-
 rm -f mh-frag
-if [ -n "${host_makefile_frag}" ] ; then
+if test -n "${host_makefile_frag}" ; then
   for f in ${host_makefile_frag}
   do
     cat ${srcdir}/$f >> mh-frag
@@ -347,7 +363,14 @@
   powerpc-*-netware*)
     target_makefile_frag="${target_makefile_frag} config/mt-netware"
     ;;
-  *-*-linux-gnu*)
+  alpha*-*-linux*)
+    target_makefile_frag="${target_makefile_frag} config/mt-linux"
+    target_makefile_frag="${target_makefile_frag} config/mt-alphaieee"
+    ;;
+  alpha*-*-*)
+    target_makefile_frag="${target_makefile_frag} config/mt-alphaieee"
+    ;;
+  *-*-linux*)
     target_makefile_frag="${target_makefile_frag} config/mt-linux"
     ;;
   *-*-aix4.[3456789]* | *-*-aix[56789].*)
@@ -390,7 +413,7 @@
   yes | "")  # the default value for this tree is that X11 is available
 	;;
   no)
-	skipdirs="${skipdirs} tk libgui gash"
+	skipdirs="${skipdirs} tk libgui"
 	;;
   *)
     	echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2
@@ -404,7 +427,7 @@
 
 is_cross_compiler=
 
-if [ x"${host}" = x"${target}" ] ; then
+if test x"${host}" = x"${target}" ; then
 	# when doing a native toolchain, don't build the targets
 	# that are in the 'cross only' list
 	skipdirs="${skipdirs} ${cross_only}"
@@ -420,7 +443,7 @@
 # can reliably find it.
 target_subdir=${target_alias}
 
-if [ ! -d ${target_subdir} ] ; then
+if test ! -d ${target_subdir} ; then
   if mkdir ${target_subdir} ; then true
   else
     echo "'*** could not make ${PWD=`pwd`}/${target_subdir}" 1>&2
@@ -430,8 +453,8 @@
 
 build_subdir=${build_alias}
 
-if [ x"${build_alias}" != x"${host}" ] ; then
-  if [ ! -d ${build_subdir} ] ; then
+if test x"${build_alias}" != x"${host}" ; then
+  if test ! -d ${build_subdir} ; then
     if mkdir ${build_subdir} ; then true
     else
       echo "'*** could not make ${PWD=`pwd`}/${build_subdir}" 1>&2
@@ -444,8 +467,8 @@
 
 # Handle --with-headers=XXX.  The contents of the named directory are
 # copied to $(tooldir)/sys-include.
-if [ x"${with_headers}" != x ]; then
-  if [ x${is_cross_compiler} = xno ]; then
+if test x"${with_headers}" != x ; then
+  if test x${is_cross_compiler} = xno ; then
     echo 1>&2 '***' --with-headers is only supported when cross compiling
     exit 1
   fi
@@ -458,8 +481,8 @@
 
 # Handle --with-libs=XXX.  Multiple directories are permitted.  The
 # contents are copied to $(tooldir)/lib.
-if [ x"${with_libs}" != x ]; then
-  if [ x${is_cross_compiler} = xno ]; then
+if test x"${with_libs}" != x ; then
+  if test x${is_cross_compiler} = xno ; then
     echo 1>&2 '***' --with-libs is only supported when cross compiling
     exit 1
   fi
@@ -476,21 +499,21 @@
 
 # If both --with-headers and --with-libs are specified, default to
 # --without-newlib.
-if [ x"${with_headers}" != x ] && [ x"${with_libs}" != x ]; then
-  if [ x"${with_newlib}" = x ]; then
+if test x"${with_headers}" != x && test x"${with_libs}" != x ; then
+  if test x"${with_newlib}" = x ; then
     with_newlib=no
   fi
 fi
 
 # Recognize --with-newlib/--without-newlib.
-if [ x${with_newlib} = xno ]; then
+if test x${with_newlib} = xno ; then
   skipdirs="${skipdirs} target-newlib"
-elif [ x${with_newlib} = xyes ]; then
+elif test x${with_newlib} = xyes ; then
   skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
 fi
 
 # Default to using --with-stabs for certain targets.
-if [ x${with_stabs} = x ]; then
+if test x${with_stabs} = x ; then
   case "${target}" in
   mips*-*-irix6*)
     ;;
@@ -504,15 +527,15 @@
 # Handle ${copy_dirs}
 set fnord ${copy_dirs}
 shift
-while [ $# != 0 ]; do
-  if [ -f $2/COPIED ] && [ x"`cat $2/COPIED`" = x"$1" ]; then
+while test $# != 0 ; do
+  if test -f $2/COPIED && test x"`cat $2/COPIED`" = x"$1" ; then
     :
   else
     echo Copying $1 to $2
 
     # Use the install script to create the directory and all required
     # parent directories.
-    if [ -d $2 ]; then
+    if test -d $2 ; then
       :
     else
       echo >config.temp
@@ -550,11 +573,14 @@
 noconfigdirs=""
 
 case "${host}" in
+  hppa*64*-*-*)
+    noconfigdirs="$noconfigdirs byacc"
+    ;;
   i[3456]86-*-vsta)
     noconfigdirs="tcl expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff guile perl apache inet itcl tix db snavigator gnuserv gettext"
     ;;
   i[3456]86-*-go32* | i[3456]86-*-msdosdjgpp*)
-    noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr uudecode dejagnu diff guile perl apache inet itcl tix db snavigator gnuserv gettext libffi"
+    noconfigdirs="tcl tk expect dejagnu send-pr uudecode guile apache inet itcl tix db snavigator gnuserv libffi"
 	;;
   i[3456]86-*-mingw32*)
     # noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr uudecode dejagnu diff guile perl apache inet itcl tix db snavigator gnuserv"
@@ -577,7 +603,6 @@
     ;;
 esac
 
-
 # Save it here so that, even in case of --enable-libgcj, if the Java
 # front-end isn't enabled, we still get libgcj disabled.
 libgcj_saved=$libgcj
@@ -595,25 +620,38 @@
 esac
 
 case "${target}" in
+  *-*-chorusos)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
+    ;;
+  *-*-freebsd[12] | *-*-freebsd[12].* | *-*-freebsd*aout*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
+    ;;
   *-*-netbsd*)
     # Skip some stuff on all NetBSD configurations.
     skipdirs="$skipdirs target-newlib target-libiberty target-libgloss"
 
     # Skip some stuff that's unsupported on some NetBSD configurations.
     case "${target}" in
+      i*86-*-netbsdelf*) ;;
       *)
-        noconfigdirs="$noconfigdirs ${libgcj}"
+	noconfigdirs="$noconfigdirs ${libgcj}"
 	;;
     esac
     ;;
   *-*-netware)
-    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-newlib target-libiberty target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-librx target-newlib target-libiberty target-libgloss ${libgcj}"
     ;;
   *-*-rtems*)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
+    case ${target} in
+	h8300*-*-* | h8500-*-*)
+	  noconfigdirs="$noconfigdirs target-libf2c"
+          ;;
+        *) ;;
+    esac
     ;;
   *-*-vxworks*)
-    noconfigdirs="$noconfigdirs target-newlib target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
     ;;
   alpha*-dec-osf*)
     # ld works, but does not support shared libraries.  emacs doesn't
@@ -622,15 +660,29 @@
     noconfigdirs="$noconfigdirs gas ld emacs fileutils target-newlib target-libgloss"
     ;;
   alpha*-*-*vms*)
-    noconfigdirs="$noconfigdirs gdb ld target-newlib target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs gdb ld target-newlib target-libgloss ${libgcj}"
+    ;;
+  alpha*-*-linux*)
+    # newlib is not 64 bit ready
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    # linux has rx in libc
+    skipdirs="$skipdirs target-librx"
+    ;;
+  alpha*-*-freebsd*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
   alpha*-*-*)
     # newlib is not 64 bit ready
-    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
     ;;
+  sh-*-linux*)
+    noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss"
+    # linux has rx in libc
+    skipdirs="$skipdirs target-librx"
+    ;;    
   sh*-*-pe|mips*-*-pe|*arm-wince-pe)
-    noconfigdirs="$noconfigdirs target-libjava target-libffi target-zlib"
-    noconfigdirs="$noconfigdirs target-boehm-gc target-qthreads target-examples"
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    noconfigdirs="$noconfigdirs target-examples"
     noconfigdirs="$noconfigdirs target-libiberty texinfo send-pr"
     noconfigdirs="$noconfigdirs tcl tix tk itcl libgui sim"
     noconfigdirs="$noconfigdirs expect dejagnu"
@@ -644,66 +696,59 @@
     esac
     ;;
   arc-*-*)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   arm-*-pe*)
-    noconfigdirs="$noconfigdirs target-libgloss"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   arm-*-oabi*)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   thumb-*-coff)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   thumb-*-elf)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   thumb-*-oabi)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   strongarm-*-elf)
-    noconfigdirs="$noconfigdirs target-libffi"
-    if [ x${is_cross_compiler} != xno ] ; then
-	   target_configdirs="${target_configdirs} target-bsp target-cygmon"
-    fi
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   strongarm-*-coff)
-    noconfigdirs="$noconfigdirs target-libffi"
-    if [ x${is_cross_compiler} != xno ] ; then
-	   target_configdirs="${target_configdirs} target-bsp target-cygmon"
-    fi
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   xscale-*-elf)
-    noconfigdirs="$noconfigdirs target-libffi"
-    if [ x${is_cross_compiler} != xno ] ; then
-	   target_configdirs="${target_configdirs} target-bsp target-cygmon"
-    fi
+    noconfigdirs="$noconfigdirs target-libffi target-qthreads"
     ;;
   xscale-*-coff)
-    noconfigdirs="$noconfigdirs target-libffi"
-    if [ x${is_cross_compiler} != xno ] ; then
-	   target_configdirs="${target_configdirs} target-bsp target-cygmon"
-    fi
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   thumb-*-pe)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   arm-*-riscix*)
-    noconfigdirs="$noconfigdirs ld target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ld target-libgloss ${libgcj}"
     ;;
   c4x-*-*)
-    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-librx target-libgloss ${libgcj}"
     ;;
   c54x*-*-* | tic54x-*-*)
-    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-libgloss target-libffi gcc gdb newlib"
+    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-libgloss ${libgcj} gcc gdb newlib"
+    ;;
+  cris-*-*)
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   d10v-*-*)
-    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-librx ${libstdcxx_version} target-libgloss ${libgcj}"
     ;;
   d30v-*-*)
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   fr30-*-elf*)
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
     fi
     ;;
@@ -711,12 +756,19 @@
     noconfigdirs="$noconfigdirs target-libgloss"
     ;;
   h8500-*-*)
-    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-librx target-libgloss ${libgcj} target-libf2c"
+    ;;
+  hppa*64*-*-linux* | parisc*64*-*-linux*)
+    # In this case, it's because the hppa64-linux target is for
+    # the kernel only at this point and has no libc, and thus no
+    # headers, crt*.o, etc., all of which are needed by these.
+    noconfigdirs="$noconfigdirs target-zlib"
     ;;
   hppa*-*-*elf* | \
-  hppa*-*-linux-gnu* | \
+  parisc*-*-linux* | hppa*-*-linux* | \
   hppa*-*-lites* | \
   hppa*64*-*-*)
+    noconfigdirs="$noconfigdirs ${libgcj}"
     # Do configure ld/binutils/gas for this case.
     ;;
   hppa*-*-*)
@@ -740,13 +792,38 @@
     noconfigdirs="$noconfigdirs tix readline mmalloc libgui itcl gdb ld"
     ;;
   i[3456]86-*-coff | i[3456]86-*-elf)
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
          target_configdirs="${target_configdirs} target-libstub target-cygmon"
     fi
     ;;
-  i[3456]86-*-go32* | i[3456]-*-msdosdjgpp*)
-    # but don't build gdb
-    noconfigdirs="$noconfigdirs gdb ${libstdcxx_version} target-libffi"
+  i[34567]86-*-freebsd*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    ;;
+  s390*-*-linux*)
+    # The libffi port is not yet in the GCC tree
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
+    # linux has rx in libc
+    skipdirs="$skipdirs target-librx"
+    ;;
+  i[3456]86-*-linux*)
+    # This section makes it possible to build newlib natively on linux.
+    # If we are using a cross compiler then don't configure newlib.
+    if test x${is_cross_compiler} != xno ; then
+         noconfigdirs="$noconfigdirs target-newlib"
+    fi
+    noconfigdirs="$noconfigdirs target-libgloss"
+    # If we are not using a cross compiler, do configure newlib.
+    # Note however, that newlib will only be configured in this situation
+    # if the --with-newlib option has been given, because otherwise
+    # 'target-newlib' will appear in skipdirs.
+    # linux has rx in libc
+    skipdirs="$skipdirs target-librx"
+    ;;
+  *-*-linux*)
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+    # linux has rx in libc
+    skipdirs="$skipdirs target-librx"
     ;;
   i[3456]86-*-mingw32*)
     target_configdirs="$target_configdirs target-mingw"
@@ -773,15 +850,15 @@
     esac
     ;;    
   i[3456]86-*-pe)
-    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ${libstdcxx_version} target-librx target-libgloss ${libgcj}"
     ;;
   i[3456]86-*-sco3.2v5*)
     # The linker does not yet know about weak symbols in COFF,
     # and is not configured to handle mixed ELF and COFF.
-    noconfigdirs="$noconfigdirs ld target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ld target-libgloss ${libgcj}"
     ;;
   i[3456]86-*-sco*)
-    noconfigdirs="$noconfigdirs gprof target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs gprof target-libgloss ${libgcj}"
     ;;
   i[3456]86-*-solaris2*)
     noconfigdirs="$noconfigdirs target-libgloss"
@@ -793,76 +870,88 @@
         *) ;;
     esac
     # but that's okay since emacs doesn't work anyway
-    noconfigdirs="$noconfigdirs emacs emacs19 target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs emacs emacs19 target-libgloss ${libgcj}"
     ;;
   i[3456]86-*-beos*)
      noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss ${libgcj}"
      ;;
- m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
-    noconfigdirs="$noconfigdirs target-libiberty target-librx target-libg++ target-libstdc++ target-libio target-libf2c target-libchill target-zlib target-libobjc"
+  m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
+    noconfigdirs="$noconfigdirs target-libiberty ${libstdcxx_version} ${libgcj}"
     ;;
- m68k-*-elf*)
-    if [ x${is_cross_compiler} != xno ] ; then
+  m68k-*-elf*)
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-bsp target-cygmon"
     fi
     ;;
   m68k-*-coff*)
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-bsp target-cygmon"
     fi
     ;;
+  mcore-*-pe*)
+  # The EPOC C++ environment does not support exceptions or rtti,
+  # and so building libstdc++-v3 tends not to always work.
+    noconfigdirs="$noconfigdirs target-libstdc++-v3"
+    ;;
+  mmix-*-*)
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    ;;
   mn10200-*-*)
-    noconfigdirs="$noconfigdirs target-libffi"
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-libstub target-cygmon"
     fi
     ;;
   mn10300-*-*)
-    noconfigdirs="$noconfigdirs target-libffi"
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
     fi
     ;;
   powerpc-*-aix*)
     # copied from rs6000-*-* entry
+    noconfigdirs="$noconfigdirs gprof cvssrc target-libgloss ${libgcj}"
     use_gnu_ld=yes
     ;;
   powerpc*-*-winnt* | powerpc*-*-pe* | ppc*-*-pe)
     target_configdirs="$target_configdirs target-winsup"
-    noconfigdirs="$noconfigdirs gdb tcl tk make expect target-libgloss itcl tix db snavigator gnuserv target-libffi"
+    noconfigdirs="$noconfigdirs gdb tcl tk make expect target-libgloss itcl tix db snavigator gnuserv ${libgcj}"
     # always build newlib.
     skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'`
     ;;
     # This is temporary until we can link against shared libraries
   powerpcle-*-solaris*)
-    noconfigdirs="$noconfigdirs gdb sim make tcl tk expect itcl tix db snavigator gnuserv target-libffi"
+    noconfigdirs="$noconfigdirs gdb sim make tcl tk expect itcl tix db snavigator gnuserv ${libgcj}"
     ;;
   powerpc-*-beos*)
-    noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
+    noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss ${libgcj}"
     ;;
   powerpc-*-eabi)
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
     fi
     ;;
   rs6000-*-lynxos*)
     # The CVS server code doesn't work on the RS/6000
-    noconfigdirs="$noconfigdirs target-newlib gprof cvssrc target-libffi"
+    noconfigdirs="$noconfigdirs target-newlib gprof cvssrc ${libgcj}"
     ;;
   rs6000-*-aix*)
-    noconfigdirs="$noconfigdirs gprof target-libffi"
+    noconfigdirs="$noconfigdirs gprof ${libgcj}"
     use_gnu_ld=yes
     ;;
   rs6000-*-*)
-    noconfigdirs="$noconfigdirs gprof target-libffi"
+    noconfigdirs="$noconfigdirs gprof ${libgcj}"
     ;;
   m68k-apollo-*)
-    noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss ${libgcj}"
     ;;
   mips*-*-irix5*)
     # The GNU linker does not support shared libraries.
     # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work)
-    noconfigdirs="$noconfigdirs ld gprof emacs target-libgloss"
+    noconfigdirs="$noconfigdirs ld gprof emacs target-libgloss ${libgcj}"
     ;;
   mips*-*-irix6*)
     # The GNU assembler does not support IRIX 6.
@@ -874,20 +963,23 @@
     noconfigdirs="$noconfigdirs gas gprof emacs target-libgloss ${libgcj}"
     ;;
   mips*-dec-bsd*)
-    noconfigdirs="$noconfigdirs gprof target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs gprof target-libgloss ${libgcj}"
     ;;
   mips*-*-bsd*)
-    noconfigdirs="$noconfigdirs gprof target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs gprof target-libgloss ${libgcj}"
     ;;
   mipstx39-*-*)
-    noconfigdirs="$noconfigdirs gprof target-libffi"   # same as generic mips
+    noconfigdirs="$noconfigdirs gprof ${libgcj}"   # same as generic mips
     target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
    ;;
+  mips*-*-linux*)
+    noconfigdirs="$noconfigdirs target-libffi"
+    ;;
   mips*-*-*)
-    noconfigdirs="$noconfigdirs gprof target-libffi"
+    noconfigdirs="$noconfigdirs gprof ${libgcj}"
     ;;
   romp-*-*)
-    noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}"
     ;;
   sh-*-*)
     case "${host}" in
@@ -896,73 +988,69 @@
       i[3456]86-*-msdosdjgpp*) ;; # don't add gprof back in
       *) skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'` ;;
     esac
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   sh64-*-*)
     noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   sparc-*-elf*)
-    if [ x${is_cross_compiler} != xno ] ; then
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-libstub target-cygmon"
     fi
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   sparc64-*-elf*)
-    if [ x${is_cross_compiler} != xno ] ; then
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-libstub target-cygmon"
     fi
-    noconfigdirs="$noconfigdirs target-libffi"
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   sparclite-*-*)
-    if [ x${is_cross_compiler} != xno ] ; then
+    if test x${is_cross_compiler} != xno ; then
 	   target_configdirs="${target_configdirs} target-bsp target-libstub target-cygmon"
     fi
-    noconfigdirs="$noconfigdirs target-libffi"
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
   sparc-*-sunos4*)
-    if [ x${is_cross_compiler} != xno ] ; then
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    if test x${is_cross_compiler} != xno ; then
            noconfigdirs="$noconfigdirs gdb gdbtest target-newlib target-libgloss"
     else
            use_gnu_ld=no
     fi
     ;;
-  sparc-*-solaris*)
-    case "${host}" in
-    sparc-*-solaris2.8)
-      # According to Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>, libjava
-      # won't build correctly on Solaris 8 if there's a
-      # previously-installed version of GCC in the configured prefix.
-      # This problem does not show up on earlier versions of Solaris.
-      noconfigdirs="$noconfigdirs ${libgcj}"
-      ;;
-    esac
+  sparc-*-solaris* | sparc64-*-solaris* | sparcv9-*-solaris*)
     ;;
   v810-*-*)
-    noconfigdirs="$noconfigdirs bfd binutils gas gcc gdb ld ${libstdcxx_version} opcodes target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs bfd binutils gas gcc gdb ld ${libstdcxx_version} opcodes target-libgloss ${libgcj}"
     ;;
   v850-*-*)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   v850e-*-*)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   v850ea-*-*)
-    noconfigdirs="$noconfigdirs target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
     ;;
   vax-*-vms)
-    noconfigdirs="$noconfigdirs bfd binutils gdb ld target-newlib opcodes target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs bfd binutils gdb ld target-newlib opcodes target-libgloss ${libgcj}"
     ;;
   vax-*-*)
-    noconfigdirs="$noconfigdirs target-newlib target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
     ;;
   *-*-lynxos*)
-    noconfigdirs="$noconfigdirs target-newlib target-libgloss target-libffi"
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
     ;; 
   *-*-macos* | \
   *-*-mpw*)
     # Macs want a resource compiler.
     configdirs="$configdirs grez"
-    noconfigdirs="$noconfigdirs target-libffi"
+    noconfigdirs="$noconfigdirs ${libgcj}"
     ;;    
+  *-*-*)
+    noconfigdirs="$noconfigdirs ${libgcj}"
+    ;;
 esac
 
 # If we aren't building newlib, then don't build libgloss, since libgloss
@@ -973,13 +1061,13 @@
 esac
 
 # Make sure we don't let GNU ld be added if we didn't want it.
-if [ x$with_gnu_ld = xno ]; then
+if test x$with_gnu_ld = xno ; then
   use_gnu_ld=no
   noconfigdirs="$noconfigdirs ld"
 fi
 
 # Make sure we don't let GNU as be added if we didn't want it.
-if [ x$with_gnu_as = xno ]; then
+if test x$with_gnu_as = xno ; then
   use_gnu_as=no
   noconfigdirs="$noconfigdirs gas"
 fi
@@ -1006,6 +1094,38 @@
 fi
 enable_languages=`echo "${enable_languages}" | sed -e 's/[ 	,][ 	,]*/,/g' -e 's/,$//'`
 
+# First scan to see if an enabled language requires some other language.
+# We assume that a given config-lang.in will list all the language
+# front ends it requires, even if some are required indirectly.
+for lang in ${srcdir}/gcc/*/config-lang.in ..
+do
+   case $lang in
+    ..)
+       ;;
+    # The odd quoting in the next line works around
+    # an apparent bug in bash 1.12 on linux.
+    ${srcdir}/gcc/[*]/config-lang.in)
+       ;;
+    *)
+       lang_alias=`sed -n -e 's,^language=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^language=\([^ 	]*\).*$,\1,p' $lang`
+       this_lang_requires=`sed -n -e 's,^lang_requires=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^lang_requires=\([^ 	]*\).*$,\1,p' $lang`
+       for other in $this_lang_requires
+       do
+	  case ,${enable_languages}, in
+	   *,$other,*)
+	      ;;
+	   *,all,*)
+	      ;;
+	   *,$lang_alias,*)
+	      echo " \`$other' language required by \`$lang_alias'; enabling" 1>&2
+	      enable_languages="$enable_languages,$other"
+	      ;;
+	  esac
+       done
+       ;;
+   esac
+done
+
 subdirs=
 for lang in ${srcdir}/gcc/*/config-lang.in ..
 do
@@ -1017,6 +1137,7 @@
 	*)
 	  lang_alias=`sed -n -e 's,^language=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^language=\([^ 	]*\).*$,\1,p' $lang`
 	  this_lang_libs=`sed -n -e 's,^target_libs=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^target_libs=\([^ 	]*\).*$,\1,p' $lang`
+	  this_lang_dirs=`sed -n -e 's,^lang_dirs=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^lang_dirs=\([^ 	]*\).*$,\1,p' $lang`
 	  build_by_default=`sed -n -e 's,^build_by_default=['"'"'"'"]\(.*\)["'"'"'"'].*$,\1,p' -e 's,^build_by_default=\([^ 	]*\).*$,\1,p' $lang`
 	  if test "x$lang_alias" = x
 	  then
@@ -1032,13 +1153,12 @@
 	  if test x"${add_this_lang}" = xyes; then
 	      eval target_libs='"$target_libs "'\"$this_lang_libs\"
 	  else
-	      eval noconfigdirs='"$noconfigdirs "'\"$this_lang_libs\"
+	      eval noconfigdirs='"$noconfigdirs "'\"$this_lang_libs $this_lang_dirs\"
 	  fi
 	  ;;
 	esac
 done
 
-
 # Remove the entries in $skipdirs and $noconfigdirs from $configdirs and
 # $target_configdirs.
 # If we have the source for $noconfigdirs entries, add them to $notsupp.
@@ -1046,10 +1166,10 @@
 notsupp=""
 for dir in . $skipdirs $noconfigdirs ; do
   dirname=`echo $dir | sed -e s/target-//g`
-  if [ $dir != . ]  && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+  if test $dir != .  && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
     configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"`
-    if [ -r $srcdir/$dirname/configure ] \
-	|| [ -r $srcdir/$dirname/configure.in ]; then
+    if test -r $srcdir/$dirname/configure \
+	|| test -r $srcdir/$dirname/configure.in ; then
       if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
 	true
       else
@@ -1057,10 +1177,10 @@
       fi
     fi
   fi
-  if [ $dir != . ]  && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
+  if test $dir != . && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
     target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"`
-    if [ -r $srcdir/$dirname/configure ] \
-	|| [ -r $srcdir/$dirname/configure.in ]; then
+    if test -r $srcdir/$dirname/configure \
+	|| test -r $srcdir/$dirname/configure.in ; then
       if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then
 	true
       else
@@ -1072,17 +1192,17 @@
 
 # Sometimes the tools are distributed with libiberty but with no other
 # libraries.  In that case, we don't want to build target-libiberty.
-if [ -n "${target_configdirs}" ]; then
+if test -n "${target_configdirs}" ; then
   others=
   for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
-    if [ "$i" != "libiberty" ]; then
-      if [ -r $srcdir/$i/configure ] || [ -r $srcdir/$i/configure.in ]; then
+    if test "$i" != "libiberty" ; then
+      if test -r $srcdir/$i/configure || test -r $srcdir/$i/configure.in ; then
 	others=yes;
 	break;
       fi
     fi
   done
-  if [ -z "${others}" ]; then
+  if test -z "${others}" ; then
     target_configdirs=
   fi
 fi
@@ -1090,30 +1210,49 @@
 # Deconfigure all subdirectories, in case we are changing the
 # configuration from one where a subdirectory is supported to one where it
 # is not.
-if [ -z "${norecursion}" ] && [ -n "${configdirs}" ]; then
+if test -z "${norecursion}" && test -n "${configdirs}" ; then
   for i in `echo ${configdirs} | sed -e s/target-//g` ; do
     rm -f $i/Makefile
   done
 fi
-if [ -z "${norecursion}" ] && [ -n "${target_configdirs}" ]; then
+if test -z "${norecursion}" && test -n "${target_configdirs}" ; then
   for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do
     rm -f ${target_subdir}/$i/Makefile
   done
 fi
 
+# Quietly strip out all directories which aren't configurable in this tree.
+# This relies on all configurable subdirectories being autoconfiscated, which
+# is now the case.
+configdirs_all="$configdirs"
+configdirs=
+for i in ${configdirs_all} ; do
+  if test -f ${srcdir}/$i/configure ; then
+    configdirs="${configdirs} $i"
+  fi
+done
+target_configdirs_all="$target_configdirs"
+target_configdirs=
+for i in ${target_configdirs_all} ; do
+  j=`echo $i | sed -e s/target-//g` 
+  if test -f ${srcdir}/$j/configure ; then
+    target_configdirs="${target_configdirs} $i"
+  fi
+done
+
 # Produce a warning message for the subdirs we can't configure.
 # This isn't especially interesting in the Cygnus tree, but in the individual
 # FSF releases, it's important to let people know when their machine isn't
 # supported by the one or two programs in a package.
 
-if [ -n "${notsupp}" ] && [ -z "${norecursion}" ]; then
+if test -n "${notsupp}" && test -z "${norecursion}" ; then
   # If $appdirs is non-empty, at least one of those directories must still
   # be configured, or we error out.  (E.g., if the gas release supports a
   # specified target in some subdirs but not the gas subdir, we shouldn't
   # pretend that all is well.)
-  if [ -n "$appdirs" ]; then
+  if test -n "$appdirs" ; then
     for dir in $appdirs ; do
-      if [ -r $dir/Makefile.in ]; then
+      if test -r $dir/Makefile.in ; then
 	if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then
 	  appdirs=""
 	  break
@@ -1124,7 +1263,7 @@
 	fi
       fi
     done
-    if [ -n "$appdirs" ]; then
+    if test -n "$appdirs" ; then
       echo "*** This configuration is not supported by this package." 1>&2
       exit 1
     fi
@@ -1149,15 +1288,15 @@
 # want to do that, then you should use the --without-gnu-as and
 # --without-gnu-ld options for the configure script.
 
-if [ x${use_gnu_as} = x ] ; then
-  if [ x${with_gnu_as} != xno ] && echo " ${configdirs} " | grep " ${gasdir} " > /dev/null 2>&1 && [ -d ${srcdir}/${gasdir} ] ; then
+if test x${use_gnu_as} = x ; then
+  if test x${with_gnu_as} != xno && echo " ${configdirs} " | grep " ${gasdir} " > /dev/null 2>&1 && test -d ${srcdir}/${gasdir} ; then
     with_gnu_as=yes
     withoptions="$withoptions --with-gnu-as"
   fi
 fi
 
-if [ x${use_gnu_ld} = x ] ; then
-  if [ x${with_gnu_ld} != xno ] && echo " ${configdirs} " | grep " ld " > /dev/null 2>&1 && [ -d ${srcdir}/ld ] ; then
+if test x${use_gnu_ld} = x ; then
+  if test x${with_gnu_ld} != xno && echo " ${configdirs} " | grep " ld " > /dev/null 2>&1 && test -d ${srcdir}/ld ; then
     with_gnu_ld=yes
     withoptions="$withoptions --with-gnu-ld"
   fi
@@ -1166,41 +1305,13 @@
 # If using newlib, add --with-newlib to the withoptions so that gcc/configure
 # can detect this case.
 
-if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 && [ -d ${srcdir}/newlib ] ; then
+if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 && test -d ${srcdir}/newlib ; then
   with_newlib=yes
   withoptions="$withoptions --with-newlib"
 fi
 
-if [ x${shared} = xyes ]; then
-  case "${target}" in
-    hppa*)
-      target_makefile_frag="${target_makefile_frag} config/mt-papic"
-      ;;
-    i[3456]86-*)
-      target_makefile_frag="${target_makefile_frag} config/mt-x86pic"
-      ;;
-    ia64-*)
-      target_makefile_frag="${target_makefile_frag} config/mt-ia64pic"
-      ;;
-    powerpc*-*-aix*)
-      # We don't want -fPIC on AIX.
-      ;;
-    powerpc*-*)
-      target_makefile_frag="${target_makefile_frag} config/mt-ppcpic"
-      ;;
-    alpha*-*-linux*)
-      target_makefile_frag="${target_makefile_frag} config/mt-elfalphapic"
-      ;;
-    *)
-      if test -f ${srcdir}/config/mt-${target_cpu}pic; then
-        target_makefile_frag="${target_makefile_frag} config/mt-${target_cpu}pic"
-      fi
-      ;;
-  esac
-fi
-
 rm -f mt-frag
-if [ -n "${target_makefile_frag}" ] ; then
+if test -n "${target_makefile_frag}" ; then
   for f in ${target_makefile_frag}
   do
     cat ${srcdir}/$f >> mt-frag
@@ -1214,33 +1325,39 @@
 # can't, we are probably in trouble.  We don't care whether we can run the
 # executable--we might be using a cross compiler--we only care whether it
 # can be created.  At this point the main configure script has set CC.
+we_are_ok=no
 echo "int main () { return 0; }" > conftest.c
 ${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
-if [ $? = 0 ] && [ -s conftest -o -s conftest.exe ]; then
-  :
-else
-  echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
-  echo 1>&2 "*** You must set the environment variable CC to a working compiler."
-  rm -f conftest*
-  exit 1
-fi
+if test $? = 0 ; then
+  if test -s conftest || test -s conftest.exe ; then
+    we_are_ok=yes
+  fi
+fi 
+case $we_are_ok in
+  no)
+    echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
+    echo 1>&2 "*** You must set the environment variable CC to a working compiler."
+    rm -f conftest*
+    exit 1
+    ;;
+esac
 rm -f conftest*
 
 # The Solaris /usr/ucb/cc compiler does not appear to work.
 case "${host}" in
   sparc-sun-solaris2*)
       CCBASE="`echo ${CC-cc} | sed 's/ .*$//'`"
-      if [ "`type $CCBASE | sed 's/^[^/]*//'`" = "/usr/ucb/cc" ] ; then 
+      if test "`type $CCBASE | sed 's/^[^/]*//'`" = "/usr/ucb/cc" ; then
           could_use=
-          [ -d /opt/SUNWspro/bin ] && could_use="/opt/SUNWspro/bin"
-          if [ -d /opt/cygnus/bin ] ; then
-              if [ "$could_use" = "" ] ; then
+          test -d /opt/SUNWspro/bin && could_use="/opt/SUNWspro/bin"
+          if test -d /opt/cygnus/bin ; then
+              if test "$could_use" = "" ; then
                   could_use="/opt/cygnus/bin"
               else
                   could_use="$could_use or /opt/cygnus/bin"
               fi
           fi
-        if [ "$could_use" = "" ] ; then
+        if test "$could_use" = "" ; then
             echo "Warning: compilation may fail because you're using"
             echo "/usr/ucb/cc.  You should change your PATH or CC "
             echo "variable and rerun configure."
@@ -1256,7 +1373,7 @@
 
 # If --enable-shared was set, we must set LD_LIBRARY_PATH so that the
 # binutils tools will find libbfd.so.
-if [ "${shared}" = "yes" ]; then
+if test "${shared}" = "yes" ; then
   sed -e 's/^SET_LIB_PATH[ 	]*=.*$/SET_LIB_PATH = $(REALLY_SET_LIB_PATH)/' \
       Makefile > Makefile.tem
   rm -f Makefile
@@ -1292,18 +1409,18 @@
 # native.  However, it would be better to use other mechanisms to make the
 # sorts of decisions they want to make on this basis.  Please consider
 # this option to be deprecated.  FIXME.
-if [ x${is_cross_compiler} = xyes ]; then
+if test x${is_cross_compiler} = xyes ; then
   targargs="--with-cross-host=${host_alias} ${targargs}"
 fi
 
 # Default to --enable-multilib.
-if [ x${enable_multilib} = x ]; then
+if test x${enable_multilib} = x ; then
   targargs="--enable-multilib ${targargs}"
 fi
 
 # Pass --with-newlib if appropriate.  Note that target_configdirs has
 # changed from the earlier setting of with_newlib.
-if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && [ -d ${srcdir}/newlib ] ; then
+if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && test -d ${srcdir}/newlib ; then
   targargs="--with-newlib ${targargs}"
 fi
 
@@ -1312,7 +1429,7 @@
 
 # provide a proper gxx_include_dir.
 # Note, if you change the default, make sure to fix both here and in
-# the gcc, libio, and libstdc++ subdirectories.
+# the gcc and libstdc++-v3 subdirectories.
 # Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
 gxx_include_dir=
 if test -n "${with_gxx_include_dir}"; then
@@ -1333,7 +1450,7 @@
     gxx_include_dir='${libsubdir}/include/g++'
   else
     . ${topsrcdir}/config.if
-    gxx_include_dir='${prefix}/include/g++'-${libstdcxx_interface}
+    gxx_include_dir='${prefix}/include/${libstdcxx_incdir}'
   fi
 else
   gxx_include_dir=${gxx_include_dir}
@@ -1343,6 +1460,10 @@
 case " $skipdirs " in
 *" target-newlib "*) ;;
 *)
+ case " $target_configdirs " in
+ *" newlib "*)
+  case " $targargs " in
+  *" --with-newlib "*)
    case "$target" in
    *-cygwin*)
      FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -L$$r/$(TARGET_SUBDIR)/winsup/w32api/lib -isystem $$s/winsup/include -isystem $$s/winsup/cygwin/include -isystem $$s/winsup/w32api/include -isystem $$s/newlib/libc/sys/cygwin -isystem $$s/newlib/libc/sys/cygwin32' ;;
@@ -1372,11 +1493,10 @@
    fi
 
    case "${target}-${is_cross_compiler}" in
-   i[3456]86-pc-linux*-no)
+   i[3456]86-*-linux*-no)
       # Here host == target, so we don't need to build gcc,
       # so we don't want to discard standard headers.
       FLAGS_FOR_TARGET=`echo " $FLAGS_FOR_TARGET " | sed -e 's/ -nostdinc / /'`
-      FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/$(TARGET_SUBDIR)/newlib/'
       ;;
    *)
       # If we're building newlib, use its generic headers last, but search
@@ -1386,6 +1506,10 @@
       ;;
    esac
    ;;
+  esac
+  ;;
+ esac
+ ;;
 esac
 
 # On Canadian crosses, we'll be searching the right directories for
@@ -1420,18 +1544,18 @@
 *) CC_FOR_TARGET=$CC_FOR_TARGET' $(FLAGS_FOR_TARGET)' ;;
 esac
 
-if test "x${CHILL_FOR_TARGET+set}" = xset; then
+if test "x${GCJ_FOR_TARGET+set}" = xset; then
   :
 elif test -d ${topsrcdir}/gcc; then
-  CHILL_FOR_TARGET='$$r/gcc/xgcc -B$$r/gcc/ -L$$r/gcc/ch/runtime/'
+  GCJ_FOR_TARGET='$$r/gcc/gcj -B$$r/gcc/'
 elif test "$host" = "$target"; then
-  CHILL_FOR_TARGET='$(CC)'
+  GCJ_FOR_TARGET='gcj'
 else
-  CHILL_FOR_TARGET=`echo gcc | sed -e 's/x/x/' ${program_transform_name}`
+  GCJ_FOR_TARGET=`echo gcj | sed -e 's/x/x/' ${program_transform_name}`
 fi
-case $CHILL_FOR_TARGET in
+case $GCJ_FOR_TARGET in
 *' $(FLAGS_FOR_TARGET)') ;;
-*) CHILL_FOR_TARGET=$CHILL_FOR_TARGET' $(FLAGS_FOR_TARGET)' ;;
+*) GCJ_FOR_TARGET=$GCJ_FOR_TARGET' $(FLAGS_FOR_TARGET)' ;;
 esac
 
 if test "x${CXX_FOR_TARGET+set}" = xset; then
@@ -1460,19 +1584,22 @@
 # macros.
 qqCXX_FOR_TARGET=`echo "$qCXX_FOR_TARGET" | sed -e 's,[$][$],$$$$,g'`
 
-sed -e "s:^TARGET_CONFIGDIRS[ 	]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
-    -e "s%^TARGET_CONFIGARGS[ 	]*=.*$%TARGET_CONFIGARGS = ${targargs}%" \
-    -e "s%^FLAGS_FOR_TARGET[ 	]*=.*$%FLAGS_FOR_TARGET = ${FLAGS_FOR_TARGET}%" \
-    -e "s%^CC_FOR_TARGET[ 	]*=.*$%CC_FOR_TARGET = ${CC_FOR_TARGET}%" \
-    -e "s%^CHILL_FOR_TARGET[ 	]*=.*$%CHILL_FOR_TARGET = ${CHILL_FOR_TARGET}%" \
-    -e "s%^CXX_FOR_TARGET[ 	]*=.*$%CXX_FOR_TARGET = ${qCXX_FOR_TARGET}%" \
-    -e "s%^CXX_FOR_TARGET_FOR_RECURSIVE_MAKE[ 	]*=.*$%CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = ${qqCXX_FOR_TARGET}%" \
-    -e "s%^TARGET_SUBDIR[ 	]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
-    -e "s%^BUILD_SUBDIR[ 	]*=.*$%BUILD_SUBDIR = ${build_subdir}%" \
-    -e "s%^BUILD_CONFIGARGS[ 	]*=.*$%BUILD_CONFIGARGS = ${buildargs}%" \
-    -e "s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
-       Makefile > Makefile.tem
-rm -f Makefile
+sedtemp=sed.$$
+cat >$sedtemp <<EOF
+s:^TARGET_CONFIGDIRS[ 	]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:
+s%^TARGET_CONFIGARGS[ 	]*=.*$%TARGET_CONFIGARGS = ${targargs}%
+s%^FLAGS_FOR_TARGET[ 	]*=.*$%FLAGS_FOR_TARGET = ${FLAGS_FOR_TARGET}%
+s%^CC_FOR_TARGET[ 	]*=.*$%CC_FOR_TARGET = ${CC_FOR_TARGET}%
+s%^GCJ_FOR_TARGET[      ]*=.*$%GCJ_FOR_TARGET = ${GCJ_FOR_TARGET}%
+s%^CXX_FOR_TARGET[ 	]*=.*$%CXX_FOR_TARGET = ${qCXX_FOR_TARGET}%
+s%^CXX_FOR_TARGET_FOR_RECURSIVE_MAKE[ 	]*=.*$%CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = ${qqCXX_FOR_TARGET}%
+s%^TARGET_SUBDIR[ 	]*=.*$%TARGET_SUBDIR = ${target_subdir}%
+s%^BUILD_SUBDIR[ 	]*=.*$%BUILD_SUBDIR = ${build_subdir}%
+s%^BUILD_CONFIGARGS[ 	]*=.*$%BUILD_CONFIGARGS = ${buildargs}%
+s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%
+EOF
+sed -f $sedtemp Makefile > Makefile.tem
+rm -f Makefile $sedtemp
 mv -f Makefile.tem Makefile
 
 #
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 68fd3d9..93a2353 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,2015 @@
-2002-03-25  Alexandre Oliva  <aoliva@redhat.com>
+2002-05-06  Jim Blandy  <jimb@redhat.com>
+
+	Separate the job of reading the line number info statement program
+	header (...expialidocious) out into its own function.
+	* dwarf2read.c (struct line_head, struct filenames, struct
+	directories): Replace with...
+	(struct line_header): New structure, containing the full
+	contents of the statement program header, including the
+	include directory and file name tables.
+	(read_file_scope): If we have line number info, instead of just
+	calling dwarf_decode_lines to do all the work, call
+	dwarf_decode_line_header first to get a `struct line_header'
+	containing the data in the statement program header, and then
+	pass that to dwarf_decode_lines, which will pick up where that
+	left off.  Be sure to clean up the `struct line_header' object.
+	(dwarf_decode_line_header, free_line_header, add_include_dir,
+	add_file_name): New functions.
+	(dwarf_decode_lines): Move all the code to read the statement
+	program header into dwarf_decode_line_header.  Take the line
+	header it built as the first argument, instead of the offset to
+	the compilation unit's line number info.  Use the new `struct
+	line_header' type instead of the old structures.  No need to do
+	cleanups here now, since we don't allocate anything.
+	(dwarf2_statement_list_fits_in_line_number_section,
+	dwarf2_line_header_too_long): New complaints.
+
+2002-05-06  Elena Zannoni  <ezannoni@redhat.com>
+
+	* gdbtypes.c (init_vector_type): New function.
+	(build_builtin_type_vec128): Simplify the representation of SIMD
+	registers.
+	(build_gdbtypes): Initialize new builtin vector types.
+	(_initialize_gdbtypes): Register new vector types with gdbarch.
+	(builtin_type_v4_float, builtin_type_v4_int32,
+	builtin_type_v8_int16, builtin_type_v16_int8,
+	builtin_type_v2_int32, builtin_type_v4_int16,
+	builtin_type_v8_int8): New (renamed) SIMD types.
+
+2002-05-06  Mark Kettenis  <kettenis@gnu.org>
+
+	* i387-nat.c (i387_fill_fsave): Use regcache_collect.
+	(i387_fill_fxsave): Likewise.
+
+2002-05-05  Alexandre Oliva  <aoliva@redhat.com>
+
+	* alpha-tdep.c (alpha_extract_return_value): Don't use
+	non-constant array size in prototype.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	From Brian Taylor <briant at model dot com>:
+	* ui-out.c (ui_out_field_core_addr): Use the function
+	longest_local_hex_string_custom'to format addresses > 32 bits
+	wide.
+
+	* ui-out.c (ui_out_field_core_addr): Update comment.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* stack.c (select_and_print_frame): Make static.  Delete the
+	parameter `level'.
+	(func_command): Update call.
+	(select_frame_command): Delete code computing the frame level.
+	* frame.h (select_and_print_frame): Delete declaration.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* sparc-tdep.c (sparc_get_saved_register): Comment why
+	get_prev_frame call is safe.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* frame.h (select_frame): Delete level parameter.
+	* stack.c (select_frame): Update.  Use frame_relative_level to
+	obtain the frame's level.
+	(select_and_print_frame): Update call.
+	(select_frame_command): Ditto.
+	(up_silently_base): Ditto.
+	(down_silently_base): Ditto.
+	* ocd.c (ocd_start_remote): Ditto.
+	* remote-rdp.c (remote_rdp_open): Ditto.
+	* remote-mips.c (mips_initialize): Ditto.
+	(common_open): Ditto.
+	* remote-e7000.c (e7000_start_remote): Ditto.
+	* m3-nat.c (select_thread): Ditto.
+	* hppa-tdep.c (child_get_current_exception_event): Ditto.
+	(child_get_current_exception_event): Ditto.
+	* varobj.c (varobj_create): Ditto.
+	(varobj_update): Ditto.
+	(c_value_of_root): Ditto.
+	* tracepoint.c (finish_tfind_command): Ditto.
+	* corelow.c (core_open): Ditto.
+	* arch-utils.c (generic_prepare_to_proceed): Ditto.
+	* thread.c (info_threads_command): Ditto.
+	(switch_to_thread): Ditto.
+	* infrun.c (normal_stop): Ditto.
+	(restore_selected_frame): Ditto.
+	(restore_inferior_status): Ditto.
+	* breakpoint.c (insert_breakpoints): Ditto.
+	(watchpoint_check): Ditto.
+	(bpstat_stop_status): Ditto.
+	(do_enable_breakpoint): Ditto.
+	* blockframe.c (flush_cached_frames): Ditto.
+	(reinit_frame_cache): Ditto.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* MAINTAINERS (Host/Native): Add Jason Thorpe as NetBSD
+	maintainer.
+
+2002-05-04  Jim Blandy  <jimb@redhat.com>
+
+	* gdbtypes.c (replace_type): Doc fix.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* valprint.c (strcat_longest): Delete commented out function.
+	Update copyright.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* MAINTAINERS: Mark a29k as deleted.
+	* NEWS: Mention that a29k was removed.  Add OBSOLETE section.
+	Move new configurations to the top.
+	* configure.tgt: Remove a29k.
+	* config/a29k/tm-vx29k.h: Delete.
+	* config/a29k/vx29k.mt: Delete.
+	* config/a29k/tm-a29k.h: Delete.
+	* config/a29k/a29k-udi.mt: Delete.
+	* config/a29k/a29k.mt: Delete.
+	* a29k-tdep.c: Delete.
+	* remote-udi.c: Delete.
+	* remote-mm.c: Delete.
+	* remote-eb.c: Delete.
+	* remote-adapt.c: Delete.
+	* Makefile.in: Remove obsolete code.
+	* gdbserver/Makefile.in: Ditto.
+	* config/s390/s390x.mt: Ditto.
+	* config/s390/s390.mt: Ditto.
+	* config/sparc/sparclynx.mh: Ditto.
+	* config/sparc/linux.mh: Ditto.
+	* config/pa/hppaosf.mh: Ditto.
+	* config/pa/hppabsd.mh: Ditto.
+	* config/ns32k/nbsd.mt: Ditto.
+	* config/mips/vr5000.mt: Ditto.
+	* config/m68k/sun3os4.mh: Ditto.
+	* config/m68k/nbsd.mt: Ditto.
+	* config/m68k/m68klynx.mh: Ditto.
+	* config/m32r/m32r.mt: Ditto.
+	* config/i386/x86-64linux.mt: Ditto.
+	* config/i386/nbsdelf.mt: Ditto.
+	* config/i386/nbsd.mt: Ditto.
+	* config/i386/i386lynx.mh: Ditto.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* target.c (debug_print_register): New function.  Handle oversize
+	registers.
+	(debug_to_fetch_registers): Call.
+	(debug_to_store_registers): Call.
+
+2002-05-03  Jim Blandy  <jimb@redhat.com>
+
+	* stabsread.c (cleanup_undefined_types): Use replace_type, not memcpy.
+	(read_type): Doc fix.
+	* gdbtypes.c (replace_type): Doc fix.
+
+	* stabsread.c (multiply_defined_struct): New complaint.
+	(read_struct_type): If the type we were passed isn't empty, or
+	incomplete, don't read the new struct type into it; complain,
+	and return the original type unchanged.  Take a new `type_code'
+	argument, which is the type code for the new type.
+	(read_type): Rather than storing the type's type code here, pass
+	it as an argument to read_struct_type, and let that take care of
+	storing it.  That way, we don't overwrite the original type code,
+	so read_struct_type can use it to decide whether we're overwriting
+	something we shouldn't.
+	(complain_about_struct_wipeout): New function.
+
+2002-05-03  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbarch.sh: Assert that gdbarch is non-NULL.
+	* gdbarch.c: Regenerate.
+
+2002-05-03  Jason Merrill  <jason@redhat.com>
+
+	* gnu-v3-abi.c (gnuv3_rtti_type): If we get confused, just warn
+	and return NULL.
+
+2002-05-03  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-tdep.c (x86_64_dwarf2gdb_regno_map),
+	(x86_64_dwarf2gdb_regno_map_length),
+	(x86_64_dwarf2_reg_to_regnum): Added.
+	(x86_64_gdbarch_init): Added registration of x86_64_dwarf2_reg_to_regnum.
+	(x86_64_gdbarch_init): Renamed from i386_gdbarch_init.
+	(_initialize_x86_64_tdep): Synced with the change above.
+	(x86_64_skip_prologue): Reformulated message.
+
+2002-05-03  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* f-exp.y: Also use new prev_lexptr variable
+	to improve error reporting. Based on Michael Snyder
+	2002-04-24 dated patch to c-exp.y.
+	* jv-exp.y: Likewise.
+	* m2-exp.y: Likewise.
+
+2002-05-02  Elena Zannoni  <ezannoni@redhat.com>
+
+	* valops.c (value_arg_coerce): Don't coerce arrays to pointers if
+	we are dealing with vectors.
+
+2002-05-02  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* config/m68k/tm-nbsd.h: Obvious fix,
+	correct machine name.
+
+2002-05-02  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* p-typeprint.c (pascal_type_print_base): Add support
+	for TYPE_CODE_STRING and TYPE_CODE_BITSTRING.
+
+2002-05-02  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* p-lang.c (pascal_create_fundamental_type): Use TYPE_CODE_CHAR
+	for fondamental pascal 'char' type.
+
+2002-05-02  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* p-lang.h (is_pascal_string_type): Declaration changed,
+	new sixth argument of type char ** added.
+	* p-lang.c (is_pascal_string_type): Implementation 
+	changed. Args length_pos, length_size, string_pos, char_size
+	can now be NULL. New argument arrayname set to the field
+	name of the char array. Return value set to char array
+	field index plus one.
+	* p-valprint.c (pascal_val_print): Adapt to new declaration of 
+	is_pascal_string_type function.
+
+2002-05-02  Andrew Cagney  <cagney@redhat.com>
+
+	* gdbarch.sh (gdbarch_update_p): Revert 2002-05-02 Andrew Cagney
+	<cagney@redhat.com> change.
+	* gdbarch.c: Regenerate.
+
+2002-05-02  Andrew Cagney  <cagney@redhat.com>
+
+	* gdbarch.sh (gdbarch_update_p): Swap out the old architecture
+	before probing for a new one.  Detect errorenous gdbarch_init
+	functions.
+	* gdbarch.c: Regenerate.
+
+2002-05-01  Andrew Cagney  <cagney@redhat.com>
+
+	* config/mn10200/tm-mn10200.h: Include "symfile.h" and "symtab.h".
+	* config/mcore/tm-mcore.h: Ditto.  Update copyright.
+	* config/v850/tm-v850.h: Ditto.  Update copyright.
+
+2002-04-30  Andrew Cagney  <ac131313@redhat.com>
+
+	* cris-tdep.c (cris_gdbarch_init): Use arches instead of
+	current_gdbarch.
+
+2002-04-30  Michael Snyder  <msnyder@redhat.com>
+
+	* arm-tdep.c: Whitespace clean-ups.
+	(arm_skip_prologue): Fix thinko; two lines
+	should have been removed as part of 4/24 change.
+
+2002-04-30  Kevin Buettner  <kevinb@redhat.com>
+
+	* rs6000-tdep.c: Added comment describing how fpscr register
+	numbers were chosen.
+
+2002-04-30  Michael Snyder  <msnyder@redhat.com>
+
+	* gnu-nat.c (gnu_find_memory_regions): Fix merge botch.
+
+2002-04-29  Elena Zannoni  <ezannoni@redhat.com>
+
+	* hpread.c (DNTT_TYPE_VECTOR): Rename from TYPE_VECTOR.
+	(DNTT_TYPE_VECTOR_LENGTH): Rename from TYPE_VECTOR_LENGTH.
+	(hpread_symfile_init, hpread_lookup_type): Substitute throughout.
+
+2002-04-29  Kevin Buettner  <kevinb@redhat.com>
+
+	From Louis Hamilton <hamilton@redhat.com>:
+	* rs6000-tdep.c (coff/xcoff.h, libxcoff.h): Include.
+	* xcoffread.c (coff/xcoff.h, libxcoff.h): Likewise.
+	* rs6000-tdep.c (rs6000_gdbarch_init): Use bfd_xcoff_is_xcoff64(),
+	not bfd-private xcoff data, to determine wordsize.
+	* xcoffread.c (read_xcoff_xymtab, read_symbol_lineno): Likewise.
+
+2002-04-29  Andrew Cagney  <ac131313@redhat.com>
+
+	GDB 5.2 released from 5.2 branch.
+
+2002-04-29  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-linux-nat.c (fill_gregset): Explicit cast to avoid warning.
+	* x86-64-tdep.c (i386_gdbarch_init): Ditto.
+	(x86_64_register_info_table): Added comments with register numbers.
+	
+2002-04-29  Elena Zannoni  <ezannoni@redhat.com>
+
+	* rs6000-tdep.c (rs6000_extract_return_value,
+	rs6000_store_return_value): Handle returning vectors.
+	(rs6000_gdbarch_init): Use
+	ppc_sysv_abi_broken_use_struct_convention for native sysv cases.
+	* ppc-linux-tdep.c (ppc_sysv_abi_broken_use_struct_convention):
+	New function.
+	(ppc_sysv_abi_use_struct_convention): Deal with functions returning
+	vectors.
+	(ppc_sysv_abi_push_arguments): Handle vector parameters.
+	* ppc-tdep.h (ppc_sysv_abi_broken_use_struct_convention): Export.
+        
+2002-04-24  Pierre Muller  <ics.u-strasbg.fr>
+
+	* hpread.c (hpread_psymtab_to_symtab_1,
+	hpread_psymtab_to_symtab): Replace fprintf (stderr,...)
+	with fprintf_unfiltered (gdb_stderr,...).
+
+2002-04-24  Pierre Muller  <ics.u-strasbg.fr>
+
+	* remote-array.c (printf_monitor, write_monitor,
+	array_insert_breakpoint, array_remove_breakpoint ): 
+	Replace fprintf (stderr,...
+	with fprintf_unfiltered (gdb_stderr,....
+	* remote-es.c: Likewise.
+	* remote-os9k.c: Likewise.
+	* remote-st.c: Likewise.
+
+2002-04-28  Andreas Schwab  <schwab@suse.de>
+
+	* config/s390/s390.mh (NATDEPFILES): Remove solib.o, add
+	linux-proc.o and gcore.o.
+
+2002-04-26  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-tdep.c (x86_64_skip_prologue): Print note when debugging
+	code without frame pointers.
+
+2002-04-26  Andrew Cagney  <ac131313@redhat.com>
+
+	* sparc-tdep.c (sparc_gdbarch_init): Add comment explaining why
+	ON_STACK is needed.
+
+2002-04-26  Ben Elliston  <bje@redhat.com>
+
+	* target.c (do_xfer_memory): Correct reference to the new option
+	"trust-readonly-sections".
+
+2002-04-26  Elena Zannoni  <ezannoni@redhat.com>
+
+	* gdbtypes.h (TYPE_FLAG_VECTOR, TYPE_VECTOR): Define.
+	* gdbtypes.c (recursive_dump_type): Output the vector flag.
+	* dwarf2read.c (dwarf_attr_name): Handle new attribute for
+	vectors.
+	(read_array_type): Record the fact that this array type is really a
+	vector (i.e. are passed in by value).
+
+2002-04-26  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.h (gdbarch_tdep): Add sigcontext_addr member.
+	* alpha-tdep.c (alpha_sigcontext_addr): New function.
+	(alpha_find_saved_regs): Use alpha_sigcontext_addr.
+	(alpha_gdbarch_init): Initialize tdep->sigcontext_addr.
+	* alpha-linux-tdep.c: Include frame.h.
+	(alpha_linux_sigcontext_addr): New function.
+	(alpha_linux_init_abi): Set tdep->sigcontext_addr to
+	alpha_linux_sigcontext_addr.
+	* alpha-osf1-tdep.c: Include gdbcore.h.
+	(alpha_osf1_sigcontext_addr): New function.
+	(alpha_osf1_init_abi): Set tdep->sigcontext_addr to
+	alpha_osf1_sigcontext_addr.
+	* config/alpha/tm-alpha.h (SIGCONTEXT_ADDR): Remove.
+	* config/alpha/tm-alphalinux.h (SIGCONTEXT_ADDR): Remove.
+
+2002-04-26  Andrew Cagney  <ac131313@redhat.com>
+
+	* stack.c (selected_frame_level): 
+	(select_frame): Do not set selected_frame_level.
+	* frame.h (selected_frame_level): Delete declaration.
+
+2002-04-26  Andrew Cagney  <ac131313@redhat.com>
+
+	* rs6000-tdep.c (rs6000_gdbarch_init): Only set
+	convert_from_func_ptr-addr when AIX / PowerOpen.
+
+2002-04-25  Andrew Cagney  <ac131313@redhat.com>
+
+	* valops.c (hand_function_call): Call
+	generic_save_call_dummy_addr.
+	* frame.h (generic_save_call_dummy_addr): Declare.
+	* blockframe.c (struct dummy_frame): Add fields call_lo and
+	call_hi.
+	(generic_find_dummy_frame): Check for PC in range call_lo to
+	call_hi instead of entry_point_address.
+	(generic_pc_in_call_dummy): Search the dummy frames for a PC in
+	the call_lo to call_hi range.  Allow for DECR_PC_AFTER_BREAK.
+	(generic_save_call_dummy_addr): New function.
+
+2002-04-24  David S. Miller  <davem@redhat.com>
+
+	* sparc-tdep.c (sparc_gdbarch_skip_prologue): Kill, duplicates
+	sparc_skip_prologue.
+	(sparc_skip_prologue): Kill frameless_p arg, and use line number
+	information to find prologue when possible.
+	(sparc_prologue_frameless_p): Call examine_prologue directly.
+	(sparc_gdbarch_init): Update set_gdbarch_skip_prologue call.
+	* config/sparc/tm-sparc.h (sparc_skip_prologue): Update for killed
+	second argument.
+	(SKIP_PROLOGUE): Likewise.
+
+2002-04-25  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.c (alpha_skip_prologue_internal): Remove
+	GDB_TARGET_HAS_SHARED_LIBS #ifdef and update comment to
+	indicate that the condition it was testing is always true.
+	* config/alpha/nm-linux.h (GDB_TARGET_HAS_SHARED_LIBS): Remove.
+	* config/alpha/nm-nbsd.h (GDB_TARGET_HAS_SHARED_LIBS): Ditto.
+	* config/alpha/nm-osf.h (GDB_TARGET_HAS_SHARED_LIBS): Ditto.
+
+2002-04-25  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.h (gdbarch_tdep): Add jb_pc and jb_elt_size members.
+	* alpha-linux-tdep.c (alpha_linux_init_abi): Initialize
+	tdep->jb_pc and tdep->jb_elt_size.
+	* alpha-osf1-tdep.c (alpha_osf1_init_abi): Likewise.
+	* alphafbsd-tdep.c (alphafbsd_init_abi): Likewise.
+	* alphanbsd-tdep.c (alphanbsd_init_abi): Likewise.
+	* alpha-nat.c (get_longjmp_target): Remove.
+	(JB_ELEMENT_SIZE): Ditto.
+	(JB_PC): Ditto.
+	* alpha-tdep.c (alpha_get_longjmp_target): New function.
+	(alpha_gdbarch_init): Default tdep->jb_pc to -1.  If the
+	OS ABI sets jb_pc to a valid value, set gdbarch_get_longjmp_target
+	to alpha_get_longjmp_target.
+	(alpha_dump_tdep): Report tdep->jb_pc and tdep->jb_elt_size.
+	* config/alpha/nm-linux.h (GET_LONGJMP_TARGET): Remove.
+	* config/alpha/nm-osf.h (GET_LONGJMP_TARGET): Remove.
+
+2002-04-25  Andrew Cagney  <ac131313@redhat.com>
+
+	* README: Update to GDB 5.2.
+
+2002-04-25  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbarch.sh (LC_ALL): Set to `c'.
+
+2002-04-25  Theodore A. Roth  <troth@verinet.com>
+
+	* avr-tdep.c: Ran through gdb_indent.sh.
+
+2002-04-25  Theodore A. Roth  <troth@verinet.com>
+
+	* MAINTAINERS: Add myself as AVR maintainer.
+	* NEWS: Note new target avr.
+
+2002-04-25  Theodore A. Roth  <troth@verinet.com>
+
+	* Makefile.in: Add support for AVR target.
+	* configure.tgt: Add support for AVR target.
+	* avr-tdep.c: New file
+ 	* config/avr/avr.mt: New file.
+
+2002-04-25  Theodore A. Roth  <troth@verinet.com>
+
+	* MAINTAINERS: Add myself to write-after-approval.
+
+2002-04-24  Pierre Muller  <ics.u-strasbg.fr>
+
+	* f-lang.c (get_bf_for_fcn): Replace fprintf (stderr,...
+	with fprintf_unfiltered (gdb_stderr,....
+
+2002-04-25  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	Fix PR gdb/508.
+	* symfile.c (add_filename_language): Fix wrong xrealloc size argument.
+
+2002-04-25  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* p-exp.y: Also use new prev_lexptr variable
+	to improve error reporting. Based on Michael Snyder
+	2002-04-24 dated patch to c-exp.y.
+
+2002-04-25  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.c (alpha_breakpoint_from_pc): New function.
+	(alpha_gdbarch_init): Set gdbarch_breakpoint_from_pc to
+	alpha_breakpoint_from_pc.  Set gdbarch_function_start_offset
+	to 0.
+	* config/alpha/tm-alpha.h: Remove forward decls of struct type
+	and struct value.
+	(FUNCTION_START_OFFSET): Remove.
+	(BREAKPOINT): Ditto.
+
+2002-04-25  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* MAINTAINERS: Reflect that multi-arch is enabled for VAX.
+	* NEWS: Ditto.
+
+2002-04-24  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-linux-tdep.c (alpha_linux_pc_in_sigtramp): New function.
+	(alpha_linux_init_abi): Set gdbarch_pc_in_sigtramp to
+	alpha_linux_pc_in_sigtramp.
+	* alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): New function.
+	(alpha_osf1_init_abi): Set gdbarch_pc_in_sigtramp to
+	alpha_osf1_pc_in_sigtramp.
+	* alpha-tdep.c (alpha_osf_in_sigtramp): Remove.
+	* alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): New function.
+	(alphafbsd_init_abi): Set gdbarch_pc_in_sigtramp to
+	alphafbsd_pc_in_sigtramp.
+	* alphanbsd-tdep.c (alphanbsd_pc_in_sigtramp): New function.
+	(alphanbsd_init_abi): Set gdbarch_pc_in_sigtramp to
+	alphanbsd_pc_in_sigtramp.
+	* config/alpha/tm-alpha.h (IN_SIGTRAMP): Remove.
+	* config/alpha/tm-alphalinux.h (IN_SIGTRAMP): Remove.
+
+2002-04-24  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* config/alpha/nbsd.mh (NATDEPFILES): Remove solib-legacy.o.
+
+2002-04-24  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* Makefile.in (ALLDEPFILES): Add alphanbsd-nat.c and
+	alphanbsd-tdep.c.
+	(alphanbsd-nat.o): New dependency list.
+	(alphanbsd-tdep.o): Ditto.
+	* NEWS: Note new native NetBSD/alpha configuration.
+	* alphanbsd-nat.c: New file.
+	* alphanbsd-tdep.c: Ditto.
+	* configure.host (alpha*-*-netbsd*): New host.
+	* configure.tgt (alpha*-*-netbsd*): New target.
+	* config/alpha/nbsd.mh: New file.
+	* config/alpha/nbsd.mt: Ditto.
+	* config/alpha/nm-nbsd.h: Ditto.
+	* config/alpha/tm-nbsd.h: Ditto.
+
+2002-04-24  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* Makefile.in (ALLDEPFILES): Add alpha-osf1-tdep.c.
+	(alpha-osf1-tdep.o): New dependency list.
+	* alpha-tdep.h (gdbarch_tdep): Add dynamic_sigtramp_offset
+	and skip_sigtramp_frame members.
+	* alpha-linux-tdep.c: Include gdbcore.h.
+	(alpha_linux_sigtramp_offset): Change return type to LONGEST.
+	(alpha_linux_init_abi): Initialize tdep->dynamic_sigtramp_offset.
+	* alpha-osf1-tdep.c: New file.
+	* alpha-tdep.c (alpha_osf_skip_sigtramp_frame): Moved to
+	alpha-osf1-dep.c.
+	(alpha_frame_past_sigtramp_frame): New function.
+	(alpha_dynamic_sigtramp_offset): Ditto.
+	(alpha_proc_desc_is_dyn_sigtramp): Ditto.
+	(alpha_set_proc_desc_is_dyn_sigtramp): Ditto.
+	(ALPHA_PROC_SIGTRAMP_MAGIC): Define.
+	(push_sigtramp_desc): Use alpha_set_proc_desc_is_dyn_sigtramp.
+	(after_prologue): Use alpha_proc_desc_is_dyn_sigtramp.
+	(find_proc_desc): Use alpha_dynamic_sigtramp_offset.
+	(alpha_frame_chain): Use alpha_frame_past_sigtramp_frame.
+	(alpha_init_extra_frame_info): Use alpha_proc_desc_is_dyn_sigtramp.
+	(alpha_pop_frame): Use alpha_proc_desc_is_dyn_sigtramp.
+	(alpha_gdbarch_init): Initialize tdep->dynamic_sigtramp_offset
+	and tdep->skip_sigtramp_frame.  Set gdbarch_skip_trampoline_code
+	to find_solib_trampoline_target.
+	* config/alpha/alpha-osf1.mt (TDEPFILES): Add alpha-osf1-tdep.o.
+	* config/alpha/tm-alpha.h: Remove inclusion of regcache.h.
+	(SKIP_TRAMPOLINE_CODE): Remove.
+	(PROC_DESC_IS_DYN_SIGTRAMP): Ditto.
+	(SET_PROC_DESC_IS_DYN_SIGTRAMP): Ditto.
+	(DYNAMIC_SIGTRAMP_OFFSET): Ditto.
+	(FRAME_PAST_SIGTRAMP_FRAME): Ditto.
+	* config/alpha/tm-alphalinux.h (PROC_DESC_IS_DYN_SIGTRAMP): Remove.
+	(PROC_SIGTRAMP_MAGIC): Ditto.
+	(PROC_DESC_IS_DYN_SIGTRAMP): Ditto.
+	(SET_PROC_DESC_IS_DYN_SIGTRAMP): Ditto.
+	(SET_PROC_DESC_IS_DYN_SIGTRAMP): Ditto.
+	(DYNAMIC_SIGTRAMP_OFFSET): Ditto.
+	(FRAME_PAST_SIGTRAMP_FRAME): Ditto.
+
+2002-04-24  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* NEWS: Note that Alpha targets are now multi-arch.
+
+2002-04-24  Michael Snyder  <msnyder@redhat.com>
+
+	* parser-defs.h (prev_lexptr): New external variable.
+	* parse.c (parse_exp_1): Set prev_lexptr to null before
+	calling the language-specific parser.
+	* c-exp.y (yylex): Set prev_lexptr to start of current token.
+	(yyerror): Use prev_lexptr in error reporting.
+
+2002-04-24  Daniel Jacobowitz  <drow@mvista.com>
+
+	* config/i386/tm-linux.h: Define FILL_FPXREGSET.
+	* gregset.h: If FILL_FPXREGSET is defined, provide
+	gdb_fpxregset_t, supply_fpxregset, and fill_fpxregset.
+	* linux-proc.c (linux_do_thread_registers): If FILL_FPXREGSET
+	is defined, call fill_fpxregset.
+
+2002-04-24  Roland McGrath  <roland@frob.com>
+
+	* config/i386/i386gnu.mh (NATDEPFILES): Add core-regset.o here.
+	* i386gnu-nat.c [HAVE_SYS_PROCFS_H]
+	(supply_gregset, supply_fpregset): New functions.
+
+	* gnu-nat.c (gnu_find_memory_regions): New function.
+	(init_gnu_ops): Set `to_find_memory_regions' hook to that.
+	(gnu_xfer_memory): Add a cast.
+
+2002-04-24  Michael Snyder  <msnyder@redhat.com>
+
+	* arm-tdep.c (arm_scan_prologue): Move "mov ip, sp" into the 
+	loop.  Add handling for "str lr, [sp, #-4]!" and for saves
+	of argument regs ("str r(0123), [r11, #-nn"]).
+	(arm_skip_prologue): Better handling for frameless functions.  
+	Treat "mov ip, sp" as optional.  Recognize "str lr, [sp, #-4]".
+	(arm_skip_prologue): Recognize str r(0123), [r11, #-nn].
+
+Wed Apr 24 14:22:21 2002  Andrew Cagney  <cagney@redhat.com>
+
+	* arm-tdep.c (arm_gdbarch_init): Add comment that NUM_REGS nor
+ 	NUM_PSEUDO_REGS can be used.
+
+2002-04-24  Andrew Cagney  <ac131313@redhat.com>
+
+	* arch-utils.h: Update copyright.
+
+	* gdbarch.sh (PC_IN_SIGTRAMP): Add.
+	* gdbarch.h, gdbarch.c: Re-generate.
+
+	* inferior.h (IN_SIGTRAMP): Delete definition.
+	* arch-utils.c (legacy_pc_in_sigtramp): New function.
+	* arch-utils.h (legacy_pc_in_sigtramp): Declare.
+
+	* mips-tdep.c (mips_init_extra_frame_info): Use PC_IN_SIGTRAMP.
+	(mips_dump_tdep): Do not print value of IN_SIGTRAMP.
+	* hppa-tdep.c (pc_in_interrupt_handler):  Use PC_IN_SIGTRAMP.
+	(find_proc_framesize): Ditto.
+	* alpha-tdep.c (alpha_osf_skip_sigtramp_frame): Ditto.
+	(alpha_init_extra_frame_info): Ditto.
+	* infrun.c (handle_inferior_event): Ditto.
+	(handle_inferior_event): Ditto.
+	(check_sigtramp2): Ditto.
+	* blockframe.c (create_new_frame): Ditto.
+	(get_prev_frame): Ditto.
+	* ppc-linux-tdep.c: Update comments.
+	* i386-linux-tdep.c: Update comments.
+	* breakpoint.c (bpstat_what): Update comment.
+
+2002-04-24  Michal Ludvig  <mludvig@suse.cz>
+
+	* gdbserver/linux-low.c (regsets_fetch_inferior_registers),
+	(regsets_store_inferior_registers): Removed cast to int from 
+	ptrace() calls.
+	* gdbserver/regcache.h: Added declaration of struct inferior_info.
+
+2002-04-24  David S. Miller  <davem@redhat.com>
+
+	* i960-tdep.c (register_in_window_p): New function.
+	(i960_find_saved_register): Use it instead of
+	REGISTER_IN_WINDOW_P.
+	* config/i960/tm-i960.h (REGISTER_IN_WINDOW): Delete.
+
+	* symtab.h (find_stab_function_addr): Kill extern.
+	* minsyms.c (find_stab_function_addr): Remove from here...
+	* dbxread.c: ... to here, and mark it static.
+
+2002-04-20  David S. Miller  <davem@redhat.com>
+
+	* sparc-tdep.c (sparc_pop_frame): Only need to allocate
+	SPARC_INTREG_SIZE * 16 bytes for reg_temp.
+
+2002-04-21  David S. Miller  <davem@redhat.com>
+
+	* remote-vxsparc.c (vx_read_register): Fix typo, we want
+	REGISTER_RAW_SIZE of SP_REGNUM not CORE_ADDR.
+	(vx_write_register): Likewise.
+
+2002-04-23  J. Brobecker  <brobecker@gnat.com>
+
+	* source.c (is_regular_file): New function.
+	(openp): Check wether file to open is a regular file
+	to avoid opening directories.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* findvar.c (extract_signed_integer): Cast printf argument
+	to suppress format warning.
+	(extract_unsigned_integer): Likewise.
+	* infcmd.c (registers_info): Likewise.
+	* top.c (get_prompt_1): Likewise.
+	* valops.c (value_assign): Likewise.
+	* valprint.c (print_decimal): Likewise.
+
+2002-04-22  H.J. Lu  (hjl@gnu.org)
+
+	* c-exp.y (typebase): Support
+	
+	[long|long long|short] [signed|unsigned] [int|]
+
+	and
+
+	signed [long|long long|short] int
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* Makefile.in (vax-tdep.o): Add $(arch_utils_h), $(inferior_h),
+	and vax-tdep.h.
+	* vax-tdep.h: New file.
+	* vax-tdep.c: Include inferior.h, arch-utils.h, and vax-tdep.h.
+	Make several routines static.
+	(vax_get_saved_register): New function.
+	(vax_gdbarch_init): New function.
+	(_initialize_vax_tdep): Register vax_gdbarch_init.
+	* config/vax/tm-vax.h: Set GDB_MULTI_ARCH to GDB_MULTI_ARCH_PARTIAL.
+	Remove macros now under the control of gdbarch.
+
+2002-04-22  Michael Snyder  <msnyder@redhat.com>
+
+	* arm-tdep.c (arm_skip_prologue): Recognize "sub sp, sp, #nn".
+	Some whitespace and coding standards tweaks.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* vax-tdep.c: Include regcache.h.
+	(vax_call_dummy_words): New.
+	(sizeof_vax_call_dummy_words): New.
+	(vax_fix_call_dummy): New function.
+	(vax_saved_pc_after_call): Ditto.
+	* config/vax/tm-vax.h: Don't include regcache.h.
+	(SAVED_PC_AFTER_CALL): Use vax_saved_pc_after_call.
+	(CALL_DUMMY): Remove.
+	(CALL_DUMMY_WORDS): Define.
+	(SIZEOF_CALL_DUMMY_WORDS): Define.
+	(FIX_CALL_DUMMY): Use vax_fix_call_dummy.
+
+2002-04-18  Michael Snyder  <msnyder@redhat.com>
+
+	* arm-tdep.h: Change regnum defines to enums for ease of debugging.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* vax-tdep.c (vax_frame_chain): New function.
+	(vax_push_dummy_frame): Ditto.
+	(vax_pop_frame): Ditto.
+	* config/vax/tm-vax.h (FRAME_CHAIN): vax_frame_chain.
+	(FRAMELESS_FUNCTION_INVOCATION): Use
+	generic_frameless_function_invocation_not.
+	(PUSH_DUMMY_FRAME): Use vax_push_dummy_frame.
+	(POP_FRAME): Use vax_pop_frame.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* vax-tdep.c (vax_store_struct_return): New function.
+	(vax_extract_return_value): Ditto.
+	(vax_store_return_value): Ditto.
+	(vax_extract_struct_value_address): Ditto.
+	* config/vax/tm-vax.h (STORE_STRUCT_RETURN): Use
+	vax_store_struct_return.
+	(EXTRACT_RETURN_VALUE): Use vax_extract_return_value.
+	(STORE_RETURN_VALUE): Use vax_store_return_value.
+	(EXTRACT_STRUCT_VALUE_ADDRESS): Use vax_extract_struct_value_address.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* vax-tdep.c (vax_frame_saved_pc): New function.
+	(vax_frame_args_address_correct): Ditto.
+	(vax_frame_args_address): Ditto.
+	(vax_frame_locals_address): Ditto.
+	(vax_frame_num_args): Move code to be in proximity to
+	other frame-related functions.
+	* config/vax/tm-vax.h (INNER_THAN): Use core_addr_lessthan.
+	(FRAME_SAVED_PC): Use vax_frame_saved_pc.
+	(FRAME_ARGS_ADDRESS_CORRECT): Use vax_frame_args_address_correct.
+	(FRAME_ARGS_ADDRESS): Use vax_frame_args_address.
+	(FRAME_LOCALS_ADDRESS): Use vax_frame_locals_address.
+
+2002-04-22  H.J. Lu  (hjl@gnu.org)
+
+	* Makefile.in (FLAGS_TO_PASS): Add libdir, mandir, datadir and
+	includedir.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* vax-tdep.c (vax_frame_init_saved_regs): New function.
+	* config/vax/tm-vax.h (FRAME_FIND_SAVED_REGS): Remove.
+	(FRAME_INIT_SAVED_REGS): New macro.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* MAINTAINERS: Reflect that the Alpha target has been multi-arch'd.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-nat.c (get_longjmp_target): Use ALPHA_* constants
+	where needed.
+	(fetch_osf_core_registers): Likewise.
+	(supply_gregset): Likewise.
+
+2002-04-22  J. Brobecker  <brobecker@gnat.com>
+  
+	* symfile.h (get_section_index): Define.
+	* symfile.c (get_section_index): New function.
+	* mdebugread.c (SC_IS_SBSS): New macro.
+	(SC_IS_BSS): Return true for the scBss storage class only, as
+	the scSBss storage class refers to the .sbss section.
+	(parse_partial_symbols): Discard the symbols which associated
+	section does not exist.
+	Make sure to use the .sbss section index for symbols which
+	storage class is scBss, rather than using the .bss section index.
+
+2002-04-22  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* vax-tdep.c: Update copyright years.
+	(vax_register_name): New function.
+	(vax_register_byte): Ditto.
+	(vax_register_raw_size): Ditto.
+	(vax_register_virtual_size): Ditto.
+	(vax_register_virtual_type): Ditto.
+	* config/vax/tm-vax.h: Update copyright years.
+	(REGISTER_NAMES): Remove.
+	(REGISTER_NAME): Define.
+	(REGISTER_BYTE): Use vax_register_byte.
+	(REGISTER_RAW_SIZE): Use vax_register_raw_size.
+	(REGISTER_VIRTUAL_SIZE): Use vax_register_virtual_size.
+	(REGISTER_VIRTUAL_TYPE): Use vax_register_virtual_type.
+
+2002-04-21  Andrew Cagney  <ac131313@redhat.com>
+
+	* config/sparc/tm-sparc.h (sparc_skip_prologue): Restore
+	declaration
+	* arc-tdep.c (arc_prologue_frameless_p): Fix syntax error.
+
+2002-04-21  David S. Miller  <davem@redhat.com>
+
+	* arch-utils.c (generic_prologue_frameless_p): Kill
+	SKIP_PROLOGUE_FRAMELESS_P code.
+	* config/arc/tm-arc.h (SKIP_PROLOGUE_FRAMELESS_P): Delete
+	references.
+	(PROLOGUE_FRAMELESS_P, arc_prologue_frameless_p): New.
+	* arc-tdep.c (arc_prologue_frameless_p): Implement.
+	* config/arc/tm-sparc.h (SKIP_PROLOGUE_FRAMELESS_P): Delete
+	references.
+	(PROLOGUE_FRAMELESS_P, sparc_prologue_frameless_p): New.
+	* sparc-tdep.c (sparc_prologue_frameless_p): Implement.
+	(sparc_gdbarch_init): Pass it to
+	set_gdbarch_prologue_frameless_p.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* Makefile.in (ALLDEPFILES): Add alphabsd-nat.c.
+	(alphabsd-nat.o): New dependency list.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* Makefile.in (ALLDEPFILES): Add alpha-linux-tdep.c and
+	alphafbsd-tdep.c.
+	(alpha-linux-tdep.o): New dependency list.
+	(alphafbsd-tdep.o): Likewise.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-linux-tdep.c: New file.  Move alpha_linux_sigtramp_offset
+	to here...
+	* alpha-tdep.c: ...from here.
+	* config/alpha/alpha-linux.mt (TDEPFILES): Add alpha-linux-tdep.o.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* config/alpha/tm-alpha.h: Move alpha_software_single_step
+	prototype from here...
+	* alpha-tdep.h: ...to here.
+
+2002-04-21  Andrew Cagney  <ac131313@redhat.com>
+
+	* frame.h (selected_frame_level): Document as deprecated.
+	(frame_relative_level): Declare.
+	* stack.c (frame_relative_level): New function.
+	(selected_frame_level): Document as deprecated.
+	(select_frame): Do not set the selected_frame_level.
+
+	* stack.c (frame_info, record_selected_frame): Update.
+	(frame_command, current_frame_command): Update.
+	(up_silently_base, up_command, down_silently_base): Update.
+	(down_command): Update.
+	* inflow.c (kill_command): Update.
+	* tracepoint.c (finish_tfind_command): Update.
+	* corelow.c (core_open): Update.
+	* thread.c (info_threads_command): Update.
+	(do_captured_thread_select): Update.
+	* infcmd.c (finish_command): Update.
+	* breakpoint.c (insert_breakpoints, do_enable_breakpoint): Update.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* config/alpha/tm-fbsd.h (FRAME_CHAIN_VALID): Remove.
+
+2002-04-21  Andrew Cagney  <ac131313@redhat.com>
+
+	* arm-tdep.c (arm_breakpoint_from_pc): Make static.  Make return
+	type const.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alphafbsd-tdep.c: Update copyright years.  Include
+	alpha-tdep.h.
+	(alphafbsd_use_struct_convention): Make static.
+	(alphafbsd_init_abi): New function.
+	(_initialize_alphafbsd_tdep): New function.
+	* config/alpha/tm-fbsd.h: Update copyright years.
+	(USE_STRUCT_CONVENTION): Remove.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.c (alpha_abi_handler): New structure to describe
+	an Alpha ABI variant.
+	(alpha_abi_handler_list): Declare.
+	(alpha_gdbarch_register_os_abi): New function.
+	(alpha_gdbarch_init): Give registered ABI variant handlers a
+	chance to tweak the gdbarch once we have set up defaults.
+	* alpha-tdep.h: Prototype alpha_gdbarch_register_os_abi.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.c (alpha_gdbarch_init): Set coerce_float_to_double
+	to standard_coerce_float_to_double.
+	* config/alpha/tm-alpha.h (COERCE_FLOAT_TO_DOUBLE): Remove.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.h (gdbarch_tdep): Add vm_min_address member.
+	* alpha-tdep.c (heuristic_proc_start): Use vm_min_address
+	from gdbarch_tdep rather than a constant.
+	(alpha_gdbarch_init): Initialize tdep->vm_min_address to
+	the default text address for all Alpha Unix ABIs.
+	(alpha_dump_tdep): Report the value of tdep->vm_min_address.
+	* config/alpha/tm-alpha.h (VM_MIN_ADDRESS): Delete.
+
+2002-04-21  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.h: New file.  Includes several Alpha target constants
+	taken from...
+	* config/alpha/tm-alpha.h: ...here.  Remove macros that we now
+	let gdbarch deal with.
+	(GDB_MULTI_ARCH): Define as GDB_MULTI_ARCH_PARTIAL.
+	* Makefile.in (alpha-nat.o): Add alpha-tdep.h and $(BFD_SRC)/elf-bfd
+	to dependency list.
+	* alpha-nat.c: Include alpha-tdep.h.  Update for adjusted
+	Alpha target register names.
+	* alphabsd-nat.c: Likewise.
+	* alpha-tdep.c: Include alpha-tdep.h.  Update for adjusted
+	Alpha target register names.  Make serveral routines static.
+	(alpha_get_saved_register): New function.
+	(alpha_abi_names): New.
+	(process_note_abi_tag_sections): New function.
+	(get_elfosabi): New function.
+	(alpha_gdbarch_init): New function.
+	(alpha_dump_tdep): New function.
+	(_initialize_alpha_tdep): Register alpha_gdbarch_init.
+
+2002-04-21  Andrew Cagney  <ac131313@redhat.com>
+
+	* frame.c (find_saved_register): Delete #ifdef
+	HAVE_REGISTER_WINDOWS code.
+	* config/sparc/tm-sparc.h: Update comments.
+	* config/i960/tm-i960.h (HAVE_REGISTER_WINDOWS): Delete macro.
+
+2002-04-21  Andrew Cagney  <ac131313@redhat.com>
+
+	* i960-tdep.c (i960_find_saved_register): New function.
+	(i960_get_saved_register): New function.
+	* config/i960/tm-i960.h (GET_SAVED_REGISTER): Define.
+	(i960_get_saved_register): Declare.
+	* config/i960/tm-i960.h, i960-tdep.c: Update copyright.
+
+2002-04-20  David S. Miller  <davem@redhat.com>
+
+	* sparc-nat.c (store-inferior_registers): Fix ambiguous else.
+
+2002-04-20  Andrew Cagney  <ac131313@redhat.com>
+
+	* arm-tdep.c (arm_gdbarch_init): Use gdbarch_num_pseudo_regs
+	instead of NUM_PSEUDO_REGS.
+
+2002-04-20  David S. Miller  <davem@redhat.com>
+
+	* config/sparc/tm-linux.h (GDB_MULTI_ARCH): Define to
+	GDB_MULTI_ARCH_PARTIAL
+	* config/sparc/tm-sp64linux.h (GDB_MULTI_ARCH): Do not
+	define, let tm-sp64.h do it.
+
+2002-04-20  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* frame.c (find_saved_register): Avoid a NULL pointer
+	dereference and actually walk the frame list.
+
+2002-04-20  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbarch.sh (gdbarch_update_p): Keep the list of architectures
+	sorted in most most-recent-used order.  Document.
+	* gdbarch.h, gdbarch.c: Regenerate.
+	
+2002-04-20  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/inferiors.c (struct inferior_info): Add regcache_data.
+	(add_inferior): Call create_register_cache.
+	(clear_inferiors): Call free_register_cache.
+	(inferior_regcache_data, set_inferior_regcache_data): New functions.
+	* gdbserver/regcache.c (struct inferior_regcache_data): New.
+	(registers): Remove.
+	(get_regcache): New function.
+	(create_register_cache, free_register_cache): New functions.
+	(set_register_cache): Don't initialize the register cache here.
+	(registers_to_string, registers_from_string, register_data): Call
+	get_regcache.
+	* gdbserver/regcache.h: Add prototypes.
+	* gdbserver/server.h: Likewise.
+
+2002-04-20  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/mem-break.c: New file.
+	* gdbserver/mem-break.h: New file.
+	* gdbserver/Makefile.in: Add mem-break.o rule; update server.h
+	dependencies.
+	* gdbserver/inferiors.c (struct inferior_info): Add target_data
+	member.
+	(clear_inferiors): Free target_data member if set.
+	(inferior_target_data, set_inferior_target_data): New functions.
+	* gdbserver/linux-i386-low.c (i386_breakpoint, i386_breakpoint_len)
+	(i386_stop_pc, i386_set_pc): New.  Add to the_low_target.
+	* gdbserver/linux-low.c (linux_bp_reinsert): New variable.
+	(struct inferior_linux_data): New.
+	(linux_create_inferior): Use set_inferior_target_data.
+	(linux_attach): Likewise.  Call add_inferior.
+	(linux_wait_for_one_inferior): New function.
+	(linux_wait): Call it.
+	(linux_write_memory): Add const.
+	(initialize_low): Call set_breakpoint_data.
+	* gdbserver/linux-low.h (struct linux_target_ops): Add breakpoint
+	handling members.
+	* gdbserver/server.c (attach_inferior): Remove extra add_inferior
+	call.
+	* gdbserver/server.h: Include mem-break.h.  Update inferior.c
+	prototypes.
+	* gdbserver/target.c (read_inferior_memory)
+	(write_inferior_memory): New functions.
+	* gdbserver/target.h (read_inferior_memory)
+	(write_inferior_memory): Change macros to prototypes.
+	(struct target_ops): Update comments.  Add const to write_memory
+	definition.
+
+2002-04-19  Andrew Cagney  <ac131313@redhat.com>
+
+	* sparc-tdep.c (sparc_get_saved_register): Use get_prev_frame
+	instead of ->prev.
+	* z8k-tdep.c (z8k_frame_chain): Do not use ->prev.
+	* s390-tdep.c (s390_frame_chain): Do not use ->prev.
+	* rs6000-tdep.c (frame_get_saved_regs): Use rs6000_frame_chain()
+	instead of ->prev.
+
+2002-04-19  Elena Zannoni  <ezannoni@redhat.com>
+
+        Fix PR gdb/471.
+	* gdbtypes.c (init_simd_type): Rewrite using new functions.
+	(build_builtin_type_vec128): Ditto.
+	(append_composite_type_field): Fix calculation of type length in
+	union case.
+
+2002-04-19  Eli Zaretskii  <eliz@is.elta.co.il>
+
+	* config/djgpp/README: Update.
+
+	* go32-nat.c (store_register): Cast &a_tss to `char *' to avoid a
+	compiler warnings.
+
+2002-04-19  Jason Thorpe  <thorpej@wasabisystems.com>
+
+	* alpha-tdep.c (setup_arbitrary_frame): Rename...
+	(alpha_setup_arbitrary_frame): ...to this.
+	* config/alpha/tm-alpha.h (SETUP_ARBITRARY_FRAME): Update
+	for alpha_setup_arbitrary_frame.
+
+2002-04-18  Andrew Cagney  <cagney@redhat.com>
+
+	* gdbarch.sh (BREAKPOINT_FROM_PC): Return a const buffer.
+	* gdbarch.h, gdbarch.c: Regenerate.
+	
+	* defs.h (breakpoint_from_pc_fn): Delete type definition.
+	* target.h (memory_breakpoint_from_pc): Update declaration.
+	* config/mcore/tm-mcore.h (mcore_breakpoint_from_p): Ditto.
+
+	* arch-utils.c (legacy_breakpoint_from_pc): Update return type.
+	* mcore-tdep.c (mcore_breakpoint_from_pc): Ditto.
+	* mem-break.c (memory_breakpoint_from_pc): Ditto.
+	* rs6000-tdep.c (rs6000_breakpoint_from_pc): Ditto.
+	* s390-tdep.c (s390_breakpoint_from_pc): Ditto
+	* xstormy16-tdep.c (xstormy16_breakpoint_from_pc): Ditto.
+	* mn10300-tdep.c (mn10300_breakpoint_from_pc): Ditto.
+	* mips-tdep.c (mips_breakpoint_from_pc): Ditto.
+	* m68hc11-tdep.c (m68hc11_breakpoint_from_pc): Ditto.
+	* ia64-tdep.c (ia64_breakpoint_from_pc): Ditto.
+	* d10v-tdep.c (d10v_breakpoint_from_pc): Ditto.
+	* arch-utils.c (legacy_breakpoint_from_pc): Ditto..
+
+	* mem-break.c (default_memory_insert_breakpoint): Make `bp' a
+	const pointer.
+	* monitor.c (monitor_insert_breakpoint): Ditto.
+	* rs6000-tdep.c (rs6000_software_single_step): Ditto for `breakp'.
+
+	* config/mcore/tm-mcore.h: Update copyright.
+	* mem-break.c: Ditto.
+	* xstormy16-tdep.c: Ditto.
+
+2002-04-18  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* p-exp.y: Add precedence rule for '^' token.
+	This removes the shift/reduce conflicts.
+	Remove the comment concerning these shift/reduce conflicts.
+
+2002-04-18  Elena Zannoni  <ezannoni@redhat.com>
+
+	* rs6000-tdep.c (COMMON_UISA_NOFP_REGS): New macro.
+	(registers_powerpc_nofp): New register set for processors
+	without floating point unit.
+
+2002-04-18  David S. Miller  <davem@redhat.com>
+
+	* MAINTAINERS: Add myself to write-after-approval.
+
+2002-04-17  Michael Snyder  <msnyder@redhat.com>
+
+	* MAINTAINERS: Add myself as co-maintainer of testsuite/gdb.asm.
+
+2002-04-17  Andrew Cagney  <ac131313@redhat.com>
+
+	* rs6000-tdep.c (frame_initial_stack_address): Use
+	frame_register_read to read the alloca_reg.
+
+2002-04-17  Andrew Cagney  <ac131313@redhat.com>
+
+	* frame.c (find_saved_register): Find saved registers in the next
+	not prev frame.
+	Fix PR gdb/365.
+
+2002-04-17  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbarch.sh (LANG): Set to ``c''.
+
+2002-04-15  Andrew Cagney  <ac131313@redhat.com>
+ 
+ 	* PROBLEMS: Mention hppa2.0-hp-hpux10.20 compile problems.
+ 
+2002-04-15  Andrew Cagney  <ac131313@redhat.com>
+
+	* bcache.c: Include <stddef.h> and <stdlib.h> after "defs.h".
+	Update copyright.
+
+ 	* hpread.c (hpread_get_lntt): Add declaration.
+ 	Also fix PR gdb/391.
+ 
+2002-04-14  Andrew Cagney  <ac131313@redhat.com>
+
+	* acinclude.m4 (AM_PROG_CC_STDC): Import from automake 1.6.
+	* aclocal.m4, configure: Re-generate.
+	Fix PR gdb/391.
+	
+2002-04-14  Elena Zannoni  <ezannoni@redhat.com>
+
+        * mi/mi-cmd-disas.c (dump_insns): Use TARGET_PRINT_INSN
+        instead of tm_print_insn.
+
+2002-04-14  Elena Zannoni  <ezannoni@redhat.com>
+
+	* ppc-bdm.c (bdm_ppc_fetch_registers): Fix typo.
+
+2002-04-14  Andrew Cagney  <ac131313@redhat.com>
+
+	* config/pa/tm-hppa.h (FRAME_CHAIN_COMBINE): Delete macro.
+	* blockframe.c (FRAME_CHAIN_COMBINE): Delete macro.
+	(get_prev_frame): Do not call FRAME_CHAIN_COMBINE.
+
+2002-04-12  Don Howard  <dhoward@redhat.com>
+
+	* cli/cli-cmds.c (init_cli_cmds): Add new user settable value:
+	max_user_call_depth.
+	(init_cmd_lists): Initialize the new value;
+	* cli/cli-script.c (execute_user_command): Limit the call depth of
+	user defined commands.  This avoids a core-dump when user commands
+	are infinitly recursive.
+
+2002-04-12  Kevin Buettner  <kevinb@redhat.com>
+
+	* ppc-tdep.h (struct gdbarch_tdep): Add new member ``lr_frame_offset''.
+	* rs6000-tdep.c (rs6000_frame_saved_pc): Use ``lr_frame_offset''
+	from tdep struct instead of DEFAULT_LR_SAVE.
+	(rs6000_gdbarch_init): Initialize ``lr_frame_offset''.
+	* config/powerpc/tm-ppc-eabi.h (DEFAULT_LR_SAVE): Delete.
+	* config/rs6000/tm-rs6000.h (DEFAULT_LR_SAVE): Delete.
+
+2002-04-12  Michael Snyder  <msnyder@redhat.com>
+
+	* Remote.c: Spelling fix.
+	* gcore.c (default_derive_heap_segment): Use bfd_section_name.
+	If no symbol found for "sbrk", try "_sbrk".
+	(make_output_phdrs): Use bfd_section_name.
+	(gcore_copy_callback): Use bfd_section_name.
+	* eval.c: Indentation fix-ups.
+	* d10v-tdep.c (d10v_make_iaddr): Make it idempotent,
+	in case it gets applied to an address that is already
+	in the instruction space.
+	* cli/cli-decode.c (help_list): Allow long lines to wrap.
+	* symfile.c: Fix indentation, long lines.
+	* source.c: White space fix-up.
+
+2002-04-12  Andrew Cagney  <cagney@redhat.com>
+
+	* defs.h (read_relative_register_raw_bytes): Delete declaration.
+	* frame.c (frame_register_read): New function.  Return non-zero on
+	success.
+	(read_relative_register_raw_bytes_for_frame): Delete.
+	(read_relative_register_raw_bytes): Delete.
+	* frame.h (frame_register_read): Declare.
+	* d30v-tdep.c: Update Copyright.  Use frame_register_read.
+	* sh-tdep.c: Ditto.
+	* infcmd.c (do_registers_info): Ditto.
+	* hppa-tdep.c: Ditto.
+	* rs6000-tdep.c: Ditto.
+	* h8500-tdep.c: Ditto.
+	* mips-tdep.c: Ditto.
+	* h8300-tdep.c: Ditto.
+	* z8k-tdep.c: Ditto.
+
+2002-04-12  Kevin Buettner  <kevinb@redhat.com>
+
+	From Jimi X <jimix@watson.ibm.com>:
+	* rs6000-tdep.c (rs6000_gdbarch_init): Use rs6000_* methods for
+	64-bit SysV ABI.
+
+2002-04-12  Kevin Buettner  <kevinb@redhat.com>
+
+	From Jimi X <jimix@watson.ibm.com>:
+	* rs6000-tdep.c (rs6000_gdbarch_init): Compute ``wordsize'' from
+	bfd info.
+
+2002-04-12  Kevin Buettner  <kevinb@redhat.com>
+
+	From Jimi X <jimix@watson.ibm.com>:
+	* rs6000-tdep.c (powerpc64, 630, rs64ii, rs64iii): Define
+	register sets for these processor variants.
+
+2002-04-11  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/linux-low.c (usr_store_inferior_registers): Support
+	registers which are allowed to fail to store.
+	* gdbserver/linux-low.h (linux_target_ops): Likewise.
+	* gdbserver/linux-ppc-low.c (ppc_regmap): Support FPSCR.
+	(ppc_cannot_store_register): FPSCR may not be storable.
+	* regformats/reg-ppc.dat: Support FPSCR.
+
+2002-04-11  Kevin Buettner  <kevinb@redhat.com>
+
+	* ppc-tdep.h (struct gdbarch_tdep): Add new field ``ppc_fpscr_regnum''.
+	* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
+	Add fpscr as an invalid/unfetchable register.
+	* ppc-linux-nat.c (ppc_register_u_addr, store_register)
+	(fetch_ppc_registers, store_ppc_registers, supply_fpregset)
+	(fill_fpregset): Add support for register fpscr.
+	(fetch_ppc_registers, store_ppc_registers, supply_gregset)
+	(fill_gregset): Account for the fact that register ``mq'' might
+	not exist.
+	* rs6000-tdep.c (PPC_UISA_SPRS): Use (unused) slot 70 for fpscr.
+	(registers_power): Add fpscr to register set at slot 71.
+	(rs6000_gdbarch_init): Account for the fact that ``mq'' doesn't
+	exist on most PPC architectures.  Initialize ppc_fpscr_regnum.
+
+2002-04-11  Michael Snyder  <msnyder@redhat.com>
+
+	* configure.in: Autoconfiscate _SYSCALL32 define for solaris.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+	* acconfig.h: Add define for _SYSCALL32.
+	* core-sol2.c: Remove #define _SYSCALL32.
+	* solib-legacy.c: Remove #define _SYSCALL32.
+
+2002-04-10  Andrew Cagney  <ac131313@redhat.com>
+
+	* stack.c (select_frame): Cleanup internal error message, do not
+	use %p.
+
+2002-04-10  Andrew Cagney  <ac131313@redhat.com>
+
+	* stack.c (select_frame): Check that selected_frame and the
+	specified level are as expected.
+	* blockframe.c (get_prev_frame): Set the `level' from next_frame.
+	Update copyright.
+	* frame.h (struct frame_info): Add field `level'.  Update
+	copyright.
+	Work-in-progress PR gdb/464.
+
+2002-04-10  Andrew Cagney  <ac131313@redhat.com>
+
+	* maint.c (maint_print_section_info): Rename print_section_info.
+	(print_bfd_section_info, print_objfile_section_info): Update.
+	* inferior.h (struct gdbarch): Add opaque declaration.
+	* gdbarch.sh: Add include of "inferior.h" to gdbarch.sh.
+	* gdbarch.h: Regenerate.
+
+2002-04-10  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-linux-nat.c (child_resume, child_xfer_memory): Delete.
+	(PTRACE_XFER_TYPE): Moved to config/i386/nm-x86-64.h.
+	(kernel_u_size): Added.
+	* config/i386/nm-x86-64.h (CHILD_XFER_MEMORY, CHILD_RESUME): Delete.
+	(PTRACE_XFER_TYPE): Moved here from config/i386/nm-x86-64.h.
+
+2002-04-04  Jim Ingham  <jingham@apple.com>
+ 
+       * valarith.c (find_size_for_pointer_math): New function, either returns
+       the size for a pointer's target, returns 1 for void *, or errors for
+       incomplete types.
+       (value_add, value_sub): use find_size_for_pointer_math.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* linux-low.c (linux_look_up_symbols): New hook.
+	(linux_target_ops): Add linux_look_up_symbols.
+	* remote-utils.c (decode_address): New function.
+	(look_up_one_symbol): New function.
+	* server.c (handle_query): Call target look_up_symbols hook.
+	* server.h (look_up_one_symbol): Add prototype.
+	* target.h (struct target_ops): Add look_up_symbols hook.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/server.h: Include <string.h> if HAVE_STRING_H.
+	* ChangeLog: Correct paths in last ChangeLog entry.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/linux-low.h: Remove obsolete prototypes.
+	(struct linux_target_ops): New.
+	(extern the_low_target): New.
+	* gdbserver/linux-low.c (num_regs, regmap): Remove declarations.
+	(register_addr): Use the_low_target explicitly.
+	(fetch_register): Likewise.
+	(usr_fetch_inferior_registers): Likewise.
+	(usr_store_inferior_registers): Likewise.
+	* gdbserver/linux-arm-low.c (num_regs): Remove.
+	(arm_num_regs): Define.
+	(arm_regmap): Renamed from regmap, made static.
+	(arm_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(arm_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-i386-low.c (num_regs): Remove.
+	(i386_num_regs): Define.
+	(i386_regmap): Renamed from regmap, made static.
+	(i386_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(i386_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-ia64-low.c (num_regs): Remove.
+	(ia64_num_regs): Define.
+	(ia64_regmap): Renamed from regmap, made static.
+	(ia64_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(ia64_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-m68k-low.c (num_regs): Remove.
+	(m68k_num_regs): Define.
+	(m68k_regmap): Renamed from regmap, made static.
+	(m68k_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(m68k_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-mips-low.c (num_regs): Remove.
+	(mips_num_regs): Define.
+	(mips_regmap): Renamed from regmap, made static.
+	(mips_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(mips_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-ppc-low.c (num_regs): Remove.
+	(ppc_num_regs): Define.
+	(ppc_regmap): Renamed from regmap, made static.
+	(ppc_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(ppc_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-s390-low.c (num_regs): Remove.
+	(s390_num_regs): Define.
+	(s390_regmap): Renamed from regmap, made static.
+	(s390_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(s390_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-sh-low.c (num_regs): Remove.
+	(sh_num_regs): Define.
+	(sh_regmap): Renamed from regmap, made static.
+	(sh_cannot_fetch_register): Renamed from cannot_fetch_register,
+	made static.
+	(sh_cannot_store_register): Renamed from cannot_store_register,
+	made static.
+	(the_low_target): New.
+	* gdbserver/linux-x86-64-low.c (x86_64_regmap): Renamed from regmap.
+	(the_low_target): New.
+
+2002-04-09  Andrew Cagney  <ac131313@redhat.com>
+
+	* frame.c (read_relative_register_raw_bytes_for_frame): Do not
+	override FP_REGNUM with frame->fp.  Update copyright.
+	* parse.c (num_std_regs, std_regs): Delete.
+	(target_map_name_to_register): Do not search std_regs.  Update
+	function description.
+	* parser-defs.h (num_std_regs, std_regs, struct std_regs): Delete
+	declarations.  Update copyright.
+	Fix PR gdb/251.
+	
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/Makefile.in: Add stamp-h target.
+	* gdbserver/configure.in: Create stamp-h.
+	* gdbserver/configure: Regenerated.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/inferiors.c: New file.
+	* gdbserver/target.c: New file.
+	* gdbserver/target.h: New file.
+	* gdbserver/Makefile.in:  Add target.o and inferiors.o.  Update
+	dependencies.
+	* gdbserver/linux-low.c (inferior_pid): New static variable,
+	moved from server.c.
+	(linux_create_inferior): Renamed from create_inferior.
+	Call add_inferior.  Return 0 on success instead of a PID.
+	(linux_attach): Renamed from myattach.
+	(linux_kill): Renamed from kill_inferior.  Call clear_inferiors ().
+	(linux_thread_alive): Renamed from mythread_alive.
+	(linux_wait): Renamed from mywait.  Call clear_inferiors () if the
+	child dies.
+	(linux_resume): Renamed from myresume.  Add missing ``return 0''.
+	(regsets_store_inferior_registers): Correct error message.
+	Add missing ``return 0''.
+	(linux_fetch_registers): Renamed from fetch_inferior_registers.
+	(linux_store_registers): Renamed from store_inferior_registers.
+	(linux_read_memory): Renamed from read_inferior_memory.
+	(linux_write_memory): Renamed from write_inferior_memory.
+	(linux_target_ops): New structure.
+	(initialize_low): Call set_target_ops ().
+	* gdbserver/remote-utils.c (unhexify): New function.
+	(hexify): New function.
+	(input_interrupt): Send signals to ``signal_pid''.
+	* gdbserver/server.c (inferior_pid): Remove.
+	(start_inferior): Update create_inferior call.
+	(attach_inferior): Call add_inferior.
+	(handle_query): New function.
+	(main): Call handle_query for `q' packets.
+	* gdbserver/server.h: Include "target.h".  Remove obsolete prototypes.
+	Add prototypes for "inferiors.c", "target.c", hexify, and unhexify.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/Makefile.in: Add WARN_CFLAGS.  Update configury
+	dependencies.
+	* gdbserver/configure.in: Check for <string.h>
+	* gdbserver/configure: Regenerate.
+	* gdbserver/config.in: Regenerate.
+	* gdbserver/gdbreplay.c: Include needed system headers.
+	(remote_open): Remove strchr prototype.
+	* gdbserver/linux-low.h: Correct #ifdef to HAVE_LINUX_USRREGS.
+	* gdbserver/regcache.c (supply_register): Change buf argument to const void *.
+	(supply_register_by_name): Likewise.
+	(collect_register): Change buf argument to void *.
+	(collect_register_by_name): Likewise.
+	* gdbserver/regcache.h: Add missing prototypes.
+	* gdbserver/remote-utils.c: Include <arpa/inet.h> for inet_ntoa.
+	* gdbserver/server.c (handle_query): New function.
+	(attached): New static variable, moved out of main.
+	(main): Quiet longjmp clobber warnings.
+	* gdbserver/server.h: Add ATTR_NORETURN and ATTR_FORMAT.  Update prototypes.
+	* gdbserver/utils.c (error): Remove NORETURN.
+	(fatal): Likewise.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* symtab.h (ALL_BLOCK_SYMBOLS): Don't dereference the pointer
+	after the last symbol in a block.
+
+2002-04-09  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* p-exp.y (yylex): Handle also the fact that is_a_field_of_this
+	is non zero as a found symbol.
+
+2002-04-08  Andrew Cagney  <ac131313@redhat.com>
+
+	* findvar.c: Include "builtin-regs.h".
+	(value_of_register): Call value_of_builtin_reg when applicable.
+	* parse.c: Include "builtin-regs.h" and "gdb_assert.h".
+	(target_map_name_to_register): Call
+	builtin_reg_map_name_to_regnum.
+	* Makefile.in (SFILES): Add builtin-regs.c and std-regs.c.
+	(COMMON_OBS): Add builtin-regs.o and std-regs.o.
+	(builtin_regs_h): Define.
+	(builtin-regs.o): New target.
+	(findvar.o): Add $(builtin_regs_h).
+	* builtin-regs.c, builtin-regs.h: New files.
+	* std-regs.c: New file.
+	Partial fix for PR gdb/251.
+
+2002-04-08  Kevin Buettner  <kevinb@redhat.com>
+
+	* rs6000-tdep.c (rs6000_gdbarch_init): Don't set tm_print_insn;
+	it's no longer required.
+
+2002-04-08  Andrew Cagney  <ac131313@redhat.com>
+
+	* Makefile.in (gdbtk-wrapper.o): Add missing dependencies.
+
+2002-04-08  Kevin Buettner  <kevinb@redhat.com>
+
+	From Jimi X <jimix@watson.ibm.com>:
+	* rs6000-tdep.c (rs6000_software_single_step): Use
+	rs6000_breakpoint_from_pc() to fetch breakpoint instruction
+	and size.  Use target_insert_breakpoint() and
+	target_remove_breakpoint() to insert and remove breakpoints
+	instead of explicit memory reads and writes.
+
+2002-04-08  Kevin Buettner  <kevinb@redhat.com>
+
+	* config/powerpc/tm-ppc-eabi.h (ELF_OBJECT_FORMAT): Delete.
+	* rs6000-tdep.c (rs6000_push_arguments): Eliminate
+	ELF_OBJECT_FORMAT ifdef.
+
+2002-04-08  Kevin Buettner  <kevinb@redhat.com>
+
+	From Jimi X <jimix@watson.ibm.com>:
+	* rs6000-tdep.c (rs6000_gdbarch_init): Use set_gdbarch_print_insn().
+
+2002-04-08  Kevin Buettner  <kevinb@redhat.com>
+
+	From Jimi X <jimix@watson.ibm.com>:
+	* rs6000-tdep.c (rs6000_fix_call_dummy): Delete unused macro
+	definitions for TOC_ADDR_OFFSET and TARGET_ADDR_OFFSET.
+
+2002-04-07  Mark Kettenis  <kettenis@gnu.org>
+
+	* fbsd-proc.c (child_pid_to_exec_file, fbsd_find_memory_regions):
+	s/asprintf/xasprintf/.
+	(fbsd_make_corefile_notes): s/strdup/xstrdup/.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	I believe Jeff Law denies responsability for this one:
+	* config/pa/hpux11w.mh (MH_CFLAGS): Add -Dvfork=fork.
+	* config/pa/hpux11.mh (MH_CFLAGS): Add -Dvfork=fork.
+	* config/pa/hpux1020.mh (MH_CFLAGS): Add -Dvfork=fork.
+	Work-around for PR gdb/366.
+
+2002-04-07  Elena Zannoni  <ezannoni@redhat.com>
+
+	* remote-e7000.c (write_small, e7000_read_inferior_memory,
+	e7000_read_inferior_memory_large, e7000_insert_breakpoint,
+	e7000_remove_breakpoint): Use paddr_nz() to print addresses.
+
+2002-04-07  Elena Zannoni  <ezannoni@redhat.com>
+
+	* sh-tdep.c (sh_fp_frame_init_saved_regs,
+	sh_nofp_frame_init_saved_regs): Use alloca() for 'where'
+	information.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* MAINTAINERS (Misc): List Daniel Jacobowitz as the GDBSERVER
+	maintainer.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* README (Reporting Bugs in GDB): Document the bug web page as the
+	prefered way of submitting bugs.
+	Fix PR gdb/402.
+
+2002-04-06  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbarch.sh (FP_REGNUM, PC_REGNUM, SP_REGNUM): Allow default of
+	-1.  Update comment.
+	* gdbarch.h, gdbarch.c: Re-generate.
+
+2002-04-07  Andreas Schwab  <schwab@suse.de>
+
+	* m68klinux-nat.c (fill_fpregset): Properly pass address of
+	buffer to regcache_collect.
+
+2002-04-06  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbarch.sh (PS_REGNUM): Add.  Document.  Default to -1.
+	* gdbarch.c, gdbarch.h: Re-generate.
+
+2002-04-06  Andrew Cagney  <ac131313@redhat.com>
+
+	* symtab.c (lookup_symtab): Remove ``const'' from ``rp''
+	declaration.  Fix -Werror.
+
+2002-04-05  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbarch.sh (initialize_non_multiarch): Call init_gdbarch_swap.
+	* gdbarch.c: Regenerate.
+
+2002-04-05  Michael Snyder  <msnyder@redhat.com>
+
+	* breakpoint.c (clear_command): Rewrite middle section to
+	combine two loops with identical control conditions.
+	Add a cleanup to eliminate a memory leak.
+	* cli/cli-dump.c (restore_section_callback): Use paddr_nz.
+
+2002-04-05  H.J. Lu  (hjl@gnu.org)
+
+	* solib-svr4.c (bkpt_names): Add "__start".
+
+2002-04-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* sparc-tdep.c (sparc_push_dummy_frame): Use GDB_TARGET_IS_SPARC64
+	as test for 64 bit target.
+
+2002-04-05  Andrew Cagney  <ac131313@redhat.com>
+
+	* h8500-tdep.c (h8500_write_fp): Delete function.
+	* dwarf2cfi.c (cfi_write_fp): Document as not used.
+	* mips-tdep.c (mips_gdbarch_init): Do not set write_fp.
+	* ia64-tdep.c (ia64_gdbarch_init): Do not set write_fp.
+	* m68hc11-tdep.c (m68hc11_gdbarch_init): Do not set write_fp.
+	* rs6000-tdep.c (rs6000_gdbarch_init): Do not set write_fp.
+	* s390-tdep.c (s390_gdbarch_init): Do not set write_fp.
+	(s390_write_fp):
+	* sh-tdep.c (sh_gdbarch_init): Do not set write_fp.
+	* x86-64-tdep.c (i386_gdbarch_init): Do not set write_fp.
+	* d10v-tdep.c (d10v_gdbarch_init): Do not set write_fp.
+	(d10v_write_fp): Delete function.
+	* inferior.h (write_fp, generic_target_write_fp): Delete
+	declarations.
+	* regcache.c (generic_target_write_fp): Delete function.
+	(write_fp): Delete function.
+	* gdbarch.sh (TARGET_WRITE_FP): Delete.
+	* gdbarch.h, gdbarch.c: Regenerate.
+	* config/v850/tm-v850.h (TARGET_WRITE_FP): Delete macro.
+	* config/sparc/tm-sp64.h (TARGET_WRITE_FP): Delete macro.
+	(sparc64_write_fp): Delete declaration.
+	* config/h8500/tm-h8500.h (TARGET_WRITE_FP): Delete macro.
+	(h8500_write_fp): Delete declaration.
+
+2002-04-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* sparc-tdep.c (sparc64_write_fp): Delete.
+	(sparc_push_dummy_frame): Replace write_fp call with code to store
+	the FP directly.
+	(sparc_gdbarch_init): Do not initialize write_fp.
+
+2002-04-05  Kevin Buettner  <kevinb@redhat.com>
+
+	* rs6000-tdep.c (skip_prologue): Eliminate unused/unreachable
+	clause.
+
+2002-03-29  Jim Blandy  <jimb@redhat.com>
+
+	* stack.c (get_selected_block): Add new argument `addr_in_block',
+	used to return the exact code address we used to select the block,
+	not just the block.
+	* blockframe.c (get_frame_block, get_current_block): Same.
+	* frame.h (get_frame_block, get_current_block,
+	get_selected_block): Update declarations.
+	* linespec.c, stack.c, blockframe.c, breakpoint.c, findvar.c,
+	linespec.c, varobj.c, printcmd.c, symtab.c: Callers changed.
+
+2002-04-05  Michael Snyder  <msnyder@redhat.com>
+
+	* breakpoint.c (insert_breakpoints): Change 'hw' to 'hardware in
+	warning message.
+
+2002-04-05  J. Brobecker  <brobecker@gnat.com>
+
+	* utils.c (xfullpath): New function.
+	* defs.h (xfullpath): Add declaration.
+	* source.c (openp): Use xfullpath in place of gdb_realpath to
+	avoid resolving the basename part of filenames when the
+	associated file is a symbolic link. This fixes a potential
+	inconsistency between the filenames known to GDB and the
+	filenames it prints in the annotations.
+	* symtab.c (lookup_symtab): Use the new xfullpath function, in order
+	to be able to match a filename with either the real filename, or
+	the name of any symbolic link to this file.
+	(lookup_partial_symtab): Ditto.
+
+2002-04-04  Michael Snyder  <msnyder@redhat.com>
+
+	* breakpoint.c: Add support for hardware breakpoints in overlays.
+	(overlay_events_enabled): New state variable.
+	(insert_breakpoints): Use overlay_events_enabled to decide
+	whether to attempt to set a breakpoint at the overlay load addr.
+	Handle bp_hardware_breakpoint as well as bp_breakpoint.
+	(remove_breakpoint): Use overlay_events_enabled to decide
+	whether breakpoints need to be removed from overlay load addr.
+	Handle bp_hardware_breakpoint as well as bp_breakpoint.
+	(bpstat_stop_status): Handle bp_hardware_breakpoint in overlays.
+	(create_overlay_event_breakpoint, enable_overlay_breakpoints, 
+	disable_overlay_breakpoints): Update overlay_events_enabled.
+
+2002-04-04  Daniel Jacobowitz  <drow@mvista.com>
+
+	* dwarf2read.c (struct function_range): New.
+	(cu_first_fn, cu_last_fn, cu_cached_fn): New.
+	(check_cu_functions): New.
+	(read_file_scope): Initialize global function lists.
+	Call dwarf_decode_line after processing children.
+	(read_func_scope): Add to global function list.
+	(dwarf_decode_lines): Call check_cu_functions everywhere
+	record_line is called.  Call record_line with a linenumber
+	of 0 to mark sequence ends.
+
+2002-04-04  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-linux-nat.c (child_xfer_memory): x86-64 ptrace() ABI 
+	change sync with glibc.
+
+2002-04-03  Jim Blandy  <jimb@redhat.com>
+
+	* configure.in: Call AC_C_INLINE.
+	* configure: Regenerated.
+	
+2002-04-01  Daniel Jacobowitz  <drow@mvista.com>
+
+	* rs6000-tdep.c: Change #include of "bfd/libcoff.h"
+	and "bfd/libbfd.h" to "libcoff.h" and "libbfd.h".
+
+2002-03-31  Mark Kettenis  <kettenis@gnu.org>
+
+	* NEWS: Mention gcore support on FreeBSD/i386.
+
+	* fbsd-proc.c: New file.
+	* config/i386/nm-fbsd.h (CHILD_PID_TO_EXEC_FILE): Define.
+	* config/i386/fbsd.mh (NATDEPFILES): Add gcore.o and fbsd-proc.o.
+
+	* lin-lwp.c (child_wait): Check SAVE_ERRNO instead of ERRNO in
+	while statement.
+
+2002-03-29  Jim Blandy  <jimb@redhat.com>
+
+	* cli/cli-dump.c (_initialize_cli_dump): Older GCC's tolerate
+	unescaped newlines in string literals, but newer ones don't.  So
+	escape them.
+
+2002-03-26  Michael Snyder  <msnyder@redhat.com>
+	    Andrew Cagney <cagney@redhat.com>
+
+	* cli/cli-dump.c: New file.  Dump memory to file, 
+	restore file to memory.
+	* cli/cli-dump.h: New file.
+	* Makefile.in: Add rules, dependencies for cli-dump.o.
+	* NEWS: Mention new commands.
+
+2002-03-28  Michael Snyder  <msnyder@redhat.com>
+
+	* symfile.c (symbol_file_add): Move test for null symbols to later.
+
+2002-03-27  Andrew Cagney  <ac131313@redhat.com>
+
+	From veksler at il.ibm.com:
+	* utils.c (gdb_realpath): If canonicalize_file_name fails, return
+	the xstrduped original path.
+	Fix PR gdb/417.
+
+2002-03-27  Michael Snyder  <msnyder@redhat.com>
+
+	* breakpoint.c (_initialize_breakpoint): Clean up help string.
+	* infcmd.c (_initialize_infcmd): Ditto.
+	* language.c (_initialize_language): Ditto.
+	* symfile.c (_initialize_symfile): Ditto.
+	* top.c (_init_main): Ditto.
+	* cli/cli-cmds.c (init_cli_cmds): Ditto.
+
+2002-03-27  Elena Zannoni  <ezannoni@redhat.com>
+
+	* rs6000-tdep.c (struct rs6000_framedata): Add fields for AltiVec
+	vector registers handling.
+	(skip_prologue): Handle new AltiVec instructions.  Fill in new
+	fields of frame data.
+	(frame_get_saved_regs): Fill in information for AltiVec registers.
+
+2002-03-27  Jim Blandy  <jimb@redhat.com>
+
+	* symtab.h (SYMBOL_INIT_MANGLED_NAME): Turn this macro's body into
+	a function; leave this macro here to invoke that function.
+	(symbol_init_mangled_name): Declaration for that function.
+	* symtab.c (symbol_init_mangled_name): New function.
+
+2002-03-27  Andrew Cagney  <ac131313@redhat.com>
+
+	* valarith.c: Replace strerror with safe_strerror.
+	* tracepoint.c: Ditto.
+	* lin-lwp.c: Ditto.
+	* go32-nat.c: Ditto.
+	* inflow.c: Ditto.
+	* gnu-nat.c: Ditto.
+
+2002-03-27  Andreas Schwab  <schwab@suse.de>
+
+	* event-top.c (command_line_handler): Remove useless if.
+
+2002-03-27  Andreas Jaeger  <aj@suse.de>
+
+	* dwarf2cfi.c: Give credit to Daniel Berlin, reformat copyright
+	comment.
+
+2002-03-27  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-tdep.h (X86_64_NUM_REGS, X86_64_NUM_GREGS): Delete #defines.
+	(x86_64_num_regs, x86_64_num_gregs): Added extern variables.
+	* x86-64-linux-nat.c (x86_64_regmap): Swapped RBX <> RDX, added DS, ES, FS, GS.
+	(x86_64_linux_dr_get_status, supply_gregset),
+	(fill_gregset): Changed X86_64_NUM_GREGS to x86_64_num_gregs.
+	* x86-64-tdep.c (x86_64_register_raw_size_table): Delete.
+	(x86_64_register_info_table): Add.
+	(X86_64_NUM_REGS, X86_64_NUM_GREGS): Add.
+	(x86_64_register_raw_size, x86_64_register_virtual_type),
+	(x86_64_register_name, _initialize_x86_64_tdep): Changed to reflect new
+	general x86_64_register_info_table.
+	(i386_gdbarch_init): gdbarch_register_bytes is now set
+	dynamicaly during initialization.
+	* regformats/reg-x86-64.dat: Synced with changes to registers above.
+	* gdbserver/linux-x86-64-low.c: Ditto.
+
+2002-03-27  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/server.c (main): Call target_signal_to_host_p
+	and target_signal_to_host on signals received from the remote.
+	* gdbserver/remote-utils.c (prepare_resume_reply): Call
+	target_signal_from_host on signals sent to the remote.
+	* gdbserver/server.h: Add prototypes.  Include "gdb/signals.h".
+	* gdbserver/Makefile.in: Add signals.o.  Add -I${INCLUDE_DIR}.
+
+2002-03-27  Daniel Jacobowitz  <drow@mvista.com>
+
+	* signals/signals.c: Include "server.h" in gdbserver build.
+	(target_signal_from_name): Don't use STREQ.
+	(_initialize_signals): Likewise.  Don't include function in
+	gdbserver build.
+
+2002-03-27  Daniel Jacobowitz  <drow@mvista.com>
+
+	* signals.c: Moved to...
+	* signals/signals.c: Here.
+	* Makefile (signals.o): Update.
+
+2002-03-26  Jeff Law (law@redhat.com)
+
+	* somread.c (som_symtab_read): Remove some commented out code and
+	updated related comments.  Do not set the minimal symbol table to
+	mst_solib_trampoline for ST_ENTRY symbols with SS_LOCAL scope
+	in a dynamic executable.
+	* hppa-tdep.c (find_proc_framesize): Sanely handle the case
+	where we are unable to find the minimal symbol for the given
+	PC value.
+
+2002-03-25  Jeff Law (law@redhat.com)
+
+	* linux-proc.c (read_mapping): Scan up to end of line for filename.
+
+2002-03-25  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-tdep.c (x86_64_skip_prologue): Rewritten from scratch.
+
+2002-03-23  Andrew Cagney  <ac131313@redhat.com>
+
+	* command.h: Update copyright.
+	(struct cmd_list_element): Replace definition with opaque
+	declaration.
+	(enum cmd_types): Document that it will eventually be moved to
+	cli/cli-decode.h
+	(CMD_DEPRECATED, DEPRECATED_WARN_USER): Delete macros.
+	(MALLOCED_REPLACEMENT): Delete macro.
+	* Makefile.in (cli_decode_h): Add $(command_h).
+	(top.o, completer.o, maint.o): Add dependency on $(cli_decode_h).
+	* top.c: Include "cli/cli-decode.h".
+	* completer.c: Include "cli/cli-decode.h".
+	* maint.c: Include "cli/cli-decode.h".
+	* cli/cli-decode.h: Include "command.h".
+	(enum command_class): Delete.
+	(enum cmd_types): Comment out.
+	(enum cmd_auto_boolean): Delete.
+	(enum var_types): Delete.
+
+2002-03-23  Andrew Cagney  <ac131313@redhat.com>
+
+	* cli/cli-decode.c: Include "gdb_assert.h".
+	(add_set_or_show_cmd): New static function.
+	(add_set_cmd): Rewrite.  Use add_set_or_show_cmd.
+	(add_show_from_set): Rewrite. Use add_set_or_show_cmd.  Don't copy
+	all fields, such as func, from the set command.
+
+2002-03-23  Andrew Cagney  <ac131313@redhat.com>
+
+	* MAINTAINERS (sh-elf): Change warning flag to -w.
+
+2002-03-23  Andrew Cagney  <cagney@redhat.com>
+
+	* defs.h (error): Add printf format attribute.
+	* thread-db.c (thread_from_lwp): Fix error format string.
+	* stack.c (parse_frame_specification): Ditto.
+	* cli/cli-decode.c (undef_cmd_error): Ditto.
+	* scm-lang.c (scm_lookup_name): Ditto.
+	* tracepoint.c (trace_error): Ditto.
+	* remote-utils.c (usage): Ditto.
+	* remote.c (compare_sections_command): Ditto.
+	Fix PR gdb/328.
+
+2002-03-22  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbtypes.c (append_composite_type_field): New function.
+	(init_composite_type): New function.
+	* gdbtypes.h (append_composite_type_field): Declare.
+	(init_composite_type): Ditto.
+
+2002-03-22  Elena Zannoni  <ezannoni@redhat.com>
+
+        * ppc-linux-tdep.c (ppc_sysv_abi_use_struct_convention): New
+        function.
+	* ppc-tdep.h (ppc_sysv_abi_use_struct_convention): Export.
+        * rs6000-tdep.c (rs6000_gdbarch_init): Use different
+        structure returning convention for SYSV ABI case, but not
+        for GNU/Linux, FreeBSD, or NetBSD.
+
+2002-03-22  Daniel Jacobowitz  <drow@mvista.com>
+
+	* symtab.h (lookup_block_symbol): Add mangled_name argument
+	to prototype.
+
+	* symmisc.c (maintenance_check_symtabs): Call lookup_block_symbol
+	with new mangled_name argument.
+	* linespec.c (decode_line_1): Likewise.
+	* valops (value_of_this): Likewise.
+	* symtab.c (lookup_transparent_type): Likewise.
+	(lookup_symbol_aux): Likewise.  Accept new mangled_name argument.
+	(lookup_symbol): If we are given a mangled name, pass it down
+	to lookup_symbol_aux.
+	(lookup_block_symbol): If we are given a mangled name to check
+	against, only return symbols which match it.
+
+2002-03-22  Christopher Faylor  <cgf@redhat.com>
+
+	* win32-nat.c (child_create_inferior): Check for proper shell to use
+	here, in case the user changes it on the fly.
+	(_initialize_inftarg): Remove shell path considerations.
+
+2002-03-21  Elena Zannoni  <ezannoni@redhat.com>
+
+	* rs6000-tdep.c (rs6000_gdbarch_init): Use correct max size value
+	for gdbarch_max_register_raw_size and max_register_virtual_size.
+	Adjust copyright year.
+
+2002-03-21  Daniel Jacobowitz  <drow@mvista.com>
+
+	 * dbxread.c (process_one_symbol): Extend the first N_SLINE
+	 in a function to cover the entire beginning of the function
+	 as well if it does not already.
+
+2002-03-21  Tom Rix  <trix@redhat.com>
+
+	* rs6000-nat.c (rs6000_ptrace32): Renamed from ptrace32.
+	(rs6000_ptrace64): Renamed from ptrace64.
+
+2002-03-20  Martin M. Hunt  <hunt@redhat.com>
+
+	* gdbserver/remote-utils.c (remote_open): Don't call
+	getprotobyname, we're all using TCP here so just use
+	IPPROTO_TCP.
+	* gdbserver/gdbreplay.c (remote_open): Ditto.
+
+2002-03-20  Martin M. Hunt  <hunt@redhat.com>
+
+	* regcache.c (_initialize_regcache): No need to call
+	build_regcache() at this time; it gets called whenever
+	the gdbarch changes.
+
+2002-03-20  David O'Brien  <obrien@FreeBSD.org>
+
+	* sparc-nat.c:  Include sys/param.h where possible.
+
+2002-03-20  Daniel Jacobowitz  <drow@mvista.com>
+
+	Fix PR gdb/422.
+	* c-lang.c (c_create_fundamental_type): Handle FT_COMPLEX,
+	FT_DBL_PREC_COMPLEX, and FT_EXT_PREC_COMPLEX.
+	* dwarf2read.c (read_base_type): Set TYPE_TARGET_TYPE for
+	complex types.
+	* stabsread.c (rs6000_builtin_type): Likewise.
+	(read_sun_floating_type): Likewise.
+
+2002-03-19  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
+
+	* stabsread.c (read_member_functions): Remove skip code for duplicate
+	constructor/destructor methods.  Use standard parsing for these
+	methods and just do not chain them to the list of methods after
+	parsing.
+
+2002-03-19  Alexandre Oliva  <aoliva@redhat.com>
 
 	* coffread.c: Remove redundant static declarations.  Replace
 	occurrences of `PTR' with `void *'.
@@ -6,31 +2017,188 @@
 	* top.h (quit_cover): Likewise.
 	* defs.h (catch_errors): Likewise.
 
-2002-03-23  Andrew Cagney  <ac131313@redhat.com>
+2002-03-18  Andrew Cagney  <ac131313@redhat.com>
 
-	* MAINTAINERS (sh-elf): Change warning flag to -w.
+	* defs.h (XMALLOC): Define.
+	* gdb-events.sh (XMALLOC): Delete macro.
+	* gdb-events.c, gdb-events.h: Regenerate.
+	* gdbarch.sh (XMALLOC): Delete macro.
+	* gdbarch.c: Regenerate.
+	* serial.c (XMALLOC): Delete macro.
+	* ui-file.c (XMALLOC): Ditto.
+	* ser-unix.h (XMALLOC): Ditto.
+	* sh-tdep.c (XMALLOC): Ditto.
+	* ui-out.c (XMALLOC): Ditto.
+	* utils.c (XMALLOC): Ditto.
+	* i386-tdep.c (XMALLOC): Ditto.
+	* gdb-events.c (XMALLOC): Ditto.
+	* d10v-tdep.c (XMALLOC): Ditto.
+	* cli-out.c (XMALLOC): Ditto.
 
-2002-03-20  David O'Brien  <obrien@FreeBSD.org>
+	* cli-out.c, d10v-tdep.c, gdb-events.c: Update copyright.
+	* gdb-events.sh, i386-tdep.c, ser-unix.h, serial.c: Ditto.
+	* ui-file.c, ui-out.c: Ditto.
 
-	* sparc-nat.c:  Include sys/param.h where possible.
+2002-03-18  Andrew Cagney  <ac131313@redhat.com>
+
+	* command.h (struct cmd_list_element): Add field context.
+	(set_cmd_context, get_cmd_context): Declare.
+	* cli/cli-decode.h: Ditto.
+	* cli/cli-decode.c (get_cmd_context): New function.
+	(set_cmd_context): New function.
+	(add_cmd): Initialize context.
+	Part of fixing PR gdb/145 and PR gdb/146.
+
+2002-03-17  Andrew Cagney  <ac131313@redhat.com>
+
+	* cli/cli-decode.c (cmd_type): New function.
+	* command.h (cmd_type): Declare.
+	* infrun.c (set_schedlock_func): Call function cmd_type.
+	* kod.c (kod_set_os): Call cmd_type.
+	* cris-tdep.c (cris_version_update): Use function cmd_type.
+	(cris_mode_update, cris_abi_update): Ditto.
+
+	* command.h: (execute_cmd_post_hook): Declare.
+	(execute_cmd_pre_hook): Declare.
+	* cli/cli-script.c (clear_hook_in_cleanup): New function.
+	(execute_cmd_post_hook, execute_cmd_pre_hook): New
+	functions. Execute pre/post hook while ensuring that afterwords
+	hook_in is cleared.
+	* top.c (execute_command): Use execute_cmd_post_hook, and
+	execute_cmd_pre_hook to execute pre/post commands.
+	* infrun.c (normal_stop): Pass stop_command and not pre_hook to
+	hook_stop_stub.
+	(hook_stop_stub): Call execute_cmd_pre_hook.
+
+2002-03-17  Andrew Cagney  <ac131313@redhat.com>
+
+	* kod.c (kod_set_os): Revert previous change.  Is called by ``info
+	set'' and this leads to a core dump.  Move xstrdup of
+	operating_system to after check that it is not NULL.
+
+2002-03-17  Andrew Cagney  <ac131313@redhat.com>
+
+	* kod.c (kod_set_os): Remove unnecessary check that
+	``command->type'' is set_cmd.
+
+	* valprint.c (set_input_radix): Use input_radix.
+	(set_output_radix): Use output_radix.
+	(set_input_radix_1, set_output_radix_1): Add FIXME - bad radix
+	isn't reverted.
+
+2002-03-16  Andrew Cagney  <ac131313@redhat.com>
+
+	* value.h (struct value): Delete field ``substring_addr''.  Change
+	aligner fields to force_doublest_align, force_longest_align,
+	force_core_addr_align and force_pointer_aligh.
+
+	* value.h (struct value): Fix typo in above change.
+
+2002-03-16  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
+
+	* ia64-tdep.c (ia64_gdbarch_init): Call set_gdbarch_frame_args_skip,
+	to fix internal_error from ``maintenance print architecture''.
+
+2002-03-16  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
+
+	* cp-valprint.c (cp_is_vtbl_ptr_type): Handle vtbl field type
+	for gcc versions after gcc-2.8.1.
+
+2002-03-16  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
+
+	* eval.c (evaluate_subexp_standard): Fix setup of ``this'' pointer
+	for method resolution.  Restore adjustment of ``this'' pointer after
+	calling value_struct_elt, which was accidentally removed during the
+	HP merge.
+
+2002-03-15  Andrew Cagney  <ac131313@redhat.com>
+
+	* eval.c (evaluate_subexp_standard): Pass ``selected_frame'' to
+	value_of_register.
+	* findvar.c (value_of_register): Add ``frame'' parameter.  Pass to
+	get_saved_register.
+	* value.h (value_of_register): Update.
+
+2002-03-14  Richard Henderson  <rth@redhat.com>
+
+	* configure.in: Detect declaration for canonicalize_file_name.
+	* utils.c (canonicalize_file_name): Declare, if needed.
+	(gdb_realpath): Prefer realpath if available and usable.
+	* config.in, configure: Rebuild.
+
+2002-03-14  Richard Henderson  <rth@redhat.com>
+
+	* dwarf2read.c (read_array_type): Accept DW_FORM_data8 as
+	a constant array bound.
+
+	* MAINTAINERS: Add myself to write-after-approval.
+
+2002-03-14  Michael Snyder  <msnyder@redhat.com>
+
+	* symfile.c (syms_from_objfile): Return immediately if no syms.
+	(symbol_file_add): Return immediately if no syms.
+	(find_sym_fns): Return immediately if no syms.
+
+2002-03-13  Michal Ludvig  <mludvig@suse.cz>
+
+	* gdbserver/remote-util.c (remote_open): Print remote-side's
+	IP address when remote debugging over the network.
 
 2002-03-12  David O'Brien  <obrien@FreeBSD.org>
 
 	* config/sparc/fbsd.mh: Fix copyright.
 	* config/sparc/fbsd.mt: Likewise.
 
+2002-03-11  Richard Earnshaw  <rearnsha@arm.com>
+
+	* MAINTAINERS: Fix typo in name of gdb warnings option.
+	(x86-64): Fix formating so that this can be parsed by awk.
+
+2002-03-10  Daniel Jacobowitz  <drow@mvista.com>
+
+	* Makefile.in (defs_h): Add $(INCLUDE_DIR)/gdb/signals.h.
+	* defs.h: Include "gdb/signals.h".
+	(enum target_signal): Move to $(INCLUDE_DIR)/gdb/signals.h.
+
+2002-03-10  Michal Ludvig  <mludvig@suse.cz>
+
+	* x86-64-tdep.h (sys/reg.h, x86_64_regmap): Moved to x86-64-linux-nat.c
+	* x86-64-linux-nat.c (sys/reg.h, x86_64_regmap): Moved here
+	from x86-64-tdep.h
+
+2002-03-10  Daniel Jacobowitz  <drow@mvista.com>
+	    Don Howard <dhoward@redhat.com>
+
+	* mips-tdep.c (ST0_FR): Define.
+	(mips2_fp_compat): New function, temporarily disabled.
+	(mips_read_fp_register_single): New function.
+	(mips_read_fp_register_double): New function.
+	(mips_print_register): Use them.
+	(do_fp_register_row): Likewise.
+
 2002-03-09  Andrew Cagney  <ac131313@redhat.com>
 
 	* MAINTAINERS: Add Jim Ingham and Klee Dienes to ``write after
 	approval''.
 
-2002-03-07  Daniel Jacobowitz  <drow@mvista.com>   
+2002-03-08  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
 
-	* gdbserver/linux-low.c (PTRACE_XFER_TYPE): Change to long.
-	(num_regs, regmap): Move inside HAVE_LINUX_USRREGS.
-	(register_addr, REGISTER_RAW_SIZE): Likewise.
-	(usr_store_inferior_registers): Use PTRACE_XFER_TYPE.
-	* gdbserver/linux-x86-64-low.c: Remove extra #endif.
+	* stabsread.c (read_member_functions): Fix is_stub test for
+	static member functions, improve comment.
+
+2002-03-07  Richard Earnshaw  <rearnsha@arm.com>
+
+	* remote-rdi.c (myprint): Replace 'PTR' with 'void *'.
+	(mywrite, mywritec, mypause, myreadc, mygets): Likewise.
+	(_initialize_remote_rdi): Use add_set_boolean_cmd to register
+	commands that set boolean values.
+	(arm_rdi_remove_breakpoint): Rewrite to avoid uninitialized warning.
+	(arm_rdi_resume): Always initialize PC.
+	(arm_rdi_open): Don't use rslt as a boolean.
+	(arm_rdi_create_inferior, arm_rdi_close, arm_rdi_resume)
+	(arm_rdi_fetch_registers, arm_rdi_store_registers)
+	(arm_rdi_xfer_memory, arm_rdi_files_info, arm_rdi_kill)
+	(arm_rdi_insert_breakpoint, arm_rdi_remove_breakpoint): Likewise.
 
 2002-03-06  Alexandre Oliva  <aoliva@redhat.com>
 
@@ -42,6 +2210,28 @@
 	* m68hc11-tdep.c (_initialize_m68hc11_tdep): Don't set tm_print_insn.
 	(m68hc11_gdbarch_init): But use set_gdbarch_print_insn instead.
 
+2002-03-06  Andrew Cagney  <ac131313@redhat.com>
+
+	* cli/cli-decode.c (set_cmd_completer): New function.
+	* command.h (set_cmd_completer): Declare.
+	* cli/cli-decode.h (set_cmd_completer): Ditto.
+
+	* breakpoint.c (_initialize_breakpoint): Use set_cmd_completer.
+	* cli/cli-cmds.c (init_cli_cmds): Ditto.
+	* win32-nat.c (_initialize_inftarg): Ditto.
+	* remote-rdi.c (_initialize_remote_rdi): Ditto.
+	* proc-api.c (_initialize_proc_api): Ditto.
+	* hppa-tdep.c (_initialize_hppa_tdep): Ditto.
+	* source.c (_initialize_source): Ditto.
+	* exec.c (_initialize_exec): Ditto.
+	* solib.c (_initialize_solib): Ditto.
+	* top.c (init_main): Ditto.
+	* tracepoint.c (_initialize_tracepoint): Ditto.
+	* symfile.c (_initialize_symfile): Ditto.
+	* printcmd.c (_initialize_printcmd): Ditto.
+	* infcmd.c (_initialize_infcmd): Ditto.
+	* corefile.c (_initialize_core): Ditto.
+
 2002-03-05  Andrew Cagney  <ac131313@redhat.com>
 
 	* MAINTAINERS (Past Maintainers): Add Frank Ch. Eigler.
@@ -54,6 +2244,20 @@
 
 	* NEWS: Update headings, 5.2 has branched.
 
+2002-03-04  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdbserver/linux-low.c (PTRACE_XFER_TYPE): Change to long.
+	(num_regs, regmap): Move inside HAVE_LINUX_USRREGS.
+	(register_addr, REGISTER_RAW_SIZE): Likewise.
+	(usr_store_inferior_registers): Use PTRACE_XFER_TYPE.
+	* gdbserver/linux-x86-64-low.c: Remove extra #endif.
+
+2002-03-03  Michal Ludvig <mludvig@suse.cz>
+
+	* MAINTAINERS (x86-64): Add myself.
+	* x86-64-tdep.c (x86_64_push_arguments): Fixed typo naregs->nregs,
+	changed value_ptr -> struct value *
+
 2002-03-01  David O'Brien  <obrien@FreeBSD.org>
 
 	* configure.host (sparc64-*-freebsd): Add.
@@ -183,7 +2387,7 @@
 	* symfile.c (symfile_bfd_open): Ditto.
 	* solib.c (solib_map_sections): Ditto.
 	Fix PR gdb/354.
-	
+
 2002-02-26  Andrew Cagney  <ac131313@redhat.com>
 
 	* remote.c (_initialize_remote): By default, disable ``e'' and
@@ -273,7 +2477,7 @@
 	* config/sparc/nm-linux.h, config/sparc/tm-linux.h: Ditto.
 	* config/sparc/tm-sp64linux.h, config/sparc/xm-linux.h: Ditto.
 	Fix PR gdb/378.
-	
+
 2002-02-23  Andrew Cagney  <ac131313@redhat.com>
 
 	* lin-thread.c: Delete file.
@@ -310,7 +2514,7 @@
         * config.in, configure: Regenerated.
         * utils.c: (gdb_realpath) If HAVE_CANONICALIZE_FILE_NAME is
 	defined use canonicalize_file_name.
-        
+
 2002-02-23  Michael Chastain  <mec@shout.net>
 
 	* MAINTAINERS: Remove Michael Chastain from "paper trail" list.
@@ -879,6 +3083,8 @@
 
 2002-02-13  Michael Snyder  <msnyder@redhat.com>
 
+	* config/i386/i386v42mp.mh: Add gcore.o to NATDEPFILES.
+
 	* gcore.c (gcore_command): Use gcore_default_target instead of NULL.
 	(default_gcore_mach): Just return 0, work around a problem in bfd.
 	(default_gcore_target): OK to return NULL if exec_bfd is null.
diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS
index 1fa070d..fbfaa8b 100644
--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -54,11 +54,10 @@
 host maintainer when resolving build issues.  The Target/Architecture
 maintainer works with the native maintainer when resolving API issues.
 
-	a29k		OBSOLETE
+	a29k		Deleted.
 
 	alpha		--target=alpha-dec-osf4.0a -Werror
 			Maintenance only
-			OBSOLETE candidate, not multi-arch
 
 	arc		--target=arc-elf ,-Werror
 			Maintenance only
@@ -70,6 +69,9 @@
 			Richard Earnshaw	rearnsha@arm.com
 			Not multi-arch
 
+	avr		--target=avr ,-Werror
+			Theodore A. Roth	troth@verinet.com
+
 	cris		--target=cris-elf -w
 			Orjan Friberg		orjanf@axis.com
 
@@ -166,7 +168,6 @@
 
 	vax		--target=vax-dec-vms5.5 ,-Werror
 			Maintenance only
-			OBSOLETE candidate, not multi-arch
 
 	w65		Deleted.
 
@@ -204,7 +205,7 @@
   }'
 
 can be used to generate a full list of --target=
---enable-gdb-build-warning= pairs.
+--enable-gdb-build-warnings= pairs.
 
 
 
@@ -235,6 +236,7 @@
 FreeBSD native & host	Mark Kettenis		kettenis@gnu.org
 			David O'Brien		obrien@freebsd.org
 hurd native		Mark Kettenis		kettenis@gnu.org
+NetBSD native & host	Jason Thorpe		thorpej@wasabisystems.com
 SCO/Unixware		Robert Lipe		rjl@sco.com
 GNU/Linux ARM native	Scott Bambrough		scottb@netwinder.org
 Solaris/x86 native & host (devolved)
@@ -324,6 +326,8 @@
 
 Misc:
 
+gdb/gdbserver		Daniel Jacobowitz	dan@debian.org
+
 Web pages.		Jim Kingdon		jkingdon@engr.sgi.com  ++
 			(anyone can edit; kingdon is just lead maintainer)
 
@@ -356,6 +360,7 @@
 Matthew Green					mrg@eterna.com.au
 Orjan Friberg					orjanf@axis.com
 Ben Harris					bjh21@netbsd.org
+Richard Henderson				rth@redhat.com
 Paul Hilfinger					hilfinger@gnat.com
 Matt Hiller					hiller@redhat.com
 Kazu Hirata					kazu@hxi.com
@@ -376,6 +381,7 @@
 Pierre Muller					muller@sources.redhat.com
 Alexandre Oliva					aoliva@redhat.com
 Tom Rix						trix@redhat.com
+Theodore A. Roth				troth@verinet.com
 Mark Salter					msalter@redhat.com
 Andreas Schwab					schwab@suse.de
 Keith Seitz					keiths@redhat.com
@@ -389,6 +395,8 @@
 Tom Tromey					tromey@redhat.com
 Corinna Vinschen				vinschen@redhat.com
 Keith Walker					keith.walker@arm.com
+Michal Ludvig                                   mludvig@suse.cz
+David S. Miller					davem@redhat.com
 
 
 
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 9ae5582..de30f43 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -137,8 +137,10 @@
 # CLI sub directory definitons
 #
 SUBDIR_CLI_OBS = \
+	cli-dump.o \
 	cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-utils.o
 SUBDIR_CLI_SRCS = \
+	cli/cli-dump.c \
 	cli/cli-decode.c cli/cli-script.c cli/cli-cmds.c cli/cli-setshow.c \
 	cli/cli-utils.c
 SUBDIR_CLI_DEPS =
@@ -412,6 +414,10 @@
 	"prefix=$(prefix)" \
 	"exec_prefix=$(exec_prefix)" \
 	"infodir=$(infodir)" \
+	"libdir=$(libdir)" \
+	"mandir=$(mandir)" \
+	"datadir=$(datadir)" \
+	"includedir=$(includedir)" \
 	"against=$(against)" \
 	"AR=$(AR)" \
 	"AR_FLAGS=$(AR_FLAGS)" \
@@ -534,7 +540,7 @@
 	memattr.c mem-break.c minsyms.c mipsread.c nlmread.c objfiles.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c \
 	printcmd.c remote.c remote-nrom.c scm-exp.c scm-lang.c \
-	scm-valprint.c signals.c source.c stabsread.c stack.c symfile.c \
+	scm-valprint.c source.c stabsread.c stack.c symfile.c \
 	symmisc.c symtab.c linespec.c target.c thread.c top.c tracepoint.c \
 	typeprint.c utils.c valarith.c valops.c valprint.c values.c \
 	serial.c ser-unix.c mdebugread.c os9kread.c \
@@ -548,6 +554,7 @@
 	tui/tui-file.h tui/tui-file.c tui/tui-out.c tui/tui-hooks.c \
 	ui-file.h ui-file.c \
 	frame.c doublest.c \
+	builtin-regs.c std-regs.c \
 	gnu-v2-abi.c gnu-v3-abi.c hpacc-abi.c cp-abi.c
 
 LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -587,12 +594,14 @@
 arch_utils_h =	arch-utils.h
 ax_h = 		ax.h $(doublest_h)
 bcache_h =	bcache.h
+builtin_regs_h = builtin-regs.h
 breakpoint_h =	breakpoint.h $(frame_h) $(value_h)
 buildsym_h =	buildsym.h
 c_lang_h =	c-lang.h $(value_h)
 call_cmds_h =	call-cmds.h
 cli_cmds_h =	$(srcdir)/cli/cli-cmds.h
-cli_decode_h =	$(srcdir)/cli/cli-decode.h
+cli_decode_h =	$(srcdir)/cli/cli-decode.h $(command_h)
+cli_dump_h =	$(srcdir)/cli/cli-dump.h
 cli_out_h =	cli-out.h
 cli_script_h =	$(srcdir)/cli/cli-script.h
 cli_setshow_h =	$(srcdir)/cli/cli-setshow.h
@@ -603,7 +612,7 @@
 cp_abi_h =	cp-abi.h
 dcache_h =	dcache.h
 defs_h =	defs.h $(xm_h) $(tm_h) $(nm_h) config.status config.h \
-		gdbarch.h ui-file.h
+		gdbarch.h ui-file.h $(INCLUDE_DIR)/gdb/signals.h
 doublest_h =	doublest.h $(floatformat_h)
 dwarf2cfi_h =	dwarf2cfi.h
 event_loop_h =  event-loop.h
@@ -705,6 +714,7 @@
 	event-loop.o event-top.o inf-loop.o completer.o \
 	gdbarch.o arch-utils.o gdbtypes.o copying.o $(DEPFILES) \
 	memattr.o mem-break.o target.o parse.o language.o $(YYOBJ) buildsym.o \
+	builtin-regs.o std-regs.o \
 	signals.o \
 	kod.o kod-cisco.o \
 	gdb-events.o \
@@ -839,6 +849,7 @@
 	    -e '/^[a-z0-9A-Z_]*_[SU].o/d' \
 	    -e '/[a-z0-9A-Z_]*-exp.tab.o/d' \
 	    -e 's/\.o/.c/' \
+	    -e 's,signals\.c,signals/signals\.c,' \
 	    -e 's|\([^  ][^     ]*\)|$(srcdir)/\1|g' | \
 	while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \
 	sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/\1/' > init.l-tmp
@@ -1166,9 +1177,13 @@
 
 ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \
 	29k-share/udi/udi2go32.c \
-	a29k-tdep.c a68v-nat.c alpha-nat.c alpha-tdep.c \
-	arm-linux-nat.c arm-linux-tdep.c arm-tdep.c armnbsd-nat.c \
-	armnbsd-tdep.c \
+	a29k-tdep.c a68v-nat.c \
+	alpha-nat.c alphabsd-nat.c alphanbsd-nat.c \
+	alpha-tdep.c alpha-linux-tdep.c alphanbsd-tdep.c alpha-osf1-tdep.c \
+	alphafbsd-tdep.c \
+	arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
+	armnbsd-nat.c armnbsd-tdep.c \
+	avr-tdep.c \
 	coff-solib.c \
 	core-sol2.c core-regset.c core-aout.c corelow.c \
 	dcache.c delta68-nat.c dpx2-nat.c dstread.c exec.c fork-child.c \
@@ -1224,18 +1239,30 @@
 udr.o: $(srcdir)/29k-share/udi/udr.c $(udiheaders) 
 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/29k-share/udi/udr.c
 
-# OBSOLETE a29k-tdep.o: a29k-tdep.c $(gdbcmd_h) $(gdbcore_h) $(inferior_h) $(defs_h) \
-# OBSOLETE 	$(regcache_h)
-
 a68v-nat.o: a68v-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) \
 	$(regcache_h)
 
 alpha-nat.o: alpha-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) $(target_h) \
-	$(regcache_h)
+	$(regcache_h) alpha-tdep.h
+
+alphabsd-nat.o: alphabsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
+	alpha-tdep.h
+
+alphanbsd-nat.o: alphanbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
+	$(gdbcore_h) alpha-tdep.h
 
 alpha-tdep.o: alpha-tdep.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) \
 	$(inferior_h) $(symtab_h) $(dis_asm_h) $(gdb_string_h) $(linespec_h) \
-	$(regcache_h) $(doublest_h)
+	$(regcache_h) $(doublest_h) $(BFD_SRC)/elf-bfd.h alpha-tdep.h
+
+alpha-linux-tdep.o: alpha-linux-tdep.c $(defs_h) $(value_h) alpha-tdep.h
+
+alpha-osf1-tdep.o: alpha-osf1-tdep.c $(defs_h) $(value_h) alpha-tdep.h
+
+alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) alpha-tdep.h
+
+alphanbsd-tdep.o: alphanbsd-tdep.c $(defs_h) $(gdbcore_h) $(value_h) \
+	alpha-tdep.h
 
 annotate.o: annotate.c $(defs_h) $(annotate_h) $(value_h) $(target_h) $(gdbtypes_h)
 
@@ -1256,6 +1283,9 @@
 
 armnbsd-tdep.o: armnbsd-tdep.c $(defs_h) arm-tdep.h
 
+avr-tdep.o: avr-tdep.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) $(inferior_h) \
+	$(symfile_h) $(regcache_h) $(arch_utils_h)
+
 bcache.o: bcache.c $(bcache_h) $(defs_h)
 
 blockframe.o: blockframe.c $(defs_h) $(gdbcore_h) $(inferior_h) \
@@ -1269,6 +1299,9 @@
 buildsym.o: buildsym.c $(bfd_h) $(buildsym_h) $(complaints_h) $(defs_h) \
 	$(objfiles_h) $(symfile_h) $(symtab_h) $(gdb_string_h)
 
+builtin-regs.o: builtin-regs.c $(defs.h) $(builtin_regs_h) $(gdbtypes_h) \
+	$(gdb_string_h) $(value_h) $(frame_h)
+
 c-lang.o: c-lang.c $(c_lang_h) $(defs_h) $(expression_h) $(gdbtypes_h) \
 	$(language_h) $(parser_defs_h) $(symtab_h)
 
@@ -1391,7 +1424,7 @@
 
 event-top.o: event-top.c $(top_h) $(readline_headers) \
       $(defs_h) $(inferior_h) $(event_loop_h) $(event_top_h) $(terminal_h) \
-	$(gdbcmd_h) $(target_h)
+	$(gdbcmd_h) $(target_h) $(cli_decode_h)
 
 inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(inf_loop_h) $(event_loop_h) \
 	 $(event_top_h)
@@ -1403,7 +1436,7 @@
 	$(language_h) $(parser_defs_h) $(symtab_h) $(value_h)
 
 findvar.o: findvar.c $(defs_h) $(gdbcore_h) $(inferior_h) $(target_h) \
-	$(gdb_string_h) $(regcache_h)
+	$(gdb_string_h) $(regcache_h) $(builtin_regs_h)
 
 frame.o: frame.c $(defs_h) $(frame_h) $(target_h) $(value_h) $(inferior_h) \
 	$(regcache_h)
@@ -1494,7 +1527,8 @@
 		$(srcdir)/gdbtk/generic/gdbtk-varobj.c
 
 gdbtk-wrapper.o: $(srcdir)/gdbtk/generic/gdbtk-wrapper.c \
-	$(srcdir)/gdbtk/generic/gdbtk-wrapper.h
+	$(srcdir)/gdbtk/generic/gdbtk-wrapper.h \
+	$(defs_h) $(frame_h) $(value_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(GDBTK_CFLAGS)\
 		$(srcdir)/gdbtk/generic/gdbtk-wrapper.c
 
@@ -1709,7 +1743,8 @@
 	$(symfile_h)  $(gdbcore_h) $(ui_out_h)
 
 maint.o: maint.c $(defs_h) $(gdbcmd_h) $(gdbtypes_h) $(symtab_h) \
-	$(language_h) $(expression_h) $(objfiles_h) $(symfile_h)
+	$(language_h) $(expression_h) $(objfiles_h) $(symfile_h) \
+	$(cli_decode_h)
 
 mcore-tdep.o: mcore-tdep.c $(defs_h) $(frame_h) $(gdbcmd_h) $(value_h) \
 	$(symtab_h) $(symfile_h) $(gdbcore_h) $(inferior_h)
@@ -1798,6 +1833,9 @@
 
 somsolib.o: somsolib.c $(defs_h) $(regcache_h)
 
+std-regs.o: std-regs.c $(defs_h) $(builtin_regs_h) $(frame_h) \
+	$(gdbtypes_h) $(value_h)
+
 pa64solib.o: pa64solib.c $(defs_h) $(regcache_h)
 
 hpux-thread.o: hpux-thread.c $(defs_h) $(gdbthread_h) $(target_h) inferior.h \
@@ -1862,9 +1900,6 @@
 proc-service.o: proc-service.c $(defs_h) $(inferior_h) gdb_proc_service.h \
 	$(symtab_h) $(target_h) gregset.h
 
-# OBSOLETE remote-adapt.o: remote-adapt.c $(defs_h) $(gdbcore_h) \
-# OBSOLETE	$(inferior_h) $(target_h) $(terminal_h) $(gdb_string_h) $(regcache_h)
-
 remote-array.o: remote-array.c $(defs_h) $(gdbcore_h) $(target_h) \
       $(gdb_string_h) $(command_h) $(serial_h) $(monitor_h) $(remote_utils_h) \
 	$(version_h) $(regcache_h)
@@ -1892,10 +1927,6 @@
 remote-e7000.o: remote-e7000.c $(defs_h) $(gdbcore_h) $(target_h) \
 	$(serial_h) $(gdb_string_h) $(regcache_h)
 
-# OBSOLETE remote-eb.o: remote-eb.c $(srcdir)/config/a29k/tm-a29k.h \
-# OBSOLETE 	$(defs_h) $(gdbcore_h) $(inferior_h) $(symfile_h) $(target_h) \
-# OBSOLETE 	$(terminal_h) $(gdb_string_h) $(regcache_h)
-
 remote-es.o: remote-es.c $(bfd_h) $(command_h) $(defs_h) \
 	$(inferior_h) $(remote_utils_h) $(terminal_h) $(gdb_string_h) \
 	$(symfile_h) $(regcache_h) $(value_h)
@@ -1910,9 +1941,6 @@
 	$(gdbcore_h) $(inferior_h) $(serial_h) $(symfile_h) $(target_h) \
 	$(regcache_h)
 
-# OBSOLETE remote-mm.o: remote-mm.c $(bfd_h) $(defs_h) $(inferior_h) \
-# OBSOLETE	minimon.h $(target_h) $(terminal_h) $(gdb_string_h) $(regcache_h)
-
 remote-nindy.o: remote-nindy.c $(floatformat_h) $(command_h) \
 	$(defs_h) $(gdbcore_h) $(inferior_h) \
 	nindy-share/env.h nindy-share/stop.h $(remote_utils_h) \
@@ -1933,10 +1961,6 @@
 remote-st.o: remote-st.c $(defs_h) $(gdbcore_h) $(serial_h) \
 	$(target_h) $(gdb_string_h) $(regcache_h)
 
-# OBSOLETE remote-udi.o: remote-udi.c $(bfd_h) $(defs_h) $(gdbcmd_h) \
-# OBSOLETE 	$(inferior_h) $(target_h) $(terminal_h) $(udiheaders) $(gdb_string_h) \
-# OBSOLETE 	$(regcache_h)
-
 remote-vx.o: remote-vx.c $(complaints_h) $(defs_h) $(gdbcmd_h) \
 	$(gdbcore_h) $(inferior_h) $(target_h) vx-share/dbgRpcLib.h \
 	vx-share/ptrace.h vx-share/xdr_ld.h vx-share/xdr_ptrace.h \
@@ -2008,7 +2032,8 @@
 	$(inferior_h) $(target_h) $(serial_h) $(terminal_h) $(arch_utils_h) \
 	$(regcache_h)
 
-signals.o: signals.c $(defs_h) $(target_h)
+signals.o: signals/signals.c $(defs_h) $(target_h)
+	$(CC) -c $(INTERNAL_CFLAGS) $<
 
 mon960-rom.o: mon960-rom.c $(monitor_h) $(bfd_h) gdb_wait.h $(defs_h) \
 	$(gdbcmd_h) $(inferior_h) $(target_h) $(serial_h) $(terminal_h)
@@ -2094,7 +2119,8 @@
 	$(regcache_h) $(ui_out_h) $(gdb_h)
 
 completer.o: completer.c $(completer_h) $(gdbtypes_h) $(symtab_h) \
-	$(defs_h) $(gdbcmd_h) $(expression_h) $(readline_headers)
+	$(defs_h) $(gdbcmd_h) $(expression_h) $(readline_headers) \
+	$(cli_decode_h)
 
 top.o: top.c $(top_h) $(bfd_h) $(getopt_h) $(readline_headers) $(call_cmds_h) \
 	$(cli_cmds_h) $(cli_script_h) $(cli_setshow_h) \
@@ -2126,7 +2152,8 @@
 	$(gdbcore_h) $(gdbtypes_h) $(symtab_h) $(target_h) $(value_h) \
 	$(gdb_string_h) scm-lang.h $(doublest_h)
 
-vax-tdep.o: vax-tdep.c $(OP_INCLUDE)/vax.h $(defs_h) $(symtab_h)
+vax-tdep.o: vax-tdep.c $(OP_INCLUDE)/vax.h $(defs_h) $(symtab_h) \
+	$(arch_utils_h) $(inferior_h) vax-tdep.h
 
 x86-64-linux-tdep.o : x86-64-linux-tdep.c $(defs_h) $(inferior_h) \
 	$(gdbcore_h) $(regcache_h) x86-64-tdep.h i386-tdep.h $(dwarf2cfi_h)
@@ -2208,15 +2235,19 @@
 # Need to explicitly specify the compile rule as make will do nothing
 # or try to compile the object file into the cli directory.
 
+cli-cmds.o: $(srcdir)/cli/cli-cmds.c  $(cli_cmds_h) $(cli_decode_h) \
+		$(cli_script_h) $(cli_setshow_h) $(top_h) $(completer_h) \
+		 $(defs_h) $(target_h) gdb_wait.h gdb_regex.h $(ui_out_h)
+	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-cmds.c
+
 cli-decode.o: $(srcdir)/cli/cli-decode.c $(cli_decode_h) \
 		$(cli_cmds_h) $(defs_h) $(ui_out_h) \
 		$(symtab_h) gdb_regex.h
 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-decode.c
 
-cli-cmds.o: $(srcdir)/cli/cli-cmds.c  $(cli_cmds_h) $(cli_decode_h) \
-		$(cli_script_h) $(cli_setshow_h) $(top_h) $(completer_h) \
-		 $(defs_h) $(target_h) gdb_wait.h gdb_regex.h $(ui_out_h)
-	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-cmds.c
+cli-dump.o: $(srcdir)/cli/cli-dump.c $(defs_h) $(gdb_string_h) $(command_h) \
+	$(value_h) $(gdbcmd_h) $(completer_h) $(cli_dump_h)
+	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-dump.c
 
 cli-setshow.o: $(srcdir)/cli/cli-setshow.c $(cli_setshow_h) \
 		$(cli_decode_h) $(cli_cmds_h) $(defs_h) \
diff --git a/gdb/NEWS b/gdb/NEWS
index 8e514d5..b4076f7 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -1,6 +1,56 @@
 		What has changed in GDB?
 	     (Organized release by release)
 
+*** Changes since GDB 5.2:
+
+* New targets.
+
+Atmel AVR					avr*-*-*
+
+* New native configurations
+
+Alpha NetBSD					alpha*-*-netbsd*
+
+* OBSOLETE configurations and files
+
+Configurations that have been declared obsolete in this release have
+been commented out.  Unless there is activity to revive these
+configurations, the next release of GDB will have their sources
+permanently REMOVED.
+
+* REMOVED configurations and files
+
+AMD 29k family via UDI				a29k-amd-udi, udi29k
+A29K VxWorks					a29k-*-vxworks
+AMD 29000 embedded, using EBMON			a29k-none-none
+AMD 29000 embedded with COFF			a29k-none-coff
+AMD 29000 embedded with a.out			a29k-none-aout
+
+testsuite/gdb.hp/gdb.threads-hp/		directory
+
+* Changes in VAX configurations.
+
+Multi-arch support is enabled for all VAX configurations.
+
+* Changes in Alpha configurations. 
+
+Multi-arch support is enabled for all Alpha configurations.
+
+* New command "set max-user-call-depth <nnn>"
+
+This command allows the user to limit the call depth of user-defined
+commands.  The default is 1024.
+
+* Changes in FreeBSD/i386 native debugging.
+
+Support for the "generate-core-file" has been added.
+
+* New commands "dump", "append", and "restore".
+
+These commands allow data to be copied from target memory
+to a bfd-format or binary file (dump and append), and back
+from a file into memory (restore).
+
 *** Changes in GDB 5.2:
 
 * New command "set trust-readonly-sections on[off]".
diff --git a/gdb/PROBLEMS b/gdb/PROBLEMS
index 6b7d72a..09c62e1 100644
--- a/gdb/PROBLEMS
+++ b/gdb/PROBLEMS
@@ -1,59 +1,20 @@
-		Known problems in GDB 5.1.1
 
+			Known problems in GDB 5.2
 
-See also the bug database http://www.gnu.org/software/gdb/bugs/
-
-
-Contrary to the GDB 5.1.1 announcement, the update did not contain
-fixes to a i386 floating point problem.  The latest sources do contain
-the fix and it will be included in GDB 5.2.
-
-
-		Known problems in GDB 5.1
+		See also: http://www.gnu.org/software/gdb/bugs/
 
 
 hppa2.0-hp-hpux10.20
+--------------------
 
-Due to a problem (conflicting types) with libiberty/regex.c, GDB 5.1
-does not build on HP/UX 10.20 when using the HP supplied compiler.
+gdb/487: The top level make files used to build GDB are not compatible
+with HP/UX make.  As a workaround, use GNU make.
 
-Due to bit rot, GDB 5.1 does not work on HP/UX 10.20 when built with
-GCC.
+gdb/486: The HP/UX C compiler defaults to K&R mode but GDB only builds
+with an ISO C compiler.  The top level configuration incorrectly sets
+CC to `cc' instead of `cc -Ae'.  As a workaround, the correct compiler
+can be specified as part of the configuration vis:
+
+    $  'CC=cc -Ae' ./configure
 
 
-hppa2.0w-hp-hpux11.00
-
-Due to a problem with ltconfig and long argument lines, GDB 5.1 does
-not configure on HP/UX 11.00.
-
-
-alpha-dec-osf5.1
-
-GDB 5.1 has a number of problems on this platform (Ref PR gdb/237).  A
-GDB 5.1 built with ``CC="cc -DUSE_LDR_ROUTINES"'' is reported to work
-much better.
-
-
-alpha-dec-osf4.0e
-
-GDB 5.1 is known to have problems on this platform (encounters an
-internal error in the symbol table reader).
-
-
-sparcv9-sun-solaris2.8
-
-There are known problems with building GDB 5.1 using GCC 3.0.x for the
-64 bit SPARC target (bad code gen).  You could try a development
-version of GCC.
-
-
-i586-sco-sysv5uw7.1.1
-
-There are known problems with GDB 5.1's thread support on this
-platform.  Non-threaded programs should work.
-
-
-*-*-*
-
-GDB 5.1 assumes that the host C compiler implemends alloca().  GCC is
-one such compiler.  This problem should be fixed on the trunk.
diff --git a/gdb/README b/gdb/README
index 341f2cf..8af440f 100644
--- a/gdb/README
+++ b/gdb/README
@@ -1,13 +1,17 @@
-		     README for gdb-5.1.1 release
-		Updated 23 January, 2002 by Andrew Cagney
+		     README for gdb-5.2 release
+		Updated 17 April, 2002 by Andrew Cagney
 
 This is GDB, the GNU source-level debugger.
-A summary of new features is in the file `NEWS'.
 
-See the GDB home page at http://www.gnu.org/software/gdb/ for up to
+A summary of new features is in the file `gdb/NEWS'.
+
+Check the GDB home page at http://www.gnu.org/software/gdb/ for up to
 date release information, mailing list links and archives, etc.
 
-See the file PROBLEMS for late breaking news.
+The file `gdb/PROBLEMS' contains information on problems identified
+late in the release cycle.  GDB's bug tracking data base at
+http://www.gnu.org/software/gdb/bugs/ contains a more complete list of
+bugs.
 
 
 Unpacking and Installation -- quick overview
@@ -16,7 +20,7 @@
    In this release, the GDB debugger sources, the generic GNU include
 files, the BFD ("binary file description") library, the readline
 library, and other libraries all have directories of their own
-underneath the gdb-5.1.1 directory.  The idea is that a variety of GNU
+underneath the gdb-5.2 directory.  The idea is that a variety of GNU
 tools can share a common copy of these things.  Be aware of variation
 over time--for example don't try to build gdb with a copy of bfd from
 a release other than the gdb release (such as a binutils release),
@@ -25,8 +29,8 @@
 directory tree and automatically build all the pieces in the right
 order.
 
-   When you unpack the gdb-5.1.1.tar.gz file, you'll find a directory
-called `gdb-5.1.1', which contains:
+   When you unpack the gdb-5.2.tar.gz file, you'll find a directory
+called `gdb-5.2', which contains:
 
   COPYING       config.sub    intl         missing         opcodes
   COPYING.LIB   configure     libiberty    mkinstalldirs   readline
@@ -40,7 +44,7 @@
 
 You can build GDB right in the source directory:
 
-      cd gdb-5.1.1
+      cd gdb-5.2
       ./configure
       make
       cp gdb/gdb /usr/local/bin/gdb	(or wherever you want)
@@ -54,12 +58,12 @@
 
       mkdir build
       cd build
-      <full path to your sources>/gdb-5.1.1/configure
+      <full path to your sources>/gdb-5.2/configure
       make
       cp gdb/gdb /usr/local/bin/gdb	(or wherever you want)
 
 (Building GDB with DJGPP tools for MS-DOS/MS-Windows is slightly
-different; see the file gdb-5.1.1/gdb/config/djgpp/README for details.)
+different; see the file gdb-5.2/gdb/config/djgpp/README for details.)
 
    This will configure and build all the libraries as well as GDB.  If
 `configure' can't determine your system type, specify one as its
@@ -90,7 +94,7 @@
 
    GDB includes an already formatted copy of the on-line Info version
 of this manual in the `gdb/doc' subdirectory.  The main Info file is
-`gdb-5.1.1/gdb/doc/gdb.info', and it refers to subordinate files
+`gdb-5.2/gdb/doc/gdb.info', and it refers to subordinate files
 matching `gdb.info*' in the same directory.  If necessary, you can
 print out these files, or read them with any editor; but they are
 easier to read using the `info' subsystem in GNU Emacs or the
@@ -102,7 +106,7 @@
 `makeinfo'.
 
    If you have `makeinfo' installed, and are in the top level GDB
-source directory (`gdb-5.1.1', in the case of version 5.1.1), you can make
+source directory (`gdb-5.2', in the case of version 5.2), you can make
 the Info file by typing:
 
       cd gdb/doc
@@ -111,7 +115,7 @@
    If you want to typeset and print copies of this manual, you need
 TeX, a program to print its DVI output files, and `texinfo.tex', the
 Texinfo definitions file.  This file is included in the GDB
-distribution, in the directory `gdb-5.1.1/texinfo'.
+distribution, in the directory `gdb-5.2/texinfo'.
 
    TeX is a typesetting program; it does not print files directly, but
 produces output files called DVI files.  To print a typeset document,
@@ -125,11 +129,11 @@
 This file tells TeX how to typeset a document written in Texinfo
 format.  On its own, TeX cannot read, much less typeset a Texinfo file.
  `texinfo.tex' is distributed with GDB and is located in the
-`gdb-5.1.1/texinfo' directory.
+`gdb-5.2/texinfo' directory.
 
    If you have TeX and a DVI printer program installed, you can typeset
 and print this manual.  First switch to the the `gdb' subdirectory of
-the main source directory (for example, to `gdb-5.1.1/gdb') and then type:
+the main source directory (for example, to `gdb-5.2/gdb') and then type:
 
       make doc/gdb.dvi
 
@@ -152,55 +156,55 @@
 a single directory, whose name is usually composed by appending the
 version number to `gdb'.
 
-   For example, the GDB version 5.1.1 distribution is in the `gdb-5.1.1'
+   For example, the GDB version 5.2 distribution is in the `gdb-5.2'
 directory.  That directory contains:
 
-`gdb-5.1.1/{COPYING,COPYING.LIB}'
+`gdb-5.2/{COPYING,COPYING.LIB}'
      Standard GNU license files.  Please read them.
 
-`gdb-5.1.1/bfd'
+`gdb-5.2/bfd'
      source for the Binary File Descriptor library
 
-`gdb-5.1.1/config*'
+`gdb-5.2/config*'
      script for configuring GDB, along with other support files
 
-`gdb-5.1.1/gdb'
+`gdb-5.2/gdb'
      the source specific to GDB itself
 
-`gdb-5.1.1/include'
+`gdb-5.2/include'
      GNU include files
 
-`gdb-5.1.1/libiberty'
+`gdb-5.2/libiberty'
      source for the `-liberty' free software library
 
-`gdb-5.1.1/mmalloc'
+`gdb-5.2/mmalloc'
      source for the GNU memory-mapped malloc package
 
-`gdb-5.1.1/opcodes'
+`gdb-5.2/opcodes'
      source for the library of opcode tables and disassemblers
 
-`gdb-5.1.1/readline'
+`gdb-5.2/readline'
      source for the GNU command-line interface
      NOTE:  The readline library is compiled for use by GDB, but will
      not be installed on your system when "make install" is issued.
 
-`gdb-5.1.1/sim'
+`gdb-5.2/sim'
      source for some simulators (ARM, D10V, SPARC, M32R, MIPS, PPC, V850, etc)
 
-`gdb-5.1.1/intl'
+`gdb-5.2/intl'
      source for the GNU gettext library, for internationalization.
      This is slightly modified from the standalone gettext
      distribution you can get from GNU.
 
-`gdb-5.1.1/texinfo'
+`gdb-5.2/texinfo'
      The `texinfo.tex' file, which you need in order to make a printed
      manual using TeX.
 
-`gdb-5.1.1/etc'
+`gdb-5.2/etc'
      Coding standards, useful files for editing GDB, and other
      miscellanea.
 
-`gdb-5.1.1/utils'
+`gdb-5.2/utils'
      A grab bag of random utilities.
 
    Note: the following instructions are for building GDB on Unix or
@@ -209,14 +213,14 @@
 
    The simplest way to configure and build GDB is to run `configure'
 from the `gdb-VERSION-NUMBER' source directory, which in this example
-is the `gdb-5.1.1' directory.
+is the `gdb-5.2' directory.
 
    First switch to the `gdb-VERSION-NUMBER' source directory if you are
 not already in it; then run `configure'.
 
    For example:
 
-      cd gdb-5.1.1
+      cd gdb-5.2
       ./configure
       make
 
@@ -232,8 +236,8 @@
       sh configure
 
    If you run `configure' from a directory that contains source
-directories for multiple libraries or programs, such as the `gdb-5.1.1'
-source directory for version 5.1.1, `configure' creates configuration
+directories for multiple libraries or programs, such as the `gdb-5.2'
+source directory for version 5.2, `configure' creates configuration
 files for every directory level underneath (unless you tell it not to,
 with the `--norecursion' option).
 
@@ -241,10 +245,10 @@
 directories in the GDB distribution, if you only want to configure that
 subdirectory; but be sure to specify a path to it.
 
-   For example, with version 5.1.1, type the following to configure only
+   For example, with version 5.2, type the following to configure only
 the `bfd' subdirectory:
 
-      cd gdb-5.1.1/bfd
+      cd gdb-5.2/bfd
       ../configure
 
    You can install `gdb' anywhere; it has no hardwired paths. However,
@@ -273,13 +277,13 @@
 argument to `--srcdir', you can leave out the `--srcdir' option; it
 will be assumed.)
 
-   For example, with version 5.1.1, you can build GDB in a separate
+   For example, with version 5.2, you can build GDB in a separate
 directory for a Sun 4 like this:
 
-     cd gdb-5.1.1
+     cd gdb-5.2
      mkdir ../gdb-sun4
      cd ../gdb-sun4
-     ../gdb-5.1.1/configure
+     ../gdb-5.2/configure
      make
 
    When `configure' builds a configuration using a remote source
@@ -300,8 +304,8 @@
 
    The `Makefile' that `configure' generates in each source directory
 also runs recursively.  If you type `make' in a source directory such
-as `gdb-5.1.1' (or in a separate configured directory configured with
-`--srcdir=PATH/gdb-5.1.1'), you will build all the required libraries,
+as `gdb-5.2' (or in a separate configured directory configured with
+`--srcdir=PATH/gdb-5.2'), you will build all the required libraries,
 and then build GDB.
 
    When you have multiple hosts or targets configured in separate
@@ -344,7 +348,7 @@
      Invalid configuration `i786v': machine `i786v' not recognized
 
 `config.sub' is also distributed in the GDB source directory
-(`gdb-5.1.1', for version 5.1.1).
+(`gdb-5.2', for version 5.2).
 
 
 `configure' options
@@ -480,22 +484,27 @@
 that also speaks UDI.
 
 
-Reporting Bugs
-===============
+Reporting Bugs in GDB
+=====================
 
-   The correct address for reporting bugs found in gdb is
-"bug-gdb@gnu.org".  Please email all bugs, and all requests for help
-with GDB, to that address.  Please include the GDB version number
-(e.g., gdb-5.1.1), and how you configured it (e.g., "sun4" or "mach386
-host, i586-intel-synopsys target").  Since GDB now supports so many
+   There are several ways of reporting bugs in GDB.  The prefered
+method is to use the World Wide Web:
+
+      http://www.gnu.org/software/gdb/bugs/
+
+As an alternative, the bug report can be submitted, via e-mail, to the
+address "bug-gdb@gnu.org".
+
+   When submitting a bug, please include the GDB version number (e.g.,
+gdb-5.2), and how you configured it (e.g., "sun4" or "mach386 host,
+i586-intel-synopsys target").  Since GDB now supports so many
 different configurations, it is important that you be precise about
 this.  If at all possible, you should include the actual banner that
 GDB prints when it starts up, or failing that, the actual configure
 command that you used when configuring GDB.
 
-   For more information on how/whether to report bugs, see the GDB
-Bugs section of the GDB manual (gdb/doc/gdb.texinfo) or the
-gdb/CONTRIBUTE file.
+   For more information on how/whether to report bugs, see the
+Reporting Bugs chapter of the GDB manual (gdb/doc/gdb.texinfo).
 
 
 Graphical interface to GDB -- X Windows, MS Windows
@@ -542,17 +551,17 @@
 Once DejaGNU is installed, you can run the tests in one of the
 following ways:
 
-  (1)	cd gdb-5.1.1
+  (1)	cd gdb-5.2
 	make check-gdb
 
 or
 
-  (2)	cd gdb-5.1.1/gdb
+  (2)	cd gdb-5.2/gdb
 	make check
 
 or
 
-  (3)	cd gdb-5.1.1/gdb/testsuite
+  (3)	cd gdb-5.2/gdb/testsuite
 	make site.exp	(builds the site specific file)
 	runtest -tool gdb GDB=../gdb    (or GDB=<somepath> as appropriate)
 
diff --git a/gdb/a29k-tdep.c b/gdb/a29k-tdep.c
deleted file mode 100644
index 4fcc0f2..0000000
--- a/gdb/a29k-tdep.c
+++ /dev/null
@@ -1,1015 +0,0 @@
-/* OBSOLETE /* Target-machine dependent code for the AMD 29000 */
-/* OBSOLETE    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
-/* OBSOLETE    2001 */
-/* OBSOLETE    Free Software Foundation, Inc. */
-/* OBSOLETE    Contributed by Cygnus Support.  Written by Jim Kingdon. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #include "defs.h" */
-/* OBSOLETE #include "gdbcore.h" */
-/* OBSOLETE #include "frame.h" */
-/* OBSOLETE #include "value.h" */
-/* OBSOLETE #include "symtab.h" */
-/* OBSOLETE #include "inferior.h" */
-/* OBSOLETE #include "gdbcmd.h" */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE  */
-/* OBSOLETE /* If all these bits in an instruction word are zero, it is a "tag word" */
-/* OBSOLETE    which precedes a function entry point and gives stack traceback info. */
-/* OBSOLETE    This used to be defined as 0xff000000, but that treated 0x00000deb as */
-/* OBSOLETE    a tag word, while it is really used as a breakpoint.  */ */
-/* OBSOLETE #define	TAGWORD_ZERO_MASK	0xff00f800 */
-/* OBSOLETE  */
-/* OBSOLETE extern CORE_ADDR text_start;	/* FIXME, kludge... */ */
-/* OBSOLETE  */
-/* OBSOLETE /* The user-settable top of the register stack in virtual memory.  We */
-/* OBSOLETE    won't attempt to access any stored registers above this address, if set */
-/* OBSOLETE    nonzero.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static CORE_ADDR rstack_high_address = UINT_MAX; */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Should call_function allocate stack space for a struct return?  */ */
-/* OBSOLETE /* On the a29k objects over 16 words require the caller to allocate space.  */ */
-/* OBSOLETE int */
-/* OBSOLETE a29k_use_struct_convention (int gcc_p, struct type *type) */
-/* OBSOLETE { */
-/* OBSOLETE   return (TYPE_LENGTH (type) > 16 * 4); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Structure to hold cached info about function prologues.  */ */
-/* OBSOLETE  */
-/* OBSOLETE struct prologue_info */
-/* OBSOLETE { */
-/* OBSOLETE   CORE_ADDR pc;			/* First addr after fn prologue */ */
-/* OBSOLETE   unsigned rsize, msize;	/* register stack frame size, mem stack ditto */ */
-/* OBSOLETE   unsigned mfp_used:1;		/* memory frame pointer used */ */
-/* OBSOLETE   unsigned rsize_valid:1;	/* Validity bits for the above */ */
-/* OBSOLETE   unsigned msize_valid:1; */
-/* OBSOLETE   unsigned mfp_valid:1; */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE /* Examine the prologue of a function which starts at PC.  Return */
-/* OBSOLETE    the first addess past the prologue.  If MSIZE is non-NULL, then */
-/* OBSOLETE    set *MSIZE to the memory stack frame size.  If RSIZE is non-NULL, */
-/* OBSOLETE    then set *RSIZE to the register stack frame size (not including */
-/* OBSOLETE    incoming arguments and the return address & frame pointer stored */
-/* OBSOLETE    with them).  If no prologue is found, *RSIZE is set to zero. */
-/* OBSOLETE    If no prologue is found, or a prologue which doesn't involve */
-/* OBSOLETE    allocating a memory stack frame, then set *MSIZE to zero. */
-/* OBSOLETE  */
-/* OBSOLETE    Note that both msize and rsize are in bytes.  This is not consistent */
-/* OBSOLETE    with the _User's Manual_ with respect to rsize, but it is much more */
-/* OBSOLETE    convenient. */
-/* OBSOLETE  */
-/* OBSOLETE    If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory */
-/* OBSOLETE    frame pointer is being used.  */ */
-/* OBSOLETE  */
-/* OBSOLETE CORE_ADDR */
-/* OBSOLETE examine_prologue (CORE_ADDR pc, unsigned *rsize, unsigned *msize, int *mfp_used) */
-/* OBSOLETE { */
-/* OBSOLETE   long insn; */
-/* OBSOLETE   CORE_ADDR p = pc; */
-/* OBSOLETE   struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); */
-/* OBSOLETE   struct prologue_info *mi = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (msymbol != NULL) */
-/* OBSOLETE     mi = (struct prologue_info *) msymbol->info; */
-/* OBSOLETE  */
-/* OBSOLETE   if (mi != 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       int valid = 1; */
-/* OBSOLETE       if (rsize != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  *rsize = mi->rsize; */
-/* OBSOLETE 	  valid &= mi->rsize_valid; */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (msize != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  *msize = mi->msize; */
-/* OBSOLETE 	  valid &= mi->msize_valid; */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (mfp_used != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  *mfp_used = mi->mfp_used; */
-/* OBSOLETE 	  valid &= mi->mfp_valid; */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (valid) */
-/* OBSOLETE 	return mi->pc; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (rsize != NULL) */
-/* OBSOLETE     *rsize = 0; */
-/* OBSOLETE   if (msize != NULL) */
-/* OBSOLETE     *msize = 0; */
-/* OBSOLETE   if (mfp_used != NULL) */
-/* OBSOLETE     *mfp_used = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Prologue must start with subtracting a constant from gr1. */
-/* OBSOLETE      Normally this is sub gr1,gr1,<rsize * 4>.  */ */
-/* OBSOLETE   insn = read_memory_integer (p, 4); */
-/* OBSOLETE   if ((insn & 0xffffff00) != 0x25010100) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* If the frame is large, instead of a single instruction it */
-/* OBSOLETE          might be a pair of instructions: */
-/* OBSOLETE          const <reg>, <rsize * 4> */
-/* OBSOLETE          sub gr1,gr1,<reg> */
-/* OBSOLETE        */ */
-/* OBSOLETE       int reg; */
-/* OBSOLETE       /* Possible value for rsize.  */ */
-/* OBSOLETE       unsigned int rsize0; */
-/* OBSOLETE  */
-/* OBSOLETE       if ((insn & 0xff000000) != 0x03000000) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  p = pc; */
-/* OBSOLETE 	  goto done; */
-/* OBSOLETE 	} */
-/* OBSOLETE       reg = (insn >> 8) & 0xff; */
-/* OBSOLETE       rsize0 = (((insn >> 8) & 0xff00) | (insn & 0xff)); */
-/* OBSOLETE       p += 4; */
-/* OBSOLETE       insn = read_memory_integer (p, 4); */
-/* OBSOLETE       if ((insn & 0xffffff00) != 0x24010100 */
-/* OBSOLETE 	  || (insn & 0xff) != reg) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  p = pc; */
-/* OBSOLETE 	  goto done; */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (rsize != NULL) */
-/* OBSOLETE 	*rsize = rsize0; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       if (rsize != NULL) */
-/* OBSOLETE 	*rsize = (insn & 0xff); */
-/* OBSOLETE     } */
-/* OBSOLETE   p += 4; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Next instruction ought to be asgeu V_SPILL,gr1,rab.   */
-/* OBSOLETE    * We don't check the vector number to allow for kernel debugging.  The  */
-/* OBSOLETE    * kernel will use a different trap number.  */
-/* OBSOLETE    * If this insn is missing, we just keep going; Metaware R2.3u compiler */
-/* OBSOLETE    * generates prologue that intermixes initializations and puts the asgeu */
-/* OBSOLETE    * way down. */
-/* OBSOLETE    */ */
-/* OBSOLETE   insn = read_memory_integer (p, 4); */
-/* OBSOLETE   if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM)) */
-/* OBSOLETE     { */
-/* OBSOLETE       p += 4; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Next instruction usually sets the frame pointer (lr1) by adding */
-/* OBSOLETE      <size * 4> from gr1.  However, this can (and high C does) be */
-/* OBSOLETE      deferred until anytime before the first function call.  So it is */
-/* OBSOLETE      OK if we don't see anything which sets lr1.   */
-/* OBSOLETE      To allow for alternate register sets (gcc -mkernel-registers)  the msp */
-/* OBSOLETE      register number is a compile time constant. */ */
-/* OBSOLETE  */
-/* OBSOLETE   /* Normally this is just add lr1,gr1,<size * 4>.  */ */
-/* OBSOLETE   insn = read_memory_integer (p, 4); */
-/* OBSOLETE   if ((insn & 0xffffff00) == 0x15810100) */
-/* OBSOLETE     p += 4; */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       /* However, for large frames it can be */
-/* OBSOLETE          const <reg>, <size *4> */
-/* OBSOLETE          add lr1,gr1,<reg> */
-/* OBSOLETE        */ */
-/* OBSOLETE       int reg; */
-/* OBSOLETE       CORE_ADDR q; */
-/* OBSOLETE  */
-/* OBSOLETE       if ((insn & 0xff000000) == 0x03000000) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  reg = (insn >> 8) & 0xff; */
-/* OBSOLETE 	  q = p + 4; */
-/* OBSOLETE 	  insn = read_memory_integer (q, 4); */
-/* OBSOLETE 	  if ((insn & 0xffffff00) == 0x14810100 */
-/* OBSOLETE 	      && (insn & 0xff) == reg) */
-/* OBSOLETE 	    p = q; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Next comes "add lr{<rsize-1>},msp,0", but only if a memory */
-/* OBSOLETE      frame pointer is in use.  We just check for add lr<anything>,msp,0; */
-/* OBSOLETE      we don't check this rsize against the first instruction, and */
-/* OBSOLETE      we don't check that the trace-back tag indicates a memory frame pointer */
-/* OBSOLETE      is in use.   */
-/* OBSOLETE      To allow for alternate register sets (gcc -mkernel-registers)  the msp */
-/* OBSOLETE      register number is a compile time constant. */
-/* OBSOLETE  */
-/* OBSOLETE      The recommended instruction is actually "sll lr<whatever>,msp,0".  */
-/* OBSOLETE      We check for that, too.  Originally Jim Kingdon's code seemed */
-/* OBSOLETE      to be looking for a "sub" instruction here, but the mask was set */
-/* OBSOLETE      up to lose all the time. */ */
-/* OBSOLETE   insn = read_memory_integer (p, 4); */
-/* OBSOLETE   if (((insn & 0xff80ffff) == (0x15800000 | (MSP_HW_REGNUM << 8)))	/* add */ */
-/* OBSOLETE       || ((insn & 0xff80ffff) == (0x81800000 | (MSP_HW_REGNUM << 8))))	/* sll */ */
-/* OBSOLETE     { */
-/* OBSOLETE       p += 4; */
-/* OBSOLETE       if (mfp_used != NULL) */
-/* OBSOLETE 	*mfp_used = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Next comes a subtraction from msp to allocate a memory frame, */
-/* OBSOLETE      but only if a memory frame is */
-/* OBSOLETE      being used.  We don't check msize against the trace-back tag. */
-/* OBSOLETE  */
-/* OBSOLETE      To allow for alternate register sets (gcc -mkernel-registers) the msp */
-/* OBSOLETE      register number is a compile time constant. */
-/* OBSOLETE  */
-/* OBSOLETE      Normally this is just */
-/* OBSOLETE      sub msp,msp,<msize> */
-/* OBSOLETE    */ */
-/* OBSOLETE   insn = read_memory_integer (p, 4); */
-/* OBSOLETE   if ((insn & 0xffffff00) == */
-/* OBSOLETE       (0x25000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8))) */
-/* OBSOLETE     { */
-/* OBSOLETE       p += 4; */
-/* OBSOLETE       if (msize != NULL) */
-/* OBSOLETE 	*msize = insn & 0xff; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       /* For large frames, instead of a single instruction it might */
-/* OBSOLETE          be */
-/* OBSOLETE  */
-/* OBSOLETE          const <reg>, <msize> */
-/* OBSOLETE          consth <reg>, <msize>     ; optional */
-/* OBSOLETE          sub msp,msp,<reg> */
-/* OBSOLETE        */ */
-/* OBSOLETE       int reg; */
-/* OBSOLETE       unsigned msize0; */
-/* OBSOLETE       CORE_ADDR q = p; */
-/* OBSOLETE  */
-/* OBSOLETE       if ((insn & 0xff000000) == 0x03000000) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  reg = (insn >> 8) & 0xff; */
-/* OBSOLETE 	  msize0 = ((insn >> 8) & 0xff00) | (insn & 0xff); */
-/* OBSOLETE 	  q += 4; */
-/* OBSOLETE 	  insn = read_memory_integer (q, 4); */
-/* OBSOLETE 	  /* Check for consth.  */ */
-/* OBSOLETE 	  if ((insn & 0xff000000) == 0x02000000 */
-/* OBSOLETE 	      && (insn & 0x0000ff00) == reg) */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      msize0 |= (insn << 8) & 0xff000000; */
-/* OBSOLETE 	      msize0 |= (insn << 16) & 0x00ff0000; */
-/* OBSOLETE 	      q += 4; */
-/* OBSOLETE 	      insn = read_memory_integer (q, 4); */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  /* Check for sub msp,msp,<reg>.  */ */
-/* OBSOLETE 	  if ((insn & 0xffffff00) == */
-/* OBSOLETE 	      (0x24000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8)) */
-/* OBSOLETE 	      && (insn & 0xff) == reg) */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      p = q + 4; */
-/* OBSOLETE 	      if (msize != NULL) */
-/* OBSOLETE 		*msize = msize0; */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Next instruction might be asgeu V_SPILL,gr1,rab.   */
-/* OBSOLETE    * We don't check the vector number to allow for kernel debugging.  The  */
-/* OBSOLETE    * kernel will use a different trap number.  */
-/* OBSOLETE    * Metaware R2.3u compiler */
-/* OBSOLETE    * generates prologue that intermixes initializations and puts the asgeu */
-/* OBSOLETE    * way down after everything else. */
-/* OBSOLETE    */ */
-/* OBSOLETE   insn = read_memory_integer (p, 4); */
-/* OBSOLETE   if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM)) */
-/* OBSOLETE     { */
-/* OBSOLETE       p += 4; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE done: */
-/* OBSOLETE   if (msymbol != NULL) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (mi == 0) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  /* Add a new cache entry.  */ */
-/* OBSOLETE 	  mi = (struct prologue_info *) xmalloc (sizeof (struct prologue_info)); */
-/* OBSOLETE 	  msymbol->info = (char *) mi; */
-/* OBSOLETE 	  mi->rsize_valid = 0; */
-/* OBSOLETE 	  mi->msize_valid = 0; */
-/* OBSOLETE 	  mi->mfp_valid = 0; */
-/* OBSOLETE 	} */
-/* OBSOLETE       /* else, cache entry exists, but info is incomplete.  */ */
-/* OBSOLETE       mi->pc = p; */
-/* OBSOLETE       if (rsize != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  mi->rsize = *rsize; */
-/* OBSOLETE 	  mi->rsize_valid = 1; */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (msize != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  mi->msize = *msize; */
-/* OBSOLETE 	  mi->msize_valid = 1; */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (mfp_used != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  mi->mfp_used = *mfp_used; */
-/* OBSOLETE 	  mi->mfp_valid = 1; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   return p; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Advance PC across any function entry prologue instructions */
-/* OBSOLETE    to reach some "real" code.  */ */
-/* OBSOLETE  */
-/* OBSOLETE CORE_ADDR */
-/* OBSOLETE a29k_skip_prologue (CORE_ADDR pc) */
-/* OBSOLETE { */
-/* OBSOLETE   return examine_prologue (pc, NULL, NULL, NULL); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* */
-/* OBSOLETE  * Examine the one or two word tag at the beginning of a function. */
-/* OBSOLETE  * The tag word is expect to be at 'p', if it is not there, we fail */
-/* OBSOLETE  * by returning 0.  The documentation for the tag word was taken from */
-/* OBSOLETE  * page 7-15 of the 29050 User's Manual.  We are assuming that the */
-/* OBSOLETE  * m bit is in bit 22 of the tag word, which seems to be the agreed upon */
-/* OBSOLETE  * convention today (1/15/92). */
-/* OBSOLETE  * msize is return in bytes. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE static int			/* 0/1 - failure/success of finding the tag word  */ */
-/* OBSOLETE examine_tag (CORE_ADDR p, int *is_trans, int *argcount, unsigned *msize, */
-/* OBSOLETE 	     int *mfp_used) */
-/* OBSOLETE { */
-/* OBSOLETE   unsigned int tag1, tag2; */
-/* OBSOLETE  */
-/* OBSOLETE   tag1 = read_memory_integer (p, 4); */
-/* OBSOLETE   if ((tag1 & TAGWORD_ZERO_MASK) != 0)	/* Not a tag word */ */
-/* OBSOLETE     return 0; */
-/* OBSOLETE   if (tag1 & (1 << 23))		/* A two word tag */ */
-/* OBSOLETE     { */
-/* OBSOLETE       tag2 = read_memory_integer (p - 4, 4); */
-/* OBSOLETE       if (msize) */
-/* OBSOLETE 	*msize = tag2 * 2; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     /* A one word tag */ */
-/* OBSOLETE     { */
-/* OBSOLETE       if (msize) */
-/* OBSOLETE 	*msize = tag1 & 0x7ff; */
-/* OBSOLETE     } */
-/* OBSOLETE   if (is_trans) */
-/* OBSOLETE     *is_trans = ((tag1 & (1 << 21)) ? 1 : 0); */
-/* OBSOLETE   /* Note that this includes the frame pointer and the return address */
-/* OBSOLETE      register, so the actual number of registers of arguments is two less. */
-/* OBSOLETE      argcount can be zero, however, sometimes, for strange assembler */
-/* OBSOLETE      routines.  */ */
-/* OBSOLETE   if (argcount) */
-/* OBSOLETE     *argcount = (tag1 >> 16) & 0x1f; */
-/* OBSOLETE   if (mfp_used) */
-/* OBSOLETE     *mfp_used = ((tag1 & (1 << 22)) ? 1 : 0); */
-/* OBSOLETE   return 1; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Initialize the frame.  In addition to setting "extra" frame info, */
-/* OBSOLETE    we also set ->frame because we use it in a nonstandard way, and ->pc */
-/* OBSOLETE    because we need to know it to get the other stuff.  See the diagram */
-/* OBSOLETE    of stacks and the frame cache in tm-a29k.h for more detail.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE init_frame_info (int innermost_frame, struct frame_info *frame) */
-/* OBSOLETE { */
-/* OBSOLETE   CORE_ADDR p; */
-/* OBSOLETE   long insn; */
-/* OBSOLETE   unsigned rsize; */
-/* OBSOLETE   unsigned msize; */
-/* OBSOLETE   int mfp_used, trans; */
-/* OBSOLETE   struct symbol *func; */
-/* OBSOLETE  */
-/* OBSOLETE   p = frame->pc; */
-/* OBSOLETE  */
-/* OBSOLETE   if (innermost_frame) */
-/* OBSOLETE     frame->frame = read_register (GR1_REGNUM); */
-/* OBSOLETE   else */
-/* OBSOLETE     frame->frame = frame->next->frame + frame->next->rsize; */
-/* OBSOLETE  */
-/* OBSOLETE #if 0				/* CALL_DUMMY_LOCATION == ON_STACK */ */
-/* OBSOLETE   This wont work; */
-/* OBSOLETE #else */
-/* OBSOLETE   if (PC_IN_CALL_DUMMY (p, 0, 0)) */
-/* OBSOLETE #endif */
-/* OBSOLETE     { */
-/* OBSOLETE       frame->rsize = DUMMY_FRAME_RSIZE; */
-/* OBSOLETE       /* This doesn't matter since we never try to get locals or args */
-/* OBSOLETE          from a dummy frame.  */ */
-/* OBSOLETE       frame->msize = 0; */
-/* OBSOLETE       /* Dummy frames always use a memory frame pointer.  */ */
-/* OBSOLETE       frame->saved_msp = */
-/* OBSOLETE 	read_register_stack_integer (frame->frame + DUMMY_FRAME_RSIZE - 4, 4); */
-/* OBSOLETE       frame->flags |= (TRANSPARENT_FRAME | MFP_USED); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   func = find_pc_function (p); */
-/* OBSOLETE   if (func != NULL) */
-/* OBSOLETE     p = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       /* Search backward to find the trace-back tag.  However, */
-/* OBSOLETE          do not trace back beyond the start of the text segment */
-/* OBSOLETE          (just as a sanity check to avoid going into never-never land).  */ */
-/* OBSOLETE #if 1 */
-/* OBSOLETE       while (p >= text_start */
-/* OBSOLETE 	  && ((insn = read_memory_integer (p, 4)) & TAGWORD_ZERO_MASK) != 0) */
-/* OBSOLETE 	p -= 4; */
-/* OBSOLETE #else /* 0 */ */
-/* OBSOLETE       char pat[4] = */
-/* OBSOLETE       {0, 0, 0, 0}; */
-/* OBSOLETE       char mask[4]; */
-/* OBSOLETE       char insn_raw[4]; */
-/* OBSOLETE       store_unsigned_integer (mask, 4, TAGWORD_ZERO_MASK); */
-/* OBSOLETE       /* Enable this once target_search is enabled and tested.  */ */
-/* OBSOLETE       target_search (4, pat, mask, p, -4, text_start, p + 1, &p, &insn_raw); */
-/* OBSOLETE       insn = extract_unsigned_integer (insn_raw, 4); */
-/* OBSOLETE #endif /* 0 */ */
-/* OBSOLETE  */
-/* OBSOLETE       if (p < text_start) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  /* Couldn't find the trace-back tag. */
-/* OBSOLETE 	     Something strange is going on.  */ */
-/* OBSOLETE 	  frame->saved_msp = 0; */
-/* OBSOLETE 	  frame->rsize = 0; */
-/* OBSOLETE 	  frame->msize = 0; */
-/* OBSOLETE 	  frame->flags = TRANSPARENT_FRAME; */
-/* OBSOLETE 	  return; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	/* Advance to the first word of the function, i.e. the word */
-/* OBSOLETE 	   after the trace-back tag.  */ */
-/* OBSOLETE 	p += 4; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* We've found the start of the function.   */
-/* OBSOLETE      Try looking for a tag word that indicates whether there is a */
-/* OBSOLETE      memory frame pointer and what the memory stack allocation is. */
-/* OBSOLETE      If one doesn't exist, try using a more exhaustive search of */
-/* OBSOLETE      the prologue.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   if (examine_tag (p - 4, &trans, (int *) NULL, &msize, &mfp_used))	/* Found good tag */ */
-/* OBSOLETE     examine_prologue (p, &rsize, 0, 0); */
-/* OBSOLETE   else				/* No tag try prologue */ */
-/* OBSOLETE     examine_prologue (p, &rsize, &msize, &mfp_used); */
-/* OBSOLETE  */
-/* OBSOLETE   frame->rsize = rsize; */
-/* OBSOLETE   frame->msize = msize; */
-/* OBSOLETE   frame->flags = 0; */
-/* OBSOLETE   if (mfp_used) */
-/* OBSOLETE     frame->flags |= MFP_USED; */
-/* OBSOLETE   if (trans) */
-/* OBSOLETE     frame->flags |= TRANSPARENT_FRAME; */
-/* OBSOLETE   if (innermost_frame) */
-/* OBSOLETE     { */
-/* OBSOLETE       frame->saved_msp = read_register (MSP_REGNUM) + msize; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       if (mfp_used) */
-/* OBSOLETE 	frame->saved_msp = */
-/* OBSOLETE 	  read_register_stack_integer (frame->frame + rsize - 4, 4); */
-/* OBSOLETE       else */
-/* OBSOLETE 	frame->saved_msp = frame->next->saved_msp + msize; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE init_extra_frame_info (struct frame_info *frame) */
-/* OBSOLETE { */
-/* OBSOLETE   if (frame->next == 0) */
-/* OBSOLETE     /* Assume innermost frame.  May produce strange results for "info frame" */
-/* OBSOLETE        but there isn't any way to tell the difference.  */ */
-/* OBSOLETE     init_frame_info (1, frame); */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       /* We're in get_prev_frame. */
-/* OBSOLETE          Take care of everything in init_frame_pc.  */ */
-/* OBSOLETE       ; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE init_frame_pc (int fromleaf, struct frame_info *frame) */
-/* OBSOLETE { */
-/* OBSOLETE   frame->pc = (fromleaf ? SAVED_PC_AFTER_CALL (frame->next) : */
-/* OBSOLETE 	       frame->next ? FRAME_SAVED_PC (frame->next) : read_pc ()); */
-/* OBSOLETE   init_frame_info (fromleaf, frame); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their */
-/* OBSOLETE    offsets being relative to the memory stack pointer (high C) or */
-/* OBSOLETE    saved_msp (gcc).  */ */
-/* OBSOLETE  */
-/* OBSOLETE CORE_ADDR */
-/* OBSOLETE frame_locals_address (struct frame_info *fi) */
-/* OBSOLETE { */
-/* OBSOLETE   if (fi->flags & MFP_USED) */
-/* OBSOLETE     return fi->saved_msp; */
-/* OBSOLETE   else */
-/* OBSOLETE     return fi->saved_msp - fi->msize; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Routines for reading the register stack.  The caller gets to treat */
-/* OBSOLETE    the register stack as a uniform stack in memory, from address $gr1 */
-/* OBSOLETE    straight through $rfb and beyond.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Analogous to read_memory except the length is understood to be 4. */
-/* OBSOLETE    Also, myaddr can be NULL (meaning don't bother to read), and */
-/* OBSOLETE    if actual_mem_addr is non-NULL, store there the address that it */
-/* OBSOLETE    was fetched from (or if from a register the offset within */
-/* OBSOLETE    registers).  Set *LVAL to lval_memory or lval_register, depending */
-/* OBSOLETE    on where it came from.  The contents written into MYADDR are in */
-/* OBSOLETE    target format.  */ */
-/* OBSOLETE void */
-/* OBSOLETE read_register_stack (CORE_ADDR memaddr, char *myaddr, */
-/* OBSOLETE 		     CORE_ADDR *actual_mem_addr, enum lval_type *lval) */
-/* OBSOLETE { */
-/* OBSOLETE   long rfb = read_register (RFB_REGNUM); */
-/* OBSOLETE   long rsp = read_register (RSP_REGNUM); */
-/* OBSOLETE  */
-/* OBSOLETE   /* If we don't do this 'info register' stops in the middle. */ */
-/* OBSOLETE   if (memaddr >= rstack_high_address) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* a bogus value */ */
-/* OBSOLETE       static char val[] = */
-/* OBSOLETE       {~0, ~0, ~0, ~0}; */
-/* OBSOLETE       /* It's in a local register, but off the end of the stack.  */ */
-/* OBSOLETE       int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; */
-/* OBSOLETE       if (myaddr != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  /* Provide bogusness */ */
-/* OBSOLETE 	  memcpy (myaddr, val, 4); */
-/* OBSOLETE 	} */
-/* OBSOLETE       supply_register (regnum, val);	/* More bogusness */ */
-/* OBSOLETE       if (lval != NULL) */
-/* OBSOLETE 	*lval = lval_register; */
-/* OBSOLETE       if (actual_mem_addr != NULL) */
-/* OBSOLETE 	*actual_mem_addr = REGISTER_BYTE (regnum); */
-/* OBSOLETE     } */
-/* OBSOLETE   /* If it's in the part of the register stack that's in real registers, */
-/* OBSOLETE      get the value from the registers.  If it's anywhere else in memory */
-/* OBSOLETE      (e.g. in another thread's saved stack), skip this part and get */
-/* OBSOLETE      it from real live memory.  */ */
-/* OBSOLETE   else if (memaddr < rfb && memaddr >= rsp) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* It's in a register.  */ */
-/* OBSOLETE       int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; */
-/* OBSOLETE       if (regnum > LR0_REGNUM + 127) */
-/* OBSOLETE 	error ("Attempt to read register stack out of range."); */
-/* OBSOLETE       if (myaddr != NULL) */
-/* OBSOLETE 	read_register_gen (regnum, myaddr); */
-/* OBSOLETE       if (lval != NULL) */
-/* OBSOLETE 	*lval = lval_register; */
-/* OBSOLETE       if (actual_mem_addr != NULL) */
-/* OBSOLETE 	*actual_mem_addr = REGISTER_BYTE (regnum); */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       /* It's in the memory portion of the register stack.  */ */
-/* OBSOLETE       if (myaddr != NULL) */
-/* OBSOLETE 	read_memory (memaddr, myaddr, 4); */
-/* OBSOLETE       if (lval != NULL) */
-/* OBSOLETE 	*lval = lval_memory; */
-/* OBSOLETE       if (actual_mem_addr != NULL) */
-/* OBSOLETE 	*actual_mem_addr = memaddr; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Analogous to read_memory_integer */
-/* OBSOLETE    except the length is understood to be 4.  */ */
-/* OBSOLETE long */
-/* OBSOLETE read_register_stack_integer (CORE_ADDR memaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   char buf[4]; */
-/* OBSOLETE   read_register_stack (memaddr, buf, NULL, NULL); */
-/* OBSOLETE   return extract_signed_integer (buf, 4); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Copy 4 bytes from GDB memory at MYADDR into inferior memory */
-/* OBSOLETE    at MEMADDR and put the actual address written into in */
-/* OBSOLETE    *ACTUAL_MEM_ADDR.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE write_register_stack (CORE_ADDR memaddr, char *myaddr, */
-/* OBSOLETE 		      CORE_ADDR *actual_mem_addr) */
-/* OBSOLETE { */
-/* OBSOLETE   long rfb = read_register (RFB_REGNUM); */
-/* OBSOLETE   long rsp = read_register (RSP_REGNUM); */
-/* OBSOLETE   /* If we don't do this 'info register' stops in the middle. */ */
-/* OBSOLETE   if (memaddr >= rstack_high_address) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* It's in a register, but off the end of the stack.  */ */
-/* OBSOLETE       if (actual_mem_addr != NULL) */
-/* OBSOLETE 	*actual_mem_addr = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (memaddr < rfb) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* It's in a register.  */ */
-/* OBSOLETE       int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; */
-/* OBSOLETE       if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127) */
-/* OBSOLETE 	error ("Attempt to read register stack out of range."); */
-/* OBSOLETE       if (myaddr != NULL) */
-/* OBSOLETE 	write_register (regnum, *(long *) myaddr); */
-/* OBSOLETE       if (actual_mem_addr != NULL) */
-/* OBSOLETE 	*actual_mem_addr = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       /* It's in the memory portion of the register stack.  */ */
-/* OBSOLETE       if (myaddr != NULL) */
-/* OBSOLETE 	write_memory (memaddr, myaddr, 4); */
-/* OBSOLETE       if (actual_mem_addr != NULL) */
-/* OBSOLETE 	*actual_mem_addr = memaddr; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Find register number REGNUM relative to FRAME and put its */
-/* OBSOLETE    (raw) contents in *RAW_BUFFER.  Set *OPTIMIZED if the variable */
-/* OBSOLETE    was optimized out (and thus can't be fetched).  If the variable */
-/* OBSOLETE    was fetched from memory, set *ADDRP to where it was fetched from, */
-/* OBSOLETE    otherwise it was fetched from a register. */
-/* OBSOLETE  */
-/* OBSOLETE    The argument RAW_BUFFER must point to aligned memory.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE a29k_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp, */
-/* OBSOLETE 			 struct frame_info *frame, int regnum, */
-/* OBSOLETE 			 enum lval_type *lvalp) */
-/* OBSOLETE { */
-/* OBSOLETE   struct frame_info *fi; */
-/* OBSOLETE   CORE_ADDR addr; */
-/* OBSOLETE   enum lval_type lval; */
-/* OBSOLETE  */
-/* OBSOLETE   if (!target_has_registers) */
-/* OBSOLETE     error ("No registers."); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Probably now redundant with the target_has_registers check.  */ */
-/* OBSOLETE   if (frame == 0) */
-/* OBSOLETE     return; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Once something has a register number, it doesn't get optimized out.  */ */
-/* OBSOLETE   if (optimized != NULL) */
-/* OBSOLETE     *optimized = 0; */
-/* OBSOLETE   if (regnum == RSP_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (raw_buffer != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->frame); */
-/* OBSOLETE 	} */
-/* OBSOLETE       if (lvalp != NULL) */
-/* OBSOLETE 	*lvalp = not_lval; */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regnum == PC_REGNUM && frame->next != NULL) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (raw_buffer != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->pc); */
-/* OBSOLETE 	} */
-/* OBSOLETE  */
-/* OBSOLETE       /* Not sure we have to do this.  */ */
-/* OBSOLETE       if (lvalp != NULL) */
-/* OBSOLETE 	*lvalp = not_lval; */
-/* OBSOLETE  */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regnum == MSP_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (raw_buffer != NULL) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  if (frame->next != NULL) */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), */
-/* OBSOLETE 			     frame->next->saved_msp); */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  else */
-/* OBSOLETE 	    read_register_gen (MSP_REGNUM, raw_buffer); */
-/* OBSOLETE 	} */
-/* OBSOLETE       /* The value may have been computed, not fetched.  */ */
-/* OBSOLETE       if (lvalp != NULL) */
-/* OBSOLETE 	*lvalp = not_lval; */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regnum < LR0_REGNUM || regnum >= LR0_REGNUM + 128) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* These registers are not saved over procedure calls, */
-/* OBSOLETE          so just print out the current values.  */ */
-/* OBSOLETE       if (raw_buffer != NULL) */
-/* OBSOLETE 	read_register_gen (regnum, raw_buffer); */
-/* OBSOLETE       if (lvalp != NULL) */
-/* OBSOLETE 	*lvalp = lval_register; */
-/* OBSOLETE       if (addrp != NULL) */
-/* OBSOLETE 	*addrp = REGISTER_BYTE (regnum); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   addr = frame->frame + (regnum - LR0_REGNUM) * 4; */
-/* OBSOLETE   if (raw_buffer != NULL) */
-/* OBSOLETE     read_register_stack (addr, raw_buffer, &addr, &lval); */
-/* OBSOLETE   if (lvalp != NULL) */
-/* OBSOLETE     *lvalp = lval; */
-/* OBSOLETE   if (addrp != NULL) */
-/* OBSOLETE     *addrp = addr; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Discard from the stack the innermost frame, */
-/* OBSOLETE    restoring all saved registers.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE pop_frame (void) */
-/* OBSOLETE { */
-/* OBSOLETE   struct frame_info *frame = get_current_frame (); */
-/* OBSOLETE   CORE_ADDR rfb = read_register (RFB_REGNUM); */
-/* OBSOLETE   CORE_ADDR gr1 = frame->frame + frame->rsize; */
-/* OBSOLETE   CORE_ADDR lr1; */
-/* OBSOLETE   CORE_ADDR original_lr0; */
-/* OBSOLETE   int must_fix_lr0 = 0; */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   /* If popping a dummy frame, need to restore registers.  */ */
-/* OBSOLETE   if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM), */
-/* OBSOLETE 			read_register (SP_REGNUM), */
-/* OBSOLETE 			FRAME_FP (frame))) */
-/* OBSOLETE     { */
-/* OBSOLETE       int lrnum = LR0_REGNUM + DUMMY_ARG / 4; */
-/* OBSOLETE       for (i = 0; i < DUMMY_SAVE_SR128; ++i) */
-/* OBSOLETE 	write_register (SR_REGNUM (i + 128), read_register (lrnum++)); */
-/* OBSOLETE       for (i = 0; i < DUMMY_SAVE_SR160; ++i) */
-/* OBSOLETE 	write_register (SR_REGNUM (i + 160), read_register (lrnum++)); */
-/* OBSOLETE       for (i = 0; i < DUMMY_SAVE_GREGS; ++i) */
-/* OBSOLETE 	write_register (RETURN_REGNUM + i, read_register (lrnum++)); */
-/* OBSOLETE       /* Restore the PCs and prepare to restore LR0.  */ */
-/* OBSOLETE       write_register (PC_REGNUM, read_register (lrnum++)); */
-/* OBSOLETE       write_register (NPC_REGNUM, read_register (lrnum++)); */
-/* OBSOLETE       write_register (PC2_REGNUM, read_register (lrnum++)); */
-/* OBSOLETE       original_lr0 = read_register (lrnum++); */
-/* OBSOLETE       must_fix_lr0 = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Restore the memory stack pointer.  */ */
-/* OBSOLETE   write_register (MSP_REGNUM, frame->saved_msp); */
-/* OBSOLETE   /* Restore the register stack pointer.  */ */
-/* OBSOLETE   write_register (GR1_REGNUM, gr1); */
-/* OBSOLETE  */
-/* OBSOLETE   /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */ */
-/* OBSOLETE   if (must_fix_lr0) */
-/* OBSOLETE     write_register (LR0_REGNUM, original_lr0); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Check whether we need to fill registers.  */ */
-/* OBSOLETE   lr1 = read_register (LR0_REGNUM + 1); */
-/* OBSOLETE   if (lr1 > rfb) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* Fill.  */ */
-/* OBSOLETE       int num_bytes = lr1 - rfb; */
-/* OBSOLETE       int i; */
-/* OBSOLETE       long word; */
-/* OBSOLETE  */
-/* OBSOLETE       write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes); */
-/* OBSOLETE       write_register (RFB_REGNUM, lr1); */
-/* OBSOLETE       for (i = 0; i < num_bytes; i += 4) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  /* Note: word is in host byte order.  */ */
-/* OBSOLETE 	  word = read_memory_integer (rfb + i, 4); */
-/* OBSOLETE 	  write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   flush_cached_frames (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Push an empty stack frame, to record the current PC, etc.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE push_dummy_frame (void) */
-/* OBSOLETE { */
-/* OBSOLETE   long w; */
-/* OBSOLETE   CORE_ADDR rab, gr1; */
-/* OBSOLETE   CORE_ADDR msp = read_register (MSP_REGNUM); */
-/* OBSOLETE   int lrnum, i; */
-/* OBSOLETE   CORE_ADDR original_lr0; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Read original lr0 before changing gr1.  This order isn't really needed */
-/* OBSOLETE      since GDB happens to have a snapshot of all the regs and doesn't toss */
-/* OBSOLETE      it when gr1 is changed.  But it's The Right Thing To Do.  */ */
-/* OBSOLETE   original_lr0 = read_register (LR0_REGNUM); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Allocate the new frame. */ */
-/* OBSOLETE   gr1 = read_register (GR1_REGNUM) - DUMMY_FRAME_RSIZE; */
-/* OBSOLETE   write_register (GR1_REGNUM, gr1); */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef VXWORKS_TARGET */
-/* OBSOLETE   /* We force re-reading all registers to get the new local registers set */
-/* OBSOLETE      after gr1 has been modified. This fix is due to the lack of single */
-/* OBSOLETE      register read/write operation in the RPC interface between VxGDB and */
-/* OBSOLETE      VxWorks. This really must be changed ! */ */
-/* OBSOLETE  */
-/* OBSOLETE   vx_read_register (-1); */
-/* OBSOLETE  */
-/* OBSOLETE #endif /* VXWORK_TARGET */ */
-/* OBSOLETE  */
-/* OBSOLETE   rab = read_register (RAB_REGNUM); */
-/* OBSOLETE   if (gr1 < rab) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* We need to spill registers.  */ */
-/* OBSOLETE       int num_bytes = rab - gr1; */
-/* OBSOLETE       CORE_ADDR rfb = read_register (RFB_REGNUM); */
-/* OBSOLETE       int i; */
-/* OBSOLETE       long word; */
-/* OBSOLETE  */
-/* OBSOLETE       write_register (RFB_REGNUM, rfb - num_bytes); */
-/* OBSOLETE       write_register (RAB_REGNUM, gr1); */
-/* OBSOLETE       for (i = 0; i < num_bytes; i += 4) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  /* Note:  word is in target byte order.  */ */
-/* OBSOLETE 	  read_register_gen (LR0_REGNUM + i / 4, (char *) &word); */
-/* OBSOLETE 	  write_memory (rfb - num_bytes + i, (char *) &word, 4); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* There are no arguments in to the dummy frame, so we don't need */
-/* OBSOLETE      more than rsize plus the return address and lr1.  */ */
-/* OBSOLETE   write_register (LR0_REGNUM + 1, gr1 + DUMMY_FRAME_RSIZE + 2 * 4); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set the memory frame pointer.  */ */
-/* OBSOLETE   write_register (LR0_REGNUM + DUMMY_FRAME_RSIZE / 4 - 1, msp); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Allocate arg_slop.  */ */
-/* OBSOLETE   write_register (MSP_REGNUM, msp - 16 * 4); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Save registers.  */ */
-/* OBSOLETE   lrnum = LR0_REGNUM + DUMMY_ARG / 4; */
-/* OBSOLETE   for (i = 0; i < DUMMY_SAVE_SR128; ++i) */
-/* OBSOLETE     write_register (lrnum++, read_register (SR_REGNUM (i + 128))); */
-/* OBSOLETE   for (i = 0; i < DUMMY_SAVE_SR160; ++i) */
-/* OBSOLETE     write_register (lrnum++, read_register (SR_REGNUM (i + 160))); */
-/* OBSOLETE   for (i = 0; i < DUMMY_SAVE_GREGS; ++i) */
-/* OBSOLETE     write_register (lrnum++, read_register (RETURN_REGNUM + i)); */
-/* OBSOLETE   /* Save the PCs and LR0.  */ */
-/* OBSOLETE   write_register (lrnum++, read_register (PC_REGNUM)); */
-/* OBSOLETE   write_register (lrnum++, read_register (NPC_REGNUM)); */
-/* OBSOLETE   write_register (lrnum++, read_register (PC2_REGNUM)); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Why are we saving LR0?  What would clobber it? (the dummy frame should */
-/* OBSOLETE      be below it on the register stack, no?).  */ */
-/* OBSOLETE   write_register (lrnum++, original_lr0); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* */
-/* OBSOLETE    This routine takes three arguments and makes the cached frames look */
-/* OBSOLETE    as if these arguments defined a frame on the cache.  This allows the */
-/* OBSOLETE    rest of `info frame' to extract the important arguments without much */
-/* OBSOLETE    difficulty.  Since an individual frame on the 29K is determined by */
-/* OBSOLETE    three values (FP, PC, and MSP), we really need all three to do a */
-/* OBSOLETE    good job.  */ */
-/* OBSOLETE  */
-/* OBSOLETE struct frame_info * */
-/* OBSOLETE setup_arbitrary_frame (int argc, CORE_ADDR *argv) */
-/* OBSOLETE { */
-/* OBSOLETE   struct frame_info *frame; */
-/* OBSOLETE  */
-/* OBSOLETE   if (argc != 3) */
-/* OBSOLETE     error ("AMD 29k frame specifications require three arguments: rsp pc msp"); */
-/* OBSOLETE  */
-/* OBSOLETE   frame = create_new_frame (argv[0], argv[1]); */
-/* OBSOLETE  */
-/* OBSOLETE   if (!frame) */
-/* OBSOLETE     internal_error (__FILE__, __LINE__, */
-/* OBSOLETE 		    "create_new_frame returned invalid frame id"); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Creating a new frame munges the `frame' value from the current */
-/* OBSOLETE      GR1, so we restore it again here.  FIXME, untangle all this */
-/* OBSOLETE      29K frame stuff...  */ */
-/* OBSOLETE   frame->frame = argv[0]; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Our MSP is in argv[2].  It'd be intelligent if we could just */
-/* OBSOLETE      save this value in the FRAME.  But the way it's set up (FIXME), */
-/* OBSOLETE      we must save our caller's MSP.  We compute that by adding our */
-/* OBSOLETE      memory stack frame size to our MSP.  */ */
-/* OBSOLETE   frame->saved_msp = argv[2] + frame->msize; */
-/* OBSOLETE  */
-/* OBSOLETE   return frame; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE gdb_print_insn_a29k (bfd_vma memaddr, disassemble_info *info) */
-/* OBSOLETE { */
-/* OBSOLETE   if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) */
-/* OBSOLETE     return print_insn_big_a29k (memaddr, info); */
-/* OBSOLETE   else */
-/* OBSOLETE     return print_insn_little_a29k (memaddr, info); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE enum a29k_processor_types processor_type = a29k_unknown; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE a29k_get_processor_type (void) */
-/* OBSOLETE { */
-/* OBSOLETE   unsigned int cfg_reg = (unsigned int) read_register (CFG_REGNUM); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Most of these don't have freeze mode.  */ */
-/* OBSOLETE   processor_type = a29k_no_freeze_mode; */
-/* OBSOLETE  */
-/* OBSOLETE   switch ((cfg_reg >> 28) & 0xf) */
-/* OBSOLETE     { */
-/* OBSOLETE     case 0: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am29000"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 1: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am29005"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 2: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am29050"); */
-/* OBSOLETE       processor_type = a29k_freeze_mode; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 3: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am29035"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 4: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am29030"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 5: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am2920*"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 6: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am2924*"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 7: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an Am29040"); */
-/* OBSOLETE       break; */
-/* OBSOLETE     default: */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, "Remote debugging an unknown Am29k\n"); */
-/* OBSOLETE       /* Don't bother to print the revision.  */ */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE   fprintf_filtered (gdb_stderr, " revision %c\n", 'A' + ((cfg_reg >> 24) & 0x0f)); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef GET_LONGJMP_TARGET */
-/* OBSOLETE /* Figure out where the longjmp will land.  We expect that we have just entered */
-/* OBSOLETE    longjmp and haven't yet setup the stack frame, so the args are still in the */
-/* OBSOLETE    output regs.  lr2 (LR2_REGNUM) points at the jmp_buf structure from which we */
-/* OBSOLETE    extract the pc (JB_PC) that we will land at.  The pc is copied into ADDR. */
-/* OBSOLETE    This routine returns true on success */ */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE get_longjmp_target (CORE_ADDR *pc) */
-/* OBSOLETE { */
-/* OBSOLETE   CORE_ADDR jb_addr; */
-/* OBSOLETE   char buf[sizeof (CORE_ADDR)]; */
-/* OBSOLETE  */
-/* OBSOLETE   jb_addr = read_register (LR2_REGNUM); */
-/* OBSOLETE  */
-/* OBSOLETE   if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) buf, */
-/* OBSOLETE 			  sizeof (CORE_ADDR))) */
-/* OBSOLETE     return 0; */
-/* OBSOLETE  */
-/* OBSOLETE   *pc = extract_address ((PTR) buf, sizeof (CORE_ADDR)); */
-/* OBSOLETE   return 1; */
-/* OBSOLETE } */
-/* OBSOLETE #endif /* GET_LONGJMP_TARGET */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE _initialize_a29k_tdep (void) */
-/* OBSOLETE { */
-/* OBSOLETE   extern CORE_ADDR text_end; */
-/* OBSOLETE  */
-/* OBSOLETE   tm_print_insn = gdb_print_insn_a29k; */
-/* OBSOLETE  */
-/* OBSOLETE   /* FIXME, there should be a way to make a CORE_ADDR variable settable. */ */
-/* OBSOLETE   add_show_from_set */
-/* OBSOLETE     (add_set_cmd ("rstack_high_address", class_support, var_uinteger, */
-/* OBSOLETE 		  (char *) &rstack_high_address, */
-/* OBSOLETE 		  "Set top address in memory of the register stack.\n\ */
-/* OBSOLETE Attempts to access registers saved above this address will be ignored\n\ */
-/* OBSOLETE or will produce the value -1.", &setlist), */
-/* OBSOLETE      &showlist); */
-/* OBSOLETE  */
-/* OBSOLETE   /* FIXME, there should be a way to make a CORE_ADDR variable settable. */ */
-/* OBSOLETE   add_show_from_set */
-/* OBSOLETE     (add_set_cmd ("call_scratch_address", class_support, var_uinteger, */
-/* OBSOLETE 		  (char *) &text_end, */
-/* OBSOLETE 		  "Set address in memory where small amounts of RAM can be used\n\ */
-/* OBSOLETE when making function calls into the inferior.", &setlist), */
-/* OBSOLETE      &showlist); */
-/* OBSOLETE } */
diff --git a/gdb/acconfig.h b/gdb/acconfig.h
index 664bbcf..619b0ae 100644
--- a/gdb/acconfig.h
+++ b/gdb/acconfig.h
@@ -65,6 +65,9 @@
 /* Define if <sys/link.h> has struct link_map32 */
 #undef HAVE_STRUCT_LINK_MAP32
 
+/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */
+#undef _SYSCALL32
+
 /* Define if the prfpregset_t type is broken. */
 #undef PRFPREGSET_T_BROKEN
 
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index a55e36f..12f4c48 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -866,3 +866,113 @@
 ifelse(yes,no,[
 AC_DEFUN([CY_GNU_GETTEXT],)
 ])
+
+## ----------------------------------------- ##
+## ANSIfy the C compiler whenever possible.  ##
+## From Franc,ois Pinard                     ##
+## ----------------------------------------- ##
+
+# Copyright 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# 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, 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.
+
+# serial 1
+
+# @defmac AC_PROG_CC_STDC
+# @maindex PROG_CC_STDC
+# @ovindex CC
+# If the C compiler in not in ANSI C mode by default, try to add an option
+# to output variable @code{CC} to make it so.  This macro tries various
+# options that select ANSI C on some system or another.  It considers the
+# compiler to be in ANSI C mode if it handles function prototypes correctly.
+#
+# If you use this macro, you should check after calling it whether the C
+# compiler has been set to accept ANSI C; if not, the shell variable
+# @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
+# code in ANSI C, you can make an un-ANSIfied copy of it by using the
+# program @code{ansi2knr}, which comes with Ghostscript.
+# @end defmac
+
+AC_DEFUN([AM_PROG_CC_STDC],
+[AC_REQUIRE([AC_PROG_CC])
+AC_BEFORE([$0], [AC_C_INLINE])
+AC_BEFORE([$0], [AC_C_CONST])
+dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
+dnl a magic option to avoid problems with ANSI preprocessor commands
+dnl like #elif.
+dnl FIXME: can't do this because then AC_AIX won't work due to a
+dnl circular dependency.
+dnl AC_BEFORE([$0], [AC_PROG_CPP])
+AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
+AC_CACHE_VAL(am_cv_prog_cc_stdc,
+[am_cv_prog_cc_stdc=no
+ac_save_CC="$CC"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
+# SVR4			-Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  AC_TRY_COMPILE(
+[#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+], [
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+],
+[am_cv_prog_cc_stdc="$ac_arg"; break])
+done
+CC="$ac_save_CC"
+])
+if test -z "$am_cv_prog_cc_stdc"; then
+  AC_MSG_RESULT([none needed])
+else
+  AC_MSG_RESULT([$am_cv_prog_cc_stdc])
+fi
+case "x$am_cv_prog_cc_stdc" in
+  x|xno) ;;
+  *) CC="$CC $am_cv_prog_cc_stdc" ;;
+esac
+])
diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
index a64c339..5b9d643 100644
--- a/gdb/aclocal.m4
+++ b/gdb/aclocal.m4
@@ -1,4 +1,4 @@
-dnl aclocal.m4 generated automatically by aclocal 1.4-p4
+dnl aclocal.m4 generated automatically by aclocal 1.4
 
 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -879,57 +879,23 @@
 AC_DEFUN([CY_GNU_GETTEXT],)
 ])
 
-# Add --enable-maintainer-mode option to configure.
-# From Jim Meyering
 
-# serial 1
+# Copyright 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
 
-AC_DEFUN(AM_MAINTAINER_MODE,
-[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
-  dnl maintainer-mode is disabled by default
-  AC_ARG_ENABLE(maintainer-mode,
-[  --enable-maintainer-mode enable make rules and dependencies not useful
-                          (and sometimes confusing) to the casual installer],
-      USE_MAINTAINER_MODE=$enableval,
-      USE_MAINTAINER_MODE=no)
-  AC_MSG_RESULT($USE_MAINTAINER_MODE)
-  AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
-  MAINT=$MAINTAINER_MODE_TRUE
-  AC_SUBST(MAINT)dnl
-]
-)
+# 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, or (at your option)
+# any later version.
 
-# Define a conditional.
+# 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.
 
-AC_DEFUN(AM_CONDITIONAL,
-[AC_SUBST($1_TRUE)
-AC_SUBST($1_FALSE)
-if $2; then
-  $1_TRUE=
-  $1_FALSE='#'
-else
-  $1_TRUE='#'
-  $1_FALSE=
-fi])
-
-#serial 1
-# This test replaces the one in autoconf.
-# Currently this macro should have the same name as the autoconf macro
-# because gettext's gettext.m4 (distributed in the automake package)
-# still uses it.  Otherwise, the use in gettext.m4 makes autoheader
-# give these diagnostics:
-#   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
-#   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
-
-undefine([AC_ISC_POSIX])
-
-AC_DEFUN([AC_ISC_POSIX],
-  [
-    dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
-    AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
-  ]
-)
-
+# 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.
 
 # serial 1
 
@@ -948,7 +914,7 @@
 # program @code{ansi2knr}, which comes with Ghostscript.
 # @end defmac
 
-AC_DEFUN(AM_PROG_CC_STDC,
+AC_DEFUN([AM_PROG_CC_STDC],
 [AC_REQUIRE([AC_PROG_CC])
 AC_BEFORE([$0], [AC_C_INLINE])
 AC_BEFORE([$0], [AC_C_CONST])
@@ -958,7 +924,7 @@
 dnl FIXME: can't do this because then AC_AIX won't work due to a
 dnl circular dependency.
 dnl AC_BEFORE([$0], [AC_PROG_CPP])
-AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
+AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
 AC_CACHE_VAL(am_cv_prog_cc_stdc,
 [am_cv_prog_cc_stdc=no
 ac_save_CC="$CC"
@@ -966,9 +932,10 @@
 # breaks some systems' header files.
 # AIX			-qlanglvl=ansi
 # Ultrix and OSF/1	-std1
-# HP-UX			-Aa -D_HPUX_SOURCE
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
 # SVR4			-Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
   AC_TRY_COMPILE(
@@ -1010,7 +977,7 @@
 if test -z "$am_cv_prog_cc_stdc"; then
   AC_MSG_RESULT([none needed])
 else
-  AC_MSG_RESULT($am_cv_prog_cc_stdc)
+  AC_MSG_RESULT([$am_cv_prog_cc_stdc])
 fi
 case "x$am_cv_prog_cc_stdc" in
   x|xno) ;;
@@ -1018,3 +985,36 @@
 esac
 ])
 
+# Add --enable-maintainer-mode option to configure.
+# From Jim Meyering
+
+# serial 1
+
+AC_DEFUN(AM_MAINTAINER_MODE,
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+  dnl maintainer-mode is disabled by default
+  AC_ARG_ENABLE(maintainer-mode,
+[  --enable-maintainer-mode enable make rules and dependencies not useful
+                          (and sometimes confusing) to the casual installer],
+      USE_MAINTAINER_MODE=$enableval,
+      USE_MAINTAINER_MODE=no)
+  AC_MSG_RESULT($USE_MAINTAINER_MODE)
+  AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
+  MAINT=$MAINTAINER_MODE_TRUE
+  AC_SUBST(MAINT)dnl
+]
+)
+
+# Define a conditional.
+
+AC_DEFUN(AM_CONDITIONAL,
+[AC_SUBST($1_TRUE)
+AC_SUBST($1_FALSE)
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi])
+
diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
new file mode 100644
index 0000000..d467840
--- /dev/null
+++ b/gdb/alpha-linux-tdep.c
@@ -0,0 +1,120 @@
+/* Target-dependent code for GNU/Linux on Alpha.
+   Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "frame.h"
+#include "gdbcore.h"
+#include "value.h"
+
+#include "alpha-tdep.h"
+
+/* Under GNU/Linux, signal handler invocations can be identified by the
+   designated code sequence that is used to return from a signal
+   handler.  In particular, the return address of a signal handler
+   points to the following sequence (the first instruction is quadword
+   aligned):
+  
+   bis $30,$30,$16
+   addq $31,0x67,$0
+   call_pal callsys 
+      
+   Each instruction has a unique encoding, so we simply attempt to
+   match the instruction the pc is pointing to with any of the above
+   instructions.  If there is a hit, we know the offset to the start
+   of the designated sequence and can then check whether we really are
+   executing in a designated sequence.  If not, -1 is returned,
+   otherwise the offset from the start of the desingated sequence is
+   returned.
+   
+   There is a slight chance of false hits: code could jump into the
+   middle of the designated sequence, in which case there is no
+   guarantee that we are in the middle of a sigreturn syscall.  Don't
+   think this will be a problem in praxis, though.  */
+LONGEST
+alpha_linux_sigtramp_offset (CORE_ADDR pc)
+{
+  unsigned int i[3], w;
+  long off;
+
+  if (read_memory_nobpt (pc, (char *) &w, 4) != 0)
+    return -1;
+
+  off = -1;
+  switch (w)
+    {
+    case 0x47de0410:
+      off = 0;
+      break;			/* bis $30,$30,$16 */
+    case 0x43ecf400:
+      off = 4;
+      break;			/* addq $31,0x67,$0 */
+    case 0x00000083:
+      off = 8;
+      break;			/* call_pal callsys */
+    default:
+      return -1;
+    }
+  pc -= off;
+  if (pc & 0x7)
+    {
+      /* designated sequence is not quadword aligned */
+      return -1;
+    }
+  if (read_memory_nobpt (pc, (char *) i, sizeof (i)) != 0)
+    return -1;
+
+  if (i[0] == 0x47de0410 && i[1] == 0x43ecf400 && i[2] == 0x00000083)
+    return off;
+
+  return -1;
+}
+
+static int
+alpha_linux_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+{
+  return (alpha_linux_sigtramp_offset (pc) >= 0);
+}
+
+static CORE_ADDR
+alpha_linux_sigcontext_addr (struct frame_info *frame)
+{
+  return (frame->frame - 0x298); /* sizeof(struct sigcontext) */
+}
+
+static void
+alpha_linux_init_abi (struct gdbarch_info info,
+                      struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, alpha_linux_pc_in_sigtramp);
+
+  tdep->dynamic_sigtramp_offset = alpha_linux_sigtramp_offset;
+  tdep->sigcontext_addr = alpha_linux_sigcontext_addr;
+
+  tdep->jb_pc = 2;
+  tdep->jb_elt_size = 8;
+}
+
+void
+_initialize_alpha_linux_tdep (void)
+{
+  alpha_gdbarch_register_os_abi (ALPHA_ABI_LINUX, alpha_linux_init_abi);
+}
diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c
index f7e565b..580dcc0 100644
--- a/gdb/alpha-nat.c
+++ b/gdb/alpha-nat.c
@@ -24,6 +24,9 @@
 #include "gdbcore.h"
 #include "target.h"
 #include "regcache.h"
+
+#include "alpha-tdep.h"
+
 #include <sys/ptrace.h>
 #ifdef __linux__
 #include <asm/reg.h>
@@ -38,40 +41,6 @@
 static void fetch_osf_core_registers (char *, unsigned, int, CORE_ADDR);
 static void fetch_elf_core_registers (char *, unsigned, int, CORE_ADDR);
 
-/* Size of elements in jmpbuf */
-
-#define JB_ELEMENT_SIZE 8
-
-/* The definition for JB_PC in machine/reg.h is wrong.
-   And we can't get at the correct definition in setjmp.h as it is
-   not always available (eg. if _POSIX_SOURCE is defined which is the
-   default). As the defintion is unlikely to change (see comment
-   in <setjmp.h>, define the correct value here.  */
-
-#undef JB_PC
-#define JB_PC 2
-
-/* Figure out where the longjmp will land.
-   We expect the first arg to be a pointer to the jmp_buf structure from which
-   we extract the pc (JB_PC) that we will land at.  The pc is copied into PC.
-   This routine returns true on success. */
-
-int
-get_longjmp_target (CORE_ADDR *pc)
-{
-  CORE_ADDR jb_addr;
-  char raw_buffer[MAX_REGISTER_RAW_SIZE];
-
-  jb_addr = read_register (A0_REGNUM);
-
-  if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, raw_buffer,
-			  sizeof (CORE_ADDR)))
-    return 0;
-
-  *pc = extract_address (raw_buffer, sizeof (CORE_ADDR));
-  return 1;
-}
-
 /* Extract the register values out of the core file and store
    them where `read_register' will find them.
 
@@ -98,7 +67,7 @@
      OSF/1.2 core files.  OSF5 uses different names for the register
      enum list, need to handle two cases.  The actual values are the
      same.  */
-  static int core_reg_mapping[NUM_REGS] =
+  static int core_reg_mapping[ALPHA_NUM_REGS] =
   {
 #ifdef NCF_REGS
 #define EFL NCF_REGS
@@ -124,7 +93,7 @@
     EF_PC, -1
 #endif
   };
-  static char zerobuf[MAX_REGISTER_RAW_SIZE] =
+  static char zerobuf[ALPHA_MAX_REGISTER_RAW_SIZE] =
   {0};
 
   for (regno = 0; regno < NUM_REGS; regno++)
@@ -171,10 +140,11 @@
   else
     {
       /* The General Registers.  */
-      memcpy (&registers[REGISTER_BYTE (V0_REGNUM)], core_reg_sect, 31 * 8);
+      memcpy (&registers[REGISTER_BYTE (ALPHA_V0_REGNUM)], core_reg_sect,
+              31 * 8);
       memcpy (&registers[REGISTER_BYTE (PC_REGNUM)], core_reg_sect + 31 * 8, 8);
-      memset (&registers[REGISTER_BYTE (ZERO_REGNUM)], 0, 8);
-      memset (&register_valid[V0_REGNUM], 1, 32);
+      memset (&registers[REGISTER_BYTE (ALPHA_ZERO_REGNUM)], 0, 8);
+      memset (&register_valid[ALPHA_V0_REGNUM], 1, 32);
       register_valid[PC_REGNUM] = 1;
     }
 }
@@ -218,7 +188,7 @@
 {
   register int regi;
   register long *regp = ALPHA_REGSET_BASE (gregsetp);
-  static char zerobuf[MAX_REGISTER_RAW_SIZE] =
+  static char zerobuf[ALPHA_MAX_REGISTER_RAW_SIZE] =
   {0};
 
   for (regi = 0; regi < 31; regi++)
@@ -227,7 +197,7 @@
   supply_register (PC_REGNUM, (char *) (regp + 31));
 
   /* Fill inaccessible registers with zero.  */
-  supply_register (ZERO_REGNUM, zerobuf);
+  supply_register (ALPHA_ZERO_REGNUM, zerobuf);
   supply_register (FP_REGNUM, zerobuf);
 }
 
diff --git a/gdb/alpha-osf1-tdep.c b/gdb/alpha-osf1-tdep.c
new file mode 100644
index 0000000..67c56cf
--- /dev/null
+++ b/gdb/alpha-osf1-tdep.c
@@ -0,0 +1,73 @@
+/* Target-dependent code for OSF/1 on Alpha.
+   Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "frame.h"
+#include "gdbcore.h"
+#include "value.h"
+
+#include "alpha-tdep.h"
+
+/* Under OSF/1, the __sigtramp routine is frameless and has a frame
+   size of zero, but we are able to backtrace through it.  */
+static CORE_ADDR
+alpha_osf1_skip_sigtramp_frame (struct frame_info *frame, CORE_ADDR pc)
+{
+  char *name;
+
+  find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
+  if (PC_IN_SIGTRAMP (pc, name))
+    return frame->frame;
+  return 0;
+}
+
+static int
+alpha_osf1_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+{
+  return (func_name != NULL && STREQ ("__sigtramp", func_name));
+}
+
+static CORE_ADDR
+alpha_osf1_sigcontext_addr (struct frame_info *frame)
+{
+  return (read_memory_integer (frame->next ? frame->next->frame
+					   : frame->frame, 8));
+}
+
+static void
+alpha_osf1_init_abi (struct gdbarch_info info,
+                     struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, alpha_osf1_pc_in_sigtramp);
+
+  tdep->skip_sigtramp_frame = alpha_osf1_skip_sigtramp_frame;
+  tdep->sigcontext_addr = alpha_osf1_sigcontext_addr;
+
+  tdep->jb_pc = 2;
+  tdep->jb_elt_size = 8;
+}
+
+void
+_initialize_alpha_osf1_tdep (void)
+{
+  alpha_gdbarch_register_os_abi (ALPHA_ABI_OSF1, alpha_osf1_init_abi);
+}
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 4ca6bcc..f354036 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -33,6 +33,52 @@
 #include "linespec.h"
 #include "regcache.h"
 #include "doublest.h"
+#include "arch-utils.h"
+
+#include "elf-bfd.h"
+
+#include "alpha-tdep.h"
+
+static gdbarch_init_ftype alpha_gdbarch_init;
+
+static gdbarch_register_name_ftype alpha_register_name;
+static gdbarch_register_raw_size_ftype alpha_register_raw_size;
+static gdbarch_register_virtual_size_ftype alpha_register_virtual_size;
+static gdbarch_register_virtual_type_ftype alpha_register_virtual_type;
+static gdbarch_register_byte_ftype alpha_register_byte;
+static gdbarch_cannot_fetch_register_ftype alpha_cannot_fetch_register;
+static gdbarch_cannot_store_register_ftype alpha_cannot_store_register;
+static gdbarch_register_convertible_ftype alpha_register_convertible;
+static gdbarch_register_convert_to_virtual_ftype
+    alpha_register_convert_to_virtual;
+static gdbarch_register_convert_to_raw_ftype alpha_register_convert_to_raw;
+static gdbarch_store_struct_return_ftype alpha_store_struct_return;
+static gdbarch_extract_return_value_ftype alpha_extract_return_value;
+static gdbarch_store_return_value_ftype alpha_store_return_value;
+static gdbarch_extract_struct_value_address_ftype
+    alpha_extract_struct_value_address;
+static gdbarch_use_struct_convention_ftype alpha_use_struct_convention;
+
+static gdbarch_breakpoint_from_pc_ftype alpha_breakpoint_from_pc;
+
+static gdbarch_frame_args_address_ftype alpha_frame_args_address;
+static gdbarch_frame_locals_address_ftype alpha_frame_locals_address;
+
+static gdbarch_skip_prologue_ftype alpha_skip_prologue;
+static gdbarch_get_saved_register_ftype alpha_get_saved_register;
+static gdbarch_saved_pc_after_call_ftype alpha_saved_pc_after_call;
+static gdbarch_frame_chain_ftype alpha_frame_chain;
+static gdbarch_frame_saved_pc_ftype alpha_frame_saved_pc;
+static gdbarch_frame_init_saved_regs_ftype alpha_frame_init_saved_regs;
+
+static gdbarch_push_arguments_ftype alpha_push_arguments;
+static gdbarch_push_dummy_frame_ftype alpha_push_dummy_frame;
+static gdbarch_pop_frame_ftype alpha_pop_frame;
+static gdbarch_fix_call_dummy_ftype alpha_fix_call_dummy;
+static gdbarch_init_frame_pc_first_ftype alpha_init_frame_pc_first;
+static gdbarch_init_extra_frame_info_ftype alpha_init_extra_frame_info;
+
+static gdbarch_get_longjmp_target_ftype alpha_get_longjmp_target;
 
 struct frame_extra_info
   {
@@ -125,8 +171,6 @@
 */
 /* *INDENT-ON* */
 
-
-
 #define PROC_LOW_ADDR(proc) ((proc)->pdr.adr)	/* least address */
 /* These next two fields are kind of being hijacked.  I wonder if
    iline is too small for the values it needs to hold, if GDB is
@@ -153,95 +197,53 @@
   }
  *linked_proc_desc_table = NULL;
 
-int
-alpha_osf_in_sigtramp (CORE_ADDR pc, char *func_name)
+static CORE_ADDR
+alpha_frame_past_sigtramp_frame (struct frame_info *frame, CORE_ADDR pc)
 {
-  return (func_name != NULL && STREQ ("__sigtramp", func_name));
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+  if (tdep->skip_sigtramp_frame != NULL)
+    return (tdep->skip_sigtramp_frame (frame, pc));
+
+  return (0);
 }
 
-/* Under GNU/Linux, signal handler invocations can be identified by the
-   designated code sequence that is used to return from a signal
-   handler.  In particular, the return address of a signal handler
-   points to the following sequence (the first instruction is quadword
-   aligned):
-
-   bis $30,$30,$16
-   addq $31,0x67,$0
-   call_pal callsys
-
-   Each instruction has a unique encoding, so we simply attempt to
-   match the instruction the pc is pointing to with any of the above
-   instructions.  If there is a hit, we know the offset to the start
-   of the designated sequence and can then check whether we really are
-   executing in a designated sequence.  If not, -1 is returned,
-   otherwise the offset from the start of the desingated sequence is
-   returned.
-
-   There is a slight chance of false hits: code could jump into the
-   middle of the designated sequence, in which case there is no
-   guarantee that we are in the middle of a sigreturn syscall.  Don't
-   think this will be a problem in praxis, though.
- */
-
-#ifndef TM_LINUXALPHA_H
-/* HACK: Provide a prototype when compiling this file for non
-   linuxalpha targets. */
-long alpha_linux_sigtramp_offset (CORE_ADDR pc);
-#endif
-long
-alpha_linux_sigtramp_offset (CORE_ADDR pc)
+static LONGEST
+alpha_dynamic_sigtramp_offset (CORE_ADDR pc)
 {
-  unsigned int i[3], w;
-  long off;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
-  if (read_memory_nobpt (pc, (char *) &w, 4) != 0)
-    return -1;
+  /* Must be provided by OS/ABI variant code if supported. */
+  if (tdep->dynamic_sigtramp_offset != NULL)
+    return (tdep->dynamic_sigtramp_offset (pc));
 
-  off = -1;
-  switch (w)
-    {
-    case 0x47de0410:
-      off = 0;
-      break;			/* bis $30,$30,$16 */
-    case 0x43ecf400:
-      off = 4;
-      break;			/* addq $31,0x67,$0 */
-    case 0x00000083:
-      off = 8;
-      break;			/* call_pal callsys */
-    default:
-      return -1;
-    }
-  pc -= off;
-  if (pc & 0x7)
-    {
-      /* designated sequence is not quadword aligned */
-      return -1;
-    }
-
-  if (read_memory_nobpt (pc, (char *) i, sizeof (i)) != 0)
-    return -1;
-
-  if (i[0] == 0x47de0410 && i[1] == 0x43ecf400 && i[2] == 0x00000083)
-    return off;
-
-  return -1;
+  return (-1);
 }
-
 
-/* Under OSF/1, the __sigtramp routine is frameless and has a frame
-   size of zero, but we are able to backtrace through it.  */
-CORE_ADDR
-alpha_osf_skip_sigtramp_frame (struct frame_info *frame, CORE_ADDR pc)
+#define ALPHA_PROC_SIGTRAMP_MAGIC 0x0e0f0f0f
+
+/* Return TRUE if the procedure descriptor PROC is a procedure
+   descriptor that refers to a dynamically generated signal
+   trampoline routine.  */
+static int
+alpha_proc_desc_is_dyn_sigtramp (struct alpha_extra_func_info *proc)
 {
-  char *name;
-  find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
-  if (IN_SIGTRAMP (pc, name))
-    return frame->frame;
-  else
-    return 0;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+  if (tdep->dynamic_sigtramp_offset != NULL)
+    return (proc->pdr.isym == ALPHA_PROC_SIGTRAMP_MAGIC);
+
+  return (0);
 }
-
+
+static void
+alpha_set_proc_desc_is_dyn_sigtramp (struct alpha_extra_func_info *proc)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+  if (tdep->dynamic_sigtramp_offset != NULL)
+    proc->pdr.isym = ALPHA_PROC_SIGTRAMP_MAGIC;
+}
 
 /* Dynamically create a signal-handler caller procedure descriptor for
    the signal-handler return code starting at address LOW_ADDR.  The
@@ -270,12 +272,12 @@
   PROC_FREG_MASK (proc_desc) = 0xffff;
   PROC_PC_REG (proc_desc) = 26;
   PROC_LOCALOFF (proc_desc) = 0;
-  SET_PROC_DESC_IS_DYN_SIGTRAMP (proc_desc);
+  alpha_set_proc_desc_is_dyn_sigtramp (proc_desc);
   return (proc_desc);
 }
 
 
-char *
+static char *
 alpha_register_name (int regno)
 {
   static char *register_names[] =
@@ -298,50 +300,61 @@
   return (register_names[regno]);
 }
 
-int
+static int
 alpha_cannot_fetch_register (int regno)
 {
-  return (regno == FP_REGNUM || regno == ZERO_REGNUM);
+  return (regno == FP_REGNUM || regno == ALPHA_ZERO_REGNUM);
 }
 
-int
+static int
 alpha_cannot_store_register (int regno)
 {
-  return (regno == FP_REGNUM || regno == ZERO_REGNUM);
+  return (regno == FP_REGNUM || regno == ALPHA_ZERO_REGNUM);
 }
 
-int
+static int
 alpha_register_convertible (int regno)
 {
   return (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 31);
 }
 
-struct type *
+static struct type *
 alpha_register_virtual_type (int regno)
 {
   return ((regno >= FP0_REGNUM && regno < (FP0_REGNUM+31))
 	  ? builtin_type_double : builtin_type_long);
 }
 
-int
+static int
 alpha_register_byte (int regno)
 {
   return (regno * 8);
 }
 
-int
+static int
 alpha_register_raw_size (int regno)
 {
   return 8;
 }
 
-int
+static int
 alpha_register_virtual_size (int regno)
 {
   return 8;
 }
 
 
+static CORE_ADDR
+alpha_sigcontext_addr (struct frame_info *fi)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+  if (tdep->sigcontext_addr)
+    return (tdep->sigcontext_addr (fi));
+
+  return (0);
+}
+
 /* Guaranteed to set frame->saved_regs to some values (it never leaves it
    NULL).  */
 
@@ -370,7 +383,12 @@
     {
       CORE_ADDR sigcontext_addr;
 
-      sigcontext_addr = SIGCONTEXT_ADDR (frame);
+      sigcontext_addr = alpha_sigcontext_addr (frame);
+      if (sigcontext_addr == 0)
+	{
+	  /* Don't know where the sigcontext is; just bail.  */
+	  return;
+	}
       for (ireg = 0; ireg < 32; ireg++)
 	{
 	  reg_position = sigcontext_addr + SIGFRAME_REGSAVE_OFF + ireg * 8;
@@ -433,7 +451,7 @@
   frame->saved_regs[PC_REGNUM] = frame->saved_regs[returnreg];
 }
 
-void
+static void
 alpha_frame_init_saved_regs (struct frame_info *fi)
 {
   if (fi->saved_regs == NULL)
@@ -441,7 +459,7 @@
   fi->saved_regs[SP_REGNUM] = fi->frame;
 }
 
-void
+static void
 alpha_init_frame_pc_first (int fromleaf, struct frame_info *prev)
 {
   prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) :
@@ -468,7 +486,7 @@
   return read_register (regno);
 }
 
-CORE_ADDR
+static CORE_ADDR
 alpha_frame_saved_pc (struct frame_info *frame)
 {
   alpha_extra_func_info_t proc_desc = frame->extra_info->proc_desc;
@@ -483,7 +501,55 @@
   return read_next_frame_reg (frame, pcreg);
 }
 
-CORE_ADDR
+static void
+alpha_get_saved_register (char *raw_buffer,
+			  int *optimized,
+			  CORE_ADDR *addrp,
+			  struct frame_info *frame,
+			  int regnum,
+			  enum lval_type *lval)
+{
+  CORE_ADDR addr;
+
+  if (!target_has_registers)
+    error ("No registers.");
+
+  /* Normal systems don't optimize out things with register numbers.  */
+  if (optimized != NULL)
+    *optimized = 0;
+  addr = find_saved_register (frame, regnum);
+  if (addr != 0)
+    {
+      if (lval != NULL)
+	*lval = lval_memory;
+      if (regnum == SP_REGNUM)
+	{
+	  if (raw_buffer != NULL)
+	    {
+	      /* Put it back in target format.  */
+	      store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
+			     (LONGEST) addr);
+	    }
+	  if (addrp != NULL)
+	    *addrp = 0;
+	  return;
+	}
+      if (raw_buffer != NULL)
+	target_read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum));
+    }
+  else
+    {
+      if (lval != NULL)
+	*lval = lval_register;
+      addr = REGISTER_BYTE (regnum);
+      if (raw_buffer != NULL)
+	read_register_gen (regnum, raw_buffer);
+    }
+  if (addrp != NULL)
+    *addrp = addr;
+}
+
+static CORE_ADDR
 alpha_saved_pc_after_call (struct frame_info *frame)
 {
   CORE_ADDR pc = frame->pc;
@@ -497,7 +563,7 @@
     pc = tmp;
 
   proc_desc = find_proc_desc (pc, frame->next);
-  pcreg = proc_desc ? PROC_PC_REG (proc_desc) : RA_REGNUM;
+  pcreg = proc_desc ? PROC_PC_REG (proc_desc) : ALPHA_RA_REGNUM;
 
   if (frame->signal_handler_caller)
     return alpha_frame_saved_pc (frame);
@@ -507,7 +573,7 @@
 
 
 static struct alpha_extra_func_info temp_proc_desc;
-static CORE_ADDR temp_saved_regs[NUM_REGS];
+static CORE_ADDR temp_saved_regs[ALPHA_NUM_REGS];
 
 /* Nonzero if instruction at PC is a return instruction.  "ret
    $zero,($ra),1" on alpha. */
@@ -527,6 +593,7 @@
 static CORE_ADDR
 heuristic_proc_start (CORE_ADDR pc)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   CORE_ADDR start_pc = pc;
   CORE_ADDR fence = start_pc - heuristic_fence_post;
 
@@ -534,8 +601,8 @@
     return 0;
 
   if (heuristic_fence_post == UINT_MAX
-      || fence < VM_MIN_ADDRESS)
-    fence = VM_MIN_ADDRESS;
+      || fence < tdep->vm_min_address)
+    fence = tdep->vm_min_address;
 
   /* search back for previous return */
   for (start_pc -= 4;; start_pc -= 4)
@@ -549,7 +616,7 @@
 	  {
 	    static int blurb_printed = 0;
 
-	    if (fence == VM_MIN_ADDRESS)
+	    if (fence == tdep->vm_min_address)
 	      warning ("Hit beginning of text section without finding");
 	    else
 	      warning ("Hit heuristic-fence-post without finding");
@@ -646,7 +713,8 @@
 	     e.g. via the minimal symbol table, might obviate this hack.  */
 	  if (pcreg == -1
 	      && cur_pc < (start_pc + 80)
-	      && (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM))
+	      && (reg == ALPHA_T7_REGNUM || reg == ALPHA_T9_REGNUM
+	          || reg == ALPHA_RA_REGNUM))
 	    pcreg = reg;
 	}
       else if ((word & 0xffe0ffff) == 0x6be08001)	/* ret zero,reg,1 */
@@ -672,7 +740,8 @@
 	      && (word & 0xffff0000) != 0xb7fe0000)	/* reg != $zero */
 	    {
 	      int reg = (word & 0x03e00000) >> 21;
-	      if (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM)
+	      if (reg == ALPHA_T7_REGNUM || reg == ALPHA_T9_REGNUM
+	          || reg == ALPHA_RA_REGNUM)
 		{
 		  pcreg = reg;
 		  break;
@@ -687,12 +756,12 @@
     }
 
   if (has_frame_reg)
-    PROC_FRAME_REG (&temp_proc_desc) = GCC_FP_REGNUM;
+    PROC_FRAME_REG (&temp_proc_desc) = ALPHA_GCC_FP_REGNUM;
   else
     PROC_FRAME_REG (&temp_proc_desc) = SP_REGNUM;
   PROC_FRAME_OFFSET (&temp_proc_desc) = frame_size;
   PROC_REG_MASK (&temp_proc_desc) = reg_mask;
-  PROC_PC_REG (&temp_proc_desc) = (pcreg == -1) ? RA_REGNUM : pcreg;
+  PROC_PC_REG (&temp_proc_desc) = (pcreg == -1) ? ALPHA_RA_REGNUM : pcreg;
   PROC_LOCALOFF (&temp_proc_desc) = 0;	/* XXX - bogus */
   return &temp_proc_desc;
 }
@@ -711,7 +780,7 @@
 
   if (proc_desc)
     {
-      if (PROC_DESC_IS_DYN_SIGTRAMP (proc_desc))
+      if (alpha_proc_desc_is_dyn_sigtramp (proc_desc))
 	return PROC_LOW_ADDR (proc_desc);	/* "prologue" is in kernel */
 
       /* If function is frameless, then we need to do it the hard way.  I
@@ -853,7 +922,7 @@
 
       /* If PC is inside a dynamically generated sigtramp handler,
          create and push a procedure descriptor for that code: */
-      offset = DYNAMIC_SIGTRAMP_OFFSET (pc);
+      offset = alpha_dynamic_sigtramp_offset (pc);
       if (offset >= 0)
 	return push_sigtramp_desc (pc - offset);
 
@@ -874,7 +943,7 @@
 
 alpha_extra_func_info_t cached_proc_desc;
 
-CORE_ADDR
+static CORE_ADDR
 alpha_frame_chain (struct frame_info *frame)
 {
   alpha_extra_func_info_t proc_desc;
@@ -902,7 +971,7 @@
   /* The previous frame from a sigtramp frame might be frameless
      and have frame size zero.  */
       && !frame->signal_handler_caller)
-    return FRAME_PAST_SIGTRAMP_FRAME (frame, saved_pc);
+    return alpha_frame_past_sigtramp_frame (frame, saved_pc);
   else
     return read_next_frame_reg (frame, PROC_FRAME_REG (proc_desc))
       + PROC_FRAME_OFFSET (proc_desc);
@@ -920,7 +989,7 @@
 		     paddr_d (fi->extra_info->proc_desc->pdr.frameoffset));
 }
 
-void
+static void
 alpha_init_extra_frame_info (int fromleaf, struct frame_info *frame)
 {
   /* Use proc_desc calculated in frame_chain */
@@ -932,7 +1001,7 @@
 
   frame->saved_regs = NULL;
   frame->extra_info->localoff = 0;
-  frame->extra_info->pc_reg = RA_REGNUM;
+  frame->extra_info->pc_reg = ALPHA_RA_REGNUM;
   frame->extra_info->proc_desc = proc_desc == &temp_proc_desc ? 0 : proc_desc;
   if (proc_desc)
     {
@@ -953,7 +1022,7 @@
          Get the value of the frame relative sp, procedure might have been
          interrupted by a signal at it's very start.  */
       else if (frame->pc == PROC_LOW_ADDR (proc_desc)
-	       && !PROC_DESC_IS_DYN_SIGTRAMP (proc_desc))
+	       && !alpha_proc_desc_is_dyn_sigtramp (proc_desc))
 	frame->frame = read_next_frame_reg (frame->next, SP_REGNUM);
       else
 	frame->frame = read_next_frame_reg (frame->next, PROC_FRAME_REG (proc_desc))
@@ -968,26 +1037,26 @@
 	     We can't use frame->signal_handler_caller, it is not yet set.  */
 	  find_pc_partial_function (frame->pc, &name,
 				    (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
-	  if (!IN_SIGTRAMP (frame->pc, name))
+	  if (!PC_IN_SIGTRAMP (frame->pc, name))
 	    {
 	      frame->saved_regs = (CORE_ADDR *)
 		frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
 	      memcpy (frame->saved_regs, temp_saved_regs,
 	              SIZEOF_FRAME_SAVED_REGS);
 	      frame->saved_regs[PC_REGNUM]
-		= frame->saved_regs[RA_REGNUM];
+		= frame->saved_regs[ALPHA_RA_REGNUM];
 	    }
 	}
     }
 }
 
-CORE_ADDR
+static CORE_ADDR
 alpha_frame_locals_address (struct frame_info *fi)
 {
   return (fi->frame - fi->extra_info->localoff);
 }
 
-CORE_ADDR
+static CORE_ADDR
 alpha_frame_args_address (struct frame_info *fi)
 {
   return (fi->frame - (ALPHA_NUM_ARG_REGS * 8));
@@ -1009,7 +1078,7 @@
    arguments without difficulty.  */
 
 struct frame_info *
-setup_arbitrary_frame (int argc, CORE_ADDR *argv)
+alpha_setup_arbitrary_frame (int argc, CORE_ADDR *argv)
 {
   if (argc != 2)
     error ("ALPHA frame specifications require two arguments: sp and pc");
@@ -1027,7 +1096,7 @@
    If the called function is returning a structure, the address of the
    structure to be returned is passed as a hidden first argument.  */
 
-CORE_ADDR
+static CORE_ADDR
 alpha_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
 		      int struct_return, CORE_ADDR struct_addr)
 {
@@ -1102,14 +1171,14 @@
       LONGEST val;
 
       val = read_memory_integer (sp + i * 8, 8);
-      write_register (A0_REGNUM + i, val);
-      write_register (FPA0_REGNUM + i, val);
+      write_register (ALPHA_A0_REGNUM + i, val);
+      write_register (ALPHA_FPA0_REGNUM + i, val);
     }
 
   return sp + arg_regs_size;
 }
 
-void
+static void
 alpha_push_dummy_frame (void)
 {
   int ireg;
@@ -1117,7 +1186,7 @@
   alpha_extra_func_info_t proc_desc;
   CORE_ADDR sp = read_register (SP_REGNUM);
   CORE_ADDR save_address;
-  char raw_buffer[MAX_REGISTER_RAW_SIZE];
+  char raw_buffer[ALPHA_MAX_REGISTER_RAW_SIZE];
   unsigned long mask;
 
   link = (struct linked_proc_info *) xmalloc (sizeof (struct linked_proc_info));
@@ -1172,14 +1241,14 @@
      registers follow in ascending order.
      The PC is saved immediately below the SP.  */
   save_address = sp + PROC_REG_OFFSET (proc_desc);
-  store_address (raw_buffer, 8, read_register (RA_REGNUM));
+  store_address (raw_buffer, 8, read_register (ALPHA_RA_REGNUM));
   write_memory (save_address, raw_buffer, 8);
   save_address += 8;
   mask = PROC_REG_MASK (proc_desc) & 0xffffffffL;
   for (ireg = 0; mask; ireg++, mask >>= 1)
     if (mask & 1)
       {
-	if (ireg == RA_REGNUM)
+	if (ireg == ALPHA_RA_REGNUM)
 	  continue;
 	store_address (raw_buffer, 8, read_register (ireg));
 	write_memory (save_address, raw_buffer, 8);
@@ -1222,10 +1291,10 @@
   PROC_HIGH_ADDR (proc_desc) = PROC_LOW_ADDR (proc_desc) + 4;
 
   SET_PROC_DESC_IS_DUMMY (proc_desc);
-  PROC_PC_REG (proc_desc) = RA_REGNUM;
+  PROC_PC_REG (proc_desc) = ALPHA_RA_REGNUM;
 }
 
-void
+static void
 alpha_pop_frame (void)
 {
   register int regnum;
@@ -1262,7 +1331,7 @@
   flush_cached_frames ();
 
   if (proc_desc && (PROC_DESC_IS_DUMMY (proc_desc)
-		    || PROC_DESC_IS_DYN_SIGTRAMP (proc_desc)))
+		    || alpha_proc_desc_is_dyn_sigtramp (proc_desc)))
     {
       struct linked_proc_info *pi_ptr, *prev_ptr;
 
@@ -1303,16 +1372,15 @@
   CORE_ADDR post_prologue_pc;
   char buf[4];
 
-#ifdef GDB_TARGET_HAS_SHARED_LIBS
   /* Silently return the unaltered pc upon memory errors.
      This could happen on OSF/1 if decode_line_1 tries to skip the
      prologue for quickstarted shared library functions when the
      shared library is not yet mapped in.
      Reading target memory is slow over serial lines, so we perform
-     this check only if the target has shared libraries.  */
+     this check only if the target has shared libraries (which all
+     Alpha targets do).  */
   if (target_read_memory (pc, buf, 4))
     return pc;
-#endif
 
   /* See if we can determine the end of the prologue via the symbol table.
      If so, then return either PC, or the PC after the prologue, whichever
@@ -1368,7 +1436,7 @@
   return pc + offset;
 }
 
-CORE_ADDR
+static CORE_ADDR
 alpha_skip_prologue (CORE_ADDR addr)
 {
   return (alpha_skip_prologue_internal (addr, 0));
@@ -1392,7 +1460,7 @@
    or
    memory format is an integer with 4 bytes or less, as the representation
    of integers in floating point registers is different. */
-void
+static void
 alpha_register_convert_to_virtual (int regnum, struct type *valtype,
 				   char *raw_buffer, char *virtual_buffer)
 {
@@ -1418,7 +1486,7 @@
     error ("Cannot retrieve value from floating point register");
 }
 
-void
+static void
 alpha_register_convert_to_raw (struct type *valtype, int regnum,
 			       char *virtual_buffer, char *raw_buffer)
 {
@@ -1447,29 +1515,40 @@
     error ("Cannot store value in floating point register");
 }
 
+static const unsigned char *
+alpha_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
+{
+  static const unsigned char alpha_breakpoint[] =
+    { 0x80, 0, 0, 0 };	/* call_pal bpt */
+
+  *lenptr = sizeof(alpha_breakpoint);
+  return (alpha_breakpoint);
+}
+
 /* Given a return value in `regbuf' with a type `valtype', 
    extract and copy its value into `valbuf'.  */
 
-void
+static void
 alpha_extract_return_value (struct type *valtype,
-			    char regbuf[REGISTER_BYTES], char *valbuf)
+			    char regbuf[ALPHA_REGISTER_BYTES], char *valbuf)
 {
   if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
     alpha_register_convert_to_virtual (FP0_REGNUM, valtype,
 				       regbuf + REGISTER_BYTE (FP0_REGNUM),
 				       valbuf);
   else
-    memcpy (valbuf, regbuf + REGISTER_BYTE (V0_REGNUM), TYPE_LENGTH (valtype));
+    memcpy (valbuf, regbuf + REGISTER_BYTE (ALPHA_V0_REGNUM),
+            TYPE_LENGTH (valtype));
 }
 
 /* Given a return value in `regbuf' with a type `valtype', 
    write its value into the appropriate register.  */
 
-void
+static void
 alpha_store_return_value (struct type *valtype, char *valbuf)
 {
-  char raw_buffer[MAX_REGISTER_RAW_SIZE];
-  int regnum = V0_REGNUM;
+  char raw_buffer[ALPHA_MAX_REGISTER_RAW_SIZE];
+  int regnum = ALPHA_V0_REGNUM;
   int length = TYPE_LENGTH (valtype);
 
   if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
@@ -1517,7 +1596,7 @@
     return SYMBOL_VALUE_ADDRESS (sym) + 4;
 }
 
-void
+static void
 alpha_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
                       struct value **args, struct type *type, int gcc_p)
 {
@@ -1525,8 +1604,8 @@
 
   if (bp_address == 0)
     error ("no place to put call");
-  write_register (RA_REGNUM, bp_address);
-  write_register (T12_REGNUM, fun);
+  write_register (ALPHA_RA_REGNUM, bp_address);
+  write_register (ALPHA_T12_REGNUM, fun);
 }
 
 /* On the Alpha, the call dummy code is nevery copied to user space
@@ -1534,25 +1613,47 @@
    matter.  */
 LONGEST alpha_call_dummy_words[] = { 0 };
 
-int
+static int
 alpha_use_struct_convention (int gcc_p, struct type *type)
 {
   /* Structures are returned by ref in extra arg0.  */
   return 1;
 }
 
-void
+static void
 alpha_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
 {
   /* Store the address of the place in which to copy the structure the
      subroutine will return.  Handled by alpha_push_arguments.  */
 }
 
-CORE_ADDR
+static CORE_ADDR
 alpha_extract_struct_value_address (char *regbuf)
 {
-  return (extract_address (regbuf + REGISTER_BYTE (V0_REGNUM),
-			   REGISTER_RAW_SIZE (V0_REGNUM)));
+  return (extract_address (regbuf + REGISTER_BYTE (ALPHA_V0_REGNUM),
+			   REGISTER_RAW_SIZE (ALPHA_V0_REGNUM)));
+}
+
+/* Figure out where the longjmp will land.
+   We expect the first arg to be a pointer to the jmp_buf structure from
+   which we extract the PC (JB_PC) that we will land at.  The PC is copied
+   into the "pc".  This routine returns true on success.  */
+
+static int
+alpha_get_longjmp_target (CORE_ADDR *pc)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  CORE_ADDR jb_addr;
+  char raw_buffer[ALPHA_MAX_REGISTER_RAW_SIZE];
+
+  jb_addr = read_register (ALPHA_A0_REGNUM);
+
+  if (target_read_memory (jb_addr + (tdep->jb_pc * tdep->jb_elt_size),
+			  raw_buffer, tdep->jb_elt_size))
+    return 0;
+
+  *pc = extract_address (raw_buffer, tdep->jb_elt_size);
+  return 1;
 }
 
 /* alpha_software_single_step() is called just before we want to resume
@@ -1664,11 +1765,439 @@
     }
 }
 
+
+/* This table matches the indices assigned to enum alpha_abi.  Keep
+   them in sync.  */
+static const char * const alpha_abi_names[] =
+{
+  "<unknown>",
+  "OSF/1",
+  "GNU/Linux",
+  "FreeBSD",
+  "NetBSD",
+  NULL
+};
+
+static void
+process_note_abi_tag_sections (bfd *abfd, asection *sect, void *obj)
+{
+  enum alpha_abi *os_ident_ptr = obj;
+  const char *name;
+  unsigned int sectsize;
+
+  name = bfd_get_section_name (abfd, sect);
+  sectsize = bfd_section_size (abfd, sect);
+
+  if (strcmp (name, ".note.ABI-tag") == 0 && sectsize > 0)
+    {
+      unsigned int name_length, data_length, note_type;
+      char *note;
+
+      /* If the section is larger than this, it's probably not what we are
+	 looking for.  */
+      if (sectsize > 128)
+	sectsize = 128;
+
+      note = alloca (sectsize);
+
+      bfd_get_section_contents (abfd, sect, note,
+				(file_ptr) 0, (bfd_size_type) sectsize);
+
+      name_length = bfd_h_get_32 (abfd, note);
+      data_length = bfd_h_get_32 (abfd, note + 4);
+      note_type   = bfd_h_get_32 (abfd, note + 8);
+
+      if (name_length == 4 && data_length == 16 && note_type == 1
+	  && strcmp (note + 12, "GNU") == 0)
+	{
+	  int os_number = bfd_h_get_32 (abfd, note + 16);
+
+	  /* The case numbers are from abi-tags in glibc.  */
+	  switch (os_number)
+	    {
+	    case 0 :
+	      *os_ident_ptr = ALPHA_ABI_LINUX;
+	      break;
+
+	    case 1 :
+	      internal_error
+		(__FILE__, __LINE__,
+		 "process_note_abi_sections: Hurd objects not supported");
+	      break;
+
+	    case 2 :
+	      internal_error
+		(__FILE__, __LINE__,
+		 "process_note_abi_sections: Solaris objects not supported");
+	      break;
+
+	    default :
+	      internal_error
+		(__FILE__, __LINE__,
+		 "process_note_abi_sections: unknown OS number %d",
+		 os_number);
+	      break;
+	    }
+	}
+    }
+  /* NetBSD uses a similar trick.  */
+  else if (strcmp (name, ".note.netbsd.ident") == 0 && sectsize > 0)
+    {
+      unsigned int name_length, desc_length, note_type;
+      char *note;
+
+      /* If the section is larger than this, it's probably not what we are
+         looking for.  */
+      if (sectsize > 128)
+	sectsize = 128;
+
+      note = alloca (sectsize);
+
+      bfd_get_section_contents (abfd, sect, note,
+				 (file_ptr) 0, (bfd_size_type) sectsize);
+      
+      name_length = bfd_h_get_32 (abfd, note);
+      desc_length = bfd_h_get_32 (abfd, note + 4);
+      note_type   = bfd_h_get_32 (abfd, note + 8);
+
+      if (name_length == 7 && desc_length == 4 && note_type == 1
+	  && strcmp (note + 12, "NetBSD") == 0)
+	/* XXX Should we check the version here?
+	   Probably not necessary yet.  */
+	*os_ident_ptr = ALPHA_ABI_NETBSD;
+    }
+}
+
+static int
+get_elfosabi (bfd *abfd)
+{
+  int elfosabi;
+  enum alpha_abi alpha_abi = ALPHA_ABI_UNKNOWN;
+
+  elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
+
+  /* When elfosabi is 0 (ELFOSABI_NONE), this is supposed to indicate
+     what we're on a SYSV system.  However, GNU/Linux uses a note section
+     to record OS/ABI info, but leaves e_ident[EI_OSABI] zero.  So we
+     have to check the note sections too.  */
+  if (elfosabi == 0)
+    {
+      bfd_map_over_sections (abfd,
+			     process_note_abi_tag_sections,
+			     &alpha_abi);
+    }
+
+  if (alpha_abi != ALPHA_ABI_UNKNOWN)
+    return alpha_abi;
+
+  switch (elfosabi)
+    {
+    case ELFOSABI_NONE:
+      /* Leave it as unknown.  */
+      break;
+
+    case ELFOSABI_NETBSD:
+      return ALPHA_ABI_NETBSD;
+
+    case ELFOSABI_FREEBSD:
+      return ALPHA_ABI_FREEBSD;
+
+    case ELFOSABI_LINUX:
+      return ALPHA_ABI_LINUX;
+    }
+
+  return ALPHA_ABI_UNKNOWN;
+}
+
+struct alpha_abi_handler
+{
+  struct alpha_abi_handler *next;
+  enum alpha_abi abi;
+  void (*init_abi)(struct gdbarch_info, struct gdbarch *);
+};
+
+struct alpha_abi_handler *alpha_abi_handler_list = NULL;
+
+void
+alpha_gdbarch_register_os_abi (enum alpha_abi abi,
+                               void (*init_abi)(struct gdbarch_info,
+						struct gdbarch *))
+{
+  struct alpha_abi_handler **handler_p;
+
+  for (handler_p = &alpha_abi_handler_list; *handler_p != NULL;
+       handler_p = &(*handler_p)->next)
+    {
+      if ((*handler_p)->abi == abi)
+	{
+	  internal_error
+	    (__FILE__, __LINE__,
+	     "alpha_gdbarch_register_os_abi: A handler for this ABI variant "
+	     "(%d) has already been registered", (int) abi);
+	  /* If user wants to continue, override previous definition.  */
+	  (*handler_p)->init_abi = init_abi;
+	  return;
+	}
+    }
+
+  (*handler_p)
+    = (struct alpha_abi_handler *) xmalloc (sizeof (struct alpha_abi_handler));
+  (*handler_p)->next = NULL;
+  (*handler_p)->abi = abi;
+  (*handler_p)->init_abi = init_abi;
+}
+
+/* Initialize the current architecture based on INFO.  If possible, re-use an
+   architecture from ARCHES, which is a list of architectures already created
+   during this debugging session.
+
+   Called e.g. at program startup, when reading a core file, and when reading
+   a binary file.  */
+
+static struct gdbarch *
+alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+{
+  struct gdbarch_tdep *tdep;
+  struct gdbarch *gdbarch;
+  enum alpha_abi alpha_abi = ALPHA_ABI_UNKNOWN;
+  struct alpha_abi_handler *abi_handler;
+
+  /* Try to determine the ABI of the object we are loading.  */
+
+  if (info.abfd != NULL)
+    {
+      switch (bfd_get_flavour (info.abfd))
+	{
+	case bfd_target_elf_flavour:
+	  alpha_abi = get_elfosabi (info.abfd);
+	  break;
+
+	case bfd_target_ecoff_flavour:
+	  /* Assume it's OSF/1.  */
+	  alpha_abi = ALPHA_ABI_OSF1;
+          break;
+
+	default:
+	  /* Not sure what to do here, leave the ABI as unknown.  */
+	  break;
+	}
+    }
+
+  /* Find a candidate among extant architectures.  */
+  for (arches = gdbarch_list_lookup_by_info (arches, &info);
+       arches != NULL;
+       arches = gdbarch_list_lookup_by_info (arches->next, &info))
+    {
+      /* Make sure the ABI selection matches.  */
+      tdep = gdbarch_tdep (arches->gdbarch);
+      if (tdep && tdep->alpha_abi == alpha_abi)
+	return arches->gdbarch;
+    }
+
+  tdep = xmalloc (sizeof (struct gdbarch_tdep));
+  gdbarch = gdbarch_alloc (&info, tdep);
+
+  tdep->alpha_abi = alpha_abi;
+  if (alpha_abi < ALPHA_ABI_INVALID)
+    tdep->abi_name = alpha_abi_names[alpha_abi];
+  else
+    {
+      internal_error (__FILE__, __LINE__, "Invalid setting of alpha_abi %d",
+		      (int) alpha_abi);
+      tdep->abi_name = "<invalid>";
+    }
+
+  /* Lowest text address.  This is used by heuristic_proc_start() to
+     decide when to stop looking.  */
+  tdep->vm_min_address = (CORE_ADDR) 0x120000000;
+
+  tdep->dynamic_sigtramp_offset = NULL;
+  tdep->skip_sigtramp_frame = NULL;
+  tdep->sigcontext_addr = NULL;
+
+  tdep->jb_pc = -1;	/* longjmp support not enabled by default  */
+
+  /* Type sizes */
+  set_gdbarch_short_bit (gdbarch, 16);
+  set_gdbarch_int_bit (gdbarch, 32);
+  set_gdbarch_long_bit (gdbarch, 64);
+  set_gdbarch_long_long_bit (gdbarch, 64);
+  set_gdbarch_float_bit (gdbarch, 32);
+  set_gdbarch_double_bit (gdbarch, 64);
+  set_gdbarch_long_double_bit (gdbarch, 64);
+  set_gdbarch_ptr_bit (gdbarch, 64);
+
+  /* Register info */
+  set_gdbarch_num_regs (gdbarch, ALPHA_NUM_REGS);
+  set_gdbarch_sp_regnum (gdbarch, ALPHA_SP_REGNUM);
+  set_gdbarch_fp_regnum (gdbarch, ALPHA_FP_REGNUM);
+  set_gdbarch_pc_regnum (gdbarch, ALPHA_PC_REGNUM);
+  set_gdbarch_fp0_regnum (gdbarch, ALPHA_FP0_REGNUM);
+
+  set_gdbarch_register_name (gdbarch, alpha_register_name);
+  set_gdbarch_register_size (gdbarch, ALPHA_REGISTER_SIZE);
+  set_gdbarch_register_bytes (gdbarch, ALPHA_REGISTER_BYTES);
+  set_gdbarch_register_byte (gdbarch, alpha_register_byte);
+  set_gdbarch_register_raw_size (gdbarch, alpha_register_raw_size);
+  set_gdbarch_max_register_raw_size (gdbarch, ALPHA_MAX_REGISTER_RAW_SIZE);
+  set_gdbarch_register_virtual_size (gdbarch, alpha_register_virtual_size);
+  set_gdbarch_max_register_virtual_size (gdbarch,
+                                         ALPHA_MAX_REGISTER_VIRTUAL_SIZE);
+  set_gdbarch_register_virtual_type (gdbarch, alpha_register_virtual_type);
+
+  set_gdbarch_cannot_fetch_register (gdbarch, alpha_cannot_fetch_register);
+  set_gdbarch_cannot_store_register (gdbarch, alpha_cannot_store_register);
+
+  set_gdbarch_register_convertible (gdbarch, alpha_register_convertible);
+  set_gdbarch_register_convert_to_virtual (gdbarch,
+                                           alpha_register_convert_to_virtual);
+  set_gdbarch_register_convert_to_raw (gdbarch, alpha_register_convert_to_raw);
+
+  set_gdbarch_skip_prologue (gdbarch, alpha_skip_prologue);
+
+  set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
+  set_gdbarch_frameless_function_invocation (gdbarch,
+                                    generic_frameless_function_invocation_not);
+
+  set_gdbarch_saved_pc_after_call (gdbarch, alpha_saved_pc_after_call);
+
+  set_gdbarch_frame_chain (gdbarch, alpha_frame_chain);
+  set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
+  set_gdbarch_frame_saved_pc (gdbarch, alpha_frame_saved_pc);
+
+  set_gdbarch_frame_init_saved_regs (gdbarch, alpha_frame_init_saved_regs);
+  set_gdbarch_get_saved_register (gdbarch, alpha_get_saved_register);
+
+  set_gdbarch_use_struct_convention (gdbarch, alpha_use_struct_convention);
+  set_gdbarch_extract_return_value (gdbarch, alpha_extract_return_value);
+
+  set_gdbarch_store_struct_return (gdbarch, alpha_store_struct_return);
+  set_gdbarch_store_return_value (gdbarch, alpha_store_return_value);
+  set_gdbarch_extract_struct_value_address (gdbarch,
+					    alpha_extract_struct_value_address);
+
+  /* Settings for calling functions in the inferior.  */
+  set_gdbarch_use_generic_dummy_frames (gdbarch, 0);
+  set_gdbarch_call_dummy_length (gdbarch, 0);
+  set_gdbarch_push_arguments (gdbarch, alpha_push_arguments);
+  set_gdbarch_pop_frame (gdbarch, alpha_pop_frame);
+
+  /* On the Alpha, the call dummy code is never copied to user space,
+     stopping the user call is achieved via a bp_call_dummy breakpoint.
+     But we need a fake CALL_DUMMY definition to enable the proper
+     call_function_by_hand and to avoid zero length array warnings.  */
+  set_gdbarch_call_dummy_p (gdbarch, 1);
+  set_gdbarch_call_dummy_words (gdbarch, alpha_call_dummy_words);
+  set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);
+  set_gdbarch_frame_args_address (gdbarch, alpha_frame_args_address);
+  set_gdbarch_frame_locals_address (gdbarch, alpha_frame_locals_address);
+  set_gdbarch_init_extra_frame_info (gdbarch, alpha_init_extra_frame_info);
+
+  /* Alpha OSF/1 inhibits execution of code on the stack.  But there is
+     no need for a dummy on the Alpha.  PUSH_ARGUMENTS takes care of all
+     argument handling and bp_call_dummy takes care of stopping the dummy.  */
+  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
+  set_gdbarch_call_dummy_address (gdbarch, alpha_call_dummy_address);
+  set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
+  set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
+  set_gdbarch_call_dummy_start_offset (gdbarch, 0);
+  set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
+  set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
+  set_gdbarch_push_dummy_frame (gdbarch, alpha_push_dummy_frame);
+  set_gdbarch_fix_call_dummy (gdbarch, alpha_fix_call_dummy);
+  set_gdbarch_init_frame_pc (gdbarch, init_frame_pc_noop);
+  set_gdbarch_init_frame_pc_first (gdbarch, alpha_init_frame_pc_first);
+
+  set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
+
+  /* Floats are always passed as doubles.  */
+  set_gdbarch_coerce_float_to_double (gdbarch,
+                                      standard_coerce_float_to_double);
+
+  set_gdbarch_breakpoint_from_pc (gdbarch, alpha_breakpoint_from_pc);
+  set_gdbarch_decr_pc_after_break (gdbarch, 4);
+
+  set_gdbarch_function_start_offset (gdbarch, 0);
+  set_gdbarch_frame_args_skip (gdbarch, 0);
+
+  /* Hook in ABI-specific overrides, if they have been registered.  */
+  if (alpha_abi == ALPHA_ABI_UNKNOWN)
+    {
+      /* Don't complain about not knowing the ABI variant if we don't
+	 have an inferior.  */
+      if (info.abfd)
+	fprintf_filtered
+	  (gdb_stderr, "GDB doesn't recognize the ABI of the inferior.  "
+	   "Attempting to continue with the default Alpha settings");
+    }
+  else
+    {
+      for (abi_handler = alpha_abi_handler_list; abi_handler != NULL;
+	   abi_handler = abi_handler->next)
+	if (abi_handler->abi == alpha_abi)
+	  break;
+
+      if (abi_handler)
+	abi_handler->init_abi (info, gdbarch);
+      else
+	{
+	  /* We assume that if GDB_MULTI_ARCH is less than
+	     GDB_MULTI_ARCH_TM that an ABI variant can be supported by
+	     overriding definitions in this file.  */
+	  if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
+	    fprintf_filtered
+	      (gdb_stderr,
+	       "A handler for the ABI variant \"%s\" is not built into this "
+	       "configuration of GDB.  "
+	       "Attempting to continue with the default Alpha settings",
+	       alpha_abi_names[alpha_abi]);
+	}
+    }
+
+  /* Now that we have tuned the configuration, set a few final things
+     based on what the OS ABI has told us.  */
+
+  if (tdep->jb_pc >= 0)
+    set_gdbarch_get_longjmp_target (gdbarch, alpha_get_longjmp_target);
+
+  return gdbarch;
+}
+
+static void
+alpha_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+  if (tdep == NULL)
+    return;
+
+  if (tdep->abi_name != NULL)
+    fprintf_unfiltered (file, "alpha_dump_tdep: ABI = %s\n", tdep->abi_name);
+  else
+    internal_error (__FILE__, __LINE__,
+		    "alpha_dump_tdep: illegal setting of tdep->alpha_abi (%d)",
+		    (int) tdep->alpha_abi);
+
+  fprintf_unfiltered (file,
+                      "alpha_dump_tdep: vm_min_address = 0x%lx\n",
+		      (long) tdep->vm_min_address);
+
+  fprintf_unfiltered (file,
+		      "alpha_dump_tdep: jb_pc = %d\n",
+		      tdep->jb_pc);
+  fprintf_unfiltered (file,
+		      "alpha_dump_tdep: jb_elt_size = %ld\n",
+		      (long) tdep->jb_elt_size);
+}
+
 void
 _initialize_alpha_tdep (void)
 {
   struct cmd_list_element *c;
 
+  gdbarch_register (bfd_arch_alpha, alpha_gdbarch_init, alpha_dump_tdep);
+
   tm_print_insn = print_insn_alpha;
 
   /* Let the user set the fence post for heuristic_proc_start.  */
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
new file mode 100644
index 0000000..c3ee007
--- /dev/null
+++ b/gdb/alpha-tdep.h
@@ -0,0 +1,125 @@
+/* Common target dependent code for GDB on Alpha systems.
+   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002 Free
+   Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef ALPHA_TDEP_H
+#define ALPHA_TDEP_H
+
+/* Say how long (ordinary) registers are.  This is a piece of bogosity
+   used in push_word and a few other places;  REGISTER_RAW_SIZE is the
+   real way to know how big a register is.  */
+#define ALPHA_REGISTER_SIZE 8
+
+/* Number of machine registers.  */
+#define ALPHA_NUM_REGS 66
+
+/* Total amount of space needed to store our copies of the machine's
+   register state.  */
+#define ALPHA_REGISTER_BYTES (ALPHA_NUM_REGS * 8)
+
+/* Largest value REGISTER_RAW_SIZE can have.  */
+#define ALPHA_MAX_REGISTER_RAW_SIZE 8
+
+/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
+#define ALPHA_MAX_REGISTER_VIRTUAL_SIZE 8
+
+/* Register numbers of various important registers.
+   Note that most of these values are "real" register numbers,
+   and correspond to the general registers of the machine,
+   and FP_REGNUM is a "phony" register number which is too large
+   to be an actual register number as far as the user is concerned
+   but serves to get the desired value when passed to read_register.  */
+
+#define ALPHA_V0_REGNUM	     0  /* Function integer return value */
+#define ALPHA_T7_REGNUM	     8  /* Return address register for OSF/1 __add* */
+#define ALPHA_GCC_FP_REGNUM 15  /* Used by gcc as frame register */
+#define ALPHA_A0_REGNUM     16  /* Loc of first arg during a subr call */
+#define ALPHA_T9_REGNUM     23  /* Return address register for OSF/1 __div* */
+#define ALPHA_T12_REGNUM    27  /* Contains start addr of current proc */
+#define ALPHA_SP_REGNUM     30  /* Contains address of top of stack */
+#define ALPHA_RA_REGNUM     26  /* Contains return address value */
+#define ALPHA_ZERO_REGNUM   31  /* Read-only register, always 0 */
+#define ALPHA_FP0_REGNUM    32  /* Floating point register 0 */
+#define ALPHA_FPA0_REGNUM   48  /* First float arg during a subr call */
+#define ALPHA_FPCR_REGNUM   63  /* Floating point control register */
+#define ALPHA_PC_REGNUM     64  /* Contains program counter */
+#define ALPHA_FP_REGNUM     65  /* Virtual frame pointer */
+
+/* The alpha has two different virtual pointers for arguments and locals.
+   
+   The virtual argument pointer is pointing to the bottom of the argument
+   transfer area, which is located immediately below the virtual frame
+   pointer. Its size is fixed for the native compiler, it is either zero
+   (for the no arguments case) or large enough to hold all argument registers.
+   gcc uses a variable sized argument transfer area. As it has
+   to stay compatible with the native debugging tools it has to use the same
+   virtual argument pointer and adjust the argument offsets accordingly.
+   
+   The virtual local pointer is localoff bytes below the virtual frame
+   pointer, the value of localoff is obtained from the PDR.  */
+#define ALPHA_NUM_ARG_REGS   6
+
+/* ABI variants that we know about.  If you add to this enum, please
+   update the table of names in alpha-tdep.c.  */
+enum alpha_abi
+{
+  ALPHA_ABI_UNKNOWN = 0,
+  ALPHA_ABI_OSF1,
+  ALPHA_ABI_LINUX,
+  ALPHA_ABI_FREEBSD,
+  ALPHA_ABI_NETBSD,
+
+  ALPHA_ABI_INVALID	/* Keep this last. */
+};
+
+/* Target-dependent structure in gdbarch.  */
+struct gdbarch_tdep
+{
+  enum alpha_abi alpha_abi;	/* OS/ABI of inferior.  */
+  const char *abi_name;		/* Name of the above.  */
+
+  CORE_ADDR vm_min_address;	/* used by heuristic_proc_start */
+
+  /* If PC is inside a dynamically-generated signal trampoline function
+     (i.e. one copied onto the user stack at run-time), return how many
+     bytes PC is beyond the start of that function.  Otherwise, return -1.  */
+  LONGEST (*dynamic_sigtramp_offset) (CORE_ADDR);
+
+  /* If FRAME refers to a sigtramp frame, return the address of the next
+     frame.  */
+  CORE_ADDR (*skip_sigtramp_frame) (struct frame_info *, CORE_ADDR);
+
+  /* Translate a signal handler frame into the address of the sigcontext
+     structure for that signal handler.  */
+  CORE_ADDR (*sigcontext_addr) (struct frame_info *);
+
+  int jb_pc;			/* Offset to PC value in jump buffer.
+				   If htis is negative, longjmp support
+				   will be disabled.  */
+  size_t jb_elt_size;		/* And the size of each entry in the buf. */
+};
+
+void alpha_software_single_step (enum target_signal, int);
+
+void alpha_gdbarch_register_os_abi (enum alpha_abi,
+                                    void (*init_abi)(struct gdbarch_info,
+						     struct gdbarch *));
+
+#endif /* ALPHA_TDEP_H */
diff --git a/gdb/alphabsd-nat.c b/gdb/alphabsd-nat.c
index d7ad3a7..92b0fc2 100644
--- a/gdb/alphabsd-nat.c
+++ b/gdb/alphabsd-nat.c
@@ -22,6 +22,8 @@
 #include "inferior.h"
 #include "regcache.h"
 
+#include "alpha-tdep.h"
+
 #include <sys/types.h>
 #include <sys/ptrace.h>
 #include <machine/reg.h>
@@ -103,7 +105,7 @@
 	supply_register (i, (char *) &fpregsetp->fpr_regs[i - FP0_REGNUM]);
     }
 
-  supply_register (FPCR_REGNUM, (char *) &fpregsetp->fpr_cr);
+  supply_register (ALPHA_FPCR_REGNUM, (char *) &fpregsetp->fpr_cr);
 }
 
 /* Fill register REGNO (if it is a floating-point register) in
@@ -119,8 +121,8 @@
     if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i))
       regcache_collect (i, (char *) &fpregsetp->fpr_regs[i - FP0_REGNUM]);
 
-  if (regno == -1 || regno == FPCR_REGNUM)
-    regcache_collect (FPCR_REGNUM, (char *) &fpregsetp->fpr_cr);
+  if (regno == -1 || regno == ALPHA_FPCR_REGNUM)
+    regcache_collect (ALPHA_FPCR_REGNUM, (char *) &fpregsetp->fpr_cr);
 }
 
 
@@ -130,7 +132,7 @@
 getregs_supplies (int regno)
 {
 
-  return ((regno >= V0_REGNUM && regno <= ZERO_REGNUM)
+  return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM)
 	  || regno >= PC_REGNUM);
 }
 
diff --git a/gdb/alphafbsd-tdep.c b/gdb/alphafbsd-tdep.c
index e2d4749..3c1e64d 100644
--- a/gdb/alphafbsd-tdep.c
+++ b/gdb/alphafbsd-tdep.c
@@ -1,5 +1,5 @@
 /* Target-dependent code for FreeBSD/Alpha.
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,7 +21,9 @@
 #include "defs.h"
 #include "value.h"
 
-int
+#include "alpha-tdep.h"
+
+static int
 alphafbsd_use_struct_convention (int gcc_p, struct type *type)
 {
   enum type_code code;
@@ -51,3 +53,30 @@
 
   return 0;
 }
+
+static int
+alphafbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+{
+  /* FIXME */
+  return 0;
+}
+
+static void
+alphafbsd_init_abi (struct gdbarch_info info,
+                    struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, alphafbsd_pc_in_sigtramp);
+
+  set_gdbarch_use_struct_convention (gdbarch, alphafbsd_use_struct_convention);
+
+  tdep->jb_pc = 2;
+  tdep->jb_elt_size = 8;
+}
+
+void
+_initialize_alphafbsd_tdep (void)
+{
+  alpha_gdbarch_register_os_abi (ALPHA_ABI_FREEBSD, alphafbsd_init_abi);
+}
diff --git a/gdb/alphanbsd-nat.c b/gdb/alphanbsd-nat.c
new file mode 100644
index 0000000..ed90de3
--- /dev/null
+++ b/gdb/alphanbsd-nat.c
@@ -0,0 +1,136 @@
+/* Native-dependent code for Alpha NetBSD.
+   Copyright 2002 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, Inc.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include <sys/types.h>
+#include <machine/reg.h>
+#include <machine/frame.h>  
+#include <machine/pcb.h>
+#include "gdbcore.h"
+#include "regcache.h"
+
+#include "alpha-tdep.h"
+
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
+
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t; 
+#endif
+
+#include "gregset.h"
+
+static void
+fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
+                      CORE_ADDR ignore)
+{
+  struct md_coredump *core_reg;
+  char *regs;
+  int regno;
+
+  /* Table to map a gdb register number to a trapframe register index.  */
+  static const int regmap[] =
+  {
+    FRAME_V0,  FRAME_T0,  FRAME_T1,  FRAME_T2,
+    FRAME_T3,  FRAME_T4,  FRAME_T5,  FRAME_T6,
+    FRAME_T7,  FRAME_S0,  FRAME_S1,  FRAME_S2,
+    FRAME_S3,  FRAME_S4,  FRAME_S5,  FRAME_S6,
+    FRAME_A0,  FRAME_A1,  FRAME_A2,  FRAME_A3,
+    FRAME_A4,  FRAME_A5,  FRAME_T8,  FRAME_T9,
+    FRAME_T10, FRAME_T11, FRAME_RA,  FRAME_T12,
+    FRAME_AT,  FRAME_GP,  FRAME_SP
+  };
+
+  /* We get everything from one section.  */
+  if (which != 0)
+    return;
+
+  core_reg = (struct md_coredump *) core_reg_sect;
+  regs = (char *) &core_reg->md_tf;
+
+  if (core_reg_size < sizeof (*core_reg))
+    {
+      warning ("Wrong size register set in core file.");
+      return;
+    }
+
+  /* Integer registers.  */
+  for (regno = 0; regno < ALPHA_ZERO_REGNUM; regno++)
+    supply_register (regno, regs + (regmap[regno] * 8));
+  supply_register (ALPHA_ZERO_REGNUM, NULL);
+  supply_register (FP_REGNUM, NULL);
+  supply_register (PC_REGNUM, regs + (FRAME_PC * 8));
+
+  /* Floating point registers.  */
+  supply_fpregset (&core_reg->md_fpstate);
+}
+
+static void
+fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which,
+                         CORE_ADDR ignore)
+{
+  switch (which)
+    {
+    case 0:  /* Integer registers.  */
+      if (core_reg_size != sizeof (struct reg))
+	warning ("Wrong size register set in core file.");
+      else
+	supply_gregset ((gregset_t *) core_reg_sect);
+      break;
+
+    case 2:  /* Floating point registers.  */
+      if (core_reg_size != sizeof (struct fpreg))
+	warning ("Wrong size FP register set in core file.");
+      else
+	supply_fpregset ((fpregset_t *) core_reg_sect);
+      break;
+
+    default:
+      /* Don't know what kind of register request this is; just ignore it.  */
+      break;
+    }
+}
+
+static struct core_fns alphanbsd_core_fns =
+{
+  bfd_target_unknown_flavour,		/* core_flavour */
+  default_check_format,			/* check_format */
+  default_core_sniffer,			/* core_sniffer */
+  fetch_core_registers,			/* core_read_registers */
+  NULL					/* next */
+};
+
+static struct core_fns alphanbsd_elfcore_fns =
+{
+  bfd_target_elf_flavour,		/* core_flavour */
+  default_check_format,			/* check_format */
+  default_core_sniffer,			/* core_sniffer */
+  fetch_elfcore_registers,		/* core_read_registers */
+  NULL					/* next */
+};
+
+void
+_initialize_alphanbsd_nat (void)
+{
+  add_core_fns (&alphanbsd_core_fns);
+  add_core_fns (&alphanbsd_elfcore_fns);
+}
diff --git a/gdb/alphanbsd-tdep.c b/gdb/alphanbsd-tdep.c
new file mode 100644
index 0000000..33c3cd7
--- /dev/null
+++ b/gdb/alphanbsd-tdep.c
@@ -0,0 +1,157 @@
+/* Target-dependent code for NetBSD/Alpha.
+   Copyright 2002 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, Inc.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "gdbcore.h"
+#include "value.h"
+#include "solib-svr4.h"
+
+#include "alpha-tdep.h"
+
+/* Fetch (and possibly build) an appropriate link_map_offsets
+   structure for NetBSD/alpha targets using the struct offsets
+   defined in <link.h> (but without actual reference to that file).
+
+   This makes it possible to access NetBSD/alpha shared libraries
+   from a GDB that was not built on a NetBSD/alpha host (for cross
+   debugging).  */
+
+static struct link_map_offsets *
+alphanbsd_solib_svr4_fetch_link_map_offsets (void)
+{
+  static struct link_map_offsets lmo;
+  static struct link_map_offsets *lmp = NULL;
+
+  if (lmp == NULL)
+    {
+      lmp = &lmo;
+
+      lmo.r_debug_size = 32;
+
+      lmo.r_map_offset = 8;
+      lmo.r_map_size   = 8;
+
+      lmo.link_map_size = 40;
+
+      lmo.l_addr_offset = 0;
+      lmo.l_addr_size   = 8;
+
+      lmo.l_name_offset = 8;
+      lmo.l_name_size   = 8;
+
+      lmo.l_next_offset = 24;
+      lmo.l_next_size   = 8;
+
+      lmo.l_prev_offset = 32;
+      lmo.l_prev_size   = 8;
+    }
+
+  return lmp;
+}
+
+/* Under NetBSD/alpha, signal handler invocations can be identified by the
+   designated code sequence that is used to return from a signal handler.
+   In particular, the return address of a signal handler points to the
+   following code sequence:
+
+	ldq	a0, 0(sp)
+	lda	sp, 16(sp)
+	lda	v0, 295(zero)	# __sigreturn14
+	call_pal callsys
+
+   Each instruction has a unique encoding, so we simply attempt to match
+   the instruction the PC is pointing to with any of the above instructions.
+   If there is a hit, we know the offset to the start of the designated
+   sequence and can then check whether we really are executing in the
+   signal trampoline.  If not, -1 is returned, otherwise the offset from the
+   start of the return sequence is returned.  */
+static const unsigned int sigtramp_retcode[] =
+{
+  0xa61e0000,		/* ldq a0, 0(sp) */
+  0x23de0010,		/* lda sp, 16(sp) */
+  0x201f0127,		/* lda v0, 295(zero) */
+  0x00000083,		/* call_pal callsys */
+};
+#define	RETCODE_NWORDS \
+  (sizeof (sigtramp_retcode) / sizeof (sigtramp_retcode[0]))
+
+LONGEST
+alphanbsd_sigtramp_offset (CORE_ADDR pc)
+{
+  unsigned int ret[4], w;
+  LONGEST off;
+  int i;
+
+  if (read_memory_nobpt (pc, (char *) &w, 4) != 0)
+    return -1;
+
+  for (i = 0; i < RETCODE_NWORDS; i++)
+    {
+      if (w == sigtramp_retcode[i])
+	break;
+    }
+  if (i == RETCODE_NWORDS)
+    return (-1);
+
+  off = i * 4;
+  pc -= off;
+
+  if (read_memory_nobpt (pc, (char *) ret, sizeof (ret)) != 0)
+    return -1;
+
+  if (memcmp (ret, sigtramp_retcode, sizeof (sigtramp_retcode)) == 0)
+    return off;
+
+  return -1;
+}
+
+static int
+alphanbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+{
+  return (alphanbsd_sigtramp_offset (pc) >= 0);
+}
+
+static void
+alphanbsd_init_abi (struct gdbarch_info info,
+                    struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, alphanbsd_pc_in_sigtramp);
+
+  /* NetBSD/alpha does not provide single step support via ptrace(2); we
+     must use software single-stepping.  */
+  set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
+
+  set_solib_svr4_fetch_link_map_offsets (gdbarch,
+                                  alphanbsd_solib_svr4_fetch_link_map_offsets);
+
+  tdep->dynamic_sigtramp_offset = alphanbsd_sigtramp_offset;
+
+  tdep->jb_pc = 2;
+  tdep->jb_elt_size = 8;
+}
+
+void
+_initialize_alphanbsd_tdep (void)
+{
+  alpha_gdbarch_register_os_abi (ALPHA_ABI_NETBSD, alphanbsd_init_abi);
+}
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index ffa538f..cab7721 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -296,6 +296,14 @@
   return codestream_tell ();
 }
 
+/* Is the prologue at PC frameless?  */
+
+int
+arc_prologue_frameless_p (CORE_ADDR pc)
+{
+  return (pc == arc_skip_prologue (pc, 1));
+}
+
 /* Return the return address for a frame.
    This is used to implement FRAME_SAVED_PC.
    This is taken from frameless_look_for_prologue.  */
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 5612ddf..154438a 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -1,5 +1,7 @@
 /* Dynamic architecture support for GDB, the GNU debugger.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
+   Inc.
 
    This file is part of GDB.
 
@@ -55,7 +57,7 @@
    and optionally adjust the pc to point to the correct memory location
    for inserting the breakpoint.  */
 
-unsigned char *
+const unsigned char *
 legacy_breakpoint_from_pc (CORE_ADDR * pcptr, int *lenptr)
 {
   /* {BIG_,LITTLE_}BREAKPOINT is the sequence of bytes we insert for a
@@ -152,11 +154,7 @@
 int
 generic_prologue_frameless_p (CORE_ADDR ip)
 {
-#ifdef SKIP_PROLOGUE_FRAMELESS_P
-  return ip == SKIP_PROLOGUE_FRAMELESS_P (ip);
-#else
   return ip == SKIP_PROLOGUE (ip);
-#endif
 }
 
 /* New/multi-arched targets should use the correct gdbarch field
@@ -340,7 +338,7 @@
 	      flush_cached_frames ();
 	      registers_changed ();
 	      stop_pc = wait_pc;
-	      select_frame (get_current_frame (), 0);
+	      select_frame (get_current_frame ());
 	    }
           /* We return 1 to indicate that there is a breakpoint here,
              so we need to step over it before continuing to avoid
@@ -421,6 +419,24 @@
   return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (regnum));
 }
 
+#if !defined (IN_SIGTRAMP)
+#if defined (SIGTRAMP_START)
+#define IN_SIGTRAMP(pc, name) \
+       ((pc) >= SIGTRAMP_START(pc)   \
+        && (pc) < SIGTRAMP_END(pc) \
+        )
+#else
+#define IN_SIGTRAMP(pc, name) \
+       (name && STREQ ("_sigtramp", name))
+#endif
+#endif
+
+int
+legacy_pc_in_sigtramp (CORE_ADDR pc, char *name)
+{
+  return IN_SIGTRAMP(pc, name);
+}
+
 
 /* Functions to manipulate the endianness of the target.  */
 
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 96d1b8b..7220062 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -1,5 +1,6 @@
 /* Dynamic architecture support for GDB, the GNU debugger.
-   Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -156,6 +157,9 @@
 
 extern int generic_register_virtual_size (int regnum);
 
+/* Prop up old targets that use various IN_SIGTRAMP() macros.  */
+extern int legacy_pc_in_sigtramp (CORE_ADDR pc, char *name);
+
 /* Initialize a ``struct info''.  Can't use memset(0) since some
    default values are not zero.  */
 extern void gdbarch_info_init (struct gdbarch_info *info);
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index b164f8e..fa0b365 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -93,8 +93,8 @@
 #define MSYMBOL_SIZE(msym)				\
 	((long) MSYMBOL_INFO (msym) & 0x7fffffff)
 
-/* This table matches the indicees assigned to enum arm_abi.  Keep
-   them in sync.  */
+/* This table matches the indicees assigned to enum arm_abi. 
+   Keep them in sync.  */
 
 static const char * const arm_abi_names[] =
 {
@@ -110,15 +110,15 @@
   NULL
 };
 
-/* Number of different reg name sets (options). */
+/* Number of different reg name sets (options).  */
 static int num_flavor_options;
 
 /* We have more registers than the disassembler as gdb can print the value
    of special registers as well.
    The general register names are overwritten by whatever is being used by
-   the disassembler at the moment. We also adjust the case of cpsr and fps. */
+   the disassembler at the moment. We also adjust the case of cpsr and fps.  */
 
-/* Initial value: Register names used in ARM's ISA documentation. */
+/* Initial value: Register names used in ARM's ISA documentation.  */
 static char * arm_register_name_strings[] =
 {"r0",  "r1",  "r2",  "r3",	/*  0  1  2  3 */
  "r4",  "r5",  "r6",  "r7",	/*  4  5  6  7 */
@@ -126,15 +126,16 @@
  "r12", "sp",  "lr",  "pc",	/* 12 13 14 15 */
  "f0",  "f1",  "f2",  "f3",	/* 16 17 18 19 */
  "f4",  "f5",  "f6",  "f7",	/* 20 21 22 23 */
- "fps", "cpsr" }; 		/* 24 25       */
+ "fps", "cpsr" };		/* 24 25       */
 static char **arm_register_names = arm_register_name_strings;
 
 /* Valid register name flavors.  */
 static const char **valid_flavors;
 
-/* Disassembly flavor to use. Default to "std" register names. */
+/* Disassembly flavor to use. Default to "std" register names.  */
 static const char *disassembly_flavor;
-static int current_option;	/* Index to that option in the opcodes table. */
+/* Index to that option in the opcodes table.  */
+static int current_option;
 
 /* This is used to keep the bfd arch_info in sync with the disassembly
    flavor.  */
@@ -148,7 +149,7 @@
    all saved registers, 'cause we need 'em a lot!  We also keep the
    current size of the stack frame, and the offset of the frame
    pointer from the stack pointer (for frameless functions, and when
-   we're still in the prologue of a function with a frame) */
+   we're still in the prologue of a function with a frame).  */
 
 struct frame_extra_info
 {
@@ -169,7 +170,7 @@
   return (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC));
 }
 
-/* Set to true if the 32-bit mode is in use. */
+/* Set to true if the 32-bit mode is in use.  */
 
 int arm_apcs_32 = 1;
 
@@ -225,7 +226,7 @@
      We hope the current stack pointer is not so far alway from the dummy
      frame location (true if we have not pushed large data structures or
      gone too many levels deep) and that our 1024 is not enough to consider
-     code regions as part of the stack (true for most practical purposes) */
+     code regions as part of the stack (true for most practical purposes).  */
   if (PC_IN_CALL_DUMMY (memaddr, sp, sp + 1024))
     return caller_is_thumb;
   else
@@ -288,7 +289,7 @@
 
   /* There are some frameless functions whose first two instructions
      follow the standard APCS form, in which case after_prologue will
-     be func_start + 8. */
+     be func_start + 8.  */
 
   frameless = (after_prologue < func_start + 12);
   return frameless;
@@ -348,49 +349,56 @@
 thumb_skip_prologue (CORE_ADDR pc, CORE_ADDR func_end)
 {
   CORE_ADDR current_pc;
-  int findmask = 0;  	/* findmask:
-      			   bit 0 - push { rlist }
-			   bit 1 - mov r7, sp  OR  add r7, sp, #imm  (setting of r7)
-      			   bit 2 - sub sp, #simm  OR  add sp, #simm  (adjusting of sp)
-			*/
+  /* findmask:
+     bit 0 - push { rlist }
+     bit 1 - mov r7, sp  OR  add r7, sp, #imm  (setting of r7)
+     bit 2 - sub sp, #simm  OR  add sp, #simm  (adjusting of sp)
+  */
+  int findmask = 0;
 
-  for (current_pc = pc; current_pc + 2 < func_end && current_pc < pc + 40; current_pc += 2)
+  for (current_pc = pc;
+       current_pc + 2 < func_end && current_pc < pc + 40;
+       current_pc += 2)
     {
       unsigned short insn = read_memory_unsigned_integer (current_pc, 2);
 
-      if ((insn & 0xfe00) == 0xb400)	/* push { rlist } */
+      if ((insn & 0xfe00) == 0xb400)		/* push { rlist } */
 	{
-	  findmask |= 1;  /* push found */
+	  findmask |= 1;			/* push found */
 	}
-      else if ((insn & 0xff00) == 0xb000)	/* add sp, #simm  OR  sub sp, #simm */
+      else if ((insn & 0xff00) == 0xb000)	/* add sp, #simm  OR  
+						   sub sp, #simm */
 	{
-	  if ((findmask & 1) == 0)  /* before push ? */
+	  if ((findmask & 1) == 0)		/* before push ? */
 	    continue;
 	  else
-	    findmask |= 4;  /* add/sub sp found */
+	    findmask |= 4;			/* add/sub sp found */
 	}
       else if ((insn & 0xff00) == 0xaf00)	/* add r7, sp, #imm */
 	{
-	  findmask |= 2;  /* setting of r7 found */
+	  findmask |= 2;			/* setting of r7 found */
 	}
       else if (insn == 0x466f)			/* mov r7, sp */
 	{
-	  findmask |= 2;  /* setting of r7 found */
+	  findmask |= 2;			/* setting of r7 found */
 	}
       else if (findmask == (4+2+1))
 	{
-	  break;	/* We have found one of each type of prologue instruction */
+	  /* We have found one of each type of prologue instruction */
+	  break;
 	}
       else
-	continue;	/* something in the prolog that we don't care about or some
-	  		   instruction from outside the prolog scheduled here for optimization */
+	/* Something in the prolog that we don't care about or some
+	   instruction from outside the prolog scheduled here for
+	   optimization.  */
+	continue;
     }
 
   return current_pc;
 }
 
-/* Advance the PC across any function entry prologue instructions to reach
-   some "real" code.
+/* Advance the PC across any function entry prologue instructions to
+   reach some "real" code.
 
    The APCS (ARM Procedure Call Standard) defines the following
    prologue:
@@ -423,7 +431,7 @@
       sym = lookup_symbol (func_name, NULL, VAR_NAMESPACE, NULL, NULL);
       if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
         {
-	  /* Don't use this trick for assembly source files. */
+	  /* Don't use this trick for assembly source files.  */
 	  sal = find_pc_line (func_addr, 0);
 	  if ((sal.line != 0) && (sal.end < func_end))
 	    return sal.end;
@@ -435,29 +443,38 @@
     return thumb_skip_prologue (pc, func_end);
 
   /* Can't find the prologue end in the symbol table, try it the hard way
-     by disassembling the instructions. */
+     by disassembling the instructions.  */
   skip_pc = pc;
   inst = read_memory_integer (skip_pc, 4);
-  if (inst != 0xe1a0c00d)	/* mov ip, sp */
-    return pc;
-
-  skip_pc += 4;
-  inst = read_memory_integer (skip_pc, 4);
-  if ((inst & 0xfffffff0) == 0xe92d0000)	/* stmfd sp!,{a1,a2,a3,a4}  */
+  /* "mov ip, sp" is no longer a required part of the prologue.  */
+  if (inst == 0xe1a0c00d)			/* mov ip, sp */
     {
       skip_pc += 4;
       inst = read_memory_integer (skip_pc, 4);
     }
 
-  if ((inst & 0xfffff800) != 0xe92dd800)	/* stmfd sp!,{...,fp,ip,lr,pc} */
-    return pc;
+  /* Some prologues begin with "str lr, [sp, #-4]!".  */
+  if (inst == 0xe52de004)			/* str lr, [sp, #-4]! */
+    {
+      skip_pc += 4;
+      inst = read_memory_integer (skip_pc, 4);
+    }
 
-  skip_pc += 4;
-  inst = read_memory_integer (skip_pc, 4);
+  if ((inst & 0xfffffff0) == 0xe92d0000)	/* stmfd sp!,{a1,a2,a3,a4} */
+    {
+      skip_pc += 4;
+      inst = read_memory_integer (skip_pc, 4);
+    }
+
+  if ((inst & 0xfffff800) == 0xe92dd800)	/* stmfd sp!,{fp,ip,lr,pc} */
+    {
+      skip_pc += 4;
+      inst = read_memory_integer (skip_pc, 4);
+    }
 
   /* Any insns after this point may float into the code, if it makes
      for better instruction scheduling, so we skip them only if we
-     find them, but still consdier the function to be frame-ful.  */
+     find them, but still consider the function to be frame-ful.  */
 
   /* We may have either one sfmfd instruction here, or several stfe
      insns, depending on the version of floating point code we
@@ -469,7 +486,7 @@
     }
   else
     {
-      while ((inst & 0xffff8fff) == 0xed6d0103)		/* stfe fn, [sp, #-12]! */
+      while ((inst & 0xffff8fff) == 0xed6d0103)	/* stfe fn, [sp, #-12]! */
 	{
 	  skip_pc += 4;
 	  inst = read_memory_integer (skip_pc, 4);
@@ -477,10 +494,26 @@
     }
 
   if ((inst & 0xfffff000) == 0xe24cb000)	/* sub fp, ip, #nn */
-    skip_pc += 4;
+    {
+      skip_pc += 4;
+      inst = read_memory_integer (skip_pc, 4);
+    }
+
+  if ((inst & 0xfffff000) == 0xe24dd000)	/* sub sp, sp, #nn */
+    {
+      skip_pc += 4;
+      inst = read_memory_integer (skip_pc, 4);
+    }
+
+  while ((inst & 0xffffcfc0) == 0xe50b0000)	/* str r(0123), [r11, #-nn] */
+    {
+      skip_pc += 4;
+      inst = read_memory_integer (skip_pc, 4);
+    }
 
   return skip_pc;
 }
+
 /* *INDENT-OFF* */
 /* Function: thumb_scan_prologue (helper function for arm_scan_prologue)
    This function decodes a Thumb function prologue to determine:
@@ -500,8 +533,8 @@
    The frame size would thus be 36 bytes, and the frame offset would be
    12 bytes.  The frame register is R7. 
    
-   The comments for thumb_skip_prolog() describe the algorithm we use to detect
-   the end of the prolog */
+   The comments for thumb_skip_prolog() describe the algorithm we use
+   to detect the end of the prolog.  */
 /* *INDENT-ON* */
 
 static void
@@ -510,26 +543,29 @@
   CORE_ADDR prologue_start;
   CORE_ADDR prologue_end;
   CORE_ADDR current_pc;
-  int saved_reg[16];		/* which register has been copied to register n? */
-  int findmask = 0;  	/* findmask:
-      			   bit 0 - push { rlist }
-			   bit 1 - mov r7, sp  OR  add r7, sp, #imm  (setting of r7)
-      			   bit 2 - sub sp, #simm  OR  add sp, #simm  (adjusting of sp)
-			*/
+  /* Which register has been copied to register n?  */
+  int saved_reg[16];
+  /* findmask:
+     bit 0 - push { rlist }
+     bit 1 - mov r7, sp  OR  add r7, sp, #imm  (setting of r7)
+     bit 2 - sub sp, #simm  OR  add sp, #simm  (adjusting of sp)
+  */
+  int findmask = 0;
   int i;
 
   if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end))
     {
       struct symtab_and_line sal = find_pc_line (prologue_start, 0);
 
-      if (sal.line == 0)	/* no line info, use current PC */
+      if (sal.line == 0)		/* no line info, use current PC  */
 	prologue_end = fi->pc;
       else if (sal.end < prologue_end)	/* next line begins after fn end */
-	prologue_end = sal.end;	/* (probably means no prologue)  */
+	prologue_end = sal.end;		/* (probably means no prologue)  */
     }
   else
-    prologue_end = prologue_start + 40;		/* We're in the boondocks: allow for */
-  /* 16 pushes, an add, and "mv fp,sp" */
+    /* We're in the boondocks: allow for 
+       16 pushes, an add, and "mv fp,sp".  */
+    prologue_end = prologue_start + 40;
 
   prologue_end = min (prologue_end, fi->pc);
 
@@ -556,7 +592,7 @@
       if ((insn & 0xfe00) == 0xb400)	/* push { rlist } */
 	{
 	  int mask;
-	  findmask |= 1;  /* push found */
+	  findmask |= 1;		/* push found */
 	  /* Bits 0-7 contain a mask for registers R0-R7.  Bit 8 says
 	     whether to save LR (R14).  */
 	  mask = (insn & 0xff) | ((insn & 0x100) << 6);
@@ -568,18 +604,20 @@
 		fi->extra_info->framesize += 4;
 		fi->saved_regs[saved_reg[regno]] =
 		  -(fi->extra_info->framesize);
-		saved_reg[regno] = regno;	/* reset saved register map */
+		/* Reset saved register map.  */
+		saved_reg[regno] = regno;
 	      }
 	}
-      else if ((insn & 0xff00) == 0xb000)	/* add sp, #simm  OR  sub sp, #simm */
+      else if ((insn & 0xff00) == 0xb000)	/* add sp, #simm  OR  
+						   sub sp, #simm */
 	{
-	  if ((findmask & 1) == 0)  /* before push ? */
+	  if ((findmask & 1) == 0)  		/* before push?  */
 	    continue;
 	  else
-	    findmask |= 4;  /* add/sub sp found */
+	    findmask |= 4;			/* add/sub sp found */
 	  
-	  offset = (insn & 0x7f) << 2;	/* get scaled offset */
-	  if (insn & 0x80)	/* is it signed? (==subtracting) */
+	  offset = (insn & 0x7f) << 2;		/* get scaled offset */
+	  if (insn & 0x80)		/* is it signed? (==subtracting) */
 	    {
 	      fi->extra_info->frameoffset += offset;
 	      offset = -offset;
@@ -588,27 +626,29 @@
 	}
       else if ((insn & 0xff00) == 0xaf00)	/* add r7, sp, #imm */
 	{
-	  findmask |= 2;  /* setting of r7 found */
+	  findmask |= 2;			/* setting of r7 found */
 	  fi->extra_info->framereg = THUMB_FP_REGNUM;
 	  /* get scaled offset */
 	  fi->extra_info->frameoffset = (insn & 0xff) << 2;
 	}
       else if (insn == 0x466f)			/* mov r7, sp */
 	{
-	  findmask |= 2;  /* setting of r7 found */
+	  findmask |= 2;			/* setting of r7 found */
 	  fi->extra_info->framereg = THUMB_FP_REGNUM;
 	  fi->extra_info->frameoffset = 0;
 	  saved_reg[THUMB_FP_REGNUM] = ARM_SP_REGNUM;
 	}
       else if ((insn & 0xffc0) == 0x4640)	/* mov r0-r7, r8-r15 */
 	{
-	  int lo_reg = insn & 7;	/* dest. register (r0-r7) */
+	  int lo_reg = insn & 7;		/* dest.  register (r0-r7) */
 	  int hi_reg = ((insn >> 3) & 7) + 8;	/* source register (r8-15) */
-	  saved_reg[lo_reg] = hi_reg;	/* remember hi reg was saved */
+	  saved_reg[lo_reg] = hi_reg;		/* remember hi reg was saved */
 	}
       else
-	continue;	/* something in the prolog that we don't care about or some
-	  		   instruction from outside the prolog scheduled here for optimization */
+	/* Something in the prolog that we don't care about or some
+	   instruction from outside the prolog scheduled here for
+	   optimization.  */ 
+	continue;
     }
 }
 
@@ -740,7 +780,7 @@
   LONGEST return_value;
   CORE_ADDR prologue_start, prologue_end, current_pc;
 
-  /* Check if this function is already in the cache of frame information. */
+  /* Check if this function is already in the cache of frame information.  */
   if (check_prologue_cache (fi))
     return;
 
@@ -791,23 +831,23 @@
 	    
 	 is a suitable endpoint since it accounts for the largest
 	 possible prologue plus up to five instructions inserted by
-	 the scheduler. */
+	 the scheduler.  */
          
       if (prologue_end > prologue_start + 64)
 	{
-	  prologue_end = prologue_start + 64;	/* See above. */
+	  prologue_end = prologue_start + 64;	/* See above.  */
 	}
     }
   else
     {
-      /* Get address of the stmfd in the prologue of the callee; the saved
-         PC is the address of the stmfd + 8.  */
+      /* Get address of the stmfd in the prologue of the callee; 
+         the saved PC is the address of the stmfd + 8.  */
       if (!safe_read_memory_integer (fi->frame, 4,  &return_value))
         return;
       else
         {
           prologue_start = ADDR_BITS_REMOVE (return_value) - 8;
-          prologue_end = prologue_start + 64;   /* See above. */
+          prologue_end = prologue_start + 64;	/* See above.  */
         }
     }
 
@@ -822,30 +862,41 @@
      traceback.
 
      In the APCS, the prologue should start with  "mov ip, sp" so
-     if we don't see this as the first insn, we will stop.  [Note:
-     This doesn't seem to be true any longer, so it's now an optional
-     part of the prologue.  - Kevin Buettner, 2001-11-20]  */
+     if we don't see this as the first insn, we will stop.  
+
+     [Note: This doesn't seem to be true any longer, so it's now an
+     optional part of the prologue.  - Kevin Buettner, 2001-11-20]
+
+     [Note further: The "mov ip,sp" only seems to be missing in
+     frameless functions at optimization level "-O2" or above,
+     in which case it is often (but not always) replaced by
+     "str lr, [sp, #-4]!".  - Michael Snyder, 2002-04-23]   */
 
   sp_offset = fp_offset = 0;
 
-  if (read_memory_unsigned_integer (prologue_start, 4)
-      == 0xe1a0c00d)		/* mov ip, sp */
-    current_pc = prologue_start + 4;
-  else
-    current_pc = prologue_start;
-
-  for (; current_pc < prologue_end; current_pc += 4)
+  for (current_pc = prologue_start;
+       current_pc < prologue_end;
+       current_pc += 4)
     {
       unsigned int insn = read_memory_unsigned_integer (current_pc, 4);
 
-      if ((insn & 0xffff0000) == 0xe92d0000)
+      if (insn == 0xe1a0c00d)		/* mov ip, sp */
+	{
+	  continue;
+	}
+      else if (insn == 0xe52de004)	/* str lr, [sp, #-4]! */
+	{
+	  /* Function is frameless: extra_info defaults OK?  */
+	  continue;
+	}
+      else if ((insn & 0xffff0000) == 0xe92d0000)
 	/* stmfd sp!, {..., fp, ip, lr, pc}
 	   or
 	   stmfd sp!, {a1, a2, a3, a4}  */
 	{
 	  int mask = insn & 0xffff;
 
-	  /* Calculate offsets of saved registers. */
+	  /* Calculate offsets of saved registers.  */
 	  for (regno = ARM_PC_REGNUM; regno >= 0; regno--)
 	    if (mask & (1 << regno))
 	      {
@@ -853,18 +904,23 @@
 		fi->saved_regs[regno] = sp_offset;
 	      }
 	}
+      else if ((insn & 0xffffcfc0) == 0xe50b0000)	/* str rx, [r11, -n] */
+	{
+	  /* No need to add this to saved_regs -- it's just an arg reg.  */
+	  continue;
+	}
       else if ((insn & 0xfffff000) == 0xe24cb000)	/* sub fp, ip #n */
 	{
-	  unsigned imm = insn & 0xff;	/* immediate value */
-	  unsigned rot = (insn & 0xf00) >> 7;	/* rotate amount */
+	  unsigned imm = insn & 0xff;			/* immediate value */
+	  unsigned rot = (insn & 0xf00) >> 7;		/* rotate amount */
 	  imm = (imm >> rot) | (imm << (32 - rot));
 	  fp_offset = -imm;
 	  fi->extra_info->framereg = ARM_FP_REGNUM;
 	}
       else if ((insn & 0xfffff000) == 0xe24dd000)	/* sub sp, sp #n */
 	{
-	  unsigned imm = insn & 0xff;	/* immediate value */
-	  unsigned rot = (insn & 0xf00) >> 7;	/* rotate amount */
+	  unsigned imm = insn & 0xff;			/* immediate value */
+	  unsigned rot = (insn & 0xf00) >> 7;		/* rotate amount */
 	  imm = (imm >> rot) | (imm << (32 - rot));
 	  sp_offset -= imm;
 	}
@@ -879,7 +935,7 @@
 	  int n_saved_fp_regs;
 	  unsigned int fp_start_reg, fp_bound_reg;
 
-	  if ((insn & 0x800) == 0x800)	/* N0 is set */
+	  if ((insn & 0x800) == 0x800)		/* N0 is set */
 	    {
 	      if ((insn & 0x40000) == 0x40000)	/* N1 is set */
 		n_saved_fp_regs = 3;
@@ -903,18 +959,18 @@
 	    }
 	}
       else if ((insn & 0xf0000000) != 0xe0000000)
-	break;	/* Condition not true, exit early */
+	break;			/* Condition not true, exit early */
       else if ((insn & 0xfe200000) == 0xe8200000) /* ldm? */
-	break;	/* Don't scan past a block load */
+	break;			/* Don't scan past a block load */
       else
 	/* The optimizer might shove anything into the prologue,
-	   so we just skip what we don't recognize. */
+	   so we just skip what we don't recognize.  */
 	continue;
     }
 
-  /* The frame size is just the negative of the offset (from the original SP)
-     of the last thing thing we pushed on the stack.  The frame offset is
-     [new FP] - [new SP].  */
+  /* The frame size is just the negative of the offset (from the
+     original SP) of the last thing thing we pushed on the stack. 
+     The frame offset is [new FP] - [new SP].  */
   fi->extra_info->framesize = -sp_offset;
   if (fi->extra_info->framereg == ARM_FP_REGNUM)
     fi->extra_info->frameoffset = fp_offset - sp_offset;
@@ -936,7 +992,7 @@
 {
   for (; fi; fi = fi->next)
 
-#if 0				/* FIXME: enable this code if we convert to new call dummy scheme.  */
+#if 0	/* FIXME: enable this code if we convert to new call dummy scheme.  */
     if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
       return generic_read_register_dummy (fi->pc, fi->frame, regnum);
     else
@@ -955,18 +1011,18 @@
 static CORE_ADDR
 arm_frame_chain (struct frame_info *fi)
 {
-#if 0				/* FIXME: enable this code if we convert to new call dummy scheme.  */
+#if 0	/* FIXME: enable this code if we convert to new call dummy scheme.  */
   CORE_ADDR fn_start, callers_pc, fp;
 
-  /* is this a dummy frame? */
+  /* Is this a dummy frame?  */
   if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
     return fi->frame;		/* dummy frame same as caller's frame */
 
-  /* is caller-of-this a dummy frame? */
+  /* Is caller-of-this a dummy frame?  */
   callers_pc = FRAME_SAVED_PC (fi);	/* find out who called us: */
   fp = arm_find_callers_reg (fi, ARM_FP_REGNUM);
   if (PC_IN_CALL_DUMMY (callers_pc, fp, fp))
-    return fp;			/* dummy frame's frame may bear no relation to ours */
+    return fp;		/* dummy frame's frame may bear no relation to ours */
 
   if (find_pc_partial_function (fi->pc, 0, &fn_start, 0))
     if (fn_start == entry_point_address ())
@@ -987,7 +1043,7 @@
   /* If the caller is Thumb and the caller is ARM, or vice versa,
      the frame register of the caller is different from ours.
      So we must scan the prologue of the caller to determine its
-     frame register number. */
+     frame register number.  */
   /* XXX Fixme, we should try to do this without creating a temporary
      caller_fi.  */
   if (arm_pc_is_thumb (caller_pc) != arm_pc_is_thumb (fi->pc))
@@ -1053,11 +1109,11 @@
 
   memset (fi->saved_regs, '\000', sizeof fi->saved_regs);
 
-#if 0				/* FIXME: enable this code if we convert to new call dummy scheme.  */
+#if 0	/* FIXME: enable this code if we convert to new call dummy scheme.  */
   if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
     {
-      /* We need to setup fi->frame here because run_stack_dummy gets it wrong
-         by assuming it's always FP.  */
+      /* We need to setup fi->frame here because run_stack_dummy gets
+         it wrong by assuming it's always FP.  */
       fi->frame = generic_read_register_dummy (fi->pc, fi->frame,
 					       ARM_SP_REGNUM);
       fi->extra_info->framesize = 0;
@@ -1067,33 +1123,33 @@
   else
 #endif
 
-  /* Compute stack pointer for this frame.  We use this value for both the
-     sigtramp and call dummy cases.  */
+  /* Compute stack pointer for this frame.  We use this value for both
+     the sigtramp and call dummy cases.  */
   if (!fi->next)
     sp = read_sp();
   else
     sp = (fi->next->frame - fi->next->extra_info->frameoffset
 	  + fi->next->extra_info->framesize);
 
-  /* Determine whether or not we're in a sigtramp frame. 
+  /* Determine whether or not we're in a sigtramp frame.
      Unfortunately, it isn't sufficient to test
      fi->signal_handler_caller because this value is sometimes set
      after invoking INIT_EXTRA_FRAME_INFO.  So we test *both*
-     fi->signal_handler_caller and IN_SIGTRAMP to determine if we need
-     to use the sigcontext addresses for the saved registers.
+     fi->signal_handler_caller and PC_IN_SIGTRAMP to determine if we
+     need to use the sigcontext addresses for the saved registers.
 
-     Note: If an ARM IN_SIGTRAMP method ever needs to compare against
-     the name of the function, the code below will have to be changed
-     to first fetch the name of the function and then pass this name
-     to IN_SIGTRAMP.  */
+     Note: If an ARM PC_IN_SIGTRAMP method ever needs to compare
+     against the name of the function, the code below will have to be
+     changed to first fetch the name of the function and then pass
+     this name to PC_IN_SIGTRAMP.  */
 
   if (SIGCONTEXT_REGISTER_ADDRESS_P () 
-      && (fi->signal_handler_caller || IN_SIGTRAMP (fi->pc, (char *)0)))
+      && (fi->signal_handler_caller || PC_IN_SIGTRAMP (fi->pc, (char *)0)))
     {
       for (reg = 0; reg < NUM_REGS; reg++)
 	fi->saved_regs[reg] = SIGCONTEXT_REGISTER_ADDRESS (sp, fi->pc, reg);
 
-      /* FIXME: What about thumb mode? */
+      /* FIXME: What about thumb mode?  */
       fi->extra_info->framereg = ARM_SP_REGNUM;
       fi->frame =
 	read_memory_integer (fi->saved_regs[fi->extra_info->framereg],
@@ -1130,20 +1186,20 @@
       arm_scan_prologue (fi);
 
       if (!fi->next)
-	/* this is the innermost frame? */
+	/* This is the innermost frame?  */
 	fi->frame = read_register (fi->extra_info->framereg);
       else if (fi->extra_info->framereg == ARM_FP_REGNUM
 	       || fi->extra_info->framereg == THUMB_FP_REGNUM)
 	{
 	  /* not the innermost frame */
-	  /* If we have an FP, the callee saved it. */
+	  /* If we have an FP, the callee saved it.  */
 	  if (fi->next->saved_regs[fi->extra_info->framereg] != 0)
 	    fi->frame =
 	      read_memory_integer (fi->next
 				   ->saved_regs[fi->extra_info->framereg], 4);
 	  else if (fromleaf)
 	    /* If we were called by a frameless fn.  then our frame is
-	       still in the frame pointer register on the board... */
+	       still in the frame pointer register on the board...  */
 	    fi->frame = read_fp ();
 	}
 
@@ -1168,7 +1224,7 @@
 static CORE_ADDR
 arm_frame_saved_pc (struct frame_info *fi)
 {
-#if 0				/* FIXME: enable this code if we convert to new call dummy scheme.  */
+#if 0	/* FIXME: enable this code if we convert to new call dummy scheme.  */
   if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
     return generic_read_register_dummy (fi->pc, fi->frame, ARM_PC_REGNUM);
   else
@@ -1309,7 +1365,7 @@
   };
   static unsigned long arm_bx_r4 = 0xe12fff14;	/* bx r4 instruction */
 
-  /* Set flag indicating whether the current PC is in a Thumb function. */
+  /* Set flag indicating whether the current PC is in a Thumb function.  */
   caller_is_thumb = arm_pc_is_thumb (read_pc ());
   arm_set_call_dummy_breakpoint_offset ();
 
@@ -1342,7 +1398,7 @@
     }
 
   /* Put the target address in r4; the call dummy will copy this to
-     the PC. */
+     the PC.  */
   write_register (4, fun);
 }
 
@@ -1363,7 +1419,7 @@
      stack is required.  Need to take care here as structs may be
      passed on the stack, and we have to to push them.  */
   nstack_size = -4 * REGISTER_SIZE;	/* Some arguments go into A1-A4.  */
-  if (struct_return)		/* The struct address goes in A1.  */
+  if (struct_return)			/* The struct address goes in A1.  */
     nstack_size += REGISTER_SIZE;
 
   /* Walk through the arguments and add their size to nstack_size.  */
@@ -1415,7 +1471,7 @@
 #if 1
       /* I don't know why this code was disable. The only logical use
          for a function pointer is to call that function, so setting
-         the mode bit is perfectly fine. FN */
+         the mode bit is perfectly fine.  FN */
       /* If the argument is a pointer to a function, and it is a Thumb
          function, set the low bit of the pointer.  */
       if (TYPE_CODE_PTR == typecode
@@ -1456,10 +1512,10 @@
   return sp;
 }
 
-/* Pop the current frame.  So long as the frame info has been initialized
-   properly (see arm_init_extra_frame_info), this code works for dummy frames
-   as well as regular frames.  I.e, there's no need to have a special case
-   for dummy frames.  */
+/* Pop the current frame.  So long as the frame info has been
+   initialized properly (see arm_init_extra_frame_info), this code
+   works for dummy frames as well as regular frames.  I.e, there's no
+   need to have a special case for dummy frames.  */
 static void
 arm_pop_frame (void)
 {
@@ -1724,7 +1780,7 @@
 {
   unsigned long pc_val = ((unsigned long) pc) + 4;	/* PC after prefetch */
   unsigned short inst1 = read_memory_integer (pc, 2);
-  CORE_ADDR nextpc = pc + 2;	/* default is next instruction */
+  CORE_ADDR nextpc = pc + 2;		/* default is next instruction */
   unsigned long offset;
 
   if ((inst1 & 0xff00) == 0xbd00)	/* pop {rlist, pc} */
@@ -1744,7 +1800,7 @@
     {
       unsigned long status = read_register (ARM_PS_REGNUM);
       unsigned long cond = bits (inst1, 8, 11);
-      if (cond != 0x0f && condition_true (cond, status))	/* 0x0f = SWI */
+      if (cond != 0x0f && condition_true (cond, status))    /* 0x0f = SWI */
 	nextpc = pc_val + (sbits (inst1, 0, 7) << 1);
     }
   else if ((inst1 & 0xf800) == 0xe000)	/* unconditional branch */
@@ -1782,7 +1838,7 @@
       switch (bits (this_instr, 24, 27))
 	{
 	case 0x0:
-	case 0x1:		/* data processing */
+	case 0x1:			/* data processing */
 	case 0x2:
 	case 0x3:
 	  {
@@ -1988,13 +2044,13 @@
    single-step support.  We find the target of the coming instruction
    and breakpoint it.
 
-   single_step is also called just after the inferior stops.  If we had
-   set up a simulated single-step, we undo our damage.  */
+   single_step() is also called just after the inferior stops.  If we
+   had set up a simulated single-step, we undo our damage.  */
 
 static void
 arm_software_single_step (enum target_signal sig, int insert_bpt)
 {
-  static int next_pc; /* State between setting and unsetting. */
+  static int next_pc;		/* State between setting and unsetting.  */
   static char break_mem[BREAKPOINT_MAX]; /* Temporary storage for mem@bpt */
 
   if (insert_bpt)
@@ -2022,10 +2078,11 @@
 
       if (csym.native == NULL)
 	{
-	  /* Create a fake symbol vector containing a Thumb symbol.  This is
-	     solely so that the code in print_insn_little_arm() and
-	     print_insn_big_arm() in opcodes/arm-dis.c will detect the presence
-	     of a Thumb symbol and switch to decoding Thumb instructions.  */
+	  /* Create a fake symbol vector containing a Thumb symbol.
+	     This is solely so that the code in print_insn_little_arm() 
+	     and print_insn_big_arm() in opcodes/arm-dis.c will detect
+	     the presence of a Thumb symbol and switch to decoding
+	     Thumb instructions.  */
 
 	  fake_target.flavour = bfd_target_coff_flavour;
 	  fake_bfd.xvec = &fake_target;
@@ -2109,9 +2166,9 @@
 /* XXX ??? from old tm-arm.h: if we're using RDP, then we're inserting
    breakpoints and storing their handles instread of what was in
    memory.  It is nice that this is the same size as a handle -
-   otherwise remote-rdp will have to change. */
+   otherwise remote-rdp will have to change.  */
 
-unsigned char *
+static const unsigned char *
 arm_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
@@ -2307,7 +2364,7 @@
 }
 
 /* Store the address of the place in which to copy the structure the
-   subroutine will return.  This is called from call_function. */
+   subroutine will return.  This is called from call_function.  */
 
 static void
 arm_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
@@ -2341,7 +2398,8 @@
 
   /* Find the starting address of the function containing the PC.  If
      the caller didn't give us a name, look it up at the same time.  */
-  if (find_pc_partial_function (pc, name ? NULL : &name, &start_addr, NULL) == 0)
+  if (0 == find_pc_partial_function (pc, name ? NULL : &name, 
+				     &start_addr, NULL))
     return 0;
 
   return strncmp (name, "_call_via_r", 11) == 0;
@@ -2381,10 +2439,10 @@
   return 0;			/* not a stub */
 }
 
-/* If the user changes the register disassembly flavor used for info register
-   and other commands, we have to also switch the flavor used in opcodes
-   for disassembly output.
-   This function is run in the set disassembly_flavor command, and does that. */
+/* If the user changes the register disassembly flavor used for info
+   register and other commands, we have to also switch the flavor used
+   in opcodes for disassembly output.  This function is run in the set
+   disassembly_flavor command, and does that.  */
 
 static void
 set_disassembly_flavor_sfunc (char *args, int from_tty,
@@ -2406,7 +2464,7 @@
   const char *setname, *setdesc, **regnames;
   int numregs, j;
 
-  /* Find the flavor that the user wants in the opcodes table. */
+  /* Find the flavor that the user wants in the opcodes table.  */
   int current = 0;
   numregs = get_arm_regnames (current, &setname, &setdesc, &regnames);
   while ((disassembly_flavor != setname)
@@ -2414,11 +2472,11 @@
     get_arm_regnames (++current, &setname, &setdesc, &regnames);
   current_option = current;
 
-  /* Fill our copy. */
+  /* Fill our copy.  */
   for (j = 0; j < numregs; j++)
     arm_register_names[j] = (char *) regnames[j];
 
-  /* Adjust case. */
+  /* Adjust case.  */
   if (isupper (*regnames[ARM_PC_REGNUM]))
     {
       arm_register_names[ARM_FPS_REGNUM] = "FPS";
@@ -2430,23 +2488,23 @@
       arm_register_names[ARM_PS_REGNUM] = "cpsr";
     }
 
-  /* Synchronize the disassembler. */
+  /* Synchronize the disassembler.  */
   set_arm_regname_option (current);
 }
 
 /* arm_othernames implements the "othernames" command.  This is kind
    of hacky, and I prefer the set-show disassembly-flavor which is
    also used for the x86 gdb.  I will keep this around, however, in
-   case anyone is actually using it. */
+   case anyone is actually using it.  */
 
 static void
 arm_othernames (char *names, int n)
 {
-  /* Circle through the various flavors. */
+  /* Circle through the various flavors.  */
   current_option = (current_option + 1) % num_flavor_options;
 
   disassembly_flavor = valid_flavors[current_option];
-  set_disassembly_flavor (); 
+  set_disassembly_flavor ();
 }
 
 /* Fetch, and possibly build, an appropriate link_map_offsets structure
@@ -2455,7 +2513,7 @@
    Instead, the relevant structs offsets were obtained from examining
    link.h.  (We can't refer to link.h from this file because the host
    system won't necessarily have it, or if it does, the structs which
-   it defines will refer to the host system, not the target.)  */
+   it defines will refer to the host system, not the target).  */
 
 struct link_map_offsets *
 arm_linux_svr4_fetch_link_map_offsets (void)
@@ -2468,13 +2526,13 @@
       lmp = &lmo;
 
       lmo.r_debug_size = 8;	/* Actual size is 20, but this is all we
-                                   need. */
+                                   need.  */
 
       lmo.r_map_offset = 4;
       lmo.r_map_size   = 4;
 
       lmo.link_map_size = 20;	/* Actual size is 552, but this is all we
-                                   need. */
+                                   need.  */
 
       lmo.l_addr_offset = 0;
       lmo.l_addr_size   = 4;
@@ -2732,12 +2790,12 @@
   (*handler_p)->init_abi = init_abi;
 }
 
-/* Initialize the current architecture based on INFO.  If possible, re-use an
-   architecture from ARCHES, which is a list of architectures already created
-   during this debugging session.
+/* Initialize the current architecture based on INFO.  If possible,
+   re-use an architecture from ARCHES, which is a list of
+   architectures already created during this debugging session.
 
-   Called e.g. at program startup, when reading a core file, and when reading
-   a binary file.  */
+   Called e.g. at program startup, when reading a core file, and when
+   reading a binary file.  */
 
 static struct gdbarch *
 arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -2833,7 +2891,7 @@
 
   /* This should be low enough for everything.  */
   tdep->lowest_pc = 0x20;
-  tdep->jb_pc = -1; /* Longjump support not enabled by default.  */
+  tdep->jb_pc = -1;	/* Longjump support not enabled by default.  */
 
   set_gdbarch_use_generic_dummy_frames (gdbarch, 0);
 
@@ -2898,7 +2956,7 @@
 
   /* Information about registers, etc.  */
   set_gdbarch_print_float_info (gdbarch, arm_print_float_info);
-  set_gdbarch_fp_regnum (gdbarch, ARM_FP_REGNUM); /* ??? */
+  set_gdbarch_fp_regnum (gdbarch, ARM_FP_REGNUM);	/* ??? */
   set_gdbarch_sp_regnum (gdbarch, ARM_SP_REGNUM);
   set_gdbarch_pc_regnum (gdbarch, ARM_PC_REGNUM);
   set_gdbarch_register_byte (gdbarch, arm_register_byte);
@@ -3013,9 +3071,13 @@
   if (prologue_cache.saved_regs != NULL)
     xfree (prologue_cache.saved_regs);
 
+  /* We can't use NUM_REGS nor NUM_PSEUDO_REGS here, since that still
+     references the old architecture vector, not the one we are
+     building here.  */
   prologue_cache.saved_regs = (CORE_ADDR *)
     xcalloc (1, (sizeof (CORE_ADDR)
-		 * (gdbarch_num_regs (gdbarch) + NUM_PSEUDO_REGS)));
+		 * (gdbarch_num_regs (gdbarch)
+		    + gdbarch_num_pseudo_regs (gdbarch))));
 
   return gdbarch;
 }
@@ -3082,18 +3144,18 @@
 
   tm_print_insn = gdb_print_insn_arm;
 
-  /* Get the number of possible sets of register names defined in opcodes. */
+  /* Get the number of possible sets of register names defined in opcodes.  */
   num_flavor_options = get_arm_regname_num_options ();
 
-  /* Sync the opcode insn printer with our register viewer: */
+  /* Sync the opcode insn printer with our register viewer.  */
   parse_arm_disassembler_option ("reg-names-std");
 
-  /* Begin creating the help text. */
+  /* Begin creating the help text.  */
   stb = mem_fileopen ();
   fprintf_unfiltered (stb, "Set the disassembly flavor.\n\
 The valid values are:\n");
 
-  /* Initialize the array that will be passed to add_set_enum_cmd(). */
+  /* Initialize the array that will be passed to add_set_enum_cmd().  */
   valid_flavors = xmalloc ((num_flavor_options + 1) * sizeof (char *));
   for (i = 0; i < num_flavor_options; i++)
     {
@@ -3101,7 +3163,7 @@
       valid_flavors[i] = setname;
       fprintf_unfiltered (stb, "%s - %s\n", setname,
 			  setdesc);
-      /* Copy the default names (if found) and synchronize disassembler. */
+      /* Copy the default names (if found) and synchronize disassembler.  */
       if (!strcmp (setname, "std"))
 	{
           disassembly_flavor = setname;
@@ -3111,15 +3173,15 @@
           set_arm_regname_option (i);
 	}
     }
-  /* Mark the end of valid options. */
+  /* Mark the end of valid options.  */
   valid_flavors[num_flavor_options] = NULL;
 
-  /* Finish the creation of the help text. */
+  /* Finish the creation of the help text.  */
   fprintf_unfiltered (stb, "The default is \"std\".");
   helptext = ui_file_xstrdup (stb, &length);
   ui_file_delete (stb);
 
-  /* Add the disassembly-flavor command */
+  /* Add the disassembly-flavor command.  */
   new_cmd = add_set_enum_cmd ("disassembly-flavor", no_class,
 			      valid_flavors,
 			      &disassembly_flavor,
@@ -3134,7 +3196,7 @@
 				  "Set usage of ARM 32-bit mode.\n", &setlist),
 		     &showlist);
 
-  /* Add the deprecated "othernames" command */
+  /* Add the deprecated "othernames" command.  */
 
   add_com ("othernames", class_obscure, arm_othernames,
 	   "Switch to the next set of register names.");
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index a4c52dc..0fad4fd 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -25,25 +25,26 @@
    the user is concerned but do serve to get the desired values when
    passed to read_register.  */
 
-#define ARM_A1_REGNUM 0		/* first integer-like argument */
-#define ARM_A4_REGNUM 3		/* last integer-like argument */
-#define ARM_AP_REGNUM 11
-#define ARM_SP_REGNUM 13	/* Contains address of top of stack */
-#define ARM_LR_REGNUM 14	/* address to return to from a function call */
-#define ARM_PC_REGNUM 15	/* Contains program counter */
-#define ARM_F0_REGNUM 16	/* first floating point register */
-#define ARM_F3_REGNUM 19	/* last floating point argument register */
-#define ARM_F7_REGNUM 23	/* last floating point register */
-#define ARM_FPS_REGNUM 24	/* floating point status register */
-#define ARM_PS_REGNUM 25	/* Contains processor status */
+enum gdb_regnum {
+  ARM_A1_REGNUM = 0,		/* first integer-like argument */
+  ARM_A4_REGNUM = 3,		/* last integer-like argument */
+  ARM_AP_REGNUM = 11,
+  ARM_SP_REGNUM = 13,		/* Contains address of top of stack */
+  ARM_LR_REGNUM = 14,		/* address to return to from a function call */
+  ARM_PC_REGNUM = 15,		/* Contains program counter */
+  ARM_F0_REGNUM = 16,		/* first floating point register */
+  ARM_F3_REGNUM = 19,		/* last floating point argument register */
+  ARM_F7_REGNUM = 23, 		/* last floating point register */
+  ARM_FPS_REGNUM = 24,		/* floating point status register */
+  ARM_PS_REGNUM = 25,		/* Contains processor status */
+  ARM_FP_REGNUM = 11,		/* Frame register in ARM code, if used.  */
+  THUMB_FP_REGNUM = 7,		/* Frame register in Thumb code, if used.  */
+  ARM_NUM_ARG_REGS = 4, 
+  ARM_LAST_ARG_REGNUM = ARM_A4_REGNUM,
+  ARM_NUM_FP_ARG_REGS = 4,
+  ARM_LAST_FP_ARG_REGNUM = ARM_F3_REGNUM
+};
 
-#define ARM_FP_REGNUM 11	/* Frame register in ARM code, if used.  */
-#define THUMB_FP_REGNUM 7	/* Frame register in Thumb code, if used.  */
-
-#define ARM_NUM_ARG_REGS 	4
-#define ARM_LAST_ARG_REGNUM 	ARM_A4_REGNUM
-#define ARM_NUM_FP_ARG_REGS 	4
-#define ARM_LAST_FP_ARG_REGNUM	ARM_F3_REGNUM
 
 /* Size of integer registers.  */
 #define INT_REGISTER_RAW_SIZE		4
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
new file mode 100644
index 0000000..71c7796
--- /dev/null
+++ b/gdb/avr-tdep.c
@@ -0,0 +1,1374 @@
+/* Target-dependent code for Atmel AVR, for GDB.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+   Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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.  */
+
+/* Contributed by Theodore A. Roth, troth@verinet.com */
+
+/* Portions of this file were taken from the original gdb-4.18 patch developed
+   by Denis Chertykov, denisc@overta.ru */
+
+#include "defs.h"
+#include "gdbcmd.h"
+#include "gdbcore.h"
+#include "inferior.h"
+#include "symfile.h"
+#include "arch-utils.h"
+#include "regcache.h"
+
+/* AVR Background:
+
+   (AVR micros are pure Harvard Architecture processors.)
+
+   The AVR family of microcontrollers have three distinctly different memory
+   spaces: flash, sram and eeprom. The flash is 16 bits wide and is used for
+   the most part to store program instructions. The sram is 8 bits wide and is
+   used for the stack and the heap. Some devices lack sram and some can have
+   an additional external sram added on as a peripheral.
+
+   The eeprom is 8 bits wide and is used to store data when the device is
+   powered down. Eeprom is not directly accessible, it can only be accessed
+   via io-registers using a special algorithm. Accessing eeprom via gdb's
+   remote serial protocol ('m' or 'M' packets) looks difficult to do and is
+   not included at this time.
+
+   [The eeprom could be read manually via ``x/b <eaddr + AVR_EMEM_START>'' or
+   written using ``set {unsigned char}<eaddr + AVR_EMEM_START>''.  For this to
+   work, the remote target must be able to handle eeprom accesses and perform
+   the address translation.]
+
+   All three memory spaces have physical addresses beginning at 0x0. In
+   addition, the flash is addressed by gcc/binutils/gdb with respect to 8 bit
+   bytes instead of the 16 bit wide words used by the real device for the
+   Program Counter.
+
+   In order for remote targets to work correctly, extra bits must be added to
+   addresses before they are send to the target or received from the target
+   via the remote serial protocol. The extra bits are the MSBs and are used to
+   decode which memory space the address is referring to. */
+
+#undef XMALLOC
+#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
+
+#undef EXTRACT_INSN
+#define EXTRACT_INSN(addr) extract_unsigned_integer(addr,2)
+
+/* Constants: prefixed with AVR_ to avoid name space clashes */
+
+enum
+{
+  AVR_REG_W = 24,
+  AVR_REG_X = 26,
+  AVR_REG_Y = 28,
+  AVR_FP_REGNUM = 28,
+  AVR_REG_Z = 30,
+
+  AVR_SREG_REGNUM = 32,
+  AVR_SP_REGNUM = 33,
+  AVR_PC_REGNUM = 34,
+
+  AVR_NUM_REGS = 32 + 1 /*SREG*/ + 1 /*SP*/ + 1 /*PC*/,
+  AVR_NUM_REG_BYTES = 32 + 1 /*SREG*/ + 2 /*SP*/ + 4 /*PC*/,
+
+  AVR_PC_REG_INDEX = 35,	/* index into array of registers */
+
+  AVR_MAX_PROLOGUE_SIZE = 56,	/* bytes */
+
+  /* Count of pushed registers. From r2 to r17 (inclusively), r28, r29 */
+  AVR_MAX_PUSHES = 18,
+
+  /* Number of the last pushed register. r17 for current avr-gcc */
+  AVR_LAST_PUSHED_REGNUM = 17,
+
+  /* FIXME: TRoth/2002-01-??: Can we shift all these memory masks left 8
+     bits? Do these have to match the bfd vma values?. It sure would make
+     things easier in the future if they didn't need to match.
+
+     Note: I chose these values so as to be consistent with bfd vma
+     addresses.
+
+     TRoth/2002-04-08: There is already a conflict with very large programs
+     in the mega128. The mega128 has 128K instruction bytes (64K words),
+     thus the Most Significant Bit is 0x10000 which gets masked off my
+     AVR_MEM_MASK.
+
+     The problem manifests itself when trying to set a breakpoint in a
+     function which resides in the upper half of the instruction space and
+     thus requires a 17-bit address.
+
+     For now, I've just removed the EEPROM mask and changed AVR_MEM_MASK
+     from 0x00ff0000 to 0x00f00000. Eeprom is not accessible from gdb yet,
+     but could be for some remote targets by just adding the correct offset
+     to the address and letting the remote target handle the low-level
+     details of actually accessing the eeprom. */
+
+  AVR_IMEM_START = 0x00000000,	/* INSN memory */
+  AVR_SMEM_START = 0x00800000,	/* SRAM memory */
+#if 1
+  /* No eeprom mask defined */
+  AVR_MEM_MASK = 0x00f00000,	/* mask to determine memory space */
+#else
+  AVR_EMEM_START = 0x00810000,	/* EEPROM memory */
+  AVR_MEM_MASK = 0x00ff0000,	/* mask to determine memory space */
+#endif
+};
+
+/* Any function with a frame looks like this
+   .......    <-SP POINTS HERE
+   LOCALS1    <-FP POINTS HERE
+   LOCALS0
+   SAVED FP
+   SAVED R3
+   SAVED R2
+   RET PC
+   FIRST ARG
+   SECOND ARG */
+
+struct frame_extra_info
+{
+  CORE_ADDR return_pc;
+  CORE_ADDR args_pointer;
+  int locals_size;
+  int framereg;
+  int framesize;
+  int is_main;
+};
+
+struct gdbarch_tdep
+{
+  /* FIXME: TRoth: is there anything to put here? */
+  int foo;
+};
+
+/* Lookup the name of a register given it's number. */
+
+static char *
+avr_register_name (int regnum)
+{
+  static char *register_names[] = {
+    "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+    "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+    "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
+    "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
+    "SREG", "SP", "PC"
+  };
+  if (regnum < 0)
+    return NULL;
+  if (regnum >= (sizeof (register_names) / sizeof (*register_names)))
+    return NULL;
+  return register_names[regnum];
+}
+
+/* Index within `registers' of the first byte of the space for
+   register REGNUM.  */
+
+static int
+avr_register_byte (int regnum)
+{
+  if (regnum < AVR_PC_REGNUM)
+    return regnum;
+  else
+    return AVR_PC_REG_INDEX;
+}
+
+/* Number of bytes of storage in the actual machine representation for
+   register REGNUM.  */
+
+static int
+avr_register_raw_size (int regnum)
+{
+  switch (regnum)
+    {
+    case AVR_PC_REGNUM:
+      return 4;
+    case AVR_SP_REGNUM:
+    case AVR_FP_REGNUM:
+      return 2;
+    default:
+      return 1;
+    }
+}
+
+/* Number of bytes of storage in the program's representation
+   for register N.  */
+
+static int
+avr_register_virtual_size (int regnum)
+{
+  return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (regnum));
+}
+
+/* Return the GDB type object for the "standard" data type
+   of data in register N.  */
+
+static struct type *
+avr_register_virtual_type (int regnum)
+{
+  switch (regnum)
+    {
+    case AVR_PC_REGNUM:
+      return builtin_type_unsigned_long;
+    case AVR_SP_REGNUM:
+      return builtin_type_unsigned_short;
+    default:
+      return builtin_type_unsigned_char;
+    }
+}
+
+/* Instruction address checks and convertions. */
+
+static CORE_ADDR
+avr_make_iaddr (CORE_ADDR x)
+{
+  return ((x) | AVR_IMEM_START);
+}
+
+static int
+avr_iaddr_p (CORE_ADDR x)
+{
+  return (((x) & AVR_MEM_MASK) == AVR_IMEM_START);
+}
+
+/* FIXME: TRoth: Really need to use a larger mask for instructions. Some
+   devices are already up to 128KBytes of flash space.
+
+   TRoth/2002-04-8: See comment above where AVR_IMEM_START is defined. */
+
+static CORE_ADDR
+avr_convert_iaddr_to_raw (CORE_ADDR x)
+{
+  return ((x) & 0xffffffff);
+}
+
+/* SRAM address checks and convertions. */
+
+static CORE_ADDR
+avr_make_saddr (CORE_ADDR x)
+{
+  return ((x) | AVR_SMEM_START);
+}
+
+static int
+avr_saddr_p (CORE_ADDR x)
+{
+  return (((x) & AVR_MEM_MASK) == AVR_SMEM_START);
+}
+
+static CORE_ADDR
+avr_convert_saddr_to_raw (CORE_ADDR x)
+{
+  return ((x) & 0xffffffff);
+}
+
+/* EEPROM address checks and convertions. I don't know if these will ever
+   actually be used, but I've added them just the same. TRoth */
+
+/* TRoth/2002-04-08: Commented out for now to allow fix for problem with large
+   programs in the mega128. */
+
+/*  static CORE_ADDR */
+/*  avr_make_eaddr (CORE_ADDR x) */
+/*  { */
+/*    return ((x) | AVR_EMEM_START); */
+/*  } */
+
+/*  static int */
+/*  avr_eaddr_p (CORE_ADDR x) */
+/*  { */
+/*    return (((x) & AVR_MEM_MASK) == AVR_EMEM_START); */
+/*  } */
+
+/*  static CORE_ADDR */
+/*  avr_convert_eaddr_to_raw (CORE_ADDR x) */
+/*  { */
+/*    return ((x) & 0xffffffff); */
+/*  } */
+
+/* Convert from address to pointer and vice-versa. */
+
+static void
+avr_address_to_pointer (struct type *type, void *buf, CORE_ADDR addr)
+{
+  /* Is it a code address?  */
+  if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
+      || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD)
+    {
+      store_unsigned_integer (buf, TYPE_LENGTH (type),
+			      avr_convert_iaddr_to_raw (addr));
+    }
+  else
+    {
+      /* Strip off any upper segment bits.  */
+      store_unsigned_integer (buf, TYPE_LENGTH (type),
+			      avr_convert_saddr_to_raw (addr));
+    }
+}
+
+static CORE_ADDR
+avr_pointer_to_address (struct type *type, void *buf)
+{
+  CORE_ADDR addr = extract_address (buf, TYPE_LENGTH (type));
+
+  if (TYPE_CODE_SPACE (TYPE_TARGET_TYPE (type)))
+    {
+      fprintf_unfiltered (gdb_stderr, "CODE_SPACE ---->> ptr->addr: 0x%lx\n",
+			  addr);
+      fprintf_unfiltered (gdb_stderr,
+			  "+++ If you see this, please send me an email <troth@verinet.com>\n");
+    }
+
+  /* Is it a code address?  */
+  if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
+      || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD
+      || TYPE_CODE_SPACE (TYPE_TARGET_TYPE (type)))
+    return avr_make_iaddr (addr);
+  else
+    return avr_make_saddr (addr);
+}
+
+static CORE_ADDR
+avr_read_pc (ptid_t ptid)
+{
+  ptid_t save_ptid;
+  CORE_ADDR pc;
+  CORE_ADDR retval;
+
+  save_ptid = inferior_ptid;
+  inferior_ptid = ptid;
+  pc = (int) read_register (AVR_PC_REGNUM);
+  inferior_ptid = save_ptid;
+  retval = avr_make_iaddr (pc);
+  return retval;
+}
+
+static void
+avr_write_pc (CORE_ADDR val, ptid_t ptid)
+{
+  ptid_t save_ptid;
+
+  save_ptid = inferior_ptid;
+  inferior_ptid = ptid;
+  write_register (AVR_PC_REGNUM, avr_convert_iaddr_to_raw (val));
+  inferior_ptid = save_ptid;
+}
+
+static CORE_ADDR
+avr_read_sp (void)
+{
+  return (avr_make_saddr (read_register (AVR_SP_REGNUM)));
+}
+
+static void
+avr_write_sp (CORE_ADDR val)
+{
+  write_register (AVR_SP_REGNUM, avr_convert_saddr_to_raw (val));
+}
+
+static CORE_ADDR
+avr_read_fp (void)
+{
+  return (avr_make_saddr (read_register (AVR_FP_REGNUM)));
+}
+
+/* Translate a GDB virtual ADDR/LEN into a format the remote target
+   understands.  Returns number of bytes that can be transfered
+   starting at TARG_ADDR.  Return ZERO if no bytes can be transfered
+   (segmentation fault).
+
+   TRoth/2002-04-08: Could this be used to check for dereferencing an invalid
+   pointer? */
+
+static void
+avr_remote_translate_xfer_address (CORE_ADDR memaddr, int nr_bytes,
+				   CORE_ADDR *targ_addr, int *targ_len)
+{
+  long out_addr;
+  long out_len;
+
+  /* FIXME: TRoth: Do nothing for now. Will need to examine memaddr at this
+     point and see if the high bit are set with the masks that we want. */
+
+  *targ_addr = memaddr;
+  *targ_len = nr_bytes;
+}
+
+/* Function pointers obtained from the target are half of what gdb expects so
+   multiply by 2. */
+
+static CORE_ADDR
+avr_convert_from_func_ptr_addr (CORE_ADDR addr)
+{
+  return addr * 2;
+}
+
+/* avr_scan_prologue is also used as the frame_init_saved_regs().
+
+   Put here the code to store, into fi->saved_regs, the addresses of
+   the saved registers of frame described by FRAME_INFO.  This
+   includes special registers such as pc and fp saved in special ways
+   in the stack frame.  sp is even more special: the address we return
+   for it IS the sp for the next frame. */
+
+/* Function: avr_scan_prologue (helper function for avr_init_extra_frame_info)
+   This function decodes a AVR function prologue to determine:
+     1) the size of the stack frame
+     2) which registers are saved on it
+     3) the offsets of saved regs
+   This information is stored in the "extra_info" field of the frame_info.
+
+   A typical AVR function prologue might look like this:
+        push rXX
+        push r28
+        push r29
+        in r28,__SP_L__
+        in r29,__SP_H__
+        sbiw r28,<LOCALS_SIZE>
+        in __tmp_reg__,__SREG__
+        cli
+        out __SP_L__,r28
+        out __SREG__,__tmp_reg__
+        out __SP_H__,r29
+
+  A `-mcall-prologues' prologue look like this:
+        ldi r26,<LOCALS_SIZE>
+        ldi r27,<LOCALS_SIZE>/265
+        ldi r30,pm_lo8(.L_foo_body)
+        ldi r31,pm_hi8(.L_foo_body)
+        rjmp __prologue_saves__+RRR
+  .L_foo_body:  */
+
+static void
+avr_scan_prologue (struct frame_info *fi)
+{
+  CORE_ADDR prologue_start;
+  CORE_ADDR prologue_end;
+  int i;
+  unsigned short insn;
+  int regno;
+  int scan_stage = 0;
+  char *name;
+  struct minimal_symbol *msymbol;
+  int prologue_len;
+  unsigned char prologue[AVR_MAX_PROLOGUE_SIZE];
+  int vpc = 0;
+
+  fi->extra_info->framereg = AVR_SP_REGNUM;
+
+  if (find_pc_partial_function
+      (fi->pc, &name, &prologue_start, &prologue_end))
+    {
+      struct symtab_and_line sal = find_pc_line (prologue_start, 0);
+
+      if (sal.line == 0)	/* no line info, use current PC */
+	prologue_end = fi->pc;
+      else if (sal.end < prologue_end)	/* next line begins after fn end */
+	prologue_end = sal.end;	/* (probably means no prologue)  */
+    }
+  else
+    /* We're in the boondocks: allow for */
+    /* 19 pushes, an add, and "mv fp,sp" */
+    prologue_end = prologue_start + AVR_MAX_PROLOGUE_SIZE;
+
+  prologue_end = min (prologue_end, fi->pc);
+
+  /* Search the prologue looking for instructions that set up the
+     frame pointer, adjust the stack pointer, and save registers.  */
+
+  fi->extra_info->framesize = 0;
+  prologue_len = prologue_end - prologue_start;
+  read_memory (prologue_start, prologue, prologue_len);
+
+  /* Scanning main()'s prologue
+     ldi r28,lo8(<RAM_ADDR> - <LOCALS_SIZE>)
+     ldi r29,hi8(<RAM_ADDR> - <LOCALS_SIZE>)
+     out __SP_H__,r29
+     out __SP_L__,r28 */
+
+  if (name && strcmp ("main", name) == 0 && prologue_len == 8)
+    {
+      CORE_ADDR locals;
+      unsigned char img[] = {
+	0xde, 0xbf,		/* out __SP_H__,r29 */
+	0xcd, 0xbf		/* out __SP_L__,r28 */
+      };
+
+      fi->extra_info->framereg = AVR_FP_REGNUM;
+      insn = EXTRACT_INSN (&prologue[vpc]);
+      /* ldi r28,lo8(<RAM_ADDR> - <LOCALS_SIZE>) */
+      if ((insn & 0xf0f0) == 0xe0c0)
+	{
+	  locals = (insn & 0xf) | ((insn & 0x0f00) >> 4);
+	  insn = EXTRACT_INSN (&prologue[vpc + 2]);
+	  /* ldi r29,hi8(<RAM_ADDR> - <LOCALS_SIZE>) */
+	  if ((insn & 0xf0f0) == 0xe0d0)
+	    {
+	      locals |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
+	      if (memcmp (prologue + vpc + 4, img, sizeof (img)) == 0)
+		{
+		  fi->frame = locals;
+
+		  /* TRoth: Does -1 mean we're in main? */
+		  fi->extra_info->is_main = 1;
+		  return;
+		}
+	    }
+	}
+    }
+
+  /* Scanning `-mcall-prologues' prologue
+     FIXME: mega prologue have a 12 bytes long */
+
+  while (prologue_len <= 12)	/* I'm use while to avoit many goto's */
+    {
+      int loc_size;
+      int body_addr;
+      unsigned num_pushes;
+
+      insn = EXTRACT_INSN (&prologue[vpc]);
+      /* ldi r26,<LOCALS_SIZE> */
+      if ((insn & 0xf0f0) != 0xe0a0)
+	break;
+      loc_size = (insn & 0xf) | ((insn & 0x0f00) >> 4);
+
+      insn = EXTRACT_INSN (&prologue[vpc + 2]);
+      /* ldi r27,<LOCALS_SIZE> / 256 */
+      if ((insn & 0xf0f0) != 0xe0b0)
+	break;
+      loc_size |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
+
+      insn = EXTRACT_INSN (&prologue[vpc + 4]);
+      /* ldi r30,pm_lo8(.L_foo_body) */
+      if ((insn & 0xf0f0) != 0xe0e0)
+	break;
+      body_addr = (insn & 0xf) | ((insn & 0x0f00) >> 4);
+
+      insn = EXTRACT_INSN (&prologue[vpc + 6]);
+      /* ldi r31,pm_hi8(.L_foo_body) */
+      if ((insn & 0xf0f0) != 0xe0f0)
+	break;
+      body_addr |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
+
+      if (body_addr != (prologue_start + 10) / 2)
+	break;
+
+      msymbol = lookup_minimal_symbol ("__prologue_saves__", NULL, NULL);
+      if (!msymbol)
+	break;
+
+      /* FIXME: prologue for mega have a JMP instead of RJMP */
+      insn = EXTRACT_INSN (&prologue[vpc + 8]);
+      /* rjmp __prologue_saves__+RRR */
+      if ((insn & 0xf000) != 0xc000)
+	break;
+
+      /* Extract PC relative offset from RJMP */
+      i = (insn & 0xfff) | (insn & 0x800 ? (-1 ^ 0xfff) : 0);
+      /* Convert offset to byte addressable mode */
+      i *= 2;
+      /* Destination address */
+      i += vpc + prologue_start + 10;
+      /* Resovle offset (in words) from __prologue_saves__ symbol.
+         Which is a pushes count in `-mcall-prologues' mode */
+      num_pushes = AVR_MAX_PUSHES - (i - SYMBOL_VALUE_ADDRESS (msymbol)) / 2;
+
+      if (num_pushes > AVR_MAX_PUSHES)
+	num_pushes = 0;
+
+      if (num_pushes)
+	{
+	  int from;
+	  fi->saved_regs[AVR_FP_REGNUM + 1] = num_pushes;
+	  if (num_pushes >= 2)
+	    fi->saved_regs[AVR_FP_REGNUM] = num_pushes - 1;
+	  i = 0;
+	  for (from = AVR_LAST_PUSHED_REGNUM + 1 - (num_pushes - 2);
+	       from <= AVR_LAST_PUSHED_REGNUM; ++from)
+	    fi->saved_regs[from] = ++i;
+	}
+      fi->extra_info->locals_size = loc_size;
+      fi->extra_info->framesize = loc_size + num_pushes;
+      fi->extra_info->framereg = AVR_FP_REGNUM;
+      return;
+    }
+
+  /* Scan interrupt or signal function */
+
+  if (prologue_len >= 12)
+    {
+      unsigned char img[] = {
+	0x78, 0x94,		/* sei */
+	0x1f, 0x92,		/* push r1 */
+	0x0f, 0x92,		/* push r0 */
+	0x0f, 0xb6,		/* in r0,0x3f SREG */
+	0x0f, 0x92,		/* push r0 */
+	0x11, 0x24		/* clr r1 */
+      };
+      if (memcmp (prologue, img, sizeof (img)) == 0)
+	{
+	  vpc += sizeof (img);
+	  fi->saved_regs[0] = 2;
+	  fi->saved_regs[1] = 1;
+	  fi->extra_info->framesize += 3;
+	}
+      else if (memcmp (img + 1, prologue, sizeof (img) - 1) == 0)
+	{
+	  vpc += sizeof (img) - 1;
+	  fi->saved_regs[0] = 2;
+	  fi->saved_regs[1] = 1;
+	  fi->extra_info->framesize += 3;
+	}
+    }
+
+  /* First stage of the prologue scanning.
+     Scan pushes */
+
+  for (; vpc <= prologue_len; vpc += 2)
+    {
+      insn = EXTRACT_INSN (&prologue[vpc]);
+      if ((insn & 0xfe0f) == 0x920f)	/* push rXX */
+	{
+	  /* Bits 4-9 contain a mask for registers R0-R32. */
+	  regno = (insn & 0x1f0) >> 4;
+	  ++fi->extra_info->framesize;
+	  fi->saved_regs[regno] = fi->extra_info->framesize;
+	  scan_stage = 1;
+	}
+      else
+	break;
+    }
+
+  /* Second stage of the prologue scanning.
+     Scan:
+     in r28,__SP_L__
+     in r29,__SP_H__ */
+
+  if (scan_stage == 1 && vpc + 4 <= prologue_len)
+    {
+      unsigned char img[] = {
+	0xcd, 0xb7,		/* in r28,__SP_L__ */
+	0xde, 0xb7		/* in r29,__SP_H__ */
+      };
+      unsigned short insn1;
+
+      if (memcmp (prologue + vpc, img, sizeof (img)) == 0)
+	{
+	  vpc += 4;
+	  fi->extra_info->framereg = AVR_FP_REGNUM;
+	  scan_stage = 2;
+	}
+    }
+
+  /* Third stage of the prologue scanning. (Really two stages)
+     Scan for:
+     sbiw r28,XX or subi r28,lo8(XX)
+     sbci r29,hi8(XX)
+     in __tmp_reg__,__SREG__
+     cli
+     out __SP_L__,r28
+     out __SREG__,__tmp_reg__
+     out __SP_H__,r29 */
+
+  if (scan_stage == 2 && vpc + 12 <= prologue_len)
+    {
+      int locals_size = 0;
+      unsigned char img[] = {
+	0x0f, 0xb6,		/* in r0,0x3f */
+	0xf8, 0x94,		/* cli */
+	0xcd, 0xbf,		/* out 0x3d,r28 ; SPL */
+	0x0f, 0xbe,		/* out 0x3f,r0  ; SREG */
+	0xde, 0xbf		/* out 0x3e,r29 ; SPH */
+      };
+      unsigned char img_sig[] = {
+	0xcd, 0xbf,		/* out 0x3d,r28 ; SPL */
+	0xde, 0xbf		/* out 0x3e,r29 ; SPH */
+      };
+      unsigned char img_int[] = {
+	0xf8, 0x94,		/* cli */
+	0xcd, 0xbf,		/* out 0x3d,r28 ; SPL */
+	0x78, 0x94,		/* sei */
+	0xde, 0xbf		/* out 0x3e,r29 ; SPH */
+      };
+
+      insn = EXTRACT_INSN (&prologue[vpc]);
+      vpc += 2;
+      if ((insn & 0xff30) == 0x9720)	/* sbiw r28,XXX */
+	locals_size = (insn & 0xf) | ((insn & 0xc0) >> 2);
+      else if ((insn & 0xf0f0) == 0x50c0)	/* subi r28,lo8(XX) */
+	{
+	  locals_size = (insn & 0xf) | ((insn & 0xf00) >> 4);
+	  insn = EXTRACT_INSN (&prologue[vpc]);
+	  vpc += 2;
+	  locals_size += ((insn & 0xf) | ((insn & 0xf00) >> 4) << 8);
+	}
+      else
+	return;
+      fi->extra_info->locals_size = locals_size;
+      fi->extra_info->framesize += locals_size;
+    }
+}
+
+/* This function actually figures out the frame address for a given pc and
+   sp.  This is tricky  because we sometimes don't use an explicit
+   frame pointer, and the previous stack pointer isn't necessarily recorded
+   on the stack.  The only reliable way to get this info is to
+   examine the prologue.  */
+
+static void
+avr_init_extra_frame_info (int fromleaf, struct frame_info *fi)
+{
+  int reg;
+
+  if (fi->next)
+    fi->pc = FRAME_SAVED_PC (fi->next);
+
+  fi->extra_info = (struct frame_extra_info *)
+    frame_obstack_alloc (sizeof (struct frame_extra_info));
+  frame_saved_regs_zalloc (fi);
+
+  fi->extra_info->return_pc = 0;
+  fi->extra_info->args_pointer = 0;
+  fi->extra_info->locals_size = 0;
+  fi->extra_info->framereg = 0;
+  fi->extra_info->framesize = 0;
+  fi->extra_info->is_main = 0;
+
+  avr_scan_prologue (fi);
+
+  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+    {
+      /* We need to setup fi->frame here because run_stack_dummy gets it wrong
+         by assuming it's always FP.  */
+      fi->frame = generic_read_register_dummy (fi->pc, fi->frame, fi->frame);
+    }
+  else if (!fi->next)		/* this is the innermost frame? */
+    fi->frame = read_register (fi->extra_info->framereg);
+  else if (fi->extra_info->is_main != 1)	/* not the innermost frame, not `main' */
+    /* If we have an next frame,  the callee saved it. */
+    {
+      struct frame_info *next_fi = fi->next;
+      if (fi->extra_info->framereg == AVR_SP_REGNUM)
+	fi->frame =
+	  next_fi->frame + 2 /* ret addr */  + next_fi->extra_info->framesize;
+      /* FIXME: I don't analyse va_args functions  */
+      else
+	{
+	  CORE_ADDR fp = 0;
+	  CORE_ADDR fp1 = 0;
+	  unsigned int fp_low, fp_high;
+
+	  /* Scan all frames */
+	  for (; next_fi; next_fi = next_fi->next)
+	    {
+	      /* look for saved AVR_FP_REGNUM */
+	      if (next_fi->saved_regs[AVR_FP_REGNUM] && !fp)
+		fp = next_fi->saved_regs[AVR_FP_REGNUM];
+	      /* look for saved AVR_FP_REGNUM + 1 */
+	      if (next_fi->saved_regs[AVR_FP_REGNUM + 1] && !fp1)
+		fp1 = next_fi->saved_regs[AVR_FP_REGNUM + 1];
+	    }
+	  fp_low = (fp ? read_memory_unsigned_integer (avr_make_saddr (fp), 1)
+		    : read_register (AVR_FP_REGNUM)) & 0xff;
+	  fp_high =
+	    (fp1 ? read_memory_unsigned_integer (avr_make_saddr (fp1), 1) :
+	     read_register (AVR_FP_REGNUM + 1)) & 0xff;
+	  fi->frame = fp_low | (fp_high << 8);
+	}
+    }
+
+  /* TRoth: Do we want to do this if we are in main? I don't think we should
+     since return_pc makes no sense when we are in main. */
+
+  if ((fi->pc) && (fi->extra_info->is_main == 0))	/* We are not in CALL_DUMMY */
+    {
+      CORE_ADDR addr;
+      int i;
+
+      addr = fi->frame + fi->extra_info->framesize + 1;
+
+      /* Return address in stack in different endianness */
+
+      fi->extra_info->return_pc =
+	read_memory_unsigned_integer (avr_make_saddr (addr), 1) << 8;
+      fi->extra_info->return_pc |=
+	read_memory_unsigned_integer (avr_make_saddr (addr + 1), 1);
+
+      /* This return address in words,
+         must be converted to the bytes address */
+      fi->extra_info->return_pc *= 2;
+
+      /* Resolve a pushed registers addresses */
+      for (i = 0; i < NUM_REGS; i++)
+	{
+	  if (fi->saved_regs[i])
+	    fi->saved_regs[i] = addr - fi->saved_regs[i];
+	}
+    }
+}
+
+/* Restore the machine to the state it had before the current frame was
+   created.  Usually used either by the "RETURN" command, or by
+   call_function_by_hand after the dummy_frame is finished. */
+
+static void
+avr_pop_frame (void)
+{
+  unsigned regnum;
+  CORE_ADDR saddr;
+  struct frame_info *frame = get_current_frame ();
+
+  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+    {
+      generic_pop_dummy_frame ();
+    }
+  else
+    {
+      /* TRoth: Why only loop over 8 registers? */
+
+      for (regnum = 0; regnum < 8; regnum++)
+	{
+	  /* Don't forget AVR_SP_REGNUM in a frame_saved_regs struct is the
+	     actual value we want, not the address of the value we want.  */
+	  if (frame->saved_regs[regnum] && regnum != AVR_SP_REGNUM)
+	    {
+	      saddr = avr_make_saddr (frame->saved_regs[regnum]);
+	      write_register (regnum,
+			      read_memory_unsigned_integer (saddr, 1));
+	    }
+	  else if (frame->saved_regs[regnum] && regnum == AVR_SP_REGNUM)
+	    write_register (regnum, frame->frame + 2);
+	}
+
+      /* Don't forget the update the PC too!  */
+      write_pc (frame->extra_info->return_pc);
+    }
+  flush_cached_frames ();
+}
+
+/* Return the saved PC from this frame. */
+
+static CORE_ADDR
+avr_frame_saved_pc (struct frame_info *frame)
+{
+  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+    return generic_read_register_dummy (frame->pc, frame->frame,
+					AVR_PC_REGNUM);
+  else
+    return frame->extra_info->return_pc;
+}
+
+static CORE_ADDR
+avr_saved_pc_after_call (struct frame_info *frame)
+{
+  unsigned char m1, m2;
+  unsigned int sp = read_register (AVR_SP_REGNUM);
+  m1 = read_memory_unsigned_integer (avr_make_saddr (sp + 1), 1);
+  m2 = read_memory_unsigned_integer (avr_make_saddr (sp + 2), 1);
+  return (m2 | (m1 << 8)) * 2;
+}
+
+/* Figure out where in REGBUF the called function has left its return value.
+   Copy that into VALBUF. */
+
+static void
+avr_extract_return_value (struct type *type, char *regbuf, char *valbuf)
+{
+  int wordsize, len;
+
+  wordsize = 2;
+
+  len = TYPE_LENGTH (type);
+
+  switch (len)
+    {
+    case 1:			/* (char) */
+    case 2:			/* (short), (int) */
+      memcpy (valbuf, regbuf + REGISTER_BYTE (24), 2);
+      break;
+    case 4:			/* (long), (float) */
+      memcpy (valbuf, regbuf + REGISTER_BYTE (22), 4);
+      break;
+    case 8:			/* (double) (doesn't seem to happen, which is good,
+				   because this almost certainly isn't right.  */
+      error ("I don't know how a double is returned.");
+      break;
+    }
+}
+
+/* Returns the return address for a dummy. */
+
+static CORE_ADDR
+avr_call_dummy_address (void)
+{
+  return entry_point_address ();
+}
+
+/* Place the appropriate value in the appropriate registers.
+   Primarily used by the RETURN command.  */
+
+static void
+avr_store_return_value (struct type *type, char *valbuf)
+{
+  int wordsize, len, regval;
+
+  wordsize = 2;
+
+  len = TYPE_LENGTH (type);
+  switch (len)
+    {
+    case 1:			/* char */
+    case 2:			/* short, int */
+      regval = extract_address (valbuf, len);
+      write_register (0, regval);
+      break;
+    case 4:			/* long, float */
+      regval = extract_address (valbuf, len);
+      write_register (0, regval >> 16);
+      write_register (1, regval & 0xffff);
+      break;
+    case 8:			/* presumeably double, but doesn't seem to happen */
+      error ("I don't know how to return a double.");
+      break;
+    }
+}
+
+/* Setup the return address for a dummy frame, as called by
+   call_function_by_hand.  Only necessary when you are using an empty
+   CALL_DUMMY. */
+
+static CORE_ADDR
+avr_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
+{
+  unsigned char buf[2];
+  int wordsize = 2;
+  struct minimal_symbol *msymbol;
+  CORE_ADDR mon_brk;
+
+  fprintf_unfiltered (gdb_stderr, "avr_push_return_address() was called\n");
+
+  buf[0] = 0;
+  buf[1] = 0;
+  sp -= wordsize;
+  write_memory (sp + 1, buf, 2);
+
+#if 0
+  /* FIXME: TRoth/2002-02-18: This should probably be removed since it's a
+     left-over from Denis' original patch which used avr-mon for the target
+     instead of the generic remote target. */
+  if ((strcmp (target_shortname, "avr-mon") == 0)
+      && (msymbol = lookup_minimal_symbol ("gdb_break", NULL, NULL)))
+    {
+      mon_brk = SYMBOL_VALUE_ADDRESS (msymbol);
+      store_unsigned_integer (buf, wordsize, mon_brk / 2);
+      sp -= wordsize;
+      write_memory (sp + 1, buf + 1, 1);
+      write_memory (sp + 2, buf, 1);
+    }
+#endif
+  return sp;
+}
+
+static CORE_ADDR
+avr_skip_prologue (CORE_ADDR pc)
+{
+  CORE_ADDR func_addr, func_end;
+  struct symtab_and_line sal;
+
+  /* See what the symbol table says */
+
+  if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
+    {
+      sal = find_pc_line (func_addr, 0);
+
+      if (sal.line != 0 && sal.end < func_end)
+	return sal.end;
+    }
+
+/* Either we didn't find the start of this function (nothing we can do),
+   or there's no line info, or the line after the prologue is after
+   the end of the function (there probably isn't a prologue). */
+
+  return pc;
+}
+
+static CORE_ADDR
+avr_frame_address (struct frame_info *fi)
+{
+  return avr_make_saddr (fi->frame);
+}
+
+/* Given a GDB frame, determine the address of the calling function's frame.
+   This will be used to create a new GDB frame struct, and then
+   INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
+
+   For us, the frame address is its stack pointer value, so we look up
+   the function prologue to determine the caller's sp value, and return it.  */
+
+static CORE_ADDR
+avr_frame_chain (struct frame_info *frame)
+{
+  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+    {
+      /* initialize the return_pc now */
+      frame->extra_info->return_pc = generic_read_register_dummy (frame->pc,
+								  frame->
+								  frame,
+								  AVR_PC_REGNUM);
+      return frame->frame;
+    }
+  return (frame->extra_info->is_main ? 0
+	  : frame->frame + frame->extra_info->framesize + 2 /* ret addr */ );
+}
+
+/* Store the address of the place in which to copy the structure the
+   subroutine will return.  This is called from call_function. 
+
+   We store structs through a pointer passed in the first Argument
+   register. */
+
+static void
+avr_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
+{
+  write_register (0, addr);
+}
+
+/* Extract from an array REGBUF containing the (raw) register state
+   the address in which a function should return its structure value,
+   as a CORE_ADDR (or an expression that can be used as one). */
+
+static CORE_ADDR
+avr_extract_struct_value_address (char *regbuf)
+{
+  return (extract_address ((regbuf) + REGISTER_BYTE (0),
+			   REGISTER_RAW_SIZE (0)) | AVR_SMEM_START);
+}
+
+/* Setup the function arguments for calling a function in the inferior.
+
+   On the AVR architecture, there are 18 registers (R25 to R8) which are
+   dedicated for passing function arguments.  Up to the first 18 arguments
+   (depending on size) may go into these registers.  The rest go on the stack.
+
+   Arguments that are larger than WORDSIZE bytes will be split between two or
+   more registers as available, but will NOT be split between a register and
+   the stack.
+
+   An exceptional case exists for struct arguments (and possibly other
+   aggregates such as arrays) -- if the size is larger than WORDSIZE bytes but
+   not a multiple of WORDSIZE bytes.  In this case the argument is never split
+   between the registers and the stack, but instead is copied in its entirety
+   onto the stack, AND also copied into as many registers as there is room
+   for.  In other words, space in registers permitting, two copies of the same
+   argument are passed in.  As far as I can tell, only the one on the stack is
+   used, although that may be a function of the level of compiler
+   optimization.  I suspect this is a compiler bug.  Arguments of these odd
+   sizes are left-justified within the word (as opposed to arguments smaller
+   than WORDSIZE bytes, which are right-justified).
+ 
+   If the function is to return an aggregate type such as a struct, the caller
+   must allocate space into which the callee will copy the return value.  In
+   this case, a pointer to the return value location is passed into the callee
+   in register R0, which displaces one of the other arguments passed in via
+   registers R0 to R2. */
+
+static CORE_ADDR
+avr_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
+		    int struct_return, CORE_ADDR struct_addr)
+{
+  int stack_alloc, stack_offset;
+  int wordsize;
+  int argreg;
+  int argnum;
+  struct type *type;
+  CORE_ADDR regval;
+  char *val;
+  char valbuf[4];
+  int len;
+
+  wordsize = 1;
+#if 0
+  /* Now make sure there's space on the stack */
+  for (argnum = 0, stack_alloc = 0; argnum < nargs; argnum++)
+    stack_alloc += TYPE_LENGTH (VALUE_TYPE (args[argnum]));
+  sp -= stack_alloc;		/* make room on stack for args */
+  /* we may over-allocate a little here, but that won't hurt anything */
+#endif
+  argreg = 25;
+  if (struct_return)		/* "struct return" pointer takes up one argreg */
+    {
+      write_register (--argreg, struct_addr);
+    }
+
+  /* Now load as many as possible of the first arguments into registers, and
+     push the rest onto the stack.  There are 3N bytes in three registers
+     available.  Loop thru args from first to last.  */
+
+  for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++)
+    {
+      type = VALUE_TYPE (args[argnum]);
+      len = TYPE_LENGTH (type);
+      val = (char *) VALUE_CONTENTS (args[argnum]);
+
+      /* NOTE WELL!!!!!  This is not an "else if" clause!!!  That's because
+         some *&^%$ things get passed on the stack AND in the registers!  */
+      while (len > 0)
+	{			/* there's room in registers */
+	  len -= wordsize;
+	  regval = extract_address (val + len, wordsize);
+	  write_register (argreg--, regval);
+	}
+    }
+  return sp;
+}
+
+/* Initialize the gdbarch structure for the AVR's. */
+
+static struct gdbarch *
+avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+{
+  /* FIXME: TRoth/2002-02-18: I have no idea if avr_call_dummy_words[] should
+     be bigger or not. Initial testing seems to show that `call my_func()`
+     works and backtrace from a breakpoint within the call looks correct.
+     Admittedly, I haven't tested with more than a very simple program. */
+  static LONGEST avr_call_dummy_words[] = { 0 };
+
+  struct gdbarch *gdbarch;
+  struct gdbarch_tdep *tdep;
+
+  /* Find a candidate among the list of pre-declared architectures. */
+  arches = gdbarch_list_lookup_by_info (arches, &info);
+  if (arches != NULL)
+    return arches->gdbarch;
+
+  /* None found, create a new architecture from the information provided. */
+  tdep = XMALLOC (struct gdbarch_tdep);
+  gdbarch = gdbarch_alloc (&info, tdep);
+
+  /* If we ever need to differentiate the device types, do it here. */
+  switch (info.bfd_arch_info->mach)
+    {
+    case bfd_mach_avr1:
+    case bfd_mach_avr2:
+    case bfd_mach_avr3:
+    case bfd_mach_avr4:
+    case bfd_mach_avr5:
+      break;
+    }
+
+  set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+  set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+  set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+  set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
+  set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+  set_gdbarch_addr_bit (gdbarch, 32);
+  set_gdbarch_bfd_vma_bit (gdbarch, 32);	/* FIXME: TRoth/2002-02-18: Is this needed? */
+
+  set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+  set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+  set_gdbarch_long_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+
+  set_gdbarch_float_format (gdbarch, &floatformat_ieee_single_little);
+  set_gdbarch_double_format (gdbarch, &floatformat_ieee_single_little);
+  set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_single_little);
+
+  set_gdbarch_read_pc (gdbarch, avr_read_pc);
+  set_gdbarch_write_pc (gdbarch, avr_write_pc);
+  set_gdbarch_read_fp (gdbarch, avr_read_fp);
+  set_gdbarch_read_sp (gdbarch, avr_read_sp);
+  set_gdbarch_write_sp (gdbarch, avr_write_sp);
+
+  set_gdbarch_num_regs (gdbarch, AVR_NUM_REGS);
+
+  set_gdbarch_sp_regnum (gdbarch, AVR_SP_REGNUM);
+  set_gdbarch_fp_regnum (gdbarch, AVR_FP_REGNUM);
+  set_gdbarch_pc_regnum (gdbarch, AVR_PC_REGNUM);
+
+  set_gdbarch_register_name (gdbarch, avr_register_name);
+  set_gdbarch_register_size (gdbarch, 1);
+  set_gdbarch_register_bytes (gdbarch, AVR_NUM_REG_BYTES);
+  set_gdbarch_register_byte (gdbarch, avr_register_byte);
+  set_gdbarch_register_raw_size (gdbarch, avr_register_raw_size);
+  set_gdbarch_max_register_raw_size (gdbarch, 4);
+  set_gdbarch_register_virtual_size (gdbarch, avr_register_virtual_size);
+  set_gdbarch_max_register_virtual_size (gdbarch, 4);
+  set_gdbarch_register_virtual_type (gdbarch, avr_register_virtual_type);
+
+  /* We might need to define our own here or define FRAME_INIT_SAVED_REGS */
+  set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
+
+  set_gdbarch_print_insn (gdbarch, print_insn_avr);
+
+  set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
+  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
+  set_gdbarch_call_dummy_address (gdbarch, avr_call_dummy_address);
+  set_gdbarch_call_dummy_start_offset (gdbarch, 0);
+  set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
+  set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
+  set_gdbarch_call_dummy_length (gdbarch, 0);
+  set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
+  set_gdbarch_call_dummy_p (gdbarch, 1);
+  set_gdbarch_call_dummy_words (gdbarch, avr_call_dummy_words);
+  set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
+  set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
+
+/*    set_gdbarch_believe_pcc_promotion (gdbarch, 1); // TRoth: should this be set? */
+
+  set_gdbarch_address_to_pointer (gdbarch, avr_address_to_pointer);
+  set_gdbarch_pointer_to_address (gdbarch, avr_pointer_to_address);
+  set_gdbarch_extract_return_value (gdbarch, avr_extract_return_value);
+  set_gdbarch_push_arguments (gdbarch, avr_push_arguments);
+  set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
+/*    set_gdbarch_push_return_address (gdbarch, avr_push_return_address); */
+  set_gdbarch_pop_frame (gdbarch, avr_pop_frame);
+
+  set_gdbarch_store_return_value (gdbarch, avr_store_return_value);
+
+  set_gdbarch_use_struct_convention (gdbarch, generic_use_struct_convention);
+  set_gdbarch_store_struct_return (gdbarch, avr_store_struct_return);
+  set_gdbarch_extract_struct_value_address (gdbarch,
+					    avr_extract_struct_value_address);
+
+  set_gdbarch_frame_init_saved_regs (gdbarch, avr_scan_prologue);
+  set_gdbarch_init_extra_frame_info (gdbarch, avr_init_extra_frame_info);
+  set_gdbarch_skip_prologue (gdbarch, avr_skip_prologue);
+/*    set_gdbarch_prologue_frameless_p (gdbarch, avr_prologue_frameless_p); */
+  set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
+
+  set_gdbarch_decr_pc_after_break (gdbarch, 0);
+
+  set_gdbarch_function_start_offset (gdbarch, 0);
+  set_gdbarch_remote_translate_xfer_address (gdbarch,
+					     avr_remote_translate_xfer_address);
+  set_gdbarch_frame_args_skip (gdbarch, 0);
+  set_gdbarch_frameless_function_invocation (gdbarch, frameless_look_for_prologue);	/* ??? */
+  set_gdbarch_frame_chain (gdbarch, avr_frame_chain);
+  set_gdbarch_frame_chain_valid (gdbarch, generic_func_frame_chain_valid);
+  set_gdbarch_frame_saved_pc (gdbarch, avr_frame_saved_pc);
+  set_gdbarch_frame_args_address (gdbarch, avr_frame_address);
+  set_gdbarch_frame_locals_address (gdbarch, avr_frame_address);
+  set_gdbarch_saved_pc_after_call (gdbarch, avr_saved_pc_after_call);
+  set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
+
+  set_gdbarch_convert_from_func_ptr_addr (gdbarch,
+					  avr_convert_from_func_ptr_addr);
+
+  return gdbarch;
+}
+
+/* Send a query request to the avr remote target asking for values of the io
+   registers. If args parameter is not NULL, then the user has requested info
+   on a specific io register [This still needs implemented and is ignored for
+   now]. The query string should be one of these forms:
+
+   "Ravr.io_reg" -> reply is "NN" number of io registers
+
+   "Ravr.io_reg:addr,len" where addr is first register and len is number of
+   registers to be read. The reply should be "<NAME>,VV;" for each io register
+   where, <NAME> is a string, and VV is the hex value of the register.
+
+   All io registers are 8-bit. */
+
+static void
+avr_io_reg_read_command (char *args, int from_tty)
+{
+  int bufsiz = 0;
+  char buf[400];
+  char query[400];
+  char *p;
+  unsigned int nreg = 0;
+  unsigned int val;
+  int i, j, k, step;
+
+/*    fprintf_unfiltered (gdb_stderr, "DEBUG: avr_io_reg_read_command (\"%s\", %d)\n", */
+/*             args, from_tty); */
+
+  if (!current_target.to_query)
+    {
+      fprintf_unfiltered (gdb_stderr,
+			  "ERR: info io_registers NOT supported by current target\n");
+      return;
+    }
+
+  /* Just get the maximum buffer size. */
+  target_query ((int) 'R', 0, 0, &bufsiz);
+  if (bufsiz > sizeof (buf))
+    bufsiz = sizeof (buf);
+
+  /* Find out how many io registers the target has. */
+  strcpy (query, "avr.io_reg");
+  target_query ((int) 'R', query, buf, &bufsiz);
+
+  if (strncmp (buf, "", bufsiz) == 0)
+    {
+      fprintf_unfiltered (gdb_stderr,
+			  "info io_registers NOT supported by target\n");
+      return;
+    }
+
+  if (sscanf (buf, "%x", &nreg) != 1)
+    {
+      fprintf_unfiltered (gdb_stderr,
+			  "Error fetching number of io registers\n");
+      return;
+    }
+
+  reinitialize_more_filter ();
+
+  printf_unfiltered ("Target has %u io registers:\n\n", nreg);
+
+  /* only fetch up to 8 registers at a time to keep the buffer small */
+  step = 8;
+
+  for (i = 0; i < nreg; i += step)
+    {
+      j = step - (nreg % step);	/* how many registers this round? */
+
+      snprintf (query, sizeof (query) - 1, "avr.io_reg:%x,%x", i, j);
+      target_query ((int) 'R', query, buf, &bufsiz);
+
+      p = buf;
+      for (k = i; k < (i + j); k++)
+	{
+	  if (sscanf (p, "%[^,],%x;", query, &val) == 2)
+	    {
+	      printf_filtered ("[%02x] %-15s : %02x\n", k, query, val);
+	      while ((*p != ';') && (*p != '\0'))
+		p++;
+	      p++;		/* skip over ';' */
+	      if (*p == '\0')
+		break;
+	    }
+	}
+    }
+}
+
+void
+_initialize_avr_tdep (void)
+{
+  register_gdbarch_init (bfd_arch_avr, avr_gdbarch_init);
+
+  /* Add a new command to allow the user to query the avr remote target for
+     the values of the io space registers in a saner way than just using
+     `x/NNNb ADDR`. */
+
+  /* FIXME: TRoth/2002-02-18: This should probably be changed to 'info avr
+     io_registers' to signify it is not available on other platforms. */
+
+  add_cmd ("io_registers", class_info, avr_io_reg_read_command,
+	   "query remote avr target for io space register values", &infolist);
+}
diff --git a/gdb/bcache.c b/gdb/bcache.c
index 753a916..73b86e8 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -1,7 +1,8 @@
 /* Implement a cached obstack.
    Written by Fred Fish <fnf@cygnus.com>
    Rewritten by Jim Blandy <jimb@cygnus.com>
-   Copyright 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -20,14 +21,14 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <stddef.h>
-#include <stdlib.h>
-
 #include "defs.h"
 #include "obstack.h"
 #include "bcache.h"
 #include "gdb_string.h"		/* For memcpy declaration */
 
+#include <stddef.h>
+#include <stdlib.h>
+
 /* The old hash function was stolen from SDBM. This is what DB 3.0 uses now,
  * and is better than the old one. 
  */
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 1f10381..706d028 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -1,7 +1,9 @@
-/* Get info from stack frames;
-   convert between frames, blocks, functions and pc values.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Get info from stack frames; convert between frames, blocks,
+   functions and pc values.
+
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -225,7 +227,7 @@
   fi->frame = addr;
   fi->pc = pc;
   find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
-  fi->signal_handler_caller = IN_SIGTRAMP (fi->pc, name);
+  fi->signal_handler_caller = PC_IN_SIGTRAMP (fi->pc, name);
 
   if (INIT_EXTRA_FRAME_INFO_P ())
     INIT_EXTRA_FRAME_INFO (0, fi);
@@ -252,7 +254,7 @@
   obstack_init (&frame_cache_obstack);
 
   current_frame = NULL;		/* Invalidate cache */
-  select_frame (NULL, -1);
+  select_frame (NULL);
   annotate_frames_invalid ();
 }
 
@@ -266,7 +268,7 @@
   /* FIXME: The inferior_ptid test is wrong if there is a corefile.  */
   if (PIDGET (inferior_ptid) != 0)
     {
-      select_frame (get_current_frame (), 0);
+      select_frame (get_current_frame ());
     }
 }
 
@@ -301,12 +303,6 @@
     return 0;
 }
 
-/* Default a few macros that people seldom redefine.  */
-
-#ifndef FRAME_CHAIN_COMBINE
-#define	FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
-#endif
-
 /* Return a structure containing various interesting information
    about the frame that called NEXT_FRAME.  Returns NULL
    if there is no such frame.  */
@@ -377,7 +373,6 @@
       address = FRAME_CHAIN (next_frame);
       if (!FRAME_CHAIN_VALID (address, next_frame))
 	return 0;
-      address = FRAME_CHAIN_COMBINE (address, next_frame);
     }
   if (address == 0)
     return 0;
@@ -393,6 +388,7 @@
     next_frame->prev = prev;
   prev->next = next_frame;
   prev->frame = address;
+  prev->level = next_frame->level + 1;
 
 /* This change should not be needed, FIXME!  We should
    determine whether any targets *need* INIT_FRAME_PC to happen
@@ -462,7 +458,7 @@
 
   find_pc_partial_function (prev->pc, &name,
 			    (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
-  if (IN_SIGTRAMP (prev->pc, name))
+  if (PC_IN_SIGTRAMP (prev->pc, name))
     prev->signal_handler_caller = 1;
 
   return prev;
@@ -504,10 +500,23 @@
 #endif
 
 /* Return the innermost lexical block in execution
-   in a specified stack frame.  The frame address is assumed valid.  */
+   in a specified stack frame.  The frame address is assumed valid.
+
+   If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the exact code
+   address we used to choose the block.  We use this to find a source
+   line, to decide which macro definitions are in scope.
+
+   The value returned in *ADDR_IN_BLOCK isn't necessarily the frame's
+   PC, and may not really be a valid PC at all.  For example, in the
+   caller of a function declared to never return, the code at the
+   return address will never be reached, so the call instruction may
+   be the very last instruction in the block.  So the address we use
+   to choose the block is actually one byte before the return address
+   --- hopefully pointing us at the call instruction, or its delay
+   slot instruction.  */
 
 struct block *
-get_frame_block (struct frame_info *frame)
+get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block)
 {
   CORE_ADDR pc;
 
@@ -520,13 +529,22 @@
        after the call insn, we probably want to make frame->pc point after
        the call insn anyway.  */
     --pc;
+
+  if (addr_in_block)
+    *addr_in_block = pc;
+
   return block_for_pc (pc);
 }
 
 struct block *
-get_current_block (void)
+get_current_block (CORE_ADDR *addr_in_block)
 {
-  return block_for_pc (read_pc ());
+  CORE_ADDR pc = read_pc ();
+
+  if (addr_in_block)
+    *addr_in_block = pc;
+
+  return block_for_pc (pc);
 }
 
 CORE_ADDR
@@ -559,7 +577,7 @@
 struct symbol *
 get_frame_function (struct frame_info *frame)
 {
-  register struct block *bl = get_frame_block (frame);
+  register struct block *bl = get_frame_block (frame, 0);
   if (bl == 0)
     return 0;
   return block_function (bl);
@@ -729,7 +747,7 @@
   /* If sigtramp is in the u area, it counts as a function (especially
      important for step_1).  */
 #if defined SIGTRAMP_START
-  if (IN_SIGTRAMP (mapped_pc, (char *) NULL))
+  if (PC_IN_SIGTRAMP (mapped_pc, (char *) NULL))
     {
       cache_pc_function_low = SIGTRAMP_START (mapped_pc);
       cache_pc_function_high = SIGTRAMP_END (mapped_pc);
@@ -1052,42 +1070,59 @@
   CORE_ADDR sp;
   CORE_ADDR top;
   char *registers;
+
+  /* Address range of the call dummy code.  Look for PC in the range
+     [LO..HI) (after allowing for DECR_PC_AFTER_BREAK).  */
+  CORE_ADDR call_lo;
+  CORE_ADDR call_hi;
 };
 
 static struct dummy_frame *dummy_frame_stack = NULL;
 
 /* Function: find_dummy_frame(pc, fp, sp)
-   Search the stack of dummy frames for one matching the given PC, FP and SP.
-   This is the work-horse for pc_in_call_dummy and read_register_dummy     */
+
+   Search the stack of dummy frames for one matching the given PC, FP
+   and SP.  Unlike PC_IN_CALL_DUMMY, this function doesn't need to
+   adjust for DECR_PC_AFTER_BREAK.  This is because it is only legal
+   to call this function after the PC has been adjusted.  */
 
 char *
 generic_find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp)
 {
   struct dummy_frame *dummyframe;
 
-  if (pc != entry_point_address ())
-    return 0;
-
   for (dummyframe = dummy_frame_stack; dummyframe != NULL;
        dummyframe = dummyframe->next)
-    if (fp == dummyframe->fp
-	|| fp == dummyframe->sp
-	|| fp == dummyframe->top)
+    if ((pc >= dummyframe->call_lo && pc < dummyframe->call_hi)
+	&& (fp == dummyframe->fp
+	    || fp == dummyframe->sp
+	    || fp == dummyframe->top))
       /* The frame in question lies between the saved fp and sp, inclusive */
       return dummyframe->registers;
 
   return 0;
 }
 
-/* Function: pc_in_call_dummy (pc, fp)
-   Return true if this is a dummy frame created by gdb for an inferior call */
+/* Function: pc_in_call_dummy (pc, sp, fp)
+
+   Return true if the PC falls in a dummy frame created by gdb for an
+   inferior call.  The code below which allows DECR_PC_AFTER_BREAK is
+   for infrun.c, which may give the function a PC without that
+   subtracted out.  */
 
 int
 generic_pc_in_call_dummy (CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR fp)
 {
-  /* if find_dummy_frame succeeds, then PC is in a call dummy */
-  /* Note: SP and not FP is passed on. */
-  return (generic_find_dummy_frame (pc, sp) != 0);
+  struct dummy_frame *dummyframe;
+  for (dummyframe = dummy_frame_stack;
+       dummyframe != NULL;
+       dummyframe = dummyframe->next)
+    {
+      if ((pc >= dummyframe->call_lo)
+	  && (pc < dummyframe->call_hi + DECR_PC_AFTER_BREAK))
+	return 1;
+    }
+  return 0;
 }
 
 /* Function: read_register_dummy 
@@ -1152,6 +1187,15 @@
   dummy_frame_stack->top = sp;
 }
 
+/* Record the upper/lower bounds on the address of the call dummy.  */
+
+void
+generic_save_call_dummy_addr (CORE_ADDR lo, CORE_ADDR hi)
+{
+  dummy_frame_stack->call_lo = lo;
+  dummy_frame_stack->call_hi = hi;
+}
+
 /* Restore the machine state from either the saved dummy stack or a
    real stack frame. */
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 640505e..6f604f1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -217,6 +217,9 @@
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
+/* Are overlay event breakpoints enabled? */
+static int overlay_events_enabled;
+
 /* Walk the following statement or block through all breakpoints.
    ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
    breakpoint.  */
@@ -735,33 +738,65 @@
 	&& !b->inserted
 	&& !b->duplicate)
       {
-	if (b->type == bp_hardware_breakpoint)
-	  val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
+	/* "Normal" instruction breakpoint: either the standard
+	   trap-instruction bp (bp_breakpoint), or a
+	   bp_hardware_breakpoint.  */
+
+	/* First check to see if we have to handle an overlay.  */
+	if (overlay_debugging == ovly_off
+	    || b->section == NULL
+	    || !(section_is_overlay (b->section)))
+	  {
+	    /* No overlay handling: just set the breakpoint.  */
+
+	    if (b->type == bp_hardware_breakpoint)
+	      val = target_insert_hw_breakpoint (b->address, 
+						 b->shadow_contents);
+	    else
+	      val = target_insert_breakpoint (b->address, b->shadow_contents);
+	  }
 	else
 	  {
-	    /* Check to see if breakpoint is in an overlay section;
-	       if so, we should set the breakpoint at the LMA address.
-	       Only if the section is currently mapped should we ALSO
-	       set a break at the VMA address. */
-	    if (overlay_debugging && b->section 
-		&& section_is_overlay (b->section))
+	    /* This breakpoint is in an overlay section.  
+	       Shall we set a breakpoint at the LMA?  */
+	    if (!overlay_events_enabled)
 	      {
-		CORE_ADDR addr;
-
-		addr = overlay_unmapped_address (b->address, b->section);
-		val = target_insert_breakpoint (addr, b->shadow_contents);
-		/* This would be the time to check val, to see if the
-		   breakpoint write to the load address succeeded.  
-		   However, this might be an ordinary occurrance, eg. if 
-		   the unmapped overlay is in ROM.  */
-		val = 0;	/* in case unmapped address failed */
-		if (section_is_mapped (b->section))
+		/* Yes -- overlay event support is not active, 
+		   so we must try to set a breakpoint at the LMA.
+		   This will not work for a hardware breakpoint.  */
+		if (b->type == bp_hardware_breakpoint)
+		  warning ("hardware breakpoint %d not supported in overlay!\n",
+			   b->number);
+		else
+		  {
+		    CORE_ADDR addr = overlay_unmapped_address (b->address, 
+							       b->section);
+		    /* Set a software (trap) breakpoint at the LMA.  */
+		    val = target_insert_breakpoint (addr, b->shadow_contents);
+		    if (val != 0)
+		      warning ("overlay breakpoint %d failed: in ROM?", 
+			       b->number);
+		  }
+	      }
+	    /* Shall we set a breakpoint at the VMA? */
+	    if (section_is_mapped (b->section))
+	      {
+		/* Yes.  This overlay section is mapped into memory.  */
+		if (b->type == bp_hardware_breakpoint)
+		  val = target_insert_hw_breakpoint (b->address, 
+						     b->shadow_contents);
+		else
 		  val = target_insert_breakpoint (b->address,
 						  b->shadow_contents);
 	      }
-	    else		/* ordinary (non-overlay) address */
-	      val = target_insert_breakpoint (b->address, b->shadow_contents);
+	    else
+	      {
+		/* No.  This breakpoint will not be inserted.  
+		   No error, but do not mark the bp as 'inserted'.  */
+		continue;
+	      }
 	  }
+
 	if (val)
 	  {
 	    /* Can't set the breakpoint.  */
@@ -866,7 +901,7 @@
 	/* Save the current frame and level so we can restore it after
 	   evaluating the watchpoint expression on its own frame.  */
 	saved_frame = selected_frame;
-	saved_level = selected_frame_level;
+	saved_level = frame_relative_level (selected_frame);
 
 	/* Determine if the watchpoint is within scope.  */
 	if (b->exp_valid_block == NULL)
@@ -883,7 +918,7 @@
 	    fi = find_frame_addr_in_frame_chain (b->watchpoint_frame);
 	    within_current_scope = (fi != NULL);
 	    if (within_current_scope)
-	      select_frame (fi, -1);
+	      select_frame (fi);
 	  }
 
 	if (within_current_scope)
@@ -967,8 +1002,8 @@
 
 	/* Restore the frame and level.  */
 	if ((saved_frame != selected_frame) ||
-	    (saved_level != selected_frame_level))
-	  select_frame (saved_frame, saved_level);
+	    (saved_level != frame_relative_level (selected_frame)))
+	  select_frame (saved_frame);
 
 	if (val)
 	  return_val = val;	/* remember failure */
@@ -1266,32 +1301,61 @@
       && b->type != bp_catch_catch
       && b->type != bp_catch_throw)
     {
-      if (b->type == bp_hardware_breakpoint)
-	val = target_remove_hw_breakpoint (b->address, b->shadow_contents);
+      /* "Normal" instruction breakpoint: either the standard
+	 trap-instruction bp (bp_breakpoint), or a
+	 bp_hardware_breakpoint.  */
+
+      /* First check to see if we have to handle an overlay.  */
+      if (overlay_debugging == ovly_off
+	  || b->section == NULL
+	  || !(section_is_overlay (b->section)))
+	{
+	  /* No overlay handling: just remove the breakpoint.  */
+
+	  if (b->type == bp_hardware_breakpoint)
+	    val = target_remove_hw_breakpoint (b->address, 
+					       b->shadow_contents);
+	  else
+	    val = target_remove_breakpoint (b->address, b->shadow_contents);
+	}
       else
 	{
-	  /* Check to see if breakpoint is in an overlay section;
-	     if so, we should remove the breakpoint at the LMA address.
-	     If that is not equal to the raw address, then we should 
-	     presumably remove the breakpoint there as well.  */
-	  if (overlay_debugging && b->section 
-	      && section_is_overlay (b->section))
+	  /* This breakpoint is in an overlay section.  
+	     Did we set a breakpoint at the LMA?  */
+	  if (!overlay_events_enabled)
+	      {
+		/* Yes -- overlay event support is not active, so we
+		   should have set a breakpoint at the LMA.  Remove it.  
+		*/
+		CORE_ADDR addr = overlay_unmapped_address (b->address, 
+							   b->section);
+		/* Ignore any failures: if the LMA is in ROM, we will
+		   have already warned when we failed to insert it.  */
+		if (b->type != bp_hardware_breakpoint)
+		  target_remove_hw_breakpoint (addr, b->shadow_contents);
+		else
+		  target_remove_breakpoint (addr, b->shadow_contents);
+	      }
+	  /* Did we set a breakpoint at the VMA? 
+	     If so, we will have marked the breakpoint 'inserted'.  */
+	  if (b->inserted)
 	    {
-	      CORE_ADDR addr;
-
-	      addr = overlay_unmapped_address (b->address, b->section);
-	      val = target_remove_breakpoint (addr, b->shadow_contents);
-	      /* This would be the time to check val, to see if the
-	         shadow breakpoint write to the load address succeeded.  
-	         However, this might be an ordinary occurrance, eg. if 
-	         the unmapped overlay is in ROM.  */
-	      val = 0;		/* in case unmapped address failed */
-	      if (section_is_mapped (b->section))
+	      /* Yes -- remove it.  Previously we did not bother to
+		 remove the breakpoint if the section had been
+		 unmapped, but let's not rely on that being safe.  We
+		 don't know what the overlay manager might do.  */
+	      if (b->type == bp_hardware_breakpoint)
+		val = target_remove_hw_breakpoint (b->address, 
+						   b->shadow_contents);
+	      else
 		val = target_remove_breakpoint (b->address,
 						b->shadow_contents);
 	    }
-	  else			/* ordinary (non-overlay) address */
-	    val = target_remove_breakpoint (b->address, b->shadow_contents);
+	  else
+	    {
+	      /* No -- not inserted, so no need to remove.  No error.  */
+	      val = 0;
+	    }
 	}
       if (val)
 	return val;
@@ -2270,7 +2334,7 @@
 	/* If we end up stopping, the current frame will get selected
 	   in normal_stop.  So this call to select_frame won't affect
 	   the user.  */
-	select_frame (fr, -1);
+	select_frame (fr);
     }
 
   if (within_current_scope)
@@ -2398,9 +2462,15 @@
 	  continue;
       }
 
-    if (b->type == bp_hardware_breakpoint
-	&& b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
-      continue;
+    if (b->type == bp_hardware_breakpoint)
+      {
+	if (b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
+	  continue;
+	if (overlay_debugging		/* unmapped overlay section */
+	    && section_is_overlay (b->section) 
+	    && !section_is_mapped (b->section))
+	  continue;
+      }
 
     /* Is this a catchpoint of a load or unload?  If so, did we
        get a load or unload of the specified library?  If not,
@@ -2595,7 +2665,7 @@
 	  {
 	    /* Need to select the frame, with all that implies
 	       so that the conditions will have the right context.  */
-	    select_frame (get_current_frame (), 0);
+	    select_frame (get_current_frame ());
 	    value_is_zero
 	      = catch_errors (breakpoint_cond_eval, (b->cond),
 			      "Error in testing breakpoint condition:\n",
@@ -2780,7 +2850,7 @@
 
   /* step_resume entries: a step resume breakpoint overrides another
      breakpoint of signal handling (see comment in wait_for_inferior
-     at first IN_SIGTRAMP where we set the step_resume breakpoint).  */
+     at first PC_IN_SIGTRAMP where we set the step_resume breakpoint).  */
   /* We handle the through_sigtramp_breakpoint the same way; having both
      one of those and a step_resume_breakpoint is probably very rare (?).  */
 
@@ -3824,9 +3894,15 @@
   b->addr_string = xstrdup (func_name);
 
   if (overlay_debugging == ovly_auto)
-    b->enable_state = bp_enabled;
+    {
+      b->enable_state = bp_enabled;
+      overlay_events_enabled = 1;
+    }
   else 
-    b->enable_state = bp_disabled;
+    {
+      b->enable_state = bp_disabled;
+      overlay_events_enabled = 0;
+    }
 }
 
 void
@@ -3839,6 +3915,7 @@
     {
       b->enable_state = bp_enabled;
       check_duplicates (b);
+      overlay_events_enabled = 1;
     }
 }
 
@@ -3852,6 +3929,7 @@
     {
       b->enable_state = bp_disabled;
       check_duplicates (b);
+      overlay_events_enabled = 0;
     }
 }
 
@@ -5621,7 +5699,7 @@
      but it's better than a core dump.  */
   if (selected_frame == NULL)
     error ("No selected frame.");
-  block = get_frame_block (selected_frame);
+  block = get_frame_block (selected_frame, 0);
   pc = selected_frame->pc;
 
   sals.nelts = 0;
@@ -6364,15 +6442,15 @@
   catch_command_1 (arg, 1, from_tty);
 }
 
+/* Delete breakpoints by address or line.  */
 
 static void
 clear_command (char *arg, int from_tty)
 {
-  register struct breakpoint *b, *b1;
+  struct breakpoint *b, *tmp, *prev, *found;
   int default_match;
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
-  register struct breakpoint *found;
   int i;
 
   if (arg)
@@ -6384,6 +6462,7 @@
     {
       sals.sals = (struct symtab_and_line *)
 	xmalloc (sizeof (struct symtab_and_line));
+      make_cleanup (xfree, sals.sals);
       INIT_SAL (&sal);		/* initialize to zeroes */
       sal.line = default_breakpoint_line;
       sal.symtab = default_breakpoint_symtab;
@@ -6398,13 +6477,11 @@
     }
 
   /* For each line spec given, delete bps which correspond
-     to it.  We do this in two loops: the first loop looks at
-     the initial bp(s) in the chain which should be deleted,
-     the second goes down the rest of the chain looking ahead
-     one so it can take those bps off the chain without messing
-     up the chain. */
+     to it.  Do it in two passes, solely to preserve the current
+     behavior that from_tty is forced true if we delete more than
+     one breakpoint.  */
 
-
+  found = NULL;
   for (i = 0; i < sals.nelts; i++)
     {
       /* If exact pc given, clear bpts at that pc.
@@ -6420,81 +6497,75 @@
          1              0             <can't happen> */
 
       sal = sals.sals[i];
-      found = (struct breakpoint *) 0;
+      prev = NULL;
 
-
-      while (breakpoint_chain
-      /* Why don't we check here that this is not
-         a watchpoint, etc., as we do below?
-         I can't make it fail, but don't know
-         what's stopping the failure: a watchpoint
-         of the same address as "sal.pc" should
-         wind up being deleted. */
-
-	     && (((sal.pc && (breakpoint_chain->address == sal.pc)) 
-		  && (!overlay_debugging 
-		      || breakpoint_chain->section == sal.section))
-		 || ((default_match || (0 == sal.pc))
-		     && breakpoint_chain->source_file != NULL
-		     && sal.symtab != NULL
-	      && STREQ (breakpoint_chain->source_file, sal.symtab->filename)
-		     && breakpoint_chain->line_number == sal.line)))
-
+      /* Find all matching breakpoints, remove them from the
+	 breakpoint chain, and add them to the 'found' chain.  */
+      ALL_BREAKPOINTS_SAFE (b, tmp)
 	{
-	  b1 = breakpoint_chain;
-	  breakpoint_chain = b1->next;
-	  b1->next = found;
-	  found = b1;
-	}
-
-      ALL_BREAKPOINTS (b)
-	while (b->next
-	       && b->next->type != bp_none
-	       && b->next->type != bp_watchpoint
-	       && b->next->type != bp_hardware_watchpoint
-	       && b->next->type != bp_read_watchpoint
-	       && b->next->type != bp_access_watchpoint
-	       && (((sal.pc && (b->next->address == sal.pc)) 
-		    && (!overlay_debugging || b->next->section == sal.section))
-		   || ((default_match || (0 == sal.pc))
-		       && b->next->source_file != NULL
-		       && sal.symtab != NULL
-		       && STREQ (b->next->source_file, sal.symtab->filename)
-		       && b->next->line_number == sal.line)))
-
-
-	{
-	  b1 = b->next;
-	  b->next = b1->next;
-	  b1->next = found;
-	  found = b1;
-	}
-
-      if (found == 0)
-	{
-	  if (arg)
-	    error ("No breakpoint at %s.", arg);
+	  /* Are we going to delete b? */
+	  if (b->type != bp_none
+	      && b->type != bp_watchpoint
+	      && b->type != bp_hardware_watchpoint
+	      && b->type != bp_read_watchpoint
+	      && b->type != bp_access_watchpoint
+	      /* Not if b is a watchpoint of any sort... */
+	      && (((sal.pc && (b->address == sal.pc)) 
+		   && (!section_is_overlay (b->section)
+		       || b->section == sal.section))
+		  /* Yes, if sal.pc matches b (modulo overlays).  */
+		  || ((default_match || (0 == sal.pc))
+		      && b->source_file != NULL
+		      && sal.symtab != NULL
+		      && STREQ (b->source_file, sal.symtab->filename)
+		      && b->line_number == sal.line)))
+	    /* Yes, if sal source file and line matches b.  */
+	    {
+	      /* Remove it from breakpoint_chain...  */
+	      if (b == breakpoint_chain)
+		{
+		  /* b is at the head of the list */
+		  breakpoint_chain = b->next;
+		}
+	      else
+		{
+		  prev->next = b->next;
+		}
+	      /* And add it to 'found' chain.  */
+	      b->next = found;
+	      found = b;
+	    }
 	  else
-	    error ("No breakpoint at this line.");
+	    {
+	      /* Keep b, and keep a pointer to it.  */
+	      prev = b;
+	    }
 	}
-
-      if (found->next)
-	from_tty = 1;		/* Always report if deleted more than one */
-      if (from_tty)
-	printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
-      breakpoints_changed ();
-      while (found)
-	{
-	  if (from_tty)
-	    printf_unfiltered ("%d ", found->number);
-	  b1 = found->next;
-	  delete_breakpoint (found);
-	  found = b1;
-	}
-      if (from_tty)
-	putchar_unfiltered ('\n');
     }
-  xfree (sals.sals);
+  /* Now go thru the 'found' chain and delete them.  */
+  if (found == 0)
+    {
+      if (arg)
+	error ("No breakpoint at %s.", arg);
+      else
+	error ("No breakpoint at this line.");
+    }
+
+  if (found->next)
+    from_tty = 1;		/* Always report if deleted more than one */
+  if (from_tty)
+    printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
+  breakpoints_changed ();
+  while (found)
+    {
+      if (from_tty)
+	printf_unfiltered ("%d ", found->number);
+      tmp = found->next;
+      delete_breakpoint (found);
+      found = tmp;
+    }
+  if (from_tty)
+    putchar_unfiltered ('\n');
 }
 
 /* Delete breakpoint in BS if they are `delete' breakpoints and
@@ -7211,8 +7282,8 @@
 	    }
 
 	  save_selected_frame = selected_frame;
-	  save_selected_frame_level = selected_frame_level;
-	  select_frame (fr, -1);
+	  save_selected_frame_level = frame_relative_level (selected_frame);
+	  select_frame (fr);
 	}
 
       value_free (bpt->val);
@@ -7247,7 +7318,7 @@
 	}
 
       if (save_selected_frame_level >= 0)
-	select_frame (save_selected_frame, save_selected_frame_level);
+	select_frame (save_selected_frame);
       value_free_to_mark (mark);
     }
   if (modify_breakpoint_hook)
@@ -7374,26 +7445,26 @@
   add_com ("condition", class_breakpoint, condition_command,
 	   "Specify breakpoint number N to break only if COND is true.\n\
 Usage is `condition N COND', where N is an integer and COND is an\n\
-expression to be evaluated whenever breakpoint N is reached.  ");
+expression to be evaluated whenever breakpoint N is reached.");
 
   c = add_com ("tbreak", class_breakpoint, tbreak_command,
 	       "Set a temporary breakpoint.  Args like \"break\" command.\n\
 Like \"break\" except the breakpoint is only temporary,\n\
 so it will be deleted when hit.  Equivalent to \"break\" followed\n\
 by using \"enable delete\" on the breakpoint number.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("hbreak", class_breakpoint, hbreak_command,
 	       "Set a hardware assisted  breakpoint. Args like \"break\" command.\n\
 Like \"break\" except the breakpoint requires hardware support,\n\
 some target hardware may not have this support.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("thbreak", class_breakpoint, thbreak_command,
 	       "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
 Like \"hbreak\" except the breakpoint is only temporary,\n\
 so it will be deleted when hit.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_prefix_cmd ("enable", class_breakpoint, enable_command,
 		  "Enable some breakpoints.\n\
@@ -7507,7 +7578,7 @@
 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
 \n\
 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_com_alias ("b", "break", class_run, 1);
   add_com_alias ("br", "break", class_run, 1);
@@ -7638,19 +7709,19 @@
 	       "Set a watchpoint for an expression.\n\
 A watchpoint stops execution of your program whenever the value of\n\
 an expression changes.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("rwatch", class_breakpoint, rwatch_command,
 	       "Set a read watchpoint for an expression.\n\
 A watchpoint stops execution of your program whenever the value of\n\
 an expression is read.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   c = add_com ("awatch", class_breakpoint, awatch_command,
 	       "Set a watchpoint for an expression.\n\
 A watchpoint stops execution of your program whenever the value of\n\
 an expression is either read or written.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_info ("watchpoints", breakpoints_info,
 	    "Synonym for ``info breakpoints''.");
diff --git a/gdb/builtin-regs.c b/gdb/builtin-regs.c
new file mode 100644
index 0000000..f9a6781
--- /dev/null
+++ b/gdb/builtin-regs.c
@@ -0,0 +1,77 @@
+/* Builtin registers, for GDB, the GNU debugger.
+
+   Copyright 2002 Free Software Foundation, Inc.
+
+   Contributed by Red Hat.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "builtin-regs.h"
+#include "gdbtypes.h"
+#include "gdb_string.h"
+#include "gdb_assert.h"
+
+/* Implement builtin register types.  Builtin registers have regnum's
+   that live above of the range [0 .. NUM_REGS + NUM_PSEUDO_REGS)
+   (which is controlled by the target).  The target should never see a
+   builtin register's regnum value.  */
+
+/* An array of builtin registers.  Always append, never delete.  By
+   doing this, the relative regnum (offset from NUM_REGS +
+   NUM_PSEUDO_REGS) assigned to each builtin register never changes.  */
+
+struct builtin_reg
+{
+  const char *name;
+  struct value *(*value) (struct frame_info * frame);
+};
+
+static struct builtin_reg *builtin_regs;
+int nr_builtin_regs;
+
+void
+add_builtin_reg (const char *name, struct value *(*value) (struct frame_info * frame))
+{
+  nr_builtin_regs++;
+  builtin_regs = xrealloc (builtin_regs,
+			   nr_builtin_regs * sizeof (builtin_regs[0]));
+  builtin_regs[nr_builtin_regs - 1].name = name;
+  builtin_regs[nr_builtin_regs - 1].value = value;
+}
+
+int
+builtin_reg_map_name_to_regnum (const char *name, int len)
+{
+  int reg;
+  for (reg = 0; reg < nr_builtin_regs; reg++)
+    {
+      if (len == strlen (builtin_regs[reg].name)
+	  && strncmp (builtin_regs[reg].name, name, len) == 0)
+	return NUM_REGS + NUM_PSEUDO_REGS + reg;
+    }
+  return -1;
+}
+
+struct value *
+value_of_builtin_reg (int regnum, struct frame_info *frame)
+{
+  int reg = regnum - NUM_REGS + NUM_PSEUDO_REGS;
+  gdb_assert (reg >= 0 && reg < nr_builtin_regs);
+  return builtin_regs[reg].value (frame);
+}
diff --git a/gdb/builtin-regs.h b/gdb/builtin-regs.h
new file mode 100644
index 0000000..b35c4e9
--- /dev/null
+++ b/gdb/builtin-regs.h
@@ -0,0 +1,35 @@
+/* Builtin registers, for GDB, the GNU debugger.
+
+   Copyright 2002 Free Software Foundation, Inc.
+
+   Contributed by Red Hat.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef BUILTIN_REGS_H
+#define BUILTIN_REGS_H
+
+extern int builtin_reg_map_name_to_regnum (const char *str, int len);
+
+extern struct value *value_of_builtin_reg (int regnum,
+					   struct frame_info *frame);
+
+extern void add_builtin_reg (const char *name,
+			     struct value *(value) (struct frame_info * frame));
+
+#endif
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 3d2d1aa..a15a445 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -807,24 +807,52 @@
 			{ $$ = builtin_type_short; }
 	|	LONG INT_KEYWORD
 			{ $$ = builtin_type_long; }
+	|	LONG SIGNED_KEYWORD INT_KEYWORD
+			{ $$ = builtin_type_long; }
+	|	LONG SIGNED_KEYWORD
+			{ $$ = builtin_type_long; }
+	|	SIGNED_KEYWORD LONG INT_KEYWORD
+			{ $$ = builtin_type_long; }
 	|	UNSIGNED LONG INT_KEYWORD
 			{ $$ = builtin_type_unsigned_long; }
+	|	LONG UNSIGNED INT_KEYWORD
+			{ $$ = builtin_type_unsigned_long; }
+	|	LONG UNSIGNED
+			{ $$ = builtin_type_unsigned_long; }
 	|	LONG LONG
 			{ $$ = builtin_type_long_long; }
 	|	LONG LONG INT_KEYWORD
 			{ $$ = builtin_type_long_long; }
+	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
+			{ $$ = builtin_type_long_long; }
+	|	LONG LONG SIGNED_KEYWORD
+			{ $$ = builtin_type_long_long; }
+	|	SIGNED_KEYWORD LONG LONG
+			{ $$ = builtin_type_long_long; }
 	|	UNSIGNED LONG LONG
 			{ $$ = builtin_type_unsigned_long_long; }
 	|	UNSIGNED LONG LONG INT_KEYWORD
 			{ $$ = builtin_type_unsigned_long_long; }
+	|	LONG LONG UNSIGNED
+			{ $$ = builtin_type_unsigned_long_long; }
+	|	LONG LONG UNSIGNED INT_KEYWORD
+			{ $$ = builtin_type_unsigned_long_long; }
 	|	SIGNED_KEYWORD LONG LONG
 			{ $$ = lookup_signed_typename ("long long"); }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
 			{ $$ = lookup_signed_typename ("long long"); }
 	|	SHORT INT_KEYWORD
 			{ $$ = builtin_type_short; }
+	|	SHORT SIGNED_KEYWORD INT_KEYWORD
+			{ $$ = builtin_type_short; }
+	|	SHORT SIGNED_KEYWORD
+			{ $$ = builtin_type_short; }
 	|	UNSIGNED SHORT INT_KEYWORD
 			{ $$ = builtin_type_unsigned_short; }
+	|	SHORT UNSIGNED 
+			{ $$ = builtin_type_unsigned_short; }
+	|	SHORT UNSIGNED INT_KEYWORD
+			{ $$ = builtin_type_unsigned_short; }
 	|	DOUBLE_KEYWORD
 			{ $$ = builtin_type_double; }
 	|	LONG DOUBLE_KEYWORD
@@ -1218,6 +1246,7 @@
    
  retry:
 
+  prev_lexptr = lexptr;
   unquoted_expr = 1;
 
   tokstart = lexptr;
@@ -1738,5 +1767,8 @@
 yyerror (msg)
      char *msg;
 {
+  if (prev_lexptr)
+    lexptr = prev_lexptr;
+
   error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index fa977cd..f98548a 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -338,6 +338,30 @@
 			TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
 			0, "long double", objfile);
       break;
+    case FT_COMPLEX:
+      type = init_type (TYPE_CODE_FLT,
+			2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+			0, "complex float", objfile);
+      TYPE_TARGET_TYPE (type)
+	= init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+		     0, "float", objfile);
+      break;
+    case FT_DBL_PREC_COMPLEX:
+      type = init_type (TYPE_CODE_FLT,
+			2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+			0, "complex double", objfile);
+      TYPE_TARGET_TYPE (type)
+	= init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+		     0, "double", objfile);
+      break;
+    case FT_EXT_PREC_COMPLEX:
+      type = init_type (TYPE_CODE_FLT,
+			2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+			0, "complex long double", objfile);
+      TYPE_TARGET_TYPE (type)
+	= init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+		     0, "long double", objfile);
+      break;
     case FT_TEMPLATE_ARG:
       type = init_type (TYPE_CODE_TEMPLATE_ARG,
 			0,
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 9bcfa46..bd079f2 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -1,5 +1,7 @@
 /* Output generating routines for GDB CLI.
-   Copyright 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions.
    Written by Fernando Nasser for Cygnus.
 
@@ -26,12 +28,6 @@
 #include "gdb_string.h"
 #include "gdb_assert.h"
 
-/* Convenience macro for allocting typesafe memory. */
-
-#ifndef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-#endif
-
 struct ui_out_data
   {
     struct ui_file *stream;
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 16cc989..bcd9a42 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -80,6 +80,9 @@
 
 void apropos_command (char *, int);
 
+/* Limit the call depth of user-defined commands */
+int max_user_call_depth;
+
 /* Define all cmd_list_elements.  */
 
 /* Chain containing all defined commands.  */
@@ -606,6 +609,8 @@
 void
 init_cmd_lists (void)
 {
+  max_user_call_depth = 1024;
+
   cmdlist = NULL;
   infolist = NULL;
   enablelist = NULL;
@@ -673,7 +678,7 @@
 	       "Set working directory to DIR for debugger and program being debugged.\n\
 The change does not take effect for the program being debugged\n\
 until the next time it is started.", &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_com ("echo", class_support, echo_command,
 	   "Print a constant string.  Give string as argument.\n\
@@ -698,11 +703,11 @@
 	       "Read commands from a file named FILE.\n\
 Note that the file \"" GDBINIT_FILENAME "\" is read automatically in this way\n\
 when gdb is started.", &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_com ("quit", class_support, quit_command, "Exit gdb.");
   c = add_com ("help", class_support, help_command, "Print list of commands.");
-  c->completer = command_completer;
+  set_cmd_completer (c, command_completer);
   add_com_alias ("q", "quit", class_support, 1);
   add_com_alias ("h", "help", class_support, 1);
 
@@ -802,9 +807,9 @@
 		  &showdebuglist, "show debug ", 0, &showlist);
 
   c = add_com ("shell", class_support, shell_escape,
-	       "Execute the rest of the line as a shell command.  \n\
+	       "Execute the rest of the line as a shell command.\n\
 With no arguments, run an inferior shell.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   /* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would
      be a really useful feature.  Unfortunately, the below wont do
@@ -817,10 +822,17 @@
 
   c = add_com ("make", class_support, make_command,
           "Run the ``make'' program using the rest of the line as arguments.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
   add_cmd ("user", no_class, show_user,
 	   "Show definitions of user defined commands.\n\
 Argument is the name of the user defined command.\n\
 With no argument, show definitions of all user defined commands.", &showlist);
   add_com ("apropos", class_support, apropos_command, "Search for commands matching a REGEXP");
+
+  add_show_from_set (
+		      add_set_cmd ("max-user-call-depth", no_class, var_integer, 
+				   (char *) &max_user_call_depth,
+				   "Set the max call depth for user-defined commands.\n", 
+				   &setlist),
+		      &showlist);
 }
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index a13b7b8..3f510ac 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -28,6 +28,8 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 
+#include "gdb_assert.h"
+
 /* Prototypes for local functions */
 
 static void undef_cmd_error (char *, char *);
@@ -86,6 +88,31 @@
   return cmd->func == do_cfunc && cmd->function.cfunc == cfunc;
 }
 
+void
+set_cmd_context (struct cmd_list_element *cmd, void *context)
+{
+  cmd->context = context;
+}
+
+void *
+get_cmd_context (struct cmd_list_element *cmd)
+{
+  return cmd->context;
+}
+
+enum cmd_types
+cmd_type (struct cmd_list_element *cmd)
+{
+  return cmd->type;
+}
+
+void
+set_cmd_completer (struct cmd_list_element *cmd,
+		   char **(*completer) (char *text, char *word))
+{
+  cmd->completer = completer; /* Ok.  */
+}
+
 
 /* Add element named NAME.
    CLASS is the top level category into which commands are broken down
@@ -133,6 +160,7 @@
   c->name = name;
   c->class = class;
   set_cmd_cfunc (c, fun);
+  set_cmd_context (c, NULL);
   c->doc = doc;
   c->flags = 0;
   c->replacement = NULL;
@@ -144,7 +172,7 @@
   c->prefixname = NULL;
   c->allow_unknown = 0;
   c->abbrev_flag = 0;
-  c->completer = make_symbol_completion_list;
+  set_cmd_completer (c, make_symbol_completion_list);
   c->type = not_set_cmd;
   c->var = NULL;
   c->var_type = var_boolean;
@@ -272,13 +300,35 @@
 {
 }
 
-/* Add element named NAME to command list LIST (the list for set
+/* Add element named NAME to command list LIST (the list for set/show
    or some sublist thereof).
+   TYPE is set_cmd or show_cmd.
    CLASS is as in add_cmd.
    VAR_TYPE is the kind of thing we are setting.
    VAR is address of the variable being controlled by this command.
    DOC is the documentation string.  */
 
+static struct cmd_list_element *
+add_set_or_show_cmd (char *name,
+		     enum cmd_types type,
+		     enum command_class class,
+		     var_types var_type,
+		     void *var,
+		     char *doc,
+		     struct cmd_list_element **list)
+{
+  struct cmd_list_element *c = add_cmd (name, class, NULL, doc, list);
+  gdb_assert (type == set_cmd || type == show_cmd);
+  c->type = type;
+  c->var_type = var_type;
+  c->var = var;
+  /* This needs to be something besides NULL so that this isn't
+     treated as a help class.  */
+  set_cmd_sfunc (c, empty_sfunc);
+  return c;
+}
+
+
 struct cmd_list_element *
 add_set_cmd (char *name,
 	     enum command_class class,
@@ -287,15 +337,7 @@
 	     char *doc,
 	     struct cmd_list_element **list)
 {
-  struct cmd_list_element *c = add_cmd (name, class, NULL, doc, list);
-
-  c->type = set_cmd;
-  c->var_type = var_type;
-  c->var = var;
-  /* This needs to be something besides NULL so that this isn't
-     treated as a help class.  */
-  set_cmd_sfunc (c, empty_sfunc);
-  return c;
+  return add_set_or_show_cmd (name, set_cmd, class, var_type, var, doc, list);
 }
 
 /* Add element named NAME to command list LIST (the list for set
@@ -360,44 +402,30 @@
 }
 
 /* Where SETCMD has already been added, add the corresponding show
-   command to LIST and return a pointer to the added command (not 
+   command to LIST and return a pointer to the added command (not
    necessarily the head of LIST).  */
+/* NOTE: cagney/2002-03-17: The original version of add_show_from_set
+   used memcpy() to clone `set' into `show'.  This ment that in
+   addition to all the needed fields (var, name, et.al.) some
+   unnecessary fields were copied (namely the callback function).  The
+   function explictly copies relevant fields.  For a `set' and `show'
+   command to share the same callback, the caller must set both
+   explicitly.  */
 struct cmd_list_element *
 add_show_from_set (struct cmd_list_element *setcmd,
 		   struct cmd_list_element **list)
 {
-  struct cmd_list_element *showcmd =
-  (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
-  struct cmd_list_element *p;
+  char *doc;
+  const static char setstring[] = "Set ";
 
-  memcpy (showcmd, setcmd, sizeof (struct cmd_list_element));
-  delete_cmd (showcmd->name, list);
-  showcmd->type = show_cmd;
+  /* Create a doc string by replacing "Set " at the start of the
+     `set'' command's doco with "Show ".  */
+  gdb_assert (strncmp (setcmd->doc, setstring, sizeof (setstring) - 1) == 0);
+  doc = concat ("Show ", setcmd->doc + sizeof (setstring) - 1, NULL);
 
-  /* Replace "set " at start of docstring with "show ".  */
-  if (setcmd->doc[0] == 'S' && setcmd->doc[1] == 'e'
-      && setcmd->doc[2] == 't' && setcmd->doc[3] == ' ')
-    showcmd->doc = concat ("Show ", setcmd->doc + 4, NULL);
-  else
-    fprintf_unfiltered (gdb_stderr, "GDB internal error: Bad docstring for set command\n");
-
-  if (*list == NULL || strcmp ((*list)->name, showcmd->name) >= 0)
-    {
-      showcmd->next = *list;
-      *list = showcmd;
-    }
-  else
-    {
-      p = *list;
-      while (p->next && strcmp (p->next->name, showcmd->name) <= 0)
-	{
-	  p = p->next;
-	}
-      showcmd->next = p->next;
-      p->next = showcmd;
-    }
-
-  return showcmd;
+  /* Insert the basic command.  */
+  return add_set_or_show_cmd (setcmd->name, show_cmd, setcmd->class,
+			      setcmd->var_type, setcmd->var, doc, list);
 }
 
 /* Remove the command named NAME from the command list.  */
@@ -645,14 +673,24 @@
   help_cmd_list (list, class, cmdtype, (int) class >= 0, stream);
 
   if (class == all_classes)
-    fprintf_filtered (stream, "\n\
-Type \"help%s\" followed by a class name for a list of commands in that class.",
-		      cmdtype1);
+    {
+      fprintf_filtered (stream, "\n\
+Type \"help%s\" followed by a class name for a list of commands in ",
+			cmdtype1);
+      wrap_here ("");
+      fprintf_filtered (stream, "that class.");
+    }
 
-  fprintf_filtered (stream, "\n\
-Type \"help%s\" followed by %scommand name for full documentation.\n\
-Command name abbreviations are allowed if unambiguous.\n",
+  fprintf_filtered (stream, "\nType \"help%s\" followed by %scommand name ",
 		    cmdtype1, cmdtype2);
+  wrap_here ("");
+  fputs_filtered ("for ", stream);
+  wrap_here ("");
+  fputs_filtered ("full ", stream);
+  wrap_here ("");
+  fputs_filtered ("documentation.\n", stream);
+  fputs_filtered ("Command name abbreviations are allowed if unambiguous.\n",
+		  stream);
 }
 
 static void
@@ -949,7 +987,7 @@
 	 cmdtype,
 	 q,
 	 *cmdtype ? " " : "",
-	 strlen (cmdtype) - 1,
+	 (int) strlen (cmdtype) - 1,
 	 cmdtype);
 }
 
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index e4b7c55..72436f0 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -20,24 +20,11 @@
 #define CLI_DECODE_H 1
 
 #include "gdb_regex.h"		/* Needed by apropos_cmd.  */
+#include "command.h"
 
-/* Command classes are top-level categories into which commands are broken
-   down for "help" purposes.  
-   Notes on classes: class_alias is for alias commands which are not
-   abbreviations of the original command.  class-pseudo is for
-   commands which are not really commands nor help topics ("stop").  */
-
-enum command_class
-{
-  /* Special args to help_list */
-  class_deprecated, all_classes = -2, all_commands = -1,
-  /* Classes of commands */
-  no_class = -1, class_run = 0, class_vars, class_stack,
-  class_files, class_support, class_info, class_breakpoint, class_trace,
-  class_alias, class_obscure, class_user, class_maintenance,
-  class_pseudo, class_tui, class_xdb
-};
-
+#if 0
+/* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
+   cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
 /* Not a set/show command.  Note that some commands which begin with
    "set" or "show" might be in this category, if their syntax does
    not fall into one of the following categories.  */
@@ -48,55 +35,7 @@
     show_cmd
   }
 cmd_types;
-
-/* Reasonable values for an AUTO_BOOLEAN variable. */
-enum cmd_auto_boolean
-{
-  CMD_AUTO_BOOLEAN_TRUE,
-  CMD_AUTO_BOOLEAN_FALSE,
-  CMD_AUTO_BOOLEAN_AUTO
-};
-
-/* Types of "set" or "show" command.  */
-typedef enum var_types
-  {
-    /* "on" or "off".  *VAR is an integer which is nonzero for on,
-       zero for off.  */
-    var_boolean,
-
-    /* "on" / "true" / "enable" or "off" / "false" / "disable" or
-       "auto.  *VAR is an ``enum cmd_auto_boolean''.  NOTE: In general
-       a custom show command will need to be implemented - one that
-       for "auto" prints both the "auto" and the current auto-selected
-       value. */
-    var_auto_boolean,
-
-    /* Unsigned Integer.  *VAR is an unsigned int.  The user can type 0
-       to mean "unlimited", which is stored in *VAR as UINT_MAX.  */
-    var_uinteger,
-
-    /* Like var_uinteger but signed.  *VAR is an int.  The user can type 0
-       to mean "unlimited", which is stored in *VAR as INT_MAX.  */
-    var_integer,
-
-    /* String which the user enters with escapes (e.g. the user types \n and
-       it is a real newline in the stored string).
-       *VAR is a malloc'd string, or NULL if the string is empty.  */
-    var_string,
-    /* String which stores what the user types verbatim.
-       *VAR is a malloc'd string, or NULL if the string is empty.  */
-    var_string_noescape,
-    /* String which stores a filename.
-       *VAR is a malloc'd string, or NULL if the string is empty.  */
-    var_filename,
-    /* ZeroableInteger.  *VAR is an int.  Like Unsigned Integer except
-       that zero really means zero.  */
-    var_zinteger,
-    /* Enumerated type.  Can only have one of the specified values.  *VAR is a
-       char pointer to the name of the element that we find.  */
-    var_enum
-  }
-var_types;
+#endif
 
 /* This structure records one command'd definition.  */
 
@@ -139,6 +78,9 @@
       }
     function;
 
+    /* Local state (context) for this command.  This can be anything.  */
+    void *context;
+
     /* Documentation of this command (or help topic).
        First line is brief documentation; remaining lines form, with it,
        the full documentation.  First line should end with a period.
@@ -286,11 +228,18 @@
 			   void (*sfunc) (char *args, int from_tty,
 					  struct cmd_list_element * c));
 
+extern void set_cmd_completer (struct cmd_list_element *cmd,
+			       char **(*completer) (char *text, char *word));
+
 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
    around in cmd objects to test the value of the commands sfunc().  */
 extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
 			 void (*cfunc) (char *args, int from_tty));
 
+/* Access to the command's local context.  */
+extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
+extern void *get_cmd_context (struct cmd_list_element *cmd);
+
 extern struct cmd_list_element *lookup_cmd (char **,
 					    struct cmd_list_element *, char *,
 					    int, int);
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
new file mode 100644
index 0000000..1edcfe2
--- /dev/null
+++ b/gdb/cli/cli-dump.c
@@ -0,0 +1,823 @@
+/* Dump-to-file commands, for GDB, the GNU debugger.
+
+   Copyright 2002 Free Software Foundation, Inc.
+
+   Contributed by Red Hat.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "gdb_string.h"
+#include "cli/cli-decode.h"
+#include "cli/cli-cmds.h"
+#include "value.h"
+#include "completer.h"
+#include "cli/cli-dump.h"
+#include "gdb_assert.h"
+#include <ctype.h>
+#include "target.h"
+
+#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
+
+
+char *
+skip_spaces (char *chp)
+{
+  if (chp == NULL)
+    return NULL;
+  while (isspace (*chp))
+    chp++;
+  return chp;
+}
+
+char *
+scan_expression_with_cleanup (char **cmd, const char *def)
+{
+  if ((*cmd) == NULL || (**cmd) == '\0')
+    {
+      char *exp = xstrdup (def);
+      make_cleanup (xfree, exp);
+      return exp;
+    }
+  else
+    {
+      char *exp;
+      char *end;
+
+      end = (*cmd) + strcspn (*cmd, " \t");
+      exp = savestring ((*cmd), end - (*cmd));
+      make_cleanup (xfree, exp);
+      (*cmd) = skip_spaces (end);
+      return exp;
+    }
+}
+
+
+static void
+do_fclose_cleanup (void *arg)
+{
+  FILE *file = arg;
+  fclose (arg);
+}
+
+static struct cleanup *
+make_cleanup_fclose (FILE *file)
+{
+  return make_cleanup (do_fclose_cleanup, file);
+}
+
+char *
+scan_filename_with_cleanup (char **cmd, const char *defname)
+{
+  char *filename;
+  char *fullname;
+
+  /* FIXME: Need to get the ``/a(ppend)'' flag from somewhere.  */
+
+  /* File.  */
+  if ((*cmd) == NULL)
+    {
+      if (defname == NULL)
+	error ("Missing filename.");
+      filename = xstrdup (defname);
+      make_cleanup (xfree, filename);
+    }
+  else
+    {
+      /* FIXME: should parse a possibly quoted string.  */
+      char *end;
+
+      (*cmd) = skip_spaces (*cmd);
+      end = *cmd + strcspn (*cmd, " \t");
+      filename = savestring ((*cmd), end - (*cmd));
+      make_cleanup (xfree, filename);
+      (*cmd) = skip_spaces (end);
+    }
+  gdb_assert (filename != NULL);
+
+  fullname = tilde_expand (filename);
+  make_cleanup (xfree, fullname);
+  
+  return fullname;
+}
+
+FILE *
+fopen_with_cleanup (char *filename, const char *mode)
+{
+  FILE *file = fopen (filename, mode);
+  if (file == NULL)
+    perror_with_name (filename);
+  make_cleanup_fclose (file);
+  return file;
+}
+
+static bfd *
+bfd_openr_with_cleanup (const char *filename, const char *target)
+{
+  bfd *ibfd;
+
+  if ((ibfd = bfd_openr (filename, target)) == NULL)
+    error ("Failed to open %s: %s.", filename, 
+	   bfd_errmsg (bfd_get_error ()));
+
+  make_cleanup_bfd_close (ibfd);
+  if (!bfd_check_format (ibfd, bfd_object))
+    error ("'%s' is not a recognized file format.", filename);
+
+  return ibfd;
+}
+
+static bfd *
+bfd_openw_with_cleanup (char *filename, const char *target, char *mode)
+{
+  bfd *obfd;
+
+  if (*mode == 'w')	/* Write: create new file */
+    {
+      if ((obfd = bfd_openw (filename, target)) == NULL)
+	error ("Failed to open %s: %s.", filename, 
+	       bfd_errmsg (bfd_get_error ()));
+      make_cleanup_bfd_close (obfd);
+      if (!bfd_set_format (obfd, bfd_object))
+	error ("bfd_openw_with_cleanup: %s.", bfd_errmsg (bfd_get_error ()));
+    }
+  else if (*mode == 'a')	/* Append to existing file */
+    {	/* FIXME -- doesn't work... */
+      error ("bfd_openw does not work with append.");
+    }
+  else
+    error ("bfd_openw_with_cleanup: unknown mode %s.", mode);
+
+  return obfd;
+}
+
+struct cmd_list_element *dump_cmdlist;
+struct cmd_list_element *append_cmdlist;
+struct cmd_list_element *srec_cmdlist;
+struct cmd_list_element *ihex_cmdlist;
+struct cmd_list_element *tekhex_cmdlist;
+struct cmd_list_element *binary_dump_cmdlist;
+struct cmd_list_element *binary_append_cmdlist;
+
+static void
+dump_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"dump\" must be followed by a subcommand.\n\n");
+  help_list (dump_cmdlist, "dump ", -1, gdb_stdout);
+}
+
+static void
+append_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"append\" must be followed by a subcommand.\n\n");
+  help_list (dump_cmdlist, "append ", -1, gdb_stdout);
+}
+
+static void
+dump_binary_file (char *filename, char *mode, 
+		  char *buf, int len)
+{
+  FILE *file;
+  int status;
+
+  file = fopen_with_cleanup (filename, mode);
+  status = fwrite (buf, len, 1, file);
+  if (status != 1)
+    perror_with_name (filename);
+}
+
+static void
+dump_bfd_file (char *filename, char *mode, 
+	       char *target, CORE_ADDR vaddr, 
+	       char *buf, int len)
+{
+  bfd *obfd;
+  asection *osection;
+
+  obfd = bfd_openw_with_cleanup (filename, target, mode);
+  osection = bfd_make_section_anyway (obfd, ".newsec");
+  bfd_set_section_size (obfd, osection, len);
+  bfd_set_section_vma (obfd, osection, vaddr);
+  bfd_set_section_alignment (obfd, osection, 0);
+  bfd_set_section_flags (obfd, osection, 0x203);
+  osection->entsize = 0;
+  bfd_set_section_contents (obfd, osection, buf, 0, len);
+}
+
+static void
+dump_memory_to_file (char *cmd, char *mode, char *file_format)
+{
+  struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL);
+  CORE_ADDR lo;
+  CORE_ADDR hi;
+  ULONGEST count;
+  char *filename;
+  void *buf;
+  char *lo_exp;
+  char *hi_exp;
+  int len;
+
+  /* Open the file.  */
+  filename = scan_filename_with_cleanup (&cmd, NULL);
+
+  /* Find the low address.  */
+  if (cmd == NULL || *cmd == '\0')
+    error ("Missing start address.");
+  lo_exp = scan_expression_with_cleanup (&cmd, NULL);
+
+  /* Find the second address - rest of line.  */
+  if (cmd == NULL || *cmd == '\0')
+    error ("Missing stop address.");
+  hi_exp = cmd;
+
+  lo = parse_and_eval_address (lo_exp);
+  hi = parse_and_eval_address (hi_exp);
+  if (hi <= lo)
+    error ("Invalid memory address range (start >= end).");
+  count = hi - lo;
+
+  /* FIXME: Should use read_memory_partial() and a magic blocking
+     value.  */
+  buf = xmalloc (count);
+  make_cleanup (xfree, buf);
+  target_read_memory (lo, buf, count);
+  
+  /* Have everything.  Open/write the data.  */
+  if (file_format == NULL || strcmp (file_format, "binary") == 0)
+    {
+      dump_binary_file (filename, mode, buf, count);
+    }
+  else
+    {
+      dump_bfd_file (filename, mode, file_format, lo, buf, count);
+    }
+
+  do_cleanups (old_cleanups);
+}
+
+static void
+dump_memory_command (char *cmd, char *mode)
+{
+  dump_memory_to_file (cmd, mode, "binary");
+}
+
+static void
+dump_value_to_file (char *cmd, char *mode, char *file_format)
+{
+  struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL);
+  struct value *val;
+  char *filename;
+
+  /* Open the file.  */
+  filename = scan_filename_with_cleanup (&cmd, NULL);
+
+  /* Find the value.  */
+  if (cmd == NULL || *cmd == '\0')
+    error ("No value to %s.", *mode == 'a' ? "append" : "dump");
+  val = parse_and_eval (cmd);
+  if (val == NULL)
+    error ("Invalid expression.");
+
+  /* Have everything.  Open/write the data.  */
+  if (file_format == NULL || strcmp (file_format, "binary") == 0)
+    {
+      dump_binary_file (filename, mode, VALUE_CONTENTS (val), 
+			TYPE_LENGTH (VALUE_TYPE (val)));
+    }
+  else
+    {
+      CORE_ADDR vaddr;
+
+      if (VALUE_LVAL (val))
+	{
+	  vaddr = VALUE_ADDRESS (val);
+	}
+      else
+	{
+	  vaddr = 0;
+	  warning ("value is not an lval: address assumed to be zero");
+	}
+
+      dump_bfd_file (filename, mode, file_format, vaddr, 
+		     VALUE_CONTENTS (val), 
+		     TYPE_LENGTH (VALUE_TYPE (val)));
+    }
+
+  do_cleanups (old_cleanups);
+}
+
+static void
+dump_value_command (char *cmd, char *mode)
+{
+  dump_value_to_file (cmd, mode, "binary");
+}
+
+static void
+dump_filetype (char *cmd, char *mode, char *filetype)
+{
+  char *suffix = cmd;
+
+  if (cmd == NULL || *cmd == '\0')
+    error ("Missing subcommand: try 'help %s %s'.", 
+	   mode[0] == 'a' ? "append" : "dump", 
+	   filetype);
+
+  suffix += strcspn (cmd, " \t");
+
+  if (suffix != cmd)
+    {
+      if (strncmp ("memory", cmd, suffix - cmd) == 0)
+	{
+	  dump_memory_to_file (suffix, mode, filetype);
+	  return;
+	}
+      else if (strncmp ("value", cmd, suffix - cmd) == 0)
+	{
+	  dump_value_to_file (suffix, mode, filetype);
+	  return;
+	}
+    }
+
+  error ("dump %s: unknown subcommand '%s' -- try 'value' or 'memory'.",
+	 filetype, cmd);
+}
+
+static void
+dump_srec_memory (char *args, int from_tty)
+{
+  dump_memory_to_file (args, "w", "srec");
+}
+
+static void
+dump_srec_value (char *args, int from_tty)
+{
+  dump_value_to_file (args, "w", "srec");
+}
+
+static void
+dump_ihex_memory (char *args, int from_tty)
+{
+  dump_memory_to_file (args, "w", "ihex");
+}
+
+static void
+dump_ihex_value (char *args, int from_tty)
+{
+  dump_value_to_file (args, "w", "ihex");
+}
+
+static void
+dump_tekhex_memory (char *args, int from_tty)
+{
+  dump_memory_to_file (args, "w", "tekhex");
+}
+
+static void
+dump_tekhex_value (char *args, int from_tty)
+{
+  dump_value_to_file (args, "w", "tekhex");
+}
+
+static void
+dump_binary_memory (char *args, int from_tty)
+{
+  dump_memory_to_file (args, "w", "binary");
+}
+
+static void
+dump_binary_value (char *args, int from_tty)
+{
+  dump_value_to_file (args, "w", "binary");
+}
+
+static void
+append_binary_memory (char *args, int from_tty)
+{
+  dump_memory_to_file (args, "a", "binary");
+}
+
+static void
+append_binary_value (char *args, int from_tty)
+{
+  dump_value_to_file (args, "a", "binary");
+}
+
+struct dump_context
+{
+  void (*func) (char *cmd, char *mode);
+  char *mode;
+};
+
+static void
+call_dump_func (struct cmd_list_element *c, char *args, int from_tty)
+{
+  struct dump_context *d = get_cmd_context (c);
+  d->func (args, d->mode);
+}
+
+void
+add_dump_command (char *name, void (*func) (char *args, char *mode),
+		  char *descr)
+
+{
+  struct cmd_list_element *c;
+  struct dump_context *d;
+
+  c = add_cmd (name, all_commands, NULL, descr, &dump_cmdlist);
+  c->completer =  filename_completer;
+  d = XMALLOC (struct dump_context);
+  d->func = func;
+  d->mode = "w";
+  set_cmd_context (c, d);
+  c->func = call_dump_func;
+
+  c = add_cmd (name, all_commands, NULL, descr, &append_cmdlist);
+  c->completer =  filename_completer;
+  d = XMALLOC (struct dump_context);
+  d->func = func;
+  d->mode = "a";
+  set_cmd_context (c, d);
+  c->func = call_dump_func;
+
+  /* Replace "Dump " at start of docstring with "Append "
+     (borrowed from add_show_from_set).  */
+  if (   c->doc[0] == 'W' 
+      && c->doc[1] == 'r' 
+      && c->doc[2] == 'i'
+      && c->doc[3] == 't' 
+      && c->doc[4] == 'e'
+      && c->doc[5] == ' ')
+    c->doc = concat ("Append ", c->doc + 6, NULL);
+}
+
+/* Opaque data for restore_section_callback. */
+struct callback_data {
+  unsigned long load_offset;
+  CORE_ADDR load_start;
+  CORE_ADDR load_end;
+};
+
+/* Function: restore_section_callback.
+
+   Callback function for bfd_map_over_sections.
+   Selectively loads the sections into memory.  */
+
+static void
+restore_section_callback (bfd *ibfd, asection *isec, void *args)
+{
+  struct callback_data *data = args;
+  bfd_vma sec_start  = bfd_section_vma (ibfd, isec);
+  bfd_size_type size = bfd_section_size (ibfd, isec);
+  bfd_vma sec_end    = sec_start + size;
+  bfd_size_type sec_offset = 0;
+  bfd_size_type sec_load_count = size;
+  struct cleanup *old_chain;
+  char *buf;
+  int ret;
+
+  /* Ignore non-loadable sections, eg. from elf files. */
+  if (!(bfd_get_section_flags (ibfd, isec) & SEC_LOAD))
+    return;
+
+  /* Does the section overlap with the desired restore range? */
+  if (sec_end <= data->load_start 
+      || (data->load_end > 0 && sec_start >= data->load_end))
+    {
+      /* No, no useable data in this section. */
+      printf_filtered ("skipping section %s...\n", 
+		       bfd_section_name (ibfd, isec));
+      return;
+    }
+
+  /* Compare section address range with user-requested
+     address range (if any).  Compute where the actual
+     transfer should start and end.  */
+  if (sec_start < data->load_start)
+    sec_offset = data->load_start - sec_start;
+  /* Size of a partial transfer: */
+  sec_load_count -= sec_offset;
+  if (data->load_end > 0 && sec_end > data->load_end)
+    sec_load_count -= sec_end - data->load_end;
+
+  /* Get the data.  */
+  buf = xmalloc (size);
+  old_chain = make_cleanup (xfree, buf);
+  if (!bfd_get_section_contents (ibfd, isec, buf, 0, size))
+    error ("Failed to read bfd file %s: '%s'.", bfd_get_filename (ibfd), 
+	   bfd_errmsg (bfd_get_error ()));
+
+  printf_filtered ("Restoring section %s (0x%lx to 0x%lx)",
+		   bfd_section_name (ibfd, isec), 
+		   (unsigned long) sec_start, 
+		   (unsigned long) sec_end);
+
+  if (data->load_offset != 0 || data->load_start != 0 || data->load_end != 0)
+    printf_filtered (" into memory (0x%s to 0x%s)\n", 
+		     paddr_nz ((unsigned long) sec_start 
+			       + sec_offset + data->load_offset), 
+		     paddr_nz ((unsigned long) sec_start + sec_offset 
+		       + data->load_offset + sec_load_count));
+  else
+    puts_filtered ("\n");
+
+  /* Write the data.  */
+  ret = target_write_memory (sec_start + sec_offset + data->load_offset, 
+			     buf + sec_offset, sec_load_count);
+  if (ret != 0)
+    warning ("restore: memory write failed (%s).", safe_strerror (ret));
+  do_cleanups (old_chain);
+  return;
+}
+
+static void
+restore_binary_file (char *filename, struct callback_data *data)
+{
+  FILE *file = fopen_with_cleanup (filename, "r");
+  int status;
+  char *buf;
+  long len;
+
+  /* Get the file size for reading.  */
+  if (fseek (file, 0, SEEK_END) == 0)
+    len = ftell (file);
+  else
+    perror_with_name (filename);
+
+  if (len <= data->load_start)
+    error ("Start address is greater than length of binary file %s.", 
+	   filename);
+
+  /* Chop off "len" if it exceeds the requested load_end addr. */
+  if (data->load_end != 0 && data->load_end < len)
+    len = data->load_end;
+  /* Chop off "len" if the requested load_start addr skips some bytes. */
+  if (data->load_start > 0)
+    len -= data->load_start;
+
+  printf_filtered 
+    ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", 
+     filename, 
+     (unsigned long) data->load_start + data->load_offset, 
+     (unsigned long) data->load_start + data->load_offset + len);
+
+  /* Now set the file pos to the requested load start pos.  */
+  if (fseek (file, data->load_start, SEEK_SET) != 0)
+    perror_with_name (filename);
+
+  /* Now allocate a buffer and read the file contents.  */
+  buf = xmalloc (len);
+  make_cleanup (xfree, buf);
+  if (fread (buf, 1, len, file) != len)
+    perror_with_name (filename);
+
+  /* Now write the buffer into target memory. */
+  len = target_write_memory (data->load_start + data->load_offset, buf, len);
+  if (len != 0)
+    warning ("restore: memory write failed (%s).", safe_strerror (len));
+  return;
+}
+
+static void
+restore_command (char *args, int from_tty)
+{
+  char *filename;
+  struct callback_data data;
+  bfd *ibfd;
+  int binary_flag = 0;
+
+  if (!target_has_execution)
+    noprocess ();
+
+  data.load_offset = 0;
+  data.load_start  = 0;
+  data.load_end    = 0;
+
+  /* Parse the input arguments.  First is filename (required). */
+  filename = scan_filename_with_cleanup (&args, NULL);
+  if (args != NULL && *args != '\0')
+    {
+      char *binary_string = "binary";
+
+      /* Look for optional "binary" flag.  */
+      if (strncmp (args, binary_string, strlen (binary_string)) == 0)
+	{
+	  binary_flag = 1;
+	  args += strlen (binary_string);
+	  args = skip_spaces (args);
+	}
+      /* Parse offset (optional). */
+      if (args != NULL && *args != '\0')
+      data.load_offset = 
+	parse_and_eval_address (scan_expression_with_cleanup (&args, 
+							      NULL));
+      if (args != NULL && *args != '\0')
+	{
+	  /* Parse start address (optional). */
+	  data.load_start = 
+	    parse_and_eval_address (scan_expression_with_cleanup (&args, 
+								  NULL));
+	  if (args != NULL && *args != '\0')
+	    {
+	      /* Parse end address (optional). */
+	      data.load_end = parse_and_eval_address (args);
+	      if (data.load_end <= data.load_start)
+		error ("Start must be less than end.");
+	    }
+	}
+    }
+
+  if (info_verbose)
+    printf_filtered ("Restore file %s offset 0x%lx start 0x%lx end 0x%lx\n",
+		     filename, (unsigned long) data.load_offset, 
+		     (unsigned long) data.load_start, 
+		     (unsigned long) data.load_end);
+
+  if (binary_flag)
+    {
+      restore_binary_file (filename, &data);
+    }
+  else
+    {
+      /* Open the file for loading. */
+      ibfd = bfd_openr_with_cleanup (filename, NULL);
+
+      /* Process the sections. */
+      bfd_map_over_sections (ibfd, restore_section_callback, &data);
+    }
+  return;
+}
+
+static void
+srec_dump_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"dump srec\" must be followed by a subcommand.\n");
+  help_list (srec_cmdlist, "dump srec ", -1, gdb_stdout);
+}
+
+static void
+ihex_dump_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"dump ihex\" must be followed by a subcommand.\n");
+  help_list (ihex_cmdlist, "dump ihex ", -1, gdb_stdout);
+}
+
+static void
+tekhex_dump_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"dump tekhex\" must be followed by a subcommand.\n");
+  help_list (tekhex_cmdlist, "dump tekhex ", -1, gdb_stdout);
+}
+
+static void
+binary_dump_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"dump binary\" must be followed by a subcommand.\n");
+  help_list (binary_dump_cmdlist, "dump binary ", -1, gdb_stdout);
+}
+
+static void
+binary_append_command (char *cmd, int from_tty)
+{
+  printf_unfiltered ("\"append binary\" must be followed by a subcommand.\n");
+  help_list (binary_append_cmdlist, "append binary ", -1, gdb_stdout);
+}
+
+void
+_initialize_cli_dump (void)
+{
+  struct cmd_list_element *c;
+  add_prefix_cmd ("dump", class_vars, dump_command, "\
+Dump target code/data to a local file.",
+		  &dump_cmdlist, "dump ",
+		  0/*allow-unknown*/,
+		  &cmdlist);
+  add_prefix_cmd ("append", class_vars, append_command, "\
+Append target code/data to a local file.",
+		  &append_cmdlist, "append ",
+		  0/*allow-unknown*/,
+		  &cmdlist);
+
+  add_dump_command ("memory", dump_memory_command, "\
+Write contents of memory to a raw binary file.\n\
+Arguments are FILE START STOP.  Writes the contents of memory within the\n\
+range [START .. STOP) to the specifed FILE in raw target ordered bytes.");
+
+  add_dump_command ("value", dump_value_command, "\
+Write the value of an expression to a raw binary file.\n\
+Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION to\n\
+the specified FILE in raw target ordered bytes.");
+
+  add_prefix_cmd ("srec", all_commands, srec_dump_command, "\
+Write target code/data to an srec file.",
+		  &srec_cmdlist, "dump srec ", 
+		  0 /*allow-unknown*/, 
+		  &dump_cmdlist);
+
+  add_prefix_cmd ("ihex", all_commands, ihex_dump_command, "\
+Write target code/data to an intel hex file.",
+		  &ihex_cmdlist, "dump ihex ", 
+		  0 /*allow-unknown*/, 
+		  &dump_cmdlist);
+
+  add_prefix_cmd ("tekhex", all_commands, tekhex_dump_command, "\
+Write target code/data to a tekhex file.",
+		  &tekhex_cmdlist, "dump tekhex ", 
+		  0 /*allow-unknown*/, 
+		  &dump_cmdlist);
+
+  add_prefix_cmd ("binary", all_commands, binary_dump_command, "\
+Write target code/data to a raw binary file.",
+		  &binary_dump_cmdlist, "dump binary ", 
+		  0 /*allow-unknown*/, 
+		  &dump_cmdlist);
+
+  add_prefix_cmd ("binary", all_commands, binary_append_command, "\
+Append target code/data to a raw binary file.",
+		  &binary_append_cmdlist, "append binary ", 
+		  0 /*allow-unknown*/, 
+		  &append_cmdlist);
+
+  add_cmd ("memory", all_commands, dump_srec_memory, "\
+Write contents of memory to an srec file.\n\
+Arguments are FILE START STOP.  Writes the contents of memory\n\
+within the range [START .. STOP) to the specifed FILE in srec format.",
+	   &srec_cmdlist);
+
+  add_cmd ("value", all_commands, dump_srec_value, "\
+Write the value of an expression to an srec file.\n\
+Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
+to the specified FILE in srec format.",
+	   &srec_cmdlist);
+
+  add_cmd ("memory", all_commands, dump_ihex_memory, "\
+Write contents of memory to an ihex file.\n\
+Arguments are FILE START STOP.  Writes the contents of memory within\n\
+the range [START .. STOP) to the specifed FILE in intel hex format.",
+	   &ihex_cmdlist);
+
+  add_cmd ("value", all_commands, dump_ihex_value, "\
+Write the value of an expression to an ihex file.\n\
+Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
+to the specified FILE in intel hex format.",
+	   &ihex_cmdlist);
+
+  add_cmd ("memory", all_commands, dump_tekhex_memory, "\
+Write contents of memory to a tekhex file.\n\
+Arguments are FILE START STOP.  Writes the contents of memory\n\
+within the range [START .. STOP) to the specifed FILE in tekhex format.",
+	   &tekhex_cmdlist);
+
+  add_cmd ("value", all_commands, dump_tekhex_value, "\
+Write the value of an expression to a tekhex file.\n\
+Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
+to the specified FILE in tekhex format.",
+	   &tekhex_cmdlist);
+
+  add_cmd ("memory", all_commands, dump_binary_memory, "\
+Write contents of memory to a raw binary file.\n\
+Arguments are FILE START STOP.  Writes the contents of memory\n\
+within the range [START .. STOP) to the specifed FILE in binary format.",
+	   &binary_dump_cmdlist);
+
+  add_cmd ("value", all_commands, dump_binary_value, "\
+Write the value of an expression to a raw binary file.\n\
+Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
+to the specified FILE in raw target ordered bytes.",
+	   &binary_dump_cmdlist);
+
+  add_cmd ("memory", all_commands, append_binary_memory, "\
+Append contents of memory to a raw binary file.\n\
+Arguments are FILE START STOP.  Writes the contents of memory within the\n\
+range [START .. STOP) to the specifed FILE in raw target ordered bytes.",
+	   &binary_append_cmdlist);
+
+  add_cmd ("value", all_commands, append_binary_value, "\
+Append the value of an expression to a raw binary file.\n\
+Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
+to the specified FILE in raw target ordered bytes.",
+	   &binary_append_cmdlist);
+
+  c = add_com ("restore", class_vars, restore_command, 
+	       "Restore the contents of FILE to target memory.\n\
+Arguments are FILE OFFSET START END where all except FILE are optional.\n\
+OFFSET will be added to the base address of the file (default zero).\n\
+If START and END are given, only the file contents within that range\n\
+(file relative) will be restored to target memory.");
+  c->completer = filename_completer;
+  /* FIXME: completers for other commands. */
+}
diff --git a/gdb/cli/cli-dump.h b/gdb/cli/cli-dump.h
new file mode 100644
index 0000000..187e0e0
--- /dev/null
+++ b/gdb/cli/cli-dump.h
@@ -0,0 +1,40 @@
+/* Dump-to-file commands, for GDB, the GNU debugger.
+
+   Copyright 2001 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef CLI_DUMP_H
+#define CLI_DUMP_H
+
+extern void add_dump_command (char *name,
+			      void (*func) (char *args, char *mode),
+			      char *descr);
+
+/* Utilities for doing the dump.  */
+extern char *scan_filename_with_cleanup (char **cmd, const char *defname);
+
+extern char *scan_expression_with_cleanup (char **cmd, const char *defname);
+
+extern FILE *fopen_with_cleanup (char *filename, const char *mode);
+
+extern char *skip_spaces (char *inp);
+
+extern struct value *parse_and_eval_with_error (char *exp, const char *fmt, ...) ATTR_FORMAT (printf, 2, 3);
+
+#endif
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 4545117..fc3261c 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -213,7 +213,49 @@
     }				/* while (list) */
 }
 
+/* Handle pre-post hooks.  */
+
+void
+clear_hook_in_cleanup (void *data)
+{
+  struct cmd_list_element *c = data;
+  c->hook_in = 0; /* Allow hook to work again once it is complete */
+}
+
+void
+execute_cmd_pre_hook (struct cmd_list_element *c)
+{
+  if ((c->hook_pre) && (!c->hook_in))
+    {
+      struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
+      c->hook_in = 1; /* Prevent recursive hooking */
+      execute_user_command (c->hook_pre, (char *) 0);
+      do_cleanups (cleanups);
+    }
+}
+
+void
+execute_cmd_post_hook (struct cmd_list_element *c)
+{
+  if ((c->hook_post) && (!c->hook_in))
+    {
+      struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
+      c->hook_in = 1; /* Prevent recursive hooking */
+      execute_user_command (c->hook_post, (char *) 0);
+      do_cleanups (cleanups);
+    }
+}
+
 /* Execute the command in CMD.  */
+void
+do_restore_user_call_depth (void * call_depth)
+{	
+  int * depth = call_depth;
+  /* We will be returning_to_top_level() at this point, so we want to
+     reset our depth. */
+  (*depth) = 0;
+}
+
 
 void
 execute_user_command (struct cmd_list_element *c, char *args)
@@ -221,6 +263,8 @@
   register struct command_line *cmdlines;
   struct cleanup *old_chain;
   enum command_control_type ret;
+  static int user_call_depth = 0;
+  extern int max_user_call_depth;
 
   old_chain = setup_user_args (args);
 
@@ -229,6 +273,11 @@
     /* Null command */
     return;
 
+  if (++user_call_depth > max_user_call_depth)
+    error ("Max user call depth exceeded -- command aborted\n");
+
+  old_chain = make_cleanup (do_restore_user_call_depth, &user_call_depth);
+
   /* Set the instream to 0, indicating execution of a
      user-defined function.  */
   old_chain = make_cleanup (do_restore_instream_cleanup, instream);
@@ -244,6 +293,8 @@
       cmdlines = cmdlines->next;
     }
   do_cleanups (old_chain);
+
+  user_call_depth--;
 }
 
 enum command_control_type
diff --git a/gdb/command.h b/gdb/command.h
index 7c20a42..db7a740 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -1,13 +1,7 @@
-/* ***DEPRECATED***  The gdblib files must not be calling/using things in any
-   of the possible command languages.  If necessary, a hook (that may be
-   present or not) must be used and set to the appropriate routine by any
-   command language that cares about it.  If you are having to include this
-   file you are possibly doing things the old way.  This file will disapear.
-   2000-12-01 fnasser@redhat.com    */
-
 /* Header file for command-reading library command.c.
-   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000
-   Free Software Foundation, Inc.
+
+   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1999,
+   2000, 2002 Free Software Foundation, Inc.
 
    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
@@ -44,6 +38,8 @@
   class_pseudo, class_tui, class_xdb
 };
 
+/* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
+   cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
 /* Not a set/show command.  Note that some commands which begin with
    "set" or "show" might be in this category, if their syntax does
    not fall into one of the following categories.  */
@@ -105,156 +101,7 @@
 var_types;
 
 /* This structure records one command'd definition.  */
-
-
-/* This flag is used by the code executing commands to warn the user 
-   the first time a deprecated command is used, see the 'flags' field in
-   the following struct.
-*/
-#define CMD_DEPRECATED            0x1
-#define DEPRECATED_WARN_USER      0x2
-#define MALLOCED_REPLACEMENT      0x4
-
-struct cmd_list_element
-  {
-    /* Points to next command in this list.  */
-    struct cmd_list_element *next;
-
-    /* Name of this command.  */
-    char *name;
-
-    /* Command class; class values are chosen by application program.  */
-    enum command_class class;
-
-    /* Function definition of this command.  NULL for command class
-       names and for help topics that are not really commands.  NOTE:
-       cagney/2002-02-02: This function signature is evolving.  For
-       the moment suggest sticking with either set_cmd_cfunc() or
-       set_cmd_sfunc().  */
-    void (*func) (struct cmd_list_element *c, char *args, int from_tty);
-    /* The command's real callback.  At present func() bounces through
-       to one of the below.  */
-    union
-      {
-	/* If type is not_set_cmd, call it like this:  */
-	void (*cfunc) (char *args, int from_tty);
-
-	/* If type is set_cmd or show_cmd, first set the variables, and
-	   then call this.  */
-	void (*sfunc) (char *args, int from_tty, struct cmd_list_element * c);
-      }
-    function;
-
-    /* Documentation of this command (or help topic).
-       First line is brief documentation; remaining lines form, with it,
-       the full documentation.  First line should end with a period.
-       Entire string should also end with a period, not a newline.  */
-    char *doc;
-
-    /* flags : a bitfield 
-       
-       bit 0: (LSB) CMD_DEPRECATED, when 1 indicated that this command
-       is deprecated. It may be removed from gdb's command set in the
-       future.
-
-       bit 1: DEPRECATED_WARN_USER, the user needs to be warned that
-       this is a deprecated command.  The user should only be warned
-       the first time a command is used.
-        
-       bit 2: MALLOCED_REPLACEMENT, when functions are deprecated at
-       compile time (this is the way it should, in general, be done)
-       the memory containing the replacement string is statically
-       allocated.  In some cases it makes sense to deprecate commands
-       at runtime (the testsuite is one example).  In this case the
-       memory for replacement is malloc'ed.  When a command is
-       undeprecated or re-deprecated at runtime we don't want to risk
-       calling free on statically allocated memory, so we check this
-       flag.  
-     */
-    int flags;
-
-    /* if this command is deprecated, this is the replacement name */
-    char *replacement;
-
-    /* If this command represents a show command, then this function
-       is called before the variable's value is examined.  */
-    void (*pre_show_hook) (struct cmd_list_element *c);
-
-    /* Hook for another command to be executed before this command.  */
-    struct cmd_list_element *hook_pre;
-
-    /* Hook for another command to be executed after this command.  */
-    struct cmd_list_element *hook_post;
-
-    /* Flag that specifies if this command is already running it's hook. */
-    /* Prevents the possibility of hook recursion. */
-    int hook_in;
-
-    /* Nonzero identifies a prefix command.  For them, the address
-       of the variable containing the list of subcommands.  */
-    struct cmd_list_element **prefixlist;
-
-    /* For prefix commands only:
-       String containing prefix commands to get here: this one
-       plus any others needed to get to it.  Should end in a space.
-       It is used before the word "command" in describing the
-       commands reached through this prefix.  */
-    char *prefixname;
-
-    /* For prefix commands only:
-       nonzero means do not get an error if subcommand is not
-       recognized; call the prefix's own function in that case.  */
-    char allow_unknown;
-
-    /* Nonzero says this is an abbreviation, and should not
-       be mentioned in lists of commands.
-       This allows "br<tab>" to complete to "break", which it
-       otherwise wouldn't.  */
-    char abbrev_flag;
-
-    /* Completion routine for this command.  TEXT is the text beyond
-       what was matched for the command itself (leading whitespace is
-       skipped).  It stops where we are supposed to stop completing
-       (rl_point) and is '\0' terminated.
-
-       Return value is a malloc'd vector of pointers to possible completions
-       terminated with NULL.  If there are no completions, returning a pointer
-       to a NULL would work but returning NULL itself is also valid.
-       WORD points in the same buffer as TEXT, and completions should be
-       returned relative to this position.  For example, suppose TEXT is "foo"
-       and we want to complete to "foobar".  If WORD is "oo", return
-       "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
-    char **(*completer) (char *text, char *word);
-
-    /* Type of "set" or "show" command (or SET_NOT_SET if not "set"
-       or "show").  */
-    cmd_types type;
-
-    /* Pointer to variable affected by "set" and "show".  Doesn't matter
-       if type is not_set.  */
-    void *var;
-
-    /* What kind of variable is *VAR?  */
-    var_types var_type;
-
-    /* Pointer to NULL terminated list of enumerated values (like argv).  */
-    const char **enums;
-
-    /* Pointer to command strings of user-defined commands */
-    struct command_line *user_commands;
-
-    /* Pointer to command that is hooked by this one, (by hook_pre)
-       so the hook can be removed when this one is deleted.  */
-    struct cmd_list_element *hookee_pre;
-
-    /* Pointer to command that is hooked by this one, (by hook_post)
-       so the hook can be removed when this one is deleted.  */
-    struct cmd_list_element *hookee_post;
-
-    /* Pointer to command that is aliased by this one, so the
-       aliased command can be located in case it has been hooked.  */
-    struct cmd_list_element *cmd_pointer;
-  };
+struct cmd_list_element;
 
 /* Forward-declarations of the entry-points of cli/cli-decode.c.  */
 
@@ -292,11 +139,37 @@
 			   void (*sfunc) (char *args, int from_tty,
 					  struct cmd_list_element * c));
 
+extern void set_cmd_completer (struct cmd_list_element *cmd,
+			       char **(*completer) (char *text, char *word));
+
 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
    around in cmd objects to test the value of the commands sfunc().  */
 extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
 			 void (*cfunc) (char *args, int from_tty));
 
+/* Each command object has a local context attached to it. .  */
+extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
+extern void *get_cmd_context (struct cmd_list_element *cmd);
+
+
+/* Execute CMD's pre/post hook.  Throw an error if the command fails.
+   If already executing this pre/post hook, or there is no pre/post
+   hook, the call is silently ignored.  */
+extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
+extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
+
+/* Return the type of the command.  */
+/* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+   the set command passed as a parameter.  The clone operation will
+   include (BUG?) any ``set'' command callback, if present.  Commands
+   like ``info set'' call all the ``show'' command callbacks.
+   Unfortunatly, for ``show'' commands cloned from ``set'', this
+   includes callbacks belonging to ``set'' commands.  Making this
+   worse, this only occures if add_show_from_set() is called after
+   add_cmd_sfunc() (BUG?).  */
+extern enum cmd_types cmd_type (struct cmd_list_element *cmd);
+
+
 extern struct cmd_list_element *lookup_cmd (char **,
 					    struct cmd_list_element *, char *,
 					    int, int);
diff --git a/gdb/completer.c b/gdb/completer.c
index 30a84d6..67ea300 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -24,6 +24,8 @@
 #include "expression.h"
 #include "filenames.h"		/* for DOSish file names */
 
+#include "cli/cli-decode.h"
+
 /* FIXME: This is needed because of lookup_cmd_1().
    We should be calling a hook instead so we eliminate the CLI dependency. */
 #include "gdbcmd.h"
diff --git a/gdb/config.in b/gdb/config.in
index f2bab55..750a8ae 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -93,6 +93,9 @@
 /* Define if <sys/link.h> has struct link_map32 */
 #undef HAVE_STRUCT_LINK_MAP32
 
+/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */
+#undef _SYSCALL32
+
 /* Define if the prfpregset_t type is broken. */
 #undef PRFPREGSET_T_BROKEN
 
@@ -457,6 +460,9 @@
 /* Define if strstr is not declared in system header files. */
 #undef NEED_DECLARATION_STRSTR
 
+/* Define if canonicalize_file_name is not declared in system header files. */
+#undef NEED_DECLARATION_CANONICALIZE_FILE_NAME
+
 /* Define if <sys/procfs.h> has pstatus_t. */
 #undef HAVE_PSTATUS_T
 
diff --git a/gdb/config/a29k/a29k-udi.mt b/gdb/config/a29k/a29k-udi.mt
deleted file mode 100644
index 6fe45b0..0000000
--- a/gdb/config/a29k/a29k-udi.mt
+++ /dev/null
@@ -1,5 +0,0 @@
-# OBSOLETE # Target: AMD 29000 on EB29K board over a serial line
-# OBSOLETE TDEPFILES= a29k-tdep.o remote-udi.o udip2soc.o udr.o udi2go32.o
-# OBSOLETE TM_FILE= tm-a29k.h
-# OBSOLETE 
-# OBSOLETE MT_CFLAGS = $(HOST_IPC)
diff --git a/gdb/config/a29k/a29k.mt b/gdb/config/a29k/a29k.mt
deleted file mode 100644
index b235c05..0000000
--- a/gdb/config/a29k/a29k.mt
+++ /dev/null
@@ -1,5 +0,0 @@
-# OBSOLETE # Target: AMD 29000
-# OBSOLETE TDEPFILES= a29k-tdep.o remote-eb.o remote-adapt.o
-# OBSOLETE TM_FILE= tm-a29k.h
-# OBSOLETE 
-# OBSOLETE MT_CFLAGS = -DNO_HIF_SUPPORT
diff --git a/gdb/config/a29k/tm-a29k.h b/gdb/config/a29k/tm-a29k.h
deleted file mode 100644
index c296f59..0000000
--- a/gdb/config/a29k/tm-a29k.h
+++ /dev/null
@@ -1,722 +0,0 @@
-/* OBSOLETE /* Parameters for target machine AMD 29000, for GDB, the GNU debugger. */
-/* OBSOLETE    Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
-/* OBSOLETE    2001 Free Software Foundation, Inc. */
-/* OBSOLETE    Contributed by Cygnus Support.  Written by Jim Kingdon. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE  */
-/* OBSOLETE /* Parameters for an EB29K (a board which plugs into a PC and is */
-/* OBSOLETE    accessed through EBMON software running on the PC, which we */
-/* OBSOLETE    use as we'd use a remote stub (see remote-eb.c). */
-/* OBSOLETE  */
-/* OBSOLETE    If gdb is ported to other a29k machines/systems, the */
-/* OBSOLETE    machine/system-specific parts should be removed from this file (a */
-/* OBSOLETE    la tm-m68k.h).  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Byte order is configurable, but this machine runs big-endian.  */ */
-/* OBSOLETE #define TARGET_BYTE_ORDER BFD_ENDIAN_BIG */
-/* OBSOLETE  */
-/* OBSOLETE /* Floating point uses IEEE representations.  */ */
-/* OBSOLETE #define IEEE_FLOAT (1) */
-/* OBSOLETE  */
-/* OBSOLETE /* Recognize our magic number.  */ */
-/* OBSOLETE #define BADMAG(x) ((x).f_magic != 0572) */
-/* OBSOLETE  */
-/* OBSOLETE /* Offset from address of function to start of its code. */
-/* OBSOLETE    Zero on most machines.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define FUNCTION_START_OFFSET 0 */
-/* OBSOLETE  */
-/* OBSOLETE /* Advance PC across any function entry prologue instructions */
-/* OBSOLETE    to reach some "real" code.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define SKIP_PROLOGUE(pc) (a29k_skip_prologue (pc)) */
-/* OBSOLETE CORE_ADDR a29k_skip_prologue (); */
-/* OBSOLETE  */
-/* OBSOLETE /* Immediately after a function call, return the saved pc. */
-/* OBSOLETE    Can't go through the frames for this because on some machines */
-/* OBSOLETE    the new frame is not set up until the new function executes */
-/* OBSOLETE    some instructions.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define SAVED_PC_AFTER_CALL(frame) ((frame->flags & TRANSPARENT_FRAME) \ */
-/* OBSOLETE 				    ? read_register (TPC_REGNUM) \ */
-/* OBSOLETE 				    : read_register (LR0_REGNUM)) */
-/* OBSOLETE  */
-/* OBSOLETE /* Stack grows downward.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define INNER_THAN(lhs,rhs) ((lhs) < (rhs)) */
-/* OBSOLETE  */
-/* OBSOLETE /* Stack must be aligned on 32-bit boundaries when synthesizing */
-/* OBSOLETE    function calls. */ */
-/* OBSOLETE  */
-/* OBSOLETE #define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3) */
-/* OBSOLETE  */
-/* OBSOLETE /* Sequence of bytes for breakpoint instruction.  */ */
-/* OBSOLETE /* ASNEQ 0x50, gr1, gr1 */
-/* OBSOLETE    The trap number 0x50 is chosen arbitrarily. */
-/* OBSOLETE    We let the command line (or previously included files) override this */
-/* OBSOLETE    setting.  */ */
-/* OBSOLETE #ifndef BREAKPOINT */
-/* OBSOLETE #if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG */
-/* OBSOLETE #define BREAKPOINT {0x72, 0x50, 0x01, 0x01} */
-/* OBSOLETE #else /* Target is little-endian.  */ */
-/* OBSOLETE #define BREAKPOINT {0x01, 0x01, 0x50, 0x72} */
-/* OBSOLETE #endif /* Target is little-endian.  */ */
-/* OBSOLETE #endif /* BREAKPOINT */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Amount PC must be decremented by after a breakpoint. */
-/* OBSOLETE    This is often the number of bytes in BREAKPOINT */
-/* OBSOLETE    but not always.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define DECR_PC_AFTER_BREAK 0 */
-/* OBSOLETE  */
-/* OBSOLETE /* Say how long (ordinary) registers are.  This is a piece of bogosity */
-/* OBSOLETE    used in push_word and a few other places; REGISTER_RAW_SIZE is the */
-/* OBSOLETE    real way to know how big a register is.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define REGISTER_SIZE 4 */
-/* OBSOLETE  */
-/* OBSOLETE /* Allow the register declarations here to be overridden for remote */
-/* OBSOLETE    kernel debugging.  */ */
-/* OBSOLETE #if !defined (REGISTER_NAMES) */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of machine registers */ */
-/* OBSOLETE  */
-/* OBSOLETE #define NUM_REGS 205 */
-/* OBSOLETE  */
-/* OBSOLETE /* Initializer for an array of names of registers. */
-/* OBSOLETE    There should be NUM_REGS strings in this initializer. */
-/* OBSOLETE  */
-/* OBSOLETE    FIXME, add floating point registers and support here. */
-/* OBSOLETE  */
-/* OBSOLETE    Also note that this list does not attempt to deal with kernel */
-/* OBSOLETE    debugging (in which the first 32 registers are gr64-gr95).  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define REGISTER_NAMES \ */
-/* OBSOLETE {"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \ */
-/* OBSOLETE  "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \ */
-/* OBSOLETE  "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \ */
-/* OBSOLETE  "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127",		 \ */
-/* OBSOLETE  "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9",   \ */
-/* OBSOLETE  "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \ */
-/* OBSOLETE  "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \ */
-/* OBSOLETE  "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \ */
-/* OBSOLETE  "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \ */
-/* OBSOLETE  "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \ */
-/* OBSOLETE  "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \ */
-/* OBSOLETE  "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \ */
-/* OBSOLETE  "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \ */
-/* OBSOLETE  "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \ */
-/* OBSOLETE  "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \ */
-/* OBSOLETE  "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \ */
-/* OBSOLETE  "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \ */
-/* OBSOLETE  "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \ */
-/* OBSOLETE  "lr124", "lr125", "lr126", "lr127",					 \ */
-/* OBSOLETE   "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9",  \ */
-/* OBSOLETE   "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP",			 \ */
-/* OBSOLETE   "bp", "fc", "cr", "q",						 \ */
-/* OBSOLETE   "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr",	 \ */
-/* OBSOLETE   "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "inte", "fps", "exo", "gr1",  \ */
-/* OBSOLETE   "alu", "ipc", "ipa", "ipb" } */
-/* OBSOLETE  */
-/* OBSOLETE /* */
-/* OBSOLETE  * Converts an sdb register number to an internal gdb register number. */
-/* OBSOLETE  * Currently under epi, gr96->0...gr127->31...lr0->32...lr127->159, or... */
-/* OBSOLETE  *                      gr64->0...gr95->31, lr0->32...lr127->159. */
-/* OBSOLETE  */ */
-/* OBSOLETE #define SDB_REG_TO_REGNUM(value) \ */
-/* OBSOLETE   (((value) >= 96 && (value) <= 127) ? ((value) - 96) : \ */
-/* OBSOLETE    ((value) >= 128 && (value) <=  255) ? ((value) - 128 + LR0_REGNUM) : \ */
-/* OBSOLETE    (value)) */
-/* OBSOLETE  */
-/* OBSOLETE /* */
-/* OBSOLETE  * Provide the processor register numbers of some registers that are */
-/* OBSOLETE  * expected/written in instructions that might change under different */
-/* OBSOLETE  * register sets.  Namely, gcc can compile (-mkernel-registers) so that */
-/* OBSOLETE  * it uses gr64-gr95 in stead of gr96-gr127. */
-/* OBSOLETE  */ */
-/* OBSOLETE #define MSP_HW_REGNUM	125	/* gr125 */ */
-/* OBSOLETE #define RAB_HW_REGNUM	126	/* gr126 */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Convert Processor Special register #x to REGISTER_NAMES register # */ */
-/* OBSOLETE #define SR_REGNUM(x) \ */
-/* OBSOLETE   ((x) < 15  ? VAB_REGNUM + (x)					 \ */
-/* OBSOLETE    : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128		 \ */
-/* OBSOLETE    : (x) == 131 ? Q_REGNUM					 \ */
-/* OBSOLETE    : (x) == 132 ? ALU_REGNUM					 \ */
-/* OBSOLETE    : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133		 \ */
-/* OBSOLETE    : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160		 \ */
-/* OBSOLETE    : (x) == 164 ? EXO_REGNUM                                     \ */
-/* OBSOLETE    : (error ("Internal error in SR_REGNUM"), 0)) */
-/* OBSOLETE #define GR96_REGNUM 0 */
-/* OBSOLETE  */
-/* OBSOLETE /* Define the return register separately, so it can be overridden for */
-/* OBSOLETE    kernel procedure calling conventions. */ */
-/* OBSOLETE #define	RETURN_REGNUM	GR96_REGNUM */
-/* OBSOLETE #define GR1_REGNUM 200 */
-/* OBSOLETE /* This needs to be the memory stack pointer, not the register stack pointer, */
-/* OBSOLETE    to make call_function work right.  */ */
-/* OBSOLETE #define SP_REGNUM MSP_REGNUM */
-/* OBSOLETE #define FP_REGNUM 33		/* lr1 */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Return register for transparent calling convention (gr122).  */ */
-/* OBSOLETE #define TPC_REGNUM (122 - 96 + GR96_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Large Return Pointer (gr123).  */ */
-/* OBSOLETE #define LRP_REGNUM (123 - 96 + GR96_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Static link pointer (gr124).  */ */
-/* OBSOLETE #define SLP_REGNUM (124 - 96 + GR96_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Memory Stack Pointer (gr125).  */ */
-/* OBSOLETE #define MSP_REGNUM (125 - 96 + GR96_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Register allocate bound (gr126).  */ */
-/* OBSOLETE #define RAB_REGNUM (126 - 96 + GR96_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Register Free Bound (gr127).  */ */
-/* OBSOLETE #define RFB_REGNUM (127 - 96 + GR96_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Register Stack Pointer.  */ */
-/* OBSOLETE #define RSP_REGNUM GR1_REGNUM */
-/* OBSOLETE #define LR0_REGNUM 32 */
-/* OBSOLETE #define BP_REGNUM 177 */
-/* OBSOLETE #define FC_REGNUM 178 */
-/* OBSOLETE #define CR_REGNUM 179 */
-/* OBSOLETE #define Q_REGNUM 180 */
-/* OBSOLETE #define VAB_REGNUM 181 */
-/* OBSOLETE #define OPS_REGNUM (VAB_REGNUM + 1) */
-/* OBSOLETE #define CPS_REGNUM (VAB_REGNUM + 2) */
-/* OBSOLETE #define CFG_REGNUM (VAB_REGNUM + 3) */
-/* OBSOLETE #define CHA_REGNUM (VAB_REGNUM + 4) */
-/* OBSOLETE #define CHD_REGNUM (VAB_REGNUM + 5) */
-/* OBSOLETE #define CHC_REGNUM (VAB_REGNUM + 6) */
-/* OBSOLETE #define RBP_REGNUM (VAB_REGNUM + 7) */
-/* OBSOLETE #define TMC_REGNUM (VAB_REGNUM + 8) */
-/* OBSOLETE #define TMR_REGNUM (VAB_REGNUM + 9) */
-/* OBSOLETE #define NPC_REGNUM (VAB_REGNUM + 10)	/* pc0 */ */
-/* OBSOLETE #define PC_REGNUM  (VAB_REGNUM + 11)	/* pc1 */ */
-/* OBSOLETE #define PC2_REGNUM (VAB_REGNUM + 12) */
-/* OBSOLETE #define MMU_REGNUM (VAB_REGNUM + 13) */
-/* OBSOLETE #define LRU_REGNUM (VAB_REGNUM + 14) */
-/* OBSOLETE #define FPE_REGNUM (VAB_REGNUM + 15) */
-/* OBSOLETE #define INTE_REGNUM (VAB_REGNUM + 16) */
-/* OBSOLETE #define FPS_REGNUM (VAB_REGNUM + 17) */
-/* OBSOLETE #define EXO_REGNUM (VAB_REGNUM + 18) */
-/* OBSOLETE /* gr1 is defined above as 200 = VAB_REGNUM + 19 */ */
-/* OBSOLETE #define ALU_REGNUM (VAB_REGNUM + 20) */
-/* OBSOLETE #define PS_REGNUM  ALU_REGNUM */
-/* OBSOLETE #define IPC_REGNUM (VAB_REGNUM + 21) */
-/* OBSOLETE #define IPA_REGNUM (VAB_REGNUM + 22) */
-/* OBSOLETE #define IPB_REGNUM (VAB_REGNUM + 23) */
-/* OBSOLETE  */
-/* OBSOLETE #endif /* !defined(REGISTER_NAMES) */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Total amount of space needed to store our copies of the machine's */
-/* OBSOLETE    register state, the array `registers'.  */ */
-/* OBSOLETE #define REGISTER_BYTES (NUM_REGS * 4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Index within `registers' of the first byte of the space for */
-/* OBSOLETE    register N.  */ */
-/* OBSOLETE #define REGISTER_BYTE(N)  ((N)*4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of bytes of storage in the actual machine representation */
-/* OBSOLETE    for register N.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* All regs are 4 bytes.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define REGISTER_RAW_SIZE(N) (4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of bytes of storage in the program's representation */
-/* OBSOLETE    for register N.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* All regs are 4 bytes.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define REGISTER_VIRTUAL_SIZE(N) (4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Largest value REGISTER_RAW_SIZE can have.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define MAX_REGISTER_RAW_SIZE (4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Largest value REGISTER_VIRTUAL_SIZE can have.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define MAX_REGISTER_VIRTUAL_SIZE (4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Return the GDB type object for the "standard" data type */
-/* OBSOLETE    of data in register N.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define REGISTER_VIRTUAL_TYPE(N) \ */
-/* OBSOLETE   (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM         \ */
-/* OBSOLETE     || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM     \ */
-/* OBSOLETE     || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM       \ */
-/* OBSOLETE     || (N) == NPC_REGNUM || (N) == PC2_REGNUM)                           \ */
-/* OBSOLETE    ? lookup_pointer_type (builtin_type_void) : builtin_type_int) */
-/* OBSOLETE  */
-/* OBSOLETE /* Store the address of the place in which to copy the structure the */
-/* OBSOLETE    subroutine will return.  This is called from call_function. */ */
-/* OBSOLETE /* On the a29k the LRP points to the part of the structure beyond the first */
-/* OBSOLETE    16 words.  */ */
-/* OBSOLETE #define STORE_STRUCT_RETURN(ADDR, SP) \ */
-/* OBSOLETE   write_register (LRP_REGNUM, (ADDR) + 16 * 4); */
-/* OBSOLETE  */
-/* OBSOLETE /* Should call_function allocate stack space for a struct return?  */ */
-/* OBSOLETE /* On the a29k objects over 16 words require the caller to allocate space.  */ */
-/* OBSOLETE extern use_struct_convention_fn a29k_use_struct_convention; */
-/* OBSOLETE #define USE_STRUCT_CONVENTION(gcc_p, type) a29k_use_struct_convention (gcc_p, type) */
-/* OBSOLETE  */
-/* OBSOLETE /* Extract from an array REGBUF containing the (raw) register state */
-/* OBSOLETE    a function return value of type TYPE, and copy that, in virtual format, */
-/* OBSOLETE    into VALBUF.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF)	      \ */
-/* OBSOLETE   {    	       	       	       	       	       	       	       	       	   \ */
-/* OBSOLETE     int reg_length = TYPE_LENGTH (TYPE);				   \ */
-/* OBSOLETE     if (reg_length > 16 * 4)						   \ */
-/* OBSOLETE       {									   \ */
-/* OBSOLETE 	reg_length = 16 * 4;						   \ */
-/* OBSOLETE 	read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4,   \ */
-/* OBSOLETE 		     TYPE_LENGTH (TYPE) - 16 * 4);			   \ */
-/* OBSOLETE       }									   \ */
-/* OBSOLETE     memcpy ((VALBUF), ((int *)(REGBUF))+RETURN_REGNUM, reg_length);	   \ */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE /* Write into appropriate registers a function return value */
-/* OBSOLETE    of type TYPE, given in virtual format.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define STORE_RETURN_VALUE(TYPE,VALBUF) \ */
-/* OBSOLETE   {									  \ */
-/* OBSOLETE     int reg_length = TYPE_LENGTH (TYPE);				  \ */
-/* OBSOLETE     if (reg_length > 16 * 4)						  \ */
-/* OBSOLETE       {									  \ */
-/* OBSOLETE         reg_length = 16 * 4;						  \ */
-/* OBSOLETE         write_memory (read_register (LRP_REGNUM),			  \ */
-/* OBSOLETE 		      (char *)(VALBUF) + 16 * 4,			  \ */
-/* OBSOLETE 		      TYPE_LENGTH (TYPE) - 16 * 4);			  \ */
-/* OBSOLETE       }									  \ */
-/* OBSOLETE     write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF),  \ */
-/* OBSOLETE 			  TYPE_LENGTH (TYPE));				  \ */
-/* OBSOLETE   } */
-/* OBSOLETE /* *INDENT-OFF* */ */
-/* OBSOLETE /* The a29k user's guide documents well what the stacks look like. */
-/* OBSOLETE    But what isn't so clear there is how this interracts with the */
-/* OBSOLETE    symbols, or with GDB. */
-/* OBSOLETE    In the following saved_msp, saved memory stack pointer (which functions */
-/* OBSOLETE    as a memory frame pointer), means either */
-/* OBSOLETE    a register containing the memory frame pointer or, in the case of */
-/* OBSOLETE    functions with fixed size memory frames (i.e. those who don't use */
-/* OBSOLETE    alloca()), the result of the calculation msp + msize. */
-/* OBSOLETE  */
-/* OBSOLETE    LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp. */
-/* OBSOLETE    For high C, these are relative to msp (making alloca impossible). */
-/* OBSOLETE    LOC_REGISTER, LOC_REGPARM - The register number is the number at the */
-/* OBSOLETE    time the function is running (after the prologue), or in the case */
-/* OBSOLETE    of LOC_REGPARM, may be a register number in the range 160-175. */
-/* OBSOLETE  */
-/* OBSOLETE    The compilers do things like store an argument into memory, and then put out */
-/* OBSOLETE    a LOC_ARG for it, or put it into global registers and put out a */
-/* OBSOLETE    LOC_REGPARM.  Thus is it important to execute the first line of */
-/* OBSOLETE    code (i.e. the line of the open brace, i.e. the prologue) of a function */
-/* OBSOLETE    before trying to print arguments or anything. */
-/* OBSOLETE  */
-/* OBSOLETE    The following diagram attempts to depict what is going on in memory */
-/* OBSOLETE    (see also the _a29k user's guide_) and also how that interacts with */
-/* OBSOLETE    GDB frames.  We arbitrarily pick fci->frame to point the same place */
-/* OBSOLETE    as the register stack pointer; since we set it ourself in */
-/* OBSOLETE    INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_* */
-/* OBSOLETE    macros, it doesn't really matter exactly how we */
-/* OBSOLETE    do it.  However, note that FRAME_FP is used in two ways in GDB: */
-/* OBSOLETE    (1) as a "magic cookie" which uniquely identifies frames (even over */
-/* OBSOLETE    calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK]) */
-/* OBSOLETE    as the value of SP_REGNUM before the dummy frame was pushed.  These */
-/* OBSOLETE    two meanings would be incompatible for the a29k if we defined */
-/* OBSOLETE    CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it). */
-/* OBSOLETE    Also note that "lr1" below, while called a frame pointer */
-/* OBSOLETE    in the user's guide, has only one function:  To determine whether */
-/* OBSOLETE    registers need to be filled in the function epilogue. */
-/* OBSOLETE  */
-/* OBSOLETE    Consider the code: */
-/* OBSOLETE    < call bar> */
-/* OBSOLETE    loc1: . . . */
-/* OBSOLETE    bar:  sub gr1,gr1,rsize_b */
-/* OBSOLETE    . . . */
-/* OBSOLETE    add mfp,msp,0 */
-/* OBSOLETE    sub msp,msp,msize_b */
-/* OBSOLETE    . . . */
-/* OBSOLETE    < call foo > */
-/* OBSOLETE    loc2: . . . */
-/* OBSOLETE    foo:  sub gr1,gr1,rsize_f */
-/* OBSOLETE    . . . */
-/* OBSOLETE    add mfp,msp,0 */
-/* OBSOLETE    sub msp,msp,msize_f */
-/* OBSOLETE    . . . */
-/* OBSOLETE    loc3: < suppose the inferior stops here > */
-/* OBSOLETE  */
-/* OBSOLETE    memory stack      register stack */
-/* OBSOLETE    |           |     |____________| */
-/* OBSOLETE    |           |     |____loc1____| */
-/* OBSOLETE    +------->|___________|     |            |   ^ */
-/* OBSOLETE    |        | ^         |     |  locals_b  |   | */
-/* OBSOLETE    |        | |         |     |____________|   | */
-/* OBSOLETE    |        | |         |     |            |   | rsize_b */
-/* OBSOLETE    |        | | msize_b |     | args_to_f  |   | */
-/* OBSOLETE    |        | |         |     |____________|   | */
-/* OBSOLETE    |        | |         |     |____lr1_____|   V */
-/* OBSOLETE    |        | V         |     |____loc2____|<----------------+ */
-/* OBSOLETE    |   +--->|___________|<---------mfp     |   ^             | */
-/* OBSOLETE    |   |    | ^         |     |  locals_f  |   |             | */
-/* OBSOLETE    |   |    | | msize_f |     |____________|   |             | */
-/* OBSOLETE    |   |    | |         |     |            |   | rsize_f     | */
-/* OBSOLETE    |   |    | V         |     |   args     |   |             | */
-/* OBSOLETE    |   |    |___________|<msp |____________|   |             | */
-/* OBSOLETE    |   |                      |_____lr1____|   V             | */
-/* OBSOLETE    |   |                      |___garbage__| <- gr1 <----+   | */
-/* OBSOLETE    |   |                                                |   | */
-/* OBSOLETE    |   |                                                |   | */
-/* OBSOLETE    |   |                             pc=loc3                    |   | */
-/* OBSOLETE    |   |                                                |   | */
-/* OBSOLETE    |   |                                                |   | */
-/* OBSOLETE    |   |            frame cache                         |   | */
-/* OBSOLETE    |   |       |_________________|                      |   | */
-/* OBSOLETE    |   |       |rsize=rsize_b    |                      |   | */
-/* OBSOLETE    |   |       |msize=msize_b    |                      |   | */
-/* OBSOLETE    +---|--------saved_msp        |                      |   | */
-/* OBSOLETE    |       |frame------------------------------------|---+ */
-/* OBSOLETE    |       |pc=loc2          |                       | */
-/* OBSOLETE    |       |_________________|                       | */
-/* OBSOLETE    |       |rsize=rsize_f    |                       | */
-/* OBSOLETE    |       |msize=msize_f    |                       | */
-/* OBSOLETE    +--------saved_msp        |                       | */
-/* OBSOLETE    |frame------------------------------------+ */
-/* OBSOLETE    |pc=loc3          | */
-/* OBSOLETE    |_________________| */
-/* OBSOLETE  */
-/* OBSOLETE    So, is that sufficiently confusing?  Welcome to the 29000. */
-/* OBSOLETE    Notes: */
-/* OBSOLETE    * The frame for foo uses a memory frame pointer but the frame for */
-/* OBSOLETE    bar does not.  In the latter case the saved_msp is */
-/* OBSOLETE    computed by adding msize to the saved_msp of the */
-/* OBSOLETE    next frame. */
-/* OBSOLETE    * msize is in the frame cache only for high C's sake.  */ */
-/* OBSOLETE /* *INDENT-ON* */ */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE void read_register_stack (); */
-/* OBSOLETE long read_register_stack_integer (); */
-/* OBSOLETE  */
-/* OBSOLETE #define FRAME_INIT_SAVED_REGS(fi)	/*no-op */ */
-/* OBSOLETE  */
-/* OBSOLETE #define EXTRA_FRAME_INFO  \ */
-/* OBSOLETE   CORE_ADDR saved_msp;    \ */
-/* OBSOLETE   unsigned int rsize;     \ */
-/* OBSOLETE   unsigned int msize;	  \ */
-/* OBSOLETE   unsigned char flags; */
-/* OBSOLETE  */
-/* OBSOLETE /* Bits for flags in EXTRA_FRAME_INFO */ */
-/* OBSOLETE #define TRANSPARENT_FRAME	0x1	/* This is a transparent frame */ */
-/* OBSOLETE #define MFP_USED		0x2	/* A memory frame pointer is used */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init */
-/* OBSOLETE    not only ->pc and ->frame, but all the extra stuff, when called from */
-/* OBSOLETE    get_prev_frame, that is.  */ */
-/* OBSOLETE #define INIT_EXTRA_FRAME_INFO(fromleaf, fci)  init_extra_frame_info(fci) */
-/* OBSOLETE void init_extra_frame_info (); */
-/* OBSOLETE  */
-/* OBSOLETE #define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci) */
-/* OBSOLETE void init_frame_pc (); */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* FRAME_CHAIN takes a FRAME */
-/* OBSOLETE    and produces the frame's chain-pointer. */
-/* OBSOLETE  */
-/* OBSOLETE    However, if FRAME_CHAIN_VALID returns zero, */
-/* OBSOLETE    it means the given frame is the outermost one and has no caller.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* On the a29k, the nominal address of a frame is the address on the */
-/* OBSOLETE    register stack of the return address (the one next to the incoming */
-/* OBSOLETE    arguments, not down at the bottom so nominal address == stack pointer). */
-/* OBSOLETE  */
-/* OBSOLETE    GDB expects "nominal address" to equal contents of FP_REGNUM, */
-/* OBSOLETE    at least when it comes time to create the innermost frame. */
-/* OBSOLETE    However, that doesn't work for us, so when creating the innermost */
-/* OBSOLETE    frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* These are mostly dummies for the a29k because INIT_FRAME_PC */
-/* OBSOLETE    sets prev->frame instead.  */ */
-/* OBSOLETE /* If rsize is zero, we must be at end of stack (or otherwise hosed). */
-/* OBSOLETE    If we don't check rsize, we loop forever if we see rsize == 0.  */ */
-/* OBSOLETE #define FRAME_CHAIN(thisframe) \ */
-/* OBSOLETE   ((thisframe)->rsize == 0 \ */
-/* OBSOLETE    ? 0 \ */
-/* OBSOLETE    : (thisframe)->frame + (thisframe)->rsize) */
-/* OBSOLETE  */
-/* OBSOLETE /* Determine if the frame has a 'previous' and back-traceable frame. */ */
-/* OBSOLETE #define FRAME_IS_UNCHAINED(frame)	((frame)->flags & TRANSPARENT_FRAME) */
-/* OBSOLETE  */
-/* OBSOLETE /* Find the previous frame of a transparent routine. */
-/* OBSOLETE  * For now lets not try and trace through a transparent routine (we might  */
-/* OBSOLETE  * have to assume that all transparent routines are traps). */
-/* OBSOLETE  */ */
-/* OBSOLETE #define FIND_PREV_UNCHAINED_FRAME(frame)	0 */
-/* OBSOLETE  */
-/* OBSOLETE /* Define other aspects of the stack frame.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* An expression that tells us whether the function invocation represented */
-/* OBSOLETE    by FI does not have a frame on the stack associated with it. */ */
-/* OBSOLETE #define FRAMELESS_FUNCTION_INVOCATION(FI) \ */
-/* OBSOLETE   (frameless_look_for_prologue (FI)) */
-/* OBSOLETE  */
-/* OBSOLETE /* Saved pc (i.e. return address).  */ */
-/* OBSOLETE #define FRAME_SAVED_PC(fraim) \ */
-/* OBSOLETE   (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4)) */
-/* OBSOLETE  */
-/* OBSOLETE /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their */
-/* OBSOLETE    offsets being relative to the memory stack pointer (high C) or */
-/* OBSOLETE    saved_msp (gcc).  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi) */
-/* OBSOLETE extern CORE_ADDR frame_locals_address (); */
-/* OBSOLETE  */
-/* OBSOLETE /* Return number of args passed to a frame. */
-/* OBSOLETE    Can return -1, meaning no way to tell.  */ */
-/* OBSOLETE /* We tried going to the effort of finding the tags word and getting */
-/* OBSOLETE    the argcount field from it, to support debugging assembler code. */
-/* OBSOLETE    Problem was, the "argcount" field never did hold the argument */
-/* OBSOLETE    count.  */ */
-/* OBSOLETE #define	FRAME_NUM_ARGS(fi) (-1) */
-/* OBSOLETE  */
-/* OBSOLETE #define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi) */
-/* OBSOLETE  */
-/* OBSOLETE /* Return number of bytes at start of arglist that are not really args.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define FRAME_ARGS_SKIP 0 */
-/* OBSOLETE  */
-/* OBSOLETE /* Provide our own get_saved_register.  HAVE_REGISTER_WINDOWS is insufficient */
-/* OBSOLETE    because registers get renumbered on the a29k without getting saved.  */ */
-/* OBSOLETE  */
-/* OBSOLETE struct frame_info; */
-/* OBSOLETE void a29k_get_saved_register (char *raw_buffer, int *optimized, */
-/* OBSOLETE 			      CORE_ADDR * addrp, struct frame_info *frame, */
-/* OBSOLETE 			      int regnum, enum lval_type *lvalp); */
-/* OBSOLETE #define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \ */
-/* OBSOLETE       a29k_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) */
-/* OBSOLETE  */
-/* OBSOLETE /* Call function stuff.  */ */
-/* OBSOLETE /* *INDENT-OFF* */ */
-/* OBSOLETE /* The dummy frame looks like this (see also the general frame picture */
-/* OBSOLETE    above): */
-/* OBSOLETE  */
-/* OBSOLETE 					register stack */
-/* OBSOLETE  */
-/* OBSOLETE 	                	      |                |  frame for function */
-/* OBSOLETE                	                      |   locals_sproc |  executing at time */
-/* OBSOLETE                                       |________________|  of call_function. */
-/* OBSOLETE                      		      |	               |  We must not disturb */
-/* OBSOLETE                      		      |	args_out_sproc |  it. */
-/* OBSOLETE         memory stack 		      |________________| */
-/* OBSOLETE                      		      |____lr1_sproc___|<-+ */
-/* OBSOLETE        |            |		      |__retaddr_sproc_|  | <-- gr1 (at start) */
-/* OBSOLETE        |____________|<-msp 0 <-----------mfp_dummy_____|  | */
-/* OBSOLETE        |            |  (at start)     |  save regs     |  | */
-/* OBSOLETE        | arg_slop   |		      |  pc0,pc1       |  | */
-/* OBSOLETE        |            |		      |  pc2,lr0 sproc |  | */
-/* OBSOLETE        | (16 words) |		      | gr96-gr124     |  | */
-/* OBSOLETE        |____________|<-msp 1--after   | sr160-sr162    |  | */
-/* OBSOLETE        |            | PUSH_DUMMY_FRAME| sr128-sr135    |  | */
-/* OBSOLETE        | struct ret |                 |________________|  | */
-/* OBSOLETE        | 17+        |                 |                |  |  */
-/* OBSOLETE        |____________|<- lrp           | args_out_dummy |  | */
-/* OBSOLETE        | struct ret |		      |  (16 words)    |  | */
-/* OBSOLETE        | 16         |		      |________________|  | */
-/* OBSOLETE        | (16 words) |                 |____lr1_dummy___|--+ */
-/* OBSOLETE        |____________|<- msp 2--after  |_retaddr_dummy__|<- gr1 after */
-/* OBSOLETE        |            | struct ret      |                |   PUSH_DUMMY_FRAME */
-/* OBSOLETE        | margs17+   | area allocated  |  locals_inf    | */
-/* OBSOLETE        |            |                 |________________|    called */
-/* OBSOLETE        |____________|<- msp 4--when   |                |    function's */
-/* OBSOLETE        |            |   inf called    | args_out_inf   |    frame (set up */
-/* OBSOLETE        | margs16    |                 |________________|    by called */
-/* OBSOLETE        | (16 words) |                 |_____lr1_inf____|    function). */
-/* OBSOLETE        |____________|<- msp 3--after  |       .        | */
-/* OBSOLETE        |            |   args pushed   |       .        | */
-/* OBSOLETE        |            |	              |       .        | */
-/* OBSOLETE                                       |                | */
-/* OBSOLETE  */
-/* OBSOLETE    arg_slop: This area is so that when the call dummy adds 16 words to */
-/* OBSOLETE       the msp, it won't end up larger than mfp_dummy (it is needed in the */
-/* OBSOLETE       case where margs and struct_ret do not add up to at least 16 words). */
-/* OBSOLETE    struct ret:  This area is allocated by GDB if the return value is more */
-/* OBSOLETE       than 16 words.  struct ret_16 is not used on the a29k. */
-/* OBSOLETE    margs:  Pushed by GDB.  The call dummy copies the first 16 words to */
-/* OBSOLETE       args_out_dummy. */
-/* OBSOLETE    retaddr_sproc:  Contains the PC at the time we call the function. */
-/* OBSOLETE       set by PUSH_DUMMY_FRAME and read by POP_FRAME. */
-/* OBSOLETE    retaddr_dummy:  This points to a breakpoint instruction in the dummy.  */ */
-/* OBSOLETE /* *INDENT-ON* */ */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Rsize for dummy frame, in bytes.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Bytes for outgoing args, lr1, and retaddr.  */ */
-/* OBSOLETE #define DUMMY_ARG (2 * 4 + 16 * 4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of special registers (sr128-) to save.  */ */
-/* OBSOLETE #define DUMMY_SAVE_SR128 8 */
-/* OBSOLETE /* Number of special registers (sr160-) to save.  */ */
-/* OBSOLETE #define DUMMY_SAVE_SR160 3 */
-/* OBSOLETE /* Number of general (gr96- or gr64-) registers to save.  */ */
-/* OBSOLETE #define DUMMY_SAVE_GREGS 29 */
-/* OBSOLETE  */
-/* OBSOLETE #define DUMMY_FRAME_RSIZE \ */
-/* OBSOLETE (4 /* mfp_dummy */     	  \ */
-/* OBSOLETE  + 4 * 4  /* pc0, pc1, pc2, lr0 */  \ */
-/* OBSOLETE  + DUMMY_SAVE_GREGS * 4   \ */
-/* OBSOLETE  + DUMMY_SAVE_SR160 * 4	  \ */
-/* OBSOLETE  + DUMMY_SAVE_SR128 * 4	  \ */
-/* OBSOLETE  + DUMMY_ARG		  \ */
-/* OBSOLETE  + 4 /* pad to doubleword */ ) */
-/* OBSOLETE  */
-/* OBSOLETE /* Push an empty stack frame, to record the current PC, etc.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define PUSH_DUMMY_FRAME push_dummy_frame() */
-/* OBSOLETE extern void push_dummy_frame (); */
-/* OBSOLETE  */
-/* OBSOLETE /* Discard from the stack the innermost frame, */
-/* OBSOLETE    restoring all saved registers.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define POP_FRAME pop_frame() */
-/* OBSOLETE extern void pop_frame (); */
-/* OBSOLETE  */
-/* OBSOLETE /* This sequence of words is the instructions */
-/* OBSOLETE    mtsrim cr, 15 */
-/* OBSOLETE    loadm 0, 0, lr2, msp     ; load first 16 words of arguments into registers */
-/* OBSOLETE    add msp, msp, 16 * 4     ; point to the remaining arguments */
-/* OBSOLETE    CONST_INSN: */
-/* OBSOLETE    const lr0,inf                ; (replaced by       half of target addr) */
-/* OBSOLETE    consth lr0,inf               ; (replaced by other half of target addr) */
-/* OBSOLETE    calli lr0, lr0  */
-/* OBSOLETE    aseq 0x40,gr1,gr1   ; nop */
-/* OBSOLETE    BREAKPT_INSN: */
-/* OBSOLETE    asneq 0x50,gr1,gr1  ; breakpoint     (replaced by local breakpoint insn) */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE #error "This file is broken.  GDB does not define HOST_BYTE_ORDER." */
-/* OBSOLETE #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER */
-/* OBSOLETE #define BS(const)	const */
-/* OBSOLETE #else */
-/* OBSOLETE #define	BS(const)	(((const) & 0xff) << 24) |	\ */
-/* OBSOLETE 			(((const) & 0xff00) << 8) |	\ */
-/* OBSOLETE 			(((const) & 0xff0000) >> 8) |	\ */
-/* OBSOLETE 			(((const) & 0xff000000) >> 24) */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /* Position of the "const" and blkt instructions within CALL_DUMMY in bytes. */ */
-/* OBSOLETE #define CONST_INSN (3 * 4) */
-/* OBSOLETE #define BREAKPT_INSN (7 * 4) */
-/* OBSOLETE #define CALL_DUMMY {	\ */
-/* OBSOLETE 		BS(0x0400870f),\ */
-/* OBSOLETE 		BS(0x36008200|(MSP_HW_REGNUM)), \ */
-/* OBSOLETE 		BS(0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16)), \ */
-/* OBSOLETE 		BS(0x03ff80ff),	\ */
-/* OBSOLETE 		BS(0x02ff80ff),	\ */
-/* OBSOLETE 		BS(0xc8008080),	\ */
-/* OBSOLETE 		BS(0x70400101),	\ */
-/* OBSOLETE 		BS(0x72500101)} */
-/* OBSOLETE #define CALL_DUMMY_LENGTH (8 * 4) */
-/* OBSOLETE  */
-/* OBSOLETE #define CALL_DUMMY_START_OFFSET 0	/* Start execution at beginning of dummy */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Helper macro for FIX_CALL_DUMMY.  WORDP is a long * which points to a */
-/* OBSOLETE    word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with */
-/* OBSOLETE    bits 0-7 and 8-15 of DATA (which is in host byte order).  */ */
-/* OBSOLETE  */
-/* OBSOLETE #if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG */
-/* OBSOLETE #define STUFF_I16(WORDP, DATA) \ */
-/* OBSOLETE   { \ */
-/* OBSOLETE     *((char *)(WORDP) + 3) = ((DATA) & 0xff);\ */
-/* OBSOLETE     *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\ */
-/* OBSOLETE   } */
-/* OBSOLETE #else /* Target is little endian.  */ */
-/* OBSOLETE #define STUFF_I16(WORDP, DATA) \ */
-/* OBSOLETE   { */
-/* OBSOLETE *(char *) (WORDP) = ((DATA) & 0xff); */
-/* OBSOLETE *((char *) (WORDP) + 2) = (((DATA) >> 8) & 0xff); */
-/* OBSOLETE } */
-/* OBSOLETE #endif /* Target is little endian.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Insert the specified number of args and function address */
-/* OBSOLETE    into a call sequence of the above form stored at DUMMYNAME.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Currently this stuffs in the address of the function that we are calling. */
-/* OBSOLETE    Since different a29k systems use different breakpoint instructions, it */
-/* OBSOLETE    also stuffs BREAKPOINT in the right place (to avoid having to */
-/* OBSOLETE    duplicate CALL_DUMMY in each tm-*.h file).  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \ */
-/* OBSOLETE   {\ */
-/* OBSOLETE     STUFF_I16((char *)dummyname + CONST_INSN, fun);		\ */
-/* OBSOLETE     STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);	\ */
-/* OBSOLETE   /* FIXME  memcpy ((char *)(dummyname) + BREAKPT_INSN, break_insn, 4); */ \ */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE /* a29k architecture has separate data & instruction memories -- wired to */
-/* OBSOLETE    different pins on the chip -- and can't execute the data memory. */
-/* OBSOLETE    Also, there should be space after text_end; */
-/* OBSOLETE    we won't get a SIGSEGV or scribble on data space.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define CALL_DUMMY_LOCATION AFTER_TEXT_END */
-/* OBSOLETE  */
-/* OBSOLETE /* Because of this, we need (as a kludge) to know the addresses of the */
-/* OBSOLETE    text section.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define	NEED_TEXT_START_END 1 */
-/* OBSOLETE  */
-/* OBSOLETE /* How to translate register numbers in the .stab's into gdb's internal register */
-/* OBSOLETE    numbers.  We don't translate them, but we warn if an invalid register */
-/* OBSOLETE    number is seen.  Note that FIXME, we use the value "sym" as an implicit */
-/* OBSOLETE    argument in printing the error message.  It happens to be available where */
-/* OBSOLETE    this macro is used.  (This macro definition appeared in a late revision */
-/* OBSOLETE    of gdb-3.91.6 and is not well tested.  Also, it should be a "complaint".) */ */
-/* OBSOLETE  */
-/* OBSOLETE #define	STAB_REG_TO_REGNUM(num) \ */
-/* OBSOLETE 	(((num) > LR0_REGNUM + 127) \ */
-/* OBSOLETE 	   ? fprintf(stderr, 	\ */
-/* OBSOLETE 		"Invalid register number %d in symbol table entry for %s\n", \ */
-/* OBSOLETE 	         (num), SYMBOL_SOURCE_NAME (sym)), (num)	\ */
-/* OBSOLETE 	   : (num)) */
-/* OBSOLETE  */
-/* OBSOLETE extern enum a29k_processor_types */
-/* OBSOLETE { */
-/* OBSOLETE   a29k_unknown, */
-/* OBSOLETE  */
-/* OBSOLETE   /* Bit 0x400 of the CPS does *not* identify freeze mode, i.e. 29000, */
-/* OBSOLETE      29030, etc.  */ */
-/* OBSOLETE   a29k_no_freeze_mode, */
-/* OBSOLETE  */
-/* OBSOLETE   /* Bit 0x400 of the CPS does identify freeze mode, i.e. 29050.  */ */
-/* OBSOLETE   a29k_freeze_mode */
-/* OBSOLETE } */
-/* OBSOLETE processor_type; */
-/* OBSOLETE  */
-/* OBSOLETE /* We need three arguments for a general frame specification for the */
-/* OBSOLETE    "frame" or "info frame" command.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv) */
-/* OBSOLETE extern struct frame_info *setup_arbitrary_frame (int, CORE_ADDR *); */
diff --git a/gdb/config/a29k/tm-vx29k.h b/gdb/config/a29k/tm-vx29k.h
deleted file mode 100644
index 40c6689..0000000
--- a/gdb/config/a29k/tm-vx29k.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/* OBSOLETE /* Target machine description for VxWorks on the 29k, for GDB, the GNU debugger. */
-/* OBSOLETE    Copyright 1994, 1995, 1998, 1999, 2000 Free Software Foundation, Inc. */
-/* OBSOLETE    Contributed by Cygnus Support. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE #include "value.h" */
-/* OBSOLETE #include "a29k/tm-a29k.h" */
-/* OBSOLETE #include "tm-vxworks.h" */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of registers in a ptrace_getregs call. */ */
-/* OBSOLETE  */
-/* OBSOLETE #define VX_NUM_REGS (NUM_REGS) */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of registers in a ptrace_getfpregs call. */ */
-/* OBSOLETE  */
-/* OBSOLETE /* #define VX_SIZE_FPREGS */ */
-/* OBSOLETE  */
-/* OBSOLETE /* This is almost certainly the wrong place for this: */ */
-/* OBSOLETE #define LR2_REGNUM 34 */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Vxworks has its own CALL_DUMMY since it manages breakpoints in the kernel */ */
-/* OBSOLETE  */
-/* OBSOLETE #undef CALL_DUMMY */
-/* OBSOLETE  */
-/* OBSOLETE /* Replace the breakpoint instruction in the CALL_DUMMY with a nop. */
-/* OBSOLETE    For Vxworks, the breakpoint is set and deleted by calls to */
-/* OBSOLETE    CALL_DUMMY_BREAK_SET and CALL_DUMMY_BREAK_DELETE.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #error "This file is broken.  GDB does not define HOST_BYTE_ORDER." */
-/* OBSOLETE #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER */
-/* OBSOLETE #define CALL_DUMMY {0x0400870f,\ */
-/* OBSOLETE 		0x36008200|(MSP_HW_REGNUM), \ */
-/* OBSOLETE 		0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \ */
-/* OBSOLETE 		0x03ff80ff, 0x02ff80ff, 0xc8008080, 0x70400101, 0x70400101} */
-/* OBSOLETE #else /* Byte order differs.  */ */
-/* OBSOLETE #define CALL_DUMMY {0x0f870004,\ */
-/* OBSOLETE 		0x00820036|(MSP_HW_REGNUM << 24), \ */
-/* OBSOLETE 		0x40000015|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \ */
-/* OBSOLETE 		0xff80ff03, 0xff80ff02, 0x808000c8, 0x01014070, 0x01014070} */
-/* OBSOLETE #endif /* Byte order differs.  */ */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* For the basic CALL_DUMMY definitions, see "tm-29k.h."  We use the */
-/* OBSOLETE    same CALL_DUMMY code, but define FIX_CALL_DUMMY (and related macros) */
-/* OBSOLETE    locally to handle remote debugging of VxWorks targets.  The difference */
-/* OBSOLETE    is in the setting and clearing of the breakpoint at the end of the */
-/* OBSOLETE    CALL_DUMMY code fragment; under VxWorks, we can't simply insert a */
-/* OBSOLETE    breakpoint instruction into the code, since that would interfere with */
-/* OBSOLETE    the breakpoint management mechanism on the target. */
-/* OBSOLETE    Note that CALL_DUMMY is a piece of code that is used to call any C function */
-/* OBSOLETE    thru VxGDB */ */
-/* OBSOLETE  */
-/* OBSOLETE /* The offset of the instruction within the CALL_DUMMY code where we */
-/* OBSOLETE    want the inferior to stop after the function call has completed. */
-/* OBSOLETE    call_function_by_hand () sets a breakpoint here (via CALL_DUMMY_BREAK_SET), */
-/* OBSOLETE    which POP_FRAME later deletes (via CALL_DUMMY_BREAK_DELETE).  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define CALL_DUMMY_STOP_OFFSET (7 * 4) */
-/* OBSOLETE  */
-/* OBSOLETE /* The offset of the first instruction of the CALL_DUMMY code fragment */
-/* OBSOLETE    relative to the frame pointer for a dummy frame.  This is equal to */
-/* OBSOLETE    the size of the CALL_DUMMY plus the arg_slop area size (see the diagram */
-/* OBSOLETE    in "tm-29k.h").  */ */
-/* OBSOLETE /* PAD : the arg_slop area size doesn't appear to me to be useful since, the */
-/* OBSOLETE    call dummy code no longer modify the msp. See below. This must be checked. */ */
-/* OBSOLETE  */
-/* OBSOLETE #define CALL_DUMMY_OFFSET_IN_FRAME (CALL_DUMMY_LENGTH + 16 * 4) */
-/* OBSOLETE  */
-/* OBSOLETE /* Insert the specified number of args and function address */
-/* OBSOLETE    into a CALL_DUMMY sequence stored at DUMMYNAME, replace the third */
-/* OBSOLETE    instruction (add msp, msp, 16*4) with a nop, and leave the final nop. */
-/* OBSOLETE    We can't keep using a CALL_DUMMY that modify the msp since, for VxWorks, */
-/* OBSOLETE    CALL_DUMMY is stored in the Memory Stack. Adding 16 words to the msp */
-/* OBSOLETE    would then make possible for the inferior to overwrite the CALL_DUMMY code, */
-/* OBSOLETE    thus creating a lot of trouble when exiting the inferior to come back in */
-/* OBSOLETE    a CALL_DUMMY code that no longer exists... Furthermore, ESF are also stored */
-/* OBSOLETE    from the msp in the memory stack. If msp is set higher than the dummy code, */
-/* OBSOLETE    an ESF may clobber this code. */ */
-/* OBSOLETE  */
-/* OBSOLETE #if TARGET_BYTE_ORDER == BFD_ENDIAN_BIG */
-/* OBSOLETE #define NOP_INSTR  0x70400101 */
-/* OBSOLETE #else /* Target is little endian */ */
-/* OBSOLETE #define NOP_INSTR  0x01014070 */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #undef FIX_CALL_DUMMY */
-/* OBSOLETE #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)  \ */
-/* OBSOLETE   {                                                                   \ */
-/* OBSOLETE     *(int *)((char *)dummyname + 8) = NOP_INSTR;                      \ */
-/* OBSOLETE     STUFF_I16((char *)dummyname + CONST_INSN, fun);                   \ */
-/* OBSOLETE     STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);         \ */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE /* For VxWorks, CALL_DUMMY must be stored in the stack of the task that is */
-/* OBSOLETE    being debugged and executed "in the context of" this task */ */
-/* OBSOLETE  */
-/* OBSOLETE #undef CALL_DUMMY_LOCATION */
-/* OBSOLETE #define CALL_DUMMY_LOCATION     ON_STACK */
-/* OBSOLETE  */
-/* OBSOLETE /* Set or delete a breakpoint at the location within a CALL_DUMMY code */
-/* OBSOLETE    fragment where we want the target program to stop after the function */
-/* OBSOLETE    call is complete.  CALL_DUMMY_ADDR is the address of the first */
-/* OBSOLETE    instruction in the CALL_DUMMY.  DUMMY_FRAME_ADDR is the value of the */
-/* OBSOLETE    frame pointer in the dummy frame. */
-/* OBSOLETE  */
-/* OBSOLETE    NOTE: in the both of the following definitions, we take advantage of */
-/* OBSOLETE    knowledge of the implementation of the target breakpoint operation, */
-/* OBSOLETE    in that we pass a null pointer as the second argument.  It seems */
-/* OBSOLETE    reasonable to assume that any target requiring the use of  */
-/* OBSOLETE    CALL_DUMMY_BREAK_{SET,DELETE} will not store the breakpoint */
-/* OBSOLETE    shadow contents in GDB; in any case, this assumption is vaild */
-/* OBSOLETE    for all VxWorks-related targets.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define CALL_DUMMY_BREAK_SET(call_dummy_addr) \ */
-/* OBSOLETE   target_insert_breakpoint ((call_dummy_addr) + CALL_DUMMY_STOP_OFFSET, \ */
-/* OBSOLETE 			    (char *) 0) */
-/* OBSOLETE  */
-/* OBSOLETE #define CALL_DUMMY_BREAK_DELETE(dummy_frame_addr) \ */
-/* OBSOLETE   target_remove_breakpoint ((dummy_frame_addr) - (CALL_DUMMY_OFFSET_IN_FRAME \ */
-/* OBSOLETE 				                  - CALL_DUMMY_STOP_OFFSET), \ */
-/* OBSOLETE 			    (char *) 0) */
-/* OBSOLETE  */
-/* OBSOLETE /* Return nonzero if the pc is executing within a CALL_DUMMY frame.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ */
-/* OBSOLETE   ((pc) >= (sp) \ */
-/* OBSOLETE     && (pc) <= (sp) + CALL_DUMMY_OFFSET_IN_FRAME + CALL_DUMMY_LENGTH) */
-/* OBSOLETE  */
-/* OBSOLETE /* Defining this prevents us from trying to pass a structure-valued argument */
-/* OBSOLETE    to a function called via the CALL_DUMMY mechanism.  This is not handled */
-/* OBSOLETE    properly in call_function_by_hand (), and the fix might require re-writing */
-/* OBSOLETE    the CALL_DUMMY handling for all targets (at least, a clean solution */
-/* OBSOLETE    would probably require this).  Arguably, this should go in "tm-29k.h" */
-/* OBSOLETE    rather than here.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define STRUCT_VAL_ARGS_UNSUPPORTED */
-/* OBSOLETE  */
-/* OBSOLETE #define BKPT_OFFSET	(7 * 4) */
-/* OBSOLETE #define BKPT_INSTR	0x72500101 */
-/* OBSOLETE  */
-/* OBSOLETE #undef FIX_CALL_DUMMY */
-/* OBSOLETE #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \ */
-/* OBSOLETE   {\ */
-/* OBSOLETE     STUFF_I16((char *)dummyname + CONST_INSN, fun);\ */
-/* OBSOLETE     STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);\ */
-/* OBSOLETE     *(int *)((char *)dummyname + BKPT_OFFSET) = BKPT_INSTR;\ */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Offsets into jmp_buf.  They are derived from VxWorks' REG_SET struct */
-/* OBSOLETE    (see VxWorks' setjmp.h). Note that Sun2, Sun3 and SunOS4 and VxWorks have */
-/* OBSOLETE    different REG_SET structs, hence different layouts for the jmp_buf struct. */
-/* OBSOLETE    Only JB_PC is needed for getting the saved PC value.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define JB_ELEMENT_SIZE 4	/* size of each element in jmp_buf */ */
-/* OBSOLETE #define JB_PC		3	/* offset of pc (pc1) in jmp_buf */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Figure out where the longjmp will land.  We expect that we have just entered */
-/* OBSOLETE    longjmp and haven't yet setup the stack frame, so the args are still in the */
-/* OBSOLETE    output regs.  lr2 (LR2_REGNUM) points at the jmp_buf structure from which we */
-/* OBSOLETE    extract the pc (JB_PC) that we will land at.  The pc is copied into ADDR. */
-/* OBSOLETE    This routine returns true on success */ */
-/* OBSOLETE  */
-/* OBSOLETE #define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) */
-/* OBSOLETE extern int get_longjmp_target (CORE_ADDR *); */
-/* OBSOLETE  */
-/* OBSOLETE /* VxWorks adjusts the PC after a breakpoint has been hit.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #undef DECR_PC_AFTER_BREAK */
-/* OBSOLETE #define DECR_PC_AFTER_BREAK 0 */
-/* OBSOLETE  */
-/* OBSOLETE /* Do whatever promotions are appropriate on a value being returned */
-/* OBSOLETE    from a function.  VAL is the user-supplied value, and FUNC_TYPE */
-/* OBSOLETE    is the return type of the function if known, else 0. */
-/* OBSOLETE  */
-/* OBSOLETE    For the Am29k, as far as I understand, if the function return type is known, */
-/* OBSOLETE    cast the value to that type; otherwise, ensure that integer return values */
-/* OBSOLETE    fill all of gr96. */
-/* OBSOLETE  */
-/* OBSOLETE    This definition really belongs in "tm-29k.h", since it applies */
-/* OBSOLETE    to most Am29K-based systems; but once moved into that file, it might */
-/* OBSOLETE    need to be redefined for all Am29K-based targets that also redefine */
-/* OBSOLETE    STORE_RETURN_VALUE.  For now, to be safe, we define it here.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #define PROMOTE_RETURN_VALUE(val, func_type) \ */
-/* OBSOLETE   do {                                                                  \ */
-/* OBSOLETE       if (func_type)                                                    \ */
-/* OBSOLETE         val = value_cast (func_type, val);                              \ */
-/* OBSOLETE       if ((TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT                \ */
-/* OBSOLETE            || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ENUM)           \ */
-/* OBSOLETE           && TYPE_LENGTH (VALUE_TYPE (val)) < REGISTER_RAW_SIZE (0))    \ */
-/* OBSOLETE         val = value_cast (builtin_type_int, val);                       \ */
-/* OBSOLETE   } while (0) */
-/* OBSOLETE  */
-/* OBSOLETE extern int vx29k_frame_chain_valid (CORE_ADDR, struct frame_info *); */
-/* OBSOLETE #define FRAME_CHAIN_VALID(chain, thisframe) vx29k_frame_chain_valid (chain, thisframe) */
-/* OBSOLETE  */
-/* OBSOLETE extern CORE_ADDR frame_saved_call_site (); */
-/* OBSOLETE  */
-/* OBSOLETE #undef PREPARE_TO_INIT_FRAME_INFO */
-/* OBSOLETE #define PREPARE_TO_INIT_FRAME_INFO(fci)	do {				      \ */
-/* OBSOLETE   long current_msp = read_register (MSP_REGNUM);			      \ */
-/* OBSOLETE   if (PC_IN_CALL_DUMMY (fci->pc, current_msp, 0))			      \ */
-/* OBSOLETE     {									      \ */
-/* OBSOLETE       fci->rsize = DUMMY_FRAME_RSIZE;					      \ */
-/* OBSOLETE       fci->msize = 0;							      \ */
-/* OBSOLETE       fci->saved_msp =	 						      \ */
-/* OBSOLETE 	read_register_stack_integer (fci->frame + DUMMY_FRAME_RSIZE - 4, 4);  \ */
-/* OBSOLETE       fci->flags |= (TRANSPARENT|MFP_USED);				      \ */
-/* OBSOLETE       return;								      \ */
-/* OBSOLETE     }									      \ */
-/* OBSOLETE   } while (0) */
diff --git a/gdb/config/a29k/vx29k.mt b/gdb/config/a29k/vx29k.mt
deleted file mode 100644
index 95a169e..0000000
--- a/gdb/config/a29k/vx29k.mt
+++ /dev/null
@@ -1,4 +0,0 @@
-# OBSOLETE # Target: AMD 29k running VxWorks
-# OBSOLETE TDEPFILES= a29k-tdep.o remote-vx.o remote-vx29k.o xdr_ld.o xdr_ptrace.o xdr_rdb.o 
-# OBSOLETE TM_FILE= tm-vx29k.h
-# OBSOLETE MT_CFLAGS = -DNO_HIF_SUPPORT
diff --git a/gdb/config/alpha/alpha-linux.mt b/gdb/config/alpha/alpha-linux.mt
index dd1c8e2..25538b3 100644
--- a/gdb/config/alpha/alpha-linux.mt
+++ b/gdb/config/alpha/alpha-linux.mt
@@ -1,3 +1,3 @@
 # Target: Little-endian Alpha
-TDEPFILES= alpha-tdep.o solib.o solib-svr4.o solib-legacy.o
+TDEPFILES= alpha-tdep.o alpha-linux-tdep.o solib.o solib-svr4.o solib-legacy.o
 TM_FILE= tm-alphalinux.h
diff --git a/gdb/config/alpha/alpha-osf1.mt b/gdb/config/alpha/alpha-osf1.mt
index 98f87c1..29212c9 100644
--- a/gdb/config/alpha/alpha-osf1.mt
+++ b/gdb/config/alpha/alpha-osf1.mt
@@ -1,3 +1,3 @@
 # Target: Little-endian Alpha
-TDEPFILES= alpha-tdep.o
+TDEPFILES= alpha-tdep.o alpha-osf1-tdep.o
 TM_FILE= tm-alpha.h
diff --git a/gdb/config/alpha/nbsd.mh b/gdb/config/alpha/nbsd.mh
new file mode 100644
index 0000000..4d7664b
--- /dev/null
+++ b/gdb/config/alpha/nbsd.mh
@@ -0,0 +1,4 @@
+# Host: Alpha running NetBSD
+NAT_CLIBS=
+NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o alphabsd-nat.o alphanbsd-nat.o
+NAT_FILE= nm-nbsd.h
diff --git a/gdb/config/alpha/nbsd.mt b/gdb/config/alpha/nbsd.mt
new file mode 100644
index 0000000..f3a2ff1
--- /dev/null
+++ b/gdb/config/alpha/nbsd.mt
@@ -0,0 +1,3 @@
+# Target: Alpha running NetBSD
+TDEPFILES= alpha-tdep.o alphanbsd-tdep.o solib.o solib-svr4.o
+TM_FILE= tm-nbsd.h
diff --git a/gdb/config/alpha/nm-linux.h b/gdb/config/alpha/nm-linux.h
index 5d5e945..c59b88c 100644
--- a/gdb/config/alpha/nm-linux.h
+++ b/gdb/config/alpha/nm-linux.h
@@ -25,15 +25,6 @@
 
 #include "nm-linux.h"
 
-/* Figure out where the longjmp will land.  We expect that we have just entered
-   longjmp and haven't yet setup the stack frame, so the args are still in the
-   argument regs.  A0_REGNUM points at the jmp_buf structure from which we
-   extract the pc (JB_PC) that we will land at.  The pc is copied into ADDR.
-   This routine returns true on success */
-
-#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
-extern int get_longjmp_target (CORE_ADDR *);
-
 /* ptrace register ``addresses'' are absolute.  */
 
 #define U_REGS_OFFSET 0
@@ -50,10 +41,6 @@
 
 #define CANNOT_STEP_BREAKPOINT
 
-/* GNU/Linux has shared libraries.  */
-
-#define GDB_TARGET_HAS_SHARED_LIBS
-
 /* Given a pointer to either a gregset_t or fpregset_t, return a
    pointer to the first register.  */
 #define ALPHA_REGSET_BASE(regsetp)  ((long *) (regsetp))
diff --git a/gdb/config/alpha/nm-nbsd.h b/gdb/config/alpha/nm-nbsd.h
new file mode 100644
index 0000000..ef6ab31
--- /dev/null
+++ b/gdb/config/alpha/nm-nbsd.h
@@ -0,0 +1,33 @@
+/* Native-dependent definitions for Alpha running NetBSD, for GDB.
+   Copyright 2002 Free Software Foundation, Inc.
+   Contributed by Wasabi Systems, Inc.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef NM_NBSD_H
+#define NM_NBSD_H
+
+#define SVR4_SHARED_LIBS
+
+/* Get generic NetBSD native definitions.  */
+#include "config/nm-nbsd.h"
+
+/* The Alpha does not step over a breakpoint.  */
+#define CANNOT_STEP_BREAKPOINT
+
+#endif /* NM_NBSD_H */
diff --git a/gdb/config/alpha/nm-osf.h b/gdb/config/alpha/nm-osf.h
index 5fc99e4..20b5ae4 100644
--- a/gdb/config/alpha/nm-osf.h
+++ b/gdb/config/alpha/nm-osf.h
@@ -18,15 +18,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* Figure out where the longjmp will land.  We expect that we have just entered
-   longjmp and haven't yet setup the stack frame, so the args are still in the
-   argument regs.  A0_REGNUM points at the jmp_buf structure from which we
-   extract the pc (JB_PC) that we will land at.  The pc is copied into ADDR.
-   This routine returns true on success */
-
-#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
-extern int get_longjmp_target (CORE_ADDR *);
-
 /* ptrace register ``addresses'' are absolute.  */
 
 #define U_REGS_OFFSET 0
@@ -43,10 +34,6 @@
 
 #define CANNOT_STEP_BREAKPOINT
 
-/* OSF/1 has shared libraries.  */
-
-#define GDB_TARGET_HAS_SHARED_LIBS
-
 /* Support for shared libraries.  */
 
 #include "solib.h"
diff --git a/gdb/config/alpha/tm-alpha.h b/gdb/config/alpha/tm-alpha.h
index 58412d0..feb752a 100644
--- a/gdb/config/alpha/tm-alpha.h
+++ b/gdb/config/alpha/tm-alpha.h
@@ -24,353 +24,28 @@
 #ifndef TM_ALPHA_H
 #define TM_ALPHA_H
 
-#include "regcache.h"
+#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PARTIAL
+
 #include "bfd.h"
 #include "coff/sym.h"		/* Needed for PDR below.  */
 #include "coff/symconst.h"
 
 struct frame_info;
-struct type;
-struct value;
 struct symbol;
 
-/* Redefine some target bit sizes from the default.  */
-
-#define TARGET_LONG_BIT 64
-#define TARGET_LONG_LONG_BIT 64
-#define TARGET_PTR_BIT 64
-
-/* Number of traps that happen between exec'ing the shell 
- * to run an inferior, and when we finally get to 
- * the inferior code.  This is 2 on most implementations.
- */
+/* Number of traps that happen between exec'ing the shell
+   to run an inferior, and when we finally get to
+   the inferior code.  This is 2 on most implementations.  */
 #define START_INFERIOR_TRAPS_EXPECTED 3
 
-/* Offset from address of function to start of its code.
-   Zero on most machines.  */
-
-#define FUNCTION_START_OFFSET 0
-
-/* Advance PC across any function entry prologue instructions
-   to reach some "real" code.  */
-
-#define SKIP_PROLOGUE(pc) alpha_skip_prologue((pc))
-extern CORE_ADDR alpha_skip_prologue (CORE_ADDR addr);
-
-/* Immediately after a function call, return the saved pc.
-   Can't always go through the frames for this because on some machines
-   the new frame is not set up until the new function executes
-   some instructions.  */
-
-#define SAVED_PC_AFTER_CALL(frame) alpha_saved_pc_after_call(frame)
-extern CORE_ADDR alpha_saved_pc_after_call (struct frame_info *);
-
-/* Are we currently handling a signal ?  */
-
-#define IN_SIGTRAMP(pc, name) alpha_osf_in_sigtramp ((pc), (name))
-extern int alpha_osf_in_sigtramp (CORE_ADDR, char *);
-
-/* Stack grows downward.  */
-
-#define INNER_THAN(lhs,rhs) core_addr_lessthan ((lhs), (rhs))
-
-#define BREAKPOINT {0x80, 0, 0, 0}	/* call_pal bpt */
-
-/* Amount PC must be decremented by after a breakpoint.
-   This is often the number of bytes in BREAKPOINT
-   but not always.  */
-
-#ifndef DECR_PC_AFTER_BREAK
-#define DECR_PC_AFTER_BREAK 4
-#endif
-
-/* Say how long (ordinary) registers are.  This is a piece of bogosity
-   used in push_word and a few other places; REGISTER_RAW_SIZE is the
-   real way to know how big a register is.  */
-
-#define REGISTER_SIZE 8
-
-/* Number of machine registers */
-
-#define NUM_REGS 66
-
-
-/* Return the name of register REGNO.  */
-
-#define REGISTER_NAME(regno) alpha_register_name ((regno))
-extern char *alpha_register_name (int);
-
-
-/* Register numbers of various important registers.
-   Note that most of these values are "real" register numbers,
-   and correspond to the general registers of the machine,
-   and FP_REGNUM is a "phony" register number which is too large
-   to be an actual register number as far as the user is concerned
-   but serves to get the desired value when passed to read_register.  */
-
-#define V0_REGNUM 0		/* Function integer return value */
-#define T7_REGNUM 8		/* Return address register for OSF/1 __add* */
-#define GCC_FP_REGNUM 15	/* Used by gcc as frame register */
-#define A0_REGNUM 16		/* Loc of first arg during a subr call */
-#define T9_REGNUM 23		/* Return address register for OSF/1 __div* */
-#define T12_REGNUM 27		/* Contains start addr of current proc */
-#define SP_REGNUM 30		/* Contains address of top of stack */
-#define RA_REGNUM 26		/* Contains return address value */
-#define ZERO_REGNUM 31		/* Read-only register, always 0 */
-#define FP0_REGNUM 32		/* Floating point register 0 */
-#define FPA0_REGNUM 48		/* First float arg during a subr call */
-#define FPCR_REGNUM 63		/* Floating point control register */
-#define PC_REGNUM 64		/* Contains program counter */
-#define FP_REGNUM 65		/* Virtual frame pointer */
-
-#define CANNOT_FETCH_REGISTER(regno) \
-  alpha_cannot_fetch_register ((regno))
-extern int alpha_cannot_fetch_register (int);
-
-#define CANNOT_STORE_REGISTER(regno) \
-  alpha_cannot_store_register ((regno))
-extern int alpha_cannot_store_register (int);
-
-/* Total amount of space needed to store our copies of the machine's
-   register state, the array `registers'.  */
-#define REGISTER_BYTES (NUM_REGS * 8)
-
-/* Index within `registers' of the first byte of the space for
-   register N.  */
-
-#define REGISTER_BYTE(N) alpha_register_byte ((N))
-extern int alpha_register_byte (int);
-
-/* Number of bytes of storage in the actual machine representation
-   for register N.  On Alphas, all regs are 8 bytes.  */
-
-#define REGISTER_RAW_SIZE(N) alpha_register_raw_size ((N))
-extern int alpha_register_raw_size (int);
-
-/* Number of bytes of storage in the program's representation
-   for register N.  On Alphas, all regs are 8 bytes.  */
-
-#define REGISTER_VIRTUAL_SIZE(N) alpha_register_virtual_size ((N))
-extern int alpha_register_virtual_size (int);
-
-/* Largest value REGISTER_RAW_SIZE can have.  */
-
-#define MAX_REGISTER_RAW_SIZE 8
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
-
-#define MAX_REGISTER_VIRTUAL_SIZE 8
-
-/* Nonzero if register N requires conversion
-   from raw format to virtual format.
-   The alpha needs a conversion between register and memory format if
-   the register is a floating point register and
-   memory format is float, as the register format must be double
-   or
-   memory format is an integer with 4 bytes or less, as the representation
-   of integers in floating point registers is different. */
-
-#define REGISTER_CONVERTIBLE(N) alpha_register_convertible ((N))
-extern int alpha_register_convertible (int);
-
-/* Convert data from raw format for register REGNUM in buffer FROM
-   to virtual format with type TYPE in buffer TO.  */
-
-#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM, TYPE, FROM, TO) \
-  alpha_register_convert_to_virtual (REGNUM, TYPE, FROM, TO)
-extern void
-alpha_register_convert_to_virtual (int, struct type *, char *, char *);
-
-/* Convert data from virtual format with type TYPE in buffer FROM
-   to raw format for register REGNUM in buffer TO.  */
-
-#define REGISTER_CONVERT_TO_RAW(TYPE, REGNUM, FROM, TO)	\
-  alpha_register_convert_to_raw (TYPE, REGNUM, FROM, TO)
-extern void
-alpha_register_convert_to_raw (struct type *, int, char *, char *);
-
-/* Return the GDB type object for the "standard" data type
-   of data in register N.  */
-
-#define REGISTER_VIRTUAL_TYPE(N) alpha_register_virtual_type ((N))
-extern struct type * alpha_register_virtual_type (int);
-
-/* Store the address of the place in which to copy the structure the
-   subroutine will return.  Handled by alpha_push_arguments.  */
-
-#define STORE_STRUCT_RETURN(addr, sp) \
-  alpha_store_struct_return ((addr), (sp))
-extern void alpha_store_struct_return (CORE_ADDR, CORE_ADDR);
-/**/
-
-/* Extract from an array REGBUF containing the (raw) register state
-   a function return value of type TYPE, and copy that, in virtual format,
-   into VALBUF.  */
-
-#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
-  alpha_extract_return_value(TYPE, REGBUF, VALBUF)
-extern void alpha_extract_return_value (struct type *, char *, char *);
-
-/* Write into appropriate registers a function return value
-   of type TYPE, given in virtual format.  */
-
-#define STORE_RETURN_VALUE(TYPE,VALBUF) \
-  alpha_store_return_value(TYPE, VALBUF)
-extern void alpha_store_return_value (struct type *, char *);
-
-/* Extract from an array REGBUF containing the (raw) register state
-   the address in which a function should return its structure value,
-   as a CORE_ADDR (or an expression that can be used as one).  */
-/* The address is passed in a0 upon entry to the function, but when
-   the function exits, the compiler has copied the value to v0.  This
-   convention is specified by the System V ABI, so I think we can rely
-   on it.  */
-
-#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
-  alpha_extract_struct_value_address (REGBUF)
-extern CORE_ADDR alpha_extract_struct_value_address (char *);
-
-/* Structures are returned by ref in extra arg0 */
-#define USE_STRUCT_CONVENTION(gcc_p, type) \
-  alpha_use_struct_convention ((gcc_p), (type))
-extern int alpha_use_struct_convention (int, struct type *);
-
-
-/* Describe the pointer in each stack frame to the previous stack frame
-   (its caller).  */
-
-/* FRAME_CHAIN takes a frame's nominal address
-   and produces the frame's chain-pointer. */
-
-#define FRAME_CHAIN(thisframe) alpha_frame_chain (thisframe)
-extern CORE_ADDR alpha_frame_chain (struct frame_info *);
-
-/* Define other aspects of the stack frame.  */
-
-
-/* An expression that tells us whether the function invocation represented
-   by FI does not have a frame on the stack associated with it. */
-/* We handle this differently for alpha, and maybe we should not */
-
-#define FRAMELESS_FUNCTION_INVOCATION(FI) \
-  generic_frameless_function_invocation_not ((FI))
-
-/* Saved Pc.  */
-
-#define FRAME_SAVED_PC(FRAME) alpha_frame_saved_pc(FRAME)
-extern CORE_ADDR alpha_frame_saved_pc (struct frame_info *);
-
-/* The alpha has two different virtual pointers for arguments and locals.
-
-   The virtual argument pointer is pointing to the bottom of the argument
-   transfer area, which is located immediately below the virtual frame
-   pointer. Its size is fixed for the native compiler, it is either zero
-   (for the no arguments case) or large enough to hold all argument registers.
-   gcc uses a variable sized argument transfer area. As it has
-   to stay compatible with the native debugging tools it has to use the same
-   virtual argument pointer and adjust the argument offsets accordingly.
-
-   The virtual local pointer is localoff bytes below the virtual frame
-   pointer, the value of localoff is obtained from the PDR.  */
-
-#define ALPHA_NUM_ARG_REGS	6
-
-#define FRAME_ARGS_ADDRESS(fi) alpha_frame_args_address ((fi))
-extern CORE_ADDR alpha_frame_args_address (struct frame_info *);
-
-#define FRAME_LOCALS_ADDRESS(fi) alpha_frame_locals_address ((fi))
-extern CORE_ADDR alpha_frame_locals_address (struct frame_info *);
-
-/* Return number of args passed to a frame.
-   Can return -1, meaning no way to tell.  */
-
-#define FRAME_NUM_ARGS(fi) frame_num_args_unknown ((fi))
-
-/* Return number of bytes at start of arglist that are not really args.  */
-
-#define FRAME_ARGS_SKIP 0
-
-/* Put here the code to store, into a struct frame_saved_regs,
-   the addresses of the saved registers of frame described by FRAME_INFO.
-   This includes special registers such as pc and fp saved in special
-   ways in the stack frame.  sp is even more special:
-   the address we return for it IS the sp for the next frame.  */
-
-#define FRAME_INIT_SAVED_REGS(frame_info) \
-  alpha_frame_init_saved_regs (frame_info)
-extern void alpha_frame_init_saved_regs (struct frame_info *);
-
-
-/* Things needed for making the inferior call functions.  */
-
-#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
-  (alpha_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
-extern CORE_ADDR
-alpha_push_arguments (int, struct value **, CORE_ADDR, int, CORE_ADDR);
-
-/* Push an empty stack frame, to record the current PC, etc.  */
-
-#define PUSH_DUMMY_FRAME alpha_push_dummy_frame()
-extern void alpha_push_dummy_frame (void);
-
-/* Discard from the stack the innermost frame, restoring all registers.  */
-
-#define POP_FRAME alpha_pop_frame()
-extern void alpha_pop_frame (void);
-
-/* Alpha OSF/1 inhibits execution of code on the stack.
-   But there is no need for a dummy on the alpha. PUSH_ARGUMENTS
-   takes care of all argument handling and bp_call_dummy takes care
-   of stopping the dummy.  */
-
-#define CALL_DUMMY_LOCATION AT_ENTRY_POINT
-
-/* On the Alpha the call dummy code is never copied to user space,
-   stopping the user call is achieved via a bp_call_dummy breakpoint.
-   But we need a fake CALL_DUMMY definition to enable the proper
-   call_function_by_hand and to avoid zero length array warnings
-   in valops.c  */
-
-#define CALL_DUMMY_P (1)
-
-#define CALL_DUMMY_WORDS alpha_call_dummy_words
-extern LONGEST alpha_call_dummy_words[];
-
-#define SIZEOF_CALL_DUMMY_WORDS 0
-
-#define CALL_DUMMY_START_OFFSET (0)
-
-#define CALL_DUMMY_BREAKPOINT_OFFSET (0)
-
-#define CALL_DUMMY_ADDRESS() alpha_call_dummy_address()
-extern CORE_ADDR alpha_call_dummy_address (void);
-
-/* Insert the specified number of args and function address
-   into a call sequence of the above form stored at DUMMYNAME.
-   We only have to set RA_REGNUM to the dummy breakpoint address
-   and T12_REGNUM (the `procedure value register') to the function address.  */
-
-#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
-  alpha_fix_call_dummy ((dummyname), (pc), (fun), (nargs), (args), \
-			(type), (gcc_p))
-extern void alpha_fix_call_dummy (char *, CORE_ADDR, CORE_ADDR, int,
-                                  struct value **, struct type *, int);
-
-/* There's a mess in stack frame creation.  See comments in blockframe.c
-   near reference to INIT_FRAME_PC_FIRST.  */
-
-#define INIT_FRAME_PC(fromleaf, prev) init_frame_pc_noop ((fromleaf), (prev))
-
-#define INIT_FRAME_PC_FIRST(fromleaf, prev) \
-  alpha_init_frame_pc_first ((fromleaf), (prev))
-extern void alpha_init_frame_pc_first (int, struct frame_info *);
-
 /* Special symbol found in blocks associated with routines.  We can hang
    alpha_extra_func_info_t's off of this.  */
 
 #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
 extern void ecoff_relocate_efi (struct symbol *, CORE_ADDR);
 
+#define RA_REGNUM 26		/* XXXJRT needed by mdebugread.c */
+
 /* Specific information about a procedure.
    This overlays the ALPHA's PDR records, 
    alpharead.c (ab)uses this to save memory */
@@ -390,10 +65,6 @@
 #define mips_extra_func_info_t alpha_extra_func_info_t
 
 
-#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \
-  alpha_init_extra_frame_info(fromleaf, fci)
-extern void alpha_init_extra_frame_info (int, struct frame_info *);
-
 #define PRINT_EXTRA_FRAME_INFO(fi) alpha_print_extra_frame_info ((fi))
 extern void alpha_print_extra_frame_info (struct frame_info *);
 
@@ -408,64 +79,8 @@
    up so that the primary value is the SP, and the PC is used to disambiguate
    multiple functions with the same SP that are at different stack levels. */
 
-#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
-extern struct frame_info *setup_arbitrary_frame (int, CORE_ADDR *);
-
-/* This is used by heuristic_proc_start.  It should be shot it the head.  */
-#ifndef VM_MIN_ADDRESS
-#define VM_MIN_ADDRESS (CORE_ADDR)0x120000000
-#endif
-
-/* If PC is in a shared library trampoline code, return the PC
-   where the function itself actually starts.  If not, return 0.  */
-#define SKIP_TRAMPOLINE_CODE(pc)  find_solib_trampoline_target (pc)
-
-/* If the current gcc for for this target does not produce correct debugging
-   information for float parameters, both prototyped and unprototyped, then
-   define this macro.  This forces gdb to  always assume that floats are
-   passed as doubles and then converted in the callee.
-
-   For the alpha, it appears that the debug info marks the parameters as
-   floats regardless of whether the function is prototyped, but the actual
-   values are always passed in as doubles.  Thus by setting this to 1, both
-   types of calls will work. */
-
-#define COERCE_FLOAT_TO_DOUBLE(formal, actual) \
-  standard_coerce_float_to_double ((formal), (actual))
-
-/* Return TRUE if procedure descriptor PROC is a procedure descriptor
-   that refers to a dynamically generated sigtramp function.
-
-   OSF/1 doesn't use dynamic sigtramp functions, so this is always
-   FALSE.  */
-
-#define PROC_DESC_IS_DYN_SIGTRAMP(proc)	(0)
-#define SET_PROC_DESC_IS_DYN_SIGTRAMP(proc)
-
-/* If PC is inside a dynamically generated sigtramp function, return
-   how many bytes the program counter is beyond the start of that
-   function.  Otherwise, return a negative value.
-
-   OSF/1 doesn't use dynamic sigtramp functions, so this always
-   returns -1.  */
-
-#define DYNAMIC_SIGTRAMP_OFFSET(pc)	(-1)
-
-/* Translate a signal handler frame into the address of the sigcontext
-   structure.  */
-
-#define SIGCONTEXT_ADDR(frame) \
-  (read_memory_integer ((frame)->next ? frame->next->frame : frame->frame, 8))
-
-/* If FRAME refers to a sigtramp frame, return the address of the next
-   frame.  */
-
-#define FRAME_PAST_SIGTRAMP_FRAME(frame, pc) \
-  (alpha_osf_skip_sigtramp_frame (frame, pc))
-extern CORE_ADDR alpha_osf_skip_sigtramp_frame (struct frame_info *,
-						CORE_ADDR);
-
-/* Single step based on where the current instruction will take us.  */
-extern void alpha_software_single_step (enum target_signal, int);
+#define SETUP_ARBITRARY_FRAME(argc, argv) \
+  alpha_setup_arbitrary_frame (argc, argv)
+extern struct frame_info *alpha_setup_arbitrary_frame (int, CORE_ADDR *);
 
 #endif /* TM_ALPHA_H */
diff --git a/gdb/config/alpha/tm-alphalinux.h b/gdb/config/alpha/tm-alphalinux.h
index 23592aa..27ff457 100644
--- a/gdb/config/alpha/tm-alphalinux.h
+++ b/gdb/config/alpha/tm-alphalinux.h
@@ -27,14 +27,9 @@
 
 #include "alpha/tm-alpha.h"
 
-/* Are we currently handling a signal ?  */
-
-extern long alpha_linux_sigtramp_offset (CORE_ADDR);
-#undef IN_SIGTRAMP
-#define IN_SIGTRAMP(pc, name)	(alpha_linux_sigtramp_offset (pc) >= 0)
-
 /* Get start and end address of sigtramp handler.  */
 
+extern LONGEST alpha_linux_sigtramp_offset (CORE_ADDR);
 #define SIGTRAMP_START(pc)	(pc - alpha_linux_sigtramp_offset (pc))
 #define SIGTRAMP_END(pc)	(SIGTRAMP_START(pc) + 3*4)
 
@@ -42,42 +37,9 @@
 /* Number of traps that happen between exec'ing the shell to run an
    inferior, and when we finally get to the inferior code.  This is 2
    on GNU/Linux and most implementations.  */
-
 #undef START_INFERIOR_TRAPS_EXPECTED
 #define START_INFERIOR_TRAPS_EXPECTED 2
 
-/* Return TRUE if procedure descriptor PROC is a procedure descriptor
-   that refers to a dynamically generated sigtramp function.  */
-
-#undef PROC_DESC_IS_DYN_SIGTRAMP
-#define PROC_SIGTRAMP_MAGIC	0x0e0f0f0f
-#define PROC_DESC_IS_DYN_SIGTRAMP(proc) ((proc)->pdr.isym		\
-					 == PROC_SIGTRAMP_MAGIC)
-#undef SET_PROC_DESC_IS_DYN_SIGTRAMP
-#define SET_PROC_DESC_IS_DYN_SIGTRAMP(proc) ((proc)->pdr.isym		\
-					     = PROC_SIGTRAMP_MAGIC)
-
-/* If PC is inside a dynamically generated sigtramp function, return
-   how many bytes the program counter is beyond the start of that
-   function.  Otherwise, return a negative value.  */
-
-#undef DYNAMIC_SIGTRAMP_OFFSET
-#define DYNAMIC_SIGTRAMP_OFFSET(pc)	(alpha_linux_sigtramp_offset (pc))
-
-/* Translate a signal handler frame into the address of the sigcontext
-   structure.  */
-
-#undef SIGCONTEXT_ADDR
-#define SIGCONTEXT_ADDR(frame)			((frame)->frame - 0x298)
-
-/* If FRAME refers to a sigtramp frame, return the address of the next frame.
-
-   Under GNU/Linux, sigtramp handlers have dynamically generated
-   procedure descriptors that make this hack unnecessary.  */
-
-#undef FRAME_PAST_SIGTRAMP_FRAME
-#define FRAME_PAST_SIGTRAMP_FRAME(frame, pc)	(0)
-
 #include "tm-linux.h"
 
 #endif /* TM_LINUXALPHA_H */
diff --git a/gdb/config/alpha/tm-fbsd.h b/gdb/config/alpha/tm-fbsd.h
index 00d3c27..d1d5254 100644
--- a/gdb/config/alpha/tm-fbsd.h
+++ b/gdb/config/alpha/tm-fbsd.h
@@ -1,5 +1,5 @@
 /* Target-dependent definitions for FreeBSD/Alpha.
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -23,19 +23,6 @@
 
 #include "alpha/tm-alpha.h"
 
-/* FreeBSD uses the old gcc convention for struct returns.  */
-
-#undef USE_STRUCT_CONVENTION
-#define USE_STRUCT_CONVENTION(gcc_p, type) \
-  alphafbsd_use_struct_convention (gcc_p, type)
-
-/* FreeBSD doesn't mark the outermost frame.  While some FreeBSD/Alpha
-   releases include (a minimal amount of) debugging info in its
-   startup code (crt1.o), the safest thing is to consider the user
-   code entry point as the outermost frame.  */
-#define FRAME_CHAIN_VALID(chain, thisframe) \
-  func_frame_chain_valid(chain, thisframe)
-
 /* Number of traps that happen between exec'ing the shell to run an
    inferior, and when we finally get to the inferior code.  The
    default is right for FreeBSD.  */
diff --git a/gdb/config/alpha/tm-nbsd.h b/gdb/config/alpha/tm-nbsd.h
new file mode 100644
index 0000000..9e92656
--- /dev/null
+++ b/gdb/config/alpha/tm-nbsd.h
@@ -0,0 +1,32 @@
+/* Target-dependent definitions for NetBSD/Alpha.
+   Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef TM_NBSD_H
+#define TM_NBSD_H
+
+#include "alpha/tm-alpha.h"
+
+/* Number of traps that happen between exec'ing the shell to run an
+   inferior, and when we finally get to the inferior code.  The
+   default is right for NetBSD.  */
+
+#undef START_INFERIOR_TRAPS_EXPECTED
+
+#endif /* TM_NBSD_H */
diff --git a/gdb/config/arc/tm-arc.h b/gdb/config/arc/tm-arc.h
index cd94476..cbdcf41 100644
--- a/gdb/config/arc/tm-arc.h
+++ b/gdb/config/arc/tm-arc.h
@@ -29,15 +29,14 @@
 #define FUNCTION_START_OFFSET 0
 
 /* Advance PC across any function entry prologue instructions
-   to reach some "real" code.  SKIP_PROLOGUE_FRAMELESS_P advances
-   the PC past some of the prologue, but stops as soon as it
-   knows that the function has a frame.  Its result is equal
-   to its input PC if the function is frameless, unequal otherwise.  */
+   to reach some "real" code.  */
 
 #define SKIP_PROLOGUE(pc) (arc_skip_prologue (pc, 0))
-#define SKIP_PROLOGUE_FRAMELESS_P(pc) (arc_skip_prologue (pc, 1))
 extern CORE_ADDR arc_skip_prologue (CORE_ADDR, int);
 
+#define PROLOGUE_FRAMELESS_P(pc) arc_prologue_frameless_p(pc)
+extern int arc_prologue_frameless_p (CORE_ADDR);
+
 /* Sequence of bytes for breakpoint instruction.
    ??? The current value is "sr -1,[-1]" and is for the simulator only.
    The simulator watches for this and does the right thing.
diff --git a/gdb/config/avr/avr.mt b/gdb/config/avr/avr.mt
new file mode 100644
index 0000000..0354a42
--- /dev/null
+++ b/gdb/config/avr/avr.mt
@@ -0,0 +1,12 @@
+# Target: AVR
+TDEPFILES= avr-tdep.o
+
+#
+# There is no simulator provided with gdb (yet).
+#
+# See <http://savannah.gnu.org/projects/simulavr/> for the simulator
+# used during development of avr support for gdb.
+#
+# Simulator: AVR
+#SIM_OBS = remote-sim.o
+#SIM = ../sim/avr/libsim.a
diff --git a/gdb/config/djgpp/README b/gdb/config/djgpp/README
index 2427b64..805e1df 100644
--- a/gdb/config/djgpp/README
+++ b/gdb/config/djgpp/README
@@ -98,16 +98,17 @@
 3. How to build
    ------------
 
-The source distribution available from DJGPP archives is already
-configured for DJGPP v2.x, so if you only want to compile it, just
-invoke Make:
+If the source distribution available from DJGPP archives is already
+configured for DJGPP v2.x (if it is, you will find files named
+`Makefile' in each subdirectory), then just invoke Make:
 
 		make
 
-To build a package downloaded from a GNU FTP site, you will need o
-configure it first.  You will also need to configure it if you want to
-change the configuration options (e.g., compile without support for the
-GDBMI interface).  To configure GDB, type this command:
+To build a package that is not yet configured, or if you downloaded
+GDB from a GNU FTP site, you will need to configure it first.  You
+will also need to configure it if you want to change the configuration
+options (e.g., compile without support for the GDBMI interface).  To
+configure GDB, type this command:
 
 		sh ./gdb/config/djgpp/djconfig.sh
 
diff --git a/gdb/config/h8500/tm-h8500.h b/gdb/config/h8500/tm-h8500.h
index f326165..fae6704 100644
--- a/gdb/config/h8500/tm-h8500.h
+++ b/gdb/config/h8500/tm-h8500.h
@@ -275,7 +275,6 @@
 extern void h8500_write_sp (CORE_ADDR);
 
 extern CORE_ADDR h8500_read_fp (void);
-extern void h8500_write_fp (CORE_ADDR);
 
 extern CORE_ADDR h8500_read_pc (ptid_t);
 extern void h8500_write_pc (CORE_ADDR, ptid_t);
@@ -287,4 +286,3 @@
 #define TARGET_WRITE_PC(x,pid) h8500_write_pc(x,pid)
 
 #define TARGET_READ_FP() h8500_read_fp()
-#define TARGET_WRITE_FP(x) h8500_write_fp(x)
diff --git a/gdb/config/i386/fbsd.mh b/gdb/config/i386/fbsd.mh
index 364dfa6..4509b9c 100644
--- a/gdb/config/i386/fbsd.mh
+++ b/gdb/config/i386/fbsd.mh
@@ -4,4 +4,4 @@
 
 NAT_FILE= nm-fbsd.h
 # NOTE: Do not spread NATDEPFILES over several lines - it hurts BSD make.
-NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i386-nat.o i387-nat.o i386bsd-nat.o i386fbsd-nat.o
+NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i386-nat.o i387-nat.o i386bsd-nat.o i386fbsd-nat.o gcore.o fbsd-proc.o
diff --git a/gdb/config/i386/i386gnu.mh b/gdb/config/i386/i386gnu.mh
index 252b2e5..13feba5 100644
--- a/gdb/config/i386/i386gnu.mh
+++ b/gdb/config/i386/i386gnu.mh
@@ -1,5 +1,9 @@
 # Host: Intel 386 running the GNU Hurd
-NATDEPFILES= i386gnu-nat.o i387-nat.o gnu-nat.o fork-child.o solib.o solib-svr4.o solib-legacy.o corelow.o notify_S.o process_reply_S.o msg_reply_S.o msg_U.o exc_request_U.o exc_request_S.o
+NATDEPFILES= i386gnu-nat.o i387-nat.o gnu-nat.o corelow.o core-regset.o \
+	     fork-child.o solib.o solib-svr4.o solib-legacy.o \
+	     notify_S.o process_reply_S.o msg_reply_S.o \
+	     msg_U.o exc_request_U.o exc_request_S.o
+
 XM_FILE= xm-i386gnu.h
 NAT_FILE= nm-gnu.h
 MH_CFLAGS = -D_GNU_SOURCE
diff --git a/gdb/config/i386/i386lynx.mh b/gdb/config/i386/i386lynx.mh
index 0552b4d..edfb1b0 100644
--- a/gdb/config/i386/i386lynx.mh
+++ b/gdb/config/i386/i386lynx.mh
@@ -4,6 +4,3 @@
 
 NAT_FILE= nm-i386lynx.h
 NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o lynx-nat.o
-
-## OBSOLETE ## GDBSERVER_LIBS= -lbsd
-## OBSOLETE ## GDBSERVER_DEPFILES= low-lynx.o
diff --git a/gdb/config/i386/i386v42mp.mh b/gdb/config/i386/i386v42mp.mh
index 007a8bf..6479be3 100644
--- a/gdb/config/i386/i386v42mp.mh
+++ b/gdb/config/i386/i386v42mp.mh
@@ -14,5 +14,7 @@
 # continuation character (backslash) to extend a commented line.  As a
 # consequence, make considers subsequent tab-indented lines to be
 # some sort of error.
-NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o i387-nat.o solib.o solib-svr4.o solib-legacy.o procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o uw-thread.o
+NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o i387-nat.o \
+	gcore.o solib.o solib-svr4.o solib-legacy.o procfs.o proc-api.o \
+	proc-events.o proc-flags.o proc-why.o uw-thread.o
 
diff --git a/gdb/config/i386/nbsd.mt b/gdb/config/i386/nbsd.mt
index 8ab606e..b8fc668 100644
--- a/gdb/config/i386/nbsd.mt
+++ b/gdb/config/i386/nbsd.mt
@@ -1,5 +1,3 @@
 # Target: Intel 386 running NetBSD
 TDEPFILES= i386-tdep.o i387-tdep.o i386bsd-tdep.o i386nbsd-tdep.o
 TM_FILE= tm-nbsd.h
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-nbsd.o
diff --git a/gdb/config/i386/nbsdelf.mt b/gdb/config/i386/nbsdelf.mt
index ab173d3..1bccd32 100644
--- a/gdb/config/i386/nbsdelf.mt
+++ b/gdb/config/i386/nbsdelf.mt
@@ -1,5 +1,3 @@
 # Target: Intel 386 running NetBSD
 TDEPFILES= i386-tdep.o i387-tdep.o i386bsd-tdep.o
 TM_FILE= tm-nbsdelf.h
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-nbsd.o
diff --git a/gdb/config/i386/nm-fbsd.h b/gdb/config/i386/nm-fbsd.h
index 939b880..b791903 100644
--- a/gdb/config/i386/nm-fbsd.h
+++ b/gdb/config/i386/nm-fbsd.h
@@ -56,6 +56,9 @@
 /* Override child_resume in `infptrace.c' to work around a kernel bug.  */
 #define CHILD_RESUME
 
+/* Override child_pid_to_exec_file in 'inftarg.c'.  */
+#define CHILD_PID_TO_EXEC_FILE
+
 /* We can attach and detach.  */
 #define ATTACH_DETACH
 
diff --git a/gdb/config/i386/nm-x86-64.h b/gdb/config/i386/nm-x86-64.h
index 0d7048e..30e3731 100644
--- a/gdb/config/i386/nm-x86-64.h
+++ b/gdb/config/i386/nm-x86-64.h
@@ -65,10 +65,8 @@
    to get the offset in the core file of the register values.  */
 #define KERNEL_U_ADDR 0x0
 
-/* FIXME use special child_xfer_memory.  */
-#define CHILD_XFER_MEMORY
-
 #define PTRACE_ARG3_TYPE void*
+#define PTRACE_XFER_TYPE unsigned long
 
 
 /* We define this if link.h is available, because with ELF we use SVR4 style
@@ -82,9 +80,6 @@
 /* Override copies of {fetch,store}_inferior_registers in `infptrace.c'.  */
 #define FETCH_INFERIOR_REGISTERS
 
-/* Override child_resume in `infptrace.c'.  */
-#define CHILD_RESUME
-
 #undef PREPARE_TO_PROCEED
 
 #include <signal.h>
diff --git a/gdb/config/i386/tm-linux.h b/gdb/config/i386/tm-linux.h
index 5c549b9..60c4b1e 100644
--- a/gdb/config/i386/tm-linux.h
+++ b/gdb/config/i386/tm-linux.h
@@ -26,6 +26,7 @@
 #define I386_GNULINUX_TARGET
 #define HAVE_I387_REGS
 #ifdef HAVE_PTRACE_GETFPXREGS
+#define FILL_FPXREGSET
 #define HAVE_SSE_REGS
 #endif
 
diff --git a/gdb/config/i386/x86-64linux.mt b/gdb/config/i386/x86-64linux.mt
index 1f3a796..85f1972 100644
--- a/gdb/config/i386/x86-64linux.mt
+++ b/gdb/config/i386/x86-64linux.mt
@@ -1,5 +1,3 @@
 # Target: AMD x86-64 running GNU/Linux
 TDEPFILES= x86-64-tdep.o x86-64-linux-tdep.o i387-tdep.o dwarf2cfi.o \
 	solib.o solib-svr4.o solib-legacy.o
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-linux.o
diff --git a/gdb/config/i960/tm-i960.h b/gdb/config/i960/tm-i960.h
index 2b24889..a62e35d 100644
--- a/gdb/config/i960/tm-i960.h
+++ b/gdb/config/i960/tm-i960.h
@@ -1,6 +1,8 @@
 /* Parameters for target machine Intel 960, for GDB, the GNU debugger.
-   Copyright 1990, 1991, 1993, 1994, 1996, 1998, 1999, 2000
-   Free Software Foundation, Inc.
+
+   Copyright 1990, 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2002 Free
+   Software Foundation, Inc.
+
    Contributed by Intel Corporation.
    This file is part of GDB.
 
@@ -114,21 +116,16 @@
 
 /* The i960 has register windows, sort of.  */
 
-#define HAVE_REGISTER_WINDOWS
+extern void i960_get_saved_register (char *raw_buffer,
+				     int *optimized,
+				     CORE_ADDR *addrp,
+				     struct frame_info *frame,
+				     int regnum,
+				     enum lval_type *lval);
 
-/* Is this register part of the register window system?  A yes answer
-   implies that 1) The name of this register will not be the same in
-   other frames, and 2) This register is automatically "saved" upon
-   subroutine calls and thus there is no need to search more than one
-   stack frame for it.
+#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
+  i960_get_saved_register(raw_buffer, optimized, addrp, frame, regnum, lval)
 
-   On the i960, in fact, the name of this register in another frame is
-   "mud" -- there is no overlap between the windows.  Each window is
-   simply saved into the stack (true for our purposes, after having been
-   flushed; normally they reside on-chip and are restored from on-chip
-   without ever going to memory).  */
-
-#define REGISTER_IN_WINDOW_P(regnum)	((regnum) <= R15_REGNUM)
 
 /* Number of bytes of storage in the actual machine representation
    for register N.  On the i960, all regs are 4 bytes except for floating
diff --git a/gdb/config/m32r/m32r.mt b/gdb/config/m32r/m32r.mt
index 2be2649..a200853 100644
--- a/gdb/config/m32r/m32r.mt
+++ b/gdb/config/m32r/m32r.mt
@@ -3,6 +3,3 @@
 TM_FILE= tm-m32r.h
 SIM_OBS = remote-sim.o
 SIM = ../sim/m32r/libsim.a
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-sim.o
-## OBSOLETE ## GDBSERVER_LIBS = ../../sim/m32r/libsim.a ../../bfd/libbfd.a ../../libiberty/libiberty.a ../../opcodes/libopcodes.a ../../intl/libintl.a
diff --git a/gdb/config/m68k/m68klynx.mh b/gdb/config/m68k/m68klynx.mh
index 803dac3..3838012 100644
--- a/gdb/config/m68k/m68klynx.mh
+++ b/gdb/config/m68k/m68klynx.mh
@@ -4,6 +4,3 @@
 
 NAT_FILE= nm-m68klynx.h
 NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o lynx-nat.o
-
-## OBSOLETE ## GDBSERVER_LIBS= -lbsd
-## OBSOLETE ## GDBSERVER_DEPFILES= low-lynx.o
diff --git a/gdb/config/m68k/nbsd.mt b/gdb/config/m68k/nbsd.mt
index d83d91d..b6ac5a0 100644
--- a/gdb/config/m68k/nbsd.mt
+++ b/gdb/config/m68k/nbsd.mt
@@ -1,5 +1,3 @@
 # Target: Motorola m68k running NetBSD
 TDEPFILES= m68k-tdep.o m68knbsd-tdep.o
 TM_FILE= tm-nbsd.h
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-nbsd.o
diff --git a/gdb/config/m68k/sun3os4.mh b/gdb/config/m68k/sun3os4.mh
index 4ed46a2..18b1f08 100644
--- a/gdb/config/m68k/sun3os4.mh
+++ b/gdb/config/m68k/sun3os4.mh
@@ -2,5 +2,3 @@
 XM_FILE= xm-sun3os4.h
 NAT_FILE= nm-sun3.h
 NATDEPFILES= fork-child.o inftarg.o infptrace.o corelow.o sun3-nat.o
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-sun3.o
diff --git a/gdb/config/m68k/tm-nbsd.h b/gdb/config/m68k/tm-nbsd.h
index 178bf56..354632a 100644
--- a/gdb/config/m68k/tm-nbsd.h
+++ b/gdb/config/m68k/tm-nbsd.h
@@ -1,4 +1,4 @@
-/* Macro definitions for i386 running under NetBSD.
+/* Macro definitions for m68k running under NetBSD.
    Copyright 1994, 1996, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
diff --git a/gdb/config/mcore/tm-mcore.h b/gdb/config/mcore/tm-mcore.h
index 7ce6373..1da21b7 100644
--- a/gdb/config/mcore/tm-mcore.h
+++ b/gdb/config/mcore/tm-mcore.h
@@ -1,5 +1,6 @@
 /* Parameters for execution on a Motorola MCore.
-   Copyright 1995, 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1995, 1999, 2000, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -19,6 +20,8 @@
    Boston, MA 02111-1307, USA. */
 
 #include "regcache.h"
+#include "symtab.h"		/* For namespace_enum.  */
+#include "symfile.h"		/* For entry_point_address().  */
 
 /* All registers are 32 bits */
 #define REGISTER_SIZE 4
@@ -62,7 +65,8 @@
 
 /* BREAKPOINT_FROM_PC uses the program counter value to determine
    the breakpoint that should be used. */
-extern breakpoint_from_pc_fn mcore_breakpoint_from_pc;
+extern const unsigned char *mcore_breakpoint_from_pc (CORE_ADDR *pcptr,
+						      int *lenptr);
 #define BREAKPOINT_FROM_PC(PCPTR, LENPTR) mcore_breakpoint_from_pc (PCPTR, LENPTR)
 
 #define INNER_THAN(LHS,RHS) ((LHS) < (RHS))
diff --git a/gdb/config/mips/vr5000.mt b/gdb/config/mips/vr5000.mt
index f9811d0..7a4a915 100644
--- a/gdb/config/mips/vr5000.mt
+++ b/gdb/config/mips/vr5000.mt
@@ -3,6 +3,3 @@
 TM_FILE= tm-vr5000.h
 SIM_OBS = remote-sim.o
 SIM = ../sim/mips/libsim.a
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-sim.o
-## OBSOLETE ## GDBSERVER_LIBS = ../../sim/mips/libsim.a ../../bfd/libbfd.a ../../libiberty/libiberty.a -lm ../../intl/libintl.a
diff --git a/gdb/config/mn10200/tm-mn10200.h b/gdb/config/mn10200/tm-mn10200.h
index 66fb037..4402b78 100644
--- a/gdb/config/mn10200/tm-mn10200.h
+++ b/gdb/config/mn10200/tm-mn10200.h
@@ -1,5 +1,7 @@
 /* Parameters for execution on a Matsushita mn10200 processor.
-   Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    Contributed by Geoffrey Noer <noer@cygnus.com>
 
@@ -24,6 +26,8 @@
    declared in "regcache.h".  The ``correct fix'' is to convert those
    macros into functions.  */
 #include "regcache.h"
+#include "symtab.h"		/* For namespace_enum.  */
+#include "symfile.h"		/* For entry_point_address().  */
 
 /* ints are only 16bits on the mn10200.  */
 #undef TARGET_INT_BIT
diff --git a/gdb/config/ns32k/nbsd.mt b/gdb/config/ns32k/nbsd.mt
index f677af1..14d37f9 100644
--- a/gdb/config/ns32k/nbsd.mt
+++ b/gdb/config/ns32k/nbsd.mt
@@ -1,5 +1,3 @@
 # Target: PC532 running NetBSD
 TDEPFILES= ns32k-tdep.o
 TM_FILE= tm-nbsd.h
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-nbsd.o
diff --git a/gdb/config/pa/hppabsd.mh b/gdb/config/pa/hppabsd.mh
index 0f66bb6..d4a152d 100644
--- a/gdb/config/pa/hppabsd.mh
+++ b/gdb/config/pa/hppabsd.mh
@@ -2,5 +2,3 @@
 XM_FILE= xm-hppab.h
 NAT_FILE= nm-hppab.h
 NATDEPFILES= hppab-nat.o corelow.o core-aout.o inftarg.o fork-child.o somread.o infptrace.o hpread.o somsolib.o
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-hppabsd.o
diff --git a/gdb/config/pa/hppaosf.mh b/gdb/config/pa/hppaosf.mh
index 95a689a..d6dd282 100644
--- a/gdb/config/pa/hppaosf.mh
+++ b/gdb/config/pa/hppaosf.mh
@@ -3,6 +3,3 @@
 NAT_FILE= nm-hppao.h
 NATDEPFILES= fork-child.o m3-nat.o hppam3-nat.o somread.o hpread.o somsolib.o
 NAT_CLIBS= -lmachid -lnetname -lmach
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-hppabsd.o
-
diff --git a/gdb/config/pa/hpux1020.mh b/gdb/config/pa/hpux1020.mh
index e9c24ee..18f542e 100644
--- a/gdb/config/pa/hpux1020.mh
+++ b/gdb/config/pa/hpux1020.mh
@@ -1,6 +1,10 @@
 # Host: Hewlett-Packard PA-RISC machine, running HPUX 10.20
 
-MH_CFLAGS = -D__HP_CURSES
+# FIXME: cagney/2002-04-07: gdb/366: The -Dvfork=fork hack below is
+# stop GDB hanging on HP/UX.  For some reason vfork() hangs yet fork()
+# doesn't ....
+
+MH_CFLAGS = -D__HP_CURSES -Dvfork=fork
 
 XM_FILE= xm-hppah.h
 
diff --git a/gdb/config/pa/hpux11.mh b/gdb/config/pa/hpux11.mh
index a9919c4..25504e0 100644
--- a/gdb/config/pa/hpux11.mh
+++ b/gdb/config/pa/hpux11.mh
@@ -1,6 +1,10 @@
 # Host: Hewlett-Packard PA-RISC machine, running HPUX 11.00
 
-MH_CFLAGS = -D__HP_CURSES
+# FIXME: cagney/2002-04-07: gdb/366: The -Dvfork=fork hack below is
+# stop GDB hanging on HP/UX.  For some reason vfork() hangs yet fork()
+# doesn't ....
+
+MH_CFLAGS = -D__HP_CURSES -Dvfork=fork
 
 XM_FILE= xm-hppah.h
 
diff --git a/gdb/config/pa/hpux11w.mh b/gdb/config/pa/hpux11w.mh
index 279efa1..b784263 100644
--- a/gdb/config/pa/hpux11w.mh
+++ b/gdb/config/pa/hpux11w.mh
@@ -1,6 +1,10 @@
 # Host: Hewlett-Packard PA-RISC machine, running HPUX 11.00
 
-MH_CFLAGS = -D__HP_CURSES
+# FIXME: cagney/2002-04-07: gdb/366: The -Dvfork=fork hack below is
+# stop GDB hanging on HP/UX.  For some reason vfork() hangs yet fork()
+# doesn't ....
+
+MH_CFLAGS = -D__HP_CURSES -Dvfork=fork
 
 XM_FILE= xm-hppah.h
 
diff --git a/gdb/config/pa/tm-hppa.h b/gdb/config/pa/tm-hppa.h
index 36e57bd..227108f 100644
--- a/gdb/config/pa/tm-hppa.h
+++ b/gdb/config/pa/tm-hppa.h
@@ -376,15 +376,8 @@
 /* Describe the pointer in each stack frame to the previous stack frame
    (its caller).  */
 
-/* FRAME_CHAIN takes a frame's nominal address
-   and produces the frame's chain-pointer.
-
-   FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
-   and produces the nominal address of the caller frame.
-
-   However, if FRAME_CHAIN_VALID returns zero,
-   it means the given frame is the outermost one and has no caller.
-   In that case, FRAME_CHAIN_COMBINE is not used.  */
+/* FRAME_CHAIN takes a frame's nominal address and produces the
+   frame's chain-pointer.  */
 
 /* In the case of the PA-RISC, the frame's nominal address
    is the address of a 4-byte word containing the calling frame's
@@ -396,8 +389,6 @@
 extern int hppa_frame_chain_valid (CORE_ADDR, struct frame_info *);
 #define FRAME_CHAIN_VALID(chain, thisframe) hppa_frame_chain_valid (chain, thisframe)
 
-#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
-
 /* Define other aspects of the stack frame.  */
 
 /* A macro that tells us whether the function invocation represented
diff --git a/gdb/config/powerpc/nbsd.mt b/gdb/config/powerpc/nbsd.mt
index 164abfe..40a2a99 100644
--- a/gdb/config/powerpc/nbsd.mt
+++ b/gdb/config/powerpc/nbsd.mt
@@ -2,7 +2,5 @@
 TDEPFILES= rs6000-tdep.o ppc-linux-tdep.o solib.o solib-svr4.o
 TM_FILE= tm-nbsd.h
 
-## OBSOLETE ## GDBSERVER_DEPFILES= low-nbsd.o
-
 SIM_OBS = remote-sim.o
 SIM = ../sim/ppc/libsim.a
diff --git a/gdb/config/powerpc/tm-ppc-eabi.h b/gdb/config/powerpc/tm-ppc-eabi.h
index 92e4127..e49b2bd 100644
--- a/gdb/config/powerpc/tm-ppc-eabi.h
+++ b/gdb/config/powerpc/tm-ppc-eabi.h
@@ -28,17 +28,11 @@
 #undef SOFTWARE_SINGLE_STEP_P
 #define SOFTWARE_SINGLE_STEP_P() 0
 
-#undef	DEFAULT_LR_SAVE
-#define	DEFAULT_LR_SAVE 4	/* eabi saves LR at 4 off of SP */
-
 #undef PROCESS_LINENUMBER_HOOK
 
 #undef TEXT_SEGMENT_BASE
 #define TEXT_SEGMENT_BASE 1
 
-/* Say that we're using ELF, not XCOFF.  */
-#define ELF_OBJECT_FORMAT 1
-
 /* The value of symbols of type N_SO and N_FUN maybe null when 
    it shouldn't be. */
 #define SOFUN_ADDRESS_MAYBE_MISSING
diff --git a/gdb/config/rs6000/rs6000lynx.mh b/gdb/config/rs6000/rs6000lynx.mh
index 2ae49c2..096473f 100644
--- a/gdb/config/rs6000/rs6000lynx.mh
+++ b/gdb/config/rs6000/rs6000lynx.mh
@@ -4,6 +4,3 @@
 
 NAT_FILE= nm-rs6000ly.h
 NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o lynx-nat.o xcoffread.o
-
-## OBSOLETE ## GDBSERVER_LIBS= -lbsd
-## OBSOLETE ## GDBSERVER_DEPFILES= low-lynx.o
diff --git a/gdb/config/rs6000/tm-rs6000.h b/gdb/config/rs6000/tm-rs6000.h
index 015a592..202ac77 100644
--- a/gdb/config/rs6000/tm-rs6000.h
+++ b/gdb/config/rs6000/tm-rs6000.h
@@ -93,9 +93,6 @@
 	      prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ());
 #define INIT_FRAME_PC(fromleaf, prev)	/* nothing */
 
-/* Default offset from SP where the LR is stored */
-#define	DEFAULT_LR_SAVE 8
-
 /* Flag for machine-specific stuff in shared files.  FIXME */
 #define IBM6000_TARGET
 
diff --git a/gdb/config/s390/s390.mh b/gdb/config/s390/s390.mh
index 28e2a1f..300a5e3 100644
--- a/gdb/config/s390/s390.mh
+++ b/gdb/config/s390/s390.mh
@@ -4,9 +4,9 @@
 XM_CLIBS=
 
 NAT_FILE= nm-linux.h
-NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o s390-nat.o core-aout.o core-regset.o
-# post 5.0 natdepfiles.
-NATDEPFILES+= thread-db.o lin-lwp.o proc-service.o 
+NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o s390-nat.o \
+	core-aout.o core-regset.o linux-proc.o gcore.o thread-db.o lin-lwp.o \
+	proc-service.o
 LOADLIBES = -ldl -rdynamic
 
 
diff --git a/gdb/config/s390/s390.mt b/gdb/config/s390/s390.mt
index 9095058..6b8d91f 100644
--- a/gdb/config/s390/s390.mt
+++ b/gdb/config/s390/s390.mt
@@ -4,5 +4,3 @@
 # Post 5.0 tdep-files
 TDEPFILES+=solib-svr4.o solib-legacy.o
 GDB_MULTI_ARCH=GDB_MULTI_ARCH_PARTIAL
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-linux.o s390-tdep.o s390-nat.o
diff --git a/gdb/config/s390/s390x.mt b/gdb/config/s390/s390x.mt
index 4df35a1..7b23cad 100644
--- a/gdb/config/s390/s390x.mt
+++ b/gdb/config/s390/s390x.mt
@@ -5,7 +5,5 @@
 TDEPFILES+=solib-svr4.o solib-legacy.o
 GDB_MULTI_ARCH=GDB_MULTI_ARCH_PARTIAL
 
-## OBSOLETE ## GDBSERVER_DEPFILES= low-linux.o s390-tdep.o s390-nat.o
-
 # needed for gdbserver.
 MT_CFLAGS= -DCONFIG_ARCH_S390X
diff --git a/gdb/config/sparc/linux.mh b/gdb/config/sparc/linux.mh
index f2c26d5..4a2c41f 100644
--- a/gdb/config/sparc/linux.mh
+++ b/gdb/config/sparc/linux.mh
@@ -12,5 +12,3 @@
 LOADLIBES = -ldl -rdynamic
 
 HOST_IPC=-DBSD_IPC
-
-## OBSOLETE ## GDBSERVER_DEPFILES= low-sparc.o
diff --git a/gdb/config/sparc/sparclynx.mh b/gdb/config/sparc/sparclynx.mh
index b938b2f..c573604 100644
--- a/gdb/config/sparc/sparclynx.mh
+++ b/gdb/config/sparc/sparclynx.mh
@@ -4,6 +4,3 @@
 
 NAT_FILE= nm-sparclynx.h
 NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o lynx-nat.o
-
-## OBSOLETE ## GDBSERVER_LIBS= -lbsd
-## OBSOLETE ## GDBSERVER_DEPFILES= low-lynx.o
diff --git a/gdb/config/sparc/sun4os4.mh b/gdb/config/sparc/sun4os4.mh
index 516be36..4e664d7 100644
--- a/gdb/config/sparc/sun4os4.mh
+++ b/gdb/config/sparc/sun4os4.mh
@@ -3,8 +3,6 @@
 NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o
 HOST_IPC=-DBSD_IPC
 
-## OBSOLETE ## GDBSERVER_DEPFILES= low-sparc.o
-
 # Setting XM_CLIBS=-lresolv would let us use the DNS, but that would screw
 # anyone who wants to use NIS, which includes at least one Cygnus customer
 # (PR 3593).  So leave it this way until/unless we find a resolver which can
diff --git a/gdb/config/sparc/tm-linux.h b/gdb/config/sparc/tm-linux.h
index c3a6f82..34d901f 100644
--- a/gdb/config/sparc/tm-linux.h
+++ b/gdb/config/sparc/tm-linux.h
@@ -23,6 +23,8 @@
 #ifndef TM_SPARCLINUX_H
 #define TM_SPARCLINUX_H
 
+#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PARTIAL
+
 #include "sparc/tm-sparc.h"
 
 #define SIGCONTEXT_PC_OFFSET 12
diff --git a/gdb/config/sparc/tm-sp64.h b/gdb/config/sparc/tm-sp64.h
index 55006c6..8486c86 100644
--- a/gdb/config/sparc/tm-sp64.h
+++ b/gdb/config/sparc/tm-sp64.h
@@ -268,12 +268,10 @@
 extern CORE_ADDR sparc64_read_sp ();
 extern CORE_ADDR sparc64_read_fp ();
 extern void sparc64_write_sp (CORE_ADDR);
-extern void sparc64_write_fp (CORE_ADDR);
 
 #define TARGET_READ_SP() (sparc64_read_sp ())
 #define TARGET_READ_FP() (sparc64_read_fp ())
 #define TARGET_WRITE_SP(X) (sparc64_write_sp (X))
-#define TARGET_WRITE_FP(X) (sparc64_write_fp (X))
 
 #undef EXTRACT_RETURN_VALUE
 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
diff --git a/gdb/config/sparc/tm-sp64linux.h b/gdb/config/sparc/tm-sp64linux.h
index 2503ccb..56b5620 100644
--- a/gdb/config/sparc/tm-sp64linux.h
+++ b/gdb/config/sparc/tm-sp64linux.h
@@ -21,8 +21,6 @@
 #ifndef TM_SPARC_LIN64_H
 #define TM_SPARC_LIN64_H
 
-#define GDB_MULTI_ARCH 0
-
 #include "sparc/tm-sp64.h"
 
 #define SIGCONTEXT_PC_OFFSET 16  /* See asm-sparc64/sigcontext.h */
diff --git a/gdb/config/sparc/tm-sparc.h b/gdb/config/sparc/tm-sparc.h
index 4db7ab7..4a53580 100644
--- a/gdb/config/sparc/tm-sparc.h
+++ b/gdb/config/sparc/tm-sparc.h
@@ -248,12 +248,10 @@
 #define BELIEVE_PCC_PROMOTION 1
 
 /* Advance PC across any function entry prologue instructions
-   to reach some "real" code.  SKIP_PROLOGUE_FRAMELESS_P advances
-   the PC past some of the prologue, but stops as soon as it
-   knows that the function has a frame.  Its result is equal
-   to its input PC if the function is frameless, unequal otherwise.  */
+   to reach some "real" code.  */
 
-#define SKIP_PROLOGUE(PC) sparc_skip_prologue (PC, 0)
+extern CORE_ADDR sparc_skip_prologue (CORE_ADDR);
+#define SKIP_PROLOGUE(PC) sparc_skip_prologue (PC)
 
 /* Immediately after a function call, return the saved pc.
    Can't go through the frames for this because on some machines
@@ -312,6 +310,10 @@
      sparc_reg_struct_has_addr (GCC_P, TYPE)
 extern int sparc_reg_struct_has_addr (int, struct type *);
 
+/* Is the prologue at PC frameless?  */
+#define PROLOGUE_FRAMELESS_P(PC) sparc_prologue_frameless_p (PC)
+extern int sparc_prologue_frameless_p (CORE_ADDR);
+
 #endif /* GDB_MULTI_ARCH */
 
 #if defined (GDB_MULTI_ARCH) && (GDB_MULTI_ARCH > 0)
@@ -333,15 +335,6 @@
 #define PC_ADJUST(PC) sparc_pc_adjust (PC)
 extern CORE_ADDR sparc_pc_adjust (CORE_ADDR);
 
-/* Advance PC across any function entry prologue instructions to reach
-   some "real" code.  SKIP_PROLOGUE_FRAMELESS_P advances the PC past
-   some of the prologue, but stops as soon as it knows that the
-   function has a frame.  Its result is equal to its input PC if the
-   function is frameless, unequal otherwise.  */
-
-#define SKIP_PROLOGUE_FRAMELESS_P(PC) sparc_skip_prologue (PC, 1)
-extern CORE_ADDR sparc_skip_prologue (CORE_ADDR, int);
-
 /* If an argument is declared "register", Sun cc will keep it in a register,
    never saving it onto the stack.  So we better not believe the "p" symbol
    descriptor stab.  */
@@ -468,9 +461,8 @@
   /* time of the register saves.  */ \
   int sp_offset;
 
-/* We need to override GET_SAVED_REGISTER so that we can deal with the way
-   outs change into ins in different frames.  HAVE_REGISTER_WINDOWS can't
-   deal with this case and also handle flat frames at the same time.  */
+/* We need to override GET_SAVED_REGISTER so that we can deal with the
+   way outs change into ins in different frames.  */
 
 void sparc_get_saved_register (char *raw_buffer,
 			       int *optimized,
diff --git a/gdb/config/v850/tm-v850.h b/gdb/config/v850/tm-v850.h
index 0636b98..c085cb5 100644
--- a/gdb/config/v850/tm-v850.h
+++ b/gdb/config/v850/tm-v850.h
@@ -1,6 +1,7 @@
 /* Parameters for execution on an NEC V850 processor.
-   Copyright 1996, 1997, 1998, 1999, 2000
-   Free Software Foundation, Inc.
+
+   Copyright 1996, 1997, 1998, 1999, 2000, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -20,6 +21,8 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "regcache.h"
+#include "symtab.h"		/* For namespace_enum.  */
+#include "symfile.h"		/* For entry_point_address().  */
 
 #define NUM_REGS 66
 
@@ -72,7 +75,6 @@
 #define FP_RAW_REGNUM 29
 
 #define TARGET_READ_FP() read_register (FP_RAW_REGNUM)
-#define TARGET_WRITE_FP(VAL) write_register (FP_REGNUM, (VAL))
 
 #define REGISTER_VIRTUAL_TYPE(REG) builtin_type_int
 
diff --git a/gdb/config/vax/tm-vax.h b/gdb/config/vax/tm-vax.h
index bfa243c..204d155 100644
--- a/gdb/config/vax/tm-vax.h
+++ b/gdb/config/vax/tm-vax.h
@@ -1,5 +1,5 @@
 /* Definitions to make GDB run on a vax under 4.2bsd.
-   Copyright 1986, 1987, 1989, 1991, 1993, 1994, 1996, 1998, 1999, 2000
+   Copyright 1986, 1987, 1989, 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -19,25 +19,7 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include "regcache.h"
-
-/* Offset from address of function to start of its code.
-   Zero on most machines.  */
-
-#define FUNCTION_START_OFFSET 2
-
-/* Advance PC across any function entry prologue instructions
-   to reach some "real" code.  */
-
-extern CORE_ADDR vax_skip_prologue (CORE_ADDR);
-#define SKIP_PROLOGUE(pc) (vax_skip_prologue (pc))
-
-/* Immediately after a function call, return the saved pc.
-   Can't always go through the frames for this because on some machines
-   the new frame is not set up until the new function executes
-   some instructions.  */
-
-#define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame)
+#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PARTIAL
 
 #define TARGET_UPAGES 14
 #define TARGET_NBPG 512
@@ -49,260 +31,18 @@
 #define SIGTRAMP_START(pc)	STACK_END_ADDR
 #define SIGTRAMP_END(pc)	0x80000000
 
-/* Stack grows downward.  */
-
-#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
-
 /* Sequence of bytes for breakpoint instruction.  */
-
 #define BREAKPOINT {3}
 
-/* Amount PC must be decremented by after a breakpoint.
-   This is often the number of bytes in BREAKPOINT
-   but not always.  */
-
-#define DECR_PC_AFTER_BREAK 0
-
-/* Say how long (ordinary) registers are.  This is a piece of bogosity
-   used in push_word and a few other places; REGISTER_RAW_SIZE is the
-   real way to know how big a register is.  */
-
-#define REGISTER_SIZE 4
-
-/* Number of machine registers */
-
-#define NUM_REGS 17
-
-/* Initializer for an array of names of registers.
-   There should be NUM_REGS strings in this initializer.  */
-
-#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", "ps"}
-
-/* Register numbers of various important registers.
-   Note that some of these values are "real" register numbers,
-   and correspond to the general registers of the machine,
-   and some are "phony" register numbers which are too large
-   to be actual register numbers as far as the user is concerned
-   but do serve to get the desired values when passed to read_register.  */
-
-#define AP_REGNUM 12
-#define FP_REGNUM 13		/* Contains address of executing stack frame */
-#define SP_REGNUM 14		/* Contains address of top of stack */
-#define PC_REGNUM 15		/* Contains program counter */
-#define PS_REGNUM 16		/* Contains processor status */
-
-/* Total amount of space needed to store our copies of the machine's
-   register state, the array `registers'.  */
-#define REGISTER_BYTES (17*4)
-
-/* Index within `registers' of the first byte of the space for
-   register N.  */
-
-#define REGISTER_BYTE(N) ((N) * 4)
-
-/* Number of bytes of storage in the actual machine representation
-   for register N.  On the vax, all regs are 4 bytes.  */
-
-#define REGISTER_RAW_SIZE(N) 4
-
-/* Number of bytes of storage in the program's representation
-   for register N.  On the vax, all regs are 4 bytes.  */
-
-#define REGISTER_VIRTUAL_SIZE(N) 4
-
-/* Largest value REGISTER_RAW_SIZE can have.  */
-
-#define MAX_REGISTER_RAW_SIZE 4
-
-/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
-
-#define MAX_REGISTER_VIRTUAL_SIZE 4
-
-/* Return the GDB type object for the "standard" data type
-   of data in register N.  */
-
-#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int
-
-/* Store the address of the place in which to copy the structure the
-   subroutine will return.  This is called from call_function. */
-
-#define STORE_STRUCT_RETURN(ADDR, SP) \
-  { write_register (1, (ADDR)); }
-
-/* Extract from an array REGBUF containing the (raw) register state
-   a function return value of type TYPE, and copy that, in virtual format,
-   into VALBUF.  */
-
-#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
-  memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE))
-
-/* Write into appropriate registers a function return value
-   of type TYPE, given in virtual format.  */
-
-#define STORE_RETURN_VALUE(TYPE,VALBUF) \
-  write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
-
-/* Extract from an array REGBUF containing the (raw) register state
-   the address in which a function should return its structure value,
-   as a CORE_ADDR (or an expression that can be used as one).  */
-
-#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
-
-
-/* Describe the pointer in each stack frame to the previous stack frame
-   (its caller).  */
-
-/* FRAME_CHAIN takes a frame's nominal address
-   and produces the frame's chain-pointer. */
-
-/* In the case of the Vax, the frame's nominal address is the FP value,
-   and 12 bytes later comes the saved previous FP value as a 4-byte word.  */
-
-#define FRAME_CHAIN(thisframe)  \
-  (!inside_entry_file ((thisframe)->pc) ? \
-   read_memory_integer ((thisframe)->frame + 12, 4) :\
-   0)
-
-/* Define other aspects of the stack frame.  */
-
-/* A macro that tells us whether the function invocation represented
-   by FI does not have a frame on the stack associated with it.  If it
-   does not, FRAMELESS is set to 1, else 0.  */
-/* On the vax, all functions have frames.  */
-#define FRAMELESS_FUNCTION_INVOCATION(FI)  (0)
-
-/* Saved Pc.  Get it from sigcontext if within sigtramp.  */
+#define AP_REGNUM 12	/* XXXJRT */
 
 /* Offset to saved PC in sigcontext, from <sys/signal.h>.  */
+/* XXXJRT should go away */
 #define SIGCONTEXT_PC_OFFSET 12
 
-#define FRAME_SAVED_PC(FRAME) \
-  (((FRAME)->signal_handler_caller \
-    ? sigtramp_saved_pc (FRAME) \
-    : read_memory_integer ((FRAME)->frame + 16, 4)) \
-   )
-
-/* Cannot find the AP register value directly from the FP value.  Must
-   find it saved in the frame called by this one, or in the AP
-   register for the innermost frame.  However, there is no way to tell
-   the difference between the innermost frame and a frame for which we
-   just don't know the frame that it called (e.g. "info frame
-   0x7ffec789").  For the sake of argument suppose that the stack is
-   somewhat trashed (which is one reason that "info frame" exists).
-   So return 0 (indicating we don't know the address of
-   the arglist) if we don't know what frame this frame calls.  */
-#define FRAME_ARGS_ADDRESS_CORRECT(fi) \
- (((fi)->next                                  \
-   ? read_memory_integer ((fi)->next->frame + 8, 4)   \
-   : /* read_register (AP_REGNUM) */ 0))
-
-/* In most of GDB, getting the args address is too important to
-   just say "I don't know".  This is sometimes wrong for functions
-   that aren't on top of the stack, but c'est la vie.  */
-#define FRAME_ARGS_ADDRESS(fi) \
- (((fi)->next                                  \
-   ? read_memory_integer ((fi)->next->frame + 8, 4)   \
-   : read_register (AP_REGNUM) /* 0 */))
-
-#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
-
-/* Return number of args passed to a frame.
-   Can return -1, meaning no way to tell.  */
-
-extern int vax_frame_num_args (struct frame_info *fi);
-#define FRAME_NUM_ARGS(fi) (vax_frame_num_args ((fi)))
-
-/* Return number of bytes at start of arglist that are not really args.  */
-
-#define FRAME_ARGS_SKIP 4
-
-/* Put here the code to store, into a struct frame_saved_regs,
-   the addresses of the saved registers of frame described by FRAME_INFO.
-   This includes special registers such as pc and fp saved in special
-   ways in the stack frame.  sp is even more special:
-   the address we return for it IS the sp for the next frame.  */
-
-#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
-{ register int regnum;     \
-  register int regmask = read_memory_integer ((frame_info)->frame+4, 4) >> 16; \
-  register CORE_ADDR next_addr;     \
-  memset (&frame_saved_regs, '\0', sizeof frame_saved_regs);     \
-  next_addr = (frame_info)->frame + 16;     \
-  /* Regmask's low bit is for register 0,     \
-     which is the first one that would be pushed.  */     \
-  for (regnum = 0; regnum < 12; regnum++, regmask >>= 1)  \
-    (frame_saved_regs).regs[regnum] = (regmask & 1) ? (next_addr += 4) : 0;  \
-  (frame_saved_regs).regs[SP_REGNUM] = next_addr + 4;  \
-  if (read_memory_integer ((frame_info)->frame + 4, 4) & 0x20000000)   \
-    (frame_saved_regs).regs[SP_REGNUM] += 4 + 4 * read_memory_integer (next_addr + 4, 4);  \
-  (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 16;  \
-  (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 12;  \
-  (frame_saved_regs).regs[AP_REGNUM] = (frame_info)->frame + 8;  \
-  (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4;  \
-}
-
-/* Things needed for making the inferior call functions.  */
-
-/* Push an empty stack frame, to record the current PC, etc.  */
-
-#define PUSH_DUMMY_FRAME \
-{ register CORE_ADDR sp = read_register (SP_REGNUM);\
-  register int regnum;				    \
-  sp = push_word (sp, 0); /* arglist */		    \
-  for (regnum = 11; regnum >= 0; regnum--)	    \
-    sp = push_word (sp, read_register (regnum));    \
-  sp = push_word (sp, read_register (PC_REGNUM));   \
-  sp = push_word (sp, read_register (FP_REGNUM));   \
-  sp = push_word (sp, read_register (AP_REGNUM));   \
-  sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef)   \
-		      + 0x2fff0000);		    \
-  sp = push_word (sp, 0); 			    \
-  write_register (SP_REGNUM, sp);		    \
-  write_register (FP_REGNUM, sp);		    \
-  write_register (AP_REGNUM, sp + 17 * sizeof (int)); }
-
-/* Discard from the stack the innermost frame, restoring all registers.  */
-
-#define POP_FRAME  \
-{ register CORE_ADDR fp = read_register (FP_REGNUM);		 \
-  register int regnum;						 \
-  register int regmask = read_memory_integer (fp + 4, 4);	 \
-  write_register (PS_REGNUM, 					 \
-		  (regmask & 0xffff)				 \
-		  | (read_register (PS_REGNUM) & 0xffff0000));	 \
-  write_register (PC_REGNUM, read_memory_integer (fp + 16, 4));  \
-  write_register (FP_REGNUM, read_memory_integer (fp + 12, 4));  \
-  write_register (AP_REGNUM, read_memory_integer (fp + 8, 4));   \
-  fp += 16;							 \
-  for (regnum = 0; regnum < 12; regnum++)			 \
-    if (regmask & (0x10000 << regnum))				 \
-      write_register (regnum, read_memory_integer (fp += 4, 4)); \
-  fp = fp + 4 + ((regmask >> 30) & 3);				 \
-  if (regmask & 0x20000000)					 \
-    { regnum = read_memory_integer (fp, 4);			 \
-      fp += (regnum + 1) * 4; }					 \
-  write_register (SP_REGNUM, fp);				 \
-  flush_cached_frames ();					 \
-}
-
-/* This sequence of words is the instructions
-   calls #69, @#32323232
-   bpt
-   Note this is 8 bytes.  */
-
-#define CALL_DUMMY {0x329f69fb, 0x03323232}
-
-#define CALL_DUMMY_START_OFFSET 0	/* Start execution at beginning of dummy */
-
-#define CALL_DUMMY_BREAKPOINT_OFFSET 7
-
-/* Insert the specified number of args and function address
-   into a call sequence of the above form stored at DUMMYNAME.  */
-
-#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \
-{ *((char *) dummyname + 1) = nargs;		\
-  *(int *)((char *) dummyname + 3) = fun; }
+/* XXXJRT not yet under gdbarch control */
+#define FRAME_ARGS_ADDRESS_CORRECT(fi) vax_frame_args_address_correct ((fi))
+extern CORE_ADDR vax_frame_args_address_correct (struct frame_info *);
 
 /* If vax pcc says CHAR or SHORT, it provides the correct address.  */
-
 #define BELIEVE_PCC_PROMOTION 1
diff --git a/gdb/configure b/gdb/configure
index 20dbe8f..e192e4c 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -934,54 +934,32 @@
 rm -f conftest*
 
 
-
-        echo $ac_n "checking for strerror in -lcposix""... $ac_c" 1>&6
-echo "configure:940: checking for strerror in -lcposix" >&5
-ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_save_LIBS="$LIBS"
-LIBS="-lcposix  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 948 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char strerror();
-
-int main() {
-strerror()
-; return 0; }
-EOF
-if { (eval echo configure:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:939: 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
   echo "$ac_t""yes" 1>&6
-  LIBS="$LIBS -lcposix"
+  ISC=yes # If later tests want to check for ISC.
+  cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+  if test "$GCC" = yes; then
+    CC="$CC -posix"
+  else
+    CC="$CC -Xp"
+  fi
 else
   echo "$ac_t""no" 1>&6
+  ISC=
 fi
 
-  
-
 
 
 
 echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
-echo "configure:985: checking for ${CC-cc} option to accept ANSI C" >&5
+echo "configure:963: checking for ${CC-cc} option to accept ANSI C" >&5
 if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -991,13 +969,14 @@
 # breaks some systems' header files.
 # AIX			-qlanglvl=ansi
 # Ultrix and OSF/1	-std1
-# HP-UX			-Aa -D_HPUX_SOURCE
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
 # SVR4			-Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
   cat > conftest.$ac_ext <<EOF
-#line 1001 "configure"
+#line 980 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -1034,7 +1013,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1038: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   am_cv_prog_cc_stdc="$ac_arg"; break
 else
@@ -1105,7 +1084,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:1109: checking host system type" >&5
+echo "configure:1088: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -1126,7 +1105,7 @@
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:1130: checking target system type" >&5
+echo "configure:1109: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -1144,7 +1123,7 @@
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:1148: checking build system type" >&5
+echo "configure:1127: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -1169,7 +1148,7 @@
 
 ALL_LINGUAS=
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1173: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1152: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1198,7 +1177,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:1202: checking for $ac_word" >&5
+echo "configure:1181: 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
@@ -1226,12 +1205,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1230: checking for ANSI C header files" >&5
+echo "configure:1209: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1235 "configure"
+#line 1214 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1239,7 +1218,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1243: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1222: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1256,7 +1235,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1260 "configure"
+#line 1239 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1274,7 +1253,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1278 "configure"
+#line 1257 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1295,7 +1274,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1299 "configure"
+#line 1278 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1306,7 +1285,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:1310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1330,12 +1309,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1334: checking for working const" >&5
+echo "configure:1313: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1339 "configure"
+#line 1318 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1384,7 +1363,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1388: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1405,21 +1384,21 @@
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1409: checking for inline" >&5
+echo "configure:1388: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 1416 "configure"
+#line 1395 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:1423: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -1445,12 +1424,12 @@
 esac
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:1449: checking for off_t" >&5
+echo "configure:1428: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1454 "configure"
+#line 1433 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1478,12 +1457,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1482: checking for size_t" >&5
+echo "configure:1461: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1487 "configure"
+#line 1466 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1513,19 +1492,19 @@
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:1517: checking for working alloca.h" >&5
+echo "configure:1496: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1522 "configure"
+#line 1501 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:1529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -1546,12 +1525,12 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:1550: checking for alloca" >&5
+echo "configure:1529: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1555 "configure"
+#line 1534 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -1579,7 +1558,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:1583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -1611,12 +1590,12 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:1615: checking whether alloca needs Cray hooks" >&5
+echo "configure:1594: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1620 "configure"
+#line 1599 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -1641,12 +1620,12 @@
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1645: checking for $ac_func" >&5
+echo "configure:1624: 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 <<EOF
-#line 1650 "configure"
+#line 1629 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1669,7 +1648,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1696,7 +1675,7 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:1700: checking stack direction for C alloca" >&5
+echo "configure:1679: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1704,7 +1683,7 @@
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 1708 "configure"
+#line 1687 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -1723,7 +1702,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:1727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1706: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -1748,17 +1727,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1752: checking for $ac_hdr" >&5
+echo "configure:1731: 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
-#line 1757 "configure"
+#line 1736 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1762: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1741: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1787,12 +1766,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1791: checking for $ac_func" >&5
+echo "configure:1770: 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 <<EOF
-#line 1796 "configure"
+#line 1775 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1815,7 +1794,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1840,7 +1819,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:1844: checking for working mmap" >&5
+echo "configure:1823: 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
@@ -1848,7 +1827,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 1852 "configure"
+#line 1831 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -1988,7 +1967,7 @@
 }
 
 EOF
-if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -2016,17 +1995,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2020: checking for $ac_hdr" >&5
+echo "configure:1999: 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
-#line 2025 "configure"
+#line 2004 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2030: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2009: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2056,12 +2035,12 @@
 __argz_count __argz_stringify __argz_next
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2060: checking for $ac_func" >&5
+echo "configure:2039: 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 <<EOF
-#line 2065 "configure"
+#line 2044 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2084,7 +2063,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2113,12 +2092,12 @@
      for ac_func in stpcpy
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2117: checking for $ac_func" >&5
+echo "configure:2096: 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 <<EOF
-#line 2122 "configure"
+#line 2101 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2141,7 +2120,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2175,19 +2154,19 @@
 
    if test $ac_cv_header_locale_h = yes; then
     echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
-echo "configure:2179: checking for LC_MESSAGES" >&5
+echo "configure:2158: checking for LC_MESSAGES" >&5
 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2184 "configure"
+#line 2163 "configure"
 #include "confdefs.h"
 #include <locale.h>
 int main() {
 return LC_MESSAGES
 ; return 0; }
 EOF
-if { (eval echo configure:2191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   am_cv_val_LC_MESSAGES=yes
 else
@@ -2208,7 +2187,7 @@
     fi
   fi
    echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6
-echo "configure:2212: checking whether NLS is requested" >&5
+echo "configure:2191: checking whether NLS is requested" >&5
         # Check whether --enable-nls or --disable-nls was given.
 if test "${enable_nls+set}" = set; then
   enableval="$enable_nls"
@@ -2228,7 +2207,7 @@
 EOF
 
       echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6
-echo "configure:2232: checking whether included gettext is requested" >&5
+echo "configure:2211: checking whether included gettext is requested" >&5
       # Check whether --with-included-gettext or --without-included-gettext was given.
 if test "${with_included_gettext+set}" = set; then
   withval="$with_included_gettext"
@@ -2247,17 +2226,17 @@
 
 	ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for libintl.h""... $ac_c" 1>&6
-echo "configure:2251: checking for libintl.h" >&5
+echo "configure:2230: checking for libintl.h" >&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
-#line 2256 "configure"
+#line 2235 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2261: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2274,19 +2253,19 @@
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6
-echo "configure:2278: checking for gettext in libc" >&5
+echo "configure:2257: checking for gettext in libc" >&5
 if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2283 "configure"
+#line 2262 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 int main() {
 return (int) gettext ("")
 ; return 0; }
 EOF
-if { (eval echo configure:2290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   gt_cv_func_gettext_libc=yes
 else
@@ -2302,7 +2281,7 @@
 
 	   if test "$gt_cv_func_gettext_libc" != "yes"; then
 	     echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
-echo "configure:2306: checking for bindtextdomain in -lintl" >&5
+echo "configure:2285: checking for bindtextdomain in -lintl" >&5
 ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2310,7 +2289,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lintl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2314 "configure"
+#line 2293 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2321,7 +2300,7 @@
 bindtextdomain()
 ; return 0; }
 EOF
-if { (eval echo configure:2325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2337,19 +2316,19 @@
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
-echo "configure:2341: checking for gettext in libintl" >&5
+echo "configure:2320: checking for gettext in libintl" >&5
 if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2346 "configure"
+#line 2325 "configure"
 #include "confdefs.h"
 
 int main() {
 return (int) gettext ("")
 ; return 0; }
 EOF
-if { (eval echo configure:2353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   gt_cv_func_gettext_libintl=yes
 else
@@ -2377,7 +2356,7 @@
 	      # Extract the first word of "msgfmt", so it can be a program name with args.
 set dummy msgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2381: checking for $ac_word" >&5
+echo "configure:2360: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2411,12 +2390,12 @@
 		for ac_func in dcgettext
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2415: checking for $ac_func" >&5
+echo "configure:2394: 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 <<EOF
-#line 2420 "configure"
+#line 2399 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2439,7 +2418,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2466,7 +2445,7 @@
 		# Extract the first word of "gmsgfmt", so it can be a program name with args.
 set dummy gmsgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2470: checking for $ac_word" >&5
+echo "configure:2449: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2502,7 +2481,7 @@
 		# Extract the first word of "xgettext", so it can be a program name with args.
 set dummy xgettext; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2506: checking for $ac_word" >&5
+echo "configure:2485: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2534,7 +2513,7 @@
 fi
 
 		cat > conftest.$ac_ext <<EOF
-#line 2538 "configure"
+#line 2517 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2542,7 +2521,7 @@
 			       return _nl_msg_cat_cntr
 ; return 0; }
 EOF
-if { (eval echo configure:2546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   CATOBJEXT=.gmo
 		   DATADIRNAME=share
@@ -2574,7 +2553,7 @@
         # Extract the first word of "msgfmt", so it can be a program name with args.
 set dummy msgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2578: checking for $ac_word" >&5
+echo "configure:2557: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2608,7 +2587,7 @@
         # Extract the first word of "gmsgfmt", so it can be a program name with args.
 set dummy gmsgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2612: checking for $ac_word" >&5
+echo "configure:2591: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2644,7 +2623,7 @@
         # Extract the first word of "xgettext", so it can be a program name with args.
 set dummy xgettext; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2648: checking for $ac_word" >&5
+echo "configure:2627: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2734,7 +2713,7 @@
        LINGUAS=
      else
        echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
-echo "configure:2738: checking for catalogs to be installed" >&5
+echo "configure:2717: checking for catalogs to be installed" >&5
        NEW_LINGUAS=
        for lang in ${LINGUAS=$ALL_LINGUAS}; do
          case "$ALL_LINGUAS" in
@@ -2762,17 +2741,17 @@
       if test "$CATOBJEXT" = ".cat"; then
 	 ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
-echo "configure:2766: checking for linux/version.h" >&5
+echo "configure:2745: checking for linux/version.h" >&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
-#line 2771 "configure"
+#line 2750 "configure"
 #include "confdefs.h"
 #include <linux/version.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2776: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2895,7 +2874,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2899: checking for $ac_word" >&5
+echo "configure:2878: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2936,7 +2915,7 @@
 # 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:2940: checking for a BSD compatible install" >&5
+echo "configure:2919: 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
@@ -2997,7 +2976,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:3001: checking for $ac_word" >&5
+echo "configure:2980: 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
@@ -3029,7 +3008,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:3033: checking for $ac_word" >&5
+echo "configure:3012: 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
@@ -3061,7 +3040,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:3065: checking for $ac_word" >&5
+echo "configure:3044: 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
@@ -3096,7 +3075,7 @@
 # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
 set dummy ${ac_tool_prefix}dlltool; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3100: checking for $ac_word" >&5
+echo "configure:3079: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3128,7 +3107,7 @@
 # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.
 set dummy ${ac_tool_prefix}windres; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3132: checking for $ac_word" >&5
+echo "configure:3111: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3162,7 +3141,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3166: checking for $ac_word" >&5
+echo "configure:3145: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3196,7 +3175,7 @@
 # Extract the first word of "${ac_tool_prefix}mig", so it can be a program name with args.
 set dummy ${ac_tool_prefix}mig; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3200: checking for $ac_word" >&5
+echo "configure:3179: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_MIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3247,12 +3226,12 @@
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3251: checking return type of signal handlers" >&5
+echo "configure:3230: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3256 "configure"
+#line 3235 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3269,7 +3248,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3273: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3252: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3289,12 +3268,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3293: checking for ANSI C header files" >&5
+echo "configure:3272: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3298 "configure"
+#line 3277 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3302,7 +3281,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3319,7 +3298,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3323 "configure"
+#line 3302 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3337,7 +3316,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3341 "configure"
+#line 3320 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3358,7 +3337,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 3362 "configure"
+#line 3341 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3369,7 +3348,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -3413,17 +3392,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3417: checking for $ac_hdr" >&5
+echo "configure:3396: 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
-#line 3422 "configure"
+#line 3401 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3427: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3406: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3450,12 +3429,12 @@
 done
 
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:3454: checking whether stat file-mode macros are broken" >&5
+echo "configure:3433: checking whether stat file-mode macros are broken" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3459 "configure"
+#line 3438 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -3507,12 +3486,12 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3511: checking for working const" >&5
+echo "configure:3490: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3516 "configure"
+#line 3495 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3561,7 +3540,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3565: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3544: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3581,17 +3560,57 @@
 
 fi
 
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:3565: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat > conftest.$ac_ext <<EOF
+#line 3572 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:3579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_c_inline=$ac_kw; break
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+  inline | yes) ;;
+  no) cat >> confdefs.h <<\EOF
+#define inline 
+EOF
+ ;;
+  *)  cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
 
 for ac_func in bcopy btowc bzero canonicalize_file_name isascii poll \
 	realpath sbrk setpgid setpgrp sigaction sigprocmask sigsetmask 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3590: checking for $ac_func" >&5
+echo "configure:3609: 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 <<EOF
-#line 3595 "configure"
+#line 3614 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3614,7 +3633,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3641,19 +3660,19 @@
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:3645: checking for working alloca.h" >&5
+echo "configure:3664: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3650 "configure"
+#line 3669 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:3657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -3674,12 +3693,12 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:3678: checking for alloca" >&5
+echo "configure:3697: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3683 "configure"
+#line 3702 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -3707,7 +3726,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:3711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -3739,12 +3758,12 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:3743: checking whether alloca needs Cray hooks" >&5
+echo "configure:3762: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3748 "configure"
+#line 3767 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -3769,12 +3788,12 @@
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3773: checking for $ac_func" >&5
+echo "configure:3792: 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 <<EOF
-#line 3778 "configure"
+#line 3797 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3797,7 +3816,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3824,7 +3843,7 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:3828: checking stack direction for C alloca" >&5
+echo "configure:3847: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3832,7 +3851,7 @@
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 3836 "configure"
+#line 3855 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -3851,7 +3870,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:3855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -3873,12 +3892,12 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3877: checking for pid_t" >&5
+echo "configure:3896: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3882 "configure"
+#line 3901 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3907,17 +3926,17 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:3911: checking for vfork.h" >&5
+echo "configure:3930: checking for vfork.h" >&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
-#line 3916 "configure"
+#line 3935 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3921: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3942,18 +3961,18 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:3946: checking for working vfork" >&5
+echo "configure:3965: checking for working vfork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
   echo $ac_n "checking for vfork""... $ac_c" 1>&6
-echo "configure:3952: checking for vfork" >&5
+echo "configure:3971: checking for vfork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3957 "configure"
+#line 3976 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vfork(); below.  */
@@ -3976,7 +3995,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_vfork=yes"
 else
@@ -3998,7 +4017,7 @@
 ac_cv_func_vfork_works=$ac_cv_func_vfork
 else
   cat > conftest.$ac_ext <<EOF
-#line 4002 "configure"
+#line 4021 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -4093,7 +4112,7 @@
   }
 }
 EOF
-if { (eval echo configure:4097: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_vfork_works=yes
 else
@@ -4117,7 +4136,7 @@
 
 if test "$cross_compiling" = no; then
   echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:4121: checking whether setpgrp takes no argument" >&5
+echo "configure:4140: checking whether setpgrp takes no argument" >&5
 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4125,7 +4144,7 @@
   { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 4129 "configure"
+#line 4148 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_UNISTD_H
@@ -4145,7 +4164,7 @@
 }
 
 EOF
-if { (eval echo configure:4149: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_setpgrp_void=no
 else
@@ -4170,12 +4189,12 @@
 
 else
   echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:4174: checking whether setpgrp takes no argument" >&5
+echo "configure:4193: checking whether setpgrp takes no argument" >&5
 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4179 "configure"
+#line 4198 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -4189,7 +4208,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4212: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_func_setpgrp_void=no
 else
@@ -4213,12 +4232,12 @@
 # Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
 # since sigsetjmp might only be defined as a macro.
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:4217: checking for sigsetjmp" >&5
+echo "configure:4236: checking for sigsetjmp" >&5
 if eval "test \"`echo '$''{'gdb_cv_func_sigsetjmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4222 "configure"
+#line 4241 "configure"
 #include "confdefs.h"
 
 #include <setjmp.h>
@@ -4227,7 +4246,7 @@
 sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);
 ; return 0; }
 EOF
-if { (eval echo configure:4231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4250: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_func_sigsetjmp=yes
 else
@@ -4250,19 +4269,19 @@
 # See if <machine/reg.h> supports the %fs and %gs i386 segment registers.
 # Older i386 BSD's don't have the r_fs and r_gs members of `struct reg'.
 echo $ac_n "checking for r_fs in struct reg""... $ac_c" 1>&6
-echo "configure:4254: checking for r_fs in struct reg" >&5
+echo "configure:4273: checking for r_fs in struct reg" >&5
 if eval "test \"`echo '$''{'gdb_cv_struct_reg_r_fs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4259 "configure"
+#line 4278 "configure"
 #include "confdefs.h"
 #include <machine/reg.h>
 int main() {
 struct reg r; r.r_fs;
 ; return 0; }
 EOF
-if { (eval echo configure:4266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_struct_reg_r_fs=yes
 else
@@ -4282,19 +4301,19 @@
 
 fi
 echo $ac_n "checking for r_gs in struct reg""... $ac_c" 1>&6
-echo "configure:4286: checking for r_gs in struct reg" >&5
+echo "configure:4305: checking for r_gs in struct reg" >&5
 if eval "test \"`echo '$''{'gdb_cv_struct_reg_r_gs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4291 "configure"
+#line 4310 "configure"
 #include "confdefs.h"
 #include <machine/reg.h>
 int main() {
 struct reg r; r.r_gs;
 ; return 0; }
 EOF
-if { (eval echo configure:4298: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4317: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_struct_reg_r_gs=yes
 else
@@ -4316,19 +4335,19 @@
 
 # See if <sys/ptrace.h> provides the PTRACE_GETREGS request.
 echo $ac_n "checking for PTRACE_GETREGS""... $ac_c" 1>&6
-echo "configure:4320: checking for PTRACE_GETREGS" >&5
+echo "configure:4339: checking for PTRACE_GETREGS" >&5
 if eval "test \"`echo '$''{'gdb_cv_have_ptrace_getregs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4325 "configure"
+#line 4344 "configure"
 #include "confdefs.h"
 #include <sys/ptrace.h>
 int main() {
 PTRACE_GETREGS;
 ; return 0; }
 EOF
-if { (eval echo configure:4332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4351: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_ptrace_getregs=yes
 else
@@ -4350,19 +4369,19 @@
 
 # See if <sys/ptrace.h> provides the PTRACE_GETFPXREGS request.
 echo $ac_n "checking for PTRACE_GETFPXREGS""... $ac_c" 1>&6
-echo "configure:4354: checking for PTRACE_GETFPXREGS" >&5
+echo "configure:4373: checking for PTRACE_GETFPXREGS" >&5
 if eval "test \"`echo '$''{'gdb_cv_have_ptrace_getfpxregs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4359 "configure"
+#line 4378 "configure"
 #include "confdefs.h"
 #include <sys/ptrace.h>
 int main() {
 PTRACE_GETFPXREGS;
 ; return 0; }
 EOF
-if { (eval echo configure:4366: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4385: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_ptrace_getfpxregs=yes
 else
@@ -4384,12 +4403,12 @@
 
 # See if <sys/ptrace.h> provides the PT_GETDBREGS request.
 echo $ac_n "checking for PT_GETDBREGS""... $ac_c" 1>&6
-echo "configure:4388: checking for PT_GETDBREGS" >&5
+echo "configure:4407: checking for PT_GETDBREGS" >&5
 if eval "test \"`echo '$''{'gdb_cv_have_pt_getdbregs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4393 "configure"
+#line 4412 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/ptrace.h>
@@ -4397,7 +4416,7 @@
 PT_GETDBREGS;
 ; return 0; }
 EOF
-if { (eval echo configure:4401: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_pt_getdbregs=yes
 else
@@ -4419,12 +4438,12 @@
 
 # See if <sys/ptrace.h> provides the PT_GETXMMREGS request.
 echo $ac_n "checking for PT_GETXMMREGS""... $ac_c" 1>&6
-echo "configure:4423: checking for PT_GETXMMREGS" >&5
+echo "configure:4442: checking for PT_GETXMMREGS" >&5
 if eval "test \"`echo '$''{'gdb_cv_have_pt_getxmmregs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4428 "configure"
+#line 4447 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/ptrace.h>
@@ -4432,7 +4451,7 @@
 PT_GETXMMREGS;
 ; return 0; }
 EOF
-if { (eval echo configure:4436: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4455: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_pt_getxmmregs=yes
 else
@@ -4454,7 +4473,7 @@
 
 
 echo $ac_n "checking for socketpair in -lsocket""... $ac_c" 1>&6
-echo "configure:4458: checking for socketpair in -lsocket" >&5
+echo "configure:4477: checking for socketpair in -lsocket" >&5
 ac_lib_var=`echo socket'_'socketpair | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4462,7 +4481,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4466 "configure"
+#line 4485 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4473,7 +4492,7 @@
 socketpair()
 ; return 0; }
 EOF
-if { (eval echo configure:4477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4503,12 +4522,12 @@
 for ac_func in socketpair
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4507: checking for $ac_func" >&5
+echo "configure:4526: 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 <<EOF
-#line 4512 "configure"
+#line 4531 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4531,7 +4550,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4558,12 +4577,12 @@
 
 
 echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6
-echo "configure:4562: checking whether malloc must be declared" >&5
+echo "configure:4581: 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 <<EOF
-#line 4567 "configure"
+#line 4586 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4584,7 +4603,7 @@
 char *(*pfn) = (char *(*)) malloc
 ; return 0; }
 EOF
-if { (eval echo configure:4588: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4607: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_malloc=no
 else
@@ -4605,12 +4624,12 @@
 fi
 
 echo $ac_n "checking whether realloc must be declared""... $ac_c" 1>&6
-echo "configure:4609: checking whether realloc must be declared" >&5
+echo "configure:4628: 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 <<EOF
-#line 4614 "configure"
+#line 4633 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4631,7 +4650,7 @@
 char *(*pfn) = (char *(*)) realloc
 ; return 0; }
 EOF
-if { (eval echo configure:4635: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_realloc=no
 else
@@ -4652,12 +4671,12 @@
 fi
 
 echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6
-echo "configure:4656: checking whether free must be declared" >&5
+echo "configure:4675: 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 <<EOF
-#line 4661 "configure"
+#line 4680 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4678,7 +4697,7 @@
 char *(*pfn) = (char *(*)) free
 ; return 0; }
 EOF
-if { (eval echo configure:4682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4701: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_free=no
 else
@@ -4699,12 +4718,12 @@
 fi
 
 echo $ac_n "checking whether strerror must be declared""... $ac_c" 1>&6
-echo "configure:4703: checking whether strerror must be declared" >&5
+echo "configure:4722: checking whether strerror must be declared" >&5
 if eval "test \"`echo '$''{'bfd_cv_decl_needed_strerror'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4708 "configure"
+#line 4727 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4725,7 +4744,7 @@
 char *(*pfn) = (char *(*)) strerror
 ; return 0; }
 EOF
-if { (eval echo configure:4729: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4748: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_strerror=no
 else
@@ -4746,12 +4765,12 @@
 fi
 
 echo $ac_n "checking whether strdup must be declared""... $ac_c" 1>&6
-echo "configure:4750: checking whether strdup must be declared" >&5
+echo "configure:4769: checking whether strdup must be declared" >&5
 if eval "test \"`echo '$''{'bfd_cv_decl_needed_strdup'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4755 "configure"
+#line 4774 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4772,7 +4791,7 @@
 char *(*pfn) = (char *(*)) strdup
 ; return 0; }
 EOF
-if { (eval echo configure:4776: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4795: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_strdup=no
 else
@@ -4793,12 +4812,12 @@
 fi
 
 echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6
-echo "configure:4797: checking whether strstr must be declared" >&5
+echo "configure:4816: 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 <<EOF
-#line 4802 "configure"
+#line 4821 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -4819,7 +4838,7 @@
 char *(*pfn) = (char *(*)) strstr
 ; return 0; }
 EOF
-if { (eval echo configure:4823: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4842: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_strstr=no
 else
@@ -4839,6 +4858,52 @@
 
 fi
 
+echo $ac_n "checking whether canonicalize_file_name must be declared""... $ac_c" 1>&6
+echo "configure:4863: checking whether canonicalize_file_name must be declared" >&5
+if eval "test \"`echo '$''{'bfd_cv_decl_needed_canonicalize_file_name'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 4868 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+int main() {
+char *(*pfn) = (char *(*)) canonicalize_file_name
+; return 0; }
+EOF
+if { (eval echo configure:4889: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  bfd_cv_decl_needed_canonicalize_file_name=no
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  bfd_cv_decl_needed_canonicalize_file_name=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bfd_cv_decl_needed_canonicalize_file_name" 1>&6
+if test $bfd_cv_decl_needed_canonicalize_file_name = yes; then
+  cat >> confdefs.h <<\EOF
+#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1
+EOF
+
+fi
 
 
 # The following save_state_t checkery is only necessary for HPUX 
@@ -4846,9 +4911,9 @@
 # could be expunged. --jsm 1999-03-22
 
 echo $ac_n "checking for HPUX save_state structure""... $ac_c" 1>&6
-echo "configure:4850: checking for HPUX save_state structure" >&5
+echo "configure:4915: checking for HPUX save_state structure" >&5
 cat > conftest.$ac_ext <<EOF
-#line 4852 "configure"
+#line 4917 "configure"
 #include "confdefs.h"
 #include <machine/save_state.h>
 EOF
@@ -4863,7 +4928,7 @@
 rm -f conftest*
 
 cat > conftest.$ac_ext <<EOF
-#line 4867 "configure"
+#line 4932 "configure"
 #include "confdefs.h"
 #include <machine/save_state.h>
 EOF
@@ -4933,12 +4998,12 @@
 
 if test "$ac_cv_header_sys_procfs_h" = yes; then
   echo $ac_n "checking for pstatus_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:4937: checking for pstatus_t in sys/procfs.h" >&5
+echo "configure:5002: checking for pstatus_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pstatus_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4942 "configure"
+#line 5007 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -4947,7 +5012,7 @@
 pstatus_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:4951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pstatus_t=yes
 else
@@ -4969,12 +5034,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_pstatus_t" 1>&6
 
   echo $ac_n "checking for prrun_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:4973: checking for prrun_t in sys/procfs.h" >&5
+echo "configure:5038: checking for prrun_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prrun_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4978 "configure"
+#line 5043 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -4983,7 +5048,7 @@
 prrun_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:4987: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prrun_t=yes
 else
@@ -5005,12 +5070,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prrun_t" 1>&6
 
   echo $ac_n "checking for gregset_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5009: checking for gregset_t in sys/procfs.h" >&5
+echo "configure:5074: checking for gregset_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_gregset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5014 "configure"
+#line 5079 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5019,7 +5084,7 @@
 gregset_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5023: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_gregset_t=yes
 else
@@ -5041,12 +5106,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_gregset_t" 1>&6
 
   echo $ac_n "checking for fpregset_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5045: checking for fpregset_t in sys/procfs.h" >&5
+echo "configure:5110: checking for fpregset_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_fpregset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5050 "configure"
+#line 5115 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5055,7 +5120,7 @@
 fpregset_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5059: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_fpregset_t=yes
 else
@@ -5077,12 +5142,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_fpregset_t" 1>&6
 
   echo $ac_n "checking for prgregset_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5081: checking for prgregset_t in sys/procfs.h" >&5
+echo "configure:5146: checking for prgregset_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prgregset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5086 "configure"
+#line 5151 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5091,7 +5156,7 @@
 prgregset_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prgregset_t=yes
 else
@@ -5113,12 +5178,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prgregset_t" 1>&6
 
   echo $ac_n "checking for prfpregset_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5117: checking for prfpregset_t in sys/procfs.h" >&5
+echo "configure:5182: checking for prfpregset_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prfpregset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5122 "configure"
+#line 5187 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5127,7 +5192,7 @@
 prfpregset_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5131: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prfpregset_t=yes
 else
@@ -5149,12 +5214,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prfpregset_t" 1>&6
 
   echo $ac_n "checking for prgregset32_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5153: checking for prgregset32_t in sys/procfs.h" >&5
+echo "configure:5218: checking for prgregset32_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prgregset32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5158 "configure"
+#line 5223 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5163,7 +5228,7 @@
 prgregset32_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5167: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prgregset32_t=yes
 else
@@ -5185,12 +5250,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prgregset32_t" 1>&6
 
   echo $ac_n "checking for prfpregset32_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5189: checking for prfpregset32_t in sys/procfs.h" >&5
+echo "configure:5254: checking for prfpregset32_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prfpregset32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5194 "configure"
+#line 5259 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5199,7 +5264,7 @@
 prfpregset32_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5203: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5268: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prfpregset32_t=yes
 else
@@ -5221,12 +5286,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prfpregset32_t" 1>&6
 
   echo $ac_n "checking for lwpid_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5225: checking for lwpid_t in sys/procfs.h" >&5
+echo "configure:5290: checking for lwpid_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5230 "configure"
+#line 5295 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5235,7 +5300,7 @@
 lwpid_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5239: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5304: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_lwpid_t=yes
 else
@@ -5257,12 +5322,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpid_t" 1>&6
 
   echo $ac_n "checking for psaddr_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5261: checking for psaddr_t in sys/procfs.h" >&5
+echo "configure:5326: checking for psaddr_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psaddr_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5266 "configure"
+#line 5331 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5271,7 +5336,7 @@
 psaddr_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5275: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5340: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_psaddr_t=yes
 else
@@ -5293,12 +5358,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_psaddr_t" 1>&6
 
   echo $ac_n "checking for prsysent_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5297: checking for prsysent_t in sys/procfs.h" >&5
+echo "configure:5362: checking for prsysent_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prsysent_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5302 "configure"
+#line 5367 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5307,7 +5372,7 @@
 prsysent_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5376: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_prsysent_t=yes
 else
@@ -5329,12 +5394,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_prsysent_t" 1>&6
 
   echo $ac_n "checking for pr_sigset_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5333: checking for pr_sigset_t in sys/procfs.h" >&5
+echo "configure:5398: checking for pr_sigset_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pr_sigset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5338 "configure"
+#line 5403 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5343,7 +5408,7 @@
 pr_sigset_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5347: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pr_sigset_t=yes
 else
@@ -5365,12 +5430,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_pr_sigset_t" 1>&6
 
   echo $ac_n "checking for pr_sigaction64_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5369: checking for pr_sigaction64_t in sys/procfs.h" >&5
+echo "configure:5434: checking for pr_sigaction64_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pr_sigaction64_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5374 "configure"
+#line 5439 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5379,7 +5444,7 @@
 pr_sigaction64_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5383: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5448: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pr_sigaction64_t=yes
 else
@@ -5401,12 +5466,12 @@
  echo "$ac_t""$bfd_cv_have_sys_procfs_type_pr_sigaction64_t" 1>&6
 
   echo $ac_n "checking for pr_siginfo64_t in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5405: checking for pr_siginfo64_t in sys/procfs.h" >&5
+echo "configure:5470: checking for pr_siginfo64_t in sys/procfs.h" >&5
  if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_pr_siginfo64_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5410 "configure"
+#line 5475 "configure"
 #include "confdefs.h"
 
 #define _SYSCALL32
@@ -5415,7 +5480,7 @@
 pr_siginfo64_t avar
 ; return 0; }
 EOF
-if { (eval echo configure:5419: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5484: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_have_sys_procfs_type_pr_siginfo64_t=yes
 else
@@ -5442,7 +5507,7 @@
         
   if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then
     echo $ac_n "checking whether prfpregset_t type is broken""... $ac_c" 1>&6
-echo "configure:5446: checking whether prfpregset_t type is broken" >&5
+echo "configure:5511: checking whether prfpregset_t type is broken" >&5
     if eval "test \"`echo '$''{'gdb_cv_prfpregset_t_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5450,7 +5515,7 @@
   gdb_cv_prfpregset_t_broken=yes
 else
   cat > conftest.$ac_ext <<EOF
-#line 5454 "configure"
+#line 5519 "configure"
 #include "confdefs.h"
 #include <sys/procfs.h>
        int main ()
@@ -5460,7 +5525,7 @@
          return 0;
        }
 EOF
-if { (eval echo configure:5464: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   gdb_cv_prfpregset_t_broken=no
 else
@@ -5485,12 +5550,12 @@
 
   
   echo $ac_n "checking for PIOCSET ioctl entry in sys/procfs.h""... $ac_c" 1>&6
-echo "configure:5489: checking for PIOCSET ioctl entry in sys/procfs.h" >&5
+echo "configure:5554: checking for PIOCSET ioctl entry in sys/procfs.h" >&5
   if eval "test \"`echo '$''{'gdb_cv_have_procfs_piocset'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5494 "configure"
+#line 5559 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 #include <sys/types.h>
@@ -5503,7 +5568,7 @@
   
 ; return 0; }
 EOF
-if { (eval echo configure:5507: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_procfs_piocset=yes
 else
@@ -5527,19 +5592,19 @@
 if test ${host} = ${target} ; then
     
   echo $ac_n "checking for member l_addr in struct link_map""... $ac_c" 1>&6
-echo "configure:5531: checking for member l_addr in struct link_map" >&5
+echo "configure:5596: checking for member l_addr in struct link_map" >&5
   if eval "test \"`echo '$''{'gdb_cv_have_struct_link_map_with_l_members'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5536 "configure"
+#line 5601 "configure"
 #include "confdefs.h"
 #include <link.h>
 int main() {
 struct link_map lm; (void) lm.l_addr;
 ; return 0; }
 EOF
-if { (eval echo configure:5543: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5608: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_struct_link_map_with_l_members=yes
 else
@@ -5561,12 +5626,12 @@
 
     
   echo $ac_n "checking for member lm_addr in struct link_map""... $ac_c" 1>&6
-echo "configure:5565: checking for member lm_addr in struct link_map" >&5
+echo "configure:5630: checking for member lm_addr in struct link_map" >&5
   if eval "test \"`echo '$''{'gdb_cv_have_struct_link_map_with_lm_members'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5570 "configure"
+#line 5635 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <link.h>
@@ -5574,7 +5639,7 @@
 struct link_map lm; (void) lm.lm_addr;
 ; return 0; }
 EOF
-if { (eval echo configure:5578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5643: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_struct_link_map_with_lm_members=yes
 else
@@ -5596,12 +5661,12 @@
 
     
   echo $ac_n "checking for member som_addr in struct so_map""... $ac_c" 1>&6
-echo "configure:5600: checking for member som_addr in struct so_map" >&5
+echo "configure:5665: checking for member som_addr in struct so_map" >&5
   if eval "test \"`echo '$''{'gdb_cv_have_struct_so_map_with_som_members'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5605 "configure"
+#line 5670 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #ifdef HAVE_NLIST_H
@@ -5612,7 +5677,7 @@
 struct so_map lm; (void) lm.som_addr;
 ; return 0; }
 EOF
-if { (eval echo configure:5616: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5681: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_struct_so_map_with_som_members=yes
 else
@@ -5634,12 +5699,12 @@
 
     
   echo $ac_n "checking for struct link_map32 in sys/link.h""... $ac_c" 1>&6
-echo "configure:5638: checking for struct link_map32 in sys/link.h" >&5
+echo "configure:5703: checking for struct link_map32 in sys/link.h" >&5
   if eval "test \"`echo '$''{'gdb_cv_have_struct_link_map32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5643 "configure"
+#line 5708 "configure"
 #include "confdefs.h"
 #define _SYSCALL32
 #include <sys/link.h>
@@ -5647,7 +5712,7 @@
 struct link_map32 l;
 ; return 0; }
 EOF
-if { (eval echo configure:5651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_struct_link_map32=yes
 else
@@ -5665,11 +5730,15 @@
 #define HAVE_STRUCT_LINK_MAP32 1
 EOF
 
+    cat >> confdefs.h <<\EOF
+#define _SYSCALL32 1
+EOF
+
   fi
 fi
 
 echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
-echo "configure:5673: checking for main in -lm" >&5
+echo "configure:5742: checking for main in -lm" >&5
 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5677,14 +5746,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5681 "configure"
+#line 5750 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5713,7 +5782,7 @@
 
 
 echo $ac_n "checking for wctype in -lc""... $ac_c" 1>&6
-echo "configure:5717: checking for wctype in -lc" >&5
+echo "configure:5786: checking for wctype in -lc" >&5
 ac_lib_var=`echo c'_'wctype | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5721,7 +5790,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5725 "configure"
+#line 5794 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5732,7 +5801,7 @@
 wctype()
 ; return 0; }
 EOF
-if { (eval echo configure:5736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5751,7 +5820,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for wctype in -lw""... $ac_c" 1>&6
-echo "configure:5755: checking for wctype in -lw" >&5
+echo "configure:5824: checking for wctype in -lw" >&5
 ac_lib_var=`echo w'_'wctype | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5759,7 +5828,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lw  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5763 "configure"
+#line 5832 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5770,7 +5839,7 @@
 wctype()
 ; return 0; }
 EOF
-if { (eval echo configure:5774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5802,12 +5871,12 @@
 
 
 echo $ac_n "checking for long long support in compiler""... $ac_c" 1>&6
-echo "configure:5806: checking for long long support in compiler" >&5
+echo "configure:5875: checking for long long support in compiler" >&5
 if eval "test \"`echo '$''{'gdb_cv_c_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5811 "configure"
+#line 5880 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -5817,7 +5886,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5890: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_c_long_long=yes
 else
@@ -5839,7 +5908,7 @@
 
 
 echo $ac_n "checking for long long support in printf""... $ac_c" 1>&6
-echo "configure:5843: checking for long long support in printf" >&5
+echo "configure:5912: checking for long long support in printf" >&5
 if eval "test \"`echo '$''{'gdb_cv_printf_has_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5847,7 +5916,7 @@
   gdb_cv_printf_has_long_long=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 5851 "configure"
+#line 5920 "configure"
 #include "confdefs.h"
 
 int main () {
@@ -5861,7 +5930,7 @@
   return (strcmp ("0x0123456789abcdef", buf));
 }
 EOF
-if { (eval echo configure:5865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   gdb_cv_printf_has_long_long=yes
 else
@@ -5885,19 +5954,19 @@
 
 
 echo $ac_n "checking for long double support in compiler""... $ac_c" 1>&6
-echo "configure:5889: checking for long double support in compiler" >&5
+echo "configure:5958: checking for long double support in compiler" >&5
 if eval "test \"`echo '$''{'ac_cv_c_long_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5894 "configure"
+#line 5963 "configure"
 #include "confdefs.h"
 
 int main() {
 long double foo;
 ; return 0; }
 EOF
-if { (eval echo configure:5901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5970: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_long_double=yes
 else
@@ -5919,7 +5988,7 @@
 
 
 echo $ac_n "checking for long double support in printf""... $ac_c" 1>&6
-echo "configure:5923: checking for long double support in printf" >&5
+echo "configure:5992: checking for long double support in printf" >&5
 if eval "test \"`echo '$''{'gdb_cv_printf_has_long_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5927,7 +5996,7 @@
   gdb_cv_printf_has_long_double=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 5931 "configure"
+#line 6000 "configure"
 #include "confdefs.h"
 
 int main () {
@@ -5937,7 +6006,7 @@
   return (strncmp ("3.14159", buf, 7));
 }
 EOF
-if { (eval echo configure:5941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   gdb_cv_printf_has_long_double=yes
 else
@@ -5961,7 +6030,7 @@
 
 
 echo $ac_n "checking for long double support in scanf""... $ac_c" 1>&6
-echo "configure:5965: checking for long double support in scanf" >&5
+echo "configure:6034: checking for long double support in scanf" >&5
 if eval "test \"`echo '$''{'gdb_cv_scanf_has_long_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5969,7 +6038,7 @@
   gdb_cv_scanf_has_long_double=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 5973 "configure"
+#line 6042 "configure"
 #include "confdefs.h"
 
 int main () {
@@ -5979,7 +6048,7 @@
   return !(f > 3.14159 && f < 3.14160);
 }
 EOF
-if { (eval echo configure:5983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   gdb_cv_scanf_has_long_double=yes
 else
@@ -6005,17 +6074,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6009: checking for $ac_hdr" >&5
+echo "configure:6078: 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
-#line 6014 "configure"
+#line 6083 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6019: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6088: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6044,12 +6113,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6048: checking for $ac_func" >&5
+echo "configure:6117: 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 <<EOF
-#line 6053 "configure"
+#line 6122 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6072,7 +6141,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6097,7 +6166,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6101: checking for working mmap" >&5
+echo "configure:6170: 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
@@ -6105,7 +6174,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 6109 "configure"
+#line 6178 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6245,7 +6314,7 @@
 }
 
 EOF
-if { (eval echo configure:6249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -6271,7 +6340,7 @@
 case ${host_os} in
 aix*)
   echo $ac_n "checking for -bbigtoc option""... $ac_c" 1>&6
-echo "configure:6275: checking for -bbigtoc option" >&5
+echo "configure:6344: checking for -bbigtoc option" >&5
 if eval "test \"`echo '$''{'gdb_cv_bigtoc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6285,14 +6354,14 @@
 
     LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
     cat > conftest.$ac_ext <<EOF
-#line 6289 "configure"
+#line 6358 "configure"
 #include "confdefs.h"
 
 int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:6296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -6315,7 +6384,7 @@
    case ${host_os} in
    hpux*)
       echo $ac_n "checking for HPUX/OSF thread support""... $ac_c" 1>&6
-echo "configure:6319: checking for HPUX/OSF thread support" >&5
+echo "configure:6388: checking for HPUX/OSF thread support" >&5
       if test -f /usr/include/dce/cma_config.h ; then
          if test "$GCC" = "yes" ; then
             echo "$ac_t""yes" 1>&6
@@ -6334,7 +6403,7 @@
       ;;
    solaris*)
       echo $ac_n "checking for Solaris thread debugging library""... $ac_c" 1>&6
-echo "configure:6338: checking for Solaris thread debugging library" >&5
+echo "configure:6407: checking for Solaris thread debugging library" >&5
       if test -f /usr/lib/libthread_db.so.1 ; then
          echo "$ac_t""yes" 1>&6
          cat >> confdefs.h <<\EOF
@@ -6344,7 +6413,7 @@
          CONFIG_LIB_OBS="${CONFIG_LIB_OBS} sol-thread.o"
          CONFIG_SRCS="${CONFIG_SRCS} sol-thread.c"
          echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:6348: checking for dlopen in -ldl" >&5
+echo "configure:6417: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6352,7 +6421,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6356 "configure"
+#line 6425 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6363,7 +6432,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:6367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6395,17 +6464,17 @@
             # all symbols visible in the dynamic symbol table.
             hold_ldflags=$LDFLAGS
             echo $ac_n "checking for the ld -export-dynamic flag""... $ac_c" 1>&6
-echo "configure:6399: checking for the ld -export-dynamic flag" >&5
+echo "configure:6468: checking for the ld -export-dynamic flag" >&5
             LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
             cat > conftest.$ac_ext <<EOF
-#line 6402 "configure"
+#line 6471 "configure"
 #include "confdefs.h"
 
 int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:6409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   found=yes
 else
@@ -6424,13 +6493,13 @@
 	 # Sun randomly tweaked the prototypes in <proc_service.h>
 	 # at one point.
 	 echo $ac_n "checking if <proc_service.h> is old""... $ac_c" 1>&6
-echo "configure:6428: checking if <proc_service.h> is old" >&5
+echo "configure:6497: checking if <proc_service.h> is old" >&5
 	 if eval "test \"`echo '$''{'gdb_cv_proc_service_is_old'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 	    cat > conftest.$ac_ext <<EOF
-#line 6434 "configure"
+#line 6503 "configure"
 #include "confdefs.h"
 
 		#include <proc_service.h>
@@ -6441,7 +6510,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6445: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_proc_service_is_old=no
 else
@@ -6660,7 +6729,7 @@
 if test "x${build_warnings}" != x -a "x$GCC" = xyes
 then
     echo $ac_n "checking compiler warning flags""... $ac_c" 1>&6
-echo "configure:6664: checking compiler warning flags" >&5
+echo "configure:6733: checking compiler warning flags" >&5
     # Separate out the -Werror flag as some files just cannot be
     # compiled with it enabled.
     for w in ${build_warnings}; do
@@ -6670,14 +6739,14 @@
 	    saved_CFLAGS="$CFLAGS"
 	    CFLAGS="$CFLAGS $w"
 	    cat > conftest.$ac_ext <<EOF
-#line 6674 "configure"
+#line 6743 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6681: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6750: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   WARN_CFLAGS="${WARN_CFLAGS} $w"
 else
@@ -6737,12 +6806,12 @@
 
 if test $want_included_regex = false; then
   echo $ac_n "checking for GNU regex""... $ac_c" 1>&6
-echo "configure:6741: checking for GNU regex" >&5
+echo "configure:6810: checking for GNU regex" >&5
   if eval "test \"`echo '$''{'gdb_cv_have_gnu_regex'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6746 "configure"
+#line 6815 "configure"
 #include "confdefs.h"
 #include <gnu-versions.h>
 #include <sys/types.h>
@@ -6754,7 +6823,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6758: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6827: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_have_gnu_regex=yes
 else
@@ -6783,12 +6852,12 @@
 
 # In the Cygwin environment, we need some additional flags.
 echo $ac_n "checking for cygwin""... $ac_c" 1>&6
-echo "configure:6787: checking for cygwin" >&5
+echo "configure:6856: checking for cygwin" >&5
 if eval "test \"`echo '$''{'gdb_cv_os_cygwin'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6792 "configure"
+#line 6861 "configure"
 #include "confdefs.h"
 
 #if defined (__CYGWIN__) || defined (__CYGWIN32__)
@@ -6826,7 +6895,7 @@
 else
   TERM_LIB=
   echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:6830: checking for tgetent in -lncurses" >&5
+echo "configure:6899: checking for tgetent in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6834,7 +6903,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6838 "configure"
+#line 6907 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6845,7 +6914,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:6849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6864,7 +6933,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -lHcurses""... $ac_c" 1>&6
-echo "configure:6868: checking for tgetent in -lHcurses" >&5
+echo "configure:6937: checking for tgetent in -lHcurses" >&5
 ac_lib_var=`echo Hcurses'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6872,7 +6941,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lHcurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6876 "configure"
+#line 6945 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6883,7 +6952,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:6887: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6902,7 +6971,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermlib""... $ac_c" 1>&6
-echo "configure:6906: checking for tgetent in -ltermlib" >&5
+echo "configure:6975: checking for tgetent in -ltermlib" >&5
 ac_lib_var=`echo termlib'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6910,7 +6979,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ltermlib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6914 "configure"
+#line 6983 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6921,7 +6990,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:6925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6940,7 +7009,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:6944: checking for tgetent in -ltermcap" >&5
+echo "configure:7013: checking for tgetent in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6948,7 +7017,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6952 "configure"
+#line 7021 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6959,7 +7028,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:6963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6978,7 +7047,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:6982: checking for tgetent in -lcurses" >&5
+echo "configure:7051: checking for tgetent in -lcurses" >&5
 ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6986,7 +7055,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6990 "configure"
+#line 7059 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6997,7 +7066,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:7001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7016,7 +7085,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -lterminfo""... $ac_c" 1>&6
-echo "configure:7020: checking for tgetent in -lterminfo" >&5
+echo "configure:7089: checking for tgetent in -lterminfo" >&5
 ac_lib_var=`echo terminfo'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7024,7 +7093,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lterminfo  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7028 "configure"
+#line 7097 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7035,7 +7104,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:7039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7200,7 +7269,7 @@
 fi
 
   echo $ac_n "checking for Tcl configuration""... $ac_c" 1>&6
-echo "configure:7204: checking for Tcl configuration" >&5
+echo "configure:7273: checking for Tcl configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_tclconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7308,7 +7377,7 @@
 fi
 
   echo $ac_n "checking for Tk configuration""... $ac_c" 1>&6
-echo "configure:7312: checking for Tk configuration" >&5
+echo "configure:7381: checking for Tk configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_tkconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7417,7 +7486,7 @@
 
 no_tcl=true
 echo $ac_n "checking for Tcl private headers. dir=${configdir}""... $ac_c" 1>&6
-echo "configure:7421: checking for Tcl private headers. dir=${configdir}" >&5
+echo "configure:7490: checking for Tcl private headers. dir=${configdir}" >&5
 # Check whether --with-tclinclude or --without-tclinclude was given.
 if test "${with_tclinclude+set}" = set; then
   withval="$with_tclinclude"
@@ -7483,17 +7552,17 @@
 if test x"${ac_cv_c_tclh}" = x ; then
    ac_safe=`echo "tclInt.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for tclInt.h""... $ac_c" 1>&6
-echo "configure:7487: checking for tclInt.h" >&5
+echo "configure:7556: checking for tclInt.h" >&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
-#line 7492 "configure"
+#line 7561 "configure"
 #include "confdefs.h"
 #include <tclInt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7497: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7566: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7553,7 +7622,7 @@
 #
 no_tk=true
 echo $ac_n "checking for Tk private headers""... $ac_c" 1>&6
-echo "configure:7557: checking for Tk private headers" >&5
+echo "configure:7626: checking for Tk private headers" >&5
 # Check whether --with-tkinclude or --without-tkinclude was given.
 if test "${with_tkinclude+set}" = set; then
   withval="$with_tkinclude"
@@ -7619,17 +7688,17 @@
 if test x"${ac_cv_c_tkh}" = x ; then
    ac_safe=`echo "tk.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for tk.h""... $ac_c" 1>&6
-echo "configure:7623: checking for tk.h" >&5
+echo "configure:7692: checking for tk.h" >&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
-#line 7628 "configure"
+#line 7697 "configure"
 #include "confdefs.h"
 #include <tk.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7633: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7702: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7675,7 +7744,7 @@
 
 	   
 echo $ac_n "checking for Itcl private headers. srcdir=${srcdir}""... $ac_c" 1>&6
-echo "configure:7679: checking for Itcl private headers. srcdir=${srcdir}" >&5
+echo "configure:7748: checking for Itcl private headers. srcdir=${srcdir}" >&5
 if test x"${ac_cv_c_itclh}" = x ; then
   for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ${srcdir}/../itcl/itcl; do
     if test -f $i/generic/itcl.h ; then
@@ -7698,7 +7767,7 @@
 
 	   
 echo $ac_n "checking for Itk private headers. srcdir=${srcdir}""... $ac_c" 1>&6
-echo "configure:7702: checking for Itk private headers. srcdir=${srcdir}" >&5
+echo "configure:7771: checking for Itk private headers. srcdir=${srcdir}" >&5
 if test x"${ac_cv_c_itkh}" = x ; then
   for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ${srcdir}/../itcl/itk; do
     if test -f $i/generic/itk.h ; then
@@ -7721,7 +7790,7 @@
 
 	   
 echo $ac_n "checking for Tix private headers. srcdir=${srcdir}""... $ac_c" 1>&6
-echo "configure:7725: checking for Tix private headers. srcdir=${srcdir}" >&5
+echo "configure:7794: checking for Tix private headers. srcdir=${srcdir}" >&5
 if test x"${ac_cv_c_tixh}" = x ; then
   for i in ${srcdir}/../tix ${srcdir}/../../tix ${srcdir}/../../../tix ; do
     if test -f $i/generic/tix.h ; then
@@ -7773,7 +7842,7 @@
 fi
 
   echo $ac_n "checking for Itcl configuration""... $ac_c" 1>&6
-echo "configure:7777: checking for Itcl configuration" >&5
+echo "configure:7846: checking for Itcl configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_itclconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7876,7 +7945,7 @@
 fi
 
   echo $ac_n "checking for Itk configuration""... $ac_c" 1>&6
-echo "configure:7880: checking for Itk configuration" >&5
+echo "configure:7949: checking for Itk configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_itkconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7979,7 +8048,7 @@
 fi
 
   echo $ac_n "checking for Tix configuration""... $ac_c" 1>&6
-echo "configure:7983: checking for Tix configuration" >&5
+echo "configure:8052: checking for Tix configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_tixconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8122,7 +8191,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:8126: checking for X" >&5
+echo "configure:8195: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -8184,12 +8253,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 8188 "configure"
+#line 8257 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8193: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8262: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8258,14 +8327,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 8262 "configure"
+#line 8331 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:8269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8338: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -8558,7 +8627,7 @@
 # ``gdbserver'' can only be built in a native configuration.
 if test x"${target}" = x"${host}"; then
     echo $ac_n "checking whether gdbserver is supported on this host""... $ac_c" 1>&6
-echo "configure:8562: checking whether gdbserver is supported on this host" >&5
+echo "configure:8631: checking whether gdbserver is supported on this host" >&5
     if test x"${build_gdbserver}" = xyes ; then
 	configdirs="${configdirs} gdbserver"
 	SUBDIRS="${SUBDIRS} gdbserver"
@@ -8620,7 +8689,7 @@
 
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:8624: checking whether ln -s works" >&5
+echo "configure:8693: checking whether ln -s works" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8644,12 +8713,12 @@
 
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:8648: checking for Cygwin environment" >&5
+echo "configure:8717: checking for Cygwin environment" >&5
 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8653 "configure"
+#line 8722 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8660,7 +8729,7 @@
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:8664: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -8677,19 +8746,19 @@
 CYGWIN=
 test "$ac_cv_cygwin" = yes && CYGWIN=yes
 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
-echo "configure:8681: checking for mingw32 environment" >&5
+echo "configure:8750: checking for mingw32 environment" >&5
 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8686 "configure"
+#line 8755 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:8693: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8762: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -8708,7 +8777,7 @@
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:8712: checking for executable suffix" >&5
+echo "configure:8781: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8718,7 +8787,7 @@
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:8722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:8791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
       *.c | *.o | *.obj | *.ilk | *.pdb) ;;
diff --git a/gdb/configure.host b/gdb/configure.host
index 4c69fff..0c26ac0 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -34,6 +34,7 @@
 alpha*-*-osf[3456789]*)	gdb_host=alpha-osf3 ;;
 alpha*-*-linux*)	gdb_host=alpha-linux ;;
 alpha*-*-freebsd*)	gdb_host=fbsd ;;
+alpha*-*-netbsd*)	gdb_host=nbsd ;;
 
 arm*-*-linux*)		gdb_host=linux ;;
 arm*-*-netbsd*)		gdb_host=nbsd ;;
diff --git a/gdb/configure.in b/gdb/configure.in
index 48f7b1a..19976dd 100644
--- a/gdb/configure.in
+++ b/gdb/configure.in
@@ -130,6 +130,7 @@
 AC_HEADER_STAT
 
 AC_C_CONST
+AC_C_INLINE
 
 AC_CHECK_FUNCS(bcopy btowc bzero canonicalize_file_name isascii poll \
 	realpath sbrk setpgid setpgrp sigaction sigprocmask sigsetmask )
@@ -241,7 +242,7 @@
 BFD_NEED_DECLARATION(strerror)
 BFD_NEED_DECLARATION(strdup)
 BFD_NEED_DECLARATION(strstr)
-
+BFD_NEED_DECLARATION(canonicalize_file_name)
 
 # The following save_state_t checkery is only necessary for HPUX 
 # versions earlier than 10.20.  When those fade from memory, this 
@@ -408,6 +409,7 @@
   AC_MSG_RESULT($gdb_cv_have_struct_link_map32)
   if test $gdb_cv_have_struct_link_map32 = yes; then
     AC_DEFINE(HAVE_STRUCT_LINK_MAP32)
+    AC_DEFINE(_SYSCALL32)
   fi
 fi
 
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 1ccdfed..9b35547 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -14,6 +14,7 @@
 
 alpha*)			gdb_target_cpu=alpha ;;
 arm*)			gdb_target_cpu=arm ;;
+avr*)			gdb_target_cpu=avr ;;
 hppa*)			gdb_target_cpu=pa ;;
 i[3456]86*)		gdb_target_cpu=i386 ;;
 m68hc11*|m6811*)	gdb_target_cpu=m68hc11 ;;
@@ -36,18 +37,10 @@
 
 case "${target}" in
 
-# OBSOLETE a29k-*-aout*)		gdb_target=a29k ;;
-# OBSOLETE a29k-*-coff*)		gdb_target=a29k ;;
-# OBSOLETE a29k-*-elf*)		gdb_target=a29k ;;
-# OBSOLETE a29k-*-ebmon*)		gdb_target=a29k ;;
-# OBSOLETE a29k-*-kern*)		gdb_target=a29k-kern ;;
-# OBSOLETE a29k-*-none*)		gdb_target=a29k ;;
-# OBSOLETE a29k-*-udi*)		gdb_target=a29k-udi ;;
-# OBSOLETE a29k-*-vxworks*)        gdb_target=vx29k ;;
-
 alpha*-*-osf*)		gdb_target=alpha-osf1 ;;
 alpha*-*-linux*)	gdb_target=alpha-linux ;;
 alpha*-*-freebsd*)	gdb_target=fbsd ;;
+alpha*-*-netbsd*)	gdb_target=nbsd ;;
 
 arc-*-*)		gdb_target=arc ;;
 
@@ -65,6 +58,10 @@
                         configdirs="$configdirs rdi-share"
                         ;;
 
+avr-*-*)		gdb_target=avr
+			gdb_multi_arch=yes
+			;;
+
 cris*)                  gdb_target=cris ;;
 
 d10v-*-*)		gdb_target=d10v ;;
diff --git a/gdb/core-sol2.c b/gdb/core-sol2.c
index e72fc2a..0123cf4 100644
--- a/gdb/core-sol2.c
+++ b/gdb/core-sol2.c
@@ -27,8 +27,6 @@
    This file combines the core register fetching from core-regset.c
    and sparc-nat.c to be able to read both flavours.  */
 
-/* for Sparc64 cross Sparc32 */
-#define _SYSCALL32
 #include "defs.h"
 
 #if defined (__sparcv9)
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 7acbd6eb..29eeac8 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -441,7 +441,7 @@
 	       "Use FILE as core dump for examining memory and registers.\n\
 No arg means have no core file.  This command has been superseded by the\n\
 `target core' and `detach' commands.", &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_set_cmd ("gnutarget", class_files, var_string_noescape,
 		   (char *) &gnutarget_string,
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 68219c5..657cdc8 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -358,8 +358,9 @@
 
       /* Now, set up the frame cache, and print the top of stack.  */
       flush_cached_frames ();
-      select_frame (get_current_frame (), 0);
-      print_stack_frame (selected_frame, selected_frame_level, 1);
+      select_frame (get_current_frame ());
+      print_stack_frame (selected_frame,
+			 frame_relative_level (selected_frame), 1);
     }
   else
     {
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 66920312..7ea9f3f 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -1,6 +1,6 @@
 /* Support for printing C++ values for GDB, the GNU debugger.
    Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -201,6 +201,8 @@
 int
 cp_is_vtbl_member (struct type *type)
 {
+  /* With older versions of g++, the vtbl field pointed to an array
+     of structures.  Nowadays it points directly to the structure. */
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
     {
       type = TYPE_TARGET_TYPE (type);
@@ -215,6 +217,17 @@
 	      return cp_is_vtbl_ptr_type (type);
 	    }
 	}
+      else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)  /* if not using thunks */
+	{
+	  return cp_is_vtbl_ptr_type (type);
+	}
+      else if (TYPE_CODE (type) == TYPE_CODE_PTR)     /* if using thunks */
+	{
+	  /* The type name of the thunk pointer is NULL when using dwarf2.
+	     We could test for a pointer to a function, but there is
+	     no type info for the virtual table either, so it wont help.  */
+	  return cp_is_vtbl_ptr_type (type);
+	}
     }
   return 0;
 }
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 4662eba..e85ac12 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3925,8 +3925,17 @@
 {
   struct gdbarch_info info;
 
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+
   /* From here on, trust the user's CRIS version setting.  */
-  if (c->type == set_cmd)
+  if (cmd_type (c) == set_cmd)
     {
       usr_cmd_cris_version_valid = 1;
   
@@ -3943,8 +3952,17 @@
 {
   struct gdbarch_info info;
   
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+
   /* From here on, trust the user's CRIS mode setting.  */
-  if (c->type == set_cmd)
+  if (cmd_type (c) == set_cmd)
     {
       usr_cmd_cris_mode_valid = 1;
   
@@ -3961,8 +3979,17 @@
 {
   struct gdbarch_info info;
   
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+
   /* From here on, trust the user's CRIS ABI setting.  */
-  if (c->type == set_cmd)
+  if (cmd_type (c) == set_cmd)
     {
       usr_cmd_cris_abi_valid = 1;
   
@@ -4073,17 +4100,19 @@
           cris_abi = CRIS_ABI_V2;
         }
     }
-  else if (gdbarch_tdep (current_gdbarch))
+  else if (arches != NULL)
     {
-      /* No bfd available.  Stick with whatever ABI we're currently using.  
-         (This is to avoid changing the ABI when the user updates the 
-         architecture with the 'set cris-version' command.)  */
-      cris_abi = gdbarch_tdep (current_gdbarch)->cris_abi;
+      /* No bfd available.  Stick with the ABI from the most recently
+         selected architecture of this same family (the head of arches
+         always points to this).  (This is to avoid changing the ABI
+         when the user updates the architecture with the 'set
+         cris-version' command.)  */
+      cris_abi = gdbarch_tdep (arches->gdbarch)->cris_abi;
     }
   else
     {
-      /* No bfd, and no current architecture available.  Assume it's the 
-         new ABI.  */
+      /* No bfd, and no previously selected architecture available.
+         Assume it's the new ABI.  */
       cris_abi = CRIS_ABI_V2;
     }
 
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index d06a0b9..2060c93 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -1,6 +1,7 @@
 /* Target-dependent code for Mitsubishi D10V, for GDB.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -41,9 +42,6 @@
 #include "floatformat.h"
 #include "sim-d10v.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 struct frame_extra_info
   {
     CORE_ADDR return_pc;
@@ -152,7 +150,7 @@
 }
 
 
-static unsigned char *
+static const unsigned char *
 d10v_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] =
@@ -358,18 +356,6 @@
     return builtin_type_int16;
 }
 
-static CORE_ADDR
-d10v_make_daddr (CORE_ADDR x)
-{
-  return ((x) | DMEM_START);
-}
-
-static CORE_ADDR
-d10v_make_iaddr (CORE_ADDR x)
-{
-  return (((x) << 2) | IMEM_START);
-}
-
 static int
 d10v_daddr_p (CORE_ADDR x)
 {
@@ -382,6 +368,20 @@
   return (((x) & 0x3000000) == IMEM_START);
 }
 
+static CORE_ADDR
+d10v_make_daddr (CORE_ADDR x)
+{
+  return ((x) | DMEM_START);
+}
+
+static CORE_ADDR
+d10v_make_iaddr (CORE_ADDR x)
+{
+  if (d10v_iaddr_p (x))
+    return x;	/* Idempotency -- x is already in the IMEM space. */
+  else
+    return (((x) << 2) | IMEM_START);
+}
 
 static CORE_ADDR
 d10v_convert_iaddr_to_raw (CORE_ADDR x)
@@ -968,12 +968,6 @@
   write_register (SP_REGNUM, d10v_convert_daddr_to_raw (val));
 }
 
-static void
-d10v_write_fp (CORE_ADDR val)
-{
-  write_register (FP_REGNUM, d10v_convert_daddr_to_raw (val));
-}
-
 static CORE_ADDR
 d10v_read_fp (void)
 {
@@ -1479,7 +1473,6 @@
   set_gdbarch_read_pc (gdbarch, d10v_read_pc);
   set_gdbarch_write_pc (gdbarch, d10v_write_pc);
   set_gdbarch_read_fp (gdbarch, d10v_read_fp);
-  set_gdbarch_write_fp (gdbarch, d10v_write_fp);
   set_gdbarch_read_sp (gdbarch, d10v_read_sp);
   set_gdbarch_write_sp (gdbarch, d10v_write_sp);
 
diff --git a/gdb/d30v-tdep.c b/gdb/d30v-tdep.c
index ede8dd8..b5d3a3b 100644
--- a/gdb/d30v-tdep.c
+++ b/gdb/d30v-tdep.c
@@ -1,6 +1,7 @@
 /* Target-dependent code for Mitsubishi D30V, for GDB.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -725,7 +726,7 @@
     {
       char regbuf[MAX_REGISTER_RAW_SIZE];
 
-      read_relative_register_raw_bytes (regnum, regbuf);
+      frame_register_read (selected_frame, regnum, regbuf);
 
       val_print (REGISTER_VIRTUAL_TYPE (regnum), regbuf, 0, 0,
 		 gdb_stdout, 'x', 1, 0, Val_pretty_default);
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 26be70c..9b2b73b 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1230,6 +1230,52 @@
   do_cleanups (back_to);
 }
 
+#ifdef SOFUN_ADDRESS_MAYBE_MISSING
+CORE_ADDR
+find_stab_function_addr (char *namestring, char *filename,
+			 struct objfile *objfile)
+{
+  struct minimal_symbol *msym;
+  char *p;
+  int n;
+
+  p = strchr (namestring, ':');
+  if (p == NULL)
+    p = namestring;
+  n = p - namestring;
+  p = alloca (n + 2);
+  strncpy (p, namestring, n);
+  p[n] = 0;
+
+  msym = lookup_minimal_symbol (p, filename, objfile);
+  if (msym == NULL)
+    {
+      /* Sun Fortran appends an underscore to the minimal symbol name,
+         try again with an appended underscore if the minimal symbol
+         was not found.  */
+      p[n] = '_';
+      p[n + 1] = 0;
+      msym = lookup_minimal_symbol (p, filename, objfile);
+    }
+
+  if (msym == NULL && filename != NULL)
+    {
+      /* Try again without the filename. */
+      p[n] = 0;
+      msym = lookup_minimal_symbol (p, NULL, objfile);
+    }
+  if (msym == NULL && filename != NULL)
+    {
+      /* And try again for Sun Fortran, but without the filename. */
+      p[n] = '_';
+      p[n + 1] = 0;
+      msym = lookup_minimal_symbol (p, NULL, objfile);
+    }
+
+  return msym == NULL ? 0 : SYMBOL_VALUE_ADDRESS (msym);
+}
+#endif /* SOFUN_ADDRESS_MAYBE_MISSING */
+
 /* Setup partial_symtab's describing each source file for which
    debugging information is available. */
 
@@ -2707,6 +2753,15 @@
      used to relocate these symbol types rather than SECTION_OFFSETS.  */
   static CORE_ADDR function_start_offset;
 
+  /* This holds the address of the start of a function, without the system
+     peculiarities of function_start_offset.  */
+  static CORE_ADDR last_function_start;
+
+  /* If this is nonzero, we've seen an N_SLINE since the start of the current
+     function.  Initialized to nonzero to assure that last_function_start
+     is never used uninitialized.  */
+  static int sline_found_in_function = 1;
+
   /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source
      file.  Used to detect the SunPRO solaris compiler.  */
   static int n_opt_found;
@@ -2758,9 +2813,13 @@
 	  break;
 	}
 
+      sline_found_in_function = 0;
+
       /* Relocate for dynamic loading */
       valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
       valu = SMASH_TEXT_ADDRESS (valu);
+      last_function_start = valu;
+
       goto define_a_symbol;
 
     case N_LBRAC:
@@ -2953,7 +3012,15 @@
 #ifdef SUN_FIXED_LBRAC_BUG
       last_pc_address = valu;	/* Save for SunOS bug circumcision */
 #endif
-      record_line (current_subfile, desc, valu);
+      /* If this is the first SLINE note in the function, record it at
+	 the start of the function instead of at the listed location.  */
+      if (within_function && sline_found_in_function == 0)
+	{
+	  record_line (current_subfile, desc, last_function_start);
+	  sline_found_in_function = 1;
+	}
+      else
+	record_line (current_subfile, desc, valu);
       break;
 
     case N_BCOMM:
diff --git a/gdb/defs.h b/gdb/defs.h
index b6e7953..ab66d73 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -39,6 +39,9 @@
 #include <unistd.h>
 #endif
 
+/* For ``enum target_signal''.  */
+#include "gdb/signals.h"
+
 /* Just in case they're not defined in stdio.h. */
 
 #ifndef SEEK_SET
@@ -219,213 +222,6 @@
     unspecified_precision
   };
 
-/* The numbering of these signals is chosen to match traditional unix
-   signals (insofar as various unices use the same numbers, anyway).
-   It is also the numbering of the GDB remote protocol.  Other remote
-   protocols, if they use a different numbering, should make sure to
-   translate appropriately.
-
-   Since these numbers have actually made it out into other software
-   (stubs, etc.), you mustn't disturb the assigned numbering.  If you
-   need to add new signals here, add them to the end of the explicitly
-   numbered signals.
-
-   This is based strongly on Unix/POSIX signals for several reasons:
-   (1) This set of signals represents a widely-accepted attempt to
-   represent events of this sort in a portable fashion, (2) we want a
-   signal to make it from wait to child_wait to the user intact, (3) many
-   remote protocols use a similar encoding.  However, it is
-   recognized that this set of signals has limitations (such as not
-   distinguishing between various kinds of SIGSEGV, or not
-   distinguishing hitting a breakpoint from finishing a single step).
-   So in the future we may get around this either by adding additional
-   signals for breakpoint, single-step, etc., or by adding signal
-   codes; the latter seems more in the spirit of what BSD, System V,
-   etc. are doing to address these issues.  */
-
-/* For an explanation of what each signal means, see
-   target_signal_to_string.  */
-
-enum target_signal
-  {
-    /* Used some places (e.g. stop_signal) to record the concept that
-       there is no signal.  */
-    TARGET_SIGNAL_0 = 0,
-    TARGET_SIGNAL_FIRST = 0,
-    TARGET_SIGNAL_HUP = 1,
-    TARGET_SIGNAL_INT = 2,
-    TARGET_SIGNAL_QUIT = 3,
-    TARGET_SIGNAL_ILL = 4,
-    TARGET_SIGNAL_TRAP = 5,
-    TARGET_SIGNAL_ABRT = 6,
-    TARGET_SIGNAL_EMT = 7,
-    TARGET_SIGNAL_FPE = 8,
-    TARGET_SIGNAL_KILL = 9,
-    TARGET_SIGNAL_BUS = 10,
-    TARGET_SIGNAL_SEGV = 11,
-    TARGET_SIGNAL_SYS = 12,
-    TARGET_SIGNAL_PIPE = 13,
-    TARGET_SIGNAL_ALRM = 14,
-    TARGET_SIGNAL_TERM = 15,
-    TARGET_SIGNAL_URG = 16,
-    TARGET_SIGNAL_STOP = 17,
-    TARGET_SIGNAL_TSTP = 18,
-    TARGET_SIGNAL_CONT = 19,
-    TARGET_SIGNAL_CHLD = 20,
-    TARGET_SIGNAL_TTIN = 21,
-    TARGET_SIGNAL_TTOU = 22,
-    TARGET_SIGNAL_IO = 23,
-    TARGET_SIGNAL_XCPU = 24,
-    TARGET_SIGNAL_XFSZ = 25,
-    TARGET_SIGNAL_VTALRM = 26,
-    TARGET_SIGNAL_PROF = 27,
-    TARGET_SIGNAL_WINCH = 28,
-    TARGET_SIGNAL_LOST = 29,
-    TARGET_SIGNAL_USR1 = 30,
-    TARGET_SIGNAL_USR2 = 31,
-    TARGET_SIGNAL_PWR = 32,
-    /* Similar to SIGIO.  Perhaps they should have the same number.  */
-    TARGET_SIGNAL_POLL = 33,
-    TARGET_SIGNAL_WIND = 34,
-    TARGET_SIGNAL_PHONE = 35,
-    TARGET_SIGNAL_WAITING = 36,
-    TARGET_SIGNAL_LWP = 37,
-    TARGET_SIGNAL_DANGER = 38,
-    TARGET_SIGNAL_GRANT = 39,
-    TARGET_SIGNAL_RETRACT = 40,
-    TARGET_SIGNAL_MSG = 41,
-    TARGET_SIGNAL_SOUND = 42,
-    TARGET_SIGNAL_SAK = 43,
-    TARGET_SIGNAL_PRIO = 44,
-    TARGET_SIGNAL_REALTIME_33 = 45,
-    TARGET_SIGNAL_REALTIME_34 = 46,
-    TARGET_SIGNAL_REALTIME_35 = 47,
-    TARGET_SIGNAL_REALTIME_36 = 48,
-    TARGET_SIGNAL_REALTIME_37 = 49,
-    TARGET_SIGNAL_REALTIME_38 = 50,
-    TARGET_SIGNAL_REALTIME_39 = 51,
-    TARGET_SIGNAL_REALTIME_40 = 52,
-    TARGET_SIGNAL_REALTIME_41 = 53,
-    TARGET_SIGNAL_REALTIME_42 = 54,
-    TARGET_SIGNAL_REALTIME_43 = 55,
-    TARGET_SIGNAL_REALTIME_44 = 56,
-    TARGET_SIGNAL_REALTIME_45 = 57,
-    TARGET_SIGNAL_REALTIME_46 = 58,
-    TARGET_SIGNAL_REALTIME_47 = 59,
-    TARGET_SIGNAL_REALTIME_48 = 60,
-    TARGET_SIGNAL_REALTIME_49 = 61,
-    TARGET_SIGNAL_REALTIME_50 = 62,
-    TARGET_SIGNAL_REALTIME_51 = 63,
-    TARGET_SIGNAL_REALTIME_52 = 64,
-    TARGET_SIGNAL_REALTIME_53 = 65,
-    TARGET_SIGNAL_REALTIME_54 = 66,
-    TARGET_SIGNAL_REALTIME_55 = 67,
-    TARGET_SIGNAL_REALTIME_56 = 68,
-    TARGET_SIGNAL_REALTIME_57 = 69,
-    TARGET_SIGNAL_REALTIME_58 = 70,
-    TARGET_SIGNAL_REALTIME_59 = 71,
-    TARGET_SIGNAL_REALTIME_60 = 72,
-    TARGET_SIGNAL_REALTIME_61 = 73,
-    TARGET_SIGNAL_REALTIME_62 = 74,
-    TARGET_SIGNAL_REALTIME_63 = 75,
-
-    /* Used internally by Solaris threads.  See signal(5) on Solaris.  */
-    TARGET_SIGNAL_CANCEL = 76,
-
-    /* Yes, this pains me, too.  But LynxOS didn't have SIG32, and now
-       GNU/Linux does, and we can't disturb the numbering, since it's
-       part of the remote protocol.  Note that in some GDB's
-       TARGET_SIGNAL_REALTIME_32 is number 76.  */
-    TARGET_SIGNAL_REALTIME_32,
-    /* Yet another pain, IRIX 6 has SIG64. */
-    TARGET_SIGNAL_REALTIME_64,
-    /* Yet another pain, GNU/Linux MIPS might go up to 128. */
-    TARGET_SIGNAL_REALTIME_65,
-    TARGET_SIGNAL_REALTIME_66,
-    TARGET_SIGNAL_REALTIME_67,
-    TARGET_SIGNAL_REALTIME_68,
-    TARGET_SIGNAL_REALTIME_69,
-    TARGET_SIGNAL_REALTIME_70,
-    TARGET_SIGNAL_REALTIME_71,
-    TARGET_SIGNAL_REALTIME_72,
-    TARGET_SIGNAL_REALTIME_73,
-    TARGET_SIGNAL_REALTIME_74,
-    TARGET_SIGNAL_REALTIME_75,
-    TARGET_SIGNAL_REALTIME_76,
-    TARGET_SIGNAL_REALTIME_77,
-    TARGET_SIGNAL_REALTIME_78,
-    TARGET_SIGNAL_REALTIME_79,
-    TARGET_SIGNAL_REALTIME_80,
-    TARGET_SIGNAL_REALTIME_81,
-    TARGET_SIGNAL_REALTIME_82,
-    TARGET_SIGNAL_REALTIME_83,
-    TARGET_SIGNAL_REALTIME_84,
-    TARGET_SIGNAL_REALTIME_85,
-    TARGET_SIGNAL_REALTIME_86,
-    TARGET_SIGNAL_REALTIME_87,
-    TARGET_SIGNAL_REALTIME_88,
-    TARGET_SIGNAL_REALTIME_89,
-    TARGET_SIGNAL_REALTIME_90,
-    TARGET_SIGNAL_REALTIME_91,
-    TARGET_SIGNAL_REALTIME_92,
-    TARGET_SIGNAL_REALTIME_93,
-    TARGET_SIGNAL_REALTIME_94,
-    TARGET_SIGNAL_REALTIME_95,
-    TARGET_SIGNAL_REALTIME_96,
-    TARGET_SIGNAL_REALTIME_97,
-    TARGET_SIGNAL_REALTIME_98,
-    TARGET_SIGNAL_REALTIME_99,
-    TARGET_SIGNAL_REALTIME_100,
-    TARGET_SIGNAL_REALTIME_101,
-    TARGET_SIGNAL_REALTIME_102,
-    TARGET_SIGNAL_REALTIME_103,
-    TARGET_SIGNAL_REALTIME_104,
-    TARGET_SIGNAL_REALTIME_105,
-    TARGET_SIGNAL_REALTIME_106,
-    TARGET_SIGNAL_REALTIME_107,
-    TARGET_SIGNAL_REALTIME_108,
-    TARGET_SIGNAL_REALTIME_109,
-    TARGET_SIGNAL_REALTIME_110,
-    TARGET_SIGNAL_REALTIME_111,
-    TARGET_SIGNAL_REALTIME_112,
-    TARGET_SIGNAL_REALTIME_113,
-    TARGET_SIGNAL_REALTIME_114,
-    TARGET_SIGNAL_REALTIME_115,
-    TARGET_SIGNAL_REALTIME_116,
-    TARGET_SIGNAL_REALTIME_117,
-    TARGET_SIGNAL_REALTIME_118,
-    TARGET_SIGNAL_REALTIME_119,
-    TARGET_SIGNAL_REALTIME_120,
-    TARGET_SIGNAL_REALTIME_121,
-    TARGET_SIGNAL_REALTIME_122,
-    TARGET_SIGNAL_REALTIME_123,
-    TARGET_SIGNAL_REALTIME_124,
-    TARGET_SIGNAL_REALTIME_125,
-    TARGET_SIGNAL_REALTIME_126,
-    TARGET_SIGNAL_REALTIME_127,
-
-#if defined(MACH) || defined(__MACH__)
-    /* Mach exceptions */
-    TARGET_EXC_BAD_ACCESS,
-    TARGET_EXC_BAD_INSTRUCTION,
-    TARGET_EXC_ARITHMETIC,
-    TARGET_EXC_EMULATION,
-    TARGET_EXC_SOFTWARE,
-    TARGET_EXC_BREAKPOINT,
-#endif
-    TARGET_SIGNAL_INFO,
-
-    /* Some signal we don't know about.  */
-    TARGET_SIGNAL_UNKNOWN,
-
-    /* Use whatever signal we use when one is not specifically specified
-       (for passing to proceed and so on).  */
-    TARGET_SIGNAL_DEFAULT,
-
-    /* Last and unused enum value, for sizing arrays, etc.  */
-    TARGET_SIGNAL_LAST
-  };
-
 /* the cleanup list records things that have to be undone
    if an error happens (descriptors to be closed, memory to be freed, etc.)
    Each link in the chain records a function to call and an
@@ -576,6 +372,7 @@
 extern void *address_to_host_pointer (CORE_ADDR addr);
 
 extern char *gdb_realpath (const char *);
+extern char *xfullpath (const char *);
 
 /* From demangle.c */
 
@@ -587,7 +384,6 @@
 typedef int (use_struct_convention_fn) (int gcc_p, struct type * value_type);
 extern use_struct_convention_fn generic_use_struct_convention;
 
-typedef unsigned char *(breakpoint_from_pc_fn) (CORE_ADDR * pcptr, int *lenptr);
 
 /* Annotation stuff.  */
 
@@ -783,10 +579,6 @@
 							    void *),
 						   void *));
 
-/* From findvar.c */
-
-extern int read_relative_register_raw_bytes (int, char *);
-
 /* Possible lvalue types.  Like enum language, this should be in
    value.h, but needs to be here for the same reason. */
 
@@ -1044,6 +836,11 @@
    "libiberty.h". */
 extern void xfree (void *);
 
+/* Utility macro to allocate typed memory.  Avoids errors like
+   ``struct foo *foo = xmalloc (sizeof bar)'' and ``struct foo *foo =
+   (struct foo *) xmalloc (sizeof bar)''.  */
+#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
+
 /* Like asprintf/vasprintf but get an internal_error if the call
    fails. */
 extern void xasprintf (char **ret, const char *format, ...) ATTR_FORMAT (printf, 2, 3);
@@ -1065,7 +862,7 @@
 
 extern NORETURN void verror (const char *fmt, va_list ap) ATTR_NORETURN;
 
-extern NORETURN void error (const char *fmt, ...) ATTR_NORETURN;
+extern NORETURN void error (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
 
 extern NORETURN void error_stream (struct ui_file *) ATTR_NORETURN;
 
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 346eaed..a431b1e 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,96 @@
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Releasing GDB): Revise `Create a Release'.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdb.texinfo: Delete obsolete references to a29k.
+
+2002-04-24  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Target Architecture Definition): Replace
+	IN_SIGTRAMP with PC_IN_SIGTRAMP.
+
+2002-04-24  David S. Miller  <davem@redhat.com>
+
+	* gdbint.texinfo (REGISTER_IN_WINDOW): Delete definition.
+
+2002-04-21  David S. Miller  <davem@redhat.com>
+
+	* gdbint.texinfo (SKIP_PROLOGUE_FRAMELESS_P): Delete definition.
+
+2002-04-21  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Target Architecture Definition): Delete
+	definition of HAVE_REGISTER_WINDOWS.
+
+2002-04-19  Eli Zaretskii  <eliz@is.elta.co.il>
+
+	* gdbint.texinfo (Releasing GDB, Coding): Fix typos.  Reported by
+	"Theodore A. Roth" <troth@verinet.com>.
+
+2002-04-15  Don Howard  <dhoward@redhat.com>
+
+	From Eli Zaretskii <eliz@is.elta.co.il>
+	* gdb.texinfo (show max-user-call-depth): Correct formatting.
+	Provide a better explaination of this feature. 
+
+2002-04-14  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Target Architecture Definition): Remove
+	FRAME_CHAIN_COMBINE.
+
+2002-04-12  Michael Chastain  <mec@shout.net>
+
+	* gdbint.texinfo (Obsolete Conditionals): Remove reference to
+	REG_STACK_SEGMENT.
+
+2002-04-09  Michael Chastain  <mec@shout.net>
+
+	* gdbint.texinfo (Obsolete Conditionals): Remove references to
+	PYRAMID_* macros.
+
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdb.texinfo (Bug Reporting): Document that the web is the
+	prefered way of submitting bug reports.
+	(Bug Reporting): Delete the s-mail address as the last resort.
+
+2002-04-05  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Target Architecture Definition): Delete
+	references to TARGET_WRITE_FP and write_fp.
+
+2002-03-27  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.texinfo: Document new commands dump, append, and restore.
+
+2002-03-27  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Releasing GDB): Revise the section `Before the
+	Branch'.
+
+2002-03-18  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdb.texinfo: Change all examples to @smallexample.
+	* gdbint.texinfo: Ditto.
+	
+2002-03-18  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Releasing GDB): Add section ``Versions and
+	Branches''.
+
+2002-03-18  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdbint.texinfo (Releasing GDB): Add the section``Branch Commit
+	Policy''.
+
+2002-03-04  Fred Fish  <fnf@redhat.com>
+
+	* gdbint.texinfo: Fix a bunch of typos (alsways, mirrorred,
+	expresson, suports, dependant, trhe, perhaphs, situtations,
+	explictily, taged, oportunity, unfortunatly).
+
 2002-02-24  Andrew Cagney  <ac131313@redhat.com>
 
 	* Makefile.in (gdb.info): Add explicit path to gdb.texinfo.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index e7d20a2..f37e288 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -767,24 +767,24 @@
 The most usual way to start @value{GDBN} is with one argument,
 specifying an executable program:
 
-@example
+@smallexample
 @value{GDBP} @var{program}
-@end example
+@end smallexample
 
 @noindent
 You can also start with both an executable program and a core file
 specified:
 
-@example
+@smallexample
 @value{GDBP} @var{program} @var{core}
-@end example
+@end smallexample
 
 You can, instead, specify a process ID as a second argument, if you want
 to debug a running process:
 
-@example
+@smallexample
 @value{GDBP} @var{program} 1234
-@end example
+@end smallexample
 
 @noindent
 would attach @value{GDBN} to process @code{1234} (unless you also have a file
@@ -799,9 +799,9 @@
 You can optionally have @code{@value{GDBP}} pass any arguments after the
 executable file to the inferior using @code{--args}.  This option stops
 option processing.
-@example
+@smallexample
 gdb --args gcc -O2 -c foo.c
-@end example
+@end smallexample
 This will cause @code{@value{GDBP}} to debug @code{gcc}, and to set
 @code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2 -c foo.c}.
 
@@ -819,9 +819,9 @@
 @noindent
 Type
 
-@example
+@smallexample
 @value{GDBP} -help
-@end example
+@end smallexample
 
 @noindent
 to display all available options and briefly describe their use
@@ -950,9 +950,9 @@
 on @file{.syms} files.)  A simple @value{GDBN} invocation to do nothing
 but build a @file{.syms} file for future use is:
 
-@example
+@smallexample
 gdb -batch -nx -mapped -readnow programname
-@end example
+@end smallexample
 
 @node Mode Options
 @subsection Choosing modes
@@ -991,9 +991,9 @@
 example to download and run a program on another computer; in order to
 make this more useful, the message
 
-@example
+@smallexample
 Program exited normally.
-@end example
+@end smallexample
 
 @noindent
 (which is ordinarily issued whenever a program running under
@@ -1283,17 +1283,17 @@
 @c complete accuracy in these examples; space introduced for clarity.
 @c If texinfo enhancements make it unnecessary, it would be nice to
 @c replace " @key" by "@key" in the following...
-@example
+@smallexample
 (@value{GDBP}) info bre @key{TAB}
-@end example
+@end smallexample
 
 @noindent
 @value{GDBN} fills in the rest of the word @samp{breakpoints}, since that is
 the only @code{info} subcommand beginning with @samp{bre}:
 
-@example
+@smallexample
 (@value{GDBP}) info breakpoints
-@end example
+@end smallexample
 
 @noindent
 You can either press @key{RET} at this point, to run the @code{info
@@ -1313,7 +1313,7 @@
 function names in your program that begin with those characters, for
 example:
 
-@example
+@smallexample
 (@value{GDBP}) b make_ @key{TAB}
 @exdent @value{GDBN} sounds bell; press @key{TAB} again, to see:
 make_a_section_from_file     make_environ
@@ -1322,7 +1322,7 @@
 make_cleanup                 make_reference_type
 make_command                 make_symbol_completion_list
 (@value{GDBP}) b make_
-@end example
+@end smallexample
 
 @noindent
 After displaying the available possibilities, @value{GDBN} copies your
@@ -1355,22 +1355,22 @@
 @value{GDBN} that it may need to consider more information than usual
 when you press @key{TAB} or @kbd{M-?} to request word completion:
 
-@example
+@smallexample
 (@value{GDBP}) b 'bubble( @kbd{M-?}
 bubble(double,double)    bubble(int,int)
 (@value{GDBP}) b 'bubble(
-@end example
+@end smallexample
 
 In some cases, @value{GDBN} can tell that completing a name requires using
 quotes.  When this happens, @value{GDBN} inserts the quote for you (while
 completing as much as it can) if you do not type the quote in the first
 place:
 
-@example
+@smallexample
 (@value{GDBP}) b bub @key{TAB}
 @exdent @value{GDBN} alters your input line to the following, and rings a bell:
 (@value{GDBP}) b 'bubble(
-@end example
+@end smallexample
 
 @noindent
 In general, @value{GDBN} can tell that a quote is needed (and inserts it) if
@@ -1806,9 +1806,9 @@
 
 For example, this command:
 
-@example
+@smallexample
 set env USER = foo
-@end example
+@end smallexample
 
 @noindent
 tells the debugged program, when subsequently run, that its user is named
@@ -1879,9 +1879,9 @@
 You can redirect your program's input and/or output using shell
 redirection with the @code{run} command.  For example,
 
-@example
+@smallexample
 run > outfile
-@end example
+@end smallexample
 
 @noindent
 starts your program, diverting its output to the file @file{outfile}.
@@ -1894,9 +1894,9 @@
 commands.  It also resets the controlling terminal for the child
 process, for future @code{run} commands.  For example,
 
-@example
+@smallexample
 tty /dev/ttyb
-@end example
+@end smallexample
 
 @noindent
 directs that processes started with subsequent @code{run} commands
@@ -2055,9 +2055,9 @@
 whose form varies depending on the particular system.  For example, on
 LynxOS, you might see
 
-@example
+@smallexample
 [New process 35 thread 27]
-@end example
+@end smallexample
 
 @noindent
 when @value{GDBN} notices a new thread.  In contrast, on an SGI system,
@@ -2126,9 +2126,9 @@
 whose form varies depending on the particular system.  For example, on
 HP-UX, you see
 
-@example
+@smallexample
 [New thread 2 (system thread 26594)]
-@end example
+@end smallexample
 
 @noindent
 when @value{GDBN} notices a new thread.
@@ -2155,7 +2155,7 @@
 @end table
 @c end table here to get a little more width for example
 
-@example
+@smallexample
 (@value{GDBP}) info threads
     * 3 system thread 26607  worker (wptr=0x7b09c318 "@@") \@*
                                at quicksort.c:137
@@ -2163,7 +2163,7 @@
                                from /usr/lib/libc.2
       1 system thread 27905  0x7b003498 in _brk () \@*
                                from /usr/lib/libc.2
-@end example
+@end smallexample
 
 @table @code
 @kindex thread @var{threadno}
@@ -2639,9 +2639,9 @@
 
 When you issue the @code{watch} command, @value{GDBN} reports
 
-@example
+@smallexample
 Hardware watchpoint @var{num}: @var{expr}
-@end example
+@end smallexample
 
 @noindent
 if it was able to set a hardware watchpoint.
@@ -2820,11 +2820,11 @@
 raised by calling a library function named @code{__raise_exception}
 which has the following ANSI C interface:
 
-@example
+@smallexample
     /* @var{addr} is where the exception identifier is stored.
        @var{id} is the exception identifier.  */
     void __raise_exception (void **addr, void *id);
-@end example
+@end smallexample
 
 @noindent
 To make the debugger catch all exceptions before any stack
@@ -3017,9 +3017,9 @@
 symbols not referenced in the context of the breakpoint, @value{GDBN}
 prints an error message:
 
-@example
+@smallexample
 No symbol "foo" in current context.
-@end example
+@end smallexample
 
 @noindent
 @value{GDBN} does
@@ -3128,14 +3128,14 @@
 For example, here is how you could use breakpoint commands to print the
 value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
 
-@example
+@smallexample
 break foo if x>0
 commands
 silent
 printf "x is %d\n",x
 cont
 end
-@end example
+@end smallexample
 
 One application for breakpoint commands is to compensate for one bug so
 you can test for another.  Put a breakpoint just after the erroneous line
@@ -3145,14 +3145,14 @@
 so that your program does not stop, and start with the @code{silent}
 command so that no output is produced.  Here is an example:
 
-@example
+@smallexample
 break 403
 commands
 silent
 set x = y + 4
 cont
 end
-@end example
+@end smallexample
 
 @node Breakpoint Menus
 @subsection Breakpoint menus
@@ -3211,10 +3211,10 @@
 attempting to run or continue a program with a breakpoint causes
 @value{GDBN} to print an error message:
 
-@example
+@smallexample
 Cannot insert breakpoints.
 The same program may be running in another process.
-@end example
+@end smallexample
 
 When this happens, you have three ways to proceed:
 
@@ -3419,13 +3419,13 @@
 (@code{frame}) command shows that execution is stopped at line
 @code{206}; yet when we use @code{until}, we get to line @code{195}:
 
-@example
+@smallexample
 (@value{GDBP}) f
 #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
 206                 expand_input();
 (@value{GDBP}) until
 195             for ( ; argc > 0; NEXTARG) @{
-@end example
+@end smallexample
 
 This happened because, for execution efficiency, the compiler had
 generated code for the loop closure test at the end, rather than the
@@ -3747,9 +3747,9 @@
 @cindex frameless execution
 Some compilers provide a way to compile functions so that they operate
 without stack frames.  (For example, the @value{GCC} option
-@example
+@smallexample
 @samp{-fomit-frame-pointer}
-@end example
+@end smallexample
 generates functions without a frame.)
 This is occasionally done with heavily used library functions to save
 the frame setup time.  @value{GDBN} has limited facilities for dealing
@@ -4404,6 +4404,7 @@
 * Registers::                   Registers
 * Floating Point Hardware::     Floating point hardware
 * Memory Region Attributes::    Memory region attributes
+* Dump/Restore Files::          Copy between memory and a file
 @end menu
 
 @node Expressions
@@ -4483,7 +4484,7 @@
 
 @noindent This means that in the function
 
-@example
+@smallexample
 foo (a)
      int a;
 @{
@@ -4493,7 +4494,7 @@
     bar (b);
   @}
 @}
-@end example
+@end smallexample
 
 @noindent
 you can examine and use the variable @code{a} whenever your program is
@@ -4515,10 +4516,10 @@
 @c info cannot cope with a :: index entry, but why deprive hard copy readers?
 @cindex @code{::}, context for variables/functions
 @end iftex
-@example
+@smallexample
 @var{file}::@var{variable}
 @var{function}::@var{variable}
-@end example
+@end smallexample
 
 @noindent
 Here @var{file} or @var{function} is the name of the context for the
@@ -4526,9 +4527,9 @@
 make sure @value{GDBN} parses the file name as a single word---for example,
 to print a global value of @code{x} defined in @file{f2.c}:
 
-@example
+@smallexample
 (@value{GDBP}) p 'f2.c'::x
-@end example
+@end smallexample
 
 @cindex C@t{++} scope resolution
 This use of @samp{::} is very rarely in conflict with the very similar
@@ -4565,9 +4566,9 @@
 might not be able to display values for such local variables.  If that
 happens, @value{GDBN} will print a message like this:
 
-@example
+@smallexample
 No symbol "foo" in current context.
-@end example
+@end smallexample
 
 To solve such problems, either recompile without optimizations, or use a
 different debug info format, if the compiler supports several such
@@ -4600,16 +4601,16 @@
 following those that hold the first element, and so on.  Here is an
 example.  If a program says
 
-@example
+@smallexample
 int *array = (int *) malloc (len * sizeof (int));
-@end example
+@end smallexample
 
 @noindent
 you can print the contents of @code{array} with
 
-@example
+@smallexample
 p *array@@len
-@end example
+@end smallexample
 
 The left operand of @samp{@@} must reside in memory.  Array values made
 with @samp{@@} in this way behave just like other arrays in terms of
@@ -4620,18 +4621,18 @@
 Another way to create an artificial array is to use a cast.
 This re-interprets a value as if it were an array.
 The value need not be in memory:
-@example
+@smallexample
 (@value{GDBP}) p/x (short[2])0x12345678
 $1 = @{0x1234, 0x5678@}
-@end example
+@end smallexample
 
 As a convenience, if you leave the array length out (as in
 @samp{(@var{type}[])@var{value}}) @value{GDBN} calculates the size to fill
 the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}:
-@example
+@smallexample
 (@value{GDBP}) p/x (short[])0x12345678
 $2 = @{0x1234, 0x5678@}
-@end example
+@end smallexample
 
 Sometimes the artificial array mechanism is not quite enough; in
 moderately complex data structures, the elements of interest may not
@@ -4644,13 +4645,13 @@
 structures, and you are interested in the values of a field @code{fv}
 in each structure.  Here is an example of what you might type:
 
-@example
+@smallexample
 set $i = 0
 p dtab[$i++]->fv
 @key{RET}
 @key{RET}
 @dots{}
-@end example
+@end smallexample
 
 @node Output Formats
 @section Output formats
@@ -4695,10 +4696,10 @@
 the nearest preceding symbol.  You can use this format used to discover
 where (in what function) an unknown address is located:
 
-@example
+@smallexample
 (@value{GDBP}) p/a 0x54320
 $3 = 0x54320 <_initialize_vx+396>
-@end example
+@end smallexample
 
 @noindent
 The command @code{info symbol 0x54320} yields similar results.
@@ -4714,9 +4715,9 @@
 
 For example, to print the program counter in hex (@pxref{Registers}), type
 
-@example
+@smallexample
 p/x $pc
-@end example
+@end smallexample
 
 @noindent
 Note that no space is required before the slash; this is because command
@@ -4843,10 +4844,10 @@
 to remove an expression from the list, you specify that number.
 The automatic display looks like this:
 
-@example
+@smallexample
 2: foo = 38
 3: bar[5] = (struct hack *) 0x3804
-@end example
+@end smallexample
 
 @noindent
 This display shows item numbers, expressions and their current values.  As with
@@ -5034,11 +5035,11 @@
 For example, here @value{GDBN} shows that a variable @code{ptt} points
 at another variable @code{t}, defined in @file{hi2.c}:
 
-@example
+@smallexample
 (@value{GDBP}) set print symbol-filename on
 (@value{GDBP}) p/a ptt
 $4 = 0xe008 <t in hi2.c>
-@end example
+@end smallexample
 
 @quotation
 @emph{Warning:} For pointers that point to a local variable, @samp{p/a}
@@ -5320,16 +5321,16 @@
 For example, suppose you have just printed a pointer to a structure and
 want to see the contents of the structure.  It suffices to type
 
-@example
+@smallexample
 p *$
-@end example
+@end smallexample
 
 If you have a chain of structures where the component @code{next} points
 to the next one, you can print the contents of the next one with this:
 
-@example
+@smallexample
 p *$.next
-@end example
+@end smallexample
 
 @noindent
 You can print successive links in the chain by repeating this
@@ -5338,10 +5339,10 @@
 Note that the history records values, not expressions.  If the value of
 @code{x} is 4 and you type these commands:
 
-@example
+@smallexample
 print x
 set x=5
-@end example
+@end smallexample
 
 @noindent
 then the value recorded in the value history by the @code{print} command
@@ -5385,9 +5386,9 @@
 expression, just as you would set a variable in your program.
 For example:
 
-@example
+@smallexample
 set $foo = *object_ptr
-@end example
+@end smallexample
 
 @noindent
 would save in @code{$foo} the value contained in the object pointed to by
@@ -5413,10 +5414,10 @@
 incremented or a pointer to be advanced.  For example, to print
 a field from successive elements of an array of structures:
 
-@example
+@smallexample
 set $i = 0
 print bar[$i++]->contents
-@end example
+@end smallexample
 
 @noindent
 Repeat that command by typing @key{RET}.
@@ -5488,16 +5489,16 @@
 register that contains the processor status.  For example,
 you could print the program counter in hex with
 
-@example
+@smallexample
 p/x $pc
-@end example
+@end smallexample
 
 @noindent
 or print the instruction to be executed next with
 
-@example
+@smallexample
 x/i $pc
-@end example
+@end smallexample
 
 @noindent
 or add four to the stack pointer@footnote{This is a way of removing
@@ -5508,9 +5509,9 @@
 regardless of machine architecture, use @code{return};
 see @ref{Returning, ,Returning from a function}.} with
 
-@example
+@smallexample
 set $sp += 4
-@end example
+@end smallexample
 
 Whenever possible, these four standard register names are available on
 your machine even though the machine has different canonical mnemonics,
@@ -5567,7 +5568,7 @@
 @end table
 
 @node Memory Region Attributes
-@section Memory Region Attributes 
+@section Memory region attributes 
 @cindex memory region attributes
 
 @dfn{Memory region attributes} allow you to describe special handling 
@@ -5697,6 +5698,82 @@
 @c @item noverify (default)
 @c @end table
 
+@node Dump/Restore Files
+@section Copy between memory and a file
+@cindex dump/restore files
+@cindex append data to a file
+@cindex dump data to a file
+@cindex restore data from a file
+@kindex dump
+@kindex append
+@kindex restore
+
+The commands @code{dump}, @code{append}, and @code{restore} are used
+for copying data between target memory and a file.  Data is written
+into a file using @code{dump} or @code{append}, and restored from a 
+file into memory by using @code{restore}.  Files may be binary, srec,
+intel hex, or tekhex (but only binary files can be appended).
+
+@table @code
+@kindex dump binary 
+@kindex append binary 
+@item dump binary memory @var{filename} @var{start_addr} @var{end_addr}
+Dump contents of memory from @var{start_addr} to @var{end_addr} into 
+raw binary format file @var{filename}.
+
+@item append binary memory @var{filename} @var{start_addr} @var{end_addr}
+Append contents of memory from @var{start_addr} to @var{end_addr} to
+raw binary format file @var{filename}.
+
+@item dump binary value @var{filename} @var{expression}
+Dump value of @var{expression} into raw binary format file @var{filename}.
+
+@item append binary memory @var{filename} @var{expression}
+Append value of @var{expression} to raw binary format file @var{filename}.
+
+@kindex dump ihex 
+@item dump ihex memory @var{filename} @var{start_addr} @var{end_addr}
+Dump contents of memory from @var{start_addr} to @var{end_addr} into 
+intel hex format file @var{filename}.
+
+@item dump ihex value @var{filename} @var{expression}
+Dump value of @var{expression} into intel hex format file @var{filename}.
+
+@kindex dump srec 
+@item dump srec memory @var{filename} @var{start_addr} @var{end_addr}
+Dump contents of memory from @var{start_addr} to @var{end_addr} into 
+srec format file @var{filename}.
+
+@item dump srec value @var{filename} @var{expression}
+Dump value of @var{expression} into srec format file @var{filename}.
+
+@kindex dump tekhex 
+@item dump tekhex memory @var{filename} @var{start_addr} @var{end_addr}
+Dump contents of memory from @var{start_addr} to @var{end_addr} into 
+tekhex format file @var{filename}.
+
+@item dump tekhex value @var{filename} @var{expression}
+Dump value of @var{expression} into tekhex format file @var{filename}.
+
+@item restore @var{filename} @var{[binary]} @var{bias} @var{start} @var{end}
+Restore the contents of file @var{filename} into memory.  The @code{restore}
+command can automatically recognize any known bfd file format, except for
+raw binary.  To restore a raw binary file you must use the optional argument
+@var{binary} after the filename.
+
+If @var{bias} is non-zero, its value will be added to the addresses 
+contained in the file.  Binary files always start at address zero, so
+they will be restored at address @var{bias}.  Other bfd files have
+a built-in location; they will be restored at offset @var{bias}
+from that location.
+
+If @var{start} and/or @var{end} are non-zero, then only data between
+file offset @var{start} and file offset @var{end} will be restored.
+These offsets are relative to the addresses in the file, before 
+the @var{bias} argument is applied.
+
+@end table
+
 @node Tracepoints
 @chapter Tracepoints
 @c This chapter is based on the documentation written by Michael
@@ -6368,7 +6445,7 @@
 @c size of all overlays.  This is intentional to remind the developer
 @c that overlays don't necessarily need to be the same size.
 
-@example
+@smallexample
 @group
     Data             Instruction            Larger
 Address Space       Address Space        Address Space
@@ -6396,7 +6473,7 @@
 
                     @anchor{A code overlay}A code overlay
 @end group
-@end example
+@end smallexample
 
 The diagram (@pxref{A code overlay}) shows a system with separate data
 and instruction address spaces.  To map an overlay, the program copies
@@ -6553,33 +6630,33 @@
 Normally, when @value{GDBN} prints a code address, it includes the name
 of the function the address falls in:
 
-@example
+@smallexample
 (gdb) print main
 $3 = @{int ()@} 0x11a0 <main>
-@end example
+@end smallexample
 @noindent
 When overlay debugging is enabled, @value{GDBN} recognizes code in
 unmapped overlays, and prints the names of unmapped functions with
 asterisks around them.  For example, if @code{foo} is a function in an
 unmapped overlay, @value{GDBN} prints it this way:
 
-@example
+@smallexample
 (gdb) overlay list
 No sections are mapped.
 (gdb) print foo
 $5 = @{int (int)@} 0x100000 <*foo*>
-@end example
+@end smallexample
 @noindent
 When @code{foo}'s overlay is mapped, @value{GDBN} prints the function's
 name normally:
 
-@example
+@smallexample
 (gdb) overlay list
 Section .ov.foo.text, loaded at 0x100000 - 0x100034, 
         mapped at 0x1016 - 0x104a
 (gdb) print foo
 $6 = @{int (int)@} 0x1016 <foo>
-@end example
+@end smallexample
 
 When overlay debugging is enabled, @value{GDBN} can find the correct
 address for functions and variables in an overlay, whether or not the
@@ -6621,7 +6698,7 @@
 @item @code{_ovly_table}:
 This variable must be an array of the following structures:
 
-@example
+@smallexample
 struct
 @{
   /* The overlay's mapped address.  */
@@ -6637,7 +6714,7 @@
      zero otherwise.  */
   unsigned long mapped;
 @}
-@end example
+@end smallexample
 
 @item @code{_novlys}:
 This variable must be a four-byte signed integer, holding the total
@@ -6698,7 +6775,7 @@
 You can build the test program using the @code{d10v-elf} GCC
 cross-compiler like this:
 
-@example
+@smallexample
 $ d10v-elf-gcc -g -c overlays.c
 $ d10v-elf-gcc -g -c ovlymgr.c
 $ d10v-elf-gcc -g -c foo.c
@@ -6707,7 +6784,7 @@
 $ d10v-elf-gcc -g -c grbx.c
 $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
                   baz.o grbx.o -Wl,-Td10v.ld -o overlays
-@end example
+@end smallexample
 
 The build process is identical for any other architecture, except that
 you must substitute the appropriate compiler and linker script for the
@@ -6836,9 +6913,9 @@
 source file were written in C, and @value{GDBN} was parsing Modula-2, a
 command such as:
 
-@example
+@smallexample
 print a = b + c
-@end example
+@end smallexample
 
 @noindent
 might not have the effect you intended.  In C, this means to add
@@ -7032,9 +7109,9 @@
 result to ``wrap around'' to lower values---for example, if @var{m} is
 the largest integer value, and @var{s} is the smallest, then
 
-@example
+@smallexample
 @var{m} + 1 @result{} @var{s}
-@end example
+@end smallexample
 
 This, too, is specific to individual languages, and in some cases
 specific to individual compilers or machines.  @xref{Support, ,
@@ -7394,9 +7471,9 @@
 @item
 Member function calls are allowed; you can use expressions like
 
-@example
+@smallexample
 count = aml->GetOriginal(x, y)
-@end example
+@end smallexample
 
 @vindex this@r{, inside C@t{++} member functions}
 @cindex namespace in C@t{++}
@@ -8014,11 +8091,11 @@
 (@code{.}) and the @value{GDBN} scope operator (@code{::}).  The two have
 similar syntax:
 
-@example
+@smallexample
 
 @var{module} . @var{id}
 @var{scope} :: @var{id}
-@end example
+@end smallexample
 
 @noindent
 where @var{scope} is the name of a module or a procedure,
@@ -8580,9 +8657,9 @@
 @samp{foo} @samp{.} @samp{c}.  To allow @value{GDBN} to recognize
 @samp{foo.c} as a single symbol, enclose it in single quotes; for example,
 
-@example
+@smallexample
 p 'foo.c'::x
-@end example
+@end smallexample
 
 @noindent
 looks up the value of @code{x} in the scope of the file @file{foo.c}.
@@ -8607,10 +8684,10 @@
 If no symbol is stored exactly at @var{addr}, @value{GDBN} prints the
 nearest symbol and an offset from it:
 
-@example
+@smallexample
 (@value{GDBP}) info symbol 0x54320
 _initialize_vx + 396 in section .text
-@end example
+@end smallexample
 
 @noindent
 This is the opposite of the @code{info address} command.  You can use
@@ -8641,14 +8718,14 @@
 
 For example, for this variable declaration:
 
-@example
+@smallexample
 struct complex @{double real; double imag;@} v;
-@end example
+@end smallexample
 
 @noindent
 the two commands give this output:
 
-@example
+@smallexample
 @group
 (@value{GDBP}) whatis v
 type = struct complex
@@ -8658,7 +8735,7 @@
     double imag;
 @}
 @end group
-@end example
+@end smallexample
 
 @noindent
 As with @code{whatis}, using @code{ptype} without an argument refers to
@@ -8854,9 +8931,9 @@
 To alter the value of a variable, evaluate an assignment expression.
 @xref{Expressions, ,Expressions}.  For example,
 
-@example
+@smallexample
 print x=4
-@end example
+@end smallexample
 
 @noindent
 stores the value 4 into the variable @code{x}, and then prints the
@@ -8880,22 +8957,22 @@
 a new value with just @samp{set width=13}, because @value{GDBN} has the
 command @code{set width}:
 
-@example
+@smallexample
 (@value{GDBP}) whatis width
 type = double
 (@value{GDBP}) p width
 $4 = 13
 (@value{GDBP}) set width=47
 Invalid syntax in expression.
-@end example
+@end smallexample
 
 @noindent
 The invalid expression, of course, is @samp{=47}.  In
 order to actually set the program's variable @code{width}, use
 
-@example
+@smallexample
 (@value{GDBP}) set var width=47
-@end example
+@end smallexample
 
 Because the @code{set} command has many subcommands that can conflict
 with the names of program variables, it is a good idea to use the
@@ -8904,7 +8981,7 @@
 to set a new value with just @samp{set g=4}, because @value{GDBN} has
 the command @code{set gnutarget}, abbreviated @code{set g}:
 
-@example
+@smallexample
 @group
 (@value{GDBP}) whatis g
 type = double
@@ -8922,16 +8999,16 @@
 (@value{GDBP}) show g
 The current BFD target is "=4".
 @end group
-@end example
+@end smallexample
 
 @noindent
 The program variable @code{g} did not change, and you silently set the
 @code{gnutarget} to an invalid value.  In order to set the variable
 @code{g}, use
 
-@example
+@smallexample
 (@value{GDBP}) set var g=4
-@end example
+@end smallexample
 
 @value{GDBN} allows more implicit conversions in assignments than C; you can
 freely store an integer value into a pointer variable or vice versa,
@@ -8946,9 +9023,9 @@
 to memory location @code{0x83040} as an integer (which implies a certain size
 and representation in memory), and
 
-@example
+@smallexample
 set @{int@}0x83040 = 4
-@end example
+@end smallexample
 
 @noindent
 stores the value 4 into that memory location.
@@ -8991,9 +9068,9 @@
 changes the address of where it @emph{will} run when you continue.  For
 example,
 
-@example
+@smallexample
 set $pc = 0x485
-@end example
+@end smallexample
 
 @noindent
 makes the next @code{continue} command or stepping command execute at
@@ -9082,12 +9159,6 @@
 with @code{void} returned values.  If the result is not void, it
 is printed and saved in the value history.
 
-@c OBSOLETE For the A29K, a user-controlled variable @code{call_scratch_address},
-@c OBSOLETE specifies the location of a scratch area to be used when @value{GDBN}
-@c OBSOLETE calls a function in the target.  This is necessary because the usual
-@c OBSOLETE method of putting the scratch area on the stack does not work in systems
-@c OBSOLETE that have separate instruction and data spaces.
-
 @node Patching
 @section Patching programs
 
@@ -9765,11 +9836,11 @@
 @item target sim
 Builtin CPU simulator.  @value{GDBN} includes simulators for most architectures.
 In general,
-@example
+@smallexample
         target sim
         load
         run
-@end example
+@end smallexample
 @noindent
 works; however, you cannot assume that a specific memory map, device
 drivers, or even basic I/O is available, although some simulators do
@@ -9891,21 +9962,21 @@
 Use the @code{set os} command to set the operating system.  This tells
 @value{GDBN} which kernel object display module to initialize:
 
-@example
+@smallexample
 (@value{GDBP}) set os cisco
-@end example
+@end smallexample
 
 If @code{set os} succeeds, @value{GDBN} will display some information
 about the operating system, and will create a new @code{info} command
 which can be used to query the target.  The @code{info} command is named
 after the operating system:
 
-@example
+@smallexample
 (@value{GDBP}) info cisco
 List of Cisco Kernel Objects
 Object     Description
 any        Any and all objects
-@end example
+@end smallexample
 
 Further subcommands can be used to query about particular objects known
 by the kernel.
@@ -10359,18 +10430,18 @@
 @item
 Insert these lines near the top of your program:
 
-@example
+@smallexample
 set_debug_traps();
 breakpoint();
-@end example
+@end smallexample
 
 @item
 For the 680x0 stub only, you need to provide a variable called
 @code{exceptionHook}.  Normally you just use:
 
-@example
+@smallexample
 void (*exceptionHook)() = 0;
-@end example
+@end smallexample
 
 @noindent
 but if before calling @code{set_debug_traps}, you set it to point to a
@@ -10408,27 +10479,27 @@
 to the target).  For example, to use a serial line connected to the
 device named @file{/dev/ttyb}:
 
-@example
+@smallexample
 target remote /dev/ttyb
-@end example
+@end smallexample
 
 @cindex TCP port, @code{target remote}
 To use a TCP connection, use an argument of the form
 @code{@var{host}:port}.  For example, to connect to port 2828 on a
 terminal server named @code{manyfarms}:
 
-@example
+@smallexample
 target remote manyfarms:2828
-@end example
+@end smallexample
 
 If your remote target is actually running on the same machine as
 your debugger session (e.g.@: a simulator of your target running on
 the same host), you can omit the hostname.  For example, to connect
 to port 1234 on your local machine:
 
-@example
+@smallexample
 target remote :1234
-@end example
+@end smallexample
 @noindent
 
 Note that the colon is still required here.
@@ -10448,10 +10519,10 @@
 and the serial drivers the remote system uses.  If you type the
 interrupt character once again, @value{GDBN} displays this prompt:
 
-@example
+@smallexample
 Interrupted while waiting for the program.
 Give up (and stop debugging it)?  (y or n)
-@end example
+@end smallexample
 
 If you type @kbd{y}, @value{GDBN} abandons the remote debugging session.
 (If you decide you want to try again later, you can use @samp{target
@@ -10845,9 +10916,9 @@
 
 @value{GDBN} comes up showing the prompt:
 
-@example
+@smallexample
 (vxgdb)
-@end example
+@end smallexample
 
 @menu
 * VxWorks Connection::          Connecting to VxWorks
@@ -10861,9 +10932,9 @@
 The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the
 network.  To connect to a target whose host name is ``@code{tt}'', type:
 
-@example
+@smallexample
 (vxgdb) target vxworks tt
-@end example
+@end smallexample
 
 @need 750
 @value{GDBN} displays messages like these:
@@ -10880,9 +10951,9 @@
 path (@pxref{Environment, ,Your program's environment}); if it fails
 to find an object file, it displays a message such as:
 
-@example
+@smallexample
 prog.o: No such file or directory.
-@end example
+@end smallexample
 
 When this happens, add the appropriate directory to the search path with
 the @value{GDBN} command @code{path}, and execute the @code{target}
@@ -10908,17 +10979,17 @@
 and in @file{@var{hostpath}/vw/demo/rdb} on the host.  To load this
 program, type this on VxWorks:
 
-@example
+@smallexample
 -> cd "@var{vxpath}/vw/demo/rdb"
-@end example
+@end smallexample
 
 @noindent
 Then, in @value{GDBN}, type:
 
-@example
+@smallexample
 (vxgdb) cd @var{hostpath}/vw/demo/rdb
 (vxgdb) load prog.o
-@end example
+@end smallexample
 
 @value{GDBN} displays a response similar to this:
 
@@ -10941,9 +11012,9 @@
 You can also attach to an existing task using the @code{attach} command as
 follows:
 
-@example
+@smallexample
 (vxgdb) attach @var{task}
-@end example
+@end smallexample
 
 @noindent
 where @var{task} is the VxWorks hexadecimal task ID.  The task can be running
@@ -10957,7 +11028,6 @@
 configurations.
 
 
-@c OBSOLETE * A29K Embedded::               AMD A29K Embedded
 @menu
 * ARM::                         ARM
 * H8/300::                      Hitachi H8/300
@@ -10976,251 +11046,6 @@
 * Z8000::                       Zilog Z8000
 @end menu
 
-@c OBSOLETE @node A29K Embedded
-@c OBSOLETE @subsection AMD A29K Embedded
-@c OBSOLETE 
-@c OBSOLETE @menu
-@c OBSOLETE * A29K UDI::
-@c OBSOLETE * A29K EB29K::
-@c OBSOLETE * Comms (EB29K)::               Communications setup
-@c OBSOLETE * gdb-EB29K::                   EB29K cross-debugging
-@c OBSOLETE * Remote Log::                  Remote log
-@c OBSOLETE @end menu
-@c OBSOLETE 
-@c OBSOLETE @table @code
-@c OBSOLETE 
-@c OBSOLETE @kindex target adapt
-@c OBSOLETE @item target adapt @var{dev}
-@c OBSOLETE Adapt monitor for A29K.
-@c OBSOLETE 
-@c OBSOLETE @kindex target amd-eb
-@c OBSOLETE @item target amd-eb @var{dev} @var{speed} @var{PROG}
-@c OBSOLETE @cindex AMD EB29K
-@c OBSOLETE Remote PC-resident AMD EB29K board, attached over serial lines.
-@c OBSOLETE @var{dev} is the serial device, as for @code{target remote};
-@c OBSOLETE @var{speed} allows you to specify the linespeed; and @var{PROG} is the
-@c OBSOLETE name of the program to be debugged, as it appears to DOS on the PC.
-@c OBSOLETE @xref{A29K EB29K, ,EBMON protocol for AMD29K}.
-@c OBSOLETE 
-@c OBSOLETE @end table
-@c OBSOLETE 
-@c OBSOLETE @node A29K UDI
-@c OBSOLETE @subsubsection A29K UDI
-@c OBSOLETE 
-@c OBSOLETE @cindex UDI
-@c OBSOLETE @cindex AMD29K via UDI
-@c OBSOLETE 
-@c OBSOLETE @value{GDBN} supports AMD's UDI (``Universal Debugger Interface'')
-@c OBSOLETE protocol for debugging the a29k processor family.  To use this
-@c OBSOLETE configuration with AMD targets running the MiniMON monitor, you need the
-@c OBSOLETE program @code{MONTIP}, available from AMD at no charge.  You can also
-@c OBSOLETE use @value{GDBN} with the UDI-conformant a29k simulator program
-@c OBSOLETE @code{ISSTIP}, also available from AMD.
-@c OBSOLETE 
-@c OBSOLETE @table @code
-@c OBSOLETE @item target udi @var{keyword}
-@c OBSOLETE @kindex udi
-@c OBSOLETE Select the UDI interface to a remote a29k board or simulator, where
-@c OBSOLETE @var{keyword} is an entry in the AMD configuration file @file{udi_soc}.
-@c OBSOLETE This file contains keyword entries which specify parameters used to
-@c OBSOLETE connect to a29k targets.  If the @file{udi_soc} file is not in your
-@c OBSOLETE working directory, you must set the environment variable @samp{UDICONF}
-@c OBSOLETE to its pathname.
-@c OBSOLETE @end table
-@c OBSOLETE 
-@c OBSOLETE @node A29K EB29K
-@c OBSOLETE @subsubsection EBMON protocol for AMD29K
-@c OBSOLETE 
-@c OBSOLETE @cindex EB29K board
-@c OBSOLETE @cindex running 29K programs
-@c OBSOLETE 
-@c OBSOLETE AMD distributes a 29K development board meant to fit in a PC, together
-@c OBSOLETE with a DOS-hosted monitor program called @code{EBMON}.  As a shorthand
-@c OBSOLETE term, this development system is called the ``EB29K''.  To use
-@c OBSOLETE @value{GDBN} from a Unix system to run programs on the EB29K board, you
-@c OBSOLETE must first connect a serial cable between the PC (which hosts the EB29K
-@c OBSOLETE board) and a serial port on the Unix system.  In the following, we
-@c OBSOLETE assume you've hooked the cable between the PC's @file{COM1} port and
-@c OBSOLETE @file{/dev/ttya} on the Unix system.
-@c OBSOLETE 
-@c OBSOLETE @node Comms (EB29K)
-@c OBSOLETE @subsubsection Communications setup
-@c OBSOLETE 
-@c OBSOLETE The next step is to set up the PC's port, by doing something like this
-@c OBSOLETE in DOS on the PC:
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE C:\> MODE com1:9600,n,8,1,none
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE @noindent
-@c OBSOLETE This example---run on an MS DOS 4.0 system---sets the PC port to 9600
-@c OBSOLETE bps, no parity, eight data bits, one stop bit, and no ``retry'' action;
-@c OBSOLETE you must match the communications parameters when establishing the Unix
-@c OBSOLETE end of the connection as well.
-@c OBSOLETE @c FIXME: Who knows what this "no retry action" crud from the DOS manual may
-@c OBSOLETE @c       mean?  It's optional; leave it out? ---doc@cygnus.com, 25feb91
-@c OBSOLETE @c
-@c OBSOLETE @c It's optional, but it's unwise to omit it: who knows what is the
-@c OBSOLETE @c default value set when the DOS machines boots?  "No retry" means that
-@c OBSOLETE @c the DOS serial device driver won't retry the operation if it fails;
-@c OBSOLETE @c I understand that this is needed because the GDB serial protocol
-@c OBSOLETE @c handles any errors and retransmissions itself. ---Eli Zaretskii, 3sep99
-@c OBSOLETE 
-@c OBSOLETE To give control of the PC to the Unix side of the serial line, type
-@c OBSOLETE the following at the DOS console:
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE C:\> CTTY com1
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE @noindent
-@c OBSOLETE (Later, if you wish to return control to the DOS console, you can use
-@c OBSOLETE the command @code{CTTY con}---but you must send it over the device that
-@c OBSOLETE had control, in our example over the @file{COM1} serial line.)
-@c OBSOLETE 
-@c OBSOLETE From the Unix host, use a communications program such as @code{tip} or
-@c OBSOLETE @code{cu} to communicate with the PC; for example,
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE cu -s 9600 -l /dev/ttya
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE @noindent
-@c OBSOLETE The @code{cu} options shown specify, respectively, the linespeed and the
-@c OBSOLETE serial port to use.  If you use @code{tip} instead, your command line
-@c OBSOLETE may look something like the following:
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE tip -9600 /dev/ttya
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE @noindent
-@c OBSOLETE Your system may require a different name where we show
-@c OBSOLETE @file{/dev/ttya} as the argument to @code{tip}.  The communications
-@c OBSOLETE parameters, including which port to use, are associated with the
-@c OBSOLETE @code{tip} argument in the ``remote'' descriptions file---normally the
-@c OBSOLETE system table @file{/etc/remote}.
-@c OBSOLETE @c FIXME: What if anything needs doing to match the "n,8,1,none" part of
-@c OBSOLETE @c the DOS side's comms setup?  cu can support -o (odd
-@c OBSOLETE @c parity), -e (even parity)---apparently no settings for no parity or
-@c OBSOLETE @c for character size.  Taken from stty maybe...?  John points out tip
-@c OBSOLETE @c can set these as internal variables, eg ~s parity=none; man stty
-@c OBSOLETE @c suggests that it *might* work to stty these options with stdin or
-@c OBSOLETE @c stdout redirected... ---doc@cygnus.com, 25feb91
-@c OBSOLETE @c
-@c OBSOLETE @c There's nothing to be done for the "none" part of the DOS MODE
-@c OBSOLETE @c command.  The rest of the parameters should be matched by the
-@c OBSOLETE @c baudrate, bits, and parity used by the Unix side. ---Eli Zaretskii, 3Sep99
-@c OBSOLETE 
-@c OBSOLETE @kindex EBMON
-@c OBSOLETE Using the @code{tip} or @code{cu} connection, change the DOS working
-@c OBSOLETE directory to the directory containing a copy of your 29K program, then
-@c OBSOLETE start the PC program @code{EBMON} (an EB29K control program supplied
-@c OBSOLETE with your board by AMD).  You should see an initial display from
-@c OBSOLETE @code{EBMON} similar to the one that follows, ending with the
-@c OBSOLETE @code{EBMON} prompt @samp{#}---
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE C:\> G:
-@c OBSOLETE 
-@c OBSOLETE G:\> CD \usr\joe\work29k
-@c OBSOLETE 
-@c OBSOLETE G:\USR\JOE\WORK29K> EBMON
-@c OBSOLETE Am29000 PC Coprocessor Board Monitor, version 3.0-18
-@c OBSOLETE Copyright 1990 Advanced Micro Devices, Inc.
-@c OBSOLETE Written by Gibbons and Associates, Inc.
-@c OBSOLETE 
-@c OBSOLETE Enter '?' or 'H' for help
-@c OBSOLETE 
-@c OBSOLETE PC Coprocessor Type   = EB29K
-@c OBSOLETE I/O Base              = 0x208
-@c OBSOLETE Memory Base           = 0xd0000
-@c OBSOLETE 
-@c OBSOLETE Data Memory Size      = 2048KB
-@c OBSOLETE Available I-RAM Range = 0x8000 to 0x1fffff
-@c OBSOLETE Available D-RAM Range = 0x80002000 to 0x801fffff
-@c OBSOLETE 
-@c OBSOLETE PageSize              = 0x400
-@c OBSOLETE Register Stack Size   = 0x800
-@c OBSOLETE Memory Stack Size     = 0x1800
-@c OBSOLETE 
-@c OBSOLETE CPU PRL               = 0x3
-@c OBSOLETE Am29027 Available     = No
-@c OBSOLETE Byte Write Available  = Yes
-@c OBSOLETE 
-@c OBSOLETE # ~.
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE Then exit the @code{cu} or @code{tip} program (done in the example by
-@c OBSOLETE typing @code{~.} at the @code{EBMON} prompt).  @code{EBMON} keeps
-@c OBSOLETE running, ready for @value{GDBN} to take over.
-@c OBSOLETE 
-@c OBSOLETE For this example, we've assumed what is probably the most convenient
-@c OBSOLETE way to make sure the same 29K program is on both the PC and the Unix
-@c OBSOLETE system: a PC/NFS connection that establishes ``drive @file{G:}'' on the
-@c OBSOLETE PC as a file system on the Unix host.  If you do not have PC/NFS or
-@c OBSOLETE something similar connecting the two systems, you must arrange some
-@c OBSOLETE other way---perhaps floppy-disk transfer---of getting the 29K program
-@c OBSOLETE from the Unix system to the PC; @value{GDBN} does @emph{not} download it over the
-@c OBSOLETE serial line.
-@c OBSOLETE 
-@c OBSOLETE @node gdb-EB29K
-@c OBSOLETE @subsubsection EB29K cross-debugging
-@c OBSOLETE 
-@c OBSOLETE Finally, @code{cd} to the directory containing an image of your 29K
-@c OBSOLETE program on the Unix system, and start @value{GDBN}---specifying as argument the
-@c OBSOLETE name of your 29K program:
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE cd /usr/joe/work29k
-@c OBSOLETE @value{GDBP} myfoo
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE @need 500
-@c OBSOLETE Now you can use the @code{target} command:
-@c OBSOLETE 
-@c OBSOLETE @example
-@c OBSOLETE target amd-eb /dev/ttya 9600 MYFOO
-@c OBSOLETE @c FIXME: test above 'target amd-eb' as spelled, with caps!  caps are meant to
-@c OBSOLETE @c emphasize that this is the name as seen by DOS (since I think DOS is
-@c OBSOLETE @c single-minded about case of letters).  ---doc@cygnus.com, 25feb91
-@c OBSOLETE @end example
-@c OBSOLETE 
-@c OBSOLETE @noindent
-@c OBSOLETE In this example, we've assumed your program is in a file called
-@c OBSOLETE @file{myfoo}.  Note that the filename given as the last argument to
-@c OBSOLETE @code{target amd-eb} should be the name of the program as it appears to DOS.
-@c OBSOLETE In our example this is simply @code{MYFOO}, but in general it can include
-@c OBSOLETE a DOS path, and depending on your transfer mechanism may not resemble
-@c OBSOLETE the name on the Unix side.
-@c OBSOLETE 
-@c OBSOLETE At this point, you can set any breakpoints you wish; when you are ready
-@c OBSOLETE to see your program run on the 29K board, use the @value{GDBN} command
-@c OBSOLETE @code{run}.
-@c OBSOLETE 
-@c OBSOLETE To stop debugging the remote program, use the @value{GDBN} @code{detach}
-@c OBSOLETE command.
-@c OBSOLETE 
-@c OBSOLETE To return control of the PC to its console, use @code{tip} or @code{cu}
-@c OBSOLETE once again, after your @value{GDBN} session has concluded, to attach to
-@c OBSOLETE @code{EBMON}.  You can then type the command @code{q} to shut down
-@c OBSOLETE @code{EBMON}, returning control to the DOS command-line interpreter.
-@c OBSOLETE Type @kbd{CTTY con} to return command input to the main DOS console,
-@c OBSOLETE and type @kbd{~.} to leave @code{tip} or @code{cu}.
-@c OBSOLETE 
-@c OBSOLETE @node Remote Log
-@c OBSOLETE @subsubsection Remote log
-@c OBSOLETE @cindex @file{eb.log}, a log file for EB29K
-@c OBSOLETE @cindex log file for EB29K
-@c OBSOLETE 
-@c OBSOLETE The @code{target amd-eb} command creates a file @file{eb.log} in the
-@c OBSOLETE current working directory, to help debug problems with the connection.
-@c OBSOLETE @file{eb.log} records all the output from @code{EBMON}, including echoes
-@c OBSOLETE of the commands sent to it.  Running @samp{tail -f} on this file in
-@c OBSOLETE another window often helps to understand trouble with @code{EBMON}, or
-@c OBSOLETE unexpected events on the PC side of the connection.
-
 @node ARM
 @subsection ARM
 
@@ -11335,7 +11160,7 @@
 for example, @samp{asyncstr 2} below runs @code{asyncstr} on
 @code{COM2}.
 
-@example
+@smallexample
 C:\H8300\TEST> asynctsr 2
 C:\H8300\TEST> mode com2:9600,n,8,1,p
 
@@ -11343,7 +11168,7 @@
 
 COM2: 9600, n, 8, 1, p
 
-@end example
+@end smallexample
 
 @quotation
 @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with
@@ -11516,9 +11341,9 @@
 options, you are prompted for what serial port to use, @emph{before} you
 reach the ordinary @value{GDBN} prompt:
 
-@example
+@smallexample
 Attach /dev/ttyNN -- specify NN, or "quit" to quit:
-@end example
+@end smallexample
 
 @noindent
 Respond to the prompt with whatever suffix (after @samp{/dev/tty})
@@ -11681,13 +11506,13 @@
 port, and loads and runs a program called @var{prog} through the
 debugger:
 
-@example
+@smallexample
 host$ @value{GDBP} @var{prog}
 @value{GDBN} is free software and @dots{}
 (@value{GDBP}) target mips /dev/ttyb
 (@value{GDBP}) load @var{prog}
 (@value{GDBP}) run
-@end example
+@end smallexample
 
 @item target mips @var{hostname}:@var{portnumber}
 On some @value{GDBN} host configurations, you can specify a TCP
@@ -11884,15 +11709,15 @@
 load it on the target.  You may also want to add the options @samp{-n} or
 @samp{-N} in order to reduce the size of the sections.  Example:
 
-@example
+@smallexample
 sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
-@end example
+@end smallexample
 
 You can use @code{objdump} to verify that the addresses are what you intended:
 
-@example
+@smallexample
 sparclet-aout-objdump --headers --syms prog
-@end example
+@end smallexample
 
 @cindex running, on Sparclet
 Once you have set
@@ -11902,9 +11727,9 @@
 
 @value{GDBN} comes up showing the prompt:
 
-@example
+@smallexample
 (gdbslet)
-@end example
+@end smallexample
 
 @menu
 * Sparclet File::                Setting the file to debug
@@ -11918,9 +11743,9 @@
 
 The @value{GDBN} command @code{file} lets you choose with program to debug.
 
-@example
+@smallexample
 (gdbslet) file prog
-@end example
+@end smallexample
 
 @need 1000
 @value{GDBN} then attempts to read the symbol table of @file{prog}.
@@ -11935,9 +11760,9 @@
 If it fails
 to find a file, it displays a message such as:
 
-@example
+@smallexample
 prog: No such file or directory.
-@end example
+@end smallexample
 
 When this happens, add the appropriate directories to the search paths with
 the @value{GDBN} commands @code{path} and @code{dir}, and execute the
@@ -11949,18 +11774,18 @@
 The @value{GDBN} command @code{target} lets you connect to a Sparclet target.
 To connect to a target on serial port ``@code{ttya}'', type:
 
-@example
+@smallexample
 (gdbslet) target sparclet /dev/ttya
 Remote target sparclet connected to /dev/ttya
 main () at ../prog.c:3
-@end example
+@end smallexample
 
 @need 750
 @value{GDBN} displays messages like these:
 
-@example
+@smallexample
 Connected to ttya.
-@end example
+@end smallexample
 
 @node Sparclet Download
 @subsubsection Sparclet download
@@ -11979,10 +11804,10 @@
 @file{prog} was linked to text address 0x1201000, with data at 0x12010160
 and bss at 0x12010170, in @value{GDBN}, type:
 
-@example
+@smallexample
 (gdbslet) load prog 0x12010000
 Loading section .text, size 0xdb0 vma 0x12010000
-@end example
+@end smallexample
 
 If the code is loaded at a different address then what the program was linked
 to, you may need to use the @code{section} and @code{add-symbol-file} commands
@@ -11996,7 +11821,7 @@
 commands, @code{b}, @code{step}, @code{run}, etc.  See the @value{GDBN}
 manual for the list of commands.
 
-@example
+@smallexample
 (gdbslet) b main
 Breakpoint 1 at 0x12010000: file prog.c, line 3.
 (gdbslet) run
@@ -12006,7 +11831,7 @@
 (gdbslet) step
 4        char *execarg = "hello!";
 (gdbslet)
-@end example
+@end smallexample
 
 @node Sparclite
 @subsection Fujitsu Sparclite
@@ -12031,9 +11856,9 @@
 To connect your ST2000 to the host system, see the manufacturer's
 manual.  Once the ST2000 is physically attached, you can run:
 
-@example
+@smallexample
 target st2000 @var{dev} @var{speed}
-@end example
+@end smallexample
 
 @noindent
 to establish it as your debugging environment.  @var{dev} is normally
@@ -12509,11 +12334,11 @@
 lot of stupid questions to confirm certain commands.  For example, if
 you try to run a program which is already running:
 
-@example
+@smallexample
 (@value{GDBP}) run
 The program being debugged has been started already.
 Start it from the beginning? (y or n)
-@end example
+@end smallexample
 
 If you are willing to unflinchingly face the consequences of your own
 commands, you can disable this ``feature'':
@@ -12704,6 +12529,14 @@
 not its documentation).  If no @var{commandname} is given, display the
 definitions for all user-defined commands.
 
+@kindex show max-user-call-depth
+@kindex set max-user-call-depth
+@item show max-user-call-depth
+@itemx set max-user-call-depth
+The value of @code{max-user-call-depth} controls how many recursion
+levels are allowed in user-defined commands before GDB suspects an
+infinite recursion and aborts the command.
+
 @end table
 
 When user-defined commands are executed, the
@@ -12753,7 +12586,7 @@
 single-stepping, but treat them normally during normal execution,
 you could define:
 
-@example
+@smallexample
 define hook-stop
 handle SIGALRM nopass
 end
@@ -12765,13 +12598,13 @@
 define hook-continue
 handle SIGLARM pass
 end
-@end example
+@end smallexample
 
 As a further example, to hook at the begining and end of the @code{echo}
 command, and to add extra text to the beginning and end of the message, 
 you could define:
 
-@example
+@smallexample
 define hook-echo
 echo <<<---
 end
@@ -12784,7 +12617,7 @@
 <<<---Hello World--->>>
 (@value{GDBP})
 
-@end example
+@end smallexample
 
 You can define a hook for any single-word command in @value{GDBN}, but
 not for command aliases; you should define a hook for the basic command
@@ -12882,9 +12715,9 @@
 not terminate execution of the command file --- execution continues with
 the next command.
 
-@example
+@smallexample
 gdb < cmds > log 2>&1
-@end example
+@end smallexample
 
 (The syntax above will vary depending on the shell used.) This example
 will execute commands from the file @file{cmds}. All output and errors
@@ -12917,19 +12750,19 @@
 A backslash at the end of @var{text} can be used, as in C, to continue
 the command onto subsequent lines.  For example,
 
-@example
+@smallexample
 echo This is some text\n\
 which is continued\n\
 onto several lines.\n
-@end example
+@end smallexample
 
 produces the same output as
 
-@example
+@smallexample
 echo This is some text\n
 echo which is continued\n
 echo onto several lines.\n
-@end example
+@end smallexample
 
 @kindex output
 @item output @var{expression}
@@ -12955,9 +12788,9 @@
 @c Either this is a bug, or the manual should document what formats are
 @c supported.
 
-@example
+@smallexample
 printf (@var{string}, @var{expressions}@dots{});
-@end example
+@end smallexample
 
 For example, you can print two values in hex like this:
 
@@ -13325,9 +13158,9 @@
 several configurations around, with different names) you can set the
 Emacs variable @code{gdb-command-name}; for example,
 
-@example
+@smallexample
 (setq gdb-command-name "mygdb")
-@end example
+@end smallexample
 
 @noindent
 (preceded by @kbd{M-:} or @kbd{ESC :}, or typed in the @code{*scratch*} buffer, or
@@ -13497,12 +13330,11 @@
 distribution.
 @c should add a web page ref...
 
-In any event, we also recommend that you send bug reports for
-@value{GDBN} to this addresses:
-
-@example
-bug-gdb@@gnu.org
-@end example
+In any event, we also recommend that you submit bug reports for
+@value{GDBN}.  The prefered method is to submit them directly using
+@uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web
+page}.  Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can
+be used.
 
 @strong{Do not send bug reports to @samp{info-gdb}, or to
 @samp{help-gdb}, or to any newsgroups.}  Most users of @value{GDBN} do
@@ -13518,16 +13350,6 @@
 we may be unable to reach you.  For this reason, it is better to send
 bug reports to the mailing list.
 
-As a last resort, send bug reports on paper to:
-
-@example
-@sc{gnu} Debugger Bugs
-Free Software Foundation Inc.
-59 Temple Place - Suite 330
-Boston, MA 02111-1307
-USA
-@end example
-
 The fundamental principle of reporting bugs usefully is this:
 @strong{report all the facts}.  If you are not sure whether to state a
 fact or leave it out, state it!
@@ -13691,9 +13513,9 @@
 The release also includes the source for the reference card.  You
 can format it, using @TeX{}, by typing:
 
-@example
+@smallexample
 make refcard.dvi
-@end example
+@end smallexample
 
 The @value{GDBN} reference card is designed to print in @dfn{landscape}
 mode on US ``letter'' size paper;
@@ -13727,10 +13549,10 @@
 @value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of
 version @value{GDBVN}), you can make the Info file by typing:
 
-@example
+@smallexample
 cd gdb
 make gdb.info
-@end example
+@end smallexample
 
 If you want to typeset and print copies of this manual, you need @TeX{},
 a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the
@@ -13756,9 +13578,9 @@
 subdirectory of the main source directory (for example, to
 @file{gdb-@value{GDBVN}/gdb}) and type:
 
-@example
+@smallexample
 make gdb.dvi
-@end example
+@end smallexample
 
 Then give @file{gdb.dvi} to your @sc{dvi} printing program.
 
@@ -13824,11 +13646,11 @@
 
 For example:
 
-@example
+@smallexample
 cd gdb-@value{GDBVN}
 ./configure @var{host}
 make
-@end example
+@end smallexample
 
 @noindent
 where @var{host} is an identifier such as @samp{sun4} or
@@ -13846,9 +13668,9 @@
 system does not recognize this automatically when you run a different
 shell, you may need to run @code{sh} on it explicitly:
 
-@example
+@smallexample
 sh configure @var{host}
-@end example
+@end smallexample
 
 If you run @code{configure} from a directory that contains source
 directories for multiple libraries or programs, such as the
@@ -13863,12 +13685,12 @@
 For example, with version @value{GDBVN}, type the following to configure only
 the @code{bfd} subdirectory:
 
-@example
+@smallexample
 @group
 cd gdb-@value{GDBVN}/bfd
 ../configure @var{host}
 @end group
-@end example
+@end smallexample
 
 You can install @code{@value{GDBP}} anywhere; it has no hardwired paths.
 However, you should make sure that the shell on your path (named by
@@ -13904,7 +13726,7 @@
 For example, with version @value{GDBVN}, you can build @value{GDBN} in a
 separate directory for a Sun 4 like this:
 
-@example
+@smallexample
 @group
 cd gdb-@value{GDBVN}
 mkdir ../gdb-sun4
@@ -13912,7 +13734,7 @@
 ../gdb-@value{GDBVN}/configure sun4
 make
 @end group
-@end example
+@end smallexample
 
 When @code{configure} builds a configuration using a remote source
 directory, it creates a tree for the binaries with the same structure
@@ -13951,9 +13773,9 @@
 aliases are also supported.  The full naming scheme encodes three pieces
 of information in the following pattern:
 
-@example
+@smallexample
 @var{architecture}-@var{vendor}-@var{os}
-@end example
+@end smallexample
 
 For example, you can use the alias @code{sun4} as a @var{host} argument,
 or as the value for @var{target} in a @code{--target=@var{target}}
@@ -13993,7 +13815,7 @@
 several other options not listed here.  @inforef{What Configure
 Does,,configure.info}, for a full explanation of @code{configure}.
 
-@example
+@smallexample
 configure @r{[}--help@r{]}
           @r{[}--prefix=@var{dir}@r{]}
           @r{[}--exec-prefix=@var{dir}@r{]}
@@ -14001,7 +13823,7 @@
           @r{[}--norecursion@r{]} @r{[}--rm@r{]}
           @r{[}--target=@var{target}@r{]}
           @var{host}
-@end example
+@end smallexample
 
 @noindent
 You may introduce options with a single @samp{-} rather than
@@ -14119,9 +13941,9 @@
 @samp{$}, the actual @var{packet-data}, and the terminating character
 @samp{#} followed by a two-digit @var{checksum}:
 
-@example
+@smallexample
 @code{$}@var{packet-data}@code{#}@var{checksum}
-@end example
+@end smallexample
 @noindent
 
 @cindex checksum, for @value{GDBN} remote
@@ -14133,9 +13955,9 @@
 Implementors should note that prior to @value{GDBN} 5.0 the protocol
 specification also included an optional two-digit @var{sequence-id}:
 
-@example
+@smallexample
 @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
-@end example
+@end smallexample
 
 @cindex sequence-id, for @value{GDBN} remote
 @noindent
@@ -14149,10 +13971,10 @@
 the package was received correctly) or @samp{-} (to request
 retransmission):
 
-@example
+@smallexample
 <- @code{$}@var{packet-data}@code{#}@var{checksum}
 -> @code{+}
-@end example
+@end smallexample
 @noindent
 
 The host (@value{GDBN}) sends @var{command}s, and the target (the
@@ -14185,9 +14007,9 @@
 character are two hex digits that indicate the size of the packet.
 
 So:
-@example
+@smallexample
 "@code{0* }"
-@end example
+@end smallexample
 @noindent
 means the same as "0000".
 
@@ -14923,7 +14745,7 @@
 Example sequence of a target being re-started.  Notice how the restart
 does not get any direct output:
 
-@example
+@smallexample
 <- @code{R00}
 -> @code{+}
 @emph{target restarts}
@@ -14931,11 +14753,11 @@
 -> @code{+}
 -> @code{T001:1234123412341234}
 <- @code{+}
-@end example
+@end smallexample
 
 Example sequence of a target being stepped by a single instruction:
 
-@example
+@smallexample
 <- @code{G1445...}
 -> @code{+}
 <- @code{s}
@@ -14947,7 +14769,7 @@
 -> @code{+}
 -> @code{1455...}
 <- @code{+}
-@end example
+@end smallexample
 
 @include gpl.texi
 
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index b046171..3387cdb 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -239,9 +239,9 @@
 machine-independent part of @value{GDBN}, except that it is used when
 setting up a new frame from scratch, as follows:
 
-@example
-      create_new_frame (read_register (FP_REGNUM), read_pc ()));
-@end example
+@smallexample
+create_new_frame (read_register (FP_REGNUM), read_pc ()));
+@end smallexample
 
 @cindex frame pointer register
 Other than that, all the meaning imparted to @code{FP_REGNUM} is
@@ -291,7 +291,7 @@
 Since they depend on hardware resources, hardware breakpoints may be
 limited in number; when the user asks for more, @value{GDBN} will
 start trying to set software breakpoints.  (On some architectures,
-notably the 32-bit x86 platforms, @value{GDBN} cannot alsways know
+notably the 32-bit x86 platforms, @value{GDBN} cannot always know
 whether there's enough hardware resources to insert all the hardware
 breakpoints and watchpoints.  On those platforms, @value{GDBN} prints
 an error message only when the program being debugged is continued.)
@@ -453,7 +453,7 @@
 possible values of the enumerated data type @code{target_hw_bp_type},
 defined by @file{breakpoint.h} as follows:
 
-@example
+@smallexample
  enum target_hw_bp_type
    @{
      hw_write   = 0, /* Common (write) HW watchpoint */
@@ -461,7 +461,7 @@
      hw_access  = 2, /* Access (read or write) HW watchpoint */
      hw_execute = 3  /* Execute HW breakpoint */
    @};
-@end example
+@end smallexample
 
 @noindent
 These two macros should return 0 for success, non-zero for failure.
@@ -628,8 +628,8 @@
 region for the same access types; if found, it just increments the
 reference count of that debug register, thus implementing debug
 register sharing between watchpoints.  If no such register is found,
-the function looks for a vacant debug register, sets its mirrorred
-value to @var{addr}, sets the mirrorred value of DR7 Debug Control
+the function looks for a vacant debug register, sets its mirrored
+value to @var{addr}, sets the mirrored value of DR7 Debug Control
 register as appropriate for the @var{len} and @var{type} parameters,
 and then passes the new values of the debug register and DR7 to the
 inferior by calling @code{I386_DR_LOW_SET_ADDR} and
@@ -638,8 +638,8 @@
 each debug register.
 
 @code{i386_remove_watchpoint} does the opposite: it resets the address
-in the mirrorred value of the debug register and its read/write and
-length bits in the mirrorred value of DR7, then passes these new
+in the mirrored value of the debug register and its read/write and
+length bits in the mirrored value of DR7, then passes these new
 values to the inferior via @code{I386_DR_LOW_RESET_ADDR} and
 @code{I386_DR_LOW_SET_CONTROL}.  If a register is shared by several
 watchpoints, each time a @code{i386_remove_watchpoint} is called, it
@@ -863,7 +863,7 @@
 
 The overall structure of the table output code is something like this:
 
-@example
+@smallexample
   ui_out_table_begin
     ui_out_table_header
     @dots{}
@@ -874,7 +874,7 @@
       ui_out_tuple_end
       @dots{}
   ui_out_table_end
-@end example
+@end smallexample
 
 Here is the description of table-, tuple- and list-related @code{ui_out}
 functions:
@@ -1139,7 +1139,7 @@
 
 The original code was:
 
-@example
+@smallexample
  if (!found_a_breakpoint++)
    @{
      annotate_breakpoints_headers ();
@@ -1162,11 +1162,11 @@
 
      annotate_breakpoints_table ();
    @}
-@end example
+@end smallexample
 
 Here's the new version:
 
-@example
+@smallexample
   nr_printable_breakpoints = @dots{};
 
   if (addressprint)
@@ -1203,13 +1203,13 @@
   ui_out_table_body (uiout);
   if (nr_printable_breakpoints > 0)
     annotate_breakpoints_table ();
-@end example
+@end smallexample
 
 This example, from the @code{print_one_breakpoint} function, shows how
 to produce the actual data for the table whose structure was defined
 in the above example.  The original code was:
 
-@example
+@smallexample
    annotate_record ();
    annotate_field (0);
    printf_filtered ("%-3d ", b->number);
@@ -1224,11 +1224,11 @@
    annotate_field (3);
    printf_filtered ("%-3c ", bpenables[(int)b->enable]);
    @dots{}
-@end example
+@end smallexample
 
 This is the new version:
 
-@example
+@smallexample
    annotate_record ();
    ui_out_tuple_begin (uiout, "bkpt");
    annotate_field (0);
@@ -1244,44 +1244,44 @@
    annotate_field (3);
    ui_out_field_fmt (uiout, "enabled", "%c", bpenables[(int)b->enable]);
    @dots{}
-@end example
+@end smallexample
 
 This example, also from @code{print_one_breakpoint}, shows how to
 produce a complicated output field using the @code{print_expression}
 functions which requires a stream to be passed.  It also shows how to
 automate stream destruction with cleanups.  The original code was:
 
-@example
+@smallexample
     annotate_field (5);
     print_expression (b->exp, gdb_stdout);
-@end example
+@end smallexample
 
 The new version is:
 
-@example
+@smallexample
   struct ui_stream *stb = ui_out_stream_new (uiout);
   struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb);
   ...
   annotate_field (5);
   print_expression (b->exp, stb->stream);
   ui_out_field_stream (uiout, "what", local_stream);
-@end example
+@end smallexample
 
 This example, also from @code{print_one_breakpoint}, shows how to use
 @code{ui_out_text} and @code{ui_out_field_string}.  The original code
 was:
 
-@example
+@smallexample
   annotate_field (5);
   if (b->dll_pathname == NULL)
     printf_filtered ("<any library> ");
   else
     printf_filtered ("library \"%s\" ", b->dll_pathname);
-@end example
+@end smallexample
 
 It became:
 
-@example
+@smallexample
   annotate_field (5);
   if (b->dll_pathname == NULL)
     @{
@@ -1294,21 +1294,21 @@
       ui_out_field_string (uiout, "what", b->dll_pathname);
       ui_out_text (uiout, "\" ");
     @}
-@end example
+@end smallexample
 
 The following example from @code{print_one_breakpoint} shows how to
 use @code{ui_out_field_int} and @code{ui_out_spaces}.  The original
 code was:
 
-@example
+@smallexample
   annotate_field (5);
   if (b->forked_inferior_pid != 0)
     printf_filtered ("process %d ", b->forked_inferior_pid);
-@end example
+@end smallexample
 
 It became:
 
-@example
+@smallexample
   annotate_field (5);
   if (b->forked_inferior_pid != 0)
     @{
@@ -1316,20 +1316,20 @@
       ui_out_field_int (uiout, "what", b->forked_inferior_pid);
       ui_out_spaces (uiout, 1);
     @}
-@end example
+@end smallexample
 
 Here's an example of using @code{ui_out_field_string}.  The original
 code was:
 
-@example
+@smallexample
   annotate_field (5);
   if (b->exec_pathname != NULL)
     printf_filtered ("program \"%s\" ", b->exec_pathname);
-@end example
+@end smallexample
 
 It became:
 
-@example
+@smallexample
   annotate_field (5);
   if (b->exec_pathname != NULL)
     @{
@@ -1337,22 +1337,22 @@
       ui_out_field_string (uiout, "what", b->exec_pathname);
       ui_out_text (uiout, "\" ");
     @}
-@end example
+@end smallexample
 
 Finally, here's an example of printing an address.  The original code:
 
-@example
+@smallexample
   annotate_field (4);
   printf_filtered ("%s ",
         local_hex_string_custom ((unsigned long) b->address, "08l"));
-@end example
+@end smallexample
 
 It became:
 
-@example
+@smallexample
   annotate_field (4);
   ui_out_field_core_addr (uiout, "Address", b->address);
-@end example
+@end smallexample
 
 
 @section Console Printing
@@ -1904,7 +1904,7 @@
 @strong{must} be included at the top of the YACC parser, to prevent the
 various parsers from defining the same global names:
 
-@example
+@smallexample
 #define yyparse         @var{lang}_parse
 #define yylex           @var{lang}_lex
 #define yyerror         @var{lang}_error
@@ -1921,7 +1921,7 @@
 #define yyexca          @var{lang}_exca
 #define yyerrflag       @var{lang}_errflag
 #define yynerrs         @var{lang}_nerrs
-@end example
+@end smallexample
 
 At the bottom of your parser, define a @code{struct language_defn} and
 initialize it with the right values for your language.  Define an
@@ -2730,7 +2730,7 @@
 
 @item CALL_DUMMY_P
 @findex CALL_DUMMY_P
-A C expresson that is non-zero when the target suports inferior function
+A C expression that is non-zero when the target supports inferior function
 calls.
 
 @item CALL_DUMMY_WORDS
@@ -2918,8 +2918,8 @@
 If the virtual frame pointer is kept in a register, then define this
 macro to be the number (greater than or equal to zero) of that register.
 
-This should only need to be defined if @code{TARGET_READ_FP} and
-@code{TARGET_WRITE_FP} are not defined.
+This should only need to be defined if @code{TARGET_READ_FP} is not
+defined.
 
 @item FRAMELESS_FUNCTION_INVOCATION(@var{fi})
 @findex FRAMELESS_FUNCTION_INVOCATION
@@ -2935,12 +2935,6 @@
 @findex FRAME_CHAIN
 Given @var{frame}, return a pointer to the calling frame.
 
-@item FRAME_CHAIN_COMBINE(@var{chain}, @var{frame})
-@findex FRAME_CHAIN_COMBINE
-Define this to take the frame chain pointer and the frame's nominal
-address and produce the nominal address of the caller's frame.
-Presently only defined for HP PA.
-
 @item FRAME_CHAIN_VALID(@var{chain}, @var{thisframe})
 @findex FRAME_CHAIN_VALID
 Define this to be an expression that returns zero if the given frame is
@@ -3018,12 +3012,12 @@
 
 @item @value{GDBN}_MULTI_ARCH
 @findex @value{GDBN}_MULTI_ARCH
-If defined and non-zero, enables suport for multiple architectures
+If defined and non-zero, enables support for multiple architectures
 within @value{GDBN}.
 
 This support can be enabled at two levels.  At level one, only
 definitions for previously undefined macros are provided; at level two,
-a multi-arch definition of all architecture dependant macros will be
+a multi-arch definition of all architecture dependent macros will be
 defined.
 
 @item @value{GDBN}_TARGET_IS_HPPA
@@ -3037,7 +3031,7 @@
 @findex GET_LONGJMP_TARGET
 For most machines, this is a target-dependent parameter.  On the
 DECstation and the Iris, this is a native-dependent parameter, since
-trhe header file @file{setjmp.h} is needed to define it.
+the header file @file{setjmp.h} is needed to define it.
 
 This macro determines the target PC address that @code{longjmp} will jump to,
 assuming that we have just stopped at a @code{longjmp} breakpoint.  It takes a
@@ -3050,15 +3044,6 @@
 Define this if you need to supply your own definition for the function
 @code{get_saved_register}.
 
-@item HAVE_REGISTER_WINDOWS
-@findex HAVE_REGISTER_WINDOWS
-Define this if the target has register windows.
-
-@item REGISTER_IN_WINDOW_P (@var{regnum})
-@findex REGISTER_IN_WINDOW_P
-Define this to be an expression that is 1 if the given register is in
-the window.
-
 @item IBM6000_TARGET
 @findex IBM6000_TARGET
 Shows that we are configured for an IBM RS/6000 target.  This
@@ -3105,11 +3090,6 @@
 the stack frame of the function already has been destroyed up to the
 final `return from function call' instruction.
 
-@item IN_SIGTRAMP (@var{pc}, @var{name})
-@findex IN_SIGTRAMP
-Define this to return non-zero if the given @var{pc} and/or @var{name}
-indicates that the current function is a @code{sigtramp}.
-
 @item SIGTRAMP_START (@var{pc})
 @findex SIGTRAMP_START
 @itemx SIGTRAMP_END (@var{pc})
@@ -3308,6 +3288,18 @@
 @findex PC_IN_CALL_DUMMY
 See @file{inferior.h}.
 
+@item PC_IN_SIGTRAMP (@var{pc}, @var{name})
+@findex PC_IN_SIGTRAMP
+@cindex sigtramp
+The @dfn{sigtramp} is a routine that the kernel calls (which then calls
+the signal handler).  On most machines it is a library routine that is
+linked into the executable.
+
+This function, given a program counter value in @var{pc} and the
+(possibly NULL) name of the function in which that @var{pc} resides,
+returns nonzero if the @var{pc} and/or @var{name} show that we are in
+sigtramp.
+
 @item PC_LOAD_SEGMENT
 @findex PC_LOAD_SEGMENT
 If defined, print information about the load segment for the program
@@ -3425,12 +3417,6 @@
 A C expression that returns the address of the ``real'' code beyond the
 function entry prologue found at @var{pc}.
 
-@item SKIP_PROLOGUE_FRAMELESS_P
-@findex SKIP_PROLOGUE_FRAMELESS_P
-A C expression that should behave similarly, but that can stop as soon
-as the function is known to have a frame.  If not defined,
-@code{SKIP_PROLOGUE} will be used instead.
-
 @item SKIP_TRAMPOLINE_CODE (@var{pc})
 @findex SKIP_TRAMPOLINE_CODE
 If the target machine has trampoline code that sits between callers and
@@ -3547,18 +3533,15 @@
 @findex TARGET_WRITE_SP
 @itemx TARGET_READ_FP
 @findex TARGET_READ_FP
-@itemx TARGET_WRITE_FP
-@findex TARGET_WRITE_FP
 @findex read_pc
 @findex write_pc
 @findex read_sp
 @findex write_sp
 @findex read_fp
-@findex write_fp
 These change the behavior of @code{read_pc}, @code{write_pc},
-@code{read_sp}, @code{write_sp}, @code{read_fp} and @code{write_fp}.
-For most targets, these may be left undefined.  @value{GDBN} will call the read
-and write register functions with the relevant @code{_REGNUM} argument.
+@code{read_sp}, @code{write_sp} and @code{read_fp}.  For most targets,
+these may be left undefined.  @value{GDBN} will call the read and write
+register functions with the relevant @code{_REGNUM} argument.
 
 These macros are useful when a target keeps one of these registers in a
 hard to get at place; for example, part in a segment register and part
@@ -3770,7 +3753,7 @@
 @emph{Maintainer's note: The @file{.mh} suffix is because this file
 originally contained @file{Makefile} fragments for hosting @value{GDBN}
 on machine @var{xyz}.  While the file is no longer used for this
-purpose, the @file{.mh} suffix remains.  Perhaphs someone will
+purpose, the @file{.mh} suffix remains.  Perhaps someone will
 eventually rename these fragments so that they have a @file{.mn}
 suffix.}
 
@@ -4185,7 +4168,7 @@
 later cleanups appended to the chain (but not yet discarded or
 performed).  E.g.:
 
-@example
+@smallexample
 make_cleanup (a, 0); 
 @{
   struct cleanup *old = make_cleanup (b, 0); 
@@ -4193,7 +4176,7 @@
   ...
   do_cleanups (old);
 @}
-@end example
+@end smallexample
 
 @noindent
 will call @code{c()} and @code{b()} but will not call @code{a()}.  The
@@ -4212,13 +4195,13 @@
 called and a forced stack unwind occurs) by ensuring that the
 @code{xfree} will always be called:
 
-@example
+@smallexample
 struct cleanup *old = make_cleanup (null_cleanup, 0);
 data = xmalloc (sizeof blah);
 make_cleanup (xfree, data);
 ... blah blah ...
 do_cleanups (old);
-@end example
+@end smallexample
 
 The second style is try/except.  Before it exits, your code-block calls
 @code{discard_cleanups} with the old cleanup chain and thus ensures that
@@ -4226,13 +4209,13 @@
 code segment, ensures that the file will be closed but only if there is
 an error:
 
-@example
+@smallexample
 FILE *file = fopen ("afile", "r");
 struct cleanup *old = make_cleanup (close_file, file);
 ... blah blah ...
 discard_cleanups (old);
 return file;
-@end example
+@end smallexample
 
 Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify
 that they ``should not be called when cleanups are not in place''.  This
@@ -4389,7 +4372,7 @@
 A function declaration should not have its name in column zero.  A
 function definition should have its name in column zero.
 
-@example
+@smallexample
 /* Declaration */
 static void foo (void);
 /* Definition */
@@ -4397,7 +4380,7 @@
 foo (void)
 @{
 @}
-@end example
+@end smallexample
 
 @emph{Pragmatics: This simplifies scripting.  Function definitions can
 be found using @samp{^function-name}.}
@@ -4415,17 +4398,17 @@
 
 Pointers are declared using the traditional K&R C style:
 
-@example
+@smallexample
 void *foo;
-@end example
+@end smallexample
 
 @noindent
 and not:
 
-@example
+@smallexample
 void * foo;
 void* foo;
-@end example
+@end smallexample
 
 @subsection Comments
 
@@ -4435,13 +4418,13 @@
 Block comments must appear in the following form, with no @code{/*}- or
 @code{*/}-only lines, and no leading @code{*}:
 
-@example
+@smallexample
 /* Wait for control to return from inferior to debugger.  If inferior
    gets a signal, we may decide to start it up again instead of
    returning.  That is why there is a loop in this function.  When
    this function actually returns it means the inferior should be left
    stopped and @value{GDBN} should read more commands.  */
-@end example
+@end smallexample
 
 (Note that this format is encouraged by Emacs; tabbing for a multi-line
 comment works correctly, and @kbd{M-q} fills the block consistently.)
@@ -4503,8 +4486,8 @@
 User errors and internal errors.  User errors include not only a user
 entering an incorrect command but also problems arising from corrupt
 object files and system errors when interacting with the target.
-Internal errors include situtations where @value{GDBN} has detected, at
-run time, a corrupt or erroneous situtation.
+Internal errors include situations where @value{GDBN} has detected, at
+run time, a corrupt or erroneous situation.
 
 When reporting an internal error, @value{GDBN} uses
 @code{internal_error} and @code{gdb_assert}.
@@ -4551,19 +4534,19 @@
 included indirectly.
 
 With the exception of the global definitions supplied by @file{defs.h},
-a header file should explictily include the header declaring any
+a header file should explicitly include the header declaring any
 @code{typedefs} et.al.@: it refers to.
 
 @code{extern} declarations should never appear in @code{.c} files.
 
 All include files should be wrapped in:
 
-@example
+@smallexample
 #ifndef INCLUDE_FILE_NAME_H
 #define INCLUDE_FILE_NAME_H
 header body
 #endif
-@end example
+@end smallexample
 
 
 @subsection Clean Design and Portable Implementation
@@ -4631,7 +4614,7 @@
 such hosts.
 
 @findex IS_DIR_SEPARATOR
-@item IS_DIR_SEPARATOR (@var{c}
+@item IS_DIR_SEPARATOR (@var{c})
 Evaluates to a non-zero value if @var{c} is a directory separator
 character.  On Unix and GNU/Linux systems, only a slash @file{/} is
 such a character, but on Windows, both @file{/} and @file{\} will
@@ -4723,16 +4706,16 @@
 @code{@var{arch}-@var{xvend}-@var{xos}}.  You can test your changes by
 running
 
-@example
+@smallexample
 ./config.sub @var{xyz}
-@end example
+@end smallexample
 
 @noindent
 and
 
-@example
+@smallexample
 ./config.sub @code{@var{arch}-@var{xvend}-@var{xos}}
-@end example
+@end smallexample
 
 @noindent
 which should both respond with @code{@var{arch}-@var{xvend}-@var{xos}}
@@ -4769,9 +4752,9 @@
 From the top level directory (containing @file{gdb}, @file{bfd},
 @file{libiberty}, and so on):
 
-@example
+@smallexample
 make -f Makefile.in gdb.tar.gz
-@end example
+@end smallexample
 
 @noindent
 This will properly configure, clean, rebuild any files that are
@@ -4817,16 +4800,147 @@
 @code{makeinfo} will split the document into one overall file and five
 or so included files.
 
+
 @node Releasing GDB
 
 @chapter Releasing @value{GDBN}
 @cindex making a new release of gdb
 
+@section Versions and Branches
+
+@subsection Version Identifiers
+
+@value{GDBN}'s version is determined by the file @file{gdb/version.in}.
+
+@value{GDBN}'s mainline uses ISO dates to differentiate between
+versions.  The CVS repository uses @var{YYYY}-@var{MM}-@var{DD}-cvs
+while the corresponding snapshot uses @var{YYYYMMDD}.
+
+@value{GDBN}'s release branch uses a slightly more complicated scheme.
+When the branch is first cut, the mainline version identifier is
+prefixed with the @var{major}.@var{minor} from of the previous release
+series but with .90 appended.  As draft releases are drawn from the
+branch, the minor minor number (.90) is incremented.  Once the first
+release (@var{M}.@var{N}) has been made, the version prefix is updated
+to @var{M}.@var{N}.0.90 (dot zero, dot ninety).  Follow on releases have
+an incremented minor minor version number (.0).
+
+Using 5.1 (previous) and 5.2 (current), the example below illustrates a
+typical sequence of version identifiers:
+
+@table @asis
+@item 5.1.1
+final release from previous branch
+@item 2002-03-03-cvs
+main-line the day the branch is cut
+@item 5.1.90-2002-03-03-cvs
+corresponding branch version
+@item 5.1.91
+first draft release candidate
+@item 5.1.91-2002-03-17-cvs
+updated branch version
+@item 5.1.92
+second draft release candidate
+@item 5.1.92-2002-03-31-cvs
+updated branch version
+@item 5.1.93
+final release candidate (see below)
+@item 5.2
+official release
+@item 5.2.0.90-2002-04-07-cvs
+updated CVS branch version
+@item 5.2.1
+second official release
+@end table
+
+Notes:
+
+@itemize @bullet
+@item
+Minor minor minor draft release candidates such as 5.2.0.91 have been
+omitted from the example.  Such release candidates are, typically, never
+made.
+@item
+For 5.1.93 the bziped tar ball @file{gdb-5.1.93.tar.bz2} is just the
+official @file{gdb-5.2.tar} renamed and compressed.
+@end itemize
+
+To avoid version conflicts, vendors are expected to modify the file
+@file{gdb/version.in} to include a vendor unique alphabetic identifier
+(an official @value{GDBN} release never uses alphabetic characters in
+its version identifer).
+
+Since @value{GDBN} does not make minor minor minor releases (e.g.,
+5.1.0.1) the conflict between that and a minor minor draft release
+identifier (e.g., 5.1.0.90) is avoided.
+
+
+@subsection Branches
+
+@value{GDBN} draws a release series (5.2, 5.2.1, @dots{}) from a single
+release branch (gdb_5_2-branch).  Since minor minor minor releases
+(5.1.0.1) are not made, the need to branch the release branch is avoided
+(it also turns out that the effort required for such a a branch and
+release is significantly greater than the effort needed to create a new
+release from the head of the release branch).
+
+Releases 5.0 and 5.1 used branch and release tags of the form:
+
+@smallexample
+gdb_N_M-YYYY-MM-DD-branchpoint
+gdb_N_M-YYYY-MM-DD-branch
+gdb_M_N-YYYY-MM-DD-release
+@end smallexample
+
+Release 5.2 is trialing the branch and release tags:
+
+@smallexample
+gdb_N_M-YYYY-MM-DD-branchpoint
+gdb_N_M-branch
+gdb_M_N-YYYY-MM-DD-release
+@end smallexample
+
+@emph{Pragmatics: The branchpoint and release tags need to identify when
+a branch and release are made.  The branch tag, denoting the head of the
+branch, does not have this criteria.}
+
+
+@section Branch Commit Policy
+
+The branch commit policy is pretty slack.  @value{GDBN} releases 5.0,
+5.1 and 5.2 all used the below:
+
+@itemize @bullet
+@item
+The @file{gdb/MAINTAINERS} file still holds.
+@item
+Don't fix something on the branch unless/until it is also fixed in the
+trunk.  If this isn't possible, mentioning it in the @file{gdb/PROBLEMS}
+file is better than committing a hack.
+@item
+When considering a patch for the branch, suggested criteria include:
+Does it fix a build?  Does it fix the sequence @kbd{break main; run}
+when debugging a static binary?
+@item
+The further a change is from the core of @value{GDBN}, the less likely
+the change will worry anyone (e.g., target specific code).
+@item
+Only post a proposal to change the core of @value{GDBN} after you've
+sent individual bribes to all the people listed in the
+@file{MAINTAINERS} file @t{;-)}
+@end itemize
+
+@emph{Pragmatics: Provided updates are restricted to non-core
+functionality there is little chance that a broken change will be fatal.
+This means that changes such as adding a new architectures or (within
+reason) support for a new host are considered acceptable.}
+
+
 @section Obsolete any code
 
 Before anything else, poke the other developers (and around the source
-code) to see there is anything that can be removed from @value{GDBN} (an
-old target, an unused file).
+code) to see if there is anything that can be removed from @value{GDBN}
+(an old target, an unused file).
 
 Obsolete code is identified by adding an @code{OBSOLETE} prefix to every
 line.  Doing this means that it is easy to identify obsolete code when
@@ -4858,7 +4972,8 @@
 history associated with the file (effectively clearing the slate) the
 developer has a much freer hand when it comes to fixing broken files.}
 
-@section Before the branch
+
+@section Before the Branch
 
 The most important objective at this stage is to find and fix simple
 changes that become a pain to track once the branch is created.  For
@@ -4866,34 +4981,17 @@
 building.  If you can't get the problem fixed, document it in the
 @file{gdb/PROBLEMS} file.
 
-@subheading Organize and announce the schedule.
+@subheading Prompt for @file{gdb/NEWS}
 
-The following is a possible schedule.  It is based on the rule-of-thumb
-that everything on the Internet takes a week.  You may want to even
-increase those times further since an analysis of the actual data
-strongly suggests that the below is far to aggressive.
+People always forget.  Send a post reminding them but also if you know
+something interesting happened add it yourself.  The @code{schedule}
+script will mention this in its e-mail.
 
-@itemize @bullet
-@item
-announce it
-@item
-wait a week
-@item
-announce branch date
-@item
-wait a week
-@item
-Cut the branch
-@item
-wait a week
-@item
-start enjoying all the fun
-@end itemize
+@subheading Review @file{gdb/README}
 
-As an aside, the branch tag name is probably regrettable vis:
-@example
-gdb_N_M-YYYY-MM-DD-@{branch,branchpoint@}
-@end example
+Grab one of the nightly snapshots and then walk through the
+@file{gdb/README} looking for anything that can be improved.  The
+@code{schedule} script will mention this in its e-mail.
 
 @subheading Refresh any imported files.
 
@@ -4903,27 +5001,28 @@
 @item
 @file{texinfo/texinfo.tex}
 @item
-@file{config.guess} et.@: al.@: 
+@file{config.guess} et.@: al.@: (see the top-level @file{MAINTAINERS}
+file)
+@item
+@file{etc/standards.texi}, @file{etc/make-stds.texi}
 @end itemize
 
-and should be refreshed.
-
-@subheading Prompt for @file{gdb/NEWS}
-
-People always forget.  Send a post reminding them but also if you know
-something interesting happened add it your self.
-
-@subheading Review @file{gdb/README}
-
-Grab one of the nightly snapshots and then walk through the
-@file{gdb/README} looking for anything that can be improved.
-
 @subheading Check the ARI
 
-ARI is an @code{awk} script (Awk Regression Indicator?) that checks for a
-number of errors and coding conventions.  The checks include things like
-using @code{malloc} instead of @code{xmalloc} and file naming problems.
-There shouldn't be any regressions.
+@uref{http://sources.redhat.com/gdb/ari,,A.R.I.} is an @code{awk} script
+(Awk Regression Index ;-) that checks for a number of errors and coding
+conventions.  The checks include things like using @code{malloc} instead
+of @code{xmalloc} and file naming problems.  There shouldn't be any
+regressions.
+
+@subsection Review the bug data base
+
+Close anything obviously fixed.
+
+@subsection Check all cross targets build
+
+The targets are listed in @file{gdb/MAINTAINERS}.
+
 
 @section Cut the branch
 
@@ -4931,7 +5030,7 @@
 
 I think something like the below was used:
 
-@example
+@smallexample
 $  d=`date -u +%Y-%m-%d`
 $  echo $d
 2002-01-24
@@ -4940,13 +5039,13 @@
 $  cvs -f -d /cvs/src rtag -b -r gdb_V_V-$d-branchpoint \
 gdb_5_1-$d-branch insight+dejagnu
 $
-@end example
+@end smallexample
 
 @itemize @bullet
 @item
 the @kbd{-D YYYY-MM-DD-gmt} forces the branch to an exact date/time.
 @item
-the trunk is first taged so that the branch point can easily be found
+the trunk is first tagged so that the branch point can easily be found
 @item
 Insight (which includes GDB) and dejagnu are tagged at the same time
 @end itemize
@@ -4963,54 +5062,84 @@
 
 @section Create a Release
 
-This procedure can be followed when creating beta and final final
-releases.  With a beta many of the steps can be skipped.
+The process of creating and then making available a release is broken
+down into a number of stages.  The first part addresses the technical
+process of creating a releasable tar ball.  The later stages address the
+process of releasing that tar ball.
 
-@subheading Establish a few defaults.
+When making a release candidate just the first section is needed.
 
-@example
-$  b=gdb_5_1-2001-07-29-branch
-$  v=5.1.1
+@subsection Create a release candidate
+
+The objective at this stage is to create a set of tar balls that can be
+made available as a formal release (or as a less formal release
+candidate).
+
+@subsubheading Freeze the branch
+
+Send out an e-mail notifying everyone that the branch is frozen to
+@email{gdb-patches@@sources.redhat.com}.
+
+@subsubheading Establish a few defaults.
+
+@smallexample
+$  b=gdb_5_2-branch
+$  v=5.2
 $  t=/sourceware/snapshot-tmp/gdbadmin-tmp
 $  echo $t/$b/$v
+/sourceware/snapshot-tmp/gdbadmin-tmp/gdb_5_2-branch/5.2
 $  mkdir -p $t/$b/$v
 $  cd $t/$b/$v
 $  pwd
-/sourceware/snapshot-tmp/gdbadmin-tmp/gdb_5_1-2001-07-29-branch/5.1.1
+/sourceware/snapshot-tmp/gdbadmin-tmp/gdb_5_2-branch/5.2
 $  which autoconf
 /home/gdbadmin/bin/autoconf
 $
-@end example
+@end smallexample
 
-NB: Check the autoconf version carefully.  You want to be using the
-version taken from the binutils snapshot directory.  It is most likely
-that your system's installed version (@file{/usr/bin}?) is probably
-correct.
+@noindent
+Notes:
 
-@subheading Check out the relevant modules:
+@itemize @bullet
+@item
+Check the @code{autoconf} version carefully.  You want to be using the
+version taken from the @file{binutils} snapshot directory.  It is very
+unlikely that a system installed version of @code{autoconf} (e.g.,
+@file{/usr/bin/autoconf}) is correct.
+@end itemize
 
-@example
+@subsubheading Check out the relevant modules:
+
+@smallexample
 $  for m in gdb insight dejagnu
 do
 ( mkdir -p $m && cd $m && cvs -q -f -d /cvs/src co -P -r $b $m )
 done
 $
-@end example
+@end smallexample
 
-NB: The reading of @file{.cvsrc} is disabled (@file{-f}) so that there
-isn't any confusion between what is written here and what your local CVS
-really does.
+@noindent
+Note:
 
-@subheading Update relevant files.
+@itemize @bullet
+@item
+The reading of @file{.cvsrc} is disabled (@file{-f}) so that there isn't
+any confusion between what is written here and what your local
+@code{cvs} really does.
+@end itemize
 
-@subsubheading @file{gdb/NEWS}
+@subsubheading Update relevant files.
+
+@table @file
+
+@item gdb/NEWS
 
 Major releases get their comments added as part of the mainline.  Minor
 releases should probably mention any significant bugs that were fixed.
 
-Don't forget to update the ChangeLog.
+Don't forget to include the @file{ChangeLog} entry.
 
-@example
+@smallexample
 $  emacs gdb/src/gdb/NEWS
 ...
 c-x 4 a
@@ -5018,13 +5147,22 @@
 c-x c-s c-x c-c
 $  cp gdb/src/gdb/NEWS insight/src/gdb/NEWS 
 $  cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog 
-@end example
+@end smallexample
 
-@subsubheading @file{gdb/README}
+@item gdb/README
 
-You'll need to update: the version, the update date, and who did it.
+You'll need to update:
 
-@example
+@itemize @bullet
+@item
+the version
+@item
+the update date
+@item
+who did it
+@end itemize
+
+@smallexample
 $  emacs gdb/src/gdb/README
 ...
 c-x 4 a
@@ -5032,192 +5170,278 @@
 c-x c-s c-x c-c
 $  cp gdb/src/gdb/README insight/src/gdb/README 
 $  cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog 
-@end example
+@end smallexample
 
-@emph{Maintainer note: Hopefully the README file was reviewed before the
-initial branch was cut so just a simple substitute is needed to get it
-updated.}
+@emph{Maintainer note: Hopefully the @file{README} file was reviewed
+before the initial branch was cut so just a simple substitute is needed
+to get it updated.}
 
 @emph{Maintainer note: Other projects generate @file{README} and
 @file{INSTALL} from the core documentation.  This might be worth
 pursuing.}
 
-@subsubheading @file{gdb/version.in}
+@item gdb/version.in
 
-@example
+@smallexample
 $  echo $v > gdb/src/gdb/version.in
+$  cat gdb/src/gdb/version.in
+5.2
 $  emacs gdb/src/gdb/version.in
 ...
 c-x 4 a
+... Bump to version ...
+c-x c-s c-x c-c
+$  cp gdb/src/gdb/version.in insight/src/gdb/version.in 
+$  cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog 
+@end smallexample
+
+@item dejagnu/src/dejagnu/configure.in
+
+Dejagnu is more complicated.  The version number is a parameter to
+@code{AM_INIT_AUTOMAKE}.  Tweak it to read something like gdb-5.1.91.
+
+Don't forget to re-generate @file{configure}.
+
+Don't forget to include a @file{ChangeLog} entry.
+
+@smallexample
+$  emacs dejagnu/src/dejagnu/configure.in
+...
+c-x 4 a
 ...
 c-x c-s c-x c-c
-$  cp gdb/src/gdb/version.in insight/src/gdb/version.in 
-$  cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog 
-@end example
+$  ( cd  dejagnu/src/dejagnu && autoconf )
+@end smallexample
 
-@subsubheading @file{dejagnu/src/dejagnu/configure.in}
+@end table
 
-Dejagnu is more complicated.  The version number is a parameter to
-@var{AM_INIT_AUTOMAKE}.  Tweak it to read something like
-@var{gdb-5.1.1}.
+@subsubheading Do the dirty work
 
-Re-generate configure.
+This is identical to the process used to create the daily snapshot.
 
-Add a ChangeLog.
-
-@subheading Do the dirty work
-
-This is identical to the process used when creating the daily snapshot.
-
-@example
-$  for m in gdb insight dejagnu
+@smallexample
+$  for m in gdb insight
 do
-( cd $m/src && gmake -f Makefile.in $m.tar.bz2 )
+( cd $m/src && gmake -f Makefile.in $m.tar )
 done
-@end example
+$  ( m=dejagnu; cd $m/src && gmake -f Makefile.in $m.tar.bz2 )
+@end smallexample
 
-@subheading Check the source files
+@subsubheading Check the source files
 
-You're looking for files that have mysteriously disappeared as the
+You're looking for files that have mysteriously disappeared.
 @kbd{distclean} has the habit of deleting files it shouldn't.  Watch out
 for the @file{version.in} update @kbd{cronjob}.
 
-@example
+@smallexample
 $  ( cd gdb/src && cvs -f -q -n update )
 M djunpack.bat
+? gdb-5.1.91.tar
 ? proto-toplev
-? gdb-5.1.1.tar.bz2
+@dots{} lots of generated files @dots{}
 M gdb/ChangeLog
 M gdb/NEWS
 M gdb/README
 M gdb/version.in
-? gdb/p-exp.tab.c
-? gdb/doc/gdb.info-11
-? gdb/doc/gdb.info-12
-? gdb/doc/gdb.info-13
-? gdb/doc/gdb.info-14
-? gdb/doc/gdb.info-15
-? gdb/doc/gdbint.info-4
-? gdb/doc/gdbint.info-5
+@dots{} lots of generated files @dots{}
 $
-@end example
+@end smallexample
 
+@noindent
 @emph{Don't worry about the @file{gdb.info-??} or
 @file{gdb/p-exp.tab.c}.  They were generated (and yes @file{gdb.info-1}
 was also generated only something strange with CVS means that they
 didn't get supressed).  Fixing it would be nice though.}
 
-@subheading Re-pack the release with @code{gzip}
+@subsubheading Create compressed versions of the release
 
-@example
-$  cp */*/*.bz2 .
-$  bunzip2 -k -v *.bz2
-$  gzip -9 -v *.tar
-@end example
+@smallexample
+$  cp */src/*.tar .
+$  cp */src/*.bz2 .
+$  ls -F
+dejagnu/ dejagnu-gdb-5.2.tar.bz2 gdb/ gdb-5.2.tar insight/ insight-5.2.tar
+$  for m in gdb insight
+do
+bzip2 -v -9 -c $m-$v.tar > $m-$v.tar.bz2
+gzip -v -9 -c $m-$v.tar > $m-$v.tar.gz
+done
+$
+@end smallexample
 
-NB: A pipe such as @kbd{bunzip2 < xxx.bz2 | gzip -9 > xxx.gz} shouldn't
-be used since, in that mode, gzip doesn't know the file name information
-and consequently can't include it.  This is also why the release process
-runs @code{tar} and @code{bzip2} as separate passes.
-
-@emph{Maintainer note: The release process could be changed to create
-@file{.tar} rather than @file{.tar.bz2} files.}
-
-@section Check the release
-
-Grab the @file{gdb.tar.bz2}, copy it to your local machine and then try
-a simple build using it.
-
-If this is a pre-release just copy the @file{.bz2} files to the snapshot
-directory and skip the remaining steps.
-
-If it is a final release, also make it available under a bogus name so
-that others can download and check it.
-
-@emph{Maintainer note: This adds an extra day to the release process but
-is very much worth it.  Other developers are given the oportunity to
-check that things like your @file{NEWS} entries are correct or that
-other changes actually work.}
-
-@section Release the tar ball
-
-This is where, unfortunatly, the notes just get vague.
-
-@subheading Install on sware
-
-@example
-$  cp *.bz2 *.gz ~ftp/pub/gdb/releases
-@end example
-
-@subheading Create and update the web pages.
-
-Try the following:
+@noindent
+Note:
 
 @itemize @bullet
 @item
-create the directory @file{htdocs/@var{version}} (e.g., @file{htdocs/5.1.1}
-@item
-copy @file{index.html} and @file{ANNOUNCE} from the previous release
-into the @file{htdocs/@var{version}} directory and edit for content.
-Things like the MD5 sums, @kbd{ls -l} output, the version number and so
-on will need updating.  Add NEWS entries to the @file{ANNOUNCE}.  This
-ensures that the previous announcement is kept somewhere handy.
-@item
-copy the @file{NEWS} from the distro into the
-@file{htdocs/@var{version}} directory, trim down to just the most recent
-news items
-@item
-Add a short (identical) announcement to both @file{htdocs/index.html}
-and @file{htdocs/news/index.html}
-@item
-edit the script @file{htdocs/index.sh} to link in the new release
-number.  Run it across all @file{index.html} files vis @kbd{./index.sh
-index.html */index.html}.
-@item
-grep the @file{htdocs} tree for references to the previous release
-version (@file{htdocs/download/index.html})
+A pipe such as @kbd{bunzip2 < xxx.bz2 | gzip -9 > xxx.gz} is not since,
+in that mode, @code{gzip} does not know the name of the file and, hence,
+can not include it in the compressed file.  This is also why the release
+process runs @code{tar} and @code{bzip2} as separate passes.
 @end itemize
 
-@emph{Maintainer note: This step is too fragile --- it is too easy to
-mis one of the entries and forget to update it.}
+@subsection Sanity check the tar ball
 
-@subheading Generate online docs
+Pick a popular machine (Solaris/PPC?) and try the build on that.
 
+@smallexample
+$  bunzip2 < gdb-5.2.tar.bz2 | tar xpf -
+$  cd gdb-5.2
+$  ./configure 
+$  make
+@dots{}
+$  ./gdb/gdb ./gdb/gdb
+GNU gdb 5.2
+@dots{}
+(gdb)  b main
+Breakpoint 1 at 0x80732bc: file main.c, line 734.
+(gdb)  run
+Starting program: /tmp/gdb-5.2/gdb/gdb 
+
+Breakpoint 1, main (argc=1, argv=0xbffff8b4) at main.c:734
+734       catch_errors (captured_main, &args, "", RETURN_MASK_ALL);
+(gdb)  print args
+$1 = @{argc = 136426532, argv = 0x821b7f0@}
+(gdb)
+@end smallexample
+
+@subsection Make a release candidate available
+
+If this is a release candidate then the only remaining steps are:
+
+@enumerate
+@item
+Commit @file{version.in} and @file{ChangeLog}
+@item
+Tweak @file{version.in} (and @file{ChangeLog} to read
+@var{L}.@var{M}.@var{N}-0000-00-00-cvs so that the version update
+process can restart.
+@item
+Make the release candidate available in
+@uref{ftp://sources.redhat.com/pub/gdb/snapshots/branch}
+@item
+Notify the relevant mailing lists ( @email{gdb@@sources.redhat.com} and
+@email{gdb-testers@@sources.redhat.com} that the candidate is available.
+@end enumerate
+
+@subsection Make a formal release available
+
+(And you thought all that was required was to post an e-mail.)
+
+@subsubheading Install on sware
+
+Copy the new files to both the release and the old release directory:
+
+@smallexample
+$  cp *.bz2 *.gz ~ftp/pub/gdb/old-releases/
+$  cp *.bz2 *.gz ~ftp/pub/gdb/releases
+@end smallexample
+
+@noindent
+Clean up the releases directory so that only the most recent releases
+are available (e.g. keep 5.2 and 5.2.1 but remove 5.1):
+
+@smallexample
+$  cd ~ftp/pub/gdb/releases
+$  rm @dots{}
+@end smallexample
+
+@noindent
+Update the file @file{README} and @file{.message} in the releases
+directory:
+
+@smallexample
+$  vi README
+@dots{}
+$  rm -f .message
+$  ln README .message
+@end smallexample
+
+@subsubheading Update the web pages.
+
+@table @file
+
+@item htdocs/download/ANNOUNCEMENT
+This file, which is posted as the official announcement, includes:
+@itemize @bullet
+@item
+General announcement
+@item
+News.  If making an @var{M}.@var{N}.1 release, retain the news from
+earlier @var{M}.@var{N} release.
+@item
+Errata
+@end itemize
+
+@item htdocs/index.html
+@itemx htdocs/news/index.html
+@itemx htdocs/download/index.html
+These files include:
+@itemize @bullet
+@item
+announcement of the most recent release
+@item
+news entry (remember to update both the top level and the news directory).
+@end itemize
+These pages also need to be regenerate using @code{index.sh}.
+
+@item download/onlinedocs/
 You need to find the magic command that is used to generate the online
 docs from the @file{.tar.bz2}.  The best way is to look in the output
-from one of the nightly cronjobs and then just edit accordingly.
+from one of the nightly @code{cron} jobs and then just edit accordingly.
 Something like:
 
-@example
+@smallexample
 $  ~/ss/update-web-docs \
- ~ftp/pub/gdb/releases/gdb-5.1.1.tar.bz2 \
+ ~ftp/pub/gdb/releases/gdb-5.2.tar.bz2 \
  $PWD/www \
- /www/sourceware/htdocs/gdb/5.1.1/onlinedocs \
+ /www/sourceware/htdocs/gdb/download/onlinedocs \
  gdb
-@end example
+@end smallexample
 
-@subheading Something about @file{ANNOUNCEMENT}
+@item download/ari/
+Just like the online documentation.  Something like:
 
-Send the @file{ANNOUNCEMENT} file you created above to:
+@smallexample
+$  /bin/sh ~/ss/update-web-ari \
+ ~ftp/pub/gdb/releases/gdb-5.2.tar.bz2 \
+ $PWD/www \
+ /www/sourceware/htdocs/gdb/download/ari \
+ gdb
+@end smallexample
+
+@end table
+
+@subsubheading Shadow the pages onto gnu
+
+Something goes here.
+
+
+@subsubheading Install the @value{GDBN} tar ball on GNU
+
+At the time of writing, the GNU machine was @kbd{gnudist.gnu.org} in
+@file{~ftp/gnu/gdb}.
+
+@subsubheading Make the @file{ANNOUNCEMENT}
+
+Post the @file{ANNOUNCEMENT} file you created above to:
 
 @itemize @bullet
 @item
 @email{gdb-announce@@sources.redhat.com, GDB Announcement mailing list}
 @item
-The gnu announce list (but delay it a day or so to let things get out).
+@email{info-gnu@@gnu.org, General GNU Announcement list} (but delay it a
+day or so to let things get out)
+@item
+@email{bug-gdb@@gnu.org, GDB Bug Report mailing list}
 @end itemize
 
-@subheading Install it on GNU
+@subsection Cleanup
 
-At the time of writing, the GNU machine was @kbd{gnudist.gnu.org} in
-@file{~ftp/gnu/gdb} (I think, I'm still waiting for it to copy into my
-home directory).
+The release is out but you're still not finished.
 
-@section Cleanup
+@subsubheading Commit outstanding changes
 
-@subheading Commit outstanding changes
-
-In particular you'll need to commit the changes to:
+In particular you'll need to commit any changes to:
 
 @itemize @bullet
 @item
@@ -5230,36 +5454,58 @@
 @file{gdb/README}
 @end itemize
 
-@subheading Tag the release
+@subsubheading Tag the release
 
 Something like:
 
-@example
+@smallexample
 $  d=`date -u +%Y-%m-%d`
 $  echo $d
 2002-01-24
 $  ( cd insight/src/gdb && cvs -f -q update )
-$  ( cd insight/src && cvs -f -q tag gdb_5_1_1-$d-release )
-@end example
+$  ( cd insight/src && cvs -f -q tag gdb_5_2-$d-release )
+@end smallexample
 
-Insight is used since that contains more of the release than GDB (yes
-dejagnu doesn't get tagged but I think we can live with that.).
+Insight is used since that contains more of the release than
+@value{GDBN} (@code{dejagnu} doesn't get tagged but I think we can live
+with that).
 
-@subheading Restart @file{gdb/version.in}
+@subsubheading Mention the release on the trunk
+
+Just put something in the @file{ChangeLog} so that the trunk also
+indicates when the release was made.
+
+@subsubheading Restart @file{gdb/version.in}
 
 If @file{gdb/version.in} does not contain an ISO date such as
 @kbd{2002-01-24} then the daily @code{cronjob} won't update it.  Having
 committed all the release changes it can be set to
-@file{5.1.0_0000-00-00-cvs} which will restart things (yes the @kbd{_}
+@file{5.2.0_0000-00-00-cvs} which will restart things (yes the @kbd{_}
 is important - it affects the snapshot process).
 
 Don't forget the @file{ChangeLog}.
 
-@subheading Merge into trunk
+@subsubheading Merge into trunk
 
 The files committed to the branch may also need changes merged into the
 trunk.
 
+@subsubheading Revise the release schedule
+
+Post a revised release schedule to @email{gdb@@sources.redhat.com, GDB
+Discussion List} with an updated announcement.  The schedule can be
+generated by running:
+
+@smallexample
+$  ~/ss/schedule `date +%s` schedule
+@end smallexample
+
+@noindent
+The first parameter is approximate date/time in seconds (from the epoch)
+of the most recent release.
+
+Also update the schedule @code{cronjob}.
+
 @section Post release
 
 Remove any @code{OBSOLETE} code.
@@ -5290,7 +5536,7 @@
 and a mention of any unexpected passes or fails.  When the testsuite is
 finished, you'll get a summary that looks like this:
 
-@example
+@smallexample
                 === gdb Summary ===
 
 # of expected passes            6016
@@ -5299,7 +5545,7 @@
 # of expected failures          183
 # of unresolved testcases       3
 # of untested testcases         5
-@end example
+@end smallexample
 
 The ideal test run consists of expected passes only; however, reality
 conspires to keep us from this ideal.  Unexpected failures indicate
@@ -5615,16 +5861,6 @@
 Any @file{@var{foo}-xdep.c} file that references STACK_END_ADDR
 is so old that it has never been converted to use BFD.  Now that's old!
 
-@item PYRAMID_CONTROL_FRAME_DEBUGGING
-pyr-xdep.c
-@item PYRAMID_CORE
-pyr-xdep.c
-@item PYRAMID_PTRACE
-pyr-xdep.c
-
-@item REG_STACK_SEGMENT
-exec.c
-
 @end table
 
 @include fdl.texi
diff --git a/gdb/dwarf2cfi.c b/gdb/dwarf2cfi.c
index 6c574bb..ffbeb5d 100644
--- a/gdb/dwarf2cfi.c
+++ b/gdb/dwarf2cfi.c
@@ -1,7 +1,7 @@
 /* Stack unwinding code based on dwarf2 frame info for GDB, the GNU debugger.
-   Copyright 2001
-   Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
    Contributed by Jiri Smid, SuSE Labs.
+   Based on code written by Daniel Berlin (dan@dberlin.org).
 
    This file is part of GDB.
 
@@ -1506,7 +1506,8 @@
   return cfa;
 }
 
-/* Store the frame address.  */
+/* Store the frame address.  This function is not used.  */
+
 void
 cfi_write_fp (CORE_ADDR val)
 {
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9dbcbde..5c06e9a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -175,19 +175,49 @@
                                          4 or 12 */
   };
 
-/* The data in the .debug_line statement prologue looks like this.  */
-struct line_head
+/* The line number information for a compilation unit (found in the
+   .debug_line section) begins with a "statement program header",
+   which contains the following information.  */
+struct line_header
+{
+  unsigned int total_length;
+  unsigned short version;
+  unsigned int header_length;
+  unsigned char minimum_instruction_length;
+  unsigned char default_is_stmt;
+  int line_base;
+  unsigned char line_range;
+  unsigned char opcode_base;
+
+  /* standard_opcode_lengths[i] is the number of operands for the
+     standard opcode whose value is i.  This means that
+     standard_opcode_lengths[0] is unused, and the last meaningful
+     element is standard_opcode_lengths[opcode_base - 1].  */
+  unsigned char *standard_opcode_lengths;
+
+  /* The include_directories table.  NOTE!  These strings are not
+     allocated with xmalloc; instead, they are pointers into
+     debug_line_buffer.  If you try to free them, `free' will get
+     indigestion.  */
+  unsigned int num_include_dirs, include_dirs_size;
+  char **include_dirs;
+
+  /* The file_names table.  NOTE!  These strings are not allocated
+     with xmalloc; instead, they are pointers into debug_line_buffer.
+     Don't try to free them directly.  */
+  unsigned int num_file_names, file_names_size;
+  struct file_entry
   {
-    unsigned int total_length;
-    unsigned short version;
-    unsigned int prologue_length;
-    unsigned char minimum_instruction_length;
-    unsigned char default_is_stmt;
-    int line_base;
-    unsigned char line_range;
-    unsigned char opcode_base;
-    unsigned char *standard_opcode_lengths;
-  };
+    char *name;
+    unsigned int dir_index;
+    unsigned int mod_time;
+    unsigned int length;
+  } *file_names;
+
+  /* The start and end of the statement program following this
+     header.  These point into dwarf_line_buffer.  */
+  char *statement_program_start, *statement_program_end;
+};
 
 /* When we construct a partial symbol table entry we only
    need this much information. */
@@ -256,6 +286,16 @@
     u;
   };
 
+struct function_range
+{
+  const char *name;
+  CORE_ADDR lowpc, highpc;
+  int seen_line;
+  struct function_range *next;
+};
+
+static struct function_range *cu_first_fn, *cu_last_fn, *cu_cached_fn;
+
 /* Get at parts of an attribute structure */
 
 #define DW_STRING(attr)    ((attr)->u.str)
@@ -492,6 +532,10 @@
 {
   "missing .debug_line section", 0, 0
 };
+static struct complaint dwarf2_statement_list_fits_in_line_number_section =
+{
+  "statement list doesn't fit in .debug_line section", 0, 0
+};
 static struct complaint dwarf2_mangled_line_number_section =
 {
   "mangled .debug_line section", 0, 0
@@ -560,6 +604,14 @@
 {
   "unsupported const value attribute form: '%s'", 0, 0
 };
+static struct complaint dwarf2_misplaced_line_number =
+{
+  "misplaced first line number at 0x%lx for '%s'", 0, 0
+};
+static struct complaint dwarf2_line_header_too_long =
+{
+  "line number info header doesn't fit in `.debug_line' section", 0, 0
+};
 
 /* local function prototypes */
 
@@ -639,7 +691,14 @@
 
 static int die_is_declaration (struct die_info *);
 
-static void dwarf_decode_lines (unsigned int, char *, bfd *,
+static void free_line_header (struct line_header *lh);
+
+static struct line_header *(dwarf_decode_line_header
+                            (unsigned int offset,
+                             bfd *abfd,
+                             const struct comp_unit_head *cu_header));
+
+static void dwarf_decode_lines (struct line_header *, char *, bfd *,
 				const struct comp_unit_head *);
 
 static void dwarf2_start_subfile (char *, char *);
@@ -794,6 +853,10 @@
 
 static struct die_info *dwarf_alloc_die (void);
 
+static void initialize_cu_func_list (void);
+
+static void add_to_cu_func_list (const char *, CORE_ADDR, CORE_ADDR);
+
 /* Try to locate the sections we need for DWARF 2 debugging
    information and return true if we have enough to do something.  */
 
@@ -1542,10 +1605,16 @@
 }
 
 static void
+initialize_cu_func_list (void)
+{
+  cu_first_fn = cu_last_fn = cu_cached_fn = NULL;
+}
+
+static void
 read_file_scope (struct die_info *die, struct objfile *objfile,
 		 const struct comp_unit_head *cu_header)
 {
-  unsigned int line_offset = 0;
+  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
   CORE_ADDR lowpc = ((CORE_ADDR) -1);
   CORE_ADDR highpc = ((CORE_ADDR) 0);
   struct attribute *attr;
@@ -1553,6 +1622,7 @@
   char *comp_dir = NULL;
   struct die_info *child_die;
   bfd *abfd = objfile->obfd;
+  struct line_header *line_header = 0;
 
   if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile))
     {
@@ -1633,13 +1703,7 @@
   start_symtab (name, comp_dir, lowpc);
   record_debugformat ("DWARF 2");
 
-  /* Decode line number information if present.  */
-  attr = dwarf_attr (die, DW_AT_stmt_list);
-  if (attr)
-    {
-      line_offset = DW_UNSND (attr);
-      dwarf_decode_lines (line_offset, comp_dir, abfd, cu_header);
-    }
+  initialize_cu_func_list ();
 
   /* Process all dies in compilation unit.  */
   if (die->has_children)
@@ -1651,6 +1715,44 @@
 	  child_die = sibling_die (child_die);
 	}
     }
+
+  /* Decode line number information if present.  */
+  attr = dwarf_attr (die, DW_AT_stmt_list);
+  if (attr)
+    {
+      unsigned int line_offset = DW_UNSND (attr);
+      line_header = dwarf_decode_line_header (line_offset,
+                                              abfd, cu_header);
+      if (line_header)
+        {
+          make_cleanup ((make_cleanup_ftype *) free_line_header,
+                        (void *) line_header);
+          dwarf_decode_lines (line_header, comp_dir, abfd, cu_header);
+        }
+    }
+
+  do_cleanups (back_to);
+}
+
+static void
+add_to_cu_func_list (const char *name, CORE_ADDR lowpc, CORE_ADDR highpc)
+{
+  struct function_range *thisfn;
+
+  thisfn = (struct function_range *)
+    obstack_alloc (&dwarf2_tmp_obstack, sizeof (struct function_range));
+  thisfn->name = name;
+  thisfn->lowpc = lowpc;
+  thisfn->highpc = highpc;
+  thisfn->seen_line = 0;
+  thisfn->next = NULL;
+
+  if (cu_last_fn == NULL)
+      cu_first_fn = thisfn;
+  else
+      cu_last_fn->next = thisfn;
+
+  cu_last_fn = thisfn;
 }
 
 static void
@@ -1674,6 +1776,9 @@
   lowpc += baseaddr;
   highpc += baseaddr;
 
+  /* Record the function range for dwarf_decode_lines.  */
+  add_to_cu_func_list (name, lowpc, highpc);
+
   if (objfile->ei.entry_point >= lowpc &&
       objfile->ei.entry_point < highpc)
     {
@@ -2538,7 +2643,8 @@
 	      else if (attr->form == DW_FORM_udata
 		       || attr->form == DW_FORM_data1
 		       || attr->form == DW_FORM_data2
-		       || attr->form == DW_FORM_data4)
+		       || attr->form == DW_FORM_data4
+		       || attr->form == DW_FORM_data8)
 		{
 		  low = DW_UNSND (attr);
 		}
@@ -2564,7 +2670,8 @@
 	      else if (attr->form == DW_FORM_udata
 		       || attr->form == DW_FORM_data1
 		       || attr->form == DW_FORM_data2
-		       || attr->form == DW_FORM_data4)
+		       || attr->form == DW_FORM_data4
+		       || attr->form == DW_FORM_data8)
 		{
 		  high = DW_UNSND (attr);
 		}
@@ -2610,6 +2717,16 @@
   while (ndim-- > 0)
     type = create_array_type (NULL, type, range_types[ndim]);
 
+  /* Understand Dwarf2 support for vector types (like they occur on
+     the PowerPC w/ AltiVec).  Gcc just adds another attribute to the
+     array type.  This is not part of the Dwarf2/3 standard yet, but a
+     custom vendor extension.  The main difference between a regular
+     array and the vector variant is that vectors are passed by value
+     to functions.  */
+  attr = dwarf_attr (die, DW_AT_GNU_vector);
+  if (attr)
+    TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR;
+
   do_cleanups (back_to);
 
   /* Install the type in the die. */
@@ -2977,6 +3094,18 @@
       type = init_type (code, size, type_flags, DW_STRING (attr), objfile);
       if (encoding == DW_ATE_address)
 	TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID);
+      else if (encoding == DW_ATE_complex_float)
+	{
+	  if (size == 32)
+	    TYPE_TARGET_TYPE (type)
+	      = dwarf2_fundamental_type (objfile, FT_EXT_PREC_FLOAT);
+	  else if (size == 16)
+	    TYPE_TARGET_TYPE (type)
+	      = dwarf2_fundamental_type (objfile, FT_DBL_PREC_FLOAT);
+	  else if (size == 8)
+	    TYPE_TARGET_TYPE (type)
+	      = dwarf2_fundamental_type (objfile, FT_FLOAT);
+	}
     }
   else
     {
@@ -3871,87 +4000,153 @@
 	  && ! dwarf_attr (die, DW_AT_specification));
 }
 
-/* Decode the line number information for the compilation unit whose
-   line number info is at OFFSET in the .debug_line section.
-   The compilation directory of the file is passed in COMP_DIR.  */
 
-struct filenames
-{
-  unsigned int num_files;
-  struct fileinfo
-    {
-      char *name;
-      unsigned int dir;
-      unsigned int time;
-      unsigned int size;
-    }
-   *files;
-};
-
-struct directories
-  {
-    unsigned int num_dirs;
-    char **dirs;
-  };
-
+/* Free the line_header structure *LH, and any arrays and strings it
+   refers to.  */
 static void
-dwarf_decode_lines (unsigned int offset, char *comp_dir, bfd *abfd,
-		    const struct comp_unit_head *cu_header)
+free_line_header (struct line_header *lh)
 {
-  char *line_ptr;
-  char *line_end;
-  struct line_head lh;
+  if (lh->standard_opcode_lengths)
+    free (lh->standard_opcode_lengths);
+
+  /* Remember that all the lh->file_names[i].name pointers are
+     pointers into debug_line_buffer, and don't need to be freed.  */
+  if (lh->file_names)
+    free (lh->file_names);
+
+  /* Similarly for the include directory names.  */
+  if (lh->include_dirs)
+    free (lh->include_dirs);
+
+  free (lh);
+}
+
+
+/* Add an entry to LH's include directory table.  */
+static void
+add_include_dir (struct line_header *lh, char *include_dir)
+{
+  /* Grow the array if necessary.  */
+  if (lh->include_dirs_size == 0)
+    {
+      lh->include_dirs_size = 1; /* for testing */
+      lh->include_dirs = xmalloc (lh->include_dirs_size
+                                  * sizeof (*lh->include_dirs));
+    }
+  else if (lh->num_include_dirs >= lh->include_dirs_size)
+    {
+      lh->include_dirs_size *= 2;
+      lh->include_dirs = xrealloc (lh->include_dirs,
+                                   (lh->include_dirs_size
+                                    * sizeof (*lh->include_dirs)));
+    }
+
+  lh->include_dirs[lh->num_include_dirs++] = include_dir;
+}
+ 
+
+/* Add an entry to LH's file name table.  */
+static void
+add_file_name (struct line_header *lh,
+               char *name,
+               unsigned int dir_index,
+               unsigned int mod_time,
+               unsigned int length)
+{
+  struct file_entry *fe;
+
+  /* Grow the array if necessary.  */
+  if (lh->file_names_size == 0)
+    {
+      lh->file_names_size = 1; /* for testing */
+      lh->file_names = xmalloc (lh->file_names_size
+                                * sizeof (*lh->file_names));
+    }
+  else if (lh->num_file_names >= lh->file_names_size)
+    {
+      lh->file_names_size *= 2;
+      lh->file_names = xrealloc (lh->file_names,
+                                 (lh->file_names_size
+                                  * sizeof (*lh->file_names)));
+    }
+
+  fe = &lh->file_names[lh->num_file_names++];
+  fe->name = name;
+  fe->dir_index = dir_index;
+  fe->mod_time = mod_time;
+  fe->length = length;
+}
+ 
+
+/* Read the statement program header starting at OFFSET in
+   dwarf_line_buffer, according to the endianness of ABFD.  Return a
+   pointer to a struct line_header, allocated using xmalloc.
+
+   NOTE: the strings in the include directory and file name tables of
+   the returned object point into debug_line_buffer, and must not be
+   freed.  */
+static struct line_header *
+dwarf_decode_line_header (unsigned int offset, bfd *abfd,
+                          const struct comp_unit_head *cu_header)
+{
   struct cleanup *back_to;
-  unsigned int i, bytes_read;
-  char *cur_file, *cur_dir;
-  unsigned char op_code, extended_op, adj_opcode;
-
-#define FILE_ALLOC_CHUNK 5
-#define DIR_ALLOC_CHUNK 5
-
-  struct filenames files;
-  struct directories dirs;
+  struct line_header *lh;
+  char *line_ptr;
+  int bytes_read;
+  int i;
+  char *cur_dir, *cur_file;
 
   if (dwarf_line_buffer == NULL)
     {
       complain (&dwarf2_missing_line_number_section);
-      return;
+      return 0;
     }
 
-  files.num_files = 0;
-  files.files = NULL;
+  /* Make sure that at least there's room for the total_length field.  That
+     could be 12 bytes long, but we're just going to fudge that.  */
+  if (offset + 4 >= dwarf_line_size)
+    {
+      complain (&dwarf2_statement_list_fits_in_line_number_section);
+      return 0;
+    }
 
-  dirs.num_dirs = 0;
-  dirs.dirs = NULL;
+  lh = xmalloc (sizeof (*lh));
+  memset (lh, 0, sizeof (*lh));
+  back_to = make_cleanup ((make_cleanup_ftype *) free_line_header,
+                          (void *) lh);
 
   line_ptr = dwarf_line_buffer + offset;
 
-  /* read in the prologue */
-  lh.total_length = read_initial_length (abfd, line_ptr, NULL, &bytes_read);
+  /* read in the header */
+  lh->total_length = read_initial_length (abfd, line_ptr, NULL, &bytes_read);
   line_ptr += bytes_read;
-  line_end = line_ptr + lh.total_length;
-  lh.version = read_2_bytes (abfd, line_ptr);
-  line_ptr += 2;
-  lh.prologue_length = read_offset (abfd, line_ptr, cu_header, &bytes_read);
-  line_ptr += bytes_read;
-  lh.minimum_instruction_length = read_1_byte (abfd, line_ptr);
-  line_ptr += 1;
-  lh.default_is_stmt = read_1_byte (abfd, line_ptr);
-  line_ptr += 1;
-  lh.line_base = read_1_signed_byte (abfd, line_ptr);
-  line_ptr += 1;
-  lh.line_range = read_1_byte (abfd, line_ptr);
-  line_ptr += 1;
-  lh.opcode_base = read_1_byte (abfd, line_ptr);
-  line_ptr += 1;
-  lh.standard_opcode_lengths = (unsigned char *)
-    xmalloc (lh.opcode_base * sizeof (unsigned char));
-  back_to = make_cleanup (free_current_contents, &lh.standard_opcode_lengths);
-
-  lh.standard_opcode_lengths[0] = 1;
-  for (i = 1; i < lh.opcode_base; ++i)
+  if (line_ptr + lh->total_length > dwarf_line_buffer + dwarf_line_size)
     {
-      lh.standard_opcode_lengths[i] = read_1_byte (abfd, line_ptr);
+      complain (&dwarf2_statement_list_fits_in_line_number_section);
+      return 0;
+    }
+  lh->statement_program_end = line_ptr + lh->total_length;
+  lh->version = read_2_bytes (abfd, line_ptr);
+  line_ptr += 2;
+  lh->header_length = read_offset (abfd, line_ptr, cu_header, &bytes_read);
+  line_ptr += bytes_read;
+  lh->minimum_instruction_length = read_1_byte (abfd, line_ptr);
+  line_ptr += 1;
+  lh->default_is_stmt = read_1_byte (abfd, line_ptr);
+  line_ptr += 1;
+  lh->line_base = read_1_signed_byte (abfd, line_ptr);
+  line_ptr += 1;
+  lh->line_range = read_1_byte (abfd, line_ptr);
+  line_ptr += 1;
+  lh->opcode_base = read_1_byte (abfd, line_ptr);
+  line_ptr += 1;
+  lh->standard_opcode_lengths
+    = (unsigned char *) xmalloc (lh->opcode_base * sizeof (unsigned char));
+
+  lh->standard_opcode_lengths[0] = 1;  /* This should never be used anyway.  */
+  for (i = 1; i < lh->opcode_base; ++i)
+    {
+      lh->standard_opcode_lengths[i] = read_1_byte (abfd, line_ptr);
       line_ptr += 1;
     }
 
@@ -3959,44 +4154,96 @@
   while ((cur_dir = read_string (abfd, line_ptr, &bytes_read)) != NULL)
     {
       line_ptr += bytes_read;
-      if ((dirs.num_dirs % DIR_ALLOC_CHUNK) == 0)
-	{
-	  dirs.dirs = (char **)
-	    xrealloc (dirs.dirs,
-		      (dirs.num_dirs + DIR_ALLOC_CHUNK) * sizeof (char *));
-	  if (dirs.num_dirs == 0)
-	    make_cleanup (free_current_contents, &dirs.dirs);
-	}
-      dirs.dirs[dirs.num_dirs++] = cur_dir;
+      add_include_dir (lh, cur_dir);
     }
   line_ptr += bytes_read;
 
   /* Read file name table */
   while ((cur_file = read_string (abfd, line_ptr, &bytes_read)) != NULL)
     {
+      unsigned int dir_index, mod_time, length;
+
       line_ptr += bytes_read;
-      if ((files.num_files % FILE_ALLOC_CHUNK) == 0)
-	{
-	  files.files = (struct fileinfo *)
-	    xrealloc (files.files,
-		      (files.num_files + FILE_ALLOC_CHUNK)
-		      * sizeof (struct fileinfo));
-	  if (files.num_files == 0)
-	    make_cleanup (free_current_contents, &files.files);
-	}
-      files.files[files.num_files].name = cur_file;
-      files.files[files.num_files].dir =
-	read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      dir_index = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      files.files[files.num_files].time =
-	read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      mod_time = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      files.files[files.num_files].size =
-	read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      files.num_files++;
+
+      add_file_name (lh, cur_file, dir_index, mod_time, length);
     }
   line_ptr += bytes_read;
+  lh->statement_program_start = line_ptr; 
+
+  if (line_ptr > dwarf_line_buffer + dwarf_line_size)
+    complain (&dwarf2_line_header_too_long);
+
+  discard_cleanups (back_to);
+  return lh;
+}
+
+/* This function exists to work around a bug in certain compilers
+   (particularly GCC 2.95), in which the first line number marker of a
+   function does not show up until after the prologue, right before
+   the second line number marker.  This function shifts ADDRESS down
+   to the beginning of the function if necessary, and is called on
+   addresses passed to record_line.  */
+
+static CORE_ADDR
+check_cu_functions (CORE_ADDR address)
+{
+  struct function_range *fn;
+
+  /* Find the function_range containing address.  */
+  if (!cu_first_fn)
+    return address;
+
+  if (!cu_cached_fn)
+    cu_cached_fn = cu_first_fn;
+
+  fn = cu_cached_fn;
+  while (fn)
+    if (fn->lowpc <= address && fn->highpc > address)
+      goto found;
+    else
+      fn = fn->next;
+
+  fn = cu_first_fn;
+  while (fn && fn != cu_cached_fn)
+    if (fn->lowpc <= address && fn->highpc > address)
+      goto found;
+    else
+      fn = fn->next;
+
+  return address;
+
+ found:
+  if (fn->seen_line)
+    return address;
+  if (address != fn->lowpc)
+    complain (&dwarf2_misplaced_line_number,
+	      (unsigned long) address, fn->name);
+  fn->seen_line = 1;
+  return fn->lowpc;
+}
+
+/* Decode the line number information for the compilation unit whose
+   line number info is at OFFSET in the .debug_line section.
+   The compilation directory of the file is passed in COMP_DIR.  */
+
+static void
+dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd,
+		    const struct comp_unit_head *cu_header)
+{
+  char *line_ptr;
+  char *line_end;
+  unsigned int i, bytes_read;
+  char *cur_dir;
+  unsigned char op_code, extended_op, adj_opcode;
+
+  line_ptr = lh->statement_program_start;
+  line_end = lh->statement_program_end;
 
   /* Read the statement sequences until there's nothing left.  */
   while (line_ptr < line_end)
@@ -4006,19 +4253,23 @@
       unsigned int file = 1;
       unsigned int line = 1;
       unsigned int column = 0;
-      int is_stmt = lh.default_is_stmt;
+      int is_stmt = lh->default_is_stmt;
       int basic_block = 0;
       int end_sequence = 0;
 
       /* Start a subfile for the current file of the state machine.  */
-      if (files.num_files >= file)
+      if (lh->num_file_names >= file)
 	{
-	  /* The file and directory tables are 0 based, the references
-	     are 1 based.  */
-	  dwarf2_start_subfile (files.files[file - 1].name,
-				(files.files[file - 1].dir
-				 ? dirs.dirs[files.files[file - 1].dir - 1]
-				 : comp_dir));
+	  /* lh->include_dirs and lh->file_names are 0-based, but the
+	     directory and file name numbers in the statement program
+	     are 1-based.  */
+          struct file_entry *fe = &lh->file_names[file - 1];
+          char *dir;
+          if (fe->dir_index)
+            dir = lh->include_dirs[fe->dir_index - 1];
+          else
+            dir = comp_dir;
+	  dwarf2_start_subfile (fe->name, dir);
 	}
 
       /* Decode the table. */
@@ -4027,13 +4278,14 @@
 	  op_code = read_1_byte (abfd, line_ptr);
 	  line_ptr += 1;
 
-	  if (op_code >= lh.opcode_base)
+	  if (op_code >= lh->opcode_base)
 	    {		/* Special operand.  */
-	      adj_opcode = op_code - lh.opcode_base;
-	      address += (adj_opcode / lh.line_range)
-		* lh.minimum_instruction_length;
-	      line += lh.line_base + (adj_opcode % lh.line_range);
+	      adj_opcode = op_code - lh->opcode_base;
+	      address += (adj_opcode / lh->line_range)
+		* lh->minimum_instruction_length;
+	      line += lh->line_base + (adj_opcode % lh->line_range);
 	      /* append row to matrix using current values */
+	      address = check_cu_functions (address);
 	      record_line (current_subfile, line, address);
 	      basic_block = 1;
 	    }
@@ -4047,12 +4299,7 @@
 		{
 		case DW_LNE_end_sequence:
 		  end_sequence = 1;
-		  /* Don't call record_line here.  The end_sequence
-		     instruction provides the address of the first byte
-		     *after* the last line in the sequence; it's not the
-		     address of any real source line.  However, the GDB
-		     linetable structure only records the starts of lines,
-		     not the ends.  This is a weakness of GDB.  */
+		  record_line (current_subfile, 0, address);
 		  break;
 		case DW_LNE_set_address:
 		  address = read_address (abfd, line_ptr, cu_header, &bytes_read);
@@ -4060,40 +4307,36 @@
 		  address += baseaddr;
 		  break;
 		case DW_LNE_define_file:
-		  cur_file = read_string (abfd, line_ptr, &bytes_read);
-		  line_ptr += bytes_read;
-		  if ((files.num_files % FILE_ALLOC_CHUNK) == 0)
-		    {
-		      files.files = (struct fileinfo *)
-			xrealloc (files.files,
-				  (files.num_files + FILE_ALLOC_CHUNK)
-				  * sizeof (struct fileinfo));
-		      if (files.num_files == 0)
-			make_cleanup (free_current_contents, &files.files);
-		    }
-		  files.files[files.num_files].name = cur_file;
-		  files.files[files.num_files].dir =
-		    read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-		  line_ptr += bytes_read;
-		  files.files[files.num_files].time =
-		    read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-		  line_ptr += bytes_read;
-		  files.files[files.num_files].size =
-		    read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-		  line_ptr += bytes_read;
-		  files.num_files++;
+                  {
+                    char *cur_file;
+                    unsigned int dir_index, mod_time, length;
+                    
+                    cur_file = read_string (abfd, line_ptr, &bytes_read);
+                    line_ptr += bytes_read;
+                    dir_index =
+                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                    line_ptr += bytes_read;
+                    mod_time =
+                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                    line_ptr += bytes_read;
+                    length =
+                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                    line_ptr += bytes_read;
+                    add_file_name (lh, cur_file, dir_index, mod_time, length);
+                  }
 		  break;
 		default:
 		  complain (&dwarf2_mangled_line_number_section);
-		  goto done;
+		  return;
 		}
 	      break;
 	    case DW_LNS_copy:
+	      address = check_cu_functions (address);
 	      record_line (current_subfile, line, address);
 	      basic_block = 0;
 	      break;
 	    case DW_LNS_advance_pc:
-	      address += lh.minimum_instruction_length
+	      address += lh->minimum_instruction_length
 		* read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 	      line_ptr += bytes_read;
 	      break;
@@ -4102,15 +4345,21 @@
 	      line_ptr += bytes_read;
 	      break;
 	    case DW_LNS_set_file:
-	      /* The file and directory tables are 0 based, the references
-	         are 1 based.  */
-	      file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-	      line_ptr += bytes_read;
-	      dwarf2_start_subfile
-		(files.files[file - 1].name,
-		 (files.files[file - 1].dir
-		  ? dirs.dirs[files.files[file - 1].dir - 1]
-		  : comp_dir));
+              {
+                /* lh->include_dirs and lh->file_names are 0-based,
+                   but the directory and file name numbers in the
+                   statement program are 1-based.  */
+                struct file_entry *fe;
+                char *dir;
+                file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                line_ptr += bytes_read;
+                fe = &lh->file_names[file - 1];
+                if (fe->dir_index)
+                  dir = lh->include_dirs[fe->dir_index - 1];
+                else
+                  dir = comp_dir;
+                dwarf2_start_subfile (fe->name, dir);
+              }
 	      break;
 	    case DW_LNS_set_column:
 	      column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
@@ -4128,8 +4377,8 @@
 	       length since special opcode 255 would have scaled the
 	       the increment.  */
 	    case DW_LNS_const_add_pc:
-	      address += (lh.minimum_instruction_length
-			  * ((255 - lh.opcode_base) / lh.line_range));
+	      address += (lh->minimum_instruction_length
+			  * ((255 - lh->opcode_base) / lh->line_range));
 	      break;
 	    case DW_LNS_fixed_advance_pc:
 	      address += read_2_bytes (abfd, line_ptr);
@@ -4138,7 +4387,7 @@
 	    default:
 	      {  /* Unknown standard opcode, ignore it.  */
 		int i;
-		for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++)
+		for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++)
 		  {
 		    (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		    line_ptr += bytes_read;
@@ -4147,8 +4396,6 @@
 	    }
 	}
     }
-done:
-  do_cleanups (back_to);
 }
 
 /* Start a subfile for DWARF.  FILENAME is the name of the file and
@@ -5161,6 +5408,8 @@
       return "DW_AT_body_begin";
     case DW_AT_body_end:
       return "DW_AT_body_end";
+    case DW_AT_GNU_vector:
+      return "DW_AT_GNU_vector";
     default:
       return "DW_AT_<unknown>";
     }
diff --git a/gdb/eval.c b/gdb/eval.c
index 3f5aca3..4ff210b 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1,6 +1,6 @@
 /* Evaluate expressions for GDB.
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001
+   1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -78,7 +78,7 @@
   struct expression *expr = parse_expression (exp);
   register CORE_ADDR addr;
   register struct cleanup *old_chain =
-  make_cleanup (free_current_contents, &expr);
+    make_cleanup (free_current_contents, &expr);
 
   addr = value_as_address (evaluate_expression (expr));
   do_cleanups (old_chain);
@@ -94,7 +94,7 @@
   struct expression *expr = parse_exp_1 (expptr, (struct block *) 0, 0);
   register CORE_ADDR addr;
   register struct cleanup *old_chain =
-  make_cleanup (free_current_contents, &expr);
+    make_cleanup (free_current_contents, &expr);
 
   addr = value_as_address (evaluate_expression (expr));
   do_cleanups (old_chain);
@@ -121,8 +121,8 @@
 {
   struct expression *expr = parse_expression (exp);
   struct value *val;
-  register struct cleanup *old_chain
-  = make_cleanup (free_current_contents, &expr);
+  register struct cleanup *old_chain =
+    make_cleanup (free_current_contents, &expr);
 
   val = evaluate_expression (expr);
   do_cleanups (old_chain);
@@ -138,8 +138,8 @@
 {
   struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1);
   struct value *val;
-  register struct cleanup *old_chain
-  = make_cleanup (free_current_contents, &expr);
+  register struct cleanup *old_chain =
+    make_cleanup (free_current_contents, &expr);
 
   val = evaluate_expression (expr);
   do_cleanups (old_chain);
@@ -447,8 +447,7 @@
     case OP_REGISTER:
       {
 	int regno = longest_to_int (exp->elts[pc + 1].longconst);
-	struct value *val = value_of_register (regno);
-
+	struct value *val = value_of_register (regno, selected_frame);
 	(*pos) += 2;
 	if (val == NULL)
 	  error ("Value of register %s not available.", REGISTER_NAME (regno));
@@ -821,15 +820,10 @@
       if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
 	{
 	  int static_memfuncp;
-	  struct value *temp = arg2;
 	  char tstr[256];
 
 	  /* Method invocation : stuff "this" as first parameter */
-	  /* pai: this used to have lookup_pointer_type for some reason,
-	   * but temp is already a pointer to the object */
-	  argvec[1]
-	    = value_from_pointer (VALUE_TYPE (temp),
-				  VALUE_ADDRESS (temp) + VALUE_OFFSET (temp));
+	  argvec[1] = arg2;
 	  /* Name of method from expression */
 	  strcpy (tstr, &exp->elts[pc2 + 2].string);
 
@@ -855,11 +849,17 @@
 	  else
 	    /* Non-C++ case -- or no overload resolution */
 	    {
-	      temp = arg2;
+	      struct value *temp = arg2;
 	      argvec[0] = value_struct_elt (&temp, argvec + 1, tstr,
 					    &static_memfuncp,
 					    op == STRUCTOP_STRUCT
 				       ? "structure" : "structure pointer");
+	      /* value_struct_elt updates temp with the correct value
+	 	 of the ``this'' pointer if necessary, so modify argvec[1] to
+		 reflect any ``this'' changes.  */
+	      arg2 = value_from_longest (lookup_pointer_type(VALUE_TYPE (temp)),
+			     VALUE_ADDRESS (temp) + VALUE_OFFSET (temp)
+			     + VALUE_EMBEDDED_OFFSET (temp));
 	      argvec[1] = arg2;	/* the ``this'' pointer */
 	    }
 
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 3bf9c34..b472694 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -685,20 +685,17 @@
     {
       p--;			/* Put on top of '\'.  */
 
-      if (*p == '\\')
-	{
-	  readline_input_state.linebuffer = savestring (linebuffer,
-							strlen (linebuffer));
-	  readline_input_state.linebuffer_ptr = p;
+      readline_input_state.linebuffer = savestring (linebuffer,
+						    strlen (linebuffer));
+      readline_input_state.linebuffer_ptr = p;
 
-	  /* We will not invoke a execute_command if there is more
-	     input expected to complete the command. So, we need to
-	     print an empty prompt here. */
-	  more_to_come = 1;
-	  push_prompt ("", "", "");
-	  display_gdb_prompt (0);
-	  return;
-	}
+      /* We will not invoke a execute_command if there is more
+	 input expected to complete the command. So, we need to
+	 print an empty prompt here. */
+      more_to_come = 1;
+      push_prompt ("", "", "");
+      display_gdb_prompt (0);
+      return;
     }
 
 #ifdef STOP_SIGNAL
diff --git a/gdb/exec.c b/gdb/exec.c
index b07175e..0228f41 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -742,7 +742,7 @@
 If FILE cannot be found as specified, your execution directory path\n\
 ($PATH) is searched for a command of that name.\n\
 No arg means to have no executable file and no symbols.", &cmdlist);
-      c->completer = filename_completer;
+      set_cmd_completer (c, filename_completer);
     }
 
   c = add_cmd ("exec-file", class_files, exec_file_command,
@@ -750,7 +750,7 @@
 If FILE cannot be found as specified, your execution directory path\n\
 is searched for a command of that name.\n\
 No arg means have no executable file.", &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_com ("section", class_files, set_section_command,
 	   "Change the base address of section SECTION of the exec file to ADDR.\n\
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 7cbfd5a..e1168772 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -924,7 +924,9 @@
   char *tokstart;
   
  retry:
-  
+ 
+  prev_lexptr = lexptr;
+ 
   tokstart = lexptr;
   
   /* First of all, let us make sure we are not dealing with the 
@@ -1171,5 +1173,8 @@
 yyerror (msg)
      char *msg;
 {
+  if (prev_lexptr)
+    lexptr = prev_lexptr;
+
   error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 1727bda..85866b3 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -904,7 +904,7 @@
     if (current_head_bf_list->symnum_fcn == the_function)
       {
 	if (global_remote_debug)
-	  fprintf (stderr, "*");
+	  fprintf_unfiltered (gdb_stderr, "*");
 
 	tmp = current_head_bf_list;
 	current_head_bf_list = current_head_bf_list->next;
@@ -916,7 +916,7 @@
      the ugly linear scan */
 
   if (global_remote_debug)
-    fprintf (stderr, "\ndefaulting to linear scan\n");
+    fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n");
 
   nprobes = 0;
   tmp = saved_bf_list;
@@ -926,7 +926,7 @@
       if (tmp->symnum_fcn == the_function)
 	{
 	  if (global_remote_debug)
-	    fprintf (stderr, "Found in %d probes\n", nprobes);
+	    fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes);
 	  current_head_bf_list = tmp->next;
 	  return (tmp->symnum_bf);
 	}
diff --git a/gdb/fbsd-proc.c b/gdb/fbsd-proc.c
new file mode 100644
index 0000000..c68238d
--- /dev/null
+++ b/gdb/fbsd-proc.c
@@ -0,0 +1,173 @@
+/* FreeBSD-specific methods for using the /proc file system.
+   Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "gdbcore.h"
+#include "inferior.h"
+
+#include <sys/procfs.h>
+#include <sys/types.h>
+
+#include "elf-bfd.h"
+
+#include "gregset.h"
+
+char *
+child_pid_to_exec_file (int pid)
+{
+  char *path;
+  char *buf;
+
+  xasprintf (&path, "/proc/%d/file", pid);
+  buf = xcalloc (MAXPATHLEN, sizeof (char));
+  make_cleanup (xfree, path);
+  make_cleanup (xfree, buf);
+
+  if (readlink (path, buf, MAXPATHLEN) > 0)
+    return buf;
+
+  return NULL;
+}
+
+static int
+read_mapping (FILE *mapfile,
+	      unsigned long *start,
+	      unsigned long *end,
+	      char *protection)
+{
+  int resident, privateresident;
+  unsigned long obj;
+  int ref_count, shadow_count;
+  unsigned flags;
+  char cow[5], access[4];
+  char type[8];
+  int ret;
+
+  /* The layout is described in /usr/src/miscfs/procfs/procfs_map.c.  */
+  ret = fscanf (mapfile, "%lx %lx %d %d %lx %s %d %d %x %s %s %s\n",
+		start, end,
+		&resident, &privateresident, &obj,
+		protection,
+		&ref_count, &shadow_count, &flags, cow, access, type);
+
+  return (ret != 0 && ret != EOF);
+}
+
+static int
+fbsd_find_memory_regions (int (*func) (CORE_ADDR,
+				       unsigned long,
+				       int, int, int,
+				       void *),
+			  void *obfd)
+{
+  pid_t pid = ptid_get_pid (inferior_ptid);
+  char *mapfilename;
+  FILE *mapfile;
+  unsigned long start, end, size;
+  char protection[4];
+  int read, write, exec;
+
+  xasprintf (&mapfilename, "/proc/%ld/map", (long) pid);
+  mapfile = fopen (mapfilename, "r");
+  if (mapfile == NULL)
+    error ("Couldn't open %s\n", mapfilename);
+
+  if (info_verbose)
+    fprintf_filtered (gdb_stdout, 
+		      "Reading memory regions from %s\n", mapfilename);
+
+  /* Now iterate until end-of-file.  */
+  while (read_mapping (mapfile, &start, &end, &protection[0]))
+    {
+      size = end - start;
+
+      read = (strchr (protection, 'r') != 0);
+      write = (strchr (protection, 'w') != 0);
+      exec = (strchr (protection, 'x') != 0);
+
+      if (info_verbose)
+	{
+	  fprintf_filtered (gdb_stdout, 
+			    "Save segment, %ld bytes at 0x%s (%c%c%c)\n", 
+			    size, paddr_nz (start),
+			    read ? 'r' : '-',
+			    write ? 'w' : '-',
+			    exec ? 'x' : '-');
+	}
+
+      /* Invoke the callback function to create the corefile segment. */
+      func (start, size, read, write, exec, obfd);
+    }
+
+  fclose (mapfile);
+  return 0;
+}
+
+static char *
+fbsd_make_corefile_notes (bfd *obfd, int *note_size)
+{
+  gregset_t gregs;
+  fpregset_t fpregs;
+  char *note_data = NULL;
+
+  fill_gregset (&gregs, -1);
+  note_data = (char *) elfcore_write_prstatus (obfd,
+					       note_data,
+					       note_size,
+					       ptid_get_pid (inferior_ptid),
+					       stop_signal,
+					       &gregs);
+
+  fill_fpregset (&fpregs, -1);
+  note_data = (char *) elfcore_write_prfpreg (obfd,
+					      note_data,
+					      note_size,
+					      &fpregs,
+					      sizeof (fpregs));
+
+  if (get_exec_file (0))
+    {
+      char *fname = strrchr (get_exec_file (0), '/') + 1;
+      char *psargs = xstrdup (fname);
+
+      if (get_inferior_args ())
+	psargs = reconcat (psargs, psargs, " ", get_inferior_args (), NULL);
+
+      note_data = (char *) elfcore_write_prpsinfo (obfd,
+						   note_data,
+						   note_size,
+						   fname,
+						   psargs);
+    }
+
+  make_cleanup (xfree, note_data);
+  return note_data;
+}
+
+
+void
+_initialize_fbsd_proc (void)
+{
+  extern void inftarg_set_find_memory_regions ();
+  extern void inftarg_set_make_corefile_notes ();
+
+  inftarg_set_find_memory_regions (fbsd_find_memory_regions);
+  inftarg_set_make_corefile_notes (fbsd_make_corefile_notes);
+}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 3a160a3..0f116ed 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -33,6 +33,7 @@
 #include "floatformat.h"
 #include "symfile.h"		/* for overlay functions */
 #include "regcache.h"
+#include "builtin-regs.h"
 
 /* Basic byte-swapping routines.  GDB has needed these for a long time...
    All extract a target-format integer at ADDR which is LEN bytes long.  */
@@ -56,7 +57,7 @@
   if (len > (int) sizeof (LONGEST))
     error ("\
 That operation is not available on integers of more than %d bytes.",
-	   sizeof (LONGEST));
+	   (int) sizeof (LONGEST));
 
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
@@ -90,7 +91,7 @@
   if (len > (int) sizeof (ULONGEST))
     error ("\
 That operation is not available on integers of more than %d bytes.",
-	   sizeof (ULONGEST));
+	   (int) sizeof (ULONGEST));
 
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
@@ -283,15 +284,15 @@
 
 
 
-/* Return a `value' with the contents of register REGNUM
-   in its virtual format, with the type specified by
-   REGISTER_VIRTUAL_TYPE.  
+/* Return a `value' with the contents of (virtual or cooked) register
+   REGNUM as found in the specified FRAME.  The register's type is
+   determined by REGISTER_VIRTUAL_TYPE.
 
-   NOTE: returns NULL if register value is not available.
-   Caller will check return value or die!  */
+   NOTE: returns NULL if register value is not available.  Caller will
+   check return value or die!  */
 
 struct value *
-value_of_register (int regnum)
+value_of_register (int regnum, struct frame_info *frame)
 {
   CORE_ADDR addr;
   int optim;
@@ -299,8 +300,13 @@
   char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
   enum lval_type lval;
 
+  /* Builtin registers lie completly outside of the range of normal
+     registers.  Catch them early so that the target never sees them.  */
+  if (regnum >= NUM_REGS + NUM_PSEUDO_REGS)
+    return value_of_builtin_reg (regnum, selected_frame);
+
   get_saved_register (raw_buffer, &optim, &addr,
-		      selected_frame, regnum, &lval);
+		      frame, regnum, &lval);
 
   if (register_cached (regnum) < 0)
     return NULL;		/* register value not available */
@@ -551,7 +557,7 @@
 
 	if (frame == NULL)
 	  return 0;
-	b = get_frame_block (frame);
+	b = get_frame_block (frame, 0);
 
 	if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR)
 	  {
diff --git a/gdb/frame.c b/gdb/frame.c
index ea59eba..2753150 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1,6 +1,7 @@
 /* Cache and manage the values of registers for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000,
+   2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -42,39 +43,6 @@
   if (frame == NULL)		/* No regs saved if want current frame */
     return 0;
 
-#ifdef HAVE_REGISTER_WINDOWS
-  /* We assume that a register in a register window will only be saved
-     in one place (since the name changes and/or disappears as you go
-     towards inner frames), so we only call get_frame_saved_regs on
-     the current frame.  This is directly in contradiction to the
-     usage below, which assumes that registers used in a frame must be
-     saved in a lower (more interior) frame.  This change is a result
-     of working on a register window machine; get_frame_saved_regs
-     always returns the registers saved within a frame, within the
-     context (register namespace) of that frame. */
-
-  /* However, note that we don't want this to return anything if
-     nothing is saved (if there's a frame inside of this one).  Also,
-     callers to this routine asking for the stack pointer want the
-     stack pointer saved for *this* frame; this is returned from the
-     next frame.  */
-
-  if (REGISTER_IN_WINDOW_P (regnum))
-    {
-      frame1 = get_next_frame (frame);
-      if (!frame1)
-	return 0;		/* Registers of this frame are active.  */
-
-      /* Get the SP from the next frame in; it will be this
-         current frame.  */
-      if (regnum != SP_REGNUM)
-	frame1 = frame;
-
-      FRAME_INIT_SAVED_REGS (frame1);
-      return frame1->saved_regs[regnum];	/* ... which might be zero */
-    }
-#endif /* HAVE_REGISTER_WINDOWS */
-
   /* Note that this next routine assumes that registers used in
      frame x will be saved only in the frame that x calls and
      frames interior to it.  This is not true on the sparc, but the
@@ -82,9 +50,10 @@
   while (1)
     {
       QUIT;
-      frame1 = get_prev_frame (frame1);
-      if (frame1 == 0 || frame1 == frame)
+      frame1 = get_next_frame (frame);
+      if (frame1 == 0)
 	break;
+      frame = frame1;
       FRAME_INIT_SAVED_REGS (frame1);
       if (frame1->saved_regs[regnum])
 	addr = frame1->saved_regs[regnum];
@@ -174,52 +143,26 @@
   GET_SAVED_REGISTER (raw_buffer, optimized, addrp, frame, regnum, lval);
 }
 
-/* READ_RELATIVE_REGISTER_RAW_BYTES_FOR_FRAME
+/* frame_register_read ()
 
-   Copy the bytes of register REGNUM, relative to the input stack frame,
-   into our memory at MYADDR, in target byte order.
+   Find and return the value of REGNUM for the specified stack frame.
    The number of bytes copied is REGISTER_RAW_SIZE (REGNUM).
 
-   Returns 1 if could not be read, 0 if could.  */
+   Returns 0 if the register value could not be found.  */
 
-/* FIXME: This function increases the confusion between FP_REGNUM
-   and the virtual/pseudo-frame pointer.  */
-
-static int
-read_relative_register_raw_bytes_for_frame (int regnum,
-					    char *myaddr,
-					    struct frame_info *frame)
+int
+frame_register_read (struct frame_info *frame, int regnum, void *myaddr)
 {
   int optim;
-  if (regnum == FP_REGNUM && frame)
-    {
-      /* Put it back in target format. */
-      store_address (myaddr, REGISTER_RAW_SIZE (FP_REGNUM),
-		     (LONGEST) FRAME_FP (frame));
-
-      return 0;
-    }
-
   get_saved_register (myaddr, &optim, (CORE_ADDR *) NULL, frame,
 		      regnum, (enum lval_type *) NULL);
 
+  /* FIXME: cagney/2002-04-10: This test is just bogus.  It is no
+     indication of the validity of the register.  The value could
+     easily be found (on the stack) even though the corresponding
+     register isn't available.  */
   if (register_cached (regnum) < 0)
-    return 1;			/* register value not available */
+    return 0;			/* register value not available */
 
-  return optim;
-}
-
-/* READ_RELATIVE_REGISTER_RAW_BYTES
-
-   Copy the bytes of register REGNUM, relative to the current stack
-   frame, into our memory at MYADDR, in target byte order.  
-   The number of bytes copied is REGISTER_RAW_SIZE (REGNUM).
-
-   Returns 1 if could not be read, 0 if could.  */
-
-int
-read_relative_register_raw_bytes (int regnum, char *myaddr)
-{
-  return read_relative_register_raw_bytes_for_frame (regnum, myaddr,
-						     selected_frame);
+  return !optim;
 }
diff --git a/gdb/frame.h b/gdb/frame.h
index b5f535a..f0631b0 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -1,6 +1,7 @@
 /* Definitions for dealing with stack frames, for GDB, the GNU debugger.
-   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
-   1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -63,6 +64,17 @@
        For other frames, it is a pc saved in the next frame.  */
     CORE_ADDR pc;
 
+    /* Level of this frame.  The inner-most (youngest) frame is at
+       level 0.  As you move towards the outer-most (oldest) frame,
+       the level increases.  This is a cached value.  It could just as
+       easily be computed by counting back from the selected frame to
+       the inner most frame.  */
+    /* NOTE: cagney/2002-04-05: Perhaphs a level of ``-1'' should be
+       reserved to indicate a bogus frame - one that has been created
+       just to keep GDB happy (GDB always needs a frame).  For the
+       moment leave this as speculation.  */
+    int level;
+
     /* Nonzero if this is a frame associated with calling a signal handler.
 
        Set by machine-dependent code.  On some machines, if
@@ -148,6 +160,11 @@
 
 #define FRAME_FP(fi) ((fi)->frame)
 
+/* Level of the frame: 0 for innermost, 1 for its caller, ...; or -1
+   for an invalid frame.  */
+
+extern int frame_relative_level (struct frame_info *fi);
+
 /* Define a default FRAME_CHAIN_VALID, in the form that is suitable for most
    targets.  If FRAME_CHAIN_VALID returns zero it means that the given frame
    is the outermost one and has no caller.
@@ -172,8 +189,6 @@
    0 for innermost, 1 for its caller, ...
    or -1 for frame specified by address with no defined level.  */
 
-extern int selected_frame_level;
-
 extern struct frame_info *create_new_frame (CORE_ADDR, CORE_ADDR);
 
 extern void flush_cached_frames (void);
@@ -196,11 +211,12 @@
 
 extern struct frame_info *get_next_frame (struct frame_info *);
 
-extern struct block *get_frame_block (struct frame_info *);
+extern struct block *get_frame_block (struct frame_info *,
+                                      CORE_ADDR *addr_in_block);
 
-extern struct block *get_current_block (void);
+extern struct block *get_current_block (CORE_ADDR *addr_in_block);
 
-extern struct block *get_selected_block (void);
+extern struct block *get_selected_block (CORE_ADDR *addr_in_block);
 
 extern struct symbol *get_frame_function (struct frame_info *);
 
@@ -228,12 +244,10 @@
 
 extern void show_stack_frame (struct frame_info *);
 
-extern void select_frame (struct frame_info *, int);
+extern void select_frame (struct frame_info *);
 
 extern void record_selected_frame (CORE_ADDR *, int *);
 
-extern void select_and_print_frame (struct frame_info *, int);
-
 extern void print_frame_info (struct frame_info *, int, int, int);
 
 extern void show_frame_info (struct frame_info *, int, int, int);
@@ -264,9 +278,16 @@
 					struct frame_info *, int,
 					enum lval_type *);
 
+extern void generic_save_call_dummy_addr (CORE_ADDR lo, CORE_ADDR hi);
+
 extern void get_saved_register (char *raw_buffer, int *optimized,
 				CORE_ADDR * addrp,
 				struct frame_info *frame,
 				int regnum, enum lval_type *lval);
 
+/* Return the register as found on the FRAME.  Return zero if the
+   register could not be found.  */
+extern int frame_register_read (struct frame_info *frame, int regnum,
+				void *buf);
+
 #endif /* !defined (FRAME_H)  */
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 494efad..25d1ed7 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -269,7 +269,7 @@
   for (sec = abfd->sections; sec; sec = sec->next)
     {
       if (bfd_get_section_flags (abfd, sec) & SEC_DATA ||
-	  strcmp (".bss", bfd_get_section_name (abfd, sec)) == 0)
+	  strcmp (".bss", bfd_section_name (abfd, sec)) == 0)
 	{
 	  sec_vaddr = bfd_get_section_vma (abfd, sec);
 	  sec_size = bfd_get_section_size_before_reloc (sec);
@@ -278,8 +278,19 @@
 	}
     }
   /* Now get the top-of-heap by calling sbrk in the inferior.  */
-  if ((sbrk = find_function_in_inferior ("sbrk")) == NULL)
+  if (lookup_minimal_symbol ("sbrk", NULL, NULL) != NULL)
+    {
+      if ((sbrk = find_function_in_inferior ("sbrk")) == NULL)
+	return 0;
+    }
+  else if (lookup_minimal_symbol ("_sbrk", NULL, NULL) != NULL)
+    {
+      if ((sbrk = find_function_in_inferior ("_sbrk")) == NULL)
+	return 0;
+    }
+  else
     return 0;
+
   if ((zero = value_from_longest (builtin_type_int, (LONGEST) 0)) == NULL)
     return 0;
   if ((sbrk = call_function_by_hand (sbrk, 1, &zero)) == NULL)
@@ -314,7 +325,7 @@
   int p_type;
 
   /* FIXME: these constants may only be applicable for ELF.  */
-  if (strncmp (osec->name, "load", 4) == 0)
+  if (strncmp (bfd_section_name (obfd, osec), "load", 4) == 0)
     p_type = PT_LOAD;
   else
     p_type = PT_NOTE;
@@ -452,7 +463,7 @@
   if (size == 0)
     return;	/* Read-only sections are marked as zero-size.
 		   We don't have to copy their contents. */
-  if (strncmp ("load", bfd_get_section_name (obfd, osec), 4) != 0)
+  if (strncmp ("load", bfd_section_name (obfd, osec), 4) != 0)
     return;	/* Only interested in "load" sections. */
 
   if ((memhunk = xmalloc (size)) == NULL)
diff --git a/gdb/gdb-events.c b/gdb/gdb-events.c
index 0fbb3ba..ada30a3 100644
--- a/gdb/gdb-events.c
+++ b/gdb/gdb-events.c
@@ -1,5 +1,6 @@
 /* User Interface Events.
-   Copyright 1999, 2001 Free Software Foundation, Inc.
+
+   Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
 
@@ -38,9 +39,6 @@
 #include "gdb-events.h"
 #include "gdbcmd.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 #if WITH_GDB_EVENTS
 static struct gdb_events null_event_hooks;
 static struct gdb_events queue_event_hooks;
diff --git a/gdb/gdb-events.h b/gdb/gdb-events.h
index 18a4a20..5f7fc6b 100644
--- a/gdb/gdb-events.h
+++ b/gdb/gdb-events.h
@@ -1,5 +1,6 @@
 /* User Interface Events.
-   Copyright 1999, 2001 Free Software Foundation, Inc.
+
+   Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
 
diff --git a/gdb/gdb-events.sh b/gdb/gdb-events.sh
index eb73465..9965f05 100755
--- a/gdb/gdb-events.sh
+++ b/gdb/gdb-events.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # User Interface Events.
-# Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 #
 # Contributed by Cygnus Solutions.
 #
@@ -113,7 +113,8 @@
 {
   cat <<EOF
 /* User Interface Events.
-   Copyright 1999, 2001 Free Software Foundation, Inc.
+
+   Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
 
@@ -303,9 +304,6 @@
 #include "gdb-events.h"
 #include "gdbcmd.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 #if WITH_GDB_EVENTS
 static struct gdb_events null_event_hooks;
 static struct gdb_events queue_event_hooks;
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 5aad461..ce4540d 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -74,13 +74,6 @@
 static void swapout_gdbarch_swap (struct gdbarch *);
 static void swapin_gdbarch_swap (struct gdbarch *);
 
-/* Convenience macro for allocting typesafe memory. */
-
-#ifndef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-#endif
-
-
 /* Non-zero if we want to trace architecture code.  */
 
 #ifndef GDBARCH_DEBUG
@@ -148,7 +141,6 @@
   gdbarch_read_pc_ftype *read_pc;
   gdbarch_write_pc_ftype *write_pc;
   gdbarch_read_fp_ftype *read_fp;
-  gdbarch_write_fp_ftype *write_fp;
   gdbarch_read_sp_ftype *read_sp;
   gdbarch_write_sp_ftype *write_sp;
   gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer;
@@ -159,6 +151,7 @@
   int sp_regnum;
   int fp_regnum;
   int pc_regnum;
+  int ps_regnum;
   int fp0_regnum;
   int npc_regnum;
   int nnpc_regnum;
@@ -257,6 +250,7 @@
   gdbarch_print_insn_ftype *print_insn;
   gdbarch_skip_trampoline_code_ftype *skip_trampoline_code;
   gdbarch_in_solib_call_trampoline_ftype *in_solib_call_trampoline;
+  gdbarch_pc_in_sigtramp_ftype *pc_in_sigtramp;
   gdbarch_in_function_epilogue_p_ftype *in_function_epilogue_p;
   gdbarch_construct_inferior_arguments_ftype *construct_inferior_arguments;
   gdbarch_dwarf2_build_frame_info_ftype *dwarf2_build_frame_info;
@@ -301,10 +295,10 @@
   0,
   0,
   0,
-  0,
-  0,
-  0,
-  0,
+  -1,
+  -1,
+  -1,
+  -1,
   0,
   0,
   0,
@@ -403,6 +397,7 @@
   0,
   0,
   0,
+  0,
   generic_in_function_epilogue_p,
   construct_inferior_arguments,
   0,
@@ -419,6 +414,7 @@
 initialize_non_multiarch ()
 {
   alloc_gdbarch_data (&startup_gdbarch);
+  init_gdbarch_swap (&startup_gdbarch);
   init_gdbarch_data (&startup_gdbarch);
 }
 
@@ -460,7 +456,6 @@
   current_gdbarch->read_pc = generic_target_read_pc;
   current_gdbarch->write_pc = generic_target_write_pc;
   current_gdbarch->read_fp = generic_target_read_fp;
-  current_gdbarch->write_fp = generic_target_write_fp;
   current_gdbarch->read_sp = generic_target_read_sp;
   current_gdbarch->write_sp = generic_target_write_sp;
   current_gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer;
@@ -468,6 +463,7 @@
   current_gdbarch->sp_regnum = -1;
   current_gdbarch->fp_regnum = -1;
   current_gdbarch->pc_regnum = -1;
+  current_gdbarch->ps_regnum = -1;
   current_gdbarch->fp0_regnum = -1;
   current_gdbarch->npc_regnum = -1;
   current_gdbarch->nnpc_regnum = -1;
@@ -522,6 +518,7 @@
   current_gdbarch->print_insn = legacy_print_insn;
   current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
   current_gdbarch->in_solib_call_trampoline = generic_in_solib_call_trampoline;
+  current_gdbarch->pc_in_sigtramp = legacy_pc_in_sigtramp;
   current_gdbarch->in_function_epilogue_p = generic_in_function_epilogue_p;
   current_gdbarch->construct_inferior_arguments = construct_inferior_arguments;
   current_gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special;
@@ -583,7 +580,6 @@
   /* Skip verify of read_pc, invalid_p == 0 */
   /* Skip verify of write_pc, invalid_p == 0 */
   /* Skip verify of read_fp, invalid_p == 0 */
-  /* Skip verify of write_fp, invalid_p == 0 */
   /* Skip verify of read_sp, invalid_p == 0 */
   /* Skip verify of write_sp, invalid_p == 0 */
   /* Skip verify of virtual_frame_pointer, invalid_p == 0 */
@@ -593,15 +589,10 @@
       && (gdbarch->num_regs == -1))
     fprintf_unfiltered (log, "\n\tnum_regs");
   /* Skip verify of num_pseudo_regs, invalid_p == 0 */
-  if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
-      && (gdbarch->sp_regnum == -1))
-    fprintf_unfiltered (log, "\n\tsp_regnum");
-  if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
-      && (gdbarch->fp_regnum == -1))
-    fprintf_unfiltered (log, "\n\tfp_regnum");
-  if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
-      && (gdbarch->pc_regnum == -1))
-    fprintf_unfiltered (log, "\n\tpc_regnum");
+  /* Skip verify of sp_regnum, invalid_p == 0 */
+  /* Skip verify of fp_regnum, invalid_p == 0 */
+  /* Skip verify of pc_regnum, invalid_p == 0 */
+  /* Skip verify of ps_regnum, invalid_p == 0 */
   /* Skip verify of fp0_regnum, invalid_p == 0 */
   /* Skip verify of npc_regnum, invalid_p == 0 */
   /* Skip verify of nnpc_regnum, invalid_p == 0 */
@@ -776,6 +767,7 @@
   /* Skip verify of print_insn, invalid_p == 0 */
   /* Skip verify of skip_trampoline_code, invalid_p == 0 */
   /* Skip verify of in_solib_call_trampoline, invalid_p == 0 */
+  /* Skip verify of pc_in_sigtramp, invalid_p == 0 */
   /* Skip verify of in_function_epilogue_p, invalid_p == 0 */
   /* Skip verify of construct_inferior_arguments, invalid_p == 0 */
   /* Skip verify of dwarf2_build_frame_info, has predicate */
@@ -1473,6 +1465,17 @@
                         (long) current_gdbarch->pc_in_call_dummy
                         /*PC_IN_CALL_DUMMY ()*/);
 #endif
+#ifdef PC_IN_SIGTRAMP
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: %s # %s\n",
+                      "PC_IN_SIGTRAMP(pc, name)",
+                      XSTRING (PC_IN_SIGTRAMP (pc, name)));
+  if (GDB_MULTI_ARCH)
+    fprintf_unfiltered (file,
+                        "gdbarch_dump: PC_IN_SIGTRAMP = 0x%08lx\n",
+                        (long) current_gdbarch->pc_in_sigtramp
+                        /*PC_IN_SIGTRAMP ()*/);
+#endif
 #ifdef PC_REGNUM
   fprintf_unfiltered (file,
                       "gdbarch_dump: PC_REGNUM # %s\n",
@@ -1542,6 +1545,14 @@
                         (long) current_gdbarch->prologue_frameless_p
                         /*PROLOGUE_FRAMELESS_P ()*/);
 #endif
+#ifdef PS_REGNUM
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: PS_REGNUM # %s\n",
+                      XSTRING (PS_REGNUM));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: PS_REGNUM = %d\n",
+                      PS_REGNUM);
+#endif
 #ifdef PUSH_ARGUMENTS
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
@@ -2096,20 +2107,6 @@
                         (long) current_gdbarch->virtual_frame_pointer
                         /*TARGET_VIRTUAL_FRAME_POINTER ()*/);
 #endif
-#ifdef TARGET_WRITE_FP
-#if GDB_MULTI_ARCH
-  /* Macro might contain `[{}]' when not multi-arch */
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: %s # %s\n",
-                      "TARGET_WRITE_FP(val)",
-                      XSTRING (TARGET_WRITE_FP (val)));
-#endif
-  if (GDB_MULTI_ARCH)
-    fprintf_unfiltered (file,
-                        "gdbarch_dump: TARGET_WRITE_FP = 0x%08lx\n",
-                        (long) current_gdbarch->write_fp
-                        /*TARGET_WRITE_FP ()*/);
-#endif
 #ifdef TARGET_WRITE_PC
 #if GDB_MULTI_ARCH
   /* Macro might contain `[{}]' when not multi-arch */
@@ -2173,6 +2170,7 @@
 const struct bfd_arch_info *
 gdbarch_bfd_arch_info (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_bfd_arch_info called\n");
   return gdbarch->bfd_arch_info;
@@ -2181,6 +2179,7 @@
 int
 gdbarch_byte_order (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_byte_order called\n");
   return gdbarch->byte_order;
@@ -2189,6 +2188,7 @@
 int
 gdbarch_short_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of short_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_short_bit called\n");
@@ -2205,6 +2205,7 @@
 int
 gdbarch_int_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of int_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_int_bit called\n");
@@ -2221,6 +2222,7 @@
 int
 gdbarch_long_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of long_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_bit called\n");
@@ -2237,6 +2239,7 @@
 int
 gdbarch_long_long_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of long_long_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_long_bit called\n");
@@ -2253,6 +2256,7 @@
 int
 gdbarch_float_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of float_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_float_bit called\n");
@@ -2269,6 +2273,7 @@
 int
 gdbarch_double_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of double_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_double_bit called\n");
@@ -2285,6 +2290,7 @@
 int
 gdbarch_long_double_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of long_double_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_double_bit called\n");
@@ -2301,6 +2307,7 @@
 int
 gdbarch_ptr_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of ptr_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_ptr_bit called\n");
@@ -2317,6 +2324,7 @@
 int
 gdbarch_addr_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->addr_bit == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_addr_bit invalid");
@@ -2335,6 +2343,7 @@
 int
 gdbarch_bfd_vma_bit (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of bfd_vma_bit, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_bfd_vma_bit called\n");
@@ -2351,6 +2360,7 @@
 int
 gdbarch_char_signed (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->char_signed == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_char_signed invalid");
@@ -2369,6 +2379,7 @@
 CORE_ADDR
 gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->read_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_read_pc invalid");
@@ -2387,6 +2398,7 @@
 void
 gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, ptid_t ptid)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->write_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_write_pc invalid");
@@ -2405,6 +2417,7 @@
 CORE_ADDR
 gdbarch_read_fp (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->read_fp == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_read_fp invalid");
@@ -2420,27 +2433,10 @@
   gdbarch->read_fp = read_fp;
 }
 
-void
-gdbarch_write_fp (struct gdbarch *gdbarch, CORE_ADDR val)
-{
-  if (gdbarch->write_fp == 0)
-    internal_error (__FILE__, __LINE__,
-                    "gdbarch: gdbarch_write_fp invalid");
-  if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_write_fp called\n");
-  gdbarch->write_fp (val);
-}
-
-void
-set_gdbarch_write_fp (struct gdbarch *gdbarch,
-                      gdbarch_write_fp_ftype write_fp)
-{
-  gdbarch->write_fp = write_fp;
-}
-
 CORE_ADDR
 gdbarch_read_sp (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->read_sp == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_read_sp invalid");
@@ -2459,6 +2455,7 @@
 void
 gdbarch_write_sp (struct gdbarch *gdbarch, CORE_ADDR val)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->write_sp == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_write_sp invalid");
@@ -2477,6 +2474,7 @@
 void
 gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->virtual_frame_pointer == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_virtual_frame_pointer invalid");
@@ -2495,12 +2493,14 @@
 int
 gdbarch_register_read_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->register_read != 0;
 }
 
 void
 gdbarch_register_read (struct gdbarch *gdbarch, int regnum, char *buf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_read == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_read invalid");
@@ -2519,12 +2519,14 @@
 int
 gdbarch_register_write_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->register_write != 0;
 }
 
 void
 gdbarch_register_write (struct gdbarch *gdbarch, int regnum, char *buf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_write == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_write invalid");
@@ -2543,6 +2545,7 @@
 int
 gdbarch_num_regs (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->num_regs == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_num_regs invalid");
@@ -2561,6 +2564,7 @@
 int
 gdbarch_num_pseudo_regs (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of num_pseudo_regs, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_num_pseudo_regs called\n");
@@ -2577,9 +2581,8 @@
 int
 gdbarch_sp_regnum (struct gdbarch *gdbarch)
 {
-  if (gdbarch->sp_regnum == -1)
-    internal_error (__FILE__, __LINE__,
-                    "gdbarch: gdbarch_sp_regnum invalid");
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of sp_regnum, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_sp_regnum called\n");
   return gdbarch->sp_regnum;
@@ -2595,9 +2598,8 @@
 int
 gdbarch_fp_regnum (struct gdbarch *gdbarch)
 {
-  if (gdbarch->fp_regnum == -1)
-    internal_error (__FILE__, __LINE__,
-                    "gdbarch: gdbarch_fp_regnum invalid");
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of fp_regnum, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_fp_regnum called\n");
   return gdbarch->fp_regnum;
@@ -2613,9 +2615,8 @@
 int
 gdbarch_pc_regnum (struct gdbarch *gdbarch)
 {
-  if (gdbarch->pc_regnum == -1)
-    internal_error (__FILE__, __LINE__,
-                    "gdbarch: gdbarch_pc_regnum invalid");
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of pc_regnum, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_pc_regnum called\n");
   return gdbarch->pc_regnum;
@@ -2629,8 +2630,26 @@
 }
 
 int
+gdbarch_ps_regnum (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of ps_regnum, invalid_p == 0 */
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_ps_regnum called\n");
+  return gdbarch->ps_regnum;
+}
+
+void
+set_gdbarch_ps_regnum (struct gdbarch *gdbarch,
+                       int ps_regnum)
+{
+  gdbarch->ps_regnum = ps_regnum;
+}
+
+int
 gdbarch_fp0_regnum (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of fp0_regnum, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_fp0_regnum called\n");
@@ -2647,6 +2666,7 @@
 int
 gdbarch_npc_regnum (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of npc_regnum, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_npc_regnum called\n");
@@ -2663,6 +2683,7 @@
 int
 gdbarch_nnpc_regnum (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of nnpc_regnum, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_nnpc_regnum called\n");
@@ -2679,6 +2700,7 @@
 int
 gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch, int stab_regnr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->stab_reg_to_regnum == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_stab_reg_to_regnum invalid");
@@ -2697,6 +2719,7 @@
 int
 gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch, int ecoff_regnr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->ecoff_reg_to_regnum == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_ecoff_reg_to_regnum invalid");
@@ -2715,6 +2738,7 @@
 int
 gdbarch_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int dwarf_regnr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->dwarf_reg_to_regnum == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_dwarf_reg_to_regnum invalid");
@@ -2733,6 +2757,7 @@
 int
 gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch, int sdb_regnr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->sdb_reg_to_regnum == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_sdb_reg_to_regnum invalid");
@@ -2751,6 +2776,7 @@
 int
 gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int dwarf2_regnr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->dwarf2_reg_to_regnum == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_dwarf2_reg_to_regnum invalid");
@@ -2769,6 +2795,7 @@
 char *
 gdbarch_register_name (struct gdbarch *gdbarch, int regnr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_name == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_name invalid");
@@ -2787,6 +2814,7 @@
 int
 gdbarch_register_size (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_size == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_size invalid");
@@ -2805,6 +2833,7 @@
 int
 gdbarch_register_bytes (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_bytes == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_bytes invalid");
@@ -2823,6 +2852,7 @@
 int
 gdbarch_register_byte (struct gdbarch *gdbarch, int reg_nr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_byte == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_byte invalid");
@@ -2841,6 +2871,7 @@
 int
 gdbarch_register_raw_size (struct gdbarch *gdbarch, int reg_nr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_raw_size == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_raw_size invalid");
@@ -2859,6 +2890,7 @@
 int
 gdbarch_max_register_raw_size (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->max_register_raw_size == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_max_register_raw_size invalid");
@@ -2877,6 +2909,7 @@
 int
 gdbarch_register_virtual_size (struct gdbarch *gdbarch, int reg_nr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_virtual_size == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_virtual_size invalid");
@@ -2895,6 +2928,7 @@
 int
 gdbarch_max_register_virtual_size (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->max_register_virtual_size == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_max_register_virtual_size invalid");
@@ -2913,6 +2947,7 @@
 struct type *
 gdbarch_register_virtual_type (struct gdbarch *gdbarch, int reg_nr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_virtual_type == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_virtual_type invalid");
@@ -2931,6 +2966,7 @@
 void
 gdbarch_do_registers_info (struct gdbarch *gdbarch, int reg_nr, int fpregs)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->do_registers_info == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_do_registers_info invalid");
@@ -2949,6 +2985,7 @@
 void
 gdbarch_print_float_info (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->print_float_info == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_print_float_info invalid");
@@ -2967,6 +3004,7 @@
 int
 gdbarch_register_sim_regno (struct gdbarch *gdbarch, int reg_nr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_sim_regno == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_sim_regno invalid");
@@ -2985,12 +3023,14 @@
 int
 gdbarch_register_bytes_ok_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->register_bytes_ok != 0;
 }
 
 int
 gdbarch_register_bytes_ok (struct gdbarch *gdbarch, long nr_bytes)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_bytes_ok == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_bytes_ok invalid");
@@ -3009,6 +3049,7 @@
 int
 gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->cannot_fetch_register == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_cannot_fetch_register invalid");
@@ -3027,6 +3068,7 @@
 int
 gdbarch_cannot_store_register (struct gdbarch *gdbarch, int regnum)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->cannot_store_register == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_cannot_store_register invalid");
@@ -3045,12 +3087,14 @@
 int
 gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->get_longjmp_target != 0;
 }
 
 int
 gdbarch_get_longjmp_target (struct gdbarch *gdbarch, CORE_ADDR *pc)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->get_longjmp_target == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_get_longjmp_target invalid");
@@ -3069,6 +3113,7 @@
 int
 gdbarch_use_generic_dummy_frames (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->use_generic_dummy_frames == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_use_generic_dummy_frames invalid");
@@ -3087,6 +3132,7 @@
 int
 gdbarch_call_dummy_location (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_location == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_location invalid");
@@ -3105,6 +3151,7 @@
 CORE_ADDR
 gdbarch_call_dummy_address (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_address invalid");
@@ -3123,6 +3170,7 @@
 CORE_ADDR
 gdbarch_call_dummy_start_offset (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_start_offset == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_start_offset invalid");
@@ -3141,6 +3189,7 @@
 CORE_ADDR
 gdbarch_call_dummy_breakpoint_offset (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_breakpoint_offset_p && gdbarch->call_dummy_breakpoint_offset == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_breakpoint_offset invalid");
@@ -3159,6 +3208,7 @@
 int
 gdbarch_call_dummy_breakpoint_offset_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_breakpoint_offset_p == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_breakpoint_offset_p invalid");
@@ -3177,6 +3227,7 @@
 int
 gdbarch_call_dummy_length (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_length == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_length invalid");
@@ -3195,6 +3246,7 @@
 int
 gdbarch_pc_in_call_dummy (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->pc_in_call_dummy == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_pc_in_call_dummy invalid");
@@ -3213,6 +3265,7 @@
 int
 gdbarch_call_dummy_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_p == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_p invalid");
@@ -3231,6 +3284,7 @@
 LONGEST *
 gdbarch_call_dummy_words (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of call_dummy_words, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_call_dummy_words called\n");
@@ -3247,6 +3301,7 @@
 int
 gdbarch_sizeof_call_dummy_words (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of sizeof_call_dummy_words, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_sizeof_call_dummy_words called\n");
@@ -3263,6 +3318,7 @@
 int
 gdbarch_call_dummy_stack_adjust_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_stack_adjust_p == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_stack_adjust_p invalid");
@@ -3281,6 +3337,7 @@
 int
 gdbarch_call_dummy_stack_adjust (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->call_dummy_stack_adjust_p && gdbarch->call_dummy_stack_adjust == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_call_dummy_stack_adjust invalid");
@@ -3299,6 +3356,7 @@
 void
 gdbarch_fix_call_dummy (struct gdbarch *gdbarch, char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, struct value **args, struct type *type, int gcc_p)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->fix_call_dummy == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_fix_call_dummy invalid");
@@ -3317,6 +3375,7 @@
 void
 gdbarch_init_frame_pc_first (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->init_frame_pc_first == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_init_frame_pc_first invalid");
@@ -3335,6 +3394,7 @@
 void
 gdbarch_init_frame_pc (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->init_frame_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_init_frame_pc invalid");
@@ -3353,6 +3413,7 @@
 int
 gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_believe_pcc_promotion called\n");
   return gdbarch->believe_pcc_promotion;
@@ -3368,6 +3429,7 @@
 int
 gdbarch_believe_pcc_promotion_type (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_believe_pcc_promotion_type called\n");
   return gdbarch->believe_pcc_promotion_type;
@@ -3383,6 +3445,7 @@
 int
 gdbarch_coerce_float_to_double (struct gdbarch *gdbarch, struct type *formal, struct type *actual)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->coerce_float_to_double == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_coerce_float_to_double invalid");
@@ -3401,6 +3464,7 @@
 void
 gdbarch_get_saved_register (struct gdbarch *gdbarch, char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->get_saved_register == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_get_saved_register invalid");
@@ -3419,6 +3483,7 @@
 int
 gdbarch_register_convertible (struct gdbarch *gdbarch, int nr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_convertible == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_convertible invalid");
@@ -3437,6 +3502,7 @@
 void
 gdbarch_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, struct type *type, char *from, char *to)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_convert_to_virtual == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_convert_to_virtual invalid");
@@ -3455,6 +3521,7 @@
 void
 gdbarch_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type, int regnum, char *from, char *to)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->register_convert_to_raw == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_register_convert_to_raw invalid");
@@ -3473,12 +3540,14 @@
 int
 gdbarch_fetch_pseudo_register_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->fetch_pseudo_register != 0;
 }
 
 void
 gdbarch_fetch_pseudo_register (struct gdbarch *gdbarch, int regnum)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->fetch_pseudo_register == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_fetch_pseudo_register invalid");
@@ -3497,12 +3566,14 @@
 int
 gdbarch_store_pseudo_register_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->store_pseudo_register != 0;
 }
 
 void
 gdbarch_store_pseudo_register (struct gdbarch *gdbarch, int regnum)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->store_pseudo_register == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_store_pseudo_register invalid");
@@ -3521,6 +3592,7 @@
 CORE_ADDR
 gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, void *buf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->pointer_to_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_pointer_to_address invalid");
@@ -3539,6 +3611,7 @@
 void
 gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, void *buf, CORE_ADDR addr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->address_to_pointer == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_address_to_pointer invalid");
@@ -3557,12 +3630,14 @@
 int
 gdbarch_integer_to_address_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->integer_to_address != 0;
 }
 
 CORE_ADDR
 gdbarch_integer_to_address (struct gdbarch *gdbarch, struct type *type, void *buf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->integer_to_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_integer_to_address invalid");
@@ -3581,6 +3656,7 @@
 int
 gdbarch_return_value_on_stack (struct gdbarch *gdbarch, struct type *type)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->return_value_on_stack == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_return_value_on_stack invalid");
@@ -3599,6 +3675,7 @@
 void
 gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, char *regbuf, char *valbuf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->extract_return_value == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_extract_return_value invalid");
@@ -3617,6 +3694,7 @@
 CORE_ADDR
 gdbarch_push_arguments (struct gdbarch *gdbarch, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->push_arguments == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_push_arguments invalid");
@@ -3635,6 +3713,7 @@
 void
 gdbarch_push_dummy_frame (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->push_dummy_frame == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_push_dummy_frame invalid");
@@ -3653,12 +3732,14 @@
 int
 gdbarch_push_return_address_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->push_return_address != 0;
 }
 
 CORE_ADDR
 gdbarch_push_return_address (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR sp)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->push_return_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_push_return_address invalid");
@@ -3677,6 +3758,7 @@
 void
 gdbarch_pop_frame (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->pop_frame == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_pop_frame invalid");
@@ -3695,6 +3777,7 @@
 void
 gdbarch_store_struct_return (struct gdbarch *gdbarch, CORE_ADDR addr, CORE_ADDR sp)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->store_struct_return == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_store_struct_return invalid");
@@ -3713,6 +3796,7 @@
 void
 gdbarch_store_return_value (struct gdbarch *gdbarch, struct type *type, char *valbuf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->store_return_value == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_store_return_value invalid");
@@ -3731,12 +3815,14 @@
 int
 gdbarch_extract_struct_value_address_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->extract_struct_value_address != 0;
 }
 
 CORE_ADDR
 gdbarch_extract_struct_value_address (struct gdbarch *gdbarch, char *regbuf)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->extract_struct_value_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_extract_struct_value_address invalid");
@@ -3755,6 +3841,7 @@
 int
 gdbarch_use_struct_convention (struct gdbarch *gdbarch, int gcc_p, struct type *value_type)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->use_struct_convention == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_use_struct_convention invalid");
@@ -3773,6 +3860,7 @@
 void
 gdbarch_frame_init_saved_regs (struct gdbarch *gdbarch, struct frame_info *frame)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_init_saved_regs == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_init_saved_regs invalid");
@@ -3791,12 +3879,14 @@
 int
 gdbarch_init_extra_frame_info_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->init_extra_frame_info != 0;
 }
 
 void
 gdbarch_init_extra_frame_info (struct gdbarch *gdbarch, int fromleaf, struct frame_info *frame)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->init_extra_frame_info == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_init_extra_frame_info invalid");
@@ -3815,6 +3905,7 @@
 CORE_ADDR
 gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->skip_prologue == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_skip_prologue invalid");
@@ -3833,6 +3924,7 @@
 int
 gdbarch_prologue_frameless_p (struct gdbarch *gdbarch, CORE_ADDR ip)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->prologue_frameless_p == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_prologue_frameless_p invalid");
@@ -3851,6 +3943,7 @@
 int
 gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->inner_than == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_inner_than invalid");
@@ -3866,9 +3959,10 @@
   gdbarch->inner_than = inner_than;
 }
 
-unsigned char *
+const unsigned char *
 gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->breakpoint_from_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_breakpoint_from_pc invalid");
@@ -3887,6 +3981,7 @@
 int
 gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, char *contents_cache)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->memory_insert_breakpoint == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_memory_insert_breakpoint invalid");
@@ -3905,6 +4000,7 @@
 int
 gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, char *contents_cache)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->memory_remove_breakpoint == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_memory_remove_breakpoint invalid");
@@ -3923,6 +4019,7 @@
 CORE_ADDR
 gdbarch_decr_pc_after_break (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->decr_pc_after_break == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_decr_pc_after_break invalid");
@@ -3941,6 +4038,7 @@
 int
 gdbarch_prepare_to_proceed (struct gdbarch *gdbarch, int select_it)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->prepare_to_proceed == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_prepare_to_proceed invalid");
@@ -3959,6 +4057,7 @@
 CORE_ADDR
 gdbarch_function_start_offset (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->function_start_offset == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_function_start_offset invalid");
@@ -3977,6 +4076,7 @@
 void
 gdbarch_remote_translate_xfer_address (struct gdbarch *gdbarch, CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->remote_translate_xfer_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_remote_translate_xfer_address invalid");
@@ -3995,6 +4095,7 @@
 CORE_ADDR
 gdbarch_frame_args_skip (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_args_skip == -1)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_args_skip invalid");
@@ -4013,6 +4114,7 @@
 int
 gdbarch_frameless_function_invocation (struct gdbarch *gdbarch, struct frame_info *fi)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frameless_function_invocation == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frameless_function_invocation invalid");
@@ -4031,6 +4133,7 @@
 CORE_ADDR
 gdbarch_frame_chain (struct gdbarch *gdbarch, struct frame_info *frame)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_chain == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_chain invalid");
@@ -4049,6 +4152,7 @@
 int
 gdbarch_frame_chain_valid (struct gdbarch *gdbarch, CORE_ADDR chain, struct frame_info *thisframe)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_chain_valid == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_chain_valid invalid");
@@ -4067,6 +4171,7 @@
 CORE_ADDR
 gdbarch_frame_saved_pc (struct gdbarch *gdbarch, struct frame_info *fi)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_saved_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_saved_pc invalid");
@@ -4085,6 +4190,7 @@
 CORE_ADDR
 gdbarch_frame_args_address (struct gdbarch *gdbarch, struct frame_info *fi)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_args_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_args_address invalid");
@@ -4103,6 +4209,7 @@
 CORE_ADDR
 gdbarch_frame_locals_address (struct gdbarch *gdbarch, struct frame_info *fi)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_locals_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_locals_address invalid");
@@ -4121,6 +4228,7 @@
 CORE_ADDR
 gdbarch_saved_pc_after_call (struct gdbarch *gdbarch, struct frame_info *frame)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->saved_pc_after_call == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_saved_pc_after_call invalid");
@@ -4139,6 +4247,7 @@
 int
 gdbarch_frame_num_args (struct gdbarch *gdbarch, struct frame_info *frame)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->frame_num_args == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_frame_num_args invalid");
@@ -4157,12 +4266,14 @@
 int
 gdbarch_stack_align_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->stack_align != 0;
 }
 
 CORE_ADDR
 gdbarch_stack_align (struct gdbarch *gdbarch, CORE_ADDR sp)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->stack_align == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_stack_align invalid");
@@ -4181,6 +4292,7 @@
 int
 gdbarch_extra_stack_alignment_needed (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   /* Skip verify of extra_stack_alignment_needed, invalid_p == 0 */
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_extra_stack_alignment_needed called\n");
@@ -4197,12 +4309,14 @@
 int
 gdbarch_reg_struct_has_addr_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->reg_struct_has_addr != 0;
 }
 
 int
 gdbarch_reg_struct_has_addr (struct gdbarch *gdbarch, int gcc_p, struct type *type)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->reg_struct_has_addr == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_reg_struct_has_addr invalid");
@@ -4221,12 +4335,14 @@
 int
 gdbarch_save_dummy_frame_tos_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->save_dummy_frame_tos != 0;
 }
 
 void
 gdbarch_save_dummy_frame_tos (struct gdbarch *gdbarch, CORE_ADDR sp)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->save_dummy_frame_tos == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_save_dummy_frame_tos invalid");
@@ -4245,6 +4361,7 @@
 int
 gdbarch_parm_boundary (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_parm_boundary called\n");
   return gdbarch->parm_boundary;
@@ -4260,6 +4377,7 @@
 const struct floatformat *
 gdbarch_float_format (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_float_format called\n");
   return gdbarch->float_format;
@@ -4275,6 +4393,7 @@
 const struct floatformat *
 gdbarch_double_format (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_double_format called\n");
   return gdbarch->double_format;
@@ -4290,6 +4409,7 @@
 const struct floatformat *
 gdbarch_long_double_format (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_double_format called\n");
   return gdbarch->long_double_format;
@@ -4305,6 +4425,7 @@
 CORE_ADDR
 gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->convert_from_func_ptr_addr == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_convert_from_func_ptr_addr invalid");
@@ -4323,6 +4444,7 @@
 CORE_ADDR
 gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->addr_bits_remove == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_addr_bits_remove invalid");
@@ -4341,6 +4463,7 @@
 CORE_ADDR
 gdbarch_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->smash_text_address == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_smash_text_address invalid");
@@ -4359,12 +4482,14 @@
 int
 gdbarch_software_single_step_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->software_single_step != 0;
 }
 
 void
 gdbarch_software_single_step (struct gdbarch *gdbarch, enum target_signal sig, int insert_breakpoints_p)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->software_single_step == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_software_single_step invalid");
@@ -4383,6 +4508,7 @@
 int
 gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, disassemble_info *info)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->print_insn == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_print_insn invalid");
@@ -4401,6 +4527,7 @@
 CORE_ADDR
 gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->skip_trampoline_code == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_skip_trampoline_code invalid");
@@ -4419,6 +4546,7 @@
 int
 gdbarch_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char *name)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->in_solib_call_trampoline == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_in_solib_call_trampoline invalid");
@@ -4435,8 +4563,28 @@
 }
 
 int
+gdbarch_pc_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc, char *name)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch->pc_in_sigtramp == 0)
+    internal_error (__FILE__, __LINE__,
+                    "gdbarch: gdbarch_pc_in_sigtramp invalid");
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_pc_in_sigtramp called\n");
+  return gdbarch->pc_in_sigtramp (pc, name);
+}
+
+void
+set_gdbarch_pc_in_sigtramp (struct gdbarch *gdbarch,
+                            gdbarch_pc_in_sigtramp_ftype pc_in_sigtramp)
+{
+  gdbarch->pc_in_sigtramp = pc_in_sigtramp;
+}
+
+int
 gdbarch_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->in_function_epilogue_p == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_in_function_epilogue_p invalid");
@@ -4455,6 +4603,7 @@
 char *
 gdbarch_construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->construct_inferior_arguments == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_construct_inferior_arguments invalid");
@@ -4473,12 +4622,14 @@
 int
 gdbarch_dwarf2_build_frame_info_p (struct gdbarch *gdbarch)
 {
+  gdb_assert (gdbarch != NULL);
   return gdbarch->dwarf2_build_frame_info != 0;
 }
 
 void
 gdbarch_dwarf2_build_frame_info (struct gdbarch *gdbarch, struct objfile *objfile)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->dwarf2_build_frame_info == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_dwarf2_build_frame_info invalid");
@@ -4497,6 +4648,7 @@
 void
 gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->elf_make_msymbol_special == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_elf_make_msymbol_special invalid");
@@ -4515,6 +4667,7 @@
 void
 gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, int val, struct minimal_symbol *msym)
 {
+  gdb_assert (gdbarch != NULL);
   if (gdbarch->coff_make_msymbol_special == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_coff_make_msymbol_special invalid");
@@ -4880,7 +5033,6 @@
 gdbarch_update_p (struct gdbarch_info info)
 {
   struct gdbarch *new_gdbarch;
-  struct gdbarch_list **list;
   struct gdbarch_registration *rego;
 
   /* Fill in missing parts of the INFO struct using a number of
@@ -4973,29 +5125,46 @@
   /* Swap all data belonging to the old target out */
   swapout_gdbarch_swap (current_gdbarch);
 
-  /* Is this a pre-existing architecture?  Yes. Swap it in.  */
-  for (list = &rego->arches;
-       (*list) != NULL;
-       list = &(*list)->next)
-    {
-      if ((*list)->gdbarch == new_gdbarch)
-	{
-	  if (gdbarch_debug)
-	    fprintf_unfiltered (gdb_stdlog,
-                                "gdbarch_update: Previous architecture 0x%08lx (%s) selected\n",
-				(long) new_gdbarch,
-				new_gdbarch->bfd_arch_info->printable_name);
-	  current_gdbarch = new_gdbarch;
-	  swapin_gdbarch_swap (new_gdbarch);
-	  architecture_changed_event ();
-	  return 1;
-	}
-    }
+  /* Is this a pre-existing architecture?  Yes. Move it to the front
+     of the list of architectures (keeping the list sorted Most
+     Recently Used) and then copy it in.  */
+  {
+    struct gdbarch_list **list;
+    for (list = &rego->arches;
+	 (*list) != NULL;
+	 list = &(*list)->next)
+      {
+	if ((*list)->gdbarch == new_gdbarch)
+	  {
+	    struct gdbarch_list *this;
+	    if (gdbarch_debug)
+	      fprintf_unfiltered (gdb_stdlog,
+				  "gdbarch_update: Previous architecture 0x%08lx (%s) selected\n",
+				  (long) new_gdbarch,
+				  new_gdbarch->bfd_arch_info->printable_name);
+	    /* Unlink this.  */
+	    this = (*list);
+	    (*list) = this->next;
+	    /* Insert in the front.  */
+	    this->next = rego->arches;
+	    rego->arches = this;
+	    /* Copy the new architecture in.  */
+	    current_gdbarch = new_gdbarch;
+	    swapin_gdbarch_swap (new_gdbarch);
+	    architecture_changed_event ();
+	    return 1;
+	  }
+      }
+  }
 
-  /* Append this new architecture to this targets list. */
-  (*list) = XMALLOC (struct gdbarch_list);
-  (*list)->next = NULL;
-  (*list)->gdbarch = new_gdbarch;
+  /* Prepend this new architecture to the architecture list (keep the
+     list sorted Most Recently Used).  */
+  {
+    struct gdbarch_list *this = XMALLOC (struct gdbarch_list);
+    this->next = rego->arches;
+    this->gdbarch = new_gdbarch;
+    rego->arches = this;
+  }    
 
   /* Switch to this new architecture.  Dump it out. */
   current_gdbarch = new_gdbarch;
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 81f5174..0e334cf 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -37,7 +37,9 @@
 
 #include "dis-asm.h" /* Get defs for disassemble_info, which unfortunately is a typedef. */
 #if !GDB_MULTI_ARCH
+/* Pull in function declarations refered to, indirectly, via macros.  */
 #include "value.h" /* For default_coerce_float_to_double which is referenced by a macro.  */
+#include "inferior.h"		/* For unsigned_address_to_pointer().  */
 #endif
 
 struct frame_info;
@@ -358,23 +360,6 @@
 #endif
 
 /* Default (function) for non- multi-arch platforms. */
-#if (!GDB_MULTI_ARCH) && !defined (TARGET_WRITE_FP)
-#define TARGET_WRITE_FP(val) (generic_target_write_fp (val))
-#endif
-
-typedef void (gdbarch_write_fp_ftype) (CORE_ADDR val);
-extern void gdbarch_write_fp (struct gdbarch *gdbarch, CORE_ADDR val);
-extern void set_gdbarch_write_fp (struct gdbarch *gdbarch, gdbarch_write_fp_ftype *write_fp);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_WRITE_FP)
-#error "Non multi-arch definition of TARGET_WRITE_FP"
-#endif
-#if GDB_MULTI_ARCH
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_WRITE_FP)
-#define TARGET_WRITE_FP(val) (gdbarch_write_fp (current_gdbarch, val))
-#endif
-#endif
-
-/* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (TARGET_READ_SP)
 #define TARGET_READ_SP() (generic_target_read_sp ())
 #endif
@@ -473,6 +458,15 @@
 #endif
 #endif
 
+/* GDB's standard (or well known) register numbers.  These can map onto
+   a real register or a pseudo (computed) register or not be defined at
+   all (-1). */
+
+/* Default (value) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (SP_REGNUM)
+#define SP_REGNUM (-1)
+#endif
+
 extern int gdbarch_sp_regnum (struct gdbarch *gdbarch);
 extern void set_gdbarch_sp_regnum (struct gdbarch *gdbarch, int sp_regnum);
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (SP_REGNUM)
@@ -484,6 +478,11 @@
 #endif
 #endif
 
+/* Default (value) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (FP_REGNUM)
+#define FP_REGNUM (-1)
+#endif
+
 extern int gdbarch_fp_regnum (struct gdbarch *gdbarch);
 extern void set_gdbarch_fp_regnum (struct gdbarch *gdbarch, int fp_regnum);
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FP_REGNUM)
@@ -495,6 +494,11 @@
 #endif
 #endif
 
+/* Default (value) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (PC_REGNUM)
+#define PC_REGNUM (-1)
+#endif
+
 extern int gdbarch_pc_regnum (struct gdbarch *gdbarch);
 extern void set_gdbarch_pc_regnum (struct gdbarch *gdbarch, int pc_regnum);
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (PC_REGNUM)
@@ -507,6 +511,22 @@
 #endif
 
 /* Default (value) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (PS_REGNUM)
+#define PS_REGNUM (-1)
+#endif
+
+extern int gdbarch_ps_regnum (struct gdbarch *gdbarch);
+extern void set_gdbarch_ps_regnum (struct gdbarch *gdbarch, int ps_regnum);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (PS_REGNUM)
+#error "Non multi-arch definition of PS_REGNUM"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (PS_REGNUM)
+#define PS_REGNUM (gdbarch_ps_regnum (current_gdbarch))
+#endif
+#endif
+
+/* Default (value) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (FP0_REGNUM)
 #define FP0_REGNUM (-1)
 #endif
@@ -1670,8 +1690,8 @@
 #define BREAKPOINT_FROM_PC(pcptr, lenptr) (legacy_breakpoint_from_pc (pcptr, lenptr))
 #endif
 
-typedef unsigned char * (gdbarch_breakpoint_from_pc_ftype) (CORE_ADDR *pcptr, int *lenptr);
-extern unsigned char * gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
+typedef const unsigned char * (gdbarch_breakpoint_from_pc_ftype) (CORE_ADDR *pcptr, int *lenptr);
+extern const unsigned char * gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
 extern void set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc);
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (BREAKPOINT_FROM_PC)
 #error "Non multi-arch definition of BREAKPOINT_FROM_PC"
@@ -2248,6 +2268,44 @@
 #endif
 #endif
 
+/* Sigtramp is a routine that the kernel calls (which then calls the
+   signal handler).  On most machines it is a library routine that is
+   linked into the executable.
+  
+   This macro, given a program counter value and the name of the
+   function in which that PC resides (which can be null if the name is
+   not known), returns nonzero if the PC and name show that we are in
+   sigtramp.
+  
+   On most machines just see if the name is sigtramp (and if we have
+   no name, assume we are not in sigtramp).
+  
+   FIXME: cagney/2002-04-21: The function find_pc_partial_function
+   calls find_pc_sect_partial_function() which calls PC_IN_SIGTRAMP.
+   This means PC_IN_SIGTRAMP function can't be implemented by doing its
+   own local NAME lookup.
+  
+   FIXME: cagney/2002-04-21: PC_IN_SIGTRAMP is something of a mess.
+   Some code also depends on SIGTRAMP_START and SIGTRAMP_END but other
+   does not. */
+
+/* Default (function) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (PC_IN_SIGTRAMP)
+#define PC_IN_SIGTRAMP(pc, name) (legacy_pc_in_sigtramp (pc, name))
+#endif
+
+typedef int (gdbarch_pc_in_sigtramp_ftype) (CORE_ADDR pc, char *name);
+extern int gdbarch_pc_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
+extern void set_gdbarch_pc_in_sigtramp (struct gdbarch *gdbarch, gdbarch_pc_in_sigtramp_ftype *pc_in_sigtramp);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (PC_IN_SIGTRAMP)
+#error "Non multi-arch definition of PC_IN_SIGTRAMP"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (PC_IN_SIGTRAMP)
+#define PC_IN_SIGTRAMP(pc, name) (gdbarch_pc_in_sigtramp (current_gdbarch, pc, name))
+#endif
+#endif
+
 /* A target might have problems with watchpoints as soon as the stack
    frame of the current function has been destroyed.  This mostly happens
    as the first action in a funtion's epilogue.  in_function_epilogue_p()
@@ -2386,9 +2444,16 @@
    architecture; ARCHES which is a list of the previously created
    ``struct gdbarch'' for this architecture.
 
-   The INIT function parameter INFO shall, as far as possible, be
-   pre-initialized with information obtained from INFO.ABFD or
-   previously selected architecture (if similar).
+   The INFO parameter is, as far as possible, be pre-initialized with
+   information obtained from INFO.ABFD or the previously selected
+   architecture.
+
+   The ARCHES parameter is a linked list (sorted most recently used)
+   of all the previously created architures for this architecture
+   family.  The (possibly NULL) ARCHES->gdbarch can used to access
+   values from the previously selected architecture for this
+   architecture family.  The global ``current_gdbarch'' shall not be
+   used.
 
    The INIT function shall return any of: NULL - indicating that it
    doesn't recognize the selected architecture; an existing ``struct
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 310d3c4..1dd2990 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -19,6 +19,12 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+# Make certain that the script is running in an internationalized
+# environment.
+LANG=c ; export LANG
+LC_ALL=c ; export LC_ALL
+
+
 compare_new ()
 {
     file=$1
@@ -415,7 +421,6 @@
 f::TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid::0:generic_target_read_pc::0
 f::TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid::0:generic_target_write_pc::0
 f::TARGET_READ_FP:CORE_ADDR:read_fp:void:::0:generic_target_read_fp::0
-f::TARGET_WRITE_FP:void:write_fp:CORE_ADDR val:val::0:generic_target_write_fp::0
 f::TARGET_READ_SP:CORE_ADDR:read_sp:void:::0:generic_target_read_sp::0
 f::TARGET_WRITE_SP:void:write_sp:CORE_ADDR val:val::0:generic_target_write_sp::0
 # Function for getting target's idea of a frame pointer.  FIXME: GDB's
@@ -432,9 +437,14 @@
 # These pseudo-registers may be aliases for other registers,
 # combinations of other registers, or they may be computed by GDB.
 v:2:NUM_PSEUDO_REGS:int:num_pseudo_regs::::0:0::0:::
-v:2:SP_REGNUM:int:sp_regnum::::0:-1
-v:2:FP_REGNUM:int:fp_regnum::::0:-1
-v:2:PC_REGNUM:int:pc_regnum::::0:-1
+
+# GDB's standard (or well known) register numbers.  These can map onto
+# a real register or a pseudo (computed) register or not be defined at
+# all (-1).
+v:2:SP_REGNUM:int:sp_regnum::::-1:-1::0
+v:2:FP_REGNUM:int:fp_regnum::::-1:-1::0
+v:2:PC_REGNUM:int:pc_regnum::::-1:-1::0
+v:2:PS_REGNUM:int:ps_regnum::::-1:-1::0
 v:2:FP0_REGNUM:int:fp0_regnum::::0:-1::0
 v:2:NPC_REGNUM:int:npc_regnum::::0:-1::0
 v:2:NNPC_REGNUM:int:nnpc_regnum::::0:-1::0
@@ -535,7 +545,7 @@
 f:2:SKIP_PROLOGUE:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip::0:0
 f:2:PROLOGUE_FRAMELESS_P:int:prologue_frameless_p:CORE_ADDR ip:ip::0:generic_prologue_frameless_p::0
 f:2:INNER_THAN:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs::0:0
-f:2:BREAKPOINT_FROM_PC:unsigned char *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr:::legacy_breakpoint_from_pc::0
+f:2:BREAKPOINT_FROM_PC:const unsigned char *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr:::legacy_breakpoint_from_pc::0
 f:2:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_insert_breakpoint::0
 f:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_remove_breakpoint::0
 v:2:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:-1
@@ -599,6 +609,27 @@
 # trampoline code in the ".plt" section.  IN_SOLIB_CALL_TRAMPOLINE evaluates
 # to nonzero if we are current stopped in one of these.
 f:2:IN_SOLIB_CALL_TRAMPOLINE:int:in_solib_call_trampoline:CORE_ADDR pc, char *name:pc, name:::generic_in_solib_call_trampoline::0
+# Sigtramp is a routine that the kernel calls (which then calls the
+# signal handler).  On most machines it is a library routine that is
+# linked into the executable.
+#
+# This macro, given a program counter value and the name of the
+# function in which that PC resides (which can be null if the name is
+# not known), returns nonzero if the PC and name show that we are in
+# sigtramp.
+#
+# On most machines just see if the name is sigtramp (and if we have
+# no name, assume we are not in sigtramp).
+#
+# FIXME: cagney/2002-04-21: The function find_pc_partial_function
+# calls find_pc_sect_partial_function() which calls PC_IN_SIGTRAMP.
+# This means PC_IN_SIGTRAMP function can't be implemented by doing its
+# own local NAME lookup.
+#
+# FIXME: cagney/2002-04-21: PC_IN_SIGTRAMP is something of a mess.
+# Some code also depends on SIGTRAMP_START and SIGTRAMP_END but other
+# does not.
+f:2:PC_IN_SIGTRAMP:int:pc_in_sigtramp:CORE_ADDR pc, char *name:pc, name:::legacy_pc_in_sigtramp::0
 # A target might have problems with watchpoints as soon as the stack
 # frame of the current function has been destroyed.  This mostly happens
 # as the first action in a funtion's epilogue.  in_function_epilogue_p()
@@ -722,7 +753,9 @@
 
 #include "dis-asm.h" /* Get defs for disassemble_info, which unfortunately is a typedef. */
 #if !GDB_MULTI_ARCH
+/* Pull in function declarations refered to, indirectly, via macros.  */
 #include "value.h" /* For default_coerce_float_to_double which is referenced by a macro.  */
+#include "inferior.h"		/* For unsigned_address_to_pointer().  */
 #endif
 
 struct frame_info;
@@ -944,9 +977,16 @@
    architecture; ARCHES which is a list of the previously created
    \`\`struct gdbarch'' for this architecture.
 
-   The INIT function parameter INFO shall, as far as possible, be
-   pre-initialized with information obtained from INFO.ABFD or
-   previously selected architecture (if similar).
+   The INFO parameter is, as far as possible, be pre-initialized with
+   information obtained from INFO.ABFD or the previously selected
+   architecture.
+
+   The ARCHES parameter is a linked list (sorted most recently used)
+   of all the previously created architures for this architecture
+   family.  The (possibly NULL) ARCHES->gdbarch can used to access
+   values from the previously selected architecture for this
+   architecture family.  The global \`\`current_gdbarch'' shall not be
+   used.
 
    The INIT function shall return any of: NULL - indicating that it
    doesn't recognize the selected architecture; an existing \`\`struct
@@ -1212,13 +1252,6 @@
 static void swapout_gdbarch_swap (struct gdbarch *);
 static void swapin_gdbarch_swap (struct gdbarch *);
 
-/* Convenience macro for allocting typesafe memory. */
-
-#ifndef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-#endif
-
-
 /* Non-zero if we want to trace architecture code.  */
 
 #ifndef GDBARCH_DEBUG
@@ -1340,6 +1373,7 @@
 initialize_non_multiarch ()
 {
   alloc_gdbarch_data (&startup_gdbarch);
+  init_gdbarch_swap (&startup_gdbarch);
   init_gdbarch_data (&startup_gdbarch);
 }
 EOF
@@ -1594,6 +1628,7 @@
 	printf "int\n"
 	printf "gdbarch_${function}_p (struct gdbarch *gdbarch)\n"
 	printf "{\n"
+        printf "  gdb_assert (gdbarch != NULL);\n"
 	if [ -n "${valid_p}" ]
 	then
 	    printf "  return ${valid_p};\n"
@@ -1613,6 +1648,7 @@
 	  printf "gdbarch_${function} (struct gdbarch *gdbarch, ${formal})\n"
 	fi
 	printf "{\n"
+        printf "  gdb_assert (gdbarch != NULL);\n"
         printf "  if (gdbarch->${function} == 0)\n"
         printf "    internal_error (__FILE__, __LINE__,\n"
 	printf "                    \"gdbarch: gdbarch_${function} invalid\");\n"
@@ -1654,6 +1690,7 @@
 	printf "${returntype}\n"
 	printf "gdbarch_${function} (struct gdbarch *gdbarch)\n"
 	printf "{\n"
+        printf "  gdb_assert (gdbarch != NULL);\n"
 	if [ "x${invalid_p}" = "x0" ]
 	then
 	    printf "  /* Skip verify of ${function}, invalid_p == 0 */\n"
@@ -1685,6 +1722,7 @@
 	printf "${returntype}\n"
 	printf "gdbarch_${function} (struct gdbarch *gdbarch)\n"
 	printf "{\n"
+        printf "  gdb_assert (gdbarch != NULL);\n"
 	printf "  if (gdbarch_debug >= 2)\n"
 	printf "    fprintf_unfiltered (gdb_stdlog, \"gdbarch_${function} called\\\\n\");\n"
 	printf "  return gdbarch->${function};\n"
@@ -2045,7 +2083,6 @@
 gdbarch_update_p (struct gdbarch_info info)
 {
   struct gdbarch *new_gdbarch;
-  struct gdbarch_list **list;
   struct gdbarch_registration *rego;
 
   /* Fill in missing parts of the INFO struct using a number of
@@ -2138,29 +2175,46 @@
   /* Swap all data belonging to the old target out */
   swapout_gdbarch_swap (current_gdbarch);
 
-  /* Is this a pre-existing architecture?  Yes. Swap it in.  */
-  for (list = &rego->arches;
-       (*list) != NULL;
-       list = &(*list)->next)
-    {
-      if ((*list)->gdbarch == new_gdbarch)
-	{
-	  if (gdbarch_debug)
-	    fprintf_unfiltered (gdb_stdlog,
-                                "gdbarch_update: Previous architecture 0x%08lx (%s) selected\\n",
-				(long) new_gdbarch,
-				new_gdbarch->bfd_arch_info->printable_name);
-	  current_gdbarch = new_gdbarch;
-	  swapin_gdbarch_swap (new_gdbarch);
-	  architecture_changed_event ();
-	  return 1;
-	}
-    }
+  /* Is this a pre-existing architecture?  Yes. Move it to the front
+     of the list of architectures (keeping the list sorted Most
+     Recently Used) and then copy it in.  */
+  {
+    struct gdbarch_list **list;
+    for (list = &rego->arches;
+	 (*list) != NULL;
+	 list = &(*list)->next)
+      {
+	if ((*list)->gdbarch == new_gdbarch)
+	  {
+	    struct gdbarch_list *this;
+	    if (gdbarch_debug)
+	      fprintf_unfiltered (gdb_stdlog,
+				  "gdbarch_update: Previous architecture 0x%08lx (%s) selected\n",
+				  (long) new_gdbarch,
+				  new_gdbarch->bfd_arch_info->printable_name);
+	    /* Unlink this.  */
+	    this = (*list);
+	    (*list) = this->next;
+	    /* Insert in the front.  */
+	    this->next = rego->arches;
+	    rego->arches = this;
+	    /* Copy the new architecture in.  */
+	    current_gdbarch = new_gdbarch;
+	    swapin_gdbarch_swap (new_gdbarch);
+	    architecture_changed_event ();
+	    return 1;
+	  }
+      }
+  }
 
-  /* Append this new architecture to this targets list. */
-  (*list) = XMALLOC (struct gdbarch_list);
-  (*list)->next = NULL;
-  (*list)->gdbarch = new_gdbarch;
+  /* Prepend this new architecture to the architecture list (keep the
+     list sorted Most Recently Used).  */
+  {
+    struct gdbarch_list *this = XMALLOC (struct gdbarch_list);
+    this->next = rego->arches;
+    this->gdbarch = new_gdbarch;
+    rego->arches = this;
+  }    
 
   /* Switch to this new architecture.  Dump it out. */
   current_gdbarch = new_gdbarch;
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 9ed226eb..2c8cd33 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -83,20 +83,22 @@
 # -I. for config files.
 # -I${srcdir} for our headers.
 # -I$(srcdir)/../regformats for regdef.h.
-INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../regformats
+INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../regformats -I$(INCLUDE_DIR)
 
 # M{H,T}_CFLAGS, if defined, has host- and target-dependent CFLAGS
 # from the config/ directory.
 GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS}
 #PROFILE_CFLAGS = -pg
 
+WARN_CFLAGS = -Wall
+
 # CFLAGS is specifically reserved for setting from the command line
 # when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
 CFLAGS = @CFLAGS@
 
 # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
-INTERNAL_CFLAGS = ${CFLAGS} ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} \
-	${INCLUDE_CFLAGS} ${BFD_CFLAGS}
+INTERNAL_CFLAGS =  $(WARN_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \
+	${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${BFD_CFLAGS}
 
 # LDFLAGS is specifically reserved for setting from the command line
 # when running make.
@@ -120,7 +122,10 @@
 SOURCES = $(SFILES)
 TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS} 
 
-OBS = utils.o $(DEPFILES) server.o remote-utils.o regcache.o
+OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
+	utils.o \
+	mem-break.o \
+	$(DEPFILES)
 
 # Prevent Sun make from putting in the machine type.  Setting
 # TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1.
@@ -195,8 +200,12 @@
 
 STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb
 
+config.h: stamp-h ; @true
+stamp-h: config.in config.status
+	CONFIG_FILES="" $(SHELL) ./config.status
+
 Makefile: Makefile.in config.status
-	$(SHELL) ./config.status
+	CONFIG_HEADERS="" $(SHELL) ./config.status
 
 config.status: configure configure.srv
 	$(SHELL) ./config.status --recheck
@@ -225,12 +234,19 @@
 regdat_sh = $(srcdir)/../regformats/regdat.sh
 regdef_h = $(srcdir)/../regformats/regdef.h
 regcache_h = $(srcdir)/regcache.h
-server_h = $(srcdir)/server.h $(regcache_h) config.h
+server_h = $(srcdir)/server.h $(regcache_h) config.h $(srcdir)/target.h \
+		$(srcdir)/mem-break.h
 
-server.o: server.c $(server_h)
-remote-utils.o: remote-utils.c terminal.h $(server_h)
-utils.o: utils.c $(server_h)
+inferiors.o: inferiors.c $(server_h)
+mem-break.o: mem-break.c $(server_h)
 regcache.o: regcache.c $(server_h) $(regdef_h)
+remote-utils.o: remote-utils.c terminal.h $(server_h)
+server.o: server.c $(server_h)
+target.o: target.c $(server_h)
+utils.o: utils.c $(server_h)
+
+signals.o: ../signals/signals.c $(server_h)
+	$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
 
 i387-fp.o: i387-fp.c $(server_h)
 
@@ -246,14 +262,6 @@
 linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
 linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h)
 
-# OBSOLETE TARGETS
-# OBSOLETE # low-lynx.o : ${srcdir}/low-lynx.c ${srcdir}/server.h
-# OBSOLETE # low-nbsd.o : ${srcdir}/low-nbsd.c ${srcdir}/server.h
-# OBSOLETE # low-sim.o : ${srcdir}/low-sim.c ${srcdir}/server.h
-# OBSOLETE # low-sparc.o : $(srcdir)/low-sparc.c $(srcdir)/server.h
-# OBSOLETE # low-sun3.o : $(srcdir)/low-sun3.c $(srcdir)/server.h
-# OBSOLETE # low-hppabsd.o : $(srcdir)/low-hppabsd.c $(srcdir)/server.h
-
 reg-arm.o : reg-arm.c $(regdef_h)
 reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
 	sh $(regdat_sh) $(srcdir)/../regformats/reg-arm.dat reg-arm.c
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index e77d5a7..9d553f2 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -16,6 +16,9 @@
 /* Define if you have the <sgtty.h> header file.  */
 #undef HAVE_SGTTY_H
 
+/* Define if you have the <string.h> header file.  */
+#undef HAVE_STRING_H
+
 /* Define if you have the <sys/reg.h> header file.  */
 #undef HAVE_SYS_REG_H
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index c08d5c2..758d483 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -1105,7 +1105,7 @@
 fi
 
 
-for ac_hdr in sgtty.h termio.h termios.h sys/reg.h
+for ac_hdr in sgtty.h termio.h termios.h sys/reg.h string.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -1593,6 +1593,10 @@
 
 EOF
 cat >> $CONFIG_STATUS <<\EOF
+case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
 
 exit 0
 EOF
diff --git a/gdb/gdbserver/configure.in b/gdb/gdbserver/configure.in
index 744aac2..db7e301 100644
--- a/gdb/gdbserver/configure.in
+++ b/gdb/gdbserver/configure.in
@@ -30,7 +30,7 @@
 
 AC_HEADER_STDC
 
-AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h)
+AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h)
 
 . ${srcdir}/configure.srv
 
@@ -66,4 +66,9 @@
 
 AC_SUBST(GDBSERVER_DEPFILES)
 
-AC_OUTPUT(Makefile)
+AC_OUTPUT(Makefile,
+[case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
+])
diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c
index ca10a06..65831b1 100644
--- a/gdb/gdbserver/gdbreplay.c
+++ b/gdb/gdbserver/gdbreplay.c
@@ -30,6 +30,12 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
 
 /* Sort of a hack... */
 #define EOL (EOF - 1)
@@ -83,8 +89,6 @@
 void
 remote_open (char *name)
 {
-  extern char *strchr ();
-
   if (!strchr (name, ':'))
     {
       fprintf (stderr, "%s: Must specify tcp connection as host:addr\n", name);
@@ -97,7 +101,6 @@
       int port;
       struct sockaddr_in sockaddr;
       int tmp;
-      struct protoent *protoent;
       int tmp_desc;
 
       port_str = strchr (name, ':');
@@ -126,10 +129,6 @@
       if (remote_desc == -1)
 	perror_with_name ("Accept failed");
 
-      protoent = getprotobyname ("tcp");
-      if (!protoent)
-	perror_with_name ("getprotobyname");
-
       /* Enable TCP keep alive process. */
       tmp = 1;
       setsockopt (tmp_desc, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp, sizeof (tmp));
@@ -137,7 +136,7 @@
       /* Tell TCP not to delay small packets.  This greatly speeds up
          interactive response. */
       tmp = 1;
-      setsockopt (remote_desc, protoent->p_proto, TCP_NODELAY,
+      setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY,
 		  (char *) &tmp, sizeof (tmp));
 
       close (tmp_desc);		/* No longer need this */
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
new file mode 100644
index 0000000..774798d
--- /dev/null
+++ b/gdb/gdbserver/inferiors.c
@@ -0,0 +1,105 @@
+/* Inferior process information for the remote server for GDB.
+   Copyright 2002
+   Free Software Foundation, Inc.
+
+   Contributed by MontaVista Software.
+
+   This file is part of GDB.
+
+   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 <stdlib.h>
+
+#include "server.h"
+
+struct inferior_info
+{
+  int pid;
+  void *target_data;
+  void *regcache_data;
+  struct inferior_info *next;
+};
+
+static struct inferior_info *inferiors;
+struct inferior_info *current_inferior;
+int signal_pid;
+
+void
+add_inferior (int pid)
+{
+  struct inferior_info *new_inferior
+    = (struct inferior_info *) malloc (sizeof (*new_inferior));
+
+  memset (new_inferior, 0, sizeof (*new_inferior));
+
+  new_inferior->pid = pid;
+
+  new_inferior->next = inferiors;
+  inferiors = new_inferior;
+
+  if (current_inferior == NULL)
+    current_inferior = inferiors;
+
+  create_register_cache (new_inferior);
+
+  if (signal_pid == 0)
+    signal_pid = pid;
+}
+
+void
+clear_inferiors (void)
+{
+  struct inferior_info *inf = inferiors, *next_inf;
+
+  while (inf)
+    {
+      next_inf = inf->next;
+
+      if (inf->target_data)
+	free (inf->target_data);
+      if (inf->regcache_data)
+	free_register_cache (inf);
+
+      free (inf);
+      inf = next_inf;
+    }
+
+  inferiors = NULL;
+}
+
+void *
+inferior_target_data (struct inferior_info *inferior)
+{
+  return inferior->target_data;
+}
+
+void
+set_inferior_target_data (struct inferior_info *inferior, void *data)
+{
+  inferior->target_data = data;
+}
+
+void *
+inferior_regcache_data (struct inferior_info *inferior)
+{
+  return inferior->regcache_data;
+}
+
+void
+set_inferior_regcache_data (struct inferior_info *inferior, void *data)
+{
+  inferior->regcache_data = data;
+}
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index f873b07..2958fdf 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -26,22 +26,28 @@
 #include <sys/reg.h>
 #endif
 
-int num_regs = 16;
+#define arm_num_regs 16
 
-int regmap[] = {
+static int arm_regmap[] = {
   0, 4, 8, 12, 16, 20, 24, 28,
   32, 36, 40, 44, 48, 52, 56, 60,
 };
 
-int
-cannot_store_register (int regno)
+static int
+arm_cannot_store_register (int regno)
 {
-  return (regno >= num_regs);
+  return (regno >= arm_num_regs);
 }
 
-int
-cannot_fetch_register (int regno)
+static int
+arm_cannot_fetch_register (int regno)
 {
-  return (regno >= num_regs);
+  return (regno >= arm_num_regs);
 }
 
+struct linux_target_ops the_low_target = {
+  arm_num_regs,
+  arm_regmap,
+  arm_cannot_fetch_register,
+  arm_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-i386-low.c b/gdb/gdbserver/linux-i386-low.c
index 2a66efa..7126432 100644
--- a/gdb/gdbserver/linux-i386-low.c
+++ b/gdb/gdbserver/linux-i386-low.c
@@ -29,13 +29,13 @@
 
 /* This module only supports access to the general purpose registers.  */
 
-int num_regs = 16;
+#define i386_num_regs 16
 
 /* This stuff comes from i386-linux-nat.c.  */
 
 /* Mapping between the general-purpose registers in `struct user'
    format and GDB's register array layout.  */
-int regmap[] = 
+static int i386_regmap[] = 
 {
   EAX * 4, ECX * 4, EDX * 4, EBX * 4,
   UESP * 4, EBP * 4, ESI * 4, EDI * 4,
@@ -43,16 +43,16 @@
   DS * 4, ES * 4, FS * 4, GS * 4
 };
 
-int
-cannot_store_register (int regno)
+static int
+i386_cannot_store_register (int regno)
 {
-  return (regno >= num_regs);
+  return (regno >= i386_num_regs);
 }
 
-int
-cannot_fetch_register (int regno)
+static int
+i386_cannot_fetch_register (int regno)
 {
-  return (regno >= num_regs);
+  return (regno >= i386_num_regs);
 }
 
 
@@ -65,8 +65,8 @@
 {
   int i;
 
-  for (i = 0; i < num_regs; i++)
-    collect_register (i, ((char *) buf) + regmap[i]);
+  for (i = 0; i < i386_num_regs; i++)
+    collect_register (i, ((char *) buf) + i386_regmap[i]);
 
   collect_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4);
 }
@@ -76,8 +76,8 @@
 {
   int i;
 
-  for (i = 0; i < num_regs; i++)
-    supply_register (i, ((char *) buf) + regmap[i]);
+  for (i = 0; i < i386_num_regs; i++)
+    supply_register (i, ((char *) buf) + i386_regmap[i]);
 
   supply_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4);
 }
@@ -121,3 +121,37 @@
 
 #endif /* HAVE_LINUX_REGSETS */
 
+static const char i386_breakpoint[] = { 0xCC };
+#define i386_breakpoint_len 1
+
+static CORE_ADDR
+i386_stop_pc ()
+{
+  unsigned long pc;
+
+  /* Overkill */
+  fetch_inferior_registers (0);
+
+  collect_register_by_name ("eip", &pc);
+  return pc - 1;
+}
+
+static void
+i386_set_pc (CORE_ADDR newpc)
+{
+  supply_register_by_name ("eip", &newpc);
+
+  /* Overkill */
+  store_inferior_registers (0);
+}
+
+struct linux_target_ops the_low_target = {
+  i386_num_regs,
+  i386_regmap,
+  i386_cannot_fetch_register,
+  i386_cannot_store_register,
+  i386_stop_pc,
+  i386_set_pc,
+  i386_breakpoint,
+  i386_breakpoint_len,
+};
diff --git a/gdb/gdbserver/linux-ia64-low.c b/gdb/gdbserver/linux-ia64-low.c
index f0f238f9..9407e6c 100644
--- a/gdb/gdbserver/linux-ia64-low.c
+++ b/gdb/gdbserver/linux-ia64-low.c
@@ -26,11 +26,11 @@
 #include <sys/reg.h>
 #endif
 
-int num_regs = 590;
+#define ia64_num_regs 590
 
 #include <asm/ptrace_offsets.h>
 
-int regmap[] =
+static int ia64_regmap[] =
   {
     /* general registers */
     -1,		/* gr0 not available; i.e, it's always zero */
@@ -283,15 +283,21 @@
     -1, -1, -1, -1, -1, -1, -1, -1,
   };
 
-int
-cannot_store_register (int regno)
+static int
+ia64_cannot_store_register (int regno)
 {
   return 0;
 }
 
-int
-cannot_fetch_register (int regno)
+static int
+ia64_cannot_fetch_register (int regno)
 {
   return 0;
 }
 
+struct linux_target_ops the_low_target = {
+  ia64_num_regs,
+  ia64_regmap,
+  ia64_cannot_fetch_register,
+  ia64_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 4e40d07..6cfe0d5 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -35,6 +35,10 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+static CORE_ADDR linux_bp_reinsert;
+
+static void linux_resume (int step, int signal);
+
 #define PTRACE_ARG3_TYPE long
 #define PTRACE_XFER_TYPE long
 
@@ -44,17 +48,20 @@
 
 extern int errno;
 
-#ifdef HAVE_LINUX_USRREGS
-extern int num_regs;
-extern int regmap[];
-#endif
+static int inferior_pid;
+
+struct inferior_linux_data
+{
+  int pid;
+};
 
 /* Start an inferior process and returns its pid.
    ALLARGS is a vector of program-name and args. */
 
-int
-create_inferior (char *program, char **allargs)
+static int
+linux_create_inferior (char *program, char **allargs)
 {
+  struct inferior_linux_data *tdata;
   int pid;
 
   pid = fork ();
@@ -73,14 +80,23 @@
       _exit (0177);
     }
 
-  return pid;
+  add_inferior (pid);
+  tdata = (struct inferior_linux_data *) malloc (sizeof (*tdata));
+  tdata->pid = pid;
+  set_inferior_target_data (current_inferior, tdata);
+
+  /* FIXME remove */
+  inferior_pid = pid;
+  return 0;
 }
 
 /* Attach to an inferior process.  */
 
-int
-myattach (int pid)
+static int
+linux_attach (int pid)
 {
+  struct inferior_linux_data *tdata;
+
   if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0)
     {
       fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid,
@@ -90,50 +106,113 @@
       _exit (0177);
     }
 
+  add_inferior (pid);
+  tdata = (struct inferior_linux_data *) malloc (sizeof (*tdata));
+  tdata->pid = pid;
+  set_inferior_target_data (current_inferior, tdata);
   return 0;
 }
 
 /* Kill the inferior process.  Make us have no inferior.  */
 
-void
-kill_inferior (void)
+static void
+linux_kill (void)
 {
   if (inferior_pid == 0)
     return;
   ptrace (PTRACE_KILL, inferior_pid, 0, 0);
   wait (0);
+  clear_inferiors ();
 }
 
 /* Return nonzero if the given thread is still alive.  */
-int
-mythread_alive (int pid)
+static int
+linux_thread_alive (int pid)
 {
   return 1;
 }
 
+static int
+linux_wait_for_one_inferior (struct inferior_info *child)
+{
+  struct inferior_linux_data *child_data = inferior_target_data (child);
+  int pid, wstat;
+
+  while (1)
+    {
+      pid = waitpid (child_data->pid, &wstat, 0);
+
+      if (pid != child_data->pid)
+	perror_with_name ("wait");
+
+      /* If this target supports breakpoints, see if we hit one.  */
+      if (the_low_target.stop_pc != NULL
+	  && WIFSTOPPED (wstat)
+	  && WSTOPSIG (wstat) == SIGTRAP)
+	{
+	  CORE_ADDR stop_pc;
+
+	  if (linux_bp_reinsert != 0)
+	    {
+	      reinsert_breakpoint (linux_bp_reinsert);
+	      linux_bp_reinsert = 0;
+	      linux_resume (0, 0);
+	      continue;
+	    }
+
+	  fetch_inferior_registers (0);
+	  stop_pc = (*the_low_target.stop_pc) ();
+
+	  if (check_breakpoints (stop_pc) != 0)
+	    {
+	      if (the_low_target.set_pc != NULL)
+		(*the_low_target.set_pc) (stop_pc);
+
+	      if (the_low_target.breakpoint_reinsert_addr == NULL)
+		{
+		  linux_bp_reinsert = stop_pc;
+		  uninsert_breakpoint (stop_pc);
+		  linux_resume (1, 0);
+		}
+	      else
+		{
+		  reinsert_breakpoint_by_bp
+		    (stop_pc, (*the_low_target.breakpoint_reinsert_addr) ());
+		  linux_resume (0, 0);
+		}
+
+	      continue;
+	    }
+	}
+
+      return wstat;
+    }
+  /* NOTREACHED */
+  return 0;
+}
+
 /* Wait for process, returns status */
 
-unsigned char
-mywait (char *status)
+static unsigned char
+linux_wait (char *status)
 {
-  int pid;
   int w;
 
   enable_async_io ();
-  pid = waitpid (inferior_pid, &w, 0);
+  w = linux_wait_for_one_inferior (current_inferior);
   disable_async_io ();
-  if (pid != inferior_pid)
-    perror_with_name ("wait");
 
   if (WIFEXITED (w))
     {
       fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
       *status = 'W';
+      clear_inferiors ();
       return ((unsigned char) WEXITSTATUS (w));
     }
   else if (!WIFSTOPPED (w))
     {
       fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
+      clear_inferiors ();
       *status = 'X';
       return ((unsigned char) WTERMSIG (w));
     }
@@ -148,8 +227,8 @@
    If STEP is nonzero, single-step it.
    If SIGNAL is nonzero, give it that signal.  */
 
-void
-myresume (int step, int signal)
+static void
+linux_resume (int step, int signal)
 {
   errno = 0;
   ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, inferior_pid, 1, signal);
@@ -167,10 +246,10 @@
 {
   int addr;
 
-  if (regnum < 0 || regnum >= num_regs)
+  if (regnum < 0 || regnum >= the_low_target.num_regs)
     error ("Invalid register number %d.", regnum);
 
-  addr = regmap[regnum];
+  addr = the_low_target.regmap[regnum];
   if (addr == -1)
     addr = 0;
 
@@ -184,9 +263,9 @@
   CORE_ADDR regaddr;
   register int i;
 
-  if (regno >= num_regs)
+  if (regno >= the_low_target.num_regs)
     return;
-  if (cannot_fetch_register (regno))
+  if ((*the_low_target.cannot_fetch_register) (regno))
     return;
 
   regaddr = register_addr (regno);
@@ -217,7 +296,7 @@
 usr_fetch_inferior_registers (int regno)
 {
   if (regno == -1 || regno == 0)
-    for (regno = 0; regno < num_regs; regno++)
+    for (regno = 0; regno < the_low_target.num_regs; regno++)
       fetch_register (regno);
   else
     fetch_register (regno);
@@ -234,10 +313,10 @@
 
   if (regno >= 0)
     {
-      if (regno >= num_regs)
+      if (regno >= the_low_target.num_regs)
 	return;
 
-      if (cannot_store_register (regno))
+      if ((*the_low_target.cannot_store_register) (regno) == 1)
 	return;
 
       regaddr = register_addr (regno);
@@ -251,20 +330,21 @@
 		  *(int *) (register_data (regno) + i));
 	  if (errno != 0)
 	    {
-	      /* Warning, not error, in case we are attached; sometimes the
-		 kernel doesn't let us at the registers.  */
-	      char *err = strerror (errno);
-	      char *msg = alloca (strlen (err) + 128);
-	      sprintf (msg, "writing register %d: %s",
-		       regno, err);
-	      error (msg);
-	      return;
+	      if ((*the_low_target.cannot_store_register) (regno) == 0)
+		{
+		  char *err = strerror (errno);
+		  char *msg = alloca (strlen (err) + 128);
+		  sprintf (msg, "writing register %d: %s",
+			   regno, err);
+		  error (msg);
+		  return;
+		}
 	    }
 	  regaddr += sizeof (int);
 	}
     }
   else
-    for (regno = 0; regno < num_regs; regno++)
+    for (regno = 0; regno < the_low_target.num_regs; regno++)
       store_inferior_registers (regno);
 }
 #endif /* HAVE_LINUX_USRREGS */
@@ -292,7 +372,7 @@
 	}
 
       buf = malloc (regset->size);
-      res = ptrace (regset->get_request, inferior_pid, 0, (int) buf);
+      res = ptrace (regset->get_request, inferior_pid, 0, buf);
       if (res < 0)
 	{
 	  if (errno == EIO)
@@ -318,6 +398,7 @@
       regset->store_function (buf);
       regset ++;
     }
+  return 0;
 }
 
 static int
@@ -340,7 +421,7 @@
 
       buf = malloc (regset->size);
       regset->fill_function (buf);
-      res = ptrace (regset->set_request, inferior_pid, 0, (int) buf);
+      res = ptrace (regset->set_request, inferior_pid, 0, buf);
       if (res < 0)
 	{
 	  if (errno == EIO)
@@ -360,18 +441,19 @@
 	    }
 	  else
 	    {
-	      perror ("Warning: ptrace(regsets_fetch_inferior_registers)");
+	      perror ("Warning: ptrace(regsets_store_inferior_registers)");
 	    }
 	}
       regset ++;
     }
+  return 0;
 }
 
 #endif /* HAVE_LINUX_REGSETS */
 
 
 void
-fetch_inferior_registers (int regno)
+linux_fetch_registers (int regno)
 {
 #ifdef HAVE_LINUX_REGSETS
   if (use_regsets_p)
@@ -386,7 +468,7 @@
 }
 
 void
-store_inferior_registers (int regno)
+linux_store_registers (int regno)
 {
 #ifdef HAVE_LINUX_REGSETS
   if (use_regsets_p)
@@ -404,8 +486,8 @@
 /* Copy LEN bytes from inferior's memory starting at MEMADDR
    to debugger memory starting at MYADDR.  */
 
-void
-read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
+static void
+linux_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
 {
   register int i;
   /* Round starting address down to longword boundary.  */
@@ -433,8 +515,8 @@
    On failure (cannot write the inferior)
    returns the value of errno.  */
 
-int
-write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
+static int
+linux_write_memory (CORE_ADDR memaddr, const char *myaddr, int len)
 {
   register int i;
   /* Round starting address down to longword boundary.  */
@@ -476,9 +558,33 @@
 
   return 0;
 }
+
+static void
+linux_look_up_symbols (void)
+{
+  /* Don't need to look up any symbols yet.  */
+}
+
 
+static struct target_ops linux_target_ops = {
+  linux_create_inferior,
+  linux_attach,
+  linux_kill,
+  linux_thread_alive,
+  linux_resume,
+  linux_wait,
+  linux_fetch_registers,
+  linux_store_registers,
+  linux_read_memory,
+  linux_write_memory,
+  linux_look_up_symbols,
+};
+
 void
 initialize_low (void)
 {
+  set_target_ops (&linux_target_ops);
+  set_breakpoint_data (the_low_target.breakpoint,
+		       the_low_target.breakpoint_len);
   init_registers ();
 }
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index 421fa22..b484982 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -18,13 +18,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifdef HAVE_LINUX_USR_REGISTERS
-extern int regmap[];
-extern int num_regs;
-int cannot_fetch_register (int regno);
-int cannot_store_register (int regno);
-#endif
-
 #ifdef HAVE_LINUX_REGSETS
 typedef void (*regset_func) (void *);
 struct regset_info
@@ -35,3 +28,22 @@
 };
 extern struct regset_info target_regsets[];
 #endif
+
+struct linux_target_ops
+{
+  int num_regs;
+  int *regmap;
+  int (*cannot_fetch_register) (int);
+
+  /* Returns 0 if we can store the register, 1 if we can not
+     store the register, and 2 if failure to store the register
+     is acceptable.  */
+  int (*cannot_store_register) (int);
+  CORE_ADDR (*stop_pc) (void);
+  void (*set_pc) (CORE_ADDR newpc);
+  const char *breakpoint;
+  int breakpoint_len;
+  CORE_ADDR (*breakpoint_reinsert_addr) (void);
+};
+
+extern struct linux_target_ops the_low_target;
diff --git a/gdb/gdbserver/linux-m68k-low.c b/gdb/gdbserver/linux-m68k-low.c
index 9e59fbd..760de6e 100644
--- a/gdb/gdbserver/linux-m68k-low.c
+++ b/gdb/gdbserver/linux-m68k-low.c
@@ -26,10 +26,10 @@
 #include <sys/reg.h>
 #endif
 
-int num_regs = 31;
+#define m68k_num_regs 31
 
 /* This table must line up with REGISTER_NAMES in tm-m68k.h */
-int regmap[] =
+static int m68k_regmap[] =
 {
 #ifdef PT_D0
   PT_D0 * 4, PT_D1 * 4, PT_D2 * 4, PT_D3 * 4,
@@ -52,14 +52,21 @@
 #endif
 };
 
-int
-cannot_store_register (int regno)
+static int
+m68k_cannot_store_register (int regno)
 {
-  return (regno >= num_regs);
+  return (regno >= m68k_num_regs);
 }
 
-int
-cannot_fetch_register (int regno)
+static int
+m68k_cannot_fetch_register (int regno)
 {
-  return (regno >= num_regs);
+  return (regno >= m68k_num_regs);
 }
+
+struct linux_target_ops the_low_target = {
+  m68k_num_regs,
+  m68k_regmap,
+  m68k_cannot_fetch_register,
+  m68k_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c
index a9114d3..f721ec9 100644
--- a/gdb/gdbserver/linux-mips-low.c
+++ b/gdb/gdbserver/linux-mips-low.c
@@ -26,14 +26,14 @@
 #include <sys/reg.h>
 #endif
 
-int num_regs = 90;
+#define mips_num_regs 90
 
 #include <asm/ptrace.h>
 
 /* Return the ptrace ``address'' of register REGNO. */
 
 /* Matches mips_generic32_regs */
-int regmap[] = {
+static int mips_regmap[] = {
   0,  1,  2,  3,  4,  5,  6,  7,
   8,  9,  10, 11, 12, 13, 14, 15,
   16, 17, 18, 19, 20, 21, 22, 23,
@@ -63,10 +63,10 @@
    ZERO_REGNUM.  We also can not set BADVADDR, CAUSE, or FCRIR via
    ptrace().  */
 
-int
-cannot_fetch_register (int regno)
+static int
+mips_cannot_fetch_register (int regno)
 {
-  if (regmap[regno] == -1)
+  if (mips_regmap[regno] == -1)
     return 1;
 
   if (find_regno ("zero") == regno)
@@ -75,10 +75,10 @@
   return 0;
 }
 
-int
-cannot_store_register (int regno)
+static int
+mips_cannot_store_register (int regno)
 {
-  if (regmap[regno] == -1)
+  if (mips_regmap[regno] == -1)
     return 1;
 
   if (find_regno ("zero") == regno)
@@ -95,3 +95,10 @@
 
   return 0;
 }
+
+struct linux_target_ops the_low_target = {
+  mips_num_regs,
+  mips_regmap,
+  mips_cannot_fetch_register,
+  mips_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c
index dcefa59..7cb315a 100644
--- a/gdb/gdbserver/linux-ppc-low.c
+++ b/gdb/gdbserver/linux-ppc-low.c
@@ -25,10 +25,10 @@
 
 #include <asm/ptrace.h>
 
-int num_regs = 71;
+#define ppc_num_regs 71
 
 /* Currently, don't check/send MQ.  */
-int regmap[] =
+static int ppc_regmap[] =
  {PT_R0 * 4,     PT_R1 * 4,     PT_R2 * 4,     PT_R3 * 4,
   PT_R4 * 4,     PT_R5 * 4,     PT_R6 * 4,     PT_R7 * 4,
   PT_R8 * 4,     PT_R9 * 4,     PT_R10 * 4,    PT_R11 * 4,
@@ -46,17 +46,27 @@
   PT_FPR0*4+192,  PT_FPR0*4+200,  PT_FPR0*4+208,  PT_FPR0*4+216,
   PT_FPR0*4+224,  PT_FPR0*4+232,  PT_FPR0*4+240,  PT_FPR0*4+248,
   PT_NIP * 4,    PT_MSR * 4,    PT_CCR * 4,    PT_LNK * 4,
-  PT_CTR * 4,    PT_XER * 4,    -1, };
+  PT_CTR * 4,    PT_XER * 4,    PT_FPSCR * 4, };
 
-int
-cannot_store_register (int regno)
+static int
+ppc_cannot_store_register (int regno)
+{
+  /* Some kernels do not allow us to store fpscr.  */
+  if (regno == find_regno ("fpscr"))
+    return 2;
+
+  return 0;
+}
+
+static int
+ppc_cannot_fetch_register (int regno)
 {
   return 0;
 }
 
-int
-cannot_fetch_register (int regno)
-{
-  return 0;
-}
-
+struct linux_target_ops the_low_target = {
+  ppc_num_regs,
+  ppc_regmap,
+  ppc_cannot_fetch_register,
+  ppc_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c
index 1920b9c..8d800ae 100644
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -27,9 +27,9 @@
 
 #include <asm/ptrace.h>
 
-int num_regs = 67;
+#define s390_num_regs 67
 
-int regmap[] = {
+static int s390_regmap[] = {
   PT_PSWMASK, PT_PSWADDR,
 
   PT_GPR0, PT_GPR1, PT_GPR2, PT_GPR3,
@@ -62,20 +62,27 @@
 #endif
 };
 
-int
-cannot_fetch_register (int regno)
+static int
+s390_cannot_fetch_register (int regno)
 {
-  if (regmap[regno] == -1)
+  if (s390_regmap[regno] == -1)
     return 1;
 
   return 0;
 }
 
-int
-cannot_store_register (int regno)
+static int
+s390_cannot_store_register (int regno)
 {
-  if (regmap[regno] == -1)
+  if (s390_regmap[regno] == -1)
     return 1;
 
   return 0;
 }
+
+struct linux_target_ops the_low_target = {
+  s390_num_regs,
+  s390_regmap,
+  s390_cannot_fetch_register,
+  s390_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-sh-low.c b/gdb/gdbserver/linux-sh-low.c
index f763339..cdc390d 100644
--- a/gdb/gdbserver/linux-sh-low.c
+++ b/gdb/gdbserver/linux-sh-low.c
@@ -28,10 +28,10 @@
 
 #include <asm/ptrace.h>
 
-int num_regs = 41;
+#define sh_num_regs 41
 
 /* Currently, don't check/send MQ.  */
-int regmap[] = {
+static int sh_regmap[] = {
  0,	4,	8,	12,	16,	20,	24,	28,
  32,	36,	40,	44,	48,	52,	56,	60,
 
@@ -45,15 +45,21 @@
  REG_FPREG0+48,  REG_FPREG0+52,  REG_FPREG0+56,  REG_FPREG0+60,
 };
 
-int
-cannot_store_register (int regno)
+static int
+sh_cannot_store_register (int regno)
 {
   return 0;
 }
 
-int
-cannot_fetch_register (int regno)
+static int
+sh_cannot_fetch_register (int regno)
 {
   return 0;
 }
 
+struct linux_target_ops the_low_target = {
+  sh_num_regs,
+  sh_regmap,
+  sh_cannot_fetch_register,
+  sh_cannot_store_register,
+};
diff --git a/gdb/gdbserver/linux-x86-64-low.c b/gdb/gdbserver/linux-x86-64-low.c
index ffb0ce7..e124890 100644
--- a/gdb/gdbserver/linux-x86-64-low.c
+++ b/gdb/gdbserver/linux-x86-64-low.c
@@ -28,12 +28,15 @@
 #include <sys/procfs.h>
 #include <sys/ptrace.h>
 
-static int regmap[] = {
-  RAX, RDX, RCX, RBX,
+#define	X86_64_NUM_GREGS 22
+
+static int x86_64_regmap[X86_64_NUM_GREGS] = {
+  RAX, RBX, RCX, RDX,
   RSI, RDI, RBP, RSP,
   R8, R9, R10, R11,
   R12, R13, R14, R15,
-  RIP, EFLAGS
+  RIP, EFLAGS,
+  DS, ES, FS, GS
 };
 
 static void
@@ -41,8 +44,8 @@
 {
   int i;
 
-  for (i = 0; i < 18; i++)
-    collect_register (i, ((char *) buf) + regmap[i]);
+  for (i = 0; i < X86_64_NUM_GREGS; i++)
+    collect_register (i, ((char *) buf) + x86_64_regmap[i]);
 }
 
 static void
@@ -50,8 +53,8 @@
 {
   int i;
 
-  for (i = 0; i < 18; i++)
-    supply_register (i, ((char *) buf) + regmap[i]);
+  for (i = 0; i < X86_64_NUM_GREGS; i++)
+    supply_register (i, ((char *) buf) + x86_64_regmap[i]);
 }
 
 static void
@@ -66,7 +69,6 @@
   i387_fxsave_to_cache (buf);
 }
 
-
 struct regset_info target_regsets[] = {
   { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t),
     x86_64_fill_gregset, x86_64_store_gregset },
@@ -74,3 +76,10 @@
     x86_64_fill_fpregset, x86_64_store_fpregset },
   { 0, 0, -1, NULL, NULL }
 };
+
+struct linux_target_ops the_low_target = {
+  -1,
+  NULL,
+  NULL,
+  NULL,
+};
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
new file mode 100644
index 0000000..91addf6
--- /dev/null
+++ b/gdb/gdbserver/mem-break.c
@@ -0,0 +1,280 @@
+/* Memory breakpoint operations for the remote server for GDB.
+   Copyright 2002
+   Free Software Foundation, Inc.
+
+   Contributed by MontaVista Software.
+
+   This file is part of GDB.
+
+   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 "server.h"
+
+const char *breakpoint_data;
+int breakpoint_len;
+
+#define MAX_BREAKPOINT_LEN 8
+
+struct breakpoint
+{
+  struct breakpoint *next;
+  CORE_ADDR pc;
+  unsigned char old_data[MAX_BREAKPOINT_LEN];
+
+  /* Non-zero iff we are stepping over this breakpoint.  */
+  int reinserting;
+
+  /* Non-NULL iff this breakpoint was inserted to step over
+     another one.  Points to the other breakpoint (which is also
+     in the *next chain somewhere).  */
+  struct breakpoint *breakpoint_to_reinsert;
+
+  /* Function to call when we hit this breakpoint.  */
+  void (*handler) (CORE_ADDR);
+};
+
+struct breakpoint *breakpoints;
+
+void
+set_breakpoint_at (CORE_ADDR where, void (*handler) (CORE_ADDR))
+{
+  struct breakpoint *bp;
+
+  if (breakpoint_data == NULL)
+    error ("Target does not support breakpoints.");
+
+  bp = malloc (sizeof (struct breakpoint));
+  memset (bp, 0, sizeof (struct breakpoint));
+
+  (*the_target->read_memory) (where, bp->old_data,
+			      breakpoint_len);
+  (*the_target->write_memory) (where, breakpoint_data,
+			       breakpoint_len);
+
+  bp->pc = where;
+  bp->handler = handler;
+
+  bp->next = breakpoints;
+  breakpoints = bp;
+}
+
+static void
+delete_breakpoint (struct breakpoint *bp)
+{
+  struct breakpoint *cur;
+
+  if (breakpoints == bp)
+    {
+      breakpoints = bp->next;
+      (*the_target->write_memory) (bp->pc, bp->old_data,
+				   breakpoint_len);
+      free (bp);
+      return;
+    }
+  cur = breakpoints;
+  while (cur->next)
+    {
+      if (cur->next == bp)
+	{
+	  cur->next = bp->next;
+	  (*the_target->write_memory) (bp->pc, bp->old_data,
+				       breakpoint_len);
+	  free (bp);
+	  return;
+	}
+    }
+  warning ("Could not find breakpoint in list.");
+}
+
+static struct breakpoint *
+find_breakpoint_at (CORE_ADDR where)
+{
+  struct breakpoint *bp = breakpoints;
+
+  while (bp != NULL)
+    {
+      if (bp->pc == where)
+	return bp;
+      bp = bp->next;
+    }
+
+  return NULL;
+}
+
+static void
+reinsert_breakpoint_handler (CORE_ADDR stop_pc)
+{
+  struct breakpoint *stop_bp, *orig_bp;
+
+  stop_bp = find_breakpoint_at (stop_pc);
+  if (stop_bp == NULL)
+    error ("lost the stopping breakpoint.");
+
+  orig_bp = stop_bp->breakpoint_to_reinsert;
+  if (orig_bp == NULL)
+    error ("no breakpoint to reinsert");
+
+  (*the_target->write_memory) (orig_bp->pc, breakpoint_data,
+			       breakpoint_len);
+  orig_bp->reinserting = 0;
+  delete_breakpoint (stop_bp);
+}
+
+void
+reinsert_breakpoint_by_bp (CORE_ADDR stop_pc, CORE_ADDR stop_at)
+{
+  struct breakpoint *bp, *orig_bp;
+
+  set_breakpoint_at (stop_at, reinsert_breakpoint_handler);
+
+  orig_bp = find_breakpoint_at (stop_at);
+  if (orig_bp == NULL)
+    error ("Could not find original breakpoint in list.");
+
+  bp = find_breakpoint_at (stop_at);
+  if (bp == NULL)
+    error ("Could not find breakpoint in list (reinserting by breakpoint).");
+  bp->breakpoint_to_reinsert = orig_bp;
+
+  (*the_target->write_memory) (orig_bp->pc, orig_bp->old_data,
+			       breakpoint_len);
+  orig_bp->reinserting = 1;
+}
+
+void
+uninsert_breakpoint (CORE_ADDR stopped_at)
+{
+  struct breakpoint *bp;
+
+  bp = find_breakpoint_at (stopped_at);
+  if (bp == NULL)
+    error ("Could not find breakpoint in list (uninserting).");
+
+  (*the_target->write_memory) (bp->pc, bp->old_data,
+			       breakpoint_len);
+  bp->reinserting = 1;
+}
+
+void
+reinsert_breakpoint (CORE_ADDR stopped_at)
+{
+  struct breakpoint *bp;
+
+  bp = find_breakpoint_at (stopped_at);
+  if (bp == NULL)
+    error ("Could not find breakpoint in list (uninserting).");
+  if (! bp->reinserting)
+    error ("Breakpoint already inserted at reinsert time.");
+
+  (*the_target->write_memory) (bp->pc, breakpoint_data,
+			       breakpoint_len);
+  bp->reinserting = 0;
+}
+
+int
+check_breakpoints (CORE_ADDR stop_pc)
+{
+  struct breakpoint *bp;
+
+  bp = find_breakpoint_at (stop_pc);
+  if (bp == NULL)
+    return 0;
+  if (bp->reinserting)
+    {
+      warning ("Hit a removed breakpoint?");
+      return 0;
+    }
+
+  (*bp->handler) (bp->pc);
+  return 1;
+}
+
+void
+set_breakpoint_data (const char *bp_data, int bp_len)
+{
+  breakpoint_data = bp_data;
+  breakpoint_len = bp_len;
+}
+
+void
+check_mem_read (CORE_ADDR mem_addr, char *buf, int mem_len)
+{
+  struct breakpoint *bp = breakpoints;
+  CORE_ADDR mem_end = mem_addr + mem_len;
+
+  for (; bp != NULL; bp = bp->next)
+    {
+      CORE_ADDR bp_end = bp->pc + breakpoint_len;
+      CORE_ADDR start, end;
+      int copy_offset, copy_len, buf_offset;
+
+      if (mem_addr >= bp_end)
+	continue;
+      if (bp->pc >= mem_end)
+	continue;
+
+      start = bp->pc;
+      if (mem_addr > start)
+	start = mem_addr;
+
+      end = bp_end;
+      if (end > mem_end)
+	end = mem_end;
+
+      copy_len = end - start;
+      copy_offset = start - bp->pc;
+      buf_offset = start - mem_addr;
+
+      memcpy (buf + buf_offset, bp->old_data + copy_offset, copy_len);
+    }
+}
+
+void
+check_mem_write (CORE_ADDR mem_addr, char *buf, int mem_len)
+{
+  struct breakpoint *bp = breakpoints;
+  CORE_ADDR mem_end = mem_addr + mem_len;
+
+  for (; bp != NULL; bp = bp->next)
+    {
+      CORE_ADDR bp_end = bp->pc + breakpoint_len;
+      CORE_ADDR start, end;
+      int copy_offset, copy_len, buf_offset;
+
+      if (mem_addr >= bp_end)
+	continue;
+      if (bp->pc >= mem_end)
+	continue;
+
+      start = bp->pc;
+      if (mem_addr > start)
+	start = mem_addr;
+
+      end = bp_end;
+      if (end > mem_end)
+	end = mem_end;
+
+      copy_len = end - start;
+      copy_offset = start - bp->pc;
+      buf_offset = start - mem_addr;
+
+      memcpy (bp->old_data + copy_offset, buf + buf_offset, copy_len);
+      if (bp->reinserting == 0)
+	memcpy (buf + buf_offset, breakpoint_data + copy_offset, copy_len);
+    }
+}
+
+
diff --git a/gdb/gdbserver/mem-break.h b/gdb/gdbserver/mem-break.h
new file mode 100644
index 0000000..356e763
--- /dev/null
+++ b/gdb/gdbserver/mem-break.h
@@ -0,0 +1,71 @@
+/* Memory breakpoint interfaces for the remote server for GDB.
+   Copyright 2002
+   Free Software Foundation, Inc.
+
+   Contributed by MontaVista Software.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef MEM_BREAK_H
+#define MEM_BREAK_H
+
+/* Breakpoints are opaque.  */
+
+/* Create a new breakpoint at WHERE, and call HANDLER when
+   it is hit.  */
+
+void set_breakpoint_at (CORE_ADDR where,
+			void (*handler) (CORE_ADDR));
+
+/* Create a reinsertion breakpoint at STOP_AT for the breakpoint
+   currently at STOP_PC (and temporarily remove the breakpoint at
+   STOP_PC).  */
+
+void reinsert_breakpoint_by_bp (CORE_ADDR stop_pc, CORE_ADDR stop_at);
+
+/* Change the status of the breakpoint at WHERE to inserted.  */
+
+void reinsert_breakpoint (CORE_ADDR where);
+
+/* Change the status of the breakpoint at WHERE to uninserted.  */
+
+void uninsert_breakpoint (CORE_ADDR where);
+
+/* See if any breakpoint claims ownership of STOP_PC.  Call the handler for
+   the breakpoint, if found.  */
+
+int check_breakpoints (CORE_ADDR stop_pc);
+
+/* See if any breakpoints shadow the target memory area from MEM_ADDR
+   to MEM_ADDR + MEM_LEN.  Update the data already read from the target
+   (in BUF) if necessary.  */
+
+void check_mem_read (CORE_ADDR mem_addr, char *buf, int mem_len);
+
+/* See if any breakpoints shadow the target memory area from MEM_ADDR
+   to MEM_ADDR + MEM_LEN.  Update the data to be written to the target
+   (in BUF) if necessary, as well as the original data for any breakpoints.  */
+
+void check_mem_write (CORE_ADDR mem_addr, char *buf, int mem_len);
+
+/* Set the byte pattern to insert for memory breakpoints.  This function
+   must be called before any breakpoints are set.  */
+
+void set_breakpoint_data (const char *bp_data, int bp_len);
+
+#endif /* MEM_BREAK_H */
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index bec20bb..701d092 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -25,7 +25,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-static char *registers;
+struct inferior_regcache_data
+{
+  char *registers;
+};
+
 static int register_bytes;
 
 static struct reg *reg_defs;
@@ -33,6 +37,19 @@
 
 const char **gdbserver_expedite_regs;
 
+static struct inferior_regcache_data *
+get_regcache (struct inferior_info *inf)
+{
+  struct inferior_regcache_data *regcache;
+
+  regcache = (struct inferior_regcache_data *) inferior_regcache_data (inf);
+
+  if (regcache == NULL)
+    fatal ("no register cache");
+
+  return regcache;
+}
+
 int
 registers_length (void)
 {
@@ -40,6 +57,28 @@
 }
 
 void
+create_register_cache (struct inferior_info *inferior)
+{
+  struct inferior_regcache_data *regcache;
+
+  regcache = malloc (sizeof (*regcache));
+
+  regcache->registers = malloc (register_bytes);
+  if (regcache->registers == NULL)
+    fatal ("Could not allocate register cache.");
+
+  set_inferior_regcache_data (inferior, regcache);
+}
+
+void
+free_register_cache (struct inferior_info *inferior)
+{
+  free (get_regcache (current_inferior)->registers);
+  free (get_regcache (current_inferior));
+  set_inferior_regcache_data (inferior, NULL);
+}
+
+void
 set_register_cache (struct reg *regs, int n)
 {
   int offset, i;
@@ -55,14 +94,13 @@
     }
 
   register_bytes = offset / 8;
-  registers = malloc (offset / 8);
-  if (!registers)
-    fatal ("Could not allocate register cache.");
 }
 
 void
 registers_to_string (char *buf)
 {
+  char *registers = get_regcache (current_inferior)->registers;
+
   convert_int_to_ascii (registers, buf, register_bytes);
 }
 
@@ -70,6 +108,7 @@
 registers_from_string (char *buf)
 {
   int len = strlen (buf);
+  char *registers = get_regcache (current_inferior)->registers;
 
   if (len != register_bytes * 2)
     {
@@ -119,29 +158,31 @@
 char *
 register_data (int n)
 {
+  char *registers = get_regcache (current_inferior)->registers;
+
   return registers + (reg_defs[n].offset / 8);
 }
 
 void
-supply_register (int n, const char *buf)
+supply_register (int n, const void *buf)
 {
   memcpy (register_data (n), buf, register_size (n));
 }
 
 void
-supply_register_by_name (const char *name, const char *buf)
+supply_register_by_name (const char *name, const void *buf)
 {
   supply_register (find_regno (name), buf);
 }
 
 void
-collect_register (int n, char *buf)
+collect_register (int n, void *buf)
 {
   memcpy (buf, register_data (n), register_size (n));
 }
 
 void
-collect_register_by_name (const char *name, char *buf)
+collect_register_by_name (const char *name, void *buf)
 {
   collect_register (find_regno (name), buf);
 }
diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h
index 07195b3..362288e 100644
--- a/gdb/gdbserver/regcache.h
+++ b/gdb/gdbserver/regcache.h
@@ -21,6 +21,16 @@
 #ifndef REGCACHE_H
 #define REGCACHE_H
 
+struct inferior_info;
+
+/* Create a new register cache for INFERIOR.  */
+
+void create_register_cache (struct inferior_info *inferior);
+
+/* Release all memory associated with the register cache for INFERIOR.  */
+
+void free_register_cache (struct inferior_info *inferior);
+
 /* Convert all registers to a string in the currently specified remote
    format.  */
 
@@ -46,4 +56,12 @@
 
 extern const char **gdbserver_expedite_regs;
 
+void supply_register (int n, const void *buf);
+
+void supply_register_by_name (const char *name, const void *buf);
+
+void collect_register (int n, void *buf);
+
+void collect_register_by_name (const char *name, void *buf);
+
 #endif /* REGCACHE_H */
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index ff1718f..14734f1 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -35,6 +35,7 @@
 #include <fcntl.h>
 #include <sys/time.h>
 #include <unistd.h>
+#include <arpa/inet.h>
 
 int remote_debug = 0;
 struct ui_file *gdb_stdlog;
@@ -48,7 +49,7 @@
 remote_open (char *name)
 {
   int save_fcntl_flags;
-
+  
   if (!strchr (name, ':'))
     {
       remote_desc = open (name, O_RDWR);
@@ -99,7 +100,7 @@
       }
 #endif
 
-
+      fprintf (stderr, "Remote debugging using %s\n", name);
     }
   else
     {
@@ -107,7 +108,6 @@
       int port;
       struct sockaddr_in sockaddr;
       int tmp;
-      struct protoent *protoent;
       int tmp_desc;
 
       port_str = strchr (name, ':');
@@ -136,10 +136,6 @@
       if (remote_desc == -1)
 	perror_with_name ("Accept failed");
 
-      protoent = getprotobyname ("tcp");
-      if (!protoent)
-	perror_with_name ("getprotobyname");
-
       /* Enable TCP keep alive process. */
       tmp = 1;
       setsockopt (tmp_desc, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp, sizeof (tmp));
@@ -147,13 +143,17 @@
       /* Tell TCP not to delay small packets.  This greatly speeds up
          interactive response. */
       tmp = 1;
-      setsockopt (remote_desc, protoent->p_proto, TCP_NODELAY,
+      setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY,
 		  (char *) &tmp, sizeof (tmp));
 
       close (tmp_desc);		/* No longer need this */
 
       signal (SIGPIPE, SIG_IGN);	/* If we don't do this, then gdbserver simply
 					   exits when the remote side dies.  */
+
+      /* Convert IP address to string.  */
+      fprintf (stderr, "Remote debugging from host %s\n", 
+         inet_ntoa (sockaddr.sin_addr));
     }
 
 #if defined(F_SETFL) && defined (FASYNC)
@@ -164,7 +164,6 @@
 #endif
 #endif
   disable_async_io ();
-  fprintf (stderr, "Remote debugging using %s\n", name);
 }
 
 void
@@ -187,6 +186,42 @@
   return 0;
 }
 
+int
+unhexify (char *bin, const char *hex, int count)
+{
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      if (hex[0] == 0 || hex[1] == 0)
+        {
+          /* Hex string is short, or of uneven length.
+             Return the count that has been converted so far. */
+          return i;
+        }
+      *bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]);
+      hex += 2;
+    }
+  return i;
+}
+
+static void
+decode_address (CORE_ADDR *addrp, const char *start, int len)
+{
+  CORE_ADDR addr;
+  char ch;
+  int i;
+
+  addr = 0;
+  for (i = 0; i < len; i++)
+    {
+      ch = start[i];
+      addr = addr << 4;
+      addr = addr | (fromhex (ch) & 0x0f);
+    }
+  *addrp = addr;
+}
+
 /* Convert number NIB to a hex digit.  */
 
 static int
@@ -198,6 +233,24 @@
     return 'a' + nib - 10;
 }
 
+int
+hexify (char *hex, const char *bin, int count)
+{
+  int i;
+
+  /* May use a length, or a nul-terminated string as input. */
+  if (count == 0)
+    count = strlen (bin);
+
+  for (i = 0; i < count; i++)
+    {
+      *hex++ = tohex ((*bin >> 4) & 0xf);
+      *hex++ = tohex (*bin++ & 0xf);
+    }
+  *hex = 0;
+  return i;
+}
+
 /* Send a packet to the remote machine, with error checking.
    The data of the packet is in BUF.  Returns >= 0 on success, -1 otherwise. */
 
@@ -293,7 +346,7 @@
 	  return;
 	}
       
-      kill (inferior_pid, SIGINT);
+      kill (signal_pid, SIGINT);
     }
 }
 
@@ -465,17 +518,15 @@
 void
 prepare_resume_reply (char *buf, char status, unsigned char signo)
 {
-  int nib;
+  int nib, sig;
 
   *buf++ = status;
 
-  /* FIXME!  Should be converting this signal number (numbered
-     according to the signal numbering of the system we are running on)
-     to the signal numbers used by the gdb protocol (see enum target_signal
-     in gdb/target.h).  */
-  nib = ((signo & 0xf0) >> 4);
+  sig = (int)target_signal_from_host (signo);
+
+  nib = ((sig & 0xf0) >> 4);
   *buf++ = tohex (nib);
-  nib = signo & 0x0f;
+  nib = sig & 0x0f;
   *buf++ = tohex (nib);
 
   if (status == 'T')
@@ -547,3 +598,42 @@
 
   convert_ascii_to_int (&from[i++], to, *len_ptr);
 }
+
+int
+look_up_one_symbol (const char *name, CORE_ADDR *addrp)
+{
+  char own_buf[266], *p, *q;
+  int len;
+
+  /* Send the request.  */
+  strcpy (own_buf, "qSymbol:");
+  hexify (own_buf + strlen ("qSymbol:"), name, strlen (name));
+  if (putpkt (own_buf) < 0)
+    return -1;
+
+  /* FIXME:  Eventually add buffer overflow checking (to getpkt?)  */
+  len = getpkt (own_buf);
+  if (len < 0)
+    return -1;
+
+  if (strncmp (own_buf, "qSymbol:", strlen ("qSymbol:")) != 0)
+    {
+      /* Malformed response.  */
+      if (remote_debug)
+	fprintf (stderr, "Malformed response to qSymbol, ignoring.\n");
+      return -1;
+    }
+
+  p = own_buf + strlen ("qSymbol:");
+  q = p;
+  while (*q && *q != ':')
+    q++;
+
+  /* Make sure we found a value for the symbol.  */
+  if (p == q || *q == '\0')
+    return 0;
+
+  decode_address (addrp, p, q - p);
+  return 1;
+}
+
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index d845422..ba85b59 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -27,13 +27,14 @@
 int old_thread_from_wait;
 int extended_protocol;
 jmp_buf toplevel;
-int inferior_pid;
 
 static unsigned char
 start_inferior (char *argv[], char *statusptr)
 {
-  inferior_pid = create_inferior (argv[0], argv);
-  fprintf (stderr, "Process %s created; pid = %d\n", argv[0], inferior_pid);
+  /* FIXME Check error? Or turn to void.  */
+  create_inferior (argv[0], argv);
+  /* FIXME Print pid properly.  */
+  fprintf (stderr, "Process %s created; pid = %d\n", argv[0], signal_pid);
 
   /* Wait till we are at 1st instruction in program, return signal number.  */
   return mywait (statusptr);
@@ -47,8 +48,6 @@
   if (myattach (pid) != 0)
     return -1;
 
-  inferior_pid = pid;
-
   *sigptr = mywait (statusptr);
 
   return 0;
@@ -56,6 +55,26 @@
 
 extern int remote_debug;
 
+/* Handle all of the extended 'q' packets.  */
+void
+handle_query (char *own_buf)
+{
+  if (strcmp ("qSymbol::", own_buf) == 0)
+    {
+      if (the_target->look_up_symbols != NULL)
+	(*the_target->look_up_symbols) ();
+
+      strcpy (own_buf, "OK");
+      return;
+    }
+
+  /* Otherwise we didn't know what packet it was.  Say we didn't
+     understand it.  */
+  own_buf[0] = 0;
+}
+
+static int attached;
+
 int
 main (int argc, char *argv[])
 {
@@ -64,9 +83,8 @@
   unsigned char signal;
   unsigned int len;
   CORE_ADDR mem_addr;
-  int bad_attach = 0;
-  int pid = 0;
-  int attached = 0;
+  int bad_attach;
+  int pid;
   char *arg_end;
 
   if (setjmp (toplevel))
@@ -75,6 +93,9 @@
       exit (1);
     }
 
+  bad_attach = 0;
+  pid = 0;
+  attached = 0;
   if (argc >= 3 && strcmp (argv[2], "--attach") == 0)
     {
       if (argc == 4
@@ -129,6 +150,9 @@
 	  ch = own_buf[i++];
 	  switch (ch)
 	    {
+	    case 'q':
+	      handle_query (own_buf);
+	      break;
 	    case 'd':
 	      remote_debug = !remote_debug;
 	      break;
@@ -190,13 +214,21 @@
 	      break;
 	    case 'C':
 	      convert_ascii_to_int (own_buf + 1, &sig, 1);
-	      myresume (0, sig);
+	      if (target_signal_to_host_p (sig))
+		signal = target_signal_to_host (sig);
+	      else
+		signal = 0;
+	      myresume (0, signal);
 	      signal = mywait (&status);
 	      prepare_resume_reply (own_buf, status, signal);
 	      break;
 	    case 'S':
 	      convert_ascii_to_int (own_buf + 1, &sig, 1);
-	      myresume (1, sig);
+	      if (target_signal_to_host_p (sig))
+		signal = target_signal_to_host (sig);
+	      else
+		signal = 0;
+	      myresume (1, signal);
 	      signal = mywait (&status);
 	      prepare_resume_reply (own_buf, status, signal);
 	      break;
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 6202b0f..32b90b5 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -23,38 +23,65 @@
 #define SERVER_H
 
 #include "config.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <setjmp.h>
 
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
 
-/* FIXME:  Both of these should be autoconf'd for.  */
-#define NORETURN
+#ifndef ATTR_NORETURN
+#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
+#define ATTR_NORETURN __attribute__ ((noreturn))
+#else
+#define ATTR_NORETURN           /* nothing */
+#endif
+#endif
+
+#ifndef ATTR_FORMAT
+#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4))
+#define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
+#else
+#define ATTR_FORMAT(type, x, y) /* nothing */
+#endif
+#endif
+
+/* FIXME: This should probably be autoconf'd for.  It's an integer type at
+   least the size of a (void *).  */
 typedef long long CORE_ADDR;
 
-#include "regcache.h"
+/* Opaque inferior process information.  */
+struct inferior_info;
 
-#include <setjmp.h>
+#include "regcache.h"
+#include "gdb/signals.h"
+
+#include "target.h"
+#include "mem-break.h"
 
 /* Target-specific functions */
 
-int create_inferior (char *program, char **allargs);
-void kill_inferior (void);
-void fetch_inferior_registers (int regno);
-void store_inferior_registers (int regno);
-int mythread_alive (int pid);
-void myresume (int step, int signo);
-unsigned char mywait (char *status);
-void read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
-int write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
-int create_inferior ();
 void initialize_low ();
 
 /* Target-specific variables */
 
 extern char *registers;
 
+/* From inferiors.c.  */
+
+extern struct inferior_info *current_inferior;
+extern int signal_pid;
+void add_inferior (int pid);
+void clear_inferiors (void);
+void *inferior_target_data (struct inferior_info *);
+void set_inferior_target_data (struct inferior_info *, void *);
+void *inferior_regcache_data (struct inferior_info *);
+void set_inferior_regcache_data (struct inferior_info *, void *);
+
 /* Public variables in server.c */
 
 extern int cont_thread;
@@ -63,7 +90,6 @@
 extern int old_thread_from_wait;
 
 extern jmp_buf toplevel;
-extern int inferior_pid;
 
 /* Functions from remote-utils.c */
 
@@ -84,15 +110,26 @@
 void decode_M_packet (char *from, CORE_ADDR * mem_addr_ptr,
 		      unsigned int *len_ptr, char *to);
 
+int unhexify (char *bin, const char *hex, int count);
+int hexify (char *hex, const char *bin, int count);
+
+int look_up_one_symbol (const char *name, CORE_ADDR *addrp);
+
+/* Functions from ``signals.c''.  */
+enum target_signal target_signal_from_host (int hostsig);
+int target_signal_to_host_p (enum target_signal oursig);
+int target_signal_to_host (enum target_signal oursig);
 
 /* Functions from utils.c */
 
 void perror_with_name (char *string);
-void error (const char *string,...);
-void fatal (const char *string,...);
+void error (const char *string,...) ATTR_NORETURN;
+void fatal (const char *string,...) ATTR_NORETURN;
 void warning (const char *string,...);
 
+/* Functions from the register cache definition.  */
 
+void init_registers (void);
 
 /* Maximum number of bytes to read/write at once.  The value here
    is chosen to fill up a packet (the headers account for the 32).  */
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
new file mode 100644
index 0000000..53a4c1e
--- /dev/null
+++ b/gdb/gdbserver/target.c
@@ -0,0 +1,47 @@
+/* Target operations for the remote server for GDB.
+   Copyright 2002
+   Free Software Foundation, Inc.
+
+   Contributed by MontaVista Software.
+
+   This file is part of GDB.
+
+   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 "server.h"
+
+struct target_ops *the_target;
+
+void
+read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
+{
+  (*the_target->read_memory) (memaddr, myaddr, len);
+  check_mem_read (memaddr, myaddr, len);
+}
+
+int
+write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
+{
+  check_mem_write (memaddr, myaddr, len);
+  return (*the_target->write_memory) (memaddr, myaddr, len);
+}
+
+void
+set_target_ops (struct target_ops *target)
+{
+  the_target = (struct target_ops *) malloc (sizeof (*the_target));
+  memcpy (the_target, target, sizeof (*the_target));
+}
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
new file mode 100644
index 0000000..6d06b9f
--- /dev/null
+++ b/gdb/gdbserver/target.h
@@ -0,0 +1,141 @@
+/* Target operations for the remote server for GDB.
+   Copyright 2002
+   Free Software Foundation, Inc.
+
+   Contributed by MontaVista Software.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef TARGET_H
+#define TARGET_H
+
+struct target_ops
+{
+  /* Start a new process.
+
+     PROGRAM is a path to the program to execute.
+     ARGS is a standard NULL-terminated array of arguments,
+     to be passed to the inferior as ``argv''.
+
+     Returns 0 on success, -1 on failure.  Registers the new
+     process with the process list.  */
+
+  int (*create_inferior) (char *program, char **args);
+
+  /* Attach to a running process.
+
+     PID is the process ID to attach to, specified by the user
+     or a higher layer.  */
+
+  int (*attach) (int pid);
+
+  /* Kill all inferiors.  */
+
+  void (*kill) (void);
+
+  /* Return 1 iff the thread with process ID PID is alive.  */
+
+  int (*thread_alive) (int pid);
+
+  /* Resume the inferior process.
+
+     If STEP is non-zero, we want to single-step.
+
+     If SIGNAL is nonzero, send the process that signal as we resume it.
+   */
+
+  void (*resume) (int step, int signo);
+
+  /* Wait for the inferior process to change state.
+
+     STATUSP will be filled in with a response code to send to GDB.
+
+     Returns the signal which caused the process to stop.  */
+
+  unsigned char (*wait) (char *status);
+
+  /* Fetch registers from the inferior process.
+
+     If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
+
+  void (*fetch_registers) (int regno);
+  
+  /* Store registers to the inferior process.
+
+     If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
+
+  void (*store_registers) (int regno);
+
+  /* Read memory from the inferior process.  This should generally be
+     called through read_inferior_memory, which handles breakpoint shadowing.
+
+     Read LEN bytes at MEMADDR into a buffer at MYADDR.  */
+
+  void (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len);
+
+  /* Write memory to the inferior process.  This should generally be
+     called through write_inferior_memory, which handles breakpoint shadowing.
+
+     Write LEN bytes from the buffer at MYADDR to MEMADDR.
+
+     Returns 0 on success and errno on failure.  */
+
+  int (*write_memory) (CORE_ADDR memaddr, const char *myaddr, int len);
+
+  /* Query GDB for the values of any symbols we're interested in.
+     This function is called whenever we receive a "qSymbols::"
+     query, which corresponds to every time more symbols (might)
+     become available.  NULL if we aren't interested in any
+     symbols.  */
+
+  void (*look_up_symbols) (void);
+};
+
+extern struct target_ops *the_target;
+
+void set_target_ops (struct target_ops *);
+
+#define create_inferior(program, args) \
+  (*the_target->create_inferior) (program, args)
+
+#define myattach(pid) \
+  (*the_target->attach) (pid)
+
+#define kill_inferior() \
+  (*the_target->kill) ()
+
+#define mythread_alive(pid) \
+  (*the_target->thread_alive) (pid)
+
+#define myresume(step,signo) \
+  (*the_target->resume) (step, signo)
+
+#define mywait(statusp) \
+  (*the_target->wait) (statusp)
+
+#define fetch_inferior_registers(regno) \
+  (*the_target->fetch_registers) (regno)
+
+#define store_inferior_registers(regno) \
+  (*the_target->store_registers) (regno)
+
+void read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
+
+int write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
+
+#endif /* TARGET_H */
diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
index a8ea9a1..e13eda8 100644
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -57,7 +57,7 @@
    STRING is the error message, used as a fprintf string,
    and ARG is passed as an argument to it.  */
 
-NORETURN void
+void
 error (const char *string,...)
 {
   extern jmp_buf toplevel;
@@ -74,7 +74,7 @@
    STRING and ARG are passed to fprintf.  */
 
 /* VARARGS */
-NORETURN void
+void
 fatal (const char *string,...)
 {
   va_list args;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index a13847e..ccff12f 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -71,6 +71,17 @@
 struct type *builtin_type_int128;
 struct type *builtin_type_uint128;
 struct type *builtin_type_bool;
+
+/* 128 bit long vector types */
+struct type *builtin_type_v4_float;
+struct type *builtin_type_v4_int32;
+struct type *builtin_type_v8_int16;
+struct type *builtin_type_v16_int8;
+/* 64 bit long vector types */
+struct type *builtin_type_v2_int32;
+struct type *builtin_type_v4_int16;
+struct type *builtin_type_v8_int8;
+
 struct type *builtin_type_v4sf;
 struct type *builtin_type_v4si;
 struct type *builtin_type_v16qi;
@@ -521,10 +532,16 @@
 
 /* Replace the contents of ntype with the type *type.
 
-   This function should not be necessary, but is due to quirks in the stabs
-   reader.  This should go away.  It does not handle the replacement type
-   being cv-qualified; it could be easily fixed to, but it should go away,
-   remember?  */
+   In order to build recursive types, it's inevitable that we'll need
+   to update types in place --- but this sort of indiscriminate
+   smashing is ugly, and needs to be replaced with something more
+   controlled.  For example, Daniel Jacobowitz has suggested moving
+   the fields common to a set of c/v variants into their own object,
+   which the variants would share.
+
+   This function does not handle the replacement type being
+   cv-qualified; it could be easily fixed to, but it would be better
+   to just change the whole approach.  */
 void
 replace_type (struct type *ntype, struct type *type)
 {
@@ -777,7 +794,6 @@
   return (result_type);
 }
 
-
 /* Construct and return a type of the form:
 	struct NAME { ELT_TYPE ELT_NAME[N]; }
    We use these types for SIMD registers.  For example, the type of
@@ -793,25 +809,27 @@
 		char *elt_name,
 		int n)
 {
-  struct type *t;
-  struct field *f;
+  struct type *simd_type;
+  struct type *array_type;
+  
+  simd_type = init_composite_type (name, TYPE_CODE_STRUCT);
+  array_type = create_array_type (0, elt_type,
+				  create_range_type (0, builtin_type_int,
+						     0, n-1));
+  append_composite_type_field (simd_type, elt_name, array_type);
+  return simd_type;
+}
 
-  /* Build the field structure.  */
-  f = xmalloc (sizeof (*f));
-  memset (f, 0, sizeof (*f));
-  f->loc.bitpos = 0;
-  f->type = create_array_type (0, elt_type,
-			       create_range_type (0, builtin_type_int,
-						  0, n-1));
-  f->name = elt_name;
-
-  /* Build a struct type with that field.  */
-  t = init_type (TYPE_CODE_STRUCT, n * TYPE_LENGTH (elt_type), 0, 0, 0);
-  t->nfields = 1;
-  t->fields = f;
-  TYPE_TAG_NAME (t) = name;
-
-  return t;
+static struct type *
+init_vector_type (struct type *elt_type, int n)
+{
+  struct type *array_type;
+ 
+  array_type = create_array_type (0, elt_type,
+				  create_range_type (0, builtin_type_int,
+						     0, n-1));
+  TYPE_FLAGS (array_type) |= TYPE_FLAG_VECTOR;
+  return array_type;
 }
 
 static struct type *
@@ -820,41 +838,24 @@
   /* Construct a type for the 128 bit registers.  The type we're
      building is this: */
 #if 0
-  union __gdb_builtin_type_vec128
+ union __gdb_builtin_type_vec128 
   {
-    struct __builtin_v16qi v16qi;
-    struct __builtin_v8hi v8hi;
-    struct __builtin_v4si v4si;
-    struct __builtin_v4sf v4sf;
-    uint128_t uint128;
+    int128_t uint128;
+    float v4_float[4];
+    int32_t v4_int32[4];
+    int16_t v8_int16[8];
+    int8_t v16_int8[16];
   };
 #endif
 
   struct type *t;
-  struct field *f;
 
-  f = (struct field *) xcalloc (5, sizeof (*f));
-
-  FIELD_TYPE (f[0]) = builtin_type_int128;
-  FIELD_NAME (f[0]) = "uint128";
-
-  FIELD_TYPE (f[1]) = builtin_type_v4sf;
-  FIELD_NAME (f[1]) = "v4sf";
-
-  FIELD_TYPE (f[2]) = builtin_type_v4si;
-  FIELD_NAME (f[2]) = "v4si";
-
-  FIELD_TYPE (f[3]) = builtin_type_v8hi;
-  FIELD_NAME (f[3]) = "v8hi";
-
-  FIELD_TYPE (f[4]) = builtin_type_v16qi;
-  FIELD_NAME (f[4]) = "v16qi";
-
-  /* Build a union type with those fields.  */
-  t = init_type (TYPE_CODE_UNION, 16, 0, 0, 0);
-  TYPE_NFIELDS (t) = 5;
-  TYPE_FIELDS (t) = f;
-  TYPE_TAG_NAME (t) = "__gdb_builtin_type_vec128";
+  t = init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION);
+  append_composite_type_field (t, "uint128", builtin_type_int128);
+  append_composite_type_field (t, "v4_float", builtin_type_v4_float);
+  append_composite_type_field (t, "v4_int32", builtin_type_v4_int32);
+  append_composite_type_field (t, "v8_int16", builtin_type_v8_int16);
+  append_composite_type_field (t, "v16_int8", builtin_type_v16_int8);
 
   return t;
 }
@@ -1753,6 +1754,48 @@
   return (type);
 }
 
+/* Helper function.  Create an empty composite type.  */
+
+struct type *
+init_composite_type (char *name, enum type_code code)
+{
+  struct type *t;
+  gdb_assert (code == TYPE_CODE_STRUCT
+	      || code == TYPE_CODE_UNION);
+  t = init_type (code, 0, 0, NULL, NULL);
+  TYPE_TAG_NAME (t) = name;
+  return t;
+}
+
+/* Helper function.  Append a field to a composite type.  */
+
+void
+append_composite_type_field (struct type *t, char *name, struct type *field)
+{
+  struct field *f;
+  TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1;
+  TYPE_FIELDS (t) = xrealloc (TYPE_FIELDS (t),
+			      sizeof (struct field) * TYPE_NFIELDS (t));
+  f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]);
+  memset (f, 0, sizeof f[0]);
+  FIELD_TYPE (f[0]) = field;
+  FIELD_NAME (f[0]) = name;
+  if (TYPE_CODE (t) == TYPE_CODE_UNION)
+    {
+      if (TYPE_LENGTH (t) < TYPE_LENGTH (field))
+	TYPE_LENGTH (t) = TYPE_LENGTH (field);
+    }
+  else if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
+    {
+      TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
+      if (TYPE_NFIELDS (t) > 1)
+	{
+	  FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1])
+				 + TYPE_LENGTH (field) * TARGET_CHAR_BIT);
+	}
+    }
+}
+
 /* Look up a fundamental type for the specified objfile.
    May need to construct such a type if this is the first use.
 
@@ -3017,6 +3060,13 @@
     {
       puts_filtered (" TYPE_FLAG_VARARGS");
     }
+  /* This is used for things like AltiVec registers on ppc.  Gcc emits
+     an attribute for the array type, which tells whether or not we
+     have a vector, instead of a regular array.  */
+  if (TYPE_VECTOR (type))
+    {
+      puts_filtered (" TYPE_FLAG_VECTOR");
+    }
   puts_filtered ("\n");
   printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type));
   gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout);
@@ -3261,9 +3311,18 @@
   builtin_type_v2si
     = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2);
 
+  /* 128 bit vectors.  */
+  builtin_type_v4_float = init_vector_type (builtin_type_float, 4);
+  builtin_type_v4_int32 = init_vector_type (builtin_type_int32, 4);
+  builtin_type_v8_int16 = init_vector_type (builtin_type_int16, 8);
+  builtin_type_v16_int8 = init_vector_type (builtin_type_int8, 16);
+  /* 64 bit vectors.  */
+  builtin_type_v2_int32 = init_vector_type (builtin_type_int32, 2);
+  builtin_type_v4_int16 = init_vector_type (builtin_type_int16, 4);
+  builtin_type_v8_int8 = init_vector_type (builtin_type_int8, 8);
+
   /* Vector types. */
-  builtin_type_vec128
-    = build_builtin_type_vec128 ();
+  builtin_type_vec128 = build_builtin_type_vec128 ();
 
   /* Pointer/Address types. */
 
@@ -3352,6 +3411,13 @@
   register_gdbarch_swap (&builtin_type_v8hi, sizeof (struct type *), NULL);
   register_gdbarch_swap (&builtin_type_v4hi, sizeof (struct type *), NULL);
   register_gdbarch_swap (&builtin_type_v2si, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v4_float, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v4_int32, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v8_int16, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v16_int8, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v2_int32, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v8_int8, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v4_int16, sizeof (struct type *), NULL);
   register_gdbarch_swap (&builtin_type_vec128, sizeof (struct type *), NULL);
   REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr);
   REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 74b521a..0411aaa 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -248,6 +248,13 @@
 #define TYPE_FLAG_VARARGS	(1 << 11)
 #define TYPE_VARARGS(t)		((t)->flags & TYPE_FLAG_VARARGS)
 
+/* Identify a vector type.  Gcc is handling this by adding an extra
+   attribute to the array type.  We slurp that in as a new flag of a
+   type.  This is used only in dwarf2read.c.  */
+#define TYPE_FLAG_VECTOR	(1 << 12)
+#define TYPE_VECTOR(t)		((t)->flags & TYPE_FLAG_VECTOR)
+
+
 struct type
   {
 
@@ -1054,6 +1061,16 @@
 extern struct type *init_type (enum type_code, int, int, char *,
 			       struct objfile *);
 
+/* Helper functions to construct a struct or record type.  An
+   initially empty type is created using init_composite_type().
+   Fields are then added using append_struct_type_field().  A union
+   type has its size set to the largest field.  A struct type has each
+   field packed against the previous.  */
+
+extern struct type *init_composite_type (char *name, enum type_code code);
+extern void append_composite_type_field (struct type *t, char *name,
+					 struct type *field);
+
 extern struct type *lookup_reference_type (struct type *);
 
 extern struct type *make_reference_type (struct type *, struct type **);
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index e48b536..a4b8020 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -299,7 +299,7 @@
 
   proc_debug (proc, "is %s", err ? "dead" : running ? "running" : "suspended");
   if (err)
-    proc_debug (proc, "err = %s", strerror (err));
+    proc_debug (proc, "err = %s", safe_strerror (err));
 
   if (running)
     {
@@ -468,7 +468,7 @@
 	proc->exc_port = exc_port;
       else
 	warning ("Error setting exception port for %s: %s",
-		 proc_string (proc), strerror (err));
+		 proc_string (proc), safe_strerror (err));
     }
 }
 
@@ -498,7 +498,7 @@
 	proc->exc_port = MACH_PORT_NULL;
       else
 	warning ("Error setting exception port for %s: %s",
-		 proc_string (proc), strerror (err));
+		 proc_string (proc), safe_strerror (err));
     }
 }
 
@@ -575,7 +575,7 @@
 				    &prev_port);
   if (err)
     warning ("Couldn't request notification for port %d: %s",
-	     port, strerror (err));
+	     port, safe_strerror (err));
   else
     {
       proc_debug (proc, "notifications to: %d", inf->event_port);
@@ -724,7 +724,7 @@
   err = mach_port_allocate (mach_task_self (),
 			    MACH_PORT_RIGHT_RECEIVE, &inf->event_port);
   if (err)
-    error ("Error allocating event port: %s", strerror (err));
+    error ("Error allocating event port: %s", safe_strerror (err));
 
   /* Make a send right for it, so we can easily copy it for other people.  */
   mach_port_insert_right (mach_task_self (), inf->event_port,
@@ -748,7 +748,7 @@
     {
       error_t err = proc_pid2task (proc_server, pid, &task_port);
       if (err)
-	error ("Error getting task for pid %d: %s", pid, strerror (err));
+	error ("Error getting task for pid %d: %s", pid, safe_strerror (err));
     }
 
   inf_debug (inf, "setting task: %d", task_port);
@@ -890,7 +890,7 @@
 	}
       else if (err)
 	warning ("Can't modify tracing state for pid %d: %s",
-		 inf->pid, strerror (err));
+		 inf->pid, safe_strerror (err));
       else
 	inf->traced = on;
     }
@@ -1366,7 +1366,7 @@
     /* Can't do too much... */
     warning ("Can't deliver signal %s: No signal thread.", NAME);
   else if (err)
-    warning ("Delivering signal %s: %s", NAME, strerror (err));
+    warning ("Delivering signal %s: %s", NAME, safe_strerror (err));
 
 #undef NAME
 }
@@ -1397,7 +1397,7 @@
     }
 
   if (err)
-    warning ("Can't continue process: %s", strerror (err));
+    warning ("Can't continue process: %s", safe_strerror (err));
 }
 
 
@@ -1460,7 +1460,7 @@
       err =
 	proc_wait_request (proc_server, inf->event_port, inf->pid, WUNTRACED);
       if (err)
-	warning ("wait request failed: %s", strerror (err));
+	warning ("wait request failed: %s", safe_strerror (err));
       else
 	{
 	  inf_debug (inf, "waits pending: %d", proc_waits_pending);
@@ -1496,7 +1496,7 @@
   if (err == EMACH_RCV_INTERRUPTED)
     inf_debug (inf, "interrupted");
   else if (err)
-    error ("Couldn't wait for an event: %s", strerror (err));
+    error ("Couldn't wait for an event: %s", safe_strerror (err));
   else
     {
       struct
@@ -1520,7 +1520,7 @@
 
       if (reply.err)
 	error ("Handling event, msgid = %d: %s",
-	       msg.hdr.msgh_id, strerror (reply.err));
+	       msg.hdr.msgh_id, safe_strerror (reply.err));
     }
 
   if (inf->pending_execs)
@@ -1796,7 +1796,7 @@
   struct inf *inf = waiting_inf;
 
   inf_debug (inf, "err = %s, pid = %d, status = 0x%x, sigcode = %d",
-	     err ? strerror (err) : "0", pid, status, sigcode);
+	     err ? safe_strerror (err) : "0", pid, status, sigcode);
 
   if (err && proc_wait_pid && (!inf->task || !inf->task->port))
     /* Ack.  The task has died, but the task-died notification code didn't
@@ -1817,7 +1817,7 @@
     {
       if (err != EINTR)
 	{
-	  warning ("Can't wait for pid %d: %s", inf->pid, strerror (err));
+	  warning ("Can't wait for pid %d: %s", inf->pid, safe_strerror (err));
 	  inf->no_wait = 1;
 
 	  /* Since we can't see the inferior's signals, don't trap them.  */
@@ -1873,7 +1873,7 @@
       inf->wait.status.value.sig = TARGET_SIGNAL_0;
     }
   else if (err)
-    warning ("Signal delivery failed: %s", strerror (err));
+    warning ("Signal delivery failed: %s", safe_strerror (err));
 
   if (err)
     /* We only get this reply when we've posted a signal to a process which we
@@ -2259,13 +2259,13 @@
   err = hurd_safe_copyin (myaddr, (void *) addr - low_address + copied, length);
   if (err)
     {
-      warning ("Read from inferior faulted: %s", strerror (err));
+      warning ("Read from inferior faulted: %s", safe_strerror (err));
       length = 0;
     }
 
   err = vm_deallocate (mach_task_self (), copied, copy_count);
   if (err)
-    warning ("gnu_read_inferior vm_deallocate failed: %s", strerror (err));
+    warning ("gnu_read_inferior vm_deallocate failed: %s", safe_strerror (err));
 
   return length;
 }
@@ -2458,7 +2458,7 @@
   else
     {
       inf_debug (current_inferior, "%s %p[%d] %s %p",
-		 write ? "writing" : "reading", memaddr, len,
+		 write ? "writing" : "reading", (void *) memaddr, len,
 		 write ? "<--" : "-->", myaddr);
       if (write)
 	return gnu_write_inferior (task, memaddr, myaddr, len);
@@ -2467,6 +2467,87 @@
     }
 }
 
+/* Call FUNC on each memory region in the task.  */
+static int
+gnu_find_memory_regions (int (*func) (CORE_ADDR,
+				      unsigned long,
+				      int, int, int,
+				      void *),
+			 void *data)
+{
+  error_t err;
+  task_t task;
+  vm_address_t region_address, last_region_address, last_region_end;
+  vm_prot_t last_protection;
+
+  if (current_inferior == 0 || current_inferior->task == 0)
+    return 0;
+  task = current_inferior->task->port;
+  if (task == MACH_PORT_NULL)
+    return 0;
+
+  region_address = last_region_address = last_region_end = VM_MIN_ADDRESS;
+  last_protection = VM_PROT_NONE;
+  while (region_address < VM_MAX_ADDRESS)
+    {
+      vm_prot_t protection;
+      vm_prot_t max_protection;
+      vm_inherit_t inheritance;
+      boolean_t shared;
+      mach_port_t object_name;
+      vm_offset_t offset;
+      vm_size_t region_length = VM_MAX_ADDRESS - region_address;
+      vm_address_t old_address = region_address;
+
+      err = vm_region (task,
+		       &region_address,
+		       &region_length,
+		       &protection,
+		       &max_protection,
+		       &inheritance,
+		       &shared,
+		       &object_name,
+		       &offset);
+      if (err == KERN_NO_SPACE)
+	break;
+      if (err != KERN_SUCCESS)
+	{
+	  warning ("vm_region failed: %s", mach_error_string (err));
+	  return -1;
+	}
+
+      if (protection == last_protection && region_address == last_region_end)
+	/* This region is contiguous with and indistinguishable from
+	   the previous one, so we just extend that one.  */
+	last_region_end = region_address += region_length;
+      else
+	{
+	  /* This region is distinct from the last one we saw, so report
+	     that previous one.  */
+	  if (last_protection != VM_PROT_NONE)
+	    (*func) (last_region_address,
+		     last_region_end - last_region_address,
+		     last_protection & VM_PROT_READ,
+		     last_protection & VM_PROT_WRITE,
+		     last_protection & VM_PROT_EXECUTE,
+		     data);
+	  last_region_address = region_address;
+	  last_region_end = region_address += region_length;
+	  last_protection = protection;
+	}
+    }
+
+  /* Report the final region.  */
+  if (last_region_end > last_region_address && last_protection != VM_PROT_NONE)
+    (*func) (last_region_address, last_region_end - last_region_address,
+	     last_protection & VM_PROT_READ,
+	     last_protection & VM_PROT_WRITE,
+	     last_protection & VM_PROT_EXECUTE,
+	     data);
+
+  return 0;
+}
+
 
 /* Return printable description of proc.  */
 char *
@@ -2524,6 +2605,7 @@
   gnu_ops.to_store_registers = gnu_store_registers;    /* to_store_registers */
   gnu_ops.to_prepare_to_store = gnu_prepare_to_store; /* to_prepare_to_store */
   gnu_ops.to_xfer_memory = gnu_xfer_memory; /* to_xfer_memory */
+  gnu_ops.to_find_memory_regions = gnu_find_memory_regions;
   gnu_ops.to_files_info = 0;		/* to_files_info */
   gnu_ops.to_insert_breakpoint = memory_insert_breakpoint;
   gnu_ops.to_remove_breakpoint = memory_remove_breakpoint;
@@ -2781,7 +2863,7 @@
 				 &port, &port_type);
   if (err)
     error ("Couldn't extract send right %d from inferior: %s",
-	   name, strerror (err));
+	   name, safe_strerror (err));
 
   if (proc->saved_exc_port)
     /* Get rid of our reference to the old one.  */
@@ -2796,7 +2878,7 @@
       proc->exc_port = proc->inf->event_port;
       err = proc_set_exception_port (proc, proc->exc_port);
       error ("Can't set exception port for %s: %s",
-	     proc_string (proc), strerror (err));
+	     proc_string (proc), safe_strerror (err));
     }
 }
 
@@ -2970,7 +3052,7 @@
 	  print_port_info (right, 0, inf->task->port, PORTINFO_DETAILS,
 			   stdout);
 	  if (err)
-	    error ("%ld: %s.", right, strerror (err));
+	    error ("%ld: %s.", right, safe_strerror (err));
 	}
     }
   else
@@ -2980,7 +3062,7 @@
       print_task_ports_info (inf->task->port, only, PORTINFO_DETAILS,
 			     stdout);
       if (err)
-	error ("%s.", strerror (err));
+	error ("%s.", safe_strerror (err));
     }
 
   value_free_to_mark (vmark);
@@ -3241,7 +3323,7 @@
   error_t err =
   thread_info (thread->port, THREAD_BASIC_INFO, (int *) &info, &info_len);
   if (err)
-    error ("%s.", strerror (err));
+    error ("%s.", safe_strerror (err));
   thread->sc = info->suspend_count;
   if (from_tty)
     printf_unfiltered ("Suspend count was %d.\n", thread->sc);
@@ -3352,6 +3434,6 @@
 			      MATTR_CACHE,
 			      &flush);
   if (ret != KERN_SUCCESS)
-    warning ("Error flushing inferior's cache : %s", strerror (ret));
+    warning ("Error flushing inferior's cache : %s", safe_strerror (ret));
 }
 #endif /* FLUSH_INFERIOR_CACHE */
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index ae2104d..720364b 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -241,22 +241,33 @@
   vtable_symbol_name = SYMBOL_DEMANGLED_NAME (vtable_symbol);
   if (vtable_symbol_name == NULL
       || strncmp (vtable_symbol_name, "vtable for ", 11))
-    error ("can't find linker symbol for virtual table for `%s' value",
-           TYPE_NAME (value_type));
+    {
+      warning ("can't find linker symbol for virtual table for `%s' value",
+	       TYPE_NAME (value_type));
+      if (vtable_symbol_name)
+	warning ("  found `%s' instead", vtable_symbol_name);
+      return NULL;
+    }
   class_name = vtable_symbol_name + 11;
 
   /* Try to look up the class name as a type name.  */
   class_symbol = lookup_symbol (class_name, 0, STRUCT_NAMESPACE, 0, 0);
   if (! class_symbol)
-    error ("can't find class named `%s', as given by C++ RTTI", class_name);
+    {
+      warning ("can't find class named `%s', as given by C++ RTTI", class_name);
+      return NULL;
+    }
 
   /* Make sure the type symbol is sane.  (An earlier version of this
      code would find constructor functions, who have the same name as
      the class.)  */
   if (SYMBOL_CLASS (class_symbol) != LOC_TYPEDEF
       || TYPE_CODE (SYMBOL_TYPE (class_symbol)) != TYPE_CODE_CLASS)
-    error ("C++ RTTI gives a class name of `%s', but that isn't a type name",
-           class_name);
+    {
+      warning ("C++ RTTI gives a class name of `%s', but that isn't a type name",
+	       class_name);
+      return NULL;
+    }
 
   /* This is the object's run-time type!  */
   run_time_type = SYMBOL_TYPE (class_symbol);
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index de5e586..7b64b17 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -491,7 +491,7 @@
 store_register (int regno)
 {
   if (regno < FP0_REGNUM)
-    regcache_collect (regno, (void *) &a_tss + regno_mapping[regno].tss_ofs);
+    regcache_collect (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs);
   else if (FP_REGNUM_P (regno) || FPC_REGNUM_P (regno))
     i387_fill_fsave ((char *) &npx, regno);
   else
@@ -804,7 +804,7 @@
   {
     redir_to_debugger (&child_cmd);
     error ("Cannot redirect standard handles for program: %s.",
-	   strerror (errno));
+	   safe_strerror (errno));
   }
   /* set the console device of the inferior to whatever mode
      (raw or cooked) we found it last time */
@@ -838,7 +838,7 @@
     {
       redir_to_child (&child_cmd);
       error ("Cannot redirect standard handles for debugger: %s.",
-	     strerror (errno));
+	     safe_strerror (errno));
     }
   }
 }
diff --git a/gdb/gregset.h b/gdb/gregset.h
index a3a1325..cb27517 100644
--- a/gdb/gregset.h
+++ b/gdb/gregset.h
@@ -52,5 +52,18 @@
 extern void fill_gregset (gdb_gregset_t *gregs, int regno);
 extern void fill_fpregset (gdb_fpregset_t *fpregs, int regno);
 
+#ifdef FILL_FPXREGSET
+/* Linux/i386: Copy register values between GDB's internal register cache
+   and the i386 extended floating point registers.  */
+
+#ifndef GDB_FPXREGSET_T
+#define GDB_FPXREGSET_T elf_fpxregset_t
+#endif
+
+typedef GDB_FPXREGSET_T gdb_fpxregset_t;
+
+extern void supply_fpxregset (gdb_fpxregset_t *fpxregs);
+extern void fill_fpxregset (gdb_fpxregset_t *fpxregs, int regno);
+#endif
 
 #endif
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index e335fdb..93b9bbb 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -1,6 +1,7 @@
 /* Target-machine dependent code for Hitachi H8/300, for GDB.
-   Copyright 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
-   2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
+   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -834,7 +835,7 @@
       int C, Z, N, V;
       unsigned char b[4];
       unsigned char l;
-      read_relative_register_raw_bytes (regno, b);
+      frame_register_read (selected_frame, regno, b);
       l = b[REGISTER_VIRTUAL_SIZE (8) - 1];
       printf_unfiltered ("\t");
       printf_unfiltered ("I-%d - ", (l & 0x80) != 0);
diff --git a/gdb/h8500-tdep.c b/gdb/h8500-tdep.c
index d303246..04ba706 100644
--- a/gdb/h8500-tdep.c
+++ b/gdb/h8500-tdep.c
@@ -1,6 +1,7 @@
 /* Target-dependent code for Hitachi H8/500, for GDB.
-   Copyright 1993, 1994, 1995, 1998, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -186,7 +187,7 @@
       unsigned char b[2];
       unsigned char l;
 
-      read_relative_register_raw_bytes (regno, b);
+      frame_register_read (selected_frame, regno, b);
       l = b[1];
       printf_unfiltered ("\t");
       printf_unfiltered ("I-%d - ", (l & 0x80) != 0);
@@ -604,12 +605,6 @@
 }
 
 void
-h8500_write_fp (CORE_ADDR v)
-{
-  write_register (PR6_REGNUM, v);
-}
-
-void
 _initialize_h8500_tdep (void)
 {
   tm_print_insn = print_insn_h8500;
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 157fb8a..3890fc2 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -1,6 +1,7 @@
 /* Target-dependent code for the HP PA architecture, for GDB.
-   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
    University of Utah (pa-gdb-bugs@cs.utah.edu).
@@ -632,7 +633,8 @@
      its frame isn't a pure interrupt frame.  Deal with this.  */
   msym_us = lookup_minimal_symbol_by_pc (pc);
 
-  return u->HP_UX_interrupt_marker && !IN_SIGTRAMP (pc, SYMBOL_NAME (msym_us));
+  return (u->HP_UX_interrupt_marker
+	  && !PC_IN_SIGTRAMP (pc, SYMBOL_NAME (msym_us)));
 }
 
 /* Called when no unwind descriptor was found for PC.  Returns 1 if it
@@ -747,8 +749,10 @@
 
   /* If Save_SP is set, and we're not in an interrupt or signal caller,
      then we have a frame pointer.  Use it.  */
-  if (u->Save_SP && !pc_in_interrupt_handler (pc)
-      && !IN_SIGTRAMP (pc, SYMBOL_NAME (msym_us)))
+  if (u->Save_SP
+      && !pc_in_interrupt_handler (pc)
+      && msym_us
+      && !PC_IN_SIGTRAMP (pc, SYMBOL_NAME (msym_us)))
     return -1;
 
   return u->Total_frame_size << 3;
@@ -2486,7 +2490,7 @@
   /* Make a copy of gdb's save area (may cause actual
      reads from the target). */
   for (i = 0; i < NUM_REGS; i++)
-    read_relative_register_raw_bytes (i, raw_regs + REGISTER_BYTE (i));
+    frame_register_read (selected_frame, i, raw_regs + REGISTER_BYTE (i));
 
   if (regnum == -1)
     pa_print_registers (raw_regs, regnum, fpregs);
@@ -2530,7 +2534,7 @@
   /* Make a copy of gdb's save area (may cause actual
      reads from the target). */
   for (i = 0; i < NUM_REGS; i++)
-    read_relative_register_raw_bytes (i, raw_regs + REGISTER_BYTE (i));
+    frame_register_read (selected_frame, i, raw_regs + REGISTER_BYTE (i));
 
   if (regnum == -1)
     pa_strcat_registers (raw_regs, regnum, fpregs, stream);
@@ -2782,7 +2786,7 @@
   char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
 
   /* Get 32bits of data.  */
-  read_relative_register_raw_bytes (i, raw_buffer);
+  frame_register_read (selected_frame, i, raw_buffer);
 
   /* Put it in the buffer.  No conversions are ever necessary.  */
   memcpy (virtual_buffer, raw_buffer, REGISTER_RAW_SIZE (i));
@@ -2800,7 +2804,7 @@
   if ((i % 2) == 0)
     {
       /* Get the data in raw format for the 2nd half.  */
-      read_relative_register_raw_bytes (i + 1, raw_buffer);
+      frame_register_read (selected_frame, i + 1, raw_buffer);
 
       /* Copy it into the appropriate part of the virtual buffer.  */
       memcpy (virtual_buffer + REGISTER_RAW_SIZE (i), raw_buffer,
@@ -2828,7 +2832,7 @@
   print_spaces_filtered (8 - strlen (REGISTER_NAME (i)), stream);
 
   /* Get 32bits of data.  */
-  read_relative_register_raw_bytes (i, raw_buffer);
+  frame_register_read (selected_frame, i, raw_buffer);
 
   /* Put it in the buffer.  No conversions are ever necessary.  */
   memcpy (virtual_buffer, raw_buffer, REGISTER_RAW_SIZE (i));
@@ -2839,7 +2843,7 @@
       char raw_buf[MAX_REGISTER_RAW_SIZE];
 
       /* Get the data in raw format for the 2nd half.  */
-      read_relative_register_raw_bytes (i + 1, raw_buf);
+      frame_register_read (selected_frame, i + 1, raw_buf);
 
       /* Copy it into the appropriate part of the virtual buffer.  */
       memcpy (virtual_buffer + REGISTER_RAW_SIZE (i), raw_buf, REGISTER_RAW_SIZE (i));
@@ -4461,7 +4465,7 @@
   if (level != 0)
     return (struct exception_event_record *) NULL;
 
-  select_frame (fi, -1);
+  select_frame (fi);
 
   /* Read in the arguments */
   /* __d_eh_notify_callback() is called with 3 arguments:
@@ -4487,11 +4491,11 @@
   if (level != 0)
     return (struct exception_event_record *) NULL;
 
-  select_frame (fi, -1);
+  select_frame (fi);
   throw_addr = fi->pc;
 
   /* Go back to original (top) frame */
-  select_frame (curr_frame, -1);
+  select_frame (curr_frame);
 
   current_ex_event.kind = (enum exception_event_kind) event_kind;
   current_ex_event.throw_sal = find_pc_line (throw_addr, 1);
@@ -4709,7 +4713,7 @@
 			      tbreak_at_finish_command,
 "Set temporary breakpoint at procedure exit.  Either there should\n\
 be no argument or the argument must be a depth.\n"), NULL);
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
   
   if (xdb_commands)
     deprecate_cmd (add_com ("bx", class_breakpoint, 
diff --git a/gdb/hpread.c b/gdb/hpread.c
index b7f0fc5..ca153f9 100644
--- a/gdb/hpread.c
+++ b/gdb/hpread.c
@@ -56,8 +56,8 @@
     unsigned int gntt_symcount;
 
     /* To keep track of all the types we've processed.  */
-    struct type **type_vector;
-    int type_vector_length;
+    struct type **dntt_type_vector;
+    int dntt_type_vector_length;
 
     /* Keeps track of the beginning of a range of source lines.  */
     sltpointer sl_index;
@@ -80,8 +80,9 @@
 #define VT_SIZE(o)              (HPUX_SYMFILE_INFO(o)->vt_size)
 #define LNTT_SYMCOUNT(o)        (HPUX_SYMFILE_INFO(o)->lntt_symcount)
 #define GNTT_SYMCOUNT(o)        (HPUX_SYMFILE_INFO(o)->gntt_symcount)
-#define TYPE_VECTOR(o)          (HPUX_SYMFILE_INFO(o)->type_vector)
-#define TYPE_VECTOR_LENGTH(o)   (HPUX_SYMFILE_INFO(o)->type_vector_length)
+#define DNTT_TYPE_VECTOR(o)     (HPUX_SYMFILE_INFO(o)->dntt_type_vector)
+#define DNTT_TYPE_VECTOR_LENGTH(o) \
+  (HPUX_SYMFILE_INFO(o)->dntt_type_vector_length)
 #define SL_INDEX(o)             (HPUX_SYMFILE_INFO(o)->sl_index)
 #define WITHIN_FUNCTION(o)      (HPUX_SYMFILE_INFO(o)->within_function)
 #define CURRENT_FUNCTION_VALUE(o) (HPUX_SYMFILE_INFO(o)->current_function_value)
@@ -200,6 +201,9 @@
 
 static union dnttentry *hpread_get_gntt (int, struct objfile *);
 
+static union dnttentry *hpread_get_lntt (int index, struct objfile *objfile);
+
+
 static unsigned long hpread_get_textlow (int, int, struct objfile *, int);
 
 static struct partial_symtab *hpread_start_psymtab
@@ -1691,7 +1695,7 @@
   memset (objfile->sym_private, 0, sizeof (struct hpread_symfile_info));
 
   /* We haven't read in any types yet.  */
-  TYPE_VECTOR (objfile) = 0;
+  DNTT_TYPE_VECTOR (objfile) = 0;
 
   /* Read in data from the $GNTT$ subspace.  */
   gntt_section = bfd_get_section_by_name (objfile->obfd, "$GNTT$");
@@ -2690,8 +2694,9 @@
   /* Complain if we've already read in this symbol table.  */
   if (pst->readin)
     {
-      fprintf (stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
-	       pst->filename);
+      fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in."
+			  "  Shouldn't happen.\n",
+			  pst->filename);
       return;
     }
 
@@ -2745,8 +2750,9 @@
   /* Sanity check.  */
   if (pst->readin)
     {
-      fprintf (stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
-	       pst->filename);
+      fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in."
+			  "  Shouldn't happen.\n",
+			  pst->filename);
       return;
     }
 
@@ -3028,18 +3034,18 @@
 
   if (index < LNTT_SYMCOUNT (objfile))
     {
-      if (index >= TYPE_VECTOR_LENGTH (objfile))
+      if (index >= DNTT_TYPE_VECTOR_LENGTH (objfile))
 	{
-	  old_len = TYPE_VECTOR_LENGTH (objfile);
+	  old_len = DNTT_TYPE_VECTOR_LENGTH (objfile);
 
 	  /* See if we need to allocate a type-vector. */
 	  if (old_len == 0)
 	    {
-	      TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile);
-	      TYPE_VECTOR (objfile) = (struct type **)
-		xmmalloc (objfile->md, TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
-	      memset (&TYPE_VECTOR (objfile)[old_len], 0,
-		      (TYPE_VECTOR_LENGTH (objfile) - old_len) *
+	      DNTT_TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile);
+	      DNTT_TYPE_VECTOR (objfile) = (struct type **)
+		xmmalloc (objfile->md, DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
+	      memset (&DNTT_TYPE_VECTOR (objfile)[old_len], 0,
+		      (DNTT_TYPE_VECTOR_LENGTH (objfile) - old_len) *
 		      sizeof (struct type *));
 	    }
 
@@ -3047,25 +3053,25 @@
 	   * initially allocate a correct-size type-vector, this code
 	   * should no longer trigger.
 	   */
-	  while (index >= TYPE_VECTOR_LENGTH (objfile))
+	  while (index >= DNTT_TYPE_VECTOR_LENGTH (objfile))
 	    {
-	      TYPE_VECTOR_LENGTH (objfile) *= 2;
+	      DNTT_TYPE_VECTOR_LENGTH (objfile) *= 2;
 	      size_changed = 1;
 	    }
 	  if (size_changed)
 	    {
-	      TYPE_VECTOR (objfile) = (struct type **)
+	      DNTT_TYPE_VECTOR (objfile) = (struct type **)
 		xmrealloc (objfile->md,
-			   (char *) TYPE_VECTOR (objfile),
-		   (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)));
+			   (char *) DNTT_TYPE_VECTOR (objfile),
+		   (DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)));
 
-	      memset (&TYPE_VECTOR (objfile)[old_len], 0,
-		      (TYPE_VECTOR_LENGTH (objfile) - old_len) *
+	      memset (&DNTT_TYPE_VECTOR (objfile)[old_len], 0,
+		      (DNTT_TYPE_VECTOR_LENGTH (objfile) - old_len) *
 		      sizeof (struct type *));
 	    }
 
 	}
-      return &TYPE_VECTOR (objfile)[index];
+      return &DNTT_TYPE_VECTOR (objfile)[index];
     }
   else
     return NULL;
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index d67c01c..9592dec 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -92,7 +92,7 @@
 
    It kind of sucks that we have to read memory from the process in
    order to identify a signal trampoline, but there doesn't seem to be
-   any other way.  The IN_SIGTRAMP macro in tm-linux.h arranges to
+   any other way.  The PC_IN_SIGTRAMP macro in tm-linux.h arranges to
    only call us if no function name could be identified, which should
    be the case since the code is on the stack.
 
@@ -317,7 +317,7 @@
    in progress when the signal trampoline was entered.  GDB mostly
    treats this frame pointer value as a magic cookie.  We detect the
    case of a signal trampoline by looking at the SIGNAL_HANDLER_CALLER
-   field, which is set based on IN_SIGTRAMP.
+   field, which is set based on PC_IN_SIGTRAMP.
 
    When a signal trampoline is invoked from a frameless function, we
    essentially have two frameless functions in a row.  In this case,
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index b2ddd28..4e3a15f 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1,7 +1,7 @@
 /* Intel 386 target-dependent stuff.
-   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -40,9 +40,6 @@
 
 #include "i386-tdep.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 /* Names of the registers.  The first 10 registers match the register
    numbering scheme used by GCC for stabs and DWARF.  */
 static char *i386_register_names[] =
diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c
index 9188ea4..e82fe0d 100644
--- a/gdb/i386gnu-nat.c
+++ b/gdb/i386gnu-nat.c
@@ -38,6 +38,10 @@
 #include "gnu-nat.h"
 #include "i387-nat.h"
 
+#ifdef HAVE_SYS_PROCFS_H
+# include <sys/procfs.h>
+# include "gregset.h"
+#endif
 
 /* Offset to the thread_state_t location where REG is stored.  */
 #define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
@@ -88,6 +92,24 @@
   i387_supply_fsave (state.hw_state);
 }
 
+#ifdef HAVE_SYS_PROCFS_H
+/* These two calls are used by the core-regset.c code for
+   reading ELF core files.  */
+void
+supply_gregset (gdb_gregset_t *gregs)
+{
+  int i;
+  for (i = 0; i < NUM_GREGS; i++)
+    supply_register (i, REG_ADDR (gregs, i));
+}
+
+void
+supply_fpregset (gdb_fpregset_t *fpregs)
+{
+  i387_supply_fsave ((char *) fpregs);
+}
+#endif
+
 /* Fetch register REGNO, or all regs if REGNO is -1.  */
 void
 gnu_fetch_registers (int regno)
diff --git a/gdb/i387-nat.c b/gdb/i387-nat.c
index 62c26f8..163dcfd 100644
--- a/gdb/i387-nat.c
+++ b/gdb/i387-nat.c
@@ -116,23 +116,26 @@
 	if (i >= FPC_REGNUM
 	    && i != FIOFF_REGNUM && i != FOOFF_REGNUM)
 	  {
+	    char buf[4];
+
+	    regcache_collect (i, buf);
+
 	    if (i == FOP_REGNUM)
 	      {
 		unsigned short oldval, newval;
 
 		/* The opcode occupies only 11 bits.  */
 		oldval = (*(unsigned short *) (FSAVE_ADDR (fsave, i)));
-		newval = *(unsigned short *) &registers[REGISTER_BYTE (i)];
+		newval = *(unsigned short *) buf;
 		newval &= ((1 << 11) - 1);
 		newval |= oldval & ~((1 << 11) - 1);
 		memcpy (FSAVE_ADDR (fsave, i), &newval, 2);
 	      }
 	    else
-	      memcpy (FSAVE_ADDR (fsave, i), &registers[REGISTER_BYTE (i)], 2);
+	      memcpy (FSAVE_ADDR (fsave, i), buf, 2);
 	  }
 	else
-	  memcpy (FSAVE_ADDR (fsave, i), &registers[REGISTER_BYTE (i)],
-		  REGISTER_RAW_SIZE (i));
+	  regcache_collect (i, FSAVE_ADDR (fsave, i));
       }
 }
 
@@ -255,13 +258,17 @@
 	if (i >= FPC_REGNUM && i < XMM0_REGNUM
 	    && i != FIOFF_REGNUM && i != FDOFF_REGNUM)
 	  {
+	    char buf[4];
+
+	    regcache_collect (i, buf);
+
 	    if (i == FOP_REGNUM)
 	      {
 		unsigned short oldval, newval;
 
 		/* The opcode occupies only 11 bits.  */
 		oldval = (*(unsigned short *) (FXSAVE_ADDR (fxsave, i)));
-		newval = *(unsigned short *) &registers[REGISTER_BYTE (i)];
+		newval = *(unsigned short *) buf;
 		newval &= ((1 << 11) - 1);
 		newval |= oldval & ~((1 << 11) - 1);
 		memcpy (FXSAVE_ADDR (fxsave, i), &newval, 2);
@@ -274,7 +281,7 @@
 		unsigned short ftag;
 		int fpreg;
 
-		ftag = *(unsigned short *) &registers[REGISTER_BYTE (i)];
+		ftag = *(unsigned short *) buf;
 
 		for (fpreg = 7; fpreg >= 0; fpreg--)
 		  {
@@ -287,12 +294,10 @@
 		memcpy (FXSAVE_ADDR (fxsave, i), &val, 2);
 	      }
 	    else
-	      memcpy (FXSAVE_ADDR (fxsave, i),
-		      &registers[REGISTER_BYTE (i)], 2);
+	      memcpy (FXSAVE_ADDR (fxsave, i), buf, 2);
 	  }
 	else
-	  memcpy (FXSAVE_ADDR (fxsave, i), &registers[REGISTER_BYTE (i)],
-		  REGISTER_RAW_SIZE (i));
+	  regcache_collect (i, FXSAVE_ADDR (fxsave, i));
       }
 }
 
diff --git a/gdb/i960-tdep.c b/gdb/i960-tdep.c
index 053c7fa..98718a3 100644
--- a/gdb/i960-tdep.c
+++ b/gdb/i960-tdep.c
@@ -1,6 +1,8 @@
 /* Target-machine dependent code for the Intel 960
-   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
+   2001, 2002 Free Software Foundation, Inc.
+
    Contributed by Intel Corporation.
    examine_prologue and other parts contributed by Wind River Systems.
 
@@ -120,6 +122,155 @@
     }
 }
 
+/* Is this register part of the register window system?  A yes answer
+   implies that 1) The name of this register will not be the same in
+   other frames, and 2) This register is automatically "saved" upon
+   subroutine calls and thus there is no need to search more than one
+   stack frame for it.
+
+   On the i960, in fact, the name of this register in another frame is
+   "mud" -- there is no overlap between the windows.  Each window is
+   simply saved into the stack (true for our purposes, after having been
+   flushed; normally they reside on-chip and are restored from on-chip
+   without ever going to memory).  */
+
+static int
+register_in_window_p (int regnum)
+{
+  return regnum <= R15_REGNUM;
+}
+
+/* i960_find_saved_register ()
+
+   Return the address in which frame FRAME's value of register REGNUM
+   has been saved in memory.  Or return zero if it has not been saved.
+   If REGNUM specifies the SP, the value we return is actually the SP
+   value, not an address where it was saved.  */
+
+static CORE_ADDR
+i960_find_saved_register (struct frame_info *frame, int regnum)
+{
+  register struct frame_info *frame1 = NULL;
+  register CORE_ADDR addr = 0;
+
+  if (frame == NULL)		/* No regs saved if want current frame */
+    return 0;
+
+  /* We assume that a register in a register window will only be saved
+     in one place (since the name changes and/or disappears as you go
+     towards inner frames), so we only call get_frame_saved_regs on
+     the current frame.  This is directly in contradiction to the
+     usage below, which assumes that registers used in a frame must be
+     saved in a lower (more interior) frame.  This change is a result
+     of working on a register window machine; get_frame_saved_regs
+     always returns the registers saved within a frame, within the
+     context (register namespace) of that frame. */
+
+  /* However, note that we don't want this to return anything if
+     nothing is saved (if there's a frame inside of this one).  Also,
+     callers to this routine asking for the stack pointer want the
+     stack pointer saved for *this* frame; this is returned from the
+     next frame.  */
+
+  if (register_in_window_p (regnum))
+    {
+      frame1 = get_next_frame (frame);
+      if (!frame1)
+	return 0;		/* Registers of this frame are active.  */
+
+      /* Get the SP from the next frame in; it will be this
+         current frame.  */
+      if (regnum != SP_REGNUM)
+	frame1 = frame;
+
+      FRAME_INIT_SAVED_REGS (frame1);
+      return frame1->saved_regs[regnum];	/* ... which might be zero */
+    }
+
+  /* Note that this next routine assumes that registers used in
+     frame x will be saved only in the frame that x calls and
+     frames interior to it.  This is not true on the sparc, but the
+     above macro takes care of it, so we should be all right. */
+  while (1)
+    {
+      QUIT;
+      frame1 = get_next_frame (frame);
+      if (frame1 == 0)
+	break;
+      frame = frame1;
+      FRAME_INIT_SAVED_REGS (frame1);
+      if (frame1->saved_regs[regnum])
+	addr = frame1->saved_regs[regnum];
+    }
+
+  return addr;
+}
+
+/* i960_get_saved_register ()
+
+   Find register number REGNUM relative to FRAME and put its (raw,
+   target format) contents in *RAW_BUFFER.  Set *OPTIMIZED if the
+   variable was optimized out (and thus can't be fetched).  Set *LVAL
+   to lval_memory, lval_register, or not_lval, depending on whether
+   the value was fetched from memory, from a register, or in a strange
+   and non-modifiable way (e.g. a frame pointer which was calculated
+   rather than fetched).  Set *ADDRP to the address, either in memory
+   on as a REGISTER_BYTE offset into the registers array.
+
+   Note that this implementation never sets *LVAL to not_lval.  But it
+   can be replaced by defining GET_SAVED_REGISTER and supplying your
+   own.
+
+   The argument RAW_BUFFER must point to aligned memory.  */
+
+void
+i960_get_saved_register (char *raw_buffer,
+			 int *optimized,
+			 CORE_ADDR *addrp,
+			 struct frame_info *frame,
+			 int regnum,
+			 enum lval_type *lval)
+{
+  CORE_ADDR addr;
+
+  if (!target_has_registers)
+    error ("No registers.");
+
+  /* Normal systems don't optimize out things with register numbers.  */
+  if (optimized != NULL)
+    *optimized = 0;
+  addr = i960_find_saved_register (frame, regnum);
+  if (addr != 0)
+    {
+      if (lval != NULL)
+	*lval = lval_memory;
+      if (regnum == SP_REGNUM)
+	{
+	  if (raw_buffer != NULL)
+	    {
+	      /* Put it back in target format.  */
+	      store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
+			     (LONGEST) addr);
+	    }
+	  if (addrp != NULL)
+	    *addrp = 0;
+	  return;
+	}
+      if (raw_buffer != NULL)
+	target_read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum));
+    }
+  else
+    {
+      if (lval != NULL)
+	*lval = lval_register;
+      addr = REGISTER_BYTE (regnum);
+      if (raw_buffer != NULL)
+	read_register_gen (regnum, raw_buffer);
+    }
+  if (addrp != NULL)
+    *addrp = addr;
+}
+
 /* Examine an i960 function prologue, recording the addresses at which
    registers are saved explicitly by the prologue code, and returning
    the address of the first instruction after the prologue (but not
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 7ca7fe7..4b14152 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -601,7 +601,7 @@
 
 /* We don't really want to use this, but remote.c needs to call it in order
    to figure out if Z-packets are supported or not.  Oh, well. */
-unsigned char *
+const unsigned char *
 ia64_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] =
@@ -667,10 +667,9 @@
    even really hard to compute the frame chain, but it can be
    computationally expensive.  So, instead of making life difficult
    (and slow), we pick a more convenient representation of the frame
-   chain, knowing that we'll have to make some small adjustments
-   in other places.  (E.g, note that read_fp() and write_fp() are
-   actually read_sp() and write_sp() below in ia64_gdbarch_init()
-   below.) 
+   chain, knowing that we'll have to make some small adjustments in
+   other places.  (E.g, note that read_fp() is actually read_sp() in
+   ia64_gdbarch_init() below.)
 
    Okay, so what is the frame chain exactly?  It'll be the SP value
    at the time that the function in question was entered.
@@ -2204,7 +2203,6 @@
      is all read_fp() is used for), simply use the stack pointer value
      instead.  */
   set_gdbarch_read_fp (gdbarch, generic_target_read_sp);
-  set_gdbarch_write_fp (gdbarch, generic_target_write_sp);
 
   /* Settings that should be unnecessary.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
@@ -2223,6 +2221,7 @@
 
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
   set_gdbarch_function_start_offset (gdbarch, 0);
+  set_gdbarch_frame_args_skip (gdbarch, 0);
 
   set_gdbarch_remote_translate_xfer_address (
     gdbarch, ia64_remote_translate_xfer_address);
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 0238448..400ac55 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1289,7 +1289,8 @@
   if (from_tty)
     {
       printf_filtered ("Run till exit from ");
-      print_stack_frame (selected_frame, selected_frame_level, 0);
+      print_stack_frame (selected_frame,
+			 frame_relative_level (selected_frame), 0);
     }
 
   /* If running asynchronously and the target support asynchronous
@@ -1590,7 +1591,7 @@
       print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout);
 
       /* Get the data in raw format.  */
-      if (read_relative_register_raw_bytes (i, raw_buffer))
+      if (! frame_register_read (selected_frame, i, raw_buffer))
 	{
 	  printf_filtered ("*value not available*\n");
 	  continue;
@@ -1680,7 +1681,7 @@
       if (*addr_exp >= '0' && *addr_exp <= '9')
 	regnum = atoi (addr_exp);	/* Take a number */
       if (regnum >= numregs)	/* Bad name, or bad number */
-	error ("%.*s: invalid register", end - addr_exp, addr_exp);
+	error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
 
     found:
       DO_REGISTERS_INFO (regnum, fpregs);
@@ -1865,14 +1866,14 @@
 
   c = add_com ("tty", class_run, tty_command,
 	       "Set terminal for future runs of program being debugged.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_set_cmd ("args", class_run, var_string_noescape,
 		   (char *) &inferior_args,
 		   "Set argument list to give program being debugged when it is started.\n\
 Follow this command with any number of args, to be passed to the program.",
 		   &setlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
   set_cmd_sfunc (c, notice_args_set);
   c = add_show_from_set (c, &showlist);
   set_cmd_sfunc (c, notice_args_read);
@@ -1883,17 +1884,17 @@
 With an argument VAR, prints the value of environment variable VAR to\n\
 give the program being debugged.  With no arguments, prints the entire\n\
 environment to be given to the program.", &showlist);
-  c->completer = noop_completer;
+  set_cmd_completer (c, noop_completer);
 
   add_prefix_cmd ("unset", no_class, unset_command,
-		  "Complement to certain \"set\" commands",
+		  "Complement to certain \"set\" commands.",
 		  &unsetlist, "unset ", 0, &cmdlist);
 
   c = add_cmd ("environment", class_run, unset_environment_command,
 	       "Cancel environment variable VAR for the program.\n\
 This does not affect the program until the next \"run\" command.",
 	       &unsetlist);
-  c->completer = noop_completer;
+  set_cmd_completer (c, noop_completer);
 
   c = add_cmd ("environment", class_run, set_environment_command,
 	       "Set environment variable value to give the program.\n\
@@ -1901,7 +1902,7 @@
 VALUES of environment variables are uninterpreted strings.\n\
 This does not affect the program until the next \"run\" command.",
 	       &setlist);
-  c->completer = noop_completer;
+  set_cmd_completer (c, noop_completer);
 
   c = add_com ("path", class_files, path_command,
 	       "Add directory DIR(s) to beginning of search path for object files.\n\
@@ -1909,7 +1910,7 @@
 This path is equivalent to the $PATH shell variable.  It is a list of\n\
 directories, separated by colons.  These directories are searched to find\n\
 fully linked executable files and separately compiled object files as needed.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_cmd ("paths", no_class, path_info,
 	       "Current search path for finding object files.\n\
@@ -1918,7 +1919,7 @@
 directories, separated by colons.  These directories are searched to find\n\
 fully linked executable files and separately compiled object files as needed.",
 	       &showlist);
-  c->completer = noop_completer;
+  set_cmd_completer (c, noop_completer);
 
   add_com ("attach", class_run, attach_command,
 	   "Attach to a process or file outside of GDB.\n\
@@ -1974,14 +1975,14 @@
 	       "Execute until the program reaches a source line greater than the current\n\
 or a specified line or address or function (same args as break command).\n\
 Execution will also stop upon exit from the current stack frame.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
   add_com_alias ("u", "until", class_run, 1);
 
   c = add_com ("jump", class_run, jump_command,
 	       "Continue program being debugged at specified line or address.\n\
 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
 for an address to start at.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   if (xdb_commands)
     {
@@ -1992,7 +1993,7 @@
 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
 expression for an address to start at.\n\
 This command is a combination of tbreak and jump.");
-      c->completer = location_completer;
+      set_cmd_completer (c, location_completer);
     }
 
   if (xdb_commands)
@@ -2013,7 +2014,7 @@
 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
 To cancel previous arguments and run with no arguments,\n\
 use \"set args\" without arguments.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
   add_com_alias ("r", "run", class_run, 1);
   if (xdb_commands)
     add_com ("R", class_run, run_no_args_command,
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 93c8d9b..2c05f35 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -23,6 +23,8 @@
 #if !defined (INFERIOR_H)
 #define INFERIOR_H 1
 
+struct gdbarch;
+
 /* For bpstat.  */
 #include "breakpoint.h"
 
@@ -177,10 +179,6 @@
 
 extern CORE_ADDR generic_target_read_fp (void);
 
-extern void write_fp (CORE_ADDR);
-
-extern void generic_target_write_fp (CORE_ADDR);
-
 extern CORE_ADDR unsigned_pointer_to_address (struct type *type, void *buf);
 
 extern void unsigned_address_to_pointer (struct type *type, void *buf,
@@ -405,29 +403,6 @@
 
 extern int attach_flag;
 
-/* Sigtramp is a routine that the kernel calls (which then calls the
-   signal handler).  On most machines it is a library routine that
-   is linked into the executable.
-
-   This macro, given a program counter value and the name of the
-   function in which that PC resides (which can be null if the
-   name is not known), returns nonzero if the PC and name show
-   that we are in sigtramp.
-
-   On most machines just see if the name is sigtramp (and if we have
-   no name, assume we are not in sigtramp).  */
-#if !defined (IN_SIGTRAMP)
-#if defined (SIGTRAMP_START)
-#define IN_SIGTRAMP(pc, name) \
-       ((pc) >= SIGTRAMP_START(pc)   \
-        && (pc) < SIGTRAMP_END(pc) \
-        )
-#else
-#define IN_SIGTRAMP(pc, name) \
-       (name && STREQ ("_sigtramp", name))
-#endif
-#endif
-
 /* Possible values for CALL_DUMMY_LOCATION.  */
 #define ON_STACK 1
 #define BEFORE_TEXT_END 2
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 66671f7..526acdf 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -171,7 +171,7 @@
 #define	OOPSY(what)	\
   if (result == -1)	\
     fprintf_unfiltered(gdb_stderr, "[%s failed in terminal_inferior: %s]\n", \
-	    what, strerror (errno))
+	    what, safe_strerror (errno))
 
 static void terminal_ours_1 (int);
 
@@ -374,7 +374,7 @@
 	     such situations as well.  */
 	  if (result == -1)
 	    fprintf_unfiltered (gdb_stderr, "[tcsetpgrp failed in terminal_ours: %s]\n",
-				strerror (errno));
+				safe_strerror (errno));
 #endif
 #endif /* termios */
 
@@ -594,7 +594,8 @@
       if (selected_frame == NULL)
 	fputs_filtered ("No selected stack frame.\n", gdb_stdout);
       else
-	print_stack_frame (selected_frame, selected_frame_level, 1);
+	print_stack_frame (selected_frame,
+			   frame_relative_level (selected_frame), 1);
     }
 }
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 6ae8f7c..e9fea2a 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -749,7 +749,15 @@
 static void
 set_schedlock_func (char *args, int from_tty, struct cmd_list_element *c)
 {
-  if (c->type == set_cmd)
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+  if (cmd_type (c) == set_cmd)
     if (!target_can_lock_scheduler)
       {
 	scheduler_mode = schedlock_off;
@@ -2632,8 +2640,8 @@
     ecs->update_step_sp = 1;
 
     /* Did we just take a signal?  */
-    if (IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
-	&& !IN_SIGTRAMP (prev_pc, prev_func_name)
+    if (PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+	&& !PC_IN_SIGTRAMP (prev_pc, prev_func_name)
 	&& INNER_THAN (read_sp (), step_sp))
       {
 	/* We've just taken a signal; go until we are back to
@@ -2744,7 +2752,7 @@
 	  {
 	    /* We're doing a "next".  */
 
-	    if (IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+	    if (PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
 		&& INNER_THAN (step_frame_address, read_sp()))
 	      /* We stepped out of a signal handler, and into its
                  calling trampoline.  This is misdetected as a
@@ -2953,8 +2961,8 @@
 check_sigtramp2 (struct execution_control_state *ecs)
 {
   if (trap_expected
-      && IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
-      && !IN_SIGTRAMP (prev_pc, prev_func_name)
+      && PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+      && !PC_IN_SIGTRAMP (prev_pc, prev_func_name)
       && INNER_THAN (read_sp (), step_sp))
     {
       /* What has happened here is that we have just stepped the
@@ -3414,13 +3422,11 @@
 
   target_terminal_ours ();
 
-  /* Look up the hook_stop and run it if it exists.  */
-
-  if (stop_command && stop_command->hook_pre)
-    {
-      catch_errors (hook_stop_stub, stop_command->hook_pre,
-		    "Error while running hook_stop:\n", RETURN_MASK_ALL);
-    }
+  /* Look up the hook_stop and run it (CLI internally handles problem
+     of stop_command's pre-hook not existing).  */
+  if (stop_command)
+    catch_errors (hook_stop_stub, stop_command,
+		  "Error while running hook_stop:\n", RETURN_MASK_ALL);
 
   if (!target_has_stack)
     {
@@ -3435,7 +3441,7 @@
 
   if (!stop_stack_dummy)
     {
-      select_frame (get_current_frame (), 0);
+      select_frame (get_current_frame ());
 
       /* Print current location without a level number, if
          we have changed functions or hit a breakpoint.
@@ -3511,7 +3517,7 @@
          Can't rely on restore_inferior_status because that only gets
          called if we don't stop in the called function.  */
       stop_pc = read_pc ();
-      select_frame (get_current_frame (), 0);
+      select_frame (get_current_frame ());
     }
 
 done:
@@ -3521,7 +3527,7 @@
 static int
 hook_stop_stub (void *cmd)
 {
-  execute_user_command ((struct cmd_list_element *) cmd, 0);
+  execute_cmd_pre_hook ((struct cmd_list_element *) cmd);
   return (0);
 }
 
@@ -4018,7 +4024,7 @@
       return 0;
     }
 
-  select_frame (frame, fr->level);
+  select_frame (frame);
 
   return (1);
 }
@@ -4073,7 +4079,7 @@
 	   frame.  */
 
 
-	select_frame (get_current_frame (), 0);
+	select_frame (get_current_frame ());
 
     }
 
diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
index 1b80ab4..495bf3e 100644
--- a/gdb/jv-exp.y
+++ b/gdb/jv-exp.y
@@ -862,6 +862,8 @@
   
  retry:
 
+  prev_lexptr = lexptr;
+
   tokstart = lexptr;
   /* See if it is a special token of length 3.  */
   for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
@@ -1207,6 +1209,9 @@
 yyerror (msg)
      char *msg;
 {
+  if (prev_lexptr)
+    lexptr = prev_lexptr;
+
   error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }
 
diff --git a/gdb/kod.c b/gdb/kod.c
index 2641c38..8f565bb 100644
--- a/gdb/kod.c
+++ b/gdb/kod.c
@@ -132,7 +132,16 @@
 {
   char *p;
 
-  if (command->type != set_cmd)
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+
+  if (cmd_type (command) != set_cmd)
     return;
 
   /* If we had already had an open OS, close it.  */
@@ -145,7 +154,6 @@
       delete_cmd (old_operating_system, &infolist);
       xfree (old_operating_system);
     }
-  old_operating_system = xstrdup (operating_system);
 
   if (! operating_system || ! *operating_system)
     {
@@ -160,6 +168,8 @@
     {
       char *kodlib;
 
+      old_operating_system = xstrdup (operating_system);
+
       load_kod_library (operating_system);
 
       kodlib = (*gdb_kod_open) (gdb_kod_display, gdb_kod_query);
diff --git a/gdb/language.c b/gdb/language.c
index 4c4036b..0b37a6f 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1559,13 +1559,13 @@
   set_cmd_cfunc (show, show_language_command);
 
   add_prefix_cmd ("check", no_class, set_check,
-		  "Set the status of the type/range checker",
+		  "Set the status of the type/range checker.",
 		  &setchecklist, "set check ", 0, &setlist);
   add_alias_cmd ("c", "check", no_class, 1, &setlist);
   add_alias_cmd ("ch", "check", no_class, 1, &setlist);
 
   add_prefix_cmd ("check", no_class, show_check,
-		  "Show the status of the type/range checker",
+		  "Show the status of the type/range checker.",
 		  &showchecklist, "show check ", 0, &showlist);
   add_alias_cmd ("c", "check", no_class, 1, &showlist);
   add_alias_cmd ("ch", "check", no_class, 1, &showlist);
diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c
index e39e787..cb5b19f 100644
--- a/gdb/lin-lwp.c
+++ b/gdb/lin-lwp.c
@@ -376,7 +376,7 @@
 
       if (ptrace (PTRACE_ATTACH, GET_LWP (ptid), 0, 0) < 0)
 	error ("Can't attach %s: %s", target_pid_to_str (ptid),
-	       strerror (errno));
+	       safe_strerror (errno));
 
       pid = waitpid (GET_LWP (ptid), &status, 0);
       if (pid == -1 && errno == ECHILD)
@@ -454,7 +454,7 @@
       if (ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0,
 		  WSTOPSIG (lp->status)) < 0)
 	error ("Can't continue %s: %s", target_pid_to_str (lp->ptid),
-	       strerror (errno));
+	       safe_strerror (errno));
 
       lp->stopped = 0;
       lp->signalled = 0;
@@ -471,7 +471,7 @@
       if (ptrace (PTRACE_DETACH, GET_LWP (lp->ptid), 0,
 		  WSTOPSIG (lp->status)) < 0)
 	error ("Can't detach %s: %s", target_pid_to_str (lp->ptid),
-	       strerror (errno));
+	       safe_strerror (errno));
 
       delete_lwp (lp->ptid);
     }
@@ -969,11 +969,11 @@
       clear_sigio_trap ();
       clear_sigint_trap ();
     }
-  while (pid == -1 && errno == EINTR);
+  while (pid == -1 && save_errno == EINTR);
 
   if (pid == -1)
     {
-      warning ("Child process unexpectedly missing: %s", strerror (errno));
+      warning ("Child process unexpectedly missing: %s", safe_strerror (errno));
 
       /* Claim it exited with unknown signal.  */
       ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
diff --git a/gdb/linespec.c b/gdb/linespec.c
index ca9d01d..cbfafcf 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1187,7 +1187,7 @@
 
   sym = lookup_symbol (copy,
 		       (s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
-			: get_selected_block ()),
+			: get_selected_block (0)),
 		       VAR_NAMESPACE, 0, &sym_symtab);
 
 symbol_found:			/* We also jump here from inside the C++ class/namespace 
@@ -1213,7 +1213,7 @@
 	    {
 	      struct blockvector *bv = BLOCKVECTOR (sym_symtab);
 	      struct block *b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-	      if (lookup_block_symbol (b, copy, VAR_NAMESPACE) != NULL)
+	      if (lookup_block_symbol (b, copy, NULL, VAR_NAMESPACE) != NULL)
 		build_canonical_line_spec (values.sals, copy, canonical);
 	    }
 	  return values;
diff --git a/gdb/linux-proc.c b/gdb/linux-proc.c
index d6f88d3..aa3b571 100644
--- a/gdb/linux-proc.c
+++ b/gdb/linux-proc.c
@@ -77,7 +77,14 @@
 
   if (ret > 0 && ret != EOF && *inode != 0)
     {
-      ret += fscanf (mapfile, "%s\n", filename);
+      /* Eat everything up to EOL for the filename.  This will prevent
+       weird filenames (such as one with embedded whitespace) from
+       confusing this code.  It also makes this code more robust
+       in respect to annotations the kernel may add after the
+       filename.
+
+       Note the filename is used for informational purposes only.  */
+      ret += fscanf (mapfile, "%[^\n]\n", filename);
     }
   else
     {
@@ -160,6 +167,9 @@
 {
   gdb_gregset_t gregs;
   gdb_fpregset_t fpregs;
+#ifdef FILL_FPXREGSET
+  gdb_fpxregset_t fpxregs;
+#endif
   unsigned long merged_pid = ptid_get_tid (ptid) << 16 | ptid_get_pid (ptid);
 
   fill_gregset (&gregs, -1);
@@ -176,6 +186,14 @@
 					      note_size, 
 					      &fpregs, 
 					      sizeof (fpregs));
+#ifdef FILL_FPXREGSET
+  fill_fpxregset (&fpxregs, -1);
+  note_data = (char *) elfcore_write_prxfpreg (obfd, 
+					       note_data, 
+					       note_size, 
+					       &fpxregs, 
+					       sizeof (fpxregs));
+#endif
   return note_data;
 }
 
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index eaaad5a..772c6b7 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -821,6 +821,8 @@
 
  retry:
 
+  prev_lexptr = lexptr;
+
   tokstart = lexptr;
 
 
@@ -1090,5 +1092,8 @@
 yyerror (msg)
      char *msg;
 {
+  if (prev_lexptr)
+    lexptr = prev_lexptr;
+
   error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }
diff --git a/gdb/m3-nat.c b/gdb/m3-nat.c
index 320cbf8..c29101b 100644
--- a/gdb/m3-nat.c
+++ b/gdb/m3-nat.c
@@ -1101,7 +1101,7 @@
       stop_pc = read_pc ();
       flush_cached_frames ();
 
-      select_frame (get_current_frame (), 0);
+      select_frame (get_current_frame ());
     }
 
   return KERN_SUCCESS;
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 630accf..6d00ab1 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -270,7 +270,7 @@
   return m68hc11_register_names[reg_nr];
 }
 
-static unsigned char *
+static const unsigned char *
 m68hc11_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] = {0x0};
@@ -1087,7 +1087,6 @@
   set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
   set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
-  set_gdbarch_write_fp (gdbarch, generic_target_write_fp);
   set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
 
diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c
index 10f4a19..82a6124 100644
--- a/gdb/m68klinux-nat.c
+++ b/gdb/m68klinux-nat.c
@@ -383,7 +383,7 @@
   /* Fill in the floating-point control registers.  */
   for (i = FPC_REGNUM; i <= FPI_REGNUM; i++)
     if (regno == -1 || regno == i)
-      regcache_collect (regno, fpregsetp->fpcntl[regno - FPC_REGNUM]);
+      regcache_collect (regno, (char *) &fpregsetp->fpcntl[regno - FPC_REGNUM]);
 }
 
 #ifdef HAVE_PTRACE_GETREGS
diff --git a/gdb/maint.c b/gdb/maint.c
index 0d2be09..ddaa390 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -36,6 +36,8 @@
 #include "objfiles.h"
 #include "value.h"
 
+#include "cli/cli-decode.h"
+
 extern void _initialize_maint_cmds (void);
 
 static void maintenance_command (char *, int);
@@ -289,9 +291,9 @@
 }
 
 static void
-print_section_info (const char *name, flagword flags, 
-		    CORE_ADDR addr, CORE_ADDR endaddr, 
-		    unsigned long filepos)
+maint_print_section_info (const char *name, flagword flags, 
+			  CORE_ADDR addr, CORE_ADDR endaddr, 
+			  unsigned long filepos)
 {
   /* FIXME-32x64: Need print_address_numeric with field width.  */
   printf_filtered ("    0x%s", paddr (addr));
@@ -319,7 +321,7 @@
 
       addr = bfd_section_vma (abfd, asect);
       endaddr = addr + bfd_section_size (abfd, asect);
-      print_section_info (name, flags, addr, endaddr, asect->filepos);
+      maint_print_section_info (name, flags, addr, endaddr, asect->filepos);
     }
 }
 
@@ -335,7 +337,7 @@
       || match_substring (string, name)
       || match_bfd_flags (string, flags))
     {
-      print_section_info (name, flags, asect->addr, asect->endaddr, 
+      maint_print_section_info (name, flags, asect->addr, asect->endaddr, 
 			  asect->the_bfd_section->filepos);
     }
 }
diff --git a/gdb/mcore-tdep.c b/gdb/mcore-tdep.c
index 184f7b5..0e6ffc8 100644
--- a/gdb/mcore-tdep.c
+++ b/gdb/mcore-tdep.c
@@ -62,7 +62,7 @@
 
 CORE_ADDR mcore_frame_chain (struct frame_info *fi);
 
-unsigned char *mcore_breakpoint_from_pc (CORE_ADDR * bp_addr, int *bp_size);
+const unsigned char *mcore_breakpoint_from_pc (CORE_ADDR * bp_addr, int *bp_size);
 
 int mcore_use_struct_convention (int gcc_p, struct type *type);
 
@@ -182,7 +182,7 @@
    instructions are 16 bits, this is all we need, regardless of
    address. bpkt = 0x0000 */
 
-unsigned char *
+const unsigned char *
 mcore_breakpoint_from_pc (CORE_ADDR * bp_addr, int *bp_size)
 {
   static char breakpoint[] =
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1bc9eef..c974c9e 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -143,7 +143,8 @@
 		   || (sc) == scPData \
 		   || (sc) == scXData)
 #define SC_IS_COMMON(sc) ((sc) == scCommon || (sc) == scSCommon)
-#define SC_IS_BSS(sc) ((sc) == scBss || (sc) == scSBss)
+#define SC_IS_BSS(sc) ((sc) == scBss)
+#define SC_IS_SBSS(sc) ((sc) == scSBss)
 #define SC_IS_UNDEF(sc) ((sc) == scUndefined || (sc) == scSUndefined)
 
 /* Various complaints about symbol reading that don't abort the process */
@@ -2425,26 +2426,72 @@
 	      ms_type = mst_bss;
 	      svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
 	    }
+          else if (SC_IS_SBSS (ext_in->asym.sc))
+            {
+              ms_type = mst_bss;
+              svalue += ANOFFSET (objfile->section_offsets, 
+                                  get_section_index (objfile, ".sbss"));
+            }
 	  else
 	    ms_type = mst_abs;
 	  break;
 	case stLabel:
 	  /* Label */
+
+          /* On certain platforms, some extra label symbols can be
+             generated by the linker. One possible usage for this kind
+             of symbols is to represent the address of the begining of a
+             given section. For instance, on Tru64 5.1, the address of
+             the _ftext label is the start address of the .text section.
+
+             The storage class of these symbols is usually directly
+             related to the section to which the symbol refers. For
+             instance, on Tru64 5.1, the storage class for the _fdata
+             label is scData, refering to the .data section.
+
+             It is actually possible that the section associated to the
+             storage class of the label does not exist. On True64 5.1
+             for instance, the libm.so shared library does not contain
+             any .data section, although it contains a _fpdata label
+             which storage class is scData... Since these symbols are
+             usually useless for the debugger user anyway, we just
+             discard these symbols.
+           */
+          
 	  if (SC_IS_TEXT (ext_in->asym.sc))
 	    {
+              if (objfile->sect_index_text == -1)
+                continue;
+                
 	      ms_type = mst_file_text;
 	      svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 	    }
 	  else if (SC_IS_DATA (ext_in->asym.sc))
 	    {
+              if (objfile->sect_index_data == -1)
+                continue;
+
 	      ms_type = mst_file_data;
 	      svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
 	    }
 	  else if (SC_IS_BSS (ext_in->asym.sc))
 	    {
+              if (objfile->sect_index_bss == -1)
+                continue;
+
 	      ms_type = mst_file_bss;
 	      svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
 	    }
+          else if (SC_IS_SBSS (ext_in->asym.sc))
+            {
+              const int sbss_sect_index = get_section_index (objfile, ".sbss");
+
+              if (sbss_sect_index == -1)
+                continue;
+
+              ms_type = mst_file_bss;
+              svalue += ANOFFSET (objfile->section_offsets, sbss_sect_index);
+            }
 	  else
 	    ms_type = mst_abs;
 	  break;
diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index a67e2a5..9cf638e 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -1,6 +1,8 @@
 /* Simulate breakpoints by patching locations in the target system, for GDB.
-   Copyright 1990, 1991, 1992, 1993, 1995, 1997, 1998, 1999, 2000
-   Free Software Foundation, Inc.
+
+   Copyright 1990, 1991, 1992, 1993, 1995, 1997, 1998, 1999, 2000,
+   2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Support.  Written by John Gilmore.
 
    This file is part of GDB.
@@ -40,7 +42,7 @@
    and optionally adjust the pc to point to the correct memory location
    for inserting the breakpoint.  */
 
-unsigned char *
+const unsigned char *
 memory_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   /* {BIG_,LITTLE_}BREAKPOINT is the sequence of bytes we insert for a
@@ -86,7 +88,7 @@
 default_memory_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
   int val;
-  unsigned char *bp;
+  const unsigned char *bp;
   int bplen;
 
   /* Determine appropriate breakpoint contents and size for this address.  */
@@ -108,7 +110,7 @@
 int
 default_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
-  unsigned char *bp;
+  const unsigned char *bp;
   int bplen;
 
   /* Determine appropriate breakpoint contents and size for this address.  */
diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog
index 7b71e8a..f2cc44a 100644
--- a/gdb/mi/ChangeLog
+++ b/gdb/mi/ChangeLog
@@ -1,3 +1,54 @@
+2002-04-14  Andrew Cagney  <ac131313@redhat.com>
+
+	* mi-main.c (mi_cmd_exec_return): 
+
+2002-04-09  Andrew Cagney  <ac131313@redhat.com>
+
+	* mi-main.c (register_changed_p): Use frame_register_read instead
+	of read_relative_register_raw_bytes.
+	(get_register): Delete out-of-date comment.
+
+2002-04-07  Elena Zannoni  <ezannoni@redhat.com>
+
+        * mi-cmd-disas.c: Run through indent.
+
+2002-04-07  Elena Zannoni  <ezannoni@redhat.com>
+
+        * mi-cmd-disas.c (dump_insns): New function.
+        (do_mixed_source_and_assembly): New function.
+        (do_assembly_only): New function.
+        (do_disassembly): New function.
+        (mi_cmd_disassemble): Rewrite using smaller, more modular
+        functions.
+
+2002-04-05  Jim Blandy  <jimb@redhat.com>
+
+	* mi-cmd-stack.c (list_args_or_locals): Pass new arg to
+	get_frame_block.  (See entry in gdb/ChangeLog.)
+
+2002-04-05  Elena Zannoni  <ezannoni@redhat.com>
+
+	* mi-cmd-disas.c (mi_cmd_disassemble): Use TARGET_PRINT_INSN
+	instead of tm_print_insn.
+	Update copyright year.
+
+2002-04-04  Daniel Jacobowitz  <drow@mvista.com>
+
+	* mi-cmd-disas.c (mi_cmd_disassemble): Skip end-of-function
+	markers in the line table.
+
+2002-03-15  Andrew Cagney  <ac131313@redhat.com>
+
+	* mi-main.c (XMALLOC): Delete macro.
+	* mi-out.c (XMALLOC): Ditto.
+	* mi-parse.c (XMALLOC): Ditto.
+	* mi-console.c (XMALLOC): Ditto.
+	* mi-cmd-var.c (XMALLOC): Ditto.
+	* mi-cmd-break.c (XMALLOC): Ditto.
+	
+	* mi/mi-cmd-var.c, mi/mi-console.c, mi/mi-out.c: Update copyright
+	* mi/mi-parse.c: Ditto.
+
 2002-02-24  Andrew Cagney  <ac131313@redhat.com>
 
 	From wiz at danbala:
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 5061392..5d15aa9 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -29,11 +29,6 @@
 #include "gdb-events.h"
 #include "gdb.h"
 
-/* Convenience macro for allocting typesafe memory. */
-
-#undef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-
 enum
   {
     FROM_TTY = 0
diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c
index afaf31c..70054c6 100644
--- a/gdb/mi/mi-cmd-disas.c
+++ b/gdb/mi/mi-cmd-disas.c
@@ -1,5 +1,5 @@
 /* MI Command Set - disassemble commands.
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions (a Red Hat company).
 
    This file is part of GDB.
@@ -26,10 +26,6 @@
 #include "mi-getopt.h"
 #include "ui-out.h"
 
-static int gdb_dis_asm_read_memory (bfd_vma memaddr, bfd_byte * myaddr, unsigned int len,
-				    disassemble_info * info);
-static int compare_lines (const PTR mle1p, const PTR mle2p);
-
 /* Disassemble functions. FIXME: these do not really belong here. We
    should get rid of all the duplicate code in gdb that does the same
    thing: disassemble_command() and the gdbtk variation. */
@@ -40,11 +36,11 @@
    reordering in this function.  */
 
 struct dis_line_entry
-  {
-    int line;
-    CORE_ADDR start_pc;
-    CORE_ADDR end_pc;
-  };
+{
+  int line;
+  CORE_ADDR start_pc;
+  CORE_ADDR end_pc;
+};
 
 /* This variable determines where memory used for disassembly is read from. */
 int gdb_disassemble_from_exec = -1;
@@ -86,6 +82,290 @@
   return mle1->start_pc - mle2->start_pc;
 }
 
+static int
+dump_insns (disassemble_info * di, CORE_ADDR low, CORE_ADDR high,
+	    int how_many, struct ui_stream *stb)
+{
+  int num_displayed = 0;
+  CORE_ADDR pc;
+
+  /* parts of the symbolic representation of the address */
+  int unmapped;
+  char *filename = NULL;
+  char *name = NULL;
+  int offset;
+  int line;
+
+  for (pc = low; pc < high;)
+    {
+      QUIT;
+      if (how_many >= 0)
+	{
+	  if (num_displayed >= how_many)
+	    break;
+	  else
+	    num_displayed++;
+	}
+      ui_out_tuple_begin (uiout, NULL);
+      ui_out_field_core_addr (uiout, "address", pc);
+
+      if (!build_address_symbolic (pc, 0, &name, &offset, &filename,
+				   &line, &unmapped))
+	{
+	  /* We don't care now about line, filename and
+	     unmapped. But we might in the future. */
+	  ui_out_field_string (uiout, "func-name", name);
+	  ui_out_field_int (uiout, "offset", offset);
+	}
+      if (filename != NULL)
+	xfree (filename);
+      if (name != NULL)
+	xfree (name);
+
+      ui_file_rewind (stb->stream);
+      pc += TARGET_PRINT_INSN (pc, di);
+      ui_out_field_stream (uiout, "inst", stb);
+      ui_file_rewind (stb->stream);
+      ui_out_tuple_end (uiout);
+    }
+  return num_displayed;
+}
+
+/* The idea here is to present a source-O-centric view of a
+   function to the user.  This means that things are presented
+   in source order, with (possibly) out of order assembly
+   immediately following.  */
+static void
+do_mixed_source_and_assembly (struct disassemble_info *di, int nlines,
+			      struct linetable_entry *le,
+			      CORE_ADDR low, CORE_ADDR high,
+			      struct symtab *symtab,
+			      int how_many, struct ui_stream *stb)
+{
+  int newlines = 0;
+  struct dis_line_entry *mle;
+  struct symtab_and_line sal;
+  int i;
+  int out_of_order = 0;
+  int next_line = 0;
+  CORE_ADDR pc;
+  int num_displayed = 0;
+
+  mle = (struct dis_line_entry *) alloca (nlines
+					  * sizeof (struct dis_line_entry));
+
+  /* Copy linetable entries for this function into our data
+     structure, creating end_pc's and setting out_of_order as
+     appropriate.  */
+
+  /* First, skip all the preceding functions.  */
+
+  for (i = 0; i < nlines - 1 && le[i].pc < low; i++);
+
+  /* Now, copy all entries before the end of this function.  */
+
+  for (; i < nlines - 1 && le[i].pc < high; i++)
+    {
+      if (le[i].line == le[i + 1].line && le[i].pc == le[i + 1].pc)
+	continue;		/* Ignore duplicates */
+
+      /* Skip any end-of-function markers.  */
+      if (le[i].line == 0)
+	continue;
+
+      mle[newlines].line = le[i].line;
+      if (le[i].line > le[i + 1].line)
+	out_of_order = 1;
+      mle[newlines].start_pc = le[i].pc;
+      mle[newlines].end_pc = le[i + 1].pc;
+      newlines++;
+    }
+
+  /* If we're on the last line, and it's part of the function,
+     then we need to get the end pc in a special way.  */
+
+  if (i == nlines - 1 && le[i].pc < high)
+    {
+      mle[newlines].line = le[i].line;
+      mle[newlines].start_pc = le[i].pc;
+      sal = find_pc_line (le[i].pc, 0);
+      mle[newlines].end_pc = sal.end;
+      newlines++;
+    }
+
+  /* Now, sort mle by line #s (and, then by addresses within
+     lines). */
+
+  if (out_of_order)
+    qsort (mle, newlines, sizeof (struct dis_line_entry), compare_lines);
+
+  /* Now, for each line entry, emit the specified lines (unless
+     they have been emitted before), followed by the assembly code
+     for that line.  */
+
+  ui_out_list_begin (uiout, "asm_insns");
+
+  for (i = 0; i < newlines; i++)
+    {
+      int close_list = 1;
+      /* Print out everything from next_line to the current line.  */
+      if (mle[i].line >= next_line)
+	{
+	  if (next_line != 0)
+	    {
+	      /* Just one line to print. */
+	      if (next_line == mle[i].line)
+		{
+		  ui_out_tuple_begin (uiout, "src_and_asm_line");
+		  print_source_lines (symtab, next_line, mle[i].line + 1, 0);
+		}
+	      else
+		{
+		  /* Several source lines w/o asm instructions associated. */
+		  for (; next_line < mle[i].line; next_line++)
+		    {
+		      ui_out_tuple_begin (uiout, "src_and_asm_line");
+		      print_source_lines (symtab, next_line, next_line + 1,
+					  0);
+		      ui_out_list_begin (uiout, "line_asm_insn");
+		      ui_out_list_end (uiout);
+		      ui_out_tuple_end (uiout);
+		    }
+		  /* Print the last line and leave list open for
+		     asm instructions to be added. */
+		  ui_out_tuple_begin (uiout, "src_and_asm_line");
+		  print_source_lines (symtab, next_line, mle[i].line + 1, 0);
+		}
+	    }
+	  else
+	    {
+	      ui_out_tuple_begin (uiout, "src_and_asm_line");
+	      print_source_lines (symtab, mle[i].line, mle[i].line + 1, 0);
+	    }
+
+	  next_line = mle[i].line + 1;
+	  ui_out_list_begin (uiout, "line_asm_insn");
+	  /* Don't close the list if the lines are not in order. */
+	  if (i < (newlines - 1) && mle[i + 1].line <= mle[i].line)
+	    close_list = 0;
+	}
+
+      num_displayed += dump_insns (di, mle[i].start_pc, mle[i].end_pc,
+				   how_many, stb);
+      if (close_list)
+	{
+	  ui_out_list_end (uiout);
+	  ui_out_tuple_end (uiout);
+	  close_list = 0;
+	}
+      if (how_many >= 0)
+	if (num_displayed >= how_many)
+	  break;
+    }
+  ui_out_list_end (uiout);
+}
+
+
+static void
+do_assembly_only (disassemble_info * di, CORE_ADDR low,
+		  CORE_ADDR high, int how_many, struct ui_stream *stb)
+{
+  int num_displayed = 0;
+
+  ui_out_list_begin (uiout, "asm_insns");
+
+  num_displayed = dump_insns (di, low, high, how_many, stb);
+
+  ui_out_list_end (uiout);
+}
+
+enum mi_cmd_result
+do_disassembly (char *file_string,
+		int line_num,
+		int mixed_source_and_assembly,
+		int how_many, CORE_ADDR low, CORE_ADDR high)
+{
+  static disassemble_info di;
+  static int di_initialized;
+  /* To collect the instruction outputted from opcodes. */
+  static struct ui_stream *stb = NULL;
+  struct symtab *symtab = NULL;
+  struct linetable_entry *le = NULL;
+  int nlines = -1;
+
+  if (!di_initialized)
+    {
+      /* We don't add a cleanup for this, because the allocation of
+         the stream is done once only for each gdb run, and we need to
+         keep it around until the end. Hopefully there won't be any
+         errors in the init code below, that make this function bail
+         out. */
+      stb = ui_out_stream_new (uiout);
+      INIT_DISASSEMBLE_INFO_NO_ARCH (di, stb->stream,
+				     (fprintf_ftype) fprintf_unfiltered);
+      di.flavour = bfd_target_unknown_flavour;
+      di.memory_error_func = dis_asm_memory_error;
+      di.print_address_func = dis_asm_print_address;
+      di_initialized = 1;
+    }
+
+  di.mach = TARGET_PRINT_INSN_INFO->mach;
+  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+    di.endian = BFD_ENDIAN_BIG;
+  else
+    di.endian = BFD_ENDIAN_LITTLE;
+
+  /* If gdb_disassemble_from_exec == -1, then we use the following heuristic to
+     determine whether or not to do disassembly from target memory or from the
+     exec file:
+
+     If we're debugging a local process, read target memory, instead of the
+     exec file.  This makes disassembly of functions in shared libs work
+     correctly.  Also, read target memory if we are debugging native threads.
+
+     Else, we're debugging a remote process, and should disassemble from the
+     exec file for speed.  However, this is no good if the target modifies its
+     code (for relocation, or whatever).  */
+
+  if (gdb_disassemble_from_exec == -1)
+    {
+      if (strcmp (target_shortname, "child") == 0
+	  || strcmp (target_shortname, "procfs") == 0
+	  || strcmp (target_shortname, "vxprocess") == 0
+	  || strstr (target_shortname, "-threads") != NULL)
+	gdb_disassemble_from_exec = 0;	/* It's a child process, read inferior mem */
+      else
+	gdb_disassemble_from_exec = 1;	/* It's remote, read the exec file */
+    }
+
+  if (gdb_disassemble_from_exec)
+    di.read_memory_func = gdb_dis_asm_read_memory;
+  else
+    di.read_memory_func = dis_asm_read_memory;
+
+  /* Assume symtab is valid for whole PC range */
+  symtab = find_pc_symtab (low);
+
+  if (symtab != NULL && symtab->linetable != NULL)
+    {
+      /* Convert the linetable to a bunch of my_line_entry's.  */
+      le = symtab->linetable->item;
+      nlines = symtab->linetable->nitems;
+    }
+
+  if (!mixed_source_and_assembly || nlines <= 0
+      || symtab == NULL || symtab->linetable == NULL)
+    do_assembly_only (&di, low, high, how_many, stb);
+
+  else if (mixed_source_and_assembly)
+    do_mixed_source_and_assembly (&di, nlines, le, low,
+				  high, symtab, how_many, stb);
+
+  gdb_flush (gdb_stdout);
+
+  return MI_CMD_DONE;
+}
+
 /* The arguments to be passed on the command line and parsed here are:
 
    either:
@@ -106,30 +386,15 @@
 
    MODE: 0 or 1 for disassembly only, or mixed source and disassembly,
    respectively. */
-
 enum mi_cmd_result
 mi_cmd_disassemble (char *command, char **argv, int argc)
 {
-  CORE_ADDR pc;
+  enum mi_cmd_result retval;
   CORE_ADDR start;
 
   int mixed_source_and_assembly;
-  int num_displayed;
-  static disassemble_info di;
-  static int di_initialized;
-
   struct symtab *s;
 
-  /* To collect the instruction outputted from opcodes. */
-  static struct ui_stream *stb = NULL;
-
-  /* parts of the symbolic representation of the address */
-  int line;
-  int offset;
-  int unmapped;
-  char *filename = NULL;
-  char *name = NULL;
-
   /* Which options have we processed ... */
   int file_seen = 0;
   int line_seen = 0;
@@ -148,11 +413,10 @@
   int optind = 0;
   char *optarg;
   enum opt
-    {
-      FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT
-    };
-  static struct mi_opt opts[] =
   {
+    FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT
+  };
+  static struct mi_opt opts[] = {
     {"f", FILE_OPT, 1},
     {"l", LINE_OPT, 1},
     {"n", NUM_OPT, 1},
@@ -201,16 +465,19 @@
 
   if (!((line_seen && file_seen && num_seen && !start_seen && !end_seen)
 	|| (line_seen && file_seen && !num_seen && !start_seen && !end_seen)
-      || (!line_seen && !file_seen && !num_seen && start_seen && end_seen)))
-    error ("mi_cmd_disassemble: Usage: ( [-f filename -l linenum [-n howmany]] | [-s startaddr -e endaddr]) [--] mixed_mode.");
+	|| (!line_seen && !file_seen && !num_seen && start_seen && end_seen)))
+    error
+      ("mi_cmd_disassemble: Usage: ( [-f filename -l linenum [-n howmany]] | [-s startaddr -e endaddr]) [--] mixed_mode.");
 
   if (argc != 1)
-    error ("mi_cmd_disassemble: Usage: [-f filename -l linenum [-n howmany]] [-s startaddr -e endaddr] [--] mixed_mode.");
+    error
+      ("mi_cmd_disassemble: Usage: [-f filename -l linenum [-n howmany]] [-s startaddr -e endaddr] [--] mixed_mode.");
 
   mixed_source_and_assembly = atoi (argv[0]);
   if ((mixed_source_and_assembly != 0) && (mixed_source_and_assembly != 1))
     error ("mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.");
 
+
   /* We must get the function beginning and end where line_num is
      contained. */
 
@@ -225,271 +492,8 @@
 	error ("mi_cmd_disassemble: No function contains specified address");
     }
 
-  if (!di_initialized)
-    {
-      /* We don't add a cleanup for this, because the allocation of
-         the stream is done once only for each gdb run, and we need to
-         keep it around until the end. Hopefully there won't be any
-         errors in the init code below, that make this function bail
-         out. */
-      stb = ui_out_stream_new (uiout);
-      INIT_DISASSEMBLE_INFO_NO_ARCH (di, stb->stream,
-				     (fprintf_ftype) fprintf_unfiltered);
-      di.flavour = bfd_target_unknown_flavour;
-      di.memory_error_func = dis_asm_memory_error;
-      di.print_address_func = dis_asm_print_address;
-      di_initialized = 1;
-    }
-
-  di.mach = TARGET_PRINT_INSN_INFO->mach;
-  if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
-    di.endian = BFD_ENDIAN_BIG;
-  else
-    di.endian = BFD_ENDIAN_LITTLE;
-
-  /* If gdb_disassemble_from_exec == -1, then we use the following heuristic to
-     determine whether or not to do disassembly from target memory or from the
-     exec file:
-
-     If we're debugging a local process, read target memory, instead of the
-     exec file.  This makes disassembly of functions in shared libs work
-     correctly.  Also, read target memory if we are debugging native threads.
-
-     Else, we're debugging a remote process, and should disassemble from the
-     exec file for speed.  However, this is no good if the target modifies its
-     code (for relocation, or whatever).
-   */
-
-  if (gdb_disassemble_from_exec == -1)
-    {
-      if (strcmp (target_shortname, "child") == 0
-	  || strcmp (target_shortname, "procfs") == 0
-	  || strcmp (target_shortname, "vxprocess") == 0
-	  || strstr (target_shortname, "-threads") != NULL)
-	gdb_disassemble_from_exec = 0;	/* It's a child process, read inferior mem */
-      else
-	gdb_disassemble_from_exec = 1;	/* It's remote, read the exec file */
-    }
-
-  if (gdb_disassemble_from_exec)
-    di.read_memory_func = gdb_dis_asm_read_memory;
-  else
-    di.read_memory_func = dis_asm_read_memory;
-
-  /* If just doing straight assembly, all we need to do is disassemble
-     everything between low and high.  If doing mixed source/assembly,
-     we've got a totally different path to follow.  */
-
-  if (mixed_source_and_assembly)
-    {
-      /* Come here for mixed source/assembly */
-      /* The idea here is to present a source-O-centric view of a
-         function to the user.  This means that things are presented
-         in source order, with (possibly) out of order assembly
-         immediately following.  */
-      struct symtab *symtab;
-      struct linetable_entry *le;
-      int nlines;
-      int newlines;
-      struct dis_line_entry *mle;
-      struct symtab_and_line sal;
-      int i;
-      int out_of_order;
-      int next_line;
-
-      /* Assume symtab is valid for whole PC range */
-      symtab = find_pc_symtab (low);
-
-      if (!symtab || !symtab->linetable)
-	goto assembly_only;
-
-      /* First, convert the linetable to a bunch of my_line_entry's.  */
-
-      le = symtab->linetable->item;
-      nlines = symtab->linetable->nitems;
-
-      if (nlines <= 0)
-	goto assembly_only;
-
-      mle = (struct dis_line_entry *) alloca (nlines * sizeof (struct dis_line_entry));
-
-      out_of_order = 0;
-
-      /* Copy linetable entries for this function into our data
-         structure, creating end_pc's and setting out_of_order as
-         appropriate.  */
-
-      /* First, skip all the preceding functions.  */
-
-      for (i = 0; i < nlines - 1 && le[i].pc < low; i++);
-
-      /* Now, copy all entries before the end of this function.  */
-
-      newlines = 0;
-      for (; i < nlines - 1 && le[i].pc < high; i++)
-	{
-	  if (le[i].line == le[i + 1].line
-	      && le[i].pc == le[i + 1].pc)
-	    continue;		/* Ignore duplicates */
-
-	  mle[newlines].line = le[i].line;
-	  if (le[i].line > le[i + 1].line)
-	    out_of_order = 1;
-	  mle[newlines].start_pc = le[i].pc;
-	  mle[newlines].end_pc = le[i + 1].pc;
-	  newlines++;
-	}
-
-      /* If we're on the last line, and it's part of the function,
-         then we need to get the end pc in a special way.  */
-
-      if (i == nlines - 1
-	  && le[i].pc < high)
-	{
-	  mle[newlines].line = le[i].line;
-	  mle[newlines].start_pc = le[i].pc;
-	  sal = find_pc_line (le[i].pc, 0);
-	  mle[newlines].end_pc = sal.end;
-	  newlines++;
-	}
-
-      /* Now, sort mle by line #s (and, then by addresses within
-         lines). */
-
-      if (out_of_order)
-	qsort (mle, newlines, sizeof (struct dis_line_entry), compare_lines);
-
-      /* Now, for each line entry, emit the specified lines (unless
-         they have been emitted before), followed by the assembly code
-         for that line.  */
-
-      next_line = 0;		/* Force out first line */
-      ui_out_list_begin (uiout, "asm_insns");
-      num_displayed = 0;
-      for (i = 0; i < newlines; i++)
-	{
-	  int close_list = 1;
-	  /* Print out everything from next_line to the current line.  */
-	  if (mle[i].line >= next_line)
-	    {
-	      if (next_line != 0)
-		{
-		  /* Just one line to print. */
-		  if (next_line == mle[i].line)
-		    {
-		      ui_out_tuple_begin (uiout, "src_and_asm_line");
-		      print_source_lines (symtab, next_line, mle[i].line + 1, 0);
-		    }
-		  else
-		    {
-		      /* Several source lines w/o asm instructions associated. */
-		      for (; next_line < mle[i].line; next_line++)
-			{
-			  ui_out_tuple_begin (uiout, "src_and_asm_line");
-			  print_source_lines (symtab, next_line, mle[i].line + 1, 0);
-			  ui_out_list_begin (uiout, "line_asm_insn");
-			  ui_out_list_end (uiout);
-			  ui_out_tuple_end (uiout);
-			}
-		      /* Print the last line and leave list open for
-		         asm instructions to be added. */
-		      ui_out_tuple_begin (uiout, "src_and_asm_line");
-		      print_source_lines (symtab, next_line, mle[i].line + 1, 0);
-		    }
-		}
-	      else
-		{
-		  ui_out_tuple_begin (uiout, "src_and_asm_line");
-		  print_source_lines (symtab, mle[i].line, mle[i].line + 1, 0);
-		}
-
-	      next_line = mle[i].line + 1;
-	      ui_out_list_begin (uiout, "line_asm_insn");
-	      if (i + 1 < newlines && mle[i + 1].line <= mle[i].line)
-		close_list = 0;
-	    }
-	  for (pc = mle[i].start_pc; pc < mle[i].end_pc;)
-	    {
-	      QUIT;
-	      if (how_many >= 0)
-		{
-		  if (num_displayed >= how_many)
-		    break;
-		  else
-		    num_displayed++;
-		}
-	      ui_out_tuple_begin (uiout, NULL);
-	      ui_out_field_core_addr (uiout, "address", pc);
-
-	      if (!build_address_symbolic (pc, 0, &name, &offset, &filename, &line, &unmapped))
-		{
-		  /* We don't care now about line, filename and
-		     unmapped, but we might in the future. */
-		  ui_out_field_string (uiout, "func-name", name);
-		  ui_out_field_int (uiout, "offset", offset);
-		}
-	      if (filename != NULL)
-		xfree (filename);
-	      if (name != NULL)
-		xfree (name);
-
-	      ui_file_rewind (stb->stream);
-	      pc += (*tm_print_insn) (pc, &di);
-	      ui_out_field_stream (uiout, "inst", stb);
-	      ui_file_rewind (stb->stream);
-	      ui_out_tuple_end (uiout);
-	    }
-	  if (close_list)
-	    {
-	      ui_out_list_end (uiout);
-	      ui_out_tuple_end (uiout);
-	      close_list = 0;
-	    }
-	  if (how_many >= 0)
-	    if (num_displayed >= how_many)
-	      break;
-	}
-      ui_out_list_end (uiout);
-    }
-  else
-    {
-    assembly_only:
-      ui_out_list_begin (uiout, "asm_insns");
-      num_displayed = 0;
-      for (pc = low; pc < high;)
-	{
-	  QUIT;
-	  if (how_many >= 0)
-	    {
-	      if (num_displayed >= how_many)
-		break;
-	      else
-		num_displayed++;
-	    }
-	  ui_out_tuple_begin (uiout, NULL);
-	  ui_out_field_core_addr (uiout, "address", pc);
-
-	  if (!build_address_symbolic (pc, 0, &name, &offset, &filename, &line, &unmapped))
-	    {
-	      /* We don't care now about line, filename and
-	         unmapped. But we might in the future. */
-	      ui_out_field_string (uiout, "func-name", name);
-	      ui_out_field_int (uiout, "offset", offset);
-	    }
-	  if (filename != NULL)
-	    xfree (filename);
-	  if (name != NULL)
-	    xfree (name);
-
-	  ui_file_rewind (stb->stream);
-	  pc += (*tm_print_insn) (pc, &di);
-	  ui_out_field_stream (uiout, "inst", stb);
-	  ui_file_rewind (stb->stream);
-	  ui_out_tuple_end (uiout);
-	}
-      ui_out_list_end (uiout);
-    }
-  gdb_flush (gdb_stdout);
-
-  return MI_CMD_DONE;
+  retval = do_disassembly (file_string,
+			   line_num,
+			   mixed_source_and_assembly, how_many, low, high);
+  return retval;
 }
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 0e4bdf4..b4bae47 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -218,7 +218,7 @@
 
   stb = ui_out_stream_new (uiout);
 
-  block = get_frame_block (fi);
+  block = get_frame_block (fi, 0);
 
   ui_out_list_begin (uiout, locals ? "locals" : "args");
 
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 0c84064..4848a4e 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -1,5 +1,7 @@
 /* MI Command Set - varobj commands.
-   Copyright 2000 Free Software Foundation, Inc.
+
+   Copyright 2000, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions (a Red Hat company).
 
    This file is part of GDB.
@@ -27,11 +29,6 @@
 #include "value.h"
 #include <ctype.h>
 
-/* Convenience macro for allocting typesafe memory. */
-
-#undef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-
 extern int varobjdebug;		/* defined in varobj.c */
 
 static int varobj_update_one (struct varobj *var);
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index 5824f83..c1b6e9f 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -1,5 +1,7 @@
 /* MI Console code.
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions (a Red Hat company).
 
    This file is part of GDB.
@@ -23,11 +25,6 @@
 #include "mi-console.h"
 #include "gdb_string.h"
 
-/* Convenience macro for allocting typesafe memory. */
-
-#undef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-
 /* MI-console: send output to std-out but correcty encapsulated */
 
 static ui_file_fputs_ftype mi_console_file_fputs;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 3a59fc8..ccb153f 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -42,11 +42,6 @@
 #include <ctype.h>
 #include <sys/time.h>
 
-/* Convenience macro for allocting typesafe memory. */
-
-#undef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-
 enum
   {
     FROM_TTY = 0
@@ -170,7 +165,7 @@
   /* Because we have called return_command with from_tty = 0, we need
      to print the frame here. */
   show_and_print_stack_frame (selected_frame,
-			      selected_frame_level,
+			      frame_relative_level (selected_frame),
 			      LOC_AND_ADDRESS);
 
   return MI_CMD_DONE;
@@ -373,7 +368,7 @@
 {
   char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
 
-  if (read_relative_register_raw_bytes (regnum, raw_buffer))
+  if (! frame_register_read (selected_frame, regnum, raw_buffer))
     return -1;
 
   if (memcmp (&old_regs[REGISTER_BYTE (regnum)], raw_buffer,
@@ -486,10 +481,6 @@
   if (format == 'N')
     format = 0;
 
-  /* read_relative_register_raw_bytes returns a virtual frame pointer
-     (FRAME_FP (selected_frame)) if regnum == FP_REGNUM instead
-     of the real contents of the register. To get around this,
-     use get_saved_register instead. */
   get_saved_register (raw_buffer, &optim, (CORE_ADDR *) NULL, selected_frame,
 		      regnum, (enum lval_type *) NULL);
   if (optim)
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index a92ccbe..947720b 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -1,5 +1,7 @@
 /* MI Command Set - output generating routines.
-   Copyright 2000 Free Software Foundation, Inc.
+
+   Copyright 2000, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions (a Red Hat company).
 
    This file is part of GDB.
@@ -23,12 +25,6 @@
 #include "ui-out.h"
 #include "mi-out.h"
 
-/* Convenience macro for allocting typesafe memory. */
-
-#ifndef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-#endif
-
 struct ui_out_data
   {
     int suppress_field_separator;
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index 2ed49b8..caefd59 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -1,5 +1,7 @@
 /* MI Command Set - MI parser.
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions (a Red Hat company).
 
    This file is part of GDB.
@@ -26,9 +28,6 @@
 #include <ctype.h>
 #include "gdb_string.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 static void
 mi_parse_argv (char *args, struct mi_parse *parse)
 {
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index a4997bf..4fa1d91 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -504,52 +504,6 @@
 {
   return lookup_minimal_symbol_by_pc_section (pc, find_pc_mapped_section (pc));
 }
-
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
-CORE_ADDR
-find_stab_function_addr (char *namestring, char *filename,
-			 struct objfile *objfile)
-{
-  struct minimal_symbol *msym;
-  char *p;
-  int n;
-
-  p = strchr (namestring, ':');
-  if (p == NULL)
-    p = namestring;
-  n = p - namestring;
-  p = alloca (n + 2);
-  strncpy (p, namestring, n);
-  p[n] = 0;
-
-  msym = lookup_minimal_symbol (p, filename, objfile);
-  if (msym == NULL)
-    {
-      /* Sun Fortran appends an underscore to the minimal symbol name,
-         try again with an appended underscore if the minimal symbol
-         was not found.  */
-      p[n] = '_';
-      p[n + 1] = 0;
-      msym = lookup_minimal_symbol (p, filename, objfile);
-    }
-
-  if (msym == NULL && filename != NULL)
-    {
-      /* Try again without the filename. */
-      p[n] = 0;
-      msym = lookup_minimal_symbol (p, NULL, objfile);
-    }
-  if (msym == NULL && filename != NULL)
-    {
-      /* And try again for Sun Fortran, but without the filename. */
-      p[n] = '_';
-      p[n + 1] = 0;
-      msym = lookup_minimal_symbol (p, NULL, objfile);
-    }
-
-  return msym == NULL ? 0 : SYMBOL_VALUE_ADDRESS (msym);
-}
-#endif /* SOFUN_ADDRESS_MAYBE_MISSING */
 
 
 /* Return leading symbol character for a BFD. If BFD is NULL,
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index f0a27d9..3cee42e 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -1,7 +1,7 @@
 /* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger.
 
-   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
    and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
@@ -44,6 +44,10 @@
 #include "elf-bfd.h"
 #include "symcat.h"
 
+/* A useful bit in the CP0 status register (PS_REGNUM).  */
+/* This bit is set if we are emulating 32-bit FPRs on a 64-bit chip.  */
+#define ST0_FR (1 << 26)
+
 /* The sizes of floating point registers.  */
 
 enum
@@ -174,6 +178,31 @@
     return 4;
 }
 
+/* Determine if a MIPS3 or later cpu is operating in MIPS{1,2} FPU
+   compatiblity mode.  A return value of 1 means that we have
+   physical 64-bit registers, but should treat them as 32-bit registers.  */
+
+static int
+mips2_fp_compat (void)
+{
+  /* MIPS1 and MIPS2 have only 32 bit FPRs, and the FR bit is not
+     meaningful.  */
+  if (REGISTER_RAW_SIZE (FP0_REGNUM) == 4)
+    return 0;
+
+#if 0
+  /* FIXME drow 2002-03-10: This is disabled until we can do it consistently,
+     in all the places we deal with FP registers.  PR gdb/413.  */
+  /* Otherwise check the FR bit in the status register - it controls
+     the FP compatiblity mode.  If it is clear we are in compatibility
+     mode.  */
+  if ((read_register (PS_REGNUM) & ST0_FR) == 0)
+    return 1;
+#endif
+  
+  return 0;
+}
+
 /* Indicate that the ABI makes use of double-precision registers
    provided by the FPU (rather than combining pairs of registers to
    form double-precision values).  Do not use "TARGET_IS_MIPS64" to
@@ -257,6 +286,9 @@
 static CORE_ADDR after_prologue (CORE_ADDR pc,
 				 mips_extra_func_info_t proc_desc);
 
+static void mips_read_fp_register_single (int regno, char *rare_buffer);
+static void mips_read_fp_register_double (int regno, char *rare_buffer);
+
 /* This value is the model of MIPS in use.  It is derived from the value
    of the PrID register.  */
 
@@ -2076,7 +2108,7 @@
 	     We can't use fci->signal_handler_caller, it is not yet set.  */
 	  find_pc_partial_function (fci->pc, &name,
 				    (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
-	  if (!IN_SIGTRAMP (fci->pc, name))
+	  if (!PC_IN_SIGTRAMP (fci->pc, name))
 	    {
 	      frame_saved_regs_zalloc (fci);
 	      memcpy (fci->saved_regs, temp_saved_regs, SIZEOF_FRAME_SAVED_REGS);
@@ -2676,34 +2708,133 @@
     }
 }
 
+/* Floating point register management.
+
+   Background: MIPS1 & 2 fp registers are 32 bits wide.  To support
+   64bit operations, these early MIPS cpus treat fp register pairs
+   (f0,f1) as a single register (d0).  Later MIPS cpu's have 64 bit fp
+   registers and offer a compatibility mode that emulates the MIPS2 fp
+   model.  When operating in MIPS2 fp compat mode, later cpu's split
+   double precision floats into two 32-bit chunks and store them in
+   consecutive fp regs.  To display 64-bit floats stored in this
+   fashion, we have to combine 32 bits from f0 and 32 bits from f1.
+   Throw in user-configurable endianness and you have a real mess.
+
+   The way this works is:
+     - If we are in 32-bit mode or on a 32-bit processor, then a 64-bit
+       double-precision value will be split across two logical registers.
+       The lower-numbered logical register will hold the low-order bits,
+       regardless of the processor's endianness.
+     - If we are on a 64-bit processor, and we are looking for a
+       single-precision value, it will be in the low ordered bits
+       of a 64-bit GPR (after mfc1, for example) or a 64-bit register
+       save slot in memory.
+     - If we are in 64-bit mode, everything is straightforward.
+
+   Note that this code only deals with "live" registers at the top of the
+   stack.  We will attempt to deal with saved registers later, when
+   the raw/cooked register interface is in place. (We need a general
+   interface that can deal with dynamic saved register sizes -- fp
+   regs could be 32 bits wide in one frame and 64 on the frame above
+   and below).  */
+
+/* Copy a 32-bit single-precision value from the current frame
+   into rare_buffer.  */
+
+static void
+mips_read_fp_register_single (int regno, char *rare_buffer)
+{
+  int raw_size = REGISTER_RAW_SIZE (regno);
+  char *raw_buffer = alloca (raw_size);
+
+  if (!frame_register_read (selected_frame, regno, raw_buffer))
+    error ("can't read register %d (%s)", regno, REGISTER_NAME (regno));
+  if (raw_size == 8)
+    {
+      /* We have a 64-bit value for this register.  Find the low-order
+	 32 bits.  */
+      int offset;
+
+      if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+	offset = 4;
+      else
+	offset = 0;
+
+      memcpy (rare_buffer, raw_buffer + offset, 4);
+    }
+  else
+    {
+      memcpy (rare_buffer, raw_buffer, 4);
+    }
+}
+
+/* Copy a 64-bit double-precision value from the current frame into
+   rare_buffer.  This may include getting half of it from the next
+   register.  */
+
+static void
+mips_read_fp_register_double (int regno, char *rare_buffer)
+{
+  int raw_size = REGISTER_RAW_SIZE (regno);
+
+  if (raw_size == 8 && !mips2_fp_compat ())
+    {
+      /* We have a 64-bit value for this register, and we should use
+	 all 64 bits.  */
+      if (!frame_register_read (selected_frame, regno, rare_buffer))
+	error ("can't read register %d (%s)", regno, REGISTER_NAME (regno));
+    }
+  else
+    {
+      if ((regno - FP0_REGNUM) & 1)
+	internal_error (__FILE__, __LINE__,
+			"mips_read_fp_register_double: bad access to "
+			"odd-numbered FP register");
+
+      /* mips_read_fp_register_single will find the correct 32 bits from
+	 each register.  */
+      if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+	{
+	  mips_read_fp_register_single (regno, rare_buffer + 4);
+	  mips_read_fp_register_single (regno + 1, rare_buffer);
+	}
+      else      
+	{
+	  mips_read_fp_register_single (regno, rare_buffer);
+	  mips_read_fp_register_single (regno + 1, rare_buffer + 4);
+	}
+    }
+}
+
 static void
 mips_print_register (int regnum, int all)
 {
   char raw_buffer[MAX_REGISTER_RAW_SIZE];
 
   /* Get the data in raw format.  */
-  if (read_relative_register_raw_bytes (regnum, raw_buffer))
+  if (!frame_register_read (selected_frame, regnum, raw_buffer))
     {
       printf_filtered ("%s: [Invalid]", REGISTER_NAME (regnum));
       return;
     }
 
-  /* If an even floating point register, also print as double. */
+  /* If we have a actual 32-bit floating point register (or we are in
+     32-bit compatibility mode), and the register is even-numbered,
+     also print it as a double (spanning two registers).  */
   if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT
+      && (REGISTER_RAW_SIZE (regnum) == 4
+	  || mips2_fp_compat ())
       && !((regnum - FP0_REGNUM) & 1))
-    if (REGISTER_RAW_SIZE (regnum) == 4)	/* this would be silly on MIPS64 or N32 (Irix 6) */
-      {
-	char dbuffer[2 * MAX_REGISTER_RAW_SIZE];
+    {
+      char dbuffer[2 * MAX_REGISTER_RAW_SIZE];
 
-	read_relative_register_raw_bytes (regnum, dbuffer);
-	read_relative_register_raw_bytes (regnum + 1, dbuffer + MIPS_REGSIZE);
-	REGISTER_CONVERT_TO_TYPE (regnum, builtin_type_double, dbuffer);
+      mips_read_fp_register_double (regnum, dbuffer);
 
-	printf_filtered ("(d%d: ", regnum - FP0_REGNUM);
-	val_print (builtin_type_double, dbuffer, 0, 0,
-		   gdb_stdout, 0, 1, 0, Val_pretty_default);
-	printf_filtered ("); ");
-      }
+      printf_filtered ("(d%d: ", regnum - FP0_REGNUM);
+      val_print (builtin_type_double, dbuffer, 0, 0,
+		 gdb_stdout, 0, 1, 0, Val_pretty_default);
+      printf_filtered ("); ");
+    }
   fputs_filtered (REGISTER_NAME (regnum), gdb_stdout);
 
   /* The problem with printing numeric register names (r26, etc.) is that
@@ -2717,8 +2848,10 @@
 
   /* If virtual format is floating, print it that way.  */
   if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
-    if (FP_REGISTER_DOUBLE)
-      {				/* show 8-byte floats as float AND double: */
+    if (REGISTER_RAW_SIZE (regnum) == 8 && !mips2_fp_compat ())
+      {
+	/* We have a meaningful 64-bit value in this register.  Show
+	   it as a 32-bit float and a 64-bit double.  */
 	int offset = 4 * (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG);
 
 	printf_filtered (" (float) ");
@@ -2753,35 +2886,25 @@
 static int
 do_fp_register_row (int regnum)
 {				/* do values for FP (float) regs */
-  char *raw_buffer[2];
-  char *dbl_buffer;
-  /* use HI and LO to control the order of combining two flt regs */
-  int HI = (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG);
-  int LO = (TARGET_BYTE_ORDER != BFD_ENDIAN_BIG);
+  char *raw_buffer;
   double doub, flt1, flt2;	/* doubles extracted from raw hex data */
   int inv1, inv2, inv3;
 
-  raw_buffer[0] = (char *) alloca (REGISTER_RAW_SIZE (FP0_REGNUM));
-  raw_buffer[1] = (char *) alloca (REGISTER_RAW_SIZE (FP0_REGNUM));
-  dbl_buffer = (char *) alloca (2 * REGISTER_RAW_SIZE (FP0_REGNUM));
+  raw_buffer = (char *) alloca (2 * REGISTER_RAW_SIZE (FP0_REGNUM));
 
-  /* Get the data in raw format.  */
-  if (read_relative_register_raw_bytes (regnum, raw_buffer[HI]))
-    error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum));
-  if (REGISTER_RAW_SIZE (regnum) == 4)
+  if (REGISTER_RAW_SIZE (regnum) == 4 || mips2_fp_compat ())
     {
-      /* 4-byte registers: we can fit two registers per row. */
-      /* Also print every pair of 4-byte regs as an 8-byte double. */
-      if (read_relative_register_raw_bytes (regnum + 1, raw_buffer[LO]))
-	error ("can't read register %d (%s)",
-	       regnum + 1, REGISTER_NAME (regnum + 1));
+      /* 4-byte registers: we can fit two registers per row.  */
+      /* Also print every pair of 4-byte regs as an 8-byte double.  */
+      mips_read_fp_register_single (regnum, raw_buffer);
+      flt1 = unpack_double (builtin_type_float, raw_buffer, &inv1);
 
-      /* copy the two floats into one double, and unpack both */
-      memcpy (dbl_buffer, raw_buffer, 2 * REGISTER_RAW_SIZE (FP0_REGNUM));
-      flt1 = unpack_double (builtin_type_float, raw_buffer[HI], &inv1);
-      flt2 = unpack_double (builtin_type_float, raw_buffer[LO], &inv2);
-      doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
+      mips_read_fp_register_single (regnum + 1, raw_buffer);
+      flt2 = unpack_double (builtin_type_float, raw_buffer, &inv2);
 
+      mips_read_fp_register_double (regnum, raw_buffer);
+      doub = unpack_double (builtin_type_double, raw_buffer, &inv3);
+      
       printf_filtered (" %-5s", REGISTER_NAME (regnum));
       if (inv1)
 	printf_filtered (": <invalid float>");
@@ -2805,14 +2928,14 @@
       regnum += 2;
     }
   else
-    {				/* eight byte registers: print each one as float AND as double. */
-      int offset = 4 * (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG);
+    {
+      /* Eight byte registers: print each one as float AND as double.  */
+      mips_read_fp_register_single (regnum, raw_buffer);
+      flt1 = unpack_double (builtin_type_double, raw_buffer, &inv1);
 
-      memcpy (dbl_buffer, raw_buffer[HI], 2 * REGISTER_RAW_SIZE (FP0_REGNUM));
-      flt1 = unpack_double (builtin_type_float,
-			    &raw_buffer[HI][offset], &inv1);
-      doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
-
+      mips_read_fp_register_double (regnum, raw_buffer);
+      doub = unpack_double (builtin_type_double, raw_buffer, &inv3);
+      
       printf_filtered (" %-5s: ", REGISTER_NAME (regnum));
       if (inv1)
 	printf_filtered ("<invalid float>");
@@ -2869,7 +2992,7 @@
       if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
 	break;			/* end row: reached FP register */
       /* OK: get the data in raw format.  */
-      if (read_relative_register_raw_bytes (regnum, raw_buffer))
+      if (!frame_register_read (selected_frame, regnum, raw_buffer))
 	error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum));
       /* pad small registers */
       for (byte = 0; byte < (MIPS_REGSIZE - REGISTER_VIRTUAL_SIZE (regnum)); byte++)
@@ -3589,7 +3712,7 @@
    (if necessary) to point to the actual memory location where the
    breakpoint should be inserted.  */
 
-unsigned char *
+const unsigned char *
 mips_breakpoint_from_pc (CORE_ADDR * pcptr, int *lenptr)
 {
   if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
@@ -4238,7 +4361,6 @@
   set_gdbarch_read_pc (gdbarch, mips_read_pc);
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
   set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
-  set_gdbarch_write_fp (gdbarch, generic_target_write_fp);
   set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
 
@@ -4455,9 +4577,6 @@
 		      "mips_dump_tdep: IGNORE_HELPER_CALL # %s\n",
 		      XSTRING (IGNORE_HELPER_CALL (PC)));
   fprintf_unfiltered (file,
-		      "mips_dump_tdep: IN_SIGTRAMP # %s\n",
-		      XSTRING (IN_SIGTRAMP (PC, NAME)));
-  fprintf_unfiltered (file,
 		      "mips_dump_tdep: IN_SOLIB_CALL_TRAMPOLINE # %s\n",
 		      XSTRING (IN_SOLIB_CALL_TRAMPOLINE (PC, NAME)));
   fprintf_unfiltered (file,
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index a618ca7..0a5704b 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -1,6 +1,7 @@
 /* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -187,7 +188,7 @@
    so we need a single byte breakpoint.  Matsushita hasn't defined
    one, so we defined it ourselves.  */
 
-static unsigned char *
+const static unsigned char *
 mn10300_breakpoint_from_pc (CORE_ADDR *bp_addr, int *bp_size)
 {
   static char breakpoint[] =
@@ -1010,7 +1011,7 @@
     printf_filtered ("%s: ", name);
 
   /* Get the data */
-  if (read_relative_register_raw_bytes (regnum, raw_buffer))
+  if (!frame_register_read (selected_frame, regnum, raw_buffer))
     {
       printf_filtered ("[invalid]");
       return;
diff --git a/gdb/monitor.c b/gdb/monitor.c
index e760d43..81340d4 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -2078,7 +2078,7 @@
 monitor_insert_breakpoint (CORE_ADDR addr, char *shadow)
 {
   int i;
-  unsigned char *bp;
+  const unsigned char *bp;
   int bplen;
 
   monitor_debug ("MON inst bkpt %s\n", paddr (addr));
diff --git a/gdb/ocd.c b/gdb/ocd.c
index 6834eea..9dd90e9 100644
--- a/gdb/ocd.c
+++ b/gdb/ocd.c
@@ -255,7 +255,7 @@
   registers_changed ();
   stop_pc = read_pc ();
   set_current_frame (create_new_frame (read_fp (), stop_pc));
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
   print_stack_frame (selected_frame, -1, 1);
 
   buf[0] = OCD_LOG_FILE;
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index d1fcb1b..8efb450 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -37,8 +37,7 @@
    too messy, particularly when such includes can be inserted at random
    times by the parser generator.  */
 
-/* FIXME: there are still 21 shift/reduce conflicts
-   Other known bugs or limitations:
+/* Known bugs or limitations:
     - pascal string operations are not supported at all.
     - there are some problems with boolean types.
     - Pascal type hexadecimal constants are not supported
@@ -212,6 +211,7 @@
 %left '*' '/'
 %right UNARY INCREMENT DECREMENT
 %right ARROW '.' '[' '('
+%left '^'
 %token <ssym> BLOCKNAME
 %type <bval> block
 %left COLONCOLON
@@ -947,6 +947,8 @@
 
  retry:
 
+  prev_lexptr = lexptr;
+
   tokstart = lexptr;
   explen = strlen (lexptr);
   /* See if it is a special token of length 3.  */
@@ -1300,7 +1302,7 @@
 			 &is_a_field_of_this,
 			 (struct symtab **) NULL);
     /* second chance uppercased (as Free Pascal does).  */
-    if (!sym)
+    if (!sym && !is_a_field_of_this)
       {
        for (i = 0; i <= namelen; i++)
          {
@@ -1311,7 +1313,7 @@
                         VAR_NAMESPACE,
                         &is_a_field_of_this,
                         (struct symtab **) NULL);
-       if (sym)
+       if (sym || is_a_field_of_this)
          for (i = 0; i <= namelen; i++)
            {
              if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
@@ -1319,7 +1321,7 @@
            }
       }
     /* Third chance Capitalized (as GPC does).  */
-    if (!sym)
+    if (!sym && !is_a_field_of_this)
       {
        for (i = 0; i <= namelen; i++)
          {
@@ -1336,7 +1338,7 @@
                          VAR_NAMESPACE,
                          &is_a_field_of_this,
                          (struct symtab **) NULL);
-        if (sym)
+        if (sym || is_a_field_of_this)
           for (i = 0; i <= namelen; i++)
             {
               if (i == 0)
@@ -1481,5 +1483,8 @@
 yyerror (msg)
      char *msg;
 {
+  if (prev_lexptr)
+    lexptr = prev_lexptr;
+
   error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 62c8a64..4796da5 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -44,7 +44,8 @@
    but this does not happen for Free Pascal nor for GPC.  */
 int
 is_pascal_string_type (struct type *type,int *length_pos,
-                       int * length_size, int *string_pos, int *char_size)
+                       int *length_size, int *string_pos, int *char_size,
+		       char **arrayname)
 {
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
@@ -54,11 +55,17 @@
           && strcmp (TYPE_FIELDS (type)[0].name, "length") == 0 
           && strcmp (TYPE_FIELDS (type)[1].name, "st") == 0)
         {
-          *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
-          *length_size = TYPE_FIELD_TYPE (type, 0)->length;
-          *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
-          *char_size = 1;
-          return 1;
+          if (length_pos)
+	    *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
+          if (length_size)
+	    *length_size = TYPE_FIELD_TYPE (type, 0)->length;
+          if (string_pos)
+	    *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
+          if (char_size)
+	    *char_size = 1;
+ 	  if (arrayname)
+	    *arrayname = TYPE_FIELDS (type)[1].name;
+         return 2;
         };
       /* GNU pascal strings.  */
       /* Three fields: Capacity, length and schema$ or _p_schema.  */
@@ -66,12 +73,18 @@
           && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
           && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
         {
-          *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
-          *length_size = TYPE_FIELD_TYPE (type, 1)->length;
-          *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
+          if (length_pos)
+	    *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
+          if (length_size)
+	    *length_size = TYPE_FIELD_TYPE (type, 1)->length;
+          if (string_pos)
+	    *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
           /* FIXME: how can I detect wide chars in GPC ?? */
-          *char_size = 1;
-          return 1;
+          if (char_size)
+	    *char_size = 1;
+ 	  if (arrayname)
+	    *arrayname = TYPE_FIELDS (type)[2].name;
+         return 3;
         };
     }
   return 0;
@@ -280,7 +293,7 @@
 			0, "void", objfile);
       break;
     case FT_CHAR:
-      type = init_type (TYPE_CODE_INT,
+      type = init_type (TYPE_CODE_CHAR,
 			TARGET_CHAR_BIT / TARGET_CHAR_BIT,
 			0, "char", objfile);
       break;
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index ca8a0a9..39eb043 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -38,7 +38,8 @@
 
 /* These are in p-lang.c: */
 
-extern int is_pascal_string_type (struct type *, int *, int *, int *, int*);
+extern int 
+  is_pascal_string_type (struct type *, int *, int *, int *, int *, char **);
 
 extern void pascal_printchar (int, struct ui_file *);
 
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index f7fc389..e8de788 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -788,6 +788,14 @@
 			 show - 1, level);
       break;
 
+    case TYPE_CODE_BITSTRING:
+      fputs_filtered ("BitString", stream);
+      break;
+
+    case TYPE_CODE_STRING:
+      fputs_filtered ("String", stream);
+      break;
+
     default:
       /* Handle types not explicitly handled by the other cases,
          such as fundamental types.  For these, just print whatever
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 0b89c72..c8060a2 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -190,8 +190,8 @@
 	     as GDB does not recognize stabs pascal strings
 	     Pascal strings are mapped to records
 	     with lowercase names PM  */
-          if (is_pascal_string_type (elttype, &length_pos,
-                                     &length_size, &string_pos, &char_size)
+          if (is_pascal_string_type (elttype, &length_pos, &length_size,
+                                     &string_pos, &char_size, NULL)
 	      && addr != 0)
 	    {
 	      ULONGEST string_length;
@@ -320,7 +320,7 @@
       else
 	{
           if (is_pascal_string_type (type, &length_pos, &length_size,
-                                     &string_pos, &char_size))
+                                     &string_pos, &char_size, NULL))
 	    {
 	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
 	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
diff --git a/gdb/parse.c b/gdb/parse.c
index b3fbe19..9c1f3e1 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -47,6 +47,8 @@
 #include "inferior.h"		/* for NUM_PSEUDO_REGS.  NOTE: replace 
 				   with "gdbarch.h" when appropriate.  */
 #include "doublest.h"
+#include "builtin-regs.h"
+#include "gdb_assert.h"
 
 
 /* Symbols which architectures can redefine.  */
@@ -74,6 +76,7 @@
 union type_stack_elt *type_stack;
 int type_stack_depth, type_stack_size;
 char *lexptr;
+char *prev_lexptr;
 char *namecopy;
 int paren_depth;
 int comma_terminates;
@@ -102,15 +105,9 @@
 
 static struct funcall *funcall_chain;
 
-/* Assign machine-independent names to certain registers 
-   (unless overridden by the REGISTER_NAMES table) */
-
-unsigned num_std_regs = 0;
-struct std_regs *std_regs;
-
 /* The generic method for targets to specify how their registers are
-   named.  The mapping can be derived from three sources:
-   REGISTER_NAME; std_regs; or a target specific alias hook. */
+   named.  The mapping can be derived from two sources: REGISTER_NAME;
+   or builtin regs.  */
 
 int
 target_map_name_to_register (char *str, int len)
@@ -125,13 +122,21 @@
 	return i;
       }
 
-  /* Try standard aliases. */
-  for (i = 0; i < num_std_regs; i++)
-    if (std_regs[i].name && len == strlen (std_regs[i].name)
-	&& STREQN (str, std_regs[i].name, len))
-      {
-	return std_regs[i].regnum;
-      }
+  /* Try builtin registers.  */
+  i = builtin_reg_map_name_to_regnum (str, len);
+  if (i >= 0)
+    {
+      gdb_assert (i >= NUM_REGS + NUM_PSEUDO_REGS);
+      return i;
+    }
+
+  /* Try builtin registers.  */
+  i = builtin_reg_map_name_to_regnum (str, len);
+  if (i >= 0)
+    {
+      gdb_assert (i >= NUM_REGS + NUM_PSEUDO_REGS);
+      return i;
+    }
 
   return -1;
 }
@@ -1122,6 +1127,7 @@
   struct cleanup *old_chain;
 
   lexptr = *stringptr;
+  prev_lexptr = NULL;
 
   paren_depth = 0;
   type_stack_depth = 0;
@@ -1134,7 +1140,7 @@
   old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
   funcall_chain = 0;
 
-  expression_context_block = block ? block : get_selected_block ();
+  expression_context_block = block ? block : get_selected_block (0);
 
   namecopy = (char *) alloca (strlen (lexptr) + 1);
   expout_size = 10;
@@ -1351,63 +1357,6 @@
     init_type (TYPE_CODE_INT, 1, 0,
 	       "<variable (not text or data), no debug info>",
 	       NULL);
-
-  /* create the std_regs table */
-
-  num_std_regs = 0;
-#ifdef PC_REGNUM
-  if (PC_REGNUM >= 0)
-    num_std_regs++;
-#endif
-#ifdef FP_REGNUM
-  if (FP_REGNUM >= 0)
-    num_std_regs++;
-#endif
-#ifdef SP_REGNUM
-  if (SP_REGNUM >= 0)
-    num_std_regs++;
-#endif
-#ifdef PS_REGNUM
-  if (PS_REGNUM >= 0)
-    num_std_regs++;
-#endif
-  /* create an empty table */
-  std_regs = xmalloc ((num_std_regs + 1) * sizeof *std_regs);
-  i = 0;
-  /* fill it in */
-#ifdef PC_REGNUM
-  if (PC_REGNUM >= 0)
-    {
-      std_regs[i].name = "pc";
-      std_regs[i].regnum = PC_REGNUM;
-      i++;
-    }
-#endif
-#ifdef FP_REGNUM
-  if (FP_REGNUM >= 0)
-    {
-      std_regs[i].name = "fp";
-      std_regs[i].regnum = FP_REGNUM;
-      i++;
-    }
-#endif
-#ifdef SP_REGNUM
-  if (SP_REGNUM >= 0)
-    {
-      std_regs[i].name = "sp";
-      std_regs[i].regnum = SP_REGNUM;
-      i++;
-    }
-#endif
-#ifdef PS_REGNUM
-  if (PS_REGNUM >= 0)
-    {
-      std_regs[i].name = "ps";
-      std_regs[i].regnum = PS_REGNUM;
-      i++;
-    }
-#endif
-  memset (&std_regs[i], 0, sizeof (std_regs[i]));
 }
 
 void
@@ -1427,8 +1376,6 @@
   register_gdbarch_swap (&msym_data_symbol_type, sizeof (msym_data_symbol_type), NULL);
   register_gdbarch_swap (&msym_unknown_symbol_type, sizeof (msym_unknown_symbol_type), NULL);
 
-  register_gdbarch_swap (&num_std_regs, sizeof (std_regs), NULL);
-  register_gdbarch_swap (&std_regs, sizeof (std_regs), NULL);
   register_gdbarch_swap (NULL, 0, build_parse);
 
   add_show_from_set (
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 66e929f..ece2849 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -1,6 +1,8 @@
 /* Parser definitions for GDB.
-   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+
    Modified from expread.y by the Department of Computer Science at the
    State University of New York at Buffalo.
 
@@ -26,15 +28,6 @@
 
 #include "doublest.h"
 
-struct std_regs
-  {
-    char *name;
-    int regnum;
-  };
-
-extern struct std_regs *std_regs;
-extern unsigned num_std_regs;
-
 extern struct expression *expout;
 extern int expout_size;
 extern int expout_ptr;
@@ -157,6 +150,10 @@
 
 extern char *lexptr;
 
+/* After a token has been recognized, this variable points to it.  
+   Currently used only for error reporting.  */
+extern char *prev_lexptr;
+
 /* Tokens that refer to names do so with explicit pointer and length,
    so they can share the storage that lexptr is parsing.
 
@@ -208,8 +205,8 @@
   };
 
 /* The generic method for targets to specify how their registers are
-   named.  The mapping can be derived from three sources:
-   REGISTER_NAME; std_regs; or a target specific alias hook. */
+   named.  The mapping can be derived from two sources: REGISTER_NAME;
+   and builtin regs. */
 
 extern int target_map_name_to_register (char *, int);
 
diff --git a/gdb/ppc-bdm.c b/gdb/ppc-bdm.c
index b2287ea..0797e0d 100644
--- a/gdb/ppc-bdm.c
+++ b/gdb/ppc-bdm.c
@@ -201,6 +201,7 @@
 
       /* if asking for an invalid register */
       if ((first_regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
+          || (first_regno == gdbarch_tdep (current_gdbarch)->ppc_fpscr_regnum)
 	  || ((first_regno >= FP0_REGNUM) && (first_regno <= FPLAST_REGNUM)))
 	{
 /*          printf("invalid reg request!\n"); */
@@ -289,7 +290,9 @@
 
       /* only attempt to write if it's a valid ppc 8xx register */
       /* (need to avoid FP regs and MQ reg) */
-      if ((i != gdbarch_tdep (current_gdbarch)->ppc_mq_regnum) && ((i < FP0_REGNUM) || (i > FPLAST_REGNUM)))
+      if ((i != gdbarch_tdep (current_gdbarch)->ppc_mq_regnum) 
+          && (i != gdbarch_tdep (current_gdbarch)->ppc_fpscr_regnum) 
+          && ((i < FP0_REGNUM) || (i > FPLAST_REGNUM)))
 	{
 /*          printf("write valid reg %d\n", bdm_regno); */
 	  ocd_write_bdm_registers (bdm_regno, registers + REGISTER_BYTE (i), 4);
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index e4bb868..25616c0 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -149,6 +149,8 @@
     u_addr = PT_MQ * 4;
   if (regno == tdep->ppc_ps_regnum)
     u_addr = PT_MSR * 4;
+  if (regno == tdep->ppc_fpscr_regnum)
+    u_addr = PT_FPSCR * 4;
 
   return u_addr;
 }
@@ -290,8 +292,10 @@
   int i;
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
-  for (i = 0; i <= tdep->ppc_mq_regnum; i++)
+  for (i = 0; i <= tdep->ppc_fpscr_regnum; i++)
     fetch_register (tid, i);
+  if (tdep->ppc_mq_regnum != -1)
+    fetch_register (tid, tdep->ppc_mq_regnum);
   if (have_ptrace_getvrregs)
     if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
       fetch_altivec_registers (tid);
@@ -376,6 +380,14 @@
       ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
 	      *(PTRACE_XFER_TYPE *) & buf[i]);
       regaddr += sizeof (PTRACE_XFER_TYPE);
+
+      if (errno == EIO 
+          && regno == gdbarch_tdep (current_gdbarch)->ppc_fpscr_regnum)
+	{
+	  /* Some older kernel versions don't allow fpscr to be written.  */
+	  continue;
+	}
+
       if (errno != 0)
 	{
 	  sprintf (mess, "writing register %s (#%d)", 
@@ -435,8 +447,10 @@
   int i;
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   
-  for (i = 0; i <= tdep->ppc_mq_regnum; i++)
+  for (i = 0; i <= tdep->ppc_fpscr_regnum; i++)
     store_register (tid, i);
+  if (tdep->ppc_mq_regnum != -1)
+    store_register (tid, tdep->ppc_mq_regnum);
   if (have_ptrace_getvrregs)
     if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
       store_altivec_registers (tid);
@@ -473,7 +487,8 @@
   supply_register (tdep->ppc_cr_regnum, (char *) (regp + PT_CCR));
   supply_register (tdep->ppc_xer_regnum, (char *) (regp + PT_XER));
   supply_register (tdep->ppc_ctr_regnum, (char *) (regp + PT_CTR));
-  supply_register (tdep->ppc_mq_regnum, (char *) (regp + PT_MQ));
+  if (tdep->ppc_mq_regnum != -1)
+    supply_register (tdep->ppc_mq_regnum, (char *) (regp + PT_MQ));
   supply_register (tdep->ppc_ps_regnum, (char *) (regp + PT_MSR));
 }
 
@@ -500,7 +515,8 @@
     regcache_collect (tdep->ppc_xer_regnum, regp + PT_XER);
   if ((regno == -1) || regno == tdep->ppc_ctr_regnum)
     regcache_collect (tdep->ppc_ctr_regnum, regp + PT_CTR);
-  if ((regno == -1) || regno == tdep->ppc_mq_regnum)
+  if (((regno == -1) || regno == tdep->ppc_mq_regnum)
+      && (tdep->ppc_mq_regnum != -1))
     regcache_collect (tdep->ppc_mq_regnum, regp + PT_MQ);
   if ((regno == -1) || regno == tdep->ppc_ps_regnum)
     regcache_collect (tdep->ppc_ps_regnum, regp + PT_MSR);
@@ -510,9 +526,11 @@
 supply_fpregset (gdb_fpregset_t * fpregsetp)
 {
   int regi;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
 
   for (regi = 0; regi < 32; regi++)
     supply_register (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
+  supply_register (tdep->ppc_fpscr_regnum, (char *) (*fpregsetp + 32));
 }
 
 /* Given a pointer to a floating point register set in /proc format
@@ -523,10 +541,13 @@
 fill_fpregset (gdb_fpregset_t *fpregsetp, int regno)
 {
   int regi;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); 
   
   for (regi = 0; regi < 32; regi++)
     {
       if ((regno == -1) || (regno == FP0_REGNUM + regi))
 	regcache_collect (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
     }
+  if ((regno == -1) || regno == tdep->ppc_fpscr_regnum)
+    regcache_collect (tdep->ppc_fpscr_regnum, (char *) (*fpregsetp + regi));
 }
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index b12cffd..f358274 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -106,10 +106,11 @@
 /* Determine if pc is in a signal trampoline...
 
    Ha!  That's not what this does at all.  wait_for_inferior in
-   infrun.c calls IN_SIGTRAMP in order to detect entry into a signal
-   trampoline just after delivery of a signal.  But on GNU/Linux,
-   signal trampolines are used for the return path only.  The kernel
-   sets things up so that the signal handler is called directly.
+   infrun.c calls PC_IN_SIGTRAMP in order to detect entry into a
+   signal trampoline just after delivery of a signal.  But on
+   GNU/Linux, signal trampolines are used for the return path only.
+   The kernel sets things up so that the signal handler is called
+   directly.
 
    If we use in_sigtramp2() in place of in_sigtramp() (see below)
    we'll (often) end up with stop_pc in the trampoline and prev_pc in
@@ -141,11 +142,11 @@
    first instruction long after the fact, just in case the observed
    behavior is ever fixed.)
 
-   IN_SIGTRAMP is called from blockframe.c as well in order to set
+   PC_IN_SIGTRAMP is called from blockframe.c as well in order to set
    the signal_handler_caller flag.  Because of our strange definition
-   of in_sigtramp below, we can't rely on signal_handler_caller getting
-   set correctly from within blockframe.c.  This is why we take pains
-   to set it in init_extra_frame_info().  */
+   of in_sigtramp below, we can't rely on signal_handler_caller
+   getting set correctly from within blockframe.c.  This is why we
+   take pains to set it in init_extra_frame_info().  */
 
 int
 ppc_linux_in_sigtramp (CORE_ADDR pc, char *func_name)
@@ -414,6 +415,32 @@
    it may be used generically by ports which use either the SysV ABI or
    the EABI */
 
+/* Until November 2001, gcc was not complying to the SYSV ABI for
+   returning structures less than or equal to 8 bytes in size.  It was
+   returning everything in memory.  When this was corrected, it wasn't
+   fixed for native platforms.  */
+int
+ppc_sysv_abi_broken_use_struct_convention (int gcc_p, struct type *value_type)
+{
+  if (TYPE_LENGTH (value_type) == 16
+      && TYPE_VECTOR (value_type))
+    return 0;
+
+  return generic_use_struct_convention (gcc_p, value_type);
+}
+
+/* Structures 8 bytes or less long are returned in the r3 & r4
+   registers, according to the SYSV ABI. */
+int
+ppc_sysv_abi_use_struct_convention (int gcc_p, struct type *value_type)
+{
+  if (TYPE_LENGTH (value_type) == 16
+      && TYPE_VECTOR (value_type))
+    return 0;
+
+  return (TYPE_LENGTH (value_type) > 8);
+}
+
 /* round2 rounds x up to the nearest multiple of s assuming that s is a
    power of 2 */
 
@@ -436,7 +463,12 @@
 			     int struct_return, CORE_ADDR struct_addr)
 {
   int argno;
-  int greg, freg;
+  /* Next available general register for non-float, non-vector arguments. */
+  int greg;
+  /* Next available floating point register for float arguments. */
+  int freg;
+  /* Next available vector register for vector arguments. */
+  int vreg;
   int argstkspace;
   int structstkspace;
   int argoffset;
@@ -449,6 +481,7 @@
 
   greg = struct_return ? 4 : 3;
   freg = 1;
+  vreg = 2;
   argstkspace = 0;
   structstkspace = 0;
 
@@ -491,21 +524,38 @@
 	      greg += 2;
 	    }
 	}
-      else
-	{
+      else if (!TYPE_VECTOR (type))
+        {
 	  if (len > 4
 	      || TYPE_CODE (type) == TYPE_CODE_STRUCT
 	      || TYPE_CODE (type) == TYPE_CODE_UNION)
 	    {
 	      /* Rounding to the nearest multiple of 8 may not be necessary,
-	         but it is safe.  Particularly since we don't know the
-	         field types of the structure */
+		 but it is safe.  Particularly since we don't know the
+		 field types of the structure */
 	      structstkspace += round2 (len, 8);
 	    }
 	  if (greg <= 10)
 	    greg++;
 	  else
 	    argstkspace += 4;
+    	}
+      else
+        {
+          if (len == 16
+	      && TYPE_CODE (type) == TYPE_CODE_ARRAY
+	      && TYPE_VECTOR (type))
+	    {
+	      if (vreg <= 13)
+		vreg++;
+	      else
+		{
+		  /* Vector arguments must be aligned to 16 bytes on
+                     the stack. */
+		  argstkspace += round2 (argstkspace, 16);
+		  argstkspace += 16;
+		}
+	    }
 	}
     }
 
@@ -531,6 +581,7 @@
   structoffset = argoffset + argstkspace;
   freg = 1;
   greg = 3;
+  vreg = 2;
   /* Fill in r3 with the return structure, if any */
   if (struct_return)
     {
@@ -552,7 +603,7 @@
 	    {
 	      if (len > 8)
 		printf_unfiltered (
-				    "Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno);
+				   "Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno);
 	      memcpy (&registers[REGISTER_BYTE (FP0_REGNUM + freg)],
 		      VALUE_CONTENTS (arg), len);
 	      freg++;
@@ -590,7 +641,7 @@
 	      greg += 2;
 	    }
 	}
-      else
+      else if (!TYPE_VECTOR (type))
 	{
 	  char val_buf[4];
 	  if (len > 4
@@ -608,7 +659,6 @@
 	    }
 	  if (greg <= 10)
 	    {
-	      *(int *) &registers[REGISTER_BYTE (greg)] = 0;
 	      memcpy (&registers[REGISTER_BYTE (greg)], val_buf, 4);
 	      greg++;
 	    }
@@ -618,6 +668,30 @@
 	      argoffset += 4;
 	    }
 	}
+      else
+	{
+	  if (len == 16
+	      && TYPE_CODE (type) == TYPE_CODE_ARRAY
+	      && TYPE_VECTOR (type))
+	    {
+	      struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+	      char *v_val_buf = alloca (16);
+	      memset (v_val_buf, 0, 16);
+	      memcpy (v_val_buf, VALUE_CONTENTS (arg), len);
+	      if (vreg <= 13)
+		{
+		  memcpy (&registers[REGISTER_BYTE (tdep->ppc_vr0_regnum
+						    + vreg)],
+			  v_val_buf, 16);
+		  vreg++;
+		}
+	      else
+		{
+		  write_memory (sp + argoffset, v_val_buf, 16);
+		  argoffset += 16;
+		}
+	    }
+        }
     }
 
   target_store_registers (-1);
@@ -751,7 +825,7 @@
 int
 ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
-  unsigned char *bp;
+  const unsigned char *bp;
   int val;
   int bplen;
   char old_contents[BREAKPOINT_MAX];
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index 029f87c..3da66ad 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -31,6 +31,8 @@
 int ppc_linux_frameless_function_invocation (struct frame_info *);
 void ppc_linux_frame_init_saved_regs (struct frame_info *);
 CORE_ADDR ppc_linux_frame_chain (struct frame_info *);
+int ppc_sysv_abi_use_struct_convention (int, struct type *);
+int ppc_sysv_abi_broken_use_struct_convention (int, struct type *);
 CORE_ADDR ppc_sysv_abi_push_arguments (int, struct value **, CORE_ADDR, int,
 				       CORE_ADDR);
 int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
@@ -61,9 +63,13 @@
     int ppc_lr_regnum;		/* Link register */
     int ppc_ctr_regnum;		/* Count register */
     int ppc_xer_regnum;		/* Integer exception register */
+    int ppc_fpscr_regnum;	/* Floating point status and condition
+    				   register */
     int ppc_mq_regnum;		/* Multiply/Divide extension register */
     int ppc_vr0_regnum;		/* First AltiVec register */
     int ppc_vrsave_regnum;	/* Last AltiVec register */
+    int lr_frame_offset;	/* Offset to ABI specific location where
+                                   link register is saved.  */
 };
 
 #endif
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 0315227..b74f558 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1113,7 +1113,7 @@
   if (exp == 0)
     error ("Argument required.");
 
-  sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
+  sym = lookup_symbol (exp, get_selected_block (0), VAR_NAMESPACE,
 		       &is_a_field_of_this, (struct symtab **) NULL);
   if (sym == NULL)
     {
@@ -1549,7 +1549,7 @@
     return;
 
   if (d->block)
-    within_current_scope = contained_in (get_selected_block (), d->block);
+    within_current_scope = contained_in (get_selected_block (0), d->block);
   else
     within_current_scope = 1;
   if (!within_current_scope)
@@ -1683,7 +1683,7 @@
       else if (d->format.format)
 	printf_filtered ("/%c ", d->format.format);
       print_expression (d->exp, gdb_stdout);
-      if (d->block && !contained_in (get_selected_block (), d->block))
+      if (d->block && !contained_in (get_selected_block (0), d->block))
 	printf_filtered (" (cannot be evaluated in the current context)");
       printf_filtered ("\n");
       gdb_flush (gdb_stdout);
@@ -2436,7 +2436,7 @@
 Default is the function surrounding the pc of the selected frame.\n\
 With a single argument, the function surrounding that address is dumped.\n\
 Two arguments are taken as a range of memory to dump.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
   if (xdb_commands)
     add_com_alias ("va", "disassemble", class_xdb, 0);
 
@@ -2519,7 +2519,7 @@
 The argument is the function name and arguments, in the notation of the\n\
 current working language.  The result is printed and saved in the value\n\
 history, if it is not void.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_cmd ("variable", class_vars, set_command,
 	   "Evaluate expression EXP and assign result to variable VAR, using assignment\n\
@@ -2552,13 +2552,13 @@
 		   "\n\
 EXP may be preceded with /FMT, where FMT is a format letter\n\
 but no count or size letter (see \"x\" command).", NULL));
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
   add_com_alias ("p", "print", class_vars, 1);
 
   c = add_com ("inspect", class_vars, inspect_command,
 	   "Same as \"print\" command, except that if you are running in the epoch\n\
 environment, the value is printed in its own window.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_show_from_set (
 		 add_set_cmd ("max-symbolic-offset", no_class, var_uinteger,
diff --git a/gdb/proc-api.c b/gdb/proc-api.c
index 986691d..2d3ca9f 100644
--- a/gdb/proc-api.c
+++ b/gdb/proc-api.c
@@ -778,7 +778,7 @@
 
   add_show_from_set (c, &showlist);
   set_cmd_sfunc (c, set_procfs_trace_cmd);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_set_cmd ("procfs-file", no_class, var_filename,
 		   (char *) &procfs_filename, 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 2885904..8c1a0aa 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -585,16 +585,16 @@
 }
 
 
-/* read_pc, write_pc, read_sp, write_sp, read_fp, write_fp, etc.
-   Special handling for registers PC, SP, and FP.  */
+/* read_pc, write_pc, read_sp, write_sp, read_fp, etc.  Special
+   handling for registers PC, SP, and FP.  */
 
 /* NOTE: cagney/2001-02-18: The functions generic_target_read_pc(),
    read_pc_pid(), read_pc(), generic_target_write_pc(),
    write_pc_pid(), write_pc(), generic_target_read_sp(), read_sp(),
-   generic_target_write_sp(), write_sp(), generic_target_read_fp(),
-   read_fp(), generic_target_write_fp(), write_fp will eventually be
-   moved out of the reg-cache into either frame.[hc] or to the
-   multi-arch framework.  The are not part of the raw register cache.  */
+   generic_target_write_sp(), write_sp(), generic_target_read_fp() and
+   read_fp(), will eventually be moved out of the reg-cache into
+   either frame.[hc] or to the multi-arch framework.  The are not part
+   of the raw register cache.  */
 
 /* This routine is getting awfully cluttered with #if's.  It's probably
    time to turn this into READ_PC and define it in the tm.h file.
@@ -738,26 +738,6 @@
   return TARGET_READ_FP ();
 }
 
-void
-generic_target_write_fp (CORE_ADDR val)
-{
-#ifdef FP_REGNUM
-  if (FP_REGNUM >= 0)
-    {
-      write_register (FP_REGNUM, val);
-      return;
-    }
-#endif
-  internal_error (__FILE__, __LINE__,
-		  "generic_target_write_fp");
-}
-
-void
-write_fp (CORE_ADDR val)
-{
-  TARGET_WRITE_FP (val);
-}
-
 /* ARGSUSED */
 static void
 reg_flush_command (char *command, int from_tty)
@@ -802,8 +782,6 @@
 void
 _initialize_regcache (void)
 {
-  build_regcache ();
-
   register_gdbarch_swap (&registers, sizeof (registers), NULL);
   register_gdbarch_swap (&register_valid, sizeof (register_valid), NULL);
   register_gdbarch_swap (NULL, 0, build_regcache);
diff --git a/gdb/regformats/reg-ppc.dat b/gdb/regformats/reg-ppc.dat
index d915996..d7f9b88 100644
--- a/gdb/regformats/reg-ppc.dat
+++ b/gdb/regformats/reg-ppc.dat
@@ -73,4 +73,4 @@
 32:lr
 32:ctr
 32:xer
-0:
+32:fpscr
diff --git a/gdb/regformats/reg-x86-64.dat b/gdb/regformats/reg-x86-64.dat
index a8a2e8c..59ebbf5 100644
--- a/gdb/regformats/reg-x86-64.dat
+++ b/gdb/regformats/reg-x86-64.dat
@@ -1,9 +1,9 @@
 name:x86_64
 expedite:rbp,rsp,rip
 64:rax
-64:rdx
-64:rcx
 64:rbx
+64:rcx
+64:rdx
 64:rsi
 64:rdi
 64:rbp
@@ -18,6 +18,10 @@
 64:r15
 64:rip
 32:eflags
+32:ds
+32:es
+32:fs
+32:gs
 80:st0
 80:st1
 80:st2
diff --git a/gdb/remote-adapt.c b/gdb/remote-adapt.c
deleted file mode 100644
index 7e87360..0000000
--- a/gdb/remote-adapt.c
+++ /dev/null
@@ -1,1524 +0,0 @@
-/* OBSOLETE /* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18.  */
-/* OBSOLETE    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
-/* OBSOLETE    2001 Free Software Foundation, Inc. */
-/* OBSOLETE    Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu). */
-/* OBSOLETE    Adapted from work done at Cygnus Support in remote-eb.c. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* This is like remote.c but is for an esoteric situation-- */
-/* OBSOLETE    having a 29k board attached to an Adapt inline monitor.  */
-/* OBSOLETE    The  monitor is connected via serial line to a unix machine  */
-/* OBSOLETE    running gdb.  */
-/* OBSOLETE  */
-/* OBSOLETE    3/91 -  developed on Sun3 OS 4.1, by David Wood */
-/* OBSOLETE    o - I can't get binary coff to load.  */
-/* OBSOLETE    o - I can't get 19200 baud rate to work.  */
-/* OBSOLETE    7/91 o - Freeze mode tracing can be done on a 29050.  */ */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE #include "defs.h" */
-/* OBSOLETE #include "gdb_string.h" */
-/* OBSOLETE #include "inferior.h" */
-/* OBSOLETE #include "value.h" */
-/* OBSOLETE #include <ctype.h> */
-/* OBSOLETE #include <fcntl.h> */
-/* OBSOLETE #include <signal.h> */
-/* OBSOLETE #include <errno.h> */
-/* OBSOLETE #include "terminal.h" */
-/* OBSOLETE #include "target.h" */
-/* OBSOLETE #include "gdbcore.h" */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE  */
-/* OBSOLETE /* This processor is getting rusty but I am trying to keep it */
-/* OBSOLETE    up to date at least with data structure changes. */
-/* OBSOLETE    Activate this block to compile just this file. */
-/* OBSOLETE  */ */
-/* OBSOLETE #define COMPILE_CHECK 0 */
-/* OBSOLETE #if COMPILE_CHECK */
-/* OBSOLETE #define Q_REGNUM 0 */
-/* OBSOLETE #define VAB_REGNUM 0 */
-/* OBSOLETE #define CPS_REGNUM 0 */
-/* OBSOLETE #define IPA_REGNUM 0 */
-/* OBSOLETE #define IPB_REGNUM 0 */
-/* OBSOLETE #define GR1_REGNUM 0 */
-/* OBSOLETE #define LR0_REGNUM 0 */
-/* OBSOLETE #define IPC_REGNUM 0 */
-/* OBSOLETE #define CR_REGNUM 0 */
-/* OBSOLETE #define BP_REGNUM 0 */
-/* OBSOLETE #define FC_REGNUM 0 */
-/* OBSOLETE #define INTE_REGNUM 0 */
-/* OBSOLETE #define EXO_REGNUM 0 */
-/* OBSOLETE #define GR96_REGNUM 0 */
-/* OBSOLETE #define NPC_REGNUM */
-/* OBSOLETE #define FPE_REGNUM 0 */
-/* OBSOLETE #define PC2_REGNUM 0 */
-/* OBSOLETE #define FPS_REGNUM 0 */
-/* OBSOLETE #define ALU_REGNUM 0 */
-/* OBSOLETE #define LRU_REGNUM 0 */
-/* OBSOLETE #define TERMINAL int */
-/* OBSOLETE #define RAW 1 */
-/* OBSOLETE #define ANYP 1 */
-/* OBSOLETE extern int a29k_freeze_mode; */
-/* OBSOLETE extern int processor_type; */
-/* OBSOLETE extern char *processor_name; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /* External data declarations */ */
-/* OBSOLETE extern int stop_soon_quietly;	/* for wait_for_inferior */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Forward data declarations */ */
-/* OBSOLETE extern struct target_ops adapt_ops;	/* Forward declaration */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Forward function declarations */ */
-/* OBSOLETE static void adapt_fetch_registers (); */
-/* OBSOLETE static void adapt_store_registers (); */
-/* OBSOLETE static void adapt_close (); */
-/* OBSOLETE static int adapt_clear_breakpoints (); */
-/* OBSOLETE  */
-/* OBSOLETE #define FREEZE_MODE 	(read_register(CPS_REGNUM) && 0x400) */
-/* OBSOLETE #define USE_SHADOW_PC	((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
-/* OBSOLETE  */
-/* OBSOLETE /* Can't seem to get binary coff working */ */
-/* OBSOLETE #define ASCII_COFF		/* Adapt will be downloaded with ascii coff */ */
-/* OBSOLETE  */
-/* OBSOLETE /* FIXME: Replace with `set remotedebug'.  */ */
-/* OBSOLETE #define LOG_FILE "adapt.log" */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE FILE *log_file = NULL; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE static int timeout = 5; */
-/* OBSOLETE static char *dev_name; */
-/* OBSOLETE  */
-/* OBSOLETE /* Descriptor for I/O to remote machine.  Initialize it to -1 so that */
-/* OBSOLETE    adapt_open knows that we don't have a file open when the program */
-/* OBSOLETE    starts.  */ */
-/* OBSOLETE int adapt_desc = -1; */
-/* OBSOLETE  */
-/* OBSOLETE /* stream which is fdopen'd from adapt_desc.  Only valid when */
-/* OBSOLETE    adapt_desc != -1.  */ */
-/* OBSOLETE FILE *adapt_stream; */
-/* OBSOLETE  */
-/* OBSOLETE #define ON	1 */
-/* OBSOLETE #define OFF	0 */
-/* OBSOLETE static void */
-/* OBSOLETE rawmode (int desc, int turnon) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   TERMINAL sg; */
-/* OBSOLETE  */
-/* OBSOLETE   if (desc < 0) */
-/* OBSOLETE     return; */
-/* OBSOLETE  */
-/* OBSOLETE   ioctl (desc, TIOCGETP, &sg); */
-/* OBSOLETE  */
-/* OBSOLETE   if (turnon) */
-/* OBSOLETE     { */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE       sg.c_lflag &= ~(ICANON); */
-/* OBSOLETE #else */
-/* OBSOLETE       sg.sg_flags |= RAW; */
-/* OBSOLETE #endif */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE       sg.c_lflag |= ICANON; */
-/* OBSOLETE #else */
-/* OBSOLETE       sg.sg_flags &= ~(RAW); */
-/* OBSOLETE #endif */
-/* OBSOLETE     } */
-/* OBSOLETE   ioctl (desc, TIOCSETP, &sg); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Suck up all the input from the adapt */ */
-/* OBSOLETE slurp_input (void) */
-/* OBSOLETE { */
-/* OBSOLETE   char buf[8]; */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   /* termio does the timeout for us.  */ */
-/* OBSOLETE   while (read (adapt_desc, buf, 8) > 0); */
-/* OBSOLETE #else */
-/* OBSOLETE   alarm (timeout); */
-/* OBSOLETE   while (read (adapt_desc, buf, 8) > 0); */
-/* OBSOLETE   alarm (0); */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Read a character from the remote system, doing all the fancy */
-/* OBSOLETE    timeout stuff.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE readchar (void) */
-/* OBSOLETE { */
-/* OBSOLETE   char buf; */
-/* OBSOLETE  */
-/* OBSOLETE   buf = '\0'; */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   /* termio does the timeout for us.  */ */
-/* OBSOLETE   read (adapt_desc, &buf, 1); */
-/* OBSOLETE #else */
-/* OBSOLETE   alarm (timeout); */
-/* OBSOLETE   if (read (adapt_desc, &buf, 1) < 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (errno == EINTR) */
-/* OBSOLETE 	error ("Timeout reading from remote system."); */
-/* OBSOLETE       else */
-/* OBSOLETE 	perror_with_name ("remote"); */
-/* OBSOLETE     } */
-/* OBSOLETE   alarm (0); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   if (buf == '\0') */
-/* OBSOLETE     error ("Timeout reading from remote system."); */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   putc (buf & 0x7f, log_file); */
-/* OBSOLETE #endif */
-/* OBSOLETE   return buf & 0x7f; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Keep discarding input from the remote system, until STRING is found.  */
-/* OBSOLETE    Let the user break out immediately.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE expect (char *string) */
-/* OBSOLETE { */
-/* OBSOLETE   char *p = string; */
-/* OBSOLETE  */
-/* OBSOLETE   fflush (adapt_stream); */
-/* OBSOLETE   immediate_quit++; */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (readchar () == *p) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  p++; */
-/* OBSOLETE 	  if (*p == '\0') */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      immediate_quit--; */
-/* OBSOLETE 	      return; */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	p = string; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Keep discarding input until we see the adapt prompt. */
-/* OBSOLETE  */
-/* OBSOLETE    The convention for dealing with the prompt is that you */
-/* OBSOLETE    o give your command */
-/* OBSOLETE    o *then* wait for the prompt. */
-/* OBSOLETE  */
-/* OBSOLETE    Thus the last thing that a procedure does with the serial line */
-/* OBSOLETE    will be an expect_prompt().  Exception:  adapt_resume does not */
-/* OBSOLETE    wait for the prompt, because the terminal is being handed over */
-/* OBSOLETE    to the inferior.  However, the next thing which happens after that */
-/* OBSOLETE    is a adapt_wait which does wait for the prompt. */
-/* OBSOLETE    Note that this includes abnormal exit, e.g. error().  This is */
-/* OBSOLETE    necessary to prevent getting into states from which we can't */
-/* OBSOLETE    recover.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE expect_prompt (void) */
-/* OBSOLETE { */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   /* This is a convenient place to do this.  The idea is to do it often */
-/* OBSOLETE      enough that we never lose much data if we terminate abnormally.  */ */
-/* OBSOLETE   fflush (log_file); */
-/* OBSOLETE #endif */
-/* OBSOLETE   fflush (adapt_stream); */
-/* OBSOLETE   expect ("\n# "); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get a hex digit from the remote system & return its value. */
-/* OBSOLETE    If ignore_space is nonzero, ignore spaces (not newline, tab, etc).  */ */
-/* OBSOLETE static int */
-/* OBSOLETE get_hex_digit (int ignore_space) */
-/* OBSOLETE { */
-/* OBSOLETE   int ch; */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       ch = readchar (); */
-/* OBSOLETE       if (ch >= '0' && ch <= '9') */
-/* OBSOLETE 	return ch - '0'; */
-/* OBSOLETE       else if (ch >= 'A' && ch <= 'F') */
-/* OBSOLETE 	return ch - 'A' + 10; */
-/* OBSOLETE       else if (ch >= 'a' && ch <= 'f') */
-/* OBSOLETE 	return ch - 'a' + 10; */
-/* OBSOLETE       else if (ch == ' ' && ignore_space) */
-/* OBSOLETE 	; */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  expect_prompt (); */
-/* OBSOLETE 	  error ("Invalid hex digit from remote system."); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get a byte from adapt_desc and put it in *BYT.  Accept any number */
-/* OBSOLETE    leading spaces.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE get_hex_byte (char *byt) */
-/* OBSOLETE { */
-/* OBSOLETE   int val; */
-/* OBSOLETE  */
-/* OBSOLETE   val = get_hex_digit (1) << 4; */
-/* OBSOLETE   val |= get_hex_digit (0); */
-/* OBSOLETE   *byt = val; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Read a 32-bit hex word from the adapt, preceded by a space  */ */
-/* OBSOLETE static long */
-/* OBSOLETE get_hex_word (void) */
-/* OBSOLETE { */
-/* OBSOLETE   long val; */
-/* OBSOLETE   int j; */
-/* OBSOLETE  */
-/* OBSOLETE   val = 0; */
-/* OBSOLETE   for (j = 0; j < 8; j++) */
-/* OBSOLETE     val = (val << 4) + get_hex_digit (j == 0); */
-/* OBSOLETE   return val; */
-/* OBSOLETE } */
-/* OBSOLETE /* Get N 32-bit hex words from remote, each preceded by a space  */
-/* OBSOLETE    and put them in registers starting at REGNO.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE get_hex_regs (int n, int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   long val; */
-/* OBSOLETE   while (n--) */
-/* OBSOLETE     { */
-/* OBSOLETE       val = get_hex_word (); */
-/* OBSOLETE       supply_register (regno++, (char *) &val); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout.  */ */
-/* OBSOLETE #ifndef HAVE_TERMIO */
-/* OBSOLETE  */
-/* OBSOLETE volatile int n_alarms; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE adapt_timer (void) */
-/* OBSOLETE { */
-/* OBSOLETE #if 0 */
-/* OBSOLETE   if (kiodebug) */
-/* OBSOLETE     printf ("adapt_timer called\n"); */
-/* OBSOLETE #endif */
-/* OBSOLETE   n_alarms++; */
-/* OBSOLETE } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /* malloc'd name of the program on the remote system.  */ */
-/* OBSOLETE static char *prog_name = NULL; */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of SIGTRAPs we need to simulate.  That is, the next */
-/* OBSOLETE    NEED_ARTIFICIAL_TRAP calls to adapt_wait should just return */
-/* OBSOLETE    SIGTRAP without actually waiting for anything.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static int need_artificial_trap = 0; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE adapt_kill (char *arg, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   fprintf (adapt_stream, "K"); */
-/* OBSOLETE   fprintf (adapt_stream, "\r"); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE /* */
-/* OBSOLETE  * Download a file specified in 'args', to the adapt.  */
-/* OBSOLETE  * FIXME: Assumes the file to download is a binary coff file. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_load (char *args, int fromtty) */
-/* OBSOLETE { */
-/* OBSOLETE   FILE *fp; */
-/* OBSOLETE   int n; */
-/* OBSOLETE   char buffer[1024]; */
-/* OBSOLETE  */
-/* OBSOLETE   if (!adapt_stream) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf_filtered ("Adapt not open. Use 'target' command to open adapt\n"); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* OK, now read in the file.  Y=read, C=COFF, T=dTe port */
-/* OBSOLETE      0=start address.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef ASCII_COFF		/* Ascii coff */ */
-/* OBSOLETE   fprintf (adapt_stream, "YA T,0\r"); */
-/* OBSOLETE   fflush (adapt_stream);	/* Just in case */ */
-/* OBSOLETE   /* FIXME: should check args for only 1 argument */ */
-/* OBSOLETE   sprintf (buffer, "cat %s | btoa > /tmp/#adapt-btoa", args); */
-/* OBSOLETE   system (buffer); */
-/* OBSOLETE   fp = fopen ("/tmp/#adapt-btoa", "r"); */
-/* OBSOLETE   rawmode (adapt_desc, OFF); */
-/* OBSOLETE   while (n = fread (buffer, 1, 1024, fp)) */
-/* OBSOLETE     { */
-/* OBSOLETE       do */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  n -= write (adapt_desc, buffer, n); */
-/* OBSOLETE 	} */
-/* OBSOLETE       while (n > 0); */
-/* OBSOLETE       if (n < 0) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  perror ("writing ascii coff"); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   fclose (fp); */
-/* OBSOLETE   rawmode (adapt_desc, ON); */
-/* OBSOLETE   system ("rm /tmp/#adapt-btoa"); */
-/* OBSOLETE #else /* Binary coff - can't get it to work . */ */
-/* OBSOLETE   fprintf (adapt_stream, "YC T,0\r"); */
-/* OBSOLETE   fflush (adapt_stream);	/* Just in case */ */
-/* OBSOLETE   if (!(fp = fopen (args, "r"))) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf_filtered ("Can't open %s\n", args); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE   while (n = fread (buffer, 1, 512, fp)) */
-/* OBSOLETE     { */
-/* OBSOLETE       do */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  n -= write (adapt_desc, buffer, n); */
-/* OBSOLETE 	} */
-/* OBSOLETE       while (n > 0); */
-/* OBSOLETE       if (n < 0) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  perror ("writing ascii coff"); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   fclose (fp); */
-/* OBSOLETE #endif */
-/* OBSOLETE   expect_prompt ();		/* Skip garbage that comes out */ */
-/* OBSOLETE   fprintf (adapt_stream, "\r"); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* This is called not only when we first attach, but also when the */
-/* OBSOLETE    user types "run" after having attached.  */ */
-/* OBSOLETE void */
-/* OBSOLETE adapt_create_inferior (char *execfile, char *args, char **env) */
-/* OBSOLETE { */
-/* OBSOLETE   int entry_pt; */
-/* OBSOLETE  */
-/* OBSOLETE   if (args && *args) */
-/* OBSOLETE     error ("Can't pass arguments to remote adapt process."); */
-/* OBSOLETE  */
-/* OBSOLETE   if (execfile == 0 || exec_bfd == 0) */
-/* OBSOLETE     error ("No executable file specified"); */
-/* OBSOLETE  */
-/* OBSOLETE   entry_pt = (int) bfd_get_start_address (exec_bfd); */
-/* OBSOLETE  */
-/* OBSOLETE   if (adapt_stream) */
-/* OBSOLETE     { */
-/* OBSOLETE       adapt_kill (NULL, NULL); */
-/* OBSOLETE       adapt_clear_breakpoints (); */
-/* OBSOLETE       init_wait_for_inferior (); */
-/* OBSOLETE       /* Clear the input because what the adapt sends back is different */
-/* OBSOLETE        * depending on whether it was running or not. */
-/* OBSOLETE        */ */
-/* OBSOLETE       slurp_input ();		/* After this there should be a prompt */ */
-/* OBSOLETE       fprintf (adapt_stream, "\r"); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE       printf_filtered ("Do you want to download '%s' (y/n)? [y] : ", prog_name); */
-/* OBSOLETE       { */
-/* OBSOLETE 	char buffer[10]; */
-/* OBSOLETE 	gets (buffer); */
-/* OBSOLETE 	if (*buffer != 'n') */
-/* OBSOLETE 	  { */
-/* OBSOLETE 	    adapt_load (prog_name, 0); */
-/* OBSOLETE 	  } */
-/* OBSOLETE       } */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef NOTDEF */
-/* OBSOLETE       /* Set the PC and wait for a go/cont */ */
-/* OBSOLETE       fprintf (adapt_stream, "G %x,N\r", entry_pt); */
-/* OBSOLETE       printf_filtered ("Now use the 'continue' command to start.\n"); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE #else */
-/* OBSOLETE       insert_breakpoints ();	/* Needed to get correct instruction in cache */ */
-/* OBSOLETE       proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       printf_filtered ("Adapt not open yet.\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Translate baud rates from integers to damn B_codes.  Unix should */
-/* OBSOLETE    have outgrown this crap years ago, but even POSIX wouldn't buck it.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef B19200 */
-/* OBSOLETE #define B19200 EXTA */
-/* OBSOLETE #endif */
-/* OBSOLETE #ifndef B38400 */
-/* OBSOLETE #define B38400 EXTB */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE static struct */
-/* OBSOLETE { */
-/* OBSOLETE   int rate, damn_b; */
-/* OBSOLETE } */
-/* OBSOLETE baudtab[] = */
-/* OBSOLETE { */
-/* OBSOLETE   { */
-/* OBSOLETE     0, B0 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     50, B50 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     75, B75 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     110, B110 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     134, B134 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     150, B150 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     200, B200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     300, B300 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     600, B600 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     1200, B1200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     1800, B1800 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     2400, B2400 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     4800, B4800 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     9600, B9600 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     19200, B19200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     38400, B38400 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     -1, -1 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE static int */
-/* OBSOLETE damn_b (int rate) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; baudtab[i].rate != -1; i++) */
-/* OBSOLETE     if (rate == baudtab[i].rate) */
-/* OBSOLETE       return baudtab[i].damn_b; */
-/* OBSOLETE   return B38400;		/* Random */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Open a connection to a remote debugger. */
-/* OBSOLETE    NAME is the filename used for communication, then a space, */
-/* OBSOLETE    then the baud rate. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE static int baudrate = 9600; */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_open (char *name, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   TERMINAL sg; */
-/* OBSOLETE   unsigned int prl; */
-/* OBSOLETE   char *p; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Find the first whitespace character, it separates dev_name from */
-/* OBSOLETE      prog_name.  */ */
-/* OBSOLETE   if (name == 0) */
-/* OBSOLETE     goto erroid; */
-/* OBSOLETE  */
-/* OBSOLETE   for (p = name; */
-/* OBSOLETE        *p != '\0' && !isspace (*p); p++) */
-/* OBSOLETE     ; */
-/* OBSOLETE   if (*p == '\0') */
-/* OBSOLETE   erroid: */
-/* OBSOLETE     error ("\ */
-/* OBSOLETE Please include the name of the device for the serial port,\n\ */
-/* OBSOLETE the baud rate, and the name of the program to run on the remote system."); */
-/* OBSOLETE   dev_name = (char *) xmalloc (p - name + 1); */
-/* OBSOLETE   strncpy (dev_name, name, p - name); */
-/* OBSOLETE   dev_name[p - name] = '\0'; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Skip over the whitespace after dev_name */ */
-/* OBSOLETE   for (; isspace (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE  */
-/* OBSOLETE   if (1 != sscanf (p, "%d ", &baudrate)) */
-/* OBSOLETE     goto erroid; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Skip the number and then the spaces */ */
-/* OBSOLETE   for (; isdigit (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE   for (; isspace (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE  */
-/* OBSOLETE   if (prog_name != NULL) */
-/* OBSOLETE     xfree (prog_name); */
-/* OBSOLETE   prog_name = savestring (p, strlen (p)); */
-/* OBSOLETE  */
-/* OBSOLETE   adapt_close (0); */
-/* OBSOLETE  */
-/* OBSOLETE   adapt_desc = open (dev_name, O_RDWR); */
-/* OBSOLETE   if (adapt_desc < 0) */
-/* OBSOLETE     perror_with_name (dev_name); */
-/* OBSOLETE   ioctl (adapt_desc, TIOCGETP, &sg); */
-/* OBSOLETE #if ! defined(COMPILE_CHECK) */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   sg.c_cc[VMIN] = 0;		/* read with timeout.  */ */
-/* OBSOLETE   sg.c_cc[VTIME] = timeout * 10; */
-/* OBSOLETE   sg.c_lflag &= ~(ICANON | ECHO); */
-/* OBSOLETE   sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
-/* OBSOLETE #else */
-/* OBSOLETE   sg.sg_ispeed = damn_b (baudrate); */
-/* OBSOLETE   sg.sg_ospeed = damn_b (baudrate); */
-/* OBSOLETE   sg.sg_flags |= RAW | ANYP; */
-/* OBSOLETE   sg.sg_flags &= ~ECHO; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   ioctl (adapt_desc, TIOCSETP, &sg); */
-/* OBSOLETE   adapt_stream = fdopen (adapt_desc, "r+"); */
-/* OBSOLETE #endif /* compile_check */ */
-/* OBSOLETE   push_target (&adapt_ops); */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef HAVE_TERMIO */
-/* OBSOLETE #ifndef NO_SIGINTERRUPT */
-/* OBSOLETE   /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
-/* OBSOLETE      the read.  */ */
-/* OBSOLETE   if (siginterrupt (SIGALRM, 1) != 0) */
-/* OBSOLETE     perror ("adapt_open: error in siginterrupt"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set up read timeout timer.  */ */
-/* OBSOLETE   if ((void (*)) signal (SIGALRM, adapt_timer) == (void (*)) -1) */
-/* OBSOLETE     perror ("adapt_open: error in signal"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   log_file = fopen (LOG_FILE, "w"); */
-/* OBSOLETE   if (log_file == NULL) */
-/* OBSOLETE     perror_with_name (LOG_FILE); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   /* Put this port into NORMAL mode, send the 'normal' character */ */
-/* OBSOLETE   write (adapt_desc, "", 1);	/* Control A */ */
-/* OBSOLETE   write (adapt_desc, "\r", 1); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Hello?  Are you there?  */ */
-/* OBSOLETE   write (adapt_desc, "\r", 1); */
-/* OBSOLETE  */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Clear any break points */ */
-/* OBSOLETE   adapt_clear_breakpoints (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Print out some stuff, letting the user now what's going on */ */
-/* OBSOLETE   printf_filtered ("Connected to an Adapt via %s.\n", dev_name); */
-/* OBSOLETE   /* FIXME: can this restriction be removed? */ */
-/* OBSOLETE   printf_filtered ("Remote debugging using virtual addresses works only\n"); */
-/* OBSOLETE   printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n"); */
-/* OBSOLETE   if (processor_type != a29k_freeze_mode) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, */
-/* OBSOLETE 			"Freeze-mode debugging not available, and can only be done on an A29050.\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Close out all files and local state before this target loses control. */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_close (int quitting) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   /* Clear any break points */ */
-/* OBSOLETE   adapt_clear_breakpoints (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Put this port back into REMOTE mode */ */
-/* OBSOLETE   if (adapt_stream) */
-/* OBSOLETE     { */
-/* OBSOLETE       fflush (adapt_stream); */
-/* OBSOLETE       sleep (1);		/* Let any output make it all the way back */ */
-/* OBSOLETE       write (adapt_desc, "R\r", 2); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Due to a bug in Unix, fclose closes not only the stdio stream, */
-/* OBSOLETE      but also the file descriptor.  So we don't actually close */
-/* OBSOLETE      adapt_desc.  */ */
-/* OBSOLETE   if (adapt_stream) */
-/* OBSOLETE     fclose (adapt_stream);	/* This also closes adapt_desc */ */
-/* OBSOLETE   if (adapt_desc >= 0) */
-/* OBSOLETE     /* close (adapt_desc); */ */
-/* OBSOLETE  */
-/* OBSOLETE     /* Do not try to close adapt_desc again, later in the program.  */ */
-/* OBSOLETE     adapt_stream = NULL; */
-/* OBSOLETE   adapt_desc = -1; */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   if (log_file) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (ferror (log_file)) */
-/* OBSOLETE 	printf_filtered ("Error writing log file.\n"); */
-/* OBSOLETE       if (fclose (log_file) != 0) */
-/* OBSOLETE 	printf_filtered ("Error closing log file.\n"); */
-/* OBSOLETE       log_file = NULL; */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Attach to the target that is already loaded and possibly running */ */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_attach (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf_filtered ("Attaching to remote program %s.\n", prog_name); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Send the adapt a kill. It is ok if it is not already running */ */
-/* OBSOLETE   fprintf (adapt_stream, "K\r"); */
-/* OBSOLETE   fflush (adapt_stream); */
-/* OBSOLETE   expect_prompt ();		/* Slurp the echo */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Terminate the open connection to the remote debugger. */
-/* OBSOLETE    Use this when you want to detach and do something else */
-/* OBSOLETE    with your gdb.  */ */
-/* OBSOLETE void */
-/* OBSOLETE adapt_detach (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   if (adapt_stream) */
-/* OBSOLETE     {				/* Send it on its way (tell it to continue)  */ */
-/* OBSOLETE       adapt_clear_breakpoints (); */
-/* OBSOLETE       fprintf (adapt_stream, "G\r"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   pop_target ();		/* calls adapt_close to do the real work */ */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf_filtered ("Ending remote %s debugging\n", target_shortname); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Tell the remote machine to resume.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE adapt_resume (ptid_t ptid, int step, enum target_signal sig) */
-/* OBSOLETE { */
-/* OBSOLETE   if (step) */
-/* OBSOLETE     { */
-/* OBSOLETE       write (adapt_desc, "t 1,s\r", 6); */
-/* OBSOLETE       /* Wait for the echo.  */ */
-/* OBSOLETE       expect ("t 1,s\r\n"); */
-/* OBSOLETE       /* Then comes a line containing the instruction we stepped to.  */ */
-/* OBSOLETE       expect ("@"); */
-/* OBSOLETE       /* Then we get the prompt.  */ */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE       /* Force the next adapt_wait to return a trap.  Not doing anything */
-/* OBSOLETE          about I/O from the target means that the user has to type */
-/* OBSOLETE          "continue" to see any.  FIXME, this should be fixed.  */ */
-/* OBSOLETE       need_artificial_trap = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       write (adapt_desc, "G\r", 2); */
-/* OBSOLETE       /* Swallow the echo.  */ */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Wait until the remote machine stops, then return, */
-/* OBSOLETE    storing status in STATUS just as `wait' would.  */ */
-/* OBSOLETE  */
-/* OBSOLETE ptid_t */
-/* OBSOLETE adapt_wait (ptid_t ptid, struct target_waitstatus *status) */
-/* OBSOLETE { */
-/* OBSOLETE   /* Strings to look for.  '?' means match any single character.   */
-/* OBSOLETE      Note that with the algorithm we use, the initial character */
-/* OBSOLETE      of the string cannot recur in the string, or we will not */
-/* OBSOLETE      find some cases of the string in the input.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   static char bpt[] = "@"; */
-/* OBSOLETE   /* It would be tempting to look for "\n[__exit + 0x8]\n" */
-/* OBSOLETE      but that requires loading symbols with "yc i" and even if */
-/* OBSOLETE      we did do that we don't know that the file has symbols.  */ */
-/* OBSOLETE   static char exitmsg[] = "@????????I    JMPTI     GR121,LR0"; */
-/* OBSOLETE   char *bp = bpt; */
-/* OBSOLETE   char *ep = exitmsg; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.  */ */
-/* OBSOLETE   char swallowed[50]; */
-/* OBSOLETE   /* Current position in swallowed.  */ */
-/* OBSOLETE   char *swallowed_p = swallowed; */
-/* OBSOLETE  */
-/* OBSOLETE   int ch; */
-/* OBSOLETE   int ch_handled; */
-/* OBSOLETE   int old_timeout = timeout; */
-/* OBSOLETE   int old_immediate_quit = immediate_quit; */
-/* OBSOLETE  */
-/* OBSOLETE   status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE   status->value.integer = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (need_artificial_trap != 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE       need_artificial_trap--; */
-/* OBSOLETE       return inferior_ptid; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   timeout = 0;			/* Don't time out -- user program is running. */ */
-/* OBSOLETE   immediate_quit = 1;		/* Helps ability to QUIT */ */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       QUIT;			/* Let user quit and leave process running */ */
-/* OBSOLETE       ch_handled = 0; */
-/* OBSOLETE       ch = readchar (); */
-/* OBSOLETE       if (ch == *bp) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  bp++; */
-/* OBSOLETE 	  if (*bp == '\0') */
-/* OBSOLETE 	    break; */
-/* OBSOLETE 	  ch_handled = 1; */
-/* OBSOLETE  */
-/* OBSOLETE 	  *swallowed_p++ = ch; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	bp = bpt; */
-/* OBSOLETE       if (ch == *ep || *ep == '?') */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  ep++; */
-/* OBSOLETE 	  if (*ep == '\0') */
-/* OBSOLETE 	    break; */
-/* OBSOLETE  */
-/* OBSOLETE 	  if (!ch_handled) */
-/* OBSOLETE 	    *swallowed_p++ = ch; */
-/* OBSOLETE 	  ch_handled = 1; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	ep = exitmsg; */
-/* OBSOLETE       if (!ch_handled) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  char *p; */
-/* OBSOLETE 	  /* Print out any characters which have been swallowed.  */ */
-/* OBSOLETE 	  for (p = swallowed; p < swallowed_p; ++p) */
-/* OBSOLETE 	    putc (*p, stdout); */
-/* OBSOLETE 	  swallowed_p = swallowed; */
-/* OBSOLETE 	  putc (ch, stdout); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   if (*bp == '\0') */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE       status->value.integer = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE   timeout = old_timeout; */
-/* OBSOLETE   immediate_quit = old_immediate_quit; */
-/* OBSOLETE   return inferior_ptid; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Return the name of register number REGNO */
-/* OBSOLETE    in the form input and output by adapt. */
-/* OBSOLETE  */
-/* OBSOLETE    Returns a pointer to a static buffer containing the answer.  */ */
-/* OBSOLETE static char * */
-/* OBSOLETE get_reg_name (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   static char buf[80]; */
-/* OBSOLETE   if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
-/* OBSOLETE     sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE   else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
-/* OBSOLETE     sprintf (buf, "GR%03d", regno - GR64_REGNUM + 64); */
-/* OBSOLETE #endif */
-/* OBSOLETE   else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
-/* OBSOLETE     sprintf (buf, "LR%03d", regno - LR0_REGNUM); */
-/* OBSOLETE   else if (regno == Q_REGNUM) */
-/* OBSOLETE     strcpy (buf, "SR131"); */
-/* OBSOLETE   else if (regno >= BP_REGNUM && regno <= CR_REGNUM) */
-/* OBSOLETE     sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); */
-/* OBSOLETE   else if (regno == ALU_REGNUM) */
-/* OBSOLETE     strcpy (buf, "SR132"); */
-/* OBSOLETE   else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) */
-/* OBSOLETE     sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); */
-/* OBSOLETE   else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* When a 29050 is in freeze-mode, read shadow pcs instead */ */
-/* OBSOLETE       if ((regno >= NPC_REGNUM && regno <= PC2_REGNUM) && USE_SHADOW_PC) */
-/* OBSOLETE 	sprintf (buf, "SR%03d", regno - NPC_REGNUM + 20); */
-/* OBSOLETE       else */
-/* OBSOLETE 	sprintf (buf, "SR%03d", regno - VAB_REGNUM); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno == GR1_REGNUM) */
-/* OBSOLETE     strcpy (buf, "GR001"); */
-/* OBSOLETE   return buf; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Read the remote registers.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_fetch_registers (void) */
-/* OBSOLETE { */
-/* OBSOLETE   int reg_index; */
-/* OBSOLETE   int regnum_index; */
-/* OBSOLETE   char tempbuf[10]; */
-/* OBSOLETE   int sreg_buf[16]; */
-/* OBSOLETE   int i, j; */
-/* OBSOLETE  */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Global registers */
-/* OBSOLETE  */ */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE   write (adapt_desc, "dw gr64,gr95\r", 13); */
-/* OBSOLETE   for (reg_index = 64, regnum_index = GR64_REGNUM; */
-/* OBSOLETE        reg_index < 96; */
-/* OBSOLETE        reg_index += 4, regnum_index += 4) */
-/* OBSOLETE     { */
-/* OBSOLETE       sprintf (tempbuf, "GR%03d ", reg_index); */
-/* OBSOLETE       expect (tempbuf); */
-/* OBSOLETE       get_hex_regs (4, regnum_index); */
-/* OBSOLETE       expect ("\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE   write (adapt_desc, "dw gr96,gr127\r", 14); */
-/* OBSOLETE   for (reg_index = 96, regnum_index = GR96_REGNUM; */
-/* OBSOLETE        reg_index < 128; */
-/* OBSOLETE        reg_index += 4, regnum_index += 4) */
-/* OBSOLETE     { */
-/* OBSOLETE       sprintf (tempbuf, "GR%03d ", reg_index); */
-/* OBSOLETE       expect (tempbuf); */
-/* OBSOLETE       get_hex_regs (4, regnum_index); */
-/* OBSOLETE       expect ("\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Local registers */
-/* OBSOLETE  */ */
-/* OBSOLETE   for (i = 0; i < 128; i += 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* The PC has a tendency to hang if we get these */
-/* OBSOLETE          all in one fell swoop ("dw lr0,lr127").  */ */
-/* OBSOLETE       sprintf (tempbuf, "dw lr%d\r", i); */
-/* OBSOLETE       write (adapt_desc, tempbuf, strlen (tempbuf)); */
-/* OBSOLETE       for (reg_index = i, regnum_index = LR0_REGNUM + i; */
-/* OBSOLETE 	   reg_index < i + 32; */
-/* OBSOLETE 	   reg_index += 4, regnum_index += 4) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  sprintf (tempbuf, "LR%03d ", reg_index); */
-/* OBSOLETE 	  expect (tempbuf); */
-/* OBSOLETE 	  get_hex_regs (4, regnum_index); */
-/* OBSOLETE 	  expect ("\n"); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Special registers */
-/* OBSOLETE  */ */
-/* OBSOLETE   sprintf (tempbuf, "dw sr0\r"); */
-/* OBSOLETE   write (adapt_desc, tempbuf, strlen (tempbuf)); */
-/* OBSOLETE   for (i = 0; i < 4; i++) */
-/* OBSOLETE     {				/* SR0 - SR14 */ */
-/* OBSOLETE       sprintf (tempbuf, "SR%3d", i * 4); */
-/* OBSOLETE       expect (tempbuf); */
-/* OBSOLETE       for (j = 0; j < (i == 3 ? 3 : 4); j++) */
-/* OBSOLETE 	sreg_buf[i * 4 + j] = get_hex_word (); */
-/* OBSOLETE     } */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   /*  */
-/* OBSOLETE    * Read the pcs individually if we are in freeze mode. */
-/* OBSOLETE    * See get_reg_name(), it translates the register names for the pcs to */
-/* OBSOLETE    * the names of the shadow pcs. */
-/* OBSOLETE    */ */
-/* OBSOLETE   if (USE_SHADOW_PC) */
-/* OBSOLETE     { */
-/* OBSOLETE       sreg_buf[10] = read_register (NPC_REGNUM);	/* pc0 */ */
-/* OBSOLETE       sreg_buf[11] = read_register (PC_REGNUM);		/* pc1 */ */
-/* OBSOLETE       sreg_buf[12] = read_register (PC2_REGNUM);	/* pc2 */ */
-/* OBSOLETE     } */
-/* OBSOLETE   for (i = 0; i < 14; i++)	/* Supply vab -> lru */ */
-/* OBSOLETE     supply_register (VAB_REGNUM + i, (char *) &sreg_buf[i]); */
-/* OBSOLETE   sprintf (tempbuf, "dw sr128\r"); */
-/* OBSOLETE   write (adapt_desc, tempbuf, strlen (tempbuf)); */
-/* OBSOLETE   for (i = 0; i < 2; i++) */
-/* OBSOLETE     {				/* SR128 - SR135 */ */
-/* OBSOLETE       sprintf (tempbuf, "SR%3d", 128 + i * 4); */
-/* OBSOLETE       expect (tempbuf); */
-/* OBSOLETE       for (j = 0; j < 4; j++) */
-/* OBSOLETE 	sreg_buf[i * 4 + j] = get_hex_word (); */
-/* OBSOLETE     } */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   supply_register (IPC_REGNUM, (char *) &sreg_buf[0]); */
-/* OBSOLETE   supply_register (IPA_REGNUM, (char *) &sreg_buf[1]); */
-/* OBSOLETE   supply_register (IPB_REGNUM, (char *) &sreg_buf[2]); */
-/* OBSOLETE   supply_register (Q_REGNUM, (char *) &sreg_buf[3]); */
-/* OBSOLETE   /* Skip ALU */ */
-/* OBSOLETE   supply_register (BP_REGNUM, (char *) &sreg_buf[5]); */
-/* OBSOLETE   supply_register (FC_REGNUM, (char *) &sreg_buf[6]); */
-/* OBSOLETE   supply_register (CR_REGNUM, (char *) &sreg_buf[7]); */
-/* OBSOLETE  */
-/* OBSOLETE   /* There doesn't seem to be any way to get these.  */ */
-/* OBSOLETE   { */
-/* OBSOLETE     int val = -1; */
-/* OBSOLETE     supply_register (FPE_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (INTE_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (FPS_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (EXO_REGNUM, (char *) &val); */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE   write (adapt_desc, "dw gr1,gr1\r", 11); */
-/* OBSOLETE   expect ("GR001 "); */
-/* OBSOLETE   get_hex_regs (1, GR1_REGNUM); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_fetch_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   if (regno == -1) */
-/* OBSOLETE     adapt_fetch_registers (); */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       char *name = get_reg_name (regno); */
-/* OBSOLETE       fprintf (adapt_stream, "dw %s,%s\r", name, name); */
-/* OBSOLETE       expect (name); */
-/* OBSOLETE       expect (" "); */
-/* OBSOLETE       get_hex_regs (1, regno); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Store the remote registers from the contents of the block REGS.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_store_registers (void) */
-/* OBSOLETE { */
-/* OBSOLETE   int i, j; */
-/* OBSOLETE  */
-/* OBSOLETE   fprintf (adapt_stream, "s gr1,%x\r", read_register (GR1_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE   for (j = 0; j < 32; j += 16) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf (adapt_stream, "s gr%d,", j + 64); */
-/* OBSOLETE       for (i = 0; i < 15; ++i) */
-/* OBSOLETE 	fprintf (adapt_stream, "%x,", read_register (GR64_REGNUM + j + i)); */
-/* OBSOLETE       fprintf (adapt_stream, "%x\r", read_register (GR64_REGNUM + j + 15)); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE   for (j = 0; j < 32; j += 16) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf (adapt_stream, "s gr%d,", j + 96); */
-/* OBSOLETE       for (i = 0; i < 15; ++i) */
-/* OBSOLETE 	fprintf (adapt_stream, "%x,", read_register (GR96_REGNUM + j + i)); */
-/* OBSOLETE       fprintf (adapt_stream, "%x\r", read_register (GR96_REGNUM + j + 15)); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   for (j = 0; j < 128; j += 16) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf (adapt_stream, "s lr%d,", j); */
-/* OBSOLETE       for (i = 0; i < 15; ++i) */
-/* OBSOLETE 	fprintf (adapt_stream, "%x,", read_register (LR0_REGNUM + j + i)); */
-/* OBSOLETE       fprintf (adapt_stream, "%x\r", read_register (LR0_REGNUM + j + 15)); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   fprintf (adapt_stream, "s sr128,%x,%x,%x\r", read_register (IPC_REGNUM), */
-/* OBSOLETE 	   read_register (IPA_REGNUM), read_register (IPB_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   fprintf (adapt_stream, "s sr133,%x,%x,%x\r", read_register (BP_REGNUM), */
-/* OBSOLETE 	   read_register (FC_REGNUM), read_register (CR_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   fprintf (adapt_stream, "s sr131,%x\r", read_register (Q_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   fprintf (adapt_stream, "s sr0,"); */
-/* OBSOLETE   for (i = 0; i < 7; ++i) */
-/* OBSOLETE     fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   fprintf (adapt_stream, "s sr7,"); */
-/* OBSOLETE   for (i = 7; i < 14; ++i) */
-/* OBSOLETE     fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Store register REGNO, or all if REGNO == -1. */
-/* OBSOLETE    Return errno value.  */ */
-/* OBSOLETE void */
-/* OBSOLETE adapt_store_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   /* printf("adapt_store_register() called.\n"); fflush(stdout); /* */ */
-/* OBSOLETE   if (regno == -1) */
-/* OBSOLETE     adapt_store_registers (); */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       char *name = get_reg_name (regno); */
-/* OBSOLETE       fprintf (adapt_stream, "s %s,%x\r", name, read_register (regno)); */
-/* OBSOLETE       /* Setting GR1 changes the numbers of all the locals, so */
-/* OBSOLETE          invalidate the register cache.  Do this *after* calling */
-/* OBSOLETE          read_register, because we want read_register to return the */
-/* OBSOLETE          value that write_register has just stuffed into the registers */
-/* OBSOLETE          array, not the value of the register fetched from the */
-/* OBSOLETE          inferior.  */ */
-/* OBSOLETE       if (regno == GR1_REGNUM) */
-/* OBSOLETE 	registers_changed (); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get ready to modify the registers array.  On machines which store */
-/* OBSOLETE    individual registers, this doesn't need to do anything.  On machines */
-/* OBSOLETE    which store all the registers in one fell swoop, this makes sure */
-/* OBSOLETE    that registers contains all the registers from the program being */
-/* OBSOLETE    debugged.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE adapt_prepare_to_store (void) */
-/* OBSOLETE { */
-/* OBSOLETE   /* Do nothing, since we can store individual regs */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static CORE_ADDR */
-/* OBSOLETE translate_addr (CORE_ADDR addr) */
-/* OBSOLETE { */
-/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
-/* OBSOLETE   /* Check for a virtual address in the kernel */ */
-/* OBSOLETE   /* Assume physical address of ublock is in  paddr_u register */ */
-/* OBSOLETE   if (addr >= UVADDR) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* PADDR_U register holds the physical address of the ublock */ */
-/* OBSOLETE       CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
-/* OBSOLETE       return (i + addr - (CORE_ADDR) UVADDR); */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       return (addr); */
-/* OBSOLETE     } */
-/* OBSOLETE #else */
-/* OBSOLETE   return (addr); */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* FIXME!  Merge these two.  */ */
-/* OBSOLETE int */
-/* OBSOLETE adapt_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
-/* OBSOLETE 			    struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
-/* OBSOLETE 			    struct target_ops *target ATTRIBUTE_UNUSED) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   memaddr = translate_addr (memaddr); */
-/* OBSOLETE  */
-/* OBSOLETE   if (write) */
-/* OBSOLETE     return adapt_write_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE   else */
-/* OBSOLETE     return adapt_read_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE adapt_files_info (void) */
-/* OBSOLETE { */
-/* OBSOLETE   printf_filtered ("\tAttached to %s at %d baud and running program %s\n", */
-/* OBSOLETE 		   dev_name, baudrate, prog_name); */
-/* OBSOLETE   printf_filtered ("\ton an %s processor.\n", processor_name[processor_type]); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
-/* OBSOLETE    to inferior's memory at MEMADDR.  Returns errno value.   */
-/* OBSOLETE    * sb/sh instructions don't work on unaligned addresses, when TU=1.  */
-/* OBSOLETE  */ */
-/* OBSOLETE int */
-/* OBSOLETE adapt_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE   unsigned int cps; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Turn TU bit off so we can do 'sb' commands */ */
-/* OBSOLETE   cps = read_register (CPS_REGNUM); */
-/* OBSOLETE   if (cps & 0x00000800) */
-/* OBSOLETE     write_register (CPS_REGNUM, cps & ~(0x00000800)); */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; i < len; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if ((i % 16) == 0) */
-/* OBSOLETE 	fprintf (adapt_stream, "sb %x,", memaddr + i); */
-/* OBSOLETE       if ((i % 16) == 15 || i == len - 1) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  fprintf (adapt_stream, "%x\r", ((unsigned char *) myaddr)[i]); */
-/* OBSOLETE 	  expect_prompt (); */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	fprintf (adapt_stream, "%x,", ((unsigned char *) myaddr)[i]); */
-/* OBSOLETE     } */
-/* OBSOLETE   /* Restore the old value of cps if the TU bit was on */ */
-/* OBSOLETE   if (cps & 0x00000800) */
-/* OBSOLETE     write_register (CPS_REGNUM, cps); */
-/* OBSOLETE   return len; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR.  Put the result */
-/* OBSOLETE    at debugger address MYADDR.  Returns errno value.  */ */
-/* OBSOLETE int */
-/* OBSOLETE adapt_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Number of bytes read so far.  */ */
-/* OBSOLETE   int count; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Starting address of this pass.  */ */
-/* OBSOLETE   unsigned long startaddr; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Number of bytes to read in this pass.  */ */
-/* OBSOLETE   int len_this_pass; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Note that this code works correctly if startaddr is just less */
-/* OBSOLETE      than UINT_MAX (well, really CORE_ADDR_MAX if there was such a */
-/* OBSOLETE      thing).  That is, something like */
-/* OBSOLETE      adapt_read_bytes (CORE_ADDR_MAX - 4, foo, 4) */
-/* OBSOLETE      works--it never adds len to memaddr and gets 0.  */ */
-/* OBSOLETE   /* However, something like */
-/* OBSOLETE      adapt_read_bytes (CORE_ADDR_MAX - 3, foo, 4) */
-/* OBSOLETE      doesn't need to work.  Detect it and give up if there's an attempt */
-/* OBSOLETE      to do that.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   if (((memaddr - 1) + len) < memaddr) */
-/* OBSOLETE     return EIO; */
-/* OBSOLETE  */
-/* OBSOLETE   startaddr = memaddr; */
-/* OBSOLETE   count = 0; */
-/* OBSOLETE   while (count < len) */
-/* OBSOLETE     { */
-/* OBSOLETE       len_this_pass = 16; */
-/* OBSOLETE       if ((startaddr % 16) != 0) */
-/* OBSOLETE 	len_this_pass -= startaddr % 16; */
-/* OBSOLETE       if (len_this_pass > (len - count)) */
-/* OBSOLETE 	len_this_pass = (len - count); */
-/* OBSOLETE  */
-/* OBSOLETE       fprintf (adapt_stream, "db %x,%x\r", startaddr, */
-/* OBSOLETE 	       (startaddr - 1) + len_this_pass); */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef NOTDEF			/* Why do this */ */
-/* OBSOLETE       expect ("\n"); */
-/* OBSOLETE       /* Look for 8 hex digits.  */ */
-/* OBSOLETE       i = 0; */
-/* OBSOLETE       while (1) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  if (isxdigit (readchar ())) */
-/* OBSOLETE 	    ++i; */
-/* OBSOLETE 	  else */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      expect_prompt (); */
-/* OBSOLETE 	      error ("Hex digit expected from remote system."); */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  if (i >= 8) */
-/* OBSOLETE 	    break; */
-/* OBSOLETE 	} */
-/* OBSOLETE #endif /* NOTDEF */ */
-/* OBSOLETE  */
-/* OBSOLETE       expect ("  "); */
-/* OBSOLETE  */
-/* OBSOLETE       for (i = 0; i < len_this_pass; i++) */
-/* OBSOLETE 	get_hex_byte (&myaddr[count++]); */
-/* OBSOLETE  */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE       startaddr += len_this_pass; */
-/* OBSOLETE     } */
-/* OBSOLETE   return count; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE #define MAX_BREAKS	8 */
-/* OBSOLETE static int num_brkpts = 0; */
-/* OBSOLETE  */
-/* OBSOLETE /* Insert a breakpoint at ADDR.  SAVE is normally the address of the */
-/* OBSOLETE    pattern buffer where the instruction that the breakpoint overwrites */
-/* OBSOLETE    is saved.  It is unused here since the Adapt Monitor is responsible */
-/* OBSOLETE    for saving/restoring the original instruction. */ */
-/* OBSOLETE  */
-/* OBSOLETE static int */
-/* OBSOLETE adapt_insert_breakpoint (CORE_ADDR addr, char *save) */
-/* OBSOLETE { */
-/* OBSOLETE   if (num_brkpts < MAX_BREAKS) */
-/* OBSOLETE     { */
-/* OBSOLETE       num_brkpts++; */
-/* OBSOLETE       fprintf (adapt_stream, "B %x", addr); */
-/* OBSOLETE       fprintf (adapt_stream, "\r"); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE       return (0);		/* Success */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, */
-/* OBSOLETE 		      "Too many break points, break point not installed\n"); */
-/* OBSOLETE       return (1);		/* Failure */ */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Remove a breakpoint at ADDR.  SAVE is normally the previously */
-/* OBSOLETE    saved pattern, but is unused here as the Adapt Monitor is */
-/* OBSOLETE    responsible for saving/restoring instructions. */ */
-/* OBSOLETE  */
-/* OBSOLETE static int */
-/* OBSOLETE adapt_remove_breakpoint (CORE_ADDR addr, char *save) */
-/* OBSOLETE { */
-/* OBSOLETE   if (num_brkpts > 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       num_brkpts--; */
-/* OBSOLETE       fprintf (adapt_stream, "BR %x", addr); */
-/* OBSOLETE       fprintf (adapt_stream, "\r"); */
-/* OBSOLETE       fflush (adapt_stream); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE   return (0); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Clear the adapts notion of what the break points are */ */
-/* OBSOLETE static int */
-/* OBSOLETE adapt_clear_breakpoints (void) */
-/* OBSOLETE { */
-/* OBSOLETE   if (adapt_stream) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf (adapt_stream, "BR");	/* Clear all break points */ */
-/* OBSOLETE       fprintf (adapt_stream, "\r"); */
-/* OBSOLETE       fflush (adapt_stream); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE   num_brkpts = 0; */
-/* OBSOLETE } */
-/* OBSOLETE static void */
-/* OBSOLETE adapt_mourn (void) */
-/* OBSOLETE { */
-/* OBSOLETE   adapt_clear_breakpoints (); */
-/* OBSOLETE   pop_target ();		/* Pop back to no-child state */ */
-/* OBSOLETE   generic_mourn_inferior (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Display everthing we read in from the adapt until we match/see the */
-/* OBSOLETE  * specified string */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE display_until (char *str) */
-/* OBSOLETE { */
-/* OBSOLETE   int i = 0, j, c; */
-/* OBSOLETE  */
-/* OBSOLETE   while (c = readchar ()) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (c == str[i]) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  i++; */
-/* OBSOLETE 	  if (i == strlen (str)) */
-/* OBSOLETE 	    return; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  if (i) */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      for (j = 0; j < i; j++)	/* Put everthing we matched */ */
-/* OBSOLETE 		putchar (str[j]); */
-/* OBSOLETE 	      i = 0; */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  putchar (c); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Put a command string, in args, out to the adapt.  The adapt is assumed to */
-/* OBSOLETE    be in raw mode, all writing/reading done through adapt_desc. */
-/* OBSOLETE    Ouput from the adapt is placed on the users terminal until the */
-/* OBSOLETE    prompt from the adapt is seen. */
-/* OBSOLETE    FIXME: Can't handle commands that take input.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE adapt_com (char *args, int fromtty) */
-/* OBSOLETE { */
-/* OBSOLETE   if (!adapt_stream) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf_filtered ("Adapt not open.  Use the 'target' command to open.\n"); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Clear all input so only command relative output is displayed */ */
-/* OBSOLETE   slurp_input (); */
-/* OBSOLETE  */
-/* OBSOLETE   switch (islower (args[0]) ? toupper (args[0]) : args[0]) */
-/* OBSOLETE     { */
-/* OBSOLETE     default: */
-/* OBSOLETE       printf_filtered ("Unknown/Unimplemented adapt command '%s'\n", args); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 'G':			/* Go, begin execution */ */
-/* OBSOLETE       write (adapt_desc, args, strlen (args)); */
-/* OBSOLETE       write (adapt_desc, "\r", 1); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 'B':			/* Break points, B or BR */ */
-/* OBSOLETE     case 'C':			/* Check current 29k status (running/halted) */ */
-/* OBSOLETE     case 'D':			/* Display data/registers */ */
-/* OBSOLETE     case 'I':			/* Input from i/o space */ */
-/* OBSOLETE     case 'J':			/* Jam an instruction */ */
-/* OBSOLETE     case 'K':			/* Kill, stop execution */ */
-/* OBSOLETE     case 'L':			/* Disassemble */ */
-/* OBSOLETE     case 'O':			/* Output to i/o space */ */
-/* OBSOLETE     case 'T':			/* Trace */ */
-/* OBSOLETE     case 'P':			/* Pulse an input line */ */
-/* OBSOLETE     case 'X':			/* Examine special purpose registers */ */
-/* OBSOLETE     case 'Z':			/* Display trace buffer */ */
-/* OBSOLETE       write (adapt_desc, args, strlen (args)); */
-/* OBSOLETE       write (adapt_desc, "\r", 1); */
-/* OBSOLETE       expect (args);		/* Don't display the command */ */
-/* OBSOLETE       display_until ("# "); */
-/* OBSOLETE       break; */
-/* OBSOLETE       /* Begin commands that take input in the form 'c x,y[,z...]' */ */
-/* OBSOLETE     case 'S':			/* Set memory or register */ */
-/* OBSOLETE       if (strchr (args, ',')) */
-/* OBSOLETE 	{			/* Assume it is properly formatted */ */
-/* OBSOLETE 	  write (adapt_desc, args, strlen (args)); */
-/* OBSOLETE 	  write (adapt_desc, "\r", 1); */
-/* OBSOLETE 	  expect_prompt (); */
-/* OBSOLETE 	} */
-/* OBSOLETE       break; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Define the target subroutine names */ */
-/* OBSOLETE  */
-/* OBSOLETE struct target_ops adapt_ops; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE init_adapt_ops (void) */
-/* OBSOLETE { */
-/* OBSOLETE   adapt_ops.to_shortname = "adapt"; */
-/* OBSOLETE   adapt_ops.to_longname = "Remote AMD `Adapt' target"; */
-/* OBSOLETE   adapt_ops.to_doc = "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232"; */
-/* OBSOLETE   adapt_ops.to_open = adapt_open; */
-/* OBSOLETE   adapt_ops.to_close = adapt_close; */
-/* OBSOLETE   adapt_ops.to_attach = adapt_attach; */
-/* OBSOLETE   adapt_ops.to_post_attach = NULL; */
-/* OBSOLETE   adapt_ops.to_require_attach = NULL; */
-/* OBSOLETE   adapt_ops.to_detach = adapt_detach; */
-/* OBSOLETE   adapt_ops.to_require_detach = NULL; */
-/* OBSOLETE   adapt_ops.to_resume = adapt_resume; */
-/* OBSOLETE   adapt_ops.to_wait = adapt_wait; */
-/* OBSOLETE   adapt_ops.to_post_wait = NULL; */
-/* OBSOLETE   adapt_ops.to_fetch_registers = adapt_fetch_register; */
-/* OBSOLETE   adapt_ops.to_store_registers = adapt_store_register; */
-/* OBSOLETE   adapt_ops.to_prepare_to_store = adapt_prepare_to_store; */
-/* OBSOLETE   adapt_ops.to_xfer_memory = adapt_xfer_inferior_memory; */
-/* OBSOLETE   adapt_ops.to_files_info = adapt_files_info; */
-/* OBSOLETE   adapt_ops.to_insert_breakpoint = adapt_insert_breakpoint; */
-/* OBSOLETE   adapt_ops.to_remove_breakpoint = adapt_remove_breakpoint; */
-/* OBSOLETE   adapt_ops.to_terminal_init = 0; */
-/* OBSOLETE   adapt_ops.to_terminal_inferior = 0; */
-/* OBSOLETE   adapt_ops.to_terminal_ours_for_output = 0; */
-/* OBSOLETE   adapt_ops.to_terminal_ours = 0; */
-/* OBSOLETE   adapt_ops.to_terminal_info = 0; */
-/* OBSOLETE   adapt_ops.to_kill = adapt_kill; */
-/* OBSOLETE   adapt_ops.to_load = adapt_load; */
-/* OBSOLETE   adapt_ops.to_lookup_symbol = 0; */
-/* OBSOLETE   adapt_ops.to_create_inferior = adapt_create_inferior; */
-/* OBSOLETE   adapt_ops.to_post_startup_inferior = NULL; */
-/* OBSOLETE   adapt_ops.to_acknowledge_created_inferior = NULL; */
-/* OBSOLETE   adapt_ops.to_clone_and_follow_inferior = NULL; */
-/* OBSOLETE   adapt_ops.to_post_follow_inferior_by_clone = NULL; */
-/* OBSOLETE   adapt_ops.to_insert_fork_catchpoint = NULL; */
-/* OBSOLETE   adapt_ops.to_remove_fork_catchpoint = NULL; */
-/* OBSOLETE   adapt_ops.to_insert_vfork_catchpoint = NULL; */
-/* OBSOLETE   adapt_ops.to_remove_vfork_catchpoint = NULL; */
-/* OBSOLETE   adapt_ops.to_has_forked = NULL; */
-/* OBSOLETE   adapt_ops.to_has_vforked = NULL; */
-/* OBSOLETE   adapt_ops.to_can_follow_vfork_prior_to_exec = NULL; */
-/* OBSOLETE   adapt_ops.to_post_follow_vfork = NULL; */
-/* OBSOLETE   adapt_ops.to_insert_exec_catchpoint = NULL; */
-/* OBSOLETE   adapt_ops.to_remove_exec_catchpoint = NULL; */
-/* OBSOLETE   adapt_ops.to_has_execd = NULL; */
-/* OBSOLETE   adapt_ops.to_reported_exec_events_per_exec_call = NULL; */
-/* OBSOLETE   adapt_ops.to_has_exited = NULL; */
-/* OBSOLETE   adapt_ops.to_mourn_inferior = adapt_mourn; */
-/* OBSOLETE   adapt_ops.to_can_run = 0; */
-/* OBSOLETE   adapt_ops.to_notice_signals = 0; */
-/* OBSOLETE   adapt_ops.to_thread_alive = 0; */
-/* OBSOLETE   adapt_ops.to_stop = 0;	/* process_stratum; */ */
-/* OBSOLETE   adapt_ops.to_pid_to_exec_file = NULL; */
-/* OBSOLETE   adapt_ops.to_stratum = 0; */
-/* OBSOLETE   adapt_ops.DONT_USE = 0; */
-/* OBSOLETE   adapt_ops.to_has_all_memory = 1; */
-/* OBSOLETE   adapt_ops.to_has_memory = 1; */
-/* OBSOLETE   adapt_ops.to_has_stack = 1; */
-/* OBSOLETE   adapt_ops.to_has_registers = 1; */
-/* OBSOLETE   adapt_ops.to_has_execution = 0; */
-/* OBSOLETE   adapt_ops.to_sections = 0; */
-/* OBSOLETE   adapt_ops.to_sections_end = 0; */
-/* OBSOLETE   adapt_ops.to_magic = OPS_MAGIC; */
-/* OBSOLETE }				/* init_adapt_ops */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE _initialize_remote_adapt (void) */
-/* OBSOLETE { */
-/* OBSOLETE   init_adapt_ops (); */
-/* OBSOLETE   add_target (&adapt_ops); */
-/* OBSOLETE   add_com ("adapt <command>", class_obscure, adapt_com, */
-/* OBSOLETE 	   "Send a command to the AMD Adapt remote monitor."); */
-/* OBSOLETE } */
diff --git a/gdb/remote-array.c b/gdb/remote-array.c
index 204aaed..ed0c40e 100644
--- a/gdb/remote-array.c
+++ b/gdb/remote-array.c
@@ -193,7 +193,8 @@
   if (strlen (buf) > PBUFSIZ)
     error ("printf_monitor(): string too long");
   if (serial_write (array_desc, buf, strlen (buf)))
-    fprintf (stderr, "serial_write failed: %s\n", safe_strerror (errno));
+    fprintf_unfiltered (gdb_stderr, "serial_write failed: %s\n", 
+			safe_strerror (errno));
 }
 /*
  * write_monitor -- send raw data to monitor.
@@ -202,7 +203,8 @@
 write_monitor (char data[], int len)
 {
   if (serial_write (array_desc, data, len))
-    fprintf (stderr, "serial_write failed: %s\n", safe_strerror (errno));
+    fprintf_unfiltered (gdb_stderr, "serial_write failed: %s\n",
+			safe_strerror (errno));
 
   *(data + len + 1) = '\0';
   debuglogs (1, "write_monitor(), Sending: \"%s\".", data);
@@ -1053,7 +1055,7 @@
 	}
     }
 
-  fprintf (stderr, "Too many breakpoints (> 16) for monitor\n");
+  fprintf_unfiltered (gdb_stderr, "Too many breakpoints (> 16) for monitor\n");
   return 1;
 }
 
@@ -1078,8 +1080,9 @@
 	  return 0;
 	}
     }
-  fprintf (stderr, "Can't find breakpoint associated with 0x%s\n",
-	   paddr_nz (addr));
+  fprintf_unfiltered (gdb_stderr,
+		      "Can't find breakpoint associated with 0x%s\n",
+		      paddr_nz (addr));
   return 1;
 }
 
diff --git a/gdb/remote-e7000.c b/gdb/remote-e7000.c
index e13401f..d9cf5e8 100644
--- a/gdb/remote-e7000.c
+++ b/gdb/remote-e7000.c
@@ -630,7 +630,7 @@
   registers_changed ();
   stop_pc = read_pc ();
   set_current_frame (create_new_frame (read_fp (), stop_pc));
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
   print_stack_frame (selected_frame, -1, 1);
 
   return 1;
@@ -1083,15 +1083,15 @@
       if (((memaddr + i) & 3) == 0 && (i + 3 < len))
 	{
 	  /* Can be done with a long word */
-	  sprintf (buf, "m %lx %x%02x%02x%02x;l\r",
-		   memaddr + i,
+	  sprintf (buf, "m %s %x%02x%02x%02x;l\r",
+		   paddr_nz (memaddr + i),
 		   myaddr[i], myaddr[i + 1], myaddr[i + 2], myaddr[i + 3]);
 	  puts_e7000debug (buf);
 	  i += 3;
 	}
       else
 	{
-	  sprintf (buf, "m %lx %x\r", memaddr + i, myaddr[i]);
+	  sprintf (buf, "m %s %x\r", paddr_nz (memaddr + i), myaddr[i]);
 	  puts_e7000debug (buf);
 	}
     }
@@ -1244,7 +1244,7 @@
       return 0;
     }
 
-  sprintf (buf, "m %lx;l\r", memaddr);
+  sprintf (buf, "m %s;l\r", paddr_nz (memaddr));
   puts_e7000debug (buf);
 
   for (count = 0; count < len; count += 4)
@@ -1323,7 +1323,7 @@
       return 0;
     }
 
-  sprintf (buf, "d %lx %lx\r", memaddr, memaddr + len - 1);
+  sprintf (buf, "d %s %s\r", paddr_nz (memaddr), paddr_nz (memaddr + len - 1));
   puts_e7000debug (buf);
 
   count = 0;
@@ -1705,12 +1705,12 @@
 #ifdef HARD_BREAKPOINTS
 	if (BC_BREAKPOINTS)
 	  {
-	    sprintf (buf, "BC%d A=%lx\r", i + 1, addr);
+	    sprintf (buf, "BC%d A=%s\r", i + 1, paddr_nz (addr));
 	    puts_e7000debug (buf);
 	  }
 	else
 	  {
-	    sprintf (buf, "B %lx\r", addr);
+	    sprintf (buf, "B %s\r", paddr_nz (addr));
 	    puts_e7000debug (buf);
 	  }
 #else
@@ -1749,12 +1749,12 @@
 	  }
 	else
 	  {
-	    sprintf (buf, "B - %lx\r", addr);
+	    sprintf (buf, "B - %s\r", paddr_nz (addr));
 	    puts_e7000debug (buf);
 	  }
 	expect_prompt ();
 #else
-	sprintf (buf, "B - %lx\r", addr);
+	sprintf (buf, "B - %s\r", paddr_nz (addr));
 	puts_e7000debug (buf);
 	expect_prompt ();
 
@@ -1766,8 +1766,8 @@
 
 	return 0;
       }
-
-  warning ("Can't find breakpoint associated with 0x%lx\n", addr);
+ 
+  warning ("Can't find breakpoint associated with 0x%s\n", paddr_nz (addr));
   return 1;
 }
 
diff --git a/gdb/remote-eb.c b/gdb/remote-eb.c
deleted file mode 100644
index dcee345..0000000
--- a/gdb/remote-eb.c
+++ /dev/null
@@ -1,1088 +0,0 @@
-/* OBSOLETE /* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB. */
-/* OBSOLETE    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001 */
-/* OBSOLETE    Free Software Foundation, Inc. */
-/* OBSOLETE    Contributed by Cygnus Support.  Written by Jim Kingdon for Cygnus. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* This is like remote.c but is for an esoteric situation-- */
-/* OBSOLETE    having a a29k board in a PC hooked up to a unix machine with */
-/* OBSOLETE    a serial line, and running ctty com1 on the PC, through which */
-/* OBSOLETE    the unix machine can run ebmon.  Not to mention that the PC */
-/* OBSOLETE    has PC/NFS, so it can access the same executables that gdb can, */
-/* OBSOLETE    over the net in real time.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #include "defs.h" */
-/* OBSOLETE #include "gdb_string.h" */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE  */
-/* OBSOLETE #include "inferior.h" */
-/* OBSOLETE #include "bfd.h" */
-/* OBSOLETE #include "symfile.h" */
-/* OBSOLETE #include "value.h" */
-/* OBSOLETE #include <ctype.h> */
-/* OBSOLETE #include <fcntl.h> */
-/* OBSOLETE #include <signal.h> */
-/* OBSOLETE #include <errno.h> */
-/* OBSOLETE #include "terminal.h" */
-/* OBSOLETE #include "target.h" */
-/* OBSOLETE #include "gdbcore.h" */
-/* OBSOLETE  */
-/* OBSOLETE extern struct target_ops eb_ops;	/* Forward declaration */ */
-/* OBSOLETE  */
-/* OBSOLETE static void eb_close (); */
-/* OBSOLETE  */
-/* OBSOLETE #define LOG_FILE "eb.log" */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE FILE *log_file; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE static int timeout = 24; */
-/* OBSOLETE  */
-/* OBSOLETE /* Descriptor for I/O to remote machine.  Initialize it to -1 so that */
-/* OBSOLETE    eb_open knows that we don't have a file open when the program */
-/* OBSOLETE    starts.  */ */
-/* OBSOLETE int eb_desc = -1; */
-/* OBSOLETE  */
-/* OBSOLETE /* stream which is fdopen'd from eb_desc.  Only valid when */
-/* OBSOLETE    eb_desc != -1.  */ */
-/* OBSOLETE FILE *eb_stream; */
-/* OBSOLETE  */
-/* OBSOLETE /* Read a character from the remote system, doing all the fancy */
-/* OBSOLETE    timeout stuff.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE readchar (void) */
-/* OBSOLETE { */
-/* OBSOLETE   char buf; */
-/* OBSOLETE  */
-/* OBSOLETE   buf = '\0'; */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   /* termio does the timeout for us.  */ */
-/* OBSOLETE   read (eb_desc, &buf, 1); */
-/* OBSOLETE #else */
-/* OBSOLETE   alarm (timeout); */
-/* OBSOLETE   if (read (eb_desc, &buf, 1) < 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (errno == EINTR) */
-/* OBSOLETE 	error ("Timeout reading from remote system."); */
-/* OBSOLETE       else */
-/* OBSOLETE 	perror_with_name ("remote"); */
-/* OBSOLETE     } */
-/* OBSOLETE   alarm (0); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   if (buf == '\0') */
-/* OBSOLETE     error ("Timeout reading from remote system."); */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   putc (buf & 0x7f, log_file); */
-/* OBSOLETE #endif */
-/* OBSOLETE   return buf & 0x7f; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Keep discarding input from the remote system, until STRING is found.  */
-/* OBSOLETE    Let the user break out immediately.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE expect (char *string) */
-/* OBSOLETE { */
-/* OBSOLETE   char *p = string; */
-/* OBSOLETE  */
-/* OBSOLETE   immediate_quit++; */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (readchar () == *p) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  p++; */
-/* OBSOLETE 	  if (*p == '\0') */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      immediate_quit--; */
-/* OBSOLETE 	      return; */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	p = string; */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Keep discarding input until we see the ebmon prompt. */
-/* OBSOLETE  */
-/* OBSOLETE    The convention for dealing with the prompt is that you */
-/* OBSOLETE    o give your command */
-/* OBSOLETE    o *then* wait for the prompt. */
-/* OBSOLETE  */
-/* OBSOLETE    Thus the last thing that a procedure does with the serial line */
-/* OBSOLETE    will be an expect_prompt().  Exception:  eb_resume does not */
-/* OBSOLETE    wait for the prompt, because the terminal is being handed over */
-/* OBSOLETE    to the inferior.  However, the next thing which happens after that */
-/* OBSOLETE    is a eb_wait which does wait for the prompt. */
-/* OBSOLETE    Note that this includes abnormal exit, e.g. error().  This is */
-/* OBSOLETE    necessary to prevent getting into states from which we can't */
-/* OBSOLETE    recover.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE expect_prompt (void) */
-/* OBSOLETE { */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   /* This is a convenient place to do this.  The idea is to do it often */
-/* OBSOLETE      enough that we never lose much data if we terminate abnormally.  */ */
-/* OBSOLETE   fflush (log_file); */
-/* OBSOLETE #endif */
-/* OBSOLETE   expect ("\n# "); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get a hex digit from the remote system & return its value. */
-/* OBSOLETE    If ignore_space is nonzero, ignore spaces (not newline, tab, etc).  */ */
-/* OBSOLETE static int */
-/* OBSOLETE get_hex_digit (int ignore_space) */
-/* OBSOLETE { */
-/* OBSOLETE   int ch; */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       ch = readchar (); */
-/* OBSOLETE       if (ch >= '0' && ch <= '9') */
-/* OBSOLETE 	return ch - '0'; */
-/* OBSOLETE       else if (ch >= 'A' && ch <= 'F') */
-/* OBSOLETE 	return ch - 'A' + 10; */
-/* OBSOLETE       else if (ch >= 'a' && ch <= 'f') */
-/* OBSOLETE 	return ch - 'a' + 10; */
-/* OBSOLETE       else if (ch == ' ' && ignore_space) */
-/* OBSOLETE 	; */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  expect_prompt (); */
-/* OBSOLETE 	  error ("Invalid hex digit from remote system."); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get a byte from eb_desc and put it in *BYT.  Accept any number */
-/* OBSOLETE    leading spaces.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE get_hex_byte (char *byt) */
-/* OBSOLETE { */
-/* OBSOLETE   int val; */
-/* OBSOLETE  */
-/* OBSOLETE   val = get_hex_digit (1) << 4; */
-/* OBSOLETE   val |= get_hex_digit (0); */
-/* OBSOLETE   *byt = val; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get N 32-bit words from remote, each preceded by a space, */
-/* OBSOLETE    and put them in registers starting at REGNO.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE get_hex_regs (int n, int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   long val; */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; i < n; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       int j; */
-/* OBSOLETE  */
-/* OBSOLETE       val = 0; */
-/* OBSOLETE       for (j = 0; j < 8; j++) */
-/* OBSOLETE 	val = (val << 4) + get_hex_digit (j == 0); */
-/* OBSOLETE       supply_register (regno++, (char *) &val); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout.  */ */
-/* OBSOLETE #ifndef HAVE_TERMIO */
-/* OBSOLETE  */
-/* OBSOLETE volatile int n_alarms; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE eb_timer (void) */
-/* OBSOLETE { */
-/* OBSOLETE #if 0 */
-/* OBSOLETE   if (kiodebug) */
-/* OBSOLETE     printf ("eb_timer called\n"); */
-/* OBSOLETE #endif */
-/* OBSOLETE   n_alarms++; */
-/* OBSOLETE } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /* malloc'd name of the program on the remote system.  */ */
-/* OBSOLETE static char *prog_name = NULL; */
-/* OBSOLETE  */
-/* OBSOLETE /* Nonzero if we have loaded the file ("yc") and not yet issued a "gi" */
-/* OBSOLETE    command.  "gi" is supposed to happen exactly once for each "yc".  */ */
-/* OBSOLETE static int need_gi = 0; */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of SIGTRAPs we need to simulate.  That is, the next */
-/* OBSOLETE    NEED_ARTIFICIAL_TRAP calls to eb_wait should just return */
-/* OBSOLETE    SIGTRAP without actually waiting for anything.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static int need_artificial_trap = 0; */
-/* OBSOLETE  */
-/* OBSOLETE /* This is called not only when we first attach, but also when the */
-/* OBSOLETE    user types "run" after having attached.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE eb_create_inferior (char *execfile, char *args, char **env) */
-/* OBSOLETE { */
-/* OBSOLETE   int entry_pt; */
-/* OBSOLETE  */
-/* OBSOLETE   if (args && *args) */
-/* OBSOLETE     error ("Can't pass arguments to remote EBMON process"); */
-/* OBSOLETE  */
-/* OBSOLETE   if (execfile == 0 || exec_bfd == 0) */
-/* OBSOLETE     error ("No executable file specified"); */
-/* OBSOLETE  */
-/* OBSOLETE   entry_pt = (int) bfd_get_start_address (exec_bfd); */
-/* OBSOLETE  */
-/* OBSOLETE   { */
-/* OBSOLETE     /* OK, now read in the file.  Y=read, C=COFF, D=no symbols */
-/* OBSOLETE        0=start address, %s=filename.  */ */
-/* OBSOLETE  */
-/* OBSOLETE     fprintf (eb_stream, "YC D,0:%s", prog_name); */
-/* OBSOLETE  */
-/* OBSOLETE     if (args != NULL) */
-/* OBSOLETE       fprintf (eb_stream, " %s", args); */
-/* OBSOLETE  */
-/* OBSOLETE     fprintf (eb_stream, "\n"); */
-/* OBSOLETE     fflush (eb_stream); */
-/* OBSOLETE  */
-/* OBSOLETE     expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE     need_gi = 1; */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE /* The "process" (board) is already stopped awaiting our commands, and */
-/* OBSOLETE    the program is already downloaded.  We just set its PC and go.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   clear_proceed_status (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Tell wait_for_inferior that we've started a new process.  */ */
-/* OBSOLETE   init_wait_for_inferior (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set up the "saved terminal modes" of the inferior */
-/* OBSOLETE      based on what modes we are starting it with.  */ */
-/* OBSOLETE   target_terminal_init (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Install inferior's terminal modes.  */ */
-/* OBSOLETE   target_terminal_inferior (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* insert_step_breakpoint ();  FIXME, do we need this?  */ */
-/* OBSOLETE   proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0);	/* Let 'er rip... */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Translate baud rates from integers to damn B_codes.  Unix should */
-/* OBSOLETE    have outgrown this crap years ago, but even POSIX wouldn't buck it.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef B19200 */
-/* OBSOLETE #define B19200 EXTA */
-/* OBSOLETE #endif */
-/* OBSOLETE #ifndef B38400 */
-/* OBSOLETE #define B38400 EXTB */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE struct */
-/* OBSOLETE { */
-/* OBSOLETE   int rate, damn_b; */
-/* OBSOLETE } */
-/* OBSOLETE baudtab[] = */
-/* OBSOLETE { */
-/* OBSOLETE   { */
-/* OBSOLETE     0, B0 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     50, B50 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     75, B75 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     110, B110 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     134, B134 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     150, B150 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     200, B200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     300, B300 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     600, B600 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     1200, B1200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     1800, B1800 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     2400, B2400 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     4800, B4800 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     9600, B9600 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     19200, B19200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     38400, B38400 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     -1, -1 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE damn_b (int rate) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; baudtab[i].rate != -1; i++) */
-/* OBSOLETE     if (rate == baudtab[i].rate) */
-/* OBSOLETE       return baudtab[i].damn_b; */
-/* OBSOLETE   return B38400;		/* Random */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Open a connection to a remote debugger. */
-/* OBSOLETE    NAME is the filename used for communication, then a space, */
-/* OBSOLETE    then the name of the program as we should name it to EBMON.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static int baudrate = 9600; */
-/* OBSOLETE static char *dev_name; */
-/* OBSOLETE void */
-/* OBSOLETE eb_open (char *name, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   TERMINAL sg; */
-/* OBSOLETE  */
-/* OBSOLETE   char *p; */
-/* OBSOLETE  */
-/* OBSOLETE   target_preopen (from_tty); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Find the first whitespace character, it separates dev_name from */
-/* OBSOLETE      prog_name.  */ */
-/* OBSOLETE   if (name == 0) */
-/* OBSOLETE     goto erroid; */
-/* OBSOLETE  */
-/* OBSOLETE   for (p = name; */
-/* OBSOLETE        *p != '\0' && !isspace (*p); p++) */
-/* OBSOLETE     ; */
-/* OBSOLETE   if (*p == '\0') */
-/* OBSOLETE   erroid: */
-/* OBSOLETE     error ("\ */
-/* OBSOLETE Please include the name of the device for the serial port,\n\ */
-/* OBSOLETE the baud rate, and the name of the program to run on the remote system."); */
-/* OBSOLETE   dev_name = alloca (p - name + 1); */
-/* OBSOLETE   strncpy (dev_name, name, p - name); */
-/* OBSOLETE   dev_name[p - name] = '\0'; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Skip over the whitespace after dev_name */ */
-/* OBSOLETE   for (; isspace (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE  */
-/* OBSOLETE   if (1 != sscanf (p, "%d ", &baudrate)) */
-/* OBSOLETE     goto erroid; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Skip the number and then the spaces */ */
-/* OBSOLETE   for (; isdigit (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE   for (; isspace (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE  */
-/* OBSOLETE   if (prog_name != NULL) */
-/* OBSOLETE     xfree (prog_name); */
-/* OBSOLETE   prog_name = savestring (p, strlen (p)); */
-/* OBSOLETE  */
-/* OBSOLETE   eb_close (0); */
-/* OBSOLETE  */
-/* OBSOLETE   eb_desc = open (dev_name, O_RDWR); */
-/* OBSOLETE   if (eb_desc < 0) */
-/* OBSOLETE     perror_with_name (dev_name); */
-/* OBSOLETE   ioctl (eb_desc, TIOCGETP, &sg); */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   sg.c_cc[VMIN] = 0;		/* read with timeout.  */ */
-/* OBSOLETE   sg.c_cc[VTIME] = timeout * 10; */
-/* OBSOLETE   sg.c_lflag &= ~(ICANON | ECHO); */
-/* OBSOLETE   sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
-/* OBSOLETE #else */
-/* OBSOLETE   sg.sg_ispeed = damn_b (baudrate); */
-/* OBSOLETE   sg.sg_ospeed = damn_b (baudrate); */
-/* OBSOLETE   sg.sg_flags |= RAW | ANYP; */
-/* OBSOLETE   sg.sg_flags &= ~ECHO; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   ioctl (eb_desc, TIOCSETP, &sg); */
-/* OBSOLETE   eb_stream = fdopen (eb_desc, "r+"); */
-/* OBSOLETE  */
-/* OBSOLETE   push_target (&eb_ops); */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf ("Remote %s debugging %s using %s\n", target_shortname, */
-/* OBSOLETE 	    prog_name, dev_name); */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef HAVE_TERMIO */
-/* OBSOLETE #ifndef NO_SIGINTERRUPT */
-/* OBSOLETE   /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
-/* OBSOLETE      the read.  */ */
-/* OBSOLETE   if (siginterrupt (SIGALRM, 1) != 0) */
-/* OBSOLETE     perror ("eb_open: error in siginterrupt"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set up read timeout timer.  */ */
-/* OBSOLETE   if ((void (*)) signal (SIGALRM, eb_timer) == (void (*)) -1) */
-/* OBSOLETE     perror ("eb_open: error in signal"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   log_file = fopen (LOG_FILE, "w"); */
-/* OBSOLETE   if (log_file == NULL) */
-/* OBSOLETE     perror_with_name (LOG_FILE); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   /* Hello?  Are you there?  */ */
-/* OBSOLETE   write (eb_desc, "\n", 1); */
-/* OBSOLETE  */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Close out all files and local state before this target loses control. */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE eb_close (int quitting) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   /* Due to a bug in Unix, fclose closes not only the stdio stream, */
-/* OBSOLETE      but also the file descriptor.  So we don't actually close */
-/* OBSOLETE      eb_desc.  */ */
-/* OBSOLETE   if (eb_stream) */
-/* OBSOLETE     fclose (eb_stream);		/* This also closes eb_desc */ */
-/* OBSOLETE   if (eb_desc >= 0) */
-/* OBSOLETE     /* close (eb_desc); */ */
-/* OBSOLETE  */
-/* OBSOLETE     /* Do not try to close eb_desc again, later in the program.  */ */
-/* OBSOLETE     eb_stream = NULL; */
-/* OBSOLETE   eb_desc = -1; */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   if (log_file) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (ferror (log_file)) */
-/* OBSOLETE 	printf ("Error writing log file.\n"); */
-/* OBSOLETE       if (fclose (log_file) != 0) */
-/* OBSOLETE 	printf ("Error closing log file.\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Terminate the open connection to the remote debugger. */
-/* OBSOLETE    Use this when you want to detach and do something else */
-/* OBSOLETE    with your gdb.  */ */
-/* OBSOLETE void */
-/* OBSOLETE eb_detach (int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   pop_target ();		/* calls eb_close to do the real work */ */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf ("Ending remote %s debugging\n", target_shortname); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Tell the remote machine to resume.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE eb_resume (ptid_t ptid, int step, enum target_signal sig) */
-/* OBSOLETE { */
-/* OBSOLETE   if (step) */
-/* OBSOLETE     { */
-/* OBSOLETE       write (eb_desc, "t 1,s\n", 6); */
-/* OBSOLETE       /* Wait for the echo.  */ */
-/* OBSOLETE       expect ("t 1,s\r"); */
-/* OBSOLETE       /* Then comes a line containing the instruction we stepped to.  */ */
-/* OBSOLETE       expect ("\n@"); */
-/* OBSOLETE       /* Then we get the prompt.  */ */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE       /* Force the next eb_wait to return a trap.  Not doing anything */
-/* OBSOLETE          about I/O from the target means that the user has to type */
-/* OBSOLETE          "continue" to see any.  This should be fixed.  */ */
-/* OBSOLETE       need_artificial_trap = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       if (need_gi) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  need_gi = 0; */
-/* OBSOLETE 	  write (eb_desc, "gi\n", 3); */
-/* OBSOLETE  */
-/* OBSOLETE 	  /* Swallow the echo of "gi".  */ */
-/* OBSOLETE 	  expect ("gi\r"); */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  write (eb_desc, "GR\n", 3); */
-/* OBSOLETE 	  /* Swallow the echo.  */ */
-/* OBSOLETE 	  expect ("GR\r"); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Wait until the remote machine stops, then return, */
-/* OBSOLETE    storing status in STATUS just as `wait' would.  */ */
-/* OBSOLETE  */
-/* OBSOLETE ptid_t */
-/* OBSOLETE eb_wait (ptid_t ptid, struct target_waitstatus *status) */
-/* OBSOLETE { */
-/* OBSOLETE   /* Strings to look for.  '?' means match any single character.   */
-/* OBSOLETE      Note that with the algorithm we use, the initial character */
-/* OBSOLETE      of the string cannot recur in the string, or we will not */
-/* OBSOLETE      find some cases of the string in the input.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   static char bpt[] = "Invalid interrupt taken - #0x50 - "; */
-/* OBSOLETE   /* It would be tempting to look for "\n[__exit + 0x8]\n" */
-/* OBSOLETE      but that requires loading symbols with "yc i" and even if */
-/* OBSOLETE      we did do that we don't know that the file has symbols.  */ */
-/* OBSOLETE   static char exitmsg[] = "\n@????????I    JMPTI     GR121,LR0"; */
-/* OBSOLETE   char *bp = bpt; */
-/* OBSOLETE   char *ep = exitmsg; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars.  */ */
-/* OBSOLETE   char swallowed[50]; */
-/* OBSOLETE   /* Current position in swallowed.  */ */
-/* OBSOLETE   char *swallowed_p = swallowed; */
-/* OBSOLETE  */
-/* OBSOLETE   int ch; */
-/* OBSOLETE   int ch_handled; */
-/* OBSOLETE  */
-/* OBSOLETE   int old_timeout = timeout; */
-/* OBSOLETE  */
-/* OBSOLETE   status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE   status->value.integer = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (need_artificial_trap != 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE       need_artificial_trap--; */
-/* OBSOLETE       return 0; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   timeout = 0;			/* Don't time out -- user program is running. */ */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       ch_handled = 0; */
-/* OBSOLETE       ch = readchar (); */
-/* OBSOLETE       if (ch == *bp) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  bp++; */
-/* OBSOLETE 	  if (*bp == '\0') */
-/* OBSOLETE 	    break; */
-/* OBSOLETE 	  ch_handled = 1; */
-/* OBSOLETE  */
-/* OBSOLETE 	  *swallowed_p++ = ch; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	bp = bpt; */
-/* OBSOLETE  */
-/* OBSOLETE       if (ch == *ep || *ep == '?') */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  ep++; */
-/* OBSOLETE 	  if (*ep == '\0') */
-/* OBSOLETE 	    break; */
-/* OBSOLETE  */
-/* OBSOLETE 	  if (!ch_handled) */
-/* OBSOLETE 	    *swallowed_p++ = ch; */
-/* OBSOLETE 	  ch_handled = 1; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	ep = exitmsg; */
-/* OBSOLETE  */
-/* OBSOLETE       if (!ch_handled) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  char *p; */
-/* OBSOLETE  */
-/* OBSOLETE 	  /* Print out any characters which have been swallowed.  */ */
-/* OBSOLETE 	  for (p = swallowed; p < swallowed_p; ++p) */
-/* OBSOLETE 	    putc (*p, stdout); */
-/* OBSOLETE 	  swallowed_p = swallowed; */
-/* OBSOLETE  */
-/* OBSOLETE 	  putc (ch, stdout); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   if (*bp == '\0') */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE       status->value.integer = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE   timeout = old_timeout; */
-/* OBSOLETE  */
-/* OBSOLETE   return 0; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Return the name of register number REGNO */
-/* OBSOLETE    in the form input and output by EBMON. */
-/* OBSOLETE  */
-/* OBSOLETE    Returns a pointer to a static buffer containing the answer.  */ */
-/* OBSOLETE static char * */
-/* OBSOLETE get_reg_name (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   static char buf[80]; */
-/* OBSOLETE   if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
-/* OBSOLETE     sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); */
-/* OBSOLETE   else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
-/* OBSOLETE     sprintf (buf, "LR%03d", regno - LR0_REGNUM); */
-/* OBSOLETE   else if (regno == Q_REGNUM) */
-/* OBSOLETE     strcpy (buf, "SR131"); */
-/* OBSOLETE   else if (regno >= BP_REGNUM && regno <= CR_REGNUM) */
-/* OBSOLETE     sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); */
-/* OBSOLETE   else if (regno == ALU_REGNUM) */
-/* OBSOLETE     strcpy (buf, "SR132"); */
-/* OBSOLETE   else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) */
-/* OBSOLETE     sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); */
-/* OBSOLETE   else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) */
-/* OBSOLETE     sprintf (buf, "SR%03d", regno - VAB_REGNUM); */
-/* OBSOLETE   else if (regno == GR1_REGNUM) */
-/* OBSOLETE     strcpy (buf, "GR001"); */
-/* OBSOLETE   return buf; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Read the remote registers into the block REGS.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE eb_fetch_registers (void) */
-/* OBSOLETE { */
-/* OBSOLETE   int reg_index; */
-/* OBSOLETE   int regnum_index; */
-/* OBSOLETE   char tempbuf[10]; */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE #if 0 */
-/* OBSOLETE   /* This should not be necessary, because one is supposed to read the */
-/* OBSOLETE      registers only when the inferior is stopped (at least with */
-/* OBSOLETE      ptrace() and why not make it the same for remote?).  */ */
-/* OBSOLETE   /* ^A is the "normal character" used to make sure we are talking to EBMON */
-/* OBSOLETE      and not to the program being debugged.  */ */
-/* OBSOLETE   write (eb_desc, "\001\n"); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw gr96,gr127\n", 14); */
-/* OBSOLETE   for (reg_index = 96, regnum_index = GR96_REGNUM; */
-/* OBSOLETE        reg_index < 128; */
-/* OBSOLETE        reg_index += 4, regnum_index += 4) */
-/* OBSOLETE     { */
-/* OBSOLETE       sprintf (tempbuf, "GR%03d ", reg_index); */
-/* OBSOLETE       expect (tempbuf); */
-/* OBSOLETE       get_hex_regs (4, regnum_index); */
-/* OBSOLETE       expect ("\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; i < 128; i += 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* The PC has a tendency to hang if we get these */
-/* OBSOLETE          all in one fell swoop ("dw lr0,lr127").  */ */
-/* OBSOLETE       sprintf (tempbuf, "dw lr%d\n", i); */
-/* OBSOLETE       write (eb_desc, tempbuf, strlen (tempbuf)); */
-/* OBSOLETE       for (reg_index = i, regnum_index = LR0_REGNUM + i; */
-/* OBSOLETE 	   reg_index < i + 32; */
-/* OBSOLETE 	   reg_index += 4, regnum_index += 4) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  sprintf (tempbuf, "LR%03d ", reg_index); */
-/* OBSOLETE 	  expect (tempbuf); */
-/* OBSOLETE 	  get_hex_regs (4, regnum_index); */
-/* OBSOLETE 	  expect ("\n"); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw sr133,sr133\n", 15); */
-/* OBSOLETE   expect ("SR133          "); */
-/* OBSOLETE   get_hex_regs (1, BP_REGNUM); */
-/* OBSOLETE   expect ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw sr134,sr134\n", 15); */
-/* OBSOLETE   expect ("SR134                   "); */
-/* OBSOLETE   get_hex_regs (1, FC_REGNUM); */
-/* OBSOLETE   expect ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw sr135,sr135\n", 15); */
-/* OBSOLETE   expect ("SR135                            "); */
-/* OBSOLETE   get_hex_regs (1, CR_REGNUM); */
-/* OBSOLETE   expect ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw sr131,sr131\n", 15); */
-/* OBSOLETE   expect ("SR131                            "); */
-/* OBSOLETE   get_hex_regs (1, Q_REGNUM); */
-/* OBSOLETE   expect ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw sr0,sr14\n", 12); */
-/* OBSOLETE   for (reg_index = 0, regnum_index = VAB_REGNUM; */
-/* OBSOLETE        regnum_index <= LRU_REGNUM; */
-/* OBSOLETE        regnum_index += 4, reg_index += 4) */
-/* OBSOLETE     { */
-/* OBSOLETE       sprintf (tempbuf, "SR%03d ", reg_index); */
-/* OBSOLETE       expect (tempbuf); */
-/* OBSOLETE       get_hex_regs (reg_index == 12 ? 3 : 4, regnum_index); */
-/* OBSOLETE       expect ("\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* There doesn't seem to be any way to get these.  */ */
-/* OBSOLETE   { */
-/* OBSOLETE     int val = -1; */
-/* OBSOLETE     supply_register (FPE_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (INTE_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (FPS_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (EXO_REGNUM, (char *) &val); */
-/* OBSOLETE   } */
-/* OBSOLETE  */
-/* OBSOLETE   write (eb_desc, "dw gr1,gr1\n", 11); */
-/* OBSOLETE   expect ("GR001 "); */
-/* OBSOLETE   get_hex_regs (1, GR1_REGNUM); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Fetch register REGNO, or all registers if REGNO is -1. */
-/* OBSOLETE    Returns errno value.  */ */
-/* OBSOLETE void */
-/* OBSOLETE eb_fetch_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   if (regno == -1) */
-/* OBSOLETE     eb_fetch_registers (); */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       char *name = get_reg_name (regno); */
-/* OBSOLETE       fprintf (eb_stream, "dw %s,%s\n", name, name); */
-/* OBSOLETE       expect (name); */
-/* OBSOLETE       expect (" "); */
-/* OBSOLETE       get_hex_regs (1, regno); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE   return; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Store the remote registers from the contents of the block REGS.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE eb_store_registers (void) */
-/* OBSOLETE { */
-/* OBSOLETE   int i, j; */
-/* OBSOLETE   fprintf (eb_stream, "s gr1,%x\n", read_register (GR1_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE   for (j = 0; j < 32; j += 16) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf (eb_stream, "s gr%d,", j + 96); */
-/* OBSOLETE       for (i = 0; i < 15; ++i) */
-/* OBSOLETE 	fprintf (eb_stream, "%x,", read_register (GR96_REGNUM + j + i)); */
-/* OBSOLETE       fprintf (eb_stream, "%x\n", read_register (GR96_REGNUM + j + 15)); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   for (j = 0; j < 128; j += 16) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf (eb_stream, "s lr%d,", j); */
-/* OBSOLETE       for (i = 0; i < 15; ++i) */
-/* OBSOLETE 	fprintf (eb_stream, "%x,", read_register (LR0_REGNUM + j + i)); */
-/* OBSOLETE       fprintf (eb_stream, "%x\n", read_register (LR0_REGNUM + j + 15)); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   fprintf (eb_stream, "s sr133,%x,%x,%x\n", read_register (BP_REGNUM), */
-/* OBSOLETE 	   read_register (FC_REGNUM), read_register (CR_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   fprintf (eb_stream, "s sr131,%x\n", read_register (Q_REGNUM)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE   fprintf (eb_stream, "s sr0,"); */
-/* OBSOLETE   for (i = 0; i < 11; ++i) */
-/* OBSOLETE     fprintf (eb_stream, "%x,", read_register (VAB_REGNUM + i)); */
-/* OBSOLETE   fprintf (eb_stream, "%x\n", read_register (VAB_REGNUM + 11)); */
-/* OBSOLETE   expect_prompt (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Store register REGNO, or all if REGNO == 0. */
-/* OBSOLETE    Return errno value.  */ */
-/* OBSOLETE void */
-/* OBSOLETE eb_store_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   if (regno == -1) */
-/* OBSOLETE     eb_store_registers (); */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       char *name = get_reg_name (regno); */
-/* OBSOLETE       fprintf (eb_stream, "s %s,%x\n", name, read_register (regno)); */
-/* OBSOLETE       /* Setting GR1 changes the numbers of all the locals, so */
-/* OBSOLETE          invalidate the register cache.  Do this *after* calling */
-/* OBSOLETE          read_register, because we want read_register to return the */
-/* OBSOLETE          value that write_register has just stuffed into the registers */
-/* OBSOLETE          array, not the value of the register fetched from the */
-/* OBSOLETE          inferior.  */ */
-/* OBSOLETE       if (regno == GR1_REGNUM) */
-/* OBSOLETE 	registers_changed (); */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Get ready to modify the registers array.  On machines which store */
-/* OBSOLETE    individual registers, this doesn't need to do anything.  On machines */
-/* OBSOLETE    which store all the registers in one fell swoop, this makes sure */
-/* OBSOLETE    that registers contains all the registers from the program being */
-/* OBSOLETE    debugged.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE eb_prepare_to_store (void) */
-/* OBSOLETE { */
-/* OBSOLETE   /* Do nothing, since we can store individual regs */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Transfer LEN bytes between GDB address MYADDR and target address */
-/* OBSOLETE    MEMADDR.  If WRITE is non-zero, transfer them to the target, */
-/* OBSOLETE    otherwise transfer them from the target.  TARGET is unused. */
-/* OBSOLETE  */
-/* OBSOLETE    Returns the number of bytes transferred. */ */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE eb_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
-/* OBSOLETE 			 struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
-/* OBSOLETE 			 struct target_ops *target ATTRIBUTE_UNUSED) */
-/* OBSOLETE { */
-/* OBSOLETE   if (write) */
-/* OBSOLETE     return eb_write_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE   else */
-/* OBSOLETE     return eb_read_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE eb_files_info (void) */
-/* OBSOLETE { */
-/* OBSOLETE   printf ("\tAttached to %s at %d baud and running program %s.\n", */
-/* OBSOLETE 	  dev_name, baudrate, prog_name); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
-/* OBSOLETE    to inferior's memory at MEMADDR.  Returns length moved.  */ */
-/* OBSOLETE int */
-/* OBSOLETE eb_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; i < len; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if ((i % 16) == 0) */
-/* OBSOLETE 	fprintf (eb_stream, "sb %x,", memaddr + i); */
-/* OBSOLETE       if ((i % 16) == 15 || i == len - 1) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  fprintf (eb_stream, "%x\n", ((unsigned char *) myaddr)[i]); */
-/* OBSOLETE 	  expect_prompt (); */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	fprintf (eb_stream, "%x,", ((unsigned char *) myaddr)[i]); */
-/* OBSOLETE     } */
-/* OBSOLETE   return len; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Read LEN bytes from inferior memory at MEMADDR.  Put the result */
-/* OBSOLETE    at debugger address MYADDR.  Returns length moved.  */ */
-/* OBSOLETE int */
-/* OBSOLETE eb_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Number of bytes read so far.  */ */
-/* OBSOLETE   int count; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Starting address of this pass.  */ */
-/* OBSOLETE   unsigned long startaddr; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Number of bytes to read in this pass.  */ */
-/* OBSOLETE   int len_this_pass; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Note that this code works correctly if startaddr is just less */
-/* OBSOLETE      than UINT_MAX (well, really CORE_ADDR_MAX if there was such a */
-/* OBSOLETE      thing).  That is, something like */
-/* OBSOLETE      eb_read_bytes (CORE_ADDR_MAX - 4, foo, 4) */
-/* OBSOLETE      works--it never adds len to memaddr and gets 0.  */ */
-/* OBSOLETE   /* However, something like */
-/* OBSOLETE      eb_read_bytes (CORE_ADDR_MAX - 3, foo, 4) */
-/* OBSOLETE      doesn't need to work.  Detect it and give up if there's an attempt */
-/* OBSOLETE      to do that.  */ */
-/* OBSOLETE   if (((memaddr - 1) + len) < memaddr) */
-/* OBSOLETE     { */
-/* OBSOLETE       errno = EIO; */
-/* OBSOLETE       return 0; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   startaddr = memaddr; */
-/* OBSOLETE   count = 0; */
-/* OBSOLETE   while (count < len) */
-/* OBSOLETE     { */
-/* OBSOLETE       len_this_pass = 16; */
-/* OBSOLETE       if ((startaddr % 16) != 0) */
-/* OBSOLETE 	len_this_pass -= startaddr % 16; */
-/* OBSOLETE       if (len_this_pass > (len - count)) */
-/* OBSOLETE 	len_this_pass = (len - count); */
-/* OBSOLETE  */
-/* OBSOLETE       fprintf (eb_stream, "db %x,%x\n", startaddr, */
-/* OBSOLETE 	       (startaddr - 1) + len_this_pass); */
-/* OBSOLETE       expect ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE       /* Look for 8 hex digits.  */ */
-/* OBSOLETE       i = 0; */
-/* OBSOLETE       while (1) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  if (isxdigit (readchar ())) */
-/* OBSOLETE 	    ++i; */
-/* OBSOLETE 	  else */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      expect_prompt (); */
-/* OBSOLETE 	      error ("Hex digit expected from remote system."); */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  if (i >= 8) */
-/* OBSOLETE 	    break; */
-/* OBSOLETE 	} */
-/* OBSOLETE  */
-/* OBSOLETE       expect ("  "); */
-/* OBSOLETE  */
-/* OBSOLETE       for (i = 0; i < len_this_pass; i++) */
-/* OBSOLETE 	get_hex_byte (&myaddr[count++]); */
-/* OBSOLETE  */
-/* OBSOLETE       expect_prompt (); */
-/* OBSOLETE  */
-/* OBSOLETE       startaddr += len_this_pass; */
-/* OBSOLETE     } */
-/* OBSOLETE   return len; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE eb_kill (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   return;			/* Ignore attempts to kill target system */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Clean up when a program exits. */
-/* OBSOLETE  */
-/* OBSOLETE    The program actually lives on in the remote processor's RAM, and may be */
-/* OBSOLETE    run again without a download.  Don't leave it full of breakpoint */
-/* OBSOLETE    instructions.  */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE eb_mourn_inferior (void) */
-/* OBSOLETE { */
-/* OBSOLETE   remove_breakpoints (); */
-/* OBSOLETE   unpush_target (&eb_ops); */
-/* OBSOLETE   generic_mourn_inferior ();	/* Do all the proper things now */ */
-/* OBSOLETE } */
-/* OBSOLETE /* Define the target subroutine names */ */
-/* OBSOLETE  */
-/* OBSOLETE struct target_ops eb_ops; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE init_eb_ops (void) */
-/* OBSOLETE { */
-/* OBSOLETE   eb_ops.to_shortname = "amd-eb"; */
-/* OBSOLETE   eb_ops.to_longname = "Remote serial AMD EBMON target"; */
-/* OBSOLETE   eb_ops.to_doc = "Use a remote computer running EBMON connected by a serial line.\n\ */
-/* OBSOLETE Arguments are the name of the device for the serial line,\n\ */
-/* OBSOLETE the speed to connect at in bits per second, and the filename of the\n\ */
-/* OBSOLETE executable as it exists on the remote computer.  For example,\n\ */
-/* OBSOLETE target amd-eb /dev/ttya 9600 demo", */
-/* OBSOLETE     eb_ops.to_open = eb_open; */
-/* OBSOLETE   eb_ops.to_close = eb_close; */
-/* OBSOLETE   eb_ops.to_attach = 0; */
-/* OBSOLETE   eb_ops.to_post_attach = NULL; */
-/* OBSOLETE   eb_ops.to_require_attach = NULL; */
-/* OBSOLETE   eb_ops.to_detach = eb_detach; */
-/* OBSOLETE   eb_ops.to_require_detach = NULL; */
-/* OBSOLETE   eb_ops.to_resume = eb_resume; */
-/* OBSOLETE   eb_ops.to_wait = eb_wait; */
-/* OBSOLETE   eb_ops.to_post_wait = NULL; */
-/* OBSOLETE   eb_ops.to_fetch_registers = eb_fetch_register; */
-/* OBSOLETE   eb_ops.to_store_registers = eb_store_register; */
-/* OBSOLETE   eb_ops.to_prepare_to_store = eb_prepare_to_store; */
-/* OBSOLETE   eb_ops.to_xfer_memory = eb_xfer_inferior_memory; */
-/* OBSOLETE   eb_ops.to_files_info = eb_files_info; */
-/* OBSOLETE   eb_ops.to_insert_breakpoint = 0; */
-/* OBSOLETE   eb_ops.to_remove_breakpoint = 0;	/* Breakpoints */ */
-/* OBSOLETE   eb_ops.to_terminal_init = 0; */
-/* OBSOLETE   eb_ops.to_terminal_inferior = 0; */
-/* OBSOLETE   eb_ops.to_terminal_ours_for_output = 0; */
-/* OBSOLETE   eb_ops.to_terminal_ours = 0; */
-/* OBSOLETE   eb_ops.to_terminal_info = 0;	/* Terminal handling */ */
-/* OBSOLETE   eb_ops.to_kill = eb_kill; */
-/* OBSOLETE   eb_ops.to_load = generic_load;	/* load */ */
-/* OBSOLETE   eb_ops.to_lookup_symbol = 0;	/* lookup_symbol */ */
-/* OBSOLETE   eb_ops.to_create_inferior = eb_create_inferior; */
-/* OBSOLETE   eb_ops.to_post_startup_inferior = NULL; */
-/* OBSOLETE   eb_ops.to_acknowledge_created_inferior = NULL; */
-/* OBSOLETE   eb_ops.to_clone_and_follow_inferior = NULL; */
-/* OBSOLETE   eb_ops.to_post_follow_inferior_by_clone = NULL; */
-/* OBSOLETE   eb_ops.to_insert_fork_catchpoint = NULL; */
-/* OBSOLETE   eb_ops.to_remove_fork_catchpoint = NULL; */
-/* OBSOLETE   eb_ops.to_insert_vfork_catchpoint = NULL; */
-/* OBSOLETE   eb_ops.to_remove_vfork_catchpoint = NULL; */
-/* OBSOLETE   eb_ops.to_has_forked = NULL; */
-/* OBSOLETE   eb_ops.to_has_vforked = NULL; */
-/* OBSOLETE   eb_ops.to_can_follow_vfork_prior_to_exec = NULL; */
-/* OBSOLETE   eb_ops.to_post_follow_vfork = NULL; */
-/* OBSOLETE   eb_ops.to_insert_exec_catchpoint = NULL; */
-/* OBSOLETE   eb_ops.to_remove_exec_catchpoint = NULL; */
-/* OBSOLETE   eb_ops.to_has_execd = NULL; */
-/* OBSOLETE   eb_ops.to_reported_exec_events_per_exec_call = NULL; */
-/* OBSOLETE   eb_ops.to_has_exited = NULL; */
-/* OBSOLETE   eb_ops.to_mourn_inferior = eb_mourn_inferior; */
-/* OBSOLETE   eb_ops.to_can_run = 0;	/* can_run */ */
-/* OBSOLETE   eb_ops.to_notice_signals = 0;	/* notice_signals */ */
-/* OBSOLETE   eb_ops.to_thread_alive = 0;	/* thread-alive */ */
-/* OBSOLETE   eb_ops.to_stop = 0;		/* to_stop */ */
-/* OBSOLETE   eb_ops.to_pid_to_exec_file = NULL; */
-/* OBSOLETE   eb_ops.to_stratum = process_stratum; */
-/* OBSOLETE   eb_ops.DONT_USE = 0;		/* next */ */
-/* OBSOLETE   eb_ops.to_has_all_memory = 1; */
-/* OBSOLETE   eb_ops.to_has_memory = 1; */
-/* OBSOLETE   eb_ops.to_has_stack = 1; */
-/* OBSOLETE   eb_ops.to_has_registers = 1; */
-/* OBSOLETE   eb_ops.to_has_execution = 1;	/* all mem, mem, stack, regs, exec */ */
-/* OBSOLETE   eb_ops.to_sections = 0;	/* sections */ */
-/* OBSOLETE   eb_ops.to_sections_end = 0;	/* sections end */ */
-/* OBSOLETE   eb_ops.to_magic = OPS_MAGIC;	/* Always the last thing */ */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE _initialize_remote_eb (void) */
-/* OBSOLETE { */
-/* OBSOLETE   init_eb_ops (); */
-/* OBSOLETE   add_target (&eb_ops); */
-/* OBSOLETE } */
diff --git a/gdb/remote-es.c b/gdb/remote-es.c
index dabbcd8..e489254 100644
--- a/gdb/remote-es.c
+++ b/gdb/remote-es.c
@@ -1616,7 +1616,7 @@
 {
   if (kiodebug)
     {
-      fprintf (stderr, "Sending: %s\n", string);
+      fprintf_unfiltered (gdb_stderr, "Sending: %s\n", string);
     }
   serial_write (es1800_desc, string, strlen (string));
 }
@@ -1663,7 +1663,7 @@
 
   if (kiodebug)
     {
-      fprintf (stderr, "message received :%s\n", buf);
+      fprintf_unfiltered (gdb_stderr, "message received :%s\n", buf);
     }
 }
 
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 385b69a..a1df0eb 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -1495,7 +1495,7 @@
 
   mips_request ('r', 0, 0, &err, mips_receive_wait, NULL);
   set_current_frame (create_new_frame (read_fp (), read_pc ()));
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
 }
 
 /* Open a connection to the remote board.  */
@@ -1621,7 +1621,7 @@
   registers_changed ();
   stop_pc = read_pc ();
   set_current_frame (create_new_frame (read_fp (), stop_pc));
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
   print_stack_frame (selected_frame, -1, 1);
   xfree (serial_port_name);
 }
diff --git a/gdb/remote-mm.c b/gdb/remote-mm.c
deleted file mode 100644
index 1cd630e..0000000
--- a/gdb/remote-mm.c
+++ /dev/null
@@ -1,1848 +0,0 @@
-/* OBSOLETE /* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB. */
-/* OBSOLETE    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, */
-/* OBSOLETE    2001 Free Software Foundation, Inc. */
-/* OBSOLETE    Originally written by Daniel Mann at AMD. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* This is like remote.c but ecpects MiniMON to be running on the Am29000  */
-/* OBSOLETE    target hardware. */
-/* OBSOLETE    - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this */
-/* OBSOLETE    file to gdb 3.95.  I was unable to get this working on sun3os4 */
-/* OBSOLETE    with termio, only with sgtty.  Because we are only attempting to */
-/* OBSOLETE    use this module to debug our kernel, which is already loaded when */
-/* OBSOLETE    gdb is started up, I did not code up the file downloading facilities.   */
-/* OBSOLETE    As a result this module has only the stubs to download files.  */
-/* OBSOLETE    You should get tagged at compile time if you need to make any  */
-/* OBSOLETE    changes/additions.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #include "defs.h" */
-/* OBSOLETE #include "inferior.h" */
-/* OBSOLETE #include "value.h" */
-/* OBSOLETE #include <ctype.h> */
-/* OBSOLETE #include <fcntl.h> */
-/* OBSOLETE #include <signal.h> */
-/* OBSOLETE #include <errno.h> */
-/* OBSOLETE #include "gdb_string.h" */
-/* OBSOLETE #include "terminal.h" */
-/* OBSOLETE #include "minimon.h" */
-/* OBSOLETE #include "target.h" */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE  */
-/* OBSOLETE /* Offset of member MEMBER in a struct of type TYPE.  */ */
-/* OBSOLETE #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) */
-/* OBSOLETE  */
-/* OBSOLETE #define DRAIN_INPUT()	(msg_recv_serial((union msg_t*)0)) */
-/* OBSOLETE  */
-/* OBSOLETE extern int stop_soon_quietly;	/* for wait_for_inferior */ */
-/* OBSOLETE  */
-/* OBSOLETE static void mm_resume (ptid_t ptid, int step, enum target_signal sig) */
-/* OBSOLETE static void mm_fetch_registers (); */
-/* OBSOLETE static int fetch_register (); */
-/* OBSOLETE static void mm_store_registers (); */
-/* OBSOLETE static int store_register (); */
-/* OBSOLETE static int regnum_to_srnum (); */
-/* OBSOLETE static void mm_close (); */
-/* OBSOLETE static char *msg_str (); */
-/* OBSOLETE static char *error_msg_str (); */
-/* OBSOLETE static int expect_msg (); */
-/* OBSOLETE static void init_target_mm (); */
-/* OBSOLETE static int mm_memory_space (); */
-/* OBSOLETE  */
-/* OBSOLETE #define FREEZE_MODE     (read_register(CPS_REGNUM) && 0x400) */
-/* OBSOLETE #define USE_SHADOW_PC	((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
-/* OBSOLETE  */
-/* OBSOLETE /* FIXME: Replace with `set remotedebug'.  */ */
-/* OBSOLETE #define LLOG_FILE "minimon.log" */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE FILE *log_file; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /*   */
-/* OBSOLETE  * Size of message buffers.  I couldn't get memory reads to work when */
-/* OBSOLETE  * the byte_count was larger than 512 (it may be a baud rate problem). */
-/* OBSOLETE  */ */
-/* OBSOLETE #define BUFER_SIZE  512 */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Size of data area in message buffer on the TARGET (remote system). */
-/* OBSOLETE  */ */
-/* OBSOLETE #define MAXDATA_T  (target_config.max_msg_size - \ */
-/* OBSOLETE 			offsetof(struct write_r_msg_t,data[0])) */
-/* OBSOLETE /*                */
-/* OBSOLETE  * Size of data area in message buffer on the HOST (gdb).  */
-/* OBSOLETE  */ */
-/* OBSOLETE #define MAXDATA_H  (BUFER_SIZE - offsetof(struct write_r_msg_t,data[0])) */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Defined as the minimum size of data areas of the two message buffers  */
-/* OBSOLETE  */ */
-/* OBSOLETE #define MAXDATA	   (MAXDATA_H < MAXDATA_T ? MAXDATA_H : MAXDATA_T) */
-/* OBSOLETE  */
-/* OBSOLETE static char out_buf[BUFER_SIZE]; */
-/* OBSOLETE static char in_buf[BUFER_SIZE]; */
-/* OBSOLETE  */
-/* OBSOLETE int msg_recv_serial (); */
-/* OBSOLETE int msg_send_serial (); */
-/* OBSOLETE  */
-/* OBSOLETE #define MAX_RETRIES 5000 */
-/* OBSOLETE extern struct target_ops mm_ops;	/* Forward declaration */ */
-/* OBSOLETE struct config_msg_t target_config;	/* HIF needs this */ */
-/* OBSOLETE union msg_t *out_msg_buf = (union msg_t *) out_buf; */
-/* OBSOLETE union msg_t *in_msg_buf = (union msg_t *) in_buf; */
-/* OBSOLETE  */
-/* OBSOLETE static int timeout = 5; */
-/* OBSOLETE  */
-/* OBSOLETE /* Descriptor for I/O to remote machine.  Initialize it to -1 so that */
-/* OBSOLETE    mm_open knows that we don't have a file open when the program */
-/* OBSOLETE    starts.  */ */
-/* OBSOLETE int mm_desc = -1; */
-/* OBSOLETE  */
-/* OBSOLETE /* stream which is fdopen'd from mm_desc.  Only valid when */
-/* OBSOLETE    mm_desc != -1.  */ */
-/* OBSOLETE FILE *mm_stream; */
-/* OBSOLETE  */
-/* OBSOLETE /* Called when SIGALRM signal sent due to alarm() timeout.  */ */
-/* OBSOLETE #ifndef HAVE_TERMIO */
-/* OBSOLETE  */
-/* OBSOLETE volatile int n_alarms; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE mm_timer (void) */
-/* OBSOLETE { */
-/* OBSOLETE #if 0 */
-/* OBSOLETE   if (kiodebug) */
-/* OBSOLETE     printf ("mm_timer called\n"); */
-/* OBSOLETE #endif */
-/* OBSOLETE   n_alarms++; */
-/* OBSOLETE } */
-/* OBSOLETE #endif	/* HAVE_TERMIO */ */
-/* OBSOLETE  */
-/* OBSOLETE /* malloc'd name of the program on the remote system.  */ */
-/* OBSOLETE static char *prog_name = NULL; */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /* Number of SIGTRAPs we need to simulate.  That is, the next */
-/* OBSOLETE    NEED_ARTIFICIAL_TRAP calls to mm_wait should just return */
-/* OBSOLETE    SIGTRAP without actually waiting for anything.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /**************************************************** REMOTE_CREATE_INFERIOR */ */
-/* OBSOLETE /* This is called not only when we first attach, but also when the */
-/* OBSOLETE    user types "run" after having attached.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_create_inferior (char *execfile, char *args, char **env) */
-/* OBSOLETE { */
-/* OBSOLETE #define MAX_TOKENS 25 */
-/* OBSOLETE #define BUFFER_SIZE 256 */
-/* OBSOLETE   int token_count; */
-/* OBSOLETE   int result; */
-/* OBSOLETE   char *token[MAX_TOKENS]; */
-/* OBSOLETE   char cmd_line[BUFFER_SIZE]; */
-/* OBSOLETE  */
-/* OBSOLETE   if (args && *args) */
-/* OBSOLETE     error ("Can't pass arguments to remote mm process (yet)."); */
-/* OBSOLETE  */
-/* OBSOLETE   if (execfile == 0 /* || exec_bfd == 0 */ ) */
-/* OBSOLETE     error ("No executable file specified"); */
-/* OBSOLETE  */
-/* OBSOLETE   if (!mm_stream) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Minimon not open yet.\n"); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* On ultra3 (NYU) we assume the kernel is already running so there is */
-/* OBSOLETE      no file to download. */
-/* OBSOLETE      FIXME: Fixed required here -> load your program, possibly with mm_load(). */
-/* OBSOLETE    */ */
-/* OBSOLETE   printf_filtered ("\n\ */
-/* OBSOLETE Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   /* We will get a task spawn event immediately.  */ */
-/* OBSOLETE   init_wait_for_inferior (); */
-/* OBSOLETE   clear_proceed_status (); */
-/* OBSOLETE   stop_soon_quietly = 1; */
-/* OBSOLETE   proceed (-1, TARGET_SIGNAL_DEFAULT, 0); */
-/* OBSOLETE   normal_stop (); */
-/* OBSOLETE } */
-/* OBSOLETE /**************************************************** REMOTE_MOURN_INFERIOR */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_mourn (void) */
-/* OBSOLETE { */
-/* OBSOLETE   pop_target ();		/* Pop back to no-child state */ */
-/* OBSOLETE   generic_mourn_inferior (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************************** damn_b */
-/* OBSOLETE */ */
-/* OBSOLETE /* Translate baud rates from integers to damn B_codes.  Unix should */
-/* OBSOLETE    have outgrown this crap years ago, but even POSIX wouldn't buck it.  */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef B19200 */
-/* OBSOLETE #define B19200 EXTA */
-/* OBSOLETE #endif */
-/* OBSOLETE #ifndef B38400 */
-/* OBSOLETE #define B38400 EXTB */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE static struct */
-/* OBSOLETE { */
-/* OBSOLETE   int rate, damn_b; */
-/* OBSOLETE } */
-/* OBSOLETE baudtab[] = */
-/* OBSOLETE { */
-/* OBSOLETE   { */
-/* OBSOLETE     0, B0 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     50, B50 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     75, B75 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     110, B110 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     134, B134 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     150, B150 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     200, B200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     300, B300 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     600, B600 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     1200, B1200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     1800, B1800 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     2400, B2400 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     4800, B4800 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     9600, B9600 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     19200, B19200 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     38400, B38400 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE   { */
-/* OBSOLETE     -1, -1 */
-/* OBSOLETE   } */
-/* OBSOLETE   , */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE static int */
-/* OBSOLETE damn_b (int rate) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; baudtab[i].rate != -1; i++) */
-/* OBSOLETE     if (rate == baudtab[i].rate) */
-/* OBSOLETE       return baudtab[i].damn_b; */
-/* OBSOLETE   return B38400;		/* Random */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /***************************************************************** REMOTE_OPEN */
-/* OBSOLETE ** Open a connection to remote minimon. */
-/* OBSOLETE    NAME is the filename used for communication, then a space, */
-/* OBSOLETE    then the baud rate. */
-/* OBSOLETE    'target adapt /dev/ttya 9600 [prognam]' for example. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE static char *dev_name; */
-/* OBSOLETE int baudrate = 9600; */
-/* OBSOLETE static void */
-/* OBSOLETE mm_open (char *name, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   TERMINAL sg; */
-/* OBSOLETE   unsigned int prl; */
-/* OBSOLETE   char *p; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Find the first whitespace character, it separates dev_name from */
-/* OBSOLETE      prog_name.  */ */
-/* OBSOLETE   for (p = name; */
-/* OBSOLETE        p && *p && !isspace (*p); p++) */
-/* OBSOLETE     ; */
-/* OBSOLETE   if (p == 0 || *p == '\0') */
-/* OBSOLETE   erroid: */
-/* OBSOLETE     error ("Usage : <command> <serial-device> <baud-rate> [progname]"); */
-/* OBSOLETE   dev_name = (char *) xmalloc (p - name + 1); */
-/* OBSOLETE   strncpy (dev_name, name, p - name); */
-/* OBSOLETE   dev_name[p - name] = '\0'; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Skip over the whitespace after dev_name */ */
-/* OBSOLETE   for (; isspace (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE  */
-/* OBSOLETE   if (1 != sscanf (p, "%d ", &baudrate)) */
-/* OBSOLETE     goto erroid; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Skip the number and then the spaces */ */
-/* OBSOLETE   for (; isdigit (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE   for (; isspace (*p); p++) */
-/* OBSOLETE     /*EMPTY */ ; */
-/* OBSOLETE  */
-/* OBSOLETE   if (prog_name != NULL) */
-/* OBSOLETE     xfree (prog_name); */
-/* OBSOLETE   prog_name = savestring (p, strlen (p)); */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE   if (mm_desc >= 0) */
-/* OBSOLETE     close (mm_desc); */
-/* OBSOLETE  */
-/* OBSOLETE   mm_desc = open (dev_name, O_RDWR); */
-/* OBSOLETE   if (mm_desc < 0) */
-/* OBSOLETE     perror_with_name (dev_name); */
-/* OBSOLETE   ioctl (mm_desc, TIOCGETP, &sg); */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   sg.c_cc[VMIN] = 0;		/* read with timeout.  */ */
-/* OBSOLETE   sg.c_cc[VTIME] = timeout * 10; */
-/* OBSOLETE   sg.c_lflag &= ~(ICANON | ECHO); */
-/* OBSOLETE   sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); */
-/* OBSOLETE #else */
-/* OBSOLETE   sg.sg_ispeed = damn_b (baudrate); */
-/* OBSOLETE   sg.sg_ospeed = damn_b (baudrate); */
-/* OBSOLETE   sg.sg_flags |= RAW; */
-/* OBSOLETE   sg.sg_flags |= ANYP; */
-/* OBSOLETE   sg.sg_flags &= ~ECHO; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE   ioctl (mm_desc, TIOCSETP, &sg); */
-/* OBSOLETE   mm_stream = fdopen (mm_desc, "r+"); */
-/* OBSOLETE  */
-/* OBSOLETE   push_target (&mm_ops); */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef HAVE_TERMIO */
-/* OBSOLETE #ifndef NO_SIGINTERRUPT */
-/* OBSOLETE   /* Cause SIGALRM's to make reads fail with EINTR instead of resuming */
-/* OBSOLETE      the read.  */ */
-/* OBSOLETE   if (siginterrupt (SIGALRM, 1) != 0) */
-/* OBSOLETE     perror ("mm_open: error in siginterrupt"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set up read timeout timer.  */ */
-/* OBSOLETE   if ((void (*)) signal (SIGALRM, mm_timer) == (void (*)) -1) */
-/* OBSOLETE     perror ("mm_open: error in signal"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   log_file = fopen (LOG_FILE, "w"); */
-/* OBSOLETE   if (log_file == NULL) */
-/* OBSOLETE     perror_with_name (LOG_FILE); */
-/* OBSOLETE #endif */
-/* OBSOLETE   /* */
-/* OBSOLETE      ** Initialize target configuration structure (global) */
-/* OBSOLETE    */ */
-/* OBSOLETE   DRAIN_INPUT (); */
-/* OBSOLETE   out_msg_buf->config_req_msg.code = CONFIG_REQ; */
-/* OBSOLETE   out_msg_buf->config_req_msg.length = 4 * 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf);	/* send config request message */ */
-/* OBSOLETE  */
-/* OBSOLETE   expect_msg (CONFIG, in_msg_buf, 1); */
-/* OBSOLETE  */
-/* OBSOLETE   a29k_get_processor_type (); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Print out some stuff, letting the user now what's going on */ */
-/* OBSOLETE   printf_filtered ("Connected to MiniMon via %s.\n", dev_name); */
-/* OBSOLETE   /* FIXME: can this restriction be removed? */ */
-/* OBSOLETE   printf_filtered ("Remote debugging using virtual addresses works only\n"); */
-/* OBSOLETE   printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n") */
-/* OBSOLETE     ; */
-/* OBSOLETE   if (processor_type != a29k_freeze_mode) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf_filtered (gdb_stderr, */
-/* OBSOLETE 			"Freeze-mode debugging not available, and can only be done on an A29050.\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   target_config.code = CONFIG; */
-/* OBSOLETE   target_config.length = 0; */
-/* OBSOLETE   target_config.processor_id = in_msg_buf->config_msg.processor_id; */
-/* OBSOLETE   target_config.version = in_msg_buf->config_msg.version; */
-/* OBSOLETE   target_config.I_mem_start = in_msg_buf->config_msg.I_mem_start; */
-/* OBSOLETE   target_config.I_mem_size = in_msg_buf->config_msg.I_mem_size; */
-/* OBSOLETE   target_config.D_mem_start = in_msg_buf->config_msg.D_mem_start; */
-/* OBSOLETE   target_config.D_mem_size = in_msg_buf->config_msg.D_mem_size; */
-/* OBSOLETE   target_config.ROM_start = in_msg_buf->config_msg.ROM_start; */
-/* OBSOLETE   target_config.ROM_size = in_msg_buf->config_msg.ROM_size; */
-/* OBSOLETE   target_config.max_msg_size = in_msg_buf->config_msg.max_msg_size; */
-/* OBSOLETE   target_config.max_bkpts = in_msg_buf->config_msg.max_bkpts; */
-/* OBSOLETE   target_config.coprocessor = in_msg_buf->config_msg.coprocessor; */
-/* OBSOLETE   target_config.reserved = in_msg_buf->config_msg.reserved; */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Connected to MiniMON :\n"); */
-/* OBSOLETE       printf ("    Debugcore version            %d.%d\n", */
-/* OBSOLETE 	      0x0f & (target_config.version >> 4), */
-/* OBSOLETE 	      0x0f & (target_config.version)); */
-/* OBSOLETE       printf ("    Configuration version        %d.%d\n", */
-/* OBSOLETE 	      0x0f & (target_config.version >> 12), */
-/* OBSOLETE 	      0x0f & (target_config.version >> 8)); */
-/* OBSOLETE       printf ("    Message system version       %d.%d\n", */
-/* OBSOLETE 	      0x0f & (target_config.version >> 20), */
-/* OBSOLETE 	      0x0f & (target_config.version >> 16)); */
-/* OBSOLETE       printf ("    Communication driver version %d.%d\n", */
-/* OBSOLETE 	      0x0f & (target_config.version >> 28), */
-/* OBSOLETE 	      0x0f & (target_config.version >> 24)); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Leave the target running...  */
-/* OBSOLETE    * The above message stopped the target in the dbg core (MiniMon),   */
-/* OBSOLETE    * so restart the target out of MiniMon,  */
-/* OBSOLETE    */ */
-/* OBSOLETE   out_msg_buf->go_msg.code = GO; */
-/* OBSOLETE   out_msg_buf->go_msg.length = 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   /* No message to expect after a GO */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /**************************************************************** REMOTE_CLOSE */
-/* OBSOLETE ** Close the open connection to the minimon debugger. */
-/* OBSOLETE    Use this when you want to detach and do something else */
-/* OBSOLETE    with your gdb.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_close (			/*FIXME: how is quitting used */ */
-/* OBSOLETE 	   int quitting) */
-/* OBSOLETE { */
-/* OBSOLETE   if (mm_desc < 0) */
-/* OBSOLETE     error ("Can't close remote connection: not debugging remotely."); */
-/* OBSOLETE  */
-/* OBSOLETE   /* We should never get here if there isn't something valid in */
-/* OBSOLETE      mm_desc and mm_stream.   */
-/* OBSOLETE  */
-/* OBSOLETE      Due to a bug in Unix, fclose closes not only the stdio stream, */
-/* OBSOLETE      but also the file descriptor.  So we don't actually close */
-/* OBSOLETE      mm_desc.  */ */
-/* OBSOLETE   DRAIN_INPUT (); */
-/* OBSOLETE   fclose (mm_stream); */
-/* OBSOLETE   /* close (mm_desc); */ */
-/* OBSOLETE  */
-/* OBSOLETE   /* Do not try to close mm_desc again, later in the program.  */ */
-/* OBSOLETE   mm_stream = NULL; */
-/* OBSOLETE   mm_desc = -1; */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (LOG_FILE) */
-/* OBSOLETE   if (ferror (log_file)) */
-/* OBSOLETE     printf ("Error writing log file.\n"); */
-/* OBSOLETE   if (fclose (log_file) != 0) */
-/* OBSOLETE     printf ("Error closing log file.\n"); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   printf ("Ending remote debugging\n"); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /************************************************************* REMOTE_ATACH */ */
-/* OBSOLETE /* Attach to a program that is already loaded and running  */
-/* OBSOLETE  * Upon exiting the process's execution is stopped. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_attach (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   if (!mm_stream) */
-/* OBSOLETE     error ("MiniMon not opened yet, use the 'target minimon' command.\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf ("Attaching to remote program %s...\n", prog_name); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Make sure the target is currently running, it is supposed to be. */ */
-/* OBSOLETE   /* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in  */
-/* OBSOLETE    *  the dbg core.  If so, we don't need to send this GO. */
-/* OBSOLETE    */ */
-/* OBSOLETE   out_msg_buf->go_msg.code = GO; */
-/* OBSOLETE   out_msg_buf->go_msg.length = 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   sleep (2);			/* At the worst it will stop, receive a message, continue */ */
-/* OBSOLETE  */
-/* OBSOLETE   /* Send the mm a break. */ */
-/* OBSOLETE   out_msg_buf->break_msg.code = BREAK; */
-/* OBSOLETE   out_msg_buf->break_msg.length = 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE } */
-/* OBSOLETE /********************************************************** REMOTE_DETACH */ */
-/* OBSOLETE /* Terminate the open connection to the remote debugger. */
-/* OBSOLETE    Use this when you want to detach and do something else */
-/* OBSOLETE    with your gdb.  Leave remote process running (with no breakpoints set). */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_detach (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   remove_breakpoints ();	/* Just in case there were any left in */ */
-/* OBSOLETE   out_msg_buf->go_msg.code = GO; */
-/* OBSOLETE   out_msg_buf->go_msg.length = 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   pop_target ();		/* calls mm_close to do the real work */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /*************************************************************** REMOTE_RESUME */
-/* OBSOLETE ** Tell the remote machine to resume.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE mm_resume (ptid_t ptid, int step, enum target_signal sig) */
-/* OBSOLETE { */
-/* OBSOLETE   if (sig != TARGET_SIGNAL_0) */
-/* OBSOLETE     warning ("Can't send signals to a remote MiniMon system."); */
-/* OBSOLETE  */
-/* OBSOLETE   if (step) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->step_msg.code = STEP; */
-/* OBSOLETE       out_msg_buf->step_msg.length = 1 * 4; */
-/* OBSOLETE       out_msg_buf->step_msg.count = 1;	/* step 1 instruction */ */
-/* OBSOLETE       msg_send_serial (out_msg_buf); */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->go_msg.code = GO; */
-/* OBSOLETE       out_msg_buf->go_msg.length = 0; */
-/* OBSOLETE       msg_send_serial (out_msg_buf); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /***************************************************************** REMOTE_WAIT */
-/* OBSOLETE ** Wait until the remote machine stops, then return, */
-/* OBSOLETE    storing status in STATUS just as `wait' would.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static ptid_t */
-/* OBSOLETE mm_wait (ptid_t ptid, struct target_waitstatus *status) */
-/* OBSOLETE { */
-/* OBSOLETE   int i, result; */
-/* OBSOLETE   int old_timeout = timeout; */
-/* OBSOLETE   int old_immediate_quit = immediate_quit; */
-/* OBSOLETE  */
-/* OBSOLETE   status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE   status->value.integer = 0; */
-/* OBSOLETE  */
-/* OBSOLETE /* wait for message to arrive. It should be: */
-/* OBSOLETE    - A HIF service request. */
-/* OBSOLETE    - A HIF exit service request. */
-/* OBSOLETE    - A CHANNEL0_ACK. */
-/* OBSOLETE    - A CHANNEL1 request. */
-/* OBSOLETE    - a debugcore HALT message. */
-/* OBSOLETE    HIF services must be responded too, and while-looping continued. */
-/* OBSOLETE    If the target stops executing, mm_wait() should return. */
-/* OBSOLETE  */ */
-/* OBSOLETE   timeout = 0;			/* Wait indefinetly for a message */ */
-/* OBSOLETE   immediate_quit = 1;		/* Helps ability to QUIT */ */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       while (msg_recv_serial (in_msg_buf)) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  QUIT;			/* Let user quit if they want */ */
-/* OBSOLETE 	} */
-/* OBSOLETE       switch (in_msg_buf->halt_msg.code) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	case HIF_CALL: */
-/* OBSOLETE 	  i = in_msg_buf->hif_call_rtn_msg.service_number; */
-/* OBSOLETE 	  result = service_HIF (in_msg_buf); */
-/* OBSOLETE 	  if (i == 1)		/* EXIT */ */
-/* OBSOLETE 	    goto exit; */
-/* OBSOLETE 	  if (result) */
-/* OBSOLETE 	    printf ("Warning: failure during HIF service %d\n", i); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case CHANNEL0_ACK: */
-/* OBSOLETE 	  service_HIF (in_msg_buf); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case CHANNEL1: */
-/* OBSOLETE 	  i = in_msg_buf->channel1_msg.length; */
-/* OBSOLETE 	  in_msg_buf->channel1_msg.data[i] = '\0'; */
-/* OBSOLETE 	  printf ("%s", in_msg_buf->channel1_msg.data); */
-/* OBSOLETE 	  gdb_flush (gdb_stdout); */
-/* OBSOLETE 	  /* Send CHANNEL1_ACK message */ */
-/* OBSOLETE 	  out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK; */
-/* OBSOLETE 	  out_msg_buf->channel1_ack_msg.length = 0; */
-/* OBSOLETE 	  result = msg_send_serial (out_msg_buf); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case HALT: */
-/* OBSOLETE 	  goto halted; */
-/* OBSOLETE 	default: */
-/* OBSOLETE 	  goto halted; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE halted: */
-/* OBSOLETE   /* FIXME, these printfs should not be here.  This is a source level  */
-/* OBSOLETE      debugger, guys!  */ */
-/* OBSOLETE   if (in_msg_buf->halt_msg.trap_number == 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d (break point)\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 1) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_BUS; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 3 */
-/* OBSOLETE 	   || in_msg_buf->halt_msg.trap_number == 4) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_FPE; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 5) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_ILL; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number >= 6 */
-/* OBSOLETE 	   && in_msg_buf->halt_msg.trap_number <= 11) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_SEGV; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 12 */
-/* OBSOLETE 	   || in_msg_buf->halt_msg.trap_number == 13) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_ILL; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 14) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_ALRM; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 15) */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number >= 16 */
-/* OBSOLETE 	   && in_msg_buf->halt_msg.trap_number <= 21) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_INT; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 22) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Am290*0 received vector number %d\n", */
-/* OBSOLETE 	      in_msg_buf->halt_msg.trap_number); */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_ILL; */
-/* OBSOLETE     }				/* BREAK message was sent */ */
-/* OBSOLETE   else if (in_msg_buf->halt_msg.trap_number == 75) */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE   exit: */
-/* OBSOLETE     { */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE       status->value.integer = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   timeout = old_timeout;	/* Restore original timeout value */ */
-/* OBSOLETE   immediate_quit = old_immediate_quit; */
-/* OBSOLETE   return inferior_ptid; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************* REMOTE_FETCH_REGISTERS */
-/* OBSOLETE  * Read a remote register 'regno'.  */
-/* OBSOLETE  * If regno==-1 then read all the registers. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_fetch_registers (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   INT32 *data_p; */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno >= 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       fetch_register (regno); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Gr1/rsp */ */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4 * 1; */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE   out_msg_buf->read_req_msg.address = 1; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (READ_ACK, in_msg_buf, 1); */
-/* OBSOLETE   data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
-/* OBSOLETE   supply_register (GR1_REGNUM, data_p); */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(GR64_REGNUM)	/* Read gr64-127 */ */
-/* OBSOLETE /* Global Registers gr64-gr95 */ */
-/* OBSOLETE   out_msg_buf->read_req_msg.code = READ_REQ; */
-/* OBSOLETE   out_msg_buf->read_req_msg.length = 4 * 3; */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4 * 32; */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE   out_msg_buf->read_req_msg.address = 64; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (READ_ACK, in_msg_buf, 1); */
-/* OBSOLETE   data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       supply_register (regno, data_p++); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif /*  GR64_REGNUM */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Global Registers gr96-gr127 */ */
-/* OBSOLETE   out_msg_buf->read_req_msg.code = READ_REQ; */
-/* OBSOLETE   out_msg_buf->read_req_msg.length = 4 * 3; */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4 * 32; */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE   out_msg_buf->read_req_msg.address = 96; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (READ_ACK, in_msg_buf, 1); */
-/* OBSOLETE   data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       supply_register (regno, data_p++); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Local Registers */ */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4 * (128); */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = LOCAL_REG; */
-/* OBSOLETE   out_msg_buf->read_req_msg.address = 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (READ_ACK, in_msg_buf, 1); */
-/* OBSOLETE   data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       supply_register (regno, data_p++); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Protected Special Registers */ */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4 * 15; */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; */
-/* OBSOLETE   out_msg_buf->read_req_msg.address = 0; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (READ_ACK, in_msg_buf, 1); */
-/* OBSOLETE   data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = 0; regno <= 14; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       supply_register (SR_REGNUM (regno), data_p++); */
-/* OBSOLETE     } */
-/* OBSOLETE   if (USE_SHADOW_PC) */
-/* OBSOLETE     {				/* Let regno_to_srnum() handle the register number */ */
-/* OBSOLETE       fetch_register (NPC_REGNUM); */
-/* OBSOLETE       fetch_register (PC_REGNUM); */
-/* OBSOLETE       fetch_register (PC2_REGNUM); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Unprotected Special Registers */ */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4 * 8; */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; */
-/* OBSOLETE   out_msg_buf->read_req_msg.address = 128; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (READ_ACK, in_msg_buf, 1); */
-/* OBSOLETE   data_p = &(in_msg_buf->read_r_ack_msg.data[0]); */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = 128; regno <= 135; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       supply_register (SR_REGNUM (regno), data_p++); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* There doesn't seem to be any way to get these.  */ */
-/* OBSOLETE   { */
-/* OBSOLETE     int val = -1; */
-/* OBSOLETE     supply_register (FPE_REGNUM, &val); */
-/* OBSOLETE     supply_register (INTE_REGNUM, &val); */
-/* OBSOLETE     supply_register (FPS_REGNUM, &val); */
-/* OBSOLETE     supply_register (EXO_REGNUM, &val); */
-/* OBSOLETE   } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /****************************************************** REMOTE_STORE_REGISTERS */
-/* OBSOLETE  * Store register regno into the target.   */
-/* OBSOLETE  * If regno==-1 then store all the registers. */
-/* OBSOLETE  * Result is 0 for success, -1 for failure. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE mm_store_registers (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   int result; */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno >= 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       store_register (regno); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   result = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   out_msg_buf->write_r_msg.code = WRITE_REQ; */
-/* OBSOLETE  */
-/* OBSOLETE /* Gr1/rsp */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * 1; */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 1; */
-/* OBSOLETE   out_msg_buf->write_r_msg.data[0] = read_register (GR1_REGNUM); */
-/* OBSOLETE  */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE /* Global registers gr64-gr95 */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * (32); */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 64; */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_r_msg.data[regno - GR64_REGNUM] = read_register (regno); */
-/* OBSOLETE     } */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE #endif /* GR64_REGNUM */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Global registers gr96-gr127 */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * (32); */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 96; */
-/* OBSOLETE   for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_r_msg.data[regno - GR96_REGNUM] = read_register (regno); */
-/* OBSOLETE     } */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Local Registers */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.memory_space = LOCAL_REG; */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * 128; */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_r_msg.data[regno - LR0_REGNUM] = read_register (regno); */
-/* OBSOLETE     } */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Protected Special Registers */ */
-/* OBSOLETE   /* VAB through TMR */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.memory_space = SPECIAL_REG; */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * 10; */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 0; */
-/* OBSOLETE   for (regno = 0; regno <= 9; regno++)	/* VAB through TMR */ */
-/* OBSOLETE     out_msg_buf->write_r_msg.data[regno] = read_register (SR_REGNUM (regno)); */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* PC0, PC1, PC2 possibly as shadow registers */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * 3; */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   for (regno = 10; regno <= 12; regno++)	/* LRU and MMU */ */
-/* OBSOLETE     out_msg_buf->write_r_msg.data[regno - 10] = read_register (SR_REGNUM (regno)); */
-/* OBSOLETE   if (USE_SHADOW_PC) */
-/* OBSOLETE     out_msg_buf->write_r_msg.address = 20;	/* SPC0 */ */
-/* OBSOLETE   else */
-/* OBSOLETE     out_msg_buf->write_r_msg.address = 10;	/* PC0 */ */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* LRU and MMU */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * 2; */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 13; */
-/* OBSOLETE   for (regno = 13; regno <= 14; regno++)	/* LRU and MMU */ */
-/* OBSOLETE     out_msg_buf->write_r_msg.data[regno - 13] = read_register (SR_REGNUM (regno)); */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Unprotected Special Registers */ */
-/* OBSOLETE   out_msg_buf->write_r_msg.byte_count = 4 * 8; */
-/* OBSOLETE   out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count; */
-/* OBSOLETE   out_msg_buf->write_r_msg.address = 128; */
-/* OBSOLETE   for (regno = 128; regno <= 135; regno++) */
-/* OBSOLETE     out_msg_buf->write_r_msg.data[regno - 128] = read_register (SR_REGNUM (regno)); */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (!expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   registers_changed (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /*************************************************** REMOTE_PREPARE_TO_STORE */ */
-/* OBSOLETE /* Get ready to modify the registers array.  On machines which store */
-/* OBSOLETE    individual registers, this doesn't need to do anything.  On machines */
-/* OBSOLETE    which store all the registers in one fell swoop, this makes sure */
-/* OBSOLETE    that registers contains all the registers from the program being */
-/* OBSOLETE    debugged.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE mm_prepare_to_store (void) */
-/* OBSOLETE { */
-/* OBSOLETE   /* Do nothing, since we can store individual regs */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************* REMOTE_XFER_MEMORY */ */
-/* OBSOLETE static CORE_ADDR */
-/* OBSOLETE translate_addr (CORE_ADDR addr) */
-/* OBSOLETE { */
-/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
-/* OBSOLETE   /* Check for a virtual address in the kernel */ */
-/* OBSOLETE   /* Assume physical address of ublock is in  paddr_u register */ */
-/* OBSOLETE   /* FIXME: doesn't work for user virtual addresses */ */
-/* OBSOLETE   if (addr >= UVADDR) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* PADDR_U register holds the physical address of the ublock */ */
-/* OBSOLETE       CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
-/* OBSOLETE       return (i + addr - (CORE_ADDR) UVADDR); */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       return (addr); */
-/* OBSOLETE     } */
-/* OBSOLETE #else */
-/* OBSOLETE   return (addr); */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************* REMOTE_FILES_INFO */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_files_info (void) */
-/* OBSOLETE { */
-/* OBSOLETE   printf ("\tAttached to %s at %d baud and running program %s.\n", */
-/* OBSOLETE 	  dev_name, baudrate, prog_name); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /************************************************* REMOTE_INSERT_BREAKPOINT */ */
-/* OBSOLETE static int */
-/* OBSOLETE mm_insert_breakpoint (CORE_ADDR addr, char *contents_cache) */
-/* OBSOLETE { */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.code = BKPT_SET; */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.length = 4 * 4; */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.memory_space = I_MEM; */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.bkpt_addr = (ADDR32) addr; */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.pass_count = 1; */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.bkpt_type = -1;	/* use illop for 29000 */ */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (expect_msg (BKPT_SET_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       return 0;			/* Success */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       return 1;			/* Failure */ */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /************************************************* REMOTE_DELETE_BREAKPOINT */ */
-/* OBSOLETE static int */
-/* OBSOLETE mm_remove_breakpoint (CORE_ADDR addr, char *contents_cache) */
-/* OBSOLETE { */
-/* OBSOLETE   out_msg_buf->bkpt_rm_msg.code = BKPT_RM; */
-/* OBSOLETE   out_msg_buf->bkpt_rm_msg.length = 4 * 3; */
-/* OBSOLETE   out_msg_buf->bkpt_rm_msg.memory_space = I_MEM; */
-/* OBSOLETE   out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   if (expect_msg (BKPT_RM_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       return 0;			/* Success */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       return 1;			/* Failure */ */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************* REMOTE_KILL */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_kill (char *arg, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   char buf[4]; */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
-/* OBSOLETE   /* We don't ever kill the kernel */ */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Kernel not killed, but left in current state.\n"); */
-/* OBSOLETE       printf ("Use detach to leave kernel running.\n"); */
-/* OBSOLETE     } */
-/* OBSOLETE #else */
-/* OBSOLETE   out_msg_buf->break_msg.code = BREAK; */
-/* OBSOLETE   out_msg_buf->bkpt_set_msg.length = 4 * 0; */
-/* OBSOLETE   expect_msg (HALT, in_msg_buf, from_tty); */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Target has been stopped."); */
-/* OBSOLETE       printf ("Would you like to do a hardware reset (y/n) [n] "); */
-/* OBSOLETE       fgets (buf, 3, stdin); */
-/* OBSOLETE       if (buf[0] == 'y') */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  out_msg_buf->reset_msg.code = RESET; */
-/* OBSOLETE 	  out_msg_buf->bkpt_set_msg.length = 4 * 0; */
-/* OBSOLETE 	  expect_msg (RESET_ACK, in_msg_buf, from_tty); */
-/* OBSOLETE 	  printf ("Target has been reset."); */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   pop_target (); */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /***************************************************************************/ */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Load a program into the target. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE mm_load (char *arg_string, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   dont_repeat (); */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(KERNEL_DEBUGGING) */
-/* OBSOLETE   printf ("The kernel had better be loaded already!  Loading not done.\n"); */
-/* OBSOLETE #else */
-/* OBSOLETE   if (arg_string == 0) */
-/* OBSOLETE     error ("The load command takes a file name"); */
-/* OBSOLETE  */
-/* OBSOLETE   arg_string = tilde_expand (arg_string); */
-/* OBSOLETE   make_cleanup (xfree, arg_string); */
-/* OBSOLETE   QUIT; */
-/* OBSOLETE   immediate_quit++; */
-/* OBSOLETE   error ("File loading is not yet supported for MiniMon."); */
-/* OBSOLETE   /* FIXME, code to load your file here... */ */
-/* OBSOLETE   /* You may need to do an init_target_mm() */ */
-/* OBSOLETE   /* init_target_mm(?,?,?,?,?,?,?,?); */ */
-/* OBSOLETE   immediate_quit--; */
-/* OBSOLETE   /* symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */ */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /************************************************ REMOTE_WRITE_INFERIOR_MEMORY */
-/* OBSOLETE ** Copy LEN bytes of data from debugger memory at MYADDR */
-/* OBSOLETE    to inferior's memory at MEMADDR.  Returns number of bytes written.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE mm_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int i, nwritten; */
-/* OBSOLETE  */
-/* OBSOLETE   out_msg_buf->write_req_msg.code = WRITE_REQ; */
-/* OBSOLETE   out_msg_buf->write_req_msg.memory_space = mm_memory_space (memaddr); */
-/* OBSOLETE  */
-/* OBSOLETE   nwritten = 0; */
-/* OBSOLETE   while (nwritten < len) */
-/* OBSOLETE     { */
-/* OBSOLETE       int num_to_write = len - nwritten; */
-/* OBSOLETE       if (num_to_write > MAXDATA) */
-/* OBSOLETE 	num_to_write = MAXDATA; */
-/* OBSOLETE       for (i = 0; i < num_to_write; i++) */
-/* OBSOLETE 	out_msg_buf->write_req_msg.data[i] = myaddr[i + nwritten]; */
-/* OBSOLETE       out_msg_buf->write_req_msg.byte_count = num_to_write; */
-/* OBSOLETE       out_msg_buf->write_req_msg.length = 3 * 4 + num_to_write; */
-/* OBSOLETE       out_msg_buf->write_req_msg.address = memaddr + nwritten; */
-/* OBSOLETE       msg_send_serial (out_msg_buf); */
-/* OBSOLETE  */
-/* OBSOLETE       if (expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  nwritten += in_msg_buf->write_ack_msg.byte_count; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   return (nwritten); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /************************************************* REMOTE_READ_INFERIOR_MEMORY */
-/* OBSOLETE ** Read LEN bytes from inferior memory at MEMADDR.  Put the result */
-/* OBSOLETE    at debugger address MYADDR.  Returns number of bytes read.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE mm_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int i, nread; */
-/* OBSOLETE  */
-/* OBSOLETE   out_msg_buf->read_req_msg.code = READ_REQ; */
-/* OBSOLETE   out_msg_buf->read_req_msg.memory_space = mm_memory_space (memaddr); */
-/* OBSOLETE  */
-/* OBSOLETE   nread = 0; */
-/* OBSOLETE   while (nread < len) */
-/* OBSOLETE     { */
-/* OBSOLETE       int num_to_read = (len - nread); */
-/* OBSOLETE       if (num_to_read > MAXDATA) */
-/* OBSOLETE 	num_to_read = MAXDATA; */
-/* OBSOLETE       out_msg_buf->read_req_msg.byte_count = num_to_read; */
-/* OBSOLETE       out_msg_buf->read_req_msg.length = 3 * 4 + num_to_read; */
-/* OBSOLETE       out_msg_buf->read_req_msg.address = memaddr + nread; */
-/* OBSOLETE       msg_send_serial (out_msg_buf); */
-/* OBSOLETE  */
-/* OBSOLETE       if (expect_msg (READ_ACK, in_msg_buf, 1)) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  for (i = 0; i < in_msg_buf->read_ack_msg.byte_count; i++) */
-/* OBSOLETE 	    myaddr[i + nread] = in_msg_buf->read_ack_msg.data[i]; */
-/* OBSOLETE 	  nread += in_msg_buf->read_ack_msg.byte_count; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   return (nread); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* FIXME!  Merge these two.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE mm_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
-/* OBSOLETE 			 struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
-/* OBSOLETE 			 struct target_ops *target ATTRIBUTE_UNUSED) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   memaddr = translate_addr (memaddr); */
-/* OBSOLETE  */
-/* OBSOLETE   if (write) */
-/* OBSOLETE     return mm_write_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE   else */
-/* OBSOLETE     return mm_read_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************** MSG_SEND_SERIAL */
-/* OBSOLETE ** This function is used to send a message over the */
-/* OBSOLETE ** serial line. */
-/* OBSOLETE ** */
-/* OBSOLETE ** If the message is successfully sent, a zero is */
-/* OBSOLETE ** returned.  If the message was not sendable, a -1 */
-/* OBSOLETE ** is returned.  This function blocks.  That is, it */
-/* OBSOLETE ** does not return until the message is completely */
-/* OBSOLETE ** sent, or until an error is encountered. */
-/* OBSOLETE ** */
-/* OBSOLETE */ */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE msg_send_serial (union msg_t *msg_ptr) */
-/* OBSOLETE { */
-/* OBSOLETE   INT32 message_size; */
-/* OBSOLETE   int byte_count; */
-/* OBSOLETE   int result; */
-/* OBSOLETE   char c; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Send message header */ */
-/* OBSOLETE   byte_count = 0; */
-/* OBSOLETE   message_size = msg_ptr->generic_msg.length + (2 * sizeof (INT32)); */
-/* OBSOLETE   do */
-/* OBSOLETE     { */
-/* OBSOLETE       c = *((char *) msg_ptr + byte_count); */
-/* OBSOLETE       result = write (mm_desc, &c, 1); */
-/* OBSOLETE       if (result == 1) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  byte_count = byte_count + 1; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   while ((byte_count < message_size)); */
-/* OBSOLETE  */
-/* OBSOLETE   return (0); */
-/* OBSOLETE }				/* end msg_send_serial() */ */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************** MSG_RECV_SERIAL */
-/* OBSOLETE ** This function is used to receive a message over a */
-/* OBSOLETE ** serial line. */
-/* OBSOLETE ** */
-/* OBSOLETE ** If the message is waiting in the buffer, a zero is */
-/* OBSOLETE ** returned and the buffer pointed to by msg_ptr is filled */
-/* OBSOLETE ** in.  If no message was available, a -1 is returned. */
-/* OBSOLETE ** If timeout==0, wait indefinetly for a character. */
-/* OBSOLETE ** */
-/* OBSOLETE */ */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE msg_recv_serial (union msg_t *msg_ptr) */
-/* OBSOLETE { */
-/* OBSOLETE   static INT32 length = 0; */
-/* OBSOLETE   static INT32 byte_count = 0; */
-/* OBSOLETE   int result; */
-/* OBSOLETE   char c; */
-/* OBSOLETE   if (msg_ptr == 0)		/* re-sync request */ */
-/* OBSOLETE     { */
-/* OBSOLETE       length = 0; */
-/* OBSOLETE       byte_count = 0; */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE       /* The timeout here is the prevailing timeout set with VTIME */ */
-/* OBSOLETE       ->"timeout==0 semantics not supported" */
-/* OBSOLETE 	read (mm_desc, in_buf, BUFER_SIZE); */
-/* OBSOLETE #else */
-/* OBSOLETE       alarm (1); */
-/* OBSOLETE       read (mm_desc, in_buf, BUFER_SIZE); */
-/* OBSOLETE       alarm (0); */
-/* OBSOLETE #endif */
-/* OBSOLETE       return (0); */
-/* OBSOLETE     } */
-/* OBSOLETE   /* Receive message */ */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE /* Timeout==0, help support the mm_wait() routine */ */
-/* OBSOLETE   ->"timeout==0 semantics not supported (and its nice if they are)" */
-/* OBSOLETE     result = read (mm_desc, &c, 1); */
-/* OBSOLETE #else */
-/* OBSOLETE   alarm (timeout); */
-/* OBSOLETE   result = read (mm_desc, &c, 1); */
-/* OBSOLETE   alarm (0); */
-/* OBSOLETE #endif */
-/* OBSOLETE   if (result < 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (errno == EINTR) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  error ("Timeout reading from remote system."); */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	perror_with_name ("remote"); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (result == 1) */
-/* OBSOLETE     { */
-/* OBSOLETE       *((char *) msg_ptr + byte_count) = c; */
-/* OBSOLETE       byte_count = byte_count + 1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Message header received.  Save message length. */ */
-/* OBSOLETE   if (byte_count == (2 * sizeof (INT32))) */
-/* OBSOLETE     length = msg_ptr->generic_msg.length; */
-/* OBSOLETE  */
-/* OBSOLETE   if (byte_count >= (length + (2 * sizeof (INT32)))) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* Message received */ */
-/* OBSOLETE       byte_count = 0; */
-/* OBSOLETE       return (0); */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     return (-1); */
-/* OBSOLETE  */
-/* OBSOLETE }				/* end msg_recv_serial() */ */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************************* KBD_RAW */
-/* OBSOLETE ** This function is used to put the keyboard in "raw" */
-/* OBSOLETE ** mode for BSD Unix.  The original status is saved */
-/* OBSOLETE ** so that it may be restored later. */
-/* OBSOLETE */ */
-/* OBSOLETE TERMINAL kbd_tbuf; */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE kbd_raw (void) */
-/* OBSOLETE { */
-/* OBSOLETE   int result; */
-/* OBSOLETE   TERMINAL tbuf; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Get keyboard termio (to save to restore original modes) */ */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   result = ioctl (0, TCGETA, &kbd_tbuf); */
-/* OBSOLETE #else */
-/* OBSOLETE   result = ioctl (0, TIOCGETP, &kbd_tbuf); */
-/* OBSOLETE #endif */
-/* OBSOLETE   if (result == -1) */
-/* OBSOLETE     return (errno); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Get keyboard TERMINAL (for modification) */ */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   result = ioctl (0, TCGETA, &tbuf); */
-/* OBSOLETE #else */
-/* OBSOLETE   result = ioctl (0, TIOCGETP, &tbuf); */
-/* OBSOLETE #endif */
-/* OBSOLETE   if (result == -1) */
-/* OBSOLETE     return (errno); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set up new parameters */ */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   tbuf.c_iflag = tbuf.c_iflag & */
-/* OBSOLETE     ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT); */
-/* OBSOLETE   tbuf.c_lflag = tbuf.c_lflag & ~(ICANON | ISIG | ECHO); */
-/* OBSOLETE   tbuf.c_cc[4] = 0;		/* MIN */ */
-/* OBSOLETE   tbuf.c_cc[5] = 0;		/* TIME */ */
-/* OBSOLETE #else */
-/* OBSOLETE   /* FIXME: not sure if this is correct (matches HAVE_TERMIO). */ */
-/* OBSOLETE   tbuf.sg_flags |= RAW; */
-/* OBSOLETE   tbuf.sg_flags |= ANYP; */
-/* OBSOLETE   tbuf.sg_flags &= ~ECHO; */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set keyboard termio to new mode (RAW) */ */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   result = ioctl (0, TCSETAF, &tbuf); */
-/* OBSOLETE #else */
-/* OBSOLETE   result = ioctl (0, TIOCSETP, &tbuf); */
-/* OBSOLETE #endif */
-/* OBSOLETE   if (result == -1) */
-/* OBSOLETE     return (errno); */
-/* OBSOLETE  */
-/* OBSOLETE   return (0); */
-/* OBSOLETE }				/* end kbd_raw() */ */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /***************************************************************** KBD_RESTORE */
-/* OBSOLETE ** This function is used to put the keyboard back in the */
-/* OBSOLETE ** mode it was in before kbk_raw was called.  Note that */
-/* OBSOLETE ** kbk_raw() must have been called at least once before */
-/* OBSOLETE ** kbd_restore() is called. */
-/* OBSOLETE */ */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE kbd_restore (void) */
-/* OBSOLETE { */
-/* OBSOLETE   int result; */
-/* OBSOLETE  */
-/* OBSOLETE   /* Set keyboard termio to original mode */ */
-/* OBSOLETE #ifdef HAVE_TERMIO */
-/* OBSOLETE   result = ioctl (0, TCSETAF, &kbd_tbuf); */
-/* OBSOLETE #else */
-/* OBSOLETE   result = ioctl (0, TIOCGETP, &kbd_tbuf); */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   if (result == -1) */
-/* OBSOLETE     return (errno); */
-/* OBSOLETE  */
-/* OBSOLETE   return (0); */
-/* OBSOLETE }				/* end kbd_cooked() */ */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /*****************************************************************************/ */
-/* OBSOLETE /* Fetch a single register indicatated by 'regno'.  */
-/* OBSOLETE  * Returns 0/-1 on success/failure.   */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE fetch_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   int result; */
-/* OBSOLETE   out_msg_buf->read_req_msg.code = READ_REQ; */
-/* OBSOLETE   out_msg_buf->read_req_msg.length = 4 * 3; */
-/* OBSOLETE   out_msg_buf->read_req_msg.byte_count = 4; */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno == GR1_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE       out_msg_buf->read_req_msg.address = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE       out_msg_buf->read_req_msg.address = (regno - GR96_REGNUM) + 96; */
-/* OBSOLETE     } */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE   else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE       out_msg_buf->read_req_msg.address = (regno - GR64_REGNUM) + 64; */
-/* OBSOLETE     } */
-/* OBSOLETE #endif /* GR64_REGNUM */ */
-/* OBSOLETE   else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->read_req_msg.memory_space = LOCAL_REG; */
-/* OBSOLETE       out_msg_buf->read_req_msg.address = (regno - LR0_REGNUM); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       int val = -1; */
-/* OBSOLETE       supply_register (160 + (regno - FPE_REGNUM), &val); */
-/* OBSOLETE       return 0;			/* Pretend Success */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; */
-/* OBSOLETE       out_msg_buf->read_req_msg.address = regnum_to_srnum (regno); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE  */
-/* OBSOLETE   if (expect_msg (READ_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       supply_register (regno, &(in_msg_buf->read_r_ack_msg.data[0])); */
-/* OBSOLETE       result = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE   return result; */
-/* OBSOLETE } */
-/* OBSOLETE /*****************************************************************************/ */
-/* OBSOLETE /* Store a single register indicated by 'regno'.  */
-/* OBSOLETE  * Returns 0/-1 on success/failure.   */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE store_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   int result; */
-/* OBSOLETE  */
-/* OBSOLETE   out_msg_buf->write_req_msg.code = WRITE_REQ; */
-/* OBSOLETE   out_msg_buf->write_req_msg.length = 4 * 4; */
-/* OBSOLETE   out_msg_buf->write_req_msg.byte_count = 4; */
-/* OBSOLETE   out_msg_buf->write_r_msg.data[0] = read_register (regno); */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno == GR1_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE       out_msg_buf->write_req_msg.address = 1; */
-/* OBSOLETE       /* Setting GR1 changes the numbers of all the locals, so invalidate the  */
-/* OBSOLETE        * register cache.  Do this *after* calling read_register, because we want  */
-/* OBSOLETE        * read_register to return the value that write_register has just stuffed  */
-/* OBSOLETE        * into the registers array, not the value of the register fetched from  */
-/* OBSOLETE        * the inferior.   */
-/* OBSOLETE        */ */
-/* OBSOLETE       registers_changed (); */
-/* OBSOLETE     } */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE   else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE       out_msg_buf->write_req_msg.address = (regno - GR64_REGNUM) + 64; */
-/* OBSOLETE     } */
-/* OBSOLETE #endif /* GR64_REGNUM */ */
-/* OBSOLETE   else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; */
-/* OBSOLETE       out_msg_buf->write_req_msg.address = (regno - GR96_REGNUM) + 96; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_req_msg.memory_space = LOCAL_REG; */
-/* OBSOLETE       out_msg_buf->write_req_msg.address = (regno - LR0_REGNUM); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       return 0;			/* Pretend Success */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     /* An unprotected or protected special register */ */
-/* OBSOLETE     { */
-/* OBSOLETE       out_msg_buf->write_req_msg.memory_space = SPECIAL_REG; */
-/* OBSOLETE       out_msg_buf->write_req_msg.address = regnum_to_srnum (regno); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE  */
-/* OBSOLETE   if (expect_msg (WRITE_ACK, in_msg_buf, 1)) */
-/* OBSOLETE     { */
-/* OBSOLETE       result = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       result = -1; */
-/* OBSOLETE     } */
-/* OBSOLETE   return result; */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Convert a gdb special register number to a 29000 special register number. */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE regnum_to_srnum (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   switch (regno) */
-/* OBSOLETE     { */
-/* OBSOLETE     case VAB_REGNUM: */
-/* OBSOLETE       return (0); */
-/* OBSOLETE     case OPS_REGNUM: */
-/* OBSOLETE       return (1); */
-/* OBSOLETE     case CPS_REGNUM: */
-/* OBSOLETE       return (2); */
-/* OBSOLETE     case CFG_REGNUM: */
-/* OBSOLETE       return (3); */
-/* OBSOLETE     case CHA_REGNUM: */
-/* OBSOLETE       return (4); */
-/* OBSOLETE     case CHD_REGNUM: */
-/* OBSOLETE       return (5); */
-/* OBSOLETE     case CHC_REGNUM: */
-/* OBSOLETE       return (6); */
-/* OBSOLETE     case RBP_REGNUM: */
-/* OBSOLETE       return (7); */
-/* OBSOLETE     case TMC_REGNUM: */
-/* OBSOLETE       return (8); */
-/* OBSOLETE     case TMR_REGNUM: */
-/* OBSOLETE       return (9); */
-/* OBSOLETE     case NPC_REGNUM: */
-/* OBSOLETE       return (USE_SHADOW_PC ? (20) : (10)); */
-/* OBSOLETE     case PC_REGNUM: */
-/* OBSOLETE       return (USE_SHADOW_PC ? (21) : (11)); */
-/* OBSOLETE     case PC2_REGNUM: */
-/* OBSOLETE       return (USE_SHADOW_PC ? (22) : (12)); */
-/* OBSOLETE     case MMU_REGNUM: */
-/* OBSOLETE       return (13); */
-/* OBSOLETE     case LRU_REGNUM: */
-/* OBSOLETE       return (14); */
-/* OBSOLETE     case IPC_REGNUM: */
-/* OBSOLETE       return (128); */
-/* OBSOLETE     case IPA_REGNUM: */
-/* OBSOLETE       return (129); */
-/* OBSOLETE     case IPB_REGNUM: */
-/* OBSOLETE       return (130); */
-/* OBSOLETE     case Q_REGNUM: */
-/* OBSOLETE       return (131); */
-/* OBSOLETE     case ALU_REGNUM: */
-/* OBSOLETE       return (132); */
-/* OBSOLETE     case BP_REGNUM: */
-/* OBSOLETE       return (133); */
-/* OBSOLETE     case FC_REGNUM: */
-/* OBSOLETE       return (134); */
-/* OBSOLETE     case CR_REGNUM: */
-/* OBSOLETE       return (135); */
-/* OBSOLETE     case FPE_REGNUM: */
-/* OBSOLETE       return (160); */
-/* OBSOLETE     case INTE_REGNUM: */
-/* OBSOLETE       return (161); */
-/* OBSOLETE     case FPS_REGNUM: */
-/* OBSOLETE       return (162); */
-/* OBSOLETE     case EXO_REGNUM: */
-/* OBSOLETE       return (164); */
-/* OBSOLETE     default: */
-/* OBSOLETE       return (255);		/* Failure ? */ */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Initialize the target debugger (minimon only). */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE init_target_mm (ADDR32 tstart, ADDR32 tend, ADDR32 dstart, ADDR32 dend, */
-/* OBSOLETE 		ADDR32 entry, INT32 ms_size, INT32 rs_size, ADDR32 arg_start) */
-/* OBSOLETE { */
-/* OBSOLETE   out_msg_buf->init_msg.code = INIT; */
-/* OBSOLETE   out_msg_buf->init_msg.length = sizeof (struct init_msg_t) - 2 * sizeof (INT32); */
-/* OBSOLETE   out_msg_buf->init_msg.text_start = tstart; */
-/* OBSOLETE   out_msg_buf->init_msg.text_end = tend; */
-/* OBSOLETE   out_msg_buf->init_msg.data_start = dstart; */
-/* OBSOLETE   out_msg_buf->init_msg.data_end = dend; */
-/* OBSOLETE   out_msg_buf->init_msg.entry_point = entry; */
-/* OBSOLETE   out_msg_buf->init_msg.mem_stack_size = ms_size; */
-/* OBSOLETE   out_msg_buf->init_msg.reg_stack_size = rs_size; */
-/* OBSOLETE   out_msg_buf->init_msg.arg_start = arg_start; */
-/* OBSOLETE   msg_send_serial (out_msg_buf); */
-/* OBSOLETE   expect_msg (INIT_ACK, in_msg_buf, 1); */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Return a pointer to a string representing the given message code. */
-/* OBSOLETE  * Not all messages are represented here, only the ones that we expect */
-/* OBSOLETE  * to be called with. */
-/* OBSOLETE  */ */
-/* OBSOLETE static char * */
-/* OBSOLETE msg_str (INT32 code) */
-/* OBSOLETE { */
-/* OBSOLETE   static char cbuf[32]; */
-/* OBSOLETE  */
-/* OBSOLETE   switch (code) */
-/* OBSOLETE     { */
-/* OBSOLETE     case BKPT_SET_ACK: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "BKPT_SET_ACK", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case BKPT_RM_ACK: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "BKPT_RM_ACK", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case INIT_ACK: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "INIT_ACK", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case READ_ACK: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "READ_ACK", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case WRITE_ACK: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "WRITE_ACK", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case ERROR: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "ERROR", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     case HALT: */
-/* OBSOLETE       sprintf (cbuf, "%s (%d)", "HALT", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     default: */
-/* OBSOLETE       sprintf (cbuf, "UNKNOWN (%d)", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     } */
-/* OBSOLETE   return (cbuf); */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /* */
-/* OBSOLETE  * Selected (not all of them) error codes that we might get. */
-/* OBSOLETE  */ */
-/* OBSOLETE static char * */
-/* OBSOLETE error_msg_str (INT32 code) */
-/* OBSOLETE { */
-/* OBSOLETE   static char cbuf[50]; */
-/* OBSOLETE  */
-/* OBSOLETE   switch (code) */
-/* OBSOLETE     { */
-/* OBSOLETE     case EMFAIL: */
-/* OBSOLETE       return ("EMFAIL: unrecoverable error"); */
-/* OBSOLETE     case EMBADADDR: */
-/* OBSOLETE       return ("EMBADADDR: Illegal address"); */
-/* OBSOLETE     case EMBADREG: */
-/* OBSOLETE       return ("EMBADREG: Illegal register "); */
-/* OBSOLETE     case EMACCESS: */
-/* OBSOLETE       return ("EMACCESS: Could not access memory"); */
-/* OBSOLETE     case EMBADMSG: */
-/* OBSOLETE       return ("EMBADMSG: Unknown message type"); */
-/* OBSOLETE     case EMMSG2BIG: */
-/* OBSOLETE       return ("EMMSG2BIG: Message to large"); */
-/* OBSOLETE     case EMNOSEND: */
-/* OBSOLETE       return ("EMNOSEND: Could not send message"); */
-/* OBSOLETE     case EMNORECV: */
-/* OBSOLETE       return ("EMNORECV: Could not recv message"); */
-/* OBSOLETE     case EMRESET: */
-/* OBSOLETE       return ("EMRESET: Could not RESET target"); */
-/* OBSOLETE     case EMCONFIG: */
-/* OBSOLETE       return ("EMCONFIG: Could not get target CONFIG"); */
-/* OBSOLETE     case EMSTATUS: */
-/* OBSOLETE       return ("EMSTATUS: Could not get target STATUS"); */
-/* OBSOLETE     case EMREAD: */
-/* OBSOLETE       return ("EMREAD: Could not READ target memory"); */
-/* OBSOLETE     case EMWRITE: */
-/* OBSOLETE       return ("EMWRITE: Could not WRITE target memory"); */
-/* OBSOLETE     case EMBKPTSET: */
-/* OBSOLETE       return ("EMBKPTSET: Could not set breakpoint"); */
-/* OBSOLETE     case EMBKPTRM: */
-/* OBSOLETE       return ("EMBKPTRM: Could not remove breakpoint"); */
-/* OBSOLETE     case EMBKPTSTAT: */
-/* OBSOLETE       return ("EMBKPTSTAT: Could not get breakpoint status"); */
-/* OBSOLETE     case EMBKPTNONE: */
-/* OBSOLETE       return ("EMBKPTNONE: All breakpoints in use"); */
-/* OBSOLETE     case EMBKPTUSED: */
-/* OBSOLETE       return ("EMBKPTUSED: Breakpoints already in use"); */
-/* OBSOLETE     case EMINIT: */
-/* OBSOLETE       return ("EMINIT: Could not init target memory"); */
-/* OBSOLETE     case EMGO: */
-/* OBSOLETE       return ("EMGO: Could not start execution"); */
-/* OBSOLETE     case EMSTEP: */
-/* OBSOLETE       return ("EMSTEP: Could not single step"); */
-/* OBSOLETE     case EMBREAK: */
-/* OBSOLETE       return ("EMBREAK: Could not BREAK"); */
-/* OBSOLETE     case EMCOMMERR: */
-/* OBSOLETE       return ("EMCOMMERR: Communication error"); */
-/* OBSOLETE     default: */
-/* OBSOLETE       sprintf (cbuf, "error number %d", code); */
-/* OBSOLETE       break; */
-/* OBSOLETE     }				/* end switch */ */
-/* OBSOLETE  */
-/* OBSOLETE   return (cbuf); */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE  */
-/* OBSOLETE /* Receive a message, placing it in MSG_BUF, and expect it to be of */
-/* OBSOLETE    type MSGCODE.  If an error occurs, a non-zero FROM_TTY indicates */
-/* OBSOLETE    that the message should be printed. */
-/* OBSOLETE     */
-/* OBSOLETE    Return 0 for failure, 1 for success.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static int */
-/* OBSOLETE expect_msg (INT32 msgcode, union msg_t *msg_buf, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   int retries = 0; */
-/* OBSOLETE   while (msg_recv_serial (msg_buf) && (retries++ < MAX_RETRIES)); */
-/* OBSOLETE   if (retries >= MAX_RETRIES) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf ("Expected msg %s, ", msg_str (msgcode)); */
-/* OBSOLETE       printf ("no message received!\n"); */
-/* OBSOLETE       return (0);		/* Failure */ */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (msg_buf->generic_msg.code != msgcode) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (from_tty) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  printf ("Expected msg %s, ", msg_str (msgcode)); */
-/* OBSOLETE 	  printf ("got msg %s\n", msg_str (msg_buf->generic_msg.code)); */
-/* OBSOLETE 	  if (msg_buf->generic_msg.code == ERROR) */
-/* OBSOLETE 	    printf ("%s\n", error_msg_str (msg_buf->error_msg.error_code)); */
-/* OBSOLETE 	} */
-/* OBSOLETE       return (0);		/* Failure */ */
-/* OBSOLETE     } */
-/* OBSOLETE   return (1);			/* Success */ */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /* */
-/* OBSOLETE  * Determine the MiniMon memory space qualifier based on the addr.  */
-/* OBSOLETE  * FIXME: Can't distinguis I_ROM/D_ROM.   */
-/* OBSOLETE  * FIXME: Doesn't know anything about I_CACHE/D_CACHE. */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE mm_memory_space (CORE_ADDR *addr) */
-/* OBSOLETE { */
-/* OBSOLETE   ADDR32 tstart = target_config.I_mem_start; */
-/* OBSOLETE   ADDR32 tend = tstart + target_config.I_mem_size; */
-/* OBSOLETE   ADDR32 dstart = target_config.D_mem_start; */
-/* OBSOLETE   ADDR32 dend = tstart + target_config.D_mem_size; */
-/* OBSOLETE   ADDR32 rstart = target_config.ROM_start; */
-/* OBSOLETE   ADDR32 rend = tstart + target_config.ROM_size; */
-/* OBSOLETE  */
-/* OBSOLETE   if (((ADDR32) addr >= tstart) && ((ADDR32) addr < tend)) */
-/* OBSOLETE     { */
-/* OBSOLETE       return I_MEM; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (((ADDR32) addr >= dstart) && ((ADDR32) addr < dend)) */
-/* OBSOLETE     { */
-/* OBSOLETE       return D_MEM; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (((ADDR32) addr >= rstart) && ((ADDR32) addr < rend)) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* FIXME: how do we determine between D_ROM and I_ROM */ */
-/* OBSOLETE       return D_ROM; */
-/* OBSOLETE     } */
-/* OBSOLETE   else				/* FIXME: what do me do now? */ */
-/* OBSOLETE     return D_MEM;		/* Hmmm! */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /*  */
-/* OBSOLETE  *  Define the target subroutine names */
-/* OBSOLETE  */ */
-/* OBSOLETE struct target_ops mm_ops; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE init_mm_ops (void) */
-/* OBSOLETE { */
-/* OBSOLETE   mm_ops.to_shortname = "minimon"; */
-/* OBSOLETE   mm_ops.to_longname = "Remote AMD/Minimon target"; */
-/* OBSOLETE   mm_ops.to_doc = "Remote debug an AMD 290*0 using the MiniMon dbg core on the target"; */
-/* OBSOLETE   mm_ops.to_open = mm_open; */
-/* OBSOLETE   mm_ops.to_close = mm_close; */
-/* OBSOLETE   mm_ops.to_attach = mm_attach; */
-/* OBSOLETE   mm_ops.to_post_attach = NULL; */
-/* OBSOLETE   mm_ops.to_require_attach = NULL; */
-/* OBSOLETE   mm_ops.to_detach = mm_detach; */
-/* OBSOLETE   mm_ops.to_require_detach = NULL; */
-/* OBSOLETE   mm_ops.to_resume = mm_resume; */
-/* OBSOLETE   mm_ops.to_wait = mm_wait; */
-/* OBSOLETE   mm_ops.to_post_wait = NULL; */
-/* OBSOLETE   mm_ops.to_fetch_registers = mm_fetch_registers; */
-/* OBSOLETE   mm_ops.to_store_registers = mm_store_registers; */
-/* OBSOLETE   mm_ops.to_prepare_to_store = mm_prepare_to_store; */
-/* OBSOLETE   mm_ops.to_xfer_memory = mm_xfer_inferior_memory; */
-/* OBSOLETE   mm_ops.to_files_info = mm_files_info; */
-/* OBSOLETE   mm_ops.to_insert_breakpoint = mm_insert_breakpoint; */
-/* OBSOLETE   mm_ops.to_remove_breakpoint = mm_remove_breakpoint; */
-/* OBSOLETE   mm_ops.to_terminal_init = 0; */
-/* OBSOLETE   mm_ops.to_terminal_inferior = 0; */
-/* OBSOLETE   mm_ops.to_terminal_ours_for_output = 0; */
-/* OBSOLETE   mm_ops.to_terminal_ours = 0; */
-/* OBSOLETE   mm_ops.to_terminal_info = 0; */
-/* OBSOLETE   mm_ops.to_kill = mm_kill; */
-/* OBSOLETE   mm_ops.to_load = mm_load; */
-/* OBSOLETE   mm_ops.to_lookup_symbol = 0; */
-/* OBSOLETE   mm_ops.to_create_inferior = mm_create_inferior; */
-/* OBSOLETE   mm_ops.to_post_startup_inferior = NULL; */
-/* OBSOLETE   mm_ops.to_acknowledge_created_inferior = NULL; */
-/* OBSOLETE   mm_ops.to_clone_and_follow_inferior = NULL; */
-/* OBSOLETE   mm_ops.to_post_follow_inferior_by_clone = NULL; */
-/* OBSOLETE   mm_ops.to_insert_fork_catchpoint = NULL; */
-/* OBSOLETE   mm_ops.to_remove_fork_catchpoint = NULL; */
-/* OBSOLETE   mm_ops.to_insert_vfork_catchpoint = NULL; */
-/* OBSOLETE   mm_ops.to_remove_vfork_catchpoint = NULL; */
-/* OBSOLETE   mm_ops.to_has_forked = NULL; */
-/* OBSOLETE   mm_ops.to_has_vforked = NULL; */
-/* OBSOLETE   mm_ops.to_can_follow_vfork_prior_to_exec = NULL; */
-/* OBSOLETE   mm_ops.to_post_follow_vfork = NULL; */
-/* OBSOLETE   mm_ops.to_insert_exec_catchpoint = NULL; */
-/* OBSOLETE   mm_ops.to_remove_exec_catchpoint = NULL; */
-/* OBSOLETE   mm_ops.to_has_execd = NULL; */
-/* OBSOLETE   mm_ops.to_reported_exec_events_per_exec_call = NULL; */
-/* OBSOLETE   mm_ops.to_has_exited = NULL; */
-/* OBSOLETE   mm_ops.to_mourn_inferior = mm_mourn; */
-/* OBSOLETE   mm_ops.to_can_run = 0; */
-/* OBSOLETE   mm_ops.to_notice_signals = 0; */
-/* OBSOLETE   mm_ops.to_thread_alive = 0; */
-/* OBSOLETE   mm_ops.to_stop = 0; */
-/* OBSOLETE   mm_ops.to_pid_to_exec_file = NULL; */
-/* OBSOLETE   mm_ops.to_stratum = process_stratum; */
-/* OBSOLETE   mm_ops.DONT_USE = 0; */
-/* OBSOLETE   mm_ops.to_has_all_memory = 1; */
-/* OBSOLETE   mm_ops.to_has_memory = 1; */
-/* OBSOLETE   mm_ops.to_has_stack = 1; */
-/* OBSOLETE   mm_ops.to_has_registers = 1; */
-/* OBSOLETE   mm_ops.to_has_execution = 1; */
-/* OBSOLETE   mm_ops.to_sections = 0; */
-/* OBSOLETE   mm_ops.to_sections_end = 0; */
-/* OBSOLETE   mm_ops.to_magic = OPS_MAGIC; */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE _initialize_remote_mm (void) */
-/* OBSOLETE { */
-/* OBSOLETE   init_mm_ops (); */
-/* OBSOLETE   add_target (&mm_ops); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef NO_HIF_SUPPORT */
-/* OBSOLETE service_HIF (union msg_t *msg) */
-/* OBSOLETE { */
-/* OBSOLETE   return (0);			/* Emulate a failure */ */
-/* OBSOLETE } */
-/* OBSOLETE #endif */
diff --git a/gdb/remote-os9k.c b/gdb/remote-os9k.c
index 2cedfb0..0a703eb 100644
--- a/gdb/remote-os9k.c
+++ b/gdb/remote-os9k.c
@@ -101,7 +101,8 @@
   va_end (args);
 
   if (serial_write (monitor_desc, buf, strlen (buf)))
-    fprintf (stderr, "serial_write failed: %s\n", safe_strerror (errno));
+    fprintf_unfiltered (gdb_stderr, "serial_write failed: %s\n",
+			safe_strerror (errno));
 }
 
 /* Read a character from the remote system, doing all the fancy timeout stuff */
@@ -380,9 +381,9 @@
   if (log_file)
     {
       if (ferror (log_file))
-	fprintf (stderr, "Error writing log file.\n");
+	fprintf_unfiltered (gdb_stderr, "Error writing log file.\n");
       if (fclose (log_file) != 0)
-	fprintf (stderr, "Error closing log file.\n");
+	fprintf_unfiltered (gdb_stderr, "Error closing log file.\n");
       log_file = 0;
     }
 }
@@ -883,7 +884,7 @@
 	return 0;
       }
 
-  fprintf (stderr, "Too many breakpoints (> 16) for monitor\n");
+  fprintf_unfiltered (gdb_stderr, "Too many breakpoints (> 16) for monitor\n");
   return 1;
 }
 
@@ -908,7 +909,8 @@
 	return 0;
       }
 
-  fprintf (stderr, "Can't find breakpoint associated with 0x%x\n", addr);
+  fprintf_unfiltered (gdb_stderr,
+		      "Can't find breakpoint associated with 0x%x\n", addr);
   return 1;
 }
 
@@ -949,7 +951,9 @@
 
       if (serial_write (monitor_desc, buf, bytes_read))
 	{
-	  fprintf (stderr, "serial_write failed: (while downloading) %s\n", safe_strerror (errno));
+	  fprintf_unfiltered (gdb_stderr,
+			      "serial_write failed: (while downloading) %s\n",
+			      safe_strerror (errno));
 	  break;
 	}
       i = 0;
diff --git a/gdb/remote-rdi.c b/gdb/remote-rdi.c
index db51dcb..695a302 100644
--- a/gdb/remote-rdi.c
+++ b/gdb/remote-rdi.c
@@ -153,20 +153,20 @@
 }
 
 static void
-myprint (PTR arg, const char *format, va_list ap)
+myprint (void *arg, const char *format, va_list ap)
 {
   vfprintf_unfiltered (gdb_stdout, format, ap);
 }
 
 static void
-mywritec (PTR arg, int c)
+mywritec (void *arg, int c)
 {
   if (isascii (c))
     fputc_unfiltered (c, gdb_stdout);
 }
 
 static int
-mywrite (PTR arg, char const *buffer, int len)
+mywrite (void *arg, char const *buffer, int len)
 {
   int i;
   char *e;
@@ -185,7 +185,7 @@
 }
 
 static void
-mypause (PTR arg)
+mypause (void *arg)
 {
 }
 
@@ -193,13 +193,13 @@
    being interrupted more carefully */
 
 static int
-myreadc (PTR arg)
+myreadc (void *arg)
 {
   return fgetc (stdin);
 }
 
 static char *
-mygets (PTR arg, char *buffer, int len)
+mygets (void *arg, char *buffer, int len)
 {
   return fgets (buffer, len, stdin);
 }
@@ -265,7 +265,7 @@
   rslt = angel_RDI_open (10, &gdb_config, &gdb_hostif, NULL);
   if (rslt == RDIError_BigEndian || rslt == RDIError_LittleEndian)
     ;				/* do nothing, this is the expected return */
-  else if (rslt)
+  else if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
       Adp_CloseDevice ();
@@ -273,33 +273,33 @@
     }
 
   rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
   rslt = angel_RDI_info (RDIInfo_Points, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
   rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
   rslt = angel_RDI_info (RDIInfo_CoPro, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
   rslt = angel_RDI_info (RDIInfo_SemiHosting, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
 
   rslt = angel_RDI_info (RDIInfo_GetLoadSize, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
@@ -310,7 +310,7 @@
   target_fetch_registers (-1);
 
   rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
     }
@@ -318,14 +318,14 @@
   arg1 = rom_at_zero ? 0x0 : 0x13b;
 
   rslt = angel_RDI_info (RDIVector_Catch, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
 
   arg1 = (unsigned long) "";
   rslt = angel_RDI_info (RDISet_Cmdline, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
@@ -397,7 +397,7 @@
 			       top_of_memory);
 
 	      rslt = angel_RDI_info (RDIInfo_SetTopMem, &top_of_memory, &arg2);
-	      if (rslt)
+	      if (rslt != RDIError_NoError)
 		{
 		  printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
 		}
@@ -408,7 +408,7 @@
 
   arg1 = (unsigned long) arg_buf;
   rslt = angel_RDI_info (RDISet_Cmdline, /* &arg1 */ (unsigned long *) arg_buf, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
@@ -437,7 +437,7 @@
   if (!closed_already)
     {
       rslt = angel_RDI_close ();
-      if (rslt)
+      if (rslt != RDIError_NoError)
 	{
 	  printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt));
 	}
@@ -459,15 +459,13 @@
   if (0 /* turn on when hardware supports single-stepping */ )
     {
       rslt = angel_RDI_step (1, &point);
-      if (rslt)
-	{
-	  printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt));
-	}
+      if (rslt != RDIError_NoError)
+	printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt));
     }
   else
     {
       char handle[4];
-      CORE_ADDR pc;
+      CORE_ADDR pc = 0;
 
       if (step)
 	{
@@ -475,17 +473,13 @@
 	  pc = arm_get_next_pc (pc);
 	  arm_rdi_insert_breakpoint (pc, handle);
 	}
+
       execute_status = rslt = angel_RDI_execute (&point);
-      if (rslt == RDIError_BreakpointReached)
-	;
-      else if (rslt)
-	{
-	  printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt));
-	}
+      if (rslt != RDIError_NoError && rslt != RDIError_BreakpointReached)
+	printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt));
+
       if (step)
-	{
-	  arm_rdi_remove_breakpoint (pc, handle);
-	}
+	arm_rdi_remove_breakpoint (pc, handle);
     }
 }
 
@@ -541,7 +535,7 @@
   if (regno == -1)
     {
       rslt = angel_RDI_CPUread (255, 0x27fff, rawregs);
-      if (rslt)
+      if (rslt != RDIError_NoError)
 	{
 	  printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
 	}
@@ -571,7 +565,7 @@
 	rdi_regmask = 1 << regno;
 
       rslt = angel_RDI_CPUread (255, rdi_regmask, &rawreg);
-      if (rslt)
+      if (rslt != RDIError_NoError)
 	{
 	  printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
 	}
@@ -618,7 +612,7 @@
 	rdi_regmask = 1 << regno;
 
       rslt = angel_RDI_CPUwrite (255, rdi_regmask, rawerreg);
-      if (rslt)
+      if (rslt != RDIError_NoError)
 	{
 	  printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt));
 	}
@@ -641,7 +635,7 @@
   if (should_write)
     {
       rslt = angel_RDI_write (myaddr, memaddr, &len);
-      if (rslt)
+      if (rslt != RDIError_NoError)
 	{
 	  printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt));
 	}
@@ -649,7 +643,7 @@
   else
     {
       rslt = angel_RDI_read (memaddr, myaddr, &len);
-      if (rslt)
+      if (rslt != RDIError_NoError)
 	{
 	  printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt));
 	  len = 0;
@@ -668,7 +662,7 @@
   unsigned long arg1, arg2;
 
   rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
@@ -680,14 +674,14 @@
     printf_filtered ("Target is real hardware.\n");
 
   rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
   printf_filtered ("Target can%s single-step.\n", (arg1 & 0x4 ? "" : "not"));
 
   rslt = angel_RDI_info (RDIInfo_Icebreaker, &arg1, &arg2);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
     }
@@ -701,7 +695,7 @@
   int rslt;
 
   rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
     }
@@ -736,7 +730,7 @@
   if (arm_pc_is_thumb (addr) || arm_pc_is_thumb_dummy (addr))
     type |= RDIPoint_16Bit;
   rslt = angel_RDI_setbreak (addr, type, 0, &point);
-  if (rslt)
+  if (rslt != RDIError_NoError)
     {
       printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt));
     }
@@ -754,36 +748,27 @@
 {
   int rslt;
   PointHandle point;
-  struct local_bp_list_entry *entry, *preventry;
+  struct local_bp_list_entry **entryp, *dead;
 
-  for (entry = local_bp_list; entry != NULL; entry = entry->next)
+  for (entryp = &local_bp_list; *entryp != NULL; entryp = &(*entryp)->next)
+    if ((*entryp)->addr == addr)
+      break;
+
+  if (*entryp)
     {
-      if (entry->addr == addr)
-	{
-	  break;
-	}
-      preventry = entry;
-    }
-  if (entry)
-    {
-      rslt = angel_RDI_clearbreak (entry->point);
-      if (rslt)
-	{
-	  printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt));
-	}
+      dead = *entryp;
+      rslt = angel_RDI_clearbreak (dead->point);
+      if (rslt != RDIError_NoError)
+	printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt));
+
       /* Delete the breakpoint entry locally.  */
-      if (entry == local_bp_list)
-	{
-	  local_bp_list = entry->next;
-	}
-      else
-	{
-	  preventry->next = entry->next;
-	}
-      xfree (entry);
+      *entryp = dead->next;
+      xfree (dead);
     }
+
   return 0;
 }
+
 
 static char *
 rdi_error_message (int err)
@@ -1044,7 +1029,7 @@
 Without an argument, shows the current logfile name.\n\
 See also: rdilogenable\n",
 	   &maintenancelist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_cmd ("rdilogenable", class_maintenance,
 	   rdilogenable_command,
@@ -1057,22 +1042,20 @@
 	   &maintenancelist);
 
   add_show_from_set
-    (add_set_cmd ("rdiromatzero", no_class,
-		  var_boolean, (char *) &rom_at_zero,
-		  "Set target has ROM at addr 0.\n\
+    (add_set_boolean_cmd ("rdiromatzero", no_class, &rom_at_zero,
+			  "Set target has ROM at addr 0.\n\
 A true value disables vector catching, false enables vector catching.\n\
 This is evaluated at the time the 'target rdi' command is executed\n",
-		  &setlist),
+			  &setlist),
      &showlist);
 
   add_show_from_set
-    (add_set_cmd ("rdiheartbeat", no_class,
-		  var_boolean, (char *) &rdi_heartbeat,
-		  "Set enable for ADP heartbeat packets.\n\
+    (add_set_boolean_cmd ("rdiheartbeat", no_class, &rdi_heartbeat,
+			  "Set enable for ADP heartbeat packets.\n\
 I don't know why you would want this. If you enable them,\n\
 it will confuse ARM and EPI JTAG interface boxes as well\n\
 as the Angel Monitor.\n",
-		  &setlist),
+			  &setlist),
      &showlist);
 }
 
diff --git a/gdb/remote-rdp.c b/gdb/remote-rdp.c
index 2f9183a..f6ccf1e 100644
--- a/gdb/remote-rdp.c
+++ b/gdb/remote-rdp.c
@@ -1164,7 +1164,7 @@
   registers_changed ();
   stop_pc = read_pc ();
   set_current_frame (create_new_frame (read_fp (), stop_pc));
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
   print_stack_frame (selected_frame, -1, 1);
 }
 
diff --git a/gdb/remote-st.c b/gdb/remote-st.c
index 46d8eab..c27ddeb 100644
--- a/gdb/remote-st.c
+++ b/gdb/remote-st.c
@@ -79,7 +79,8 @@
   va_end (args);
 
   if (serial_write (st2000_desc, buf, strlen (buf)))
-    fprintf (stderr, "serial_write failed: %s\n", safe_strerror (errno));
+    fprintf_unfiltered (gdb_stderr, "serial_write failed: %s\n",
+			safe_strerror (errno));
 }
 
 /* Read a character from the remote system, doing all the fancy timeout
@@ -324,9 +325,9 @@
   if (log_file)
     {
       if (ferror (log_file))
-	fprintf (stderr, "Error writing log file.\n");
+	fprintf_unfiltered (gdb_stderr, "Error writing log file.\n");
       if (fclose (log_file) != 0)
-	fprintf (stderr, "Error closing log file.\n");
+	fprintf_unfiltered (gdb_stderr, "Error closing log file.\n");
     }
 #endif
 }
@@ -616,7 +617,7 @@
 	return 0;
       }
 
-  fprintf (stderr, "Too many breakpoints (> 16) for STDBUG\n");
+  fprintf_unfiltered (gdb_stderr, "Too many breakpoints (> 16) for STDBUG\n");
   return 1;
 }
 
@@ -635,7 +636,8 @@
 	return 0;
       }
 
-  fprintf (stderr, "Can't find breakpoint associated with 0x%x\n", addr);
+  fprintf_unfiltered (gdb_stderr,
+		      "Can't find breakpoint associated with 0x%x\n", addr);
   return 1;
 }
 
diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c
deleted file mode 100644
index f7863a8..0000000
--- a/gdb/remote-udi.c
+++ /dev/null
@@ -1,1722 +0,0 @@
-/* OBSOLETE /* Remote debugging interface for AMD 29k interfaced via UDI, for GDB. */
-/* OBSOLETE    Copyright 1990, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 */
-/* OBSOLETE    Free Software Foundation, Inc. */
-/* OBSOLETE    Written by Daniel Mann.  Contributed by AMD. */
-/* OBSOLETE  */
-/* OBSOLETE    This file is part of GDB. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is free software; you can redistribute it and/or modify */
-/* OBSOLETE    it under the terms of the GNU General Public License as published by */
-/* OBSOLETE    the Free Software Foundation; either version 2 of the License, or */
-/* OBSOLETE    (at your option) any later version. */
-/* OBSOLETE  */
-/* OBSOLETE    This program is distributed in the hope that it will be useful, */
-/* OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
-/* OBSOLETE    GNU General Public License for more details. */
-/* OBSOLETE  */
-/* OBSOLETE    You should have received a copy of the GNU General Public License */
-/* OBSOLETE    along with this program; if not, write to the Free Software */
-/* OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330, */
-/* OBSOLETE    Boston, MA 02111-1307, USA.  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* This is like remote.c but uses the Universal Debug Interface (UDI) to  */
-/* OBSOLETE    talk to the target hardware (or simulator).  UDI is a TCP/IP based */
-/* OBSOLETE    protocol; for hardware that doesn't run TCP, an interface adapter  */
-/* OBSOLETE    daemon talks UDI on one side, and talks to the hardware (typically */
-/* OBSOLETE    over a serial port) on the other side. */
-/* OBSOLETE  */
-/* OBSOLETE    - Originally written by Daniel Mann at AMD for MiniMON and gdb 3.91.6. */
-/* OBSOLETE    - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this */
-/* OBSOLETE    file to gdb 3.95.  I was unable to get this working on sun3os4 */
-/* OBSOLETE    with termio, only with sgtty. */
-/* OBSOLETE    - Daniel Mann at AMD took the 3.95 adaptions above and replaced */
-/* OBSOLETE    MiniMON interface with UDI-p interface.        */ */
-/* OBSOLETE  */
-/* OBSOLETE #include "defs.h" */
-/* OBSOLETE #include "frame.h" */
-/* OBSOLETE #include "inferior.h" */
-/* OBSOLETE #include "value.h" */
-/* OBSOLETE #include <ctype.h> */
-/* OBSOLETE #include <fcntl.h> */
-/* OBSOLETE #include <errno.h> */
-/* OBSOLETE #include "gdb_string.h" */
-/* OBSOLETE #include "terminal.h" */
-/* OBSOLETE #include "target.h" */
-/* OBSOLETE #include "29k-share/udi/udiproc.h" */
-/* OBSOLETE #include "gdbcmd.h" */
-/* OBSOLETE #include "bfd.h" */
-/* OBSOLETE #include "gdbcore.h"		/* For download function */ */
-/* OBSOLETE #include "regcache.h" */
-/* OBSOLETE  */
-/* OBSOLETE /* access the register store directly, without going through */
-/* OBSOLETE    the normal handler functions. This avoids an extra data copy.  */ */
-/* OBSOLETE  */
-/* OBSOLETE extern int stop_soon_quietly;	/* for wait_for_inferior */ */
-/* OBSOLETE extern struct value *call_function_by_hand (); */
-/* OBSOLETE static void udi_resume (ptid_t ptid, int step, enum target_signal sig); */
-/* OBSOLETE static void udi_fetch_registers (int regno); */
-/* OBSOLETE static void udi_load (char *args, int from_tty); */
-/* OBSOLETE static void fetch_register (int regno); */
-/* OBSOLETE static void udi_store_registers (int regno); */
-/* OBSOLETE static int store_register (int regno); */
-/* OBSOLETE static int regnum_to_srnum (int regno); */
-/* OBSOLETE static void udi_close (int quitting); */
-/* OBSOLETE static CPUSpace udi_memory_space (CORE_ADDR addr); */
-/* OBSOLETE static int udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, */
-/* OBSOLETE 				      int len); */
-/* OBSOLETE static int udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, */
-/* OBSOLETE 				     int len); */
-/* OBSOLETE static void download (char *load_arg_string, int from_tty); */
-/* OBSOLETE char CoffFileName[100] = ""; */
-/* OBSOLETE  */
-/* OBSOLETE #define FREEZE_MODE     (read_register(CPS_REGNUM) & 0x400) */
-/* OBSOLETE #define USE_SHADOW_PC	((processor_type == a29k_freeze_mode) && FREEZE_MODE) */
-/* OBSOLETE  */
-/* OBSOLETE static int timeout = 5; */
-/* OBSOLETE extern struct target_ops udi_ops;	/* Forward declaration */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Special register enumeration. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************************* UDI DATA*/ */
-/* OBSOLETE #define	MAXDATA		2*1024	/* max UDI[read/write] byte size */ */
-/* OBSOLETE /* Descriptor for I/O to remote machine.  Initialize it to -1 so that */
-/* OBSOLETE    udi_open knows that we don't have a file open when the program */
-/* OBSOLETE    starts.  */ */
-/* OBSOLETE  */
-/* OBSOLETE UDISessionId udi_session_id = -1; */
-/* OBSOLETE static char *udi_config_id; */
-/* OBSOLETE  */
-/* OBSOLETE CPUOffset IMemStart = 0; */
-/* OBSOLETE CPUSizeT IMemSize = 0; */
-/* OBSOLETE CPUOffset DMemStart = 0; */
-/* OBSOLETE CPUSizeT DMemSize = 0; */
-/* OBSOLETE CPUOffset RMemStart = 0; */
-/* OBSOLETE CPUSizeT RMemSize = 0; */
-/* OBSOLETE UDIUInt32 CPUPRL; */
-/* OBSOLETE UDIUInt32 CoProcPRL; */
-/* OBSOLETE  */
-/* OBSOLETE UDIMemoryRange address_ranges[2];	/* Text and data */ */
-/* OBSOLETE UDIResource entry = */
-/* OBSOLETE {0, 0};				/* Entry point */ */
-/* OBSOLETE CPUSizeT stack_sizes[2];	/* Regular and memory stacks */ */
-/* OBSOLETE  */
-/* OBSOLETE #define	SBUF_MAX	1024	/* maximum size of string handling buffer */ */
-/* OBSOLETE char sbuf[SBUF_MAX]; */
-/* OBSOLETE  */
-/* OBSOLETE typedef struct bkpt_entry_str */
-/* OBSOLETE   { */
-/* OBSOLETE     UDIResource Addr; */
-/* OBSOLETE     UDIUInt32 PassCount; */
-/* OBSOLETE     UDIBreakType Type; */
-/* OBSOLETE     unsigned int BreakId; */
-/* OBSOLETE   } */
-/* OBSOLETE bkpt_entry_t; */
-/* OBSOLETE #define		BKPT_TABLE_SIZE 40 */
-/* OBSOLETE static bkpt_entry_t bkpt_table[BKPT_TABLE_SIZE]; */
-/* OBSOLETE extern char dfe_errmsg[];	/* error string */ */
-/* OBSOLETE  */
-/* OBSOLETE /* malloc'd name of the program on the remote system.  */ */
-/* OBSOLETE static char *prog_name = NULL; */
-/* OBSOLETE  */
-/* OBSOLETE /* This is called not only when we first attach, but also when the */
-/* OBSOLETE    user types "run" after having attached.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_create_inferior (char *execfile, char *args, char **env) */
-/* OBSOLETE { */
-/* OBSOLETE   char *args1; */
-/* OBSOLETE  */
-/* OBSOLETE   if (execfile) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (prog_name != NULL) */
-/* OBSOLETE 	xfree (prog_name); */
-/* OBSOLETE       prog_name = savestring (execfile, strlen (execfile)); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (entry.Offset) */
-/* OBSOLETE     execfile = ""; */
-/* OBSOLETE   else */
-/* OBSOLETE     error ("No image loaded into target."); */
-/* OBSOLETE  */
-/* OBSOLETE   if (udi_session_id < 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* If the TIP is not open, open it.  */ */
-/* OBSOLETE       if (UDIConnect (udi_config_id, &udi_session_id)) */
-/* OBSOLETE 	error ("UDIConnect() failed: %s\n", dfe_errmsg); */
-/* OBSOLETE       /* We will need to download the program.  */ */
-/* OBSOLETE       entry.Offset = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   inferior_ptid = pid_to_ptid (40000); */
-/* OBSOLETE  */
-/* OBSOLETE   if (!entry.Offset) */
-/* OBSOLETE     download (execfile, 0); */
-/* OBSOLETE  */
-/* OBSOLETE   args1 = alloca (strlen (execfile) + strlen (args) + 2); */
-/* OBSOLETE  */
-/* OBSOLETE   if (execfile[0] == '\0') */
-/* OBSOLETE  */
-/* OBSOLETE     /* It is empty.  We need to quote it somehow, or else the target */
-/* OBSOLETE        will think there is no argument being passed here.  According */
-/* OBSOLETE        to the UDI spec it is quoted "according to TIP OS rules" which */
-/* OBSOLETE        I guess means quoting it like the Unix shell should work */
-/* OBSOLETE        (sounds pretty bogus to me...).  In fact it doesn't work (with */
-/* OBSOLETE        isstip anyway), but passing in two quotes as the argument seems */
-/* OBSOLETE        like a reasonable enough behavior anyway (I guess).  */ */
-/* OBSOLETE  */
-/* OBSOLETE     strcpy (args1, "''"); */
-/* OBSOLETE   else */
-/* OBSOLETE     strcpy (args1, execfile); */
-/* OBSOLETE   strcat (args1, " "); */
-/* OBSOLETE   strcat (args1, args); */
-/* OBSOLETE  */
-/* OBSOLETE   UDIInitializeProcess (address_ranges,		/* ProcessMemory[] */ */
-/* OBSOLETE 			(UDIInt) 2,	/* NumberOfRanges */ */
-/* OBSOLETE 			entry,	/* EntryPoint */ */
-/* OBSOLETE 			stack_sizes,	/* *StackSizes */ */
-/* OBSOLETE 			(UDIInt) 2,	/* NumberOfStacks */ */
-/* OBSOLETE 			args1);	/* ArgString */ */
-/* OBSOLETE  */
-/* OBSOLETE   init_wait_for_inferior (); */
-/* OBSOLETE   clear_proceed_status (); */
-/* OBSOLETE   proceed (-1, TARGET_SIGNAL_DEFAULT, 0); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_mourn (void) */
-/* OBSOLETE { */
-/* OBSOLETE #if 0 */
-/* OBSOLETE   /* Requiring "target udi" each time you run is a major pain.  I suspect */
-/* OBSOLETE      this was just blindy copied from remote.c, in which "target" and */
-/* OBSOLETE      "run" are combined.  Having a udi target without an inferior seems */
-/* OBSOLETE      to work between "target udi" and "run", so why not now?  */ */
-/* OBSOLETE   pop_target ();		/* Pop back to no-child state */ */
-/* OBSOLETE #endif */
-/* OBSOLETE   /* But if we're going to want to run it again, we better remove the */
-/* OBSOLETE      breakpoints...  */ */
-/* OBSOLETE   remove_breakpoints (); */
-/* OBSOLETE   generic_mourn_inferior (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************************** UDI_OPEN */
-/* OBSOLETE ** Open a connection to remote TIP. */
-/* OBSOLETE    NAME is the socket domain used for communication with the TIP, */
-/* OBSOLETE    then a space and the socket name or TIP-host name. */
-/* OBSOLETE    '<udi_udi_config_id>' for example. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE /* XXX - need cleanups for udiconnect for various failures!!! */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_open (char *name, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   unsigned int prl; */
-/* OBSOLETE   char *p; */
-/* OBSOLETE   int cnt; */
-/* OBSOLETE   UDIMemoryRange KnownMemory[10]; */
-/* OBSOLETE   UDIUInt32 ChipVersions[10]; */
-/* OBSOLETE   UDIInt NumberOfRanges = 10; */
-/* OBSOLETE   UDIInt NumberOfChips = 10; */
-/* OBSOLETE   UDIPId PId; */
-/* OBSOLETE   UDIUInt32 TIPId, TargetId, DFEId, DFE, TIP, DFEIPCId, TIPIPCId; */
-/* OBSOLETE  */
-/* OBSOLETE   target_preopen (from_tty); */
-/* OBSOLETE  */
-/* OBSOLETE   entry.Offset = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) */
-/* OBSOLETE     bkpt_table[cnt].Type = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (udi_config_id) */
-/* OBSOLETE     xfree (udi_config_id); */
-/* OBSOLETE  */
-/* OBSOLETE   if (!name) */
-/* OBSOLETE     error ("Usage: target udi config_id, where config_id appears in udi_soc file"); */
-/* OBSOLETE  */
-/* OBSOLETE   udi_config_id = xstrdup (strtok (name, " \t")); */
-/* OBSOLETE  */
-/* OBSOLETE   if (UDIConnect (udi_config_id, &udi_session_id)) */
-/* OBSOLETE     /* FIXME: Should set udi_session_id to -1 here.  */ */
-/* OBSOLETE     error ("UDIConnect() failed: %s\n", dfe_errmsg); */
-/* OBSOLETE  */
-/* OBSOLETE   push_target (&udi_ops); */
-/* OBSOLETE  */
-/* OBSOLETE   /* */
-/* OBSOLETE      ** Initialize target configuration structure (global) */
-/* OBSOLETE    */ */
-/* OBSOLETE   if (UDIGetTargetConfig (KnownMemory, &NumberOfRanges, */
-/* OBSOLETE 			  ChipVersions, &NumberOfChips)) */
-/* OBSOLETE     error ("UDIGetTargetConfig() failed"); */
-/* OBSOLETE   if (NumberOfChips > 2) */
-/* OBSOLETE     fprintf_unfiltered (gdb_stderr, "Target has more than one processor\n"); */
-/* OBSOLETE   for (cnt = 0; cnt < NumberOfRanges; cnt++) */
-/* OBSOLETE     { */
-/* OBSOLETE       switch (KnownMemory[cnt].Space) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	default: */
-/* OBSOLETE 	  fprintf_unfiltered (gdb_stderr, "UDIGetTargetConfig() unknown memory space\n"); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case UDI29KCP_S: */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case UDI29KIROMSpace: */
-/* OBSOLETE 	  RMemStart = KnownMemory[cnt].Offset; */
-/* OBSOLETE 	  RMemSize = KnownMemory[cnt].Size; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case UDI29KIRAMSpace: */
-/* OBSOLETE 	  IMemStart = KnownMemory[cnt].Offset; */
-/* OBSOLETE 	  IMemSize = KnownMemory[cnt].Size; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case UDI29KDRAMSpace: */
-/* OBSOLETE 	  DMemStart = KnownMemory[cnt].Offset; */
-/* OBSOLETE 	  DMemSize = KnownMemory[cnt].Size; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   a29k_get_processor_type (); */
-/* OBSOLETE  */
-/* OBSOLETE   if (UDICreateProcess (&PId)) */
-/* OBSOLETE     fprintf_unfiltered (gdb_stderr, "UDICreateProcess() failed\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Print out some stuff, letting the user now what's going on */ */
-/* OBSOLETE   if (UDICapabilities (&TIPId, &TargetId, DFEId, DFE, &TIP, &DFEIPCId, */
-/* OBSOLETE 		       &TIPIPCId, sbuf)) */
-/* OBSOLETE     error ("UDICapabilities() failed"); */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     { */
-/* OBSOLETE       printf_filtered ("Connected via UDI socket,\n\ */
-/* OBSOLETE  DFE-IPC version %x.%x.%x  TIP-IPC version %x.%x.%x  TIP version %x.%x.%x\n %s\n", */
-/* OBSOLETE 	       (DFEIPCId >> 8) & 0xf, (DFEIPCId >> 4) & 0xf, DFEIPCId & 0xf, */
-/* OBSOLETE 	       (TIPIPCId >> 8) & 0xf, (TIPIPCId >> 4) & 0xf, TIPIPCId & 0xf, */
-/* OBSOLETE 	       (TargetId >> 8) & 0xf, (TargetId >> 4) & 0xf, TargetId & 0xf, */
-/* OBSOLETE 		       sbuf); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************************* UDI_CLOSE */
-/* OBSOLETE    Close the open connection to the TIP process. */
-/* OBSOLETE    Use this when you want to detach and do something else */
-/* OBSOLETE    with your gdb.  */ */
-/* OBSOLETE static void */
-/* OBSOLETE udi_close (			/*FIXME: how is quitting used */ */
-/* OBSOLETE 	    int quitting) */
-/* OBSOLETE { */
-/* OBSOLETE   if (udi_session_id < 0) */
-/* OBSOLETE     return; */
-/* OBSOLETE  */
-/* OBSOLETE   /* We should never get here if there isn't something valid in */
-/* OBSOLETE      udi_session_id.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   if (UDIDisconnect (udi_session_id, UDITerminateSession)) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (quitting) */
-/* OBSOLETE 	warning ("UDIDisconnect() failed in udi_close"); */
-/* OBSOLETE       else */
-/* OBSOLETE 	error ("UDIDisconnect() failed in udi_close"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Do not try to close udi_session_id again, later in the program.  */ */
-/* OBSOLETE   udi_session_id = -1; */
-/* OBSOLETE   inferior_ptid = null_ptid; */
-/* OBSOLETE  */
-/* OBSOLETE   printf_filtered ("  Ending remote debugging\n"); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /**************************************************************** UDI_ATACH */ */
-/* OBSOLETE /* Attach to a program that is already loaded and running  */
-/* OBSOLETE  * Upon exiting the process's execution is stopped. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE udi_attach (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIResource From; */
-/* OBSOLETE   UDIInt32 PC_adds; */
-/* OBSOLETE   UDICount Count = 1; */
-/* OBSOLETE   UDISizeT Size = 4; */
-/* OBSOLETE   UDICount CountDone; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE  */
-/* OBSOLETE   if (args == NULL) */
-/* OBSOLETE     error_no_arg ("program to attach"); */
-/* OBSOLETE  */
-/* OBSOLETE   if (udi_session_id < 0) */
-/* OBSOLETE     error ("UDI connection not opened yet, use the 'target udi' command.\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf_unfiltered ("Attaching to remote program %s...\n", prog_name); */
-/* OBSOLETE  */
-/* OBSOLETE   UDIStop (); */
-/* OBSOLETE   From.Space = UDI29KSpecialRegs; */
-/* OBSOLETE   From.Offset = 11; */
-/* OBSOLETE   if (err = UDIRead (From, &PC_adds, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead failed in udi_attach"); */
-/* OBSOLETE   printf_unfiltered ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds); */
-/* OBSOLETE } */
-/* OBSOLETE /************************************************************* UDI_DETACH */ */
-/* OBSOLETE /* Terminate the open connection to the TIP process. */
-/* OBSOLETE    Use this when you want to detach and do something else */
-/* OBSOLETE    with your gdb.  Leave remote process running (with no breakpoints set). */ */
-/* OBSOLETE static void */
-/* OBSOLETE udi_detach (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   remove_breakpoints ();	/* Just in case there were any left in */ */
-/* OBSOLETE  */
-/* OBSOLETE   if (UDIDisconnect (udi_session_id, UDIContinueSession)) */
-/* OBSOLETE     error ("UDIDisconnect() failed in udi_detach"); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Don't try to UDIDisconnect it again in udi_close, which is called from */
-/* OBSOLETE      pop_target.  */ */
-/* OBSOLETE   udi_session_id = -1; */
-/* OBSOLETE   inferior_ptid = null_ptid; */
-/* OBSOLETE  */
-/* OBSOLETE   pop_target (); */
-/* OBSOLETE  */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf_unfiltered ("Detaching from TIP\n"); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /****************************************************************** UDI_RESUME */
-/* OBSOLETE ** Tell the remote machine to resume.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_resume (ptid_t ptid, int step, enum target_signal sig) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIError tip_error; */
-/* OBSOLETE   UDIUInt32 Steps = 1; */
-/* OBSOLETE   UDIStepType StepType = UDIStepNatural; */
-/* OBSOLETE   UDIRange Range; */
-/* OBSOLETE  */
-/* OBSOLETE   if (step)			/* step 1 instruction */ */
-/* OBSOLETE     { */
-/* OBSOLETE       tip_error = UDIStep (Steps, StepType, Range); */
-/* OBSOLETE       if (!tip_error) */
-/* OBSOLETE 	return; */
-/* OBSOLETE  */
-/* OBSOLETE       fprintf_unfiltered (gdb_stderr, "UDIStep() error = %d\n", tip_error); */
-/* OBSOLETE       error ("failed in udi_resume"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (UDIExecute ()) */
-/* OBSOLETE     error ("UDIExecute() failed in udi_resume"); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /******************************************************************** UDI_WAIT */
-/* OBSOLETE ** Wait until the remote machine stops, then return, */
-/* OBSOLETE    storing status in STATUS just as `wait' would.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static ptid_t */
-/* OBSOLETE udi_wait (ptid_t ptid, struct target_waitstatus *status) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIInt32 MaxTime; */
-/* OBSOLETE   UDIPId PId; */
-/* OBSOLETE   UDIInt32 StopReason; */
-/* OBSOLETE   UDISizeT CountDone; */
-/* OBSOLETE   int old_timeout = timeout; */
-/* OBSOLETE   int old_immediate_quit = immediate_quit; */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE   status->value.integer = 0; */
-/* OBSOLETE  */
-/* OBSOLETE /* wait for message to arrive. It should be: */
-/* OBSOLETE    If the target stops executing, udi_wait() should return. */
-/* OBSOLETE  */ */
-/* OBSOLETE   timeout = 0;			/* Wait indefinetly for a message */ */
-/* OBSOLETE   immediate_quit = 1;		/* Helps ability to QUIT */ */
-/* OBSOLETE  */
-/* OBSOLETE   while (1) */
-/* OBSOLETE     { */
-/* OBSOLETE       i = 0; */
-/* OBSOLETE       MaxTime = UDIWaitForever; */
-/* OBSOLETE       UDIWait (MaxTime, &PId, &StopReason); */
-/* OBSOLETE       QUIT;			/* Let user quit if they want */ */
-/* OBSOLETE  */
-/* OBSOLETE       switch (StopReason & UDIGrossState) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	case UDIStdoutReady: */
-/* OBSOLETE 	  if (UDIGetStdout (sbuf, (UDISizeT) SBUF_MAX, &CountDone)) */
-/* OBSOLETE 	    /* This is said to happen if the program tries to output */
-/* OBSOLETE 	       a whole bunch of output (more than SBUF_MAX, I would */
-/* OBSOLETE 	       guess).  It doesn't seem to happen with the simulator.  */ */
-/* OBSOLETE 	    warning ("UDIGetStdout() failed in udi_wait"); */
-/* OBSOLETE 	  fwrite (sbuf, 1, CountDone, stdout); */
-/* OBSOLETE 	  gdb_flush (gdb_stdout); */
-/* OBSOLETE 	  continue; */
-/* OBSOLETE  */
-/* OBSOLETE 	case UDIStderrReady: */
-/* OBSOLETE 	  UDIGetStderr (sbuf, (UDISizeT) SBUF_MAX, &CountDone); */
-/* OBSOLETE 	  fwrite (sbuf, 1, CountDone, stderr); */
-/* OBSOLETE 	  gdb_flush (gdb_stderr); */
-/* OBSOLETE 	  continue; */
-/* OBSOLETE  */
-/* OBSOLETE 	case UDIStdinNeeded: */
-/* OBSOLETE 	  { */
-/* OBSOLETE 	    int ch; */
-/* OBSOLETE 	    i = 0; */
-/* OBSOLETE 	    do */
-/* OBSOLETE 	      { */
-/* OBSOLETE 		ch = getchar (); */
-/* OBSOLETE 		if (ch == EOF) */
-/* OBSOLETE 		  break; */
-/* OBSOLETE 		sbuf[i++] = ch; */
-/* OBSOLETE 	      } */
-/* OBSOLETE 	    while (i < SBUF_MAX && ch != '\n'); */
-/* OBSOLETE 	    UDIPutStdin (sbuf, (UDISizeT) i, &CountDone); */
-/* OBSOLETE 	    continue; */
-/* OBSOLETE 	  } */
-/* OBSOLETE  */
-/* OBSOLETE 	case UDIRunning: */
-/* OBSOLETE 	  /* In spite of the fact that we told UDIWait to wait forever, it will */
-/* OBSOLETE 	     return spuriously sometimes.  */ */
-/* OBSOLETE 	case UDIStdinModeX: */
-/* OBSOLETE 	  continue; */
-/* OBSOLETE 	default: */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE       break; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   switch (StopReason & UDIGrossState) */
-/* OBSOLETE     { */
-/* OBSOLETE     case UDITrapped: */
-/* OBSOLETE       printf_unfiltered ("Am290*0 received vector number %d\n", StopReason >> 24); */
-/* OBSOLETE  */
-/* OBSOLETE       switch ((StopReason >> 8) & 0xff) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	case 0:		/* Illegal opcode */ */
-/* OBSOLETE 	  printf_unfiltered ("	(break point)\n"); */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 1:		/* Unaligned Access */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_BUS; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 3: */
-/* OBSOLETE 	case 4: */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_FPE; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 5:		/* Protection Violation */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  /* Why not SEGV?  What is a Protection Violation?  */ */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_ILL; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 6: */
-/* OBSOLETE 	case 7: */
-/* OBSOLETE 	case 8:		/* User Instruction Mapping Miss */ */
-/* OBSOLETE 	case 9:		/* User Data Mapping Miss */ */
-/* OBSOLETE 	case 10:		/* Supervisor Instruction Mapping Miss */ */
-/* OBSOLETE 	case 11:		/* Supervisor Data Mapping Miss */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_SEGV; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 12: */
-/* OBSOLETE 	case 13: */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_ILL; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 14:		/* Timer */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_ALRM; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 15:		/* Trace */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 16:		/* INTR0 */ */
-/* OBSOLETE 	case 17:		/* INTR1 */ */
-/* OBSOLETE 	case 18:		/* INTR2 */ */
-/* OBSOLETE 	case 19:		/* INTR3/Internal */ */
-/* OBSOLETE 	case 20:		/* TRAP0 */ */
-/* OBSOLETE 	case 21:		/* TRAP1 */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_INT; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 22:		/* Floating-Point Exception */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  /* Why not FPE?  */ */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_ILL; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	case 77:		/* assert 77 */ */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE 	  status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	default: */
-/* OBSOLETE 	  status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE 	  status->value.integer = 0; */
-/* OBSOLETE 	} */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDINotExecuting: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TERM; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDIStopped: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TSTP; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDIWarned: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_URG; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDIStepped: */
-/* OBSOLETE     case UDIBreak: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_TRAP; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDIWaiting: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_STOP; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDIHalted: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_STOPPED; */
-/* OBSOLETE       status->value.sig = TARGET_SIGNAL_KILL; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case UDIExited: */
-/* OBSOLETE     default: */
-/* OBSOLETE       status->kind = TARGET_WAITKIND_EXITED; */
-/* OBSOLETE       status->value.integer = 0; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   timeout = old_timeout;	/* Restore original timeout value */ */
-/* OBSOLETE   immediate_quit = old_immediate_quit; */
-/* OBSOLETE   return inferior_ptid; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE #if 0 */
-/* OBSOLETE /* Handy for debugging */ */
-/* OBSOLETE udi_pc (void) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIResource From; */
-/* OBSOLETE   UDIUInt32 *To; */
-/* OBSOLETE   UDICount Count; */
-/* OBSOLETE   UDISizeT Size = 4; */
-/* OBSOLETE   UDICount CountDone; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE   int pc[2]; */
-/* OBSOLETE   unsigned long myregs[256]; */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KPC; */
-/* OBSOLETE   From.Offset = 0; */
-/* OBSOLETE   To = (UDIUInt32 *) pc; */
-/* OBSOLETE   Count = 2; */
-/* OBSOLETE  */
-/* OBSOLETE   err = UDIRead (From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE  */
-/* OBSOLETE   printf_unfiltered ("err = %d, CountDone = %d, pc[0] = 0x%x, pc[1] = 0x%x\n", */
-/* OBSOLETE 		     err, CountDone, pc[0], pc[1]); */
-/* OBSOLETE  */
-/* OBSOLETE   udi_fetch_registers (-1); */
-/* OBSOLETE  */
-/* OBSOLETE   printf_unfiltered ("other pc1 = 0x%x, pc0 = 0x%x\n", *(int *) &registers[4 * PC_REGNUM], */
-/* OBSOLETE 		     *(int *) &registers[4 * NPC_REGNUM]); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Now, read all the registers globally */ */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   From.Offset = 0; */
-/* OBSOLETE   err = UDIRead (From, myregs, 256, 4, &CountDone, HostEndian); */
-/* OBSOLETE  */
-/* OBSOLETE   printf ("err = %d, CountDone = %d\n", err, CountDone); */
-/* OBSOLETE  */
-/* OBSOLETE   printf ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = 0; i < 256; i += 2) */
-/* OBSOLETE     printf ("%d:\t%#10x\t%11d\t%#10x\t%11d\n", i, myregs[i], myregs[i], */
-/* OBSOLETE 	    myregs[i + 1], myregs[i + 1]); */
-/* OBSOLETE   printf ("\n"); */
-/* OBSOLETE  */
-/* OBSOLETE   return pc[0]; */
-/* OBSOLETE } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************** UDI_FETCH_REGISTERS */
-/* OBSOLETE  * Read a remote register 'regno'.  */
-/* OBSOLETE  * If regno==-1 then read all the registers. */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE udi_fetch_registers (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIResource From; */
-/* OBSOLETE   UDIUInt32 *To; */
-/* OBSOLETE   UDICount Count; */
-/* OBSOLETE   UDISizeT Size = 4; */
-/* OBSOLETE   UDICount CountDone; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE   int i; */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno >= 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       fetch_register (regno); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Gr1/rsp */ */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   From.Offset = 1; */
-/* OBSOLETE   To = (UDIUInt32 *) & registers[4 * GR1_REGNUM]; */
-/* OBSOLETE   Count = 1; */
-/* OBSOLETE   if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   register_valid[GR1_REGNUM] = 1; */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(GR64_REGNUM)	/* Read gr64-127 */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Global Registers gr64-gr95 */ */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   From.Offset = 64; */
-/* OBSOLETE   To = (UDIUInt32 *) & registers[4 * GR64_REGNUM]; */
-/* OBSOLETE   Count = 32; */
-/* OBSOLETE   if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++) */
-/* OBSOLETE     register_valid[i] = 1; */
-/* OBSOLETE  */
-/* OBSOLETE #endif /*  GR64_REGNUM */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Global Registers gr96-gr127 */ */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   From.Offset = 96; */
-/* OBSOLETE   To = (UDIUInt32 *) & registers[4 * GR96_REGNUM]; */
-/* OBSOLETE   Count = 32; */
-/* OBSOLETE   if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++) */
-/* OBSOLETE     register_valid[i] = 1; */
-/* OBSOLETE  */
-/* OBSOLETE /* Local Registers */ */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KLocalRegs; */
-/* OBSOLETE   From.Offset = 0; */
-/* OBSOLETE   To = (UDIUInt32 *) & registers[4 * LR0_REGNUM]; */
-/* OBSOLETE   Count = 128; */
-/* OBSOLETE   if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++) */
-/* OBSOLETE     register_valid[i] = 1; */
-/* OBSOLETE  */
-/* OBSOLETE /* Protected Special Registers */ */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = UDI29KSpecialRegs; */
-/* OBSOLETE   From.Offset = 0; */
-/* OBSOLETE   To = (UDIUInt32 *) & registers[4 * SR_REGNUM (0)]; */
-/* OBSOLETE   Count = 15; */
-/* OBSOLETE   if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   for (i = SR_REGNUM (0); i < SR_REGNUM (0) + 15; i++) */
-/* OBSOLETE     register_valid[i] = 1; */
-/* OBSOLETE  */
-/* OBSOLETE   if (USE_SHADOW_PC) */
-/* OBSOLETE     {				/* Let regno_to_srnum() handle the register number */ */
-/* OBSOLETE       fetch_register (NPC_REGNUM); */
-/* OBSOLETE       fetch_register (PC_REGNUM); */
-/* OBSOLETE       fetch_register (PC2_REGNUM); */
-/* OBSOLETE  */
-/* OBSOLETE /* Unprotected Special Registers sr128-sr135 */ */
-/* OBSOLETE  */
-/* OBSOLETE       From.Space = UDI29KSpecialRegs; */
-/* OBSOLETE       From.Offset = 128; */
-/* OBSOLETE       To = (UDIUInt32 *) & registers[4 * SR_REGNUM (128)]; */
-/* OBSOLETE       Count = 135 - 128 + 1; */
-/* OBSOLETE       if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE 	error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE       for (i = SR_REGNUM (128); i < SR_REGNUM (128) + 135 - 128 + 1; i++) */
-/* OBSOLETE 	register_valid[i] = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (remote_debug) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf_unfiltered (gdb_stdlog, "Fetching all registers\n"); */
-/* OBSOLETE       fprintf_unfiltered (gdb_stdlog, */
-/* OBSOLETE 			  "Fetching PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n", */
-/* OBSOLETE 			  read_register (NPC_REGNUM), */
-/* OBSOLETE 			  read_register (PC_REGNUM), */
-/* OBSOLETE 			  read_register (PC2_REGNUM)); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* There doesn't seem to be any way to get these.  */ */
-/* OBSOLETE   { */
-/* OBSOLETE     int val = -1; */
-/* OBSOLETE     supply_register (FPE_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (INTE_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (FPS_REGNUM, (char *) &val); */
-/* OBSOLETE     supply_register (EXO_REGNUM, (char *) &val); */
-/* OBSOLETE   } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************* UDI_STORE_REGISTERS */
-/* OBSOLETE ** Store register regno into the target.   */
-/* OBSOLETE  * If regno==-1 then store all the registers. */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_store_registers (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIUInt32 *From; */
-/* OBSOLETE   UDIResource To; */
-/* OBSOLETE   UDICount Count; */
-/* OBSOLETE   UDISizeT Size = 4; */
-/* OBSOLETE   UDICount CountDone; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno >= 0) */
-/* OBSOLETE     { */
-/* OBSOLETE       store_register (regno); */
-/* OBSOLETE       return; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (remote_debug) */
-/* OBSOLETE     { */
-/* OBSOLETE       fprintf_unfiltered (gdb_stdlog, "Storing all registers\n"); */
-/* OBSOLETE       fprintf_unfiltered (gdb_stdlog, */
-/* OBSOLETE 			  "PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n", */
-/* OBSOLETE 			  read_register (NPC_REGNUM), */
-/* OBSOLETE 			  read_register (PC_REGNUM), */
-/* OBSOLETE 			  read_register (PC2_REGNUM)); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE /* Gr1/rsp */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * GR1_REGNUM]; */
-/* OBSOLETE   To.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   To.Offset = 1; */
-/* OBSOLETE   Count = 1; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE /* Global registers gr64-gr95 */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * GR64_REGNUM]; */
-/* OBSOLETE   To.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   To.Offset = 64; */
-/* OBSOLETE   Count = 32; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE #endif /* GR64_REGNUM */ */
-/* OBSOLETE  */
-/* OBSOLETE /* Global registers gr96-gr127 */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * GR96_REGNUM]; */
-/* OBSOLETE   To.Space = UDI29KGlobalRegs; */
-/* OBSOLETE   To.Offset = 96; */
-/* OBSOLETE   Count = 32; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE /* Local Registers */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * LR0_REGNUM]; */
-/* OBSOLETE   To.Space = UDI29KLocalRegs; */
-/* OBSOLETE   To.Offset = 0; */
-/* OBSOLETE   Count = 128; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE   /* Protected Special Registers *//* VAB through TMR */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * SR_REGNUM (0)]; */
-/* OBSOLETE   To.Space = UDI29KSpecialRegs; */
-/* OBSOLETE   To.Offset = 0; */
-/* OBSOLETE   Count = 10; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE /* PC0, PC1, PC2 possibly as shadow registers */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * SR_REGNUM (10)]; */
-/* OBSOLETE   To.Space = UDI29KSpecialRegs; */
-/* OBSOLETE   Count = 3; */
-/* OBSOLETE   if (USE_SHADOW_PC) */
-/* OBSOLETE     To.Offset = 20;		/* SPC0 */ */
-/* OBSOLETE   else */
-/* OBSOLETE     To.Offset = 10;		/* PC0 */ */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE /* PC1 via UDI29KPC */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * PC_REGNUM]; */
-/* OBSOLETE   To.Space = UDI29KPC; */
-/* OBSOLETE   To.Offset = 0;		/* PC1 */ */
-/* OBSOLETE   Count = 1; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE   /* LRU and MMU */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * SR_REGNUM (13)]; */
-/* OBSOLETE   To.Space = UDI29KSpecialRegs; */
-/* OBSOLETE   To.Offset = 13; */
-/* OBSOLETE   Count = 2; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE /* Unprotected Special Registers */ */
-/* OBSOLETE  */
-/* OBSOLETE   From = (UDIUInt32 *) & registers[4 * SR_REGNUM (128)]; */
-/* OBSOLETE   To.Space = UDI29KSpecialRegs; */
-/* OBSOLETE   To.Offset = 128; */
-/* OBSOLETE   Count = 135 - 128 + 1; */
-/* OBSOLETE   if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIWrite() failed in udi_store_regisetrs"); */
-/* OBSOLETE  */
-/* OBSOLETE   registers_changed (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /****************************************************** UDI_PREPARE_TO_STORE */ */
-/* OBSOLETE /* Get ready to modify the registers array.  On machines which store */
-/* OBSOLETE    individual registers, this doesn't need to do anything.  On machines */
-/* OBSOLETE    which store all the registers in one fell swoop, this makes sure */
-/* OBSOLETE    that registers contains all the registers from the program being */
-/* OBSOLETE    debugged.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_prepare_to_store (void) */
-/* OBSOLETE { */
-/* OBSOLETE   /* Do nothing, since we can store individual regs */ */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************** TRANSLATE_ADDR */ */
-/* OBSOLETE static CORE_ADDR */
-/* OBSOLETE translate_addr (CORE_ADDR addr) */
-/* OBSOLETE { */
-/* OBSOLETE #if defined(ULTRA3) && defined(KERNEL_DEBUGGING) */
-/* OBSOLETE   /* Check for a virtual address in the kernel */ */
-/* OBSOLETE   /* Assume physical address of ublock is in  paddr_u register */ */
-/* OBSOLETE   /* FIXME: doesn't work for user virtual addresses */ */
-/* OBSOLETE   if (addr >= UVADDR) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* PADDR_U register holds the physical address of the ublock */ */
-/* OBSOLETE       CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM); */
-/* OBSOLETE       return (i + addr - (CORE_ADDR) UVADDR); */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       return (addr); */
-/* OBSOLETE     } */
-/* OBSOLETE #else */
-/* OBSOLETE   return (addr); */
-/* OBSOLETE #endif */
-/* OBSOLETE } */
-/* OBSOLETE /************************************************* UDI_XFER_INFERIOR_MEMORY */ */
-/* OBSOLETE /* FIXME!  Merge these two.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE udi_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, */
-/* OBSOLETE 			  struct mem_attrib *attrib ATTRIBUTE_UNUSED, */
-/* OBSOLETE 			  struct target_ops *target ATTRIBUTE_UNUSED) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE   memaddr = translate_addr (memaddr); */
-/* OBSOLETE  */
-/* OBSOLETE   if (write) */
-/* OBSOLETE     return udi_write_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE   else */
-/* OBSOLETE     return udi_read_inferior_memory (memaddr, myaddr, len); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************** UDI_FILES_INFO */ */
-/* OBSOLETE static void */
-/* OBSOLETE udi_files_info (struct target_ops *target) */
-/* OBSOLETE { */
-/* OBSOLETE   printf_unfiltered ("\tAttached to UDI socket to %s", udi_config_id); */
-/* OBSOLETE   if (prog_name != NULL) */
-/* OBSOLETE     printf_unfiltered ("and running program %s", prog_name); */
-/* OBSOLETE   printf_unfiltered (".\n"); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /**************************************************** UDI_INSERT_BREAKPOINT */ */
-/* OBSOLETE static int */
-/* OBSOLETE udi_insert_breakpoint (CORE_ADDR addr, char *contents_cache) */
-/* OBSOLETE { */
-/* OBSOLETE   int cnt; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE  */
-/* OBSOLETE   for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) */
-/* OBSOLETE     if (bkpt_table[cnt].Type == 0)	/* Find first free slot */ */
-/* OBSOLETE       break; */
-/* OBSOLETE  */
-/* OBSOLETE   if (cnt >= BKPT_TABLE_SIZE) */
-/* OBSOLETE     error ("Too many breakpoints set"); */
-/* OBSOLETE  */
-/* OBSOLETE   bkpt_table[cnt].Addr.Offset = addr; */
-/* OBSOLETE   bkpt_table[cnt].Addr.Space = UDI29KIRAMSpace; */
-/* OBSOLETE   bkpt_table[cnt].PassCount = 1; */
-/* OBSOLETE   bkpt_table[cnt].Type = UDIBreakFlagExecute; */
-/* OBSOLETE  */
-/* OBSOLETE   err = UDISetBreakpoint (bkpt_table[cnt].Addr, */
-/* OBSOLETE 			  bkpt_table[cnt].PassCount, */
-/* OBSOLETE 			  bkpt_table[cnt].Type, */
-/* OBSOLETE 			  &bkpt_table[cnt].BreakId); */
-/* OBSOLETE  */
-/* OBSOLETE   if (err == 0) */
-/* OBSOLETE     return 0;			/* Success */ */
-/* OBSOLETE  */
-/* OBSOLETE   bkpt_table[cnt].Type = 0; */
-/* OBSOLETE   error ("UDISetBreakpoint returned error code %d\n", err); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /**************************************************** UDI_REMOVE_BREAKPOINT */ */
-/* OBSOLETE static int */
-/* OBSOLETE udi_remove_breakpoint (CORE_ADDR addr, char *contents_cache) */
-/* OBSOLETE { */
-/* OBSOLETE   int cnt; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE  */
-/* OBSOLETE   for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++) */
-/* OBSOLETE     if (bkpt_table[cnt].Addr.Offset == addr)	/* Find matching breakpoint */ */
-/* OBSOLETE       break; */
-/* OBSOLETE  */
-/* OBSOLETE   if (cnt >= BKPT_TABLE_SIZE) */
-/* OBSOLETE     error ("Can't find breakpoint in table"); */
-/* OBSOLETE  */
-/* OBSOLETE   bkpt_table[cnt].Type = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   err = UDIClearBreakpoint (bkpt_table[cnt].BreakId); */
-/* OBSOLETE   if (err == 0) */
-/* OBSOLETE     return 0;			/* Success */ */
-/* OBSOLETE  */
-/* OBSOLETE   error ("UDIClearBreakpoint returned error code %d\n", err); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_kill (void) */
-/* OBSOLETE { */
-/* OBSOLETE  */
-/* OBSOLETE #if 0 */
-/* OBSOLETE /* */
-/* OBSOLETE    UDIStop does not really work as advertised.  It causes the TIP to close it's */
-/* OBSOLETE    connection, which usually results in GDB dying with a SIGPIPE.  For now, we */
-/* OBSOLETE    just invoke udi_close, which seems to get things right. */
-/* OBSOLETE  */ */
-/* OBSOLETE   UDIStop (); */
-/* OBSOLETE  */
-/* OBSOLETE   udi_session_id = -1; */
-/* OBSOLETE   inferior_ptid = null_ptid; */
-/* OBSOLETE  */
-/* OBSOLETE   if (from_tty) */
-/* OBSOLETE     printf_unfiltered ("Target has been stopped."); */
-/* OBSOLETE #endif /* 0 */ */
-/* OBSOLETE #if 0 */
-/* OBSOLETE   udi_close (0); */
-/* OBSOLETE   pop_target (); */
-/* OBSOLETE #endif /* 0 */ */
-/* OBSOLETE  */
-/* OBSOLETE   /* Keep the target around, e.g. so "run" can do the right thing when */
-/* OBSOLETE      we are already debugging something.  */ */
-/* OBSOLETE  */
-/* OBSOLETE   if (UDIDisconnect (udi_session_id, UDITerminateSession)) */
-/* OBSOLETE     { */
-/* OBSOLETE       warning ("UDIDisconnect() failed"); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   /* Do not try to close udi_session_id again, later in the program.  */ */
-/* OBSOLETE   udi_session_id = -1; */
-/* OBSOLETE   inferior_ptid = null_ptid; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /*  */
-/* OBSOLETE    Load a program into the target.  Args are: `program {options}'.  The options */
-/* OBSOLETE    are used to control loading of the program, and are NOT passed onto the */
-/* OBSOLETE    loaded code as arguments.  (You need to use the `run' command to do that.) */
-/* OBSOLETE  */
-/* OBSOLETE    The options are: */
-/* OBSOLETE    -ms %d       Set mem stack size to %d */
-/* OBSOLETE    -rs %d       Set regular stack size to %d */
-/* OBSOLETE    -i   send init info (default) */
-/* OBSOLETE    -noi don't send init info */
-/* OBSOLETE    -[tT]        Load Text section */
-/* OBSOLETE    -[dD]        Load Data section */
-/* OBSOLETE    -[bB]        Load BSS section */
-/* OBSOLETE    -[lL]        Load Lit section */
-/* OBSOLETE  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE download (char *load_arg_string, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE #define DEFAULT_MEM_STACK_SIZE 		0x6000 */
-/* OBSOLETE #define DEFAULT_REG_STACK_SIZE 		0x2000 */
-/* OBSOLETE  */
-/* OBSOLETE   char *token; */
-/* OBSOLETE   char *filename; */
-/* OBSOLETE   asection *section; */
-/* OBSOLETE   bfd *pbfd; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE   int load_text = 1, load_data = 1, load_bss = 1, load_lit = 1; */
-/* OBSOLETE  */
-/* OBSOLETE   address_ranges[0].Space = UDI29KIRAMSpace; */
-/* OBSOLETE   address_ranges[0].Offset = 0xffffffff; */
-/* OBSOLETE   address_ranges[0].Size = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   address_ranges[1].Space = UDI29KDRAMSpace; */
-/* OBSOLETE   address_ranges[1].Offset = 0xffffffff; */
-/* OBSOLETE   address_ranges[1].Size = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   stack_sizes[0] = DEFAULT_REG_STACK_SIZE; */
-/* OBSOLETE   stack_sizes[1] = DEFAULT_MEM_STACK_SIZE; */
-/* OBSOLETE  */
-/* OBSOLETE   dont_repeat (); */
-/* OBSOLETE  */
-/* OBSOLETE   filename = strtok (load_arg_string, " \t"); */
-/* OBSOLETE   if (!filename) */
-/* OBSOLETE     error ("Must specify at least a file name with the load command"); */
-/* OBSOLETE  */
-/* OBSOLETE   filename = tilde_expand (filename); */
-/* OBSOLETE   make_cleanup (xfree, filename); */
-/* OBSOLETE  */
-/* OBSOLETE   while (token = strtok (NULL, " \t")) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (token[0] == '-') */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  token++; */
-/* OBSOLETE  */
-/* OBSOLETE 	  if (STREQ (token, "ms")) */
-/* OBSOLETE 	    stack_sizes[1] = atol (strtok (NULL, " \t")); */
-/* OBSOLETE 	  else if (STREQ (token, "rs")) */
-/* OBSOLETE 	    stack_sizes[0] = atol (strtok (NULL, " \t")); */
-/* OBSOLETE 	  else */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      load_text = load_data = load_bss = load_lit = 0; */
-/* OBSOLETE  */
-/* OBSOLETE 	      while (*token) */
-/* OBSOLETE 		{ */
-/* OBSOLETE 		  switch (*token++) */
-/* OBSOLETE 		    { */
-/* OBSOLETE 		    case 't': */
-/* OBSOLETE 		    case 'T': */
-/* OBSOLETE 		      load_text = 1; */
-/* OBSOLETE 		      break; */
-/* OBSOLETE 		    case 'd': */
-/* OBSOLETE 		    case 'D': */
-/* OBSOLETE 		      load_data = 1; */
-/* OBSOLETE 		      break; */
-/* OBSOLETE 		    case 'b': */
-/* OBSOLETE 		    case 'B': */
-/* OBSOLETE 		      load_bss = 1; */
-/* OBSOLETE 		      break; */
-/* OBSOLETE 		    case 'l': */
-/* OBSOLETE 		    case 'L': */
-/* OBSOLETE 		      load_lit = 1; */
-/* OBSOLETE 		      break; */
-/* OBSOLETE 		    default: */
-/* OBSOLETE 		      error ("Unknown UDI load option -%s", token - 1); */
-/* OBSOLETE 		    } */
-/* OBSOLETE 		} */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   pbfd = bfd_openr (filename, gnutarget); */
-/* OBSOLETE  */
-/* OBSOLETE   if (!pbfd) */
-/* OBSOLETE     /* FIXME: should be using bfd_errmsg, not assuming it was */
-/* OBSOLETE        bfd_error_system_call.  */ */
-/* OBSOLETE     perror_with_name (filename); */
-/* OBSOLETE  */
-/* OBSOLETE   /* FIXME: should be checking for errors from bfd_close (for one thing, */
-/* OBSOLETE      on error it does not free all the storage associated with the */
-/* OBSOLETE      bfd).  */ */
-/* OBSOLETE   make_cleanup_bfd_close (pbfd); */
-/* OBSOLETE  */
-/* OBSOLETE   QUIT; */
-/* OBSOLETE   immediate_quit++; */
-/* OBSOLETE  */
-/* OBSOLETE   if (!bfd_check_format (pbfd, bfd_object)) */
-/* OBSOLETE     error ("It doesn't seem to be an object file"); */
-/* OBSOLETE  */
-/* OBSOLETE   for (section = pbfd->sections; section; section = section->next) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (bfd_get_section_flags (pbfd, section) & SEC_ALLOC) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  UDIResource To; */
-/* OBSOLETE 	  UDICount Count; */
-/* OBSOLETE 	  unsigned long section_size, section_end; */
-/* OBSOLETE 	  const char *section_name; */
-/* OBSOLETE  */
-/* OBSOLETE 	  section_name = bfd_get_section_name (pbfd, section); */
-/* OBSOLETE 	  if (STREQ (section_name, ".text") && !load_text) */
-/* OBSOLETE 	    continue; */
-/* OBSOLETE 	  else if (STREQ (section_name, ".data") && !load_data) */
-/* OBSOLETE 	    continue; */
-/* OBSOLETE 	  else if (STREQ (section_name, ".bss") && !load_bss) */
-/* OBSOLETE 	    continue; */
-/* OBSOLETE 	  else if (STREQ (section_name, ".lit") && !load_lit) */
-/* OBSOLETE 	    continue; */
-/* OBSOLETE  */
-/* OBSOLETE 	  To.Offset = bfd_get_section_vma (pbfd, section); */
-/* OBSOLETE 	  section_size = bfd_section_size (pbfd, section); */
-/* OBSOLETE 	  section_end = To.Offset + section_size; */
-/* OBSOLETE  */
-/* OBSOLETE 	  if (section_size == 0) */
-/* OBSOLETE 	    /* This is needed at least in the BSS case, where the code */
-/* OBSOLETE 	       below starts writing before it even checks the size.  */ */
-/* OBSOLETE 	    continue; */
-/* OBSOLETE  */
-/* OBSOLETE 	  printf_unfiltered ("[Loading section %s at %x (%d bytes)]\n", */
-/* OBSOLETE 			     section_name, */
-/* OBSOLETE 			     To.Offset, */
-/* OBSOLETE 			     section_size); */
-/* OBSOLETE  */
-/* OBSOLETE 	  if (bfd_get_section_flags (pbfd, section) & SEC_CODE) */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      To.Space = UDI29KIRAMSpace; */
-/* OBSOLETE  */
-/* OBSOLETE 	      address_ranges[0].Offset = min (address_ranges[0].Offset, */
-/* OBSOLETE 					      To.Offset); */
-/* OBSOLETE 	      address_ranges[0].Size = max (address_ranges[0].Size, */
-/* OBSOLETE 					    section_end */
-/* OBSOLETE 					    - address_ranges[0].Offset); */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  else */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      To.Space = UDI29KDRAMSpace; */
-/* OBSOLETE  */
-/* OBSOLETE 	      address_ranges[1].Offset = min (address_ranges[1].Offset, */
-/* OBSOLETE 					      To.Offset); */
-/* OBSOLETE 	      address_ranges[1].Size = max (address_ranges[1].Size, */
-/* OBSOLETE 					    section_end */
-/* OBSOLETE 					    - address_ranges[1].Offset); */
-/* OBSOLETE 	    } */
-/* OBSOLETE  */
-/* OBSOLETE 	  if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)		/* Text, data or lit */ */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      file_ptr fptr; */
-/* OBSOLETE  */
-/* OBSOLETE 	      fptr = 0; */
-/* OBSOLETE  */
-/* OBSOLETE 	      while (section_size > 0) */
-/* OBSOLETE 		{ */
-/* OBSOLETE 		  char buffer[1024]; */
-/* OBSOLETE  */
-/* OBSOLETE 		  Count = min (section_size, 1024); */
-/* OBSOLETE  */
-/* OBSOLETE 		  bfd_get_section_contents (pbfd, section, buffer, fptr, */
-/* OBSOLETE 					    Count); */
-/* OBSOLETE  */
-/* OBSOLETE 		  err = UDIWrite ((UDIHostMemPtr) buffer,	/* From */ */
-/* OBSOLETE 				  To,	/* To */ */
-/* OBSOLETE 				  Count,	/* Count */ */
-/* OBSOLETE 				  (UDISizeT) 1,		/* Size */ */
-/* OBSOLETE 				  &Count,	/* CountDone */ */
-/* OBSOLETE 				  (UDIBool) 0);		/* HostEndian */ */
-/* OBSOLETE 		  if (err) */
-/* OBSOLETE 		    error ("UDIWrite failed, error = %d", err); */
-/* OBSOLETE  */
-/* OBSOLETE 		  To.Offset += Count; */
-/* OBSOLETE 		  fptr += Count; */
-/* OBSOLETE 		  section_size -= Count; */
-/* OBSOLETE 		} */
-/* OBSOLETE 	    } */
-/* OBSOLETE 	  else */
-/* OBSOLETE 	    /* BSS */ */
-/* OBSOLETE 	    { */
-/* OBSOLETE 	      UDIResource From; */
-/* OBSOLETE 	      unsigned long zero = 0; */
-/* OBSOLETE  */
-/* OBSOLETE 	      /* Write a zero byte at the vma */ */
-/* OBSOLETE 	      /* FIXME: Broken for sections of 1-3 bytes (we test for */
-/* OBSOLETE 	         zero above).  */ */
-/* OBSOLETE 	      err = UDIWrite ((UDIHostMemPtr) & zero,	/* From */ */
-/* OBSOLETE 			      To,	/* To */ */
-/* OBSOLETE 			      (UDICount) 1,	/* Count */ */
-/* OBSOLETE 			      (UDISizeT) 4,	/* Size */ */
-/* OBSOLETE 			      &Count,	/* CountDone */ */
-/* OBSOLETE 			      (UDIBool) 0);	/* HostEndian */ */
-/* OBSOLETE 	      if (err) */
-/* OBSOLETE 		error ("UDIWrite failed, error = %d", err); */
-/* OBSOLETE  */
-/* OBSOLETE 	      From = To; */
-/* OBSOLETE 	      To.Offset += 4; */
-/* OBSOLETE  */
-/* OBSOLETE 	      /* Now, duplicate it for the length of the BSS */ */
-/* OBSOLETE 	      err = UDICopy (From,	/* From */ */
-/* OBSOLETE 			     To,	/* To */ */
-/* OBSOLETE 			     (UDICount) (section_size / 4 - 1),		/* Count */ */
-/* OBSOLETE 			     (UDISizeT) 4,	/* Size */ */
-/* OBSOLETE 			     &Count,	/* CountDone */ */
-/* OBSOLETE 			     (UDIBool) 1);	/* Direction */ */
-/* OBSOLETE 	      if (err) */
-/* OBSOLETE 		{ */
-/* OBSOLETE 		  char message[100]; */
-/* OBSOLETE 		  int xerr; */
-/* OBSOLETE  */
-/* OBSOLETE 		  xerr = UDIGetErrorMsg (err, 100, message, &Count); */
-/* OBSOLETE 		  if (!xerr) */
-/* OBSOLETE 		    fprintf_unfiltered (gdb_stderr, "Error is %s\n", message); */
-/* OBSOLETE 		  else */
-/* OBSOLETE 		    fprintf_unfiltered (gdb_stderr, "xerr is %d\n", xerr); */
-/* OBSOLETE 		  error ("UDICopy failed, error = %d", err); */
-/* OBSOLETE 		} */
-/* OBSOLETE 	    } */
-/* OBSOLETE  */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   entry.Space = UDI29KIRAMSpace; */
-/* OBSOLETE   entry.Offset = bfd_get_start_address (pbfd); */
-/* OBSOLETE  */
-/* OBSOLETE   immediate_quit--; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /* Function to download an image into the remote target.  */ */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE udi_load (char *args, int from_tty) */
-/* OBSOLETE { */
-/* OBSOLETE   download (args, from_tty); */
-/* OBSOLETE  */
-/* OBSOLETE   /* As a convenience, pick up any symbol info that is in the program */
-/* OBSOLETE      being loaded.  Note that we assume that the program is the``mainline''; */
-/* OBSOLETE      if this is not always true, then this code will need to be augmented.  */ */
-/* OBSOLETE   symbol_file_add (strtok (args, " \t"), from_tty, NULL, 1, 0); */
-/* OBSOLETE  */
-/* OBSOLETE   /* Getting new symbols may change our opinion about what is */
-/* OBSOLETE      frameless.  */ */
-/* OBSOLETE   reinit_frame_cache (); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /*************************************************** UDI_WRITE_INFERIOR_MEMORY */
-/* OBSOLETE ** Copy LEN bytes of data from debugger memory at MYADDR */
-/* OBSOLETE    to inferior's memory at MEMADDR.  Returns number of bytes written.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE udi_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int nwritten = 0; */
-/* OBSOLETE   UDIUInt32 *From; */
-/* OBSOLETE   UDIResource To; */
-/* OBSOLETE   UDICount Count; */
-/* OBSOLETE   UDISizeT Size = 1; */
-/* OBSOLETE   UDICount CountDone = 0; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   To.Space = udi_memory_space (memaddr); */
-/* OBSOLETE   From = (UDIUInt32 *) myaddr; */
-/* OBSOLETE  */
-/* OBSOLETE   while (nwritten < len) */
-/* OBSOLETE     { */
-/* OBSOLETE       Count = len - nwritten; */
-/* OBSOLETE       if (Count > MAXDATA) */
-/* OBSOLETE 	Count = MAXDATA; */
-/* OBSOLETE       To.Offset = memaddr + nwritten; */
-/* OBSOLETE       if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  error ("UDIWrite() failed in udi_write_inferior_memory"); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  nwritten += CountDone; */
-/* OBSOLETE 	  From += CountDone; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   return (nwritten); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /**************************************************** UDI_READ_INFERIOR_MEMORY */
-/* OBSOLETE ** Read LEN bytes from inferior memory at MEMADDR.  Put the result */
-/* OBSOLETE    at debugger address MYADDR.  Returns number of bytes read.  */ */
-/* OBSOLETE static int */
-/* OBSOLETE udi_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len) */
-/* OBSOLETE { */
-/* OBSOLETE   int nread = 0; */
-/* OBSOLETE   UDIResource From; */
-/* OBSOLETE   UDIUInt32 *To; */
-/* OBSOLETE   UDICount Count; */
-/* OBSOLETE   UDISizeT Size = 1; */
-/* OBSOLETE   UDICount CountDone = 0; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE  */
-/* OBSOLETE   From.Space = udi_memory_space (memaddr); */
-/* OBSOLETE   To = (UDIUInt32 *) myaddr; */
-/* OBSOLETE  */
-/* OBSOLETE   while (nread < len) */
-/* OBSOLETE     { */
-/* OBSOLETE       Count = len - nread; */
-/* OBSOLETE       if (Count > MAXDATA) */
-/* OBSOLETE 	Count = MAXDATA; */
-/* OBSOLETE       From.Offset = memaddr + nread; */
-/* OBSOLETE       if (err = UDIRead (From, To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  error ("UDIRead() failed in udi_read_inferior_memory"); */
-/* OBSOLETE 	  break; */
-/* OBSOLETE 	} */
-/* OBSOLETE       else */
-/* OBSOLETE 	{ */
-/* OBSOLETE 	  nread += CountDone; */
-/* OBSOLETE 	  To += CountDone; */
-/* OBSOLETE 	} */
-/* OBSOLETE     } */
-/* OBSOLETE   return (nread); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE /********************************************************************* WARNING */
-/* OBSOLETE */ */
-/* OBSOLETE udi_warning (int num) */
-/* OBSOLETE { */
-/* OBSOLETE   error ("ERROR while loading program into remote TIP: $d\n", num); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE  */
-/* OBSOLETE /*****************************************************************************/ */
-/* OBSOLETE /* Fetch a single register indicatated by 'regno'.  */
-/* OBSOLETE  * Returns 0/-1 on success/failure.   */
-/* OBSOLETE  */ */
-/* OBSOLETE static void */
-/* OBSOLETE fetch_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIResource From; */
-/* OBSOLETE   UDIUInt32 To; */
-/* OBSOLETE   UDICount Count = 1; */
-/* OBSOLETE   UDISizeT Size = 4; */
-/* OBSOLETE   UDICount CountDone; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE   UDIError err; */
-/* OBSOLETE   int result; */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno == GR1_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE       From.Offset = 1; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE       From.Offset = (regno - GR96_REGNUM) + 96;; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE  */
-/* OBSOLETE   else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       From.Space = UDI29KGlobalRegs; */
-/* OBSOLETE       From.Offset = (regno - GR64_REGNUM) + 64; */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE #endif /* GR64_REGNUM */ */
-/* OBSOLETE  */
-/* OBSOLETE   else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
-/* OBSOLETE     { */
-/* OBSOLETE       From.Space = UDI29KLocalRegs; */
-/* OBSOLETE       From.Offset = (regno - LR0_REGNUM); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       int val = -1; */
-/* OBSOLETE       /*supply_register(160 + (regno - FPE_REGNUM),(char *) &val); */ */
-/* OBSOLETE       supply_register (regno, (char *) &val); */
-/* OBSOLETE       return;			/* Pretend Success */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     { */
-/* OBSOLETE       From.Space = UDI29KSpecialRegs; */
-/* OBSOLETE       From.Offset = regnum_to_srnum (regno); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (err = UDIRead (From, &To, Count, Size, &CountDone, HostEndian)) */
-/* OBSOLETE     error ("UDIRead() failed in udi_fetch_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   supply_register (regno, (char *) &To); */
-/* OBSOLETE  */
-/* OBSOLETE   if (remote_debug) */
-/* OBSOLETE     fprintf_unfiltered (gdb_stdlog, "Fetching register %s = 0x%x\n", */
-/* OBSOLETE 			REGISTER_NAME (regno), To); */
-/* OBSOLETE } */
-/* OBSOLETE /*****************************************************************************/ */
-/* OBSOLETE /* Store a single register indicated by 'regno'.  */
-/* OBSOLETE  * Returns 0/-1 on success/failure.   */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE store_register (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   int result; */
-/* OBSOLETE   UDIUInt32 From; */
-/* OBSOLETE   UDIResource To; */
-/* OBSOLETE   UDICount Count = 1; */
-/* OBSOLETE   UDISizeT Size = 4; */
-/* OBSOLETE   UDICount CountDone; */
-/* OBSOLETE   UDIBool HostEndian = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   From = read_register (regno);	/* get data value */ */
-/* OBSOLETE  */
-/* OBSOLETE   if (remote_debug) */
-/* OBSOLETE     fprintf_unfiltered (gdb_stdlog, "Storing register %s = 0x%x\n", */
-/* OBSOLETE 			REGISTER_NAME (regno), From); */
-/* OBSOLETE  */
-/* OBSOLETE   if (regno == GR1_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       To.Space = UDI29KGlobalRegs; */
-/* OBSOLETE       To.Offset = 1; */
-/* OBSOLETE       result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE       /* Setting GR1 changes the numbers of all the locals, so invalidate the  */
-/* OBSOLETE        * register cache.  Do this *after* calling read_register, because we want  */
-/* OBSOLETE        * read_register to return the value that write_register has just stuffed  */
-/* OBSOLETE        * into the registers array, not the value of the register fetched from  */
-/* OBSOLETE        * the inferior.   */
-/* OBSOLETE        */ */
-/* OBSOLETE       registers_changed (); */
-/* OBSOLETE     } */
-/* OBSOLETE #if defined(GR64_REGNUM) */
-/* OBSOLETE   else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       To.Space = UDI29KGlobalRegs; */
-/* OBSOLETE       To.Offset = (regno - GR64_REGNUM) + 64; */
-/* OBSOLETE       result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif /* GR64_REGNUM */ */
-/* OBSOLETE   else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) */
-/* OBSOLETE     { */
-/* OBSOLETE       To.Space = UDI29KGlobalRegs; */
-/* OBSOLETE       To.Offset = (regno - GR96_REGNUM) + 96; */
-/* OBSOLETE       result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) */
-/* OBSOLETE     { */
-/* OBSOLETE       To.Space = UDI29KLocalRegs; */
-/* OBSOLETE       To.Offset = (regno - LR0_REGNUM); */
-/* OBSOLETE       result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM) */
-/* OBSOLETE     return 0;			/* Pretend Success */ */
-/* OBSOLETE   else if (regno == PC_REGNUM) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* PC1 via UDI29KPC */ */
-/* OBSOLETE  */
-/* OBSOLETE       To.Space = UDI29KPC; */
-/* OBSOLETE       To.Offset = 0;		/* PC1 */ */
-/* OBSOLETE       result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE  */
-/* OBSOLETE       /* Writing to this loc actually changes the values of pc0 & pc1 */ */
-/* OBSOLETE  */
-/* OBSOLETE       register_valid[PC_REGNUM] = 0;	/* pc1 */ */
-/* OBSOLETE       register_valid[NPC_REGNUM] = 0;	/* pc0 */ */
-/* OBSOLETE     } */
-/* OBSOLETE   else */
-/* OBSOLETE     /* An unprotected or protected special register */ */
-/* OBSOLETE     { */
-/* OBSOLETE       To.Space = UDI29KSpecialRegs; */
-/* OBSOLETE       To.Offset = regnum_to_srnum (regno); */
-/* OBSOLETE       result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian); */
-/* OBSOLETE     } */
-/* OBSOLETE  */
-/* OBSOLETE   if (result != 0) */
-/* OBSOLETE     error ("UDIWrite() failed in store_registers"); */
-/* OBSOLETE  */
-/* OBSOLETE   return 0; */
-/* OBSOLETE } */
-/* OBSOLETE /********************************************************** REGNUM_TO_SRNUM */ */
-/* OBSOLETE /*  */
-/* OBSOLETE  * Convert a gdb special register number to a 29000 special register number. */
-/* OBSOLETE  */ */
-/* OBSOLETE static int */
-/* OBSOLETE regnum_to_srnum (int regno) */
-/* OBSOLETE { */
-/* OBSOLETE   switch (regno) */
-/* OBSOLETE     { */
-/* OBSOLETE     case VAB_REGNUM: */
-/* OBSOLETE       return (0); */
-/* OBSOLETE     case OPS_REGNUM: */
-/* OBSOLETE       return (1); */
-/* OBSOLETE     case CPS_REGNUM: */
-/* OBSOLETE       return (2); */
-/* OBSOLETE     case CFG_REGNUM: */
-/* OBSOLETE       return (3); */
-/* OBSOLETE     case CHA_REGNUM: */
-/* OBSOLETE       return (4); */
-/* OBSOLETE     case CHD_REGNUM: */
-/* OBSOLETE       return (5); */
-/* OBSOLETE     case CHC_REGNUM: */
-/* OBSOLETE       return (6); */
-/* OBSOLETE     case RBP_REGNUM: */
-/* OBSOLETE       return (7); */
-/* OBSOLETE     case TMC_REGNUM: */
-/* OBSOLETE       return (8); */
-/* OBSOLETE     case TMR_REGNUM: */
-/* OBSOLETE       return (9); */
-/* OBSOLETE     case NPC_REGNUM: */
-/* OBSOLETE       return (USE_SHADOW_PC ? (20) : (10)); */
-/* OBSOLETE     case PC_REGNUM: */
-/* OBSOLETE       return (USE_SHADOW_PC ? (21) : (11)); */
-/* OBSOLETE     case PC2_REGNUM: */
-/* OBSOLETE       return (USE_SHADOW_PC ? (22) : (12)); */
-/* OBSOLETE     case MMU_REGNUM: */
-/* OBSOLETE       return (13); */
-/* OBSOLETE     case LRU_REGNUM: */
-/* OBSOLETE       return (14); */
-/* OBSOLETE     case IPC_REGNUM: */
-/* OBSOLETE       return (128); */
-/* OBSOLETE     case IPA_REGNUM: */
-/* OBSOLETE       return (129); */
-/* OBSOLETE     case IPB_REGNUM: */
-/* OBSOLETE       return (130); */
-/* OBSOLETE     case Q_REGNUM: */
-/* OBSOLETE       return (131); */
-/* OBSOLETE     case ALU_REGNUM: */
-/* OBSOLETE       return (132); */
-/* OBSOLETE     case BP_REGNUM: */
-/* OBSOLETE       return (133); */
-/* OBSOLETE     case FC_REGNUM: */
-/* OBSOLETE       return (134); */
-/* OBSOLETE     case CR_REGNUM: */
-/* OBSOLETE       return (135); */
-/* OBSOLETE     case FPE_REGNUM: */
-/* OBSOLETE       return (160); */
-/* OBSOLETE     case INTE_REGNUM: */
-/* OBSOLETE       return (161); */
-/* OBSOLETE     case FPS_REGNUM: */
-/* OBSOLETE       return (162); */
-/* OBSOLETE     case EXO_REGNUM: */
-/* OBSOLETE       return (164); */
-/* OBSOLETE     default: */
-/* OBSOLETE       return (255);		/* Failure ? */ */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE /****************************************************************************/ */
-/* OBSOLETE /* */
-/* OBSOLETE  * Determine the Target memory space qualifier based on the addr.  */
-/* OBSOLETE  * FIXME: Can't distinguis I_ROM/D_ROM.   */
-/* OBSOLETE  * FIXME: Doesn't know anything about I_CACHE/D_CACHE. */
-/* OBSOLETE  */ */
-/* OBSOLETE static CPUSpace */
-/* OBSOLETE udi_memory_space (CORE_ADDR addr) */
-/* OBSOLETE { */
-/* OBSOLETE   UDIUInt32 tstart = IMemStart; */
-/* OBSOLETE   UDIUInt32 tend = tstart + IMemSize; */
-/* OBSOLETE   UDIUInt32 dstart = DMemStart; */
-/* OBSOLETE   UDIUInt32 dend = tstart + DMemSize; */
-/* OBSOLETE   UDIUInt32 rstart = RMemStart; */
-/* OBSOLETE   UDIUInt32 rend = tstart + RMemSize; */
-/* OBSOLETE  */
-/* OBSOLETE   if (((UDIUInt32) addr >= tstart) && ((UDIUInt32) addr < tend)) */
-/* OBSOLETE     { */
-/* OBSOLETE       return UDI29KIRAMSpace; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (((UDIUInt32) addr >= dstart) && ((UDIUInt32) addr < dend)) */
-/* OBSOLETE     { */
-/* OBSOLETE       return UDI29KDRAMSpace; */
-/* OBSOLETE     } */
-/* OBSOLETE   else if (((UDIUInt32) addr >= rstart) && ((UDIUInt32) addr < rend)) */
-/* OBSOLETE     { */
-/* OBSOLETE       /* FIXME: how do we determine between D_ROM and I_ROM */ */
-/* OBSOLETE       return UDI29KIROMSpace; */
-/* OBSOLETE     } */
-/* OBSOLETE   else				/* FIXME: what do me do now? */ */
-/* OBSOLETE     return UDI29KDRAMSpace;	/* Hmmm! */ */
-/* OBSOLETE } */
-/* OBSOLETE /*********************************************************************** STUBS */
-/* OBSOLETE */ */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE convert16 (void) */
-/* OBSOLETE {; */
-/* OBSOLETE } */
-/* OBSOLETE void */
-/* OBSOLETE convert32 (void) */
-/* OBSOLETE {; */
-/* OBSOLETE } */
-/* OBSOLETE struct ui_file *EchoFile = 0;	/* used for debugging */ */
-/* OBSOLETE int QuietMode = 0;		/* used for debugging */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef NO_HIF_SUPPORT */
-/* OBSOLETE service_HIF (union msg_t *msg) */
-/* OBSOLETE { */
-/* OBSOLETE   return (0);			/* Emulate a failure */ */
-/* OBSOLETE } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE /* Target_ops vector.  Not static because there does not seem to be */
-/* OBSOLETE    any portable way to do a forward declaration of a static variable. */
-/* OBSOLETE    The RS/6000 doesn't like "extern" followed by "static"; SunOS */
-/* OBSOLETE    /bin/cc doesn't like "static" twice.  */ */
-/* OBSOLETE  */
-/* OBSOLETE struct target_ops udi_ops; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE init_udi_ops (void) */
-/* OBSOLETE { */
-/* OBSOLETE   udi_ops.to_shortname = "udi"; */
-/* OBSOLETE   udi_ops.to_longname = "Remote UDI connected TIP"; */
-/* OBSOLETE   udi_ops.to_doc = "Remote debug an AMD 29k using UDI socket connection to TIP process.\n\ */
-/* OBSOLETE Arguments are\n\ */
-/* OBSOLETE `configuration-id AF_INET hostname port-number'\n\ */
-/* OBSOLETE To connect via the network, where hostname and port-number specify the\n\ */
-/* OBSOLETE host and port where you can connect via UDI.\n\ */
-/* OBSOLETE configuration-id is unused.\n\ */
-/* OBSOLETE \n\ */
-/* OBSOLETE `configuration-id AF_UNIX socket-name tip-program'\n\ */
-/* OBSOLETE To connect using a local connection to the \"tip.exe\" program which is\n\ */
-/* OBSOLETE     supplied by AMD.  If socket-name specifies an AF_UNIX socket then the\n\ */
-/* OBSOLETE     tip program must already be started; connect to it using that socket.\n\ */
-/* OBSOLETE     If not, start up tip-program, which should be the name of the tip\n\ */
-/* OBSOLETE     program.  If appropriate, the PATH environment variable is searched.\n\ */
-/* OBSOLETE     configuration-id is unused.\n\ */
-/* OBSOLETE \n\ */
-/* OBSOLETE `configuration-id'\n\ */
-/* OBSOLETE     Look up the configuration in ./udi_soc or /etc/udi_soc, which\n\ */
-/* OBSOLETE     are files containing lines in the above formats.  configuration-id is\n\ */
-/* OBSOLETE     used to pick which line of the file to use."; */
-/* OBSOLETE   udi_ops.to_open = udi_open; */
-/* OBSOLETE   udi_ops.to_close = udi_close; */
-/* OBSOLETE   udi_ops.to_attach = udi_attach; */
-/* OBSOLETE   udi_ops.to_detach = udi_detach; */
-/* OBSOLETE   udi_ops.to_resume = udi_resume; */
-/* OBSOLETE   udi_ops.to_wait = udi_wait; */
-/* OBSOLETE   udi_ops.to_fetch_registers = udi_fetch_registers; */
-/* OBSOLETE   udi_ops.to_store_registers = udi_store_registers; */
-/* OBSOLETE   udi_ops.to_prepare_to_store = udi_prepare_to_store; */
-/* OBSOLETE   udi_ops.to_xfer_memory = udi_xfer_inferior_memory; */
-/* OBSOLETE   udi_ops.to_files_info = udi_files_info; */
-/* OBSOLETE   udi_ops.to_insert_breakpoint = udi_insert_breakpoint; */
-/* OBSOLETE   udi_ops.to_remove_breakpoint = udi_remove_breakpoint; */
-/* OBSOLETE   udi_ops.to_terminal_init = 0; */
-/* OBSOLETE   udi_ops.to_terminal_inferior = 0; */
-/* OBSOLETE   udi_ops.to_terminal_ours_for_output = 0; */
-/* OBSOLETE   udi_ops.to_terminal_ours = 0; */
-/* OBSOLETE   udi_ops.to_terminal_info = 0; */
-/* OBSOLETE   udi_ops.to_kill = udi_kill; */
-/* OBSOLETE   udi_ops.to_load = udi_load; */
-/* OBSOLETE   udi_ops.to_lookup_symbol = 0; */
-/* OBSOLETE   udi_ops.to_create_inferior = udi_create_inferior; */
-/* OBSOLETE   udi_ops.to_mourn_inferior = udi_mourn; */
-/* OBSOLETE   udi_ops.to_can_run = 0; */
-/* OBSOLETE   udi_ops.to_notice_signals = 0; */
-/* OBSOLETE   udi_ops.to_thread_alive = 0; */
-/* OBSOLETE   udi_ops.to_stop = 0; */
-/* OBSOLETE   udi_ops.to_stratum = process_stratum; */
-/* OBSOLETE   udi_ops.DONT_USE = 0; */
-/* OBSOLETE   udi_ops.to_has_all_memory = 1; */
-/* OBSOLETE   udi_ops.to_has_memory = 1; */
-/* OBSOLETE   udi_ops.to_has_stack = 1; */
-/* OBSOLETE   udi_ops.to_has_registers = 1; */
-/* OBSOLETE   udi_ops.to_has_execution = 1; */
-/* OBSOLETE   udi_ops.to_sections = 0; */
-/* OBSOLETE   udi_ops.to_sections_end = 0; */
-/* OBSOLETE   udi_ops.to_magic = OPS_MAGIC; */
-/* OBSOLETE }; */
-/* OBSOLETE  */
-/* OBSOLETE void */
-/* OBSOLETE _initialize_remote_udi (void) */
-/* OBSOLETE { */
-/* OBSOLETE   init_udi_ops (); */
-/* OBSOLETE   add_target (&udi_ops); */
-/* OBSOLETE } */
diff --git a/gdb/remote-utils.c b/gdb/remote-utils.c
index e703f3d..ba150e3 100644
--- a/gdb/remote-utils.c
+++ b/gdb/remote-utils.c
@@ -86,7 +86,7 @@
     fprintf_unfiltered (gdb_stderr, "Unrecognized arguments: `%s'.\n", junk);
 
   error ("Usage: target %s [DEVICE [SPEED [DEBUG]]]\n\
-where DEVICE is the name of a device or HOST:PORT", proto, proto);
+where DEVICE is the name of a device or HOST:PORT", proto);
 
   return;
 }
diff --git a/gdb/remote-vxsparc.c b/gdb/remote-vxsparc.c
index 014f1d4..294e940 100644
--- a/gdb/remote-vxsparc.c
+++ b/gdb/remote-vxsparc.c
@@ -102,7 +102,7 @@
      (FRAME_FIND_SAVED_REGS, in particular, depends on this).  */
 
   sp = extract_address (&registers[REGISTER_BYTE (SP_REGNUM)],
-			REGISTER_RAW_SIZE (CORE_ADDR));
+			REGISTER_RAW_SIZE (SP_REGNUM));
   write_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
 		16 * REGISTER_RAW_SIZE (L0_REGNUM));
 
@@ -173,7 +173,7 @@
       if (regno < 0 || (L0_REGNUM <= regno && regno <= I7_REGNUM))
 	{
 	  sp = extract_address (&registers[REGISTER_BYTE (SP_REGNUM)],
-				REGISTER_RAW_SIZE (CORE_ADDR));
+				REGISTER_RAW_SIZE (SP_REGNUM));
 	  write_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
 			16 * REGISTER_RAW_SIZE (L0_REGNUM));
 	}
diff --git a/gdb/remote.c b/gdb/remote.c
index 2d70baf..a773680 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -211,7 +211,7 @@
 
 void _initialize_remote (void);
 
-/* Description of the remote protocol.  Strictly speeking, when the
+/* Description of the remote protocol.  Strictly speaking, when the
    target is open()ed, remote.c should create a per-target description
    of the remote protocol using that target's architecture.
    Unfortunatly, the target stack doesn't include local state.  For
@@ -5013,8 +5013,8 @@
 
       getpkt (buf, (rs->remote_packet_size), 0);
       if (buf[0] == 'E')
-	error ("target memory fault, section %s, range 0x%08x -- 0x%08x",
-	       sectname, lma, lma + size);
+	error ("target memory fault, section %s, range 0x%s -- 0x%s",
+	       sectname, paddr (lma), paddr (lma + size));
       if (buf[0] != 'C')
 	error ("remote target does not support this operation");
 
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index c2b1dd9..8fb2fec 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -160,11 +160,11 @@
 /* Call ptrace(REQ, ID, ADDR, DATA, BUF). */
 
 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
 {
   int ret = ptrace (req, id, (int *)addr, data, buf);
 #if 0
-  printf ("ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
+  printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
 	  req, id, (unsigned int)addr, data, (unsigned int)buf, ret);
 #endif
   return ret;
@@ -173,7 +173,7 @@
 /* Call ptracex(REQ, ID, ADDR, DATA, BUF). */
 
 static int
-ptrace64 (int req, int id, long long addr, int data, int *buf)
+rs6000_ptrace64 (int req, int id, long long addr, int data, int *buf)
 {
 #ifdef ARCH3264
   int ret = ptracex (req, id, addr, data, buf);
@@ -181,7 +181,7 @@
   int ret = 0;
 #endif
 #if 0
-  printf ("ptrace64 (%d, %d, 0x%llx, %08x, 0x%x) = 0x%x\n",
+  printf ("rs6000_ptrace64 (%d, %d, 0x%llx, %08x, 0x%x) = 0x%x\n",
 	  req, id, addr, data, (unsigned int)buf, ret);
 #endif
   return ret;
@@ -202,7 +202,7 @@
   if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
     {
       nr = regno - FP0_REGNUM + FPR0;
-      ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0);
+      rs6000_ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0);
     }
 
   /* Bogus register number. */
@@ -223,13 +223,13 @@
 	nr = regno;
 
       if (!ARCH64 ())
-	*addr = ptrace32 (PT_READ_GPR, PIDGET (inferior_ptid), (int *)nr, 0, 0);
+	*addr = rs6000_ptrace32 (PT_READ_GPR, PIDGET (inferior_ptid), (int *)nr, 0, 0);
       else
 	{
 	  /* PT_READ_GPR requires the buffer parameter to point to long long,
 	     even if the register is really only 32 bits. */
 	  long long buf;
-	  ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf);
+	  rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf);
 	  if (REGISTER_RAW_SIZE (regno) == 8)
 	    memcpy (addr, &buf, 8);
 	  else
@@ -264,7 +264,7 @@
   if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
     {
       nr = regno - FP0_REGNUM + FPR0;
-      ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0);
+      rs6000_ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0);
     }
 
   /* Bogus register number. */
@@ -293,7 +293,7 @@
 	nr = regno;
 
       if (!ARCH64 ())
-	ptrace32 (PT_WRITE_GPR, PIDGET (inferior_ptid), (int *)nr, *addr, 0);
+	rs6000_ptrace32 (PT_WRITE_GPR, PIDGET (inferior_ptid), (int *)nr, *addr, 0);
       else
 	{
 	  /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
@@ -303,7 +303,7 @@
 	    memcpy (&buf, addr, 8);
 	  else
 	    buf = *addr;
-	  ptrace64 (PT_WRITE_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf);
+	  rs6000_ptrace64 (PT_WRITE_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf);
 	}
     }
 
@@ -377,9 +377,9 @@
   errno = 0;
 
   if (arch64)
-    *to = ptrace64 (PT_READ_I, PIDGET (inferior_ptid), from, 0, NULL);
+    *to = rs6000_ptrace64 (PT_READ_I, PIDGET (inferior_ptid), from, 0, NULL);
   else
-    *to = ptrace32 (PT_READ_I, PIDGET (inferior_ptid), (int *)(long) from,
+    *to = rs6000_ptrace32 (PT_READ_I, PIDGET (inferior_ptid), (int *)(long) from,
                     0, NULL);
 
   return !errno;
@@ -449,9 +449,9 @@
       for (i = 0, errno = 0; i < count; i++, addr += sizeof (int))
 	{
 	  if (arch64)
-	    ptrace64 (PT_WRITE_D, PIDGET (inferior_ptid), addr, buf[i], NULL);
+	    rs6000_ptrace64 (PT_WRITE_D, PIDGET (inferior_ptid), addr, buf[i], NULL);
 	  else
-	    ptrace32 (PT_WRITE_D, PIDGET (inferior_ptid), (int *)(long) addr,
+	    rs6000_ptrace32 (PT_WRITE_D, PIDGET (inferior_ptid), (int *)(long) addr,
 		      buf[i], NULL);
 
 	  if (errno)
@@ -490,9 +490,9 @@
   prev_pc = read_pc ();
   write_pc (DUMMY_INSN_ADDR);
   if (ARCH64 ())
-    ret = ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
+    ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
   else
-    ret = ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid), (int *)1, 0, NULL);
+    ret = rs6000_ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid), (int *)1, 0, NULL);
 
   if (ret != 0)
     perror ("pt_continue");
@@ -987,9 +987,9 @@
 #endif
 
       if (arch64)
-	rc = ptrace64 (PT_LDINFO, pid, (unsigned long) ldi, size, NULL);
+	rc = rs6000_ptrace64 (PT_LDINFO, pid, (unsigned long) ldi, size, NULL);
       else
-	rc = ptrace32 (PT_LDINFO, pid, (int *) ldi, size, NULL);
+	rc = rs6000_ptrace32 (PT_LDINFO, pid, (int *) ldi, size, NULL);
 
       if (rc == -1)
         {
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 2105727..74285a3 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -1,6 +1,6 @@
 /* Target-dependent code for GDB, the GNU debugger.
    Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001
+   1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -35,9 +35,11 @@
 #include "value.h"
 #include "parser-defs.h"
 
-#include "bfd/libbfd.h"		/* for bfd_default_set_arch_mach */
+#include "libbfd.h"		/* for bfd_default_set_arch_mach */
 #include "coff/internal.h"	/* for libcoff.h */
-#include "bfd/libcoff.h"	/* for xcoff_data */
+#include "libcoff.h"		/* for xcoff_data */
+#include "coff/xcoff.h"
+#include "libxcoff.h"
 
 #include "elf-bfd.h"
 
@@ -64,13 +66,16 @@
 				   the frame */
     int saved_gpr;		/* smallest # of saved gpr */
     int saved_fpr;		/* smallest # of saved fpr */
+    int saved_vr;               /* smallest # of saved vr */
     int alloca_reg;		/* alloca register number (frame ptr) */
     char frameless;		/* true if frameless functions. */
     char nosavedpc;		/* true if pc not saved. */
     int gpr_offset;		/* offset of saved gprs from prev sp */
     int fpr_offset;		/* offset of saved fprs from prev sp */
+    int vr_offset;              /* offset of saved vrs from prev sp */
     int lr_offset;		/* offset of saved lr */
     int cr_offset;		/* offset of saved cr */
+    int vrsave_offset;          /* offset of saved vrsave register */
   };
 
 /* Description of a single register. */
@@ -277,7 +282,7 @@
 #define BIG_BREAKPOINT { 0x7d, 0x82, 0x10, 0x08 }
 #define LITTLE_BREAKPOINT { 0x08, 0x10, 0x82, 0x7d }
 
-static unsigned char *
+const static unsigned char *
 rs6000_breakpoint_from_pc (CORE_ADDR *bp_addr, int *bp_size)
 {
   static unsigned char big_breakpoint[] = BIG_BREAKPOINT;
@@ -296,11 +301,9 @@
 rs6000_software_single_step (enum target_signal signal,
 			     int insert_breakpoints_p)
 {
-#define	INSNLEN(OPCODE)	 4
-
-  static char le_breakp[] = LITTLE_BREAKPOINT;
-  static char be_breakp[] = BIG_BREAKPOINT;
-  char *breakp = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? be_breakp : le_breakp;
+  CORE_ADDR dummy;
+  int breakp_sz;
+  const char *breakp = rs6000_breakpoint_from_pc (&dummy, &breakp_sz);
   int ii, insn;
   CORE_ADDR loc;
   CORE_ADDR breaks[2];
@@ -313,7 +316,7 @@
 
       insn = read_memory_integer (loc, 4);
 
-      breaks[0] = loc + INSNLEN (insn);
+      breaks[0] = loc + breakp_sz;
       opcode = insn >> 26;
       breaks[1] = branch_dest (opcode, insn, loc, breaks[0]);
 
@@ -329,10 +332,7 @@
 	  /* ignore invalid breakpoint. */
 	  if (breaks[ii] == -1)
 	    continue;
-
-	  read_memory (breaks[ii], stepBreaks[ii].data, 4);
-
-	  write_memory (breaks[ii], breakp, 4);
+	  target_insert_breakpoint (breaks[ii], stepBreaks[ii].data);
 	  stepBreaks[ii].address = breaks[ii];
 	}
 
@@ -343,9 +343,8 @@
       /* remove step breakpoints. */
       for (ii = 0; ii < 2; ++ii)
 	if (stepBreaks[ii].address != 0)
-	  write_memory
-	    (stepBreaks[ii].address, stepBreaks[ii].data, 4);
-
+	  target_remove_breakpoint (stepBreaks[ii].address,
+				    stepBreaks[ii].data);
     }
   errno = 0;			/* FIXME, don't ignore errors! */
   /* What errors?  {read,write}_memory call error().  */
@@ -362,12 +361,15 @@
    which we decrement the sp to allocate the frame.
    - saved_gpr is the number of the first saved gpr.
    - saved_fpr is the number of the first saved fpr.
+   - saved_vr is the number of the first saved vr.
    - alloca_reg is the number of the register used for alloca() handling.
    Otherwise -1.
    - gpr_offset is the offset of the first saved gpr from the previous frame.
    - fpr_offset is the offset of the first saved fpr from the previous frame.
+   - vr_offset is the offset of the first saved vr from the previous frame.
    - lr_offset is the offset of the saved lr
    - cr_offset is the offset of the saved cr
+   - vrsave_offset is the offset of the saved vrsave register
  */
 
 #define SIGNED_SHORT(x) 						\
@@ -434,11 +436,15 @@
 {
   CORE_ADDR orig_pc = pc;
   CORE_ADDR last_prologue_pc = pc;
+  CORE_ADDR li_found_pc = 0;
   char buf[4];
   unsigned long op;
   long offset = 0;
+  long vr_saved_offset = 0;
   int lr_reg = -1;
   int cr_reg = -1;
+  int vr_reg = -1;
+  int vrsave_reg = -1;
   int reg;
   int framep = 0;
   int minimal_toc_loaded = 0;
@@ -463,6 +469,7 @@
   memset (fdata, 0, sizeof (struct rs6000_framedata));
   fdata->saved_gpr = -1;
   fdata->saved_fpr = -1;
+  fdata->saved_vr = -1;
   fdata->alloca_reg = -1;
   fdata->frameless = 1;
   fdata->nosavedpc = 1;
@@ -581,17 +588,8 @@
 	  break;
 
 	}
-      else if (((op & 0xffff0000) == 0x801e0000 ||	/* lwz 0,NUM(r30), used
-							   in V.4 -mrelocatable */
-		op == 0x7fc0f214) &&	/* add r30,r0,r30, used
-					   in V.4 -mrelocatable */
-	       lr_reg == 0x901e0000)
-	{
-	  continue;
-
-	}
-      else if ((op & 0xffff0000) == 0x3fc00000 ||	/* addis 30,0,foo@ha, used
-							   in V.4 -mminimal-toc */
+      else if ((op & 0xffff0000) == 0x3fc00000 ||  /* addis 30,0,foo@ha, used
+						      in V.4 -mminimal-toc */
 	       (op & 0xffff0000) == 0x3bde0000)
 	{			/* addi 30,30,foo@l */
 	  continue;
@@ -602,17 +600,17 @@
 				   to save fprs??? */
 
 	  fdata->frameless = 0;
-	  /* Don't skip over the subroutine call if it is not within the first
-	     three instructions of the prologue.  */
+	  /* Don't skip over the subroutine call if it is not within
+	     the first three instructions of the prologue.  */
 	  if ((pc - orig_pc) > 8)
 	    break;
 
 	  op = read_memory_integer (pc + 4, 4);
 
-	  /* At this point, make sure this is not a trampoline function
-	     (a function that simply calls another functions, and nothing else).
-	     If the next is not a nop, this branch was part of the function
-	     prologue. */
+	  /* At this point, make sure this is not a trampoline
+	     function (a function that simply calls another functions,
+	     and nothing else).  If the next is not a nop, this branch
+	     was part of the function prologue. */
 
 	  if (op == 0x4def7b82 || op == 0)	/* crorc 15, 15, 15 */
 	    break;		/* don't skip over 
@@ -658,8 +656,7 @@
 
 	  /* store parameters in stack */
 	}
-      else if ((op & 0xfc1f0000) == 0x90010000 ||	/* st rx,NUM(r1) */
-	       (op & 0xfc1f0003) == 0xf8010000 ||	/* std rx,NUM(r1) */
+      else if ((op & 0xfc1f0003) == 0xf8010000 ||	/* std rx,NUM(r1) */
 	       (op & 0xfc1f0000) == 0xd8010000 ||	/* stfd Rx,NUM(r1) */
 	       (op & 0xfc1f0000) == 0xfc010000)		/* frsp, fp?,NUM(r1) */
 	{
@@ -692,8 +689,74 @@
 	  framep = 1;
 	  fdata->alloca_reg = (op & ~0x38010000) >> 21;
 	  continue;
-
 	}
+      /* AltiVec related instructions.  */
+      /* Store the vrsave register (spr 256) in another register for
+	 later manipulation, or load a register into the vrsave
+	 register.  2 instructions are used: mfvrsave and
+	 mtvrsave.  They are shorthand notation for mfspr Rn, SPR256
+	 and mtspr SPR256, Rn.  */
+      /* mfspr Rn SPR256 == 011111 nnnnn 0000001000 01010100110
+	 mtspr SPR256 Rn == 011111 nnnnn 0000001000 01110100110  */
+      else if ((op & 0xfc1fffff) == 0x7c0042a6)    /* mfvrsave Rn */
+	{
+          vrsave_reg = GET_SRC_REG (op);
+	  continue;
+	}
+      else if ((op & 0xfc1fffff) == 0x7c0043a6)     /* mtvrsave Rn */
+        {
+          continue;
+        }
+      /* Store the register where vrsave was saved to onto the stack:
+         rS is the register where vrsave was stored in a previous
+	 instruction.  */
+      /* 100100 sssss 00001 dddddddd dddddddd */
+      else if ((op & 0xfc1f0000) == 0x90010000)     /* stw rS, d(r1) */
+        {
+          if (vrsave_reg == GET_SRC_REG (op))
+	    {
+	      fdata->vrsave_offset = SIGNED_SHORT (op) + offset;
+	      vrsave_reg = -1;
+	    }
+          continue;
+        }
+      /* Compute the new value of vrsave, by modifying the register
+         where vrsave was saved to.  */
+      else if (((op & 0xfc000000) == 0x64000000)    /* oris Ra, Rs, UIMM */
+	       || ((op & 0xfc000000) == 0x60000000))/* ori Ra, Rs, UIMM */
+	{
+	  continue;
+	}
+      /* li r0, SIMM (short for addi r0, 0, SIMM).  This is the first
+	 in a pair of insns to save the vector registers on the
+	 stack.  */
+      /* 001110 00000 00000 iiii iiii iiii iiii  */
+      else if ((op & 0xffff0000) == 0x38000000)    /* li r0, SIMM */
+	{
+	  li_found_pc = pc;
+	  vr_saved_offset = SIGNED_SHORT (op);
+	}
+      /* Store vector register S at (r31+r0) aligned to 16 bytes.  */      
+      /* 011111 sssss 11111 00000 00111001110 */
+      else if ((op & 0xfc1fffff) == 0x7c1f01ce)   /* stvx Vs, R31, R0 */
+        {
+	  if (pc == (li_found_pc + 4))
+	    {
+	      vr_reg = GET_SRC_REG (op);
+	      /* If this is the first vector reg to be saved, or if
+		 it has a lower number than others previously seen,
+		 reupdate the frame info.  */
+	      if (fdata->saved_vr == -1 || fdata->saved_vr > vr_reg)
+		{
+		  fdata->saved_vr = vr_reg;
+		  fdata->vr_offset = vr_saved_offset + offset;
+		}
+	      vr_saved_offset = -1;
+	      vr_reg = -1;
+	      li_found_pc = 0;
+	    }
+	}
+      /* End AltiVec related instructions.  */
       else
 	{
 	  /* Not a recognized prologue instruction.
@@ -842,9 +905,6 @@
 		       int nargs, struct value **args, struct type *type,
 		       int gcc_p)
 {
-#define	TOC_ADDR_OFFSET		20
-#define	TARGET_ADDR_OFFSET	28
-
   int ii;
   CORE_ADDR target_addr;
 
@@ -975,7 +1035,7 @@
 ran_out_of_registers_for_arguments:
 
   saved_sp = read_sp ();
-#ifndef ELF_OBJECT_FORMAT
+
   /* location for 8 parameters are always reserved. */
   sp -= wordsize * 8;
 
@@ -984,7 +1044,6 @@
 
   /* stack pointer must be quadword aligned */
   sp &= -16;
-#endif
 
   /* if there are more arguments, allocate space for them in 
      the stack, then push them starting from the ninth one. */
@@ -1087,6 +1146,7 @@
 rs6000_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
 {
   int offset = 0;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
   if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
     {
@@ -1108,6 +1168,13 @@
 	  memcpy (valbuf, &ff, sizeof (float));
 	}
     }
+  else if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY
+           && TYPE_LENGTH (valtype) == 16
+           && TYPE_VECTOR (valtype))
+    {
+      memcpy (valbuf, regbuf + REGISTER_BYTE (tdep->ppc_vr0_regnum + 2),
+	      TYPE_LENGTH (valtype));
+    }
   else
     {
       /* return value is copied starting from r3. */
@@ -1262,7 +1329,8 @@
 {
   CORE_ADDR func_start;
   struct rs6000_framedata fdata;
-  int wordsize = TDEP->wordsize;
+  struct gdbarch_tdep *tdep = TDEP;
+  int wordsize = tdep->wordsize;
 
   if (fi->signal_handler_caller)
     return read_memory_addr (fi->frame + SIG_FRAME_PC_OFFSET, wordsize);
@@ -1285,7 +1353,7 @@
 	return read_memory_addr (fi->next->frame + SIG_FRAME_LR_OFFSET,
 				 wordsize);
       else
-	return read_memory_addr (FRAME_CHAIN (fi) + DEFAULT_LR_SAVE,
+	return read_memory_addr (FRAME_CHAIN (fi) + tdep->lr_frame_offset,
 				 wordsize);
     }
 
@@ -1304,7 +1372,8 @@
 {
   CORE_ADDR frame_addr;
   struct rs6000_framedata work_fdata;
-  int wordsize = TDEP->wordsize;
+  struct gdbarch_tdep * tdep = gdbarch_tdep (current_gdbarch);
+  int wordsize = tdep->wordsize;
 
   if (fi->saved_regs)
     return;
@@ -1322,13 +1391,20 @@
   /* The following is true only if the frame doesn't have a call to
      alloca(), FIXME. */
 
-  if (fdatap->saved_fpr == 0 && fdatap->saved_gpr == 0
-      && fdatap->lr_offset == 0 && fdatap->cr_offset == 0)
+  if (fdatap->saved_fpr == 0
+      && fdatap->saved_gpr == 0
+      && fdatap->saved_vr == 0
+      && fdatap->lr_offset == 0
+      && fdatap->cr_offset == 0
+      && fdatap->vr_offset == 0)
     frame_addr = 0;
-  else if (fi->prev && fi->prev->frame)
-    frame_addr = fi->prev->frame;
   else
-    frame_addr = read_memory_addr (fi->frame, wordsize);
+    /* NOTE: cagney/2002-04-14: The ->frame points to the inner-most
+       address of the current frame.  Things might be easier if the
+       ->frame pointed to the outer-most address of the frame.  In the
+       mean time, the address of the prev frame is used as the base
+       address of this frame.  */
+    frame_addr = FRAME_CHAIN (fi);
 
   /* if != -1, fdatap->saved_fpr is the smallest number of saved_fpr.
      All fpr's from saved_fpr to fp31 are saved.  */
@@ -1358,17 +1434,36 @@
 	}
     }
 
+  /* if != -1, fdatap->saved_vr is the smallest number of saved_vr.
+     All vr's from saved_vr to vr31 are saved.  */
+  if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1)
+    {
+      if (fdatap->saved_vr >= 0)
+	{
+	  int i;
+	  CORE_ADDR vr_addr = frame_addr + fdatap->vr_offset;
+	  for (i = fdatap->saved_vr; i < 32; i++)
+	    {
+	      fi->saved_regs[tdep->ppc_vr0_regnum + i] = vr_addr;
+	      vr_addr += REGISTER_RAW_SIZE (tdep->ppc_vr0_regnum);
+	    }
+	}
+    }
+
   /* If != 0, fdatap->cr_offset is the offset from the frame that holds
      the CR.  */
   if (fdatap->cr_offset != 0)
-    fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_cr_regnum] =
-      frame_addr + fdatap->cr_offset;
+    fi->saved_regs[tdep->ppc_cr_regnum] = frame_addr + fdatap->cr_offset;
 
   /* If != 0, fdatap->lr_offset is the offset from the frame that holds
      the LR.  */
   if (fdatap->lr_offset != 0)
-    fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_lr_regnum] =
-      frame_addr + fdatap->lr_offset;
+    fi->saved_regs[tdep->ppc_lr_regnum] = frame_addr + fdatap->lr_offset;
+
+  /* If != 0, fdatap->vrsave_offset is the offset from the frame that holds
+     the VRSAVE.  */
+  if (fdatap->vrsave_offset != 0)
+    fi->saved_regs[tdep->ppc_vrsave_regnum] = frame_addr + fdatap->vrsave_offset;
 }
 
 /* Return the address of a frame. This is the inital %sp value when the frame
@@ -1406,41 +1501,22 @@
       return fi->extra_info->initial_sp;
     }
 
-  /* This function has an alloca register. If this is the top-most frame
-     (with the lowest address), the value in alloca register is good. */
-
-  if (!fi->next)
-    return fi->extra_info->initial_sp = read_register (fdata.alloca_reg);
-
-  /* Otherwise, this is a caller frame. Callee has usually already saved
-     registers, but there are exceptions (such as when the callee
-     has no parameters). Find the address in which caller's alloca
-     register is saved. */
-
-  for (callee_fi = fi->next; callee_fi; callee_fi = callee_fi->next)
-    {
-
-      if (!callee_fi->saved_regs)
-	frame_get_saved_regs (callee_fi, NULL);
-
-      /* this is the address in which alloca register is saved. */
-
-      tmpaddr = callee_fi->saved_regs[fdata.alloca_reg];
-      if (tmpaddr)
-	{
-	  fi->extra_info->initial_sp =
-	    read_memory_addr (tmpaddr, TDEP->wordsize);
-	  return fi->extra_info->initial_sp;
-	}
-
-      /* Go look into deeper levels of the frame chain to see if any one of
-         the callees has saved alloca register. */
-    }
-
-  /* If alloca register was not saved, by the callee (or any of its callees)
-     then the value in the register is still good. */
-
-  fi->extra_info->initial_sp = read_register (fdata.alloca_reg);
+  /* There is an alloca register, use its value, in the current frame,
+     as the initial stack pointer.  */
+  {
+    char *tmpbuf = alloca (MAX_REGISTER_RAW_SIZE);
+    if (frame_register_read (fi, fdata.alloca_reg, tmpbuf))
+      {
+	fi->extra_info->initial_sp
+	  = extract_unsigned_integer (tmpbuf,
+				      REGISTER_RAW_SIZE (fdata.alloca_reg));
+      }
+    else
+      /* NOTE: cagney/2002-04-17: At present the only time
+         frame_register_read will fail is when the register isn't
+         available.  If that does happen, use the frame.  */
+      fi->extra_info->initial_sp = fi->frame;
+  }
   return fi->extra_info->initial_sp;
 }
 
@@ -1648,7 +1724,7 @@
       print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout);
 
       /* Get the data in raw format.  */
-      if (read_relative_register_raw_bytes (i, raw_buffer))
+      if (!frame_register_read (selected_frame, i, raw_buffer))
         {
           printf_filtered ("*value not available*\n");
           continue;
@@ -1745,7 +1821,7 @@
       print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout);
 
       /* Get the data in raw format.  */
-      if (read_relative_register_raw_bytes (i, raw_buffer))
+      if (!frame_register_read (selected_frame, i, raw_buffer))
         {
           printf_filtered ("*value not available*\n");
           continue;
@@ -1843,6 +1919,8 @@
 static void
 rs6000_store_return_value (struct type *type, char *valbuf)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
 
     /* Floating point values are returned starting from FPR1 and up.
@@ -1851,6 +1929,13 @@
 
     write_register_bytes (REGISTER_BYTE (FP0_REGNUM + 1), valbuf,
 			  TYPE_LENGTH (type));
+  else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+    {
+      if (TYPE_LENGTH (type) == 16
+          && TYPE_VECTOR (type))
+	write_register_bytes (REGISTER_BYTE (tdep->ppc_vr0_regnum + 2),
+			      valbuf, TYPE_LENGTH (type));
+    }
   else
     /* Everything else is returned in GPR3 and up. */
     write_register_bytes (REGISTER_BYTE (gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum + 3),
@@ -1941,7 +2026,21 @@
 
    Most of these register groups aren't anything formal.  I arrived at
    them by looking at the registers that occurred in more than one
-   processor. */
+   processor.
+   
+   Note: kevinb/2002-04-30: Support for the fpscr register was added
+   during April, 2002.  Slot 70 is being used for PowerPC and slot 71
+   for Power.  For PowerPC, slot 70 was unused and was already in the
+   PPC_UISA_SPRS which is ideally where fpscr should go.  For Power,
+   slot 70 was being used for "mq", so the next available slot (71)
+   was chosen.  It would have been nice to be able to make the
+   register numbers the same across processor cores, but this wasn't
+   possible without either 1) renumbering some registers for some
+   processors or 2) assigning fpscr to a really high slot that's
+   larger than any current register number.  Doing (1) is bad because
+   existing stubs would break.  Doing (2) is undesirable because it
+   would introduce a really large gap between fpscr and the rest of
+   the registers for most processors.  */
 
 /* Convenience macros for populating register arrays. */
 
@@ -1992,9 +2091,20 @@
   /* 56 */ F(f24),F(f25),F(f26),F(f27),F(f28),F(f29),F(f30),F(f31), \
   /* 64 */ R(pc), R(ps)
 
+#define COMMON_UISA_NOFP_REGS \
+  /*  0 */ R(r0), R(r1), R(r2), R(r3), R(r4), R(r5), R(r6), R(r7),  \
+  /*  8 */ R(r8), R(r9), R(r10),R(r11),R(r12),R(r13),R(r14),R(r15), \
+  /* 16 */ R(r16),R(r17),R(r18),R(r19),R(r20),R(r21),R(r22),R(r23), \
+  /* 24 */ R(r24),R(r25),R(r26),R(r27),R(r28),R(r29),R(r30),R(r31), \
+  /* 32 */ R0,    R0,    R0,    R0,    R0,    R0,    R0,    R0,     \
+  /* 40 */ R0,    R0,    R0,    R0,    R0,    R0,    R0,    R0,     \
+  /* 48 */ R0,    R0,    R0,    R0,    R0,    R0,    R0,    R0,     \
+  /* 56 */ R0,    R0,    R0,    R0,    R0,    R0,    R0,    R0,     \
+  /* 64 */ R(pc), R(ps)
+
 /* UISA-level SPRs for PowerPC.  */
 #define PPC_UISA_SPRS \
-  /* 66 */ R4(cr),  R(lr), R(ctr), R4(xer), R0
+  /* 66 */ R4(cr),  R(lr), R(ctr), R4(xer), R4(fpscr)
 
 /* Segment registers, for PowerPC.  */
 #define PPC_SEGMENT_REGS \
@@ -2028,7 +2138,8 @@
 static const struct reg registers_power[] =
 {
   COMMON_UISA_REGS,
-  /* 66 */ R4(cnd), R(lr), R(cnt), R4(xer), R4(mq)
+  /* 66 */ R4(cnd), R(lr), R(cnt), R4(xer), R4(mq),
+  /* 71 */ R4(fpscr)
 };
 
 /* PowerPC UISA - a PPC processor as viewed by user-level code.  A UISA-only
@@ -2040,6 +2151,14 @@
   PPC_ALTIVEC_REGS
 };
 
+/* PowerPC UISA - a PPC processor as viewed by user-level
+   code, but without floating point registers.  */
+static const struct reg registers_powerpc_nofp[] =
+{
+  COMMON_UISA_NOFP_REGS,
+  PPC_UISA_SPRS
+};
+
 /* IBM PowerPC 403. */
 static const struct reg registers_403[] =
 {
@@ -2245,11 +2364,21 @@
   {"7400", "Motorola/IBM PowerPC 7400 (G4)", bfd_arch_powerpc,
    bfd_mach_ppc_7400, num_registers (registers_7400), registers_7400},
 
-  /* FIXME: I haven't checked the register sets of the following. */
+  /* 64-bit */
+  {"powerpc64", "PowerPC 64-bit user-level", bfd_arch_powerpc,
+   bfd_mach_ppc64, num_registers (registers_powerpc), registers_powerpc},
   {"620", "Motorola PowerPC 620", bfd_arch_powerpc,
    bfd_mach_ppc_620, num_registers (registers_powerpc), registers_powerpc},
+  {"630", "Motorola PowerPC 630", bfd_arch_powerpc,
+   bfd_mach_ppc_630, num_registers (registers_powerpc), registers_powerpc},
   {"a35", "PowerPC A35", bfd_arch_powerpc,
    bfd_mach_ppc_a35, num_registers (registers_powerpc), registers_powerpc},
+  {"rs64ii", "PowerPC rs64ii", bfd_arch_powerpc,
+   bfd_mach_ppc_rs64ii, num_registers (registers_powerpc), registers_powerpc},
+  {"rs64iii", "PowerPC rs64iii", bfd_arch_powerpc,
+   bfd_mach_ppc_rs64iii, num_registers (registers_powerpc), registers_powerpc},
+
+  /* FIXME: I haven't checked the register sets of the following. */
   {"rs1", "IBM POWER RS1", bfd_arch_rs6000,
    bfd_mach_rs6k_rs1, num_registers (registers_power), registers_power},
   {"rsc", "IBM POWER RSC", bfd_arch_rs6000,
@@ -2377,6 +2506,7 @@
   unsigned long mach;
   bfd abfd;
   int osabi, sysv_abi;
+  gdbarch_print_insn_ftype *print_insn;
 
   from_xcoff_exec = info.abfd && info.abfd->format == bfd_object &&
     bfd_get_flavour (info.abfd) == bfd_target_xcoff_flavour;
@@ -2392,7 +2522,7 @@
      that, else choose a likely default. */
   if (from_xcoff_exec)
     {
-      if (xcoff_data (info.abfd)->xcoff64)
+      if (bfd_xcoff_is_xcoff64 (info.abfd))
 	wordsize = 8;
       else
 	wordsize = 4;
@@ -2406,7 +2536,11 @@
     }
   else
     {
-      wordsize = 4;
+      if (info.bfd_arch_info != NULL && info.bfd_arch_info->bits_per_word != 0)
+	wordsize = info.bfd_arch_info->bits_per_word /
+	  info.bfd_arch_info->bits_per_byte;
+      else
+	wordsize = 4;
     }
 
   /* Find a candidate among extant architectures. */
@@ -2448,11 +2582,6 @@
   gdbarch = gdbarch_alloc (&info, tdep);
   power = arch == bfd_arch_rs6000;
 
-  /* Select instruction printer. */
-  tm_print_insn = arch == power ? print_insn_rs6000 :
-    info.byte_order == BFD_ENDIAN_BIG ? print_insn_big_powerpc :
-      print_insn_little_powerpc;
-
   /* Choose variant. */
   v = find_variant_by_arch (arch, mach);
   if (!v)
@@ -2470,8 +2599,11 @@
   tdep->ppc_xer_regnum = 69;
   if (v->mach == bfd_mach_ppc_601)
     tdep->ppc_mq_regnum = 124;
-  else
+  else if (power)
     tdep->ppc_mq_regnum = 70;
+  else
+    tdep->ppc_mq_regnum = -1;
+  tdep->ppc_fpscr_regnum = power ? 71 : 70;
 
   if (v->arch == bfd_arch_powerpc)
     switch (v->mach)
@@ -2490,7 +2622,15 @@
 	break;
       }   
 
-  /* Calculate byte offsets in raw register array. */
+  /* Set lr_frame_offset.  */
+  if (wordsize == 8)
+    tdep->lr_frame_offset = 16;
+  else if (sysv_abi)
+    tdep->lr_frame_offset = 4;
+  else
+    tdep->lr_frame_offset = 8;
+
+  /* Calculate byte offsets in raw register array.  */
   tdep->regoff = xmalloc (v->nregs * sizeof (int));
   for (i = off = 0; i < v->nregs; i++)
     {
@@ -2498,10 +2638,18 @@
       off += regsize (v->regs + i, wordsize);
     }
 
+  /* Select instruction printer.  */
+  if (arch == power)
+    print_insn = print_insn_rs6000;
+  else if (info.byte_order == BFD_ENDIAN_BIG)
+    print_insn = print_insn_big_powerpc;
+  else
+    print_insn = print_insn_little_powerpc;
+  set_gdbarch_print_insn (gdbarch, print_insn);
+
   set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
   set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
-  set_gdbarch_write_fp (gdbarch, generic_target_write_fp);
   set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
 
@@ -2514,9 +2662,9 @@
   set_gdbarch_register_bytes (gdbarch, off);
   set_gdbarch_register_byte (gdbarch, rs6000_register_byte);
   set_gdbarch_register_raw_size (gdbarch, rs6000_register_raw_size);
-  set_gdbarch_max_register_raw_size (gdbarch, 8);
+  set_gdbarch_max_register_raw_size (gdbarch, 16);
   set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size);
-  set_gdbarch_max_register_virtual_size (gdbarch, 8);
+  set_gdbarch_max_register_virtual_size (gdbarch, 16);
   set_gdbarch_register_virtual_type (gdbarch, rs6000_register_virtual_type);
   set_gdbarch_do_registers_info (gdbarch, rs6000_do_registers_info);
 
@@ -2555,7 +2703,14 @@
 
   set_gdbarch_extract_return_value (gdbarch, rs6000_extract_return_value);
   
-  if (sysv_abi)
+  /* Note: kevinb/2002-04-12: I'm not convinced that rs6000_push_arguments()
+     is correct for the SysV ABI when the wordsize is 8, but I'm also
+     fairly certain that ppc_sysv_abi_push_arguments() will give even
+     worse results since it only works for 32-bit code.  So, for the moment,
+     we're better off calling rs6000_push_arguments() since it works for
+     64-bit code.  At some point in the future, this matter needs to be
+     revisited.  */
+  if (sysv_abi && wordsize == 4)
     set_gdbarch_push_arguments (gdbarch, ppc_sysv_abi_push_arguments);
   else
     set_gdbarch_push_arguments (gdbarch, rs6000_push_arguments);
@@ -2563,8 +2718,6 @@
   set_gdbarch_store_struct_return (gdbarch, rs6000_store_struct_return);
   set_gdbarch_store_return_value (gdbarch, rs6000_store_return_value);
   set_gdbarch_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address);
-  set_gdbarch_use_struct_convention (gdbarch, generic_use_struct_convention);
-
   set_gdbarch_pop_frame (gdbarch, rs6000_pop_frame);
 
   set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue);
@@ -2576,8 +2729,31 @@
   /* Not sure on this. FIXMEmgo */
   set_gdbarch_frame_args_skip (gdbarch, 8);
 
+  /* Until November 2001, gcc was not complying to the SYSV ABI for
+     returning structures less than or equal to 8 bytes in size. It was
+     returning everything in memory. When this was corrected, it wasn't
+     fixed for native platforms. */
+  if (sysv_abi)
+    {
+      if (osabi == ELFOSABI_LINUX
+          || osabi == ELFOSABI_NETBSD
+          || osabi == ELFOSABI_FREEBSD)
+	set_gdbarch_use_struct_convention (gdbarch,
+					   ppc_sysv_abi_broken_use_struct_convention);
+      else
+	set_gdbarch_use_struct_convention (gdbarch,
+					   ppc_sysv_abi_use_struct_convention);
+    }
+  else
+    {
+      set_gdbarch_use_struct_convention (gdbarch,
+					 generic_use_struct_convention);
+    }
+
   set_gdbarch_frame_chain_valid (gdbarch, file_frame_chain_valid);
-  if (osabi == ELFOSABI_LINUX)
+  /* Note: kevinb/2002-04-12: See note above regarding *_push_arguments().
+     The same remarks hold for the methods below.  */
+  if (osabi == ELFOSABI_LINUX && wordsize == 4)
     {
       set_gdbarch_frameless_function_invocation (gdbarch,
 	ppc_linux_frameless_function_invocation);
@@ -2603,8 +2779,11 @@
 
       set_gdbarch_frame_init_saved_regs (gdbarch, rs6000_frame_init_saved_regs);
       set_gdbarch_init_extra_frame_info (gdbarch, rs6000_init_extra_frame_info);
-
-      /* Handle RS/6000 function pointers.  */
+    }
+  if (!sysv_abi)
+    {
+      /* Handle RS/6000 function pointers (which are really function
+         descriptors).  */
       set_gdbarch_convert_from_func_ptr_addr (gdbarch,
 	rs6000_convert_from_func_ptr_addr);
     }
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 3f02e2a..c69aca6 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1009,9 +1009,7 @@
 {
   CORE_ADDR prev_fp = 0;
 
-  if (thisframe->prev && thisframe->prev->frame)
-    prev_fp = thisframe->prev->frame;
-  else if (generic_find_dummy_frame (thisframe->pc, thisframe->frame))
+  if (generic_find_dummy_frame (thisframe->pc, thisframe->frame))
     return generic_read_register_dummy (thisframe->pc, thisframe->frame,
                                         S390_SP_REGNUM);
   else
@@ -1212,13 +1210,6 @@
 }
 
 
-void
-s390_write_fp (CORE_ADDR val)
-{
-  write_register (s390_fp_regnum (), val);
-}
-
-
 static void
 s390_pop_frame_regular (struct frame_info *frame)
 {
@@ -1707,7 +1698,7 @@
 
 
 
-static unsigned char *
+const static unsigned char *
 s390_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] = { 0x0, 0x1 };
@@ -1801,7 +1792,6 @@
   set_gdbarch_init_extra_frame_info (gdbarch, s390_init_extra_frame_info);
   set_gdbarch_init_frame_pc_first (gdbarch, s390_init_frame_pc_first);
   set_gdbarch_read_fp (gdbarch, s390_read_fp);
-  set_gdbarch_write_fp (gdbarch, s390_write_fp);
   /* This function that tells us whether the function invocation represented
      by FI does not have a frame on the stack associated with it.  If it
      does not, FRAMELESS is set to 1, else 0.  */
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 30ca763..00d6797 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -180,7 +180,7 @@
 		       (struct symtab **) NULL);
   if (sym)
     return value_of_variable (sym, NULL);
-  error ("No symbol \"%s\" in current context.");
+  error ("No symbol \"%s\" in current context.", str);
 }
 
 struct value *
diff --git a/gdb/ser-unix.h b/gdb/ser-unix.h
index 861694f..f7be059 100644
--- a/gdb/ser-unix.h
+++ b/gdb/ser-unix.h
@@ -1,5 +1,6 @@
 /* Serial interface for UN*X file-descriptor based connection.
-   Copyright 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,9 +22,6 @@
 #ifndef SER_UNIX_H
 #define SER_UNIX_H
 
-#undef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-
 /* Generic UNIX/FD functions */
 
 extern int ser_unix_nop_flush_output (struct serial *scb);
diff --git a/gdb/serial.c b/gdb/serial.c
index 22964eb..ada5631 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -1,7 +1,7 @@
 /* Generic serial interface routines
 
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -58,9 +58,6 @@
 static const char *logbase_enums[] =
 {logbase_hex, logbase_octal, logbase_ascii, NULL};
 static const char *serial_logbase = logbase_ascii;
-
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 
 
 static int serial_current_type = 0;
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 3f7bc6a..996e611 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -43,9 +43,6 @@
 
 #include "solib-svr4.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 void (*sh_show_regs) (void);
 CORE_ADDR (*skip_prologue_hard_way) (CORE_ADDR);
 void (*do_pseudo_register) (int);
@@ -484,7 +481,7 @@
 static void
 sh_nofp_frame_init_saved_regs (struct frame_info *fi)
 {
-  int where[NUM_REGS + NUM_PSEUDO_REGS];
+  int *where = (int *) alloca (NUM_REGS + NUM_PSEUDO_REGS);
   int rn;
   int have_fp = 0;
   int depth;
@@ -626,7 +623,7 @@
 static void
 sh_fp_frame_init_saved_regs (struct frame_info *fi)
 {
-  int where[NUM_REGS + NUM_PSEUDO_REGS];
+  int *where = (int *) alloca (NUM_REGS + NUM_PSEUDO_REGS);
   int rn;
   int have_fp = 0;
   int depth;
@@ -1735,7 +1732,7 @@
   raw_buffer = (char *) alloca (REGISTER_RAW_SIZE (FP0_REGNUM));
 
   /* Get the data in raw format.  */
-  if (read_relative_register_raw_bytes (regnum, raw_buffer))
+  if (!frame_register_read (selected_frame, regnum, raw_buffer))
     error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum));
 
   /* Get the register as a number */ 
@@ -1772,7 +1769,7 @@
   print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), gdb_stdout);
 
   /* Get the data in raw format.  */
-  if (read_relative_register_raw_bytes (regnum, raw_buffer))
+  if (!frame_register_read (selected_frame, regnum, raw_buffer))
     printf_filtered ("*value not available*\n");
       
   val_print (REGISTER_VIRTUAL_TYPE (regnum), raw_buffer, 0, 0,
@@ -2122,7 +2119,6 @@
   set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
   set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
-  set_gdbarch_write_fp (gdbarch, generic_target_write_fp);
   set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
 
diff --git a/gdb/signals.c b/gdb/signals.c
deleted file mode 100644
index d37ec06..0000000
--- a/gdb/signals.c
+++ /dev/null
@@ -1,837 +0,0 @@
-/* Target signal translation functions for GDB.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001 Free Software Foundation, Inc.
-   Contributed by Cygnus Support.
-
-   This file is part of GDB.
-
-   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 "defs.h"
-#include "target.h"
-#include <signal.h>
-
-/* This table must match in order and size the signals in enum target_signal
-   in target.h.  */
-/* *INDENT-OFF* */
-static struct {
-  char *name;
-  char *string;
-  } signals [] =
-{
-  {"0", "Signal 0"},
-  {"SIGHUP", "Hangup"},
-  {"SIGINT", "Interrupt"},
-  {"SIGQUIT", "Quit"},
-  {"SIGILL", "Illegal instruction"},
-  {"SIGTRAP", "Trace/breakpoint trap"},
-  {"SIGABRT", "Aborted"},
-  {"SIGEMT", "Emulation trap"},
-  {"SIGFPE", "Arithmetic exception"},
-  {"SIGKILL", "Killed"},
-  {"SIGBUS", "Bus error"},
-  {"SIGSEGV", "Segmentation fault"},
-  {"SIGSYS", "Bad system call"},
-  {"SIGPIPE", "Broken pipe"},
-  {"SIGALRM", "Alarm clock"},
-  {"SIGTERM", "Terminated"},
-  {"SIGURG", "Urgent I/O condition"},
-  {"SIGSTOP", "Stopped (signal)"},
-  {"SIGTSTP", "Stopped (user)"},
-  {"SIGCONT", "Continued"},
-  {"SIGCHLD", "Child status changed"},
-  {"SIGTTIN", "Stopped (tty input)"},
-  {"SIGTTOU", "Stopped (tty output)"},
-  {"SIGIO", "I/O possible"},
-  {"SIGXCPU", "CPU time limit exceeded"},
-  {"SIGXFSZ", "File size limit exceeded"},
-  {"SIGVTALRM", "Virtual timer expired"},
-  {"SIGPROF", "Profiling timer expired"},
-  {"SIGWINCH", "Window size changed"},
-  {"SIGLOST", "Resource lost"},
-  {"SIGUSR1", "User defined signal 1"},
-  {"SIGUSR2", "User defined signal 2"},
-  {"SIGPWR", "Power fail/restart"},
-  {"SIGPOLL", "Pollable event occurred"},
-  {"SIGWIND", "SIGWIND"},
-  {"SIGPHONE", "SIGPHONE"},
-  {"SIGWAITING", "Process's LWPs are blocked"},
-  {"SIGLWP", "Signal LWP"},
-  {"SIGDANGER", "Swap space dangerously low"},
-  {"SIGGRANT", "Monitor mode granted"},
-  {"SIGRETRACT", "Need to relinquish monitor mode"},
-  {"SIGMSG", "Monitor mode data available"},
-  {"SIGSOUND", "Sound completed"},
-  {"SIGSAK", "Secure attention"},
-  {"SIGPRIO", "SIGPRIO"},
-  {"SIG33", "Real-time event 33"},
-  {"SIG34", "Real-time event 34"},
-  {"SIG35", "Real-time event 35"},
-  {"SIG36", "Real-time event 36"},
-  {"SIG37", "Real-time event 37"},
-  {"SIG38", "Real-time event 38"},
-  {"SIG39", "Real-time event 39"},
-  {"SIG40", "Real-time event 40"},
-  {"SIG41", "Real-time event 41"},
-  {"SIG42", "Real-time event 42"},
-  {"SIG43", "Real-time event 43"},
-  {"SIG44", "Real-time event 44"},
-  {"SIG45", "Real-time event 45"},
-  {"SIG46", "Real-time event 46"},
-  {"SIG47", "Real-time event 47"},
-  {"SIG48", "Real-time event 48"},
-  {"SIG49", "Real-time event 49"},
-  {"SIG50", "Real-time event 50"},
-  {"SIG51", "Real-time event 51"},
-  {"SIG52", "Real-time event 52"},
-  {"SIG53", "Real-time event 53"},
-  {"SIG54", "Real-time event 54"},
-  {"SIG55", "Real-time event 55"},
-  {"SIG56", "Real-time event 56"},
-  {"SIG57", "Real-time event 57"},
-  {"SIG58", "Real-time event 58"},
-  {"SIG59", "Real-time event 59"},
-  {"SIG60", "Real-time event 60"},
-  {"SIG61", "Real-time event 61"},
-  {"SIG62", "Real-time event 62"},
-  {"SIG63", "Real-time event 63"},
-  {"SIGCANCEL", "LWP internal signal"},
-  {"SIG32", "Real-time event 32"},
-  {"SIG64", "Real-time event 64"},
-  {"SIG65", "Real-time event 65"},
-  {"SIG66", "Real-time event 66"},
-  {"SIG67", "Real-time event 67"},
-  {"SIG68", "Real-time event 68"},
-  {"SIG69", "Real-time event 69"},
-  {"SIG70", "Real-time event 70"},
-  {"SIG71", "Real-time event 71"},
-  {"SIG72", "Real-time event 72"},
-  {"SIG73", "Real-time event 73"},
-  {"SIG74", "Real-time event 74"},
-  {"SIG75", "Real-time event 75"},
-  {"SIG76", "Real-time event 76"},
-  {"SIG77", "Real-time event 77"},
-  {"SIG78", "Real-time event 78"},
-  {"SIG79", "Real-time event 79"},
-  {"SIG80", "Real-time event 80"},
-  {"SIG81", "Real-time event 81"},
-  {"SIG82", "Real-time event 82"},
-  {"SIG83", "Real-time event 83"},
-  {"SIG84", "Real-time event 84"},
-  {"SIG85", "Real-time event 85"},
-  {"SIG86", "Real-time event 86"},
-  {"SIG87", "Real-time event 87"},
-  {"SIG88", "Real-time event 88"},
-  {"SIG89", "Real-time event 89"},
-  {"SIG90", "Real-time event 90"},
-  {"SIG91", "Real-time event 91"},
-  {"SIG92", "Real-time event 92"},
-  {"SIG93", "Real-time event 93"},
-  {"SIG94", "Real-time event 94"},
-  {"SIG95", "Real-time event 95"},
-  {"SIG96", "Real-time event 96"},
-  {"SIG97", "Real-time event 97"},
-  {"SIG98", "Real-time event 98"},
-  {"SIG99", "Real-time event 99"},
-  {"SIG100", "Real-time event 100"},
-  {"SIG101", "Real-time event 101"},
-  {"SIG102", "Real-time event 102"},
-  {"SIG103", "Real-time event 103"},
-  {"SIG104", "Real-time event 104"},
-  {"SIG105", "Real-time event 105"},
-  {"SIG106", "Real-time event 106"},
-  {"SIG107", "Real-time event 107"},
-  {"SIG108", "Real-time event 108"},
-  {"SIG109", "Real-time event 109"},
-  {"SIG110", "Real-time event 110"},
-  {"SIG111", "Real-time event 111"},
-  {"SIG112", "Real-time event 112"},
-  {"SIG113", "Real-time event 113"},
-  {"SIG114", "Real-time event 114"},
-  {"SIG115", "Real-time event 115"},
-  {"SIG116", "Real-time event 116"},
-  {"SIG117", "Real-time event 117"},
-  {"SIG118", "Real-time event 118"},
-  {"SIG119", "Real-time event 119"},
-  {"SIG120", "Real-time event 120"},
-  {"SIG121", "Real-time event 121"},
-  {"SIG122", "Real-time event 122"},
-  {"SIG123", "Real-time event 123"},
-  {"SIG124", "Real-time event 124"},
-  {"SIG125", "Real-time event 125"},
-  {"SIG126", "Real-time event 126"},
-  {"SIG127", "Real-time event 127"},
-
-#if defined(MACH) || defined(__MACH__)
-  /* Mach exceptions */
-  {"EXC_BAD_ACCESS", "Could not access memory"},
-  {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
-  {"EXC_ARITHMETIC", "Arithmetic exception"},
-  {"EXC_EMULATION", "Emulation instruction"},
-  {"EXC_SOFTWARE", "Software generated exception"},
-  {"EXC_BREAKPOINT", "Breakpoint"},
-#endif
-  {"SIGINFO", "Information request"},
-
-  {NULL, "Unknown signal"},
-  {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
-
-  /* Last entry, used to check whether the table is the right size.  */
-  {NULL, "TARGET_SIGNAL_MAGIC"}
-};
-/* *INDENT-ON* */
-
-
-
-/* Return the string for a signal.  */
-char *
-target_signal_to_string (enum target_signal sig)
-{
-  if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
-    return signals[sig].string;
-  else
-    return signals[TARGET_SIGNAL_UNKNOWN].string;
-}
-
-/* Return the name for a signal.  */
-char *
-target_signal_to_name (enum target_signal sig)
-{
-  if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST)
-      && signals[sig].name != NULL)
-    return signals[sig].name;
-  else
-    /* I think the code which prints this will always print it along
-       with the string, so no need to be verbose (very old comment).  */
-    return "?";
-}
-
-/* Given a name, return its signal.  */
-enum target_signal
-target_signal_from_name (char *name)
-{
-  enum target_signal sig;
-
-  /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
-     for TARGET_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
-     questionable; seems like by now people should call it SIGABRT
-     instead.  */
-
-  /* This ugly cast brought to you by the native VAX compiler.  */
-  for (sig = TARGET_SIGNAL_HUP;
-       signals[sig].name != NULL;
-       sig = (enum target_signal) ((int) sig + 1))
-    if (STREQ (name, signals[sig].name))
-      return sig;
-  return TARGET_SIGNAL_UNKNOWN;
-}
-
-/* The following functions are to help certain targets deal
-   with the signal/waitstatus stuff.  They could just as well be in
-   a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
-
-/* Convert host signal to our signals.  */
-enum target_signal
-target_signal_from_host (int hostsig)
-{
-  /* A switch statement would make sense but would require special kludges
-     to deal with the cases where more than one signal has the same number.  */
-
-  if (hostsig == 0)
-    return TARGET_SIGNAL_0;
-
-#if defined (SIGHUP)
-  if (hostsig == SIGHUP)
-    return TARGET_SIGNAL_HUP;
-#endif
-#if defined (SIGINT)
-  if (hostsig == SIGINT)
-    return TARGET_SIGNAL_INT;
-#endif
-#if defined (SIGQUIT)
-  if (hostsig == SIGQUIT)
-    return TARGET_SIGNAL_QUIT;
-#endif
-#if defined (SIGILL)
-  if (hostsig == SIGILL)
-    return TARGET_SIGNAL_ILL;
-#endif
-#if defined (SIGTRAP)
-  if (hostsig == SIGTRAP)
-    return TARGET_SIGNAL_TRAP;
-#endif
-#if defined (SIGABRT)
-  if (hostsig == SIGABRT)
-    return TARGET_SIGNAL_ABRT;
-#endif
-#if defined (SIGEMT)
-  if (hostsig == SIGEMT)
-    return TARGET_SIGNAL_EMT;
-#endif
-#if defined (SIGFPE)
-  if (hostsig == SIGFPE)
-    return TARGET_SIGNAL_FPE;
-#endif
-#if defined (SIGKILL)
-  if (hostsig == SIGKILL)
-    return TARGET_SIGNAL_KILL;
-#endif
-#if defined (SIGBUS)
-  if (hostsig == SIGBUS)
-    return TARGET_SIGNAL_BUS;
-#endif
-#if defined (SIGSEGV)
-  if (hostsig == SIGSEGV)
-    return TARGET_SIGNAL_SEGV;
-#endif
-#if defined (SIGSYS)
-  if (hostsig == SIGSYS)
-    return TARGET_SIGNAL_SYS;
-#endif
-#if defined (SIGPIPE)
-  if (hostsig == SIGPIPE)
-    return TARGET_SIGNAL_PIPE;
-#endif
-#if defined (SIGALRM)
-  if (hostsig == SIGALRM)
-    return TARGET_SIGNAL_ALRM;
-#endif
-#if defined (SIGTERM)
-  if (hostsig == SIGTERM)
-    return TARGET_SIGNAL_TERM;
-#endif
-#if defined (SIGUSR1)
-  if (hostsig == SIGUSR1)
-    return TARGET_SIGNAL_USR1;
-#endif
-#if defined (SIGUSR2)
-  if (hostsig == SIGUSR2)
-    return TARGET_SIGNAL_USR2;
-#endif
-#if defined (SIGCLD)
-  if (hostsig == SIGCLD)
-    return TARGET_SIGNAL_CHLD;
-#endif
-#if defined (SIGCHLD)
-  if (hostsig == SIGCHLD)
-    return TARGET_SIGNAL_CHLD;
-#endif
-#if defined (SIGPWR)
-  if (hostsig == SIGPWR)
-    return TARGET_SIGNAL_PWR;
-#endif
-#if defined (SIGWINCH)
-  if (hostsig == SIGWINCH)
-    return TARGET_SIGNAL_WINCH;
-#endif
-#if defined (SIGURG)
-  if (hostsig == SIGURG)
-    return TARGET_SIGNAL_URG;
-#endif
-#if defined (SIGIO)
-  if (hostsig == SIGIO)
-    return TARGET_SIGNAL_IO;
-#endif
-#if defined (SIGPOLL)
-  if (hostsig == SIGPOLL)
-    return TARGET_SIGNAL_POLL;
-#endif
-#if defined (SIGSTOP)
-  if (hostsig == SIGSTOP)
-    return TARGET_SIGNAL_STOP;
-#endif
-#if defined (SIGTSTP)
-  if (hostsig == SIGTSTP)
-    return TARGET_SIGNAL_TSTP;
-#endif
-#if defined (SIGCONT)
-  if (hostsig == SIGCONT)
-    return TARGET_SIGNAL_CONT;
-#endif
-#if defined (SIGTTIN)
-  if (hostsig == SIGTTIN)
-    return TARGET_SIGNAL_TTIN;
-#endif
-#if defined (SIGTTOU)
-  if (hostsig == SIGTTOU)
-    return TARGET_SIGNAL_TTOU;
-#endif
-#if defined (SIGVTALRM)
-  if (hostsig == SIGVTALRM)
-    return TARGET_SIGNAL_VTALRM;
-#endif
-#if defined (SIGPROF)
-  if (hostsig == SIGPROF)
-    return TARGET_SIGNAL_PROF;
-#endif
-#if defined (SIGXCPU)
-  if (hostsig == SIGXCPU)
-    return TARGET_SIGNAL_XCPU;
-#endif
-#if defined (SIGXFSZ)
-  if (hostsig == SIGXFSZ)
-    return TARGET_SIGNAL_XFSZ;
-#endif
-#if defined (SIGWIND)
-  if (hostsig == SIGWIND)
-    return TARGET_SIGNAL_WIND;
-#endif
-#if defined (SIGPHONE)
-  if (hostsig == SIGPHONE)
-    return TARGET_SIGNAL_PHONE;
-#endif
-#if defined (SIGLOST)
-  if (hostsig == SIGLOST)
-    return TARGET_SIGNAL_LOST;
-#endif
-#if defined (SIGWAITING)
-  if (hostsig == SIGWAITING)
-    return TARGET_SIGNAL_WAITING;
-#endif
-#if defined (SIGCANCEL)
-  if (hostsig == SIGCANCEL)
-    return TARGET_SIGNAL_CANCEL;
-#endif
-#if defined (SIGLWP)
-  if (hostsig == SIGLWP)
-    return TARGET_SIGNAL_LWP;
-#endif
-#if defined (SIGDANGER)
-  if (hostsig == SIGDANGER)
-    return TARGET_SIGNAL_DANGER;
-#endif
-#if defined (SIGGRANT)
-  if (hostsig == SIGGRANT)
-    return TARGET_SIGNAL_GRANT;
-#endif
-#if defined (SIGRETRACT)
-  if (hostsig == SIGRETRACT)
-    return TARGET_SIGNAL_RETRACT;
-#endif
-#if defined (SIGMSG)
-  if (hostsig == SIGMSG)
-    return TARGET_SIGNAL_MSG;
-#endif
-#if defined (SIGSOUND)
-  if (hostsig == SIGSOUND)
-    return TARGET_SIGNAL_SOUND;
-#endif
-#if defined (SIGSAK)
-  if (hostsig == SIGSAK)
-    return TARGET_SIGNAL_SAK;
-#endif
-#if defined (SIGPRIO)
-  if (hostsig == SIGPRIO)
-    return TARGET_SIGNAL_PRIO;
-#endif
-
-  /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_BAD_ACCESS)
-    return TARGET_EXC_BAD_ACCESS;
-#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
-    return TARGET_EXC_BAD_INSTRUCTION;
-#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_ARITHMETIC)
-    return TARGET_EXC_ARITHMETIC;
-#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_EMULATION)
-    return TARGET_EXC_EMULATION;
-#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_SOFTWARE)
-    return TARGET_EXC_SOFTWARE;
-#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
-  if (hostsig == _NSIG + EXC_BREAKPOINT)
-    return TARGET_EXC_BREAKPOINT;
-#endif
-
-#if defined (SIGINFO)
-  if (hostsig == SIGINFO)
-    return TARGET_SIGNAL_INFO;
-#endif
-
-#if defined (REALTIME_LO)
-  if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
-    {
-      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
-      if (33 <= hostsig && hostsig <= 63)
-	return (enum target_signal)
-	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
-      else if (hostsig == 32)
-	return TARGET_SIGNAL_REALTIME_32;
-      else if (64 <= hostsig && hostsig <= 127)
-	return (enum target_signal)
-	  (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
-      else
-	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
-    }
-#endif
-
-#if defined (SIGRTMIN)
-  if (hostsig >= SIGRTMIN && hostsig <= SIGRTMAX)
-    {
-      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
-      if (33 <= hostsig && hostsig <= 63)
-	return (enum target_signal)
-	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
-      else if (hostsig == 64)
-	return TARGET_SIGNAL_REALTIME_64;
-      else
-	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
-    }
-#endif
-  return TARGET_SIGNAL_UNKNOWN;
-}
-
-/* Convert a OURSIG (an enum target_signal) to the form used by the
-   target operating system (refered to as the ``host'') or zero if the
-   equivalent host signal is not available.  Set/clear OURSIG_OK
-   accordingly. */
-
-static int
-do_target_signal_to_host (enum target_signal oursig,
-			  int *oursig_ok)
-{
-  *oursig_ok = 1;
-  switch (oursig)
-    {
-    case TARGET_SIGNAL_0:
-      return 0;
-
-#if defined (SIGHUP)
-    case TARGET_SIGNAL_HUP:
-      return SIGHUP;
-#endif
-#if defined (SIGINT)
-    case TARGET_SIGNAL_INT:
-      return SIGINT;
-#endif
-#if defined (SIGQUIT)
-    case TARGET_SIGNAL_QUIT:
-      return SIGQUIT;
-#endif
-#if defined (SIGILL)
-    case TARGET_SIGNAL_ILL:
-      return SIGILL;
-#endif
-#if defined (SIGTRAP)
-    case TARGET_SIGNAL_TRAP:
-      return SIGTRAP;
-#endif
-#if defined (SIGABRT)
-    case TARGET_SIGNAL_ABRT:
-      return SIGABRT;
-#endif
-#if defined (SIGEMT)
-    case TARGET_SIGNAL_EMT:
-      return SIGEMT;
-#endif
-#if defined (SIGFPE)
-    case TARGET_SIGNAL_FPE:
-      return SIGFPE;
-#endif
-#if defined (SIGKILL)
-    case TARGET_SIGNAL_KILL:
-      return SIGKILL;
-#endif
-#if defined (SIGBUS)
-    case TARGET_SIGNAL_BUS:
-      return SIGBUS;
-#endif
-#if defined (SIGSEGV)
-    case TARGET_SIGNAL_SEGV:
-      return SIGSEGV;
-#endif
-#if defined (SIGSYS)
-    case TARGET_SIGNAL_SYS:
-      return SIGSYS;
-#endif
-#if defined (SIGPIPE)
-    case TARGET_SIGNAL_PIPE:
-      return SIGPIPE;
-#endif
-#if defined (SIGALRM)
-    case TARGET_SIGNAL_ALRM:
-      return SIGALRM;
-#endif
-#if defined (SIGTERM)
-    case TARGET_SIGNAL_TERM:
-      return SIGTERM;
-#endif
-#if defined (SIGUSR1)
-    case TARGET_SIGNAL_USR1:
-      return SIGUSR1;
-#endif
-#if defined (SIGUSR2)
-    case TARGET_SIGNAL_USR2:
-      return SIGUSR2;
-#endif
-#if defined (SIGCHLD) || defined (SIGCLD)
-    case TARGET_SIGNAL_CHLD:
-#if defined (SIGCHLD)
-      return SIGCHLD;
-#else
-      return SIGCLD;
-#endif
-#endif /* SIGCLD or SIGCHLD */
-#if defined (SIGPWR)
-    case TARGET_SIGNAL_PWR:
-      return SIGPWR;
-#endif
-#if defined (SIGWINCH)
-    case TARGET_SIGNAL_WINCH:
-      return SIGWINCH;
-#endif
-#if defined (SIGURG)
-    case TARGET_SIGNAL_URG:
-      return SIGURG;
-#endif
-#if defined (SIGIO)
-    case TARGET_SIGNAL_IO:
-      return SIGIO;
-#endif
-#if defined (SIGPOLL)
-    case TARGET_SIGNAL_POLL:
-      return SIGPOLL;
-#endif
-#if defined (SIGSTOP)
-    case TARGET_SIGNAL_STOP:
-      return SIGSTOP;
-#endif
-#if defined (SIGTSTP)
-    case TARGET_SIGNAL_TSTP:
-      return SIGTSTP;
-#endif
-#if defined (SIGCONT)
-    case TARGET_SIGNAL_CONT:
-      return SIGCONT;
-#endif
-#if defined (SIGTTIN)
-    case TARGET_SIGNAL_TTIN:
-      return SIGTTIN;
-#endif
-#if defined (SIGTTOU)
-    case TARGET_SIGNAL_TTOU:
-      return SIGTTOU;
-#endif
-#if defined (SIGVTALRM)
-    case TARGET_SIGNAL_VTALRM:
-      return SIGVTALRM;
-#endif
-#if defined (SIGPROF)
-    case TARGET_SIGNAL_PROF:
-      return SIGPROF;
-#endif
-#if defined (SIGXCPU)
-    case TARGET_SIGNAL_XCPU:
-      return SIGXCPU;
-#endif
-#if defined (SIGXFSZ)
-    case TARGET_SIGNAL_XFSZ:
-      return SIGXFSZ;
-#endif
-#if defined (SIGWIND)
-    case TARGET_SIGNAL_WIND:
-      return SIGWIND;
-#endif
-#if defined (SIGPHONE)
-    case TARGET_SIGNAL_PHONE:
-      return SIGPHONE;
-#endif
-#if defined (SIGLOST)
-    case TARGET_SIGNAL_LOST:
-      return SIGLOST;
-#endif
-#if defined (SIGWAITING)
-    case TARGET_SIGNAL_WAITING:
-      return SIGWAITING;
-#endif
-#if defined (SIGCANCEL)
-    case TARGET_SIGNAL_CANCEL:
-      return SIGCANCEL;
-#endif
-#if defined (SIGLWP)
-    case TARGET_SIGNAL_LWP:
-      return SIGLWP;
-#endif
-#if defined (SIGDANGER)
-    case TARGET_SIGNAL_DANGER:
-      return SIGDANGER;
-#endif
-#if defined (SIGGRANT)
-    case TARGET_SIGNAL_GRANT:
-      return SIGGRANT;
-#endif
-#if defined (SIGRETRACT)
-    case TARGET_SIGNAL_RETRACT:
-      return SIGRETRACT;
-#endif
-#if defined (SIGMSG)
-    case TARGET_SIGNAL_MSG:
-      return SIGMSG;
-#endif
-#if defined (SIGSOUND)
-    case TARGET_SIGNAL_SOUND:
-      return SIGSOUND;
-#endif
-#if defined (SIGSAK)
-    case TARGET_SIGNAL_SAK:
-      return SIGSAK;
-#endif
-#if defined (SIGPRIO)
-    case TARGET_SIGNAL_PRIO:
-      return SIGPRIO;
-#endif
-
-      /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
-    case TARGET_EXC_BAD_ACCESS:
-      return _NSIG + EXC_BAD_ACCESS;
-#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
-    case TARGET_EXC_BAD_INSTRUCTION:
-      return _NSIG + EXC_BAD_INSTRUCTION;
-#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
-    case TARGET_EXC_ARITHMETIC:
-      return _NSIG + EXC_ARITHMETIC;
-#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
-    case TARGET_EXC_EMULATION:
-      return _NSIG + EXC_EMULATION;
-#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
-    case TARGET_EXC_SOFTWARE:
-      return _NSIG + EXC_SOFTWARE;
-#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
-    case TARGET_EXC_BREAKPOINT:
-      return _NSIG + EXC_BREAKPOINT;
-#endif
-
-#if defined (SIGINFO)
-    case TARGET_SIGNAL_INFO:
-      return SIGINFO;
-#endif
-
-    default:
-#if defined (REALTIME_LO)
-      if (oursig >= TARGET_SIGNAL_REALTIME_33
-	  && oursig <= TARGET_SIGNAL_REALTIME_63)
-	{
-	  /* This block of signals is continuous, and
-             TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
-	  int retsig =
-	    (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
-	  if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
-	    return retsig;
-	}
-#if (REALTIME_LO < 33)
-      else if (oursig == TARGET_SIGNAL_REALTIME_32)
-	{
-	  /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
-             TARGET_SIGNAL_REALTIME_33.  It is 32 by definition.  */
-	  return 32;
-	}
-#endif
-#if (REALTIME_HI > 64)
-      if (oursig >= TARGET_SIGNAL_REALTIME_64
-	  && oursig <= TARGET_SIGNAL_REALTIME_127)
-	{
-	  /* This block of signals is continuous, and
-             TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
-	  int retsig =
-	    (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
-	  if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
-	    return retsig;
-	}
-      
-#endif
-#endif
-
-#if defined (SIGRTMIN)
-      if (oursig >= TARGET_SIGNAL_REALTIME_33
-	  && oursig <= TARGET_SIGNAL_REALTIME_63)
-	{
-	  /* This block of signals is continuous, and
-             TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
-	  int retsig =
-	    (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
-	  if (retsig >= SIGRTMIN && retsig <= SIGRTMAX)
-	    return retsig;
-	}
-      else if (oursig == TARGET_SIGNAL_REALTIME_64)
-	return 64;
-#endif
-      *oursig_ok = 0;
-      return 0;
-    }
-}
-
-int
-target_signal_to_host_p (enum target_signal oursig)
-{
-  int oursig_ok;
-  do_target_signal_to_host (oursig, &oursig_ok);
-  return oursig_ok;
-}
-
-int
-target_signal_to_host (enum target_signal oursig)
-{
-  int oursig_ok;
-  int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
-  if (!oursig_ok)
-    {
-      /* The user might be trying to do "signal SIGSAK" where this system
-         doesn't have SIGSAK.  */
-      warning ("Signal %s does not exist on this system.\n",
-	       target_signal_to_name (oursig));
-      return 0;
-    }
-  else
-    return targ_signo;
-}
-
-/* In some circumstances we allow a command to specify a numeric
-   signal.  The idea is to keep these circumstances limited so that
-   users (and scripts) develop portable habits.  For comparison,
-   POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
-   numeric signal at all is obsolescent.  We are slightly more
-   lenient and allow 1-15 which should match host signal numbers on
-   most systems.  Use of symbolic signal names is strongly encouraged.  */
-
-enum target_signal
-target_signal_from_command (int num)
-{
-  if (num >= 1 && num <= 15)
-    return (enum target_signal) num;
-  error ("Only signals 1-15 are valid as numeric signals.\n\
-Use \"info signals\" for a list of symbolic signals.");
-}
-
-void
-_initialize_signals (void)
-{
-  if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
-    internal_error (__FILE__, __LINE__, "failed internal consistency check");
-}
diff --git a/gdb/solib-legacy.c b/gdb/solib-legacy.c
index ca730c4..2dd9fa5 100644
--- a/gdb/solib-legacy.c
+++ b/gdb/solib-legacy.c
@@ -19,7 +19,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#define _SYSCALL32	/* for Sparc64 cross Sparc32 */
 #include "defs.h"
 #include "gdbcore.h"
 #include "solib-svr4.h"
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 9c71509..1a7ffbf 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -92,6 +92,7 @@
   SOLIB_BKPT_NAME,		/* Prefer configured name if it exists. */
 #endif
   "_start",
+  "__start",
   "main",
   NULL
 };
diff --git a/gdb/solib.c b/gdb/solib.c
index c47c438..0c7eaba 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -872,7 +872,7 @@
 For other (relative) files, you can add values using `set solib-search-path'.",
 		   &setlist);
   add_show_from_set (c, &showlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_set_cmd ("solib-search-path", class_support, var_string,
 		   (char *) &solib_search_path,
@@ -880,5 +880,5 @@
 This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.",
 		   &setlist);
   add_show_from_set (c, &showlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 }
diff --git a/gdb/somread.c b/gdb/somread.c
index e4fec18..38e35b2 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -117,20 +117,13 @@
      can do the right thing for ST_ENTRY vs ST_CODE symbols).
 
      There's nothing in the header which easily allows us to do
-     this.  The only reliable way I know of is to check for the
-     existence of a $SHLIB_INFO$ section with a non-zero size.  */
-  /* The code below is not a reliable way to check whether an
-   * executable is dynamic, so I commented it out - RT
-   * shlib_info = bfd_get_section_by_name (objfile->obfd, "$SHLIB_INFO$");
-   * if (shlib_info)
-   *   dynamic = (bfd_section_size (objfile->obfd, shlib_info) != 0);
-   * else
-   *   dynamic = 0;
-   */
-  /* I replaced the code with a simple check for text offset not being
-   * zero. Still not 100% reliable, but a more reliable way of asking
-   * "is this a dynamic executable?" than the above. RT
-   */
+     this.
+
+     This code used to rely upon the existence of a $SHLIB_INFO$
+     section to make this determination.  HP claims that it is
+     more accurate to check for a nonzero text offset, but they
+     have not provided any information about why that test is
+     more accurate.  */
   dynamic = (text_offset != 0);
 
   endbufp = buf + number_of_symbols;
@@ -240,13 +233,11 @@
 
 	    case ST_ENTRY:
 	      symname = bufp->name.n_strx + stringtab;
-	      /* For a dynamic executable, ST_ENTRY symbols are
-	         the stubs, while the ST_CODE symbol is the real
-	         function.  */
-	      if (dynamic)
-		ms_type = mst_solib_trampoline;
-	      else
-		ms_type = mst_file_text;
+	      /* SS_LOCAL symbols in a shared library do not have
+		 export stubs, so we do not have to worry about
+		 using mst_file_text vs mst_solib_trampoline here like
+		 we do for SS_UNIVERSAL and SS_EXTERNAL symbols above.  */
+	      ms_type = mst_file_text;
 	      bufp->symbol_value += text_offset;
 	      bufp->symbol_value = SMASH_TEXT_ADDRESS (bufp->symbol_value);
 	      break;
diff --git a/gdb/source.c b/gdb/source.c
index ee4998d..ac74372 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -503,6 +503,23 @@
 }
 
 
+/* Return True if the file NAME exists and is a regular file */
+static int
+is_regular_file (const char *name)
+{
+  struct stat st;
+  const int status = stat (name, &st);
+
+  /* Stat should never fail except when the file does not exist.
+     If stat fails, analyze the source of error and return True
+     unless the file does not exist, to avoid returning false results
+     on obscure systems where stat does not work as expected.
+   */
+  if (status != 0)
+    return (errno != ENOENT);
+
+  return S_ISREG (st.st_mode);
+}
 
 /* Open a file named STRING, searching path PATH (dir names sep by some char)
    using mode MODE and protection bits PROT in the calls to open.
@@ -514,7 +531,7 @@
    get that particular version of foo or an error message).
 
    If FILENAME_OPENED is non-null, set it to a newly allocated string naming
-   the actual file opened (this string will always start with a "/".  We
+   the actual file opened (this string will always start with a "/").  We
    have to take special pains to avoid doubling the "/" between the directory
    and the file, sigh!  Emacs gets confuzzed by this when we print the
    source file name!!! 
@@ -523,7 +540,7 @@
    Otherwise, return -1, with errno set for the last name we tried to open.  */
 
 /*  >>>> This should only allow files of certain types,
-   >>>>  eg executable, non-directory */
+    >>>>  eg executable, non-directory */
 int
 openp (const char *path, int try_cwd_first, const char *string,
        int mode, int prot,
@@ -543,7 +560,7 @@
   mode |= O_BINARY;
 #endif
 
-  if (try_cwd_first || IS_ABSOLUTE_PATH (string))
+  if ((try_cwd_first || IS_ABSOLUTE_PATH (string)) && is_regular_file (string))
     {
       int i;
       filename = alloca (strlen (string) + 1);
@@ -601,18 +618,26 @@
       strcat (filename + len, SLASH_STRING);
       strcat (filename, string);
 
-      fd = open (filename, mode);
-      if (fd >= 0)
-	break;
+      if (is_regular_file (filename))
+      {
+        fd = open (filename, mode);
+        if (fd >= 0)
+          break;
+      }
     }
 
 done:
   if (filename_opened)
     {
+      /* If a file was opened, canonicalize its filename. Use xfullpath
+         rather than gdb_realpath to avoid resolving the basename part
+         of filenames when the associated file is a symbolic link. This
+         fixes a potential inconsistency between the filenames known to
+         GDB and the filenames it prints in the annotations.  */
       if (fd < 0)
 	*filename_opened = NULL;
       else if (IS_ABSOLUTE_PATH (filename))
-	*filename_opened = gdb_realpath (filename);
+	*filename_opened = xfullpath (filename);
       else
 	{
 	  /* Beware the // my son, the Emacs barfs, the botch that catch... */
@@ -621,7 +646,7 @@
            IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
 				     ? "" : SLASH_STRING,
 				     filename, NULL);
-	  *filename_opened = gdb_realpath (f);
+	  *filename_opened = xfullpath (f);
 	  xfree (f);
 	}
     }
@@ -1586,7 +1611,7 @@
   if (dbx_commands)
     add_com_alias ("use", "directory", class_files, 0);
 
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_cmd ("directories", no_class, show_directories,
 	   "Current search path for finding source files.\n\
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index 7069c3a..e892fe8 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -155,21 +155,23 @@
   /* First decide which pieces of machine-state we need to modify.  
      Default for regno == -1 case is all pieces.  */
   if (regno >= 0)
-    if (FP0_REGNUM <= regno && regno < FP0_REGNUM + 32)
-      {
-	wanna_store = FP_REGS;
-      }
-    else
-      {
-	if (regno == SP_REGNUM)
-	  wanna_store = INT_REGS + STACK_REGS;
-	else if (regno < L0_REGNUM || regno > I7_REGNUM)
-	  wanna_store = INT_REGS;
-	else if (regno == FPS_REGNUM)
+    {
+      if (FP0_REGNUM <= regno && regno < FP0_REGNUM + 32)
+	{
 	  wanna_store = FP_REGS;
-	else
-	  wanna_store = STACK_REGS;
-      }
+	}
+      else
+	{
+	  if (regno == SP_REGNUM)
+	    wanna_store = INT_REGS + STACK_REGS;
+	  else if (regno < L0_REGNUM || regno > I7_REGNUM)
+	    wanna_store = INT_REGS;
+	  else if (regno == FPS_REGNUM)
+	    wanna_store = FP_REGS;
+	  else
+	    wanna_store = STACK_REGS;
+	}
+    }
 
   /* See if we're forcing the stores to happen now, or deferring. */
   if (regno == -2)
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index b2380b4..6461ca0 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1,6 +1,8 @@
 /* Target-dependent code for the SPARC for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
+   Inc.
 
    This file is part of GDB.
 
@@ -683,10 +685,36 @@
   return pc;
 }
 
+/* Advance PC across any function entry prologue instructions to reach
+   some "real" code.  */
+
 CORE_ADDR
-sparc_skip_prologue (CORE_ADDR start_pc, int frameless_p)
+sparc_skip_prologue (CORE_ADDR start_pc)
 {
-  return examine_prologue (start_pc, frameless_p, NULL, NULL);
+  struct symtab_and_line sal;
+  CORE_ADDR func_start, func_end;
+
+  /* This is the preferred method, find the end of the prologue by
+     using the debugging information.  */
+  if (find_pc_partial_function (start_pc, NULL, &func_start, &func_end))
+    {
+      sal = find_pc_line (func_start, 0);
+
+      if (sal.end < func_end
+	  && start_pc <= sal.end)
+	return sal.end;
+    }
+
+  /* Oh well, examine the code by hand.  */
+  return examine_prologue (start_pc, 0, NULL, NULL);
+}
+
+/* Is the prologue at IP frameless?  */
+
+int
+sparc_prologue_frameless_p (CORE_ADDR ip)
+{
+  return ip == examine_prologue (ip, 1, NULL, NULL);
 }
 
 /* Check instruction at ADDR to see if it is a branch.
@@ -827,11 +855,21 @@
 	    addr = frame1->frame + (regnum - G0_REGNUM) * SPARC_INTREG_SIZE
 	      - (FP_REGISTER_BYTES + 8 * SPARC_INTREG_SIZE);
 	  else if (regnum >= I0_REGNUM && regnum < I0_REGNUM + 8)
-	    addr = (frame1->prev->extra_info->bottom
+	    /* NOTE: cagney/2002-05-04: The call to get_prev_frame()
+               is safe/cheap - there will always be a prev frame.
+               This is because frame1 is initialized to frame->next
+               (frame1->prev == frame) and is then advanced towards
+               the innermost (next) frame.  */
+	    addr = (get_prev_frame (frame1)->extra_info->bottom
 		    + (regnum - I0_REGNUM) * SPARC_INTREG_SIZE
 		    + FRAME_SAVED_I0);
 	  else if (regnum >= L0_REGNUM && regnum < L0_REGNUM + 8)
-	    addr = (frame1->prev->extra_info->bottom
+	    /* NOTE: cagney/2002-05-04: The call to get_prev_frame()
+               is safe/cheap - there will always be a prev frame.
+               This is because frame1 is initialized to frame->next
+               (frame1->prev == frame) and is then advanced towards
+               the innermost (next) frame.  */
+	    addr = (get_prev_frame (frame1)->extra_info->bottom
 		    + (regnum - L0_REGNUM) * SPARC_INTREG_SIZE
 		    + FRAME_SAVED_L0);
 	  else if (regnum >= O0_REGNUM && regnum < O0_REGNUM + 8)
@@ -873,11 +911,11 @@
 	{
 	  /* Normal frame.  Local and In registers are saved on stack.  */
 	  if (regnum >= I0_REGNUM && regnum < I0_REGNUM + 8)
-	    addr = (frame1->prev->extra_info->bottom
+	    addr = (get_prev_frame (frame1)->extra_info->bottom
 		    + (regnum - I0_REGNUM) * SPARC_INTREG_SIZE
 		    + FRAME_SAVED_I0);
 	  else if (regnum >= L0_REGNUM && regnum < L0_REGNUM + 8)
-	    addr = (frame1->prev->extra_info->bottom
+	    addr = (get_prev_frame (frame1)->extra_info->bottom
 		    + (regnum - L0_REGNUM) * SPARC_INTREG_SIZE
 		    + FRAME_SAVED_L0);
 	  else if (regnum >= O0_REGNUM && regnum < O0_REGNUM + 8)
@@ -986,8 +1024,26 @@
 
   if (strcmp (target_shortname, "sim") != 0)
     {
-      write_fp (old_sp);
-
+      /* NOTE: cagney/2002-04-04: The code below originally contained
+         GDB's _only_ call to write_fp().  That call was eliminated by
+         inlining the corresponding code.  For the 64 bit case, the
+         old function (sparc64_write_fp) did the below although I'm
+         not clear why.  The same goes for why this is only done when
+         the underlying target is a simulator.  */
+      if (GDB_TARGET_IS_SPARC64)
+	{
+	  /* Target is a 64 bit SPARC.  */
+	  CORE_ADDR oldfp = read_register (FP_REGNUM);
+	  if (oldfp & 1)
+	    write_register (FP_REGNUM, old_sp - 2047);
+	  else
+	    write_register (FP_REGNUM, old_sp);
+	}
+      else
+	{
+	  /* Target is a 32 bit SPARC.  */
+	  write_register (FP_REGNUM, old_sp);
+	}
       /* Set return address register for the call dummy to the current PC.  */
       write_register (I7_REGNUM, read_pc () - 8);
     }
@@ -1234,7 +1290,7 @@
 
       char *reg_temp;
 
-      reg_temp = alloca (REGISTER_BYTES);
+      reg_temp = alloca (SPARC_INTREG_SIZE * 16);
 
       read_memory (fsr[I0_REGNUM], raw_buffer, 8 * SPARC_INTREG_SIZE);
 
@@ -1811,8 +1867,8 @@
     {
       char value[16];
 
-      if (!read_relative_register_raw_bytes (regno, value)
-	  && !read_relative_register_raw_bytes (regno + 1, value + 4))
+      if (frame_register_read (selected_frame, regno, value)
+	  && frame_register_read (selected_frame, regno + 1, value + 4))
 	{
 	  printf_unfiltered ("\t");
 	  print_floating (value, builtin_type_double, gdb_stdout);
@@ -1820,8 +1876,8 @@
 #if 0				/* FIXME: gdb doesn't handle long doubles */
       if ((regno & 3) == 0)
 	{
-	  if (!read_relative_register_raw_bytes (regno + 2, value + 8)
-	      && !read_relative_register_raw_bytes (regno + 3, value + 12))
+	  if (frame_register_read (selected_frame, regno + 2, value + 8)
+	      && frame_register_read (selected_frame, regno + 3, value + 12))
 	    {
 	      printf_unfiltered ("\t");
 	      print_floating (value, builtin_type_long_double, gdb_stdout);
@@ -1840,8 +1896,8 @@
     {
       char value[16];
 
-      if (!read_relative_register_raw_bytes (regno, value)
-	  && !read_relative_register_raw_bytes (regno + 1, value + 8))
+      if (frame_register_read (selected_frame, regno, value)
+	  && frame_register_read (selected_frame, regno + 1, value + 8))
 	{
 	  printf_unfiltered ("\t");
 	  print_floating (value, builtin_type_long_double, gdb_stdout);
@@ -2261,16 +2317,6 @@
     write_register (SP_REGNUM, val);
 }
 
-void
-sparc64_write_fp (CORE_ADDR val)
-{
-  CORE_ADDR oldfp = read_register (FP_REGNUM);
-  if (oldfp & 1)
-    write_register (FP_REGNUM, val - 2047);
-  else
-    write_register (FP_REGNUM, val);
-}
-
 /* The SPARC 64 ABI passes floating-point arguments in FP0 to FP31,
    and all other arguments in O0 to O5.  They are also copied onto
    the stack in the correct places.  Apparently (empirically), 
@@ -2766,18 +2812,6 @@
     return 64 * 8 + (regno - 80) * 8;
 }
 
-/* Advance PC across any function entry prologue instructions to reach
-   some "real" code.  SKIP_PROLOGUE_FRAMELESS_P advances the PC past
-   some of the prologue, but stops as soon as it knows that the
-   function has a frame.  Its result is equal to its input PC if the
-   function is frameless, unequal otherwise.  */
-
-static CORE_ADDR
-sparc_gdbarch_skip_prologue (CORE_ADDR ip)
-{
-  return examine_prologue (ip, 0, NULL, NULL);
-}
-
 /* Immediately after a function call, return the saved pc.
    Can't go through the frames for this because on some machines
    the new frame is not set up until the new function executes
@@ -2976,8 +3010,9 @@
   set_gdbarch_reg_struct_has_addr (gdbarch, sparc_reg_struct_has_addr);
   set_gdbarch_return_value_on_stack (gdbarch, sparc_return_value_on_stack);
   set_gdbarch_saved_pc_after_call (gdbarch, sparc_saved_pc_after_call);
+  set_gdbarch_prologue_frameless_p (gdbarch, sparc_prologue_frameless_p);
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
-  set_gdbarch_skip_prologue (gdbarch, sparc_gdbarch_skip_prologue);
+  set_gdbarch_skip_prologue (gdbarch, sparc_skip_prologue);
   set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM);
   set_gdbarch_use_generic_dummy_frames (gdbarch, 0);
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
@@ -3001,6 +3036,50 @@
       set_gdbarch_call_dummy_address (gdbarch, sparc_call_dummy_address);
       set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0x30);
       set_gdbarch_call_dummy_length (gdbarch, 0x38);
+
+      /* NOTE: cagney/2002-04-26: Based from info posted by Peter
+	 Schauer around Oct '99.  Briefly, due to aspects of the SPARC
+	 ABI, it isn't possible to use ON_STACK with a strictly
+	 compliant compiler.
+
+	 Peter Schauer writes ...
+
+	 No, any call from GDB to a user function returning a
+	 struct/union will fail miserably. Try this:
+
+	 *NOINDENT*
+	 struct x
+	 {
+           int a[4];
+         };
+
+	 struct x gx;
+
+	 struct x
+	 sret ()
+	 {
+	   return gx;
+	 }
+
+	 main ()
+	 {
+	   int i;
+	   for (i = 0; i < 4; i++)
+	     gx.a[i] = i + 1;
+	   gx = sret ();
+	 }
+	 *INDENT*
+
+	 Set a breakpoint at the gx = sret () statement, run to it and
+	 issue a `print sret()'. It will not succed with your
+	 approach, and I doubt that continuing the program will work
+	 as well.
+
+	 For details of the ABI see the Sparc Architecture Manual.  I
+	 have Version 8 (Prentice Hall ISBN 0-13-825001-4) and the
+	 calling conventions for functions returning aggregate values
+	 are explained in Appendix D.3.  */
+
       set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
       set_gdbarch_call_dummy_words (gdbarch, call_dummy_32);
 #else
@@ -3038,7 +3117,6 @@
       set_gdbarch_store_struct_return (gdbarch, sparc32_store_struct_return);
       set_gdbarch_use_struct_convention (gdbarch, 
 					 generic_use_struct_convention);
-      set_gdbarch_write_fp (gdbarch, generic_target_write_fp);
       set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
       tdep->y_regnum = SPARC32_Y_REGNUM;
       tdep->fp_max_regnum = SPARC_FP0_REGNUM + 32;
@@ -3097,7 +3175,6 @@
       set_gdbarch_store_struct_return (gdbarch, sparc64_store_struct_return);
       set_gdbarch_use_struct_convention (gdbarch, 
 					 sparc64_use_struct_convention);
-      set_gdbarch_write_fp (gdbarch, sparc64_write_fp);
       set_gdbarch_write_sp (gdbarch, sparc64_write_sp);
       tdep->y_regnum = SPARC64_Y_REGNUM;
       tdep->fp_max_regnum = SPARC_FP0_REGNUM + 48;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 5b11546..7065b7b 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -136,6 +136,7 @@
 attach_fields_to_type (struct field_info *, struct type *, struct objfile *);
 
 static struct type *read_struct_type (char **, struct type *,
+                                      enum type_code,
 				      struct objfile *);
 
 static struct type *read_array_type (char **, struct type *,
@@ -2536,7 +2537,24 @@
 	       the related problems with unnecessarily stubbed types;
 	       someone motivated should attempt to clean up the issue
 	       here as well.  Once a type pointed to has been created it
-	       should not be modified.  */
+	       should not be modified.
+
+               Well, it's not *absolutely* wrong.  Constructing recursive
+               types (trees, linked lists) necessarily entails modifying
+               types after creating them.  Constructing any loop structure
+               entails side effects.  The Dwarf 2 reader does handle this
+               more gracefully (it never constructs more than once
+               instance of a type object, so it doesn't have to copy type
+               objects wholesale), but it still mutates type objects after
+               other folks have references to them.
+
+               Keep in mind that this circularity/mutation issue shows up
+               at the source language level, too: C's "incomplete types",
+               for example.  So the proper cleanup, I think, would be to
+               limit GDB's type smashing to match exactly those required
+               by the source language.  So GDB could have a
+               "complete_this_type" function, but never create unnecessary
+               copies of a type otherwise.  */
 	    replace_type (type, xtype);
 	    TYPE_NAME (type) = NULL;
 	    TYPE_TAG_NAME (type) = NULL;
@@ -2801,18 +2819,21 @@
 
     case 's':			/* Struct type */
     case 'u':			/* Union type */
-      type = dbx_alloc_type (typenums, objfile);
-      switch (type_descriptor)
-	{
-	case 's':
-	  TYPE_CODE (type) = TYPE_CODE_STRUCT;
-	  break;
-	case 'u':
-	  TYPE_CODE (type) = TYPE_CODE_UNION;
-	  break;
-	}
-      type = read_struct_type (pp, type, objfile);
-      break;
+      {
+        enum type_code type_code = TYPE_CODE_UNDEF;
+        type = dbx_alloc_type (typenums, objfile);
+        switch (type_descriptor)
+          {
+          case 's':
+            type_code = TYPE_CODE_STRUCT;
+            break;
+          case 'u':
+            type_code = TYPE_CODE_UNION;
+            break;
+          }
+        type = read_struct_type (pp, type, type_code, objfile);
+        break;
+      }
 
     case 'a':			/* Array type */
       if (**pp != 'r')
@@ -2978,10 +2999,14 @@
     case 25:
       /* Complex type consisting of two IEEE single precision values.  */
       rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL);
+      TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 4, 0, "float",
+					      NULL);
       break;
     case 26:
       /* Complex type consisting of two IEEE double precision values.  */
       rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
+      TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 8, 0, "double",
+					      NULL);
       break;
     case 27:
       rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL);
@@ -3037,7 +3062,6 @@
 {
   int nfn_fields = 0;
   int length = 0;
-  int skip_method;
   /* Total number of member functions defined in this class.  If the class
      defines two `f' functions, and one `g' function, then this will have
      the value 3.  */
@@ -3077,36 +3101,6 @@
       look_ahead_type = NULL;
       length = 0;
 
-      skip_method = 0;
-      if (p - *pp == strlen ("__base_ctor")
-	  && strncmp (*pp, "__base_ctor", strlen ("__base_ctor")) == 0)
-	skip_method = 1;
-      else if (p - *pp == strlen ("__base_dtor")
-	       && strncmp (*pp, "__base_dtor", strlen ("__base_dtor")) == 0)
-	skip_method = 1;
-      else if (p - *pp == strlen ("__deleting_dtor")
-	       && strncmp (*pp, "__deleting_dtor",
-			   strlen ("__deleting_dtor")) == 0)
-	skip_method = 1;
-
-      if (skip_method)
-	{
-	  /* Skip past '::'.  */
-	  *pp = p + 2;
-	  /* Read the type.  */
-	  read_type (pp, objfile);
-	  /* Skip past the colon, mangled name, semicolon, flags, and final
-	     semicolon.  */
-	  while (**pp != ';')
-	    (*pp) ++;
-	  (*pp) ++;
-	  while (**pp != ';')
-	    (*pp) ++;
-	  (*pp) ++;
-
-	  continue;
-	}
-
       new_fnlist = (struct next_fnfieldlist *)
 	xmalloc (sizeof (struct next_fnfieldlist));
       make_cleanup (xfree, new_fnlist);
@@ -3287,13 +3281,30 @@
 	      }
 	    case '?':
 	      /* static member function.  */
-	      new_sublist->fn_field.voffset = VOFFSET_STATIC;
-	      if (strncmp (new_sublist->fn_field.physname,
-			   main_fn_name, strlen (main_fn_name)))
-		{
-		  new_sublist->fn_field.is_stub = 1;
-		}
-	      break;
+	      {
+		int slen = strlen (main_fn_name);
+
+		new_sublist->fn_field.voffset = VOFFSET_STATIC;
+
+		/* For static member functions, we can't tell if they
+		   are stubbed, as they are put out as functions, and not as
+		   methods.
+		   GCC v2 emits the fully mangled name if
+		   dbxout.c:flag_minimal_debug is not set, so we have to
+		   detect a fully mangled physname here and set is_stub
+		   accordingly.  Fully mangled physnames in v2 start with
+		   the member function name, followed by two underscores.
+		   GCC v3 currently always emits stubbed member functions,
+		   but with fully mangled physnames, which start with _Z.  */
+		if (!(strncmp (new_sublist->fn_field.physname,
+			       main_fn_name, slen) == 0
+		      && new_sublist->fn_field.physname[slen] == '_'
+		      && new_sublist->fn_field.physname[slen + 1] == '_'))
+		  {
+		    new_sublist->fn_field.is_stub = 1;
+		  }
+		break;
+	      }
 
 	    default:
 	      /* error */
@@ -3315,23 +3326,34 @@
       while (**pp != ';' && **pp != '\0');
 
       (*pp)++;
-
-      new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
-	obstack_alloc (&objfile->type_obstack,
-		       sizeof (struct fn_field) * length);
-      memset (new_fnlist->fn_fieldlist.fn_fields, 0,
-	      sizeof (struct fn_field) * length);
-      for (i = length; (i--, sublist); sublist = sublist->next)
-	{
-	  new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
-	}
-
-      new_fnlist->fn_fieldlist.length = length;
-      new_fnlist->next = fip->fnlist;
-      fip->fnlist = new_fnlist;
-      nfn_fields++;
-      total_length += length;
       STABS_CONTINUE (pp, objfile);
+
+      /* Skip GCC 3.X member functions which are duplicates of the callable
+	 constructor/destructor.  */
+      if (strcmp (main_fn_name, "__base_ctor") == 0
+	  || strcmp (main_fn_name, "__base_dtor") == 0
+	  || strcmp (main_fn_name, "__deleting_dtor") == 0)
+	{
+	  xfree (main_fn_name);
+	}
+      else
+	{
+	  new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
+	    obstack_alloc (&objfile->type_obstack,
+			   sizeof (struct fn_field) * length);
+	  memset (new_fnlist->fn_fieldlist.fn_fields, 0,
+		  sizeof (struct fn_field) * length);
+	  for (i = length; (i--, sublist); sublist = sublist->next)
+	    {
+	      new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
+	    }
+
+	  new_fnlist->fn_fieldlist.length = length;
+	  new_fnlist->next = fip->fnlist;
+	  fip->fnlist = new_fnlist;
+	  nfn_fields++;
+	  total_length += length;
+	}
     }
 
   if (nfn_fields)
@@ -4155,6 +4177,45 @@
   return 1;
 }
 
+
+static struct complaint multiply_defined_struct =
+{"struct/union type gets multiply defined: %s%s", 0, 0};
+
+
+/* Complain that the compiler has emitted more than one definition for the
+   structure type TYPE.  */
+static void 
+complain_about_struct_wipeout (struct type *type)
+{
+  char *name = "";
+  char *kind = "";
+
+  if (TYPE_TAG_NAME (type))
+    {
+      name = TYPE_TAG_NAME (type);
+      switch (TYPE_CODE (type))
+        {
+        case TYPE_CODE_STRUCT: kind = "struct "; break;
+        case TYPE_CODE_UNION:  kind = "union ";  break;
+        case TYPE_CODE_ENUM:   kind = "enum ";   break;
+        default: kind = "";
+        }
+    }
+  else if (TYPE_NAME (type))
+    {
+      name = TYPE_NAME (type);
+      kind = "";
+    }
+  else
+    {
+      name = "<unknown>";
+      kind = "";
+    }
+
+  complain (&multiply_defined_struct, kind, name);
+}
+
+
 /* Read the description of a structure (or union type) and return an object
    describing the type.
 
@@ -4170,7 +4231,8 @@
  */
 
 static struct type *
-read_struct_type (char **pp, struct type *type, struct objfile *objfile)
+read_struct_type (char **pp, struct type *type, enum type_code type_code,
+                  struct objfile *objfile)
 {
   struct cleanup *back_to;
   struct field_info fi;
@@ -4178,9 +4240,30 @@
   fi.list = NULL;
   fi.fnlist = NULL;
 
+  /* When describing struct/union/class types in stabs, G++ always drops
+     all qualifications from the name.  So if you've got:
+       struct A { ... struct B { ... }; ... };
+     then G++ will emit stabs for `struct A::B' that call it simply
+     `struct B'.  Obviously, if you've got a real top-level definition for
+     `struct B', or other nested definitions, this is going to cause
+     problems.
+
+     Obviously, GDB can't fix this by itself, but it can at least avoid
+     scribbling on existing structure type objects when new definitions
+     appear.  */
+  if (! (TYPE_CODE (type) == TYPE_CODE_UNDEF
+         || TYPE_STUB (type)))
+    {
+      complain_about_struct_wipeout (type);
+
+      /* It's probably best to return the type unchanged.  */
+      return type;
+    }
+
   back_to = make_cleanup (null_cleanup, 0);
 
   INIT_CPLUS_SPECIFIC (type);
+  TYPE_CODE (type) = type_code;
   TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
 
   /* First comes the total size in bytes.  */
@@ -4494,6 +4577,7 @@
   int nbits;
   int details;
   int nbytes;
+  struct type *rettype;
 
   /* The first number has more details about the type, for example
      FN_COMPLEX.  */
@@ -4508,9 +4592,12 @@
 
   if (details == NF_COMPLEX || details == NF_COMPLEX16
       || details == NF_COMPLEX32)
-    /* This is a type we can't handle, but we do know the size.
-       We also will be able to give it a name.  */
-    return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
+    {
+      rettype = init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
+      TYPE_TARGET_TYPE (rettype)
+	= init_type (TYPE_CODE_FLT, nbytes / 2, 0, NULL, objfile);
+      return rettype;
+    }
 
   return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile);
 }
@@ -5052,10 +5139,7 @@
 			    && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
 				TYPE_CODE (*type))
 			    && STREQ (SYMBOL_NAME (sym), typename))
-			  {
-			    memcpy (*type, SYMBOL_TYPE (sym),
-				    sizeof (struct type));
-			  }
+                          replace_type (*type, SYMBOL_TYPE (sym));
 		      }
 		  }
 	      }
diff --git a/gdb/stack.c b/gdb/stack.c
index 68f16b6..2dab0de 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -119,7 +119,17 @@
    0 for innermost, 1 for its caller, ...
    or -1 for frame specified by address with no defined level.  */
 
-int selected_frame_level;
+/* Level of the selected frame: 0 for innermost, 1 for its caller, ...
+   or -1 for NULL frame.  */
+
+int
+frame_relative_level (struct frame_info *fi)
+{
+  if (fi == NULL)
+    return -1;
+  else
+    return fi->level;
+}
 
 /* Zero means do things normally; we are interacting directly with the
    user.  One means print the full filename and linenumber when a
@@ -704,7 +714,7 @@
 	   really should be used instead of spaces to delimit; using spaces
 	   normally works in an expression).  */
 #ifdef SETUP_ARBITRARY_FRAME
-	error ("No frame %d", args[0]);
+	error ("No frame %s", paddr_d (args[0]));
 #endif
 
 	/* If (s)he specifies the frame with an address, he deserves what
@@ -817,9 +827,10 @@
     }
   calling_frame_info = get_prev_frame (fi);
 
-  if (!addr_exp && selected_frame_level >= 0)
+  if (!addr_exp && frame_relative_level (selected_frame) >= 0)
     {
-      printf_filtered ("Stack level %d, frame at ", selected_frame_level);
+      printf_filtered ("Stack level %d, frame at ",
+		       frame_relative_level (selected_frame));
       print_address_numeric (fi->frame, 1, gdb_stdout);
       printf_filtered (":\n");
     }
@@ -1238,7 +1249,7 @@
 print_frame_local_vars (register struct frame_info *fi, register int num_tabs,
 			register struct ui_file *stream)
 {
-  register struct block *block = get_frame_block (fi);
+  register struct block *block = get_frame_block (fi, 0);
   register int values_printed = 0;
 
   if (block == 0)
@@ -1272,7 +1283,7 @@
 			register struct ui_file *stream)
 {
   register struct blockvector *bl;
-  register struct block *block = get_frame_block (fi);
+  register struct block *block = get_frame_block (fi, 0);
   register int values_printed = 0;
   int index, have_default = 0;
   char *blocks_printed;
@@ -1448,18 +1459,18 @@
 }
 
 
-/* Select frame FI, and note that its stack level is LEVEL.
-   LEVEL may be -1 if an actual level number is not known.  */
+/* Select frame FI (or NULL - to invalidate the current frame).  */
 
 void
-select_frame (struct frame_info *fi, int level)
+select_frame (struct frame_info *fi)
 {
   register struct symtab *s;
 
   selected_frame = fi;
-  selected_frame_level = level;
+  /* NOTE: cagney/2002-05-04: FI can be NULL.  This occures when the
+     frame is being invalidated.  */
   if (selected_frame_level_changed_hook)
-    selected_frame_level_changed_hook (level);
+    selected_frame_level_changed_hook (frame_relative_level (fi));
 
   /* Ensure that symbols for this frame are read in.  Also, determine the
      source language of this frame, and switch to it if desired.  */
@@ -1477,15 +1488,15 @@
 }
 
 
-/* Select frame FI, noting that its stack level is LEVEL.  Also print
-   the stack frame and show the source if this is the tui version.  */
-void
-select_and_print_frame (struct frame_info *fi, int level)
+/* Select frame FI.  Also print the stack frame and show the source if
+   this is the tui version.  */
+static void
+select_and_print_frame (struct frame_info *fi)
 {
-  select_frame (fi, level);
+  select_frame (fi);
   if (fi)
     {
-      print_stack_frame (fi, level, 1);
+      print_stack_frame (fi, frame_relative_level (fi), 1);
     }
 }
 
@@ -1497,21 +1508,25 @@
 record_selected_frame (CORE_ADDR *frameaddrp, int *levelp)
 {
   *frameaddrp = selected_frame ? selected_frame->frame : 0;
-  *levelp = selected_frame_level;
+  *levelp = frame_relative_level (selected_frame);
 }
 
 /* Return the symbol-block in which the selected frame is executing.
-   Can return zero under various legitimate circumstances.  */
+   Can return zero under various legitimate circumstances.
+
+   If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant
+   code address within the block returned.  We use this to decide
+   which macros are in scope.  */
 
 struct block *
-get_selected_block (void)
+get_selected_block (CORE_ADDR *addr_in_block)
 {
   if (!target_has_stack)
     return 0;
 
   if (!selected_frame)
-    return get_current_block ();
-  return get_frame_block (selected_frame);
+    return get_current_block (addr_in_block);
+  return get_frame_block (selected_frame, addr_in_block);
 }
 
 /* Find a frame a certain number of levels away from FRAME.
@@ -1579,21 +1594,7 @@
 
   frame = parse_frame_specification (level_exp);
 
-  /* Try to figure out what level this frame is.  But if there is
-     no current stack, don't error out -- let the user set one.  */
-  frame1 = 0;
-  if (get_current_frame ())
-    {
-      for (frame1 = get_prev_frame (0);
-	   frame1 && frame1 != frame;
-	   frame1 = get_prev_frame (frame1))
-	level++;
-    }
-
-  if (!frame1)
-    level = 0;
-
-  select_frame (frame, level);
+  select_frame (frame);
 }
 
 /* The "frame" command.  With no arg, print selected frame briefly.
@@ -1604,7 +1605,8 @@
 frame_command (char *level_exp, int from_tty)
 {
   select_frame_command (level_exp, from_tty);
-  show_and_print_stack_frame (selected_frame, selected_frame_level, 1);
+  show_and_print_stack_frame (selected_frame,
+			      frame_relative_level (selected_frame), 1);
 }
 
 /* The XDB Compatibility command to print the current frame. */
@@ -1614,7 +1616,8 @@
 {
   if (target_has_stack == 0 || selected_frame == 0)
     error ("No stack.");
-  print_only_stack_frame (selected_frame, selected_frame_level, 1);
+  print_only_stack_frame (selected_frame,
+			  frame_relative_level (selected_frame), 1);
 }
 
 /* Select the frame up one or COUNT stack levels
@@ -1636,7 +1639,7 @@
   fi = find_relative_frame (selected_frame, &count1);
   if (count1 != 0 && count_exp == 0)
     error ("Initial frame selected; you cannot go up.");
-  select_frame (fi, selected_frame_level + count - count1);
+  select_frame (fi);
 }
 
 static void
@@ -1649,7 +1652,8 @@
 up_command (char *count_exp, int from_tty)
 {
   up_silently_base (count_exp);
-  show_and_print_stack_frame (selected_frame, selected_frame_level, 1);
+  show_and_print_stack_frame (selected_frame,
+			      frame_relative_level (selected_frame), 1);
 }
 
 /* Select the frame down one or COUNT stack levels
@@ -1680,7 +1684,7 @@
       error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
     }
 
-  select_frame (frame, selected_frame_level + count - count1);
+  select_frame (frame);
 }
 
 /* ARGSUSED */
@@ -1694,7 +1698,8 @@
 down_command (char *count_exp, int from_tty)
 {
   down_silently_base (count_exp);
-  show_and_print_stack_frame (selected_frame, selected_frame_level, 1);
+  show_and_print_stack_frame (selected_frame,
+			      frame_relative_level (selected_frame), 1);
 }
 
 void
@@ -1846,7 +1851,7 @@
   if (!found)
     printf_filtered ("'%s' not within current stack frame.\n", arg);
   else if (fp != selected_frame)
-    select_and_print_frame (fp, level);
+    select_and_print_frame (fp);
 }
 
 /* Gets the language of the current frame.  */
diff --git a/gdb/std-regs.c b/gdb/std-regs.c
new file mode 100644
index 0000000..b96c901
--- /dev/null
+++ b/gdb/std-regs.c
@@ -0,0 +1,150 @@
+/* Builtin frame register, for GDB, the GNU debugger.
+
+   Copyright 2002 Free Software Foundation, Inc.
+
+   Contributed by Red Hat.
+
+   This file is part of GDB.
+
+   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 "defs.h"
+#include "builtin-regs.h"
+#include "frame.h"
+#include "gdbtypes.h"
+#include "value.h"
+
+/* Types that describe the various builtin registers.  */
+
+static struct type *builtin_type_frame_reg;
+
+/* Constructors for those types.  */
+
+static void
+build_builtin_type_frame_reg (void)
+{
+  /* $frame.  */
+  if (builtin_type_frame_reg == NULL)
+    {
+#if 0
+      struct frame
+      {
+	void *base;
+      };
+#endif
+      builtin_type_frame_reg = init_composite_type ("frame", TYPE_CODE_STRUCT);
+      append_composite_type_field (builtin_type_frame_reg, "base",
+				   builtin_type_void_data_ptr);
+    }
+}
+
+static struct value *
+value_of_builtin_frame_reg (struct frame_info *frame)
+{
+  struct value *val;
+  char *buf;
+  build_builtin_type_frame_reg ();
+  val = allocate_value (builtin_type_frame_reg);
+  VALUE_LVAL (val) = not_lval;
+  buf = VALUE_CONTENTS_RAW (val);
+  memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
+  /* frame.base.  */
+  if (frame != NULL)
+    ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf, frame->frame);
+  buf += TYPE_LENGTH (builtin_type_void_data_ptr);
+  /* frame.XXX.  */
+  return val;
+}
+
+static struct value *
+value_of_builtin_frame_fp_reg (struct frame_info *frame)
+{
+#ifdef FP_REGNUM
+  if (FP_REGNUM >= 0)
+    return value_of_register (FP_REGNUM, frame);
+#endif
+  {
+    struct value *val = allocate_value (builtin_type_void_data_ptr);
+    char *buf = VALUE_CONTENTS_RAW (val);
+    if (frame == NULL)
+      memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
+    else
+      ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf, frame->frame);
+    return val;
+  }
+}
+
+static struct value *
+value_of_builtin_frame_pc_reg (struct frame_info *frame)
+{
+#ifdef PC_REGNUM
+  if (PC_REGNUM >= 0)
+    return value_of_register (PC_REGNUM, frame);
+#endif
+  {
+    struct value *val = allocate_value (builtin_type_void_data_ptr);
+    char *buf = VALUE_CONTENTS_RAW (val);
+    if (frame == NULL)
+      memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
+    else
+      ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf, frame->pc);
+    return val;
+  }
+}
+
+static struct value *
+value_of_builtin_frame_sp_reg (struct frame_info *frame)
+{
+#ifdef SP_REGNUM
+  if (SP_REGNUM >= 0)
+    return value_of_register (SP_REGNUM, frame);
+#endif
+  error ("Standard register ``$sp'' is not available for this target");
+}
+
+static struct value *
+value_of_builtin_frame_ps_reg (struct frame_info *frame)
+{
+#ifdef PS_REGNUM
+  if (PS_REGNUM >= 0)
+    return value_of_register (PS_REGNUM, frame);
+#endif
+  error ("Standard register ``$ps'' is not available for this target");
+}
+
+void
+_initialize_frame_reg (void)
+{
+  /* FIXME: cagney/2002-02-08: At present the local builtin types
+     can't be initialized using _initialize*() or gdbarch.  Due mainly
+     to non-multi-arch targets, GDB initializes things piece meal and,
+     as a consequence can leave these types NULL.  */
+  REGISTER_GDBARCH_SWAP (builtin_type_frame_reg);
+
+  /* Frame based $fp, $pc, $sp and $ps.  These only come into play
+     when the target does not define its own version of these
+     registers.  */
+  add_builtin_reg ("fp", value_of_builtin_frame_fp_reg);
+  add_builtin_reg ("pc", value_of_builtin_frame_pc_reg);
+  add_builtin_reg ("sp", value_of_builtin_frame_sp_reg);
+  add_builtin_reg ("ps", value_of_builtin_frame_ps_reg);
+
+  /* NOTE: cagney/2002-04-05: For moment leave the $frame / $gdbframe
+     / $gdb.frame disabled.  It isn't yet clear which of the many
+     options is the best.  */
+  if (0)
+    add_builtin_reg ("frame", value_of_builtin_frame_reg);
+}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index feca03b..7c7141d 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -120,6 +120,8 @@
 
 bfd *symfile_bfd_open (char *);
 
+int get_section_index (struct objfile *, char *);
+
 static void find_sym_fns (struct objfile *);
 
 static void decrement_reading_symtab (void *);
@@ -577,6 +579,9 @@
   init_entry_point_info (objfile);
   find_sym_fns (objfile);
 
+  if (objfile->sf == NULL)
+    return;	/* No symbols. */
+
   /* Make sure that partially constructed symbol tables will be cleaned up
      if an error occurs during symbol reading.  */
   old_chain = make_cleanup_free_objfile (objfile);
@@ -891,6 +896,9 @@
 	}
     }
 
+  if (objfile->sf == NULL)
+    return objfile;	/* No symbols. */
+
   new_symfile_objfile (objfile, mainline, from_tty);
 
   if (target_new_objfile_hook)
@@ -1109,6 +1117,18 @@
   return (sym_bfd);
 }
 
+/* Return the section index for the given section name. Return -1 if
+   the section was not found. */
+int
+get_section_index (struct objfile *objfile, char *section_name)
+{
+  asection *sect = bfd_get_section_by_name (objfile->obfd, section_name);
+  if (sect)
+    return sect->index;
+  else
+    return -1;
+}
+
 /* Link a new symtab_fns into the global symtab_fns list.  Called on gdb
    startup by the _initialize routine in each object file format reader,
    to register information about each format the the reader is prepared
@@ -1134,6 +1154,11 @@
   enum bfd_flavour our_flavour = bfd_get_flavour (objfile->obfd);
   char *our_target = bfd_get_target (objfile->obfd);
 
+  if (our_flavour == bfd_target_srec_flavour
+      || our_flavour == bfd_target_ihex_flavour
+      || our_flavour == bfd_target_tekhex_flavour)
+    return;	/* No symbols. */
+
   /* Special kludge for apollo.  See dstread.c.  */
   if (STREQN (our_target, "apollo", 6))
     our_flavour = (enum bfd_flavour) -2;
@@ -1806,8 +1831,9 @@
   if (fl_table_next >= fl_table_size)
     {
       fl_table_size += 10;
-      filename_language_table = xrealloc (filename_language_table,
-					  fl_table_size);
+      filename_language_table = 
+	xrealloc (filename_language_table,
+		  fl_table_size * sizeof (*filename_language_table));
     }
 
   filename_language_table[fl_table_next].ext = xstrdup (ext);
@@ -3214,7 +3240,7 @@
 	       "Load symbol table from executable file FILE.\n\
 The `file' command can also load symbol tables, as well as setting the file\n\
 to execute.", &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command,
 	       "Usage: add-symbol-file FILE ADDR [-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> ...]\n\
@@ -3222,9 +3248,9 @@
 ADDR is the starting address of the file's text.\n\
 The optional arguments are section-name section-address pairs and\n\
 should be specified if the data and bss segments are not contiguous\n\
-with the text. SECT is a section name to be loaded at SECT_ADDR.",
+with the text.  SECT is a section name to be loaded at SECT_ADDR.",
 	       &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   c = add_cmd ("add-shared-symbol-files", class_files,
 	       add_shared_symbol_files_command,
@@ -3236,7 +3262,7 @@
   c = add_cmd ("load", class_files, load_command,
 	       "Dynamically load FILE into the running program, and record its symbols\n\
 for access from GDB.", &cmdlist);
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_show_from_set
     (add_set_cmd ("symbol-reloading", class_support, var_boolean,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 9ab8068..39eb308 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -252,6 +252,8 @@
 
 extern bfd *symfile_bfd_open (char *);
 
+extern int get_section_index (struct objfile *, char *);
+
 /* Utility functions for overlay sections: */
 extern enum overlay_debugging_state {
   ovly_off, 
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 3c12988..2f1bb72 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -959,7 +959,7 @@
     while (length--)
       {
 	sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
-				   SYMBOL_NAMESPACE (*psym));
+				   NULL, SYMBOL_NAMESPACE (*psym));
 	if (!sym)
 	  {
 	    printf_filtered ("Static symbol `");
@@ -976,7 +976,7 @@
     while (length--)
       {
 	sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
-				   SYMBOL_NAMESPACE (*psym));
+				   NULL, SYMBOL_NAMESPACE (*psym));
 	if (!sym)
 	  {
 	    printf_filtered ("Global symbol `");
diff --git a/gdb/symtab.c b/gdb/symtab.c
index e464b0b..3a42867 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -80,11 +80,12 @@
 						     const char *, int,
 						     namespace_enum);
 
-static struct symbol *lookup_symbol_aux (const char *name, const
-					 struct block *block, const
-					 namespace_enum namespace, int
-					 *is_a_field_of_this, struct
-					 symtab **symtab);
+static struct symbol *lookup_symbol_aux (const char *name,
+					 const char *mangled_name,
+					 const struct block *block,
+					 const namespace_enum namespace,
+					 int *is_a_field_of_this,
+					 struct symtab **symtab);
 
 
 static struct symbol *find_active_alias (struct symbol *sym, CORE_ADDR addr);
@@ -143,11 +144,17 @@
   register struct partial_symtab *ps;
   register struct objfile *objfile;
   char *real_path = NULL;
+  char *full_path = NULL;
 
   /* Here we are interested in canonicalizing an absolute path, not
      absolutizing a relative path.  */
   if (IS_ABSOLUTE_PATH (name))
-    real_path = gdb_realpath (name);
+    {
+      full_path = xfullpath (name);
+      make_cleanup (xfree, full_path);
+      real_path = gdb_realpath (name);
+      make_cleanup (xfree, real_path);
+    }
 
 got_symtab:
 
@@ -157,24 +164,32 @@
   {
     if (FILENAME_CMP (name, s->filename) == 0)
       {
-	xfree (real_path);
 	return s;
       }
+      
     /* If the user gave us an absolute path, try to find the file in
        this symtab and use its absolute path.  */
+    
+    if (full_path != NULL)
+      {
+	const char *fp = symtab_to_filename (s);
+	if (FILENAME_CMP (full_path, fp) == 0)
+	  {
+	    return s;
+	  }
+      }
+
     if (real_path != NULL)
       {
-	char *rp = symtab_to_filename (s);
+	char *rp = gdb_realpath (symtab_to_filename (s));
+        make_cleanup (xfree, rp);
 	if (FILENAME_CMP (real_path, rp) == 0)
 	  {
-	    xfree (real_path);
 	    return s;
 	  }
       }
   }
 
-  xfree (real_path);
-
   /* Now, search for a matching tail (only if name doesn't have any dirs) */
 
   if (lbasename (name) == name)
@@ -220,37 +235,56 @@
 {
   register struct partial_symtab *pst;
   register struct objfile *objfile;
+  char *full_path = NULL;
   char *real_path = NULL;
 
   /* Here we are interested in canonicalizing an absolute path, not
      absolutizing a relative path.  */
   if (IS_ABSOLUTE_PATH (name))
-    real_path = gdb_realpath (name);
+    {
+      full_path = xfullpath (name);
+      make_cleanup (xfree, full_path);
+      real_path = gdb_realpath (name);
+      make_cleanup (xfree, real_path);
+    }
 
   ALL_PSYMTABS (objfile, pst)
   {
     if (FILENAME_CMP (name, pst->filename) == 0)
       {
-	xfree (real_path);
 	return (pst);
       }
+
     /* If the user gave us an absolute path, try to find the file in
        this symtab and use its absolute path.  */
-    if (real_path != NULL)
+    if (full_path != NULL)
       {
 	if (pst->fullname == NULL)
 	  source_full_path_of (pst->filename, &pst->fullname);
 	if (pst->fullname != NULL
-	    && FILENAME_CMP (real_path, pst->fullname) == 0)
+	    && FILENAME_CMP (full_path, pst->fullname) == 0)
 	  {
-	    xfree (real_path);
+	    return pst;
+	  }
+      }
+
+    if (real_path != NULL)
+      {
+        char *rp = NULL;
+	if (pst->fullname == NULL)
+	  source_full_path_of (pst->filename, &pst->fullname);
+        if (pst->fullname != NULL)
+          {
+            rp = gdb_realpath (pst->fullname);
+            make_cleanup (xfree, rp);
+          }
+	if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
+	  {
 	    return pst;
 	  }
       }
   }
 
-  xfree (real_path);
-
   /* Now, search for a matching tail (only if name doesn't have any dirs) */
 
   if (lbasename (name) == name)
@@ -348,6 +382,83 @@
   strcat (mangled_name, physname);
   return (mangled_name);
 }
+
+
+/* Initialize a symbol's mangled name.  */
+
+/* Try to initialize the demangled name for a symbol, based on the
+   language of that symbol.  If the language is set to language_auto,
+   it will attempt to find any demangling algorithm that works and
+   then set the language appropriately.  If no demangling of any kind
+   is found, the language is set back to language_unknown, so we can
+   avoid doing this work again the next time we encounter the symbol.
+   Any required space to store the name is obtained from the specified
+   obstack. */
+
+void
+symbol_init_demangled_name (struct general_symbol_info *gsymbol,
+                            struct obstack *obstack)
+{
+  char *mangled = gsymbol->name;
+  char *demangled = NULL;
+
+  if (gsymbol->language == language_unknown)
+    gsymbol->language = language_auto;
+  if (gsymbol->language == language_cplus
+      || gsymbol->language == language_auto)
+    {
+      demangled =
+        cplus_demangle (gsymbol->name, DMGL_PARAMS | DMGL_ANSI);
+      if (demangled != NULL)
+        {
+          gsymbol->language = language_cplus;
+          gsymbol->language_specific.cplus_specific.demangled_name =
+            obsavestring (demangled, strlen (demangled), obstack);
+          xfree (demangled);
+        }
+      else
+        {
+          gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+        }
+    }
+  if (gsymbol->language == language_java)
+    {
+      demangled =
+        cplus_demangle (gsymbol->name,
+                        DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
+      if (demangled != NULL)
+        {
+          gsymbol->language = language_java;
+          gsymbol->language_specific.cplus_specific.demangled_name =
+            obsavestring (demangled, strlen (demangled), obstack);
+          xfree (demangled);
+        }
+      else
+        {
+          gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+        }
+    }
+  if (demangled == NULL
+      && (gsymbol->language == language_chill
+          || gsymbol->language == language_auto))
+    {
+      demangled =
+        chill_demangle (gsymbol->name);
+      if (demangled != NULL)
+        {
+          gsymbol->language = language_chill;
+          gsymbol->language_specific.chill_specific.demangled_name =
+            obsavestring (demangled, strlen (demangled), obstack);
+          xfree (demangled);
+        }
+      else
+        {
+          gsymbol->language_specific.chill_specific.demangled_name = NULL;
+        }
+    }
+}
+
+
 
 
 
@@ -570,6 +681,7 @@
 {
   char *modified_name = NULL;
   char *modified_name2 = NULL;
+  const char *mangled_name = NULL;
   int needtofreename = 0;
   struct symbol *returnval;
 
@@ -595,13 +707,14 @@
       modified_name2 = cplus_demangle (modified_name, DMGL_ANSI | DMGL_PARAMS);
       if (modified_name2)
 	{
+	  mangled_name = name;
 	  modified_name = modified_name2;
 	  needtofreename = 1;
 	}
     }
 
-  returnval = lookup_symbol_aux (modified_name, block, namespace,
-				 is_a_field_of_this, symtab);
+  returnval = lookup_symbol_aux (modified_name, mangled_name, block,
+				 namespace, is_a_field_of_this, symtab);
   if (needtofreename)
     xfree (modified_name2);
 
@@ -609,9 +722,9 @@
 }
 
 static struct symbol *
-lookup_symbol_aux (const char *name, const struct block *block,
-	       const namespace_enum namespace, int *is_a_field_of_this,
-	       struct symtab **symtab)
+lookup_symbol_aux (const char *name, const char *mangled_name,
+		   const struct block *block, const namespace_enum namespace,
+		   int *is_a_field_of_this, struct symtab **symtab)
 {
   register struct symbol *sym;
   register struct symtab *s = NULL;
@@ -626,7 +739,7 @@
 
   while (block != 0)
     {
-      sym = lookup_block_symbol (block, name, namespace);
+      sym = lookup_block_symbol (block, name, mangled_name, namespace);
       if (sym)
 	{
 	  block_found = block;
@@ -679,7 +792,7 @@
 	if (BLOCK_START (b) <= BLOCK_START (block)
 	    && BLOCK_END (b) > BLOCK_START (block))
 	  {
-	    sym = lookup_block_symbol (b, name, VAR_NAMESPACE);
+	    sym = lookup_block_symbol (b, name, mangled_name, VAR_NAMESPACE);
 	    if (sym)
 	      {
 		block_found = b;
@@ -717,7 +830,7 @@
   {
     bv = BLOCKVECTOR (s);
     block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-    sym = lookup_block_symbol (block, name, namespace);
+    sym = lookup_block_symbol (block, name, mangled_name, namespace);
     if (sym)
       {
 	block_found = block;
@@ -746,14 +859,14 @@
 	      bv = BLOCKVECTOR (s);
 	      block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
 	      sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
-					 namespace);
+					 mangled_name, namespace);
 	      /* We kept static functions in minimal symbol table as well as
 	         in static scope. We want to find them in the symbol table. */
 	      if (!sym)
 		{
 		  block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
 		  sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
-					     namespace);
+					     mangled_name, namespace);
 		}
 
 	      /* sym == 0 if symbol was found in the minimal symbol table
@@ -779,7 +892,7 @@
 	    {
 	      /* This is a mangled variable, look it up by its
 	         mangled name.  */
-	      return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
+	      return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name, block,
 					namespace, is_a_field_of_this, symtab);
 	    }
 	  /* There are no debug symbols for this file, or we are looking
@@ -797,7 +910,7 @@
 	s = PSYMTAB_TO_SYMTAB (ps);
 	bv = BLOCKVECTOR (s);
 	block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-	sym = lookup_block_symbol (block, name, namespace);
+	sym = lookup_block_symbol (block, name, mangled_name, namespace);
 	if (!sym)
 	  {
 	    /* This shouldn't be necessary, but as a last resort
@@ -806,7 +919,7 @@
 	     * the psymtab gets it wrong in some cases.
 	     */
 	    block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-	    sym = lookup_block_symbol (block, name, namespace);
+	    sym = lookup_block_symbol (block, name, mangled_name, namespace);
 	    if (!sym)
 	      error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
 %s may be an inlined function, or may be a template function\n\
@@ -830,7 +943,7 @@
   {
     bv = BLOCKVECTOR (s);
     block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-    sym = lookup_block_symbol (block, name, namespace);
+    sym = lookup_block_symbol (block, name, mangled_name, namespace);
     if (sym)
       {
 	block_found = block;
@@ -847,7 +960,7 @@
 	s = PSYMTAB_TO_SYMTAB (ps);
 	bv = BLOCKVECTOR (s);
 	block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-	sym = lookup_block_symbol (block, name, namespace);
+	sym = lookup_block_symbol (block, name, mangled_name, namespace);
 	if (!sym)
 	  {
 	    /* This shouldn't be necessary, but as a last resort
@@ -856,7 +969,7 @@
 	     * the psymtab gets it wrong in some cases.
 	     */
 	    block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-	    sym = lookup_block_symbol (block, name, namespace);
+	    sym = lookup_block_symbol (block, name, mangled_name, namespace);
 	    if (!sym)
 	      error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
 %s may be an inlined function, or may be a template function\n\
@@ -913,14 +1026,14 @@
 	      bv = BLOCKVECTOR (s);
 	      block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
 	      sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
-					 namespace);
+					 mangled_name, namespace);
 	      /* We kept static functions in minimal symbol table as well as
 	         in static scope. We want to find them in the symbol table. */
 	      if (!sym)
 		{
 		  block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
 		  sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
-					     namespace);
+					     mangled_name, namespace);
 		}
 	      /* If we found one, return it */
 	      if (sym)
@@ -957,8 +1070,9 @@
 		   && MSYMBOL_TYPE (msymbol) != mst_file_text
 		   && !STREQ (name, SYMBOL_NAME (msymbol)))
 	    {
-	      return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
-					namespace, is_a_field_of_this, symtab);
+	      return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name,
+					block, namespace, is_a_field_of_this,
+					symtab);
 	    }
 	}
     }
@@ -1084,7 +1198,7 @@
   {
     bv = BLOCKVECTOR (s);
     block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-    sym = lookup_block_symbol (block, name, STRUCT_NAMESPACE);
+    sym = lookup_block_symbol (block, name, NULL, STRUCT_NAMESPACE);
     if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
       {
 	return SYMBOL_TYPE (sym);
@@ -1098,7 +1212,7 @@
 	s = PSYMTAB_TO_SYMTAB (ps);
 	bv = BLOCKVECTOR (s);
 	block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-	sym = lookup_block_symbol (block, name, STRUCT_NAMESPACE);
+	sym = lookup_block_symbol (block, name, NULL, STRUCT_NAMESPACE);
 	if (!sym)
 	  {
 	    /* This shouldn't be necessary, but as a last resort
@@ -1107,7 +1221,7 @@
 	     * the psymtab gets it wrong in some cases.
 	     */
 	    block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-	    sym = lookup_block_symbol (block, name, STRUCT_NAMESPACE);
+	    sym = lookup_block_symbol (block, name, NULL, STRUCT_NAMESPACE);
 	    if (!sym)
 	      error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
 %s may be an inlined function, or may be a template function\n\
@@ -1131,7 +1245,7 @@
   {
     bv = BLOCKVECTOR (s);
     block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-    sym = lookup_block_symbol (block, name, STRUCT_NAMESPACE);
+    sym = lookup_block_symbol (block, name, NULL, STRUCT_NAMESPACE);
     if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
       {
 	return SYMBOL_TYPE (sym);
@@ -1145,7 +1259,7 @@
 	s = PSYMTAB_TO_SYMTAB (ps);
 	bv = BLOCKVECTOR (s);
 	block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-	sym = lookup_block_symbol (block, name, STRUCT_NAMESPACE);
+	sym = lookup_block_symbol (block, name, NULL, STRUCT_NAMESPACE);
 	if (!sym)
 	  {
 	    /* This shouldn't be necessary, but as a last resort
@@ -1154,7 +1268,7 @@
 	     * the psymtab gets it wrong in some cases.
 	     */
 	    block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-	    sym = lookup_block_symbol (block, name, STRUCT_NAMESPACE);
+	    sym = lookup_block_symbol (block, name, NULL, STRUCT_NAMESPACE);
 	    if (!sym)
 	      error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
 %s may be an inlined function, or may be a template function\n\
@@ -1198,10 +1312,15 @@
    binary search terminates, we drop through and do a straight linear
    search on the symbols.  Each symbol which is marked as being a C++
    symbol (language_cplus set) has both the encoded and non-encoded names
-   tested for a match. */
+   tested for a match.
+
+   If MANGLED_NAME is non-NULL, verify that any symbol we find has this
+   particular mangled name.
+*/
 
 struct symbol *
 lookup_block_symbol (register const struct block *block, const char *name,
+		     const char *mangled_name,
 		     const namespace_enum namespace)
 {
   register int bot, top, inc;
@@ -1261,14 +1380,19 @@
          return the first one; I believe it is now impossible for us
          to encounter two symbols with the same name and namespace
          here, because blocks containing argument symbols are no
-         longer sorted.  */
+         longer sorted.  The exception is for C++, where multiple functions
+	 (cloned constructors / destructors, in particular) can have
+	 the same demangled name.  So if we have a particular
+	 mangled name to match, try to do so.  */
 
       top = BLOCK_NSYMS (block);
       while (bot < top)
 	{
 	  sym = BLOCK_SYM (block, bot);
-	  if (SYMBOL_NAMESPACE (sym) == namespace &&
-	      SYMBOL_MATCHES_NAME (sym, name))
+	  if (SYMBOL_NAMESPACE (sym) == namespace
+	      && (mangled_name
+		  ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
+		  : SYMBOL_MATCHES_NAME (sym, name)))
 	    {
 	      return sym;
 	    }
@@ -1300,8 +1424,10 @@
       while (bot < top)
 	{
 	  sym = BLOCK_SYM (block, bot);
-	  if (SYMBOL_NAMESPACE (sym) == namespace &&
-	      SYMBOL_MATCHES_NAME (sym, name))
+	  if (SYMBOL_NAMESPACE (sym) == namespace
+	      && (mangled_name
+		  ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
+		  : SYMBOL_MATCHES_NAME (sym, name)))
 	    {
 	      /* If SYM has aliases, then use any alias that is active
 	         at the current PC.  If no alias is active at the current
@@ -3186,7 +3312,7 @@
   /* Search upwards from currently selected frame (so that we can
      complete on local vars.  */
 
-  for (b = get_selected_block (); b != NULL; b = BLOCK_SUPERBLOCK (b))
+  for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
     {
       if (!BLOCK_SUPERBLOCK (b))
 	{
@@ -3719,7 +3845,7 @@
   /* Search upwards from currently selected frame (so that we can
      complete on local vars.  */
 
-  for (b = get_selected_block (); b != NULL; b = BLOCK_SUPERBLOCK (b))
+  for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
     {
       if (!BLOCK_SUPERBLOCK (b))
 	{
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 75470e6..231364e 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -159,74 +159,12 @@
       }									\
   } while (0)
 
-/* Macro that attempts to initialize the demangled name for a symbol,
-   based on the language of that symbol.  If the language is set to
-   language_auto, it will attempt to find any demangling algorithm
-   that works and then set the language appropriately.  If no demangling
-   of any kind is found, the language is set back to language_unknown,
-   so we can avoid doing this work again the next time we encounter
-   the symbol.  Any required space to store the name is obtained from the
-   specified obstack. */
+#define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack) \
+  (symbol_init_demangled_name (&symbol->ginfo, (obstack)))
+extern void symbol_init_demangled_name (struct general_symbol_info *symbol,
+                                        struct obstack *obstack);
 
-#define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack)			\
-  do {									\
-    char *demangled = NULL;						\
-    if (SYMBOL_LANGUAGE (symbol) == language_unknown)                 \
-          SYMBOL_LANGUAGE (symbol) = language_auto;                    \
-    if (SYMBOL_LANGUAGE (symbol) == language_cplus			\
-	|| SYMBOL_LANGUAGE (symbol) == language_auto)			\
-      {									\
-	demangled =							\
-	  cplus_demangle (SYMBOL_NAME (symbol), DMGL_PARAMS | DMGL_ANSI);\
-	if (demangled != NULL)						\
-	  {								\
-	    SYMBOL_LANGUAGE (symbol) = language_cplus;			\
-	    SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = 			\
-	      obsavestring (demangled, strlen (demangled), (obstack));	\
-	    xfree (demangled);						\
-	  }								\
-	else								\
-	  {								\
-	    SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL;		\
-	  }								\
-      }									\
-    if (SYMBOL_LANGUAGE (symbol) == language_java)			\
-      {									\
-	demangled =							\
-	  cplus_demangle (SYMBOL_NAME (symbol),				\
-			  DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);		\
-	if (demangled != NULL)						\
-	  {								\
-	    SYMBOL_LANGUAGE (symbol) = language_java;			\
-	    SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = 			\
-	      obsavestring (demangled, strlen (demangled), (obstack));	\
-	    xfree (demangled);						\
-	  }								\
-	else								\
-	  {								\
-	    SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL;		\
-	  }								\
-      }									\
-    if (demangled == NULL						\
-	&& (SYMBOL_LANGUAGE (symbol) == language_chill			\
-	    || SYMBOL_LANGUAGE (symbol) == language_auto))		\
-      {									\
-	demangled =							\
-	  chill_demangle (SYMBOL_NAME (symbol));			\
-	if (demangled != NULL)						\
-	  {								\
-	    SYMBOL_LANGUAGE (symbol) = language_chill;			\
-	    SYMBOL_CHILL_DEMANGLED_NAME (symbol) = 			\
-	      obsavestring (demangled, strlen (demangled), (obstack));	\
-	    xfree (demangled);						\
-	  }								\
-	else								\
-	  {								\
-	    SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL;		\
-	  }								\
-      }									\
-  } while (0)
-
+  
 /* Macro that returns the demangled name for a symbol based on the language
    for that symbol.  If no demangled name exists, returns NULL. */
 
@@ -469,11 +407,15 @@
 
 /* Macro to loop through all symbols in a block BL.
    i counts which symbol we are looking at, and sym points to the current
-   symbol.  */
+   symbol.
+   The contortion at the end is to avoid reading past the last valid
+   BLOCK_SYM.  */
 #define ALL_BLOCK_SYMBOLS(bl, i, sym)			\
 	for ((i) = 0, (sym) = BLOCK_SYM ((bl), (i));	\
 	     (i) < BLOCK_NSYMS ((bl));			\
-	     ++(i), (sym) = BLOCK_SYM ((bl), (i)))
+	     ++(i), (sym) = ((i) < BLOCK_NSYMS ((bl)))	\
+			    ? BLOCK_SYM ((bl), (i))	\
+			    : NULL)
 
 /* Nonzero if symbols of block BL should be sorted alphabetically.
    Don't sort a block which corresponds to a function.  If we did the
@@ -1098,6 +1040,7 @@
 /* lookup a symbol by name, within a specified block */
 
 extern struct symbol *lookup_block_symbol (const struct block *, const char *,
+					   const char *,
 					   const namespace_enum);
 
 /* lookup a [struct, union, enum] by name, within a specified block */
@@ -1196,10 +1139,6 @@
    enum minimal_symbol_type,
    char *info, int section, asection * bfd_section, struct objfile *);
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
-extern CORE_ADDR find_stab_function_addr (char *, char *, struct objfile *);
-#endif
-
 extern unsigned int msymbol_hash_iw (const char *);
 
 extern unsigned int msymbol_hash (const char *);
diff --git a/gdb/target.c b/gdb/target.c
index d5f205f..2cd4928 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -861,9 +861,9 @@
 
   if (!write && trust_readonly)
     {
-      /* User-settable option, "trust-readonly".  If true, then
-	 memory from any SEC_READONLY bfd section may be read
-	 directly from the bfd file. */
+      /* User-settable option, "trust-readonly-sections".  If true,
+         then memory from any SEC_READONLY bfd section may be read
+         directly from the bfd file. */
 
       struct section_table *secp;
 
@@ -1653,31 +1653,47 @@
 }
 
 static void
+debug_print_register (const char * func, int regno)
+{
+  fprintf_unfiltered (gdb_stdlog, "%s ", func);
+  if (regno >= 0 && regno < NUM_REGS + NUM_PSEUDO_REGS
+      && REGISTER_NAME (regno) != NULL && REGISTER_NAME (regno)[0] != '\0')
+    fprintf_unfiltered (gdb_stdlog, "(%s)", REGISTER_NAME (regno));
+  else
+    fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
+  if (regno >= 0)
+    {
+      int i;
+      unsigned char *buf = alloca (MAX_REGISTER_RAW_SIZE);
+      read_register_gen (regno, buf);
+      fprintf_unfiltered (gdb_stdlog, " = ");
+      for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
+	{
+	  fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
+	}
+      if (REGISTER_RAW_SIZE (regno) <= sizeof (LONGEST))
+	{
+	  fprintf_unfiltered (gdb_stdlog, " 0x%s %s",
+			      paddr_nz (read_register (regno)),
+			      paddr_d (read_register (regno)));
+	}
+    }
+  fprintf_unfiltered (gdb_stdlog, "\n");
+}
+
+static void
 debug_to_fetch_registers (int regno)
 {
   debug_target.to_fetch_registers (regno);
-
-  fprintf_unfiltered (gdb_stdlog, "target_fetch_registers (%s)",
-		      regno != -1 ? REGISTER_NAME (regno) : "-1");
-  if (regno != -1)
-    fprintf_unfiltered (gdb_stdlog, " = 0x%lx %ld",
-			(unsigned long) read_register (regno),
-			(unsigned long) read_register (regno));
-  fprintf_unfiltered (gdb_stdlog, "\n");
+  debug_print_register ("target_fetch_registers", regno);
 }
 
 static void
 debug_to_store_registers (int regno)
 {
   debug_target.to_store_registers (regno);
-
-  if (regno >= 0 && regno < NUM_REGS)
-    fprintf_unfiltered (gdb_stdlog, "target_store_registers (%s) = 0x%lx %ld\n",
-			REGISTER_NAME (regno),
-			(unsigned long) read_register (regno),
-			(unsigned long) read_register (regno));
-  else
-    fprintf_unfiltered (gdb_stdlog, "target_store_registers (%d)\n", regno);
+  debug_print_register ("target_store_registers", regno);
+  fprintf_unfiltered (gdb_stdlog, "\n");
 }
 
 static void
diff --git a/gdb/target.h b/gdb/target.h
index b5d036b..1797fc1 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1184,7 +1184,8 @@
 
 extern int default_memory_insert_breakpoint (CORE_ADDR, char *);
 
-extern breakpoint_from_pc_fn memory_breakpoint_from_pc;
+extern const unsigned char *memory_breakpoint_from_pc (CORE_ADDR *pcptr,
+						       int *lenptr);
 
 
 /* From target.c */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2b75520..6c35655 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,265 @@
+2002-05-06  Ben Elliston  <bje@redhat.com>
+From Graydon Hoare  <graydon@redhat.com>
+
+	* config/sid.exp: Include support for "rawsid" protocol.
+
+2002-05-03  Jim Blandy  <jimb@redhat.com>
+
+	* gdb.c++/hang.exp: Check for corruption of the cv_type chain.
+	* gdb.c++/hang3.C: New file.
+
+2002-05-04  Andrew Cagney  <ac131313@redhat.com>
+
+	* gdb.base/default.exp: Remove obsolete code.
+	* gdb.c++/misc.exp: Ditto.  Update copyright.
+	* gdb.c++/cplusfuncs.exp: Ditto.  Update copyright.
+	* gdb.base/whatis.exp: Ditto.  Update copyright.
+	* gdb.base/scope.exp: Ditto.  Update copyright.
+	* gdb.base/ptype.exp: Ditto.  Update copyright.
+	* gdb.base/printcmds.exp: Ditto.  Update copyright.
+	* gdb.base/opaque.exp: Ditto.  Update copyright.
+	* gdb.base/list.exp: Ditto.
+	* gdb.base/funcargs.exp: Ditto.  Update copyright.
+	* gdb.hp/gdb.threads-hp/usrthbasic.c: Delete.
+	* gdb.hp/gdb.threads-hp/usrthbasic.exp: Delete.
+	* gdb.hp/gdb.threads-hp/usrthcore.c: Delete.
+	* gdb.hp/gdb.threads-hp/usrthcore.exp: Delete.
+	* gdb.hp/gdb.threads-hp/usrthfork.c: Delete.
+	* gdb.hp/gdb.threads-hp/usrthfork.exp: Delete.
+
+2002-05-02  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/watchpoint.exp: Add xscale target.
+	* gdb.base/long_long.exp: Add xscale target.
+	* gdb.base/default.exp: Add xscale target.
+
+2002-05-01  Jim Blandy  <jimb@redhat.com>
+
+	* gdb.c++/hang1.C, gdb.c++/hang2.C, gdb.c++/hang.H,
+	gdb.c++/hang.exp: New test.
+
+2002-05-01  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/completion.exp: Handle completions of "./Make" for
+	more than one completion possibility, as is the case when we
+	build and test in the source tree.
+
+2002-04-29  Anthony Green  <green@redhat.com>
+
+	* gdb.java/jmisc1.exp: New file.
+	* gdb.java/jmisc2.exp: New file.
+
+2002-04-24  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdb.threads/linux-dp.exp: Use 'unset' instead of 'array unset'.
+
+2002-04-23  Elena Zannoni  <ezannoni@redhat.com>
+
+	* gdb.base/help.exp: Change 'help status' to allow for target
+	dependent output differences.
+
+2002-04-22  Michael Chastain  <mec@shout.net>
+
+	* gdb.c++/local.exp: Add PR numbers: gdb/482, gdb/483.
+
+2002-04-22  Michael Chastain  <mec@shout.net>
+
+	* gdb.c++/method.exp: Fix syntax of reference to gdb/277.
+
+2002-04-17  David S. Miller  <davem@redhat.com>
+
+	* gdb.asm/sparc64.inc: New file.
+	* gdb.asm/asm-source.exp: Handle sparc64-*-*.
+
+2002-04-19  Elena Zannoni  <ezannoni@redhat.com>
+
+	* gdb.asm/asm-source.exp: Don't use a symlink, just copy the
+	instruction file directly into the build tree.  Clean up at end of
+	test.
+
+2002-04-18  David S. Miller  <davem@redhat.com>
+
+	* gdb.base/annota1.exp: Expect addresses as $hex + whitespace to
+	handle 64-bit platforms correctly.
+	* gdb.base/maint.exp: Likewise.
+
+2002-04-18  Kevin Buettner  <kevinb@redhat.com>
+
+	* gdb.base/shlib-call.exp (additional_flags): AIX doesn't need
+	``-fpic'' when compiling files comprising a shared library, but
+	it does need additional linker flags in order to find shared
+	libraries at run time.
+
+2002-04-18  Kevin Buettner  <kevinb@redhat.com>
+
+	* gdb.base/cvexpr.c (use): New function.
+	(main): Invoke use() on all global variables to prevent
+	some linkers from deleting these otherwise unused symbols.
+
+2002-04-17  Michael Chastain  <mec@shout.net>
+From David S. Miller  <davem@redhat.com>
+
+	* gdb.c++/ovldbreak.exp: Expect addresses as $hex + whitespace to
+	handle 64-bit platforms correctly.
+
+2002-04-12  Michael Snyder  <msnyder@redhat.com>
+From Jim Blandy  <jimb@redhat.com>
+        * gdb.base/foo.c (foox): Remove section attribute; the linker
+	script can handle this instead.
+	* gdb.base/bar.c (barx): Same.
+	* gdb.base/baz.c (bazx): Same.
+	* gdb.base/grbx.c (grbxx): Same.
+
+	* gdb.base/overlays.exp: New test: check that GDB's manual overlay
+	manager doesn't automatically unmap overlays unnecessarily.
+
+2002-04-10  Martin M. Hunt  <hunt@redhat.com>
+
+	* gdb.base/ending-run.exp: Fix pattern for Mips targets
+	stepping out of main.
+
+2002-04-09  Michael Chastain  <mec@shout.net>
+
+	* gdb.c++/local.cc (main): Move call to marker1() inside nested
+	scope so that the nested scope tests will make sense.
+	* gdb.c++/local.exp: Write patterns that actually work with gcc
+	(the HP patterns "were never known to work with gcc").
+	Keep the old aCC patterns too.
+
+2002-04-09  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdb.base/attach.exp: Correct target board test.
+
+2002-04-08  Michael Chastain  <mec@shout.net>
+
+	* gdb.c++/method.exp: Require "const ... A * ..." for "ptype this"
+	in a const method.  Add some xfail and fail cases for configurations
+	that do not emit the "const ...".
+
+2002-04-07  Michael Chastain  <mec@shout.net>
+
+	* gdb.c++/method.exp: Use gdb_test instead of send_gdb/gdb_expect.
+	Accept "A * const" and "const A * const" as type of "this".
+	Fix spelling of getFunky throughout.  Make messages uniform.
+
+2002-04-07  Elena Zannoni  <ezannoni@redhat.com>
+
+        Work around for PR gdb/285:
+	* gdb.asm/asm-source.exp: Bail out if multilibs are detected.
+
+2002-04-07  Elena Zannoni  <ezannoni@redhat.com>
+
+	* gdb.asm/asm-source.exp: Build symbolic link to arch specific
+	instructions file at run time instead of configure time.
+	Sometimes we run the test in a directory that is not the one we
+	configured in.
+	* gdb.asm/configure.in: Delete creation of symlink.
+	* gdb.asm/configure: Regenerate.
+
+2002-04-05  J. Brobecker  <brobecker@gnat.com>
+
+	* gdb.gdb/xfullpath.exp: New test, to exercise the new
+	xfullpath () function.
+
+2002-04-04  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdb.asm/Makefile.in: Correct dependencies.
+
+	* gdb.asm/powerpc.inc: New file.
+	* gdb.asm/asm-source.exp: Add PowerPC.
+	* gdb.asm/configure.in: Likewise.
+	* gdb.asm/configure: Regenerated.
+
+2002-04-04  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdb.base/relocate.exp: New file.
+	* gdb.base/relocate.c: New file.
+
+2002-04-04  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/step-test.exp: Update comment regarding stopping in
+	memcpy/bcopy calls inserted as part of the compiler runtime.
+
+2002-04-04  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/ovlymgr.c: Add overlay event breakpoint support.
+
+2002-04-03  Daniel Jacobowitz  <drow@mvista.com>
+
+	* lib/gdb.exp (gdb_test): Move -notransfer inside of gdb_expect.
+	(gdb_expect): Remove $notransfer hack.
+
+2002-04-02  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdb.c++/classes.exp ("calling method for small class"): Match
+	updated register output.
+
+2002-03-30  Daniel Jacobowitz  <drow@mvista.com>
+
+	Fix PR gdb/452
+	* gdb.base/dbx.exp: Restore old definition of gdb_file_cmd
+	when finished.  Make gdb_file_cmd send "exec-file" when
+	appropriate.
+
+2002-03-30  Daniel Jacobowitz  <drow@mvista.com>
+
+	* gdb.base/attach.exp: Remove extra setup_xfail.
+
+2002-03-26  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/default.exp: Add tests for dump, append, and restore.
+	* gdb.base/help.exp: Add tests for dump, append, and restore.
+	* gdb.base/dump.exp: New file, test dump, append and restore.
+	* gdb.base/dump.c: New file.
+
+2002-03-27  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/help.exp: Modify expect strings to reflect 
+	clean-ups in help messages.
+
+2002-03-26  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/step-test.exp: Accept stopping in memcpy/bcopy when we
+	have debugging info for those functions and the compiler uses them
+	internally to copy structs around.
+
+2002-03-26  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/list.exp: Revert the change made yesterday and add note
+	about why we don't list the default lines for remote targets.
+
+2002-03-25  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/help.exp: Clean up unnecessary wild cards in regexps.
+
+2002-03-25  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/list.exp: This test works on remote targets so remove
+	the short circuit for remote targets.  Update copyright.
+
+2002-03-25  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/attach.exp: Fix logic error that was suppressing this
+	test for all non hppa*-*-hpux* targets, instead of the hp target.
+	Move comments closer to the suppression point.  Also now need to
+	check that we are running natively.
+
+2002-03-22  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/default.exp: Add test for gcore.  Update copyright.
+	* gdb.base/help.exp: Add test for gcore.  Update copyright.
+
+2002-03-06  Fred Fish  <fnf@redhat.com>
+
+	* gdb.base/funcargs.c:  Remove extraneous ';' character.
+	* gdb.trace/gdb_c_test.c: Remove extraneous ';' character.
+
+2002-03-04  Michael Chastain  <mec@shout.net>
+
+	* gdb.mi/mi-var-cmd.exp: In test "create local variable func",
+	accommodate gcc v3 function signature.
+	* gdb.mi/mi0-var-cmd-exp: Ditto.
+
 2002-02-24  Andrew Cagney  <ac131313@redhat.com>
 
 	* testsuite/gdb.base/huge.c: Replace ``Linux'' with either
@@ -58,6 +320,10 @@
 	* gdb.c++/userdef.exp: Test overloaded operators properly.
 	Remove xfails.
 
+2002-02-14  Michael Snyder  <msnyder@redhat.com>
+
+	* gdb.base/gcore.exp: Relax recognition of function breakpoint.
+
 2002-02-14  Daniel Jacobowitz  <drow@mvista.com>
 
 	* gdb.base/a2-run.exp: Check for a remote target properly.
diff --git a/gdb/testsuite/config/sid.exp b/gdb/testsuite/config/sid.exp
index 07a684f..987c9be 100644
--- a/gdb/testsuite/config/sid.exp
+++ b/gdb/testsuite/config/sid.exp
@@ -53,6 +53,8 @@
 	}
 	if { [board_info target sim,protocol] == "sid" } {
 	    set spawncmd "[target_info sim] [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
+	} elseif { [board_info target sim,protocol] == "rawsid" } {
+	    set spawncmd "[target_info sim] [target_info sim,options] -$sidendian --gdb=$port"
 	} else {
 	    set spawncmd "../../sid/bsp/[target_info sim] $sidendian --gdb=$port [target_info sim,options]"
 	}
@@ -67,6 +69,8 @@
 	    # FIXME: sim,options may be from the build tree, should find
 	    # it in the install tree.
 	    set spawncmd "sid [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
+	} elseif { [board_info target sim,protocol] == "rawsid" } {
+	    set spawncmd "[target_info sim] [target_info sim,options] -$sidendian --gdb=$port"
 	} else {
 	    set spawncmd "[target_info sim] $sidendian --gdb=$port [target_info sim,options]"
 	}
diff --git a/gdb/testsuite/gdb.asm/Makefile.in b/gdb/testsuite/gdb.asm/Makefile.in
index ce169b5..05ed656 100644
--- a/gdb/testsuite/gdb.asm/Makefile.in
+++ b/gdb/testsuite/gdb.asm/Makefile.in
@@ -29,5 +29,8 @@
 	-rm -f *-init.exp
 	-rm -fr *.log summary detail *.plog *.sum *.psum site.*
 
-Makefile : $(srcdir)/Makefile.in $(srcdir)/configure.in
+Makefile : $(srcdir)/Makefile.in config.status
+	$(SHELL) ./config.status
+
+config.status: $(srcdir)/configure
 	$(SHELL) ./config.status --recheck
diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index 471b31a..298ba2e 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -1,4 +1,4 @@
-#   Copyright 1998, 2000 Free Software Foundation, Inc.
+# Copyright 1998, 2000, 2002 Free Software Foundation, Inc.
 # 
 # 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
@@ -53,9 +53,16 @@
 if [istarget "m32r*-*"] then {
     set asm-arch m32r
 }
+if [istarget "powerpc*-*"] then {
+    set asm-arch powerpc
+}
 if [istarget "sparc-*-*"] then {
     set asm-arch sparc
 }
+if [istarget "sparc64-*-*"] then {
+    set asm-arch sparc64
+    set asm-flags "-xarch=v9 -gstabs -I${srcdir}/${subdir} -I${objdir}/${subdir}"
+}
 if [istarget "xstormy16-*-*"] then {
     set asm-arch xstormy16
     set asm-flags "-gdwarf2 -I${srcdir}/${subdir} -I${objdir}/${subdir}"
@@ -64,11 +71,29 @@
     gdb_suppress_entire_file "Assembly source test -- not implemented for this target."
 }
 
+# Watch out, we are invoking the assembler, but the testsuite sets multilib
+# switches according to compiler syntax.  If we pass these options straight
+# to the assembler, they won't always make sense.  If we don't pass them to
+# the assembler, the final link will complain that the object files were
+# built with different defaults.  So no matter what we do, we lose.  We may as
+# well get out of this test sooner rather than later.
+set dest [target_info name]
+if [board_info $dest exists multilib_flags] {
+	set multilib_flags [board_info $dest multilib_flags]
+	if { "${multilib_flags}" != "" } {
+	   gdb_suppress_entire_file "Assembly source test -- multilibs not supported by this test."
+	   return;
+	 }
+}
+
 set testfile "asm-source"
 set binfile ${objdir}/${subdir}/${testfile}
 set src1 ${srcdir}/${subdir}/asmsrc1.s
 set src2 ${srcdir}/${subdir}/asmsrc2.s
 
+remote_exec build "rm -f ${subdir}/arch.inc"
+remote_download host ${srcdir}/${subdir}/${asm-arch}.inc ${subdir}/arch.inc
+
 if { "${asm-flags}" == "" } {
     #set asm-flags "-Wa,-gstabs,-I${srcdir}/${subdir},-I${objdir}/${subdir}"
     set asm-flags "-gstabs -I${srcdir}/${subdir} -I${objdir}/${subdir}"
@@ -256,3 +281,4 @@
 gdb_test "disassem foostatic" ".*<foostatic>:.*End of assembler dump." \
 	"look at static function"
 
+remote_exec build "rm -f ${subdir}/arch.inc"
diff --git a/gdb/testsuite/gdb.asm/configure b/gdb/testsuite/gdb.asm/configure
index 72945d2..1dd8138 100755
--- a/gdb/testsuite/gdb.asm/configure
+++ b/gdb/testsuite/gdb.asm/configure
@@ -28,6 +28,7 @@
 program_transform_name=s,x,x,
 silent=
 site=
+sitefile=
 srcdir=
 target=NONE
 verbose=
@@ -142,6 +143,7 @@
   --help                  print this message
   --no-create             do not create output files
   --quiet, --silent       do not print \`checking...' messages
+  --site-file=FILE        use FILE as the site file
   --version               print the version of autoconf that created configure
 Directory and file names:
   --prefix=PREFIX         install architecture-independent files in PREFIX
@@ -312,6 +314,11 @@
   -site=* | --site=* | --sit=*)
     site="$ac_optarg" ;;
 
+  -site-file | --site-file | --site-fil | --site-fi | --site-f)
+    ac_prev=sitefile ;;
+  -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
+    sitefile="$ac_optarg" ;;
+
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
@@ -477,12 +484,16 @@
 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
 
 # Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+if test -z "$sitefile"; then
+  if test -z "$CONFIG_SITE"; then
+    if test "x$prefix" != xNONE; then
+      CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+    else
+      CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+    fi
   fi
+else
+  CONFIG_SITE="$sitefile"
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
@@ -571,7 +582,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:575: checking host system type" >&5
+echo "configure:586: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -592,7 +603,7 @@
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:596: checking target system type" >&5
+echo "configure:607: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -610,7 +621,7 @@
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:614: checking build system type" >&5
+echo "configure:625: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -633,19 +644,6 @@
   program_prefix=${target_alias}-
 
 
-archinc=common.inc
-case ${target} in
-*arm-*-*) archinc=arm.inc ;;
-xscale-*-*) archinc=arm.inc ;;
-d10v-*-*) archinc=d10v.inc ;;
-s390-*-*) archinc=s390.inc ;;
-i[3456]86*) archinc=i386.inc ;;
-m32r*-*) archinc=m32r.inc ;;
-sparc-*-*) archinc=sparc.inc ;;
-xstormy16-*-*) archinc=xstormy16.inc ;;
-esac
-
-
 trap '' 1 2 15
 cat > confcache <<\EOF
 # This file is a shell script that caches the results of configure
@@ -902,51 +900,6 @@
 rm -f conftest.s*
 
 EOF
-
-cat >> $CONFIG_STATUS <<EOF
-ac_sources="$archinc"
-ac_dests="arch.inc"
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-srcdir=$ac_given_srcdir
-while test -n "$ac_sources"; do
-  set $ac_dests; ac_dest=$1; shift; ac_dests=$*
-  set $ac_sources; ac_source=$1; shift; ac_sources=$*
-
-  echo "linking $srcdir/$ac_source to $ac_dest"
-
-  if test ! -r $srcdir/$ac_source; then
-    { echo "configure: error: $srcdir/$ac_source: File not found" 1>&2; exit 1; }
-  fi
-  rm -f $ac_dest
-
-  # Make relative symlinks.
-  # Remove last slash and all that follows it.  Not all systems have dirname.
-  ac_dest_dir=`echo $ac_dest|sed 's%/[^/][^/]*$%%'`
-  if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then
-    # The dest file is in a subdirectory.
-    test ! -d "$ac_dest_dir" && mkdir "$ac_dest_dir"
-    ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`"
-    # A "../" for each directory in $ac_dest_dir_suffix.
-    ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[^/]*%../%g'`
-  else
-    ac_dest_dir_suffix= ac_dots=
-  fi
-
-  case "$srcdir" in
-  [/$]*) ac_rel_source="$srcdir/$ac_source" ;;
-  *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;;
-  esac
-
-  # Make a symlink if possible; otherwise try a hard link.
-  if ln -s $ac_rel_source $ac_dest 2>/dev/null ||
-    ln $srcdir/$ac_source $ac_dest; then :
-  else
-    { echo "configure: error: can not link $ac_dest to $srcdir/$ac_source" 1>&2; exit 1; }
-  fi
-done
-EOF
 cat >> $CONFIG_STATUS <<EOF
 
 EOF
diff --git a/gdb/testsuite/gdb.asm/configure.in b/gdb/testsuite/gdb.asm/configure.in
index 6e3b2c5..bded89e 100644
--- a/gdb/testsuite/gdb.asm/configure.in
+++ b/gdb/testsuite/gdb.asm/configure.in
@@ -12,18 +12,4 @@
 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../../..)
 AC_CANONICAL_SYSTEM
 
-dnl In default case we need to link with some file so use common.inc.
-archinc=common.inc
-case ${target} in
-*arm-*-*) archinc=arm.inc ;;
-xscale-*-*) archinc=arm.inc ;;
-d10v-*-*) archinc=d10v.inc ;;
-s390-*-*) archinc=s390.inc ;;
-i[[3456]]86*) archinc=i386.inc ;;
-m32r*-*) archinc=m32r.inc ;;
-sparc-*-*) archinc=sparc.inc ;;
-xstormy16-*-*) archinc=xstormy16.inc ;;
-esac
-AC_LINK_FILES($archinc,arch.inc)
-
 AC_OUTPUT(Makefile)
diff --git a/gdb/testsuite/gdb.asm/powerpc.inc b/gdb/testsuite/gdb.asm/powerpc.inc
new file mode 100644
index 0000000..5aefde2
--- /dev/null
+++ b/gdb/testsuite/gdb.asm/powerpc.inc
@@ -0,0 +1,46 @@
+	comment "subroutine prologue"
+	.macro gdbasm_enter
+	stwu	1, -16(1)
+	stw	31, 8(1)
+	mr	31, 1
+	mflr	0
+	stw	0, 20(1)
+	.endm
+
+	comment "subroutine epilogue"
+	.macro gdbasm_leave
+	lwz	0, 20(1)
+	mtlr	0
+	lwz	31, 8(1)
+	lwz	1, 0(1)
+	blr
+	.endm
+
+	.macro gdbasm_call subr
+	bl \subr
+	.endm
+
+	.macro gdbasm_several_nops
+	nop
+	nop
+	nop
+	nop
+	.endm
+
+	comment "exit (0)"
+	.macro gdbasm_exit0
+	comment "Don't know how to exit, but this will certainly halt..."
+	li	0, 0
+	lwz 	0, 0(0)
+	.endm
+
+	comment "crt0 startup"
+	.macro gdbasm_startup
+	.endm
+
+	comment "Declare a data variable"
+	.macro gdbasm_datavar name value
+	.data
+\name:
+	.long   \value
+	.endm
diff --git a/gdb/testsuite/gdb.asm/sparc64.inc b/gdb/testsuite/gdb.asm/sparc64.inc
new file mode 100644
index 0000000..fb2253e
--- /dev/null
+++ b/gdb/testsuite/gdb.asm/sparc64.inc
@@ -0,0 +1,34 @@
+	comment "subroutine prologue"
+	.macro gdbasm_enter
+	save	%sp, -192, %sp
+	.endm
+
+	comment "subroutine epilogue"
+	.macro gdbasm_leave
+	return %i7 + 8
+	nop
+	.endm
+
+	.macro gdbasm_call subr
+	call	\subr
+	nop
+	.endm
+
+	.macro gdbasm_several_nops
+	nop
+	nop
+	nop
+	nop
+	.endm
+
+	comment "exit (0)"
+	.macro gdbasm_exit0
+	comment "Don't know how to exit, but this will certainly halt..."
+	ldx	[%g0], %i0
+	.endm
+
+	comment "crt0 startup"
+	.macro gdbasm_startup
+	clr	%fp
+	.endm
+
diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
index bdb5646..bda2bec 100644
--- a/gdb/testsuite/gdb.base/annota1.exp
+++ b/gdb/testsuite/gdb.base/annota1.exp
@@ -115,7 +115,7 @@
 #
 send_gdb "info break\n" 
 gdb_expect {
- -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-headers\r\n\r\n\032\032field 0\r\nNum \r\n\032\032field 1\r\nType           \r\n\032\032field 2\r\nDisp \r\n\032\032field 3\r\nEnb \r\n\032\032field 4\r\nAddress    +\r\n\032\032field 5\r\nWhat\r\n\r\n\032\032breakpoints-table\r\n\r\n\032\032record\r\n\r\n\032\032field 0\r\n1   \r\n\032\032field 1\r\nbreakpoint     \r\n\032\032field 2\r\nkeep \r\n\032\032field 3\r\ny   \r\n\032\032field 4\r\n$hex \r\n\032\032field 5\r\nin main at ${srcdir}/${subdir}/${srcfile}:$main_line\r\n\r\n\032\032breakpoints-table-end\r\n$gdb_prompt$" \
+ -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-headers\r\n\r\n\032\032field 0\r\nNum \r\n\032\032field 1\r\nType           \r\n\032\032field 2\r\nDisp \r\n\032\032field 3\r\nEnb \r\n\032\032field 4\r\nAddress    +\r\n\032\032field 5\r\nWhat\r\n\r\n\032\032breakpoints-table\r\n\r\n\032\032record\r\n\r\n\032\032field 0\r\n1   \r\n\032\032field 1\r\nbreakpoint     \r\n\032\032field 2\r\nkeep \r\n\032\032field 3\r\ny   \r\n\032\032field 4\r\n$hex +\r\n\032\032field 5\r\nin main at ${srcdir}/${subdir}/${srcfile}:$main_line\r\n\r\n\032\032breakpoints-table-end\r\n$gdb_prompt$" \
 	{pass "breakpoint info"}
    -re ".*$gdb_prompt$" { fail "breakpoint info" }
    timeout { fail "breakpoint info (timeout)" }
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index ca6f5e0..2b341af 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -1,4 +1,4 @@
-#   Copyright 1997, 1999 Free Software Foundation, Inc.
+#   Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
 
 # 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
@@ -17,16 +17,6 @@
 # Please email any bugs, comments, and/or additions to this file to:
 # bug-gdb@prep.ai.mit.edu
 
-# On HP-UX 11.0, this test is causing a process running
-# the program "attach" to be left around spinning.
-# Until we figure out why, I am commenting out the test
-# to avoid polluting tiamat (our 11.0 nightly test machine)
-# with these processes. RT
-#
-# Setting the magic bit in the target app should work.
-# I added a "kill", and also a test for the R3 register
-#  warning.           JB
-# 
 if $tracelevel then {
 	strace $tracelevel
 	}
@@ -34,9 +24,19 @@
 set prms_id 0
 set bug_id 0
 
+# On HP-UX 11.0, this test is causing a process running the program
+# "attach" to be left around spinning.  Until we figure out why, I am
+# commenting out the test to avoid polluting tiamat (our 11.0 nightly
+# test machine) with these processes. RT
+#
+# Setting the magic bit in the target app should work.  I added a
+# "kill", and also a test for the R3 register warning.  JB
+if { [istarget "hppa*-*-hpux*"] } {
+    return 0
+}
 
-if { ![istarget "hppa*-*-hpux*"] } {
-    #setup_xfail "*-*-*"
+# are we on a target board
+if [is_remote target] then {
     return 0
 }
 
@@ -426,13 +426,6 @@
 gdb_reinitialize_dir $srcdir/$subdir
 do_call_attach_tests
 
-# Until "set follow-fork-mode" and "catch fork" are implemented on
-# other targets...
-#
-if ![istarget "hppa*-hp-hpux*"] then {
-   setup_xfail "*-*-*"
-}
-
 # Cleanup the files placed in /tmp and the symlinks
   remote_exec build "rm -f ${binfile} ${binfile2} /tmp/attach1.${pid} /tmp/attach2.${pid}"
 
diff --git a/gdb/testsuite/gdb.base/bar.c b/gdb/testsuite/gdb.base/bar.c
index 8a4da980..dd0bf92 100644
--- a/gdb/testsuite/gdb.base/bar.c
+++ b/gdb/testsuite/gdb.base/bar.c
@@ -1,4 +1,4 @@
-static int barx __attribute__ ((section (".data01"))) = 'b' + 'a' + 'r';
+static int barx = 'b' + 'a' + 'r';
 
 int bar (int x)
 {
diff --git a/gdb/testsuite/gdb.base/baz.c b/gdb/testsuite/gdb.base/baz.c
index a13cd16..8da4ffa 100644
--- a/gdb/testsuite/gdb.base/baz.c
+++ b/gdb/testsuite/gdb.base/baz.c
@@ -1,4 +1,4 @@
-static int bazx __attribute__ ((section (".data02"))) = 'b' + 'a' + 'z';
+static int bazx = 'b' + 'a' + 'z';
 
 int baz (int x)
 {
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index d8d5baf..f8f4568 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -1,4 +1,4 @@
-# Copyright 1998, 1999 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2002 Free Software Foundation, Inc.
 
 # 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
@@ -631,12 +631,18 @@
 #
 # So, we avoid long lines.  We `cd' to ${objdir} first, and then do
 # the completion relative to the current directory.
+#
+# Note that if we are building in the source tree, then there will be
+# more than one completion for ./Make, so we need to handle that also.
+# A better long term solution might be to create a temporary directory,
+# populate it with a set of known names, and use that directory to
+# test completions.
 
 gdb_test "cd ${objdir}" "Working directory ${objdir}.*" "cd to \${objdir}"
 send_gdb "file ./Make\t"
 sleep 1
 gdb_expect  {
-        -re "file ./Makefile.*$"\
+        -re "^file ./Make(\\\x07|)file.*$"\
             { send_gdb "\n"
               gdb_expect {
                       -re "\r\nA program is being debugged already\\.  Kill it\\? \\(y or n\\) $"\
diff --git a/gdb/testsuite/gdb.base/cvexpr.c b/gdb/testsuite/gdb.base/cvexpr.c
index 176bbe9..5871209 100644
--- a/gdb/testsuite/gdb.base/cvexpr.c
+++ b/gdb/testsuite/gdb.base/cvexpr.c
@@ -273,8 +273,162 @@
 float		(*v_float_func) (int, int*);
 double		(*v_double_func) (int, int*);
 
-
+void use (void *p)
+{
+}
 
 int main ()
 {
+  use (&v_char);
+  use (&v_signed_char);
+  use (&v_unsigned_char);
+
+  use (&v_short);
+  use (&v_signed_short);
+  use (&v_unsigned_short);
+
+  use (&v_int);
+  use (&v_signed_int);
+  use (&v_unsigned_int);
+
+  use (&v_long);
+  use (&v_signed_long);
+  use (&v_unsigned_long);
+
+  use (&v_long_long);
+  use (&v_signed_long_long);
+  use (&v_unsigned_long_long);
+
+  use (&v_float);
+  use (&v_double);
+
+  use (v_char_array);
+  use (v_signed_char_array);
+  use (v_unsigned_char_array);
+
+  use (v_short_array);
+  use (v_signed_short_array);
+  use (v_unsigned_short_array);
+
+  use (v_int_array);
+  use (v_signed_int_array);
+  use (v_unsigned_int_array);
+
+  use (v_long_array);
+  use (v_signed_long_array);
+  use (v_unsigned_long_array);
+
+  use (v_float_array);
+  use (v_double_array);
+
+  use (v_char_pointer);
+  use (v_signed_char_pointer);
+  use (v_unsigned_char_pointer);
+
+  use (v_short_pointer);
+  use (v_signed_short_pointer);
+  use (v_unsigned_short_pointer);
+
+  use (v_int_pointer);
+  use (v_signed_int_pointer);
+  use (v_unsigned_int_pointer);
+
+  use (v_long_pointer);
+  use (v_signed_long_pointer);
+  use (v_unsigned_long_pointer);
+
+  use (v_float_pointer);
+  use (v_double_pointer);
+
+  use (v_char_pointer_pointer);
+  use (v_signed_char_pointer_pointer);
+  use (v_unsigned_char_pointer_pointer);
+
+  use (v_short_pointer_pointer);
+  use (v_signed_short_pointer_pointer);
+  use (v_unsigned_short_pointer_pointer);
+
+  use (v_int_pointer_pointer);
+  use (v_signed_int_pointer_pointer);
+  use (v_unsigned_int_pointer_pointer);
+
+  use (v_long_pointer_pointer);
+  use (v_signed_long_pointer_pointer);
+  use (v_unsigned_long_pointer_pointer);
+
+  use (v_float_pointer_pointer);
+  use (v_double_pointer_pointer);
+
+  use (v_char_array_pointer);
+  use (v_signed_char_array_pointer);
+  use (v_unsigned_char_array_pointer);
+
+  use (v_short_array_pointer);
+  use (v_signed_short_array_pointer);
+  use (v_unsigned_short_array_pointer);
+
+  use (v_int_array_pointer);
+  use (v_signed_int_array_pointer);
+  use (v_unsigned_int_array_pointer);
+
+  use (v_long_array_pointer);
+  use (v_signed_long_array_pointer);
+  use (v_unsigned_long_array_pointer);
+
+  use (v_float_array_pointer);
+  use (v_double_array_pointer);
+
+  use (v_char_pointer_array);
+  use (v_signed_char_pointer_array);
+  use (v_unsigned_char_pointer_array);
+
+  use (v_short_pointer_array);
+  use (v_signed_short_pointer_array);
+  use (v_unsigned_short_pointer_array);
+
+  use (v_int_pointer_array);
+  use (v_signed_int_pointer_array);
+  use (v_unsigned_int_pointer_array);
+
+  use (v_long_pointer_array);
+  use (v_signed_long_pointer_array);
+  use (v_unsigned_long_pointer_array);
+
+  use (v_float_pointer_array);
+  use (v_double_pointer_array);
+
+  use (&v_struct1);
+  use (&v_struct2);
+  use (&v_struct3);
+
+  use (&v_union);
+  use (&v_union2);
+  use (&v_union3);
+
+  use (&v_boolean);
+  use (&v_boolean2);
+  use (&v_misordered);
+
+  use (v_char_func);
+  use (v_signed_char_func);
+  use (v_unsigned_char_func);
+
+  use (v_short_func);
+  use (v_signed_short_func);
+  use (v_unsigned_short_func);
+
+  use (v_int_func);
+  use (v_signed_int_func);
+  use (v_unsigned_int_func);
+
+  use (v_long_func);
+  use (v_signed_long_func);
+  use (v_unsigned_long_func);
+
+  use (v_long_long_func);
+  use (v_signed_long_long_func);
+  use (v_unsigned_long_long_func);
+
+  use (v_float_func);
+  use (v_double_func);
 }
diff --git a/gdb/testsuite/gdb.base/dbx.exp b/gdb/testsuite/gdb.base/dbx.exp
index 9df3bda..161333c 100644
--- a/gdb/testsuite/gdb.base/dbx.exp
+++ b/gdb/testsuite/gdb.base/dbx.exp
@@ -168,6 +168,11 @@
 # file into gdb for a dbx session. So why not just override gdb_file_cmd with the
 # right sequence of events, allowing gdb_load to do its normal thing? This way
 # remotes and simulators will work, too.
+#
+# [drow 2002-03-30]: We can restore the old gdb_file_cmd afterwards, though.
+set old_gdb_file_cmd_args [info args gdb_file_cmd]
+set old_gdb_file_cmd_body [info body gdb_file_cmd]
+
 proc gdb_file_cmd {arg} {
     global verbose
     global loadpath
@@ -206,6 +211,11 @@
             verbose "\t\tLoaded $arg into the $GDB"
             send_gdb "exec-file $arg\n" 
             gdb_expect {
+	        -re "A program is being debugged already.*Kill it.*y or n. $" {
+	            send_gdb "y\n"
+	                verbose "\t\tKilling previous program being debugged"
+	            exp_continue
+	        }
                 -re ".*$gdb_prompt $" {
                     verbose "\t\tLoaded $arg with new symbol table into $GDB"
                     return 0
@@ -221,23 +231,9 @@
             perror "$arg wasn't compiled with \"-g\""
             return -1
         }
-        -re "A program is being debugged already.*Kill it.*y or n. $" {
-            send_gdb "y\n"
-                verbose "\t\tKilling previous program being debugged"
-            exp_continue
-        }
         -re "Load new symbol table from \".*\".*y or n. $" {
             send_gdb "y\n"
-            gdb_expect {
-                -re "Reading symbols from.*done.*$gdb_prompt $" {
-                    verbose "\t\tLoaded $arg with new symbol table into $GDB"
-                    return 0
-                }
-                timeout {
-                    perror "(timeout) Couldn't load $arg, other program already loaded."
-                    return -1
-                }
-            }
+	    exp_continue
         }
         -re ".*No such file or directory.*$gdb_prompt $" {
             perror "($arg) No such file or directory\n"
@@ -339,4 +335,6 @@
 gdb_exit
 
 set GDBFLAGS $saved_gdbflags
+eval proc gdb_file_cmd {$old_gdb_file_cmd_args} {$old_gdb_file_cmd_body}
+
 return 0
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 17d7027..09b65a9 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -1,5 +1,5 @@
 #   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001
+#   2000, 2001, 2002
 #   Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,14 @@
 
 gdb_test "add-symbol-file" "add-symbol-file takes a file name and an address" "add-symbol-file"
 
+# test append
+gdb_test "append" "\"append\" must be followed by a subcommand\.\[\r\n\]+List of append subcommands:.*" 
+gdb_test "append binary" "\"append binary\" must be followed by a subcommand\.\[\r\n\]+List of append binary subcommands:.*" 
+gdb_test "append memory" "Missing filename\." 
+gdb_test "append value"  "Missing filename\." 
+gdb_test "append binary memory" "Missing filename\." 
+gdb_test "append binary value"  "Missing filename\." 
+
 setup_xfail "mips-idt-*"
 send_gdb "attach\n"
 gdb_expect {
@@ -53,12 +61,6 @@
     timeout { fail "(timeout) attach" }
 }
 
-# OBSOLETE # FIXME: attach kills the udi connection
-# OBSOLETE if { [istarget "a29k-*-udi"] } {
-# OBSOLETE     gdb_exit
-# OBSOLETE     gdb_start
-# OBSOLETE }
-
 if ![target_info exists use_gdb_stub] {
     gdb_test "break" "No default breakpoint address now." "break"
     foreach i "b br bre brea" {
@@ -67,7 +69,6 @@
 
     
     setup_xfail "mips-idt-*"
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_test "backtrace" "No stack."
 
     # ba and bac are no longer unique command prefixes. So these tests
@@ -76,7 +77,6 @@
     #
     foreach i "bt ba bac" {
 	setup_xfail "mips-idt-*"
-	# OBSOLETE setup_xfail "a29k-*-udi"
 	gdb_test $i "No stack." "backtrace \"$i\" abbreviation"
     }
 } else {
@@ -85,18 +85,10 @@
 
 # This works on the MIPS IDT board, but confuses future tests.
 if ![istarget "mips-idt-*"] then {
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_test "continue" "The program is not being run." "continue"
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_test "c" "The program is not being run." "continue \"c\" abbreviation"
 }
 
-# OBSOLETE # FIXME: continue kills the udi connection
-# OBSOLETE if [istarget "a29k-*-udi"] then {
-# OBSOLETE     gdb_exit
-# OBSOLETE     gdb_start
-# OBSOLETE }
-
 #test call
 gdb_test "call" "The history is empty..*" "call"
 
@@ -144,11 +136,6 @@
 #test detach
 gdb_test "detach" "" "detach"
 
-# OBSOLETE # FIXME: continue kills the udi connection
-# OBSOLETE if [istarget "a29k-*-udi"] then {
-# OBSOLETE     gdb_exit
-# OBSOLETE     gdb_start
-# OBSOLETE }
 if [istarget "h8300-*-hms"] then {
     gdb_exit
     gdb_start
@@ -191,6 +178,22 @@
 gdb_test "down" "No stack.*" "down"
 #test down-silently
 gdb_test "down-silently" "No stack." "down-silently"
+# test dump
+gdb_test "dump" "\"dump\" must be followed by a subcommand\.\[\r\n\]+List of dump subcommands:.*" 
+gdb_test "dump binary" "\"dump binary\" must be followed by a subcommand\.\[\r\n\]+List of dump binary subcommands:.*" 
+gdb_test "dump ihex" "\"dump ihex\" must be followed by a subcommand\.\[\r\n\]+List of dump ihex subcommands:.*" 
+gdb_test "dump memory" "Missing filename\." 
+gdb_test "dump srec" "\"dump srec\" must be followed by a subcommand\.\[\r\n\]+List of dump srec subcommands:.*" 
+gdb_test "dump tekhex" "\"dump tekhex\" must be followed by a subcommand\.\[\r\n\]+List of dump tekhex subcommands:.*" 
+gdb_test "dump value" "Missing filename\." 
+gdb_test "dump binary memory" "Missing filename\." 
+gdb_test "dump binary value"  "Missing filename\." 
+gdb_test "dump ihex memory" "Missing filename\." 
+gdb_test "dump ihex value"  "Missing filename\." 
+gdb_test "dump srec memory" "Missing filename\." 
+gdb_test "dump srec value"  "Missing filename\." 
+gdb_test "dump tekhex memory" "Missing filename\." 
+gdb_test "dump tekhex value"  "Missing filename\." 
 #test echo
 gdb_test "echo" "" "echo"
 #test enable breakpoints delete
@@ -226,13 +229,10 @@
 }
 
 #test frame "f" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "f" "No stack." "frame \"f\" abbreviation"
 #test frame
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "frame" "No stack." "frame"
 #test fg
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "fg" "The program is not being run." "fg"
 # FIXME: fg kills the udi connection
 #test file
@@ -253,12 +253,32 @@
 }
 
 #test finish
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "finish" "The program is not running." "finish"
 #test forward-search
 # The message here comes from the regexp library, not gdb, and so can
 # vary on different systems.
 gdb_test "forward-search" "No previous regular expression.*|There is no previous regular expression.*" "forward-search"
+#test gcore
+send_gdb "gcore\n"
+gdb_expect {
+    -re "You can\'t do that without a process to debug.*$gdb_prompt $" {
+	pass "gcore"
+    }
+    -re "Undefined command: .*$gdb_prompt $" {
+	pass "gcore"
+    }
+    default { fail "gcore" }
+}
+send_gdb "generate-core-file\n"
+gdb_expect {
+    -re "You can\'t do that without a process to debug.*$gdb_prompt $" {
+	pass "generate-core-file"
+    }
+    -re "Undefined command: .*$gdb_prompt $" {
+	pass "generate-core-file"
+    }
+    default { fail "generate-core-file" }
+}
 #test help "h" abbreviation
 gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- Aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "help \"h\" abbreviation"
 #test help
@@ -274,7 +294,6 @@
 #test info address
 gdb_test "info address" "Argument required." "info address"
 #test info all-registers
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "info all-registers" "The program has no registers now." "info all-registers"
 #test info args
 gdb_test "info args" "No frame selected." "info args"
@@ -303,6 +322,8 @@
 #test info float
 if [istarget "arm*-*-*"] then {
     gdb_test "info float" "Software FPU type.*mask:.*flags:.*" "info float"
+} elseif [istarget "xscale*-*-*"] then {
+    gdb_test "info float" "Software FPU type.*mask:.*flags:.*" "info float"
 } elseif [istarget "thumb*-*-*"] then {
     gdb_test "info float" "Software FPU type.*mask:.*flags:.*" "info float"
 } elseif [istarget "strongarm*-*-*"] then {
@@ -317,16 +338,12 @@
 #test info locals
 gdb_test "info locals" "No frame selected." "info locals"
 #test info program
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "info program" "The program being debugged is not being run." "info program"
 #test info registers
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "info registers" "The program has no registers now." "info registers"
 #test info stack "s" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "info s" "No stack." "info stack \"s\" abbreviation"
 #test info stack
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "info stack" "No stack." "info stack"
 #test info set
 # FIXME -- needs to match the entire output
@@ -353,7 +370,6 @@
 #test inspect
 gdb_test "inspect" "The history is empty." "inspect"
 #test jump
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "jump" "The program is not being run." "jump"
 #test kill
 gdb_test "kill" "The program is not being run." "kill"
@@ -367,16 +383,12 @@
 # to deduce the filename from the exec file.
 gdb_test "load" "You can't do that when your target is `None'.*|The load command takes a file name.*|Must specify at least a file name with the load command.*|.*Use the .file. or .exec-file. command.*" "load"
 #test next "n" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "n" "The program is not being run." "next \"n\" abbreviation"
 #test next
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "next" "The program is not being run." "next"
 #test nexti "ni" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "ni" "The program is not being run." "nexti \"ni\" abbreviation"
 #test nexti
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "nexti" "The program is not being run." "nexti"
 #test output
 gdb_test "output" "Argument required .expression to compute.*" "output"
@@ -470,8 +482,11 @@
 #test rbreak
 gdb_test "rbreak" "" "rbreak"
 
+# test restore
+gdb_test "restore" "You can't do that without a process to debug\."
+
 #test return
-# The middle case accomodated the OBSOLETE a29k, where doing the "ni"
+# The middle case accomodated the obsolete a29k, where doing the "ni"
 # above causes an initial stack to be created.
 gdb_test "return" "No selected frame..*" "return"  "Make .* return now.*y or n. $" "y"
 
@@ -479,10 +494,8 @@
 #test reverse-search
 gdb_test "reverse-search" "No previous regular expression.*|There is no previous regular expression.*" "reverse-search"
 #test step "s" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "s" "The program is not being run." "step \"s\" abbreviation #1"
 #test step
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "step" "The program is not being run." "step #1"
 #test search
 gdb_test "search" "No previous regular expression.*|There is no previous regular expression.*" "search"
@@ -667,21 +680,16 @@
 #test show
 gdb_test "show" "confirm:  *Whether to confirm potentially dangerous operations is on.(\[^\r\n\]*\[\r\n\])+history filename:  *The filename in which to record the command history is (\[^\r\n\]*\[\r\n\])+history save:  *Saving of the history record on exit is on.(\[^\r\n\]*\[\r\n\])+history size:  *The size of the command history is(\[^\r\n\]*\[\r\n\])+listsize:  *Number of source lines gdb will list by default is 10(\[^\r\n]*\[\r\n\])+print elements:  *Limit on string chars or array elements to print is 200..*" "show"
 #test stepi "si" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test  "si" "The program is not being run." "stepi \"si\" abbreviation"
 #test stepi
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "stepi" "The program is not being run." "stepi"
 #test signal
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "signal" "The program is not being run." "signal"
 #test source
 gdb_test "source" "source command requires pathname of file to source..*|No such file or directory.*" "source"
 #test step "s" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "s" "The program is not being run." "step \"s\" abbreviation #2"
 #test step
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "step" "The program is not being run." "step #2"
 #test symbol-file
 gdb_test "symbol-file" "" "symbol-file"
@@ -752,10 +760,8 @@
 #test tty
 gdb_test "tty" "Argument required .terminal name for running target process.*" "tty"
 #test until "u" abbreviation
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "u" "The program is not running." "until \"u\" abbreviation"
 #test until
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "until" "The program is not running." "until"
 #test undisplay
 # FIXME -- need to dump full output to detailed log
@@ -798,7 +804,6 @@
 #test whatis
 gdb_test "whatis" "The history is empty." "whatis"
 #test where
-# OBSOLETE setup_xfail "a29k-*-udi"
 gdb_test "where" "No stack." "where"
 #test x
 #The case in which it prints a number is for vxgdb.
diff --git a/gdb/testsuite/gdb.base/dump.c b/gdb/testsuite/gdb.base/dump.c
new file mode 100644
index 0000000..784edf6
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dump.c
@@ -0,0 +1,44 @@
+#define ARRSIZE 32
+int intarray[ARRSIZE], intarray2[ARRSIZE];
+
+struct teststruct {
+  int a;
+  int b;
+  int c;
+  int d;
+  int e;
+  int f;
+  int g;
+} intstruct, intstruct2;
+
+void checkpoint1 ()
+{
+  /* intarray and teststruct have been initialized. */
+}
+
+void
+zero_all ()
+{
+  memset ((char *) &intarray,   0, sizeof (intarray));
+  memset ((char *) &intarray2,  0, sizeof (intarray2));
+  memset ((char *) &intstruct,  0, sizeof (intstruct));
+  memset ((char *) &intstruct2, 0, sizeof (intstruct2));
+}
+
+main()
+{
+  int i;
+
+  for (i = 0; i < ARRSIZE; i++)
+    intarray[i] = i+1;
+
+  intstruct.a = 12 * 1;
+  intstruct.b = 12 * 2;
+  intstruct.c = 12 * 3;
+  intstruct.d = 12 * 4;
+  intstruct.e = 12 * 5;
+  intstruct.f = 12 * 6;
+  intstruct.g = 12 * 7;
+
+  checkpoint1 ();
+}
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
new file mode 100644
index 0000000..826fdfb
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -0,0 +1,442 @@
+
+# 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.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Michael Snyder (msnyder@redhat.com)
+# This is a test for the gdb command "dump".
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+set testfile "dump"
+
+set srcfile  ${testfile}.c
+set binfile  ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Clean up any stale output files from previous test runs
+
+remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
+
+# Test help (FIXME:)
+
+# Run target program until data structs are initialized.
+
+if { ! [ runto checkpoint1 ] } then {
+    gdb_suppress_entire_file "Program failed to run, so all tests in this file will automatically fail."
+}
+
+# Now generate some dump files.
+
+proc make_dump_file { command msg } {
+  global gdb_prompt
+
+    send_gdb "${command}\n"
+    gdb_expect {
+	-re ".*\[Ee\]rror.*$gdb_prompt $"      { fail $msg }
+	-re ".*\[Ww\]arning.*$gdb_prompt $"    { fail $msg }
+	-re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
+	-re ".*$gdb_prompt $" { pass $msg }
+	timeout                                { fail "$msg (timeout)" }
+    }
+}
+
+make_dump_file "dump val intarr1.bin intarray" \
+	"dump array as value, default"
+
+make_dump_file "dump val intstr1.bin intstruct" \
+	"dump struct as value, default"
+
+make_dump_file "dump bin val intarr1b.bin intarray" \
+	"dump array as value, binary"
+
+make_dump_file "dump bin val intstr1b.bin intstruct" \
+	"dump struct as value, binary"
+
+make_dump_file "dump srec val intarr1.srec intarray" \
+	"dump array as value, srec"
+
+make_dump_file "dump srec val intstr1.srec intstruct" \
+	"dump struct as value, srec"
+
+make_dump_file "dump ihex val intarr1.ihex intarray" \
+	"dump array as value, intel hex"
+
+make_dump_file "dump ihex val intstr1.ihex intstruct" \
+	"dump struct as value, intel hex"
+
+make_dump_file "dump tekhex val intarr1.tekhex intarray" \
+	"dump array as value, tekhex"
+
+make_dump_file "dump tekhex val intstr1.tekhex intstruct" \
+	"dump struct as value, tekhex"
+
+proc capture_value { expression } {
+    global gdb_prompt
+    global expect_out
+
+    set output_string ""
+    send_gdb "print ${expression}\n"
+    gdb_expect {
+	-re ".*\[\r\n\]+.\[0123456789\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
+	    set output_string $expect_out(1,string)
+	}
+	default {
+	    fail "capture_value failed on $expression."
+	}
+    }
+    return $output_string
+}
+
+set array_start  [capture_value "/x &intarray\[0\]"]
+set array_end    [capture_value "/x &intarray\[32\]"]
+set struct_start [capture_value "/x &intstruct"]
+set struct_end   [capture_value "/x &intstruct + 1"]
+
+set array_val    [capture_value "intarray"]
+set struct_val   [capture_value "intstruct"]
+
+make_dump_file "dump mem intarr2.bin $array_start $array_end" \
+	"dump array as memory, default"
+
+make_dump_file "dump  mem intstr2.bin $struct_start $struct_end" \
+	"dump struct as memory, default"
+
+make_dump_file "dump bin mem intarr2b.bin $array_start $array_end" \
+	"dump array as memory, binary"
+
+make_dump_file "dump bin mem intstr2b.bin $struct_start $struct_end" \
+	"dump struct as memory, binary"
+
+make_dump_file "dump srec mem intarr2.srec $array_start $array_end" \
+	"dump array as memory, srec"
+
+make_dump_file "dump srec mem intstr2.srec $struct_start $struct_end" \
+	"dump struct as memory, srec"
+
+make_dump_file "dump ihex mem intarr2.ihex $array_start $array_end" \
+	"dump array as memory, ihex"
+
+make_dump_file "dump ihex mem intstr2.ihex $struct_start $struct_end" \
+	"dump struct as memory, ihex"
+
+make_dump_file "dump tekhex mem intarr2.tekhex $array_start $array_end" \
+	"dump array as memory, tekhex"
+
+make_dump_file "dump tekhex mem intstr2.tekhex $struct_start $struct_end" \
+	"dump struct as memory, tekhex"
+
+# test complex expressions
+make_dump_file \
+	"dump srec mem intarr3.srec &intarray \(char *\) &intarray + sizeof intarray" \
+	"dump array as mem, srec, expressions"
+
+
+# Now start a fresh gdb session, and reload the saved value files.
+
+gdb_exit
+gdb_start
+gdb_file_cmd ${binfile}
+
+# Reload saved values one by one, and compare.
+
+if { ![string compare $array_val [capture_value "intarray"]] } then {
+    fail "start with intarray un-initialized"
+} else {
+    pass "start with intarray un-initialized"
+}
+
+if { ![string compare $struct_val [capture_value "intstruct"]] } then {
+    fail "start with intstruct un-initialized"
+} else {
+    pass "start with intstruct un-initialized"
+}
+
+proc test_reload_saved_value { filename msg oldval newval } {
+    global gdb_prompt
+    
+    gdb_file_cmd $filename
+    if { ![string compare $oldval [capture_value $newval]] } then { 
+	pass $msg 
+    } else {
+	fail $msg 
+    }
+}
+
+proc test_restore_saved_value { restore_args msg oldval newval } {
+    global gdb_prompt
+    
+    gdb_test "restore $restore_args" \
+	    "Restoring .*" \
+	    "Restore command, $msg"
+
+    if { ![string compare $oldval [capture_value $newval]] } then { 
+	pass "Restored value, $msg"
+    } else {
+	fail "Restored value, $msg"
+    }
+}
+
+test_reload_saved_value "intarr1.srec" "reload array as value, srec" \
+	$array_val "intarray"
+test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
+	$struct_val "intstruct"
+test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
+	$array_val "intarray"
+test_reload_saved_value "intstr2.srec" "reload struct as memory, srec" \
+	$struct_val "intstruct"
+
+test_reload_saved_value "intarr1.ihex" "reload array as value, intel hex" \
+	$array_val "intarray"
+test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
+	$struct_val "intstruct"
+test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
+	$array_val "intarray"
+test_reload_saved_value "intstr2.ihex" "reload struct as memory, intel hex" \
+	$struct_val "intstruct"
+
+test_reload_saved_value "intarr1.tekhex" "reload array as value, tekhex" \
+	$array_val "intarray"
+test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
+	$struct_val "intstruct"
+test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
+	$array_val "intarray"
+test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
+	$struct_val "intstruct"
+
+# Start a fresh gdb session
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Run to main.
+if { ! [ runto main ] } then {
+    gdb_suppress_entire_file "Program failed to run, so remaining tests in this file will automatically fail."
+}
+
+if { ![string compare $array_val [capture_value "intarray"]] } then {
+    fail "start with intarray un-initialized, runto main"
+} else {
+    pass "start with intarray un-initialized, runto main"
+}
+
+if { ![string compare $struct_val [capture_value "intstruct"]] } then {
+    fail "start with intstruct un-initialized, runto main"
+} else {
+    pass "start with intstruct un-initialized, runto main"
+}
+
+test_restore_saved_value "intarr1.srec" "array as value, srec" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr1.srec" "struct as value, srec" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" "void" "zero all"
+
+test_restore_saved_value "intarr2.srec" "array as memory, srec" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr2.srec" "struct as memory, srec" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.ihex" "array as value, ihex" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr1.ihex" "struct as value, ihex" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr2.ihex" "array as memory, ihex" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr2.ihex" "struct as memory, ihex" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.tekhex" "array as value, tekhex" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr1.tekhex" "struct as value, tekhex" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr2.tekhex" "array as memory, tekhex" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr2.tekhex" "struct as memory, tekhex" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.bin binary $array_start" \
+	"array as value, binary" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr1.bin binary $struct_start" \
+	"struct as value, binary" \
+	$struct_val "intstruct"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr2.bin binary $array_start" \
+	"array as memory, binary" \
+	$array_val "intarray"
+
+test_restore_saved_value "intstr2.bin binary $struct_start" \
+	"struct as memory, binary" \
+	$struct_val "intstruct"
+
+# test restore with offset.
+
+set array2_start   [capture_value "/x &intarray2\[0\]"]
+set struct2_start  [capture_value "/x &intstruct2"]
+set array2_offset  \
+	[capture_value "/x (char *) &intarray2 - (char *) &intarray"]
+set struct2_offset \
+	[capture_value "/x (char *) &intstruct2 - (char *) &intstruct"]
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.srec $array2_offset" \
+	"array copy, srec" \
+	$array_val "intarray2"
+
+test_restore_saved_value "intstr1.srec $struct2_offset" \
+	"struct copy, srec" \
+	$struct_val "intstruct2"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.ihex $array2_offset" \
+	"array copy, ihex" \
+	$array_val "intarray2"
+
+test_restore_saved_value "intstr1.ihex $struct2_offset" \
+	"struct copy, ihex" \
+	$struct_val "intstruct2"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.tekhex $array2_offset" \
+	"array copy, tekhex" \
+	$array_val "intarray2"
+
+test_restore_saved_value "intstr1.tekhex $struct2_offset" \
+	"struct copy, tekhex" \
+	$struct_val "intstruct2"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.bin binary $array2_start" \
+	"array copy, binary" \
+	$array_val "intarray2"
+
+test_restore_saved_value "intstr1.bin binary $struct2_start" \
+	"struct copy, binary" \
+	$struct_val "intstruct2"
+
+#
+# test restore with start/stop addresses.
+#
+# For this purpose, we will restore just the third element of the array, 
+# and check to see that adjacent elements are not modified.
+#
+# We will need the address and offset of the third and fourth elements.
+#
+
+set element3_start  [capture_value "/x &intarray\[3\]"]
+set element4_start  [capture_value "/x &intarray\[4\]"]
+set element3_offset \
+	[capture_value "/x (char *) &intarray\[3\] - (char *) &intarray\[0\]"]
+set element4_offset \
+	[capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.srec 0 $element3_start $element4_start" \
+	"array partial, srec" \
+	[capture_value "4"] "intarray\[3\]"
+
+gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
+gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.ihex 0 $element3_start $element4_start" \
+	"array partial, ihex" \
+	[capture_value "4"] "intarray\[3\]"
+
+gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
+gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value "intarr1.tekhex 0 $element3_start $element4_start" \
+	"array partial, tekhex" \
+	[capture_value "4"] "intarray\[3\]"
+
+gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
+gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
+
+gdb_test "print zero_all ()" ""
+
+test_restore_saved_value \
+    "intarr1.bin binary $array_start $element3_offset $element4_offset" \
+    "array partial, binary" \
+    [capture_value "4"] "intarray\[3\]"
+
+gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
+gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
+
+gdb_test "print zero_all ()" "" ""
+
+# restore with expressions 
+test_restore_saved_value \
+	"intarr3.srec ${array2_start}-${array_start} &intarray\[3\] &intarray\[4\]" \
+	"array partial with expressions" \
+	[capture_value "4"] "intarray2\[3\]"
+
+gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
+gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
+
+
+# clean up files
+
+remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
+
diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp
index 80f1cc0..df6a708 100644
--- a/gdb/testsuite/gdb.base/ending-run.exp
+++ b/gdb/testsuite/gdb.base/ending-run.exp
@@ -178,6 +178,10 @@
 		# This is what happens on Sanyo XStormy16
 		pass "step out of main"
 	    }
+	    -re ".*init ().*$gdb_prompt $" {
+		# This is what happens on many Mips targets
+		pass "step out of main"
+	    }
 	    -re ".*in ..change.mode ().*$gdb_prompt $" {
 		# This is what happens on ARM in thumb mode -fn 2000-02-01
 		pass "step out of main on ARM thumb"
diff --git a/gdb/testsuite/gdb.base/foo.c b/gdb/testsuite/gdb.base/foo.c
index ada9cf4..2553607 100644
--- a/gdb/testsuite/gdb.base/foo.c
+++ b/gdb/testsuite/gdb.base/foo.c
@@ -1,4 +1,4 @@
-static int foox __attribute__ ((section (".data00"))) = 'f' + 'o' + 'o';
+static int foox = 'f' + 'o' + 'o';
 
 int foo (int x)
 {
diff --git a/gdb/testsuite/gdb.base/funcargs.c b/gdb/testsuite/gdb.base/funcargs.c
index 31c5eec..f7dfc64 100644
--- a/gdb/testsuite/gdb.base/funcargs.c
+++ b/gdb/testsuite/gdb.base/funcargs.c
@@ -747,7 +747,7 @@
   call2f (f, l, d, c, f, s, d, i);
   call2g (l, d, c, f, s, d, i, f);
   call2h (d, c, f, s, d, i, f, l);
-  call2i (c, f, c, c, d, c, c, c, f, s, c, d);;
+  call2i (c, f, c, c, d, c, c, c, f, s, c, d);
 
   /* Test dereferencing pointers to various integral and floating types */
 
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 3b837bc..2ed154a 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -1,4 +1,4 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -58,9 +58,6 @@
     gdb_breakpoint call0e
 
     # Run; should stop at call0a and print actual arguments.
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
     gdb_run_cmd
     gdb_expect {
@@ -118,9 +115,6 @@
     gdb_breakpoint call1e;
 
     # Run; should stop at call1a and print actual arguments.
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
     gdb_run_cmd
     gdb_expect {
@@ -184,9 +178,6 @@
     # Run; should stop at call2a and print actual arguments.
 
     setup_xfail "i960-*-*" 1813
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
     # The debug info. for "f" is not correct. It's a known bug.
     if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*}
@@ -285,9 +276,6 @@
     # Run; should stop at call3a and print actual arguments.
     # Try dereferencing the arguments.
 
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_run_cmd
     gdb_expect {
 	 -re ".* call3a \\(cp=$hex \"a.*\", sp=$hex, ip=$hex, lp=$hex\\) .*$gdb_prompt $" { pass "run to call3a" }
@@ -344,9 +332,6 @@
     # Run; should stop at call4a and print actual arguments.
     # Try dereferencing the arguments.
 
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_run_cmd
     gdb_expect {
 	 -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" {
@@ -403,9 +388,6 @@
     # Run; should stop at call5a and print actual arguments.
     # Try dereferencing the arguments.
 
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_run_cmd
     gdb_expect {
 	 -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" {
@@ -480,9 +462,6 @@
     # Run; should stop at call6a and print actual arguments.
     # Print backtrace.
 
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_run_cmd
     gdb_expect {
 	 -re ".*Breakpoint $decimal, call6a .*$gdb_prompt $" { pass "run to call6a" }
@@ -754,9 +733,6 @@
     # Run; should stop at call7a and print actual arguments.
     # Print backtrace.
 
-    # OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-    # OBSOLETE # code is broken.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_run_cmd
     gdb_expect {
 	 -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" {
@@ -983,9 +959,6 @@
     }
 
     if ![istarget sparclet-*-*] {
-	# OBSOLETE # The a29k fails all of these tests, perhaps because the prologue
-	# OBSOLETE # code is broken.
-	# OBSOLETE setup_xfail "a29k-*-udi"
 	send_gdb "backtrace 100\n"
 	gdb_expect_list "recursive passing of structs by value" ".*$gdb_prompt $" {
 	    ".*\[\r\n\]#0 .* hitbottom \\(\\) "
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index da3ab49..f8d5baa 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -85,7 +85,7 @@
 gdb_test "break terminal_func" "Breakpoint .* at .*${srcfile}, line .*" \
 	"set breakpoint at terminal_func"
 
-gdb_test "continue" "Breakpoint .*, terminal_func.*" \
+gdb_test "continue" "Breakpoint .* terminal_func.*" \
 	"continue to terminal_func"
 
 set print_prefix ".\[0123456789\]* = "
diff --git a/gdb/testsuite/gdb.base/grbx.c b/gdb/testsuite/gdb.base/grbx.c
index 92f7323..58034bb 100644
--- a/gdb/testsuite/gdb.base/grbx.c
+++ b/gdb/testsuite/gdb.base/grbx.c
@@ -1,4 +1,4 @@
-static int grbxx __attribute__ ((section (".data03"))) = 'g' + 'r' + 'b' + 'x';
+static int grbxx = 'g' + 'r' + 'b' + 'x';
 
 int grbx (int x)
 {
diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp
index a09f8da..4b3d2ee 100644
--- a/gdb/testsuite/gdb.base/help.exp
+++ b/gdb/testsuite/gdb.base/help.exp
@@ -1,5 +1,5 @@
 #   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000
+#   2000, 2002
 #   Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -35,512 +35,560 @@
 
 # use a larger expect input buffer for long help outputs.
 # test help add-symbol-file
-gdb_test "help add-symbol-file" "Usage: add-symbol-file FILE ADDR .-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> ....*\[\r\n\]+Load the symbols from FILE, assuming FILE has been dynamically loaded..*\[\r\n\]+ADDR is the starting address of the file's text..*\[\r\n\]+The optional arguments are section-name section-address pairs and.*\[\r\n\]+should be specified if the data and bss segments are not contiguous.*\[\r\n\]+with the text. SECT is a section name to be loaded at SECT_ADDR." "help add-symbol-file"
+gdb_test "help add-symbol-file" "Usage: add-symbol-file FILE ADDR \\\[-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> \.\.\.\\\]\[\r\n\]+Load the symbols from FILE, assuming FILE has been dynamically loaded\.\[\r\n\]+ADDR is the starting address of the file's text\.\[\r\n\]+The optional arguments are section-name section-address pairs and\[\r\n\]+should be specified if the data and bss segments are not contiguous\[\r\n\]+with the text\.  SECT is a section name to be loaded at SECT_ADDR\." "help add-symbol-file"
 # test help aliases
-gdb_test "help aliases" "Aliases of other commands..*\[\r\n\]+List of commands\:.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help aliases"
-gdb_test "help attach" "Attach to a process or file outside of GDB..*\[\r\n\]+This command attaches to another target, of the same type as your last.*\[\r\n\]+\"target\" command .\"info files\" will show your target stack.*\[\r\n\]+The command may take as argument a process id or a device file..*\[\r\n\]+For a process id, you must have permission to send the process a signal,.*\[\r\n\]+and it must have the same effective uid as the debugger..*\[\r\n\]+When using \"attach\" with a process id, the debugger finds the.*\[\r\n\]+program running in the process, looking first in the current working.*\[\r\n\]+directory, or .if not found there. using the source file search path.*\[\r\n\]+\\(see the \"directory\" command\\).  You can also use the \"file\" command.*\[\r\n\]+to specify the program, and to load its symbol table." "help attach"
+gdb_test "help aliases" "Aliases of other commands\.\[\r\n\]+List of commands\:.*\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help aliases"
+# test help append
+gdb_test "help append" "Append target code/data to a local file\.\[\r\n\]+List of append subcommands:.*" 
+gdb_test "help append binary" "Append target code/data to a raw binary file\.\[\r\n\]+List of append binary subcommands:.*" 
+gdb_test "help append memory" "Append contents of memory to a raw binary file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory within the\[\r\n\]+range \\\[START \.\. STOP\\) to the specifed FILE in raw target ordered bytes\." 
+gdb_test "help append value" "Append the value of an expression to a raw binary file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION to\[\r\n\]+the specified FILE in raw target ordered bytes\." 
+gdb_test "help append binary memory" "Append contents of memory to a raw binary file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory within the\[\r\n\]+range \\\[START \.\. STOP\\) to the specifed FILE in raw target ordered bytes\." 
+gdb_test "help append binary value" "Append the value of an expression to a raw binary file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION\[\r\n\]+to the specified FILE in raw target ordered bytes\." 
+# test help attach
+gdb_test "help attach" "Attach to a process or file outside of GDB\.\[\r\n\]+This command attaches to another target, of the same type as your last\[\r\n\]+\"target\" command \\(\"info files\" will show your target stack\\)\.\[\r\n\]+The command may take as argument a process id or a device file\.\[\r\n\]+For a process id, you must have permission to send the process a signal,\[\r\n\]+and it must have the same effective uid as the debugger\.\[\r\n\]+When using \"attach\" with a process id, the debugger finds the\[\r\n\]+program running in the process, looking first in the current working\[\r\n\]+directory, or \\(if not found there\\) using the source file search path\[\r\n\]+\\(see the \"directory\" command\\)\.  You can also use the \"file\" command\[\r\n\]+to specify the program, and to load its symbol table\." "help attach"
 # test help breakpoint "b" abbreviation
-gdb_test "help b" "Set breakpoint at specified line or function..*\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address..*\[\r\n\]+If line number is specified, break at start of code for that line..*\[\r\n\]+If function is specified, break at start of code for that function..*\[\r\n\]+If an address is specified, break at that exact address..*\[\r\n\]+With no arg, uses current execution address of selected stack frame..*\[\r\n\]+This is useful for breaking on return to a stack frame..*\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional..*\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints." "help breakpoint \"b\" abbreviation"
+gdb_test "help b" "Set breakpoint at specified line or function\.\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address\.\[\r\n\]+If line number is specified, break at start of code for that line\.\[\r\n\]+If function is specified, break at start of code for that function\.\[\r\n\]+If an address is specified, break at that exact address\.\[\r\n\]+With no arg, uses current execution address of selected stack frame\.\[\r\n\]+This is useful for breaking on return to a stack frame\.\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional\.\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints\." "help breakpoint \"b\" abbreviation"
 # test help breakpoint "br" abbreviation
-gdb_test "help br" "Set breakpoint at specified line or function..*\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address..*\[\r\n\]+If line number is specified, break at start of code for that line..*\[\r\n\]+If function is specified, break at start of code for that function..*\[\r\n\]+If an address is specified, break at that exact address..*\[\r\n\]+With no arg, uses current execution address of selected stack frame..*\[\r\n\]+This is useful for breaking on return to a stack frame..*\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional..*\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints." "help breakpoint \"br\" abbreviation"
+gdb_test "help br" "Set breakpoint at specified line or function\.\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address\.\[\r\n\]+If line number is specified, break at start of code for that line\.\[\r\n\]+If function is specified, break at start of code for that function\.\[\r\n\]+If an address is specified, break at that exact address\.\[\r\n\]+With no arg, uses current execution address of selected stack frame\.\[\r\n\]+This is useful for breaking on return to a stack frame\.\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional\.\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints\." "help breakpoint \"br\" abbreviation"
 # test help breakpoint "bre" abbreviation
-gdb_test "help bre" "Set breakpoint at specified line or function..*\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address..*\[\r\n\]+If line number is specified, break at start of code for that line..*\[\r\n\]+If function is specified, break at start of code for that function..*\[\r\n\]+If an address is specified, break at that exact address..*\[\r\n\]+With no arg, uses current execution address of selected stack frame..*\[\r\n\]+This is useful for breaking on return to a stack frame..*\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional..*\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints." "help breakpoint \"bre\" abbreviation"
+gdb_test "help bre" "Set breakpoint at specified line or function\.\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address\.\[\r\n\]+If line number is specified, break at start of code for that line\.\[\r\n\]+If function is specified, break at start of code for that function\.\[\r\n\]+If an address is specified, break at that exact address\.\[\r\n\]+With no arg, uses current execution address of selected stack frame\.\[\r\n\]+This is useful for breaking on return to a stack frame\.\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional\.\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints\." "help breakpoint \"bre\" abbreviation"
 # test help breakpoint "brea" abbreviation
-gdb_test "help brea" "Set breakpoint at specified line or function..*\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address..*\[\r\n\]+If line number is specified, break at start of code for that line..*\[\r\n\]+If function is specified, break at start of code for that function..*\[\r\n\]+If an address is specified, break at that exact address..*\[\r\n\]+With no arg, uses current execution address of selected stack frame..*\[\r\n\]+This is useful for breaking on return to a stack frame..*\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional..*\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints." "help breakpoint \"brea\" abbreviation"
+gdb_test "help brea" "Set breakpoint at specified line or function\.\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address\.\[\r\n\]+If line number is specified, break at start of code for that line\.\[\r\n\]+If function is specified, break at start of code for that function\.\[\r\n\]+If an address is specified, break at that exact address\.\[\r\n\]+With no arg, uses current execution address of selected stack frame\.\[\r\n\]+This is useful for breaking on return to a stack frame\.\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional\.\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints\." "help breakpoint \"brea\" abbreviation"
 # test help breakpoint "break" abbreviation
-gdb_test "help break" "Set breakpoint at specified line or function..*\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address..*\[\r\n\]+If line number is specified, break at start of code for that line..*\[\r\n\]+If function is specified, break at start of code for that function..*\[\r\n\]+If an address is specified, break at that exact address..*\[\r\n\]+With no arg, uses current execution address of selected stack frame..*\[\r\n\]+This is useful for breaking on return to a stack frame..*\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional..*\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints." "help breakpoint \"break\" abbreviation"
+gdb_test "help break" "Set breakpoint at specified line or function\.\[\r\n\]+Argument may be line number, function name, or \"\[*\]\" and an address\.\[\r\n\]+If line number is specified, break at start of code for that line\.\[\r\n\]+If function is specified, break at start of code for that function\.\[\r\n\]+If an address is specified, break at that exact address\.\[\r\n\]+With no arg, uses current execution address of selected stack frame\.\[\r\n\]+This is useful for breaking on return to a stack frame\.\[\r\n\]+Multiple breakpoints at one place are permitted, and useful if conditional\.\[\r\n\]+Do \"help breakpoints\" for info on other commands dealing with breakpoints\." "help breakpoint \"break\" abbreviation"
 # test help breakpoints
-gdb_test "help breakpoints" "Making program stop at certain points..*\[\r\n\]+List of commands\:.*\[\r\n\]+awatch -- Set a watchpoint for an expression.*\[\r\n\]+break -- Set breakpoint at specified line or function.*\[\r\n\]+catch -- Set catchpoints to catch events.*\[\r\n\]+clear -- Clear breakpoint at specified line or function.*\[\r\n\]+commands -- Set commands to be executed when a breakpoint is hit.*\[\r\n\]+condition -- Specify breakpoint number N to break only if COND is true.*\[\r\n\]+delete -- Delete some breakpoints or auto-display expressions.*\[\r\n\]+disable -- Disable some breakpoints.*\[\r\n\]+enable -- Enable some breakpoints.*\[\r\n\]+hbreak -- Set a hardware assisted  breakpoint.*\[\r\n\]+ignore -- Set ignore-count of breakpoint number N to COUNT.*\[\r\n\]+rwatch -- Set a read watchpoint for an expression.*\[\r\n\]+tbreak -- Set a temporary breakpoint.*\[\r\n\]+tcatch -- Set temporary catchpoints to catch events.*\[\r\n\]+thbreak -- Set a temporary hardware assisted breakpoint.*\[\r\n\]+watch -- Set a watchpoint for an expression.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help breakpoints"
+gdb_test "help breakpoints" "Making program stop at certain points\.\[\r\n\]+List of commands:\[\r\n\]+awatch -- Set a watchpoint for an expression\[\r\n\]+break -- Set breakpoint at specified line or function\[\r\n\]+catch -- Set catchpoints to catch events\[\r\n\]+clear -- Clear breakpoint at specified line or function\[\r\n\]+commands -- Set commands to be executed when a breakpoint is hit\[\r\n\]+condition -- Specify breakpoint number N to break only if COND is true\[\r\n\]+delete -- Delete some breakpoints or auto-display expressions\[\r\n\]+disable -- Disable some breakpoints\[\r\n\]+enable -- Enable some breakpoints\[\r\n\]+hbreak -- Set a hardware assisted  breakpoint\[\r\n\]+ignore -- Set ignore-count of breakpoint number N to COUNT\[\r\n\]+rbreak -- Set a breakpoint for all functions matching REGEXP\[\r\n\]+rwatch -- Set a read watchpoint for an expression\[\r\n\]+tbreak -- Set a temporary breakpoint\[\r\n\]+tcatch -- Set temporary catchpoints to catch events\[\r\n\]+thbreak -- Set a temporary hardware assisted breakpoint\[\r\n\]+watch -- Set a watchpoint for an expression\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help breakpoints"
 # test help backtrace "bt" abbreviation
-gdb_test "help bt" "Print backtrace of all stack frames, or innermost COUNT frames..*\[\r\n\]+With a negative argument, print outermost -COUNT frames..*\[\r\n\]+Use of the 'full' qualifier also prints the values of the local variables." "help backtrace \"bt\" abbreviation"
+gdb_test "help bt" "Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+With a negative argument, print outermost -COUNT frames\.\[\r\n\]+Use of the 'full' qualifier also prints the values of the local variables\." "help backtrace \"bt\" abbreviation"
 # test help backtrace
-gdb_test "help backtrace" "Print backtrace of all stack frames, or innermost COUNT frames..*\[\r\n\]+With a negative argument, print outermost -COUNT frames..*\[\r\n\]+Use of the 'full' qualifier also prints the values of the local variables." "help backtrace"
+gdb_test "help backtrace" "Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+With a negative argument, print outermost -COUNT frames\.\[\r\n\]+Use of the 'full' qualifier also prints the values of the local variables\." "help backtrace"
 # test help continue "c" abbreviation
-gdb_test "help c" "Continue program being debugged.*"  "help continue \"c\" abbreviation"
+gdb_test "help c" "Continue program being debugged.*" "help continue \"c\" abbreviation"
 # test help continue
-gdb_test "help continue" "Continue program being debugged.*"  "help continue"
+gdb_test "help continue" "Continue program being debugged.*" "help continue"
 # test help call
-gdb_test "help call" "Call a function.*"  "help call"
+gdb_test "help call" "Call a function.*" "help call"
 # test help catch
 gdb_test "help catch" "Set catchpoints to catch events.*Raised signals may be caught:.*catch signal.*all signals.*catch signal.*signame.*a particular signal.*Raised exceptions may be caught:.*catch throw.*all exceptions, when thrown.*catch throw.*exceptname.*a particular exception, when thrown.*catch catch.*all exceptions, when caught.*catch catch.*exceptname.*a particular exception, when caught.*Thread or process events may be caught:.*catch thread_start.*any threads, just after creation.*catch thread_exit.*any threads, just before expiration.*catch thread_join.*any threads, just after joins.*catch start.*any processes, just after creation.*catch exit.*any processes, just before expiration.*catch fork.*calls to fork.*catch vfork.*calls to vfork.*catch exec.*calls to exec.*Dynamically.linked library events may be caught:.*catch load.*loads of any library.*catch load.*libname.*loads of a particular library.*catch unload.*unloads of any library.*catch unload.*libname.*unloads of a particular library.*The act of your program's execution stopping may also be caught:.*catch stop.*Do.*help set follow-fork-mode.*for info on debugging your program.*after a fork or vfork is caught.*Do.*help breakpoints.*for info on other commands dealing with breakpoints." "help catch"
 # test help cd
-gdb_test "help cd" "Set working directory to DIR for debugger and program being debugged..*\[\r\n\]+The change does not take effect for the program being debugged.*\[\r\n\]+until the next time it is started." "help cd"
+gdb_test "help cd" "Set working directory to DIR for debugger and program being debugged\.\[\r\n\]+The change does not take effect for the program being debugged\[\r\n\]+until the next time it is started\." "help cd"
 # test help clear
-gdb_test "help clear" "Clear breakpoint at specified line or function.*\[\r\n\]+Argument may be line number, function name, or .* and an address.*\[\r\n\]+If line number is specified, all breakpoints in that line are cleared.*\[\r\n\]+If function is specified, breakpoints at beginning of function are cleared.*\[\r\n\]+If an address is specified, breakpoints at that address are cleared.*\[\r\n\]+With no argument, clears all breakpoints in the line that the selected frame.*\[\r\n\]+is executing in..*\[\r\n\]+See also the \"delete\" command which clears breakpoints by number." "help clear"
+gdb_test "help clear" "Clear breakpoint at specified line or function\.\[\r\n\]+Argument may be line number, function name, or \"\\*\" and an address\.\[\r\n\]+If line number is specified, all breakpoints in that line are cleared\.\[\r\n\]+If function is specified, breakpoints at beginning of function are cleared\.\[\r\n\]+If an address is specified, breakpoints at that address are cleared\.\[\r\n\]+With no argument, clears all breakpoints in the line that the selected frame\[\r\n\]+is executing in\.\[\r\n\]+See also the \"delete\" command which clears breakpoints by number\." "help clear"
 # test help commands
-gdb_test "help commands" "Set commands to be executed when a breakpoint is hit..*\[\r\n\]+Give breakpoint number as argument after \"commands\"..*\[\r\n\]+With no argument, the targeted breakpoint is the last one set..*\[\r\n\]+The commands themselves follow starting on the next line..*\[\r\n\]+Type a line containing \"end\" to indicate the end of them..*\[\r\n\]+Give \"silent\" as the first line to make the breakpoint silent;.*\[\r\n\]+then no output is printed when it is hit, except what the commands print." "help commands"
+gdb_test "help commands" "Set commands to be executed when a breakpoint is hit\.\[\r\n\]+Give breakpoint number as argument after \"commands\"\.\[\r\n\]+With no argument, the targeted breakpoint is the last one set\.\[\r\n\]+The commands themselves follow starting on the next line\.\[\r\n\]+Type a line containing \"end\" to indicate the end of them\.\[\r\n\]+Give \"silent\" as the first line to make the breakpoint silent;\[\r\n\]+then no output is printed when it is hit, except what the commands print\." "help commands"
 # test help condition
-gdb_test "help condition" "Specify breakpoint number N to break only if COND is true..*\[\r\n\]+Usage is `condition N COND', where N is an integer and COND is an.*\[\r\n\]+expression to be evaluated whenever breakpoint N is reached.  " "help condition"
+gdb_test "help condition" "Specify breakpoint number N to break only if COND is true\.\[\r\n\]+Usage is `condition N COND', where N is an integer and COND is an\[\r\n\]+expression to be evaluated whenever breakpoint N is reached." "help condition"
 # test help core-file
-gdb_test "help core-file" "Use FILE as core dump for examining memory and registers..*\[\r\n\]+No arg means have no core file.  This command has been superseded by the.*\[\r\n\]+`target core' and `detach' commands." "help core-file"
+gdb_test "help core-file" "Use FILE as core dump for examining memory and registers\.\[\r\n\]+No arg means have no core file\.  This command has been superseded by the\[\r\n\]+`target core' and `detach' commands\." "help core-file"
 # test help delete "d" abbreviation
-gdb_test "help d" "Delete some breakpoints or auto-display expressions..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To delete all breakpoints, give no argument..*\[\r\n\]+Also a prefix command for deletion of other GDB objects..*\[\r\n\]+The \"unset\" command is also an alias for \"delete\"..*\[\r\n\]+List of delete subcommands:.*\[\r\n\]+delete breakpoints -- Delete some breakpoints or auto-display expressions.*\[\r\n\]+delete display -- Cancel some expressions to be displayed when program stops.*\[\r\n\]+Type \"help delete\" followed by delete subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help delete \"d\" abbreviation"
+gdb_test "help d" "Delete some breakpoints or auto-display expressions\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To delete all breakpoints, give no argument\.\[\r\n\]+Also a prefix command for deletion of other GDB objects\.\[\r\n\]+The \"unset\" command is also an alias for \"delete\"\.\[\r\n\]+List of delete subcommands:\[\r\n\]+delete breakpoints -- Delete some breakpoints or auto-display expressions\[\r\n\]+delete display -- Cancel some expressions to be displayed when program stops\[\r\n\]+delete mem -- Delete memory region\[\r\n\]+delete tracepoints -- Delete specified tracepoints\[\r\n\]+Type \"help delete\" followed by delete subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help delete \"d\" abbreviation"
 # test help delete
-gdb_test "help delete" "Delete some breakpoints or auto-display expressions..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To delete all breakpoints, give no argument..*\[\r\n\]+Also a prefix command for deletion of other GDB objects..*\[\r\n\]+The \"unset\" command is also an alias for \"delete\"..*\[\r\n\]+List of delete subcommands:.*\[\r\n\]+delete breakpoints -- Delete some breakpoints or auto-display expressions.*\[\r\n\]+delete display -- Cancel some expressions to be displayed when program stops.*\[\r\n\]+Type \"help delete\" followed by delete subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help delete"
+gdb_test "help delete" "Delete some breakpoints or auto-display expressions\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To delete all breakpoints, give no argument\.\[\r\n\]+Also a prefix command for deletion of other GDB objects\.\[\r\n\]+The \"unset\" command is also an alias for \"delete\"\.\[\r\n\]+List of delete subcommands:\[\r\n\]+delete breakpoints -- Delete some breakpoints or auto-display expressions\[\r\n\]+delete display -- Cancel some expressions to be displayed when program stops\[\r\n\]+delete mem -- Delete memory region\[\r\n\]+delete tracepoints -- Delete specified tracepoints\[\r\n\]+Type \"help delete\" followed by delete subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help delete"
 # test help data
-gdb_test "help data" ".*\[\r\n\]+Examining data..*\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help data"
+gdb_test "help data" "Examining data\.\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help data"
 # test help define
-gdb_test "help define" "Define a new command.*"  "help define"
+gdb_test "help define" "Define a new command.*" "help define"
 # test help delete breakpoints
-gdb_test "help delete breakpoints" "Delete some breakpoints or auto-display expressions..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To delete all breakpoints, give no argument..*\[\r\n\]+This command may be abbreviated \"delete\"." "help delete breakpoints"
+gdb_test "help delete breakpoints" "Delete some breakpoints or auto-display expressions\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To delete all breakpoints, give no argument\.\[\r\n\]+This command may be abbreviated \"delete\"\." "help delete breakpoints"
 # test help delete display
-gdb_test "help delete display" "Cancel some expressions to be displayed when program stops..*\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying..*\[\r\n\]+No argument means cancel all automatic-display expressions..*\[\r\n\]+Do \"info display\" to see current list of code numbers." "help delete display"
+gdb_test "help delete display" "Cancel some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means cancel all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help delete display"
 # test help detach
-gdb_test "help detach" "Detach a process or file previously attached.\[\r\n\]+If a process, it is no longer traced, and it continues its execution.\[ \r\n\]+If\[ \r\n\]+you were debugging a file, the file is closed and gdb no longer accesses it." "help detach"
+gdb_test "help detach" "Detach a process or file previously attached\.\[\r\n\]+If a process, it is no longer traced, and it continues its execution\.\[ \r\n\]+If\[ \r\n\]+you were debugging a file, the file is closed and gdb no longer accesses it\." "help detach"
 # test help directory
-gdb_test "help directory" "Add directory DIR to beginning of search path for source files..*\[\r\n\]+Forget cached info on source file locations and line positions..*\[\r\n\]+DIR can also be .cwd for the current working directory, or .cdir for the.*\[\r\n\]+directory in which the source file was compiled into object code..*\[\r\n\]+With no argument, reset the search path to .cdir:.cwd, the default." "help directory"
+gdb_test "help directory" "Add directory DIR to beginning of search path for source files\.\[\r\n\]+Forget cached info on source file locations and line positions\.\[\r\n\]+DIR can also be \\\$cwd for the current working directory, or \\\$cdir for the\[\r\n\]+directory in which the source file was compiled into object code\.\[\r\n\]+With no argument, reset the search path to \\\$cdir:\\\$cwd, the default\." "help directory"
 # test help disable "dis" abbreviation
-gdb_test "help dis" "Disable some breakpoints..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To disable all breakpoints, give no argument..*\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled..*\[\r\n\]+List of disable subcommands:.*\[\r\n\]+disable breakpoints -- Disable some breakpoints.*\[\r\n\]+disable display -- Disable some expressions to be displayed when program stops.*\[\r\n\]+Type \"help disable\" followed by disable subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help disable \"dis\" abbreviation"
+gdb_test "help dis" "Disable some breakpoints\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To disable all breakpoints, give no argument\.\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled\.\[\r\n\]+List of disable subcommands:\[\r\n\]+disable breakpoints -- Disable some breakpoints\[\r\n\]+disable display -- Disable some expressions to be displayed when program stops\[\r\n\]+disable mem -- Disable memory region\[\r\n\]+disable tracepoints -- Disable specified tracepoints\[\r\n\]+Type \"help disable\" followed by disable subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help disable \"dis\" abbreviation"
 # test help disable "disa" abbreviation
-gdb_test "help disa" "Disable some breakpoints..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To disable all breakpoints, give no argument..*\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled..*\[\r\n\]+List of disable subcommands:.*\[\r\n\]+disable breakpoints -- Disable some breakpoints.*\[\r\n\]+disable display -- Disable some expressions to be displayed when program stops.*\[\r\n\]+Type \"help disable\" followed by disable subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help disable \"disa\" abbreviation"
+gdb_test "help disa" "Disable some breakpoints\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To disable all breakpoints, give no argument\.\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled\.\[\r\n\]+List of disable subcommands:\[\r\n\]+disable breakpoints -- Disable some breakpoints\[\r\n\]+disable display -- Disable some expressions to be displayed when program stops\[\r\n\]+disable mem -- Disable memory region\[\r\n\]+disable tracepoints -- Disable specified tracepoints\[\r\n\]+Type \"help disable\" followed by disable subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help disable \"disa\" abbreviation"
 # test help disable
-gdb_test "help disable" "Disable some breakpoints..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To disable all breakpoints, give no argument..*\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled..*\[\r\n\]+List of disable subcommands:.*\[\r\n\]+disable breakpoints -- Disable some breakpoints.*\[\r\n\]+disable display -- Disable some expressions to be displayed when program stops.*\[\r\n\]+Type \"help disable\" followed by disable subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help disable"
+gdb_test "help disable" "Disable some breakpoints\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To disable all breakpoints, give no argument\.\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled\.\[\r\n\]+List of disable subcommands:\[\r\n\]+disable breakpoints -- Disable some breakpoints\[\r\n\]+disable display -- Disable some expressions to be displayed when program stops\[\r\n\]+disable mem -- Disable memory region\[\r\n\]+disable tracepoints -- Disable specified tracepoints\[\r\n\]+Type \"help disable\" followed by disable subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help disable"
 # test help disable breakpoints
-gdb_test "help disable breakpoints" "Disable some breakpoints..*\[\r\n\]+Arguments are breakpoint numbers with spaces in between..*\[\r\n\]+To disable all breakpoints, give no argument..*\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled..*\[\r\n\]+This command may be abbreviated \"disable\"." "help disable breakpoints"
+gdb_test "help disable breakpoints" "Disable some breakpoints\.\[\r\n\]+Arguments are breakpoint numbers with spaces in between\.\[\r\n\]+To disable all breakpoints, give no argument\.\[\r\n\]+A disabled breakpoint is not forgotten, but has no effect until reenabled\.\[\r\n\]+This command may be abbreviated \"disable\"." "help disable breakpoints"
 # test help disable display
-gdb_test "help disable display" "Disable some expressions to be displayed when program stops..*\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying..*\[\r\n\]+No argument means disable all automatic-display expressions..*\[\r\n\]+Do \"info display\" to see current list of code numbers." "help disable display"
+gdb_test "help disable display" "Disable some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means disable all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help disable display"
 # test help disassemble
-gdb_test "help disassemble" "Disassemble a specified section of memory..*\[\r\n\]+Default is the function surrounding the pc of the selected frame..*\[\r\n\]+With a single argument, the function surrounding that address is dumped..*\[\r\n\]+Two arguments are taken as a range of memory to dump." "help disassemble"
+gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble"
 # test help display
-gdb_test "help display" "Print value of expression EXP each time the program stops..*\[\r\n\]+/FMT may be used before EXP as in the \"print\" command..*\[\r\n\]+/FMT \"i\" or \"s\" or including a size-letter is allowed,.*\[\r\n\]+as in the \"x\" command, and then EXP is used to get the address to examine.*\[\r\n\]+and examining is done as in the \"x\" command..*\[\r\n\]+With no argument, display all currently requested auto-display expressions..*\[\r\n\]+Use \"undisplay\" to cancel display requests previously made." "help display"
+gdb_test "help display" "Print value of expression EXP each time the program stops\.\[\r\n\]+/FMT may be used before EXP as in the \"print\" command\.\[\r\n\]+/FMT \"i\" or \"s\" or including a size-letter is allowed,\[\r\n\]+as in the \"x\" command, and then EXP is used to get the address to examine\[\r\n\]+and examining is done as in the \"x\" command\.\[\r\n\]+With no argument, display all currently requested auto-display expressions\.\[\r\n\]+Use \"undisplay\" to cancel display requests previously made\." "help display"
 # test help do
-gdb_test "help do" "Select and print stack frame called by this one..*\[\r\n\]+An argument says how many frames down to go." "help do"
+gdb_test "help do" "Select and print stack frame called by this one\.\[\r\n\]+An argument says how many frames down to go\." "help do"
 # test help document
-gdb_test "help document" "Document a user-defined command..*\[\r\n\]+Give command name as argument.  Give documentation on following lines..*\[\r\n\]+End with a line of just \"end\"." "help document"
+gdb_test "help document" "Document a user-defined command\.\[\r\n\]+Give command name as argument\.  Give documentation on following lines\.\[\r\n\]+End with a line of just \"end\"\." "help document"
 # test help down
-gdb_test "help down" "Select and print stack frame called by this one..*\[\r\n\]+An argument says how many frames down to go." "help down"
+gdb_test "help down" "Select and print stack frame called by this one\.\[\r\n\]+An argument says how many frames down to go\." "help down"
 # test help down-silently
-gdb_test "help down-silently" "Same as the `down' command, but does not print anything..*\[\r\n\]+This is useful in command scripts." "help down-silently"
+gdb_test "help down-silently" "Same as the `down' command, but does not print anything\.\[\r\n\]+This is useful in command scripts\." "help down-silently"
+# test help dump 
+gdb_test "help dump" "Dump target code/data to a local file\.\[\r\n\]+List of dump subcommands:.*" 
+gdb_test "help dump binary" "Write target code/data to a raw binary file\.\[\r\n\]+List of dump binary subcommands:.*" 
+gdb_test "help dump ihex" "Write target code/data to an intel hex file\.\[\r\n\]+List of dump ihex subcommands:.*" 
+gdb_test "help dump memory" "Write contents of memory to a raw binary file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory within the\[\r\n\]+range \\\[START \.\. STOP\\) to the specifed FILE in raw target ordered bytes\." 
+gdb_test "help dump srec" "Write target code/data to an srec file\.\[\r\n\]+List of dump srec subcommands:.*" 
+gdb_test "help dump tekhex" "Write target code/data to a tekhex file\.\[\r\n\]+List of dump tekhex subcommands:.*" 
+gdb_test "help dump value" "Write the value of an expression to a raw binary file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION to\[\r\n\]+the specified FILE in raw target ordered bytes\." 
+gdb_test "help dump binary memory" "Write contents of memory to a raw binary file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory\[\r\n\]+within the range \\\[START \.\. STOP\\) to the specifed FILE in binary format\." 
+gdb_test "help dump binary value" "Write the value of an expression to a raw binary file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION\[\r\n\]+to the specified FILE in raw target ordered bytes\." "help dump binary value"
+gdb_test "help dump ihex memory" "Write contents of memory to an ihex file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory within\[\r\n\]+the range \\\[START \.\. STOP\\) to the specifed FILE in intel hex format\." 
+gdb_test "help dump ihex value" "Write the value of an expression to an ihex file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION\[\r\n\]+to the specified FILE in intel hex format\." 
+gdb_test "help dump srec memory" "Write contents of memory to an srec file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory\[\r\n\]+within the range \\\[START \.\. STOP\\) to the specifed FILE in srec format\." 
+gdb_test "help dump srec value" "Write the value of an expression to an srec file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION\[\r\n\]+to the specified FILE in srec format\." 
+gdb_test "help dump tekhex memory" "Write contents of memory to a tekhex file\.\[\r\n\]+Arguments are FILE START STOP\.  Writes the contents of memory\[\r\n\]+within the range \\\[START \.\. STOP\\) to the specifed FILE in tekhex format\." 
+gdb_test "help dump tekhex value" "Write the value of an expression to a tekhex file\.\[\r\n\]+Arguments are FILE EXPRESSION\.  Writes the value of EXPRESSION\[\r\n\]+to the specified FILE in tekhex format\." 
 # this command was removed from GDB 4.5.8
 # test help dump-me
 #send_gdb "help dump-me"
-# -re "Get fatal error; make debugger dump its core."
+# -re "Get fatal error; make debugger dump its core\."
 # 
 # }
 # test help echo
-gdb_test "help echo" "Print a constant string.  Give string as argument..*\[\r\n\]+C escape sequences may be used in the argument..*\[\r\n\]+No newline is added at the end of the argument;.*\[\r\n\]+use \".n\" if you want a newline to be printed..*\[\r\n\]+Since leading and trailing whitespace are ignored in command arguments,.*\[\r\n\]+if you want to print some you must use \".\" before leading whitespace.*\[\r\n\]+to be printed or after trailing whitespace." "help echo"
+gdb_test "help echo" "Print a constant string\.  Give string as argument\.\[\r\n\]+C escape sequences may be used in the argument\.\[\r\n\]+No newline is added at the end of the argument;\[\r\n\]+use \"\\\\n\" if you want a newline to be printed\.\[\r\n\]+Since leading and trailing whitespace are ignored in command arguments,\[\r\n\]+if you want to print some you must use \"\\\\\" before leading whitespace\[\r\n\]+to be printed or after trailing whitespace\." "help echo"
 # test help enable breakpoints delete
-gdb_test "help enable breakpoints delete" "Enable breakpoints and delete when hit.  Give breakpoint numbers..*\[\r\n\]+If a breakpoint is hit while enabled in this fashion, it is deleted." "help enable breakpoints delete"
+gdb_test "help enable breakpoints delete" "Enable breakpoints and delete when hit\.  Give breakpoint numbers\.\[\r\n\]+If a breakpoint is hit while enabled in this fashion, it is deleted\." "help enable breakpoints delete"
 # test help enable breakpoints once
-gdb_test "help enable breakpoints once" "Enable breakpoints for one hit..*"  "help enable breakpoints once"
+gdb_test "help enable breakpoints once" "Enable breakpoints for one hit.*" "help enable breakpoints once"
 # test help enable breakpoints
-gdb_test "help enable breakpoints" "Enable some breakpoints..*\[\r\n\]+Give breakpoint numbers .separated by spaces. as arguments..*\[\r\n\]+This is used to cancel the effect of the \"disable\" command..*\[\r\n\]+May be abbreviated to simply \"enable\"..*.*\[\r\n\]+List of enable breakpoints subcommands:.*\[\r\n\]+enable breakpoints delete -- Enable breakpoints and delete when hit.*\[\r\n\]+enable breakpoints once -- Enable breakpoints for one hit.*\[\r\n\]+Type \"help enable breakpoints\" followed by enable breakpoints subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help enable breakpoints"
+gdb_test "help enable breakpoints" "Enable some breakpoints\.\[\r\n\]+Give breakpoint numbers \\(separated by spaces\\) as arguments\.\[\r\n\]+This is used to cancel the effect of the \"disable\" command\.\[\r\n\]+May be abbreviated to simply \"enable\"\.\[\r\n\]+List of enable breakpoints subcommands:\[\r\n\]+enable breakpoints delete -- Enable breakpoints and delete when hit\[\r\n\]+enable breakpoints once -- Enable breakpoints for one hit\[\r\n\]+Type \"help enable breakpoints\" followed by enable breakpoints subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help enable breakpoints"
 # test help enable delete
-gdb_test "help enable delete" "Enable breakpoints and delete when hit.  Give breakpoint numbers..*\[\r\n\]+If a breakpoint is hit while enabled in this fashion, it is deleted." "help enable delete"
+gdb_test "help enable delete" "Enable breakpoints and delete when hit\.  Give breakpoint numbers\.\[\r\n\]+If a breakpoint is hit while enabled in this fashion, it is deleted\." "help enable delete"
 # test help enable display
-gdb_test "help enable display" "Enable some expressions to be displayed when program stops..*\[\r\n\]+Arguments are the code numbers of the expressions to resume displaying..*\[\r\n\]+No argument means enable all automatic-display expressions..*\[\r\n\]+Do \"info display\" to see current list of code numbers." "help enable display"
+gdb_test "help enable display" "Enable some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to resume displaying\.\[\r\n\]+No argument means enable all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help enable display"
 # test help enable once
-gdb_test "help enable once" "Enable breakpoints for one hit.*"  "help enable once"
+gdb_test "help enable once" "Enable breakpoints for one hit.*" "help enable once"
 # test help enable
-gdb_test "help enable" "Enable some breakpoints..*\[\r\n\]+Give breakpoint numbers .separated by spaces. as arguments..*\[\r\n\]+With no subcommand, breakpoints are enabled until you command otherwise..*\[\r\n\]+This is used to cancel the effect of the \"disable\" command..*\[\r\n\]+With a subcommand you can enable temporarily..*\[\r\n\]+List of enable subcommands:.*\[\r\n\]+enable delete -- Enable breakpoints and delete when hit.*\[\r\n\]+enable display -- Enable some expressions to be displayed when program stops.*\[\r\n\]+enable once -- Enable breakpoints for one hit.*\[\r\n\]+Type \"help enable\" followed by enable subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help enable"
+gdb_test "help enable" "Enable some breakpoints\.\[\r\n\]+Give breakpoint numbers \\(separated by spaces\\) as arguments\.\[\r\n\]+With no subcommand, breakpoints are enabled until you command otherwise\.\[\r\n\]+This is used to cancel the effect of the \"disable\" command\.\[\r\n\]+With a subcommand you can enable temporarily\.\[\r\n\]+List of enable subcommands:\[\r\n\]+enable delete -- Enable breakpoints and delete when hit\[\r\n\]+enable display -- Enable some expressions to be displayed when program stops\[\r\n\]+enable mem -- Enable memory region\[\r\n\]+enable once -- Enable breakpoints for one hit\[\r\n\]+enable tracepoints -- Enable specified tracepoints\[\r\n\]+Type \"help enable\" followed by enable subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help enable"
 # test help exec-file
-gdb_test "help exec-file" "Use FILE as program for getting contents of pure memory..*\[\r\n\]+If FILE cannot be found as specified, your execution directory path.*\[\r\n\]+is searched for a command of that name..*\[\r\n\]+No arg means have no executable file." "help exec-file"
+gdb_test "help exec-file" "Use FILE as program for getting contents of pure memory\.\[\r\n\]+If FILE cannot be found as specified, your execution directory path\[\r\n\]+is searched for a command of that name\.\[\r\n\]+No arg means have no executable file\." "help exec-file"
 # test help frame "f" abbreviation
-gdb_test "help f" "Select and print a stack frame..*\[\r\n\]+With no argument, print the selected stack frame.  .See also \"info frame\".*\[\r\n\]+An argument specifies the frame to select..*\[\r\n\]+It can be a stack frame number or the address of the frame..*\[\r\n\]+With argument, nothing is printed if input is coming from.*\[\r\n\]+a command file or a user-defined command." "help frame \"f\" abbreviation"
+gdb_test "help f" "Select and print a stack frame\.\[\r\n\]+With no argument, print the selected stack frame\.  \\(See also \"info frame\"\\)\.\[\r\n\]+An argument specifies the frame to select\.\[\r\n\]+It can be a stack frame number or the address of the frame\.\[\r\n\]+With argument, nothing is printed if input is coming from\[\r\n\]+a command file or a user-defined command\." "help frame \"f\" abbreviation"
 # test help frame
-gdb_test "help frame" "Select and print a stack frame..*\[\r\n\]+With no argument, print the selected stack frame.  .See also \"info frame\"...*\[\r\n\]+An argument specifies the frame to select..*\[\r\n\]+It can be a stack frame number or the address of the frame..*\[\r\n\]+With argument, nothing is printed if input is coming from.*\[\r\n\]+a command file or a user-defined command." "help frame"
+gdb_test "help frame" "Select and print a stack frame\.\[\r\n\]+With no argument, print the selected stack frame\.  \\(See also \"info frame\"\\)\.\[\r\n\]+An argument specifies the frame to select\.\[\r\n\]+It can be a stack frame number or the address of the frame\.\[\r\n\]+With argument, nothing is printed if input is coming from\[\r\n\]+a command file or a user-defined command\." "help frame"
 # test help fg
-gdb_test "help fg" "Continue program being debugged.*"  "help fg"
+gdb_test "help fg" "Continue program being debugged.*" "help fg"
 # test help file
-gdb_test "help file" "Use FILE as program to be debugged..*\[\r\n\]+It is read for its symbols, for getting the contents of pure memory,.*\[\r\n\]+and it is the program executed when you use the `run' command..*\[\r\n\]+If FILE cannot be found as specified, your execution directory path.*\[\r\n\]+..PATH. is searched for a command of that name..*\[\r\n\]+No arg means to have no executable file and no symbols." "help file"
+gdb_test "help file" "Use FILE as program to be debugged\.\[\r\n\]+It is read for its symbols, for getting the contents of pure memory,\[\r\n\]+and it is the program executed when you use the `run' command\.\[\r\n\]+If FILE cannot be found as specified, your execution directory path\[\r\n\]+\\(\\\$PATH\\) is searched for a command of that name\.\[\r\n\]+No arg means to have no executable file and no symbols\." "help file"
 # test help files
 gdb_test "help files" "Specifying.*" "help files"
 # test help finish
-gdb_test "help finish" "Execute until selected stack frame returns..*\[\r\n\]+Upon return, the value returned is printed and put in the value history." "help finish"
+gdb_test "help finish" "Execute until selected stack frame returns\.\[\r\n\]+Upon return, the value returned is printed and put in the value history\." "help finish"
 # test help forward-search
-gdb_test "help forward-search" "Search for regular expression .see regex.3.. from last line listed..*"  "help forward-search"
+gdb_test "help forward-search" "Search for regular expression \\(see regex\\(3\\)\\) from last line listed.*" "help forward-search"
+# test help gcore
+send_gdb "help gcore\n"
+gdb_expect {
+    -re "Undefined command: \"gcore\"\.  Try \"help\".*$gdb_prompt $" {
+	pass "help gcore"
+    }
+    -re "Save a core file with the current state of the debugged process\.\[\r\n\]+Argument is optional filename\.  Default filename is 'core\.<process_id>'.*$gdb_prompt $" {
+	pass "help gcore"
+    }
+    default { fail "help gcore" }
+}
+send_gdb "help generate-core-file\n"
+gdb_expect {
+    -re "Undefined command: \"generate-core-file\"\.  Try \"help\".*$gdb_prompt $" {
+	pass "help gcore"
+    }
+    -re "Save a core file with the current state of the debugged process\.\[\r\n\]+Argument is optional filename\.  Default filename is 'core\.<process_id>'.*$gdb_prompt $" {
+	pass "help gcore"
+    }
+    default { fail "help gcore" }
+}
 # test help help "h" abbreviation 
-gdb_test "help h" "Print list of commands."  "help help \"h\" abbreviation"
+gdb_test "help h" "Print list of commands\." "help help \"h\" abbreviation"
 # test help help
-gdb_test "help help" "Print list of commands."  "help help"
+gdb_test "help help" "Print list of commands\." "help help"
 # test help handle
-gdb_test "help handle" "Specify how to handle a signal..*"  "help handle"
+gdb_test "help handle" "Specify how to handle a signal\..*" "help handle"
 # test help info "i" abbreviation
-gdb_test "help i" "Generic command for showing things about the program being debugged..*\[\r\n\]+List of info subcommands:.*\[\r\n\]+Type \"help info\" followed by info subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help info \"i\" abbreviation"
+gdb_test "help i" "Generic command for showing things about the program being debugged\.\[\r\n\]+List of info subcommands:.*\[\r\n\]+Type \"help info\" followed by info subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help info \"i\" abbreviation"
 # test help info
-gdb_test "help info" "Generic command for showing things about the program being debugged..*\[\r\n\]+List of info subcommands:.*\[\r\n\]+Type \"help info\" followed by info subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help info"
+gdb_test "help info" "Generic command for showing things about the program being debugged\.\[\r\n\]+List of info subcommands:.*\[\r\n\]+Type \"help info\" followed by info subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help info"
 # test help ignore
-gdb_test "help ignore" "Set ignore-count of breakpoint number N to COUNT..*\[\r\n\]+Usage is `ignore N COUNT'." "help ignore"
+gdb_test "help ignore" "Set ignore-count of breakpoint number N to COUNT\.\[\r\n\]+Usage is `ignore N COUNT'\." "help ignore"
 # test help info address
-gdb_test "help info address" "Describe where symbol SYM is stored."  "help info address"
+gdb_test "help info address" "Describe where symbol SYM is stored\." "help info address"
 # test help info all-registers
-gdb_test "help info all-registers" "List of all registers and their contents, for selected stack frame..*\[\r\n\]+Register name as argument means describe only that register." "help info all-registers"
+gdb_test "help info all-registers" "List of all registers and their contents, for selected stack frame\.\[\r\n\]+Register name as argument means describe only that register\." "help info all-registers"
 # test help info args
-gdb_test "help info args" "Argument variables of current stack frame."  "help info args"
+gdb_test "help info args" "Argument variables of current stack frame\." "help info args"
 # test help info breakpoints
-gdb_test "help info breakpoints" "Status of user-settable breakpoints, or breakpoint number NUMBER..*\[\r\n\]+breakpoint set." "help info breakpoints"
+gdb_test "help info breakpoints" "Status of user-settable breakpoints, or breakpoint number NUMBER\..*\[\r\n\]+breakpoint set\." "help info breakpoints"
 # test help info catch
-gdb_test "help info catch" "Exceptions that can be caught in the current stack frame."  "help info catch"
+gdb_test "help info catch" "Exceptions that can be caught in the current stack frame\." "help info catch"
 # test help info copying
-gdb_test "help info copying" "Conditions for redistributing copies of GDB."  "help info copying"
+gdb_test "help info copying" "Conditions for redistributing copies of GDB\." "help info copying"
 # test help info display
-gdb_test "help info display" "Expressions to display when program stops, with code numbers."  "help info display"
+gdb_test "help info display" "Expressions to display when program stops, with code numbers\." "help info display"
 # test help info frame "f" abbreviation
-gdb_test "help info f" "All about selected stack frame, or frame at ADDR."  "help info frame \"f\" abbreviation"
+gdb_test "help info f" "All about selected stack frame, or frame at ADDR\." "help info frame \"f\" abbreviation"
 # test help info frame
-gdb_test "help info frame" "All about selected stack frame, or frame at ADDR."  "help info frame"
+gdb_test "help info frame" "All about selected stack frame, or frame at ADDR\." "help info frame"
 # test help info files
-gdb_test "help info files" "Names of targets and files being debugged..*\[\r\n\]+Shows the entire stack of targets currently in use .including the exec-file,.*\[\r\n\]+core-file, and process, if any., as well as the symbol file name." "help info files"
+gdb_test "help info files" "Names of targets and files being debugged\.\[\r\n\]+Shows the entire stack of targets currently in use \\(including the exec-file,\[\r\n\]+core-file, and process, if any\\), as well as the symbol file name\." "help info files"
 # test help info float
-gdb_test "help info float" "Print the status of the floating point unit"  "help info float"
+gdb_test "help info float" "Print the status of the floating point unit" "help info float"
 # test help info functions
-gdb_test "help info functions" "All function names, or those matching REGEXP."  "help info functions"
+gdb_test "help info functions" "All function names, or those matching REGEXP\." "help info functions"
 # test help info line
-gdb_test "help info line" "Core addresses of the code for a source line..*\[\r\n\]+Line can be specified as.*\[\r\n\]+  LINENUM, to list around that line in current file,.*\[\r\n\]+  FILE:LINENUM, to list around that line in that file,.*\[\r\n\]+  FUNCTION, to list around beginning of that function,.*\[\r\n\]+  FILE:FUNCTION, to distinguish among like-named static functions..*\[\r\n\]+Default is to describe the last source line that was listed..*\[\r\n\]+This sets the default address for \"x\" to the line's first instruction.*\[\r\n\]+so that \"x.i\" suffices to start examining the machine code..*\[\r\n\]+The address is also stored as the value of \"._\"." "help info line"
+gdb_test "help info line" "Core addresses of the code for a source line\.\[\r\n\]+Line can be specified as\[\r\n\]+  LINENUM, to list around that line in current file,\[\r\n\]+  FILE:LINENUM, to list around that line in that file,\[\r\n\]+  FUNCTION, to list around beginning of that function,\[\r\n\]+  FILE:FUNCTION, to distinguish among like-named static functions\.\[\r\n\]+Default is to describe the last source line that was listed\.\[\r\n\]+This sets the default address for \"x\" to the line's first instruction\[\r\n\]+so that \"x/i\" suffices to start examining the machine code\.\[\r\n\]+The address is also stored as the value of \"\\\$_\"\." "help info line"
 # test help info locals
-gdb_test "help info locals" "Local variables of current stack frame."  "help info locals"
+gdb_test "help info locals" "Local variables of current stack frame\." "help info locals"
 # test help info program
-gdb_test "help info program" "Execution status of the program."  "help info program"
+gdb_test "help info program" "Execution status of the program\." "help info program"
 # test help info registers
-gdb_test "help info registers" "List of integer registers and their contents, for selected stack frame..*\[\r\n\]+Register name as argument means describe only that register." "help info registers"
+gdb_test "help info registers" "List of integer registers and their contents, for selected stack frame\.\[\r\n\]+Register name as argument means describe only that register\." "help info registers"
 # test help info stack "s" abbreviation
-gdb_test "help info s" "Backtrace of the stack, or innermost COUNT frames."  "help info stack \"s\" abbreviation"
+gdb_test "help info s" "Backtrace of the stack, or innermost COUNT frames\." "help info stack \"s\" abbreviation"
 # test help info stack
-gdb_test "help info stack" "Backtrace of the stack, or innermost COUNT frames."  "help info stack"
+gdb_test "help info stack" "Backtrace of the stack, or innermost COUNT frames\." "help info stack"
 # test help info set
-gdb_test "help info set" "Show all GDB settings."  "help info set"
+gdb_test "help info set" "Show all GDB settings\." "help info set"
 # test help info signals
-gdb_test "help info signals" "What debugger does when program gets various signals.*"  "help info signals"
+gdb_test "help info signals" "What debugger does when program gets various signals.*" "help info signals"
 # test help info source
-gdb_test "help info source" "Information about the current source file."  "help info source"
+gdb_test "help info source" "Information about the current source file\." "help info source"
 # test help info sources
-gdb_test "help info sources" "Source files in the program."  "help info sources"
+gdb_test "help info sources" "Source files in the program\." "help info sources"
 # test help info symbol
 gdb_test "help info symbol" "Describe what symbol is at location ADDR.*"
 # test help info target
-gdb_test "help info target" "Names of targets and files being debugged..*\[\r\n\]+Shows the entire stack of targets currently in use .including the exec-file,.*\[\r\n\]+core-file, and process, if any., as well as the symbol file name." "help info target"
+gdb_test "help info target" "Names of targets and files being debugged\.\[\r\n\]+Shows the entire stack of targets currently in use \\(including the exec-file,\[\r\n\]+core-file, and process, if any\\), as well as the symbol file name\." "help info target"
 # test help info terminal
-gdb_test "help info terminal" "Print inferior's saved terminal status."  "help info terminal"
+gdb_test "help info terminal" "Print inferior's saved terminal status\." "help info terminal"
 # test help info types
-gdb_test "help info types" "All type names, or those matching REGEXP."  "help info types"
+gdb_test "help info types" "All type names, or those matching REGEXP\." "help info types"
 # test help info variables
-gdb_test "help info variables" "All global and static variable names, or those matching REGEXP."  "help info variables"
+gdb_test "help info variables" "All global and static variable names, or those matching REGEXP\." "help info variables"
 # test help info warranty
-gdb_test "help info warranty" "Various kinds of warranty you do not have."  "help info warranty"
+gdb_test "help info warranty" "Various kinds of warranty you do not have\." "help info warranty"
 # test help info watchpoints
-gdb_test "help info watchpoints" "Synonym for ``info breakpoints''."  "help info watchpoints"
+gdb_test "help info watchpoints" "Synonym for ``info breakpoints''\." "help info watchpoints"
 # test help inspect
-gdb_test "help inspect" "Same as \"print\" command, except that if you are running in the epoch.*\[\r\n\]+environment, the value is printed in its own window." "help inspect"
+gdb_test "help inspect" "Same as \"print\" command, except that if you are running in the epoch\[\r\n\]+environment, the value is printed in its own window\." "help inspect"
 # test help jump
-gdb_test "help jump" "Continue program being debugged at specified line or address..*\[\r\n\]+Give as argument either LINENUM or \[*\]+ADDR, where ADDR is an expression.*\[\r\n\]+for an address to start at." "help jump"
+gdb_test "help jump" "Continue program being debugged at specified line or address\.\[\r\n\]+Give as argument either LINENUM or \[*\]+ADDR, where ADDR is an expression\[\r\n\]+for an address to start at\." "help jump"
 # test help kill
-gdb_test "help kill" "Kill execution of program being debugged."  "help kill"
+gdb_test "help kill" "Kill execution of program being debugged\." "help kill"
 # test help list "l" abbreviation
-gdb_test "help l" "List specified function or line..*\[\r\n\]+With no argument, lists ten more lines after or around previous listing..*\[\r\n\]+\"list -\" lists the ten lines before a previous ten-line listing..*\[\r\n\]+One argument specifies a line, and ten lines are listed around that line..*\[\r\n\]+Two arguments with comma between specify starting and ending lines to list..*\[\r\n\]+Lines can be specified in these ways:.*\[\r\n\]+  LINENUM, to list around that line in current file,.*\[\r\n\]+  FILE:LINENUM, to list around that line in that file,.*\[\r\n\]+  FUNCTION, to list around beginning of that function,.*\[\r\n\]+  FILE:FUNCTION, to distinguish among like-named static functions..*\[\r\n\]+  \[*\]+ADDRESS, to list around the line containing that address..*\[\r\n\]+With two args if one is empty it stands for ten lines away from the other arg." "help list \"l\" abbreviation"
+gdb_test "help l" "List specified function or line\.\[\r\n\]+With no argument, lists ten more lines after or around previous listing\.\[\r\n\]+\"list -\" lists the ten lines before a previous ten-line listing\.\[\r\n\]+One argument specifies a line, and ten lines are listed around that line\.\[\r\n\]+Two arguments with comma between specify starting and ending lines to list\.\[\r\n\]+Lines can be specified in these ways:\[\r\n\]+  LINENUM, to list around that line in current file,\[\r\n\]+  FILE:LINENUM, to list around that line in that file,\[\r\n\]+  FUNCTION, to list around beginning of that function,\[\r\n\]+  FILE:FUNCTION, to distinguish among like-named static functions\.\[\r\n\]+  \[*\]ADDRESS, to list around the line containing that address\.\[\r\n\]+With two args if one is empty it stands for ten lines away from the other arg\." "help list \"l\" abbreviation"
 # test help list
-gdb_test "help list" "List specified function or line..*\[\r\n\]+With no argument, lists ten more lines after or around previous listing..*\[\r\n\]+\"list -\" lists the ten lines before a previous ten-line listing..*\[\r\n\]+One argument specifies a line, and ten lines are listed around that line..*\[\r\n\]+Two arguments with comma between specify starting and ending lines to list..*\[\r\n\]+Lines can be specified in these ways:.*\[\r\n\]+  LINENUM, to list around that line in current file,.*\[\r\n\]+  FILE:LINENUM, to list around that line in that file,.*\[\r\n\]+  FUNCTION, to list around beginning of that function,.*\[\r\n\]+  FILE:FUNCTION, to distinguish among like-named static functions..*\[\r\n\]+  \[*\]+ADDRESS, to list around the line containing that address..*\[\r\n\]+With two args if one is empty it stands for ten lines away from the other arg." "help list"
+gdb_test "help list" "List specified function or line\.\[\r\n\]+With no argument, lists ten more lines after or around previous listing\.\[\r\n\]+\"list -\" lists the ten lines before a previous ten-line listing\.\[\r\n\]+One argument specifies a line, and ten lines are listed around that line\.\[\r\n\]+Two arguments with comma between specify starting and ending lines to list\.\[\r\n\]+Lines can be specified in these ways:\[\r\n\]+  LINENUM, to list around that line in current file,\[\r\n\]+  FILE:LINENUM, to list around that line in that file,\[\r\n\]+  FUNCTION, to list around beginning of that function,\[\r\n\]+  FILE:FUNCTION, to distinguish among like-named static functions\.\[\r\n\]+  \[*\]ADDRESS, to list around the line containing that address\.\[\r\n\]+With two args if one is empty it stands for ten lines away from the other arg\." "help list"
 # test help load
-gdb_test "help load" "Dynamically load FILE into the running program, and record its symbols.*\[\r\n\]+for access from GDB." "help load"
+gdb_test "help load" "Dynamically load FILE into the running program, and record its symbols\[\r\n\]+for access from GDB\." "help load"
 # test help make
-gdb_test "help make" "Run the ``make'' program using the rest of the line as arguments."  "help make"
+gdb_test "help make" "Run the ``make'' program using the rest of the line as arguments\." "help make"
 # test help next "n" abbreviation
-gdb_test "help n" "Step program, proceeding through subroutine calls..*\[\r\n\]+Like the \"step\" command as long as subroutine calls do not happen;.*\[\r\n\]+when they do, the call is treated as one instruction..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help next \"n\" abbreviation"
+gdb_test "help n" "Step program, proceeding through subroutine calls\.\[\r\n\]+Like the \"step\" command as long as subroutine calls do not happen;\[\r\n\]+when they do, the call is treated as one instruction\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help next \"n\" abbreviation"
 # test help next
-gdb_test "help next" "Step program, proceeding through subroutine calls..*\[\r\n\]+Like the \"step\" command as long as subroutine calls do not happen;.*\[\r\n\]+when they do, the call is treated as one instruction..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help next"
+gdb_test "help next" "Step program, proceeding through subroutine calls\.\[\r\n\]+Like the \"step\" command as long as subroutine calls do not happen;\[\r\n\]+when they do, the call is treated as one instruction\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help next"
 # test help nexti
-gdb_test "help ni" "Step one instruction, but proceed through subroutine calls..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help nexti"
+gdb_test "help ni" "Step one instruction, but proceed through subroutine calls\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help nexti"
 # all the commands that used to be here are now in "maintainance" instead
 # test help obscure
-gdb_test "help obscure" "Obscure features..*\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help obscure"
+gdb_test "help obscure" "Obscure features\.\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help obscure"
 # test help output
-gdb_test "help output" "Like \"print\" but don't put in value history and don't print newline..*\[\r\n\]+This is useful in user-defined commands." "help output"
+gdb_test "help output" "Like \"print\" but don't put in value history and don't print newline\.\[\r\n\]+This is useful in user-defined commands\." "help output"
 # test help overlay
 gdb_test "help overlay"       "Commands for debugging overlays.*"
-gdb_test "help overlay off"   "Disable overlay debugging."
-gdb_test "help overlay manual" "Enable overlay debugging."
-gdb_test "help overlay auto"  "Enable automatic overlay debugging."
-gdb_test "help overlay list"  "List mappings of overlay sections."
-gdb_test "help overlay map"   "Assert that an overlay section is mapped."
-gdb_test "help overlay unmap" "Assert that an overlay section is unmapped."
-gdb_test "help overlay load"  "Read the overlay mapping state from the target."
+gdb_test "help overlay off"   "Disable overlay debugging\."
+gdb_test "help overlay manual" "Enable overlay debugging\."
+gdb_test "help overlay auto"  "Enable automatic overlay debugging\."
+gdb_test "help overlay list"  "List mappings of overlay sections\."
+gdb_test "help overlay map"   "Assert that an overlay section is mapped\."
+gdb_test "help overlay unmap" "Assert that an overlay section is unmapped\."
+gdb_test "help overlay load"  "Read the overlay mapping state from the target\."
 # test help print "p" abbreviation
-gdb_test "help p" "Print value of expression EXP..*\[\r\n\]+Variables accessible are those of the lexical environment of the selected.*\[\r\n\]+EXP may be preceded with /FMT, where FMT is a format letter.*\[\r\n\]+but no count or size letter .see \"x\" command.." "help print \"p\" abbreviation"
+gdb_test "help p" "Print value of expression EXP\.\[\r\n\]+Variables accessible are those of the lexical environment of the selected.*\[\r\n\]+EXP may be preceded with /FMT, where FMT is a format letter\[\r\n\]+but no count or size letter \\(see \"x\" command\\)\." "help print \"p\" abbreviation"
 # test help print
-gdb_test "help print" "Print value of expression EXP..*\[\r\n\]+Variables accessible are those of the lexical environment of the selected.*\[\r\n\]+EXP may be preceded with /FMT, where FMT is a format letter.*\[\r\n\]+but no count or size letter .see \"x\" command.." "help print"
+gdb_test "help print" "Print value of expression EXP\.\[\r\n\]+Variables accessible are those of the lexical environment of the selected.*\[\r\n\]+EXP may be preceded with /FMT, where FMT is a format letter\[\r\n\]+but no count or size letter \\(see \"x\" command\\)\." "help print"
 # test help path
-gdb_test "help path" "Add directory DIR.s. to beginning of search path for object files..*\[\r\n\]+.cwd in the path means the current working directory..*\[\r\n\]+This path is equivalent to the .PATH shell variable.  It is a list of.*\[\r\n\]+directories, separated by colons.  These directories are searched to find.*\[\r\n\]+fully linked executable files and separately compiled object files as needed." "help path"
+gdb_test "help path" "Add directory DIR\\(s\\) to beginning of search path for object files\.\[\r\n\]+\\\$cwd in the path means the current working directory\.\[\r\n\]+This path is equivalent to the \\\$PATH shell variable\.  It is a list of\[\r\n\]+directories, separated by colons\.  These directories are searched to find\[\r\n\]+fully linked executable files and separately compiled object files as needed\." "help path"
 # test help printcmds
-gdb_test "help printcmds" "Undefined command: \"printcmds\".  Try \"help\"."  "help printcmds"
+gdb_test "help printcmds" "Undefined command: \"printcmds\"\.  Try \"help\"\." "help printcmds"
 # test help printf
-gdb_test "help printf" "printf \"printf format string\", arg1, arg2, arg3, ..., argn.*\[\r\n\]+This is useful for formatted output in user-defined commands." "help printf"
+gdb_test "help printf" "printf \"printf format string\", arg1, arg2, arg3, \.\.\., argn\[\r\n\]+This is useful for formatted output in user-defined commands\." "help printf"
 # test help ptype
-gdb_test "help ptype" "Print definition of type.*"  "help ptype"
+gdb_test "help ptype" "Print definition of type.*" "help ptype"
 # test help pwd
-gdb_test "help pwd" "Print working directory.  This is used for your program as well."  "help pwd"
+gdb_test "help pwd" "Print working directory\.  This is used for your program as well\." "help pwd"
 # test help quit "q" abbreviation
-gdb_test "help q" "Exit gdb." "help quit \"q\" abbreviation"
+gdb_test "help q" "Exit gdb\." "help quit \"q\" abbreviation"
 # test help quit
-gdb_test "help quit" "Exit gdb."  "help quit"
+gdb_test "help quit" "Exit gdb\." "help quit"
 # test help run "r" abbreviation
-gdb_test "help r" "Start debugged program.  You may specify arguments to give it..*\[\r\n\]+Args may include .*, or .*; they are expanded using \"sh\"..*\[\r\n\]+Input and output redirection with \".\", \".\", or \"..\" are also allowed..*\[\r\n\]+With no arguments, uses arguments last specified .with \"run\" or \"set args\"...*\[\r\n\]+To cancel previous arguments and run with no arguments,.*\[\r\n\]+use \"set args\" without arguments." "help run \"r\" abbreviation"
+gdb_test "help r" "Start debugged program\.  You may specify arguments to give it\.\[\r\n\]+Args may include \"\\*\", or \"\\\[\.\.\.\\\]\"; they are expanded using \"sh\"\.\[\r\n\]+Input and output redirection with \">\", \"<\", or \">>\" are also allowed\.\[\r\n\]+With no arguments, uses arguments last specified \\(with \"run\" or \"set args\"\\)\.\[\r\n\]+To cancel previous arguments and run with no arguments,\[\r\n\]+use \"set args\" without arguments\." "help run \"r\" abbreviation"
 # test help run
-gdb_test "help run" "Start debugged program.  You may specify arguments to give it..*\[\r\n\]+Args may include .*, or .*; they are expanded using \"sh\"..*\[\r\n\]+Input and output redirection with \".\", \".\", or \"..\" are also allowed..*\[\r\n\]+With no arguments, uses arguments last specified .with \"run\" or \"set args\"...*\[\r\n\]+To cancel previous arguments and run with no arguments,.*\[\r\n\]+use \"set args\" without arguments." "help run"
+gdb_test "help run" "Start debugged program\.  You may specify arguments to give it\.\[\r\n\]+Args may include \"\\*\", or \"\\\[\.\.\.\\\]\"; they are expanded using \"sh\"\.\[\r\n\]+Input and output redirection with \">\", \"<\", or \">>\" are also allowed\.\[\r\n\]+With no arguments, uses arguments last specified \\(with \"run\" or \"set args\"\\)\.\[\r\n\]+To cancel previous arguments and run with no arguments,\[\r\n\]+use \"set args\" without arguments\." "help run"
 # test help rbreak
-gdb_test "help rbreak" "Set a breakpoint for all functions matching REGEXP."  "help rbreak"
+gdb_test "help rbreak" "Set a breakpoint for all functions matching REGEXP\." "help rbreak"
+# test help restore
+gdb_test "help restore" "Restore the contents of FILE to target memory\.\[\r\n\]+Arguments are FILE OFFSET START END where all except FILE are optional\.\[\r\n\]+OFFSET will be added to the base address of the file \\(default zero\\)\.\[\r\n\]+If START and END are given, only the file contents within that range\[\r\n\]+\\(file relative\\) will be restored to target memory\."
 # test help return
-gdb_test "help return" "Make selected stack frame return to its caller..*\[\r\n\]+Control remains in the debugger, but when you continue.*\[\r\n\]+execution will resume in the frame above the one now selected..*\[\r\n\]+If an argument is given, it is an expression for the value to return." "help return"
+gdb_test "help return" "Make selected stack frame return to its caller\.\[\r\n\]+Control remains in the debugger, but when you continue\[\r\n\]+execution will resume in the frame above the one now selected\.\[\r\n\]+If an argument is given, it is an expression for the value to return\." "help return"
 # test help reverse-search
-gdb_test "help reverse-search" "Search backward for regular expression .see regex.3.. from last line listed..*"  "help reverse-search"
+gdb_test "help reverse-search" "Search backward for regular expression \\(see regex\\(3\\)\\) from last line listed\..*" "help reverse-search"
 # test help running
-gdb_test "help running" "Running the program..*\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help running"
+gdb_test "help running" "Running the program\.\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help running"
 # test help step "s" abbreviation
-gdb_test "help s" "Step program until it reaches a different source line..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help step \"s\" abbreviation"
+gdb_test "help s" "Step program until it reaches a different source line\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help step \"s\" abbreviation"
 # test help step
-gdb_test "help step" "Step program until it reaches a different source line..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help step #1"
+gdb_test "help step" "Step program until it reaches a different source line\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help step #1"
 # test help search
-gdb_test "help search" "Search for regular expression .see regex.3.. from last line listed..*"  "help search"
+gdb_test "help search" "Search for regular expression \\(see regex\\(3\\)\\) from last line listed\..*" "help search"
 # test help section
-gdb_test "help section" "Change the base address of section SECTION of the exec file to ADDR..*\[\r\n\]+This can be used if the exec file does not contain section addresses,.*\[\r\n\]+.such as in the a.out format., or when the addresses specified in the.*\[\r\n\]+file itself are wrong.  Each section must be changed separately.  The.*\[\r\n\]+``info files'' command lists all the sections and their addresses." "help section"
+gdb_test "help section" "Change the base address of section SECTION of the exec file to ADDR\.\[\r\n\]+This can be used if the exec file does not contain section addresses,\[\r\n\]+\\(such as in the a\.out format\\), or when the addresses specified in the\[\r\n\]+file itself are wrong\.  Each section must be changed separately\.  The\[\r\n\]+``info files'' command lists all the sections and their addresses\." "help section"
 #test help set annotate
-gdb_test "help set annotate" "Set annotation_level.*\[\r\n\]+0 == normal;     1 == fullname \\(for use when running under emacs\\).*\[\r\n\]+2 == output annotated suitably for use by programs that control GDB." "help set annotate"
+gdb_test "help set annotate" "Set annotation_level\.\[\r\n\]+0 == normal;     1 == fullname \\(for use when running under emacs\\)\[\r\n\]+2 == output annotated suitably for use by programs that control GDB\." "help set annotate"
 # test help set args
-gdb_test "help set args" "Set argument list to give program being debugged when it is started..*\[\r\n\]+Follow this command with any number of args, to be passed to the program."
+gdb_test "help set args" "Set argument list to give program being debugged when it is started\.\[\r\n\]+Follow this command with any number of args, to be passed to the program\."
 # test help set check "c" abbreviation
-gdb_test "help set c" "Set the status of the type/range checker.*\[\r\n\]+List of set check subcommands:.*\[\r\n\]+set check range -- Set range checking.*\[\r\n\]+set check type -- Set type checking.*\[\r\n\]+Type \"help set check\" followed by set check subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set check \"c\" abbreviation"
+gdb_test "help set c" "Set the status of the type/range checker\.\[\r\n\]+List of set check subcommands:\[\r\n\]+set check range -- Set range checking\[\r\n\]+set check type -- Set type checking\[\r\n\]+Type \"help set check\" followed by set check subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set check \"c\" abbreviation"
 # test help set check "ch" abbreviation
-gdb_test "help set ch" "Set the status of the type/range checker.*\[\r\n\]+List of set check subcommands:.*\[\r\n\]+set check range -- Set range checking.*\[\r\n\]+set check type -- Set type checking.*\[\r\n\]+Type \"help set check\" followed by set check subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set check \"ch\" abbreviation"
+gdb_test "help set ch" "Set the status of the type/range checker\.\[\r\n\]+List of set check subcommands:\[\r\n\]+set check range -- Set range checking\[\r\n\]+set check type -- Set type checking\[\r\n\]+Type \"help set check\" followed by set check subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set check \"ch\" abbreviation"
 # test help set check
-gdb_test "help set check" "Set the status of the type/range checker.*\[\r\n\]+List of set check subcommands:.*\[\r\n\]+set check range -- Set range checking.*\[\r\n\]+set check type -- Set type checking.*\[\r\n\]+Type \"help set check\" followed by set check subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set check"
+gdb_test "help set check" "Set the status of the type/range checker\.\[\r\n\]+List of set check subcommands:\[\r\n\]+set check range -- Set range checking\[\r\n\]+set check type -- Set type checking\[\r\n\]+Type \"help set check\" followed by set check subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set check"
 # test help set check range
-gdb_test "help set check range" "Set range checking.  .on/warn/off/auto."  "help set check range"
+gdb_test "help set check range" "Set range checking\.  \\(on/warn/off/auto\\)" "help set check range"
 # test help set check type
-gdb_test "help set check type" "Set type checking.  .on/warn/off/auto."  "help set check type"
+gdb_test "help set check type" "Set type checking\.  \\(on/warn/off/auto\\)." "help set check type"
 # test help set complaints
-gdb_test "help set complaints" "Set max number of complaints about incorrect symbols."  "help set complaints"
+gdb_test "help set complaints" "Set max number of complaints about incorrect symbols\." "help set complaints"
 # test help set confirm
-gdb_test "help set confirm" "Set whether to confirm potentially dangerous operations."  "help set confirm"
+gdb_test "help set confirm" "Set whether to confirm potentially dangerous operations\." "help set confirm"
 # test help set editing
-gdb_test "help set editing" "Set editing of command lines as they are typed..*\[\r\n\]+Use \"on\" to enable the editing, and \"off\" to disable it..*\[\r\n\]+Without an argument, command line editing is enabled.  To edit, use.*\[\r\n\]+EMACS-like or VI-like commands like control-P or ESC." "help set editing"
+gdb_test "help set editing" "Set editing of command lines as they are typed\.\[\r\n\]+Use \"on\" to enable the editing, and \"off\" to disable it\.\[\r\n\]+Without an argument, command line editing is enabled\.  To edit, use\[\r\n\]+EMACS-like or VI-like commands like control-P or ESC\." "help set editing"
 # test help set environment
-gdb_test "help set environment" "Set environment variable value to give the program..*\[\r\n\]+Arguments are VAR VALUE where VAR is variable name and VALUE is value..*\[\r\n\]+VALUES of environment variables are uninterpreted strings..*\[\r\n\]+This does not affect the program until the next \"run\" command." "help set environment"
+gdb_test "help set environment" "Set environment variable value to give the program\.\[\r\n\]+Arguments are VAR VALUE where VAR is variable name and VALUE is value\.\[\r\n\]+VALUES of environment variables are uninterpreted strings\.\[\r\n\]+This does not affect the program until the next \"run\" command\." "help set environment"
 # test help set height
-gdb_test "help set height" "Set number of lines gdb thinks are in a page."  "help set height"
+gdb_test "help set height" "Set number of lines gdb thinks are in a page\." "help set height"
 # test help set history expansion
-gdb_test "help set history expansion" "Set history expansion on command input..*\[\r\n\]+Without an argument, history expansion is enabled." "help set history expansion"
+gdb_test "help set history expansion" "Set history expansion on command input\.\[\r\n\]+Without an argument, history expansion is enabled\." "help set history expansion"
 # test help set history filename
-gdb_test "help set history filename" "Set the filename in which to record the command history.*\[\r\n\]+ .the list of previous commands of which a record is kept.." "help set history filename"
+gdb_test "help set history filename" "Set the filename in which to record the command history\[\r\n\]+\\(the list of previous commands of which a record is kept\\)\." "help set history filename"
 # test help set history save
-gdb_test "help set history save" "Set saving of the history record on exit..*\[\r\n\]+Use \"on\" to enable the saving, and \"off\" to disable it..*\[\r\n\]+Without an argument, saving is enabled." "help set history save"
+gdb_test "help set history save" "Set saving of the history record on exit\.\[\r\n\]+Use \"on\" to enable the saving, and \"off\" to disable it\.\[\r\n\]+Without an argument, saving is enabled\." "help set history save"
 # test help set history size
-gdb_test "help set history size" "Set the size of the command history, .*\[\r\n\]+ie. the number of previous commands to keep a record of." "help set history size"
+gdb_test "help set history size" "Set the size of the command history,\[\r\n\]+ie\. the number of previous commands to keep a record of\." "help set history size"
 # test help set history
-gdb_test "help set history" "Generic command for setting command history parameters..*\[\r\n\]+List of set history subcommands:.*\[\r\n\]+set history expansion -- Set history expansion on command input.*\[\r\n\]+set history filename -- Set the filename in which to record the command history.*\[\r\n\]+set history save -- Set saving of the history record on exit.*\[\r\n\]+set history size -- Set the size of the command history.*\[\r\n\]+Type \"help set history\" followed by set history subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set history"
+gdb_test "help set history" "Generic command for setting command history parameters\.\[\r\n\]+List of set history subcommands:\[\r\n\]+set history expansion -- Set history expansion on command input\[\r\n\]+set history filename -- Set the filename in which to record the command history\[\r\n\]+set history save -- Set saving of the history record on exit\[\r\n\]+set history size -- Set the size of the command history\[\r\n\]+Type \"help set history\" followed by set history subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set history"
 # test help set language
-gdb_test "help set language" "Set the current source language."  "help set language"
+gdb_test "help set language" "Set the current source language\." "help set language"
 # test help set listsize
-gdb_test "help set listsize" "Set number of source lines gdb will list by default."  "help set listsize"
+gdb_test "help set listsize" "Set number of source lines gdb will list by default\." "help set listsize"
 # test help set print "p" abbreviation
 # FIXME -- Ultrix hangs randomly on this very long output from gdb and
 # continues with its output only if something is sent to gdb.
 # Also, if the system is slow, it may time out because the output is large.
-gdb_test "help set p" ".*\[\r\n\]+Generic command for setting how things print..*\[\r\n\]+List of set print subcommands:.*\[\r\n\]+Type \"help set print\" followed by set print subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set print \"p\" abbreviatio"
+gdb_test "help set p" "Generic command for setting how things print\.\[\r\n\]+List of set print subcommands:.*\[\r\n\]+Type \"help set print\" followed by set print subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set print \"p\" abbreviation"
 # test help set print "pr" abbreviation
-gdb_test "help set pr" ".*\[\r\n\]+Generic command for setting how things print..*\[\r\n\]+List of set print subcommands:.*\[\r\n\]+Type \"help set print\" followed by set print subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set print \"pr\" abbreviation"
+gdb_test "help set pr" "Generic command for setting how things print\.\[\r\n\]+List of set print subcommands:.*\[\r\n\]+Type \"help set print\" followed by set print subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set print \"pr\" abbreviation"
 # test help set print
-gdb_test "help set print" ".*\[\r\n\]+Generic command for setting how things print..*\[\r\n\]+List of set print subcommands:.*\[\r\n\]+Type \"help set print\" followed by set print subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help set print"
+gdb_test "help set print" "Generic command for setting how things print\.\[\r\n\]+List of set print subcommands:.*\[\r\n\]+Type \"help set print\" followed by set print subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help set print"
 # test help set print address
-gdb_test "help set print address" "Set printing of addresses."  "help set print address"
+gdb_test "help set print address" "Set printing of addresses\." "help set print address"
 # test help set print array
-gdb_test "help set print array" "Set prettyprinting of arrays."  "help set print array"
+gdb_test "help set print array" "Set prettyprinting of arrays\." "help set print array"
 # test help set print asm-demangle
-gdb_test "help set print asm-demangle" "Set demangling of C\[+\]+ names in disassembly listings."  "help set print asm-demangle"
+gdb_test "help set print asm-demangle" "Set demangling of C\[+\]+ names in disassembly listings\." "help set print asm-demangle"
 # test help set print demangle
-gdb_test "help set print demangle" "Set demangling of encoded C\[+\]+ names when displaying symbols."  "help set print demangle"
+gdb_test "help set print demangle" "Set demangling of encoded C\[+\]+ names when displaying symbols\." "help set print demangle"
 # test help set print elements
-gdb_test "help set print elements" "Set limit on string chars or array elements to print..*\[\r\n\]+\"set print elements 0\" causes there to be no limit." "help set print elements"
+gdb_test "help set print elements" "Set limit on string chars or array elements to print\.\[\r\n\]+\"set print elements 0\" causes there to be no limit\." "help set print elements"
 # test help set print object
-gdb_test "help set print object" "Set printing of object's derived type based on vtable info."  "help set print object"
+gdb_test "help set print object" "Set printing of object's derived type based on vtable info\." "help set print object"
 # test help set print pretty
-gdb_test "help set print pretty" "Set prettyprinting of structures."  "help set print pretty"
+gdb_test "help set print pretty" "Set prettyprinting of structures\." "help set print pretty"
 # test help set print sevenbit-strings
-gdb_test "help set print sevenbit-strings" "Set printing of 8-bit characters in strings as .nnn."  "help set print sevenbit-strings"
+gdb_test "help set print sevenbit-strings" "Set printing of 8-bit characters in strings as \\\\nnn\." "help set print sevenbit-strings"
 # test help set print union
-gdb_test "help set print union" "Set printing of unions interior to structures."  "help set print union"
+gdb_test "help set print union" "Set printing of unions interior to structures\." "help set print union"
 # test help set print vtbl
-gdb_test "help set print vtbl" "Set printing of C\[+\]+ virtual function tables."  "help set print vtbl"
+gdb_test "help set print vtbl" "Set printing of C\[+\]+ virtual function tables\." "help set print vtbl"
 # test help set prompt
-gdb_test "help set prompt" "Set gdb's prompt"  "help set prompt"
+gdb_test "help set prompt" "Set gdb's prompt" "help set prompt"
 # test help set radix
-gdb_test "help set radix" "Set default input and output number radices.*\[\r\n\]+Use \'set input-radix\' or \'set output-radix\' to independently set each..*\[\r\n\]+Without an argument, sets both radices back to the default value of 10..*\[\r\n\]+" "help set radix"
+gdb_test "help set radix" "Set default input and output number radices\.\[\r\n\]+Use \'set input-radix\' or \'set output-radix\' to independently set each\.\[\r\n\]+Without an argument, sets both radices back to the default value of 10\." "help set radix"
 # test help set symbol-reloading
-gdb_test "help set symbol-reloading" "Set dynamic symbol table reloading multiple times in one run."  "help set symbol-reloading"
+gdb_test "help set symbol-reloading" "Set dynamic symbol table reloading multiple times in one run\." "help set symbol-reloading"
 # test help set variable
-gdb_test "help set variable" ".*\[\r\n\]+Evaluate expression EXP and assign result to variable VAR, using assignment.*\[\r\n\]+syntax appropriate for the current language .VAR = EXP or VAR := EXP for.*\[\r\n\]+example..  VAR may be a debugger \"convenience\" variable .names starting.*\[\r\n\]+with \\\$., a register .a few standard names starting with \\\$., or an actual.*\[\r\n\]+variable in the program being debugged.  EXP is any valid expression.*\[\r\n\]+This may usually be abbreviated to simply \"set\"." "help set variable"
+gdb_test "help set variable" "Evaluate expression EXP and assign result to variable VAR, using assignment\[\r\n\]+syntax appropriate for the current language \\(VAR = EXP or VAR := EXP for\[\r\n\]+example\\)\.  VAR may be a debugger \"convenience\" variable \\(names starting\[\r\n\]+with \\\$\\), a register \\(a few standard names starting with \\\$\\), or an actual\[\r\n\]+variable in the program being debugged\.  EXP is any valid expression\.\[\r\n\]+This may usually be abbreviated to simply \"set\"\." "help set variable"
 # test help set verbose
-gdb_test "help set verbose" "Set verbosity."  "help set verbose"
+gdb_test "help set verbose" "Set verbosity\." "help set verbose"
 #test help set width
-gdb_test "help set width" "Set number of characters gdb thinks are in a line."  "help set width"
+gdb_test "help set width" "Set number of characters gdb thinks are in a line\." "help set width"
 # test help set write
 # This is only supported on targets which use exec.o.
-gdb_test "help set write" "Set writing into executable and core files."  "help set write"
+gdb_test "help set write" "Set writing into executable and core files\." "help set write"
 # test help set
 # FIXME -- Ultrix hangs randomly on this very long output from gdb and
 # continues with its output only if something is sent to gdb.
 # Also, if the system is slow, it may time out because the output is large.
-#gdb_test "help set" ".*\[\r\n\]+Evaluate expression EXP and assign result to variable VAR, using assignment.*\[\r\n\]+syntax appropriate for the current language .VAR = EXP or VAR := EXP for.*\[\r\n\]+example..  VAR may be a debugger \"convenience\" variable .names starting.*\[\r\n\]+with \\\$., a register .a few standard names starting with \\\$., or an actual.*\[\r\n\]+variable in the program being debugged.  EXP is any valid expression.*\[\r\n\]+set listsize -- Set number of source lines gdb will list by default.*\[\r\n\]+Type \"help set\" followed by set subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous..*\[\r\n\]+" "help set"
+gdb_test "help set" "Evaluate expression EXP and assign result to variable VAR, using assignment\[\r\n\]+syntax appropriate for the current language \\(VAR = EXP or VAR := EXP for\[\r\n\]+example\\)\.  VAR may be a debugger \"convenience\" variable \\(names starting\[\r\n\]+with \\\$\\), a register \\(a few standard names starting with \\\$\\), or an actual\[\r\n\]+variable in the program being debugged\.  EXP is any valid expression.*\[\r\n\]+set listsize -- Set number of source lines gdb will list by default.*\[\r\n\]+Type \"help set\" followed by set subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous..*\[\r\n\]+" "help set"
 # test help shell
-gdb_test "help shell" "Execute the rest of the line as a shell command.  .*\[\r\n\]+With no arguments, run an inferior shell." "help shell"
+gdb_test "help shell" "Execute the rest of the line as a shell command\.\[\r\n\]+With no arguments, run an inferior shell\." "help shell"
 #test help show annotate
-gdb_test "help show annotate" "Show annotation_level.*\[\r\n\]+0 == normal;     1 == fullname \\(for use when running under emacs\\).*\[\r\n\]+2 == output annotated suitably for use by programs that control GDB." "help show annotate"
+gdb_test "help show annotate" "Show annotation_level\.\[\r\n\]+0 == normal;     1 == fullname \\(for use when running under emacs\\)\[\r\n\]+2 == output annotated suitably for use by programs that control GDB\." "help show annotate"
 # test help show args
-gdb_test "help show args" "Show argument list to give program being debugged when it is started..*\[\r\n\]+Follow this command with any number of args, to be passed to the program."
+gdb_test "help show args" "Show argument list to give program being debugged when it is started\.\[\r\n\]+Follow this command with any number of args, to be passed to the program\."
 # test help show check "c" abbreviation
-gdb_test "help show c" "Show the status of the type/range checker.*\[\r\n\]+List of show check subcommands:.*\[\r\n\]+show check range -- Show range checking.*\[\r\n\]+show check type -- Show type checking.*\[\r\n\]+Type \"help show check\" followed by show check subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show check \"c\" abbreviation"
+gdb_test "help show c" "Show the status of the type/range checker\.\[\r\n\]+List of show check subcommands:\[\r\n\]+show check range -- Show range checking\[\r\n\]+show check type -- Show type checking\[\r\n\]+Type \"help show check\" followed by show check subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show check \"c\" abbreviation"
 # test help show check
-gdb_test "help show check" "Show the status of the type/range checker.*\[\r\n\]+List of show check subcommands:.*\[\r\n\]+show check range -- Show range checking.*\[\r\n\]+show check type -- Show type checking.*\[\r\n\]+Type \"help show check\" followed by show check subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show check"
+gdb_test "help show check" "Show the status of the type/range checker\.\[\r\n\]+List of show check subcommands:\[\r\n\]+show check range -- Show range checking\[\r\n\]+show check type -- Show type checking\[\r\n\]+Type \"help show check\" followed by show check subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show check"
 # test help show check range
-gdb_test "help show check range" "Show range checking.  .on/warn/off/auto."  "help show check range"
+gdb_test "help show check range" "Show range checking\.  \\(on/warn/off/auto\\)" "help show check range"
 # test help show check type
-gdb_test "help show check type" "Show type checking.  .on/warn/off/auto."  "help show check type"
+gdb_test "help show check type" "Show type checking\.  \\(on/warn/off/auto\\)" "help show check type"
 # test help show commands
-gdb_test "help show commands" "Show the history of commands you typed..*\[\r\n\]+You can supply a command number to start with, or a `\[+\]' to start after.*\[\r\n\]+the previous command number shown." "help show commands"
+gdb_test "help show commands" "Show the history of commands you typed\.\[\r\n\]+You can supply a command number to start with, or a `\[+\]' to start after\[\r\n\]+the previous command number shown\." "help show commands"
 # test help show complaints
-gdb_test "help show complaints" "Show max number of complaints about incorrect symbols."  "help show complaints"
+gdb_test "help show complaints" "Show max number of complaints about incorrect symbols\." "help show complaints"
 # test help show confirm
-gdb_test "help show confirm" "Show whether to confirm potentially dangerous operations."  "help show confirm"
+gdb_test "help show confirm" "Show whether to confirm potentially dangerous operations\." "help show confirm"
 # test help show convenience
-gdb_test "help show convenience" "Debugger convenience .\".foo\". variables..*\[\r\n\]+These variables are created when you assign them values;.*\[\r\n\]+thus, \"print .foo=1\" gives \".foo\" the value 1.  Values may be any type..*\[\r\n\]+A few convenience variables are given values automatically:.*\[\r\n\]+\"._\"holds the last address examined with \"x\" or \"info lines\",.*\[\r\n\]+\".__\" holds the contents of the last address examined with \"x\"." "help show convenience"
+gdb_test "help show convenience" "Debugger convenience \\(\"\\\$foo\"\\) variables\.\[\r\n\]+These variables are created when you assign them values;\[\r\n\]+thus, \"print \\\$foo=1\" gives \"\\\$foo\" the value 1\.  Values may be any type\.\[\r\n\]+A few convenience variables are given values automatically:\[\r\n\]+\"\\\$_\"holds the last address examined with \"x\" or \"info lines\",\[\r\n\]+\"\\\$__\" holds the contents of the last address examined with \"x\"\." "help show convenience"
 # test help show directories
-gdb_test "help show directories" "Current search path for finding source files..*\[\r\n\]+.cwd in the path means the current working directory..*\[\r\n\]+.cdir in the path means the compilation directory of the source file." "help show directories"
+gdb_test "help show directories" "Current search path for finding source files\.\[\r\n\]+\\\$cwd in the path means the current working directory\.\[\r\n\]+\\\$cdir in the path means the compilation directory of the source file\." "help show directories"
 # test help show editing
-gdb_test "help show editing" "Show editing of command lines as they are typed..*\[\r\n\]+Use \"on\" to enable the editing, and \"off\" to disable it..*\[\r\n\]+Without an argument, command line editing is enabled.  To edit, use.*\[\r\n\]+EMACS-like or VI-like commands like control-P or ESC." "help show editing"
+gdb_test "help show editing" "Show editing of command lines as they are typed\.\[\r\n\]+Use \"on\" to enable the editing, and \"off\" to disable it\.\[\r\n\]+Without an argument, command line editing is enabled\.  To edit, use\[\r\n\]+EMACS-like or VI-like commands like control-P or ESC\." "help show editing"
 # test help show environment
-gdb_test "help show environment" "The environment to give the program, or one variable's value..*\[\r\n\]+With an argument VAR, prints the value of environment variable VAR to.*\[\r\n\]+give the program being debugged.  With no arguments, prints the entire.*\[\r\n\]+environment to be given to the program." "help show environment"
+gdb_test "help show environment" "The environment to give the program, or one variable's value\.\[\r\n\]+With an argument VAR, prints the value of environment variable VAR to\[\r\n\]+give the program being debugged\.  With no arguments, prints the entire\[\r\n\]+environment to be given to the program\." "help show environment"
 # test help show height
-gdb_test "help show height" "Show number of lines gdb thinks are in a page."  "help show height"
+gdb_test "help show height" "Show number of lines gdb thinks are in a page\." "help show height"
 # test help show history expansion
-gdb_test "help show history expansion" "Show history expansion on command input..*\[\r\n\]+Without an argument, history expansion is enabled." "help show history expansion"
+gdb_test "help show history expansion" "Show history expansion on command input\.\[\r\n\]+Without an argument, history expansion is enabled\." "help show history expansion"
 # test help show history filename
-gdb_test "help show history filename" "Show the filename in which to record the command history.*\[\r\n\]+ .the list of previous commands of which a record is kept.." "help show history filename"
+gdb_test "help show history filename" "Show the filename in which to record the command history\[\r\n\]+\\(the list of previous commands of which a record is kept\\)\." "help show history filename"
 # test help show history save
-gdb_test "help show history save" "Show saving of the history record on exit..*\[\r\n\]+Use \"on\" to enable the saving, and \"off\" to disable it..*\[\r\n\]+Without an argument, saving is enabled." "help show history save"
+gdb_test "help show history save" "Show saving of the history record on exit\.\[\r\n\]+Use \"on\" to enable the saving, and \"off\" to disable it\.\[\r\n\]+Without an argument, saving is enabled\." "help show history save"
 # test help show history size
-gdb_test "help show history size" "Show the size of the command history, .*\[\r\n\]+ie. the number of previous commands to keep a record of." "help show history size"
+gdb_test "help show history size" "Show the size of the command history,\[\r\n\]+ie\. the number of previous commands to keep a record of\." "help show history size"
 # test help show history
-gdb_test "help show history" "Generic command for showing command history parameters..*\[\r\n\]+List of show history subcommands:.*\[\r\n\]+show history expansion -- Show history expansion on command input.*\[\r\n\]+show history filename -- Show the filename in which to record the command history.*\[\r\n\]+show history save -- Show saving of the history record on exit.*\[\r\n\]+show history size -- Show the size of the command history.*\[\r\n\]+Type \"help show history\" followed by show history subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show history"
+gdb_test "help show history" "Generic command for showing command history parameters\.\[\r\n\]+List of show history subcommands:\[\r\n\]+show history expansion -- Show history expansion on command input\[\r\n\]+show history filename -- Show the filename in which to record the command history\[\r\n\]+show history save -- Show saving of the history record on exit\[\r\n\]+show history size -- Show the size of the command history\[\r\n\]+Type \"help show history\" followed by show history subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show history"
 # test help show language
-gdb_test "help show language" "Show the current source language."  "help show language"
+gdb_test "help show language" "Show the current source language\." "help show language"
 # test help show listsize
-gdb_test "help show listsize" "Show number of source lines gdb will list by default."  "help show listsize"
+gdb_test "help show listsize" "Show number of source lines gdb will list by default\." "help show listsize"
 # test help show print "p" abbreviation
-gdb_test "help show p" "Generic command for showing print settings..*\[\r\n\]+List of show print subcommands:.*\[\r\n\]+Type \"help show print\" followed by show print subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show print \"p\" abbreviation"
+gdb_test "help show p" "Generic command for showing print settings\.\[\r\n\]+List of show print subcommands:.*\[\r\n\]+Type \"help show print\" followed by show print subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show print \"p\" abbreviation"
 # test help show print "pr" abbreviation
-gdb_test "help show pr" "Generic command for showing print settings..*\[\r\n\]+List of show print subcommands:.*\[\r\n\]+Type \"help show print\" followed by show print subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show print \"pr\" abbreviation"
+gdb_test "help show pr" "Generic command for showing print settings\.\[\r\n\]+List of show print subcommands:.*\[\r\n\]+Type \"help show print\" followed by show print subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show print \"pr\" abbreviation"
 # test help show print
-gdb_test "help show print" "Generic command for showing print settings..*\[\r\n\]+List of show print subcommands:.*\[\r\n\]+Type \"help show print\" followed by show print subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show print"
+gdb_test "help show print" "Generic command for showing print settings\.\[\r\n\]+List of show print subcommands:.*\[\r\n\]+Type \"help show print\" followed by show print subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show print"
 # test help show paths
-gdb_test "help show paths" "Current search path for finding object files..*\[\r\n\]+.cwd in the path means the current working directory..*\[\r\n\]+This path is equivalent to the .PATH shell variable.  It is a list of.*\[\r\n\]+directories, separated by colons.  These directories are searched to find.*\[\r\n\]+fully linked executable files and separately compiled object files as needed." "help show paths"
+gdb_test "help show paths" "Current search path for finding object files\.\[\r\n\]+\\\$cwd in the path means the current working directory\.\[\r\n\]+This path is equivalent to the \\\$PATH shell variable\.  It is a list of\[\r\n\]+directories, separated by colons\.  These directories are searched to find\[\r\n\]+fully linked executable files and separately compiled object files as needed\." "help show paths"
 # test help show print address
-gdb_test "help show print address" "Show printing of addresses."  "help show print address"
+gdb_test "help show print address" "Show printing of addresses\." "help show print address"
 # test help show print array
-gdb_test "help show print array" "Show prettyprinting of arrays."  "help show print array"
+gdb_test "help show print array" "Show prettyprinting of arrays\." "help show print array"
 # test help show print asm-demangle
-gdb_test "help show print asm-demangle" "Show demangling of C\[+\]+ names in disassembly listings."  "help show print asm-demangle"
+gdb_test "help show print asm-demangle" "Show demangling of C\[+\]+ names in disassembly listings\." "help show print asm-demangle"
 # test help show print demangle
-gdb_test "help show print demangle" "Show demangling of encoded C\[+\]+ names when displaying symbols."  "help show print demangle"
+gdb_test "help show print demangle" "Show demangling of encoded C\[+\]+ names when displaying symbols\." "help show print demangle"
 # test help show print elements
-gdb_test "help show print elements" "Show limit on string chars or array elements to print..*\[\r\n\]+\"set print elements 0\" causes there to be no limit." "help show print elements"
+gdb_test "help show print elements" "Show limit on string chars or array elements to print\.\[\r\n\]+\"set print elements 0\" causes there to be no limit\." "help show print elements"
 # test help show print object
-gdb_test "help show print object" "Show printing of object's derived type based on vtable info."  "help show print object"
+gdb_test "help show print object" "Show printing of object's derived type based on vtable info\." "help show print object"
 # test help show print pretty
-gdb_test "help show print pretty" "Show prettyprinting of structures."  "help show print pretty"
+gdb_test "help show print pretty" "Show prettyprinting of structures\." "help show print pretty"
 # test help show print sevenbit-strings
-gdb_test "help show print sevenbit-strings" "Show printing of 8-bit characters in strings as .nnn."  "help show print sevenbit-strings"
+gdb_test "help show print sevenbit-strings" "Show printing of 8-bit characters in strings as \\\\nnn\." "help show print sevenbit-strings"
 # test help show print union
-gdb_test "help show print union" "Show printing of unions interior to structures."  "help show print union"
+gdb_test "help show print union" "Show printing of unions interior to structures\." "help show print union"
 # test help show print vtbl
-gdb_test "help show print vtbl" "Show printing of C\[+\]+ virtual function tables."  "help show print vtbl"
+gdb_test "help show print vtbl" "Show printing of C\[+\]+ virtual function tables\." "help show print vtbl"
 # test help show prompt
-gdb_test "help show prompt" "Show gdb's prompt"  "help show prompt"
+gdb_test "help show prompt" "Show gdb's prompt" "help show prompt"
 # test help show radix
-gdb_test "help show radix" "Show the default input and output number radices.*\[\r\n\]+Use \'show input-radix\' or \'show output-radix\' to independently show each.*\[\r\n\]+" "help show radix"
+gdb_test "help show radix" "Show the default input and output number radices\.\[\r\n\]+Use \'show input-radix\' or \'show output-radix\' to independently show each\." "help show radix"
 # test help show symbol-reloading
-gdb_test "help show symbol-reloading" "Show dynamic symbol table reloading multiple times in one run." "help show symbol-reloading"
+gdb_test "help show symbol-reloading" "Show dynamic symbol table reloading multiple times in one run\." "help show symbol-reloading"
 # test help show user
-gdb_test "help show user" "Show definitions of user defined commands..*\[\r\n\]+Argument is the name of the user defined command..*\[\r\n\]+With no argument, show definitions of all user defined commands." "help show user"
+gdb_test "help show user" "Show definitions of user defined commands\.\[\r\n\]+Argument is the name of the user defined command\.\[\r\n\]+With no argument, show definitions of all user defined commands\." "help show user"
 # test help show values
-gdb_test "help show values" "Elements of value history around item number IDX .or last ten.."  "help show values"
+gdb_test "help show values" "Elements of value history around item number IDX \\(or last ten\\)\." "help show values"
 # test help show verbose
-gdb_test "help show verbose" "Show verbosity..*"  "help show verbose"
+gdb_test "help show verbose" "Show verbosity\." "help show verbose"
 # test help show version
-gdb_test "help show version" "Show what version of GDB this is."  "help show version"
+gdb_test "help show version" "Show what version of GDB this is\." "help show version"
 # test help show width
-gdb_test "help show width" "Show number of characters gdb thinks are in a line."  "help show width"
+gdb_test "help show width" "Show number of characters gdb thinks are in a line\." "help show width"
 # test help show write
 # This is only supported on targets which use exec.o.
-gdb_test "help show write" "Show writing into executable and core files."  "help show write"
+gdb_test "help show write" "Show writing into executable and core files\." "help show write"
 # test help show
 # FIXME -- Ultrix hangs randomly on this very long output from gdb and
 # continues with its output only if something is sent to gdb.
 # Also, if the system is slow, it may time out because the output is large.
-#gdb_test "help show" "Generic command for showing things about the debugger..*\[\r\n\]+List of show subcommands:.*\[\r\n\]+show listsize -- Show number of source lines gdb will list by default.*\[\r\n\]+show directories -- Current search path for finding source files.*\[\r\n\]+Type \"help show\" followed by show subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help show"
+gdb_test "help show" "Generic command for showing things about the debugger\.\[\r\n\]+List of show subcommands:.*\[\r\n\]+show directories -- Current search path for finding source files.*\[\r\n\]+show listsize -- Show number of source lines gdb will list by default.*\[\r\n\]+Type \"help show\" followed by show subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help show"
 # test help step
-gdb_test "help step" "Step program until it reaches a different source line..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help step #2"
+gdb_test "help step" "Step program until it reaches a different source line\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help step #2"
 # test help stepi "si" abbreviation
-gdb_test "help si" "Step one instruction exactly..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help stepi \"si\" abbreviation"
+gdb_test "help si" "Step one instruction exactly\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help stepi \"si\" abbreviation"
 # test help stepi
-gdb_test "help stepi" "Step one instruction exactly..*\[\r\n\]+Argument N means do this N times .or till program stops for another reason.." "help stepi"
+gdb_test "help stepi" "Step one instruction exactly\.\[\r\n\]+Argument N means do this N times \\(or till program stops for another reason\\)\." "help stepi"
 # test help signal
-gdb_test "help signal" "Continue program giving it signal.*"  "help signal"
+gdb_test "help signal" "Continue program giving it signal.*" "help signal"
 # test help source
 # vxgdb reads .vxgdbinit
-gdb_test "help source" "Read commands from a file named FILE..*\[\r\n\]+Note that the file \"\[^\"\]*\" is read automatically in this way.*\[\r\n\]+when gdb is started." "help source"
+gdb_test "help source" "Read commands from a file named FILE\.\[\r\n\]+Note that the file \"\[^\"\]*\" is read automatically in this way\[\r\n\]+when gdb is started\." "help source"
 # test help stack
-gdb_test "help stack" "Examining the stack..*\[\r\n\]+When the program being debugged stops, gdb selects the innermost frame..*\[\r\n\]+The commands below can be used to select other frames by number or address..*\[\r\n\]+List of commands:.*\[\r\n\]+backtrace -- Print backtrace of all stack frames.*\[\r\n\]+bt -- Print backtrace of all stack frames.*\[\r\n\]+down -- Select and print stack frame called by this one.*\[\r\n\]+frame -- Select and print a stack frame.*\[\r\n\]+return -- Make selected stack frame return to its caller.*\[\r\n\]+select-frame -- Select a stack frame without printing anything.*\[\r\n\]+up -- Select and print stack frame that called this one.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help stack"
+gdb_test "help stack" "Examining the stack\..*\[\r\n\]+When the program being debugged stops, gdb selects the innermost frame\.\[\r\n\]+The commands below can be used to select other frames by number or address\.\[\r\n\]+List of commands:\[\r\n\]+backtrace -- Print backtrace of all stack frames\[\r\n\]+bt -- Print backtrace of all stack frames\[\r\n\]+down -- Select and print stack frame called by this one\[\r\n\]+frame -- Select and print a stack frame\[\r\n\]+return -- Make selected stack frame return to its caller\[\r\n\]+select-frame -- Select a stack frame without printing anything\[\r\n\]+up -- Select and print stack frame that called this one\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help stack"
 # test help status
-gdb_test "help status" "Status inquiries..*\[\r\n\]+List of commands:.*\[\r\n\]+info -- Generic command for showing things about the program being debugged.*\[\r\n\]+show -- Generic command for showing things about the debugger.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help status"
+gdb_test "help status" "Status inquiries\.\[\r\n\]+List of commands:\[\r\n\]+info -- Generic command for showing things about the program being debugged.*\[\r\n\]+show -- Generic command for showing things about the debugger\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help status"
+
 # test help support
 # FIXME -- Ultrix hangs randomly on this very long output from gdb and
 # continues with its output only if something is sent to gdb.
 # Also, if the system is slow, it may time out because the output is large.
-#gdb_test "help support" "Support facilities..*\[\r\n\]+List of commands:.*\[\r\n\]+show confirm -- Show whether to confirm potentially dangerous operations.*\[\r\n\]+show history -- Generic command for showing command history parameters.*\[\r\n\]+down-silently -- Same as the `down' command.*\[\r\n\]+up-silently -- Same as the `up' command.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help support"
+gdb_test "help support" "Support facilities\.\[\r\n\]+List of commands:.*\[\r\n\]+show confirm -- Show whether to confirm potentially dangerous operations.*\[\r\n\]+show history -- Generic command for showing command history parameters.*\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help support"
 # test help symbol-file
-gdb_test "help symbol-file" "Load symbol table from executable file FILE..*\[\r\n\]+The `file' command can also load symbol tables, as well as setting the file.*\[\r\n\]+to execute." "help symbol-file"
+gdb_test "help symbol-file" "Load symbol table from executable file FILE\.\[\r\n\]+The `file' command can also load symbol tables, as well as setting the file\[\r\n\]+to execute\." "help symbol-file"
 # test help target child
-gdb_test "help target child" "Unix child process .started by the \"run\" command..*|Undefined target command: \"child\".  Try \"help target\"." "help target child"
+gdb_test "help target child" "Unix child process \\(started by the \"run\" command\\)\.|Undefined target command: \"child\"\.  Try \"help target\"\." "help target child"
 # test help target procfs
-gdb_test "help target procfs" "Unix /proc child process .started by the \"run\" command.*|Undefined target command: \"procfs\".  Try \"help target\"." "help target procfs (procfs version)"
+gdb_test "help target procfs" "Unix /proc child process \\(started by the \"run\" command\\)\.|Undefined target command: \"procfs\"\.  Try \"help target\"\." "help target procfs (procfs version)"
 # test help target core
-gdb_test "help target core" ".*Use a core file as a target.*Specify the filename of the core file.*|(Undefined target command: \"core\".  Try \"help target\".)" "help target core"
+gdb_test "help target core" "Use a core file as a target\.  Specify the filename of the core file\.|(Undefined target command: \"core\"\.  Try \"help target\"\.)" "help target core"
 # test help target exec
-gdb_test "help target exec" "Use an executable file as a target..*\[\r\n\]+Specify the filename of the executable file." "help target exec"
+gdb_test "help target exec" "Use an executable file as a target\.\[\r\n\]+Specify the filename of the executable file\." "help target exec"
 # test help target remote
-gdb_test "help target remote" "Use a remote computer via a serial line, using a gdb-specific protocol..*\[\r\n\]+Specify the serial device it is connected to.*\[\r\n\]+.e.g. .*" "help target remote"
+gdb_test "help target remote" "Use a remote computer via a serial line, using a gdb-specific protocol\.\[\r\n\]+Specify the serial device it is connected to\[\r\n\]+\\(e.g. .*" "help target remote"
 # test help target
 # the child process target may be "target child" or "target procfs"
-gdb_test "help target" "Connect to a target machine or process..*\[\r\n\]+The first argument is the type or protocol of the target machine..*\[\r\n\]+Remaining arguments are interpreted by the target protocol.  For more.*\[\r\n\]+information on the arguments for a particular protocol, type.*\[\r\n\]+`help target ' followed by the protocol name..*\[\r\n\]+List of target subcommands:.*\[\r\n\]+target exec -- Use an executable file as a target.*\[\r\n\]+Type \"help target\" followed by target subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help target"
+gdb_test "help target" "Connect to a target machine or process\.\[\r\n\]+The first argument is the type or protocol of the target machine\.\[\r\n\]+Remaining arguments are interpreted by the target protocol\.  For more\[\r\n\]+information on the arguments for a particular protocol, type\[\r\n\]+`help target ' followed by the protocol name\.\[\r\n\]+List of target subcommands:.*\[\r\n\]+target exec -- Use an executable file as a target.*\[\r\n\]+Type \"help target\" followed by target subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help target"
 # test help tbreak
-gdb_test "help tbreak" "Set a temporary breakpoint.*"  "help tbreak"
+gdb_test "help tbreak" "Set a temporary breakpoint.*" "help tbreak"
 # test help tty
-gdb_test "help tty" "Set terminal for future runs of program being debugged."  "help tty"
+gdb_test "help tty" "Set terminal for future runs of program being debugged\." "help tty"
 # test help until "u" abbreviation
-gdb_test "help u" "Execute until the program reaches a source line greater than the current.*\[\r\n\]+or a specified line or address or function .same args as break command...*\[\r\n\]+Execution will also stop upon exit from the current stack frame." "help until \"u\" abbreviation"
+gdb_test "help u" "Execute until the program reaches a source line greater than the current\[\r\n\]+or a specified line or address or function \\(same args as break command\\)\.\[\r\n\]+Execution will also stop upon exit from the current stack frame\." "help until \"u\" abbreviation"
 # test help until
-gdb_test "help until" "Execute until the program reaches a source line greater than the current.*\[\r\n\]+or a specified line or address or function .same args as break command...*\[\r\n\]+Execution will also stop upon exit from the current stack frame." "help until"
+gdb_test "help until" "Execute until the program reaches a source line greater than the current\[\r\n\]+or a specified line or address or function \\(same args as break command\\)\.\[\r\n\]+Execution will also stop upon exit from the current stack frame\." "help until"
 # test help undisplay
-gdb_test "help undisplay" "Cancel some expressions to be displayed when program stops..*\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying..*\[\r\n\]+No argument means cancel all automatic-display expressions..*\[\r\n\]+\"delete display\" has the same effect as this command..*\[\r\n\]+Do \"info display\" to see current list of code numbers." "help undisplay"
+gdb_test "help undisplay" "Cancel some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means cancel all automatic-display expressions\.\[\r\n\]+\"delete display\" has the same effect as this command\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help undisplay"
 # test help unset environment
-gdb_test "help unset environment" "Cancel environment variable VAR for the program..*\[\r\n\]+This does not affect the program until the next \"run\" command." "help unset environment"
+gdb_test "help unset environment" "Cancel environment variable VAR for the program\.\[\r\n\]+This does not affect the program until the next \"run\" command\." "help unset environment"
 # test help unset
-gdb_test "help unset" "Complement to certain \"set\" commands.*\[\r\n\]+List of unset subcommands:.*\[\r\n\]+unset environment -- Cancel environment variable VAR for the program.*\[\r\n\]+Type \"help unset\" followed by unset subcommand name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help unset"
+gdb_test "help unset" "Complement to certain \"set\" commands\.\[\r\n\]+List of unset subcommands:\[\r\n\]+unset environment -- Cancel environment variable VAR for the program\[\r\n\]+Type \"help unset\" followed by unset subcommand name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help unset"
 # test help up
-gdb_test "help up" "Select and print stack frame that called this one..*\[\r\n\]+An argument says how many frames up to go." "help up"
+gdb_test "help up" "Select and print stack frame that called this one\.\[\r\n\]+An argument says how many frames up to go\." "help up"
 # test help up-silently
-gdb_test "help up-silently" "Same as the `up' command, but does not print anything..*\[\r\n\]+This is useful in command scripts." "help up-silently"
+gdb_test "help up-silently" "Same as the `up' command, but does not print anything\.\[\r\n\]+This is useful in command scripts\." "help up-silently"
 # test help user-defined
-gdb_test "help user-defined" "User-defined commands..*\[\r\n\]+The commands in this class are those defined by the user..*\[\r\n\]+Use the \"define\" command to define a command..*\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation..*\[\r\n\]+Command name abbreviations are allowed if unambiguous." "help user-defined"
+gdb_test "help user-defined" "User-defined commands\.\[\r\n\]+The commands in this class are those defined by the user\.\[\r\n\]+Use the \"define\" command to define a command\.\[\r\n\]+List of commands:.*\[\r\n\]+Type \"help\" followed by command name for full documentation\.\[\r\n\]+Command name abbreviations are allowed if unambiguous\." "help user-defined"
 # test help watch
-gdb_test "help watch" "Set a watchpoint for an expression..*\[\r\n\]+A watchpoint stops execution of your program whenever the value of.*\[\r\n\]+an expression changes." "help watch"
+gdb_test "help watch" "Set a watchpoint for an expression\.\[\r\n\]+A watchpoint stops execution of your program whenever the value of\[\r\n\]+an expression changes\." "help watch"
 # test help whatis
-gdb_test "help whatis" "Print data type of expression EXP."  "help whatis"
+gdb_test "help whatis" "Print data type of expression EXP\." "help whatis"
 # test help where
-gdb_test "help where" "Print backtrace of all stack frames, or innermost COUNT frames..*\[\r\n\]+With a negative argument, print outermost -COUNT frames..*\[\r\n\]+Use of the 'full' qualifier also prints the values of the local variables." "help where"
+gdb_test "help where" "Print backtrace of all stack frames, or innermost COUNT frames\.\[\r\n\]+With a negative argument, print outermost -COUNT frames\.\[\r\n\]+Use of the 'full' qualifier also prints the values of the local variables\." "help where"
 # test help x
-gdb_test "help x" "Examine memory: x/FMT ADDRESS..*\[\r\n\]+ADDRESS is an expression for the memory address to examine..*\[\r\n\]+FMT is a repeat count followed by a format letter and a size letter..*\[\r\n\]+Defaults for format and size letters are those previously used..*\[\r\n\]+Default count is 1.  Default address is following last thing printed.*\[\r\n\]+with this command or \"print\"." "help x"
+gdb_test "help x" "Examine memory: x/FMT ADDRESS\.\[\r\n\]+ADDRESS is an expression for the memory address to examine\.\[\r\n\]+FMT is a repeat count followed by a format letter and a size letter\..*\[\r\n\]+Defaults for format and size letters are those previously used\.\[\r\n\]+Default count is 1\.  Default address is following last thing printed\[\r\n\]+with this command or \"print\"\." "help x"
 # test help info bogus-gdb-command
-gdb_test "help info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\".  Try \"help info\"."  "help info bogus-gdb-command"
+gdb_test "help info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\"\.  Try \"help info\"\." "help info bogus-gdb-command"
 # test help gotcha
-gdb_test "help gotcha" "Undefined command: \"gotcha\".  Try \"help\"."  "help gotcha"
+gdb_test "help gotcha" "Undefined command: \"gotcha\"\.  Try \"help\"\." "help gotcha"
 # test apropos regex
 gdb_test "apropos \\\(print\[\^ bsiedf\\\".-\]\\\)" "handle -- Specify how to handle a signal"
 # test apropos >1 word string
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index ddd1e36..881e0e6 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -1,4 +1,4 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999
+# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2002
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -93,6 +93,8 @@
     gdb_test "show listsize" "Number of source lines gdb will list by default is 10.*" "show default list size"
     
     # Show the default lines
+    # Note that remote targets that have debugging info for _start available will
+    # list the lines there instead of main, so we skip this test for remote targets.
     # The second case is for optimized code, it is still correct.
     
     if [is_remote target] {
@@ -162,12 +164,10 @@
 proc test_list_include_file {} {
     global gdb_prompt
 
-    # OBSOLETE setup_xfail "a29k-*-udi"
     setup_xfail_format "DWARF 1"
     setup_xfail_format "COFF"
     gdb_test "list list0.h:1" "1\[ \t\]+/\[*\]+ An include file .*10\[ \t\]+bar \\(x\\+\\+\\);" "list line 1 in include file"
 
-    # OBSOLETE setup_xfail "a29k-*-udi"
     setup_xfail_format "DWARF 1"
     setup_xfail_format "COFF"
     gdb_test "list list0.h:100" "Line number 95 out of range; .*list0.h has 3\[67\] lines." "list message for lines past EOF"
@@ -229,7 +229,6 @@
     # gcc appears to generate incorrect debugging information for code
     # in include files, which breaks this test.
     # SunPRO cc is the second case below, it's also correct.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     gdb_test "list main" "(5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;|1\[ \t\]+#include .*10\[ \t\]+x = 0;)" "list function in source file 1"
 
     # Ultrix gdb takes the second case below; it's also correct.
@@ -394,7 +393,6 @@
     # gcc appears to generate incorrect debugging information for code
     # in include files, which breaks this test.
     # SunPRO cc is the second case below, it's also correct.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     send_gdb "list list0.c:main\n"
     gdb_expect {
 	-re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" {
@@ -408,7 +406,6 @@
     }
 
     # The i960 is a second case
-    # OBSOLETE # The a29k-amd-udi is a second case
 
     # Not sure what the point of having this function be unused is.
     # AIX is legitimately removing it.
@@ -432,7 +429,6 @@
     # SunPRO cc is the third case.
     setup_xfail "rs6000-*-*" 1804
     setup_xfail "powerpc-*-*" 1804
-    # OBSOLETE setup_xfail "a29k-*-udi"
     setup_xfail_format "DWARF 1"
     setup_xfail_format "COFF"
     send_gdb "list list0.h:foo\n"
@@ -454,7 +450,6 @@
     }
 
     # Ultrix gdb is the second case.
-    # OBSOLETE # a29k-amd-udi is the third case.
     send_gdb "list list1.c:bar\n"
     gdb_expect {
 	-re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
@@ -471,7 +466,6 @@
     }
 
     # The i960 is a second case
-    # OBSOLETE # The a29k-amd-udi is a second case
 
     # Not sure what the point of having this function be unused is.
     # AIX is legitimately removing it.
diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp
index ff8a1f9..016b0e6 100644
--- a/gdb/testsuite/gdb.base/long_long.exp
+++ b/gdb/testsuite/gdb.base/long_long.exp
@@ -157,6 +157,11 @@
 #   assume the long long represents a floating point double in ARM format
      gdb_test "p/f oct" ".*2.1386676354387559e\\+265.*"
 
+  } elseif [ istarget "xscale*-*-*" ] then {
+
+#   assume the long long represents a floating point double in ARM format
+     gdb_test "p/f oct" ".*2.1386676354387559e\\+265.*"
+
   } else {
 
 #   assume the long long represents a floating point double in little
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 11a14c1..44ae25d 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -415,7 +415,7 @@
 
 send_gdb "maint info breakpoints\n"
 gdb_expect {
-	-re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex in main at.*break.c:75\r\n\[ \t\]+breakpoint already hit 1 time\r\n.*$gdb_prompt $"\
+    -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex\[ \t\]+in main at.*break.c:75\r\n\[ \t\]+breakpoint already hit 1 time\r\n.*$gdb_prompt $"\
 		{ pass "maint info breakpoints" }
 	-re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex in main at.*break.c:75\r\n\[ \t\]+breakpoint already hit 1 time\r\n-1\[ \t\]+shlib events\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex.*breakpoint already hit.*$gdb_prompt $"\
 		{ pass "maint info breakpoints (with shlib events)" }
diff --git a/gdb/testsuite/gdb.base/opaque.exp b/gdb/testsuite/gdb.base/opaque.exp
index 668e1c3..4030b4f 100644
--- a/gdb/testsuite/gdb.base/opaque.exp
+++ b/gdb/testsuite/gdb.base/opaque.exp
@@ -1,4 +1,5 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2002 Free Software
+# Foundation, Inc.
 
 # 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
@@ -85,7 +86,6 @@
 	global gcc_compiled
 
 	setup_xfail "vax-*-*" "i*86-sequent-bsd*"
-	# OBSOLETE setup_xfail "a29k-*-udi"
 	if {!$gcc_compiled} then {
 		setup_xfail "alpha-*-*" "mips-sgi-irix5*"
 	}
diff --git a/gdb/testsuite/gdb.base/overlays.exp b/gdb/testsuite/gdb.base/overlays.exp
index a65adea..9188b27 100644
--- a/gdb/testsuite/gdb.base/overlays.exp
+++ b/gdb/testsuite/gdb.base/overlays.exp
@@ -178,6 +178,42 @@
     timeout			{ fail "(timeout) Automatic unmapping"   }
 }
 
+# Verify that both sec1 and sec2 can be loaded simultaneously.
+proc simultaneous_pair { sec1 sec2 } {
+    global gdb_prompt
+
+    set pairname "$sec1 and $sec2 mapped simultaneously"
+    gdb_test "overlay map $sec1" "" "$pairname: map $sec1"
+    gdb_test "overlay map $sec2" "" "$pairname: map $sec2"
+
+    set seen_sec1 0
+    set seen_sec2 0
+
+    send_gdb "overlay list\n"
+    gdb_expect {
+        -re ".*[string_to_regexp $sec1], " { set seen_sec1 1; exp_continue }
+        -re ".*[string_to_regexp $sec2], " { set seen_sec2 1; exp_continue }
+        -re ".*$gdb_prompt $" {
+            if {$seen_sec1 && $seen_sec2} {
+                pass "$pairname"
+            } else {
+                fail "$pairname"
+            }
+        }
+        timeout { fail "(timeout) $pairname" }
+    }
+}
+
+simultaneous_pair .ovly0 .ovly2
+simultaneous_pair .ovly0 .ovly3
+simultaneous_pair .ovly1 .ovly2
+simultaneous_pair .ovly1 .ovly3
+
+simultaneous_pair .data00 .data02
+simultaneous_pair .data00 .data03
+simultaneous_pair .data01 .data02
+simultaneous_pair .data01 .data03
+
 # test automatic mode
 
 gdb_test "overlay auto" ""
diff --git a/gdb/testsuite/gdb.base/ovlymgr.c b/gdb/testsuite/gdb.base/ovlymgr.c
index 0b04c54..f4958ed 100644
--- a/gdb/testsuite/gdb.base/ovlymgr.c
+++ b/gdb/testsuite/gdb.base/ovlymgr.c
@@ -30,6 +30,15 @@
 #endif
 }
 
+/* _ovly_debug_event:
+ * Debuggers may set a breakpoint here, to be notified 
+ * when the overlay table has been modified.
+ */
+static void
+_ovly_debug_event (void)
+{
+}
+
 /* OverlayLoad:
  * Copy the overlay into its runtime region,
  * and mark the overlay as "mapped".
@@ -57,7 +66,7 @@
 	     _ovly_table[ovlyno][SIZE]);
 
   FlushCache ();
-
+  _ovly_debug_event ();
   return TRUE;
 }
 
@@ -80,6 +89,7 @@
 	     _ovly_table[ovlyno][VMA],
 	     _ovly_table[ovlyno][SIZE]);
 
+  _ovly_debug_event ();
   return TRUE;
 }
 
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 279816a..6c4213e 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -1,5 +1,5 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000
-# Free Software Foundation, Inc.
+# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002 Free
+# Software Foundation, Inc.
 
 # 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
@@ -619,25 +619,16 @@
     # (Test may involve inferior malloc() calls).
     set timeout 60;
 
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p \"a string\""		" = \"a string\""
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\0 null\""
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p \"abcd\"\[2\]"	" = 99 'c'"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p sizeof (\"abcdef\")"	" = 7"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "ptype \"foo\""		" = char \\\[4\\\]"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p *\"foo\""		" = 102 'f'"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "ptype *\"foo\""		" = char"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p &*\"foo\""		" = \"foo\""
     setup_xfail "*-*-*"
     gdb_test "ptype &*\"foo\""	"type = char \\*"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "p (char *)\"foo\""	" = \"foo\""
 }
 
@@ -653,17 +644,11 @@
     # (Test may involve inferior malloc() calls).
     set timeout 60;
 
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "print {'a','b','c'}"	" = \"abc\""
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test_escape_braces "print {0,1,2}"    " = {0, 1, 2}"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test_escape_braces "print {(long)0,(long)1,(long)2}"  " = {0, 1, 2}"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test_escape_braces "print {{0,1,2},{3,4,5}}"  " = {{0, 1, 2}, {3, 4, 5}}"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "print {4,5,6}\[2\]"	" = 6"
-    # OBSOLETE setup_xfail "a29k-*-udi" 2416
     gdb_test "print *&{4,5,6}\[1\]"	" = 5"
 }
 
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index 2851e89..8ef738e 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -1,5 +1,5 @@
-#   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2000
-#   Free Software Foundation, Inc.
+# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999,
+# 2000, 2002 Free Software Foundation, Inc.
 
 # 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
@@ -174,7 +174,6 @@
 # merged into whatis.exp, or else maintenance will be a royal pain -kingdon
 #setup_xfail "i960-*-*" 1821
 #setup_xfail "mips-idt-*" "mips-sgi-*"
-# OBSOLETE #setup_xfail "a29k-*-*"
 #send "ptype v_char\n"
 #gdb_expect {
 #    -re "type = char.*$gdb_prompt $"	{ pass "ptype char" }
@@ -184,7 +183,6 @@
 #
 #
 #setup_xfail "mips-*-*"
-# OBSOLETE #setup_xfail "a29k-*-*"
 #send "ptype v_signed_char\n"
 #gdb_expect {
 #    -re "type = signed char.*$gdb_prompt $"	{ pass "ptype signed char" }
@@ -281,7 +279,6 @@
 #
 #setup_xfail "i960-*-*" 1821
 #setup_xfail "mips-idt-*" "mips-sgi-*"
-# OBSOLETE #setup_xfail "a29k-*-*"
 #send "ptype v_char_array\n"
 #gdb_expect {
 #    -re "type = char .2..*$gdb_prompt $"	{ pass "ptype char array" }
@@ -291,7 +288,6 @@
 #
 #
 #setup_xfail "mips-*-*"
-# OBSOLETE #setup_xfail "a29k-*-*"
 #send "ptype v_signed_char_array\n"
 #gdb_expect {
 #    -re "type = (|signed )char .2..*$gdb_prompt $"	{ pass "ptype signed char array" }
@@ -386,7 +382,6 @@
 ##
 #setup_xfail "i960-*-*" 1821
 #setup_xfail "mips-idt-*" "mips-sgi-*"
-# OBSOLETE #setup_xfail "a29k-*-*"
 #send "ptype v_char_pointer\n"
 #gdb_expect {
 #    -re "type = char \*.*$gdb_prompt $"	{ pass "ptype char pointer" }
@@ -396,7 +391,6 @@
 #
 #
 #setup_xfail "mips-*-*"
-# OBSOLETE #setup_xfail "a29k-*-*"
 #send "ptype v_signed_char_pointer\n"
 #gdb_expect {
 #    -re "type = (|signed )char \*.*$gdb_prompt $"
diff --git a/gdb/testsuite/gdb.base/relocate.c b/gdb/testsuite/gdb.base/relocate.c
new file mode 100644
index 0000000..d202392
--- /dev/null
+++ b/gdb/testsuite/gdb.base/relocate.c
@@ -0,0 +1,17 @@
+static int static_foo = 1;
+static int static_bar = 2;
+
+int global_foo = 3;
+int global_bar = 4;
+
+int
+function_foo ()
+{
+  return 5;
+}
+
+int
+function_bar ()
+{
+  return 6;
+}
diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp
new file mode 100644
index 0000000..c4e25de
--- /dev/null
+++ b/gdb/testsuite/gdb.base/relocate.exp
@@ -0,0 +1,108 @@
+# Copyright 2002 Free Software Foundation, Inc.
+
+# 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.  */
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# relocate.exp -- Expect script to test loading symbols from unrelocated
+#		  object files.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set testfile relocate
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}.o
+
+remote_exec build "rm -f ${binfile}"
+if { [gdb_compile "${srcfile}" "${binfile}" object {debug}] != "" } {
+     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+proc get_var_address { var } {
+  global gdb_prompt hex
+
+  send_gdb "print &${var}\n"
+  # Match output like:
+  # $1 = (int *) 0x0
+  # $5 = (int (*)()) 0
+  # $6 = (int (*)()) 0x24 <function_bar>
+  gdb_expect {
+    -re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
+	{
+	  pass "get address of ${var}"
+	  if { $expect_out(1,string) == "0" } {
+	    return "0x0"
+	  } else {
+	    return $expect_out(1,string)
+	  }
+	}
+    -re "${gdb_prompt} $"
+	{ fail "get address of ${var} (unknown output)" }
+    timeout
+	{ fail "get address of ${var} (timeout)" }
+  }
+  return ""
+}
+
+
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the object file.
+gdb_test "add-symbol-file ${binfile} 0" \
+	"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\." \
+	"add-symbol-file ${testfile}.o 0" \
+	"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x0\[\r\n\]+\\(y or n\\) " \
+	"y"
+
+# Print the addresses of static variables.
+set static_foo_addr [get_var_address static_foo]
+set static_bar_addr [get_var_address static_bar]
+
+# Make sure they have different addresses.
+if { "${static_foo_addr}" == "${static_bar_addr}" } {
+  fail "static variables have different addresses"
+} else {
+  pass "static variables have different addresses"
+}
+
+# Print the addresses of global variables.
+set global_foo_addr [get_var_address global_foo]
+set global_bar_addr [get_var_address global_bar]
+
+# Make sure they have different addresses.
+if { "${global_foo_addr}" == "${global_bar_addr}" } {
+  fail "global variables have different addresses"
+} else {
+  pass "global variables have different addresses"
+}
+
+# Print the addresses of functions.
+set function_foo_addr [get_var_address function_foo]
+set function_bar_addr [get_var_address function_bar]
+
+# Make sure they have different addresses.
+if { "${function_foo_addr}" == "${function_bar_addr}" } {
+  fail "functions have different addresses"
+} else {
+  pass "functions have different addresses"
+}
+
+return 0
diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp
index 1765a44..db2c7ea 100644
--- a/gdb/testsuite/gdb.base/scope.exp
+++ b/gdb/testsuite/gdb.base/scope.exp
@@ -1,5 +1,5 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-# Free Software Foundation, Inc.
+# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002 Free
+# Software Foundation, Inc.
 
 # 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
@@ -515,7 +515,6 @@
 
     # This test will only fail if the file was compiled by gcc, but
     # there's no way to check that.
-    # OBSOLETE setup_xfail "a29k-*-udi" 2423
     if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
 	"continue to marker4 in scope.exp"] then { gdb_suppress_tests }
     if [gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp"] {
diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp
index d5336f4..47919be 100644
--- a/gdb/testsuite/gdb.base/shlib-call.exp
+++ b/gdb/testsuite/gdb.base/shlib-call.exp
@@ -70,7 +70,12 @@
 	set additional_flags ""
     }
 } else {
-    set additional_flags "additional_flags=-fpic"
+    if { ([istarget "powerpc*-*-aix*"]
+       || [istarget "rs6000*-*-aix*"]) } {
+	set additional_flags ""
+    } else {
+	set additional_flags "additional_flags=-fpic"
+    }
 }
 
 if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} {
@@ -93,7 +98,15 @@
 	gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
     }
 }
-if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}1.sl ${objdir}/${subdir}/${libfile}2.sl" "${binfile}" executable {debug}] != ""} {
+
+if { ($gcc_compiled 
+      &&  ([istarget "powerpc*-*-aix*"]
+	|| [istarget "rs6000*-*-aix*"] )) } {
+    set additional_flags "additional_flags=-L${objdir}/${subdir}"
+} else {
+    set additional_flags ""
+}
+if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}1.sl ${objdir}/${subdir}/${libfile}2.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp
index 48af23c..9a21136 100644
--- a/gdb/testsuite/gdb.base/step-test.exp
+++ b/gdb/testsuite/gdb.base/step-test.exp
@@ -1,4 +1,4 @@
-# Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
 
 # 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
@@ -204,6 +204,12 @@
 # argument.  Opinion is bitterly divided about whether this is the
 # right behavior for GDB or not, but we'll catch it here, so folks
 # won't forget about it.
+# Update 4/4/2002 - Regardless of which opinion you have, you would
+# probably have to agree that gdb is currently behaving as designed,
+# in the absence of additional code to not stop in functions used
+# internally by the compiler.  Since the testsuite should be checking
+# for conformance to the design, the correct behavior is to accept the
+# cases where gdb stops in memcpy/bcopy.
 
 gdb_test \
   "break [gdb_get_line_number "step-test.exp: large struct by value"]" \
@@ -212,9 +218,23 @@
 gdb_test "continue" \
          ".*Breakpoint ${decimal},.*large_struct_by_value.*" \
 	 "run to pass large struct"
-gdb_test "step" \
-         ".*step-test.exp: arrive here 1.*" \
-         "large struct by value"
+send_gdb "step\n"
+gdb_expect {
+    -re ".*step-test.exp: arrive here 1.*$gdb_prompt $" {
+	pass "large struct by value"
+    }
+    -re ".*(memcpy|bcopy).*$gdb_prompt $" {
+	send_gdb "finish\n" ; gdb_expect -re "$gdb_prompt $"
+	send_gdb "step\n"
+	exp_continue
+    }
+    -re ".*$gdb_prompt $" {
+	fail "large struct by value"
+    }
+    timeout {
+	fail "large struct by value (timeout)"
+    }
+}
 
 gdb_continue_to_end "step-test.exp"
 
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 083d807..e150d55 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -383,6 +383,7 @@
 	# because we are out of the dummy by the first time the inferior
 	# stops.
 	clear_xfail "arm*-*-*"
+	clear_xfail "xscale*-*-*"
 	clear_xfail "d10v*-*-*"
 	clear_xfail "m68*-*-*"
 	clear_xfail "i*86*-*-*"
diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp
index c2d7608..79c48e4 100644
--- a/gdb/testsuite/gdb.base/whatis.exp
+++ b/gdb/testsuite/gdb.base/whatis.exp
@@ -1,5 +1,5 @@
-#   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999
-#   Free Software Foundation, Inc.
+# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002
+# Free Software Foundation, Inc.
 
 # 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
@@ -85,7 +85,6 @@
 } else {
     set signed_char "signed char"
 }
-# OBSOLETE setup_xfail "a29k-*-*"
 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
 gdb_test "whatis v_signed_char" \
     "type = $signed_char" \
diff --git a/gdb/testsuite/gdb.c++/classes.exp b/gdb/testsuite/gdb.c++/classes.exp
index 87d533b..dbdea5d 100644
--- a/gdb/testsuite/gdb.c++/classes.exp
+++ b/gdb/testsuite/gdb.c++/classes.exp
@@ -907,7 +907,7 @@
 	    -re "= 82.*$gdb_prompt $" {
 		pass "calling method for small class"
 	    }
-	    -re "Address requested for identifier .v. which is in a register.*$gdb_prompt $" {
+	    -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" {
 		setup_xfail "*-*-*" 2972
 		fail "calling method for small class"
 	    }
diff --git a/gdb/testsuite/gdb.c++/cplusfuncs.exp b/gdb/testsuite/gdb.c++/cplusfuncs.exp
index 61d26ae..9057cc2 100644
--- a/gdb/testsuite/gdb.c++/cplusfuncs.exp
+++ b/gdb/testsuite/gdb.c++/cplusfuncs.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 1992, 1997, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1992, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
 
 # 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
@@ -320,13 +320,6 @@
     global dm_type_void
     global dm_type_void_star
 
-    # OBSOLETE # # These tests don't work for COFF targets; don't even try them
-    # OBSOLETE # if [istarget "a29k-*-udi"] then {
-    # OBSOLETE #     setup_xfail "a29k-*-udi"
-    # OBSOLETE #     fail "skipping operator tests"
-    # OBSOLETE #     return
-    # OBSOLETE #  }
-
     # operator* requires quoting so that GDB does not treat it as a regexp.
     info_func "operator\\*("	"void foo::operator*($dm_type_foo_ref);"
     info_func "operator%("	"void foo::operator%($dm_type_foo_ref);"
diff --git a/gdb/testsuite/gdb.c++/hang.H b/gdb/testsuite/gdb.c++/hang.H
new file mode 100644
index 0000000..26fec87
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/hang.H
@@ -0,0 +1,12 @@
+struct A
+{
+  struct B *b_ptr_in_a;
+};
+
+struct C
+{
+  struct B
+  {
+    int member_of_B_in_C;
+  };
+};
diff --git a/gdb/testsuite/gdb.c++/hang.exp b/gdb/testsuite/gdb.c++/hang.exp
new file mode 100644
index 0000000..4c117a1
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/hang.exp
@@ -0,0 +1,128 @@
+#   Copyright (C) 2002 Free Software Foundation, Inc.
+
+# 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.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+if { [skip_cplus_tests] } { continue }
+
+set testfile hang
+set binfile ${objdir}/${subdir}/${testfile}
+
+foreach file {hang1 hang2 hang3} {
+    if {[gdb_compile "${srcdir}/${subdir}/${file}.C" "${file}.o" object {c++ debug}] != ""} {
+        gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    }
+}
+
+if {[gdb_compile "hang1.o hang2.o hang3.o" ${binfile} executable {c++ debug}] != "" } {
+     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+
+# As of May 1, 2002, GDB hangs trying to read the debug info for the
+# `hang2.o' compilation unit from the executable `hang', when compiled
+# by g++ 2.96 with STABS debugging info.  Here's what's going on, as
+# best as I can tell.
+#
+# The definition of `struct A' in `hang.H' refers to `struct B' as an
+# incomplete type.  The stabs declare type number (1,3) to be a cross-
+# reference type, `xsB:'.
+#
+# The definition of `struct C' contains a nested definition for
+# `struct B' --- or more properly, `struct C::B'.  However, the stabs
+# fail to qualify the structure tag: it just looks like a definition
+# for `struct B'.  I think this is a compiler bug, but perhaps GCC
+# doesn't emit qualified names for a reason.
+#
+# `hang.H' gets #included by both `hang1.C' and `hang2.C'.  So the
+# stabs for `struct A', the incomplete `struct B', and `struct C'
+# appear in both hang1.o's and hang2.o's stabs.
+#
+# When those two files are linked together, since hang2.o appears
+# later in the command line, its #inclusion of `hang.H' gets replaced
+# with an N_EXCL stab, referring back to hang1.o's stabs for the
+# header file.
+#
+# When GDB builds psymtabs for the executable hang, it notes that
+# hang2.o's stabs contain an N_EXCL referring to a header that appears
+# in full in hang1.o's stabs.  So hang2.o's psymtab lists a dependency
+# on hang1.o's psymtab.
+#
+# When the user types the command `print var_in_b', GDB scans the
+# psymtabs for a symbol by that name, and decides to read full symbols
+# for `hang2.o'.
+#
+# Since `hang2.o''s psymtab lists `hang1.o' as a dependency, GDB first
+# reads `hang1.o''s symbols.  When GDB sees `(1,3)=xsB:', it creates a
+# type object for `struct B', sets its TYPE_FLAG_STUB flag, and
+# records it as type number `(1,3)'.
+#
+# When GDB finds the definition of `struct C::B', since the stabs
+# don't indicate that the type is nested within C, it treats it as
+# a definition of `struct B'.
+#
+# When GDB is finished reading `hang1.o''s symbols, it calls
+# `cleanup_undefined_types'.  This function mistakes the definition of
+# `struct C::B' for a definition for `struct B', and overwrites the
+# incomplete type object for the real `struct B', using `memcpy'.  Now
+# stabs type number `(1,3)' refers to this (incorrect) complete type.
+# Furthermore, the `memcpy' simply copies the original's `cv_type'
+# field to the target, giving the target a corrupt `cv_type' ring: the
+# chain does not point back to the target type.
+#
+# Having satisfied `hang2.o''s psymtab's dependencies, GDB begins to
+# read `hang2.o''s symbols.  These contain the true definition for
+# `struct B', which refers to type number `(1,3)' as the type it's
+# defining.  GDB looks up type `(1,3)', and finds the (incorrect)
+# complete type established by the call to `cleanup_undefined_types'
+# above.  However, it doesn't notice that the type is already defined,
+# and passes it to `read_struct_type', which then writes the new
+# definition's size, field list, etc. into the type object which
+# already has those fields initialized.  Adding insult to injury,
+# `read_struct_type' then calls `finish_cv_type'; since the `memcpy'
+# in `cleanup_undefined_types' corrupted the target type's `cv_type'
+# ring, `finish_cv_type' enters an infinite loop.
+
+# This checks that GDB recognizes when a structure is about to be
+# overwritten, and refuses, with a complaint.
+gdb_test "print var_in_b" " = 1729" "doesn't overwrite struct type"
+
+# This checks that cleanup_undefined_types doesn't create corrupt
+# cv_type chains.  Note that var_in_hang3 does need to be declared in
+# a separate compilation unit, whose psymtab depends on hang1.o's
+# psymtab.  Otherwise, GDB won't call cleanup_undefined_types (as it
+# finishes hang1.o's symbols) before it calls make_cv_type (while
+# reading hang3.o's symbols).
+#
+# The bug only happens when you compile with -gstabs+; Otherwise, GCC
+# won't include the `const' qualifier on `const_B_ptr' in `hang3.o''s
+# STABS, so GDB won't try to create a const variant of the smashed
+# struct type, and get caught by the corrupted cv_type chain.
+gdb_test "print var_in_hang3" " = 42" "doesn't corrupt cv_type chain"
diff --git a/gdb/testsuite/gdb.c++/hang1.C b/gdb/testsuite/gdb.c++/hang1.C
new file mode 100644
index 0000000..4b04d77
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/hang1.C
@@ -0,0 +1,3 @@
+#include "hang.H"
+
+int main (int argc, char **argv) { return 0; }
diff --git a/gdb/testsuite/gdb.c++/hang2.C b/gdb/testsuite/gdb.c++/hang2.C
new file mode 100644
index 0000000..59732f8
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/hang2.C
@@ -0,0 +1,8 @@
+#include "hang.H"
+
+struct B
+{
+  int member_of_B;
+};
+
+int var_in_b = 1729;
diff --git a/gdb/testsuite/gdb.c++/hang3.C b/gdb/testsuite/gdb.c++/hang3.C
new file mode 100644
index 0000000..92c82fa
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/hang3.C
@@ -0,0 +1,4 @@
+#include "hang.H"
+
+const struct B *const_B_ptr;
+int var_in_hang3 = 42;
diff --git a/gdb/testsuite/gdb.c++/local.cc b/gdb/testsuite/gdb.c++/local.cc
index c811deb..5bfc44a 100644
--- a/gdb/testsuite/gdb.c++/local.cc
+++ b/gdb/testsuite/gdb.c++/local.cc
@@ -56,12 +56,6 @@
 
    il.ilc = 'b';
    il.ip = &c;
+   marker1();
  }
- marker1();
 }
-
-  
-
-  
-  
-    
diff --git a/gdb/testsuite/gdb.c++/local.exp b/gdb/testsuite/gdb.c++/local.exp
index a93598f..091d643 100644
--- a/gdb/testsuite/gdb.c++/local.exp
+++ b/gdb/testsuite/gdb.c++/local.exp
@@ -1,4 +1,4 @@
-# Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 # 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
@@ -19,6 +19,7 @@
 
 # tests for local variables
 # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
+# Cleaned by Michael Chastain <mec@shout.net> 2002-04-08
 
 
 # This file is part of the gdb testsuite
@@ -68,28 +69,46 @@
 
 gdb_test "up" ".*main.*" "up from marker1"
 
-
-# srikanth, These tests have always been run only with aCC. Now in
-# the new scheme of things, we run it twice, once with aCC, and once
-# with g++. Flag these tests as expected failures when run with g++.
-# as these are failing now and were never known to pass with g++.
-global gcc_compiled
-if {$gcc_compiled} then  {
-setup_xfail "*-*-*"
-}
-
 # Local classes in g++ get names like "main.1::InnerLocal", just like local
 # static variables.  Some targets use "___" instead of ".".
+
+# ---
+# Pattern 1:
+# PASS
+#   dwarf-2
+#     gcc 2.95.3
+#
+# Pattern 2:
+# FAIL
+# This has a duplicate "char loc_foo" line.  This is a bug.
+# Historically this has been an XFAIL.
+#   dwarf-2
+#     gcc 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# Pattern 3:
+# PASS
+#   stabs+
+#     gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# Pattern 4:
+# This an old pattern from the hppa aCC version of this file.
+# I left it alone.
+#
+# chastain 2002-04-08
+
 set sep "(\[.\]|___)\[0-9\]"
 
 send_gdb "ptype Local\n"
 gdb_expect {
-    -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*.char loc_foo\\(char\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:10\\).*$gdb_prompt $" { pass "ptype Local" }
-    -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*.char loc_foo\\(char\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype Local (incorrect line number?)" }
-    -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*Local & operator=\\((foobar__Fi${sep}::|)Local const &\\);\r\n\[\t \]*Local\\((foobar__Fi${sep}::|)Local const &\\);\r\n\[\t \]*Local\\(void\\);\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\}*.*$gdb_prompt $" { pass "ptype Local" }
-    -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { pass "ptype Local (aCC)" }
-    -re ".*$gdb_prompt $"   {  fail "ptype Local" }
-    timeout             { fail "(timeout) ptype Local" }
+  -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
+  -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
+    # setup_kfail "gdb/483"
+    fail "ptype Local (gdb/483)"
+  }
+  -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
+  -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" }
+  -re ".*$gdb_prompt $"   {  fail "ptype Local" }
+  timeout             { fail "(timeout) ptype Local" }
 }
 
 # DTS CLLbs14316 and CLLbs17058
@@ -99,49 +118,82 @@
 #   There is a number at the end of InnerLocal4 which should not be there,
 #       DTS CLLbs14316
 #   The line number for the class 
-setup_xfail "hppa*-*-*" CLLbs14316
+# setup_xfail "hppa*-*-*" CLLbs14316
+
+# ---
+# Pattern 1:
+# PASS
+#   dwarf-2
+#     2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# Pattern 2:
+# PASS
+#   stabs+
+#     2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# Pattern 3:
+# Old hppa pattern.
+#
+# Pattern 4:
+# Old hppa pattern.
+#
+# chastain 2002-04-08
+
 send_gdb "ptype InnerLocal\n"
 gdb_expect {
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal" }
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal" }
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal (incorrect line number?" }
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal (incorrect line number?" }
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal HP aCC" }
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*NestedInnerLocal nest1;\r\n\r\n\[\t \]*InnerLocal & operator=\\((main${sep}::|)InnerLocal const &\\);\r\n\[\t \]*InnerLocal\\((main${sep}::|)InnerLocal const &\\);\r\n\[\t \]*InnerLocal\\(void\\);\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\*\}\r\n*.*$gdb_prompt $" { pass "ptype InnerLocal" }
-    -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" { pass "ptype InnerLocal (aCC)" }
-    -re ".*$gdb_prompt $"   {  fail "ptype InnerLocal" }
-    timeout             { fail "(timeout) ptype InnerLocal" }
+  -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*NestedInnerLocal nest1;\[\r\n\t \]*int il_foo\\((unsigned char const|const unsigned char) *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal" }
+  -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*NestedInnerLocal nest1;\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal" }
+  -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" }
+  -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" }
+  -re ".*$gdb_prompt $"   {  fail "ptype InnerLocal" }
+  timeout             { fail "(timeout) ptype InnerLocal" }
 }
 
+#---
+# Pattern 1:
+# PASS
+#   dwarf-2
+#     gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# Pattern 2:
+# PASS
+#   stabs+
+#     gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# chastain 2002-04-08
+
 send_gdb "ptype NestedInnerLocal\n"
 gdb_expect {
-    -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:44\\).*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
-    -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype NestedInnerLocal (incorrect line number?)" }
-    -re "type = class NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*NestedInnerLocal & operator=\\((main${sep}::InnerLocal::|)NestedInnerLocal const &\\);\r\n\[\t \]*NestedInnerLocal\\((main${sep}::InnerLocal::|)NestedInnerLocal const &\\);\r\n\[\t \]*NestedInnerLocal\\(void\\);\r\n\[\t \]*int nil_foo\\(int\\);\r\n\}\r\n*.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
-    -re "No symbol.*in current context.*$gdb_prompt $" { pass "ptype NestedInnerLocal (known aCC limitation)" }
-    -re ".*$gdb_prompt $"   {  fail "ptype NestedInnerLocal" }
-    timeout             { fail "(timeout) ptype NestedInnerLocal" }
-}     
-
-# srikanth, These tests have always been run only with aCC. Now in
-# the new scheme of things, we run it twice, once with aCC, and once
-# with g++. Flag these tests as expected failures when run with g++.
-# as these are failing now and were never known to pass with g++.
-global gcc_compiled
-if {$gcc_compiled} then  {
-setup_xfail "*-*-*"
+  -re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
+  -re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
+  -re ".*$gdb_prompt $"   {  fail "ptype NestedInnerLocal" }
+  timeout             { fail "(timeout) ptype NestedInnerLocal" }
 }
 
 # gdb incorrectly interprets the NestedInnerLocal in
 # InnerLocal::NestedInnerLocal as field name instead of a type name;
 # See CLLbs14784.
-setup_xfail *-*-* CLLbs14784
+
+#---
+# Pattern 3:
+# FAIL
+# The comment above, about CLLbs14784, is still correct.
+#   dwarf-2
+#     gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#   stabs+
+#     gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+#
+# chastain 2002-04-08
+
 send_gdb "ptype InnerLocal::NestedInnerLocal\n"
 gdb_expect {
-    -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:44\\).*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
-    -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal (incorrect line number?)" }
-    -re ".*$gdb_prompt $"   {  fail "ptype InnerLocal::NestedInnerLocal" }
-    timeout             { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
+  -re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
+  -re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
+  -re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
+    # setup_kfail "gdb/482"
+    fail "ptype InnerLocal::NestedInnerLocal (gdb/482)"
+  }
+  -re "No symbol .*NestedInnerLocal.* in current context.*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal (bogus symbol lookup)" }
+  -re ".*$gdb_prompt $"   {  fail "ptype InnerLocal::NestedInnerLocal" }
+  timeout             { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
 }
-
-
diff --git a/gdb/testsuite/gdb.c++/method.exp b/gdb/testsuite/gdb.c++/method.exp
index 99369a9..8deafa8 100644
--- a/gdb/testsuite/gdb.c++/method.exp
+++ b/gdb/testsuite/gdb.c++/method.exp
@@ -70,157 +70,95 @@
     continue
 }
 
-send_gdb "break A::foo\n"
-gdb_expect {
-   -re "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 38*\\.\r\n$gdb_prompt $" {
-       pass "set breakpoint on A::foo"
-   }
-   -re ".*$gdb_prompt $" { fail "set breakpoint on A::foo" }
-   timeout { fail "(timeout) set breakpoint on A::foo" }
-}
+gdb_test "break A::foo" \
+  "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 38\\."
 
-send_gdb "continue\n"
-gdb_expect {
-   -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::foo(\\(int\\)|) \\(this=$hex, arg=13\\) at .*method\\.cc:38\r\n38\[\t \]*x \\+= arg;\r\n$gdb_prompt $" {
-      pass "continued and got breakpoint in A::foo"
-   }
-   -re ".*$gdb_prompt $" { fail "continuing and breaking in A::foo" }
-   timeout { fail "(timeout) continue" }
-}
+gdb_test "continue" \
+  "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::foo(\\(int\\)|) \\(this=$hex, arg=13\\) at .*method\\.cc:38\r\n38\[\t \]*x \\+= arg;" \
+  "continue to A::foo"
 
 # Check ability to access this-relative stuff.
 
-send_gdb "print x\n"
-gdb_expect {
-   -re "\\$\[0-9\]* = 20\r\n$gdb_prompt $" {
-       pass "access this-relative x (in foo)"
-   }
-   -re ".*$gdb_prompt $" { fail "print x (in foo)" } 
-   timeout { fail "(timeout) print x (in foo)" }
-}
+gdb_test "print x" \
+   "\\$\[0-9\]* = 20" \
+   "print x in A::foo"
 
 # Check access to this pointer       
 
-send_gdb "print this\n"
-gdb_expect {
-   -re "\\$\[0-9\]* = \\(A \\*\\) $hex\r\n$gdb_prompt $" {
-       pass "print this (in foo)"
-   }
-   -re ".*$gdb_prompt $" { fail "print this (in foo)" }
-   timeout { fail "(timeout) print this (in foo)" }
-}
+gdb_test "print this" \
+   "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex" \
+   "print this in A::foo"
 
 # Now do everything over again for A::bar, because sometimes processing one method
 # (the first one) is fine, but the second one's debug info gets munged beyond recognition.
 
-send_gdb "break A::bar\n"
-gdb_expect {
-   -re "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 44\\.\r\n$gdb_prompt $" {
-       pass "set breakpoint on A::bar"
-   }
-   -re ".*$gdb_prompt $" { fail "set breakpoint on A::bar" }
-   timeout { fail "(timeout) set breakpoint on A::bar" }
-}
+gdb_test "break A::bar" \
+  "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 44\\."
 
-send_gdb "continue\n"
-gdb_expect {
-   -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(\\(int\\) const|) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;\r\n$gdb_prompt $" {
-      pass "continued and got breakpoint in A::bar"
-   }
-   -re ".*$gdb_prompt $" { fail "continuing and breaking in A::bar" }
-   timeout { fail "(timeout) continue" }
-}
+gdb_test "continue" \
+  "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(\\(int\\) const|) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;" \
+  "continue to A::bar"
 
 # Check ability to access this-relative stuff.
 
-send_gdb "print x\n"
-gdb_expect {
-   -re "\\$\[0-9\]* = 33\r\n$gdb_prompt $" {
-       pass "access this-relative x (in bar)"
-   }
-   -re ".*$gdb_prompt $" { fail "print x (in bar)" }
-   timeout { fail "(timeout) print x (in bar)" }
-}
+gdb_test "print x" \
+  "\\$\[0-9\]* = 33" \
+  "print x in A::bar"
 
 # Check access to this pointer       
 
+get_debug_format
+
 send_gdb "print this\n"
 gdb_expect {
-   -re "\\$\[0-9\]* = \\(const class A \\*\\) $hex\r\n$gdb_prompt $" {
-     global gcc_compiled
-     if {$gcc_compiled} {
-       xfail "print this (in bar)"
-     } else {
-       pass "print this (in bar)"
-     }
-   }
-   -re "\\$\[0-9\]* = \\(A \\*\\) $hex\r\n$gdb_prompt $" {
-     global gcc_compiled
-     if {$gcc_compiled} {
-       pass "print this (in bar)"
-     } else {
-       xfail "print this (in bar)"
-     }
-   }
-   -re ".*$gdb_prompt $" { fail "print this (in bar)" }
-   timeout { fail "(timeout) print this (in bar)" }
+  -re "\\$\[0-9\]* = \\(const (class |)A *\\* *(const|)\\) $hex\r\n$gdb_prompt $" {
+    pass "print this in A::bar"
+  }
+  -re "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex\r\n$gdb_prompt $" {
+    # gcc versions up to 3.0.4 with -gstabs+ do not emit "const" indicators,
+    # so the output is "A *".  It should be "const A *" or "const A * const".
+    setup_xfail_format "stabs"
+    fail "print this in A::bar (missing const)"
+  }
+  -re "\\$\[0-9\]* = \\(const (class |)\{\\.\\.\\.\} *\\* *(const|)\\) $hex\r\n$gdb_prompt $" {
+    # gcc versions gcc-3_1-branch%20020404 and HEAD%20020404 with -gstabs+
+    # produce good stabs, but gdb prints "const class {...} *" const.
+    # This is PR gdb/277.
+    # setup_kfail "gdb/277"
+    fail "print this in A::bar (gdb/277)"
+  }
+  -re ".*$gdb_prompt $" { fail "print this in A::bar" }
+  timeout { fail "(timeout) print this in A::bar" }
 }
 
 # Check again with funk::getFunky (this is the original test case
 # for CHFts23426); sometimes having a constructor with no arguments
 # will nuke the debug info read in for other methods in the class.
 
-send_gdb "break funk::getFunky\n"
-gdb_expect {
-   -re "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 20\\.\r\n$gdb_prompt $" {
-       pass "set breakpoint on funk::getFunky"
-   }
-   -re ".*$gdb_prompt $" { fail "set breakpoint on funk::getfunky" }
-   timeout { fail "(timeout) set breakpoint on funk::getfunky" }
-}
+gdb_test "break 21" \
+  "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 21\\."
 
-send_gdb "continue\n"
-gdb_expect {
-   -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, funk::getFunky(\\(int, int\\)|) \\(this=$hex, a=1, b=2\\) at .*method\\.cc:20\r\n20\[\t \]*res = a \\+ b - data_;\r\n$gdb_prompt $" {
-      pass "continued and got breakpoint in funk::getfunky"
-   }
-   -re ".*$gdb_prompt $" { fail "continuing and breaking in funk::getfunky" }
-   timeout { fail "(timeout) continue" }
-}
+gdb_test "continue" \
+  "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, funk::getFunky(\\(int, int\\)|) \\(this=$hex, a=1, b=2\\) at .*method\\.cc:21\r\n21\[\t \]*data_ = res;" \
+  "continue to 21"
 
 # Check ability to access this-relative stuff.
 
-send_gdb "print data_\n"
-gdb_expect {
-   -re "\\$\[0-9\]* = 33\r\n$gdb_prompt $" {
-       pass "access this-relative data_ in getFunky"
-   }
-   -re ".*$gdb_prompt $" { fail "print data_ in getFunky" }
-   timeout { fail "(timeout) print data_ in getFunky" }
-}
+gdb_test "print data_" \
+  "\\$\[0-9\]* = 33" \
+  "print data_ in funk::getFunky"
 
 # Check access to this pointer       
 
-send_gdb "print this\n"
-gdb_expect {
-   -re "\\$\[0-9\]* = \\(funk \\*\\) $hex\r\n$gdb_prompt $" {
-       pass "print this in getFunky"
-   }
-   -re ".*$gdb_prompt $" { fail "print this in getfunky" }
-   timeout { fail "(timeout) print this in getfunky" }
-}
+gdb_test "print this" \
+  "\\$\[0-9\]* = \\((class |)funk *\\* *(const|)\\) $hex" \
+  "print this in funk::getFunky"
 
 # Check access to local variable
 
-send_gdb "print res\n"
-gdb_expect {
-   -re "\\$\[0-9\]* = .\[0-9\]*\r\n$gdb_prompt $" {
-       pass "print res in getFunky"
-   }
-   -re ".*$gdb_prompt $" { fail "print res in getfunky" }
-   timeout { fail "(timeout) print res in getfunky" }
-}
-
+gdb_test "print res" \
+  "\\$\[0-9\]* = -30" \
+   "print res in funk::getFunky"
 
 # Check ptype of class -- should show const/volatile methods
 
@@ -242,12 +180,6 @@
    timeout { fail "(timeout) ptype A" }
 }
 
-send_gdb "cont\n"
-gdb_expect {
-    -re "Continuing.\r\n\r\nProgram exited normally.\r\n$gdb_prompt $" {
-        pass "finish program"
-    }
-    -re "$gdb_prompt $" { fail "finish program"  }
-    timeout { fail "(timeout) finish program"  }
-}
-
+gdb_test "cont" \
+  "Continuing.\r\n\r\nProgram exited normally." \
+  "finish program"
diff --git a/gdb/testsuite/gdb.c++/misc.exp b/gdb/testsuite/gdb.c++/misc.exp
index 1cdc61c..a2d122f 100644
--- a/gdb/testsuite/gdb.c++/misc.exp
+++ b/gdb/testsuite/gdb.c++/misc.exp
@@ -1,4 +1,5 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2002 Free Software
+# Foundation, Inc.
 
 # 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
@@ -41,7 +42,6 @@
 
     # See what language gdb thinks main() is, prior to reading full symbols.
     # I think this fails for COFF targets.
-    # OBSOLETE setup_xfail "a29k-*-udi"
     send_gdb "show language\n"
     gdb_expect {
 	-re ".* source language is \"auto; currently c\[+\]+\".*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.c++/ovldbreak.exp b/gdb/testsuite/gdb.c++/ovldbreak.exp
index 7f5513b..9852cb5 100644
--- a/gdb/testsuite/gdb.c++/ovldbreak.exp
+++ b/gdb/testsuite/gdb.c++/ovldbreak.exp
@@ -157,20 +157,20 @@
 
 gdb_test "info break" \
     "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in main at.*$srcfile:49\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
 \[\t \]+breakpoint already hit 1 time\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(char\\) at.*$srcfile:111\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(short\\) at.*$srcfile:114\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(int\\) at.*$srcfile:116\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(long\\) at.*$srcfile:118\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(float\\) at.*$srcfile:120\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(double\\) at.*$srcfile:121\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
     "breakpoint info (after setting one-by-one)"
 
 
@@ -215,20 +215,20 @@
 
 gdb_test "info break" \
     "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in main at.*$srcfile:49\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
 \[\t \]+breakpoint already hit 1 time\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(char\\) at.*$srcfile:111\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(short\\) at.*$srcfile:114\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(int\\) at.*$srcfile:116\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(long\\) at.*$srcfile:118\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(float\\) at.*$srcfile:120\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(double\\) at.*$srcfile:121\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
     "breakpoint info (after cancel)"
 
 
@@ -294,18 +294,18 @@
 
 gdb_test "info break" \
     "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(double\\) at.*$srcfile:121\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(float\\) at.*$srcfile:120\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(long\\) at.*$srcfile:118\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(int\\) at.*$srcfile:116\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(short\\) at.*$srcfile:114\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\(char\\) at.*$srcfile:111\r
-\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
+\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
     "breakpoint info (after setting on all)"
 
 
diff --git a/gdb/testsuite/gdb.gdb/xfullpath.exp b/gdb/testsuite/gdb.gdb/xfullpath.exp
new file mode 100644
index 0000000..e4a6e2a
--- /dev/null
+++ b/gdb/testsuite/gdb.gdb/xfullpath.exp
@@ -0,0 +1,198 @@
+#   Copyright 2002
+#   Free Software Foundation, Inc.
+
+# 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.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Joel Brobecker. (brobecker@gnat.com), derived
+# from selftest.exp, written by Rob Savoye.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+# are we on a target board
+if [is_remote target] {
+    return
+}
+
+if [istarget "m68k*-*-hpux*"] then {
+    # The top-level makefile passes CFLAGS= (no -g) for hp300.  This probably
+    # should be fixed (it is only needed for gcc bootstrapping, not gdb),
+    # but until then.....
+    setup_xfail "*-*-*"
+    fail "cannot test self if compiled without debug info"
+    return -1
+}
+
+proc setup_test { executable } {
+    global gdb_prompt
+    global timeout
+
+    # load yourself into the debugger
+    # This can take a relatively long time, particularly for testing where
+    # the executable is being accessed over a network, or where gdb does not
+    # support partial symbols for a particular target and has to load the
+    # entire symbol table.  Set the timeout to 10 minutes, which should be
+    # adequate for most environments (it *has* timed out with 5 min on a
+    # SPARCstation SLC under moderate load, so this isn't unreasonable).
+    # After gdb is started, set the timeout to 30 seconds for the duration
+    # of this test, and then back to the original value.
+
+    set oldtimeout $timeout
+    set timeout 600
+    verbose "Timeout is now $timeout seconds" 2
+    if {[gdb_load $executable] <0} then {
+	set timeout $oldtimeout
+	verbose "Timeout is now $timeout seconds" 2
+	return -1
+    }
+    set timeout $oldtimeout
+    verbose "Timeout is now $timeout seconds" 2
+
+    # Set a breakpoint at main
+    gdb_test "break captured_main" \
+            "Breakpoint.*at.* file.*, line.*" \
+            "breakpoint in captured_main"
+
+    # run yourself
+    # It may take a very long time for the inferior gdb to start (lynx),
+    # so we bump it back up for the duration of this command.
+    set timeout 600
+
+    set description "run until breakpoint at captured_main"
+    send_gdb "run -nw\n"
+    gdb_expect {
+        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
+            pass "$description"
+        }
+        -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" {
+            xfail "$description (line numbers scrambled?)"
+        }
+        -re "vfork: No more processes.*$gdb_prompt $" {
+            fail "$description (out of virtual memory)"
+            set timeout $oldtimeout
+            verbose "Timeout is now $timeout seconds" 2
+            return -1
+        }
+        -re ".*$gdb_prompt $" {
+            fail "$description"
+            set timeout $oldtimeout
+            verbose "Timeout is now $timeout seconds" 2
+            return -1
+        }
+        timeout {
+            fail "$description (timeout)"
+        }
+    }
+
+    set timeout $oldtimeout
+    verbose "Timeout is now $timeout seconds" 2
+
+    return 0
+}
+
+proc test_with_self { executable } {
+
+    set setup_result [setup_test $executable]
+    if {$setup_result <0} then {
+        return -1
+    }
+
+    # A file which contains a directory prefix
+    gdb_test "print xfullpath (\"./xfullpath.exp\")" \
+             ".\[0-9\]+ =.*\".*/xfullpath.exp\"" \
+             "A filename with ./ as the directory prefix"
+
+    # A file which contains a directory prefix
+    gdb_test "print xfullpath (\"../../defs.h\")" \
+             ".\[0-9\]+ =.*\".*/defs.h\"" \
+             "A filename with ../ in the directory prefix"
+
+    # A one-character filename
+    gdb_test "print xfullpath (\"./a\")" \
+             ".\[0-9\]+ =.*\".*/a\"" \
+             "A one-char filename in the current directory"
+          
+    # A file in the root directory
+    gdb_test "print xfullpath (\"/root_file_which_should_exist\")" \
+             ".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \
+             "A filename in the root directory"
+          
+    # A file which does not have a directory prefix
+    gdb_test "print xfullpath (\"xfullpath.exp\")" \
+             ".\[0-9\]+ =.*\"xfullpath.exp\"" \
+             "A filename without any directory prefix"
+
+    # A one-char filename without any directory prefix
+    gdb_test "print xfullpath (\"a\")" \
+             ".\[0-9\]+ =.*\"a\"" \
+             "A one-char filename without any directory prefix"
+
+    # An empty filename
+    gdb_test "print xfullpath (\"\")" \
+             ".\[0-9\]+ =.*\"\"" \
+             "An empty filename"
+
+    return 0
+}
+
+# Find a pathname to a file that we would execute if the shell was asked
+# to run $arg using the current PATH.
+
+proc find_gdb { arg } {
+
+    # If the arg directly specifies an existing executable file, then
+    # simply use it.
+
+    if [file executable $arg] then {
+	return $arg
+    }
+
+    set result [which $arg]
+    if [string match "/" [ string range $result 0 0 ]] then {
+	return $result
+    }
+
+    # If everything fails, just return the unqualified pathname as default
+    # and hope for best.
+
+    return $arg
+}
+
+# Run the test with self.
+# Copy the file executable file in case this OS doesn't like to edit its own
+# text space.
+
+set GDB_FULLPATH [find_gdb $GDB]
+
+# Remove any old copy lying around.
+remote_file host delete x$tool
+
+gdb_start
+set file [remote_download host $GDB_FULLPATH x$tool]
+set result [test_with_self $file];
+gdb_exit;
+catch "remote_file host delete $file";
+
+if {$result <0} then {
+    warning "Couldn't test self"
+    return -1
+}
diff --git a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.c b/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.c
deleted file mode 100644
index 043b2a6..0000000
--- a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* OBSOLETE #include <stdio.h> */
-/* OBSOLETE  */
-/* OBSOLETE /* #include "config.h" */ */
-/* OBSOLETE #define HAVE_PTHREAD_H */
-/* OBSOLETE #define __hpux__ */
-/* OBSOLETE #define __osf__ */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef HAVE_PTHREAD_H */
-/* OBSOLETE  */
-/* OBSOLETE /* Don't even try to compile.  In fact, cause a syntax error that we can */
-/* OBSOLETE    look for as a compiler error message and know that we have no pthread */
-/* OBSOLETE    support.  In that case we can just suppress the test completely. */ */
-/* OBSOLETE  */
-/* OBSOLETE #error "no posix threads support" */
-/* OBSOLETE  */
-/* OBSOLETE #else */
-/* OBSOLETE  */
-/* OBSOLETE /* OK.  We have the right header.  If we try to compile this and fail, then */
-/* OBSOLETE    there is something wrong and the user should know about it so the testsuite */
-/* OBSOLETE    should issue an ERROR result.. */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef __linux__ */
-/* OBSOLETE #define  _MIT_POSIX_THREADS 1	/* Linux (or at least RedHat 4.0) needs this */ */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #include <pthread.h> */
-/* OBSOLETE  */
-/* OBSOLETE /* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create */
-/* OBSOLETE    is prototyped to be just a "pthread_attr_t", while under Solaris it */
-/* OBSOLETE    is a "pthread_attr_t *".  Arg! */ */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (__osf__) || defined (__hpux__) */
-/* OBSOLETE #define PTHREAD_CREATE_ARG2(arg) arg */
-/* OBSOLETE #define PTHREAD_CREATE_NULL_ARG2 null_attr */
-/* OBSOLETE static pthread_attr_t null_attr; */
-/* OBSOLETE #else */
-/* OBSOLETE #define PTHREAD_CREATE_ARG2(arg) &arg */
-/* OBSOLETE #define PTHREAD_CREATE_NULL_ARG2 NULL */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE static int verbose = 0; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE common_routine (arg) */
-/* OBSOLETE      int arg; */
-/* OBSOLETE { */
-/* OBSOLETE   static int from_thread1; */
-/* OBSOLETE   static int from_thread2; */
-/* OBSOLETE   static int from_main; */
-/* OBSOLETE   static int hits; */
-/* OBSOLETE   static int full_coverage; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf("common_routine (%d)\n", arg); */
-/* OBSOLETE   hits++; */
-/* OBSOLETE   switch (arg) */
-/* OBSOLETE     { */
-/* OBSOLETE     case 0: */
-/* OBSOLETE       from_main++; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 1: */
-/* OBSOLETE       from_thread1++; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 2: */
-/* OBSOLETE       from_thread2++; */
-/* OBSOLETE       break; */
-/* OBSOLETE     } */
-/* OBSOLETE   if (from_main && from_thread1 && from_thread2) */
-/* OBSOLETE     full_coverage = 1; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void * */
-/* OBSOLETE thread1 (void *arg) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE   int z = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf ("thread1 (%0x) ; pid = %d\n", arg, getpid ()); */
-/* OBSOLETE   for (i=1; i <= 10000000; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (verbose) printf("thread1 %d\n", pthread_self ()); */
-/* OBSOLETE       z += i; */
-/* OBSOLETE       common_routine (1); */
-/* OBSOLETE       sleep(1); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void * */
-/* OBSOLETE thread2 (void * arg) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE   int k = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf ("thread2 (%0x) ; pid = %d\n", arg, getpid ()); */
-/* OBSOLETE   for (i=1; i <= 10000000; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (verbose) printf("thread2 %d\n", pthread_self ()); */
-/* OBSOLETE       k += i; */
-/* OBSOLETE       common_routine (2); */
-/* OBSOLETE       sleep(1); */
-/* OBSOLETE     } */
-/* OBSOLETE   sleep(100); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE foo (a, b, c) */
-/* OBSOLETE      int a, b, c; */
-/* OBSOLETE { */
-/* OBSOLETE   int d, e, f; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf("a=%d\n", a); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE main(argc, argv) */
-/* OBSOLETE      int argc; */
-/* OBSOLETE      char **argv; */
-/* OBSOLETE { */
-/* OBSOLETE   pthread_t tid1, tid2; */
-/* OBSOLETE   int j; */
-/* OBSOLETE   int t = 0; */
-/* OBSOLETE   void (*xxx) (); */
-/* OBSOLETE   pthread_attr_t attr; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf ("pid = %d\n", getpid()); */
-/* OBSOLETE  */
-/* OBSOLETE   foo (1, 2, 3); */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef __osf__ */
-/* OBSOLETE   if (pthread_attr_init (&attr)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_attr_init 1"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef PTHREAD_SCOPE_SYSTEM */
-/* OBSOLETE   if (pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_attr_setscope 1"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   if (pthread_create (&tid1, pthread_attr_default, thread1, (void *) 0xfeedface)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_create 1"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE   if (verbose) printf ("Made thread %d\n", tid1); */
-/* OBSOLETE   sleep (1); */
-/* OBSOLETE  */
-/* OBSOLETE   if (pthread_create (&tid2, null_attr, thread2, (void *) 0xdeadbeef)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_create 2"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE   if (verbose) printf("Made thread %d\n", tid2); */
-/* OBSOLETE  */
-/* OBSOLETE   sleep (1); */
-/* OBSOLETE  */
-/* OBSOLETE   for (j = 1; j <= 10000000; j++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (verbose) printf("top %d\n", pthread_self ()); */
-/* OBSOLETE       common_routine (0); */
-/* OBSOLETE       sleep(1); */
-/* OBSOLETE       t += j; */
-/* OBSOLETE     } */
-/* OBSOLETE    */
-/* OBSOLETE   exit(0); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE #endif	/* ifndef HAVE_PTHREAD_H */ */
diff --git a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.exp b/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.exp
deleted file mode 100644
index 60f3605..0000000
--- a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthbasic.exp
+++ /dev/null
@@ -1,110 +0,0 @@
-# OBSOLETE # usrthbasic.exp -- Expect script to test gdb with user threads
-# OBSOLETE # Copyright (C) 1992 Free Software Foundation, Inc.
-# OBSOLETE 
-# OBSOLETE # This program is free software; you can redistribute it and/or modify
-# OBSOLETE # it under the terms of the GNU General Public License as published by
-# OBSOLETE # the Free Software Foundation; either version 2 of the License, or
-# OBSOLETE # (at your option) any later version.
-# OBSOLETE # 
-# OBSOLETE # This program is distributed in the hope that it will be useful,
-# OBSOLETE # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# OBSOLETE # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# OBSOLETE # GNU General Public License for more details.
-# OBSOLETE # 
-# OBSOLETE # You should have received a copy of the GNU General Public License
-# OBSOLETE # along with this program; if not, write to the Free Software
-# OBSOLETE # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-# OBSOLETE 
-# OBSOLETE # Please email any bugs, comments, and/or additions to this file to:
-# OBSOLETE # bug-gdb@prep.ai.mit.edu
-# OBSOLETE 
-# OBSOLETE # use this to debug:
-# OBSOLETE #
-# OBSOLETE #log_user 1
-# OBSOLETE 
-verbose "HP's thread tests are broken beyond repair right now." 
-return 0
-# OBSOLETE 
-# OBSOLETE if $tracelevel {
-# OBSOLETE     strace $tracelevel
-# OBSOLETE }
-# OBSOLETE 
-# OBSOLETE if { [skip_hp_tests] } { continue }
-# OBSOLETE 
-# OBSOLETE if { ![istarget "hppa*-*-hpux*"] || [istarget "hppa64-*-*"] } {
-# OBSOLETE     verbose "HPUX thread test ignored for non-hppa or PA64 targets."
-# OBSOLETE     return 0
-# OBSOLETE }
-# OBSOLETE 
-# OBSOLETE set testfile usrthbasic
-# OBSOLETE set srcfile ${srcdir}/${subdir}/${testfile}.c
-# OBSOLETE set binfile ${srcdir}/${subdir}/${testfile}
-# OBSOLETE 
-# OBSOLETE # To build the executable we need to link against the thread library.
-# OBSOLETE #
-# OBSOLETE #	/opt/ansic/bin/cc -Ae +DAportable -g -o usrthbasic -lcma usrthbasic.c
-# OBSOLETE #
-# OBSOLETE ## we have trouble building it on 11.0, so we use the prebuilt
-# OBSOLETE ## executable instead.
-# OBSOLETE ##
-# OBSOLETE ##if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}" executable {debug additional_flags=-Ae ldflags=-lcma}] != "" } {
-# OBSOLETE ##    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-# OBSOLETE ##}
-# OBSOLETE 
-# OBSOLETE # We don't really seem to need longer waits.
-# OBSOLETE #
-# OBSOLETE ##set oldtimeout $timeout
-# OBSOLETE ##set timeout [expr "$timeout + 0"]
-# OBSOLETE ##set oldverbose $verbose
-# OBSOLETE ##set verbose 40
-# OBSOLETE 
-# OBSOLETE #=========================
-# OBSOLETE #
-# OBSOLETE # Test looking at threads.
-# OBSOLETE #
-# OBSOLETE gdb_exit
-# OBSOLETE gdb_start
-# OBSOLETE gdb_reinitialize_dir $srcdir/$subdir
-# OBSOLETE gdb_load ${binfile}
-# OBSOLETE 
-# OBSOLETE gdb_test "b main" ".*Breakpoint 1.*" "b main"
-# OBSOLETE gdb_test "run" "Breakpoint 1, main.*:119.*" "run to main"
-# OBSOLETE gdb_test "b thread1" ".*Breakpoint 2.*" "b thread1"
-# OBSOLETE gdb_test "info threads" "\\* 1 system thread.*:119\[^(\]*" \
-# OBSOLETE 	 "info threads at main"
-# OBSOLETE gdb_test "c" "Breakpoint 2, thread1.*" "continue to thread1"
-# OBSOLETE gdb_test "info threads" \
-# OBSOLETE     "\\* 3 system thread.*thread1.*libcma.1.*libcma.1\[^(\]*" \
-# OBSOLETE     "info threads at main"
-# OBSOLETE gdb_test "b 165" "Breakpoint 3.*165.*" "break at main counter"
-# OBSOLETE gdb_test "c" "Breakpoint 3, main.*" "continue to main counter"
-# OBSOLETE gdb_test "info threads" "  4 system thread.*\\* 1 system thread.*main.*" \
-# OBSOLETE     "info threads at main counter"
-# OBSOLETE gdb_test "b 97" "Breakpoint 4.*97.*" "break at thread2 counter"
-# OBSOLETE gdb_test "b 81" "Breakpoint 5.*81.*" "break at thread1 counter"
-# OBSOLETE gdb_test "bt" "#0  main.* at \[^(\]*" "backtrace at main counter"
-# OBSOLETE 
-# OBSOLETE # After switching to thread 4, the cma scheduler should schedule it next
-# OBSOLETE # and we should hit its breakpoint in thread2.
-# OBSOLETE gdb_test "thread 4" ".Switching to thread 4.*cma__dispatch.*" \
-# OBSOLETE 	 "switch to thread 4"
-# OBSOLETE gdb_test "bt" "#0  .*thread2.*" "backtrace at thread 4"
-# OBSOLETE sleep 1
-# OBSOLETE gdb_test "c" ".*Breakpoint 4, thread2.*" "continue and get to thread 4"
-# OBSOLETE 
-# OBSOLETE # After switching to thread 1, the cma scheduler should schedule it next
-# OBSOLETE # and we should hit its breakpoint (in main).
-# OBSOLETE gdb_test "thread 1" ".*Switching to thread 1.*cma__dispatch.*" \
-# OBSOLETE     "switch to thread 1"
-# OBSOLETE sleep 1
-# OBSOLETE gdb_test "c" ".*Breakpoint 3, main.*usrthbasic.c:165.*" \
-# OBSOLETE     "continue and get to thread 1"
-# OBSOLETE 
-# OBSOLETE # Done!
-# OBSOLETE #
-# OBSOLETE gdb_exit
-# OBSOLETE 
-# OBSOLETE ##set timeout $oldtimeout
-# OBSOLETE ##set verbose $oldverbose
-# OBSOLETE 
-# OBSOLETE return 0
diff --git a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.c b/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.c
deleted file mode 100644
index c3bc18d..0000000
--- a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* OBSOLETE #include <stdio.h> */
-/* OBSOLETE  */
-/* OBSOLETE /* #include "config.h" */ */
-/* OBSOLETE #define HAVE_PTHREAD_H */
-/* OBSOLETE #define __hpux__ */
-/* OBSOLETE #define __osf__ */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef HAVE_PTHREAD_H */
-/* OBSOLETE  */
-/* OBSOLETE /* Don't even try to compile.  In fact, cause a syntax error that we can */
-/* OBSOLETE    look for as a compiler error message and know that we have no pthread */
-/* OBSOLETE    support.  In that case we can just suppress the test completely. */ */
-/* OBSOLETE  */
-/* OBSOLETE #error "no posix threads support" */
-/* OBSOLETE  */
-/* OBSOLETE #else */
-/* OBSOLETE  */
-/* OBSOLETE /* OK.  We have the right header.  If we try to compile this and fail, then */
-/* OBSOLETE    there is something wrong and the user should know about it so the testsuite */
-/* OBSOLETE    should issue an ERROR result.. */ */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef __linux__ */
-/* OBSOLETE #define  _MIT_POSIX_THREADS 1	/* Linux (or at least RedHat 4.0) needs this */ */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #include <pthread.h> */
-/* OBSOLETE  */
-/* OBSOLETE /* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create */
-/* OBSOLETE    is prototyped to be just a "pthread_attr_t", while under Solaris it */
-/* OBSOLETE    is a "pthread_attr_t *".  Arg! */ */
-/* OBSOLETE  */
-/* OBSOLETE #if defined (__osf__) || defined (__hpux__) */
-/* OBSOLETE #define PTHREAD_CREATE_ARG2(arg) arg */
-/* OBSOLETE #define PTHREAD_CREATE_NULL_ARG2 null_attr */
-/* OBSOLETE static pthread_attr_t null_attr; */
-/* OBSOLETE #else */
-/* OBSOLETE #define PTHREAD_CREATE_ARG2(arg) &arg */
-/* OBSOLETE #define PTHREAD_CREATE_NULL_ARG2 NULL */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE static int verbose = 0; */
-/* OBSOLETE  */
-/* OBSOLETE static void */
-/* OBSOLETE common_routine (arg) */
-/* OBSOLETE      int arg; */
-/* OBSOLETE { */
-/* OBSOLETE   static int from_thread1; */
-/* OBSOLETE   static int from_thread2; */
-/* OBSOLETE   static int from_main; */
-/* OBSOLETE   static int hits; */
-/* OBSOLETE   static int full_coverage; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf("common_routine (%d)\n", arg); */
-/* OBSOLETE   hits++; */
-/* OBSOLETE   switch (arg) */
-/* OBSOLETE     { */
-/* OBSOLETE     case 0: */
-/* OBSOLETE       from_main++; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 1: */
-/* OBSOLETE       from_thread1++; */
-/* OBSOLETE       break; */
-/* OBSOLETE     case 2: */
-/* OBSOLETE       from_thread2++; */
-/* OBSOLETE       break; */
-/* OBSOLETE     } */
-/* OBSOLETE   if (from_main && from_thread1 && from_thread2) */
-/* OBSOLETE     full_coverage = 1; */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void * */
-/* OBSOLETE thread1 (void *arg) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE   int z = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf ("thread1 (%0x) ; pid = %d\n", arg, getpid ()); */
-/* OBSOLETE   for (i=1; i <= 10000000; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (verbose) printf("thread1 %d\n", pthread_self ()); */
-/* OBSOLETE       z += i; */
-/* OBSOLETE       common_routine (1); */
-/* OBSOLETE       sleep(1); */
-/* OBSOLETE     } */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE static void * */
-/* OBSOLETE thread2 (void * arg) */
-/* OBSOLETE { */
-/* OBSOLETE   int i; */
-/* OBSOLETE   int k = 0; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf ("thread2 (%0x) ; pid = %d\n", arg, getpid ()); */
-/* OBSOLETE   for (i=1; i <= 10000000; i++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (verbose) printf("thread2 %d\n", pthread_self ()); */
-/* OBSOLETE       k += i; */
-/* OBSOLETE       common_routine (2); */
-/* OBSOLETE       sleep(1); */
-/* OBSOLETE     } */
-/* OBSOLETE   sleep(100); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE int */
-/* OBSOLETE foo (a, b, c) */
-/* OBSOLETE      int a, b, c; */
-/* OBSOLETE { */
-/* OBSOLETE   int d, e, f; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf("a=%d\n", a); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE main(argc, argv) */
-/* OBSOLETE      int argc; */
-/* OBSOLETE      char **argv; */
-/* OBSOLETE { */
-/* OBSOLETE   pthread_t tid1, tid2; */
-/* OBSOLETE   int j; */
-/* OBSOLETE   int t = 0; */
-/* OBSOLETE   void (*xxx) (); */
-/* OBSOLETE   pthread_attr_t attr; */
-/* OBSOLETE  */
-/* OBSOLETE   if (verbose) printf ("pid = %d\n", getpid()); */
-/* OBSOLETE  */
-/* OBSOLETE   foo (1, 2, 3); */
-/* OBSOLETE  */
-/* OBSOLETE #ifndef __osf__ */
-/* OBSOLETE   if (pthread_attr_init (&attr)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_attr_init 1"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE #ifdef PTHREAD_SCOPE_SYSTEM */
-/* OBSOLETE   if (pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_attr_setscope 1"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE #endif */
-/* OBSOLETE  */
-/* OBSOLETE   if (pthread_create (&tid1, pthread_attr_default, thread1, (void *) 0xfeedface)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_create 1"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE   if (verbose) printf ("Made thread %d\n", tid1); */
-/* OBSOLETE   sleep (1); */
-/* OBSOLETE  */
-/* OBSOLETE   if (pthread_create (&tid2, null_attr, thread2, (void *) 0xdeadbeef)) */
-/* OBSOLETE     { */
-/* OBSOLETE       perror ("pthread_create 2"); */
-/* OBSOLETE       exit (1); */
-/* OBSOLETE     } */
-/* OBSOLETE   if (verbose) printf("Made thread %d\n", tid2); */
-/* OBSOLETE  */
-/* OBSOLETE   sleep (1); */
-/* OBSOLETE  */
-/* OBSOLETE   for (j = 1; j <= 10000000; j++) */
-/* OBSOLETE     { */
-/* OBSOLETE       if (verbose) printf("top %d\n", pthread_self ()); */
-/* OBSOLETE       common_routine (0); */
-/* OBSOLETE       sleep(1); */
-/* OBSOLETE       t += j; */
-/* OBSOLETE       if (j > 3)  */
-/* OBSOLETE       { */
-/* OBSOLETE 	 int*	int_p; */
-/* OBSOLETE 	 int_p = 0; */
-/* OBSOLETE 	 *int_p = 1; */
-/* OBSOLETE       } */
-/* OBSOLETE     } */
-/* OBSOLETE    */
-/* OBSOLETE   exit(0); */
-/* OBSOLETE } */
-/* OBSOLETE  */
-/* OBSOLETE #endif	/* ifndef HAVE_PTHREAD_H */ */
diff --git a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.exp b/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.exp
deleted file mode 100644
index b373c3a..0000000
--- a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthcore.exp
+++ /dev/null
@@ -1,92 +0,0 @@
-# OBSOLETE # usrthcore.exp -- Expect script to test gdb with user threads
-# OBSOLETE # Copyright (C) 1992 Free Software Foundation, Inc.
-# OBSOLETE 
-# OBSOLETE # This program is free software; you can redistribute it and/or modify
-# OBSOLETE # it under the terms of the GNU General Public License as published by
-# OBSOLETE # the Free Software Foundation; either version 2 of the License, or
-# OBSOLETE # (at your option) any later version.
-# OBSOLETE # 
-# OBSOLETE # This program is distributed in the hope that it will be useful,
-# OBSOLETE # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# OBSOLETE # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# OBSOLETE # GNU General Public License for more details.
-# OBSOLETE # 
-# OBSOLETE # You should have received a copy of the GNU General Public License
-# OBSOLETE # along with this program; if not, write to the Free Software
-# OBSOLETE # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-# OBSOLETE 
-# OBSOLETE # Please email any bugs, comments, and/or additions to this file to:
-# OBSOLETE # bug-gdb@prep.ai.mit.edu
-# OBSOLETE 
-# OBSOLETE # use this to debug:
-# OBSOLETE #
-# OBSOLETE #log_user 1
-# OBSOLETE 
-verbose "HP's thread tests are broken beyond repair right now." 
-return 0
-# OBSOLETE 
-# OBSOLETE if $tracelevel {
-# OBSOLETE     strace $tracelevel
-# OBSOLETE }
-# OBSOLETE 
-# OBSOLETE if { [skip_hp_tests] } { continue }
-# OBSOLETE 
-# OBSOLETE if { ![istarget "hppa*-*-hpux*"] || [istarget "hppa64-*-*"] } {
-# OBSOLETE     verbose "HPUX thread test ignored for non-hppa or PA64 targets."
-# OBSOLETE     return 0
-# OBSOLETE }
-# OBSOLETE 
-# OBSOLETE set testfile usrthcore
-# OBSOLETE set srcfile ${srcdir}/${subdir}/${testfile}.c
-# OBSOLETE set binfile ${srcdir}/${subdir}/${testfile}
-# OBSOLETE 
-# OBSOLETE # To build the executable we need to link against the thread library.
-# OBSOLETE #
-# OBSOLETE #	/opt/ansic/bin/cc -Ae +DAportable -g -o usrthcore -lcma usrthcore.c
-# OBSOLETE #
-# OBSOLETE ## we have trouble building it on 11.0, so we use the prebuilt
-# OBSOLETE ## executable instead.
-# OBSOLETE ##
-# OBSOLETE ##if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c -lcma" "${binfile}" executable {debug additional_flags=-Ae ldflags=-lcma}] != "" } {
-# OBSOLETE ##    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-# OBSOLETE ##}
-# OBSOLETE 
-# OBSOLETE #=========================
-# OBSOLETE #
-# OBSOLETE # Test looking at threads in a core file
-# OBSOLETE #
-# OBSOLETE 
-# OBSOLETE remote_exec build "rm -f core"
-# OBSOLETE remote_exec build "${binfile}"
-# OBSOLETE 
-# OBSOLETE gdb_exit
-# OBSOLETE gdb_start
-# OBSOLETE gdb_reinitialize_dir $srcdir/$subdir
-# OBSOLETE gdb_load ${binfile}
-# OBSOLETE gdb_test "core-file core" \
-# OBSOLETE     ".*Core was generated by `usrthcore'.*in main.*usrthcore.c:170.*" \
-# OBSOLETE     "load corefile"
-# OBSOLETE 
-# OBSOLETE gdb_test "info thread" \
-# OBSOLETE     "  4 .*cma__dispatch.*\\* 1 .*in main.*usrthcore.c:170.*" \
-# OBSOLETE     "info thread on core file"
-# OBSOLETE gdb_test "bt" "#0.*in main.*usrthcore.c:170" "backtrace on active thread"
-# OBSOLETE gdb_test "thread 4" ".*Switching to thread 4.*cma__dispatch.*" \
-# OBSOLETE     "switch to thread 4 (thread2 procedure)"
-# OBSOLETE gdb_test "bt" "#0.*cma__dispatch.*thread2.*usrthcore.c:99.*" \
-# OBSOLETE     "Backtrace on inactive thread (thread2 procedure)"
-# OBSOLETE gdb_test "b thread1"  "Breakpoint 1.*usrthcore.c, line 75.*" \
-# OBSOLETE     "break on thread1"
-# OBSOLETE gdb_test "run" "Starting program.*Breakpoint 1, thread1.*usrthcore.c:75.*" \
-# OBSOLETE     "run program, get to thread1 procedure"
-# OBSOLETE gdb_test "info threads" "\\* \[23\] .*thread1.* 1 .*cma__dispatch.*" \
-# OBSOLETE     "info threads after running core"
-# OBSOLETE 
-# OBSOLETE 
-# OBSOLETE # Done!
-# OBSOLETE #
-# OBSOLETE gdb_exit
-# OBSOLETE 
-# OBSOLETE remote_exec build "rm -f core"
-# OBSOLETE 
-# OBSOLETE return 0
diff --git a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.c b/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.c
deleted file mode 100644
index f5614de..0000000
--- a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* OBSOLETE #include <stdio.h> */
-/* OBSOLETE #include <pthread.h> */
-/* OBSOLETE #include <sys/types.h> */
-/* OBSOLETE  */
-/* OBSOLETE int main(void){ */
-/* OBSOLETE pid_t pid; */
-/* OBSOLETE  */
-/* OBSOLETE switch (pid = fork()){ */
-/* OBSOLETE   case 0: */
-/* OBSOLETE     printf("child\n"); */
-/* OBSOLETE     break; */
-/* OBSOLETE   default: */
-/* OBSOLETE     printf("parent\n"); */
-/* OBSOLETE     break; */
-/* OBSOLETE   } */
-/* OBSOLETE   return 0; */
-/* OBSOLETE } */
diff --git a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.exp b/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.exp
deleted file mode 100644
index 994a6e2..0000000
--- a/gdb/testsuite/gdb.hp/gdb.threads-hp/usrthfork.exp
+++ /dev/null
@@ -1,75 +0,0 @@
-# OBSOLETE # user_th_basic.exp -- Expect script to test gdb with user threads
-# OBSOLETE # Copyright (C) 1992 Free Software Foundation, Inc.
-# OBSOLETE 
-# OBSOLETE # This program is free software; you can redistribute it and/or modify
-# OBSOLETE # it under the terms of the GNU General Public License as published by
-# OBSOLETE # the Free Software Foundation; either version 2 of the License, or
-# OBSOLETE # (at your option) any later version.
-# OBSOLETE # 
-# OBSOLETE # This program is distributed in the hope that it will be useful,
-# OBSOLETE # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# OBSOLETE # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# OBSOLETE # GNU General Public License for more details.
-# OBSOLETE # 
-# OBSOLETE # You should have received a copy of the GNU General Public License
-# OBSOLETE # along with this program; if not, write to the Free Software
-# OBSOLETE # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-# OBSOLETE 
-# OBSOLETE # Please email any bugs, comments, and/or additions to this file to:
-# OBSOLETE # bug-gdb@prep.ai.mit.edu
-# OBSOLETE 
-verbose "HP's thread tests are broken beyond repair right now." 
-return 0
-# OBSOLETE 
-# OBSOLETE if $tracelevel {
-# OBSOLETE     strace $tracelevel
-# OBSOLETE }
-# OBSOLETE 
-# OBSOLETE if { ![istarget "hppa*-*-hpux*"] || [istarget "hppa64-*-*"] } {
-# OBSOLETE     verbose "HPUX thread test ignored for non-hppa or PA64 targets."
-# OBSOLETE     return 0
-# OBSOLETE }
-# OBSOLETE 
-# OBSOLETE set testfile usrthfork
-# OBSOLETE set srcfile ${srcdir}/${subdir}/${testfile}.c
-# OBSOLETE set binfile ${srcdir}/${subdir}/${testfile}
-# OBSOLETE 
-# OBSOLETE # To build the executable we need to link against the thread library.
-# OBSOLETE #
-# OBSOLETE #	/opt/ansic/bin/cc -Ae -g -o usrthfork -lcma usrthfork.c
-# OBSOLETE #
-# OBSOLETE ## we have trouble building it on 11.0, so we use the prebuilt
-# OBSOLETE ## executable instead.
-# OBSOLETE ##
-# OBSOLETE ##if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}" executable {debug additional_flags=-Ae ldflags=-lcma}] != "" } {
-# OBSOLETE ##    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-# OBSOLETE ##}
-# OBSOLETE 
-# OBSOLETE #=========================
-# OBSOLETE #
-# OBSOLETE # Test looking at threads.
-# OBSOLETE #
-# OBSOLETE gdb_exit
-# OBSOLETE gdb_start
-# OBSOLETE gdb_reinitialize_dir $srcdir/$subdir
-# OBSOLETE gdb_load ${binfile}
-# OBSOLETE 
-# OBSOLETE gdb_test "set follow-fork-mode parent" ".*" "set follow-fork-mode parent"
-# OBSOLETE gdb_test "b main" "Breakpoint 1.*" "b main"
-# OBSOLETE gdb_test "run" "Breakpoint 1, main.*:8.*" "run to main"
-# OBSOLETE ##gdb_test "next" \
-# OBSOLETE ##    ".*New process.*Detaching after fork from process.*13.*parent.*" \
-# OBSOLETE ##    "next on CMA fork"
-# OBSOLETE send_gdb "next\n"
-# OBSOLETE gdb_expect {
-# OBSOLETE     -re ".*Detaching after fork from.*$gdb_prompt $" {
-# OBSOLETE 	pass "next on CMA fork"
-# OBSOLETE     }
-# OBSOLETE     -re ".*$gdb_prompt $" { fail "next on CMA fork" }
-# OBSOLETE     timeout { fail "(timeout) next on CMA fork" }
-# OBSOLETE }
-# OBSOLETE exec sleep 1
-# OBSOLETE 
-# OBSOLETE gdb_exit
-# OBSOLETE 
-# OBSOLETE return 0
diff --git a/gdb/testsuite/gdb.java/jmisc1.exp b/gdb/testsuite/gdb.java/jmisc1.exp
new file mode 100644
index 0000000..eea559e
--- /dev/null
+++ b/gdb/testsuite/gdb.java/jmisc1.exp
@@ -0,0 +1,91 @@
+# Copyright 2002 Free Software Foundation, Inc.
+
+# 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.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Anthony Green. (green@redhat.com)
+#
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+load_lib "java.exp"
+
+set testfile "jmisc"
+set srcfile ${srcdir}/$subdir/${testfile}.java
+set binfile ${objdir}/${subdir}/${testfile}
+if  { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } {
+    untested "Couldn't compile ${srcfile}"
+    return -1
+}
+
+# Set the current language to java.  This counts as a test.  If it
+# fails, then we skip the other tests.
+
+proc set_lang_java {} {
+    global gdb_prompt
+    global binfile objdir subdir
+
+    verbose "loading file '$binfile'"
+    gdb_load $binfile
+
+    send_gdb "set language java\n"
+    gdb_expect {
+	-re ".*$gdb_prompt $" {}
+	timeout { fail "set language java (timeout)" ; return 0 }
+    }
+
+    return [gdb_test "show language" ".* source language is \"java\".*" \
+	"set language to \"java\""]
+}
+
+set prms_id 0
+set bug_id 0
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "set print sevenbit-strings" ".*"
+
+if ![set_lang_java] then {
+    runto ${testfile}.main(java.lang.String\[\])
+
+    send_gdb "ptype jmisc\n"   
+    gdb_expect {   
+	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+void <init>\\(void\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"               { pass "ptype jmisc" }
+	-re ".*$gdb_prompt $"             { fail "ptype jmisc" }
+	timeout { fail "ptype jmisc (timeout)" ; return }
+    }
+
+    send_gdb "p args\n"
+    gdb_expect {   
+	-re "\\\$1 = java\.lang\.String\\\[]@\[a-f0-9]+\[\r\n\ \t]+$gdb_prompt $"                                        { pass "p args" }
+	-re ".*$gdb_prompt $"             { fail "p args" }
+	timeout { fail "p args (timeout)" ; return }
+    }
+
+    send_gdb "p *args\n"
+    gdb_expect {   
+	-re "\\\$2 = \{length: 0\}\[\r\n\ \t]+$gdb_prompt $"                                                             { pass "p *args" }
+	-re ".*$gdb_prompt $"             { fail "p *args" }
+	timeout { fail "p *args (timeout)" ; return }
+    }
+}
diff --git a/gdb/testsuite/gdb.java/jmisc2.exp b/gdb/testsuite/gdb.java/jmisc2.exp
new file mode 100644
index 0000000..2eeb99d
--- /dev/null
+++ b/gdb/testsuite/gdb.java/jmisc2.exp
@@ -0,0 +1,91 @@
+# Copyright 2002 Free Software Foundation, Inc.
+
+# 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.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Anthony Green. (green@redhat.com)
+#
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+load_lib "java.exp"
+
+set testfile "jmisc"
+set srcfile ${srcdir}/$subdir/${testfile}.java
+set binfile ${objdir}/${subdir}/${testfile}
+if  { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } {
+    untested "Couldn't compile ${srcfile}"
+    return -1
+}
+
+# Set the current language to java.  This counts as a test.  If it
+# fails, then we skip the other tests.
+
+proc set_lang_java {} {
+    global gdb_prompt
+    global binfile objdir subdir
+
+    verbose "loading file '$binfile'"
+    gdb_load $binfile
+
+    send_gdb "set language java\n"
+    gdb_expect {
+	-re ".*$gdb_prompt $" {}
+	timeout { fail "set language java (timeout)" ; return 0 }
+    }
+
+    return [gdb_test "show language" ".* source language is \"java\".*" \
+	"set language to \"java\""]
+}
+
+set prms_id 0
+set bug_id 0
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "set print sevenbit-strings" ".*"
+
+if ![set_lang_java] then {
+    send_gdb "ptype jmisc\n"   
+    gdb_expect {   
+	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+void <init>\\(void\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"               { pass "ptype jmisc" }
+	-re ".*$gdb_prompt $"             { fail "ptype jmisc" }
+	timeout { fail "ptype jmisc (timeout)" ; return }
+    }
+
+    runto ${testfile}.main(java.lang.String\[\])
+
+    send_gdb "p args\n"
+    gdb_expect {   
+	-re "\\\$1 = java\.lang\.String\\\[]@\[a-f0-9]+\[\r\n\ \t]+$gdb_prompt $"                                        { pass "p args" }
+	-re ".*$gdb_prompt $"             { fail "p args" }
+	timeout { fail "p args (timeout)" ; return }
+    }
+
+    send_gdb "p *args\n"
+    gdb_expect {   
+	-re "\\\$2 = \{length: 0\}\[\r\n\ \t]+$gdb_prompt $"                                                             { pass "p *args" }
+	-re ".*$gdb_prompt $"             { fail "p *args" }
+	timeout { fail "p *args (timeout)" ; return }
+    }
+}
diff --git a/gdb/testsuite/gdb.threads/linux-dp.exp b/gdb/testsuite/gdb.threads/linux-dp.exp
index 0f1b26a..67ed122 100644
--- a/gdb/testsuite/gdb.threads/linux-dp.exp
+++ b/gdb/testsuite/gdb.threads/linux-dp.exp
@@ -214,7 +214,8 @@
 }
 
 set any_interesting 0
-array unset seen
+array set seen {}
+unset seen
 for {set i 1} {$i <= 7} {incr i} {
     if [check_philosopher_stack $i seen] {
 	set any_interesting 1
diff --git a/gdb/testsuite/gdb.trace/gdb_c_test.c b/gdb/testsuite/gdb.trace/gdb_c_test.c
index 7477590..03382c2 100644
--- a/gdb/testsuite/gdb.trace/gdb_c_test.c
+++ b/gdb/testsuite/gdb.trace/gdb_c_test.c
@@ -2542,7 +2542,7 @@
 		 mem, mem_block, mem_addr, mem_size, mem_stamp);
 #endif
 	  *location = mem_block + (mem - mem_addr);
-	  length = mem_size - (mem - mem_addr);;
+	  length = mem_size - (mem - mem_addr);
 
 	  if (length < count)
 	    *incr = length;
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b36211f..e476599 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -440,9 +440,9 @@
 		# we need to set -notransfer expect option so that
 		# command output is not lost for pattern matching
 		# - guo
-		gdb_expect -notransfer 2 {
-		    -re "\[\r\n\]" { }
-		    timeout { }
+		gdb_expect 2 {
+		    -notransfer -re "\[\r\n\]" { verbose "partial: match" 3 }
+		    timeout { verbose "partial: timeout" 3 }
 		}
 		set string [string range "$string" [expr $foo + 1] end];
 	    } else {
@@ -1132,20 +1132,6 @@
 #
 
 proc gdb_expect { args } {
-    # allow -notransfer expect flag specification,
-    # used by gdb_test routine for multi-line commands.
-    # packed with gtimeout when fed to remote_expect routine,
-    # which is a hack but due to what looks like a res and orig
-    # parsing problem in remote_expect routine (dejagnu/lib/remote.exp):
-    # what's fed into res is not removed from orig.
-    # - guo
-    if { [lindex $args 0] == "-notransfer" } {
-	set notransfer -notransfer;
-	set args [lrange $args 1 end];
-    } else {
-	set notransfer "";
-    }
-
     if { [llength $args] == 2  && [lindex $args 0] != "-re" } {
 	set gtimeout [lindex $args 0];
 	set expcode [list [lindex $args 1]];
@@ -1186,7 +1172,7 @@
 	}
     }
     set code [catch \
-	{uplevel remote_expect host "$gtimeout $notransfer" $expcode} string];
+	{uplevel remote_expect host $gtimeout $expcode} string];
     if [info exists old_val] {
 	set remote_suppress_flag $old_val;
     } else {
diff --git a/gdb/thread-db.c b/gdb/thread-db.c
index 2e7620e..d38db74 100644
--- a/gdb/thread-db.c
+++ b/gdb/thread-db.c
@@ -239,7 +239,7 @@
 
   err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), &th);
   if (err != TD_OK)
-    error ("Cannot find user-level thread for LWP %d: %s",
+    error ("Cannot find user-level thread for LWP %ld: %s",
 	   GET_LWP (ptid), thread_db_err_str (err));
 
   err = td_thr_get_info_p (&th, &ti);
diff --git a/gdb/thread.c b/gdb/thread.c
index b9c1f02..45130bb 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -421,7 +421,7 @@
   struct thread_info *tp;
   ptid_t current_ptid;
   struct frame_info *cur_frame;
-  int saved_frame_level = selected_frame_level;
+  int saved_frame_level = frame_relative_level (selected_frame);
   int counter;
   char *extra_info;
 
@@ -476,7 +476,7 @@
     }
   else
     {
-      select_frame (cur_frame, saved_frame_level);
+      select_frame (cur_frame);
     }
 
   /* re-show current frame. */
@@ -495,7 +495,7 @@
   flush_cached_frames ();
   registers_changed ();
   stop_pc = read_pc ();
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
 }
 
 static void
@@ -713,7 +713,7 @@
 #endif
   ui_out_text (uiout, ")]");
 
-  print_stack_frame (selected_frame, selected_frame_level, 1);
+  print_stack_frame (selected_frame, frame_relative_level (selected_frame), 1);
   return GDB_RC_OK;
 }
 
diff --git a/gdb/top.c b/gdb/top.c
index 972a557..4749c38 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -27,6 +27,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-script.h"
 #include "cli/cli-setshow.h"
+#include "cli/cli-decode.h"
 #include "symtab.h"
 #include "inferior.h"
 #include <signal.h>
@@ -693,12 +694,7 @@
 	}
 
       /* If this command has been pre-hooked, run the hook first. */
-      if ((c->hook_pre) && (!c->hook_in))
-      {
-        c->hook_in = 1; /* Prevent recursive hooking */
-        execute_user_command (c->hook_pre, (char *) 0);
-        c->hook_in = 0; /* Allow hook to work again once it is complete */
-      }
+      execute_cmd_pre_hook (c);
 
       if (c->flags & DEPRECATED_WARN_USER)
 	deprecated_cmd_warning (&line);
@@ -715,12 +711,7 @@
 	(*c->func) (c, arg, from_tty & caution);
        
       /* If this command has been post-hooked, run the hook last. */
-      if ((c->hook_post) && (!c->hook_in))
-      {
-        c->hook_in = 1; /* Prevent recursive hooking */
-        execute_user_command (c->hook_post, (char *) 0);
-        c->hook_in = 0; /* allow hook to work again once it is complete */
-      }
+      execute_cmd_post_hook (c);
 
     }
 
@@ -1444,7 +1435,7 @@
 
 		  if (*promptp != gdb_prompt_escape)
 		    error ("Syntax error at prompt position %d",
-			   promptp - local_prompt);
+			   (int) (promptp - local_prompt));
 		  else
 		    {
 		      promptp++;	/* skip second escape char */
@@ -1590,7 +1581,7 @@
 		  break;	/* void type -- no output */
 		default:
 		  error ("bad data type at prompt position %d",
-			 promptp - local_prompt);
+			 (int) (promptp - local_prompt));
 		  break;
 		}
 	      outp += strlen (outp);
@@ -1999,7 +1990,7 @@
      &showhistlist);
 
   c = add_set_cmd ("size", no_class, var_integer, (char *) &history_size,
-		   "Set the size of the command history, \n\
+		   "Set the size of the command history,\n\
 ie. the number of previous commands to keep a record of.", &sethistlist);
   add_show_from_set (c, &showhistlist);
   set_cmd_sfunc (c, set_history_size_command);
@@ -2007,8 +1998,8 @@
   c = add_set_cmd ("filename", no_class, var_filename,
 		   (char *) &history_filename,
 		   "Set the filename in which to record the command history\n\
- (the list of previous commands of which a record is kept).", &sethistlist);
-  c->completer = filename_completer;
+(the list of previous commands of which a record is kept).", &sethistlist);
+  set_cmd_completer (c, filename_completer);
   add_show_from_set (c, &showhistlist);
 
   add_show_from_set
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 860b483..dd5adb0 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -190,7 +190,7 @@
       if (*++buf == '0')	/*   general case: */
 	error ("tracepoint.c: error in outgoing packet.");
       else
-	error ("tracepoint.c: error in outgoing packet at field #%d.",
+	error ("tracepoint.c: error in outgoing packet at field #%ld.",
 	       strtol (buf, NULL, 16));
     case '2':
       error ("trace API error 0x%s.", ++buf);
@@ -1928,7 +1928,7 @@
 
   flush_cached_frames ();
   registers_changed ();
-  select_frame (get_current_frame (), 0);
+  select_frame (get_current_frame ());
   set_traceframe_num (target_frameno);
   set_tracepoint_num (target_tracept);
   if (target_frameno == -1)
@@ -1958,7 +1958,8 @@
       else
 	source_only = 1;
 
-      print_stack_frame (selected_frame, selected_frame_level, source_only);
+      print_stack_frame (selected_frame, frame_relative_level (selected_frame),
+			 source_only);
       do_displays ();
     }
 }
@@ -2280,7 +2281,7 @@
   pathname = tilde_expand (args);
   if (!(fp = fopen (pathname, "w")))
     error ("Unable to open file '%s' for saving tracepoints (%s)",
-	   args, strerror (errno));
+	   args, safe_strerror (errno));
   xfree (pathname);
   
   ALL_TRACEPOINTS (tp)
@@ -2677,7 +2678,7 @@
   c = add_com ("save-tracepoints", class_trace, tracepoint_save_command,
 	       "Save current tracepoint definitions as a script.\n\
 Use the 'source' command in another debug session to restore them.");
-  c->completer = filename_completer;
+  set_cmd_completer (c, filename_completer);
 
   add_com ("tdump", class_trace, trace_dump_command,
 	   "Print everything collected at the current tracepoint.");
@@ -2800,7 +2801,7 @@
 For a line number or function, trace at the start of its code.\n\
 If an address is specified, trace at that exact address.\n\n\
 Do \"help tracepoints\" for info on other tracepoint commands.");
-  c->completer = location_completer;
+  set_cmd_completer (c, location_completer);
 
   add_com_alias ("tp", "trace", class_alias, 0);
   add_com_alias ("tr", "trace", class_alias, 1);
diff --git a/gdb/tui/ChangeLog b/gdb/tui/ChangeLog
index 2f676a8..d278c6a 100644
--- a/gdb/tui/ChangeLog
+++ b/gdb/tui/ChangeLog
@@ -1,3 +1,7 @@
+2002-03-15  Andrew Cagney  <ac131313@redhat.com>
+
+	* tui-out.c (XMALLOC): Delete macro.  Update copyright.
+
 2002-03-01  Andrew Cagney  <ac131313@redhat.com>
 
 	* tui-hooks.c: Add FIXME to explain true/false problem.  Update
diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c
index 9789c65..a8cc58b 100644
--- a/gdb/tui/tui-out.c
+++ b/gdb/tui/tui-out.c
@@ -1,5 +1,7 @@
 /* Output generating routines for GDB CLI.
-   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions.
    Written by Fernando Nasser for Cygnus.
 
@@ -26,12 +28,6 @@
 #include "gdb_string.h"
 #include "gdb_assert.h"
 
-/* Convenience macro for allocting typesafe memory. */
-
-#ifndef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-#endif
-
 struct ui_out_data
   {
     struct ui_file *stream;
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 86655e9..3dbcaab 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -1,5 +1,6 @@
 /* UI_FILE - a generic STDIO like output stream.
-   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,9 +25,6 @@
 #include "ui-file.h"
 #include "gdb_string.h"
 
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-
 static ui_file_isatty_ftype null_file_isatty;
 static ui_file_write_ftype null_file_write;
 static ui_file_fputs_ftype null_file_fputs;
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 06db646..c07d695 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -1,5 +1,7 @@
 /* Output generating routines for GDB.
-   Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
    Contributed by Cygnus Solutions.
    Written by Fernando Nasser for Cygnus.
 
@@ -27,11 +29,6 @@
 #include "ui-out.h"
 #include "gdb_assert.h"
 
-/* Convenience macro for allocting typesafe memory. */
-
-#undef XMALLOC
-#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
-
 /* table header structures */
 
 struct ui_out_hdr
@@ -495,9 +492,14 @@
 {
   char addstr[20];
 
-  /* FIXME-32x64: need a print_address_numeric with field width */
+  /* FIXME: cagney/2002-05-03: Need local_address_string() function
+     that returns the language localized string formatted to a width
+     based on TARGET_ADDR_BIT.  */
   /* print_address_numeric (address, 1, local_stream); */
-  strcpy (addstr, local_hex_string_custom ((unsigned long) address, "08l"));
+  if (TARGET_ADDR_BIT <= 32)
+    strcpy (addstr, local_hex_string_custom ((unsigned long) address, "08l"));
+  else
+    strcpy (addstr, local_hex_string_custom ((unsigned long) address, "016l"));
 
   ui_out_field_string (uiout, fldname, addstr);
 }
diff --git a/gdb/utils.c b/gdb/utils.c
index be9dc45..4baea62 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -61,6 +61,7 @@
 #include "expression.h"
 #include "language.h"
 #include "annotate.h"
+#include "filenames.h"
 
 #include "inferior.h" /* for signed_pointer_to_address */
 
@@ -81,9 +82,11 @@
 #ifdef NEED_DECLARATION_FREE
 extern void free ();
 #endif
-
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
+/* Actually, we'll never have the decl, since we don't define _GNU_SOURCE.  */
+#if defined(HAVE_CANONICALIZE_FILE_NAME) \
+    && defined(NEED_DECLARATION_CANONICALIZE_FILE_NAME)
+extern char *canonicalize_file_name (const char *);
+#endif
 
 /* readline defines this.  */
 #undef savestring
@@ -2532,21 +2535,76 @@
 char *
 gdb_realpath (const char *filename)
 {
-#ifdef HAVE_CANONICALIZE_FILE_NAME
-  return canonicalize_file_name (filename);
-#elif defined (HAVE_REALPATH)
-#if defined (PATH_MAX)
+#if defined(HAVE_REALPATH)
+# if defined (PATH_MAX)
   char buf[PATH_MAX];
-#elif defined (MAXPATHLEN)
+#  define USE_REALPATH
+# elif defined (MAXPATHLEN)
   char buf[MAXPATHLEN];
-#elif defined (HAVE_UNISTD_H) && defined(HAVE_ALLOCA)
+#  define USE_REALPATH
+# elif defined (HAVE_UNISTD_H) && defined(HAVE_ALLOCA)
   char *buf = alloca ((size_t)pathconf ("/", _PC_PATH_MAX));
-#else
-#error "Neither PATH_MAX nor MAXPATHLEN defined"
-#endif
+#  define USE_REALPATH
+# endif
+#endif /* HAVE_REALPATH */
+
+#if defined(USE_REALPATH)
   char *rp = realpath (filename, buf);
   return xstrdup (rp ? rp : filename);
+#elif defined(HAVE_CANONICALIZE_FILE_NAME)
+  char *rp = canonicalize_file_name (filename);
+  if (rp == NULL)
+    return xstrdup (filename);
+  else
+    return rp;
 #else
   return xstrdup (filename);
 #endif
 }
+
+/* Return a copy of FILENAME, with its directory prefix canonicalized
+   by gdb_realpath.  */
+
+char *
+xfullpath (const char *filename)
+{
+  const char *base_name = lbasename (filename);
+  char *dir_name;
+  char *real_path;
+  char *result;
+
+  /* Extract the basename of filename, and return immediately 
+     a copy of filename if it does not contain any directory prefix. */
+  if (base_name == filename)
+    return xstrdup (filename);
+
+  dir_name = alloca ((size_t) (base_name - filename + 2));
+  /* Allocate enough space to store the dir_name + plus one extra
+     character sometimes needed under Windows (see below), and
+     then the closing \000 character */
+  strncpy (dir_name, filename, base_name - filename);
+  dir_name[base_name - filename] = '\000';
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  /* We need to be careful when filename is of the form 'd:foo', which
+     is equivalent of d:./foo, which is totally different from d:/foo.  */
+  if (strlen (dir_name) == 2 &&
+      isalpha (dir_name[0]) && dir_name[1] == ':')
+    {
+      dir_name[2] = '.';
+      dir_name[3] = '\000';
+    }
+#endif
+
+  /* Canonicalize the directory prefix, and build the resulting
+     filename. If the dirname realpath already contains an ending
+     directory separator, avoid doubling it.  */
+  real_path = gdb_realpath (dir_name);
+  if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
+    result = concat (real_path, base_name, NULL);
+  else
+    result = concat (real_path, SLASH_STRING, base_name, NULL);
+
+  xfree (real_path);
+  return result;
+}
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 5852ac6..cc067cb 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -43,12 +43,50 @@
 void _initialize_valarith (void);
 
 
+/* Given a pointer, return the size of its target.
+   If the pointer type is void *, then return 1.
+   If the target type is incomplete, then error out.
+   This isn't a general purpose function, but just a 
+   helper for value_sub & value_add.
+*/
+
+static LONGEST
+find_size_for_pointer_math (struct type *ptr_type)
+{
+  LONGEST sz = -1;
+  struct type *ptr_target;
+
+  ptr_target = check_typedef (TYPE_TARGET_TYPE (ptr_type));
+
+  sz = TYPE_LENGTH (ptr_target);
+  if (sz == 0)
+    {
+      if (TYPE_CODE (ptr_type) == TYPE_CODE_VOID)
+	sz = 1;
+      else
+	{
+	  char *name;
+	  
+	  name = TYPE_NAME (ptr_target);
+	  if (name == NULL)
+	    name = TYPE_TAG_NAME (ptr_target);
+	  if (name == NULL)
+	    error ("Cannot perform pointer math on incomplete types, "
+		   "try casting to a known type, or void *.");
+	  else
+	    error ("Cannot perform pointer math on incomplete type \"%s\", "
+		   "try casting to a known type, or void *.", name);
+	}
+    }
+  return sz;
+}
+
 struct value *
 value_add (struct value *arg1, struct value *arg2)
 {
   struct value *valint;
   struct value *valptr;
-  register int len;
+  LONGEST sz;
   struct type *type1, *type2, *valptrtype;
 
   COERCE_NUMBER (arg1);
@@ -77,12 +115,12 @@
 	  valint = arg1;
 	  valptrtype = type2;
 	}
-      len = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (valptrtype)));
-      if (len == 0)
-	len = 1;		/* For (void *) */
+
+      sz = find_size_for_pointer_math (valptrtype);
+
       retval = value_from_pointer (valptrtype,
 				   value_as_address (valptr)
-				   + (len * value_as_long (valint)));
+				   + (sz * value_as_long (valint)));
       VALUE_BFD_SECTION (retval) = VALUE_BFD_SECTION (valptr);
       return retval;
     }
@@ -104,7 +142,8 @@
       if (TYPE_CODE (type2) == TYPE_CODE_INT)
 	{
 	  /* pointer - integer.  */
-	  LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+	  LONGEST sz = find_size_for_pointer_math (type1);
+
 	  return value_from_pointer (type1,
 				     (value_as_address (arg1)
 				      - (sz * value_as_long (arg2))));
@@ -759,7 +798,7 @@
         case BINOP_EXP:
           v = pow (v1, v2);
           if (errno)
-            error ("Cannot perform exponentiation: %s", strerror (errno));
+            error ("Cannot perform exponentiation: %s", safe_strerror (errno));
           break;
 
 	default:
@@ -897,7 +936,7 @@
             case BINOP_EXP:
               v = pow (v1, v2);
               if (errno)
-                error ("Cannot perform exponentiation: %s", strerror (errno));
+                error ("Cannot perform exponentiation: %s", safe_strerror (errno));
               break;
 
 	    case BINOP_REM:
@@ -1021,7 +1060,7 @@
             case BINOP_EXP:
               v = pow (v1, v2);
               if (errno)
-                error ("Cannot perform exponentiation: %s", strerror (errno));
+                error ("Cannot perform exponentiation: %s", safe_strerror (errno));
 	      break;
 
 	    case BINOP_REM:
diff --git a/gdb/valops.c b/gdb/valops.c
index 4532da7..146f1a6 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -607,7 +607,7 @@
 
 	    if (changed_len > (int) sizeof (LONGEST))
 	      error ("Can't handle bitfields which don't fit in a %d bit word.",
-		     sizeof (LONGEST) * HOST_CHAR_BIT);
+		     (int) sizeof (LONGEST) * HOST_CHAR_BIT);
 
 	    read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
 			 buffer, changed_len);
@@ -644,7 +644,7 @@
 
 	  if (len > (int) sizeof (LONGEST))
 	    error ("Can't handle bitfields in registers larger than %d bits.",
-		   sizeof (LONGEST) * HOST_CHAR_BIT);
+		   (int) sizeof (LONGEST) * HOST_CHAR_BIT);
 
 	  if (VALUE_BITPOS (toval) + VALUE_BITSIZE (toval)
 	      > len * HOST_CHAR_BIT)
@@ -1190,8 +1190,12 @@
       type = lookup_pointer_type (type);
       break;
     case TYPE_CODE_ARRAY:
+      /* Arrays are coerced to pointers to their first element, unless
+         they are vectors, in which case we want to leave them alone,
+         because they are passed by value.  */
       if (current_language->c_style_arrays)
-	type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
+	if (!TYPE_VECTOR (type))
+	  type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
       break;
     case TYPE_CODE_UNDEF:
     case TYPE_CODE_PTR:
@@ -1385,6 +1389,8 @@
   if (CALL_DUMMY_LOCATION == ON_STACK)
     {
       write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
+      if (USE_GENERIC_DUMMY_FRAMES)
+	generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
     }
 
   if (CALL_DUMMY_LOCATION == BEFORE_TEXT_END)
@@ -1401,6 +1407,8 @@
       sp = old_sp;
       real_pc = text_end - sizeof_dummy1;
       write_memory (real_pc, (char *) dummy1, sizeof_dummy1);
+      if (USE_GENERIC_DUMMY_FRAMES)
+	generic_save_call_dummy_addr (real_pc, real_pc + sizeof_dummy1);
     }
 
   if (CALL_DUMMY_LOCATION == AFTER_TEXT_END)
@@ -1412,11 +1420,18 @@
       errcode = target_write_memory (real_pc, (char *) dummy1, sizeof_dummy1);
       if (errcode != 0)
 	error ("Cannot write text segment -- call_function failed");
+      if (USE_GENERIC_DUMMY_FRAMES)
+	generic_save_call_dummy_addr (real_pc, real_pc + sizeof_dummy1);
     }
 
   if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT)
     {
       real_pc = funaddr;
+      if (USE_GENERIC_DUMMY_FRAMES)
+	/* NOTE: cagney/2002-04-13: The entry point is going to be
+           modified with a single breakpoint.  */
+	generic_save_call_dummy_addr (CALL_DUMMY_ADDRESS (),
+				      CALL_DUMMY_ADDRESS () + 1);
     }
 
 #ifdef lint
@@ -3250,7 +3265,7 @@
 
   /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
      symbol instead of the LOC_ARG one (if both exist).  */
-  sym = lookup_block_symbol (b, funny_this, VAR_NAMESPACE);
+  sym = lookup_block_symbol (b, funny_this, NULL, VAR_NAMESPACE);
   if (sym == NULL)
     {
       if (complain)
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 131769b..36854ce 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1,7 +1,8 @@
 /* Print values for GDB, the GNU debugger.
-   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
+   Inc.
 
    This file is part of GDB.
 
@@ -335,7 +336,7 @@
 			val_long);
       break;
     case 'u':
-      fprintf_filtered (stream, "%llu", val_long);
+      fprintf_filtered (stream, "%llu", (long long) val_long);
       break;
     case 'x':
       fprintf_filtered (stream,
@@ -414,109 +415,6 @@
 #endif /* CC_HAS_LONG_LONG || PRINTF_HAS_LONG_LONG */
 }
 
-#if 0
-void
-strcat_longest (int format, int use_local, LONGEST val_long, char *buf,
-		int buflen)
-{
-/* FIXME: Use buflen to avoid buffer overflow.  */
-#if defined (CC_HAS_LONG_LONG) && !defined (PRINTF_HAS_LONG_LONG)
-  long vtop, vbot;
-
-  vtop = val_long >> (sizeof (long) * HOST_CHAR_BIT);
-  vbot = (long) val_long;
-
-  if ((format == 'd' && (val_long < INT_MIN || val_long > INT_MAX))
-      || ((format == 'u' || format == 'x') && (unsigned long long) val_long > UINT_MAX))
-    {
-      sprintf (buf, "0x%lx%08lx", vtop, vbot);
-      return;
-    }
-#endif
-
-#ifdef PRINTF_HAS_LONG_LONG
-  switch (format)
-    {
-    case 'd':
-      sprintf (buf,
-	       (use_local ? local_decimal_format_custom ("ll") : "%lld"),
-	       val_long);
-      break;
-    case 'u':
-      sprintf (buf, "%llu", val_long);
-      break;
-    case 'x':
-      sprintf (buf,
-	       (use_local ? local_hex_format_custom ("ll") : "%llx"),
-
-	       val_long);
-      break;
-    case 'o':
-      sprintf (buf,
-	       (use_local ? local_octal_format_custom ("ll") : "%llo"),
-	       val_long);
-      break;
-    case 'b':
-      sprintf (buf, local_hex_format_custom ("02ll"), val_long);
-      break;
-    case 'h':
-      sprintf (buf, local_hex_format_custom ("04ll"), val_long);
-      break;
-    case 'w':
-      sprintf (buf, local_hex_format_custom ("08ll"), val_long);
-      break;
-    case 'g':
-      sprintf (buf, local_hex_format_custom ("016ll"), val_long);
-      break;
-    default:
-      internal_error (__FILE__, __LINE__, "failed internal consistency check");
-    }
-#else /* !PRINTF_HAS_LONG_LONG */
-  /* In the following it is important to coerce (val_long) to a long. It does
-     nothing if !LONG_LONG, but it will chop off the top half (which we know
-     we can ignore) if the host supports long longs.  */
-
-  switch (format)
-    {
-    case 'd':
-      sprintf (buf, (use_local ? local_decimal_format_custom ("l") : "%ld"),
-	       ((long) val_long));
-      break;
-    case 'u':
-      sprintf (buf, "%lu", ((unsigned long) val_long));
-      break;
-    case 'x':
-      sprintf (buf, (use_local ? local_hex_format_custom ("l") : "%lx"),
-	       ((long) val_long));
-      break;
-    case 'o':
-      sprintf (buf, (use_local ? local_octal_format_custom ("l") : "%lo"),
-	       ((long) val_long));
-      break;
-    case 'b':
-      sprintf (buf, local_hex_format_custom ("02l"),
-	       ((long) val_long));
-      break;
-    case 'h':
-      sprintf (buf, local_hex_format_custom ("04l"),
-	       ((long) val_long));
-      break;
-    case 'w':
-      sprintf (buf, local_hex_format_custom ("08l"),
-	       ((long) val_long));
-      break;
-    case 'g':
-      sprintf (buf, local_hex_format_custom ("016l"),
-	       ((long) val_long));
-      break;
-    default:
-      internal_error (__FILE__, __LINE__, "failed internal consistency check");
-    }
-
-#endif /* !PRINTF_HAS_LONG_LONG */
-}
-#endif
-
 /* This used to be a macro, but I don't think it is called often enough
    to merit such treatment.  */
 /* Convert a LONGEST to an int.  This is used in contexts (e.g. number of
@@ -1294,7 +1192,7 @@
 static void
 set_input_radix (char *args, int from_tty, struct cmd_list_element *c)
 {
-  set_input_radix_1 (from_tty, *(unsigned *) c->var);
+  set_input_radix_1 (from_tty, input_radix);
 }
 
 /* ARGSUSED */
@@ -1310,6 +1208,8 @@
 
   if (radix < 2)
     {
+      /* FIXME: cagney/2002-03-17: This needs to revert the bad radix
+         value.  */
       error ("Nonsense input radix ``decimal %u''; input radix unchanged.",
 	     radix);
     }
@@ -1325,7 +1225,7 @@
 static void
 set_output_radix (char *args, int from_tty, struct cmd_list_element *c)
 {
-  set_output_radix_1 (from_tty, *(unsigned *) c->var);
+  set_output_radix_1 (from_tty, output_radix);
 }
 
 static void
@@ -1345,6 +1245,8 @@
       output_format = 'o';	/* octal */
       break;
     default:
+      /* FIXME: cagney/2002-03-17: This needs to revert the bad radix
+         value.  */
       error ("Unsupported output radix ``decimal %u''; output radix unchanged.",
 	     radix);
     }
diff --git a/gdb/value.h b/gdb/value.h
index d6fa9ff..62dc490 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -125,14 +125,6 @@
        list.  */
     struct value *next;
 
-    /* ??? When is this used?  */
-    union
-      {
-	CORE_ADDR memaddr;
-	char *myaddr;
-      }
-    substring_addr;
-
     /* Register number if the value is from a register.  Is not kept
        if you take a field of a structure that is stored in a
        register.  Shouldn't it be?  */
@@ -166,9 +158,10 @@
     union
       {
 	long contents[1];
-	double force_double_align;
-	LONGEST force_longlong_align;
-	char *literal_data;
+	DOUBLEST force_doublest_align;
+	LONGEST force_longest_align;
+	CORE_ADDR force_core_addr_align;
+	void *force_pointer_align;
       }
     aligner;
     /* Do not add any new members here -- contents above will trash them */
@@ -317,7 +310,8 @@
 
 extern struct value *value_of_variable (struct symbol *var, struct block *b);
 
-extern struct value *value_of_register (int regnum);
+extern struct value *value_of_register (int regnum,
+					struct frame_info *frame);
 
 extern int symbol_read_needs_frame (struct symbol *);
 
diff --git a/gdb/varobj.c b/gdb/varobj.c
index f56b7aa..9ae145e 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -426,7 +426,7 @@
 
       block = NULL;
       if (fi != NULL)
-	block = get_frame_block (fi);
+	block = get_frame_block (fi, 0);
 
       p = expression;
       innermost_block = NULL;
@@ -458,7 +458,7 @@
 	{
 	  var->root->frame = FRAME_FP (fi);
 	  old_fi = selected_frame;
-	  select_frame (fi, -1);
+	  select_frame (fi);
 	}
 
       /* We definitively need to catch errors here.
@@ -485,7 +485,7 @@
 
       /* Reset the selected frame */
       if (fi != NULL)
-	select_frame (old_fi, -1);
+	select_frame (old_fi);
     }
 
   /* If the variable object name is null, that means this
@@ -983,7 +983,7 @@
     }
 
   /* Restore selected frame */
-  select_frame (old_fi, -1);
+  select_frame (old_fi);
 
   if (type_changed)
     return -2;
@@ -1862,7 +1862,7 @@
       within_scope = fi != NULL;
       /* FIXME: select_frame could fail */
       if (within_scope)
-	select_frame (fi, -1);
+	select_frame (fi);
     }
 
   if (within_scope)
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index a5fbe3a..0478227 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -1,5 +1,5 @@
 /* Print VAX instructions for GDB, the GNU debugger.
-   Copyright 1986, 1989, 1991, 1992, 1995, 1996, 1998, 1999, 2000
+   Copyright 1986, 1989, 1991, 1992, 1995, 1996, 1998, 1999, 2000, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -23,8 +23,39 @@
 #include "symtab.h"
 #include "opcode/vax.h"
 #include "gdbcore.h"
+#include "inferior.h"
+#include "regcache.h"
 #include "frame.h"
 #include "value.h"
+#include "arch-utils.h"
+
+#include "vax-tdep.h"
+
+static gdbarch_register_name_ftype vax_register_name;
+static gdbarch_register_byte_ftype vax_register_byte;
+static gdbarch_register_raw_size_ftype vax_register_raw_size;
+static gdbarch_register_virtual_size_ftype vax_register_virtual_size;
+static gdbarch_register_virtual_type_ftype vax_register_virtual_type;
+
+static gdbarch_skip_prologue_ftype vax_skip_prologue;
+static gdbarch_saved_pc_after_call_ftype vax_saved_pc_after_call;
+static gdbarch_frame_num_args_ftype vax_frame_num_args;
+static gdbarch_frame_chain_ftype vax_frame_chain;
+static gdbarch_frame_saved_pc_ftype vax_frame_saved_pc;
+static gdbarch_frame_args_address_ftype vax_frame_args_address;
+static gdbarch_frame_locals_address_ftype vax_frame_locals_address;
+static gdbarch_frame_init_saved_regs_ftype vax_frame_init_saved_regs;
+static gdbarch_get_saved_register_ftype vax_get_saved_register;
+
+static gdbarch_store_struct_return_ftype vax_store_struct_return;
+static gdbarch_extract_return_value_ftype vax_extract_return_value;
+static gdbarch_store_return_value_ftype vax_store_return_value;
+static gdbarch_extract_struct_value_address_ftype
+    vax_extract_struct_value_address;
+
+static gdbarch_push_dummy_frame_ftype vax_push_dummy_frame;
+static gdbarch_pop_frame_ftype vax_pop_frame;
+static gdbarch_fix_call_dummy_ftype vax_fix_call_dummy;
 
 /* Return 1 if P points to an invalid floating point value.
    LEN is the length in bytes -- not relevant on the Vax.  */
@@ -52,10 +83,280 @@
 
 static unsigned char *print_insn_arg ();
 
+static char *
+vax_register_name (int regno)
+{
+  static char *register_names[] =
+  {
+    "r0",  "r1",  "r2",  "r3", "r4", "r5", "r6", "r7",
+    "r8",  "r9", "r10", "r11", "ap", "fp", "sp", "pc",
+    "ps",
+  };
+
+  if (regno < 0)
+    return (NULL);
+  if (regno >= (sizeof(register_names) / sizeof(*register_names)))
+    return (NULL);
+  return (register_names[regno]);
+}
+
+static int
+vax_register_byte (int regno)
+{
+  return (regno * 4);
+}
+
+static int
+vax_register_raw_size (int regno)
+{
+  return (4);
+}
+
+static int
+vax_register_virtual_size (int regno)
+{
+  return (4);
+}
+
+static struct type *
+vax_register_virtual_type (int regno)
+{
+  return (builtin_type_int);
+}
+
+static void
+vax_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
+                        struct frame_info *frame, int regnum,
+                        enum lval_type *lval)
+{
+  CORE_ADDR addr;
+
+  if (!target_has_registers)
+    error ("No registers.");
+
+  /* Normal systems don't optimize out things with register numbers.  */
+  if (optimized != NULL)
+    *optimized = 0;
+  addr = find_saved_register (frame, regnum);
+  if (addr != 0)
+    {
+      if (lval != NULL)
+	*lval = lval_memory;
+      if (regnum == SP_REGNUM)
+	{
+	  if (raw_buffer != NULL)
+	    {
+	      /* Put it back in target format.  */
+	      store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
+			     (LONGEST) addr);
+	    }
+	  if (addrp != NULL)
+	    *addrp = 0;
+	  return;
+	}
+      if (raw_buffer != NULL)
+	target_read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum));
+    }
+  else
+    {
+      if (lval != NULL)
+	*lval = lval_register;
+      addr = REGISTER_BYTE (regnum);
+      if (raw_buffer != NULL)
+	read_register_gen (regnum, raw_buffer);
+    }
+  if (addrp != NULL)
+    *addrp = addr;
+}
+
+static void
+vax_frame_init_saved_regs (struct frame_info *frame)
+{
+  int regnum, regmask;
+  CORE_ADDR next_addr;
+
+  if (frame->saved_regs)
+    return;
+
+  frame_saved_regs_zalloc (frame);
+
+  regmask = read_memory_integer (frame->frame + 4, 4) >> 16;
+
+  next_addr = frame->frame + 16;
+
+  /* regmask's low bit is for register 0, which is the first one
+     what would be pushed.  */
+  for (regnum = 0; regnum < AP_REGNUM; regnum++)
+    {
+      if (regmask & (1 << regnum))
+        frame->saved_regs[regnum] = next_addr += 4;
+    }
+
+  frame->saved_regs[SP_REGNUM] = next_addr + 4;
+  if (regmask & (1 << FP_REGNUM))
+    frame->saved_regs[SP_REGNUM] +=
+      4 + (4 * read_memory_integer (next_addr + 4, 4));
+
+  frame->saved_regs[PC_REGNUM] = frame->frame + 16;
+  frame->saved_regs[FP_REGNUM] = frame->frame + 12;
+  frame->saved_regs[AP_REGNUM] = frame->frame + 8;
+  frame->saved_regs[PS_REGNUM] = frame->frame + 4;
+}
+
+static CORE_ADDR
+vax_frame_saved_pc (struct frame_info *frame)
+{
+  if (frame->signal_handler_caller)
+    return (sigtramp_saved_pc (frame)); /* XXXJRT */
+
+  return (read_memory_integer (frame->frame + 16, 4));
+}
+
+CORE_ADDR
+vax_frame_args_address_correct (struct frame_info *frame)
+{
+  /* Cannot find the AP register value directly from the FP value.  Must
+     find it saved in the frame called by this one, or in the AP register
+     for the innermost frame.  However, there is no way to tell the
+     difference between the innermost frame and a frame for which we
+     just don't know the frame that it called (e.g. "info frame 0x7ffec789").
+     For the sake of argument, suppose that the stack is somewhat trashed
+     (which is one reason that "info frame" exists).  So, return 0 (indicating
+     we don't know the address of the arglist) if we don't know what frame
+     this frame calls.  */
+  if (frame->next)
+    return (read_memory_integer (frame->next->frame + 8, 4));
+
+  return (0);
+}
+
+static CORE_ADDR
+vax_frame_args_address (struct frame_info *frame)
+{
+  /* In most of GDB, getting the args address is too important to
+     just say "I don't know".  This is sometimes wrong for functions
+     that aren't on top of the stack, but c'est la vie.  */
+  if (frame->next)
+    return (read_memory_integer (frame->next->frame + 8, 4));
+
+  return (read_register (AP_REGNUM));
+}
+
+static CORE_ADDR
+vax_frame_locals_address (struct frame_info *frame)
+{
+  return (frame->frame);
+}
+
+static int
+vax_frame_num_args (struct frame_info *fi)
+{
+  return (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1));
+}
+
+static CORE_ADDR
+vax_frame_chain (struct frame_info *frame)
+{
+  /* In the case of the VAX, the frame's nominal address is the FP value,
+     and 12 bytes later comes the saved previous FP value as a 4-byte word.  */
+  if (inside_entry_file (frame->pc))
+    return (0);
+
+  return (read_memory_integer (frame->frame + 12, 4));
+}
+
+static void
+vax_push_dummy_frame (void)
+{
+  CORE_ADDR sp = read_register (SP_REGNUM);
+  int regnum;
+
+  sp = push_word (sp, 0);	/* arglist */
+  for (regnum = 11; regnum >= 0; regnum--)
+    sp = push_word (sp, read_register (regnum));
+  sp = push_word (sp, read_register (PC_REGNUM));
+  sp = push_word (sp, read_register (FP_REGNUM));
+  sp = push_word (sp, read_register (AP_REGNUM));
+  sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) + 0x2fff0000);
+  sp = push_word (sp, 0);
+  write_register (SP_REGNUM, sp);
+  write_register (FP_REGNUM, sp);
+  write_register (AP_REGNUM, sp + (17 * 4));
+}
+
+static void
+vax_pop_frame (void)
+{
+  CORE_ADDR fp = read_register (FP_REGNUM);
+  int regnum;
+  int regmask = read_memory_integer (fp + 4, 4);
+
+  write_register (PS_REGNUM,
+		  (regmask & 0xffff)
+		  | (read_register (PS_REGNUM) & 0xffff0000));
+  write_register (PC_REGNUM, read_memory_integer (fp + 16, 4));
+  write_register (FP_REGNUM, read_memory_integer (fp + 12, 4));
+  write_register (AP_REGNUM, read_memory_integer (fp + 8, 4));
+  fp += 16;
+  for (regnum = 0; regnum < 12; regnum++)
+    if (regmask & (0x10000 << regnum))
+      write_register (regnum, read_memory_integer (fp += 4, 4));
+  fp = fp + 4 + ((regmask >> 30) & 3);
+  if (regmask & 0x20000000)
+    {
+      regnum = read_memory_integer (fp, 4);
+      fp += (regnum + 1) * 4;
+    }
+  write_register (SP_REGNUM, fp);
+  flush_cached_frames ();
+}
+
+/* The VAX call dummy sequence:
+
+	calls #69, @#32323232
+	bpt
+
+   It is 8 bytes long.  The address and argc are patched by
+   vax_fix_call_dummy().  */
+static LONGEST vax_call_dummy_words[] = { 0x329f69fb, 0x03323232 };
+static int sizeof_vax_call_dummy_words = sizeof(vax_call_dummy_words);
+
+static void
+vax_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
+                    struct value **args, struct type *type, int gcc_p)
+{
+  dummy[1] = nargs;
+  store_unsigned_integer (dummy + 3, 4, fun);
+}
+
+static void
+vax_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
+{
+  write_register (1, addr);
+}
+
+static void
+vax_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
+{
+  memcpy (valbuf, regbuf + REGISTER_BYTE (0), TYPE_LENGTH (valtype));
+}
+
+static void
+vax_store_return_value (struct type *valtype, char *valbuf)
+{
+  write_register_bytes (0, valbuf, TYPE_LENGTH (valtype));
+}
+
+static CORE_ADDR
+vax_extract_struct_value_address (char *regbuf)
+{
+  return (extract_address (regbuf + REGISTER_BYTE (0), REGISTER_RAW_SIZE (0)));
+}
+
 /* Advance PC across any function entry prologue instructions
    to reach some "real" code.  */
 
-CORE_ADDR
+static CORE_ADDR
 vax_skip_prologue (CORE_ADDR pc)
 {
   register int op = (unsigned char) read_memory_integer (pc, 1);
@@ -81,17 +382,12 @@
   return pc;
 }
 
-/* Return number of args passed to a frame.
-   Can return -1, meaning no way to tell.  */
-
-int
-vax_frame_num_args (struct frame_info *fi)
+static CORE_ADDR
+vax_saved_pc_after_call (struct frame_info *frame)
 {
-  return (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1));
+  return (FRAME_SAVED_PC(frame));
 }
-
-
-
+
 /* Print the vax instruction at address MEMADDR in debugged memory,
    from disassembler info INFO.
    Returns length of the instruction, in bytes.  */
@@ -142,7 +438,7 @@
     }
   return p - buffer;
 }
-
+
 static unsigned char *
 print_insn_arg (char *d, register char *p, CORE_ADDR addr,
 		disassemble_info *info)
@@ -313,9 +609,101 @@
 
   return (unsigned char *) p;
 }
+
+/* Initialize the current architecture based on INFO.  If possible, re-use an
+   architecture from ARCHES, which is a list of architectures already created
+   during this debugging session.
+
+   Called e.g. at program startup, when reading a core file, and when reading
+   a binary file.  */
+
+static struct gdbarch *
+vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+{
+  struct gdbarch *gdbarch;
+
+  /* Right now there is only one VAX architecture variant.  */
+  if (arches != NULL)
+    return (arches->gdbarch);
+
+  gdbarch = gdbarch_alloc (&info, NULL);
+
+  /* Register info */
+  set_gdbarch_num_regs (gdbarch, VAX_NUM_REGS);
+  set_gdbarch_sp_regnum (gdbarch, VAX_SP_REGNUM);
+  set_gdbarch_fp_regnum (gdbarch, VAX_FP_REGNUM);
+  set_gdbarch_pc_regnum (gdbarch, VAX_PC_REGNUM);
+  set_gdbarch_ps_regnum (gdbarch, VAX_PS_REGNUM);
+
+  set_gdbarch_register_name (gdbarch, vax_register_name);
+  set_gdbarch_register_size (gdbarch, VAX_REGISTER_SIZE);
+  set_gdbarch_register_bytes (gdbarch, VAX_REGISTER_BYTES);
+  set_gdbarch_register_byte (gdbarch, vax_register_byte);
+  set_gdbarch_register_raw_size (gdbarch, vax_register_raw_size);
+  set_gdbarch_max_register_raw_size (gdbarch, VAX_MAX_REGISTER_RAW_SIZE);
+  set_gdbarch_register_virtual_size (gdbarch, vax_register_virtual_size);
+  set_gdbarch_max_register_virtual_size (gdbarch,
+                                         VAX_MAX_REGISTER_VIRTUAL_SIZE);
+  set_gdbarch_register_virtual_type (gdbarch, vax_register_virtual_type);
+
+  /* Frame and stack info */
+  set_gdbarch_skip_prologue (gdbarch, vax_skip_prologue);
+  set_gdbarch_saved_pc_after_call (gdbarch, vax_saved_pc_after_call);
+
+  set_gdbarch_frame_num_args (gdbarch, vax_frame_num_args);
+  set_gdbarch_frameless_function_invocation (gdbarch,
+				   generic_frameless_function_invocation_not);
+
+  set_gdbarch_frame_chain (gdbarch, vax_frame_chain);
+  set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
+  set_gdbarch_frame_saved_pc (gdbarch, vax_frame_saved_pc);
+
+  set_gdbarch_frame_args_address (gdbarch, vax_frame_args_address);
+  set_gdbarch_frame_locals_address (gdbarch, vax_frame_locals_address);
+
+  set_gdbarch_frame_init_saved_regs (gdbarch, vax_frame_init_saved_regs);
+
+  set_gdbarch_frame_args_skip (gdbarch, 4);
+
+  set_gdbarch_get_saved_register (gdbarch, vax_get_saved_register);
+
+  set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
+
+  /* Return value info */
+  set_gdbarch_store_struct_return (gdbarch, vax_store_struct_return);
+  set_gdbarch_extract_return_value (gdbarch, vax_extract_return_value);
+  set_gdbarch_store_return_value (gdbarch, vax_store_return_value);
+  set_gdbarch_extract_struct_value_address (gdbarch,
+					    vax_extract_struct_value_address);
+
+  /* Call dummy info */
+  set_gdbarch_push_dummy_frame (gdbarch, vax_push_dummy_frame);
+  set_gdbarch_pop_frame (gdbarch, vax_pop_frame);
+  set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+  set_gdbarch_call_dummy_p (gdbarch, 1);
+  set_gdbarch_call_dummy_words (gdbarch, vax_call_dummy_words);
+  set_gdbarch_sizeof_call_dummy_words (gdbarch, sizeof_vax_call_dummy_words);
+  set_gdbarch_fix_call_dummy (gdbarch, vax_fix_call_dummy);
+  set_gdbarch_call_dummy_start_offset (gdbarch, 0);
+  set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
+  set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 7);
+  set_gdbarch_use_generic_dummy_frames (gdbarch, 0);
+  set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_on_stack);
+  set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
+
+  /* Breakpoint info */
+  set_gdbarch_decr_pc_after_break (gdbarch, 0);
+
+  /* Misc info */
+  set_gdbarch_function_start_offset (gdbarch, 2);
+
+  return (gdbarch);
+}
 
 void
 _initialize_vax_tdep (void)
 {
+  gdbarch_register (bfd_arch_vax, vax_gdbarch_init, NULL);
+
   tm_print_insn = vax_print_insn;
 }
diff --git a/gdb/vax-tdep.h b/gdb/vax-tdep.h
new file mode 100644
index 0000000..95324bc
--- /dev/null
+++ b/gdb/vax-tdep.h
@@ -0,0 +1,55 @@
+/* Common target dependent code for GDB on VAX systems.
+   Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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.  */
+
+#ifndef VAX_TDEP_H
+#define VAX_TDEP_H
+
+/* Say how long (ordinary) registers are.  This is a piece of bogosity
+   used in push_word and a few other places;  REGISTER_RAW_SIZE is the
+   real way to know how big a register is.  */
+#define VAX_REGISTER_SIZE 4
+
+/* Number of machine registers.  */
+#define VAX_NUM_REGS 17
+
+/* Total amount of space needed to store our copies of the machine's
+   register state.  */
+#define VAX_REGISTER_BYTES (VAX_NUM_REGS * 4)
+
+/* Largest value REGISTER_RAW_SIZE can have.  */
+#define VAX_MAX_REGISTER_RAW_SIZE 4
+
+/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
+#define VAX_MAX_REGISTER_VIRTUAL_SIZE 4
+
+/* Register numbers of various important registers.
+   Note that most of these values are "real" register numbers,
+   and correspond to the general registers of the machine,
+   and are "phony" register numbers which is too large
+   to be an actual register number as far as the user is concerned
+   but serves to get the desired value when passed to read_register.  */
+
+#define VAX_AP_REGNUM     12  /* argument pointer */
+#define VAX_FP_REGNUM     13  /* Contains address of executing stack frame */
+#define VAX_SP_REGNUM     14  /* Contains address of top of stack */
+#define VAX_PC_REGNUM     15  /* Contains program counter */
+#define VAX_PS_REGNUM     16  /* Contains processor status */
+
+#endif /* VAX_TDEP_H */
diff --git a/gdb/version.in b/gdb/version.in
index 4810350..63bac33 100644
--- a/gdb/version.in
+++ b/gdb/version.in
@@ -1 +1 @@
-5.1.90-2002-03-27-cvs
+2002-05-06-cvs
diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index ddbcd0b..d519f7b 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -123,7 +123,8 @@
 					   WaitForDebugEvent */
 static HANDLE current_process_handle;	/* Currently executing process */
 static thread_info *current_thread;	/* Info on currently selected thread */
-static DWORD main_thread_id;	/* Thread ID of the main thread */
+static DWORD main_thread_id;		/* Thread ID of the main thread */
+static pid_t cygwin_pid;		/* pid of cygwin process */
 
 /* Counts of things. */
 static int exception_count = 0;
@@ -139,9 +140,6 @@
 static int debug_exceptions = 0;	/* show target exceptions */
 static int useshell = 0;		/* use shell for subprocesses */
 
-/* Path to shell */
-static char shell[MAX_PATH + 1];
-
 /* This vector maps GDB's idea of a register's number into an address
    in the win32 exception context vector.
 
@@ -1461,6 +1459,8 @@
   char *args;
   char real_path[MAXPATHLEN];
   char *toexec;
+  char shell[MAX_PATH + 1]; /* Path to shell */
+  const char *sh;
 
   if (!exec_file)
     error ("No executable specified, use `target exec'.\n");
@@ -1468,7 +1468,7 @@
   memset (&si, 0, sizeof (si));
   si.cb = sizeof (si);
 
-  if (!useshell || !shell[0])
+  if (!useshell)
     {
       flags = DEBUG_ONLY_THIS_PROCESS;
       cygwin_conv_to_win32_path (exec_file, real_path);
@@ -1476,8 +1476,13 @@
     }
   else
     {
-      char *newallargs = alloca (sizeof (" -c 'exec  '") + strlen (exec_file)
-				 + strlen (allargs) + 2);
+      char *newallargs;
+      sh = getenv ("SHELL");
+      if (!sh)
+	sh = "/bin/sh";
+      cygwin_conv_to_win32_path (sh, shell);
+      newallargs = alloca (sizeof (" -c 'exec  '") + strlen (exec_file)
+			   + strlen (allargs) + 2);
       sprintf (newallargs, " -c 'exec %s %s'", exec_file, allargs);
       allargs = newallargs;
       toexec = shell;
@@ -1497,7 +1502,7 @@
 
   /* Prepare the environment vars for CreateProcess.  */
   {
-    /* This code use to assume all env vars were file names and would
+    /* This code used to assume all env vars were file names and would
        translate them all to win32 style.  That obviously doesn't work in the
        general case.  The current rule is that we only translate PATH.
        We need to handle PATH because we're about to call CreateProcess and
@@ -1813,27 +1818,12 @@
 _initialize_inftarg (void)
 {
   struct cmd_list_element *c;
-  const char *sh;
 
   init_child_ops ();
 
   c = add_com ("dll-symbols", class_files, dll_symbol_command,
 	       "Load dll library symbols from FILE.");
-  c->completer = filename_completer;
-
-  sh = getenv ("SHELL");
-  if (!sh)
-    sh = "/bin/sh";
-  if (access (sh, X_OK) != 0)
-    {
-      shell[0] = '\0';
-      useshell = 0;
-    }
-  else
-    {
-      cygwin_conv_to_win32_path (sh, shell);
-      useshell = 1;
-    }
+  set_cmd_completer (c, filename_completer);
 
   add_com_alias ("sharedlibrary", "dll-symbols", class_alias, 1);
 
diff --git a/gdb/x86-64-linux-nat.c b/gdb/x86-64-linux-nat.c
index 3fb24dd..fd9246c 100644
--- a/gdb/x86-64-linux-nat.c
+++ b/gdb/x86-64-linux-nat.c
@@ -33,6 +33,19 @@
 #include <sys/debugreg.h>
 #include <sys/syscall.h>
 #include <sys/procfs.h>
+#include <sys/reg.h>
+
+/* Mapping between the general-purpose registers in `struct user'
+   format and GDB's register array layout.  */
+
+static int x86_64_regmap[] = {
+  RAX, RBX, RCX, RDX,
+  RSI, RDI, RBP, RSP,
+  R8, R9, R10, R11,
+  R12, R13, R14, R15,
+  RIP, EFLAGS,
+  DS, ES, FS, GS
+};
 
 static unsigned long
 x86_64_linux_dr_get (int regnum)
@@ -74,8 +87,7 @@
   tid = PIDGET (inferior_ptid);
 
   errno = 0;
-  ptrace (PT_WRITE_U, tid,
-	  offsetof (struct user, u_debugreg[regnum]), value);
+  ptrace (PT_WRITE_U, tid, offsetof (struct user, u_debugreg[regnum]), value);
   if (errno != 0)
     perror_with_name ("Couldn't write debug register");
 }
@@ -113,11 +125,9 @@
    the register sets used by `ptrace'.  */
 
 #define GETREGS_SUPPLIES(regno) \
-  (0 <= (regno) && (regno) <= 17)
+  (0 <= (regno) && (regno) < x86_64_num_gregs)
 #define GETFPREGS_SUPPLIES(regno) \
   (FP0_REGNUM <= (regno) && (regno) <= MXCSR_REGNUM)
-
-#define PTRACE_XFER_TYPE unsigned long
 
 
 /* Transfering the general-purpose registers between GDB, inferiors
@@ -132,7 +142,7 @@
   elf_greg_t *regp = (elf_greg_t *) gregsetp;
   int i;
 
-  for (i = 0; i < X86_64_NUM_GREGS; i++)
+  for (i = 0; i < x86_64_num_gregs; i++)
     supply_register (i, (char *) (regp + x86_64_regmap[i]));
 }
 
@@ -146,9 +156,9 @@
   elf_greg_t *regp = (elf_greg_t *) gregsetp;
   int i;
 
-  for (i = 0; i < X86_64_NUM_GREGS; i++)
+  for (i = 0; i < x86_64_num_gregs; i++)
     if ((regno == -1 || regno == i))
-      read_register_gen (i, regp + x86_64_regmap[i]);
+      read_register_gen (i, (char *) (regp + x86_64_regmap[i]));
 }
 
 /* Fetch all general-purpose registers from process/thread TID and
@@ -160,7 +170,7 @@
   elf_gregset_t regs;
 
   if (ptrace (PTRACE_GETREGS, tid, 0, (long) &regs) < 0)
-      perror_with_name ("Couldn't get registers");
+    perror_with_name ("Couldn't get registers");
 
   supply_gregset (&regs);
 }
@@ -332,163 +342,7 @@
 /* Offset to saved processor registers from <asm/ucontext.h> */
 #define LINUX_UCONTEXT_SIGCONTEXT_OFFSET (36)
 
-/* Resume execution of the inferior process.
-   If STEP is nonzero, single-step it.
-   If SIGNAL is nonzero, give it that signal.  */
-
-void
-child_resume (ptid_t ptid, int step, enum target_signal signal)
-{
-  int pid = PIDGET (ptid);
-  int request = PTRACE_CONT;
-
-  if (pid == -1)
-    /* Resume all threads.  */
-    /* I think this only gets used in the non-threaded case, where "resume
-       all threads" and "resume inferior_ptid" are the same.  */
-    pid = PIDGET (inferior_ptid);
-
-  if (step)
-    {
-      CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid));
-      unsigned char buf[LINUX_SYSCALL_LEN];
-
-      request = PTRACE_SINGLESTEP;
-
-      /* Returning from a signal trampoline is done by calling a
-         special system call (sigreturn or rt_sigreturn, see
-         i386-linux-tdep.c for more information).  This system call
-         restores the registers that were saved when the signal was
-         raised, including %eflags.  That means that single-stepping
-         won't work.  Instead, we'll have to modify the signal context
-         that's about to be restored, and set the trace flag there.  */
-
-      /* First check if PC is at a system call.  */
-      if (read_memory_nobpt (pc, (char *) buf, LINUX_SYSCALL_LEN) == 0
-	  && memcmp (buf, linux_syscall, LINUX_SYSCALL_LEN) == 0)
-	{
-	  int syscall =
-	    read_register_pid (LINUX_SYSCALL_REGNUM, pid_to_ptid (pid));
-
-	  /* Then check the system call number.  */
-	  if (syscall == SYS_rt_sigreturn)
-	    {
-	      CORE_ADDR sp = read_register (SP_REGNUM);
-	      CORE_ADDR addr = sp;
-	      unsigned long int eflags;
-
-	      addr +=
-		sizeof (struct siginfo) + LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
-
-	      /* Set the trace flag in the context that's about to be
-	         restored.  */
-	      addr += LINUX_SIGCONTEXT_EFLAGS_OFFSET;
-	      read_memory (addr, (char *) &eflags, 8);
-	      eflags |= 0x0100;
-	      write_memory (addr, (char *) &eflags, 8);
-	    }
-	}
-    }
-
-  if (ptrace (request, pid, 0, target_signal_to_host (signal)) == -1)
-    perror_with_name ("ptrace");
-}
-
-
-/* Copy LEN bytes to or from inferior's memory starting at MEMADDR
-   to debugger memory starting at MYADDR.   Copy to inferior if
-   WRITE is nonzero.  TARGET is ignored.
-
-   Returns the length copied, which is either the LEN argument or zero.
-   This xfer function does not do partial moves, since child_ops
-   doesn't allow memory operations to cross below us in the target stack
-   anyway.  */
-
-int
-child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
-		   struct mem_attrib *attrib, struct target_ops *target)
-{
-  register int i;
-  /* Round starting address down to longword boundary.  */
-  register CORE_ADDR addr = memaddr & -sizeof (PTRACE_XFER_TYPE);
-  /* Round ending address up; get number of longwords that makes.  */
-  register int count
-    = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
-    / sizeof (PTRACE_XFER_TYPE);
-  /* Allocate buffer of that many longwords.  */
-  /* FIXME (alloca): This code, cloned from infptrace.c, is unsafe
-     because it uses alloca to allocate a buffer of arbitrary size.
-     For very large xfers, this could crash GDB's stack.  */
-  register PTRACE_XFER_TYPE *buffer
-    = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
-
-  if (write)
-    {
-      /* Fill start and end extra bytes of buffer with existing memory data.  */
-      if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE))
-	{
-	  /* Need part of initial word -- fetch it.  */
-	  ptrace (PT_READ_I, PIDGET (inferior_ptid),
-		  (PTRACE_ARG3_TYPE) addr, buffer);
-	}
-
-      if (count > 1)		/* FIXME, avoid if even boundary */
-	{
-	  ptrace (PT_READ_I, PIDGET (inferior_ptid),
-		  ((PTRACE_ARG3_TYPE)
-		   (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
-		  buffer + count - 1);
-	}
-
-      /* Copy data to be written over corresponding part of buffer */
-
-      memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
-	      myaddr, len);
-
-      /* Write the entire buffer.  */
-
-      for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
-	{
-	  errno = 0;
-	  ptrace (PT_WRITE_D, PIDGET (inferior_ptid),
-		  (PTRACE_ARG3_TYPE) addr, buffer[i]);
-	  if (errno)
-	    {
-	      /* Using the appropriate one (I or D) is necessary for
-	         Gould NP1, at least.  */
-	      errno = 0;
-	      ptrace (PT_WRITE_I, PIDGET (inferior_ptid),
-		      (PTRACE_ARG3_TYPE) addr, buffer[i]);
-	    }
-	  if (errno)
-	    return 0;
-	}
-#ifdef CLEAR_INSN_CACHE
-      CLEAR_INSN_CACHE ();
-#endif
-    }
-  else
-    {
-      /* Read all the longwords */
-      for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
-	{
-	  errno = 0;
-	  ptrace (PT_READ_I, PIDGET (inferior_ptid),
-		  (PTRACE_ARG3_TYPE) addr, buffer + i);
-	  if (errno)
-	    return 0;
-	}
-
-      /* Copy appropriate bytes out of the buffer.  */
-      memcpy (myaddr,
-	      (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
-	      len);
-    }
-  return len;
-}
-
 /* Interpreting register set info found in core files.  */
-
 /* Provide registers to GDB from a core file.
 
    CORE_REG_SECT points to an array of bytes, which are the contents
@@ -567,12 +421,12 @@
   CORE_ADDR fpstate;
   CORE_ADDR ubase;
   ubase = blockend;
-  if (IS_FP_REGNUM(regnum))
+  if (IS_FP_REGNUM (regnum))
     {
       fpstate = ubase + ((char *) &u.i387.st_space - (char *) &u);
       return (fpstate + 16 * (regnum - FP0_REGNUM));
     }
-  else if (IS_SSE_REGNUM(regnum))
+  else if (IS_SSE_REGNUM (regnum))
     {
       fpstate = ubase + ((char *) &u.i387.xmm_space - (char *) &u);
       return (fpstate + 16 * (regnum - XMM0_REGNUM));
@@ -586,3 +440,9 @@
 {
   add_core_fns (&linux_elf_core_fns);
 }
+
+int
+kernel_u_size (void)
+{
+  return (sizeof (struct user));
+}
diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c
index c13dd34..50b0227 100644
--- a/gdb/x86-64-tdep.c
+++ b/gdb/x86-64-tdep.c
@@ -32,44 +32,132 @@
 #include "dwarf2cfi.h"
 #include "gdb_assert.h"
 
-
 /* Register numbers of various important registers.  */
 #define RAX_REGNUM 0
-#define RDX_REGNUM 1
+#define RDX_REGNUM 3
 #define RDI_REGNUM 5
 #define EFLAGS_REGNUM 17
-#define XMM1_REGNUM  35
+#define ST0_REGNUM 22
+#define XMM1_REGNUM  39
+
+struct register_info
+{
+  int size;
+  char *name;
+  struct type **type;
+};
 
 /* x86_64_register_raw_size_table[i] is the number of bytes of storage in
    GDB's register array occupied by register i.  */
-int x86_64_register_raw_size_table[X86_64_NUM_REGS] = {
-  8, 8, 8, 8,
-  8, 8, 8, 8,
-  8, 8, 8, 8,
-  8, 8, 8, 8,
-  8, 4,
-  10, 10, 10, 10,
-  10, 10, 10, 10,
-  4, 4, 4, 4,
-  4, 4, 4, 4,
-  16, 16, 16, 16,
-  16, 16, 16, 16,
-  16, 16, 16, 16,
-  16, 16, 16, 16,
-  4
+static struct register_info x86_64_register_info_table[] = {
+  /*  0 */ {8, "rax", &builtin_type_int64},
+  /*  1 */ {8, "rbx", &builtin_type_int64},
+  /*  2 */ {8, "rcx", &builtin_type_int64},
+  /*  3 */ {8, "rdx", &builtin_type_int64},
+  /*  4 */ {8, "rsi", &builtin_type_int64},
+  /*  5 */ {8, "rdi", &builtin_type_int64},
+  /*  6 */ {8, "rbp", &builtin_type_void_func_ptr},
+  /*  7 */ {8, "rsp", &builtin_type_void_func_ptr},
+  /*  8 */ {8, "r8", &builtin_type_int64},
+  /*  9 */ {8, "r9", &builtin_type_int64},
+  /* 10 */ {8, "r10", &builtin_type_int64},
+  /* 11 */ {8, "r11", &builtin_type_int64},
+  /* 12 */ {8, "r12", &builtin_type_int64},
+  /* 13 */ {8, "r13", &builtin_type_int64},
+  /* 14 */ {8, "r14", &builtin_type_int64},
+  /* 15 */ {8, "r15", &builtin_type_int64},
+  /* 16 */ {8, "rip", &builtin_type_void_func_ptr},
+  /* 17 */ {4, "eflags", &builtin_type_int32},
+  /* 18 */ {4, "ds", &builtin_type_int32},
+  /* 19 */ {4, "es", &builtin_type_int32},
+  /* 20 */ {4, "fs", &builtin_type_int32},
+  /* 21 */ {4, "gs", &builtin_type_int32},
+  /* 22 */ {10, "st0", &builtin_type_i387_ext},
+  /* 23 */ {10, "st1", &builtin_type_i387_ext},
+  /* 24 */ {10, "st2", &builtin_type_i387_ext},
+  /* 25 */ {10, "st3", &builtin_type_i387_ext},
+  /* 26 */ {10, "st4", &builtin_type_i387_ext},
+  /* 27 */ {10, "st5", &builtin_type_i387_ext},
+  /* 28 */ {10, "st6", &builtin_type_i387_ext},
+  /* 29 */ {10, "st7", &builtin_type_i387_ext},
+  /* 30 */ {4, "fctrl", &builtin_type_int32},
+  /* 31 */ {4, "fstat", &builtin_type_int32},
+  /* 32 */ {4, "ftag", &builtin_type_int32},
+  /* 33 */ {4, "fiseg", &builtin_type_int32},
+  /* 34 */ {4, "fioff", &builtin_type_int32},
+  /* 35 */ {4, "foseg", &builtin_type_int32},
+  /* 36 */ {4, "fooff", &builtin_type_int32},
+  /* 37 */ {4, "fop", &builtin_type_int32},
+  /* 38 */ {16, "xmm0", &builtin_type_v4sf},
+  /* 39 */ {16, "xmm1", &builtin_type_v4sf},
+  /* 40 */ {16, "xmm2", &builtin_type_v4sf},
+  /* 41 */ {16, "xmm3", &builtin_type_v4sf},
+  /* 42 */ {16, "xmm4", &builtin_type_v4sf},
+  /* 43 */ {16, "xmm5", &builtin_type_v4sf},
+  /* 44 */ {16, "xmm6", &builtin_type_v4sf},
+  /* 45 */ {16, "xmm7", &builtin_type_v4sf},
+  /* 46 */ {16, "xmm8", &builtin_type_v4sf},
+  /* 47 */ {16, "xmm9", &builtin_type_v4sf},
+  /* 48 */ {16, "xmm10", &builtin_type_v4sf},
+  /* 49 */ {16, "xmm11", &builtin_type_v4sf},
+  /* 50 */ {16, "xmm12", &builtin_type_v4sf},
+  /* 51 */ {16, "xmm13", &builtin_type_v4sf},
+  /* 52 */ {16, "xmm14", &builtin_type_v4sf},
+  /* 53 */ {16, "xmm15", &builtin_type_v4sf},
+  /* 54 */ {4, "mxcsr", &builtin_type_int32}
 };
 
+/* This array is a mapping from Dwarf-2 register 
+   numbering to GDB's one. Dwarf-2 numbering is 
+   defined in x86-64 ABI, section 3.6.  */
+static int x86_64_dwarf2gdb_regno_map[] = {
+  0, 1, 2, 3,			/* RAX - RDX */
+  4, 5, 6, 7,			/* RSI, RDI, RBP, RSP */
+  8, 9, 10, 11,			/* R8 - R11 */
+  12, 13, 14, 15,		/* R12 - R15 */
+  -1,				/* RA - not mapped */
+  XMM1_REGNUM - 1, XMM1_REGNUM,	/* XMM0 ... */
+  XMM1_REGNUM + 1, XMM1_REGNUM + 2,
+  XMM1_REGNUM + 3, XMM1_REGNUM + 4,
+  XMM1_REGNUM + 5, XMM1_REGNUM + 6,
+  XMM1_REGNUM + 7, XMM1_REGNUM + 8,
+  XMM1_REGNUM + 9, XMM1_REGNUM + 10,
+  XMM1_REGNUM + 11, XMM1_REGNUM + 12,
+  XMM1_REGNUM + 13, XMM1_REGNUM + 14,	/* ... XMM15 */
+  ST0_REGNUM + 0, ST0_REGNUM + 1,	/* ST0 ... */
+  ST0_REGNUM + 2, ST0_REGNUM + 3,
+  ST0_REGNUM + 4, ST0_REGNUM + 5,
+  ST0_REGNUM + 6, ST0_REGNUM + 7	/* ... ST7 */
+};
+
+static int x86_64_dwarf2gdb_regno_map_length =
+  sizeof (x86_64_dwarf2gdb_regno_map) /
+  sizeof (x86_64_dwarf2gdb_regno_map[0]);
+
+/* Number of all registers */
+#define X86_64_NUM_REGS (sizeof (x86_64_register_info_table) / \
+  sizeof (x86_64_register_info_table[0]))
+
+/* Number of general registers.  */
+#define X86_64_NUM_GREGS (22)
+
+int x86_64_num_regs = X86_64_NUM_REGS;
+int x86_64_num_gregs = X86_64_NUM_GREGS;
+
+/* Did we already print a note about frame pointer?  */
+int omit_fp_note_printed = 0;
+
 /* Number of bytes of storage in the actual machine representation for
    register REGNO.  */
 int
 x86_64_register_raw_size (int regno)
 {
-  return x86_64_register_raw_size_table[regno];
+  return x86_64_register_info_table[regno].size;
 }
 
 /* x86_64_register_byte_table[i] is the offset into the register file of the
    start of register number i.  We initialize this from
-   x86_64_register_raw_size_table.  */
+   x86_64_register_info_table.  */
 int x86_64_register_byte_table[X86_64_NUM_REGS];
 
 /* Index within `registers' of the first byte of the space for register REGNO.  */
@@ -84,16 +172,7 @@
 static struct type *
 x86_64_register_virtual_type (int regno)
 {
-  if (regno == PC_REGNUM || regno == SP_REGNUM)
-    return builtin_type_void_func_ptr;
-  if (IS_FP_REGNUM (regno))
-    return builtin_type_i387_ext;
-  if (IS_SSE_REGNUM (regno))
-    return builtin_type_v4sf;
-  if (IS_FPU_CTRL_REGNUM (regno) || regno == MXCSR_REGNUM
-      || regno == EFLAGS_REGNUM)
-    return builtin_type_int32;
-  return builtin_type_int64;
+  return *x86_64_register_info_table[regno].type;
 }
 
 /* x86_64_register_convertible is true if register N's virtual format is
@@ -147,6 +226,19 @@
   memcpy (to, from, FPU_REG_RAW_SIZE);
 }
 
+/* Dwarf-2 <-> GDB register numbers mapping.  */
+int
+x86_64_dwarf2_reg_to_regnum (int dw_reg)
+{
+  if (dw_reg < 0 || dw_reg > x86_64_dwarf2gdb_regno_map_length)
+    {
+      warning ("Dwarf-2 uses unmapped register #%d\n", dw_reg);
+      return dw_reg;
+    }
+
+  return x86_64_dwarf2gdb_regno_map[dw_reg];
+}
+
 /* This is the variable that is set with "set disassembly-flavour", and
    its legitimate values.  */
 static const char att_flavour[] = "att";
@@ -556,20 +648,20 @@
   int ssereg = 0;
   int i;
   static int int_parameter_registers[INT_REGS] = {
-    5 /*RDI*/, 4 /*RSI*/,
-    1 /*RDX*/, 2 /*RCX*/,
-    8 /*R8 */ , 9		/*R9 */
+    5 /* RDI */ , 4 /* RSI */ ,
+    3 /* RDX */ , 2 /* RCX */ ,
+    8 /* R8  */ , 9		/* R9  */
   };
   /* XMM0 - XMM15  */
   static int sse_parameter_registers[SSE_REGS] = {
-    34, 35, 36, 37,
-    38, 39, 40, 41,
-    42, 43, 44, 45,
-    46, 47, 48, 49
+    XMM1_REGNUM - 1, XMM1_REGNUM, XMM1_REGNUM + 1, XMM1_REGNUM + 2,
+    XMM1_REGNUM + 3, XMM1_REGNUM + 4, XMM1_REGNUM + 5, XMM1_REGNUM + 6,
+    XMM1_REGNUM + 7, XMM1_REGNUM + 8, XMM1_REGNUM + 9, XMM1_REGNUM + 10,
+    XMM1_REGNUM + 11, XMM1_REGNUM + 12, XMM1_REGNUM + 13, XMM1_REGNUM + 14
   };
   int stack_values_count = 0;
   int *stack_values;
-  stack_values = alloca (naregs * sizeof (int));
+  stack_values = alloca (nargs * sizeof (int));
   for (i = 0; i < nargs; i++)
     {
       enum x86_64_reg_class class[MAX_CLASSES];
@@ -639,7 +731,7 @@
     }
   while (--stack_values_count >= 0)
     {
-      value_ptr arg = args[stack_values[stack_values_count]];
+      struct value *arg = args[stack_values[stack_values_count]];
       int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
       len += 7;
       len -= len % 8;
@@ -704,27 +796,9 @@
 static char *
 x86_64_register_name (int reg_nr)
 {
-  static char *register_names[] = {
-    "rax", "rdx", "rcx", "rbx",
-    "rsi", "rdi", "rbp", "rsp",
-    "r8", "r9", "r10", "r11",
-    "r12", "r13", "r14", "r15",
-    "rip", "eflags",
-    "st0", "st1", "st2", "st3",
-    "st4", "st5", "st6", "st7",
-    "fctrl", "fstat", "ftag", "fiseg",
-    "fioff", "foseg", "fooff", "fop",
-    "xmm0", "xmm1", "xmm2", "xmm3",
-    "xmm4", "xmm5", "xmm6", "xmm7",
-    "xmm8", "xmm9", "xmm10", "xmm11",
-    "xmm12", "xmm13", "xmm14", "xmm15",
-    "mxcsr"
-  };
-  if (reg_nr < 0)
+  if (reg_nr < 0 || reg_nr >= X86_64_NUM_REGS)
     return NULL;
-  if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
-    return NULL;
-  return register_names[reg_nr];
+  return x86_64_register_info_table[reg_nr].name;
 }
 
 
@@ -759,16 +833,75 @@
   return 0;
 }
 
-/* On x86_64 there are no reasonable prologs.  */
+/* If a function with debugging information and known beginning
+   is detected, we will return pc of the next line in the source 
+   code. With this approach we effectively skip the prolog.  */
+
+#define PROLOG_BUFSIZE 4
 CORE_ADDR
 x86_64_skip_prologue (CORE_ADDR pc)
 {
+  int i, firstline, currline;
+  struct symtab_and_line v_sal;
+  struct symbol *v_function;
+  CORE_ADDR salendaddr = 0, endaddr = 0;
+
+  /* We will handle only functions beginning with:
+     55          pushq %rbp
+     48 89 e5    movq %rsp,%rbp 
+   */
+  unsigned char prolog_expect[PROLOG_BUFSIZE] = { 0x55, 0x48, 0x89, 0xe5 },
+    prolog_buf[PROLOG_BUFSIZE];
+
+  read_memory (pc, (char *) prolog_buf, PROLOG_BUFSIZE);
+
+  /* First check, whether pc points to pushq %rbp. If not, 
+   * print a recommendation to enable frame pointer.  */
+  if (prolog_expect[0] != prolog_buf[0])
+    {
+      if (!omit_fp_note_printed)
+	{
+	  printf_filtered
+	    ("NOTE: This function doesn't seem to have a valid prologue.\n"
+	     "      Consider adding -fno-omit-frame-pointer to your gcc's CFLAGS.\n");
+	  omit_fp_note_printed++;
+	}
+      return pc;
+    }
+  /* Valid prolog continues with movq %rsp,%rbp.  */
+  for (i = 1; i < PROLOG_BUFSIZE; i++)
+    if (prolog_expect[i] != prolog_buf[i])
+      return pc + 1;		/* First instruction after pushq %rbp.  */
+
+  v_function = find_pc_function (pc);
+  v_sal = find_pc_line (pc, 0);
+
+  /* If pc doesn't point to a function with debuginfo, 
+     some of the following may be NULL.  */
+  if (!v_function || !v_function->ginfo.value.block || !v_sal.symtab)
+    return pc;
+
+  firstline = v_sal.line;
+  currline = firstline;
+  salendaddr = v_sal.end;
+  endaddr = v_function->ginfo.value.block->endaddr;
+
+  for (i = 0; i < v_sal.symtab->linetable->nitems; i++)
+    if (v_sal.symtab->linetable->item[i].line > firstline
+	&& v_sal.symtab->linetable->item[i].pc >= salendaddr
+	&& v_sal.symtab->linetable->item[i].pc < endaddr)
+      {
+	pc = v_sal.symtab->linetable->item[i].pc;
+	currline = v_sal.symtab->linetable->item[i].line;
+	break;
+      }
+
   return pc;
 }
 
 /* Sequence of bytes for breakpoint instruction.  */
 static unsigned char *
-x86_64_breakpoint_from_pc (CORE_ADDR *pc, int *lenptr)
+x86_64_breakpoint_from_pc (CORE_ADDR * pc, int *lenptr)
 {
   static unsigned char breakpoint[] = { 0xcc };
   *lenptr = 1;
@@ -776,10 +909,11 @@
 }
 
 static struct gdbarch *
-i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+x86_64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
   struct gdbarch_tdep *tdep;
+  int i, sum;
 
   /* Find a candidate among the list of pre-declared architectures. */
   for (arches = gdbarch_list_lookup_by_info (arches, &info);
@@ -801,7 +935,7 @@
 	      break;
 	    default:
 	      internal_error (__FILE__, __LINE__,
-			      "i386_gdbarch_init: unknown machine type");
+			      "x86_64_gdbarch_init: unknown machine type");
 	    }
 	  break;
 	case bfd_mach_i386_i386:
@@ -818,12 +952,12 @@
 	      return arches->gdbarch;
 	    default:
 	      internal_error (__FILE__, __LINE__,
-			      "i386_gdbarch_init: unknown machine type");
+			      "x86_64_gdbarch_init: unknown machine type");
 	    }
 	  break;
 	default:
 	  internal_error (__FILE__, __LINE__,
-			  "i386_gdbarch_init: unknown machine type");
+			  "x86_64_gdbarch_init: unknown machine type");
 	}
     }
 
@@ -843,7 +977,7 @@
       break;
     default:
       internal_error (__FILE__, __LINE__,
-		      "i386_gdbarch_init: unknown machine type");
+		      "x86_64_gdbarch_init: unknown machine type");
     }
 
   set_gdbarch_long_bit (gdbarch, 64);
@@ -858,10 +992,12 @@
   set_gdbarch_register_raw_size (gdbarch, x86_64_register_raw_size);
   set_gdbarch_max_register_raw_size (gdbarch, 16);
   set_gdbarch_register_byte (gdbarch, x86_64_register_byte);
+
   /* Total amount of space needed to store our copies of the machine's register
      (SIZEOF_GREGS + SIZEOF_FPU_REGS + SIZEOF_FPU_CTRL_REGS + SIZEOF_SSE_REGS) */
-  set_gdbarch_register_bytes (gdbarch,
-			      (18 * 8) + (8 * 10) + (8 * 4) + (16 * 16 + 4));
+  for (i = 0, sum = 0; i < X86_64_NUM_REGS; i++)
+    sum += x86_64_register_info_table[i].size;
+  set_gdbarch_register_bytes (gdbarch, sum);
   set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size);
   set_gdbarch_max_register_virtual_size (gdbarch, 16);
 
@@ -878,10 +1014,9 @@
   set_gdbarch_fp_regnum (gdbarch, 6);	/* (rbp) */
   set_gdbarch_pc_regnum (gdbarch, 16);	/* (rip) Contains program counter.  */
 
-  set_gdbarch_fp0_regnum (gdbarch, 18);	/* First FPU floating-point register.  */
+  set_gdbarch_fp0_regnum (gdbarch, X86_64_NUM_GREGS);	/* First FPU floating-point register.  */
 
   set_gdbarch_read_fp (gdbarch, cfi_read_fp);
-  set_gdbarch_write_fp (gdbarch, cfi_write_fp);
 
 /* Discard from the stack the innermost frame, restoring all registers.  */
   set_gdbarch_pop_frame (gdbarch, x86_64_pop_frame);
@@ -970,7 +1105,9 @@
 
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
-  set_gdbarch_breakpoint_from_pc (gdbarch, x86_64_breakpoint_from_pc);
+  set_gdbarch_breakpoint_from_pc (gdbarch,
+				  (gdbarch_breakpoint_from_pc_ftype *)
+				  x86_64_breakpoint_from_pc);
 
 
 /* Amount PC must be decremented by after a breakpoint.  This is often the
@@ -979,13 +1116,15 @@
 
 /* Use dwarf2 debug frame informations.  */
   set_gdbarch_dwarf2_build_frame_info (gdbarch, dwarf2_build_frame_info);
+  set_gdbarch_dwarf2_reg_to_regnum (gdbarch, x86_64_dwarf2_reg_to_regnum);
+
   return gdbarch;
 }
 
 void
 _initialize_x86_64_tdep (void)
 {
-  register_gdbarch_init (bfd_arch_i386, i386_gdbarch_init);
+  register_gdbarch_init (bfd_arch_i386, x86_64_gdbarch_init);
 
   /* Initialize the table saying where each register starts in the
      register file.  */
@@ -996,7 +1135,7 @@
     for (i = 0; i < X86_64_NUM_REGS; i++)
       {
 	x86_64_register_byte_table[i] = offset;
-	offset += x86_64_register_raw_size_table[i];
+	offset += x86_64_register_info_table[i].size;
       }
   }
 
diff --git a/gdb/x86-64-tdep.h b/gdb/x86-64-tdep.h
index d04da8b..d15b8e7 100644
--- a/gdb/x86-64-tdep.h
+++ b/gdb/x86-64-tdep.h
@@ -24,24 +24,9 @@
 #define X86_64_TDEP_H
 
 #include "i386-tdep.h"
-#include <sys/reg.h>
 
-/* Mapping between the general-purpose registers in `struct user'
-   format and GDB's register array layout.  */
-
-static int x86_64_regmap[] = {
-  RAX, RDX, RCX, RBX,
-  RSI, RDI, RBP, RSP,
-  R8, R9, R10, R11,
-  R12, R13, R14, R15,
-  RIP, EFLAGS
-};
-
-/* Number of all registers */
-#define X86_64_NUM_REGS (51)
-
-/* Number of general registers.  */
-#define X86_64_NUM_GREGS (18)
+extern int x86_64_num_regs;
+extern int x86_64_num_gregs;
 
 gdbarch_frame_saved_pc_ftype x86_64_linux_frame_saved_pc;
 gdbarch_saved_pc_after_call_ftype x86_64_linux_saved_pc_after_call;
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 965473a..d878111 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -38,6 +38,8 @@
 
 #include "coff/internal.h"
 #include "libcoff.h"		/* FIXME, internal data from BFD */
+#include "coff/xcoff.h"
+#include "libxcoff.h"
 #include "coff/rs6000.h"
 
 #include "symtab.h"
@@ -908,7 +910,7 @@
   char *strtbl = ((struct coff_symfile_info *) objfile->sym_private)->strtbl;
   char *debugsec =
   ((struct coff_symfile_info *) objfile->sym_private)->debugsec;
-  char *debugfmt = xcoff_data (abfd)->xcoff64 ? "XCOFF64" : "XCOFF";
+  char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF";
 
   struct internal_syment symbol[1];
   union internal_auxent main_aux;
@@ -1632,7 +1634,7 @@
 read_symbol_lineno (int symno)
 {
   struct objfile *objfile = this_symtab_psymtab->objfile;
-  boolean xcoff64 = xcoff_data (objfile->obfd)->xcoff64;
+  boolean xcoff64 = bfd_xcoff_is_xcoff64 (objfile->obfd);
 
   struct coff_symfile_info *info =
     (struct coff_symfile_info *)objfile->sym_private;
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 918a19e..f8c20b7 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -1,5 +1,6 @@
 /* Target-dependent code for the Sanyo Xstormy16a (LC590000) processor.
-   Copyright 2001, Free Software Foundation, Inc.
+
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -857,7 +858,7 @@
   return pc;
 }
 
-static unsigned char *
+const static unsigned char *
 xstormy16_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] = { 0x06, 0x0 };
diff --git a/gdb/z8k-tdep.c b/gdb/z8k-tdep.c
index 622cbc0..572a878 100644
--- a/gdb/z8k-tdep.c
+++ b/gdb/z8k-tdep.c
@@ -1,6 +1,7 @@
 /* Target-machine dependent code for Zilog Z8000, for GDB.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+
+   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+   2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -159,10 +160,6 @@
 CORE_ADDR
 z8k_frame_chain (struct frame_info *thisframe)
 {
-  if (thisframe->prev == 0)
-    {
-      /* This is the top of the stack, let's get the sp for real */
-    }
   if (!inside_entry_file (thisframe->pc))
     {
       return read_memory_pointer (thisframe->frame);
@@ -330,8 +327,8 @@
     {
       unsigned short l[2];
 
-      read_relative_register_raw_bytes (regno, (char *) (l + 0));
-      read_relative_register_raw_bytes (regno + 1, (char *) (l + 1));
+      frame_register_read (selected_frame, regno, (char *) (l + 0));
+      frame_register_read (selected_frame, regno + 1, (char *) (l + 1));
       printf_unfiltered ("\t");
       printf_unfiltered ("%04x%04x", l[0], l[1]);
     }
@@ -340,10 +337,10 @@
     {
       unsigned short l[4];
 
-      read_relative_register_raw_bytes (regno, (char *) (l + 0));
-      read_relative_register_raw_bytes (regno + 1, (char *) (l + 1));
-      read_relative_register_raw_bytes (regno + 2, (char *) (l + 2));
-      read_relative_register_raw_bytes (regno + 3, (char *) (l + 3));
+      frame_register_read (selected_frame, regno, (char *) (l + 0));
+      frame_register_read (selected_frame, regno + 1, (char *) (l + 1));
+      frame_register_read (selected_frame, regno + 2, (char *) (l + 2));
+      frame_register_read (selected_frame, regno + 3, (char *) (l + 3));
 
       printf_unfiltered ("\t");
       printf_unfiltered ("%04x%04x%04x%04x", l[0], l[1], l[2], l[3]);
@@ -353,7 +350,7 @@
       unsigned short rval;
       int i;
 
-      read_relative_register_raw_bytes (regno, (char *) (&rval));
+      frame_register_read (selected_frame, regno, (char *) (&rval));
 
       printf_unfiltered ("\n");
       for (i = 0; i < 10; i += 2)
diff --git a/include/ChangeLog b/include/ChangeLog
index 8ccea05..dd0a230 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,20 @@
+2002-04-16  David S. Miller  <davem@redhat.com>
+
+	* xregex2.h (__restrict_arr): Define to __restrict on GCC
+	3.1 and later.  Do not redefine.
+
+2002-04-01  Phil Edwards  <pme@gcc.gnu.org>
+
+	* dyn-string.h:  Also allow IN_GLIBCPP_V3 to redefine names.
+
+2002-03-10  Daniel Jacobowitz <drow@mvista.com>
+
+	* gdb: New directory.
+
+2002-03-06  Andrew Cagney  <ac131313@redhat.com>
+
+	* floatformat.h (floatformat_arm_ext): Delete declaration.
+
 2002-02-21  Jim Blandy  <jimb@redhat.com>
 
 	Allow the user to specify functions for allocating memory for
diff --git a/include/coff/ChangeLog b/include/coff/ChangeLog
index 79e8e18..23b0627 100644
--- a/include/coff/ChangeLog
+++ b/include/coff/ChangeLog
@@ -1,3 +1,7 @@
+2002-03-18  Tom Rix  <trix@redhat.com>
+
+	* rs6k64.h: Add U64_TOCMAGIC, AIX 5 64 bit magic number.
+
 2002-02-01  Tom Rix  <trix@redhat.com>
 
 	* xcoff.h: Conditionally support <aiaff> for pre AIX 4.3.
diff --git a/include/coff/rs6k64.h b/include/coff/rs6k64.h
index c9dd29f..47d0802 100644
--- a/include/coff/rs6k64.h
+++ b/include/coff/rs6k64.h
@@ -1,5 +1,5 @@
 /* IBM RS/6000 "XCOFF64" file definitions for BFD.
-   Copyright (C) 2000 Free Software Foundation, Inc.  
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.  
 
    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
@@ -13,40 +13,39 @@
    
    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.  
-*/
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /********************** FILE HEADER **********************/
 
-struct external_filehdr {
-	char f_magic[2];	/* magic number			*/
-	char f_nscns[2];	/* number of sections		*/
-	char f_timdat[4];	/* time & date stamp		*/
-	char f_symptr[8];/* file pointer to symtab 	*/
-	char f_opthdr[2];	/* sizeof(optional hdr)		*/
-	char f_flags[2];	/* flags			*/
-	char f_nsyms[4];	/* number of symtab entries	*/
+struct external_filehdr
+{
+  char f_magic[2];	/* magic number			*/
+  char f_nscns[2];	/* number of sections		*/
+  char f_timdat[4];	/* time & date stamp		*/
+  char f_symptr[8];	/* file pointer to symtab 	*/
+  char f_opthdr[2];	/* sizeof(optional hdr)		*/
+  char f_flags[2];	/* flags			*/
+  char f_nsyms[4];	/* number of symtab entries	*/
 };
 
-        /* IBM RS/6000 */
-#define U803XTOCMAGIC 0757	/* readonly text segments and TOC, XCOFF64 */
-
-#define BADMAG(x) ((x).f_magic != U803XTOCMAGIC)
+/* IBM RS/6000.  */
+#define U803XTOCMAGIC 0757	/* Aix 4.3 64-bit XCOFF */
+#define	U64_TOCMAGIC  0767	/* AIX 5+ 64-bit XCOFF */
+#define BADMAG(x) ((x).f_magic != U803XTOCMAGIC && (x).f_magic != U64_TOCMAGIC)
 
 #define	FILHDR	struct external_filehdr
 #define	FILHSZ	24
 
 /********************** AOUT "OPTIONAL HEADER" **********************/
 
-
 typedef struct 
 {
   unsigned char	magic[2];		/* type of file			*/
   unsigned char	vstamp[2];		/* version stamp		*/
   unsigned char	o_debugger[4];		/* reserved 			*/
-  unsigned char	text_start[8];	/* base of text used for this file */
-  unsigned char	data_start[8];	/* base of data used for this file */
-  unsigned char	o_toc[8];	/* address of TOC */
+  unsigned char	text_start[8];		/* base of text used for this file */
+  unsigned char	data_start[8];		/* base of data used for this file */
+  unsigned char	o_toc[8];		/* address of TOC */
   unsigned char	o_snentry[2];		/* section number of entry point */
   unsigned char	o_sntext[2];		/* section number of .text section */
   unsigned char	o_sndata[2];		/* section number of .data section */
@@ -62,8 +61,8 @@
   unsigned char	dsize[8];		/* initialized data "  "	*/
   unsigned char	bsize[8];		/* uninitialized data "   "	*/
   unsigned char	entry[8];		/* entry pt.			*/
-  unsigned char	o_maxstack[8];	/* max stack size (??) 		*/
-  unsigned char o_maxdata[8];	/* max data size (??) 		*/
+  unsigned char	o_maxstack[8];		/* max stack size (??) 		*/
+  unsigned char o_maxdata[8];		/* max data size (??) 		*/
   unsigned char	o_resv3[16];		/* reserved 			*/
 }
 AOUTHDR;
@@ -74,22 +73,21 @@
 
 /********************** SECTION HEADER **********************/
 
-
-struct external_scnhdr {
-	char	s_name[8];		/* section name			*/
-	char	s_paddr[8];	/* physical address, aliased s_nlib */
-	char	s_vaddr[8];	/* virtual address		*/
-	char	s_size[8];	/* section size			*/
-	char	s_scnptr[8];	/* file ptr to raw data for section */
-	char	s_relptr[8];	/* file ptr to relocation	*/
-	char	s_lnnoptr[8];	/* file ptr to line numbers	*/
-	char	s_nreloc[4];	/* number of relocation entries	*/
-	char	s_nlnno[4];	/* number of line number entries*/
-	char	s_flags[4];		/* flags			*/
-	char    s_pad[4];		/* padding */  
+struct external_scnhdr
+{
+  char	s_name[8];	/* section name			*/
+  char	s_paddr[8];	/* physical address, aliased s_nlib */
+  char	s_vaddr[8];	/* virtual address		*/
+  char	s_size[8];	/* section size			*/
+  char	s_scnptr[8];	/* file ptr to raw data for section */
+  char	s_relptr[8];	/* file ptr to relocation	*/
+  char	s_lnnoptr[8];	/* file ptr to line numbers	*/
+  char	s_nreloc[4];	/* number of relocation entries	*/
+  char	s_nlnno[4];	/* number of line number entries*/
+  char	s_flags[4];	/* flags			*/
+  char  s_pad[4];	/* padding */  
 };
 
-
 #define	SCNHDR	struct external_scnhdr
 
 #define	SCNHSZ	72
@@ -97,24 +95,25 @@
 /********************** LINE NUMBERS **********************/
 
 /* 1 line number entry for every "breakpointable" source line in a section.
- * Line numbers are grouped on a per function basis; first entry in a function
- * grouping will have l_lnno = 0 and in place of physical address will be the
- * symbol table index of the function name.
- */
-struct external_lineno {
-	union {
-		char l_symndx[4];/* function name symbol index, iff l_lnno == 0*/
-		char l_paddr[8];	/* (physical) address of line number	*/
-	} l_addr;
-	char l_lnno[4];		/* line number		*/
-};
+   Line numbers are grouped on a per function basis; first entry in a function
+   grouping will have l_lnno = 0 and in place of physical address will be the
+   symbol table index of the function name.  */
 
+struct external_lineno
+{
+  union
+  {
+    char l_symndx[4];	/* function name symbol index, iff l_lnno == 0*/
+    char l_paddr[8];	/* (physical) address of line number	*/
+  } l_addr;
+
+  char l_lnno[4];	/* line number		*/
+};
 
 #define	LINENO	struct external_lineno
 
 #define	LINESZ	12
 
-
 /********************** SYMBOLS **********************/
 
 #define E_SYMNMLEN	8	/* # characters in a symbol name	*/
@@ -131,16 +130,13 @@
   char e_numaux[1];
 };
 
-
-
 #define N_BTMASK	(017)
 #define N_TMASK		(060)
 #define N_BTSHFT	(4)
 #define N_TSHIFT	(2)
-  
 
-union external_auxent {
-
+union external_auxent
+{
     struct {
     	union {
 	    struct {
@@ -196,26 +192,23 @@
 #define DBXMASK 0x80		/* for dbx storage mask */
 #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
 
-/* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h */
+/* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h.  */
 #define _AUX_EXCEPT     255
 #define _AUX_FCN        254
 #define _AUX_SYM        253
 #define _AUX_FILE       252
 #define _AUX_CSECT      251
 
-
-
 /********************** RELOCATION DIRECTIVES **********************/
 
-
-struct external_reloc {
+struct external_reloc
+{
   char r_vaddr[8];
   char r_symndx[4];
   char r_size[1];
   char r_type[1];
 };
 
-
 #define RELOC struct external_reloc
 #define RELSZ 14
 
diff --git a/include/dyn-string.h b/include/dyn-string.h
index 315f63f..2a771c7 100644
--- a/include/dyn-string.h
+++ b/include/dyn-string.h
@@ -1,5 +1,5 @@
 /* An abstract string datatype.
-   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
 This file is part of GCC.
@@ -45,7 +45,7 @@
    names in user programs, the functions that are used in the
    demangler are given implementation-reserved names.  */
 
-#ifdef IN_LIBGCC2
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
 
 #define dyn_string_init                 __cxa_dyn_string_init
 #define dyn_string_new                  __cxa_dyn_string_new
@@ -66,7 +66,7 @@
 #define dyn_string_substring            __cxa_dyn_string_substring
 #define dyn_string_eq                   __cxa_dyn_string_eq
 
-#endif /* IN_LIBGCC2 */
+#endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */
 
 
 extern int dyn_string_init              PARAMS ((struct dyn_string *, int));
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index e70f7fd..c225793 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,7 @@
+2002-04-24  Elena Zannoni  <ezannoni@redhat.com>
+
+	* dwarf2.h: Add DW_AT_GNU_vector.
+
 2002-02-13  Matt Fredette  <fredette@netbsd.org>
 
 	* m68k.h (EF_M68000): Define.
diff --git a/include/elf/dwarf2.h b/include/elf/dwarf2.h
index 53eb655..750a720 100644
--- a/include/elf/dwarf2.h
+++ b/include/elf/dwarf2.h
@@ -328,6 +328,7 @@
     DW_AT_src_coords = 0x2104,
     DW_AT_body_begin = 0x2105,
     DW_AT_body_end   = 0x2106,
+    DW_AT_GNU_vector = 0x2107,
     /* VMS Extensions.  */
     DW_AT_VMS_rtnbeg_pd_address = 0x2201
   };
diff --git a/include/floatformat.h b/include/floatformat.h
index 0cd09be..53ead3e 100644
--- a/include/floatformat.h
+++ b/include/floatformat.h
@@ -96,7 +96,6 @@
 extern const struct floatformat floatformat_i960_ext;
 extern const struct floatformat floatformat_m88110_ext;
 extern const struct floatformat floatformat_m88110_harris_ext;
-extern const struct floatformat floatformat_arm_ext; /* deprecated. */
 extern const struct floatformat floatformat_arm_ext_big;
 extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
 /* IA-64 Floating Point register spilt into memory.  */
diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog
index 8d63771..2882ce5 100644
--- a/include/opcode/ChangeLog
+++ b/include/opcode/ChangeLog
@@ -1,3 +1,19 @@
+2002-04-11  Alan Modra  <amodra@bigpond.net.au>
+
+	* i386.h: Add intel mode cmpsd and movsd.
+	Put them before SSE2 insns, so that rep prefix works.
+
+2002-03-15  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* mips.h (INSN_MIPS3D): New definition used to mark MIPS-3D
+	instructions.
+	(OPCODE_IS_MEMBER): Adjust comments to indicate that ASE bit masks
+	may be passed along with the ISA bitmask.
+
+2002-03-05  Paul Koning  <pkoning@equallogic.com>
+
+	* pdp11.h: Add format codes for float instruction formats.
+
 2002-02-25  Alan Modra  <amodra@bigpond.net.au>
 
 	* ppc.h (PPC_OPCODE_POWER4, PPC_OPCODE_NOPOWER4): Define.
diff --git a/include/opcode/i386.h b/include/opcode/i386.h
index 43d7208..0171f62 100644
--- a/include/opcode/i386.h
+++ b/include/opcode/i386.h
@@ -1231,6 +1231,9 @@
 {"cmpunordpd",2, 0x660fc2,  3, CpuSSE2, FP|Modrm|ImmExt,{ RegXMM|LLongMem, RegXMM, 0 } },
 {"cmpunordsd",2, 0xf20fc2,  3, CpuSSE2, FP|Modrm|ImmExt,{ RegXMM|LongMem, RegXMM, 0 } },
 {"cmppd",     3, 0x660fc2,  X, CpuSSE2, FP|Modrm,	{ Imm8, RegXMM|LLongMem, RegXMM } },
+/* Intel mode string compare.  */
+{"cmpsd",     0, 0xa7,      X, 0, NoSuf|Size32|IsString, { 0, 0, 0} },
+{"cmpsd",     2, 0xa7,      X, 0, NoSuf|Size32|IsString, { AnyMem, AnyMem|EsSeg, 0} },
 {"cmpsd",     3, 0xf20fc2,  X, CpuSSE2, FP|Modrm,	{ Imm8, RegXMM|LongMem, RegXMM } },
 {"comisd",    2, 0x660f2f,  X, CpuSSE2, FP|Modrm,	{ RegXMM|LongMem, RegXMM, 0 } },
 {"cvtpi2pd",  2, 0x660f2a,  X, CpuSSE2, FP|Modrm,	{ RegMMX|LLongMem, RegXMM, 0 } },
@@ -1249,6 +1252,9 @@
 {"movlpd",    2, 0x660f13,  X, CpuSSE2, FP|Modrm,	{ RegXMM, LLongMem, 0 } },
 {"movmskpd",  2, 0x660f50,  X, CpuSSE2, lq_Suf|IgnoreSize|Modrm, { RegXMM|InvMem, Reg32|Reg64, 0 } },
 {"movntpd",   2, 0x660f2b,  X, CpuSSE2, FP|Modrm, 	{ RegXMM, LLongMem, 0 } },
+/* Intel mode string move.  */
+{"movsd",     0, 0xa5,      X, 0, NoSuf|Size32|IsString, { 0, 0, 0} },
+{"movsd",     2, 0xa5,      X, 0, NoSuf|Size32|IsString, { AnyMem, AnyMem|EsSeg, 0} },
 {"movsd",     2, 0xf20f10,  X, CpuSSE2, FP|Modrm,	{ RegXMM|LongMem, RegXMM, 0 } },
 {"movsd",     2, 0xf20f11,  X, CpuSSE2, FP|Modrm,	{ RegXMM, RegXMM|LongMem, 0 } },
 {"movupd",    2, 0x660f10,  X, CpuSSE2, FP|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
diff --git a/include/opcode/mips.h b/include/opcode/mips.h
index 1469e10..96c7a57 100644
--- a/include/opcode/mips.h
+++ b/include/opcode/mips.h
@@ -316,6 +316,11 @@
 #define INSN_ISA32                0x00000200
 #define INSN_ISA64                0x00000400
 
+/* Masks used for MIPS-defined ASEs.  */
+
+/* MIPS-3D ASE */
+#define INSN_MIPS3D               0x00004000
+
 /* Chip specific instructions.  These are bitmasks.  */
 
 /* MIPS R4650 instruction.  */
@@ -367,10 +372,10 @@
 #define CPU_MIPS64      64
 #define CPU_SB1         12310201        /* octal 'SB', 01.  */
 
-/* Test for membership in an ISA including chip specific ISAs.
-   INSN is pointer to an element of the opcode table; ISA is the
-   specified ISA to test against; and CPU is the CPU specific ISA
-   to test, or zero if no CPU specific ISA test is desired.  */
+/* Test for membership in an ISA including chip specific ISAs.  INSN
+   is pointer to an element of the opcode table; ISA is the specified
+   ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
+   test, or zero if no CPU specific ISA test is desired.  */
 
 #define OPCODE_IS_MEMBER(insn, isa, cpu)				\
     (((insn)->membership & isa) != 0					\
diff --git a/include/opcode/pdp11.h b/include/opcode/pdp11.h
index 3cd7123..228c221 100644
--- a/include/opcode/pdp11.h
+++ b/include/opcode/pdp11.h
@@ -1,5 +1,5 @@
 /* PDP-11 opcde list.
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GDB and GAS.
 
@@ -27,7 +27,7 @@
 #define PDP11_OPCODE_REG_OP	 3	/* register and generic operand */
 #define PDP11_OPCODE_REG_OP_REV	 4	/* register and generic operand,
 					   reversed syntax */
-#define PDP11_OPCODE_AC_OP	 5	/* fpu accumulator and generic
+#define PDP11_OPCODE_AC_FOP	 5	/* fpu accumulator and generic float
 					   operand */
 #define PDP11_OPCODE_OP_OP	 6	/* two generic operands */
 #define PDP11_OPCODE_DISPL	 7	/* pc-relative displacement */
@@ -37,6 +37,13 @@
 #define PDP11_OPCODE_IMM6	10	/* 6-bit immediate */
 #define PDP11_OPCODE_IMM3	11	/* 3-bit immediate */
 #define PDP11_OPCODE_ILLEGAL	12	/* illegal instruction */
+#define PDP11_OPCODE_FOP_AC	13	/* generic float argument, then fpu
+					   accumulator */
+#define PDP11_OPCODE_FOP	14	/* generic float operand */
+#define PDP11_OPCODE_AC_OP	15	/* fpu accumulator and generic int
+					   operand */
+#define PDP11_OPCODE_OP_AC	16	/* generic int argument, then fpu
+					   accumulator */
 
 /*
  * PDP-11 instruction set extensions.
diff --git a/include/xregex2.h b/include/xregex2.h
index b9c2d97..2991daf 100644
--- a/include/xregex2.h
+++ b/include/xregex2.h
@@ -529,10 +529,16 @@
 #  endif
 # endif
 #endif
-/* For now unconditionally define __restrict_arr to expand to nothing.
-   Ideally we would have a test for the compiler which allows defining
-   it to restrict.  */
-#define __restrict_arr
+
+/* GCC 3.1 and later support declaring arrays as non-overlapping
+   using the syntax array_name[restrict]  */
+#ifndef __restrict_arr
+# if ! (3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) || defined (__GNUG__)
+#  define __restrict_arr
+# else
+#  define __restrict_arr __restrict
+# endif
+#endif
 
 /* POSIX compatibility.  */
 extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
diff --git a/intl/ChangeLog b/intl/ChangeLog
index 996df73..44d88e4 100644
--- a/intl/ChangeLog
+++ b/intl/ChangeLog
@@ -1,12 +1,3 @@
-2002-03-08  Daniel Jacobowitz  <drow@mvista.com>
-
-	* Makefile.in (distclean): Remove config.h.
-
-2002-03-08  Daniel Jacobowitz  <drow@mvista.com>
-
-	* Makefile.in (distclean): Remove config.cache, stamp-h, and
-	config.status.
-
 2002-01-21  Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
 
 	* linux-msg.sed: Comment typo fix.
diff --git a/intl/Makefile.in b/intl/Makefile.in
index b7e7898..09647de 100644
--- a/intl/Makefile.in
+++ b/intl/Makefile.in
@@ -173,7 +173,6 @@
 
 distclean: clean
 	rm -f Makefile ID TAGS po2msg.sed po2tbl.sed libintl.h config.log
-	rm -f config.cache stamp-h config.status config.h
 
 maintainer-clean: distclean
 	@echo "This command is intended for maintainers to use;"
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index e46c711..63efe6e 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,77 @@
+2002-04-09  Richard Henderson  <rth@redhat.com>
+
+	* hashtab.c (higher_prime_number): Use 7 as minimum.
+	(find_empty_slot_for_expand): Don't compute hash2 unless needed.
+	(htab_find_slot_with_hash): Likewise.
+
+2002-04-01  Phil Edwards  <pme@gcc.gnu.org>
+
+	* cp-demangle.c (__cxa_demangle):  Also protect with IN_GLIBCPP_V3.
+	(is_gnu_v3_mangled_ctor, is_gnu_v3_mangled_ctor):  Conditionally
+	not compile if IN_GLIBCPP_V3 defined.
+	* dyn-string.c:  Also allow IN_GLIBCPP_V3 to change allocation scheme.
+
+2002-03-30  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
+
+	* cp-demangle.c (java_demangle_v3): Don't try to release "demangled"
+	if it is NULL.
+
+2002-03-27  DJ Delorie  <dj@redhat.com>
+
+	* hex.c: Add documentation.
+	(_hex_value): Provide non-ASCII empty table.
+	(hex_init): Initialize the non-ASCII table.
+	* functions.texi: Regenerate.
+
+2002-03-27  Mark Mitchell  <mark@codesourcery.com>
+
+	* dyn-string.c: Add libgcc exception to copyright notice.
+
+2002-03-26  H.J. Lu  (hjl@gnu.org)
+
+	* config.table: Support --with-build-subdir.
+	* configure.in: Likewise.
+	* configure: Rebuild.
+
+2002-03-18  Stuart Griffith  <Stuart_Griffith@credence.com>
+
+	* strtod.c (strtod): Increment 8 chars, not 7, when `infinity'
+	seen.
+
+2002-03-12  Mark Mitchell  <mark@codesourcery.com>
+
+	* cp-demangle.c: Add libgcc exception to cp-demangle.c copyright
+	notice.
+
+2002-03-11  Douglas B Rupp  <rupp@gnat.com>
+
+	* xatexit.c [VMS]: Include stdlib.h and unixlib.h.
+
+2002-03-06  Jim Blandy  <jimb@redhat.com>
+
+	* splay-tree.c (splay_tree_xmalloc_allocate,
+	splay_tree_xmalloc_deallocate): Use K&R-style definitions, not
+	prototyped definitions.  Mark `data' arguments as unused.
+
+2002-03-06  Andrew Cagney  <ac131313@redhat.com>
+
+	* floatformat.c (floatformat_arm_ext_big): Delete definition.
+
+2002-03-04  Phil Edwards  <pme@gcc.gnu.org>
+
+	* configure.in:  Add --enable-install-libiberty option.
+	* Makefile.in (INSTALLED_HEADERS):  New variable.
+	(install_to_libdir):  Possibly also copy headers.
+	* configure:  Regenerated.
+
+2002-03-04  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+	* xmalloc.c (xmalloc_fail): Clarify error message further.
+
+2002-03-03  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+	* xmalloc.c (xmalloc_fail): Clarify error message.
+
 2002-02-21  Jim Blandy  <jimb@redhat.com>
 
 	* splay-tree.c (splay_tree_xmalloc_allocate,
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 5fa9630..3dccfad 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -1,6 +1,6 @@
 #
 # Makefile
-#   Copyright (C) 1990, 91-99, 2000, 2001
+#   Copyright (C) 1990, 91-99, 2000, 2001, 2002
 #   Free Software Foundation
 #
 # This file is part of the libiberty library.
@@ -34,6 +34,8 @@
 exec_prefix = @exec_prefix@
 bindir = @bindir@
 libdir = @libdir@
+includedir = @includedir@
+target_header_dir = @target_header_dir@
 
 SHELL = @SHELL@
 
@@ -48,6 +50,7 @@
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+mkinstalldirs = $(SHELL) $(srcdir)/../mkinstalldirs
 
 AR = @AR@
 AR_FLAGS = rc
@@ -181,6 +184,22 @@
 	vasprintf.o vfork.o vfprintf.o vprintf.o vsprintf.o		\
 	waitpid.o
 
+# These files are installed if the library has been configured to do so.
+INSTALLED_HEADERS =                                                     \
+	$(INCDIR)/ansidecl.h                                            \
+	$(INCDIR)/demangle.h                                            \
+	$(INCDIR)/dyn-string.h                                          \
+	$(INCDIR)/fibheap.h                                             \
+	$(INCDIR)/floatformat.h                                         \
+	$(INCDIR)/hashtab.h                                             \
+	$(INCDIR)/libiberty.h                                           \
+	$(INCDIR)/objalloc.h                                            \
+	$(INCDIR)/partition.h                                           \
+	$(INCDIR)/safe-ctype.h                                          \
+	$(INCDIR)/sort.h                                                \
+	$(INCDIR)/splay-tree.h                                          \
+	$(INCDIR)/ternary.h
+
 $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
 	-rm -f $(TARGETLIB) pic/$(TARGETLIB)
 	$(AR) $(AR_FLAGS) $(TARGETLIB) \
@@ -240,6 +259,16 @@
 	$(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB)n
 	( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB)n )
 	mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB)n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
+	if test -n "${target_header_dir}"; then \
+	  case "${target_header_dir}" in \
+	    /*)    thd=${target_header_dir};; \
+	    *)     thd=${includedir}${MULTISUBDIR}/${target_header_dir};; \
+	  esac; \
+	  ${mkinstalldirs} $${thd}; \
+	  for h in ${INSTALLED_HEADERS}; do \
+	    ${INSTALL_DATA} $$h $${thd}; \
+	  done; \
+	fi
 	@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
 
 install_to_tooldir: all
diff --git a/libiberty/config.table b/libiberty/config.table
index fa892c0..6118a9c 100644
--- a/libiberty/config.table
+++ b/libiberty/config.table
@@ -1,3 +1,9 @@
+# Don't build the shared library for build.
+if [ -n "${with_build_subdir}" ]; then
+  enable_shared=no
+fi
+
+frag=
 case "${host}" in
   rs6000-ibm-aix3.1 | rs6000-ibm-aix)
                         frag=mh-aix ;;
@@ -8,7 +14,11 @@
   i[345]86-*-windows*)	frag=mh-windows ;;
 esac
 
-frags=$frag
+if [ -n "${frag}" ]; then
+  frags=${libiberty_topdir}/libiberty/config/$frag
+else
+  frags=
+fi
 
 # If they didn't specify --enable-shared, don't generate shared libs.
 case "${enable_shared}" in
@@ -18,31 +28,26 @@
   *) shared=yes ;;
 esac
 if [ "${shared}" = "yes" ]; then
+  frag=
   case "${host}" in
     *-*-cygwin*)	;;
-    alpha*-*-linux*)	frags="${frags} ../../config/mh-elfalphapic" ;;
-    arm*-*-*)		frags="${frags} ../../config/mh-armpic" ;;
-    hppa*-*-*)		frags="${frags} ../../config/mh-papic" ;;
-    i[3456]86-*-*)	frags="${frags} ../../config/mh-x86pic" ;;
+    alpha*-*-linux*)	frag=mh-elfalphapic ;;
+    arm*-*-*)		frag=mh-armpic ;;
+    hppa*-*-*)		frag=mh-papic ;;
+    i[3456]86-*-*)	frag=mh-x86pic ;;
     powerpc*-*-aix*)	;;
-    powerpc*-*-*)	frags="${frags} ../../config/mh-ppcpic" ;;
-    sparc*-*-*)		frags="${frags} ../../config/mh-sparcpic" ;;
-    *-*-*)		frags="${frags} ../../config/mh-${host_cpu}pic" ;;
+    powerpc*-*-*)	frag=mh-ppcpic ;;
+    sparc*-*-*)		frag=mh-sparcpic ;;
+    *)			frag=mh-${host_cpu}pic ;;
   esac
+  if [ -n "${frag}" ]; then
+    frags="${frags} ${libiberty_topdir}/config/${frag}"
+  fi
 fi
 
 echo "# Warning: this fragment is automatically generated" > temp-frag
 
 for frag in ${frags}; do
-  case ${frag} in
-    ../* )
-      if [ ${srcdir} = . ]; then
-	[ -n "${with_target_subdir}" ] && frag=../${frag}
-	[ -n "${with_multisrctop}" ] && frag=${with_multisrctop}${frag}
-      fi
-      ;;
-  esac
-  frag=${srcdir}/${xsrcdir}config/$frag
   if [ -f ${frag} ]; then
     echo "Appending ${frag} to xhost-mkfrag"
     echo "# Following fragment copied from ${frag}" >> temp-frag
diff --git a/libiberty/configure b/libiberty/configure
index 84c10ad..cbbec35 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -12,7 +12,9 @@
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
-  --with-target-subdir=SUBDIR      Configuring in a subdirectory"
+  --with-target-subdir=SUBDIR      Configuring in a subdirectory for target"
+ac_help="$ac_help
+  --with-build-subdir=SUBDIR       Configuring in a subdirectory for build"
 ac_help="$ac_help
   --with-cross-host=HOST           Configuring with a cross compiler"
 ac_help="$ac_help
@@ -21,6 +23,8 @@
   --enable-maintainer-mode
                           enable make rules and dependencies not useful
                           (and sometimes confusing) to the casual installer"
+ac_help="$ac_help
+  --enable-install-libiberty       Install headers for end users"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -538,6 +542,12 @@
   :
 fi
 
+# Check whether --with-build-subdir or --without-build-subdir was given.
+if test "${with_build_subdir+set}" = set; then
+  withval="$with_build_subdir"
+  :
+fi
+
 # Check whether --with-cross-host or --without-cross-host was given.
 if test "${with_cross_host+set}" = set; then
   withval="$with_cross_host"
@@ -552,7 +562,10 @@
 
 
 if test "${srcdir}" = "."; then
-  if test -z "${with_target_subdir}"; then
+  if test -n "${with_build_subdir}"; then
+    libiberty_topdir="${srcdir}/../.."
+    with_target_subdir=
+  elif test -z "${with_target_subdir}"; then
     libiberty_topdir="${srcdir}/.."
   else
     if test "${with_target_subdir}" != "."; then
@@ -586,7 +599,7 @@
 
 
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:590: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:603: checking whether to enable maintainer-specific portions of Makefiles" >&5
     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
@@ -611,7 +624,7 @@
 # Extract the first word of "makeinfo", so it can be a program name with args.
 set dummy makeinfo; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:615: checking for $ac_word" >&5
+echo "configure:628: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -657,7 +670,7 @@
 # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:661: checking for $ac_word" >&5
+echo "configure:674: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -697,7 +710,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:701: checking host system type" >&5
+echo "configure:714: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -720,7 +733,7 @@
 
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:724: checking build system type" >&5
+echo "configure:737: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -746,7 +759,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:750: checking for $ac_word" >&5
+echo "configure:763: 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
@@ -778,7 +791,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:782: checking for $ac_word" >&5
+echo "configure:795: 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
@@ -810,7 +823,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:814: checking for $ac_word" >&5
+echo "configure:827: 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
@@ -847,7 +860,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:851: checking for $ac_word" >&5
+echo "configure:864: 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
@@ -877,7 +890,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:881: checking for $ac_word" >&5
+echo "configure:894: 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
@@ -926,7 +939,7 @@
 fi
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:930: checking whether we are using GNU C" >&5
+echo "configure:943: 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
@@ -935,7 +948,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:939: \"$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:952: \"$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
@@ -951,7 +964,7 @@
   ac_save_CFLAGS="$CFLAGS"
   CFLAGS=
   echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:955: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:968: 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
@@ -982,7 +995,7 @@
 
 
 echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:986: checking for POSIXized ISC" >&5
+echo "configure:999: 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
@@ -1003,12 +1016,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1007: checking for working const" >&5
+echo "configure:1020: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1012 "configure"
+#line 1025 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1057,7 +1070,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1061: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1074: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1078,21 +1091,21 @@
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1082: checking for inline" >&5
+echo "configure:1095: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 1089 "configure"
+#line 1102 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:1096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1109: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -1135,7 +1148,7 @@
 # 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:1139: checking for a BSD compatible install" >&5
+echo "configure:1152: 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
@@ -1196,7 +1209,7 @@
 # able to link anything, it had better be able to at least compile
 # something.
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1200: checking how to run the C preprocessor" >&5
+echo "configure:1213: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1211,13 +1224,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1215 "configure"
+#line 1228 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1228,13 +1241,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1232 "configure"
+#line 1245 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1251: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1245,13 +1258,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1249 "configure"
+#line 1262 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1268: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1279,17 +1292,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1283: checking for $ac_hdr" >&5
+echo "configure:1296: 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
-#line 1288 "configure"
+#line 1301 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1293: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1316,12 +1329,12 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1320: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1333: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1325 "configure"
+#line 1338 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -1337,7 +1350,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:1341: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1354: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -1358,12 +1371,12 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1362: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1375: 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 <<EOF
-#line 1367 "configure"
+#line 1380 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1372,7 +1385,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:1376: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1389: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -1394,19 +1407,19 @@
 
 
 echo $ac_n "checking whether errno must be declared""... $ac_c" 1>&6
-echo "configure:1398: checking whether errno must be declared" >&5
+echo "configure:1411: checking whether errno must be declared" >&5
 if eval "test \"`echo '$''{'libiberty_cv_declare_errno'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1403 "configure"
+#line 1416 "configure"
 #include "confdefs.h"
 #include <errno.h>
 int main() {
 int x = errno;
 ; return 0; }
 EOF
-if { (eval echo configure:1410: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1423: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   libiberty_cv_declare_errno=no
 else
@@ -1428,12 +1441,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1432: checking for ANSI C header files" >&5
+echo "configure:1445: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1437 "configure"
+#line 1450 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1441,7 +1454,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1458: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1458,7 +1471,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1462 "configure"
+#line 1475 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1476,7 +1489,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1480 "configure"
+#line 1493 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1497,7 +1510,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1501 "configure"
+#line 1514 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1508,7 +1521,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:1512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1532,12 +1545,12 @@
 fi
 
 echo $ac_n "checking for uintptr_t""... $ac_c" 1>&6
-echo "configure:1536: checking for uintptr_t" >&5
+echo "configure:1549: checking for uintptr_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uintptr_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1541 "configure"
+#line 1554 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1630,12 +1643,12 @@
   for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1634: checking for $ac_func" >&5
+echo "configure:1647: 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 <<EOF
-#line 1639 "configure"
+#line 1652 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1658,7 +1671,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1685,12 +1698,12 @@
   for ac_func in getcwd getpagesize index insque mkstemps memchr memcmp memcpy
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1689: checking for $ac_func" >&5
+echo "configure:1702: 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 <<EOF
-#line 1694 "configure"
+#line 1707 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1713,7 +1726,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1740,12 +1753,12 @@
   for ac_func in memmove memset putenv random rename rindex sigsetmask
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1744: checking for $ac_func" >&5
+echo "configure:1757: 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 <<EOF
-#line 1749 "configure"
+#line 1762 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1768,7 +1781,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1795,12 +1808,12 @@
   for ac_func in strcasecmp setenv strchr strdup strncasecmp strrchr strstr
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1799: checking for $ac_func" >&5
+echo "configure:1812: 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 <<EOF
-#line 1804 "configure"
+#line 1817 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1823,7 +1836,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1850,12 +1863,12 @@
   for ac_func in strtod strtol strtoul tmpnam vasprintf vfprintf vprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1854: checking for $ac_func" >&5
+echo "configure:1867: 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 <<EOF
-#line 1859 "configure"
+#line 1872 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1878,7 +1891,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1905,12 +1918,12 @@
   for ac_func in vsprintf waitpid getrusage on_exit psignal strerror strsignal
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1909: checking for $ac_func" >&5
+echo "configure:1922: 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 <<EOF
-#line 1914 "configure"
+#line 1927 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1933,7 +1946,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1960,12 +1973,12 @@
   for ac_func in sysconf times sbrk gettimeofday ffs
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1964: checking for $ac_func" >&5
+echo "configure:1977: 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 <<EOF
-#line 1969 "configure"
+#line 1982 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1988,7 +2001,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2032,6 +2045,7 @@
 
 setobjs=
 CHECK=
+target_header_dir=
 if test -n "${with_target_subdir}"; then
 
   # We are being configured as a target library.  AC_REPLACE_FUNCS
@@ -2072,6 +2086,30 @@
 
   fi
 
+  # We may wish to install the target headers somewhere.
+  # Check whether --enable-install-libiberty or --disable-install-libiberty was given.
+if test "${enable_install_libiberty+set}" = set; then
+  enableval="$enable_install_libiberty"
+  enable_install_libiberty=$enableval
+else
+  enable_install_libiberty=no
+fi
+  
+  # Option parsed, now set things appropriately.
+  case x"$enable_install_libiberty" in
+    xyes|x)
+      target_header_dir=libiberty
+      ;;
+    xno)   
+      target_header_dir=
+      ;;
+    *) 
+      # This could be sanity-checked in various ways...
+      target_header_dir="${enable_install_libiberty}"
+      ;;
+  esac
+
+
 else
 
    # Not a target library, so we set things up to run the test suite.
@@ -2081,6 +2119,7 @@
 
 
 
+
 case "${host}" in
   *-*-cygwin* | *-*-mingw*)
     cat >> confdefs.h <<\EOF
@@ -2192,7 +2231,7 @@
   # We haven't set the list of objects yet.  Use the standard autoconf
   # tests.  This will only work if the compiler works.
   echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2196: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2235: 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.
@@ -2203,12 +2242,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 2207 "configure"
+#line 2246 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; 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
@@ -2234,19 +2273,19 @@
   { 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:2238: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2277: 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
 
   for ac_func in $funcs
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2245: checking for $ac_func" >&5
+echo "configure:2284: 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 <<EOF
-#line 2250 "configure"
+#line 2289 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2269,7 +2308,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2296,12 +2335,12 @@
 
 
   echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:2300: checking whether alloca needs Cray hooks" >&5
+echo "configure:2339: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2305 "configure"
+#line 2344 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -2326,12 +2365,12 @@
 if test $ac_cv_os_cray = yes; then
   for ac_func in _getb67 GETB67 getb67; do
     echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2330: checking for $ac_func" >&5
+echo "configure:2369: 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 <<EOF
-#line 2335 "configure"
+#line 2374 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2354,7 +2393,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2380,7 +2419,7 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:2384: checking stack direction for C alloca" >&5
+echo "configure:2423: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2388,7 +2427,7 @@
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 2392 "configure"
+#line 2431 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -2407,7 +2446,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -2428,12 +2467,12 @@
 
 
   echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2432: checking for pid_t" >&5
+echo "configure:2471: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2437 "configure"
+#line 2476 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2462,17 +2501,17 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2466: checking for vfork.h" >&5
+echo "configure:2505: checking for vfork.h" >&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
-#line 2471 "configure"
+#line 2510 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2476: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2515: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2497,18 +2536,18 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2501: checking for working vfork" >&5
+echo "configure:2540: checking for working vfork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
   echo $ac_n "checking for vfork""... $ac_c" 1>&6
-echo "configure:2507: checking for vfork" >&5
+echo "configure:2546: checking for vfork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2512 "configure"
+#line 2551 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vfork(); below.  */
@@ -2531,7 +2570,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_vfork=yes"
 else
@@ -2553,7 +2592,7 @@
 ac_cv_func_vfork_works=$ac_cv_func_vfork
 else
   cat > conftest.$ac_ext <<EOF
-#line 2557 "configure"
+#line 2596 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -2648,7 +2687,7 @@
   }
 }
 EOF
-if { (eval echo configure:2652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_vfork_works=yes
 else
@@ -2680,12 +2719,12 @@
     for ac_func in _doprnt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2684: checking for $ac_func" >&5
+echo "configure:2723: 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 <<EOF
-#line 2689 "configure"
+#line 2728 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2708,7 +2747,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2738,12 +2777,12 @@
     for ac_func in _doprnt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2742: checking for $ac_func" >&5
+echo "configure:2781: 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 <<EOF
-#line 2747 "configure"
+#line 2786 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2766,7 +2805,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2809: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2794,19 +2833,19 @@
 
   for v in $vars; do
     echo $ac_n "checking for $v""... $ac_c" 1>&6
-echo "configure:2798: checking for $v" >&5
+echo "configure:2837: checking for $v" >&5
     if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2803 "configure"
+#line 2842 "configure"
 #include "confdefs.h"
 int *p;
 int main() {
 extern int $v []; p = &$v;
 ; return 0; }
 EOF
-if { (eval echo configure:2810: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "libiberty_cv_var_$v=yes"
 else
@@ -2832,12 +2871,12 @@
   for ac_func in $checkfuncs
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2836: checking for $ac_func" >&5
+echo "configure:2875: 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 <<EOF
-#line 2841 "configure"
+#line 2880 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2860,7 +2899,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2886,21 +2925,21 @@
 
 fi
 
-for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
+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:2894: checking for $ac_hdr" >&5
+echo "configure:2933: 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
-#line 2899 "configure"
+#line 2938 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2904: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2929,12 +2968,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2933: checking for $ac_func" >&5
+echo "configure:2972: 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 <<EOF
-#line 2938 "configure"
+#line 2977 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2957,7 +2996,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2982,7 +3021,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:2986: checking for working mmap" >&5
+echo "configure:3025: 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
@@ -2990,7 +3029,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 2994 "configure"
+#line 3033 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -3018,24 +3057,11 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
 
 /* Assume that all systems that can run configure have sys/param.h.  */
 # ifndef HAVE_SYS_PARAM_H
@@ -3143,7 +3169,7 @@
 }
 
 EOF
-if { (eval echo configure:3147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -3167,7 +3193,7 @@
 
 
 echo $ac_n "checking for working strncmp""... $ac_c" 1>&6
-echo "configure:3171: checking for working strncmp" >&5
+echo "configure:3197: checking for working strncmp" >&5
 if eval "test \"`echo '$''{'ac_cv_func_strncmp_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3175,7 +3201,7 @@
   ac_cv_func_strncmp_works=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 3179 "configure"
+#line 3205 "configure"
 #include "confdefs.h"
 
 /* Test by Jim Wilson and Kaveh Ghazi.
@@ -3239,7 +3265,7 @@
 }
 
 EOF
-if { (eval echo configure:3243: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_strncmp_works=yes
 else
@@ -3430,6 +3456,7 @@
 s%@host_makefile_frag@%%g
 s%@CPP@%$CPP%g
 s%@CHECK@%$CHECK%g
+s%@target_header_dir@%$target_header_dir%g
 s%@LIBOBJS@%$LIBOBJS%g
 s%@INSTALL_DEST@%$INSTALL_DEST%g
 
@@ -3645,6 +3672,7 @@
 host=${host}
 target=${target}
 with_target_subdir=${with_target_subdir}
+with_build_subdir=${with_build_subdir}
 with_multisubdir=${with_multisubdir}
 ac_configure_args="--enable-multilib ${ac_configure_args}"
 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
@@ -3654,7 +3682,7 @@
 cat >> $CONFIG_STATUS <<\EOF
 test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
 if test -n "$CONFIG_FILES"; then
-  if test -n "${with_target_subdir}"; then
+  if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
     # FIXME: We shouldn't need to set ac_file
     ac_file=Makefile
     . ${libiberty_topdir}/config-ml.in
diff --git a/libiberty/configure.in b/libiberty/configure.in
index fb930e4..0de0f8a 100644
--- a/libiberty/configure.in
+++ b/libiberty/configure.in
@@ -5,14 +5,19 @@
 
 dnl We use these options to decide which functions to include.
 AC_ARG_WITH(target-subdir,
-[  --with-target-subdir=SUBDIR      Configuring in a subdirectory])
+[  --with-target-subdir=SUBDIR      Configuring in a subdirectory for target])
+AC_ARG_WITH(build-subdir,
+[  --with-build-subdir=SUBDIR       Configuring in a subdirectory for build])
 AC_ARG_WITH(cross-host,
 [  --with-cross-host=HOST           Configuring with a cross compiler])
 AC_ARG_WITH(newlib,
 [  --with-newlib                    Configuring with newlib])
 
 if test "${srcdir}" = "."; then
-  if test -z "${with_target_subdir}"; then
+  if test -n "${with_build_subdir}"; then
+    libiberty_topdir="${srcdir}/../.."
+    with_target_subdir=
+  elif test -z "${with_target_subdir}"; then
     libiberty_topdir="${srcdir}/.."
   else
     if test "${with_target_subdir}" != "."; then
@@ -205,6 +210,7 @@
 
 setobjs=
 CHECK=
+target_header_dir=
 if test -n "${with_target_subdir}"; then
 
   # We are being configured as a target library.  AC_REPLACE_FUNCS
@@ -239,6 +245,27 @@
 
   fi
 
+  # We may wish to install the target headers somewhere.
+  AC_ARG_ENABLE(install-libiberty,
+  [  --enable-install-libiberty       Install headers for end users],
+  enable_install_libiberty=$enableval,
+  enable_install_libiberty=no)dnl
+  
+  # Option parsed, now set things appropriately.
+  case x"$enable_install_libiberty" in
+    xyes|x)
+      target_header_dir=libiberty
+      ;;
+    xno)   
+      target_header_dir=
+      ;;
+    *) 
+      # This could be sanity-checked in various ways...
+      target_header_dir="${enable_install_libiberty}"
+      ;;
+  esac
+
+
 else
 
    # Not a target library, so we set things up to run the test suite.
@@ -247,6 +274,7 @@
 fi
 
 AC_SUBST(CHECK)
+AC_SUBST(target_header_dir)
 
 case "${host}" in
   *-*-cygwin* | *-*-mingw*)
@@ -394,7 +422,7 @@
 AC_OUTPUT(Makefile testsuite/Makefile,
 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
 if test -n "$CONFIG_FILES"; then
-  if test -n "${with_target_subdir}"; then
+  if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
     # FIXME: We shouldn't need to set ac_file
     ac_file=Makefile
     . ${libiberty_topdir}/config-ml.in
@@ -404,6 +432,7 @@
 host=${host}
 target=${target}
 with_target_subdir=${with_target_subdir}
+with_build_subdir=${with_build_subdir}
 with_multisubdir=${with_multisubdir}
 ac_configure_args="--enable-multilib ${ac_configure_args}"
 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 136dc72..4a91700 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1,5 +1,5 @@
 /* Demangler for IA64 / g++ V3 ABI.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    Written by Alex Samuel <samuel@codesourcery.com>. 
 
    This file is part of GNU CC.
@@ -9,6 +9,15 @@
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
 
+   In addition to the permissions in the GNU General Public License, the
+   Free Software Foundation gives you unlimited permission to link the
+   compiled version of this file into combinations with other programs,
+   and to distribute those combinations without any restriction coming
+   from the use of this file.  (The General Public License restrictions
+   do apply in other respects; for example, they cover modification of
+   the file, and distribution when not linked into a combined
+   executable.)
+
    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
@@ -3568,7 +3577,7 @@
   return status;
 }
 
-#ifdef IN_LIBGCC2
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
 extern char *__cxa_demangle PARAMS ((const char *, char *, size_t *, int *));
 
 /* ia64 ABI-mandated entry point in the C++ runtime library for performing
@@ -3676,7 +3685,7 @@
     }
 }
 
-#else /* !IN_LIBGCC2 */
+#else /* ! (IN_LIBGCC2 || IN_GLIBCPP_V3) */
 
 /* Variant entry point for integration with the existing cplus-dem
    demangler.  Attempts to demangle MANGLED.  If the demangling
@@ -3837,11 +3846,15 @@
 
   free (cplus_demangled);
   
-  return_value = dyn_string_release (demangled);
+  if (demangled)
+    return_value = dyn_string_release (demangled);
+  else
+    return_value = NULL;
+
   return return_value;
 }
 
-#endif /* IN_LIBGCC2 */
+#endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */
 
 
 /* Demangle NAME in the G++ V3 ABI demangling style, and return either
@@ -3881,6 +3894,7 @@
 }
 
 
+#ifndef IN_GLIBCPP_V3
 /* Return non-zero iff NAME is the mangled form of a constructor name
    in the G++ V3 ABI demangling style.  Specifically, return:
    - '1' if NAME is a complete object constructor,
@@ -3923,6 +3937,7 @@
   else
     return 0;
 }
+#endif /* IN_GLIBCPP_V3 */
 
 
 #ifdef STANDALONE_DEMANGLER
diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c
index 34f88ad..1da76c2 100644
--- a/libiberty/dyn-string.c
+++ b/libiberty/dyn-string.c
@@ -1,5 +1,5 @@
 /* An abstract string datatype.
-   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
 This file is part of GNU CC.
@@ -9,6 +9,15 @@
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file.  (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combined
+executable.)
+
 GNU CC 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
@@ -41,7 +50,7 @@
    abort if an allocation fails.  Instead, percolate an error code up
    through the call chain.  */
 
-#ifdef IN_LIBGCC2
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
 #define RETURN_ON_ALLOCATION_FAILURE
 #endif
 
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index b5d0121..d9e9fad 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -103,13 +103,6 @@
   floatformat_intbit_no,
   "floatformat_m88110_ext_harris"
 };
-const struct floatformat floatformat_arm_ext =
-{
-  /* Bits 1 to 16 are unused.  */
-  floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
-  floatformat_intbit_yes,
-  "floatformat_arm_ext"
-};
 const struct floatformat floatformat_arm_ext_big =
 {
   /* Bits 1 to 16 are unused.  */
diff --git a/libiberty/functions.texi b/libiberty/functions.texi
index af7760d..b518243 100644
--- a/libiberty/functions.texi
+++ b/libiberty/functions.texi
@@ -317,6 +317,34 @@
 
 @end deftypefn
 
+@c hex.c:25
+@deftypefn Extension void hex_init (void)
+
+Initializes the array mapping the current character set to
+corresponding hex values.  This function must be called before any
+call to @code{hex_p} or @code{hex_value}.
+
+@end deftypefn
+
+@c hex.c:33
+@deftypefn Extension int hex_p (int @var{c})
+
+Evaluates to non-zero if the given character is a valid hex character,
+or zero if it is not.  Note that the value you pass will be cast to
+@code{unsigned char} within the macro.
+
+@end deftypefn
+
+@c hex.c:41
+@deftypefn Extension int hex_value (int @var{c})
+
+Returns the numeric equivalent of the given character when interpreted
+as a hexidecimal digit.  The result is undefined if you pass an
+invalid hex digit.  Note that the value you pass will be cast to
+@code{unsigned char} within the macro.
+
+@end deftypefn
+
 @c index.c:5
 @deftypefn Supplemental char* index (char *@var{s}, int @var{c})
 
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 36ad6e4..7477c35 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
 This file is part of the libiberty library.
@@ -81,7 +81,6 @@
   /* These are primes that are near, but slightly smaller than, a
      power of two.  */
   static const unsigned long primes[] = {
-    (unsigned long) 2,
     (unsigned long) 7,
     (unsigned long) 13,
     (unsigned long) 31,
@@ -264,21 +263,27 @@
      hashval_t hash;
 {
   size_t size = htab->size;
-  hashval_t hash2 = 1 + hash % (size - 2);
   unsigned int index = hash % size;
+  PTR *slot = htab->entries + index;
+  hashval_t hash2;
 
+  if (*slot == EMPTY_ENTRY)
+    return slot;
+  else if (*slot == DELETED_ENTRY)
+    abort ();
+
+  hash2 = 1 + hash % (size - 2);
   for (;;)
     {
-      PTR *slot = htab->entries + index;
+      index += hash2;
+      if (index >= size)
+	index -= size;
 
+      slot = htab->entries + index;
       if (*slot == EMPTY_ENTRY)
 	return slot;
       else if (*slot == DELETED_ENTRY)
 	abort ();
-
-      index += hash2;
-      if (index >= size)
-	index -= size;
     }
 }
 
@@ -405,50 +410,59 @@
   unsigned int index;
   hashval_t hash2;
   size_t size;
+  PTR entry;
 
   if (insert == INSERT && htab->size * 3 <= htab->n_elements * 4
       && htab_expand (htab) == 0)
     return NULL;
 
   size = htab->size;
-  hash2 = 1 + hash % (size - 2);
   index = hash % size;
 
   htab->searches++;
   first_deleted_slot = NULL;
 
+  entry = htab->entries[index];
+  if (entry == EMPTY_ENTRY)
+    goto empty_entry;
+  else if (entry == DELETED_ENTRY)
+    first_deleted_slot = &htab->entries[index];
+  else if ((*htab->eq_f) (entry, element))
+    return &htab->entries[index];
+      
+  hash2 = 1 + hash % (size - 2);
   for (;;)
     {
-      PTR entry = htab->entries[index];
-      if (entry == EMPTY_ENTRY)
-	{
-	  if (insert == NO_INSERT)
-	    return NULL;
-
-	  htab->n_elements++;
-
-	  if (first_deleted_slot)
-	    {
-	      *first_deleted_slot = EMPTY_ENTRY;
-	      return first_deleted_slot;
-	    }
-
-	  return &htab->entries[index];
-	}
-
-      if (entry == DELETED_ENTRY)
-	{
-	  if (!first_deleted_slot)
-	    first_deleted_slot = &htab->entries[index];
-	}
-      else  if ((*htab->eq_f) (entry, element))
-	return &htab->entries[index];
-      
       htab->collisions++;
       index += hash2;
       if (index >= size)
 	index -= size;
+      
+      entry = htab->entries[index];
+      if (entry == EMPTY_ENTRY)
+	goto empty_entry;
+      else if (entry == DELETED_ENTRY)
+	{
+	  if (!first_deleted_slot)
+	    first_deleted_slot = &htab->entries[index];
+	}
+      else if ((*htab->eq_f) (entry, element))
+	return &htab->entries[index];
     }
+
+ empty_entry:
+  if (insert == NO_INSERT)
+    return NULL;
+
+  htab->n_elements++;
+
+  if (first_deleted_slot)
+    {
+      *first_deleted_slot = EMPTY_ENTRY;
+      return first_deleted_slot;
+    }
+
+  return &htab->entries[index];
 }
 
 /* Like htab_find_slot_with_hash, but compute the hash value from the
diff --git a/libiberty/hex.c b/libiberty/hex.c
index 3ba04ba..5f82292 100644
--- a/libiberty/hex.c
+++ b/libiberty/hex.c
@@ -20,11 +20,40 @@
 #include <stdio.h>  /* for EOF */
 #include "libiberty.h"
 
-/* Provided for ABI compatibility.  */
-void
-hex_init ()
-{
-}
+/*
+
+@deftypefn Extension void hex_init (void)
+
+Initializes the array mapping the current character set to
+corresponding hex values.  This function must be called before any
+call to @code{hex_p} or @code{hex_value}.  If you fail to call it, a
+default ASCII-based table will normally be used on ASCII systems.
+
+@end deftypefn
+
+@deftypefn Extension int hex_p (int @var{c})
+
+Evaluates to non-zero if the given character is a valid hex character,
+or zero if it is not.  Note that the value you pass will be cast to
+@code{unsigned char} within the macro.
+
+@end deftypefn
+
+@deftypefn Extension int hex_value (int @var{c})
+
+Returns the numeric equivalent of the given character when interpreted
+as a hexidecimal digit.  The result is undefined if you pass an
+invalid hex digit.  Note that the value you pass will be cast to
+@code{unsigned char} within the macro.
+
+@end deftypefn
+
+@undocumented _hex_array_size
+@undocumented _hex_bad
+@undocumented _hex_value
+
+*/
+
 
 /* Are we ASCII? */
 #if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
@@ -106,6 +135,46 @@
   _hex_bad, _hex_bad, _hex_bad, _hex_bad,
   _hex_bad, _hex_bad, _hex_bad, _hex_bad,
 };
+#define HEX_TABLE_INITIALIZED
+
 #else
- #error "Unsupported host character set"
+
+char _hex_value[_hex_array_size];
+
 #endif /* not ASCII */
+
+void
+hex_init ()
+{
+#ifndef HEX_TABLE_INITIALIZED
+  int i;
+
+  for (i=0; i<_hex_array_size; i++)
+    {
+      switch (i)
+	{
+	case '0': _hex_value[i] = 0; break;
+	case '1': _hex_value[i] = 1; break;
+	case '2': _hex_value[i] = 2; break;
+	case '3': _hex_value[i] = 3; break;
+	case '4': _hex_value[i] = 4; break;
+	case '5': _hex_value[i] = 5; break;
+	case '6': _hex_value[i] = 6; break;
+	case '7': _hex_value[i] = 7; break;
+	case '8': _hex_value[i] = 8; break;
+	case '9': _hex_value[i] = 9; break;
+
+	case 'a': case 'A': _hex_value[i] = 10; break;
+	case 'b': case 'B': _hex_value[i] = 11; break;
+	case 'c': case 'C': _hex_value[i] = 12; break;
+	case 'd': case 'D': _hex_value[i] = 13; break;
+	case 'e': case 'E': _hex_value[i] = 14; break;
+	case 'f': case 'F': _hex_value[i] = 15; break;
+
+	default:
+	  _hex_value[i] = _hex_bad;
+	  break;
+	}
+    }
+#endif
+}
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index f12b4cc..7999447 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -230,13 +230,17 @@
 
 /* An allocator and deallocator based on xmalloc.  */
 static void *
-splay_tree_xmalloc_allocate (int size, void *data)
+splay_tree_xmalloc_allocate (size, data)
+     int size;
+     void *data ATTRIBUTE_UNUSED;
 {
   return xmalloc (size);
 }
 
 static void
-splay_tree_xmalloc_deallocate (void *object, void *data)
+splay_tree_xmalloc_deallocate (object, data)
+     void *object;
+     void *data ATTRIBUTE_UNUSED;
 {
   free (object);
 }
diff --git a/libiberty/strtod.c b/libiberty/strtod.c
index 6b69ccf..97fc933 100644
--- a/libiberty/strtod.c
+++ b/libiberty/strtod.c
@@ -1,5 +1,5 @@
 /* Implementation of strtod for systems with atof.
-   Copyright (C) 1991, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
@@ -75,7 +75,7 @@
 	  && (p[6] == 't' || p[6] == 'T')
 	  && (p[7] == 'y' || p[7] == 'Y'))
 	{
-	  *ptr = p + 7;
+	  *ptr = p + 8;
 	  return atof (str);
 	}
       else
diff --git a/libiberty/xatexit.c b/libiberty/xatexit.c
index 728254b..abf3407 100644
--- a/libiberty/xatexit.c
+++ b/libiberty/xatexit.c
@@ -33,8 +33,13 @@
 #define size_t unsigned long
 #endif
 
+#if VMS
+#include <stdlib.h>
+#include <unixlib.h>
+#else
 /* For systems with larger pointers than ints, this must be declared.  */
 PTR malloc PARAMS ((size_t));
+#endif
 
 static void xatexit_cleanup PARAMS ((void));
 
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index bf0cf2d..4c8249a 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -120,12 +120,12 @@
   else
     allocated = (char *) sbrk (0) - (char *) &environ;
   fprintf (stderr,
-	   "\n%s%sCannot allocate %lu bytes after allocating %lu bytes\n",
+	   "\n%s%sout of memory allocating %lu bytes after a total of %lu bytes\n",
 	   name, *name ? ": " : "",
 	   (unsigned long) size, (unsigned long) allocated);
 #else /* HAVE_SBRK */
   fprintf (stderr,
-	   "\n%s%sCannot allocate %lu bytes\n",
+	   "\n%s%sout of memory allocating %lu bytes\n",
 	   name, *name ? ": " : "",
 	   (unsigned long) size);
 #endif /* HAVE_SBRK */
diff --git a/ltmain.sh b/ltmain.sh
index bd76cfb..c3547e5 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -107,6 +107,7 @@
 execute_dlfiles=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
+taglist=
 
 # Parse our command line options once, thoroughly.
 while test $# -gt 0
@@ -140,6 +141,7 @@
       CC)
 	# Don't test for the "default" C tag, as we know, it's there, but
 	# not specially marked.
+	taglist="$taglist $tagname"
 	;;
       *)
         if grep "^### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then
@@ -4299,7 +4301,11 @@
 	fi
       done
       # Quote the link command for shipping.
-      relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args"
+      tagopts=
+      for tag in $taglist; do
+        tagopts="$tagopts --tag $tag"
+      done
+      relink_command="(cd `pwd`; $SHELL $0$tagopts --mode=relink $libtool_args)"
       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
 
       # Only create the output if not a dry run.
@@ -4605,7 +4611,7 @@
 	  if $run eval "$relink_command"; then :
 	  else
 	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
-	    continue
+	    exit 1
 	  fi
 	fi
 
diff --git a/mmalloc/ChangeLog b/mmalloc/ChangeLog
index 20339a5..8b59d38 100644
--- a/mmalloc/ChangeLog
+++ b/mmalloc/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-07  Andrew Cagney  <ac131313@redhat.com>
+
+	From 2002-03-05 Scott Pakin <pakin@uiuc.edu>
+	* mmap-sup.c (MAP_PRIVATE_OR_SHARED): Define.
+	(__mmalloc_mmap_morecore): Use.
+	(__mmalloc_remap_core): Use.
+	
 2000-05-17  Eli Zaretskii  <eliz@is.elta.co.il>
 
 	* Makefile.in (install-info): Make sure $(infodir) exists.  Run
diff --git a/mmalloc/mmap-sup.c b/mmalloc/mmap-sup.c
index 56146e2..b12e43c 100644
--- a/mmalloc/mmap-sup.c
+++ b/mmalloc/mmap-sup.c
@@ -48,6 +48,15 @@
 #define PAGE_ALIGN(addr) (caddr_t) (((long)(addr) + pagesize - 1) & \
 				    ~(pagesize - 1))
 
+
+/* Return MAP_PRIVATE if MDP represents /dev/zero.  Otherwise, return
+   MAP_SHARED.  */
+
+#define MAP_PRIVATE_OR_SHARED(MDP) ((MDP -> flags & MMALLOC_DEVZERO) \
+                                    ? MAP_PRIVATE \
+                                    : MAP_SHARED)
+
+
 /*  Get core for the memory region specified by MDP, using SIZE as the
     amount to either add to or subtract from the existing region.  Works
     like sbrk(), but using mmap(). */
@@ -113,7 +122,7 @@
 	    {
 	      /* Let mmap pick the map start address */
 	      mapto = mmap (0, mapbytes, PROT_READ | PROT_WRITE,
-			    MAP_SHARED, mdp -> fd, foffset);
+			    MAP_PRIVATE_OR_SHARED (mdp), mdp -> fd, foffset);
 	      if (mapto != (caddr_t) -1)
 		{
 		  mdp -> base = mdp -> breakval = mapto;
@@ -125,7 +134,8 @@
 	  else
 	    {
 	      mapto = mmap (mdp -> top, mapbytes, PROT_READ | PROT_WRITE,
-			    MAP_SHARED | MAP_FIXED, mdp -> fd, foffset);
+			    MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED, mdp -> fd,
+			    foffset);
 	      if (mapto == mdp -> top)
 		{
 		  mdp -> top = moveto;
@@ -152,7 +162,7 @@
   /* FIXME:  Quick hack, needs error checking and other attention. */
 
   base = mmap (mdp -> base, mdp -> top - mdp -> base,
-	       PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED,
+	       PROT_READ | PROT_WRITE, MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED,
 	       mdp -> fd, 0);
   return ((PTR) base);
 }
@@ -166,13 +176,13 @@
   caddr_t base = NULL;
 
 #ifdef MAP_ANONYMOUS
-  flags = MAP_SHARED | MAP_ANONYMOUS;
+  flags = MAP_PRIVATE | MAP_ANONYMOUS;
   fd = -1;
 #else
 #ifdef MAP_FILE
-  flags = MAP_SHARED | MAP_FILE;
+  flags = MAP_PRIVATE | MAP_FILE;
 #else
-  flags = MAP_SHARED;
+  flags = MAP_PRIVATE;
 #endif
   fd = open ("/dev/zero", O_RDWR);
   if (fd != -1)
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index a7b5e13..80f094c 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,141 @@
+2002-05-01  Alan Modra  <amodra@bigpond.net.au>
+
+	* ppc-opc.c: Add "tlbsx." and "tlbsxe." for booke.
+
+2002-04-24  Christian Groessler <chris@groessler.org>
+
+	* z8k-dis.c (print_insn_z8k): Set disassemble_info to 2
+	bytes_per_chunk, 6 bytes_per_line for nicer display of the hex
+	codes.
+	(z8k_lookup_instr): CLASS_IGNORE case added.
+	(output_instr): Don't print hex codes, they are already
+	printed.
+	(unpack_instr): ARG_NIM4 case added.  ARG_NIM8 case
+	fixed. Support CLASS_BIT_1OR2 and CLASS_IGNORE cases.
+	(unparse_instr): Fix base and indexed addressing disassembly:
+	The index is inside the brackets.
+	* z8kgen.c (gas): Add ARG_NIM4 and CLASS_IGNORE defines.
+	(opt): Fix shift left/right arithmetic/logical byte defines:
+	The high byte of the immediate word is ignored by the
+	processor.
+	Fix n parameter of ldm opcodes: The opcode contains (n-1).
+	(args): Fix "n" entry.
+	(toks): Add "nim4" and "iiii" entries.
+	* z8k-opc.h: Regenerated with new z8kgen.c.
+
+2002-04-24  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* po/id.po: New Indonesian translation.
+	* configure.in (ALL_LIGUAS): Add id.po
+	* configure: Regenerate.
+
+2002-04-17  matthew green  <mrg@redhat.com>
+
+	* ppc-opc.c (powerpc_opcode): Fix dssall operand list.
+
+2002-04-04  Alan Modra  <amodra@bigpond.net.au>
+
+	* dep-in.sed: Cope with absolute paths.
+	* Makefile.am (dep.sed): Subst TOPDIR.
+	Run "make dep-am".
+	* Makefile.in: Regenerate.
+	* ppc-opc.c: Whitespace.
+	* s390-dis.c: Fix copyright date.
+
+2002-03-23  matthew green  <mrg@redhat.com>
+
+	* ppc-opc.c (vmaddfp): Fix operand order.
+
+2002-03-21  Alan Modra  <amodra@bigpond.net.au>
+
+	* Makefile.am: Run "make dep-am".
+	* Makefile.in: Regenerate.
+
+2002-03-21  Anton Blanchard  <anton@samba.org>
+
+	* ppc-opc.c: Add optional field to mtmsrd.
+	(MTMSRD_L, XRLARB_MASK): Define.
+
+Mon Mar 18 21:10:43 CET 2002  Jan Hubicka  <jh@suse.cz>
+
+	* i386-dis.c (prefix_name): Fix handling of 32bit address prefix
+	in 64bit mode.
+	(print_insn) Likewise.
+	(putop): Fix handling of 'E'
+	(OP_E, OP_OFF): handle 32bit addressing mode in 64bit.
+	(ptr_reg): Likewise.
+
+2002-03-18  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* po/fr.po: Updated version.
+
+2002-03-16  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips-opc.c (M3D): Tweak comment.
+	(mips_builtin_op): Add comment indicating that opcodes of the
+	same name must be placed together in the table, and sort
+	the "recip.fmt", "recip1.fmt", "recip2.fmt", "rsqrt.fmt",
+	"rsqrt1.fmt", and "rsqrt2.fmt" opcodes by name.
+
+2002-03-16  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* Makefile.am: Tidy up sh64 rules.
+        * Makefile.in: Regenerate.
+
+2002-03-15  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* mips-dis.c: Update copyright years.
+
+2002-03-15  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* mips-dis.c (mips_isa_type): Add MIPS3D instructions to the ISA
+	bit masks for bfd_mach_mips_sb1 and bfd_mach_mipsisa64.  Add
+	comments for bfd_mach_mipsisa32 and bfd_mach_mipsisa64 that
+	indicate that they should dissassemble all applicable
+	MIPS-specified ASEs.
+	* mips-opc.c: Add support for MIPS-3D instructions.
+	(M3D): New definition.
+
+	* mips-opc.c: Update copyright years.
+
+2002-03-15  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* mips-opc.c (mips_builtin_opcodes): Sort bc<N> opcodes by name.
+
+2002-03-15  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips-dis.c (is_newabi): Fix ABI decoding.
+
+2002-03-14  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* mips-dis.c (mips_isa_type): Fix formatting of bfd_mach_mipsisa32
+	and bfd_mach_mipsisa64 cases to match the rest.
+
+2002-03-13  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* po/fr.po: Updated version.
+
+2002-03-13  Alan Modra  <amodra@bigpond.net.au>
+
+	* ppc-opc.c: Add optional `L' field to tlbie.
+	(XRTLRA_MASK): Define.
+
+2002-03-06  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips-opc.c (mips_builtin_opcodes): Mark "pref" as being
+	present on I4.
+
+	* mips-opc.c (mips_builtin_opcodes): Add "movn.ps" and "movz.ps".
+
+2002-03-05  Paul Koning  <pkoning@equallogic.com>
+
+	* pdp11-opc.c: Fix "mark" operand type.  Fix operand types
+	for float opcodes that take float operands.  Add alternate
+	names (xxxD vs. xxxF) for float opcodes.
+	* pdp11-dis.c (print_operand): Clean up formatting for mode 67.
+	(print_foperand): New function to handle float opcode operands.
+	(print_insn_pdp11): Use print_foperand to disassemble float ops.
+
 2002-02-27  Nick Clifton  <nickc@cambridge.redhat.com>
 
 	* po/de.po: Updated.
@@ -786,7 +924,7 @@
 	* arc-opc.c: Include "sysdep.h" to get stdio.h as include file.
 	* arc-ext.c: Likewise.
 
-2001-08-28  matthew gren  <mrg@redhat.com>
+2001-08-28  matthew green  <mrg@redhat.com>
 
 	* ppc-opc.c (icbt): Order correctly.
 
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index 00edf82..ad3bdf4 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -24,14 +24,14 @@
 	arm-opc.h \
 	fr30-desc.h fr30-opc.h \
 	h8500-opc.h \
+	ia64-asmtab.h \
+	ia64-opc.h \
 	m32r-desc.h m32r-opc.h \
 	mcore-opc.h \
 	openrisc-desc.h openrisc-opc.h \
 	sh-opc.h \
+	sh64-opc.h \
 	sysdep.h \
-	ia64-asmtab.h \
-	ia64-opc.h \
-	  sh64-opc.h \
 	w65-opc.h \
 	xstormy16-desc.h xstormy16-opc.h \
 	z8k-opc.h
@@ -119,6 +119,8 @@
 	s390-opc.c \
 	s390-dis.c \
 	sh-dis.c \
+	sh64-dis.c \
+	sh64-opc.c \
 	sparc-dis.c \
 	sparc-opc.c \
 	tic30-dis.c \
@@ -129,8 +131,6 @@
 	v850-dis.c \
 	v850-opc.c \
 	vax-dis.c \
-	  sh64-dis.c \
-	  sh64-opc.c \
 	w65-dis.c \
 	xstormy16-asm.c \
 	xstormy16-desc.c \
@@ -211,6 +211,8 @@
 	s390-dis.lo \
 	s390-opc.lo \
 	sh-dis.lo \
+	sh64-dis.lo \
+	sh64-opc.lo \
 	sparc-dis.lo \
 	sparc-opc.lo \
 	tic30-dis.lo \
@@ -221,8 +223,6 @@
 	v850-dis.lo \
 	v850-opc.lo \
 	vax-dis.lo \
-	  sh64-dis.lo \
-	  sh64-opc.lo \
 	w65-dis.lo \
 	xstormy16-asm.lo \
 	xstormy16-desc.lo \
@@ -325,10 +325,6 @@
 stamp-fr30: $(CGENDEPS) $(CPUDIR)/fr30.cpu $(CPUDIR)/fr30.opc
 	$(MAKE) run-cgen arch=fr30 prefix=fr30 options= extrafiles=
 
-sh64-opc.lo: sh64-opc.c sh64-opc.h
-sh64-dis.lo: sh64-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
-  sh64-opc.h $(INCDIR)/dis-asm.h $(BFD_H) opintl.h
-
 $(srcdir)/openrisc-desc.h $(srcdir)/openrisc-desc.c $(srcdir)/openrisc-opc.h $(srcdir)/openrisc-opc.c $(srcdir)/openrisc-ibld.c $(srcdir)/openrisc-asm.c $(srcdir)/openrisc-dis.c: $(OPENRISC_DEPS)
 	@true
 stamp-openrisc: $(CGENDEPS) $(CPUDIR)/openrisc.cpu $(CPUDIR)/openrisc.opc
@@ -380,7 +376,8 @@
 		-e 's!@BFD_H@!$(BFD_H)!'	\
 		-e 's!@INCDIR@!$(INCDIR)!'	\
 		-e 's!@BFDDIR@!$(BFDDIR)!'	\
-		-e 's!@SRCDIR@!$(srcdir)!'
+		-e 's!@SRCDIR@!$(srcdir)!'	\
+		-e 's!@TOPDIR@!'`echo $(srcdir) | sed -e s,/opcodes$$,,`'!'
 
 dep: DEP
 	sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
@@ -410,11 +407,11 @@
 alpha-opc.lo: alpha-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/alpha.h $(BFD_H) $(INCDIR)/symcat.h \
   opintl.h
-arc-dis.lo: arc-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
-  $(INCDIR)/symcat.h $(INCDIR)/opcode/arc.h $(BFDDIR)/elf-bfd.h \
-  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
-  $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h $(INCDIR)/elf/reloc-macros.h \
-  opintl.h arc-dis.h arc-ext.h
+arc-dis.lo: arc-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+  $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/arc.h \
+  $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h \
+  $(INCDIR)/elf/reloc-macros.h opintl.h arc-dis.h arc-ext.h
 arc-opc.lo: arc-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/arc.h
 arc-ext.lo: arc-ext.c sysdep.h config.h $(INCDIR)/ansidecl.h \
@@ -492,19 +489,25 @@
   $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
 ia64-dis.lo: ia64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
   $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/opcode/ia64.h
-ia64-opc-a.lo: ia64-opc-a.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-b.lo: ia64-opc-b.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-f.lo: ia64-opc-f.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-i.lo: ia64-opc-i.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-m.lo: ia64-opc-m.c ia64-opc.h $(INCDIR)/opcode/ia64.h
+ia64-opc-a.lo: ia64-opc-a.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-b.lo: ia64-opc-b.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-f.lo: ia64-opc-f.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-i.lo: ia64-opc-i.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-m.lo: ia64-opc-m.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
 ia64-opc-d.lo: ia64-opc-d.c
 ia64-opc.lo: ia64-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
   sysdep.h config.h ia64-asmtab.h $(INCDIR)/opcode/ia64.h \
-  ia64-asmtab.c
+  $(BFD_H) $(INCDIR)/symcat.h ia64-asmtab.c
 ia64-gen.lo: ia64-gen.c $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
   $(INCDIR)/safe-ctype.h sysdep.h config.h ia64-opc.h \
-  $(INCDIR)/opcode/ia64.h ia64-opc-a.c ia64-opc-i.c ia64-opc-m.c \
-  ia64-opc-b.c ia64-opc-f.c ia64-opc-x.c ia64-opc-d.c
+  $(INCDIR)/opcode/ia64.h $(BFD_H) $(INCDIR)/symcat.h \
+  ia64-opc-a.c ia64-opc-i.c ia64-opc-m.c ia64-opc-b.c \
+  ia64-opc-f.c ia64-opc-x.c ia64-opc-d.c
 ia64-asmtab.lo: ia64-asmtab.c
 m32r-asm.lo: m32r-asm.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(BFD_H) $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
@@ -532,7 +535,7 @@
   $(INCDIR)/opcode/m68hc11.h
 m68k-dis.lo: m68k-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/floatformat.h \
-  opintl.h $(INCDIR)/opcode/m68k.h
+  $(INCDIR)/libiberty.h opintl.h $(INCDIR)/opcode/m68k.h
 m68k-opc.lo: m68k-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/m68k.h
 m88k-dis.lo: m88k-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
@@ -608,6 +611,12 @@
   $(INCDIR)/opcode/s390.h
 sh-dis.lo: sh-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   sh-opc.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
+sh64-dis.lo: sh64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+  $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h sysdep.h config.h \
+  sh64-opc.h $(INCDIR)/libiberty.h $(BFDDIR)/elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  $(INCDIR)/bfdlink.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h
+sh64-opc.lo: sh64-opc.c sh64-opc.h
 sparc-dis.lo: sparc-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/sparc.h $(INCDIR)/dis-asm.h $(BFD_H) \
   $(INCDIR)/symcat.h $(INCDIR)/libiberty.h opintl.h
@@ -633,12 +642,6 @@
 vax-dis.lo: vax-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/vax.h $(INCDIR)/dis-asm.h $(BFD_H) \
   $(INCDIR)/symcat.h
-sh64-dis.lo: sh64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
-  $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h sysdep.h config.h \
-  sh64-opc.h $(INCDIR)/libiberty.h $(BFDDIR)/elf-bfd.h \
-  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
-  $(INCDIR)/bfdlink.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h
-sh64-opc.lo: sh64-opc.c sh64-opc.h
 w65-dis.lo: w65-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   w65-opc.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
 xstormy16-asm.lo: xstormy16-asm.c sysdep.h config.h \
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
index 824e9aa..48c8630 100644
--- a/opcodes/Makefile.in
+++ b/opcodes/Makefile.in
@@ -134,14 +134,14 @@
 	arm-opc.h \
 	fr30-desc.h fr30-opc.h \
 	h8500-opc.h \
+	ia64-asmtab.h \
+	ia64-opc.h \
 	m32r-desc.h m32r-opc.h \
 	mcore-opc.h \
 	openrisc-desc.h openrisc-opc.h \
 	sh-opc.h \
+	sh64-opc.h \
 	sysdep.h \
-	ia64-asmtab.h \
-	ia64-opc.h \
-	  sh64-opc.h \
 	w65-opc.h \
 	xstormy16-desc.h xstormy16-opc.h \
 	z8k-opc.h
@@ -230,6 +230,8 @@
 	s390-opc.c \
 	s390-dis.c \
 	sh-dis.c \
+	sh64-dis.c \
+	sh64-opc.c \
 	sparc-dis.c \
 	sparc-opc.c \
 	tic30-dis.c \
@@ -240,8 +242,6 @@
 	v850-dis.c \
 	v850-opc.c \
 	vax-dis.c \
-	  sh64-dis.c \
-	  sh64-opc.c \
 	w65-dis.c \
 	xstormy16-asm.c \
 	xstormy16-desc.c \
@@ -323,6 +323,8 @@
 	s390-dis.lo \
 	s390-opc.lo \
 	sh-dis.lo \
+	sh64-dis.lo \
+	sh64-opc.lo \
 	sparc-dis.lo \
 	sparc-opc.lo \
 	tic30-dis.lo \
@@ -333,8 +335,6 @@
 	v850-dis.lo \
 	v850-opc.lo \
 	vax-dis.lo \
-	  sh64-dis.lo \
-	  sh64-opc.lo \
 	w65-dis.lo \
 	xstormy16-asm.lo \
 	xstormy16-desc.lo \
@@ -416,7 +416,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 SOURCES = libopcodes.a.c $(libopcodes_la_SOURCES)
 OBJECTS = libopcodes.a.$(OBJEXT) $(libopcodes_la_OBJECTS)
@@ -836,10 +836,6 @@
 stamp-fr30: $(CGENDEPS) $(CPUDIR)/fr30.cpu $(CPUDIR)/fr30.opc
 	$(MAKE) run-cgen arch=fr30 prefix=fr30 options= extrafiles=
 
-sh64-opc.lo: sh64-opc.c sh64-opc.h
-sh64-dis.lo: sh64-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
-  sh64-opc.h $(INCDIR)/dis-asm.h $(BFD_H) opintl.h
-
 $(srcdir)/openrisc-desc.h $(srcdir)/openrisc-desc.c $(srcdir)/openrisc-opc.h $(srcdir)/openrisc-opc.c $(srcdir)/openrisc-ibld.c $(srcdir)/openrisc-asm.c $(srcdir)/openrisc-dis.c: $(OPENRISC_DEPS)
 	@true
 stamp-openrisc: $(CGENDEPS) $(CPUDIR)/openrisc.cpu $(CPUDIR)/openrisc.opc
@@ -891,7 +887,8 @@
 		-e 's!@BFD_H@!$(BFD_H)!'	\
 		-e 's!@INCDIR@!$(INCDIR)!'	\
 		-e 's!@BFDDIR@!$(BFDDIR)!'	\
-		-e 's!@SRCDIR@!$(srcdir)!'
+		-e 's!@SRCDIR@!$(srcdir)!'	\
+		-e 's!@TOPDIR@!'`echo $(srcdir) | sed -e s,/opcodes$$,,`'!'
 
 dep: DEP
 	sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
@@ -921,11 +918,11 @@
 alpha-opc.lo: alpha-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/alpha.h $(BFD_H) $(INCDIR)/symcat.h \
   opintl.h
-arc-dis.lo: arc-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
-  $(INCDIR)/symcat.h $(INCDIR)/opcode/arc.h $(BFDDIR)/elf-bfd.h \
-  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
-  $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h $(INCDIR)/elf/reloc-macros.h \
-  opintl.h arc-dis.h arc-ext.h
+arc-dis.lo: arc-dis.c $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+  $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/arc.h \
+  $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h \
+  $(INCDIR)/elf/reloc-macros.h opintl.h arc-dis.h arc-ext.h
 arc-opc.lo: arc-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/arc.h
 arc-ext.lo: arc-ext.c sysdep.h config.h $(INCDIR)/ansidecl.h \
@@ -1003,19 +1000,25 @@
   $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
 ia64-dis.lo: ia64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
   $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/opcode/ia64.h
-ia64-opc-a.lo: ia64-opc-a.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-b.lo: ia64-opc-b.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-f.lo: ia64-opc-f.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-i.lo: ia64-opc-i.c ia64-opc.h $(INCDIR)/opcode/ia64.h
-ia64-opc-m.lo: ia64-opc-m.c ia64-opc.h $(INCDIR)/opcode/ia64.h
+ia64-opc-a.lo: ia64-opc-a.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-b.lo: ia64-opc-b.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-f.lo: ia64-opc-f.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-i.lo: ia64-opc-i.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
+ia64-opc-m.lo: ia64-opc-m.c ia64-opc.h $(INCDIR)/opcode/ia64.h \
+  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
 ia64-opc-d.lo: ia64-opc-d.c
 ia64-opc.lo: ia64-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
   sysdep.h config.h ia64-asmtab.h $(INCDIR)/opcode/ia64.h \
-  ia64-asmtab.c
+  $(BFD_H) $(INCDIR)/symcat.h ia64-asmtab.c
 ia64-gen.lo: ia64-gen.c $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
   $(INCDIR)/safe-ctype.h sysdep.h config.h ia64-opc.h \
-  $(INCDIR)/opcode/ia64.h ia64-opc-a.c ia64-opc-i.c ia64-opc-m.c \
-  ia64-opc-b.c ia64-opc-f.c ia64-opc-x.c ia64-opc-d.c
+  $(INCDIR)/opcode/ia64.h $(BFD_H) $(INCDIR)/symcat.h \
+  ia64-opc-a.c ia64-opc-i.c ia64-opc-m.c ia64-opc-b.c \
+  ia64-opc-f.c ia64-opc-x.c ia64-opc-d.c
 ia64-asmtab.lo: ia64-asmtab.c
 m32r-asm.lo: m32r-asm.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(BFD_H) $(INCDIR)/symcat.h m32r-desc.h $(INCDIR)/opcode/cgen.h \
@@ -1043,7 +1046,7 @@
   $(INCDIR)/opcode/m68hc11.h
 m68k-dis.lo: m68k-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/floatformat.h \
-  opintl.h $(INCDIR)/opcode/m68k.h
+  $(INCDIR)/libiberty.h opintl.h $(INCDIR)/opcode/m68k.h
 m68k-opc.lo: m68k-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/m68k.h
 m88k-dis.lo: m88k-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
@@ -1119,6 +1122,12 @@
   $(INCDIR)/opcode/s390.h
 sh-dis.lo: sh-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   sh-opc.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
+sh64-dis.lo: sh64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
+  $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h sysdep.h config.h \
+  sh64-opc.h $(INCDIR)/libiberty.h $(BFDDIR)/elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  $(INCDIR)/bfdlink.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h
+sh64-opc.lo: sh64-opc.c sh64-opc.h
 sparc-dis.lo: sparc-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/sparc.h $(INCDIR)/dis-asm.h $(BFD_H) \
   $(INCDIR)/symcat.h $(INCDIR)/libiberty.h opintl.h
@@ -1144,12 +1153,6 @@
 vax-dis.lo: vax-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/opcode/vax.h $(INCDIR)/dis-asm.h $(BFD_H) \
   $(INCDIR)/symcat.h
-sh64-dis.lo: sh64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
-  $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h sysdep.h config.h \
-  sh64-opc.h $(INCDIR)/libiberty.h $(BFDDIR)/elf-bfd.h \
-  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
-  $(INCDIR)/bfdlink.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h
-sh64-opc.lo: sh64-opc.c sh64-opc.h
 w65-dis.lo: w65-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
   w65-opc.h $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h
 xstormy16-asm.lo: xstormy16-asm.c sysdep.h config.h \
diff --git a/opcodes/configure b/opcodes/configure
index 2e978ad..d8f162a 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -2588,7 +2588,7 @@
 fi
 
 
-ALL_LINGUAS="fr sv tr es da de"
+ALL_LINGUAS="fr sv tr es da de id"
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
 echo "configure:2594: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
diff --git a/opcodes/configure.in b/opcodes/configure.in
index 0088fe9..699f9be 100644
--- a/opcodes/configure.in
+++ b/opcodes/configure.in
@@ -77,7 +77,7 @@
 
 AC_PROG_CC
 
-ALL_LINGUAS="fr sv tr es da de"
+ALL_LINGUAS="fr sv tr es da de id"
 CY_GNU_GETTEXT
 
 . ${srcdir}/../bfd/configure.host
diff --git a/opcodes/dep-in.sed b/opcodes/dep-in.sed
index c30dee56..e373d4c 100644
--- a/opcodes/dep-in.sed
+++ b/opcodes/dep-in.sed
@@ -6,7 +6,9 @@
 s!\.o:!.lo:!
 s! @BFD_H@! $(BFD_H)!g
 s!@INCDIR@!$(INCDIR)!g
+s!@TOPDIR@/include!$(INCDIR)!g
 s!@BFDDIR@!$(BFDDIR)!g
+s!@TOPDIR@/bfd!$(BFDDIR)!g
 s!@SRCDIR@/!!g
 
 s/\\\n */ /g
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 7b4b858..d2271d8 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -1807,7 +1807,10 @@
     case 0x66:
       return (sizeflag & DFLAG) ? "data16" : "data32";
     case 0x67:
-      return (sizeflag & AFLAG) ? "addr16" : "addr32";
+      if (mode_64bit)
+        return (sizeflag & AFLAG) ? "addr32" : "addr64";
+      else
+        return ((sizeflag & AFLAG) && !mode_64bit) ? "addr16" : "addr32";
     case FWAIT_OPCODE:
       return "fwait";
     default:
@@ -2081,7 +2084,7 @@
       sizeflag ^= AFLAG;
       if (dp->bytemode3 != loop_jcxz_mode || intel_syntax)
 	{
-	  if (sizeflag & AFLAG)
+	  if ((sizeflag & AFLAG) || mode_64bit)
 	    oappend ("addr32 ");
 	  else
 	    oappend ("addr16 ");
@@ -2626,8 +2629,16 @@
 	    *obufp++ = 'b';
 	  break;
 	case 'E':		/* For jcxz/jecxz */
-	  if (sizeflag & AFLAG)
-	    *obufp++ = 'e';
+	  if (mode_64bit)
+	    {
+	      if (sizeflag & AFLAG)
+		*obufp++ = 'r';
+	      else
+		*obufp++ = 'e';
+	    }
+	  else
+	    if (sizeflag & AFLAG)
+	      *obufp++ = 'e';
 	  used_prefixes |= (prefixes & PREFIX_ADDR);
 	  break;
 	case 'F':
@@ -2636,9 +2647,9 @@
 	  if ((prefixes & PREFIX_ADDR) || (sizeflag & SUFFIX_ALWAYS))
 	    {
 	      if (sizeflag & AFLAG)
-		*obufp++ = 'l';
+		*obufp++ = mode_64bit ? 'q' : 'l';
 	      else
-		*obufp++ = 'w';
+		*obufp++ = mode_64bit ? 'l' : 'w';
 	      used_prefixes |= (prefixes & PREFIX_ADDR);
 	    }
 	  break;
@@ -3014,7 +3025,7 @@
   disp = 0;
   append_seg ();
 
-  if (sizeflag & AFLAG) /* 32 bit address mode */
+  if ((sizeflag & AFLAG) || mode_64bit) /* 32 bit address mode */
     {
       int havesib;
       int havebase;
@@ -3048,7 +3059,7 @@
 	  if ((base & 7) == 5)
 	    {
 	      havebase = 0;
-	      if (mode_64bit && !havesib)
+	      if (mode_64bit && !havesib && (sizeflag & AFLAG))
 		riprel = 1;
 	      disp = get32s ();
 	    }
@@ -3115,7 +3126,8 @@
 	  if (!havesib && (rex & REX_EXTZ))
 	    base += 8;
 	  if (havebase)
-	    oappend (mode_64bit ? names64[base] : names32[base]);
+	    oappend (mode_64bit && (sizeflag & AFLAG)
+		     ? names64[base] : names32[base]);
 	  if (havesib)
 	    {
 	      if (index != 4)
@@ -3128,11 +3140,13 @@
                           *obufp = '\0';
                         }
                       sprintf (scratchbuf, "%s",
-			       mode_64bit ? names64[index] : names32[index]);
+			       mode_64bit && (sizeflag & AFLAG)
+			       ? names64[index] : names32[index]);
                     }
                   else
 		    sprintf (scratchbuf, ",%s",
-			     mode_64bit ? names64[index] : names32[index]);
+			     mode_64bit && (sizeflag & AFLAG)
+			     ? names64[index] : names32[index]);
 		  oappend (scratchbuf);
 		}
               if (!intel_syntax
@@ -3703,7 +3717,7 @@
 
   append_seg ();
 
-  if (sizeflag & AFLAG)
+  if ((sizeflag & AFLAG) || mode_64bit)
     off = get32 ();
   else
     off = get16 ();
@@ -3764,7 +3778,12 @@
 
   USED_REX (REX_MODE64);
   if (rex & REX_MODE64)
-    s = names64[code - eAX_reg];
+    {
+      if (!(sizeflag & AFLAG))
+        s = names32[code - eAX_reg];
+      else
+        s = names64[code - eAX_reg];
+    }
   else if (sizeflag & AFLAG)
     s = names32[code - eAX_reg];
   else
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index 13eb728..9931a18 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -1,6 +1,6 @@
 /* Print mips instructions for GDB, the GNU debugger, or for objdump.
    Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp).
 
@@ -373,15 +373,21 @@
       break;
     case bfd_mach_mips_sb1:
       *cputype = CPU_SB1;
-      *isa = ISA_MIPS64 | INSN_SB1;
+      *isa = ISA_MIPS64 | INSN_MIPS3D | INSN_SB1;
       break;
     case bfd_mach_mipsisa32:
-      * cputype = CPU_MIPS32;
-      * isa = ISA_MIPS32;
+      *cputype = CPU_MIPS32;
+      /* For stock MIPS32, disassemble all applicable MIPS-specified ASEs.
+	 Note that MIPS-3D is not applicable to MIPS32.  (See _MIPS32
+	 Architecture For Programmers Volume I: Introduction to the
+	 MIPS32 Architecture_ (MIPS Document Number MD00082, Revision 0.95),
+	 page 1.  */
+      *isa = ISA_MIPS32;
       break;
     case bfd_mach_mipsisa64:
-      * cputype = CPU_MIPS64;
-      * isa = ISA_MIPS64;
+      *cputype = CPU_MIPS64;
+      /* For stock MIPS64, disassemble all applicable MIPS-specified ASEs.  */
+      *isa = ISA_MIPS64 | INSN_MIPS3D;
       break;
 
     default:
@@ -397,10 +403,14 @@
 is_newabi (header)
      Elf_Internal_Ehdr *header;
 {
-  if ((header->e_flags
-       & (E_MIPS_ABI_EABI32 | E_MIPS_ABI_EABI64 | EF_MIPS_ABI2)) != 0
-      || (header->e_ident[EI_CLASS] == ELFCLASS64
-	  && (header->e_flags & E_MIPS_ABI_O64) == 0))
+  /* There are no old-style ABIs which use 64-bit ELF.  */
+  if (header->e_ident[EI_CLASS] == ELFCLASS64)
+    return 1;
+
+  /* If a 32-bit ELF file, N32, EABI32, and EABI64 are new-style ABIs.  */
+  if ((header->e_flags & EF_MIPS_ABI2) != 0
+      || (header->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI32
+      || (header->e_flags & EF_MIPS_ABI) == E_MIPS_ABI_EABI64)
     return 1;
 
   return 0;
diff --git a/opcodes/mips-opc.c b/opcodes/mips-opc.c
index e2386e8..d3776d6 100644
--- a/opcodes/mips-opc.c
+++ b/opcodes/mips-opc.c
@@ -1,9 +1,10 @@
 /* mips-opc.c -- MIPS opcode list.
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Contributed by Ralph Campbell and OSF
    Commented and modified by Ian Lance Taylor, Cygnus Support
    Extended for MIPS32 support by Anders Norlander, and by SiByte, Inc.
+   MIPS-3D support added by Broadcom Corporation (SiByte).
 
 This file is part of GDB, GAS, and the GNU binutils.
 
@@ -82,6 +83,9 @@
 #define I32	INSN_ISA32
 #define I64     INSN_ISA64
 
+/* MIPS64 MIPS-3D ASE support.  */
+#define M3D     INSN_MIPS3D
+
 #define P3	INSN_4650
 #define L1	INSN_4010
 #define V1      INSN_4100
@@ -105,6 +109,9 @@
    immediate operands must apear after the same instruction with
    registers.
 
+   Because of the lookup algorithm used, entries with the same opcode
+   name must be contiguous.
+ 
    Many instructions are short hand for other instructions (i.e., The
    jal <register> instruction is short for jalr <register>).  */
 
@@ -114,7 +121,7 @@
    them first.  The assemblers uses a hash table based on the
    instruction name anyhow.  */
 /* name,    args,	match,	    mask,	pinfo,          	membership */
-{"pref",    "k,o(b)",   0xcc000000, 0xfc000000, RD_b,           	I32|G3	},
+{"pref",    "k,o(b)",   0xcc000000, 0xfc000000, RD_b,           	I4|I32|G3	},
 {"prefx",   "h,t(b)",	0x4c00000f, 0xfc0007ff, RD_b|RD_t,		I4	},
 {"nop",     "",         0x00000000, 0xffffffff, 0,              	I1      },
 {"ssnop",   "",         0x00000040, 0xffffffff, 0,              	I32	},
@@ -140,6 +147,7 @@
 {"add.ps",  "D,V,T",	0x46c00000, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	I5	},
 {"addi",    "t,r,j",	0x20000000, 0xfc000000,	WR_t|RD_s,		I1	},
 {"addiu",   "t,r,j",	0x24000000, 0xfc000000,	WR_t|RD_s,		I1	},
+{"addr.ps", "D,S,T",	0x46c00018, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	M3D	},
 {"addu",    "d,v,t",	0x00000021, 0xfc0007ff,	WR_d|RD_s|RD_t,		I1	},
 {"addu",    "t,r,I",	0,    (int) M_ADDU_I,	INSN_MACRO,		I1	},
 {"alnv.ps", "D,V,T,s",	0x4c00001e, 0xfc00003f,	WR_D|RD_S|RD_T|FP_D,	I5	},
@@ -150,22 +158,26 @@
 /* bal is at the top of the table.  */
 {"bc0f",    "p",	0x41000000, 0xffff0000,	CBD|RD_CC,		I1	},
 {"bc0fl",   "p",	0x41020000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
+{"bc0t",    "p",	0x41010000, 0xffff0000,	CBD|RD_CC,		I1	},
+{"bc0tl",   "p",	0x41030000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
+{"bc1any2f", "N,p",	0x45200000, 0xffe30000,	CBD|RD_CC|FP_S,		M3D	},
+{"bc1any2t", "N,p",	0x45210000, 0xffe30000,	CBD|RD_CC|FP_S,		M3D	},
+{"bc1any4f", "N,p",	0x45400000, 0xffe30000,	CBD|RD_CC|FP_S,		M3D	},
+{"bc1any4t", "N,p",	0x45410000, 0xffe30000,	CBD|RD_CC|FP_S,		M3D	},
 {"bc1f",    "p",	0x45000000, 0xffff0000,	CBD|RD_CC|FP_S,		I1	},
 {"bc1f",    "N,p",      0x45000000, 0xffe30000, CBD|RD_CC|FP_S, 	I4|I32	},
 {"bc1fl",   "p",	0x45020000, 0xffff0000,	CBL|RD_CC|FP_S,		I2|T3	},
 {"bc1fl",   "N,p",      0x45020000, 0xffe30000, CBL|RD_CC|FP_S, 	I4|I32	},
-{"bc2f",    "p",	0x49000000, 0xffff0000,	CBD|RD_CC,		I1	},
-{"bc2fl",   "p",	0x49020000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
-{"bc3f",    "p",	0x4d000000, 0xffff0000,	CBD|RD_CC,		I1	},
-{"bc3fl",   "p",	0x4d020000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
-{"bc0t",    "p",	0x41010000, 0xffff0000,	CBD|RD_CC,		I1	},
-{"bc0tl",   "p",	0x41030000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
 {"bc1t",    "p",	0x45010000, 0xffff0000,	CBD|RD_CC|FP_S,		I1	},
 {"bc1t",    "N,p",      0x45010000, 0xffe30000, CBD|RD_CC|FP_S, 	I4|I32	},
 {"bc1tl",   "p",	0x45030000, 0xffff0000,	CBL|RD_CC|FP_S,		I2|T3	},
 {"bc1tl",   "N,p",      0x45030000, 0xffe30000, CBL|RD_CC|FP_S, 	I4|I32	},
+{"bc2f",    "p",	0x49000000, 0xffff0000,	CBD|RD_CC,		I1	},
+{"bc2fl",   "p",	0x49020000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
 {"bc2t",    "p",	0x49010000, 0xffff0000,	CBD|RD_CC,		I1	},
 {"bc2tl",   "p",	0x49030000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
+{"bc3f",    "p",	0x4d000000, 0xffff0000,	CBD|RD_CC,		I1	},
+{"bc3fl",   "p",	0x4d020000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
 {"bc3t",    "p",	0x4d010000, 0xffff0000,	CBD|RD_CC,		I1	},
 {"bc3tl",   "p",	0x4d030000, 0xffff0000,	CBL|RD_CC,		I2|T3	},
 {"beqz",    "s,p",	0x10000000, 0xfc1f0000,	CBD|RD_s,		I1	},
@@ -324,6 +336,54 @@
 {"c.ngt.s", "M,S,T",    0x4600003f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S,   I4|I32	},
 {"c.ngt.ps","S,T",	0x46c0003f, 0xffe007ff,	RD_S|RD_T|WR_CC|FP_D,	I5	},
 {"c.ngt.ps","M,S,T",	0x46c0003f, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	I5	},
+{"cabs.eq.d",  "M,S,T",	0x46200072, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.eq.ps", "M,S,T",	0x46c00072, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.eq.s",  "M,S,T",	0x46000072, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.f.d",   "M,S,T",	0x46200070, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.f.ps",  "M,S,T",	0x46c00070, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.f.s",   "M,S,T",	0x46000070, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.le.d",  "M,S,T",	0x4620007e, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.le.ps", "M,S,T",	0x46c0007e, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.le.s",  "M,S,T",	0x4600007e, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.lt.d",  "M,S,T",	0x4620007c, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.lt.ps", "M,S,T",	0x46c0007c, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.lt.s",  "M,S,T",	0x4600007c, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.nge.d", "M,S,T",	0x4620007d, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.nge.ps","M,S,T",	0x46c0007d, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.nge.s", "M,S,T",	0x4600007d, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ngl.d", "M,S,T",	0x4620007b, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ngl.ps","M,S,T",	0x46c0007b, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ngl.s", "M,S,T",	0x4600007b, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ngle.d","M,S,T",	0x46200079, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ngle.ps","M,S,T",0x46c00079, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ngle.s","M,S,T",	0x46000079, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ngt.d", "M,S,T",	0x4620007f, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ngt.ps","M,S,T",	0x46c0007f, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ngt.s", "M,S,T",	0x4600007f, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ole.d", "M,S,T",	0x46200076, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ole.ps","M,S,T",	0x46c00076, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ole.s", "M,S,T",	0x46000076, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.olt.d", "M,S,T",	0x46200074, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.olt.ps","M,S,T",	0x46c00074, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.olt.s", "M,S,T",	0x46000074, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.seq.d", "M,S,T",	0x4620007a, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.seq.ps","M,S,T",	0x46c0007a, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.seq.s", "M,S,T",	0x4600007a, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.sf.d",  "M,S,T",	0x46200078, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.sf.ps", "M,S,T",	0x46c00078, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.sf.s",  "M,S,T",	0x46000078, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ueq.d", "M,S,T",	0x46200073, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ueq.ps","M,S,T",	0x46c00073, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ueq.s", "M,S,T",	0x46000073, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ule.d", "M,S,T",	0x46200077, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ule.ps","M,S,T",	0x46c00077, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ule.s", "M,S,T",	0x46000077, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.ult.d", "M,S,T",	0x46200075, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ult.ps","M,S,T",	0x46c00075, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.ult.s", "M,S,T",	0x46000075, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
+{"cabs.un.d",  "M,S,T",	0x46200071, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.un.ps", "M,S,T",	0x46c00071, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_D,	M3D	},
+{"cabs.un.s",  "M,S,T",	0x46000071, 0xffe000ff,	RD_S|RD_T|WR_CC|FP_S,	M3D	},
 {"cache",   "k,o(b)",   0xbc000000, 0xfc000000, RD_b,           	I3|I32|T3},
 {"ceil.l.d", "D,S",	0x4620000a, 0xffff003f, WR_D|RD_S|FP_D,		I3	},
 {"ceil.l.s", "D,S",	0x4600000a, 0xffff003f, WR_D|RD_S|FP_S,		I3	},
@@ -353,7 +413,9 @@
 {"cvt.s.pu","D,S",	0x46c00020, 0xffff003f,	WR_D|RD_S|FP_S|FP_D,	I5	},
 {"cvt.w.d", "D,S",	0x46200024, 0xffff003f,	WR_D|RD_S|FP_D,		I1	},
 {"cvt.w.s", "D,S",	0x46000024, 0xffff003f,	WR_D|RD_S|FP_S,		I1	},
+{"cvt.ps.pw", "D,S",	0x46800026, 0xffff003f,	WR_D|RD_S|FP_S|FP_D,	M3D	},
 {"cvt.ps.s","D,V,T",	0x46000026, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	I5	},
+{"cvt.pw.ps", "D,S",	0x46c00024, 0xffff003f,	WR_D|RD_S|FP_S|FP_D,	M3D	},
 {"dabs",    "d,v",	0,    (int) M_DABS,	INSN_MACRO,		I3	},
 {"dadd",    "d,v,t",	0x0000002c, 0xfc0007ff, WR_d|RD_s|RD_t,		I3	},
 {"dadd",    "t,r,I",	0,    (int) M_DADD_I,	INSN_MACRO,		I3	},
@@ -583,6 +645,7 @@
 {"ffc",     "d,v",	0x0000000b, 0xfc1f07ff,	WR_d|RD_s,		L1	},
 {"movn.d",  "D,S,t",    0x46200013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D,    I4|I32	},
 {"movn.s",  "D,S,t",    0x46000013, 0xffe0003f, WR_D|RD_S|RD_t|FP_S,    I4|I32	},
+{"movn.ps", "D,S,t",    0x46c00013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D,    I5	},
 {"movt",    "d,s,N",    0x00010001, 0xfc0307ff, WR_d|RD_s|RD_CC,        I4|I32	},
 {"movt.d",  "D,S,N",    0x46210011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D,   I4|I32	},
 {"movt.s",  "D,S,N",    0x46010011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_S,   I4|I32	},
@@ -591,6 +654,7 @@
 {"ffs",     "d,v",	0x0000000a, 0xfc1f07ff,	WR_d|RD_s,		L1	},
 {"movz.d",  "D,S,t",    0x46200012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D,    I4|I32	},
 {"movz.s",  "D,S,t",    0x46000012, 0xffe0003f, WR_D|RD_S|RD_t|FP_S,    I4|I32	},
+{"movz.ps", "D,S,t",    0x46c00012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D,    I5	},
 /* move is at the top of the table.  */
 {"msub.d",  "D,R,S,T",	0x4c000029, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, I4	},
 {"msub.s",  "D,R,S,T",	0x4c000028, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, I4	},
@@ -621,6 +685,7 @@
 {"mulo",    "d,v,I",	0,    (int) M_MULO_I,	INSN_MACRO,		I1	},
 {"mulou",   "d,v,t",	0,    (int) M_MULOU,	INSN_MACRO,		I1	},
 {"mulou",   "d,v,I",	0,    (int) M_MULOU_I,	INSN_MACRO,		I1	},
+{"mulr.ps", "D,S,T",	0x46c0001a, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	M3D	},
 {"mult",    "s,t",      0x00000018, 0xfc00ffff, RD_s|RD_t|WR_HILO|IS_M, I1	},
 {"mult",    "d,s,t",    0x00000018, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d|IS_M, G1	},
 {"multu",   "s,t",      0x00000019, 0xfc00ffff, RD_s|RD_t|WR_HILO|IS_M, I1	},
@@ -653,8 +718,14 @@
 {"puu.ps",  "D,V,T",	0x46c0002f, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	I5	},
 
 {"recip.d", "D,S",	0x46200015, 0xffff003f, WR_D|RD_S|FP_D,		I4	},
-{"recip.s", "D,S",	0x46000015, 0xffff003f, WR_D|RD_S|FP_S,		I4	},
 {"recip.ps","D,S",	0x46c00015, 0xffff003f, WR_D|RD_S|FP_D,		SB1	},
+{"recip.s", "D,S",	0x46000015, 0xffff003f, WR_D|RD_S|FP_S,		I4	},
+{"recip1.d",  "D,S",	0x4620001d, 0xffff003f,	WR_D|RD_S|FP_D,		M3D	},
+{"recip1.ps", "D,S",	0x46c0001d, 0xffff003f,	WR_D|RD_S|FP_S,		M3D	},
+{"recip1.s",  "D,S",	0x4600001d, 0xffff003f,	WR_D|RD_S|FP_S,		M3D	},
+{"recip2.d",  "D,S,T",	0x4620001c, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	M3D	},
+{"recip2.ps", "D,S,T",	0x46c0001c, 0xffe0003f,	WR_D|RD_S|RD_T|FP_S,	M3D	},
+{"recip2.s",  "D,S,T",	0x4600001c, 0xffe0003f,	WR_D|RD_S|RD_T|FP_S,	M3D	},
 {"rem",     "z,s,t",    0x0000001a, 0xfc00ffff, RD_s|RD_t|WR_HILO,      I1	},
 {"rem",     "d,v,t",	0,    (int) M_REM_3,	INSN_MACRO,		I1	},
 {"rem",     "d,v,I",	0,    (int) M_REM_3I,	INSN_MACRO,		I1	},
@@ -671,8 +742,14 @@
 {"round.w.d", "D,S",	0x4620000c, 0xffff003f, WR_D|RD_S|FP_D,		I2	},
 {"round.w.s", "D,S",	0x4600000c, 0xffff003f, WR_D|RD_S|FP_S,		I2	},
 {"rsqrt.d", "D,S",	0x46200016, 0xffff003f, WR_D|RD_S|FP_D,		I4	},
-{"rsqrt.s", "D,S",	0x46000016, 0xffff003f, WR_D|RD_S|FP_S,		I4	},
 {"rsqrt.ps","D,S",	0x46c00016, 0xffff003f, WR_D|RD_S|FP_D,		SB1	},
+{"rsqrt.s", "D,S",	0x46000016, 0xffff003f, WR_D|RD_S|FP_S,		I4	},
+{"rsqrt1.d",  "D,S",	0x4620001e, 0xffff003f,	WR_D|RD_S|FP_D,		M3D	},
+{"rsqrt1.ps", "D,S",	0x46c0001e, 0xffff003f,	WR_D|RD_S|FP_S,		M3D	},
+{"rsqrt1.s",  "D,S",	0x4600001e, 0xffff003f,	WR_D|RD_S|FP_S,		M3D	},
+{"rsqrt2.d",  "D,S,T",	0x4620001f, 0xffe0003f,	WR_D|RD_S|RD_T|FP_D,	M3D	},
+{"rsqrt2.ps", "D,S,T",	0x46c0001f, 0xffe0003f,	WR_D|RD_S|RD_T|FP_S,	M3D	},
+{"rsqrt2.s",  "D,S,T",	0x4600001f, 0xffe0003f,	WR_D|RD_S|RD_T|FP_S,	M3D	},
 {"sb",      "t,o(b)",	0xa0000000, 0xfc000000,	SM|RD_t|RD_b,		I1	},
 {"sb",      "t,A(b)",	0,    (int) M_SB_AB,	INSN_MACRO,		I1	},
 {"sc",	    "t,o(b)",	0xe0000000, 0xfc000000, SM|RD_t|WR_t|RD_b,	I2	},
diff --git a/opcodes/pdp11-dis.c b/opcodes/pdp11-dis.c
index 850248e..507db93 100644
--- a/opcodes/pdp11-dis.c
+++ b/opcodes/pdp11-dis.c
@@ -1,5 +1,5 @@
 /* Print DEC PDP-11 instructions.
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
 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
@@ -38,6 +38,8 @@
 static void print_freg PARAMS ((int freg, disassemble_info *info));
 static int print_operand PARAMS ((bfd_vma *memaddr, int code,
 				  disassemble_info *info));
+static int print_foperand PARAMS ((bfd_vma *memaddr, int code,
+                                   disassemble_info *info));
 int print_insn_pdp11 PARAMS ((bfd_vma memaddr, disassemble_info *info));
 
 static int
@@ -165,8 +167,10 @@
       if (reg == 7)
 	{
 	  bfd_vma address = *memaddr + sign_extend (disp);
+	  if (mode == 7)
+	    FPRINTF (F, "*");
 	  if (!(code & JUMP))
-	    FPRINTF (F, "*$");
+	    FPRINTF (F, "$");
 	  (*info->print_address_func) (address, info);
 	}
       else
@@ -184,6 +188,23 @@
   return 0;
 }
 
+static int
+print_foperand (memaddr, code, info)
+     bfd_vma *memaddr;
+     int code;
+     disassemble_info *info;
+{
+  int mode = (code >> 3) & 7;
+  int reg = code & 7;
+
+  if (mode == 0)
+    print_freg (reg, info);
+  else
+    return print_operand (memaddr, code, info);
+
+  return 0;
+}
+
 /* Print the PDP-11 instruction at address MEMADDR in debugged memory,
    on INFO->STREAM.  Returns length of the instruction, in bytes.  */
 
@@ -230,6 +251,14 @@
 	    if (print_operand (&memaddr, dst, info) < 0)
 	      return -1;
 	    goto done;
+	  case PDP11_OPCODE_FOP:
+	    FPRINTF (F, OP.name);
+	    FPRINTF (F, AFTER_INSTRUCTION);
+	    if (strcmp (OP.name, "jmp") == 0)
+	      dst |= JUMP;
+	    if (print_foperand (&memaddr, dst, info) < 0)
+	      return -1;
+	    goto done;
 	  case PDP11_OPCODE_REG_OP:
 	    FPRINTF (F, OP.name);
 	    FPRINTF (F, AFTER_INSTRUCTION);
@@ -248,6 +277,28 @@
 	    FPRINTF (F, OPERAND_SEPARATOR);
 	    print_reg (src, info);
 	    goto done;
+	  case PDP11_OPCODE_AC_FOP:
+	    {
+	      int ac = (opcode & 0xe0) >> 6;
+	      FPRINTF (F, OP.name);
+	      FPRINTF (F, AFTER_INSTRUCTION);
+	      print_freg (ac, info);
+	      FPRINTF (F, OPERAND_SEPARATOR);
+	      if (print_foperand (&memaddr, dst, info) < 0)
+		return -1;
+	      goto done;
+	    }
+	  case PDP11_OPCODE_FOP_AC:
+	    {
+	      int ac = (opcode & 0xe0) >> 6;
+	      FPRINTF (F, OP.name);
+	      FPRINTF (F, AFTER_INSTRUCTION);
+	      if (print_foperand (&memaddr, dst, info) < 0)
+		return -1;
+	      FPRINTF (F, OPERAND_SEPARATOR);
+	      print_freg (ac, info);
+	      goto done;
+	    }
 	  case PDP11_OPCODE_AC_OP:
 	    {
 	      int ac = (opcode & 0xe0) >> 6;
@@ -259,6 +310,17 @@
 		return -1;
 	      goto done;
 	    }
+	  case PDP11_OPCODE_OP_AC:
+	    {
+	      int ac = (opcode & 0xe0) >> 6;
+	      FPRINTF (F, OP.name);
+	      FPRINTF (F, AFTER_INSTRUCTION);
+	      if (print_operand (&memaddr, dst, info) < 0)
+		return -1;
+	      FPRINTF (F, OPERAND_SEPARATOR);
+	      print_freg (ac, info);
+	      goto done;
+	    }
 	  case PDP11_OPCODE_OP_OP:
 	    FPRINTF (F, OP.name);
 	    FPRINTF (F, AFTER_INSTRUCTION);
diff --git a/opcodes/pdp11-opc.c b/opcodes/pdp11-opc.c
index 3517dee..7445cde 100644
--- a/opcodes/pdp11-opc.c
+++ b/opcodes/pdp11-opc.c
@@ -1,5 +1,5 @@
 /* Opcode table for PDP-11.
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
 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
@@ -86,7 +86,7 @@
   { "rol",	0x0c40, 0xffc0, PDP11_OPCODE_OP,	PDP11_BASIC },
   { "asr",	0x0c80, 0xffc0, PDP11_OPCODE_OP,	PDP11_BASIC },
   { "asl",	0x0cc0, 0xffc0, PDP11_OPCODE_OP,	PDP11_BASIC },
-  { "mark",	0x0d00, 0xffc0, PDP11_OPCODE_OP,	PDP11_LEIS },
+  { "mark",	0x0d00, 0xffc0, PDP11_OPCODE_IMM6,	PDP11_LEIS },
   { "mfpi",	0x0d40, 0xffc0, PDP11_OPCODE_OP,	PDP11_BASIC },
   { "mtpi",	0x0d80, 0xffc0, PDP11_OPCODE_OP,	PDP11_BASIC },
   { "sxt",	0x0dc0, 0xffc0, PDP11_OPCODE_OP,	PDP11_LEIS },
@@ -211,24 +211,28 @@
   { "ldfps",	0xf040, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
   { "stfps",	0xf080, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
   { "stst",	0xf0c0, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
-  { "clrf",	0xf100, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
-  { "tstf",	0xf140, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
-  { "absf",	0xf180, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
-  { "negf",	0xf1c0, 0xffc0, PDP11_OPCODE_OP,	PDP11_FPP },
-  { "mulf",	0xf200, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "modf",	0xf300, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "addf",	0xf400, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "ldf",	0xf500, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },/*movif*/
-  { "subf",	0xf600, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "cmpf",	0xf700, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "stf",	0xf800, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },/*movfi*/
-  { "divf",	0xf900, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
+  { "clrf",	0xf100, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "tstf",	0xf140, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "absf",	0xf180, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "negf",	0xf1c0, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "mulf",	0xf200, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "modf",	0xf300, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "addf",	0xf400, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "ldf",	0xf500, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },/*movif*/
+  { "subf",	0xf600, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "cmpf",	0xf700, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "stf",	0xf800, 0xff00, PDP11_OPCODE_AC_FOP,	PDP11_FPP },/*movfi*/
+  { "divf",	0xf900, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
   { "stexp",	0xfa00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
   { "stcfi",	0xfb00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "stcff",	0xfc00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },/* ? */
-  { "ldexp",	0xfd00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "ldcif",	0xfe00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
-  { "ldcff",	0xff00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },/* ? */
+  { "stcff",	0xfc00, 0xff00, PDP11_OPCODE_AC_FOP,	PDP11_FPP },/* ? */
+  { "ldexp",	0xfd00, 0xff00, PDP11_OPCODE_OP_AC,	PDP11_FPP },
+  { "ldcif",	0xfe00, 0xff00, PDP11_OPCODE_OP_AC,	PDP11_FPP },
+  { "ldcff",	0xff00, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },/* ? */
+/* This entry MUST be last; it is a "catch-all" entry that will match when no
+ * other opcode entry matches during disassembly.
+ */
+  { "",		0x0000, 0x0000, PDP11_OPCODE_ILLEGAL,	PDP11_NONE },
 };
 
 const struct pdp11_opcode pdp11_aliases[] =
@@ -239,6 +243,29 @@
   { "bhis",	0x8600, 0xff00, PDP11_OPCODE_DISPL,	PDP11_BASIC },
   { "blo",	0x8700, 0xff00, PDP11_OPCODE_DISPL,	PDP11_BASIC },
   { "trap",	0x8900, 0xff00, PDP11_OPCODE_IMM8,	PDP11_BASIC },
+  /* fpp xxxd alternate names to xxxf opcodes */
+  { "clrd",	0xf100, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "tstd",	0xf140, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "absd",	0xf180, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "negd",	0xf1c0, 0xffc0, PDP11_OPCODE_FOP,	PDP11_FPP },
+  { "muld",	0xf200, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "modd",	0xf300, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "addd",	0xf400, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "ldd",	0xf500, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },/*movif*/
+  { "subd",	0xf600, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "cmpd",	0xf700, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "std",	0xf800, 0xff00, PDP11_OPCODE_AC_FOP,	PDP11_FPP },/*movfi*/
+  { "divd",	0xf900, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },
+  { "stcfl",	0xfb00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
+  { "stcdi",	0xfb00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
+  { "stcdl",	0xfb00, 0xff00, PDP11_OPCODE_AC_OP,	PDP11_FPP },
+  { "stcfd",	0xfc00, 0xff00, PDP11_OPCODE_AC_FOP,	PDP11_FPP },/* ? */
+  { "stcdf",	0xfc00, 0xff00, PDP11_OPCODE_AC_FOP,	PDP11_FPP },/* ? */
+  { "ldcid",	0xfe00, 0xff00, PDP11_OPCODE_OP_AC,	PDP11_FPP },
+  { "ldclf",	0xfe00, 0xff00, PDP11_OPCODE_OP_AC,	PDP11_FPP },
+  { "ldcld",	0xfe00, 0xff00, PDP11_OPCODE_OP_AC,	PDP11_FPP },
+  { "ldcfd",	0xff00, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },/* ? */
+  { "ldcdf",	0xff00, 0xff00, PDP11_OPCODE_FOP_AC,	PDP11_FPP },/* ? */
 };
 
 const int pdp11_num_opcodes = sizeof pdp11_opcodes / sizeof pdp11_opcodes[0];
diff --git a/opcodes/po/fr.po b/opcodes/po/fr.po
index 3853414..e1806b0 100644
--- a/opcodes/po/fr.po
+++ b/opcodes/po/fr.po
@@ -5,8 +5,8 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: opcodes 2.12-pre020121\n"
-"POT-Creation-Date: 2002-01-31 17:10+0000\n"
-"PO-Revision-Date: 2002-01-25 08:00-0500\n"
+"POT-Creation-Date: 2002-01-17 13:58+0000\n"
+"PO-Revision-Date: 2002-03-17 20:00-0500\n"
 "Last-Translator: Michel Robitaille <robitail@IRO.UMontreal.CA>\n"
 "Language-Team: French <traduc@traduc.org>\n"
 "MIME-Version: 1.0\n"
@@ -25,21 +25,21 @@
 msgid "Illegal limm reference in last instruction!\n"
 msgstr "Référence limite illégale dans la dernière instruction!\n"
 
-#: arm-dis.c:502
+#: arm-dis.c:509
 msgid "<illegal precision>"
 msgstr "<précision illégale>"
 
-#: arm-dis.c:1012
+#: arm-dis.c:1019
 #, c-format
 msgid "Unrecognised register name set: %s\n"
 msgstr "Nom de jeu de registres inconnu: %s\n"
 
-#: arm-dis.c:1019
+#: arm-dis.c:1026
 #, c-format
 msgid "Unrecognised disassembler option: %s\n"
 msgstr "Option du désassembleur non reconnue: %s\n"
 
-#: arm-dis.c:1191
+#: arm-dis.c:1198
 msgid ""
 "\n"
 "The following ARM specific disassembler options are supported for use with\n"
@@ -60,10 +60,9 @@
 #: avr-dis.c:228
 #, c-format
 msgid "unknown constraint `%c'"
-msgstr "contrainte inconnue `%c'"
+msgstr "contrainte inconnue « %c »"
 
 #: cgen-asm.c:346 fr30-ibld.c:195 m32r-ibld.c:195 openrisc-ibld.c:195
-#: xstormy16-ibld.c:195
 #, c-format
 msgid "operand out of range (%ld not between %ld and %ld)"
 msgstr "opérande hors gamme (%ld n'est pas entre %ld et %ld)"
@@ -89,101 +88,94 @@
 msgid "Address 0x%x is out of bounds.\n"
 msgstr "Adresse 0x%x est hors gamme.\n"
 
-#: fr30-asm.c:323 m32r-asm.c:325 openrisc-asm.c:244 xstormy16-asm.c:231
+#: fr30-asm.c:324 m32r-asm.c:326 openrisc-asm.c:245
 #, c-format
 msgid "Unrecognized field %d while parsing.\n"
 msgstr "Champ non reconnu %d lors de l'analyse.\n"
 
-#: fr30-asm.c:373 m32r-asm.c:375 openrisc-asm.c:294 xstormy16-asm.c:281
+#: fr30-asm.c:374 m32r-asm.c:376 openrisc-asm.c:295
 msgid "missing mnemonic in syntax string"
 msgstr "mnémonique manquante dans la syntaxe de la chaîne"
 
 #. We couldn't parse it.
-#: fr30-asm.c:509 fr30-asm.c:513 fr30-asm.c:600 fr30-asm.c:702 m32r-asm.c:511
-#: m32r-asm.c:515 m32r-asm.c:602 m32r-asm.c:704 openrisc-asm.c:430
-#: openrisc-asm.c:434 openrisc-asm.c:521 openrisc-asm.c:623
-#: xstormy16-asm.c:417 xstormy16-asm.c:421 xstormy16-asm.c:508
-#: xstormy16-asm.c:610
+#: fr30-asm.c:510 fr30-asm.c:514 fr30-asm.c:601 fr30-asm.c:703 m32r-asm.c:512 m32r-asm.c:516 m32r-asm.c:603 m32r-asm.c:705 openrisc-asm.c:431 openrisc-asm.c:435 openrisc-asm.c:522 openrisc-asm.c:624
 msgid "unrecognized instruction"
 msgstr "instruction non reconnue"
 
-#: fr30-asm.c:556 m32r-asm.c:558 openrisc-asm.c:477 xstormy16-asm.c:464
+#: fr30-asm.c:557 m32r-asm.c:559 openrisc-asm.c:478
 #, c-format
 msgid "syntax error (expected char `%c', found `%c')"
-msgstr "erreur de syntaxe (caractère `%c' attendu,  `%c' obtenu)"
+msgstr "erreur de syntaxe (caractère « %c » attendu,  « %c » obtenu)"
 
-#: fr30-asm.c:566 m32r-asm.c:568 openrisc-asm.c:487 xstormy16-asm.c:474
+#: fr30-asm.c:567 m32r-asm.c:569 openrisc-asm.c:488
 #, c-format
 msgid "syntax error (expected char `%c', found end of instruction)"
-msgstr ""
-"erreur de syntaxe (caractère `%c' attendu, fin de l'instruction obtenue)"
+msgstr "erreur de syntaxe (caractère « %c » attendu, fin de l'instruction obtenue)"
 
-#: fr30-asm.c:594 m32r-asm.c:596 openrisc-asm.c:515 xstormy16-asm.c:502
+#: fr30-asm.c:595 m32r-asm.c:597 openrisc-asm.c:516
 msgid "junk at end of line"
 msgstr "rebut à la fin de la ligne"
 
-#: fr30-asm.c:701 m32r-asm.c:703 openrisc-asm.c:622 xstormy16-asm.c:609
+#: fr30-asm.c:702 m32r-asm.c:704 openrisc-asm.c:623
 msgid "unrecognized form of instruction"
 msgstr "forme d'instruction non reconnue"
 
-#: fr30-asm.c:713 m32r-asm.c:715 openrisc-asm.c:634 xstormy16-asm.c:621
+#: fr30-asm.c:714 m32r-asm.c:716 openrisc-asm.c:635
 #, c-format
 msgid "bad instruction `%.50s...'"
-msgstr "instruction erronée `%.50s...'"
+msgstr "instruction erronée « %.50s... »"
 
-#: fr30-asm.c:716 m32r-asm.c:718 openrisc-asm.c:637 xstormy16-asm.c:624
+#: fr30-asm.c:717 m32r-asm.c:719 openrisc-asm.c:638
 #, c-format
 msgid "bad instruction `%.50s'"
-msgstr "instruction erronée `%.50s'"
+msgstr "instruction erronée « %.50s »"
 
 #. Default text to print if an instruction isn't recognized.
 #: fr30-dis.c:39 m32r-dis.c:39 mmix-dis.c:282 openrisc-dis.c:39
-#: xstormy16-dis.c:39
 msgid "*unknown*"
 msgstr "*inconnu*"
 
-#: fr30-dis.c:318 m32r-dis.c:249 openrisc-dis.c:136 xstormy16-dis.c:169
+#: fr30-dis.c:319 m32r-dis.c:250 openrisc-dis.c:137
 #, c-format
 msgid "Unrecognized field %d while printing insn.\n"
 msgstr "Champ non reconnu %d lors de l'impression insn.\n"
 
-#: fr30-ibld.c:166 m32r-ibld.c:166 openrisc-ibld.c:166 xstormy16-ibld.c:166
+#: fr30-ibld.c:166 m32r-ibld.c:166 openrisc-ibld.c:166
 #, c-format
 msgid "operand out of range (%ld not between %ld and %lu)"
 msgstr "opérande hors gamme (%ld n'est pas entre %ld et %lu)"
 
-#: fr30-ibld.c:179 m32r-ibld.c:179 openrisc-ibld.c:179 xstormy16-ibld.c:179
+#: fr30-ibld.c:179 m32r-ibld.c:179 openrisc-ibld.c:179
 #, c-format
 msgid "operand out of range (%lu not between 0 and %lu)"
 msgstr "opérande hors gamme (%lu n'est pas entre 0 et %lu)"
 
-#: fr30-ibld.c:730 m32r-ibld.c:659 openrisc-ibld.c:633 xstormy16-ibld.c:678
+#: fr30-ibld.c:731 m32r-ibld.c:660 openrisc-ibld.c:634
 #, c-format
 msgid "Unrecognized field %d while building insn.\n"
 msgstr "Champ non reconnu %d lors de la construction de insn.\n"
 
-#: fr30-ibld.c:937 m32r-ibld.c:792 openrisc-ibld.c:735 xstormy16-ibld.c:826
+#: fr30-ibld.c:939 m32r-ibld.c:794 openrisc-ibld.c:737
 #, c-format
 msgid "Unrecognized field %d while decoding insn.\n"
 msgstr "Champ non reconnu %d lors du décodage de insn.\n"
 
-#: fr30-ibld.c:1086 m32r-ibld.c:902 openrisc-ibld.c:815 xstormy16-ibld.c:939
+#: fr30-ibld.c:1088 m32r-ibld.c:904 openrisc-ibld.c:817
 #, c-format
 msgid "Unrecognized field %d while getting int operand.\n"
 msgstr "Champ non reconnu %d lors de la prise d'une opérande int.\n"
 
-#: fr30-ibld.c:1215 m32r-ibld.c:992 openrisc-ibld.c:875 xstormy16-ibld.c:1032
+#: fr30-ibld.c:1217 m32r-ibld.c:994 openrisc-ibld.c:877
 #, c-format
 msgid "Unrecognized field %d while getting vma operand.\n"
 msgstr "Champ non reconnu %d lors de la prise d'une opérande vma.\n"
 
-#: fr30-ibld.c:1349 m32r-ibld.c:1090 openrisc-ibld.c:944 xstormy16-ibld.c:1134
+#: fr30-ibld.c:1351 m32r-ibld.c:1092 openrisc-ibld.c:946
 #, c-format
 msgid "Unrecognized field %d while setting int operand.\n"
 msgstr "Champ non reconnu %d lors de l'initialisation d'une opérande int.\n"
 
-#: fr30-ibld.c:1471 m32r-ibld.c:1176 openrisc-ibld.c:1001
-#: xstormy16-ibld.c:1224
+#: fr30-ibld.c:1473 m32r-ibld.c:1178 openrisc-ibld.c:1003
 #, c-format
 msgid "Unrecognized field %d while setting vma operand.\n"
 msgstr "Champ non reconnu %d lors de l'initialisation d'une opérande vma.\n"
@@ -289,9 +281,7 @@
 
 #: ppc-opc.c:800
 msgid "attempt to set y bit when using + or - modifier"
-msgstr ""
-"tentative d'initialisation du bit y lorsque le modificateur + ou - a été "
-"utilisé"
+msgstr "tentative d'initialisation du bit y lorsque le modificateur + ou - a été utilisé"
 
 #: ppc-opc.c:832 ppc-opc.c:884
 msgid "offset not a multiple of 4"
@@ -307,9 +297,7 @@
 
 #: ppc-opc.c:910
 msgid "ignoring least significant bits in branch offset"
-msgstr ""
-"Les derniers bits les moins significatifs sont ignorés dans le décalage de "
-"branchement"
+msgstr "Les derniers bits les moins significatifs sont ignorés dans le décalage de branchement"
 
 #: ppc-opc.c:944 ppc-opc.c:981
 msgid "illegal bitmask"
@@ -335,17 +323,17 @@
 #: sparc-dis.c:824
 #, c-format
 msgid "Internal error:  bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
-msgstr "Erreur interne:  sparc-opcode.h erroné: \"%s\", %#.8lx, %#.8lx\n"
+msgstr "Erreur interne:  sparc-opcode.h erroné: « %s », %#.8lx, %#.8lx\n"
 
 #: sparc-dis.c:835
 #, c-format
 msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
-msgstr "Erreur interne: sparc-opcode.h erroné: \"%s\", %#.8lx, %#.8lx\n"
+msgstr "Erreur interne: sparc-opcode.h erroné: « %s », %#.8lx, %#.8lx\n"
 
 #: sparc-dis.c:884
 #, c-format
 msgid "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"
-msgstr "Erreur interne: sparc-opcode.h erroné: \"%s\" == \"%s\"\n"
+msgstr "Erreur interne: sparc-opcode.h erroné: « %s » == « %s »\n"
 
 #: v850-dis.c:224
 #, c-format
@@ -406,36 +394,5 @@
 msgid "immediate value must be even"
 msgstr "La valeur immédiate doit être paire."
 
-#: xstormy16-asm.c:74
-#, fuzzy
-msgid "Bad register in preincrement"
-msgstr "registre index n'est pas dans la plage de chargement"
-
-#: xstormy16-asm.c:79
-#, fuzzy
-msgid "Bad register in postincrement"
-msgstr "registre invalide pour un ajustement de la pile"
-
-#: xstormy16-asm.c:81
-#, fuzzy
-msgid "Bad register name"
-msgstr "registre index n'est pas dans la plage de chargement"
-
-#: xstormy16-asm.c:85
-msgid "Label conflicts with register name"
-msgstr ""
-
-#: xstormy16-asm.c:89
-msgid "Label conflicts with `Rx'"
-msgstr ""
-
-#: xstormy16-asm.c:91
-msgid "Bad immediate expression"
-msgstr ""
-
-#: xstormy16-asm.c:120
-msgid "Small operand was not an immediate number"
-msgstr ""
-
 #~ msgid "unrecognized keyword/register name"
 #~ msgstr "nom de mot clé ou de registre non reconnu"
diff --git a/opcodes/po/id.po b/opcodes/po/id.po
new file mode 100644
index 0000000..3c69b4b
--- /dev/null
+++ b/opcodes/po/id.po
@@ -0,0 +1,395 @@
+# opcodes 2.12-pre020121 (Indonesian)
+# Copyright (C) 2002 Free Software Foundation, Inc.
+# Tedi Heriyanto <tedi_h@gmx.net>, 2002.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: opcodes 2.12-pre020121\n"
+"POT-Creation-Date: 2002-01-17 13:58+0000\n"
+"PO-Revision-Date: 2002-04-02 08:20GMT+0700\n"
+"Last-Translator: Tedi Heriyanto <tedi_h@gmx.net>\n"
+"Language-Team: Indonesian <translation-team-id@lists.sourceforge.net>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 0.9.5\n"
+
+#: alpha-opc.c:335
+msgid "branch operand unaligned"
+msgstr "operand cabang tidak rata"
+
+#: alpha-opc.c:358 alpha-opc.c:380
+msgid "jump hint unaligned"
+msgstr "petunjuk lompat tidak rata"
+
+#: arc-dis.c:52
+msgid "Illegal limm reference in last instruction!\n"
+msgstr "referensi limm ilegal dalam instruksi terakhir!\n"
+
+#: arm-dis.c:509
+msgid "<illegal precision>"
+msgstr "<presisi ilegal>"
+
+#: arm-dis.c:1019
+#, c-format
+msgid "Unrecognised register name set: %s\n"
+msgstr "Set nama register tidak dikenal: %s\n"
+
+#: arm-dis.c:1026
+#, c-format
+msgid "Unrecognised disassembler option: %s\n"
+msgstr "Option disasembler tidak dikenal: %s\n"
+
+#: arm-dis.c:1198
+msgid ""
+"\n"
+"The following ARM specific disassembler options are supported for use with\n"
+"the -M switch:\n"
+msgstr ""
+"\n"
+"Option disablembler khusus ARM berikut ini didukung untuk digunakan dengan\n"
+"switch -M:\n"
+
+#: avr-dis.c:118 avr-dis.c:128
+msgid "undefined"
+msgstr "tidak didefinisikan"
+
+#: avr-dis.c:180
+msgid "Internal disassembler error"
+msgstr "Kesalahan disasembler internal"
+
+#: avr-dis.c:228
+#, c-format
+msgid "unknown constraint `%c'"
+msgstr "konstrain tidak dikenal `%c'"
+
+#: cgen-asm.c:346 fr30-ibld.c:195 m32r-ibld.c:195 openrisc-ibld.c:195
+#, c-format
+msgid "operand out of range (%ld not between %ld and %ld)"
+msgstr "operand keluar batas (%ld tidak antara %ld dan %ld)"
+
+#: cgen-asm.c:367
+#, c-format
+msgid "operand out of range (%lu not between %lu and %lu)"
+msgstr "operand keluar batas (%lu tidak antara %lu dan %lu)"
+
+#: d30v-dis.c:312
+#, c-format
+msgid "<unknown register %d>"
+msgstr "<register tidak dikenal %d>"
+
+#. Can't happen.
+#: dis-buf.c:57
+#, c-format
+msgid "Unknown error %d\n"
+msgstr "Kesalahan tidak dikenal %d\n"
+
+#: dis-buf.c:62
+#, c-format
+msgid "Address 0x%x is out of bounds.\n"
+msgstr "Alamat 0x%x di luar batas.\n"
+
+#: fr30-asm.c:324 m32r-asm.c:326 openrisc-asm.c:245
+#, c-format
+msgid "Unrecognized field %d while parsing.\n"
+msgstr "Field tidak dikenal %d saat parsing.\n"
+
+#: fr30-asm.c:374 m32r-asm.c:376 openrisc-asm.c:295
+msgid "missing mnemonic in syntax string"
+msgstr "mnemonik hilang dalam string sintaks"
+
+#. We couldn't parse it.
+#: fr30-asm.c:510 fr30-asm.c:514 fr30-asm.c:601 fr30-asm.c:703 m32r-asm.c:512 m32r-asm.c:516 m32r-asm.c:603 m32r-asm.c:705 openrisc-asm.c:431 openrisc-asm.c:435 openrisc-asm.c:522 openrisc-asm.c:624
+msgid "unrecognized instruction"
+msgstr "instruksti tidak dikenal"
+
+#: fr30-asm.c:557 m32r-asm.c:559 openrisc-asm.c:478
+#, c-format
+msgid "syntax error (expected char `%c', found `%c')"
+msgstr "kesalahan sintaks (diharapkan karakter `%c', ditemukan `%c')"
+
+#: fr30-asm.c:567 m32r-asm.c:569 openrisc-asm.c:488
+#, c-format
+msgid "syntax error (expected char `%c', found end of instruction)"
+msgstr "kesalahan sintaks (diharapkan karakter `%c', ditemukan akhir instruksi)"
+
+#: fr30-asm.c:595 m32r-asm.c:597 openrisc-asm.c:516
+msgid "junk at end of line"
+msgstr "sampah di akhir baris"
+
+#: fr30-asm.c:702 m32r-asm.c:704 openrisc-asm.c:623
+msgid "unrecognized form of instruction"
+msgstr "bentuk instruksi tidak dikenal"
+
+#: fr30-asm.c:714 m32r-asm.c:716 openrisc-asm.c:635
+#, c-format
+msgid "bad instruction `%.50s...'"
+msgstr "instruksi buruk `%.50s...'"
+
+#: fr30-asm.c:717 m32r-asm.c:719 openrisc-asm.c:638
+#, c-format
+msgid "bad instruction `%.50s'"
+msgstr "instruksi buruk `%.50s'"
+
+#. Default text to print if an instruction isn't recognized.
+#: fr30-dis.c:39 m32r-dis.c:39 mmix-dis.c:282 openrisc-dis.c:39
+msgid "*unknown*"
+msgstr "*tidak dikenal*"
+
+#: fr30-dis.c:319 m32r-dis.c:250 openrisc-dis.c:137
+#, c-format
+msgid "Unrecognized field %d while printing insn.\n"
+msgstr "Field tidak dikenal %d saat mencetak insn.\n"
+
+#: fr30-ibld.c:166 m32r-ibld.c:166 openrisc-ibld.c:166
+#, c-format
+msgid "operand out of range (%ld not between %ld and %lu)"
+msgstr "operand di luar batas (%ld tidak antara %ld dan %lu)"
+
+#: fr30-ibld.c:179 m32r-ibld.c:179 openrisc-ibld.c:179
+#, c-format
+msgid "operand out of range (%lu not between 0 and %lu)"
+msgstr "operand di luar batas (%lu tidak antara 0 dan %lu)"
+
+#: fr30-ibld.c:731 m32r-ibld.c:660 openrisc-ibld.c:634
+#, c-format
+msgid "Unrecognized field %d while building insn.\n"
+msgstr "Field tidak dikenal %d saat membuild insn.\n"
+
+#: fr30-ibld.c:939 m32r-ibld.c:794 openrisc-ibld.c:737
+#, c-format
+msgid "Unrecognized field %d while decoding insn.\n"
+msgstr "Field tidak dikenal %d saat mendekode insn.\n"
+
+#: fr30-ibld.c:1088 m32r-ibld.c:904 openrisc-ibld.c:817
+#, c-format
+msgid "Unrecognized field %d while getting int operand.\n"
+msgstr "Field tidak dikenal %d saat memperoleh operand int.\n"
+
+#: fr30-ibld.c:1217 m32r-ibld.c:994 openrisc-ibld.c:877
+#, c-format
+msgid "Unrecognized field %d while getting vma operand.\n"
+msgstr "Field tidak dikenal %d saat memperoleh operand vma.\n"
+
+#: fr30-ibld.c:1351 m32r-ibld.c:1092 openrisc-ibld.c:946
+#, c-format
+msgid "Unrecognized field %d while setting int operand.\n"
+msgstr "Field tidak dikenal %d saat menset operand int.\n"
+
+#: fr30-ibld.c:1473 m32r-ibld.c:1178 openrisc-ibld.c:1003
+#, c-format
+msgid "Unrecognized field %d while setting vma operand.\n"
+msgstr "Field tidak dikenal %d saat menset operand vma.\n"
+
+#: h8300-dis.c:384
+#, c-format
+msgid "Hmmmm %x"
+msgstr "Hmmmm %x"
+
+#: h8300-dis.c:395
+#, c-format
+msgid "Don't understand %x \n"
+msgstr "Tidak mengerti %x \n"
+
+#: h8500-dis.c:143
+#, c-format
+msgid "can't cope with insert %d\n"
+msgstr "tidak dapat menangani insert %d\n"
+
+#. Couldn't understand anything.
+#: h8500-dis.c:350
+#, c-format
+msgid "%02x\t\t*unknown*"
+msgstr "%02x\t\t*tidak dikenal*"
+
+#: i386-dis.c:1649
+msgid "<internal disassembler error>"
+msgstr "<kesalahan asembler internal>"
+
+#: m10200-dis.c:199
+#, c-format
+msgid "unknown\t0x%02x"
+msgstr "tidak dikenal\t0x%02x"
+
+#: m10200-dis.c:339
+#, c-format
+msgid "unknown\t0x%04lx"
+msgstr "tidak dikenal\t0x%04lx"
+
+#: m10300-dis.c:685
+#, c-format
+msgid "unknown\t0x%04x"
+msgstr "tidak dikenal\t0x%04x"
+
+#: m68k-dis.c:429
+#, c-format
+msgid "<internal error in opcode table: %s %s>\n"
+msgstr "<kesalahan internal dalam tabel opcode: %s %s>\n"
+
+#: m68k-dis.c:1007
+#, c-format
+msgid "<function code %d>"
+msgstr "<kode fungsi %d>"
+
+#: m88k-dis.c:255
+#, c-format
+msgid "# <dis error: %08x>"
+msgstr "# <kesalahan dis: %08x>"
+
+#: mips-dis.c:290
+#, c-format
+msgid "# internal error, undefined modifier(%c)"
+msgstr "# kesalahan internal, modifier tidak didefinisikan(%c)"
+
+#: mips-dis.c:1154
+#, c-format
+msgid "# internal disassembler error, unrecognised modifier (%c)"
+msgstr "# kesalahan internal disasembler, modifier tidak dikenal (%c)"
+
+#: mmix-dis.c:34
+#, c-format
+msgid "Bad case %d (%s) in %s:%d\n"
+msgstr "Case buruk %d (%s) dalam %s:%d\n"
+
+#: mmix-dis.c:44
+#, c-format
+msgid "Internal: Non-debugged code (test-case missing): %s:%d"
+msgstr "Internal: Kode belum didebug (tidak ada test-case): %s:%d"
+
+#: mmix-dis.c:53
+msgid "(unknown)"
+msgstr "(tidak dikenal)"
+
+#: mmix-dis.c:517
+#, c-format
+msgid "*unknown operands type: %d*"
+msgstr "*tipe operand tidak dikenal: %d*"
+
+#. I and Z are output operands and can`t be immediate
+#. * A is an address and we can`t have the address of
+#. * an immediate either. We don't know how much to increase
+#. * aoffsetp by since whatever generated this is broken
+#. * anyway!
+#.
+#: ns32k-dis.c:628
+msgid "$<undefined>"
+msgstr "$<tidak didefinisikan>"
+
+#: ppc-opc.c:765 ppc-opc.c:798
+msgid "invalid conditional option"
+msgstr "option kondisional tidak valid"
+
+#: ppc-opc.c:800
+msgid "attempt to set y bit when using + or - modifier"
+msgstr "berusaha menset bit y saat menggunakan modifier + atau -"
+
+#: ppc-opc.c:832 ppc-opc.c:884
+msgid "offset not a multiple of 4"
+msgstr "offset bukan kelipatan 4"
+
+#: ppc-opc.c:857
+msgid "offset not between -2048 and 2047"
+msgstr "offset tidak berada antara -2048 dan 2047"
+
+#: ppc-opc.c:882
+msgid "offset not between -8192 and 8191"
+msgstr "offset tidak berada antara -8192 dan 8191"
+
+#: ppc-opc.c:910
+msgid "ignoring least significant bits in branch offset"
+msgstr "mengabaikan least significant bit dalam offset cabang"
+
+#: ppc-opc.c:944 ppc-opc.c:981
+msgid "illegal bitmask"
+msgstr "bitmask ilegal"
+
+#: ppc-opc.c:1054
+msgid "value out of range"
+msgstr "nilai di luar batas"
+
+#: ppc-opc.c:1130
+msgid "index register in load range"
+msgstr "register indeks dalam daerah pemuatan"
+
+#: ppc-opc.c:1146
+msgid "invalid register operand when updating"
+msgstr "operand register tidak valid saat mengupdate"
+
+#. Mark as non-valid instruction
+#: sparc-dis.c:749
+msgid "unknown"
+msgstr "tidak dikenal"
+
+#: sparc-dis.c:824
+#, c-format
+msgid "Internal error:  bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
+msgstr "Kesalahan internal:  sparc-opcode.h buruk: \"%s\", %#.8lx, %#.8lx\n"
+
+#: sparc-dis.c:835
+#, c-format
+msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
+msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\", %#.8lx, %#.8lx\n"
+
+#: sparc-dis.c:884
+#, c-format
+msgid "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"
+msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\" == \"%s\"\n"
+
+#: v850-dis.c:224
+#, c-format
+msgid "unknown operand shift: %x\n"
+msgstr "shift operand tidak dikenal: %x\n"
+
+#: v850-dis.c:236
+#, c-format
+msgid "unknown pop reg: %d\n"
+msgstr "reg pop tidak dikenal: %d\n"
+
+#. The functions used to insert and extract complicated operands.
+#. Note: There is a conspiracy between these functions and
+#. v850_insert_operand() in gas/config/tc-v850.c.  Error messages
+#. containing the string 'out of range' will be ignored unless a
+#. specific command line option is given to GAS.
+#: v850-opc.c:68
+msgid "displacement value is not in range and is not aligned"
+msgstr "nilai displacement tidak dalam jangkauan dan tidak rata"
+
+#: v850-opc.c:69
+msgid "displacement value is out of range"
+msgstr "nilai displacement di luar batas"
+
+#: v850-opc.c:70
+msgid "displacement value is not aligned"
+msgstr "nilai displacement tidak rata"
+
+#: v850-opc.c:72
+msgid "immediate value is out of range"
+msgstr "nilai langsung di luar batas"
+
+#: v850-opc.c:83
+msgid "branch value not in range and to odd offset"
+msgstr "nilai cabang tidak dalam jangkauan"
+
+#: v850-opc.c:85 v850-opc.c:117
+msgid "branch value out of range"
+msgstr "nilai cabang di luar jangkauan"
+
+#: v850-opc.c:88 v850-opc.c:120
+msgid "branch to odd offset"
+msgstr "cabang offset ganjil"
+
+#: v850-opc.c:115
+msgid "branch value not in range and to an odd offset"
+msgstr "nilai cabang di luar jangkauan dan offset ganjil"
+
+#: v850-opc.c:346
+msgid "invalid register for stack adjustment"
+msgstr "register tidak valid untuk penyesuaian stack"
+
+#: v850-opc.c:370
+msgid "immediate value not in range and not even"
+msgstr "nilai langsung tidak dalam jangkauan dan tidak genap"
+
+#: v850-opc.c:375
+msgid "immediate value must be even"
+msgstr "nilai langsung harus genap"
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
index 6597066..1e49597 100644
--- a/opcodes/ppc-opc.c
+++ b/opcodes/ppc-opc.c
@@ -510,6 +510,10 @@
 #define WS_MASK (0x7 << 11)
   { 3, 11, 0, 0, 0 },
 
+  /* The L field in an mtmsrd instruction */
+#define MTMSRD_L WS + 1
+  { 1, 16, 0, 0, PPC_OPERAND_OPTIONAL },
+
 };
 
 /* The functions used to insert and extract complicated operands.  */
@@ -1412,9 +1416,15 @@
 /* An X_MASK with the RA and RB fields fixed.  */
 #define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
 
+/* An XRARB_MASK, but with the L bit clear. */
+#define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16))
+
 /* An X_MASK with the RT and RA fields fixed.  */
 #define XRTRA_MASK (X_MASK | RT_MASK | RA_MASK)
 
+/* An XRTRA_MASK, but with L bit clear.  */
+#define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21))
+
 /* An X form comparison instruction.  */
 #define XCMPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21))
 
@@ -1803,7 +1813,7 @@
 { "vctuxs",    VX(4,  906), VX_MASK,	PPCVEC,		{ VD, VB, UIMM } },
 { "vexptefp",  VX(4,  394), VX_MASK,	PPCVEC,		{ VD, VB } },
 { "vlogefp",   VX(4,  458), VX_MASK,	PPCVEC,		{ VD, VB } },
-{ "vmaddfp",   VXA(4,  46), VXA_MASK,	PPCVEC,		{ VD, VA, VB, VC } },
+{ "vmaddfp",   VXA(4,  46), VXA_MASK,	PPCVEC,		{ VD, VA, VC, VB } },
 { "vmaxfp",    VX(4, 1034), VX_MASK,	PPCVEC,		{ VD, VA, VB } },
 { "vmaxsb",    VX(4,  258), VX_MASK,	PPCVEC,		{ VD, VA, VB } },
 { "vmaxsh",    VX(4,  322), VX_MASK,	PPCVEC,		{ VD, VA, VB } },
@@ -2947,7 +2957,7 @@
 { "wrteei",  X(31,163),	XE_MASK,	PPC403,		{ E } },
 { "wrteei",  X(31,163),	XE_MASK,	BOOKE,		{ E } },
 
-{ "mtmsrd",  X(31,178),	XRARB_MASK,	PPC64,		{ RS } },
+{ "mtmsrd",  X(31,178),	XRLARB_MASK,	PPC64,		{ RS, MTMSRD_L } },
 
 { "stdux",   X(31,181),	X_MASK,		PPC64,		{ RS, RAS, RB } },
 
@@ -3071,7 +3081,7 @@
 
 { "lhzxe",   X(31,287),	X_MASK,		BOOKE64,	{ RT, RA, RB } },
 
-{ "tlbie",   X(31,306),	XRTRA_MASK,	PPC,		{ RB } },
+{ "tlbie",   X(31,306),	XRTLRA_MASK,	PPC,		{ RB, L } },
 { "tlbi",    X(31,306),	XRT_MASK,	POWER,		{ RA, RB } },
 
 { "eciwx",   X(31,310), X_MASK,		PPC,		{ RT, RA, RB } },
@@ -3662,7 +3672,7 @@
 { "rac",     X(31,818),	X_MASK,		PWRCOM,		{ RT, RA, RB } },
 
 { "dss",     XDSS(31,822,0), XDSS_MASK,	PPCVEC,		{ STRM } },
-{ "dssall",  XDSS(31,822,1), XDSS_MASK,	PPCVEC,		{ STRM } },
+{ "dssall",  XDSS(31,822,1), XDSS_MASK,	PPCVEC,		{ 0 } },
 
 { "srawi",   XRC(31,824,0), X_MASK,	PPCCOM,		{ RA, RS, SH } },
 { "srai",    XRC(31,824,0), X_MASK,	PWRCOM,		{ RA, RS, SH } },
@@ -3678,7 +3688,9 @@
 { "tlbsx.",  XRC(31,914,1), X_MASK, 	PPC403,		{ RT, RA, RB } },
 
 { "tlbsx",   XRC(31,914,0), X_MASK,	BOOKE,		{ RA, RB } },
+{ "tlbsx.",  XRC(31,914,1), X_MASK,	BOOKE,		{ RA, RB } },
 { "tlbsxe",  XRC(31,915,0), X_MASK,	BOOKE,		{ RA, RB } },
+{ "tlbsxe.", XRC(31,915,1), X_MASK,	BOOKE,		{ RA, RB } },
 
 { "slbmfee", X(31,915), XRA_MASK,	PPC64,		{ RT, RB } },
 
diff --git a/opcodes/s390-dis.c b/opcodes/s390-dis.c
index 2f2311b..8745a89 100644
--- a/opcodes/s390-dis.c
+++ b/opcodes/s390-dis.c
@@ -1,5 +1,5 @@
 /* s390-dis.c -- Disassemble S390 instructions
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
    This file is part of GDB, GAS and the GNU binutils.
diff --git a/opcodes/z8k-dis.c b/opcodes/z8k-dis.c
index 091d937..d375e69 100644
--- a/opcodes/z8k-dis.c
+++ b/opcodes/z8k-dis.c
@@ -1,22 +1,23 @@
 /* Disassemble z8000 code.
-   Copyright 1992, 1993, 1998, 2000, 2001
+   Copyright 1992, 1993, 1998, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
-This file is part of GNU Binutils.
+   This file is part of GNU Binutils.
 
-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 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.
+   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.  */
+   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 "sysdep.h"
 #include "dis-asm.h"
@@ -26,7 +27,8 @@
 
 #include <setjmp.h>
 
-typedef struct {
+typedef struct
+{
   /* These are all indexed by nibble number (i.e only every other entry
      of bytes is used, and every 4th entry of words).  */
   unsigned char nibbles[24];
@@ -48,7 +50,8 @@
   unsigned long ctrl_code;
   unsigned long flags;
   unsigned long interrupts;
-} instr_data_s;
+}
+instr_data_s;
 
 static int fetch_data PARAMS ((struct disassemble_info *, int));
 
@@ -106,35 +109,37 @@
   return 1;
 }
 
-static char *codes[16] = {
-  "f",
-  "lt",
-  "le",
-  "ule",
-  "ov/pe",
-  "mi",
-  "eq",
-  "c/ult",
-  "t",
-  "ge",
-  "gt",
-  "ugt",
-  "nov/po",
-  "pl",
-  "ne",
-  "nc/uge"
-};
+static char *codes[16] =
+  {
+    "f",
+    "lt",
+    "le",
+    "ule",
+    "ov/pe",
+    "mi",
+    "eq",
+    "c/ult",
+    "t",
+    "ge",
+    "gt",
+    "ugt",
+    "nov/po",
+    "pl",
+    "ne",
+    "nc/uge"
+  };
 
-static char *ctrl_names[8] = {
-  "<invld>",
-  "flags",
-  "fcw",
-  "refresh",
-  "psapseg",
-  "psapoff",
-  "nspseg",
-  "nspoff"
-};
+static char *ctrl_names[8] =
+  {
+    "<invld>",
+    "flags",
+    "fcw",
+    "refresh",
+    "psapseg",
+    "psapoff",
+    "nspseg",
+    "nspoff"
+  };
 
 static int seg_length;
 static int print_insn_z8k PARAMS ((bfd_vma, disassemble_info *, int));
@@ -159,6 +164,10 @@
     /* Error return.  */
     return -1;
 
+  info->bytes_per_chunk = 2;
+  info->bytes_per_line = 6;
+  info->display_endian = BFD_ENDIAN_BIG;
+
   instr_data.tabl_index = z8k_lookup_instr (instr_data.nibbles, info);
   if (instr_data.tabl_index > 0)
     {
@@ -227,6 +236,8 @@
 	      if (datum_value != instr_nibl)
 		nibl_matched = 0;
 	      break;
+	    case CLASS_IGNORE:
+	      break;
 	    case CLASS_00II:
 	      if (!((~instr_nibl) & 0x4))
 		nibl_matched = 0;
@@ -265,10 +276,9 @@
 	      break;
 	    }
 	}
+
       if (nibl_matched)
-	{
-	  return tabl_index;
-	}
+	return tabl_index;
 
       tabl_index++;
     }
@@ -281,24 +291,13 @@
      unsigned long addr ATTRIBUTE_UNUSED;
      disassemble_info *info;
 {
-  int loop, loop_limit;
-  char tmp_str[20];
+  int num_bytes;
   char out_str[100];
 
-  strcpy (out_str, "\t");
+  out_str[0] = 0;
 
-  loop_limit = (z8k_table[instr_data->tabl_index].length + seg_length) * 2;
-  FETCH_DATA (info, loop_limit);
-  for (loop = 0; loop < loop_limit; loop++)
-    {
-      sprintf (tmp_str, "%x", instr_data->nibbles[loop]);
-      strcat (out_str, tmp_str);
-    }
-
-  while (loop++ < 8)
-    {
-      strcat (out_str, " ");
-    }
+  num_bytes = (z8k_table[instr_data->tabl_index].length + seg_length) * 2;
+  FETCH_DATA (info, num_bytes);
 
   strcat (out_str, instr_data->instr_asmsrc);
 
@@ -320,6 +319,7 @@
   nibl_count = 0;
   loop = 0;
   seg_length = 0;
+
   while (z8k_table[instr_data->tabl_index].byte_info[loop] != 0)
     {
       FETCH_DATA (info, nibl_count + 4 - (nibl_count % 4));
@@ -343,16 +343,13 @@
 	      break;
 	    case ARG_DISP12:
 	      if (instr_word & 0x800)
-		{
-		  /* neg. 12 bit displacement */
-		  instr_data->displacement = instr_data->insn_start + 2
-		    - (signed short) ((instr_word & 0xfff) | 0xf000) * 2;
-		}
+		/* Negative 12 bit displacement.  */
+		instr_data->displacement = instr_data->insn_start + 2
+		  - (signed short) ((instr_word & 0xfff) | 0xf000) * 2;
 	      else
-		{
-		  instr_data->displacement = instr_data->insn_start + 2
-		    - (instr_word & 0x0fff) * 2;
-		}
+		instr_data->displacement = instr_data->insn_start + 2
+		  - (instr_word & 0x0fff) * 2;
+
 	      nibl_count += 2;
 	      break;
 	    default:
@@ -365,8 +362,11 @@
 	    case ARG_IMM4:
 	      instr_data->immediate = instr_nibl;
 	      break;
+	    case ARG_NIM4:
+	      instr_data->immediate = (- instr_nibl) & 0xf;
+	      break;
 	    case ARG_NIM8:
-	      instr_data->immediate = (-instr_byte);
+	      instr_data->immediate = (- instr_byte) & 0xff;
 	      nibl_count += 1;
 	      break;
 	    case ARG_IMM8:
@@ -452,6 +452,7 @@
 	case CLASS_00II:
 	  instr_data->interrupts = instr_nibl & 0x3;
 	  break;
+	case CLASS_IGNORE:
 	case CLASS_BIT:
 	  instr_data->ctrl_code = instr_nibl & 0x7;
 	  break;
@@ -469,6 +470,10 @@
 	    instr_data->insn_start + 2 + (signed char) instr_byte * 2;
 	  nibl_count += 1;
 	  break;
+        case CLASS_BIT_1OR2:
+          instr_data->immediate = ((instr_nibl >> 1) & 0x1) + 1;
+          nibl_count += 1;
+	  break;
 	default:
 	  abort ();
 	  break;
@@ -489,7 +494,7 @@
   int loop, loop_limit;
   char out_str[80], tmp_str[25];
 
-  sprintf (out_str, "\t%s\t", z8k_table[instr_data->tabl_index].name);
+  sprintf (out_str, "%s\t", z8k_table[instr_data->tabl_index].name);
 
   loop_limit = z8k_table[instr_data->tabl_index].noperands;
   for (loop = 0; loop < loop_limit; loop++)
@@ -504,18 +509,26 @@
       switch (datum_class)
 	{
 	case CLASS_X:
-	  sprintf (tmp_str, "0x%0lx(R%ld)", instr_data->address,
-		   instr_data->arg_reg[datum_value]);
+          sprintf (tmp_str, "0x%0lx(r%ld)", instr_data->address,
+                   instr_data->arg_reg[datum_value]);
 	  strcat (out_str, tmp_str);
 	  break;
 	case CLASS_BA:
-	  sprintf (tmp_str, "r%ld(#%lx)", instr_data->arg_reg[datum_value],
-		   instr_data->immediate);
+          if (is_segmented)
+            sprintf (tmp_str, "rr%ld(#%lx)", instr_data->arg_reg[datum_value],
+                     instr_data->immediate);
+          else
+            sprintf (tmp_str, "r%ld(#%lx)", instr_data->arg_reg[datum_value],
+                     instr_data->immediate);
 	  strcat (out_str, tmp_str);
 	  break;
 	case CLASS_BX:
-	  sprintf (tmp_str, "r%ld(R%ld)", instr_data->arg_reg[datum_value],
-		   instr_data->arg_reg[ARG_RX]);
+          if (is_segmented)
+            sprintf (tmp_str, "rr%ld(r%ld)", instr_data->arg_reg[datum_value],
+                     instr_data->arg_reg[ARG_RX]);
+          else
+            sprintf (tmp_str, "r%ld(r%ld)", instr_data->arg_reg[datum_value],
+                     instr_data->arg_reg[ARG_RX]);
 	  strcat (out_str, tmp_str);
 	  break;
 	case CLASS_DISP:
diff --git a/opcodes/z8k-opc.h b/opcodes/z8k-opc.h
index c62867c..025cfab 100644
--- a/opcodes/z8k-opc.h
+++ b/opcodes/z8k-opc.h
@@ -21,6 +21,7 @@
 #define ARG_IMM2 0x0a
 #define ARG_IMM1OR2 0x0b
 #define ARG_DISP12 0x0b
+#define ARG_NIM4 0x0c
 #define ARG_DISP8 0x0c
 #define ARG_IMM4M1 0x0d
 #define CLASS_MASK 0x1fff0
@@ -32,6 +33,7 @@
 #define CLASS_IMM 0x60
 #define CLASS_CC 0x70
 #define CLASS_CTRL 0x80
+#define CLASS_IGNORE 0x90
 #define CLASS_ADDRESS 0xd0
 #define CLASS_0CCC 0xe0
 #define CLASS_1CCC 0xf0
@@ -2419,64 +2421,64 @@
 	{CLASS_BIT+7,CLASS_BIT+5,CLASS_REGN0+(ARG_RS),CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_REG+(ARG_RX),CLASS_BIT+0,CLASS_BIT+0,0,},2,4,215},
 
 
-/* 0001 1100 ddN0 1001 0000 ssss 0000 nminus1 *** ldm @rd,rs,n */
+/* 0001 1100 ddN0 1001 0000 ssss 0000 imm4m1 *** ldm @rd,rs,n */
 {
 #ifdef NICENAMES
 "ldm @rd,rs,n",16,11,
 0x00,
 #endif
-"ldm",OPC_ldm,0,{CLASS_IR+(ARG_RD),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
-	{CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),0,},3,4,216},
+"ldm",OPC_ldm,0,{CLASS_IR+(ARG_RD),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMM4M1),},
+	{CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),0,},3,4,216},
 
 
-/* 0101 1100 ddN0 1001 0000 ssss 0000 nminus1 address_dst *** ldm address_dst(rd),rs,n */
+/* 0101 1100 ddN0 1001 0000 ssss 0000 imm4m1 address_dst *** ldm address_dst(rd),rs,n */
 {
 #ifdef NICENAMES
 "ldm address_dst(rd),rs,n",16,15,
 0x00,
 #endif
-"ldm",OPC_ldm,0,{CLASS_X+(ARG_RD),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
-	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_DST),},3,6,217},
+"ldm",OPC_ldm,0,{CLASS_X+(ARG_RD),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMM4M1),},
+	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),},3,6,217},
 
 
-/* 0101 1100 0000 1001 0000 ssss 0000 nminus1 address_dst *** ldm address_dst,rs,n */
+/* 0101 1100 0000 1001 0000 ssss 0000 imm4m1 address_dst *** ldm address_dst,rs,n */
 {
 #ifdef NICENAMES
 "ldm address_dst,rs,n",16,14,
 0x00,
 #endif
-"ldm",OPC_ldm,0,{CLASS_DA+(ARG_DST),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
-	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_DST),},3,6,218},
+"ldm",OPC_ldm,0,{CLASS_DA+(ARG_DST),CLASS_REG_WORD+(ARG_RS),CLASS_IMM + (ARG_IMM4M1),},
+	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+9,CLASS_BIT+0,CLASS_REG+(ARG_RS),CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_DST),},3,6,218},
 
 
-/* 0001 1100 ssN0 0001 0000 dddd 0000 nminus1 *** ldm rd,@rs,n */
+/* 0001 1100 ssN0 0001 0000 dddd 0000 imm4m1 *** ldm rd,@rs,n */
 {
 #ifdef NICENAMES
 "ldm rd,@rs,n",16,11,
 0x00,
 #endif
-"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
-	{CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),0,},3,4,219},
+"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_IR+(ARG_RS),CLASS_IMM + (ARG_IMM4M1),},
+	{CLASS_BIT+1,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),0,},3,4,219},
 
 
-/* 0101 1100 ssN0 0001 0000 dddd 0000 nminus1 address_src *** ldm rd,address_src(rs),n */
+/* 0101 1100 ssN0 0001 0000 dddd 0000 imm4m1 address_src *** ldm rd,address_src(rs),n */
 {
 #ifdef NICENAMES
 "ldm rd,address_src(rs),n",16,15,
 0x00,
 #endif
-"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),CLASS_IMM + (ARG_IMMN),},
-	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_SRC),},3,6,220},
+"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_X+(ARG_RS),CLASS_IMM + (ARG_IMM4M1),},
+	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_REGN0+(ARG_RS),CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_SRC),},3,6,220},
 
 
-/* 0101 1100 0000 0001 0000 dddd 0000 nminus1 address_src *** ldm rd,address_src,n */
+/* 0101 1100 0000 0001 0000 dddd 0000 imm4m1 address_src *** ldm rd,address_src,n */
 {
 #ifdef NICENAMES
 "ldm rd,address_src,n",16,14,
 0x00,
 #endif
-"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),CLASS_IMM + (ARG_IMMN),},
-	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMMNMINUS1),CLASS_ADDRESS+(ARG_SRC),},3,6,221},
+"ldm",OPC_ldm,0,{CLASS_REG_WORD+(ARG_RD),CLASS_DA+(ARG_SRC),CLASS_IMM + (ARG_IMM4M1),},
+	{CLASS_BIT+5,CLASS_BIT+0xc,CLASS_BIT+0,CLASS_BIT+1,CLASS_BIT+0,CLASS_REG+(ARG_RD),CLASS_BIT+0,CLASS_IMM+(ARG_IMM4M1),CLASS_ADDRESS+(ARG_SRC),},3,6,221},
 
 
 /* 0011 1001 ssN0 0000 *** ldps @rs */
@@ -3729,14 +3731,14 @@
 	{CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,346},
 
 
-/* 1011 0010 dddd 1001  0000 0000 imm8 *** slab rbd,imm8 */
+/* 1011 0010 dddd 1001 iiii iiii 0000 imm4 *** slab rbd,imm4 */
 {
 #ifdef NICENAMES
-"slab rbd,imm8",8,13,
+"slab rbd,imm4",8,13,
 0x3c,
 #endif
-"slab",OPC_slab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
-	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,347},
+"slab",OPC_slab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_IGNORE,CLASS_IGNORE,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),0,},2,4,347},
 
 
 /* 1011 0011 dddd 1101 0000 0000 imm8 *** slal rrd,imm8 */
@@ -3759,14 +3761,14 @@
 	{CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,349},
 
 
-/* 1011 0010 dddd 0001  0000 0000 imm8 *** sllb rbd,imm8 */
+/* 1011 0010 dddd 0001 iiii iiii 0000 imm4 *** sllb rbd,imm4 */
 {
 #ifdef NICENAMES
-"sllb rbd,imm8",8,13,
+"sllb rbd,imm4",8,13,
 0x38,
 #endif
-"sllb",OPC_sllb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
-	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_IMM8),0,0,},2,4,350},
+"sllb",OPC_sllb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_IGNORE,CLASS_IGNORE,CLASS_BIT+0,CLASS_IMM+(ARG_IMM4),0,},2,4,350},
 
 
 /* 1011 0011 dddd 0101 0000 0000 imm8 *** slll rrd,imm8 */
@@ -3849,14 +3851,14 @@
 	{CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0xf,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM8),0,0,},2,4,358},
 
 
-/* 1011 0010 dddd 1001 0000 0000 nim8 *** srab rbd,imm8 */
+/* 1011 0010 dddd 1001 iiii iiii 1111 nim4 *** srab rbd,imm4 */
 {
 #ifdef NICENAMES
-"srab rbd,imm8",8,13,
+"srab rbd,imm4",8,13,
 0x3c,
 #endif
-"srab",OPC_srab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
-	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_NIM8),0,0,},2,4,359},
+"srab",OPC_srab,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+9,CLASS_IGNORE,CLASS_IGNORE,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM4),0,},2,4,359},
 
 
 /* 1011 0011 dddd 1101 1111 1111 nim8 *** sral rrd,imm8 */
@@ -3879,14 +3881,14 @@
 	{CLASS_BIT+0xb,CLASS_BIT+3,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0xf,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM8),0,0,},2,4,361},
 
 
-/* 1011 0010 dddd 0001 0000 0000 nim8 *** srlb rbd,imm8 */
+/* 1011 0010 dddd 0001 iiii iiii 1111 nim4 *** srlb rbd,imm4 */
 {
 #ifdef NICENAMES
-"srlb rbd,imm8",8,13,
+"srlb rbd,imm4",8,13,
 0x3c,
 #endif
-"srlb",OPC_srlb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM+(ARG_IMM8),},
-	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_BIT+0,CLASS_BIT+0,CLASS_IMM+(ARG_NIM8),0,0,},2,4,362},
+"srlb",OPC_srlb,0,{CLASS_REG_BYTE+(ARG_RD),CLASS_IMM +(ARG_IMM4),},
+	{CLASS_BIT+0xb,CLASS_BIT+2,CLASS_REG+(ARG_RD),CLASS_BIT+1,CLASS_IGNORE,CLASS_IGNORE,CLASS_BIT+0xf,CLASS_IMM+(ARG_NIM4),0,},2,4,362},
 
 
 /* 1011 0011 dddd 0101 1111 1111 nim8 *** srll rrd,imm8 */
diff --git a/opcodes/z8kgen.c b/opcodes/z8kgen.c
index f171724..fa85059 100644
--- a/opcodes/z8kgen.c
+++ b/opcodes/z8kgen.c
@@ -1,23 +1,23 @@
-/*
-  Copyright 2001 Free Software Foundation, Inc.
+/* Copyright 2001, 2002 Free Software Foundation, Inc.
 
-  This file is part of GNU Binutils.
+   This file is part of GNU Binutils.
 
-  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 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.
+   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.  */
+   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.  */
 
-/* This program generates z8k-opc.h */
+/* This program generates z8k-opc.h.  */
 
 #include <stdio.h>
 #include "sysdep.h"
@@ -285,12 +285,12 @@
 
   "------", 5, 16, "1011 1101 dddd imm4", "ldk rd,imm4", 0,
 
-  "------", 11, 16, "0001 1100 ddN0 1001 0000 ssss 0000 nminus1", "ldm @rd,rs,n", 0,
-  "------", 15, 16, "0101 1100 ddN0 1001 0000 ssss 0000 nminus1 address_dst", "ldm address_dst(rd),rs,n", 0,
-  "------", 14, 16, "0101 1100 0000 1001 0000 ssss 0000 nminus1 address_dst", "ldm address_dst,rs,n", 0,
-  "------", 11, 16, "0001 1100 ssN0 0001 0000 dddd 0000 nminus1", "ldm rd,@rs,n", 0,
-  "------", 15, 16, "0101 1100 ssN0 0001 0000 dddd 0000 nminus1 address_src", "ldm rd,address_src(rs),n", 0,
-  "------", 14, 16, "0101 1100 0000 0001 0000 dddd 0000 nminus1 address_src", "ldm rd,address_src,n", 0,
+  "------", 11, 16, "0001 1100 ddN0 1001 0000 ssss 0000 imm4m1", "ldm @rd,rs,n", 0,
+  "------", 15, 16, "0101 1100 ddN0 1001 0000 ssss 0000 imm4m1 address_dst", "ldm address_dst(rd),rs,n", 0,
+  "------", 14, 16, "0101 1100 0000 1001 0000 ssss 0000 imm4m1 address_dst", "ldm address_dst,rs,n", 0,
+  "------", 11, 16, "0001 1100 ssN0 0001 0000 dddd 0000 imm4m1", "ldm rd,@rs,n", 0,
+  "------", 15, 16, "0101 1100 ssN0 0001 0000 dddd 0000 imm4m1 address_src", "ldm rd,address_src(rs),n", 0,
+  "------", 14, 16, "0101 1100 0000 0001 0000 dddd 0000 imm4m1 address_src", "ldm rd,address_src,n", 0,
 
   "CZSVDH", 12, 16, "0011 1001 ssN0 0000", "ldps @rs", 0,
   "CZSVDH", 16, 16, "0111 1001 0000 0000 address_src", "ldps address_src", 0,
@@ -434,11 +434,11 @@
   "------", 0, 16, "0011 1010 ssN0 0001 0000 aaaa ddN0 0000", "sinibr @rd,@rs,ra", 0,
 
   "CZSV--", 13, 16, "1011 0011 dddd 1001 0000 0000 imm8", "sla rd,imm8", 0,
-  "CZSV--", 13, 8, "1011 0010 dddd 1001  0000 0000 imm8", "slab rbd,imm8", 0,
+  "CZSV--", 13, 8, "1011 0010 dddd 1001 iiii iiii 0000 imm4", "slab rbd,imm4", 0,
   "CZSV--", 13, 32, "1011 0011 dddd 1101 0000 0000 imm8", "slal rrd,imm8", 0,
 
   "CZS---", 13, 16, "1011 0011 dddd 0001 0000 0000 imm8", "sll rd,imm8", 0,
-  "CZS---", 13, 8, "1011 0010 dddd 0001  0000 0000 imm8", "sllb rbd,imm8", 0,
+  "CZS---", 13, 8, "1011 0010 dddd 0001 iiii iiii 0000 imm4", "sllb rbd,imm4", 0,
   "CZS---", 13, 32, "1011 0011 dddd 0101 0000 0000 imm8", "slll rrd,imm8", 0,
 
   "------", 0, 16, "0011 1011 ssss 0111 imm16", "sout imm16,rs", 0,
@@ -449,11 +449,11 @@
   "------", 0, 16, "0011 1010 ssN0 0011 0000 aaaa ddN0 0000", "soutibr @rd,@rs,ra", 0,
 
   "CZSV--", 13, 16, "1011 0011 dddd 1001 1111 1111 nim8", "sra rd,imm8", 0,
-  "CZSV--", 13, 8, "1011 0010 dddd 1001 0000 0000 nim8", "srab rbd,imm8", 0,
+  "CZSV--", 13, 8, "1011 0010 dddd 1001 iiii iiii 1111 nim4", "srab rbd,imm4", 0,
   "CZSV--", 13, 32, "1011 0011 dddd 1101 1111 1111 nim8", "sral rrd,imm8", 0,
 
   "CZSV--", 13, 16, "1011 0011 dddd 0001 1111 1111 nim8", "srl rd,imm8", 0,
-  "CZSV--", 13, 8, "1011 0010 dddd 0001 0000 0000 nim8", "srlb rbd,imm8", 0,
+  "CZSV--", 13, 8, "1011 0010 dddd 0001 iiii iiii 1111 nim4", "srlb rbd,imm4", 0,
   "CZSV--", 13, 32, "1011 0011 dddd 0101 1111 1111 nim8", "srll rrd,imm8", 0,
 
   "CZSV--", 7, 16, "0000 0011 ssN0 dddd", "sub rd,@rs", 0,
@@ -595,7 +595,7 @@
   {"imm32", "CLASS_IMM+(ARG_IMM32)",},
   {"imm4m1", "CLASS_IMM +(ARG_IMM4M1)",},
   {"imm4", "CLASS_IMM +(ARG_IMM4)",},
-  {"n", "CLASS_IMM + (ARG_IMMN)",},
+  {"n", "CLASS_IMM + (ARG_IMM4M1)",},
   {"ctrl", "CLASS_CTRL",},
   {"rba", "CLASS_REG_BYTE+(ARG_RA)",},
   {"rbb", "CLASS_REG_BYTE+(ARG_RB)",},
@@ -695,6 +695,7 @@
   "imm8", "CLASS_IMM+(ARG_IMM8)", 2,
   "imm16", "CLASS_IMM+(ARG_IMM16)", 4,
   "imm32", "CLASS_IMM+(ARG_IMM32)", 8,
+  "nim4", "CLASS_IMM+(ARG_NIM4)", 2,
   "nim8", "CLASS_IMM+(ARG_NIM8)", 2,
   "0ccc", "CLASS_0CCC", 1,
   "1ccc", "CLASS_1CCC", 1,
@@ -703,6 +704,8 @@
   "1disp7", "CLASS_1DISP7", 2,
   "01ii", "CLASS_01II", 1,
   "00ii", "CLASS_00II", 1,
+
+  "iiii", "CLASS_IGNORE", 1,
   0, 0
 };
 
@@ -992,6 +995,7 @@
   printf ("#define ARG_IMM1OR2 0x0b\n");
 
   printf ("#define ARG_DISP12 0x0b\n");
+  printf ("#define ARG_NIM4 0x0c\n");
   printf ("#define ARG_DISP8 0x0c\n");
   printf ("#define ARG_IMM4M1 0x0d\n");
   printf ("#define CLASS_MASK 0x1fff0\n");
@@ -1003,6 +1007,7 @@
   printf ("#define CLASS_IMM 0x60\n");
   printf ("#define CLASS_CC 0x70\n");
   printf ("#define CLASS_CTRL 0x80\n");
+  printf ("#define CLASS_IGNORE 0x90\n");
   printf ("#define CLASS_ADDRESS 0xd0\n");
   printf ("#define CLASS_0CCC 0xe0\n");
   printf ("#define CLASS_1CCC 0xf0\n");
diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index bf7256c..04c7e28 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -1,3 +1,7 @@
+2002-03-17  Anthony Green  <green@redhat.com>
+
+	* wrapper.c (mem_size): Increase the default target memory to 8MB.
+
 2002-02-21  Keith Seitz  <keiths@redhat.com>
 
 	* armos.c (SWIWrite0): Use generic host_callback mechanism
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index e00c21b..773ef35 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -47,7 +47,7 @@
 static char *myname;
 
 /* Memory size in bytes.  */
-static int mem_size = (1 << 21);
+static int mem_size = (1 << 23);
 
 /* Non-zero to display start up banner, and maybe other things.  */
 static int verbosity;
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 84c2964..6935b01 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,7 @@
+2002-05-01  Chris Demetriou  <cgd@broadcom.com>
+
+	* callback.c: Use 'deprecated' rather than 'depreciated.'
+
 2002-02-24  Andrew Cagney  <ac131313@redhat.com>
 
 	From wiz at danbala:
diff --git a/sim/common/callback.c b/sim/common/callback.c
index 64b4e7c..af5de14 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -435,7 +435,7 @@
   return 1;
 }
 
-/* DEPRECIATED */
+/* DEPRECATED */
 
 /* VARARGS */
 static void
diff --git a/sim/igen/ChangeLog b/sim/igen/ChangeLog
index ea88fb0..d5ba8ab 100644
--- a/sim/igen/ChangeLog
+++ b/sim/igen/ChangeLog
@@ -1,3 +1,18 @@
+2002-05-01  Chris Demetriou  <cgd@broadcom.com>
+
+	* igen.c: Use 'deprecated' rather than 'depreciated.'
+
+2002-03-23  Andrew Cagney  <ac131313@redhat.com>
+
+ 	* gen.c (format_name_cmp): New function.
+	(insn_list_insert): Use the instruction field name as an
+	additional key.  Different field names indicate different
+	semantics.
+
+2002-03-07  Chris Demetriou  <cgd@broadcom.com>
+
+	* igen.c (print_itrace_format): Add support for a new "%#lx" format.
+
 Tue May 23 21:39:23 2000  Andrew Cagney  <cagney@b1.cygnus.com>
 
 	* configure: Regenerated to track ../common/aclocal.m4 changes.
diff --git a/sim/igen/gen.c b/sim/igen/gen.c
index de88619..7c24b46 100644
--- a/sim/igen/gen.c
+++ b/sim/igen/gen.c
@@ -308,7 +308,18 @@
     }
 }
 
-
+/* Same as strcmp().  */
+static int
+format_name_cmp (const char *l, const char *r)
+{
+  if (l == NULL && r == NULL)
+    return 0;
+  if (l != NULL && r == NULL)
+    return -1;
+  if (l == NULL && r != NULL)
+    return +1;
+  return strcmp (l, r);
+}
 
 
 typedef enum {
@@ -351,6 +362,18 @@
       else if (cmp > 0)
 	continue;
 
+      /* key#4 sort according to the format-name.  If two apparently
+	 identical instructions have unique format-names, then the
+	 instructions are different.  This is because the
+	 format-name's use is overloaded, it not only indicates the
+	 format name but also provides a unique semantic name for the
+	 function.  */
+      cmp = format_name_cmp (insn->format_name, (*cur_insn_ptr)->insn->format_name);
+      if (cmp < 0)
+	break;
+      else if (cmp > 0)
+	continue;
+
       /* duplicate keys, report problem */
       switch (duplicate_action)
 	{
diff --git a/sim/igen/igen.c b/sim/igen/igen.c
index 094f0cd..1399d30 100644
--- a/sim/igen/igen.c
+++ b/sim/igen/igen.c
@@ -445,6 +445,17 @@
 		      lf_write (file, param, strlen_param);
 		    }
 		}
+	      else if (strncmp (fmt, "%#lx<", 5) == 0)
+		/* simple hex with 0x prefix*/
+		{
+		  if (pass == 1)
+		    lf_printf (file, "%%#lx");
+		  else
+		    {
+		      lf_printf (file, "(unsigned long) ");
+		      lf_write (file, param, strlen_param);
+		    }
+		}
 	      else if (strncmp (fmt, "%08lx<", 6) == 0)
 		/* simple hex */
 		{
@@ -1026,7 +1037,7 @@
       printf ("Config options:\n");
       printf ("\n");
       printf ("  -B <bit-size>\n");
-      printf ("\t Set the number of bits in an instruction (depreciated).\n");
+      printf ("\t Set the number of bits in an instruction (deprecated).\n");
       printf ("\t This option can now be set directly in the instruction table.\n");
       printf ("\n");
       printf ("  -D <data-structure>\n");
@@ -1038,7 +1049,7 @@
       printf ("\t a flag not listed in the <filter-list>.\n");
       printf ("\n");
       printf ("  -H <high-bit>\n");
-      printf ("\t Set the number of the high (most significant) instruction bit (depreciated).\n");
+      printf ("\t Set the number of the high (most significant) instruction bit (deprecated).\n");
       printf ("\t This option can now be set directly in the instruction table.\n");
       printf ("\n");
       printf ("  -I <directory>\n");
@@ -1109,7 +1120,7 @@
       printf ("\t trace-rule-expansion   - report each instruction as it is expanded (before insertion into a decode table)\n");
       printf ("\t trace-all              - enable all trace options\n");
       printf ("\n");
-      printf ("\t field-widths           - instruction formats specify widths (depreciated)\n");
+      printf ("\t field-widths           - instruction formats specify widths (deprecated)\n");
       printf ("\t                          By default, an instruction format specifies bit\n");
       printf ("\t                          positions\n");
       printf ("\t                          This option can now be set directly in the\n");
@@ -1119,7 +1130,7 @@
       printf ("\n");
       printf ("Input options:\n");
       printf ("\n");
-      printf ("  -k <cache-rules> (depreciated)\n");
+      printf ("  -k <cache-rules> (deprecated)\n");
       printf ("  -o <decode-rules>\n");
       printf ("  -i <instruction-table>\n");
       printf ("\n");
diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog
index 4ffef07..3887539 100644
--- a/sim/mips/ChangeLog
+++ b/sim/mips/ChangeLog
@@ -1,3 +1,168 @@
+2002-05-01  Chris Demetriou  <cgd@broadcom.com>
+
+	* interp.c: Use 'deprecated' rather than 'depreciated.'
+	* sim-main.h: Likewise.
+
+2002-05-01  Chris Demetriou  <cgd@broadcom.com>
+
+	* cp1.c (store_fpr): Remove #ifdef'd out call to UndefinedResult
+	which wouldn't compile anyway.
+	* sim-main.h (unpredictable_action): New function prototype.
+	(Unpredictable): Define to call igen function unpredictable().
+	(NotWordValue): New macro to call igen function not_word_value().
+	(UndefinedResult): Remove.
+	* interp.c (undefined_result): Remove.
+	(unpredictable_action): New function.
+	* mips.igen (not_word_value, unpredictable): New functions.
+	(ADD, ADDI, do_addiu, do_addu, BGEZAL, BGEZALL, BLTZAL, BLTZALL)
+	(CLO, CLZ, MADD, MADDU, MSUB, MSUBU, MUL, do_mult, do_multu)
+	(do_sra, do_srav, do_srl, do_srlv, SUB, do_subu): Invoke
+	NotWordValue() to check for unpredictable inputs, then
+	Unpredictable() to handle them.
+
+2002-02-24  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen: Fix formatting of calls to Unpredictable().
+
+2002-04-20  Andrew Cagney  <ac131313@redhat.com>
+
+	* interp.c (sim_open): Revert previous change.
+
+2002-04-18  Alexandre Oliva  <aoliva@redhat.com>
+
+	* interp.c (sim_open): Disable chunk of code that wrote code in
+	vector table entries.
+
+2002-03-19  Chris Demetriou  <cgd@broadcom.com>
+
+	* cp1.c (FP_S_s, FP_D_s, FP_S_be, FP_D_be, FP_S_e, FP_D_e, FP_S_f)
+	(FP_D_f, FP_S_fb, FP_D_fb, FPINF_SINGLE, FPINF_DOUBLE): Remove
+	unused definitions.
+
+2002-03-19  Chris Demetriou  <cgd@broadcom.com>
+
+	* cp1.c: Fix many formatting issues.
+
+2002-03-19  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* cp1.c (fpu_format_name): New function to replace...
+	(DOFMT): This.  Delete, and update all callers.
+	(fpu_rounding_mode_name): New function to replace...
+	(RMMODE): This.  Delete, and update all callers.
+
+2002-03-19  Chris G. Demetriou  <cgd@broadcom.com>
+
+	* interp.c: Move FPU support routines from here to...
+	* cp1.c: Here.  New file.
+	* Makefile.in (SIM_OBJS): Add cp1.o to object list.
+	(cp1.o): New target.
+
+2002-03-12  Chris Demetriou  <cgd@broadcom.com>
+
+	* configure.in (mipsisa32*-*-*, mipsisa64*-*-*): New targets.
+	* mips.igen (mips32, mips64): New models, add to all instructions
+	and functions as appropriate.
+	(loadstore_ea, check_u64): New variant for model mips64.
+	(check_fmt_p): New variant for models mipsV and mips64, remove
+	mipsV model marking fro other variant.
+	(SLL) Rename to...
+	(SLLa) this.
+	(CLO, CLZ, MADD, MADDU, MSUB, MSUBU, MUL, SLLb): New instructions
+	for mips32 and mips64.
+	(DCLO, DCLZ): New instructions for mips64.
+
+2002-03-07  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen (BREAK, LUI, ORI, SYSCALL, XORI): Print
+	immediate or code as a hex value with the "%#lx" format.
+	(ANDI): Likewise, and fix printed instruction name.
+
+2002-03-05  Chris Demetriou  <cgd@broadcom.com>
+
+	* sim-main.h (UndefinedResult, Unpredictable): New macros
+	which currently do nothing.
+
+2002-03-05  Chris Demetriou  <cgd@broadcom.com>
+
+	* sim-main.h (status_UX, status_SX, status_KX, status_TS)
+	(status_PX, status_MX, status_CU0, status_CU1, status_CU2)
+	(status_CU3): New definitions.
+
+	* sim-main.h (ExceptionCause): Add new values for MIPS32
+	and MIPS64: MDMX, MCheck, CacheErr.  Update comments
+	for DebugBreakPoint and NMIReset to note their status in
+	MIPS32 and MIPS64.
+	(SignalExceptionMDMX, SignalExceptionWatch, SignalExceptionMCheck)
+	(SignalExceptionCacheErr): New exception macros.
+
+2002-03-05  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen (check_fpu): Enable check for coprocessor 1 usability.
+	* sim-main.h (COP_Usable): Define, but for now coprocessor 1
+	is always enabled.
+	(SignalExceptionCoProcessorUnusable): Take as argument the
+	unusable coprocessor number.
+
+2002-03-05  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen: Fix formatting of all SignalException calls.
+
+2002-03-05  Chris Demetriou  <cgd@broadcom.com>
+
+	* sim-main.h (SIGNEXTEND): Remove.
+
+2002-03-04  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen: Remove gencode comment from top of file, fix
+	spelling in another comment.
+
+2002-03-04  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen (check_fmt, check_fmt_p): New functions to check
+	whether specific floating point formats are usable.
+	(ABS.fmt, ADD.fmt, CEIL.L.fmt, CEIL.W, DIV.fmt, FLOOR.L.fmt)
+	(FLOOR.W.fmt, MOV.fmt, MUL.fmt, NEG.fmt, RECIP.fmt, ROUND.L.fmt)
+	(ROUND.W.fmt, RSQRT.fmt, SQRT.fmt, SUB.fmt, TRUNC.L.fmt, TRUNC.W):
+	Use the new functions.
+	(do_c_cond_fmt): Remove format checks...
+	(C.cond.fmta, C.cond.fmtb): And move them into all callers.
+
+2002-03-03  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen: Fix formatting of check_fpu calls.
+
+2002-03-03  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen (FLOOR.L.fmt): Store correct destination register.
+
+2002-03-03  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen: Remove whitespace at end of lines.
+
+2002-03-02  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen (loadstore_ea): New function to do effective
+	address calculations.
+	(do_load, do_load_left, do_load_right, LL, LDD, PREF, do_store,
+	do_store_left, do_store_right, SC, SCD, PREFX, SWC1, SWXC1,
+	CACHE): Use loadstore_ea to do effective address computations.
+
+2002-03-02  Chris Demetriou  <cgd@broadcom.com>
+
+	* interp.c (load_word): Use EXTEND32 rather than SIGNEXTEND.
+	* mips.igen (LL, CxC1, MxC1): Likewise.
+
+2002-03-02  Chris Demetriou  <cgd@broadcom.com>
+
+	* mips.igen (LL, LLD, PREF, SC, SCD, ABS.fmt, ADD.fmt, CEIL.L.fmt,
+	CEIL.W, CVT.D.fmt, CVT.L.fmt, CVT.S.fmt, CVT.W.fmt, DIV.fmt,
+	FLOOR.L.fmt, FLOOR.W.fmt, MADD.D, MADD.S, MOV.fmt, MOVtf.fmt,
+	MSUB.D, MSUB.S, MUL.fmt, NEG.fmt, NMADD.D, NMADD.S, NMSUB.D,
+	NMSUB.S, PREFX, RECIP.fmt, ROUND.L.fmt, ROUND.W.fmt, RSQRT.fmt,
+	SQRT.fmt, SUB.fmt, SWC1, SWXC1, TRUNC.L.fmt, TRUNC.W, CACHE):
+	Don't split opcode fields by hand, use the opcode field values
+	provided by igen.
+
 2002-03-01  Chris Demetriou  <cgd@broadcom.com>
 
 	* mips.igen (do_divu): Fix spacing.
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 9883175..5d0a336 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -41,6 +41,7 @@
 	$(SIM_@sim_gen@_OBJ) \
 	$(SIM_NEW_COMMON_OBJS) \
 	$(MIPS_EXTRA_OBJS) \
+	cp1.o \
 	interp.o \
 	sim-main.o \
 	sim-hload.o \
@@ -68,6 +69,7 @@
 ## COMMON_POST_CONFIG_FRAG
 
 interp.o: $(srcdir)/interp.c config.h sim-main.h itable.h
+cp1.o: $(srcdir)/cp1.c config.h sim-main.h
 
 
 ../igen/igen:
diff --git a/sim/mips/configure b/sim/mips/configure
index 3b94005..e5f427e 100755
--- a/sim/mips/configure
+++ b/sim/mips/configure
@@ -3764,6 +3764,8 @@
 #
 case "${target}" in
   mips*tx39*)           SIM_SUBTARGET="-DSUBTARGET_R3900=1";;
+  mipsisa32*-*-*)       SIM_SUBTARGET="-DTARGET_ENABLE_FR=1";;
+  mipsisa64*-*-*)       SIM_SUBTARGET="-DTARGET_ENABLE_FR=1";;
   *)                    SIM_SUBTARGET="";;
 esac
 
@@ -3780,6 +3782,8 @@
   mips64vr*el-*-*)      default_endian=LITTLE_ENDIAN ;;
   mips64*-*-*)          default_endian=BIG_ENDIAN ;;
   mips16*-*-*)          default_endian=BIG_ENDIAN ;;
+  mipsisa32*-*-*)       default_endian=BIG_ENDIAN ;;
+  mipsisa64*-*-*)       default_endian=BIG_ENDIAN ;;
   mips*-*-*)            default_endian=BIG_ENDIAN ;;
   *)                    default_endian=BIG_ENDIAN ;;
 esac
@@ -3839,6 +3843,8 @@
 case "${target}" in
   mips64*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
   mips16*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
+  mipsisa32*-*-*)       mips_bitsize=32 ; mips_msb=31 ;;
+  mipsisa64*-*-*)       mips_bitsize=64 ; mips_msb=63 ;;
   mips*-*-*)            mips_bitsize=32 ; mips_msb=31 ;;
   *)                    mips_bitsize=64 ; mips_msb=63 ;;
 esac
@@ -3916,6 +3922,8 @@
 			;;
   mips64*-*-*)          mips_fpu=HARD_FLOATING_POINT ;;
   mips16*-*-*)          mips_fpu=HARD_FLOATING_POINT ;;
+  mipsisa32*-*-*)       mips_fpu=HARD_FLOATING_POINT ; mips_fpu_bitsize=64 ;;
+  mipsisa64*-*-*)       mips_fpu=HARD_FLOATING_POINT ; mips_fpu_bitsize=64 ;;
   mips*-*-*)            mips_fpu=HARD_FLOATING_POINT ; mips_fpu_bitsize=32 ;;
   *)                    mips_fpu=HARD_FLOATING_POINT ;;
 esac
@@ -4011,6 +4019,14 @@
 			sim_igen_filter="32,64,f"
 			sim_m16_filter="16"
 			;;
+  mipsisa32*-*-*)	sim_gen=IGEN
+		        sim_igen_machine="-M mips32"
+			sim_igen_filter="32,f"
+			;;
+  mipsisa64*-*-*)	sim_gen=IGEN
+		        sim_igen_machine="-M mips64"
+			sim_igen_filter="32,64,f"
+			;;
   mips*lsi*)	        sim_gen=M16
 			sim_igen_machine="-M mipsIII,mips16"
 			sim_m16_machine="-M mips16,mipsIII"
@@ -4116,7 +4132,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:4120: checking for X" >&5
+echo "configure:4136: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -4178,12 +4194,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 4182 "configure"
+#line 4198 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4187: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4203: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4252,14 +4268,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4256 "configure"
+#line 4272 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:4263: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -4352,17 +4368,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4356: checking for $ac_hdr" >&5
+echo "configure:4372: 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
-#line 4361 "configure"
+#line 4377 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4382: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4389,7 +4405,7 @@
 done
 
 echo $ac_n "checking for fabs in -lm""... $ac_c" 1>&6
-echo "configure:4393: checking for fabs in -lm" >&5
+echo "configure:4409: checking for fabs in -lm" >&5
 ac_lib_var=`echo m'_'fabs | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4397,7 +4413,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4401 "configure"
+#line 4417 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4408,7 +4424,7 @@
 fabs()
 ; return 0; }
 EOF
-if { (eval echo configure:4412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4438,12 +4454,12 @@
 for ac_func in aint anint sqrt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4442: checking for $ac_func" >&5
+echo "configure:4458: 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 <<EOF
-#line 4447 "configure"
+#line 4463 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4466,7 +4482,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
diff --git a/sim/mips/configure.in b/sim/mips/configure.in
index bff4bc3..d8c4023 100644
--- a/sim/mips/configure.in
+++ b/sim/mips/configure.in
@@ -19,6 +19,8 @@
 #
 case "${target}" in
   mips*tx39*)           SIM_SUBTARGET="-DSUBTARGET_R3900=1";;
+  mipsisa32*-*-*)       SIM_SUBTARGET="-DTARGET_ENABLE_FR=1";;
+  mipsisa64*-*-*)       SIM_SUBTARGET="-DTARGET_ENABLE_FR=1";;
   *)                    SIM_SUBTARGET="";;
 esac
 AC_SUBST(SIM_SUBTARGET)
@@ -35,6 +37,8 @@
   mips64vr*el-*-*)      default_endian=LITTLE_ENDIAN ;;
   mips64*-*-*)          default_endian=BIG_ENDIAN ;;
   mips16*-*-*)          default_endian=BIG_ENDIAN ;;
+  mipsisa32*-*-*)       default_endian=BIG_ENDIAN ;;
+  mipsisa64*-*-*)       default_endian=BIG_ENDIAN ;;
   mips*-*-*)            default_endian=BIG_ENDIAN ;;
   *)                    default_endian=BIG_ENDIAN ;;
 esac
@@ -49,6 +53,8 @@
 case "${target}" in
   mips64*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
   mips16*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
+  mipsisa32*-*-*)       mips_bitsize=32 ; mips_msb=31 ;;
+  mipsisa64*-*-*)       mips_bitsize=64 ; mips_msb=63 ;;
   mips*-*-*)            mips_bitsize=32 ; mips_msb=31 ;;
   *)                    mips_bitsize=64 ; mips_msb=63 ;;
 esac
@@ -67,6 +73,8 @@
 			;;
   mips64*-*-*)          mips_fpu=HARD_FLOATING_POINT ;;
   mips16*-*-*)          mips_fpu=HARD_FLOATING_POINT ;;
+  mipsisa32*-*-*)       mips_fpu=HARD_FLOATING_POINT ; mips_fpu_bitsize=64 ;;
+  mipsisa64*-*-*)       mips_fpu=HARD_FLOATING_POINT ; mips_fpu_bitsize=64 ;;
   mips*-*-*)            mips_fpu=HARD_FLOATING_POINT ; mips_fpu_bitsize=32 ;;
   *)                    mips_fpu=HARD_FLOATING_POINT ;;
 esac
@@ -116,6 +124,14 @@
 			sim_igen_filter="32,64,f"
 			sim_m16_filter="16"
 			;;
+  mipsisa32*-*-*)	sim_gen=IGEN
+		        sim_igen_machine="-M mips32"
+			sim_igen_filter="32,f"
+			;;
+  mipsisa64*-*-*)	sim_gen=IGEN
+		        sim_igen_machine="-M mips64"
+			sim_igen_filter="32,64,f"
+			;;
   mips*lsi*)	        sim_gen=M16
 			sim_igen_machine="-M mipsIII,mips16"
 			sim_m16_machine="-M mips16,mipsIII"
diff --git a/sim/mips/cp1.c b/sim/mips/cp1.c
new file mode 100644
index 0000000..063c241
--- /dev/null
+++ b/sim/mips/cp1.c
@@ -0,0 +1,1193 @@
+/*> cp1.c <*/
+/* Floating Point Support for gdb MIPS simulators
+
+   This file is part of the MIPS sim
+
+		THIS SOFTWARE IS NOT COPYRIGHTED
+
+   Cygnus offers the following for use in the public domain.  Cygnus
+   makes no warranty with regard to the software or it's performance
+   and the user accepts the software "AS IS" with all faults.
+
+   CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
+   THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+   (Originally, this code was in interp.c)
+*/
+
+#include "sim-main.h"
+#include "sim-fpu.h"
+
+/* Within cp1.c we refer to sim_cpu directly.  */
+#define CPU cpu
+#define SD sd
+
+/*-- FPU support routines ---------------------------------------------------*/
+
+/* Numbers are held in normalized form. The SINGLE and DOUBLE binary
+   formats conform to ANSI/IEEE Std 754-1985.  */
+/* SINGLE precision floating:
+ *    seeeeeeeefffffffffffffffffffffff
+ *      s =  1bit  = sign
+ *      e =  8bits = exponent
+ *      f = 23bits = fraction
+ */
+/* SINGLE precision fixed:
+ *    siiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+ *      s =  1bit  = sign
+ *      i = 31bits = integer
+ */
+/* DOUBLE precision floating:
+ *    seeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffff
+ *      s =  1bit  = sign
+ *      e = 11bits = exponent
+ *      f = 52bits = fraction
+ */
+/* DOUBLE precision fixed:
+ *    siiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+ *      s =  1bit  = sign
+ *      i = 63bits = integer
+ */
+
+/* Explicit QNaN values used when value required:  */
+#define FPQNaN_SINGLE   (0x7FBFFFFF)
+#define FPQNaN_WORD     (0x7FFFFFFF)
+#define FPQNaN_DOUBLE   ((((uword64) 0x7FF7FFFF) << 32) | 0xFFFFFFFF)
+#define FPQNaN_LONG     ((((uword64) 0x7FFFFFFF) << 32) | 0xFFFFFFFF)
+
+static const char *fpu_format_name (FP_formats fmt);
+#ifdef DEBUG
+static const char *fpu_rounding_mode_name (int rm);
+#endif
+
+uword64
+value_fpr (SIM_DESC sd,
+	   sim_cpu *cpu,
+	   address_word cia,
+	   int fpr,
+	   FP_formats fmt)
+{
+  uword64 value = 0;
+  int err = 0;
+
+  /* Treat unused register values, as fixed-point 64bit values:  */
+  if ((fmt == fmt_uninterpreted) || (fmt == fmt_unknown))
+    {
+#if 1
+      /* If request to read data as "uninterpreted", then use the current
+	 encoding:  */
+      fmt = FPR_STATE[fpr];
+#else
+      fmt = fmt_long;
+#endif
+    }
+
+  /* For values not yet accessed, set to the desired format:  */
+  if (FPR_STATE[fpr] == fmt_uninterpreted)
+    {
+      FPR_STATE[fpr] = fmt;
+#ifdef DEBUG
+      printf ("DBG: Register %d was fmt_uninterpreted. Now %s\n", fpr,
+	      fpu_format_name (fmt));
+#endif /* DEBUG */
+    }
+  if (fmt != FPR_STATE[fpr])
+    {
+      sim_io_eprintf (sd, "FPR %d (format %s) being accessed with format %s - setting to unknown (PC = 0x%s)\n",
+		      fpr, fpu_format_name (FPR_STATE[fpr]),
+		      fpu_format_name (fmt), pr_addr (cia));
+      FPR_STATE[fpr] = fmt_unknown;
+    }
+
+  if (FPR_STATE[fpr] == fmt_unknown)
+    {
+      /* Set QNaN value:  */
+      switch (fmt)
+	{
+	case fmt_single:
+	  value = FPQNaN_SINGLE;
+	  break;
+
+	case fmt_double:
+	  value = FPQNaN_DOUBLE;
+	  break;
+
+	case fmt_word:
+	  value = FPQNaN_WORD;
+	  break;
+
+	case fmt_long:
+	  value = FPQNaN_LONG;
+	  break;
+
+	default:
+	  err = -1;
+	  break;
+	}
+    }
+  else if (SizeFGR () == 64)
+    {
+      switch (fmt)
+	{
+	case fmt_single:
+	case fmt_word:
+	  value = (FGR[fpr] & 0xFFFFFFFF);
+	  break;
+
+	case fmt_uninterpreted:
+	case fmt_double:
+	case fmt_long:
+	  value = FGR[fpr];
+	  break;
+
+	default:
+	  err = -1;
+	  break;
+	}
+    }
+  else
+    {
+      switch (fmt)
+	{
+	case fmt_single:
+	case fmt_word:
+	  value = (FGR[fpr] & 0xFFFFFFFF);
+	  break;
+
+	case fmt_uninterpreted:
+	case fmt_double:
+	case fmt_long:
+	  if ((fpr & 1) == 0)
+	    {
+	      /* even registers only */
+#ifdef DEBUG
+	      printf ("DBG: ValueFPR: FGR[%d] = %s, FGR[%d] = %s\n",
+		      fpr + 1, pr_uword64 ((uword64) FGR[fpr+1]),
+		      fpr, pr_uword64 ((uword64) FGR[fpr]));
+#endif
+	      value = ((((uword64) FGR[fpr+1]) << 32)
+		       | (FGR[fpr] & 0xFFFFFFFF));
+	    }
+	  else
+	    {
+	      SignalException (ReservedInstruction, 0);
+	    }
+	  break;
+
+	default :
+	  err = -1;
+	  break;
+	}
+    }
+
+  if (err)
+    SignalExceptionSimulatorFault ("Unrecognised FP format in ValueFPR ()");
+
+#ifdef DEBUG
+  printf ("DBG: ValueFPR: fpr = %d, fmt = %s, value = 0x%s : PC = 0x%s : SizeFGR () = %d\n",
+	  fpr, fpu_format_name (fmt), pr_uword64 (value), pr_addr (cia),
+	  SizeFGR ());
+#endif /* DEBUG */
+
+  return (value);
+}
+
+void
+store_fpr (SIM_DESC sd,
+	   sim_cpu *cpu,
+	   address_word cia,
+	   int fpr,
+	   FP_formats fmt,
+	   uword64 value)
+{
+  int err = 0;
+
+#ifdef DEBUG
+  printf ("DBG: StoreFPR: fpr = %d, fmt = %s, value = 0x%s : PC = 0x%s : SizeFGR () = %d, \n",
+	  fpr, fpu_format_name (fmt), pr_uword64 (value), pr_addr (cia),
+	  SizeFGR ());
+#endif /* DEBUG */
+
+  if (SizeFGR () == 64)
+    {
+      switch (fmt)
+	{
+	case fmt_uninterpreted_32:
+	  fmt = fmt_uninterpreted;
+	case fmt_single :
+	case fmt_word :
+	  if (STATE_VERBOSE_P (SD))
+	    sim_io_eprintf (SD,
+			    "Warning: PC 0x%s: interp.c store_fpr DEADCODE\n",
+			    pr_addr (cia));
+	  FGR[fpr] = (((uword64) 0xDEADC0DE << 32) | (value & 0xFFFFFFFF));
+	  FPR_STATE[fpr] = fmt;
+	  break;
+
+	case fmt_uninterpreted_64:
+	  fmt = fmt_uninterpreted;
+	case fmt_uninterpreted:
+	case fmt_double :
+	case fmt_long :
+	  FGR[fpr] = value;
+	  FPR_STATE[fpr] = fmt;
+	  break;
+
+	default :
+	  FPR_STATE[fpr] = fmt_unknown;
+	  err = -1;
+	  break;
+	}
+    }
+  else
+    {
+      switch (fmt)
+	{
+	case fmt_uninterpreted_32:
+	  fmt = fmt_uninterpreted;
+	case fmt_single :
+	case fmt_word :
+	  FGR[fpr] = (value & 0xFFFFFFFF);
+	  FPR_STATE[fpr] = fmt;
+	  break;
+
+	case fmt_uninterpreted_64:
+	  fmt = fmt_uninterpreted;
+	case fmt_uninterpreted:
+	case fmt_double :
+	case fmt_long :
+	  if ((fpr & 1) == 0)
+	    {
+	      /* even register number only */
+	      FGR[fpr+1] = (value >> 32);
+	      FGR[fpr] = (value & 0xFFFFFFFF);
+	      FPR_STATE[fpr + 1] = fmt;
+	      FPR_STATE[fpr] = fmt;
+	    }
+	  else
+	    {
+	      FPR_STATE[fpr] = fmt_unknown;
+	      FPR_STATE[fpr + 1] = fmt_unknown;
+	      SignalException (ReservedInstruction, 0);
+	    }
+	  break;
+
+	default :
+	  FPR_STATE[fpr] = fmt_unknown;
+	  err = -1;
+	  break;
+	}
+    }
+
+  if (err)
+    SignalExceptionSimulatorFault ("Unrecognised FP format in StoreFPR ()");
+
+#ifdef DEBUG
+  printf ("DBG: StoreFPR: fpr[%d] = 0x%s (format %s)\n",
+	  fpr, pr_uword64 (FGR[fpr]), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return;
+}
+
+int
+NaN (op, fmt)
+     uword64 op;
+     FP_formats fmt;
+{
+  int boolean = 0;
+  switch (fmt)
+    {
+    case fmt_single:
+    case fmt_word:
+      {
+	sim_fpu wop;
+	sim_fpu_32to (&wop, op);
+	boolean = sim_fpu_is_nan (&wop);
+	break;
+      }
+    case fmt_double:
+    case fmt_long:
+      {
+	sim_fpu wop;
+	sim_fpu_64to (&wop, op);
+	boolean = sim_fpu_is_nan (&wop);
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: NaN: returning %d for 0x%s (format = %s)\n",
+	  boolean, pr_addr (op), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (boolean);
+}
+
+int
+Infinity (op, fmt)
+     uword64 op;
+     FP_formats fmt;
+{
+  int boolean = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Infinity: format %s 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op));
+#endif /* DEBUG */
+
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop;
+	sim_fpu_32to (&wop, op);
+	boolean = sim_fpu_is_infinity (&wop);
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop;
+	sim_fpu_64to (&wop, op);
+	boolean = sim_fpu_is_infinity (&wop);
+	break;
+      }
+    default:
+      printf ("DBG: TODO: unrecognised format (%s) for Infinity check\n",
+	      fpu_format_name (fmt));
+      break;
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Infinity: returning %d for 0x%s (format = %s)\n",
+	  boolean, pr_addr (op), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (boolean);
+}
+
+int
+Less (op1, op2, fmt)
+     uword64 op1;
+     uword64 op2;
+     FP_formats fmt;
+{
+  int boolean = 0;
+
+  /* Argument checking already performed by the FPCOMPARE code */
+
+#ifdef DEBUG
+  printf ("DBG: Less: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	boolean = sim_fpu_is_lt (&wop1, &wop2);
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	boolean = sim_fpu_is_lt (&wop1, &wop2);
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Less: returning %d (format = %s)\n",
+	  boolean, fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (boolean);
+}
+
+int
+Equal (op1, op2, fmt)
+     uword64 op1;
+     uword64 op2;
+     FP_formats fmt;
+{
+  int boolean = 0;
+
+  /* Argument checking already performed by the FPCOMPARE code */
+
+#ifdef DEBUG
+  printf ("DBG: Equal: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	boolean = sim_fpu_is_eq (&wop1, &wop2);
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	boolean = sim_fpu_is_eq (&wop1, &wop2);
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Equal: returning %d (format = %s)\n",
+	  boolean, fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (boolean);
+}
+
+uword64
+AbsoluteValue (op, fmt)
+     uword64 op;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: AbsoluteValue: %s: op = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op));
+#endif /* DEBUG */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop;
+	unsigned32 ans;
+	sim_fpu_32to (&wop, op);
+	sim_fpu_abs (&wop, &wop);
+	sim_fpu_to32 (&ans, &wop);
+	result = ans;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop;
+	unsigned64 ans;
+	sim_fpu_64to (&wop, op);
+	sim_fpu_abs (&wop, &wop);
+	sim_fpu_to64 (&ans, &wop);
+	result = ans;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+  return (result);
+}
+
+uword64
+Negate (op, fmt)
+     uword64 op;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Negate: %s: op = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op));
+#endif /* DEBUG */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop;
+	unsigned32 ans;
+	sim_fpu_32to (&wop, op);
+	sim_fpu_neg (&wop, &wop);
+	sim_fpu_to32 (&ans, &wop);
+	result = ans;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop;
+	unsigned64 ans;
+	sim_fpu_64to (&wop, op);
+	sim_fpu_neg (&wop, &wop);
+	sim_fpu_to64 (&ans, &wop);
+	result = ans;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+  return (result);
+}
+
+uword64
+Add (op1, op2, fmt)
+     uword64 op1;
+     uword64 op2;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Add: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+  
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned32 res;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	sim_fpu_add (&ans, &wop1, &wop2);
+	sim_fpu_to32 (&res, &ans);
+	result = res;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned64 res;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	sim_fpu_add (&ans, &wop1, &wop2);
+	sim_fpu_to64 (&res, &ans);
+	result = res;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Add: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+
+uword64
+Sub (op1, op2, fmt)
+     uword64 op1;
+     uword64 op2;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Sub: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned32 res;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	sim_fpu_sub (&ans, &wop1, &wop2);
+	sim_fpu_to32 (&res, &ans);
+	result = res;
+      }
+      break;
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned64 res;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	sim_fpu_sub (&ans, &wop1, &wop2);
+	sim_fpu_to64 (&res, &ans);
+	result = res;
+      }
+      break;
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Sub: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+
+uword64
+Multiply (op1, op2, fmt)
+     uword64 op1;
+     uword64 op2;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Multiply: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned32 res;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	sim_fpu_mul (&ans, &wop1, &wop2);
+	sim_fpu_to32 (&res, &ans);
+	result = res;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned64 res;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	sim_fpu_mul (&ans, &wop1, &wop2);
+	sim_fpu_to64 (&res, &ans);
+	result = res;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Multiply: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+
+uword64
+Divide (op1, op2, fmt)
+     uword64 op1;
+     uword64 op2;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Divide: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned32 res;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	sim_fpu_div (&ans, &wop1, &wop2);
+	sim_fpu_to32 (&res, &ans);
+	result = res;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu ans;
+	unsigned64 res;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	sim_fpu_div (&ans, &wop1, &wop2);
+	sim_fpu_to64 (&res, &ans);
+	result = res;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Divide: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+
+uword64 UNUSED
+Recip (op, fmt)
+     uword64 op;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: Recip: %s: op = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop;
+	sim_fpu ans;
+	unsigned32 res;
+	sim_fpu_32to (&wop, op);
+	sim_fpu_inv (&ans, &wop);
+	sim_fpu_to32 (&res, &ans);
+	result = res;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop;
+	sim_fpu ans;
+	unsigned64 res;
+	sim_fpu_64to (&wop, op);
+	sim_fpu_inv (&ans, &wop);
+	sim_fpu_to64 (&res, &ans);
+	result = res;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Recip: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+
+uword64
+SquareRoot (op, fmt)
+     uword64 op;
+     FP_formats fmt;
+{
+  uword64 result = 0;
+
+#ifdef DEBUG
+  printf ("DBG: SquareRoot: %s: op = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop;
+	sim_fpu ans;
+	unsigned32 res;
+	sim_fpu_32to (&wop, op);
+	sim_fpu_sqrt (&ans, &wop);
+	sim_fpu_to32 (&res, &ans);
+	result = res;
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop;
+	sim_fpu ans;
+	unsigned64 res;
+	sim_fpu_64to (&wop, op);
+	sim_fpu_sqrt (&ans, &wop);
+	sim_fpu_to64 (&res, &ans);
+	result = res;
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: SquareRoot: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+
+#if 0
+uword64
+Max (uword64 op1,
+     uword64 op2,
+     FP_formats fmt)
+{
+  int cmp;
+  unsigned64 result;
+
+#ifdef DEBUG
+  printf ("DBG: Max: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	cmp = sim_fpu_cmp (&wop1, &wop2);
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	cmp = sim_fpu_cmp (&wop1, &wop2);
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+  switch (cmp)
+    {
+    case SIM_FPU_IS_SNAN:
+    case SIM_FPU_IS_QNAN:
+      result = op1;
+    case SIM_FPU_IS_NINF:
+    case SIM_FPU_IS_NNUMBER:
+    case SIM_FPU_IS_NDENORM:
+    case SIM_FPU_IS_NZERO:
+      result = op2; /* op1 - op2 < 0 */
+    case SIM_FPU_IS_PINF:
+    case SIM_FPU_IS_PNUMBER:
+    case SIM_FPU_IS_PDENORM:
+    case SIM_FPU_IS_PZERO:
+      result = op1; /* op1 - op2 > 0 */
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Max: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+#endif
+
+#if 0
+uword64
+Min (uword64 op1,
+     uword64 op2,
+     FP_formats fmt)
+{
+  int cmp;
+  unsigned64 result;
+
+#ifdef DEBUG
+  printf ("DBG: Min: %s: op1 = 0x%s : op2 = 0x%s\n",
+	  fpu_format_name (fmt), pr_addr (op1), pr_addr (op2));
+#endif /* DEBUG */
+
+  /* The registers must specify FPRs valid for operands of type
+     "fmt". If they are not valid, the result is undefined.  */
+
+  /* The format type should already have been checked:  */
+  switch (fmt)
+    {
+    case fmt_single:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_32to (&wop1, op1);
+	sim_fpu_32to (&wop2, op2);
+	cmp = sim_fpu_cmp (&wop1, &wop2);
+	break;
+      }
+    case fmt_double:
+      {
+	sim_fpu wop1;
+	sim_fpu wop2;
+	sim_fpu_64to (&wop1, op1);
+	sim_fpu_64to (&wop2, op2);
+	cmp = sim_fpu_cmp (&wop1, &wop2);
+	break;
+      }
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+  switch (cmp)
+    {
+    case SIM_FPU_IS_SNAN:
+    case SIM_FPU_IS_QNAN:
+      result = op1;
+    case SIM_FPU_IS_NINF:
+    case SIM_FPU_IS_NNUMBER:
+    case SIM_FPU_IS_NDENORM:
+    case SIM_FPU_IS_NZERO:
+      result = op1; /* op1 - op2 < 0 */
+    case SIM_FPU_IS_PINF:
+    case SIM_FPU_IS_PNUMBER:
+    case SIM_FPU_IS_PDENORM:
+    case SIM_FPU_IS_PZERO:
+      result = op2; /* op1 - op2 > 0 */
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Min: returning 0x%s (format = %s)\n",
+	  pr_addr (result), fpu_format_name (fmt));
+#endif /* DEBUG */
+
+  return (result);
+}
+#endif
+
+uword64
+convert (SIM_DESC sd,
+	 sim_cpu *cpu,
+	 address_word cia,
+	 int rm,
+	 uword64 op,
+	 FP_formats from,
+	 FP_formats to)
+{
+  sim_fpu wop;
+  sim_fpu_round round;
+  unsigned32 result32;
+  unsigned64 result64;
+
+#ifdef DEBUG
+#if 0 /* FIXME: doesn't compile */
+  printf ("DBG: Convert: mode %s : op 0x%s : from %s : to %s : (PC = 0x%s)\n",
+	  fpu_rounding_mode_name (rm), pr_addr (op), fpu_format_name (from),
+	  fpu_format_name (to), pr_addr (IPC));
+#endif
+#endif /* DEBUG */
+
+  switch (rm)
+    {
+    case FP_RM_NEAREST:
+      /* Round result to nearest representable value. When two
+	 representable values are equally near, round to the value
+	 that has a least significant bit of zero (i.e. is even).  */
+      round = sim_fpu_round_near;
+      break;
+    case FP_RM_TOZERO:
+      /* Round result to the value closest to, and not greater in
+	 magnitude than, the result.  */
+      round = sim_fpu_round_zero;
+      break;
+    case FP_RM_TOPINF:
+      /* Round result to the value closest to, and not less than,
+	 the result.  */
+      round = sim_fpu_round_up;
+      break;
+
+    case FP_RM_TOMINF:
+      /* Round result to the value closest to, and not greater than,
+	 the result.  */
+      round = sim_fpu_round_down;
+      break;
+    default:
+      round = 0;
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+  /* Convert the input to sim_fpu internal format */
+  switch (from)
+    {
+    case fmt_double:
+      sim_fpu_64to (&wop, op);
+      break;
+    case fmt_single:
+      sim_fpu_32to (&wop, op);
+      break;
+    case fmt_word:
+      sim_fpu_i32to (&wop, op, round);
+      break;
+    case fmt_long:
+      sim_fpu_i64to (&wop, op, round);
+      break;
+    default:
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+  /* Convert sim_fpu format into the output */
+  /* The value WOP is converted to the destination format, rounding
+     using mode RM. When the destination is a fixed-point format, then
+     a source value of Infinity, NaN or one which would round to an
+     integer outside the fixed point range then an IEEE Invalid
+     Operation condition is raised.  */
+  switch (to)
+    {
+    case fmt_single:
+      sim_fpu_round_32 (&wop, round, 0);
+      sim_fpu_to32 (&result32, &wop);
+      result64 = result32;
+      break;
+    case fmt_double:
+      sim_fpu_round_64 (&wop, round, 0);
+      sim_fpu_to64 (&result64, &wop);
+      break;
+    case fmt_word:
+      sim_fpu_to32i (&result32, &wop, round);
+      result64 = result32;
+      break;
+    case fmt_long:
+      sim_fpu_to64i (&result64, &wop, round);
+      break;
+    default:
+      result64 = 0;
+      fprintf (stderr, "Bad switch\n");
+      abort ();
+    }
+
+#ifdef DEBUG
+  printf ("DBG: Convert: returning 0x%s (to format = %s)\n",
+	  pr_addr (result64), fpu_format_name (to));
+#endif /* DEBUG */
+
+  return (result64);
+}
+
+static const char *
+fpu_format_name (FP_formats fmt)
+{
+  switch (fmt)
+    {
+    case fmt_single:
+      return "single";
+    case fmt_double:
+      return "double";
+    case fmt_word:
+      return "word";
+    case fmt_long:
+      return "long";
+    case fmt_unknown:
+      return "<unknown>";
+    case fmt_uninterpreted:
+      return "<uninterpreted>";
+    case fmt_uninterpreted_32:
+      return "<uninterpreted_32>";
+    case fmt_uninterpreted_64:
+      return "<uninterpreted_64>";
+    default:
+      return "<format error>";
+    }
+}
+
+#ifdef DEBUG
+static const char *
+fpu_rounding_mode_name (int rm)
+{
+  switch (rm)
+    {
+    case FP_RM_NEAREST:
+      return "Round";
+    case FP_RM_TOZERO:
+      return "Trunc";
+    case FP_RM_TOPINF:
+      return "Ceil";
+    case FP_RM_TOMINF:
+      return "Floor";
+    default:
+      return "<rounding mode error>";
+    }
+}
+#endif /* DEBUG */
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index 95f0ab6..805f72a 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -1238,7 +1238,7 @@
 	sim_write (sd, A0 + 0, (char *)&value, 4);
 	sim_write (sd, A0 + 4, (char *)&zero, 4);
 	sim_write (sd, A0 + 8, (char *)&zero, 4);
-	/* sim_io_eprintf (sd, "sim: get_mem_info() depreciated\n"); */
+	/* sim_io_eprintf (sd, "sim: get_mem_info() deprecated\n"); */
 	break;
       }
     
@@ -1426,7 +1426,7 @@
 	  LoadMemory (&memval,NULL,uncached, AccessLength_WORD, paddr, vaddr,
 			       isDATA, isREAL);
 	  byte = (vaddr & mask) ^ (bigend << 2);
-	  return SIGNEXTEND (((memval >> (8 * byte)) & 0xffffffff), 32);
+	  return EXTEND32 (memval >> (8 * byte));
 	}
     }
 
@@ -1869,1096 +1869,30 @@
 
 
 
-#if defined(WARN_RESULT)
-/* Description from page A-26 of the "MIPS IV Instruction Set" manual (revision 3.1) */
-/* This function indicates that the result of the operation is
-   undefined. However, this should not affect the instruction
-   stream. All that is meant to happen is that the destination
-   register is set to an undefined result. To keep the simulator
-   simple, we just don't bother updating the destination register, so
-   the overall result will be undefined. If desired we can stop the
-   simulator by raising a pseudo-exception. */
-#define UndefinedResult() undefined_result (sd,cia)
-static void
-undefined_result(sd,cia)
-     SIM_DESC sd;
-     address_word cia;
-{
-  sim_io_eprintf(sd,"UndefinedResult: PC = 0x%s\n",pr_addr(cia));
-#if 0 /* Disabled for the moment, since it actually happens a lot at the moment. */
-  state |= simSTOP;
-#endif
-  return;
-}
-#endif /* WARN_RESULT */
+/* This function implements what the MIPS32 and MIPS64 ISAs define as
+   "UNPREDICTABLE" behaviour.
 
-/*-- FPU support routines ---------------------------------------------------*/
+   About UNPREDICTABLE behaviour they say: "UNPREDICTABLE results
+   may vary from processor implementation to processor implementation,
+   instruction to instruction, or as a function of time on the same
+   implementation or instruction.  Software can never depend on results
+   that are UNPREDICTABLE. ..."  (MIPS64 Architecture for Programmers
+   Volume II, The MIPS64 Instruction Set.  MIPS Document MD00087 revision
+   0.95, page 2.)
+  
+   For UNPREDICTABLE behaviour, we print a message, if possible print
+   the offending instructions mips.igen instruction name (provided by
+   the caller), and stop the simulator.
 
-/* Numbers are held in normalized form. The SINGLE and DOUBLE binary
-   formats conform to ANSI/IEEE Std 754-1985. */
-/* SINGLE precision floating:
- *    seeeeeeeefffffffffffffffffffffff
- *      s =  1bit  = sign
- *      e =  8bits = exponent
- *      f = 23bits = fraction
- */
-/* SINGLE precision fixed:
- *    siiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
- *      s =  1bit  = sign
- *      i = 31bits = integer
- */
-/* DOUBLE precision floating:
- *    seeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffff
- *      s =  1bit  = sign
- *      e = 11bits = exponent
- *      f = 52bits = fraction
- */
-/* DOUBLE precision fixed:
- *    siiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
- *      s =  1bit  = sign
- *      i = 63bits = integer
- */
-
-/* Extract sign-bit: */
-#define FP_S_s(v)    (((v) & ((unsigned)1 << 31)) ? 1 : 0)
-#define FP_D_s(v)    (((v) & ((uword64)1 << 63)) ? 1 : 0)
-/* Extract biased exponent: */
-#define FP_S_be(v)   (((v) >> 23) & 0xFF)
-#define FP_D_be(v)   (((v) >> 52) & 0x7FF)
-/* Extract unbiased Exponent: */
-#define FP_S_e(v)    (FP_S_be(v) - 0x7F)
-#define FP_D_e(v)    (FP_D_be(v) - 0x3FF)
-/* Extract complete fraction field: */
-#define FP_S_f(v)    ((v) & ~((unsigned)0x1FF << 23))
-#define FP_D_f(v)    ((v) & ~((uword64)0xFFF << 52))
-/* Extract numbered fraction bit: */
-#define FP_S_fb(b,v) (((v) & (1 << (23 - (b)))) ? 1 : 0)
-#define FP_D_fb(b,v) (((v) & (1 << (52 - (b)))) ? 1 : 0)
-
-/* Explicit QNaN values used when value required: */
-#define FPQNaN_SINGLE   (0x7FBFFFFF)
-#define FPQNaN_WORD     (0x7FFFFFFF)
-#define FPQNaN_DOUBLE   (((uword64)0x7FF7FFFF << 32) | 0xFFFFFFFF)
-#define FPQNaN_LONG     (((uword64)0x7FFFFFFF << 32) | 0xFFFFFFFF)
-
-/* Explicit Infinity values used when required: */
-#define FPINF_SINGLE    (0x7F800000)
-#define FPINF_DOUBLE    (((uword64)0x7FF00000 << 32) | 0x00000000)
-
-#define RMMODE(v) (((v) == FP_RM_NEAREST) ? "Round" : (((v) == FP_RM_TOZERO) ? "Trunc" : (((v) == FP_RM_TOPINF) ? "Ceil" : "Floor")))
-#define DOFMT(v)  (((v) == fmt_single) ? "single" : (((v) == fmt_double) ? "double" : (((v) == fmt_word) ? "word" : (((v) == fmt_long) ? "long" : (((v) == fmt_unknown) ? "<unknown>" : (((v) == fmt_uninterpreted) ? "<uninterpreted>" : (((v) == fmt_uninterpreted_32) ? "<uninterpreted_32>" : (((v) == fmt_uninterpreted_64) ? "<uninterpreted_64>" : "<format error>"))))))))
-
-uword64
-value_fpr (SIM_DESC sd,
-	   sim_cpu *cpu,
-	   address_word cia,
-	   int fpr,
-	   FP_formats fmt)
-{
-  uword64 value = 0;
-  int err = 0;
-
-  /* Treat unused register values, as fixed-point 64bit values: */
-  if ((fmt == fmt_uninterpreted) || (fmt == fmt_unknown))
-#if 1
-   /* If request to read data as "uninterpreted", then use the current
-      encoding: */
-   fmt = FPR_STATE[fpr];
-#else
-   fmt = fmt_long;
-#endif
-
-  /* For values not yet accessed, set to the desired format: */
-  if (FPR_STATE[fpr] == fmt_uninterpreted) {
-    FPR_STATE[fpr] = fmt;
-#ifdef DEBUG
-    printf("DBG: Register %d was fmt_uninterpreted. Now %s\n",fpr,DOFMT(fmt));
-#endif /* DEBUG */
-  }
-  if (fmt != FPR_STATE[fpr]) {
-    sim_io_eprintf(sd,"FPR %d (format %s) being accessed with format %s - setting to unknown (PC = 0x%s)\n",fpr,DOFMT(FPR_STATE[fpr]),DOFMT(fmt),pr_addr(cia));
-    FPR_STATE[fpr] = fmt_unknown;
-  }
-
-  if (FPR_STATE[fpr] == fmt_unknown) {
-   /* Set QNaN value: */
-   switch (fmt) {
-    case fmt_single:
-     value = FPQNaN_SINGLE;
-     break;
-
-    case fmt_double:
-     value = FPQNaN_DOUBLE;
-     break;
-
-    case fmt_word:
-     value = FPQNaN_WORD;
-     break;
-
-    case fmt_long:
-     value = FPQNaN_LONG;
-     break;
-
-    default:
-     err = -1;
-     break;
-   }
-  } else if (SizeFGR() == 64) {
-    switch (fmt) {
-     case fmt_single:
-     case fmt_word:
-      value = (FGR[fpr] & 0xFFFFFFFF);
-      break;
-
-     case fmt_uninterpreted:
-     case fmt_double:
-     case fmt_long:
-      value = FGR[fpr];
-      break;
-
-     default :
-      err = -1;
-      break;
-    }
-  } else {
-    switch (fmt) {
-     case fmt_single:
-     case fmt_word:
-      value = (FGR[fpr] & 0xFFFFFFFF);
-      break;
-
-     case fmt_uninterpreted:
-     case fmt_double:
-     case fmt_long:
-      if ((fpr & 1) == 0) { /* even registers only */
-#ifdef DEBUG
-	printf("DBG: ValueFPR: FGR[%d] = %s, FGR[%d] = %s\n", 
-	       fpr+1, pr_uword64( (uword64) FGR[fpr+1] ),
-	       fpr, pr_uword64( (uword64) FGR[fpr] ));
-#endif
-	value = ((((uword64)FGR[fpr+1]) << 32) | (FGR[fpr] & 0xFFFFFFFF));
-      } else {
-	SignalException(ReservedInstruction,0);
-      }
-      break;
-
-     default :
-      err = -1;
-      break;
-    }
-  }
-
-  if (err)
-   SignalExceptionSimulatorFault ("Unrecognised FP format in ValueFPR()");
-
-#ifdef DEBUG
-  printf("DBG: ValueFPR: fpr = %d, fmt = %s, value = 0x%s : PC = 0x%s : SizeFGR() = %d\n",fpr,DOFMT(fmt),pr_uword64(value),pr_addr(cia),SizeFGR());
-#endif /* DEBUG */
-
-  return(value);
-}
-
+   XXX FIXME: eventually, stopping the simulator should be made conditional
+   on a command-line option.  */
 void
-store_fpr (SIM_DESC sd,
-	   sim_cpu *cpu,
-	   address_word cia,
-	   int fpr,
-	   FP_formats fmt,
-	   uword64 value)
+unpredictable_action(sim_cpu *cpu, address_word cia)
 {
-  int err = 0;
+  SIM_DESC sd = CPU_STATE(cpu);
 
-#ifdef DEBUG
-  printf("DBG: StoreFPR: fpr = %d, fmt = %s, value = 0x%s : PC = 0x%s : SizeFGR() = %d,\n",fpr,DOFMT(fmt),pr_uword64(value),pr_addr(cia),SizeFGR());
-#endif /* DEBUG */
-
-  if (SizeFGR() == 64) {
-    switch (fmt) {
-      case fmt_uninterpreted_32:
-	fmt = fmt_uninterpreted;
-      case fmt_single :
-      case fmt_word :
-       if (STATE_VERBOSE_P(SD))
-         sim_io_eprintf (SD, "Warning: PC 0x%s: interp.c store_fpr DEADCODE\n",
-	   pr_addr(cia));
-       FGR[fpr] = (((uword64)0xDEADC0DE << 32) | (value & 0xFFFFFFFF));
-       FPR_STATE[fpr] = fmt;
-       break;
-
-      case fmt_uninterpreted_64:
-	fmt = fmt_uninterpreted;
-      case fmt_uninterpreted:
-      case fmt_double :
-      case fmt_long :
-       FGR[fpr] = value;
-       FPR_STATE[fpr] = fmt;
-       break;
-
-      default :
-       FPR_STATE[fpr] = fmt_unknown;
-       err = -1;
-       break;
-    }
-  } else {
-    switch (fmt) {
-      case fmt_uninterpreted_32:
-	fmt = fmt_uninterpreted;
-      case fmt_single :
-      case fmt_word :
-       FGR[fpr] = (value & 0xFFFFFFFF);
-       FPR_STATE[fpr] = fmt;
-       break;
-
-      case fmt_uninterpreted_64:
-	fmt = fmt_uninterpreted;
-      case fmt_uninterpreted:
-      case fmt_double :
-      case fmt_long :
-	if ((fpr & 1) == 0) { /* even register number only */
-	  FGR[fpr+1] = (value >> 32);
-	  FGR[fpr] = (value & 0xFFFFFFFF);
-	  FPR_STATE[fpr + 1] = fmt;
-	  FPR_STATE[fpr] = fmt;
-	} else {
-	  FPR_STATE[fpr] = fmt_unknown;
-	  FPR_STATE[fpr + 1] = fmt_unknown;
-	  SignalException(ReservedInstruction,0);
-	}
-       break;
-
-      default :
-       FPR_STATE[fpr] = fmt_unknown;
-       err = -1;
-       break;
-    }
-  }
-#if defined(WARN_RESULT)
-  else
-    UndefinedResult();
-#endif /* WARN_RESULT */
-
-  if (err)
-   SignalExceptionSimulatorFault ("Unrecognised FP format in StoreFPR()");
-
-#ifdef DEBUG
-  printf("DBG: StoreFPR: fpr[%d] = 0x%s (format %s)\n",fpr,pr_uword64(FGR[fpr]),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return;
-}
-
-int
-NaN(op,fmt)
-     uword64 op;
-     FP_formats fmt; 
-{
-  int boolean = 0;
-  switch (fmt) {
-   case fmt_single:
-   case fmt_word:
-    {
-      sim_fpu wop;
-      sim_fpu_32to (&wop, op);
-      boolean = sim_fpu_is_nan (&wop);
-      break;
-    }
-   case fmt_double:
-   case fmt_long:
-    {
-      sim_fpu wop;
-      sim_fpu_64to (&wop, op);
-      boolean = sim_fpu_is_nan (&wop);
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-printf("DBG: NaN: returning %d for 0x%s (format = %s)\n",boolean,pr_addr(op),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(boolean);
-}
-
-int
-Infinity(op,fmt)
-     uword64 op;
-     FP_formats fmt; 
-{
-  int boolean = 0;
-
-#ifdef DEBUG
-  printf("DBG: Infinity: format %s 0x%s\n",DOFMT(fmt),pr_addr(op));
-#endif /* DEBUG */
-
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop;
-      sim_fpu_32to (&wop, op);
-      boolean = sim_fpu_is_infinity (&wop);
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop;
-      sim_fpu_64to (&wop, op);
-      boolean = sim_fpu_is_infinity (&wop);
-      break;
-    }
-   default:
-    printf("DBG: TODO: unrecognised format (%s) for Infinity check\n",DOFMT(fmt));
-    break;
-  }
-
-#ifdef DEBUG
-  printf("DBG: Infinity: returning %d for 0x%s (format = %s)\n",boolean,pr_addr(op),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(boolean);
-}
-
-int
-Less(op1,op2,fmt)
-     uword64 op1;
-     uword64 op2;
-     FP_formats fmt; 
-{
-  int boolean = 0;
-
-  /* Argument checking already performed by the FPCOMPARE code */
-
-#ifdef DEBUG
-  printf("DBG: Less: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu_32to (&wop1, op1);
-      sim_fpu_32to (&wop2, op2);
-      boolean = sim_fpu_is_lt (&wop1, &wop2);
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu_64to (&wop1, op1);
-      sim_fpu_64to (&wop2, op2);
-      boolean = sim_fpu_is_lt (&wop1, &wop2);
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Less: returning %d (format = %s)\n",boolean,DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(boolean);
-}
-
-int
-Equal(op1,op2,fmt)
-     uword64 op1;
-     uword64 op2;
-     FP_formats fmt; 
-{
-  int boolean = 0;
-
-  /* Argument checking already performed by the FPCOMPARE code */
-
-#ifdef DEBUG
-  printf("DBG: Equal: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu_32to (&wop1, op1);
-      sim_fpu_32to (&wop2, op2);
-      boolean = sim_fpu_is_eq (&wop1, &wop2);
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu_64to (&wop1, op1);
-      sim_fpu_64to (&wop2, op2);
-      boolean = sim_fpu_is_eq (&wop1, &wop2);
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Equal: returning %d (format = %s)\n",boolean,DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(boolean);
-}
-
-uword64
-AbsoluteValue(op,fmt)
-     uword64 op;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: AbsoluteValue: %s: op = 0x%s\n",DOFMT(fmt),pr_addr(op));
-#endif /* DEBUG */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop;
-      unsigned32 ans;
-      sim_fpu_32to (&wop, op);
-      sim_fpu_abs (&wop, &wop);
-      sim_fpu_to32 (&ans, &wop);
-      result = ans;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop;
-      unsigned64 ans;
-      sim_fpu_64to (&wop, op);
-      sim_fpu_abs (&wop, &wop);
-      sim_fpu_to64 (&ans, &wop);
-      result = ans;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-  return(result);
-}
-
-uword64
-Negate(op,fmt)
-     uword64 op;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: Negate: %s: op = 0x%s\n",DOFMT(fmt),pr_addr(op));
-#endif /* DEBUG */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop;
-      unsigned32 ans;
-      sim_fpu_32to (&wop, op);
-      sim_fpu_neg (&wop, &wop);
-      sim_fpu_to32 (&ans, &wop);
-      result = ans;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop;
-      unsigned64 ans;
-      sim_fpu_64to (&wop, op);
-      sim_fpu_neg (&wop, &wop);
-      sim_fpu_to64 (&ans, &wop);
-      result = ans;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-  return(result);
-}
-
-uword64
-Add(op1,op2,fmt)
-     uword64 op1;
-     uword64 op2;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: Add: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned32 res;
-      sim_fpu_32to (&wop1, op1);
-      sim_fpu_32to (&wop2, op2);
-      sim_fpu_add (&ans, &wop1, &wop2);
-      sim_fpu_to32 (&res, &ans);
-      result = res;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned64 res;
-      sim_fpu_64to (&wop1, op1);
-      sim_fpu_64to (&wop2, op2);
-      sim_fpu_add (&ans, &wop1, &wop2);
-      sim_fpu_to64 (&res, &ans);
-      result = res;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Add: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-
-uword64
-Sub(op1,op2,fmt)
-     uword64 op1;
-     uword64 op2;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: Sub: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned32 res;
-      sim_fpu_32to (&wop1, op1);
-      sim_fpu_32to (&wop2, op2);
-      sim_fpu_sub (&ans, &wop1, &wop2);
-      sim_fpu_to32 (&res, &ans);
-      result = res;
-    }
-    break;
-   case fmt_double:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned64 res;
-      sim_fpu_64to (&wop1, op1);
-      sim_fpu_64to (&wop2, op2);
-      sim_fpu_sub (&ans, &wop1, &wop2);
-      sim_fpu_to64 (&res, &ans);
-      result = res;
-    }
-    break;
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Sub: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-
-uword64
-Multiply(op1,op2,fmt)
-     uword64 op1;
-     uword64 op2;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: Multiply: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned32 res;
-      sim_fpu_32to (&wop1, op1);
-      sim_fpu_32to (&wop2, op2);
-      sim_fpu_mul (&ans, &wop1, &wop2);
-      sim_fpu_to32 (&res, &ans);
-      result = res;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned64 res;
-      sim_fpu_64to (&wop1, op1);
-      sim_fpu_64to (&wop2, op2);
-      sim_fpu_mul (&ans, &wop1, &wop2);
-      sim_fpu_to64 (&res, &ans);
-      result = res;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Multiply: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-
-uword64
-Divide(op1,op2,fmt)
-     uword64 op1;
-     uword64 op2;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: Divide: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned32 res;
-      sim_fpu_32to (&wop1, op1);
-      sim_fpu_32to (&wop2, op2);
-      sim_fpu_div (&ans, &wop1, &wop2);
-      sim_fpu_to32 (&res, &ans);
-      result = res;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop1;
-      sim_fpu wop2;
-      sim_fpu ans;
-      unsigned64 res;
-      sim_fpu_64to (&wop1, op1);
-      sim_fpu_64to (&wop2, op2);
-      sim_fpu_div (&ans, &wop1, &wop2);
-      sim_fpu_to64 (&res, &ans);
-      result = res;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Divide: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-
-uword64 UNUSED
-Recip(op,fmt)
-     uword64 op;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: Recip: %s: op = 0x%s\n",DOFMT(fmt),pr_addr(op));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop;
-      sim_fpu ans;
-      unsigned32 res;
-      sim_fpu_32to (&wop, op);
-      sim_fpu_inv (&ans, &wop);
-      sim_fpu_to32 (&res, &ans);
-      result = res;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop;
-      sim_fpu ans;
-      unsigned64 res;
-      sim_fpu_64to (&wop, op);
-      sim_fpu_inv (&ans, &wop);
-      sim_fpu_to64 (&res, &ans);
-      result = res;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: Recip: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-
-uword64
-SquareRoot(op,fmt)
-     uword64 op;
-     FP_formats fmt; 
-{
-  uword64 result = 0;
-
-#ifdef DEBUG
-  printf("DBG: SquareRoot: %s: op = 0x%s\n",DOFMT(fmt),pr_addr(op));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt) {
-   case fmt_single:
-    {
-      sim_fpu wop;
-      sim_fpu ans;
-      unsigned32 res;
-      sim_fpu_32to (&wop, op);
-      sim_fpu_sqrt (&ans, &wop);
-      sim_fpu_to32 (&res, &ans);
-      result = res;
-      break;
-    }
-   case fmt_double:
-    {
-      sim_fpu wop;
-      sim_fpu ans;
-      unsigned64 res;
-      sim_fpu_64to (&wop, op);
-      sim_fpu_sqrt (&ans, &wop);
-      sim_fpu_to64 (&res, &ans);
-      result = res;
-      break;
-    }
-   default:
-    fprintf (stderr, "Bad switch\n");
-    abort ();
-  }
-
-#ifdef DEBUG
-  printf("DBG: SquareRoot: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-
-#if 0
-uword64
-Max (uword64 op1,
-     uword64 op2,
-     FP_formats fmt)
-{
-  int cmp;
-  unsigned64 result;
-
-#ifdef DEBUG
-  printf("DBG: Max: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt)
-    {
-    case fmt_single:
-      {
-	sim_fpu wop1;
-	sim_fpu wop2;
-	sim_fpu_32to (&wop1, op1);
-	sim_fpu_32to (&wop2, op2);
-	cmp = sim_fpu_cmp (&wop1, &wop2);
-	break;
-      }
-    case fmt_double:
-      {
-	sim_fpu wop1;
-	sim_fpu wop2;
-	sim_fpu_64to (&wop1, op1);
-	sim_fpu_64to (&wop2, op2);
-	cmp = sim_fpu_cmp (&wop1, &wop2);
-	break;
-      }
-    default:
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
-  
-  switch (cmp)
-    {
-    case SIM_FPU_IS_SNAN:
-    case SIM_FPU_IS_QNAN:
-      result = op1;
-    case SIM_FPU_IS_NINF:
-    case SIM_FPU_IS_NNUMBER:
-    case SIM_FPU_IS_NDENORM:
-    case SIM_FPU_IS_NZERO:
-      result = op2; /* op1 - op2 < 0 */
-    case SIM_FPU_IS_PINF:
-    case SIM_FPU_IS_PNUMBER:
-    case SIM_FPU_IS_PDENORM:
-    case SIM_FPU_IS_PZERO:
-      result = op1; /* op1 - op2 > 0 */
-    default:
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
-
-#ifdef DEBUG
-  printf("DBG: Max: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-#endif 
-
-#if 0
-uword64
-Min (uword64 op1,
-     uword64 op2,
-     FP_formats fmt)
-{
-  int cmp;
-  unsigned64 result;
-
-#ifdef DEBUG
-  printf("DBG: Min: %s: op1 = 0x%s : op2 = 0x%s\n",DOFMT(fmt),pr_addr(op1),pr_addr(op2));
-#endif /* DEBUG */
-
-  /* The registers must specify FPRs valid for operands of type
-     "fmt". If they are not valid, the result is undefined. */
-
-  /* The format type should already have been checked: */
-  switch (fmt)
-    {
-    case fmt_single:
-      {
-	sim_fpu wop1;
-	sim_fpu wop2;
-	sim_fpu_32to (&wop1, op1);
-	sim_fpu_32to (&wop2, op2);
-	cmp = sim_fpu_cmp (&wop1, &wop2);
-	break;
-      }
-    case fmt_double:
-      {
-	sim_fpu wop1;
-	sim_fpu wop2;
-	sim_fpu_64to (&wop1, op1);
-	sim_fpu_64to (&wop2, op2);
-	cmp = sim_fpu_cmp (&wop1, &wop2);
-	break;
-      }
-    default:
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
-  
-  switch (cmp)
-    {
-    case SIM_FPU_IS_SNAN:
-    case SIM_FPU_IS_QNAN:
-      result = op1;
-    case SIM_FPU_IS_NINF:
-    case SIM_FPU_IS_NNUMBER:
-    case SIM_FPU_IS_NDENORM:
-    case SIM_FPU_IS_NZERO:
-      result = op1; /* op1 - op2 < 0 */
-    case SIM_FPU_IS_PINF:
-    case SIM_FPU_IS_PNUMBER:
-    case SIM_FPU_IS_PDENORM:
-    case SIM_FPU_IS_PZERO:
-      result = op2; /* op1 - op2 > 0 */
-    default:
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
-
-#ifdef DEBUG
-  printf("DBG: Min: returning 0x%s (format = %s)\n",pr_addr(result),DOFMT(fmt));
-#endif /* DEBUG */
-
-  return(result);
-}
-#endif
-
-uword64
-convert (SIM_DESC sd,
-	 sim_cpu *cpu,
-	 address_word cia,
-	 int rm,
-	 uword64 op,
-	 FP_formats from,
-	 FP_formats to)
-{
-  sim_fpu wop;
-  sim_fpu_round round;
-  unsigned32 result32;
-  unsigned64 result64;
-
-#ifdef DEBUG
-#if 0 /* FIXME: doesn't compile */
-  printf("DBG: Convert: mode %s : op 0x%s : from %s : to %s : (PC = 0x%s)\n",RMMODE(rm),pr_addr(op),DOFMT(from),DOFMT(to),pr_addr(IPC));
-#endif
-#endif /* DEBUG */
-
-  switch (rm)
-    {
-    case FP_RM_NEAREST:
-      /* Round result to nearest representable value. When two
-	 representable values are equally near, round to the value
-	 that has a least significant bit of zero (i.e. is even). */
-      round = sim_fpu_round_near;
-      break;
-    case FP_RM_TOZERO:
-      /* Round result to the value closest to, and not greater in
-	 magnitude than, the result. */
-      round = sim_fpu_round_zero;
-      break;
-    case FP_RM_TOPINF:
-      /* Round result to the value closest to, and not less than,
-	 the result. */
-      round = sim_fpu_round_up;
-      break;
-      
-    case FP_RM_TOMINF:
-      /* Round result to the value closest to, and not greater than,
-	 the result. */
-      round = sim_fpu_round_down;
-      break;
-    default:
-      round = 0;
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
-  
-  /* Convert the input to sim_fpu internal format */
-  switch (from)
-    {
-    case fmt_double:
-      sim_fpu_64to (&wop, op);
-      break;
-    case fmt_single:
-      sim_fpu_32to (&wop, op);
-      break;
-    case fmt_word:
-      sim_fpu_i32to (&wop, op, round);
-      break;
-    case fmt_long:
-      sim_fpu_i64to (&wop, op, round);
-      break;
-    default:
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
-
-  /* Convert sim_fpu format into the output */
-  /* The value WOP is converted to the destination format, rounding
-     using mode RM. When the destination is a fixed-point format, then
-     a source value of Infinity, NaN or one which would round to an
-     integer outside the fixed point range then an IEEE Invalid
-     Operation condition is raised. */
-  switch (to)
-    {
-    case fmt_single:
-      sim_fpu_round_32 (&wop, round, 0);
-      sim_fpu_to32 (&result32, &wop);
-      result64 = result32;
-      break;
-    case fmt_double:
-      sim_fpu_round_64 (&wop, round, 0);
-      sim_fpu_to64 (&result64, &wop);
-      break;
-    case fmt_word:
-      sim_fpu_to32i (&result32, &wop, round);
-      result64 = result32;
-      break;
-    case fmt_long:
-      sim_fpu_to64i (&result64, &wop, round);
-      break;
-    default:
-      result64 = 0;
-      fprintf (stderr, "Bad switch\n");
-      abort ();
-    }
- 
-#ifdef DEBUG
-  printf("DBG: Convert: returning 0x%s (to format = %s)\n",pr_addr(result64),DOFMT(to));
-#endif /* DEBUG */
-
-  return(result64);
+  sim_io_eprintf(sd, "UNPREDICTABLE: PC = 0x%s\n", pr_addr (cia));
+  sim_engine_halt (SD, CPU, NULL, cia, sim_stopped, SIM_SIGABRT);
 }
 
 
diff --git a/sim/mips/mips.igen b/sim/mips/mips.igen
index b5930d5..cd96766 100644
--- a/sim/mips/mips.igen
+++ b/sim/mips/mips.igen
@@ -1,9 +1,5 @@
 // -*- C -*-
 //
-// In mips.igen, the semantics for many of the instructions were created
-// using code generated by gencode.  Those semantic segments could be
-// greatly simplified.
-//
 //    <insn> ::=
 //        <insn-word> { "+" <insn-word> }
 //        ":" <format-name>
@@ -48,6 +44,8 @@
 :model:::mipsIII:mips4000:
 :model:::mipsIV:mips8000:
 :model:::mipsV:mipsisaV:
+:model:::mips32:mipsisa32:
+:model:::mips64:mipsisa64:
 
 //  Vendor ISAs:
 //
@@ -109,8 +107,107 @@
   return CIA + 8;
 }
 
+
 // Helper:
-// 
+//
+// Calculate an effective address given a base and an offset.
+//
+
+:function:::address_word:loadstore_ea:address_word base, address_word offset
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mipsV:
+*mips32:
+*vr4100:
+*vr5000:
+*r3900:
+{
+  return base + offset;
+}
+
+:function:::address_word:loadstore_ea:address_word base, address_word offset
+*mips64:
+{
+#if 0 /* XXX FIXME: enable this only after some additional testing.  */
+  /* If in user mode and UX is not set, use 32-bit compatibility effective
+     address computations as defined in the MIPS64 Architecture for
+     Programmers Volume III, Revision 0.95, section 4.9.  */
+  if ((SR & (status_KSU_mask|status_EXL|status_ERL|status_UX))
+      == (ksu_user << status_KSU_shift))
+    return (address_word)((signed32)base + (signed32)offset);
+#endif
+  return base + offset;
+}
+
+
+// Helper:
+//
+// Check that a 32-bit register value is properly sign-extended.
+// (See NotWordValue in ISA spec.)
+//
+
+:function:::int:not_word_value:unsigned_word value
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mipsV:
+*vr4100:
+*vr5000:
+*r3900:
+{
+  /* For historical simulator compatibility (until documentation is
+     found that makes these operations unpredictable on some of these
+     architectures), this check never returns true.  */
+  return 0;
+}
+
+:function:::int:not_word_value:unsigned_word value
+*mips32:
+{
+  /* On MIPS32, since registers are 32-bits, there's no check to be done.  */
+  return 0;
+}
+
+:function:::int:not_word_value:unsigned_word value
+*mips64:
+{
+  return ((value >> 32) != (value & 0x80000000 ? 0xFFFFFFFF : 0));
+}
+
+
+// Helper:
+//
+// Handle UNPREDICTABLE operation behaviour.  The goal here is to prevent
+// theoretically portable code which invokes non-portable behaviour from
+// running with no indication of the portability issue.
+// (See definition of UNPREDICTABLE in ISA spec.)
+//
+
+:function:::void:unpredictable:
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mipsV:
+*vr4100:
+*vr5000:
+*r3900:
+{
+}
+
+:function:::void:unpredictable:
+*mips32:
+*mips64:
+{
+  unpredictable_action (CPU, CIA);
+}
+
+
+// Helper:
+//
 // Check that an access to a HI/LO register meets timing requirements
 //
 // The following requirements exist:
@@ -128,7 +225,7 @@
       sim_engine_abort (SD, CPU, CIA, "HILO: %s: %s at 0x%08lx too close to MF at 0x%08lx\n",
 			itable[MY_INDEX].name,
 			new, (long) CIA,
-			(long) history->mf.cia);      
+			(long) history->mf.cia);
       return 0;
     }
   return 1;
@@ -151,6 +248,8 @@
 }
 
 :function:::int:check_mt_hilo:hilo_history *history
+*mips32:
+*mips64:
 *r3900:
 {
   signed64 time = sim_events_time (SD);
@@ -166,6 +265,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -186,7 +287,7 @@
 			itable[MY_INDEX].name,
 			(long) CIA,
 			(long) history->op.cia,
-			(long) peer->mt.cia);      
+			(long) peer->mt.cia);
       ok = 0;
     }
   history->mf.timestamp = time;
@@ -218,6 +319,8 @@
 // The r3900 mult and multu insns _can_ be exectuted immediatly after
 // a mf{hi,lo}
 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
+*mips32:
+*mips64:
 *r3900:
 {
   /* FIXME: could record the fact that a stall occured if we want */
@@ -236,6 +339,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -252,9 +357,9 @@
 
 
 // Helper:
-// 
+//
 // Check that the 64-bit instruction can currently be used, and signal
-// an ReservedInstruction exception if not.
+// a ReservedInstruction exception if not.
 //
 
 :function:::void:check_u64:instruction_word insn
@@ -264,16 +369,24 @@
 *vr4100:
 *vr5000:
 {
-  // On mips64, if UserMode check SR:PX & SR:UX bits.
   // The check should be similar to mips64 for any with PX/UX bit equivalents.
 }
 
+:function:::void:check_u64:instruction_word insn
+*mips64:
+{
+#if 0 /* XXX FIXME: enable this only after some additional testing.  */
+  if (UserMode && (SR & (status_UX|status_PX)) == 0)
+    SignalException (ReservedInstruction, insn);
+#endif
+}
+
 
 
 //
 // MIPS Architecture:
 //
-//        CPU Instruction Set (mipsI - mipsV)
+//        CPU Instruction Set (mipsI - mipsV, mips32, mips64)
 //
 
 
@@ -285,10 +398,14 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
   {
     ALU32_BEGIN (GPR[RS]);
@@ -307,10 +424,14 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
+  if (NotWordValue (GPR[RS]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[RS], EXTEND16 (IMMEDIATE));
   {
     ALU32_BEGIN (GPR[RS]);
@@ -324,6 +445,8 @@
 
 :function:::void:do_addiu:int rs, int rt, unsigned16 immediate
 {
+  if (NotWordValue (GPR[rs]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
   GPR[rt] = EXTEND32 (GPR[rs] + EXTEND16 (immediate));
   TRACE_ALU_RESULT (GPR[rt]);
@@ -336,6 +459,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -347,6 +472,8 @@
 
 :function:::void:do_addu:int rs, int rt, int rd
 {
+  if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
   GPR[rd] = EXTEND32 (GPR[rs] + GPR[rt]);
   TRACE_ALU_RESULT (GPR[rd]);
@@ -359,6 +486,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -382,6 +511,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -392,12 +523,14 @@
 
 
 001100,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ANDI
-"and r<RT>, r<RS>, <IMMEDIATE>"
+"andi r<RT>, r<RS>, %#lx<IMMEDIATE>"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -416,6 +549,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -437,6 +572,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -461,6 +598,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -483,12 +622,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
   address_word offset = EXTEND16 (OFFSET) << 2;
   check_branch_bug ();
+  if (RS == 31)
+    Unpredictable ();
   RA = (CIA + 8);
   if ((signed_word) GPR[RS] >= 0)
     {
@@ -505,12 +648,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
   address_word offset = EXTEND16 (OFFSET) << 2;
   check_branch_bug ();
+  if (RS == 31)
+    Unpredictable ();
   RA = (CIA + 8);
   /* NOTE: The branch occurs AFTER the next instruction has been
      executed */
@@ -531,6 +678,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -555,6 +704,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -576,6 +727,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -602,6 +755,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -625,6 +780,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -649,6 +806,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -671,12 +830,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
   address_word offset = EXTEND16 (OFFSET) << 2;
   check_branch_bug ();
+  if (RS == 31)
+    Unpredictable ();
   RA = (CIA + 8);
   /* NOTE: The branch occurs AFTER the next instruction has been
      executed */
@@ -695,12 +858,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
   address_word offset = EXTEND16 (OFFSET) << 2;
   check_branch_bug ();
+  if (RS == 31)
+    Unpredictable ();
   RA = (CIA + 8);
   if ((signed_word) GPR[RS] < 0)
     {
@@ -719,6 +886,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -745,6 +914,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -766,6 +937,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -784,12 +957,14 @@
 
 
 000000,20.CODE,001101:SPECIAL:32::BREAK
-"break <CODE>"
+"break %#lx<CODE>"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -809,24 +984,73 @@
         PC = cia - 4; /* reference the branch instruction */
       else
         PC = cia;
-      SignalException(BreakPoint, instruction_0);
+      SignalException (BreakPoint, instruction_0);
     }
 
   else
     {
-      /* If we get this far, we're not an instruction reserved by the sim.  Raise 
+      /* If we get this far, we're not an instruction reserved by the sim.  Raise
 	 the exception. */
-      SignalException(BreakPoint, instruction_0);
+      SignalException (BreakPoint, instruction_0);
     }
 }
 
 
 
+011100,5.RS,5.RT,5.RD,00000,100001:SPECIAL2:32::CLO
+"clo r<RD>, r<RS>"
+*mips32:
+*mips64:
+{
+  unsigned32 temp = GPR[RS];
+  unsigned32 i, mask;
+  if (RT != RD)
+    Unpredictable ();
+  if (NotWordValue (GPR[RS]))
+    Unpredictable ();
+  TRACE_ALU_INPUT1 (GPR[RS]);
+  for (mask = ((unsigned32)1<<31), i = 0; i < 32; ++i)
+    {
+      if ((temp & mask) == 0)
+	break;
+      mask >>= 1;
+    }
+  GPR[RD] = EXTEND32 (i);
+  TRACE_ALU_RESULT (GPR[RD]);
+}
+
+
+
+011100,5.RS,5.RT,5.RD,00000,100000:SPECIAL2:32::CLZ
+"clz r<RD>, r<RS>"
+*mips32:
+*mips64:
+{
+  unsigned32 temp = GPR[RS];
+  unsigned32 i, mask;
+  if (RT != RD)
+    Unpredictable ();
+  if (NotWordValue (GPR[RS]))
+    Unpredictable ();
+  TRACE_ALU_INPUT1 (GPR[RS]);
+  for (mask = ((unsigned32)1<<31), i = 0; i < 32; ++i)
+    {
+      if ((temp & mask) != 0)
+	break;
+      mask >>= 1;
+    }
+  GPR[RD] = EXTEND32 (i);
+  TRACE_ALU_RESULT (GPR[RD]);
+}
+
+
+
 000000,5.RS,5.RT,5.RD,00000,101100:SPECIAL:64::DADD
 "dadd r<RD>, r<RS>, r<RT>"
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -847,6 +1071,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -874,6 +1099,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -895,6 +1121,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -904,6 +1131,52 @@
 
 
 
+011100,5.RS,5.RT,5.RD,00000,100101:SPECIAL2:64::DCLO
+"dclo r<RD>, r<RS>"
+*mips64:
+{
+  unsigned64 temp = GPR[RS];
+  unsigned32 i;
+  unsigned64 mask;
+  check_u64 (SD_, instruction_0);
+  if (RT != RD)
+    Unpredictable ();
+  TRACE_ALU_INPUT1 (GPR[RS]);
+  for (mask = ((unsigned64)1<<63), i = 0; i < 64; ++i)
+    {
+      if ((temp & mask) == 0)
+	break;
+      mask >>= 1;
+    }
+  GPR[RD] = EXTEND32 (i);
+  TRACE_ALU_RESULT (GPR[RD]);
+}
+
+
+
+011100,5.RS,5.RT,5.RD,00000,100100:SPECIAL2:64::DCLZ
+"dclz r<RD>, r<RS>"
+*mips64:
+{
+  unsigned64 temp = GPR[RS];
+  unsigned32 i;
+  unsigned64 mask;
+  check_u64 (SD_, instruction_0);
+  if (RT != RD)
+    Unpredictable ();
+  TRACE_ALU_INPUT1 (GPR[RS]);
+  for (mask = ((unsigned64)1<<63), i = 0; i < 64; ++i)
+    {
+      if ((temp & mask) != 0)
+	break;
+      mask >>= 1;
+    }
+  GPR[RD] = EXTEND32 (i);
+  TRACE_ALU_RESULT (GPR[RD]);
+}
+
+
+
 :function:::void:do_ddiv:int rs, int rt
 {
   check_div_hilo (SD_, HIHISTORY, LOHISTORY);
@@ -939,6 +1212,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -978,6 +1252,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1020,6 +1295,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1057,6 +1334,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1080,7 +1359,7 @@
   unsigned64 op2 = GPR[rt];
   check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
   TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
-  /* make signed multiply unsigned */ 
+  /* make signed multiply unsigned */
   sign = 0;
   if (signed_p)
     {
@@ -1136,6 +1415,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 {
   check_u64 (SD_, instruction_0);
@@ -1163,6 +1443,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 {
   check_u64 (SD_, instruction_0);
@@ -1190,6 +1471,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1203,6 +1485,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1226,6 +1509,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1246,6 +1530,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1259,6 +1544,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1283,6 +1569,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1303,6 +1590,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1316,6 +1604,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1342,6 +1631,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1355,6 +1645,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1381,6 +1672,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1396,6 +1688,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1414,6 +1708,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1433,6 +1729,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1450,6 +1748,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1469,7 +1769,7 @@
   unsigned64 memval;
   address_word vaddr;
 
-  vaddr = base + offset;
+  vaddr = loadstore_ea (SD_, base, offset);
   if ((vaddr & access) != 0)
     {
       SIM_CORE_SIGNAL (SD, STATE_CPU (SD, 0), cia, read_map, access+1, vaddr, read_transfer, sim_core_unaligned_signal);
@@ -1497,7 +1797,7 @@
   unsigned_word lhs_mask;
   unsigned_word temp;
 
-  vaddr = base + offset;
+  vaddr = loadstore_ea (SD_, base, offset);
   AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
   paddr = (paddr ^ (reverseendian & mask));
   if (BigEndianMem == 0)
@@ -1548,7 +1848,7 @@
   unsigned64 memval;
   address_word vaddr;
 
-  vaddr = base + offset;
+  vaddr = loadstore_ea (SD_, base, offset);
   AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
   /* NOTE: SPEC is wrong, has `BigEndianMem == 0' not `BigEndianMem != 0' */
   paddr = (paddr ^ (reverseendian & mask));
@@ -1575,6 +1875,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1590,6 +1892,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1603,6 +1907,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1617,6 +1922,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1632,6 +1939,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1645,6 +1953,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1660,6 +1969,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1675,6 +1986,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1689,15 +2002,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
-  int destreg = ((instruction >> 16) & 0x0000001F);
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
   {
-    address_word vaddr = ((unsigned64)op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     if ((vaddr & 3) != 0)
@@ -1718,7 +2031,7 @@
 	    paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
 	    LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
 	    byte = ((vaddr & mask) ^ (bigend << shift));
-	    GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
+	    GPR[RT] = EXTEND32 (memval >> (8 * byte));
 	    LLBIT = 1;
 	  }
       }
@@ -1731,16 +2044,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
-  int destreg = ((instruction >> 16) & 0x0000001F);
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
   check_u64 (SD_, instruction_0);
   {
-    address_word vaddr = ((unsigned64)op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     if ((vaddr & 7) != 0)
@@ -1754,7 +2066,7 @@
 	    unsigned64 memval = 0;
 	    unsigned64 memval1 = 0;
 	    LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
-	    GPR[destreg] = memval;
+	    GPR[RT] = memval;
 	    LLBIT = 1;
 	  }
       }
@@ -1763,12 +2075,14 @@
 
 
 001111,00000,5.RT,16.IMMEDIATE:NORMAL:32::LUI
-"lui r<RT>, <IMMEDIATE>"
+"lui r<RT>, %#lx<IMMEDIATE>"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1786,6 +2100,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1801,6 +2117,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1816,6 +2134,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1831,6 +2151,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1844,6 +2166,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -1852,6 +2175,44 @@
 }
 
 
+
+011100,5.RS,5.RT,00000,00000,000000:SPECIAL2:32::MADD
+"madd r<RS>, r<RT>"
+*mips32:
+*mips64:
+{
+  signed64 temp;
+  check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
+  TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
+  temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
+          + ((signed64) EXTEND32 (GPR[RT]) * (signed64) EXTEND32 (GPR[RS])));
+  LO = EXTEND32 (temp);
+  HI = EXTEND32 (VH4_8 (temp));
+  TRACE_ALU_RESULT2 (HI, LO);
+}
+
+
+
+011100,5.RS,5.RT,00000,00000,000001:SPECIAL2:32::MADDU
+"maddu r<RS>, r<RT>"
+*mips32:
+*mips64:
+{
+  unsigned64 temp;
+  check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
+  TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
+  temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
+          + ((unsigned64) VL4_8 (GPR[RS]) * (unsigned64) VL4_8 (GPR[RT])));
+  LO = EXTEND32 (temp);
+  HI = EXTEND32 (VH4_8 (temp));
+  TRACE_ALU_RESULT2 (HI, LO);
+}
+
+
 :function:::void:do_mfhi:int rd
 {
   check_mf_hilo (SD_, HIHISTORY, LOHISTORY);
@@ -1867,6 +2228,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1891,6 +2254,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1904,6 +2269,8 @@
 "movn r<RD>, r<RS>, r<RT>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
   if (GPR[RT] != 0)
@@ -1916,6 +2283,8 @@
 "movz r<RD>, r<RS>, r<RT>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
   if (GPR[RT] == 0)
@@ -1924,6 +2293,44 @@
 
 
 
+011100,5.RS,5.RT,00000,00000,000100:SPECIAL2:32::MSUB
+"msub r<RS>, r<RT>"
+*mips32:
+*mips64:
+{
+  signed64 temp;
+  check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
+  TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
+  temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
+          - ((signed64) EXTEND32 (GPR[RT]) * (signed64) EXTEND32 (GPR[RS])));
+  LO = EXTEND32 (temp);
+  HI = EXTEND32 (VH4_8 (temp));
+  TRACE_ALU_RESULT2 (HI, LO);
+}
+
+
+
+011100,5.RS,5.RT,00000,00000,000101:SPECIAL2:32::MSUBU
+"msubu r<RS>, r<RT>"
+*mips32:
+*mips64:
+{
+  unsigned64 temp;
+  check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
+  TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
+  temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
+          - ((unsigned64) VL4_8 (GPR[RS]) * (unsigned64) VL4_8 (GPR[RT])));
+  LO = EXTEND32 (temp);
+  HI = EXTEND32 (VH4_8 (temp));
+  TRACE_ALU_RESULT2 (HI, LO);
+}
+
+
+
 000000,5.RS,000000000000000,010001:SPECIAL:32::MTHI
 "mthi r<RS>"
 *mipsI:
@@ -1931,6 +2338,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1948,6 +2357,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -1958,10 +2369,29 @@
 
 
 
+011100,5.RS,5.RT,5.RD,00000,000010:SPECIAL2:32::MUL
+"mul r<RD>, r<RS>, r<RT>"
+*mips32:
+*mips64:
+{
+  signed64 prod;
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
+  TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
+  prod = (((signed64)(signed32) GPR[RS])
+          * ((signed64)(signed32) GPR[RT]));
+  GPR[RD] = EXTEND32 (VL4_8 (prod));
+  TRACE_ALU_RESULT (GPR[RD]);
+}
+
+
+
 :function:::void:do_mult:int rs, int rt, int rd
 {
   signed64 prod;
   check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
+  if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
   prod = (((signed64)(signed32) GPR[rs])
 	  * ((signed64)(signed32) GPR[rt]));
@@ -1979,6 +2409,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 {
   do_mult (SD_, RS, RT, 0);
@@ -1999,6 +2431,8 @@
 {
   unsigned64 prod;
   check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
+  if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
   prod = (((unsigned64)(unsigned32) GPR[rs])
 	  * ((unsigned64)(unsigned32) GPR[rt]));
@@ -2016,6 +2450,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 {
   do_multu (SD_, RS, RT, 0);
@@ -2045,6 +2481,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2067,6 +2505,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2084,12 +2524,14 @@
 }
 
 001101,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ORI
-"ori r<RT>, r<RS>, <IMMEDIATE>"
+"ori r<RT>, r<RS>, %#lx<IMMEDIATE>"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2102,19 +2544,19 @@
 "pref <HINT>, <OFFSET>(r<BASE>)"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
-  int hint = ((instruction >> 16) & 0x0000001F);
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
   {
-    address_word vaddr = ((unsigned64)op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     {
       if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
-	Prefetch(uncached,paddr,vaddr,isDATA,hint);
+	Prefetch(uncached,paddr,vaddr,isDATA,HINT);
     }
   }
 }
@@ -2131,7 +2573,7 @@
   unsigned64 memval;
   address_word vaddr;
 
-  vaddr = base + offset;
+  vaddr = loadstore_ea (SD_, base, offset);
   if ((vaddr & access) != 0)
     {
       SIM_CORE_SIGNAL (SD, STATE_CPU(SD, 0), cia, read_map, access+1, vaddr, write_transfer, sim_core_unaligned_signal);
@@ -2157,7 +2599,7 @@
   int nr_lhs_bits;
   int nr_rhs_bits;
 
-  vaddr = base + offset;
+  vaddr = loadstore_ea (SD_, base, offset);
   AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
   paddr = (paddr ^ (reverseendian & mask));
   if (BigEndianMem == 0)
@@ -2199,7 +2641,7 @@
   unsigned64 memval;
   address_word vaddr;
 
-  vaddr = base + offset;
+  vaddr = loadstore_ea (SD_, base, offset);
   AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
   paddr = (paddr ^ (reverseendian & mask));
   if (BigEndianMem != 0)
@@ -2217,6 +2659,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2231,15 +2675,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   unsigned32 instruction = instruction_0;
-  signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
-  signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
   {
-    address_word vaddr = ((unsigned64)op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     if ((vaddr & 3) != 0)
@@ -2256,12 +2701,12 @@
 	    unsigned int byte;
 	    paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
 	    byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
-	    memval = ((unsigned64) op2 << (8 * byte));
+	    memval = ((unsigned64) GPR[RT] << (8 * byte));
 	    if (LLBIT)
 	      {
 		StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
 	      }
-	    GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
+	    GPR[RT] = LLBIT;
 	  }
       }
   }
@@ -2273,16 +2718,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
-  signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
   check_u64 (SD_, instruction_0);
   {
-    address_word vaddr = ((unsigned64)op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     if ((vaddr & 7) != 0)
@@ -2295,12 +2739,12 @@
 	  {
 	    unsigned64 memval = 0;
 	    unsigned64 memval1 = 0;
-	    memval = op2;
+	    memval = GPR[RT];
 	    if (LLBIT)
 	      {
 		StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
 	      }
-	    GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
+	    GPR[RT] = LLBIT;
 	  }
       }
   }
@@ -2312,6 +2756,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -2326,6 +2771,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -2338,6 +2785,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -2351,6 +2799,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -2366,6 +2815,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2382,7 +2833,7 @@
   TRACE_ALU_RESULT (GPR[rd]);
 }
 
-000000,00000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLL
+000000,00000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLLa
 "nop":RD == 0 && RT == 0 && SHIFT == 0
 "sll r<RD>, r<RT>, <SHIFT>"
 *mipsI:
@@ -2400,6 +2851,19 @@
     do_sll (SD_, RT, RD, SHIFT);
 }
 
+000000,00000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLLb
+"nop":RD == 0 && RT == 0 && SHIFT == 0
+"ssnop":RD == 0 && RT == 0 && SHIFT == 1
+"sll r<RD>, r<RT>, <SHIFT>"
+*mips32:
+*mips64:
+{
+  /* Skip shift for NOP and SSNOP, so that there won't be lots of
+     extraneous trace output.  */
+  if (RD != 0 || RT != 0 || (SHIFT != 0 && SHIFT != 1))
+    do_sll (SD_, RT, RD, SHIFT);
+}
+
 
 :function:::void:do_sllv:int rs, int rt, int rd
 {
@@ -2417,6 +2881,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2439,6 +2905,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2461,6 +2929,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2483,6 +2953,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2506,6 +2978,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2517,6 +2991,8 @@
 :function:::void:do_sra:int rt, int rd, int shift
 {
   signed32 temp = (signed32) GPR[rt] >> shift;
+  if (NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rt], shift);
   GPR[rd] = EXTEND32 (temp);
   TRACE_ALU_RESULT (GPR[rd]);
@@ -2529,6 +3005,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2542,6 +3020,8 @@
 {
   int s = MASKED (GPR[rs], 4, 0);
   signed32 temp = (signed32) GPR[rt] >> s;
+  if (NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rt], s);
   GPR[rd] = EXTEND32 (temp);
   TRACE_ALU_RESULT (GPR[rd]);
@@ -2554,6 +3034,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2566,6 +3048,8 @@
 :function:::void:do_srl:int rt, int rd, int shift
 {
   unsigned32 temp = (unsigned32) GPR[rt] >> shift;
+  if (NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rt], shift);
   GPR[rd] = EXTEND32 (temp);
   TRACE_ALU_RESULT (GPR[rd]);
@@ -2578,6 +3062,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2590,6 +3076,8 @@
 {
   int s = MASKED (GPR[rs], 4, 0);
   unsigned32 temp = (unsigned32) GPR[rt] >> s;
+  if (NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rt], s);
   GPR[rd] = EXTEND32 (temp);
   TRACE_ALU_RESULT (GPR[rd]);
@@ -2602,6 +3090,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2617,10 +3107,14 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
+  if (NotWordValue (GPR[RS]) || NotWordValue (GPR[RT]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
   {
     ALU32_BEGIN (GPR[RS]);
@@ -2633,6 +3127,8 @@
 
 :function:::void:do_subu:int rs, int rt, int rd
 {
+  if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
+    Unpredictable ();
   TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
   GPR[rd] = EXTEND32 (GPR[rs] - GPR[rt]);
   TRACE_ALU_RESULT (GPR[rd]);
@@ -2645,6 +3141,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2660,6 +3158,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *r3900:
 *vr5000:
@@ -2675,6 +3175,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2690,6 +3192,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2705,6 +3209,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2720,6 +3226,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2729,17 +3237,19 @@
 
 
 000000,20.CODE,001100:SPECIAL:32::SYSCALL
-"syscall <CODE>"
+"syscall %#lx<CODE>"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  SignalException(SystemCall, instruction_0);
+  SignalException (SystemCall, instruction_0);
 }
 
 
@@ -2749,11 +3259,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2763,11 +3275,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] == (signed_word) EXTEND16 (IMMEDIATE))
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2777,11 +3291,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] >= (signed_word) GPR[RT])
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2791,11 +3307,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] >= (signed_word) EXTEND16 (IMMEDIATE))
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2805,11 +3323,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((unsigned_word) GPR[RS] >= (unsigned_word) EXTEND16 (IMMEDIATE))
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2819,11 +3339,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((unsigned_word) GPR[RS] >= (unsigned_word) GPR[RT])
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2833,11 +3355,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] < (signed_word) GPR[RT])
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2847,11 +3371,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] < (signed_word) EXTEND16 (IMMEDIATE))
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2861,11 +3387,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE))
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2875,11 +3403,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT])
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2889,11 +3419,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2903,11 +3435,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
   if ((signed_word) GPR[RS] != (signed_word) EXTEND16 (IMMEDIATE))
-    SignalException(Trap, instruction_0);
+    SignalException (Trap, instruction_0);
 }
 
 
@@ -2925,6 +3459,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -2941,12 +3477,14 @@
 }
 
 001110,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::XORI
-"xori r<RT>, r<RS>, <IMMEDIATE>"
+"xori r<RT>, r<RS>, %#lx<IMMEDIATE>"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -3024,26 +3562,80 @@
     }
 }
 
+
+// Helpers:
+//
+// Check that the given FPU format is usable, and signal a
+// ReservedInstruction exception if not.
+//
+
+// check_fmt checks that the format is single or double.
+:function:::void:check_fmt:int fmt, instruction_word insn
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mipsV:
+*mips32:
+*mips64:
+*vr4100:
+*vr5000:
+*r3900:
+{
+  if ((fmt != fmt_single) && (fmt != fmt_double))
+    SignalException (ReservedInstruction, insn);
+}
+
+// check_fmt_p checks that the format is single, double, or paired single.
+:function:::void:check_fmt_p:int fmt, instruction_word insn
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mips32:
+*vr4100:
+*vr5000:
+*r3900:
+{
+  /* None of these ISAs support Paired Single, so just fall back to
+     the single/double check.  */
+  check_fmt (SD_, fmt, insn);
+}
+
+:function:::void:check_fmt_p:int fmt, instruction_word insn
+*mipsV:
+*mips64:
+{
+#if 0 /* XXX FIXME: FP code doesn't yet support paired single ops.  */
+  if ((fmt != fmt_single) && (fmt != fmt_double)
+      && (fmt != fmt_ps || (UserMode && (SR & (status_UX|status_PX)) == 0)))
+    SignalException (ReservedInstruction, insn);
+#else
+  check_fmt (SD_, fmt, insn);
+#endif
+}
+
+
 // Helper:
-// 
+//
 // Check that the FPU is currently usable, and signal a CoProcessorUnusable
 // exception if not.
 //
 
 :function:::void:check_fpu:
-*mipsI: 
+*mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-#if 0	/* XXX FIXME: For now, never treat the FPU as disabled.  */
   if (! COP_Usable (1))
     SignalExceptionCoProcessorUnusable (1);
-#endif
 }
 
 
@@ -3054,21 +3646,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,format,AbsoluteValue(ValueFPR(fs,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,AbsoluteValue(ValueFPR(FS,fmt),fmt));
 }
 
 
@@ -3080,22 +3667,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction, instruction);
-    else
-      StoreFPR(destreg,format,Add(ValueFPR(fs,format),ValueFPR(ft,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Add(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
 }
 
 
@@ -3111,7 +3692,7 @@
 *mipsII:
 *mipsIII:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_branch_bug ();
   TRACE_BRANCH_INPUT (PREVCOC1());
   if (PREVCOC1() == TF)
@@ -3137,11 +3718,13 @@
 "bc1%s<TF>%s<ND> <CC>, <OFFSET>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 #*vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_branch_bug ();
   if (GETFCC(CC) == TF)
     {
@@ -3166,38 +3749,33 @@
 
 :function:::void:do_c_cond_fmt:int fmt, int ft, int fs, int cc, int cond, instruction_word insn
 {
-  if ((fmt != fmt_single) && (fmt != fmt_double))
-    SignalException (ReservedInstruction, insn);
+  int less;
+  int equal;
+  int unordered;
+  int condition;
+  unsigned64 ofs = ValueFPR (fs, fmt);
+  unsigned64 oft = ValueFPR (ft, fmt);
+  if (NaN (ofs, fmt) || NaN (oft, fmt))
+    {
+      if (FCSR & FP_ENABLE (IO))
+	{
+	  FCSR |= FP_CAUSE (IO);
+	  SignalExceptionFPE ();
+	}
+      less = 0;
+      equal = 0;
+      unordered = 1;
+    }
   else
     {
-      int less;
-      int equal;
-      int unordered;
-      int condition;
-      unsigned64 ofs = ValueFPR (fs, fmt);
-      unsigned64 oft = ValueFPR (ft, fmt);
-      if (NaN (ofs, fmt) || NaN (oft, fmt))
-	{
-	  if (FCSR & FP_ENABLE (IO))
-	    {
-	      FCSR |= FP_CAUSE (IO);
-	      SignalExceptionFPE ();
-	    }
-	  less = 0;
-	  equal = 0;
-	  unordered = 1;
-	}
-      else
-	{
-	  less = Less (ofs, oft, fmt);
-	  equal = Equal (ofs, oft, fmt);
-	  unordered = 0;
-	}
-      condition = (((cond & (1 << 2)) && less)
-		   || ((cond & (1 << 1)) && equal)
-		   || ((cond & (1 << 0)) && unordered));
-      SETFCC (cc, condition);
+      less = Less (ofs, oft, fmt);
+      equal = Equal (ofs, oft, fmt);
+      unordered = 0;
     }
+  condition = (((cond & (1 << 2)) && less)
+	       || ((cond & (1 << 1)) && equal)
+	       || ((cond & (1 << 0)) && unordered));
+  SETFCC (cc, condition);
 }
 
 010001,10,3.FMT,5.FT,5.FS,3.0,00,11,4.COND:COP1:32,f::C.cond.fmta
@@ -3206,8 +3784,10 @@
 *mipsII:
 *mipsIII:
 {
-  check_fpu(SD_);
-  do_c_cond_fmt (SD_, FMT, FT, FS, 0, COND, instruction_0);
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  do_c_cond_fmt (SD_, fmt, FT, FS, 0, COND, instruction_0);
 }
 
 010001,10,3.FMT,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32,f::C.cond.fmtb
@@ -3215,12 +3795,16 @@
 "c.%s<COND>.%s<FMT> <CC>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
-  do_c_cond_fmt (SD_, FMT, FT, FS, CC, COND, instruction_0);
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  do_c_cond_fmt (SD_, fmt, FT, FS, CC, COND, instruction_0);
 }
 
 
@@ -3229,21 +3813,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_long));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(FS,fmt),fmt,fmt_long));
 }
 
 
@@ -3252,21 +3830,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-  if ((format != fmt_single) && (format != fmt_double))
-   SignalException(ReservedInstruction,instruction);
-  else
-   StoreFPR(destreg,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_word));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(FS,fmt),fmt,fmt_word));
 }
 
 
@@ -3278,7 +3851,7 @@
 *mipsII:
 *mipsIII:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (X)
     {
       if (FS == 0)
@@ -3291,9 +3864,9 @@
   else
     { /* control from */
       if (FS == 0)
- 	PENDING_FILL(RT,SIGNEXTEND(FCR0,32));
+ 	PENDING_FILL(RT, EXTEND32 (FCR0));
       else if (FS == 31)
- 	PENDING_FILL(RT,SIGNEXTEND(FCR31,32));
+ 	PENDING_FILL(RT, EXTEND32 (FCR31));
       /* else NOP */
     }
 }
@@ -3301,11 +3874,13 @@
 "c%s<X>c1 r<RT>, f<FS>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (X)
     {
       /* control to */
@@ -3332,12 +3907,12 @@
       if (FS == 0)
 	{
 	  TRACE_ALU_INPUT1 (FCR0);
-	  GPR[RT] = SIGNEXTEND (FCR0, 32);
+	  GPR[RT] = EXTEND32 (FCR0);
 	}
       else if (FS == 31)
 	{
 	  TRACE_ALU_INPUT1 (FCR31);
-	  GPR[RT] = SIGNEXTEND (FCR31, 32);
+	  GPR[RT] = EXTEND32 (FCR31);
 	}
       TRACE_ALU_RESULT (GPR[RT]);
       /* else NOP */
@@ -3355,20 +3930,19 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
+  int fmt = FMT;
+  check_fpu (SD_);
   {
-    if ((format == fmt_double) | 0)
-      SignalException(ReservedInstruction,instruction);
+    if ((fmt == fmt_double) | 0)
+      SignalException (ReservedInstruction, instruction_0);
     else
-      StoreFPR(destreg,fmt_double,Convert(GETRM(),ValueFPR(fs,format),format,fmt_double));
+      StoreFPR(FD,fmt_double,Convert(GETRM(),ValueFPR(FS,fmt),fmt,fmt_double));
   }
 }
 
@@ -3378,20 +3952,18 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
+  int fmt = FMT;
+  check_fpu (SD_);
   {
-    if ((format == fmt_long) | ((format == fmt_long) || (format == fmt_word)))
-      SignalException(ReservedInstruction,instruction);
+    if ((fmt == fmt_long) | ((fmt == fmt_long) || (fmt == fmt_word)))
+      SignalException (ReservedInstruction, instruction_0);
     else
-      StoreFPR(destreg,fmt_long,Convert(GETRM(),ValueFPR(fs,format),format,fmt_long));
+      StoreFPR(FD,fmt_long,Convert(GETRM(),ValueFPR(FS,fmt),fmt,fmt_long));
   }
 }
 
@@ -3406,20 +3978,19 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
+  int fmt = FMT;
+  check_fpu (SD_);
   {
-    if ((format == fmt_single) | 0)
-      SignalException(ReservedInstruction,instruction);
+    if ((fmt == fmt_single) | 0)
+      SignalException (ReservedInstruction, instruction_0);
     else
-      StoreFPR(destreg,fmt_single,Convert(GETRM(),ValueFPR(fs,format),format,fmt_single));
+      StoreFPR(FD,fmt_single,Convert(GETRM(),ValueFPR(FS,fmt),fmt,fmt_single));
   }
 }
 
@@ -3431,20 +4002,19 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
+  int fmt = FMT;
+  check_fpu (SD_);
   {
-    if ((format == fmt_word) | ((format == fmt_long) || (format == fmt_word)))
-      SignalException(ReservedInstruction,instruction);
+    if ((fmt == fmt_word) | ((fmt == fmt_long) || (fmt == fmt_word)))
+      SignalException (ReservedInstruction, instruction_0);
     else
-      StoreFPR(destreg,fmt_word,Convert(GETRM(),ValueFPR(fs,format),format,fmt_word));
+      StoreFPR(FD,fmt_word,Convert(GETRM(),ValueFPR(FS,fmt),fmt,fmt_word));
   }
 }
 
@@ -3456,22 +4026,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,format,Divide(ValueFPR(fs,format),ValueFPR(ft,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Divide(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
 }
 
 
@@ -3481,7 +4045,7 @@
 "dm%s<X>c1 r<RT>, f<FS>"
 *mipsIII:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_u64 (SD_, instruction_0);
   if (X)
     {
@@ -3502,7 +4066,7 @@
       else
 	{
 	  if (STATE_VERBOSE_P(SD))
-	    sim_io_eprintf (SD, 
+	    sim_io_eprintf (SD,
 	      "Warning: PC 0x%lx: semantic_DMxC1_COP1Sa 32-bit use of odd FPR number\n",
 	      (long) CIA);
 	  PENDING_FILL(RT,SET64HI(0xDEADC0DE) | 0xBAD0BAD0);
@@ -3513,11 +4077,12 @@
 "dm%s<X>c1 r<RT>, f<FS>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_u64 (SD_, instruction_0);
   if (X)
     {
@@ -3535,7 +4100,7 @@
       else
 	{
 	  if (STATE_VERBOSE_P(SD))
-	    sim_io_eprintf (SD, 
+	    sim_io_eprintf (SD,
 	      "Warning: PC 0x%lx: DMxC1 32-bit use of odd FPR number\n",
 			    (long) CIA);
 	  GPR[RT] = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
@@ -3549,21 +4114,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_long));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(FS,fmt),fmt,fmt_long));
 }
 
 
@@ -3573,21 +4132,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_word));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(FS,fmt),fmt,fmt_word));
 }
 
 
@@ -3597,11 +4151,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   COP_LD (1, FT, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
 }
 
@@ -3610,27 +4166,30 @@
 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_u64 (SD_, instruction_0);
   COP_LD (1, FD, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX]));
 }
 
 
 
-110001,5.BASE,5.FT,16.OFFSET:COP1:32,f::LWC1 
+110001,5.BASE,5.FT,16.OFFSET:COP1:32,f::LWC1
 "lwc1 f<FT>, <OFFSET>(r<BASE>)"
 *mipsI:
 *mipsII:
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   COP_LW (1, FT, do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
 }
 
@@ -3639,9 +4198,10 @@
 "lwxc1 f<FD>, r<INDEX>(r<BASE>)"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_u64 (SD_, instruction_0);
   COP_LW (1, FD, do_load (SD_, AccessLength_WORD, GPR[BASE], GPR[INDEX]));
 }
@@ -3655,16 +4215,12 @@
 "madd.d f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
+  check_fpu (SD_);
   {
-    StoreFPR(destreg,fmt_double,Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
+    StoreFPR(FD,fmt_double,Add(Multiply(ValueFPR(FS,fmt_double),ValueFPR(FT,fmt_double),fmt_double),ValueFPR(FR,fmt_double),fmt_double));
   }
 }
 
@@ -3673,16 +4229,12 @@
 "madd.s f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
+  check_fpu (SD_);
   {
-    StoreFPR(destreg,fmt_single,Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
+    StoreFPR(FD,fmt_single,Add(Multiply(ValueFPR(FS,fmt_single),ValueFPR(FT,fmt_single),fmt_single),ValueFPR(FR,fmt_single),fmt_single));
   }
 }
 
@@ -3695,13 +4247,13 @@
 *mipsII:
 *mipsIII:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (X)
     { /*MTC1*/
       if (SizeFGR() == 64)
 	{
 	  if (STATE_VERBOSE_P(SD))
-	    sim_io_eprintf (SD, 
+	    sim_io_eprintf (SD,
 			    "Warning:  PC 0x%lx: MTC1 not DMTC1 with 64 bit regs\n",
 			    (long) CIA);
 	  PENDING_FILL ((FS + FGRIDX), (SET64HI(0xDEADC0DE) | VL4_8(GPR[RT])));
@@ -3710,23 +4262,25 @@
 	PENDING_FILL ((FS + FGRIDX), VL4_8(GPR[RT]));
     }
   else /*MFC1*/
-    PENDING_FILL (RT, SIGNEXTEND(FGR[FS],32));
+    PENDING_FILL (RT, EXTEND32 (FGR[FS]));
 }
 010001,00,X,00,5.RT,5.FS,00000000000:COP1Sb:32,f::MxC1
 "m%s<X>c1 r<RT>, f<FS>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
   int fs = FS;
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (X)
     /*MTC1*/
     StoreFPR (FS, fmt_uninterpreted_32, VL4_8 (GPR[RT]));
   else /*MFC1*/
-    GPR[RT] = SIGNEXTEND(FGR[FS],32);
+    GPR[RT] = EXTEND32 (FGR[FS]);
 }
 
 
@@ -3737,18 +4291,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    StoreFPR(destreg,format,ValueFPR(fs,format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,ValueFPR(FS,fmt));
 }
 
 
@@ -3758,9 +4310,11 @@
 "mov%s<TF> r<RD>, r<RS>, <CC>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (GETFCC(CC) == TF)
     GPR[RD] = GPR[RS];
 }
@@ -3772,16 +4326,17 @@
 "mov%s<TF>.%s<FMT> f<FD>, f<FS>, <CC>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
+  int fmt = FMT;
+  check_fpu (SD_);
   {
    if (GETFCC(CC) == TF)
-     StoreFPR (FD, format, ValueFPR (FS, format));
+     StoreFPR (FD, fmt, ValueFPR (FS, fmt));
    else
-     StoreFPR (FD, format, ValueFPR (FD, format));
+     StoreFPR (FD, fmt, ValueFPR (FD, fmt));
   }
 }
 
@@ -3790,9 +4345,11 @@
 "movn.%s<FMT> f<FD>, f<FS>, r<RT>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (GPR[RT] != 0)
     StoreFPR (FD, FMT, ValueFPR (FS, FMT));
   else
@@ -3811,9 +4368,11 @@
 "movz.%s<FMT> f<FD>, f<FS>, r<RT>"
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr5000:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   if (GPR[RT] == 0)
     StoreFPR (FD, FMT, ValueFPR (FS, FMT));
   else
@@ -3826,17 +4385,11 @@
 "msub.d f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
-  {
-    StoreFPR(destreg,fmt_double,Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
-  }
+  check_fpu (SD_);
+  StoreFPR(FD,fmt_double,Sub(Multiply(ValueFPR(FS,fmt_double),ValueFPR(FT,fmt_double),fmt_double),ValueFPR(FR,fmt_double),fmt_double));
 }
 
 
@@ -3845,17 +4398,11 @@
 "msub.s f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
-  {
-   StoreFPR(destreg,fmt_single,Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
-  }
+  check_fpu (SD_);
+  StoreFPR(FD,fmt_single,Sub(Multiply(ValueFPR(FS,fmt_single),ValueFPR(FT,fmt_single),fmt_single),ValueFPR(FR,fmt_single),fmt_single));
 }
 
 
@@ -3869,22 +4416,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,format,Multiply(ValueFPR(fs,format),ValueFPR(ft,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Multiply(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
 }
 
 
@@ -3895,21 +4436,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,format,Negate(ValueFPR(fs,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Negate(ValueFPR(FS,fmt),fmt));
 }
 
 
@@ -3918,17 +4454,11 @@
 "nmadd.d f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
-  {
-   StoreFPR(destreg,fmt_double,Negate(Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double),fmt_double));
-  }
+  check_fpu (SD_);
+  StoreFPR(FD,fmt_double,Negate(Add(Multiply(ValueFPR(FS,fmt_double),ValueFPR(FT,fmt_double),fmt_double),ValueFPR(FR,fmt_double),fmt_double),fmt_double));
 }
 
 
@@ -3937,17 +4467,11 @@
 "nmadd.s f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
-  {
-   StoreFPR(destreg,fmt_single,Negate(Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single),fmt_single));
-  }
+  check_fpu (SD_);
+  StoreFPR(FD,fmt_single,Negate(Add(Multiply(ValueFPR(FS,fmt_single),ValueFPR(FT,fmt_single),fmt_single),ValueFPR(FR,fmt_single),fmt_single),fmt_single));
 }
 
 
@@ -3956,17 +4480,11 @@
 "nmsub.d f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
-  {
-   StoreFPR(destreg,fmt_double,Negate(Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double),fmt_double));
-  }
+  check_fpu (SD_);
+  StoreFPR(FD,fmt_double,Negate(Sub(Multiply(ValueFPR(FS,fmt_double),ValueFPR(FT,fmt_double),fmt_double),ValueFPR(FR,fmt_double),fmt_double),fmt_double));
 }
 
 
@@ -3975,17 +4493,11 @@
 "nmsub.s f<FD>, f<FR>, f<FS>, f<FT>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int fr = ((instruction >> 21) & 0x0000001F);
-  check_fpu(SD_);
-  {
-    StoreFPR(destreg,fmt_single,Negate(Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single),fmt_single));
-  }
+  check_fpu (SD_);
+  StoreFPR(FD,fmt_single,Negate(Sub(Multiply(ValueFPR(FS,fmt_single),ValueFPR(FT,fmt_single),fmt_single),ValueFPR(FR,fmt_single),fmt_single),fmt_single));
 }
 
 
@@ -3993,18 +4505,17 @@
 "prefx <HINT>, r<INDEX>(r<BASE>)"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int fs = ((instruction >> 11) & 0x0000001F);
-  signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word index = GPR[INDEX];
   {
-    address_word vaddr = ((unsigned64)op1 + (unsigned64)op2);
+    address_word vaddr = loadstore_ea (SD_, base, index);
     address_word paddr;
     int uncached;
     if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
-      Prefetch(uncached,paddr,vaddr,isDATA,fs);
+      Prefetch(uncached,paddr,vaddr,isDATA,HINT);
   }
 }
 
@@ -4012,19 +4523,13 @@
 "recip.%s<FMT> f<FD>, f<FS>"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-  if ((format != fmt_single) && (format != fmt_double))
-   SignalException(ReservedInstruction,instruction);
-  else
-   StoreFPR(destreg,format,Recip(ValueFPR(fs,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Recip(ValueFPR(FS,fmt),fmt));
 }
 
 
@@ -4033,21 +4538,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_long));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(FS,fmt),fmt,fmt_long));
 }
 
 
@@ -4057,41 +4556,30 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-  if ((format != fmt_single) && (format != fmt_double))
-   SignalException(ReservedInstruction,instruction);
-  else
-   StoreFPR(destreg,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_word));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(FS,fmt),fmt,fmt_word));
 }
 
 
 010001,10,3.FMT,00000,5.FS,5.FD,010110:COP1:32,f::RSQRT.fmt
 *mipsIV:
 *mipsV:
+*mips64:
 "rsqrt.%s<FMT> f<FD>, f<FS>"
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-  if ((format != fmt_single) && (format != fmt_double))
-   SignalException(ReservedInstruction,instruction);
-  else
-   StoreFPR(destreg,format,Recip(SquareRoot(ValueFPR(fs,format),format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Recip(SquareRoot(ValueFPR(FS,fmt),fmt),fmt));
 }
 
 
@@ -4101,11 +4589,13 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (1, FT));
 }
 
@@ -4114,9 +4604,10 @@
 "sdxc1 f<FS>, r<INDEX>(r<BASE>)"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  check_fpu(SD_);
+  check_fpu (SD_);
   check_u64 (SD_, instruction_0);
   do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX], COP_SD (1, FS));
 }
@@ -4128,21 +4619,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,format,(SquareRoot(ValueFPR(fs,format),format)));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,(SquareRoot(ValueFPR(FS,fmt),fmt)));
 }
 
 
@@ -4153,22 +4639,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int ft = ((instruction >> 16) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-    if ((format != fmt_single) && (format != fmt_double))
-      SignalException(ReservedInstruction,instruction);
-    else
-      StoreFPR(destreg,format,Sub(ValueFPR(fs,format),ValueFPR(ft,format),format));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt_p (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt,Sub(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
 }
 
 
@@ -4180,17 +4660,17 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  signed_word offset = EXTEND16 (OFFSET);
-  int destreg UNUSED = ((instruction >> 16) & 0x0000001F);
-  signed_word op1 UNUSED = GPR[((instruction >> 21) & 0x0000001F)];
-  check_fpu(SD_);
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
+  check_fpu (SD_);
   {
-    address_word vaddr = ((uword64)op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     if ((vaddr & 3) != 0)
@@ -4209,7 +4689,7 @@
 	    unsigned int byte;
 	    paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
 	    byte = ((vaddr & mask) ^ bigendiancpu);
-	    memval = (((uword64)COP_SW(((instruction >> 26) & 0x3),destreg)) << (8 * byte));
+	    memval = (((uword64)COP_SW(((instruction_0 >> 26) & 0x3),FT)) << (8 * byte));
 	    StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
 	  }
       }
@@ -4221,16 +4701,16 @@
 "swxc1 f<FS>, r<INDEX>(r<BASE>)"
 *mipsIV:
 *mipsV:
+*mips64:
 *vr5000:
 {
-  unsigned32 instruction = instruction_0;
-  int fs = ((instruction >> 11) & 0x0000001F);
-  signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
-  check_fpu(SD_);
+
+  address_word base = GPR[BASE];
+  address_word index = GPR[INDEX];
+  check_fpu (SD_);
   check_u64 (SD_, instruction_0);
   {
-   address_word vaddr = ((unsigned64)op1 + op2);
+   address_word vaddr = loadstore_ea (SD_, base, index);
    address_word paddr;
    int uncached;
    if ((vaddr & 3) != 0)
@@ -4247,7 +4727,7 @@
      unsigned int byte;
      paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
      byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
-     memval = (((unsigned64)COP_SW(1,fs)) << (8 * byte));
+     memval = (((unsigned64)COP_SW(1,FS)) << (8 * byte));
       {
        StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
       }
@@ -4262,21 +4742,15 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-  if ((format != fmt_single) && (format != fmt_double))
-   SignalException(ReservedInstruction,instruction);
-  else
-   StoreFPR(destreg,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_long));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(FS,fmt),fmt,fmt_long));
 }
 
 
@@ -4286,21 +4760,16 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  int destreg = ((instruction >> 6) & 0x0000001F);
-  int fs = ((instruction >> 11) & 0x0000001F);
-  int format = ((instruction >> 21) & 0x00000007);
-  check_fpu(SD_);
-  {
-  if ((format != fmt_single) && (format != fmt_double))
-   SignalException(ReservedInstruction,instruction);
-  else
-   StoreFPR(destreg,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_word));
-  }
+  int fmt = FMT;
+  check_fpu (SD_);
+  check_fmt (SD_, fmt, instruction_0);
+  StoreFPR(FD,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(FS,fmt),fmt,fmt_word));
 }
 
 
@@ -4318,6 +4787,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4337,6 +4808,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4348,6 +4821,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 
 
@@ -4358,6 +4833,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4367,20 +4844,20 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
 {
-  unsigned32 instruction = instruction_0;
-  signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
-  int hint = ((instruction >> 16) & 0x0000001F);
-  signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
+  address_word base = GPR[BASE];
+  address_word offset = EXTEND16 (OFFSET);
   {
-    address_word vaddr = (op1 + offset);
+    address_word vaddr = loadstore_ea (SD_, base, offset);
     address_word paddr;
     int uncached;
     if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
-      CacheOp(hint,vaddr,paddr,instruction);
+      CacheOp(OP,vaddr,paddr,instruction_0);
   }
 }
 
@@ -4401,6 +4878,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 {
   check_u64 (SD_, instruction_0);
   DecodeCoproc (instruction_0);
@@ -4412,6 +4890,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 {
   check_u64 (SD_, instruction_0);
   DecodeCoproc (instruction_0);
@@ -4425,6 +4904,7 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4434,6 +4914,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 {
@@ -4459,6 +4941,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -4475,6 +4959,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 *r3900:
@@ -4505,6 +4991,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *r3900:
 {
@@ -4520,6 +5008,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4531,6 +5021,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4542,6 +5034,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
@@ -4553,6 +5047,8 @@
 *mipsIII:
 *mipsIV:
 *mipsV:
+*mips32:
+*mips64:
 *vr4100:
 *vr5000:
 
diff --git a/sim/mips/sim-main.h b/sim/mips/sim-main.h
index 215a816..bcdcd80 100644
--- a/sim/mips/sim-main.h
+++ b/sim/mips/sim-main.h
@@ -43,7 +43,7 @@
 #include "sim-base.h"
 
 
-/* Depreciated macros and types for manipulating 64bit values.  Use
+/* Deprecated macros and types for manipulating 64bit values.  Use
    ../common/sim-bits.h and ../common/sim-endian.h macros instead. */
 
 typedef signed64 word64;
@@ -56,15 +56,6 @@
 #define WORD64(h,l)     ((word64)((SET64HI(h)|SET64LO(l))))
 #define UWORD64(h,l)     (SET64HI(h)|SET64LO(l))
 
-/* Sign-extend the given value (e) as a value (b) bits long. We cannot
-   assume the HI32bits of the operand are zero, so we must perform a
-   mask to ensure we can use the simple subtraction to sign-extend. */
-#define SIGNEXTEND(e,b) \
- ((unsigned_word) \
-  (((e) & ((uword64) 1 << ((b) - 1))) \
-   ? (((e) & (((uword64) 1 << (b)) - 1)) - ((uword64)1 << (b))) \
-   : ((e) & (((((uword64) 1 << ((b) - 1)) - 1) << 1) | 1))))
-
 /* Check if a value will fit within a halfword: */
 #define NOTHALFWORDVALUE(v) ((((((uword64)(v)>>16) == 0) && !((v) & ((unsigned)1 << 15))) || (((((uword64)(v)>>32) == 0xFFFFFFFF) && ((((uword64)(v)>>16) & 0xFFFF) == 0xFFFF)) && ((v) & ((unsigned)1 << 15)))) ? (1 == 0) : (1 == 1))
 
@@ -543,6 +534,18 @@
 #define status_NMI       (1 << 20)      /* NMI */
 #define status_NMI       (1 << 20)      /* NMI */
 
+/* Status bits used by MIPS32/MIPS64.  */
+#define status_UX        (1 <<  5)      /* 64-bit user addrs */
+#define status_SX        (1 <<  6)      /* 64-bit supervisor addrs */
+#define status_KX        (1 <<  7)      /* 64-bit kernel addrs */
+#define status_TS        (1 << 21)      /* TLB shutdown has occurred */
+#define status_PX        (1 << 23)      /* Enable 64 bit operations */
+#define status_MX        (1 << 24)      /* Enable MDMX resources */
+#define status_CU0       (1 << 28)      /* Coprocessor 0 usable */
+#define status_CU1       (1 << 29)      /* Coprocessor 1 usable */
+#define status_CU2       (1 << 30)      /* Coprocessor 2 usable */
+#define status_CU3       (1 << 31)      /* Coprocessor 3 usable */
+
 #define cause_BD ((unsigned)1 << 31)    /* L1 Exception in branch delay slot */
 #define cause_BD2         (1 << 30)     /* L2 Exception in branch delay slot */
 #define cause_CE_mask     0x30000000	/* Coprocessor exception */
@@ -620,9 +623,12 @@
   IntegerOverflow         = 12,    /* Arithmetic overflow (IDT monitor raises SIGFPE) */
   Trap                    = 13,
   FPE                     = 15,
-  DebugBreakPoint         = 16,
+  DebugBreakPoint         = 16,    /* Impl. dep. in MIPS32/MIPS64.  */
+  MDMX                    = 22,
   Watch                   = 23,
-  NMIReset                = 31,
+  MCheck                  = 24,
+  CacheErr                = 30,
+  NMIReset                = 31,    /* Reserved in MIPS32/MIPS64.  */
 
 
 /* The following exception code is actually private to the simulator
@@ -662,16 +668,23 @@
 #define SignalExceptionSimulatorFault(buf)   signal_exception (SD, CPU, cia, SimulatorFault, buf)
 #define SignalExceptionFPE()                 signal_exception (SD, CPU, cia, FPE)
 #define SignalExceptionIntegerOverflow()     signal_exception (SD, CPU, cia, IntegerOverflow)
-#define SignalExceptionCoProcessorUnusable() signal_exception (SD, CPU, cia, CoProcessorUnusable)
+#define SignalExceptionCoProcessorUnusable(cop) signal_exception (SD, CPU, cia, CoProcessorUnusable)
 #define SignalExceptionNMIReset()            signal_exception (SD, CPU, cia, NMIReset)
 #define SignalExceptionTLBRefillStore()      signal_exception (SD, CPU, cia, TLBStore, TLB_REFILL)
 #define SignalExceptionTLBRefillLoad()       signal_exception (SD, CPU, cia, TLBLoad, TLB_REFILL)
 #define SignalExceptionTLBInvalidStore()     signal_exception (SD, CPU, cia, TLBStore, TLB_INVALID)
 #define SignalExceptionTLBInvalidLoad()      signal_exception (SD, CPU, cia, TLBLoad, TLB_INVALID)
 #define SignalExceptionTLBModification()     signal_exception (SD, CPU, cia, TLBModification)
+#define SignalExceptionMDMX()                signal_exception (SD, CPU, cia, MDMX)
+#define SignalExceptionWatch()               signal_exception (SD, CPU, cia, Watch)
+#define SignalExceptionMCheck()              signal_exception (SD, CPU, cia, MCheck)
+#define SignalExceptionCacheErr()            signal_exception (SD, CPU, cia, CacheErr)
 
 /* Co-processor accesses */
 
+/* XXX FIXME: For now, assume that FPU (cp1) is always usable.  */
+#define COP_Usable(coproc_num)		(coproc_num == 1)
+
 void cop_lw  PARAMS ((SIM_DESC sd, sim_cpu *cpu, address_word cia, int coproc_num, int coproc_reg, unsigned int memword));
 void cop_ld  PARAMS ((SIM_DESC sd, sim_cpu *cpu, address_word cia, int coproc_num, int coproc_reg, uword64 memword));
 unsigned int cop_sw PARAMS ((SIM_DESC sd, sim_cpu *cpu, address_word cia, int coproc_num, int coproc_reg));
@@ -758,6 +771,10 @@
 #define Prefetch(CCA,pAddr,vAddr,DATA,hint) \
 prefetch (SD, CPU, cia, CCA, pAddr, vAddr, DATA, hint)
 
+void unpredictable_action (sim_cpu *cpu, address_word cia);
+#define NotWordValue(val)	not_word_value (SD_, (val))
+#define Unpredictable()		unpredictable (SD_)
+
 INLINE_SIM_MAIN (unsigned32) ifetch32 PARAMS ((SIM_DESC sd, sim_cpu *cpu, address_word cia, address_word vaddr));
 #define IMEM32(CIA) ifetch32 (SD, CPU, (CIA), (CIA))
 INLINE_SIM_MAIN (unsigned16) ifetch16 PARAMS ((SIM_DESC sd, sim_cpu *cpu, address_word cia, address_word vaddr));
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index 25d96ea..d8198e1 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,3 +1,19 @@
+2002-04-15  Elena Zannoni  <ezannoni@redhat.com>
+
+        * sim_calls.c (sim_fetch_register, sim_store_register): Return -1 for
+        AltiVec registers as a temporary stopgap.
+
+2002-03-24  David O'Brien  <obrien@FreeBSD.org>
+
+	* ppc/hw_disk.c: Export a disk device property.
+
+2002-03-23  Andrew Cagney  <ac131313@redhat.com>
+
+	From 2001-12-09 Julien Ducourthial <jducourt@noos.fr>:
+	* ppc-instructions (lswx): Do the register control with the
+	register count.  Initialize the right register in the loop.
+	(mtfsfi) : Correct prefix for the instruction.
+
 2002-02-24  Andrew Cagney  <ac131313@redhat.com>
 
 	From wiz at danbala:
diff --git a/sim/ppc/hw_disk.c b/sim/ppc/hw_disk.c
index 5934fea..84086ff 100644
--- a/sim/ppc/hw_disk.c
+++ b/sim/ppc/hw_disk.c
@@ -232,6 +232,9 @@
 			space, address, 0/*size*/, access_read_write_exec,
 			me);
 
+  /* Tell the world we are a disk.  */
+  device_add_string_property(me, "device_type", "disk");
+
   /* get the name of the file specifying the disk image */
   disk->name_index = 0;
   disk->nr_names = device_find_string_array_property(me, "file",
diff --git a/sim/ppc/ppc-instructions b/sim/ppc/ppc-instructions
index 25a9d78..6ba0090 100644
--- a/sim/ppc/ppc-instructions
+++ b/sim/ppc/ppc-instructions
@@ -2275,11 +2275,11 @@
 	r = RT - 1;
 	i = 32;
 	nr = (n + 3) / 4;
-	if (((RT + n >= 32)
-	     ? ((RA >= RT || RA < (RT + n) % 32)
-	        || (RB >= RT || RB < (RT + n) % 32))
-	     : ((RA >= RT && RA < RT + n)
-	        || (RB >= RT && RB < RT + n)))
+	if (((RT + nr >= 32)
+	     ? ((RA >= RT || RA < (RT + nr) % 32)
+	        || (RB >= RT || RB < (RT + nr) % 32))
+	     : ((RA >= RT && RA < RT + nr)
+	        || (RB >= RT && RB < RT + nr)))
 	    || (RT == RA || RT == RB))
 	  program_interrupt(processor, cia,
 	                  illegal_instruction_program_interrupt);
@@ -2288,7 +2288,7 @@
 	while (n > 0) {
 	  if (i == 32) {
 	    r = (r + 1) % 32;
-	    GPR(i) = 0;
+	    GPR(r) = 0;
 	  }
 	  GPR(r) |= INSERTED(MEM(unsigned, EA, 1), i, i+7);
 	  i = i + 8;
@@ -4582,7 +4582,7 @@
 	FPSCR_SET(BFA, 0); /* FPSCR_END fixes up FEX/VX */
 	FPSCR_END(0);
 
-0.64,6.BF,9./,11./,16.U,20./,21.134,31.Rc:X:f::Move To FPSCR Field Immediate
+0.63,6.BF,9./,11./,16.U,20./,21.134,31.Rc:X:f::Move To FPSCR Field Immediate
 	FPSCR_BEGIN;
 	FPSCR_SET(BF, U);
 	FPSCR_END(Rc);
diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c
index 72f90d2..47af5b1 100644
--- a/sim/ppc/sim_calls.c
+++ b/sim/ppc/sim_calls.c
@@ -194,7 +194,11 @@
      But there are loops that just walk through the entire list of
      names and try to get everything.  */
   regname = gdbarch_register_name (current_gdbarch, regno);
-  if (! regname || regname[0] == '\0')
+  /* FIXME: ezannoni 2002/04/15 Remove the 'vr' and 'vscr' check
+     once AltiVec support is committed.  */
+  if (! regname || regname[0] == '\0'
+      || (regname[0] == 'v' && regname[1] == 'r')
+      || (strcmp (regname, "vscr") == 0))
     return -1;
 
   TRACE(trace_gdb, ("sim_fetch_register(regno=%d(%s), buf=0x%lx)\n",
@@ -215,7 +219,11 @@
 
   /* See comments in sim_fetch_register, above.  */
   regname = gdbarch_register_name (current_gdbarch, regno);
-  if (! regname || regname[0] == '\0')
+  /* FIXME: ezannoni 2002/04/15 Remove the 'vr' and 'vscr' check
+     once AltiVec support is committed.  */
+  if (! regname || regname[0] == '\0'
+      || (regname[0] == 'v' && regname[1] == 'r')
+      || (strcmp (regname, "vscr") == 0))
     return -1;
 
   TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%lx)\n",
diff --git a/sim/z8k/ChangeLog b/sim/z8k/ChangeLog
index 64468a1..8036fe3 100644
--- a/sim/z8k/ChangeLog
+++ b/sim/z8k/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-29  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* writecode.c (lookup_inst): Ignore CLASS_IGNORE.
+        (info_args): Treat CLASS_IGNORE like CLASS_BIT.
+        Handle ARG_NIM4.
+        (info_len_in_words): Handle CLASS_IGNORE and ARG_NIM4.
+
 Tue May 23 21:39:23 2000  Andrew Cagney  <cagney@b1.cygnus.com>
 
 	* configure: Regenerated to track ../common/aclocal.m4 changes.
diff --git a/sim/z8k/writecode.c b/sim/z8k/writecode.c
index 8b4c868..b398545 100644
--- a/sim/z8k/writecode.c
+++ b/sim/z8k/writecode.c
@@ -139,6 +139,8 @@
 		    nibl_matched = 0;
 		  break;
 
+		case CLASS_IGNORE:
+		  break;
 		case CLASS_BIT:
 		  if (datum_value != instr_nibl)
 		    nibl_matched = 0;
@@ -539,6 +541,7 @@
 	case CLASS_BIT_1OR2:
 	  emit ("register unsigned int imm_src=(<insn_4>& 2)?2:1;\n");
 	  break;
+	case CLASS_IGNORE:
 	case CLASS_BIT:
 	  /* Just ignore these, we've already decoded this bit */
 	  nibs++;
@@ -589,6 +592,10 @@
 		emit ("register unsigned int imm_src=<insn_4>;\n");
 		nibs++;
 		break;
+	      case ARG_NIM4:
+		emit ("register unsigned int imm_src = - <insn_4>;\n");
+		nibs++;
+		break;
 	      case ARG_IMM2:
 		emit ("register unsigned int imm_src=<insn_4> & 0x2;\n");
 		nibs++;
@@ -1938,6 +1945,7 @@
     {
       switch (*p & CLASS_MASK)
 	{
+	case CLASS_IGNORE:
 	case CLASS_BIT:
 	case CLASS_REGN0:
 	case CLASS_REG:
@@ -1959,6 +1967,7 @@
 	      break;
 	    case ARG_IMM2:
 	    case ARG_IMM4:
+	    case ARG_NIM4:
 	    case ARG_IMM4M1:
 	    case ARG_IMM_1:
 	    case ARG_IMM_2: